@@ -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;
@@ -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,
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@rpi.edu> --- lib/pb-protocol/pb-protocol.c | 8 +++++++- lib/types/types.h | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-)