struct dhcp_option flags field is now exclusively for type, so rename it.
Remove unused struct dhcp_option types.
This commit is contained in:
parent
f28c0c7445
commit
2719d12d3c
@ -75,25 +75,13 @@ static int fill_options(char *dest, unsigned char *option,
|
|||||||
|
|
||||||
dest += snprintf(dest, maxlen, "%s=", type_p->name);
|
dest += snprintf(dest, maxlen, "%s=", type_p->name);
|
||||||
|
|
||||||
type = type_p->flags & TYPE_MASK;
|
type = type_p->type;
|
||||||
optlen = option_lengths[type];
|
optlen = option_lengths[type];
|
||||||
for(;;) {
|
for(;;) {
|
||||||
switch (type) {
|
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. */
|
case OPTION_IP: /* Works regardless of host byte order. */
|
||||||
dest += sprintip(dest, maxlen - (dest - odest), "", option);
|
dest += sprintip(dest, maxlen - (dest - odest), "", option);
|
||||||
break;
|
break;
|
||||||
case OPTION_BOOLEAN:
|
|
||||||
dest += snprintf(dest, maxlen - (dest - odest),
|
|
||||||
*option ? "yes " : "no ");
|
|
||||||
break;
|
|
||||||
case OPTION_U8:
|
case OPTION_U8:
|
||||||
dest += snprintf(dest, maxlen - (dest - odest),
|
dest += snprintf(dest, maxlen - (dest - odest),
|
||||||
"%u ", *option);
|
"%u ", *option);
|
||||||
|
@ -21,7 +21,7 @@ enum {
|
|||||||
|
|
||||||
/* supported options are easily added here */
|
/* supported options are easily added here */
|
||||||
struct dhcp_option options[] = {
|
struct dhcp_option options[] = {
|
||||||
/* name[10] flags code */
|
/* name[10] type code */
|
||||||
{"subnet" , OPTION_IP, 0x01},
|
{"subnet" , OPTION_IP, 0x01},
|
||||||
{"timezone" , OPTION_S32, 0x02},
|
{"timezone" , OPTION_S32, 0x02},
|
||||||
{"router" , OPTION_IP, 0x03},
|
{"router" , OPTION_IP, 0x03},
|
||||||
@ -55,8 +55,6 @@ struct dhcp_option options[] = {
|
|||||||
/* Lengths of the different option types */
|
/* Lengths of the different option types */
|
||||||
int option_lengths[] = {
|
int option_lengths[] = {
|
||||||
[OPTION_IP] = 4,
|
[OPTION_IP] = 4,
|
||||||
[OPTION_IP_PAIR] = 8,
|
|
||||||
[OPTION_BOOLEAN] = 1,
|
|
||||||
[OPTION_STRING] = 1,
|
[OPTION_STRING] = 1,
|
||||||
[OPTION_U8] = 1,
|
[OPTION_U8] = 1,
|
||||||
[OPTION_U16] = 2,
|
[OPTION_U16] = 2,
|
||||||
@ -216,7 +214,7 @@ int add_simple_option(unsigned char *optionptr, unsigned char code,
|
|||||||
|
|
||||||
for (i = 0; options[i].code; i++)
|
for (i = 0; options[i].code; i++)
|
||||||
if (options[i].code == code) {
|
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);
|
log_line("aso(): code=0x%02x length=0x%02x", code, length);
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
|
||||||
#define TYPE_MASK 0x0F
|
|
||||||
|
|
||||||
#define DHCP_OPTIONS_BUFSIZE 308
|
#define DHCP_OPTIONS_BUFSIZE 308
|
||||||
|
|
||||||
/* DHCP option codes (partial list) */
|
/* DHCP option codes (partial list) */
|
||||||
@ -55,9 +53,7 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
OPTION_IP=1,
|
OPTION_IP=1,
|
||||||
OPTION_IP_PAIR,
|
|
||||||
OPTION_STRING,
|
OPTION_STRING,
|
||||||
OPTION_BOOLEAN,
|
|
||||||
OPTION_U8,
|
OPTION_U8,
|
||||||
OPTION_U16,
|
OPTION_U16,
|
||||||
OPTION_S16,
|
OPTION_S16,
|
||||||
@ -67,7 +63,7 @@ enum {
|
|||||||
|
|
||||||
struct dhcp_option {
|
struct dhcp_option {
|
||||||
char name[10];
|
char name[10];
|
||||||
char flags;
|
char type;
|
||||||
unsigned char code;
|
unsigned char code;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user