unsigned int i, len;
len = 4 /* config->autoboot_enabled */ +
- 4 /* config->autoboot_timeout_sec */;
+ 4 /* config->autoboot_timeout_sec */ +
+ 4 /* config->safe_mode */;
len += 4;
for (i = 0; i < config->network.n_interfaces; i++)
len += 4;
len += config->n_boot_priorities * 8;
+ len += 4 + optional_strlen(config->boot_device);
+
+ len += 4 + optional_strlen(config->lang);
+
return len;
}
+int pb_protocol_url_len(const char *url)
+{
+ /* url + length field */
+ return 4 + optional_strlen(url);
+}
+
int pb_protocol_serialise_device(const struct device *dev,
char *buf, int buf_len)
{
*(uint32_t *)pos = __cpu_to_be32(config->autoboot_timeout_sec);
pos += 4;
+ *(uint32_t *)pos = config->safe_mode;
+ pos += 4;
+
*(uint32_t *)pos = __cpu_to_be32(config->network.n_interfaces);
pos += 4;
for (i = 0; i < config->network.n_interfaces; i++) {
pos += pb_protocol_serialise_string(pos, config->boot_device);
+ pos += pb_protocol_serialise_string(pos, config->lang);
+
assert(pos <= buf + buf_len);
(void)buf_len;
return 0;
}
+int pb_protocol_serialise_url(const char *url, char *buf, int buf_len)
+{
+ char *pos = buf;
+
+ pos += pb_protocol_serialise_string(pos, url);
+
+ assert(pos <=buf+buf_len);
+ (void)buf_len;
+
+ return 0;
+}
+
int pb_protocol_write_message(int fd, struct pb_protocol_message *message)
{
int total_len, rc;
if (read_u32(&pos, &len, &config->autoboot_timeout_sec))
goto out;
+ if (read_u32(&pos, &len, &tmp))
+ goto out;
+ config->safe_mode = !!tmp;
+
if (read_u32(&pos, &len, &config->network.n_interfaces))
goto out;
config->boot_device = str;
+ if (read_string(config, &pos, &len, &str))
+ goto out;
+
+ config->lang = str;
+
rc = 0;
out: