[PATCH 4/7] lib/types: Add DHCP scheme to network config
Samuel Mendoza-Jonas
sam at mendozajonas.com
Wed May 9 15:37:02 AEST 2018
Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
lib/pb-protocol/pb-protocol.c | 9 +++++++++
lib/types/types.h | 4 ++++
2 files changed, 13 insertions(+)
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index dbbda40..74a89de 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -309,6 +309,8 @@ int pb_protocol_config_len(const struct config *config)
for (i = 0; i < config->network.n_dns_servers; i++)
len += 4 + optional_strlen(config->network.dns_servers[i]);
+ len += 4 /* config->network.addr_type */;
+
len += 4 + optional_strlen(config->http_proxy);
len += 4 + optional_strlen(config->https_proxy);
@@ -581,6 +583,9 @@ int pb_protocol_serialise_config(const struct config *config,
config->network.dns_servers[i]);
}
+ *(uint32_t *)pos = __cpu_to_be32(config->network.addr_type);
+ pos += 4;
+
pos += pb_protocol_serialise_string(pos, config->http_proxy);
pos += pb_protocol_serialise_string(pos, config->https_proxy);
@@ -1141,6 +1146,10 @@ int pb_protocol_deserialise_config(struct config *config,
config->network.dns_servers[i] = str;
}
+ if (read_u32(&pos, &len, &tmp))
+ goto out;
+ config->network.addr_type = tmp;
+
if (read_string(config, &pos, &len, &str))
goto out;
config->http_proxy = str;
diff --git a/lib/types/types.h b/lib/types/types.h
index 9ab2a43..1bf518e 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -162,6 +162,10 @@ struct network_config {
unsigned int n_interfaces;
const char **dns_servers;
unsigned int n_dns_servers;
+ enum {
+ ADDR_IPV4,
+ ADDR_IPV6,
+ } addr_type;
};
struct autoboot_option {
--
2.17.0
More information about the Petitboot
mailing list