update_engine: Store and test kern/fw versions as 4 values
- Refactors the handling of _firmware_version and _kernel_version
attributes to split as 4x 16 bit values.
- Based on discussion, we are trying to avoid using the client
specific version format in the network protocol.
- Each of firmware and kernel versions will be stored separately
as uint16_t rather than combined as a uint32_t.
- In the Omaha response the two fields of each version type will
be encoded as key_version.version
- Adds tests for the actual parsing of the response.
BUG=chromium:840432
TEST=cros_run_unit_tests --board=samus --packages update_engine
Change-Id: I4da02e3f4715a132db7e96e55c30139fff6fe6ea
Reviewed-on: https://chromium-review.googlesource.com/1123106
Commit-Ready: Marton Hunyady <hunyadym@chromium.org>
Tested-by: Zentaro Kavanagh <zentaro@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_response.h b/omaha_response.h
index ef69de2..0ac09df 100644
--- a/omaha_response.h
+++ b/omaha_response.h
@@ -21,6 +21,7 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include <limits>
#include <string>
#include <vector>
@@ -86,12 +87,21 @@
// True if the returned image is a rollback for the device.
bool is_rollback = false;
- // Kernel version of the returned rollback image. 0 if the image is not a
- // rollback.
- uint32_t kernel_version = 0;
- // Firmware version of the returned rollback image. 0 if the image is not a
- // rollback.
- uint32_t firmware_version = 0;
+
+ struct RollbackKeyVersion {
+ // Kernel key version. 0xffff if the value is unknown.
+ uint16_t kernel_key = std::numeric_limits<uint16_t>::max();
+ // Kernel version. 0xffff if the value is unknown.
+ uint16_t kernel = std::numeric_limits<uint16_t>::max();
+ // Firmware key verison. 0xffff if the value is unknown.
+ uint16_t firmware_key = std::numeric_limits<uint16_t>::max();
+ // Firmware version. 0xffff if the value is unknown.
+ uint16_t firmware = std::numeric_limits<uint16_t>::max();
+ };
+
+ // Key versions of the returned rollback image. Values are 0xffff if the
+ // image not a rollback, or the fields were not present.
+ RollbackKeyVersion rollback_key_version;
};
static_assert(sizeof(off_t) == 8, "off_t not 64 bit");