[PATCH 05/11] Add hwaddr length field to interface config
Daniel M. Weeks
weeksd2 at rpi.edu
Fri Apr 17 03:54:48 AEST 2020
This field allows hardware addresses of different lengths to be stored
in in the fixed-size field hwaddr. The pb interface_config (de)serialize
functions are updated to include this new field.
Signed-off-by: Daniel M. Weeks <weeksd2 at rpi.edu>
---
lib/pb-protocol/pb-protocol.c | 8 +++++++-
lib/types/types.h | 5 +++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index dbbda40..b5186ad 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -273,7 +273,7 @@ static int pb_protocol_interface_config_len(struct interface_config *conf)
{
unsigned int len;
- len = sizeof(conf->hwaddr) +
+ len = 4 + sizeof(conf->hwaddr) +
4 /* conf->ignore */;
if (conf->ignore)
@@ -524,6 +524,9 @@ static int pb_protocol_serialise_config_interface(char *buf,
{
char *pos = buf;
+ *(uint32_t *)pos = __cpu_to_be32(conf->hwaddr_len);
+ pos += 4;
+
memcpy(pos, conf->hwaddr, sizeof(conf->hwaddr));
pos += sizeof(conf->hwaddr);
@@ -1058,6 +1061,9 @@ static int pb_protocol_deserialise_config_interface(const char **buf,
{
unsigned int tmp;
+ if (read_u32(buf, len, &iface->hwaddr_len))
+ return -1;
+
if (*len < sizeof(iface->hwaddr))
return -1;
diff --git a/lib/types/types.h b/lib/types/types.h
index 9ab2a43..719332a 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -139,8 +139,9 @@ struct system_info {
#define HWADDR_SIZE 6
struct interface_config {
- uint8_t hwaddr[HWADDR_SIZE];
- bool ignore;
+ unsigned int hwaddr_len;
+ uint8_t hwaddr[HWADDR_SIZE];
+ bool ignore;
enum {
CONFIG_METHOD_DHCP,
CONFIG_METHOD_STATIC,
--
Daniel M. Weeks
--
Daniel M. Weeks
Lead HPC Developer
Center for Computational Innovations
Rensselaer Polytechnic Institute
Troy, NY 12180
518-276-4458
More information about the Petitboot
mailing list