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 17 #ifndef UPDATE_ENGINE_OMAHA_RESPONSE_H_ 18 #define UPDATE_ENGINE_OMAHA_RESPONSE_H_ 19 20 #include <fcntl.h> 21 #include <sys/stat.h> 22 #include <sys/types.h> 23 24 #include <limits> 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 { 33 // True iff there is an update to be downloaded. 34 bool update_exists = false; 35 36 // If non-zero, server-dictated poll interval in seconds. 37 int poll_interval = 0; 38 39 // These are only valid if update_exists is true: 40 std::string version; 41 std::string system_version; 42 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; 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; 54 // True if the payload can be excluded from updating if consistently faulty. 55 // False if the payload is critical to update. 56 bool can_exclude = false; 57 }; 58 std::vector<Package> packages; 59 60 std::string more_info_url; 61 std::string deadline; 62 int max_days_to_scatter = 0; 63 // The number of URL-related failures to tolerate before moving on to the 64 // next URL in the current pass. This is a configurable value from the 65 // Omaha Response attribute, if ever we need to fine tune the behavior. 66 uint32_t max_failure_count_per_url = 0; 67 bool prompt = false; 68 69 // True if the Omaha rule instructs us to disable the back-off logic 70 // on the client altogether. False otherwise. 71 bool disable_payload_backoff = false; 72 73 // True if the Omaha rule instructs us to disable p2p for downloading. 74 bool disable_p2p_for_downloading = false; 75 76 // True if the Omaha rule instructs us to disable p2p for sharing. 77 bool disable_p2p_for_sharing = false; 78 79 // True if the Omaha rule instructs us to powerwash. 80 bool powerwash_required = false; 81 82 // If not blank, a base-64 encoded representation of the PEM-encoded 83 // public key in the response. 84 std::string public_key_rsa; 85 86 // If not -1, the number of days since the epoch Jan 1, 2007 0:00 87 // PST, according to the Omaha Server's clock and timezone (PST8PDT, 88 // aka "Pacific Time".) 89 int install_date_days = -1; 90 91 // True if the returned image is a rollback for the device. 92 bool is_rollback = false; 93 94 struct RollbackKeyVersion { 95 // Kernel key version. 0xffff if the value is unknown. 96 uint16_t kernel_key = std::numeric_limits<uint16_t>::max(); 97 // Kernel version. 0xffff if the value is unknown. 98 uint16_t kernel = std::numeric_limits<uint16_t>::max(); 99 // Firmware key verison. 0xffff if the value is unknown. 100 uint16_t firmware_key = std::numeric_limits<uint16_t>::max(); 101 // Firmware version. 0xffff if the value is unknown. 102 uint16_t firmware = std::numeric_limits<uint16_t>::max(); 103 }; 104 105 // Key versions of the returned rollback image. Values are 0xffff if the 106 // image not a rollback, or the fields were not present. 107 RollbackKeyVersion rollback_key_version; 108 109 // Key versions of the N - rollback_allowed_milestones release. For example, 110 // if the current version is 70 and rollback_allowed_milestones is 4, this 111 // will contain the key versions of version 66. This is used to ensure that 112 // the kernel and firmware keys are at most those of v66 so that v66 can be 113 // rolled back to. 114 RollbackKeyVersion past_rollback_key_version; 115 }; 116 static_assert(sizeof(off_t) == 8, "off_t not 64 bit"); 117 118 } // namespace chromeos_update_engine 119 120 #endif // UPDATE_ENGINE_OMAHA_RESPONSE_H_ 121