struct dhcp_option flags field is now exclusively for type, so rename it.

Remove unused struct dhcp_option types.
This commit is contained in:
Nicholas J. Kain 2011-03-30 08:19:08 -04:00
parent f28c0c7445
commit 2719d12d3c
3 changed files with 4 additions and 22 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;
};