Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 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 | // |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 16 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_OMAHA_RESPONSE_H_ |
| 18 | #define UPDATE_ENGINE_OMAHA_RESPONSE_H_ |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 19 | |
| 20 | #include <fcntl.h> |
| 21 | #include <sys/stat.h> |
| 22 | #include <sys/types.h> |
| 23 | |
Zentaro Kavanagh | 0ff621c | 2018-07-13 13:06:56 -0700 | [diff] [blame] | 24 | #include <limits> |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 25 | #include <string> |
| 26 | #include <vector> |
| 27 | |
| 28 | namespace chromeos_update_engine { |
| 29 | |
| 30 | // This struct encapsulates the data Omaha's response for the request. |
| 31 | // The strings in this struct are not XML escaped. |
| 32 | struct OmahaResponse { |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 33 | // True iff there is an update to be downloaded. |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 34 | bool update_exists = false; |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 35 | |
| 36 | // If non-zero, server-dictated poll interval in seconds. |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 37 | int poll_interval = 0; |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 38 | |
| 39 | // These are only valid if update_exists is true: |
Chris Sosa | 3b74843 | 2013-06-20 16:42:59 -0700 | [diff] [blame] | 40 | std::string version; |
Aaron Wood | 7dcdedf | 2017-09-06 17:17:41 -0700 | [diff] [blame] | 41 | std::string system_version; |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 42 | |
Sen Jiang | 0affc2c | 2017-02-10 15:55:05 -0800 | [diff] [blame] | 43 | struct Package { |
| 44 | // The ordered list of URLs in the Omaha response. Each item is a complete |
| 45 | // URL (i.e. in terms of Omaha XML, each value is a urlBase + packageName) |
| 46 | std::vector<std::string> payload_urls; |
| 47 | uint64_t size = 0; |
| 48 | uint64_t metadata_size = 0; |
| 49 | std::string metadata_signature; |
| 50 | std::string hash; |
Sen Jiang | cdd5206 | 2017-05-18 15:33:10 -0700 | [diff] [blame] | 51 | // True if the payload described in this response is a delta payload. |
| 52 | // False if it's a full payload. |
| 53 | bool is_delta = false; |
Sen Jiang | 0affc2c | 2017-02-10 15:55:05 -0800 | [diff] [blame] | 54 | }; |
| 55 | std::vector<Package> packages; |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 56 | |
| 57 | std::string more_info_url; |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 58 | std::string deadline; |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 59 | int max_days_to_scatter = 0; |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 60 | // The number of URL-related failures to tolerate before moving on to the |
| 61 | // next URL in the current pass. This is a configurable value from the |
| 62 | // Omaha Response attribute, if ever we need to fine tune the behavior. |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 63 | uint32_t max_failure_count_per_url = 0; |
| 64 | bool prompt = false; |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 65 | |
Alex Vakulenko | 072359c | 2014-07-18 11:41:07 -0700 | [diff] [blame] | 66 | // True if the Omaha rule instructs us to disable the back-off logic |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 67 | // on the client altogether. False otherwise. |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 68 | bool disable_payload_backoff = false; |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 69 | |
| 70 | // True if the Omaha rule instructs us to disable p2p for downloading. |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 71 | bool disable_p2p_for_downloading = false; |
David Zeuthen | 8f191b2 | 2013-08-06 12:27:50 -0700 | [diff] [blame] | 72 | |
| 73 | // True if the Omaha rule instructs us to disable p2p for sharing. |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 74 | bool disable_p2p_for_sharing = false; |
David Zeuthen | e7f8917 | 2013-10-31 10:21:04 -0700 | [diff] [blame] | 75 | |
Sen Jiang | fe28440 | 2018-03-21 14:03:50 -0700 | [diff] [blame] | 76 | // True if the Omaha rule instructs us to powerwash. |
| 77 | bool powerwash_required = false; |
| 78 | |
David Zeuthen | e7f8917 | 2013-10-31 10:21:04 -0700 | [diff] [blame] | 79 | // If not blank, a base-64 encoded representation of the PEM-encoded |
| 80 | // public key in the response. |
| 81 | std::string public_key_rsa; |
David Zeuthen | 639aa36 | 2014-02-03 16:23:44 -0800 | [diff] [blame] | 82 | |
| 83 | // If not -1, the number of days since the epoch Jan 1, 2007 0:00 |
| 84 | // PST, according to the Omaha Server's clock and timezone (PST8PDT, |
| 85 | // aka "Pacific Time".) |
Alex Deymo | 8e18f93 | 2015-03-27 16:16:59 -0700 | [diff] [blame] | 86 | int install_date_days = -1; |
Marton Hunyady | 199152d | 2018-05-07 19:08:48 +0200 | [diff] [blame] | 87 | |
| 88 | // True if the returned image is a rollback for the device. |
| 89 | bool is_rollback = false; |
Zentaro Kavanagh | 0ff621c | 2018-07-13 13:06:56 -0700 | [diff] [blame] | 90 | |
| 91 | struct RollbackKeyVersion { |
| 92 | // Kernel key version. 0xffff if the value is unknown. |
| 93 | uint16_t kernel_key = std::numeric_limits<uint16_t>::max(); |
| 94 | // Kernel version. 0xffff if the value is unknown. |
| 95 | uint16_t kernel = std::numeric_limits<uint16_t>::max(); |
| 96 | // Firmware key verison. 0xffff if the value is unknown. |
| 97 | uint16_t firmware_key = std::numeric_limits<uint16_t>::max(); |
| 98 | // Firmware version. 0xffff if the value is unknown. |
| 99 | uint16_t firmware = std::numeric_limits<uint16_t>::max(); |
| 100 | }; |
| 101 | |
| 102 | // Key versions of the returned rollback image. Values are 0xffff if the |
| 103 | // image not a rollback, or the fields were not present. |
| 104 | RollbackKeyVersion rollback_key_version; |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 105 | }; |
Alex Vakulenko | a3cf75a | 2016-01-20 07:56:15 -0800 | [diff] [blame] | 106 | static_assert(sizeof(off_t) == 8, "off_t not 64 bit"); |
Jay Srinivasan | 0826288 | 2012-12-28 19:29:43 -0800 | [diff] [blame] | 107 | |
| 108 | } // namespace chromeos_update_engine |
| 109 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 110 | #endif // UPDATE_ENGINE_OMAHA_RESPONSE_H_ |