From 2719d12d3c25f765f30bb85f21dc88a9ce1e8064 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Wed, 30 Mar 2011 08:19:08 -0400 Subject: [PATCH] struct dhcp_option flags field is now exclusively for type, so rename it. Remove unused struct dhcp_option types. --- ndhc/ifchange.c | 14 +------------- ndhc/options.c | 6 ++---- ndhc/options.h | 6 +----- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/ndhc/ifchange.c b/ndhc/ifchange.c index 8e106c2..985e0d9 100644 --- a/ndhc/ifchange.c +++ b/ndhc/ifchange.c @@ -75,25 +75,13 @@ static int fill_options(char *dest, unsigned char *option, dest += snprintf(dest, maxlen, "%s=", type_p->name); - type = type_p->flags & TYPE_MASK; + type = type_p->type; optlen = option_lengths[type]; for(;;) { switch (type) { - case OPTION_IP_PAIR: - dest += sprintip(dest, maxlen - (dest - odest), "", option); - *(dest++) = '/'; - option += 4; - optlen = 4; - dest += sprintip(dest, maxlen - (dest - odest), "", option); - optlen = option_lengths[type]; - break; case OPTION_IP: /* Works regardless of host byte order. */ dest += sprintip(dest, maxlen - (dest - odest), "", option); break; - case OPTION_BOOLEAN: - dest += snprintf(dest, maxlen - (dest - odest), - *option ? "yes " : "no "); - break; case OPTION_U8: dest += snprintf(dest, maxlen - (dest - odest), "%u ", *option); diff --git a/ndhc/options.c b/ndhc/options.c index 5c32b87..ec573b3 100644 --- a/ndhc/options.c +++ b/ndhc/options.c @@ -21,7 +21,7 @@ enum { /* supported options are easily added here */ struct dhcp_option options[] = { - /* name[10] flags code */ + /* name[10] type code */ {"subnet" , OPTION_IP, 0x01}, {"timezone" , OPTION_S32, 0x02}, {"router" , OPTION_IP, 0x03}, @@ -55,8 +55,6 @@ struct dhcp_option options[] = { /* Lengths of the different option types */ int option_lengths[] = { [OPTION_IP] = 4, - [OPTION_IP_PAIR] = 8, - [OPTION_BOOLEAN] = 1, [OPTION_STRING] = 1, [OPTION_U8] = 1, [OPTION_U16] = 2, @@ -216,7 +214,7 @@ int add_simple_option(unsigned char *optionptr, unsigned char code, for (i = 0; options[i].code; i++) if (options[i].code == code) { - length = option_lengths[options[i].flags & TYPE_MASK]; + length = option_lengths[(size_t)options[i].type]; } log_line("aso(): code=0x%02x length=0x%02x", code, length); diff --git a/ndhc/options.h b/ndhc/options.h index b7bd8a4..ca8fa59 100644 --- a/ndhc/options.h +++ b/ndhc/options.h @@ -4,8 +4,6 @@ #include "packet.h" -#define TYPE_MASK 0x0F - #define DHCP_OPTIONS_BUFSIZE 308 /* DHCP option codes (partial list) */ @@ -55,9 +53,7 @@ enum { OPTION_IP=1, - OPTION_IP_PAIR, OPTION_STRING, - OPTION_BOOLEAN, OPTION_U8, OPTION_U16, OPTION_S16, @@ -67,7 +63,7 @@ enum { struct dhcp_option { char name[10]; - char flags; + char type; unsigned char code; };