From 4959a89f421fdebc521f48003a79c2161e59d192 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Fri, 14 Nov 2014 11:19:10 -0800 Subject: Represent DHCP "origin" as an enum, not a string. See IBFT standard for location of "origin" field in iBFT table, and see MS document: http://msdn.microsoft.com/en-us/library/aa366281.aspx for description of enums, duplicated here in part: typedef enum { IpPrefixOriginOther = 0, IpPrefixOriginManual, IpPrefixOriginWellKnown, IpPrefixOriginDhcp, IpPrefixOriginRouterAdvertisement, IpPrefixOriginUnchanged = 16 } IP_PREFIX_ORIGIN; --- utils/fwparam_ibft/fw_entry.c | 5 +++-- utils/fwparam_ibft/fwparam_sysfs.c | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'utils') diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c index 9f0797f..f94a035 100644 --- a/utils/fwparam_ibft/fw_entry.c +++ b/utils/fwparam_ibft/fw_entry.c @@ -192,11 +192,12 @@ static void dump_network(struct boot_context *context) if (strlen(context->mac)) printf("%s = %s\n", IFACE_HWADDR, context->mac); /* - * If the 'origin' field is '3' then DHCP is used. + * If the 'origin' field is 3 (IBFT_IP_PREFIX_ORIGIN_DHCP), + * then DHCP is used. * Otherwise evaluate the 'dhcp' field, if this has a valid * address then DHCP was used (broadcom sends 0.0.0.0). */ - if ((strlen(context->origin) && !strcmp(context->origin, "3")) || + if ((context->origin == IBFT_IP_PREFIX_ORIGIN_DHCP) || (strlen(context->dhcp) && strcmp(context->dhcp, "0.0.0.0"))) printf("%s = DHCP\n", IFACE_BOOT_PROTO); else diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c index b531906..cd87b68 100644 --- a/utils/fwparam_ibft/fwparam_sysfs.c +++ b/utils/fwparam_ibft/fwparam_sysfs.c @@ -217,8 +217,7 @@ static int fill_nic_context(char *subsys, char *id, sizeof(context->secondary_dns)); sysfs_get_str(id, subsys, "dhcp", context->dhcp, sizeof(context->dhcp)); - sysfs_get_str(id, subsys, "origin", context->origin, - sizeof(context->origin)); + sysfs_get_int(id, subsys, "origin", (int *)&context->origin); return 0; } -- cgit v1.2.1