omaha_response.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // Copyright (C) 2012 The Android Open Source Project
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. #ifndef UPDATE_ENGINE_OMAHA_RESPONSE_H_
  17. #define UPDATE_ENGINE_OMAHA_RESPONSE_H_
  18. #include <fcntl.h>
  19. #include <sys/stat.h>
  20. #include <sys/types.h>
  21. #include <limits>
  22. #include <string>
  23. #include <vector>
  24. namespace chromeos_update_engine {
  25. // This struct encapsulates the data Omaha's response for the request.
  26. // The strings in this struct are not XML escaped.
  27. struct OmahaResponse {
  28. // True iff there is an update to be downloaded.
  29. bool update_exists = false;
  30. // If non-zero, server-dictated poll interval in seconds.
  31. int poll_interval = 0;
  32. // These are only valid if update_exists is true:
  33. std::string version;
  34. std::string system_version;
  35. struct Package {
  36. // The ordered list of URLs in the Omaha response. Each item is a complete
  37. // URL (i.e. in terms of Omaha XML, each value is a urlBase + packageName)
  38. std::vector<std::string> payload_urls;
  39. uint64_t size = 0;
  40. uint64_t metadata_size = 0;
  41. std::string metadata_signature;
  42. std::string hash;
  43. // True if the payload described in this response is a delta payload.
  44. // False if it's a full payload.
  45. bool is_delta = false;
  46. };
  47. std::vector<Package> packages;
  48. std::string more_info_url;
  49. std::string deadline;
  50. int max_days_to_scatter = 0;
  51. // The number of URL-related failures to tolerate before moving on to the
  52. // next URL in the current pass. This is a configurable value from the
  53. // Omaha Response attribute, if ever we need to fine tune the behavior.
  54. uint32_t max_failure_count_per_url = 0;
  55. bool prompt = false;
  56. // True if the Omaha rule instructs us to disable the back-off logic
  57. // on the client altogether. False otherwise.
  58. bool disable_payload_backoff = false;
  59. // True if the Omaha rule instructs us to disable p2p for downloading.
  60. bool disable_p2p_for_downloading = false;
  61. // True if the Omaha rule instructs us to disable p2p for sharing.
  62. bool disable_p2p_for_sharing = false;
  63. // True if the Omaha rule instructs us to powerwash.
  64. bool powerwash_required = false;
  65. // If not blank, a base-64 encoded representation of the PEM-encoded
  66. // public key in the response.
  67. std::string public_key_rsa;
  68. // If not -1, the number of days since the epoch Jan 1, 2007 0:00
  69. // PST, according to the Omaha Server's clock and timezone (PST8PDT,
  70. // aka "Pacific Time".)
  71. int install_date_days = -1;
  72. // True if the returned image is a rollback for the device.
  73. bool is_rollback = false;
  74. struct RollbackKeyVersion {
  75. // Kernel key version. 0xffff if the value is unknown.
  76. uint16_t kernel_key = std::numeric_limits<uint16_t>::max();
  77. // Kernel version. 0xffff if the value is unknown.
  78. uint16_t kernel = std::numeric_limits<uint16_t>::max();
  79. // Firmware key verison. 0xffff if the value is unknown.
  80. uint16_t firmware_key = std::numeric_limits<uint16_t>::max();
  81. // Firmware version. 0xffff if the value is unknown.
  82. uint16_t firmware = std::numeric_limits<uint16_t>::max();
  83. };
  84. // Key versions of the returned rollback image. Values are 0xffff if the
  85. // image not a rollback, or the fields were not present.
  86. RollbackKeyVersion rollback_key_version;
  87. };
  88. static_assert(sizeof(off_t) == 8, "off_t not 64 bit");
  89. } // namespace chromeos_update_engine
  90. #endif // UPDATE_ENGINE_OMAHA_RESPONSE_H_