X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Fpb-protocol%2Fpb-protocol.c;h=c184719be85fad32eab5dc3fe7ec48de4411f1a8;hp=5a1cee7a417bc648e883a0c3020f0c42c640430d;hb=e1f6ffb9ca9e35738385a3524ba46896a0b519e6;hpb=b955fa07fc256b39caedb311f97fed404a63c8d5 diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c index 5a1cee7..c184719 100644 --- a/lib/pb-protocol/pb-protocol.c +++ b/lib/pb-protocol/pb-protocol.c @@ -267,7 +267,8 @@ int pb_protocol_config_len(const struct config *config) 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++) @@ -279,7 +280,11 @@ int pb_protocol_config_len(const struct config *config) len += 4 + optional_strlen(config->network.dns_servers[i]); len += 4; - len += config->n_boot_priorities * 4; + len += config->n_boot_priorities * 8; + + len += 4 + optional_strlen(config->boot_device); + + len += 4 + optional_strlen(config->lang); return len; } @@ -446,6 +451,9 @@ int pb_protocol_serialise_config(const struct config *config, *(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++) { @@ -464,10 +472,18 @@ int pb_protocol_serialise_config(const struct config *config, *(uint32_t *)pos = __cpu_to_be32(config->n_boot_priorities); pos += 4; for (i = 0; i < config->n_boot_priorities; i++) { - *(uint32_t *)pos = __cpu_to_be32(config->boot_priorities[i].type); + *(uint32_t *)pos = + __cpu_to_be32(config->boot_priorities[i].type); + pos += 4; + *(uint32_t *)pos = + __cpu_to_be32(config->boot_priorities[i].priority); pos += 4; } + 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; @@ -842,6 +858,7 @@ int pb_protocol_deserialise_config(struct config *config, unsigned int len, i, tmp; const char *pos; int rc = -1; + char *str; len = message->payload_len; pos = message->payload; @@ -853,6 +870,10 @@ int pb_protocol_deserialise_config(struct config *config, 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; @@ -874,10 +895,9 @@ int pb_protocol_deserialise_config(struct config *config, config->network.n_dns_servers); for (i = 0; i < config->network.n_dns_servers; i++) { - char *tmp; - if (read_string(config->network.dns_servers, &pos, &len, &tmp)) + if (read_string(config->network.dns_servers, &pos, &len, &str)) goto out; - config->network.dns_servers[i] = tmp; + config->network.dns_servers[i] = str; } if (read_u32(&pos, &len, &config->n_boot_priorities)) @@ -886,11 +906,24 @@ int pb_protocol_deserialise_config(struct config *config, config->n_boot_priorities); for (i = 0; i < config->n_boot_priorities; i++) { + if (read_u32(&pos, &len, &tmp)) + goto out; + config->boot_priorities[i].priority = (int)tmp; if (read_u32(&pos, &len, &tmp)) goto out; config->boot_priorities[i].type = tmp; } + if (read_string(config, &pos, &len, &str)) + goto out; + + config->boot_device = str; + + if (read_string(config, &pos, &len, &str)) + goto out; + + config->lang = str; + rc = 0; out: