blob: 3b07745a883702c804810a875634fde7945ac47f [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
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 Srinivasan08262882012-12-28 19:29:43 -080016
Amin Hassaniec7bc112020-10-29 16:47:58 -070017#ifndef UPDATE_ENGINE_CROS_OMAHA_RESPONSE_H_
18#define UPDATE_ENGINE_CROS_OMAHA_RESPONSE_H_
Jay Srinivasan08262882012-12-28 19:29:43 -080019
20#include <fcntl.h>
21#include <sys/stat.h>
22#include <sys/types.h>
23
Zentaro Kavanagh0ff621c2018-07-13 13:06:56 -070024#include <limits>
Jay Srinivasan08262882012-12-28 19:29:43 -080025#include <string>
26#include <vector>
27
28namespace 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.
32struct OmahaResponse {
Jay Srinivasan08262882012-12-28 19:29:43 -080033 // True iff there is an update to be downloaded.
Alex Deymo8e18f932015-03-27 16:16:59 -070034 bool update_exists = false;
Jay Srinivasan08262882012-12-28 19:29:43 -080035
36 // If non-zero, server-dictated poll interval in seconds.
Alex Deymo8e18f932015-03-27 16:16:59 -070037 int poll_interval = 0;
Jay Srinivasan08262882012-12-28 19:29:43 -080038
39 // These are only valid if update_exists is true:
Chris Sosa3b748432013-06-20 16:42:59 -070040 std::string version;
Jay Srinivasan08262882012-12-28 19:29:43 -080041
Sen Jiang0affc2c2017-02-10 15:55:05 -080042 struct Package {
43 // The ordered list of URLs in the Omaha response. Each item is a complete
44 // URL (i.e. in terms of Omaha XML, each value is a urlBase + packageName)
45 std::vector<std::string> payload_urls;
46 uint64_t size = 0;
47 uint64_t metadata_size = 0;
48 std::string metadata_signature;
49 std::string hash;
Sen Jiangcdd52062017-05-18 15:33:10 -070050 // True if the payload described in this response is a delta payload.
51 // False if it's a full payload.
52 bool is_delta = false;
Jae Hoon Kim694eeb02020-06-01 14:24:08 -070053 // True if the payload can be excluded from updating if consistently faulty.
54 // False if the payload is critical to update.
55 bool can_exclude = false;
Jae Hoon Kim3e69b4c2020-06-16 09:23:39 -070056 // The App ID associated with the package.
57 std::string app_id;
Vyshu Khota4c5413d2020-11-04 16:17:25 -080058 // The unique fingerprint value associated with the package.
59 std::string fp;
Sen Jiang0affc2c2017-02-10 15:55:05 -080060 };
61 std::vector<Package> packages;
Jay Srinivasan08262882012-12-28 19:29:43 -080062
63 std::string more_info_url;
Jay Srinivasan08262882012-12-28 19:29:43 -080064 std::string deadline;
Alex Deymo8e18f932015-03-27 16:16:59 -070065 int max_days_to_scatter = 0;
Jay Srinivasan08262882012-12-28 19:29:43 -080066 // The number of URL-related failures to tolerate before moving on to the
67 // next URL in the current pass. This is a configurable value from the
68 // Omaha Response attribute, if ever we need to fine tune the behavior.
Alex Deymo8e18f932015-03-27 16:16:59 -070069 uint32_t max_failure_count_per_url = 0;
70 bool prompt = false;
Jay Srinivasan08262882012-12-28 19:29:43 -080071
Alex Vakulenko072359c2014-07-18 11:41:07 -070072 // True if the Omaha rule instructs us to disable the back-off logic
Jay Srinivasan08262882012-12-28 19:29:43 -080073 // on the client altogether. False otherwise.
Alex Deymo8e18f932015-03-27 16:16:59 -070074 bool disable_payload_backoff = false;
David Zeuthen8f191b22013-08-06 12:27:50 -070075
76 // True if the Omaha rule instructs us to disable p2p for downloading.
Alex Deymo8e18f932015-03-27 16:16:59 -070077 bool disable_p2p_for_downloading = false;
David Zeuthen8f191b22013-08-06 12:27:50 -070078
79 // True if the Omaha rule instructs us to disable p2p for sharing.
Alex Deymo8e18f932015-03-27 16:16:59 -070080 bool disable_p2p_for_sharing = false;
David Zeuthene7f89172013-10-31 10:21:04 -070081
Sen Jiangfe284402018-03-21 14:03:50 -070082 // True if the Omaha rule instructs us to powerwash.
83 bool powerwash_required = false;
84
David Zeuthene7f89172013-10-31 10:21:04 -070085 // If not blank, a base-64 encoded representation of the PEM-encoded
86 // public key in the response.
87 std::string public_key_rsa;
David Zeuthen639aa362014-02-03 16:23:44 -080088
89 // If not -1, the number of days since the epoch Jan 1, 2007 0:00
90 // PST, according to the Omaha Server's clock and timezone (PST8PDT,
91 // aka "Pacific Time".)
Alex Deymo8e18f932015-03-27 16:16:59 -070092 int install_date_days = -1;
Marton Hunyady199152d2018-05-07 19:08:48 +020093
94 // True if the returned image is a rollback for the device.
95 bool is_rollback = false;
Zentaro Kavanagh0ff621c2018-07-13 13:06:56 -070096
97 struct RollbackKeyVersion {
98 // Kernel key version. 0xffff if the value is unknown.
99 uint16_t kernel_key = std::numeric_limits<uint16_t>::max();
100 // Kernel version. 0xffff if the value is unknown.
101 uint16_t kernel = std::numeric_limits<uint16_t>::max();
102 // Firmware key verison. 0xffff if the value is unknown.
103 uint16_t firmware_key = std::numeric_limits<uint16_t>::max();
104 // Firmware version. 0xffff if the value is unknown.
105 uint16_t firmware = std::numeric_limits<uint16_t>::max();
106 };
107
108 // Key versions of the returned rollback image. Values are 0xffff if the
109 // image not a rollback, or the fields were not present.
110 RollbackKeyVersion rollback_key_version;
Zentaro Kavanagh0ef9a2f2018-07-02 12:05:07 -0700111
112 // Key versions of the N - rollback_allowed_milestones release. For example,
113 // if the current version is 70 and rollback_allowed_milestones is 4, this
114 // will contain the key versions of version 66. This is used to ensure that
115 // the kernel and firmware keys are at most those of v66 so that v66 can be
116 // rolled back to.
117 RollbackKeyVersion past_rollback_key_version;
Jay Srinivasan08262882012-12-28 19:29:43 -0800118};
Alex Vakulenkoa3cf75a2016-01-20 07:56:15 -0800119static_assert(sizeof(off_t) == 8, "off_t not 64 bit");
Jay Srinivasan08262882012-12-28 19:29:43 -0800120
121} // namespace chromeos_update_engine
122
Amin Hassaniec7bc112020-10-29 16:47:58 -0700123#endif // UPDATE_ENGINE_CROS_OMAHA_RESPONSE_H_