mirror of
https://github.com/sheumann/hush.git
synced 2025-01-14 12:30:40 +00:00
udhcpd: allow "domain" to be a list of DNS servers, not just one
This commit is contained in:
parent
de55b5d014
commit
c4d606e367
@ -101,19 +101,8 @@ static void attach_option(struct option_set **opt_list,
|
|||||||
{
|
{
|
||||||
struct option_set *existing, *new, **curr;
|
struct option_set *existing, *new, **curr;
|
||||||
|
|
||||||
/* add it to an existing option */
|
|
||||||
existing = find_option(*opt_list, option->code);
|
existing = find_option(*opt_list, option->code);
|
||||||
if (existing) {
|
if (!existing) {
|
||||||
DEBUG("Attaching option %s to existing member of list", option->name);
|
|
||||||
if (option->flags & OPTION_LIST) {
|
|
||||||
if (existing->data[OPT_LEN] + length <= 255) {
|
|
||||||
existing->data = realloc(existing->data,
|
|
||||||
existing->data[OPT_LEN] + length + 2);
|
|
||||||
memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length);
|
|
||||||
existing->data[OPT_LEN] += length;
|
|
||||||
} /* else, ignore the data, we could put this in a second option in the future */
|
|
||||||
} /* else, ignore the new data */
|
|
||||||
} else {
|
|
||||||
DEBUG("Attaching option %s to list", option->name);
|
DEBUG("Attaching option %s to list", option->name);
|
||||||
|
|
||||||
/* make a new option */
|
/* make a new option */
|
||||||
@ -129,7 +118,26 @@ static void attach_option(struct option_set **opt_list,
|
|||||||
|
|
||||||
new->next = *curr;
|
new->next = *curr;
|
||||||
*curr = new;
|
*curr = new;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* add it to an existing option */
|
||||||
|
DEBUG("Attaching option %s to existing member of list", option->name);
|
||||||
|
if (option->flags & OPTION_LIST) {
|
||||||
|
if (existing->data[OPT_LEN] + length <= 255) {
|
||||||
|
existing->data = xrealloc(existing->data,
|
||||||
|
existing->data[OPT_LEN] + length + 3);
|
||||||
|
if ((option->flags & TYPE_MASK) == OPTION_STRING) {
|
||||||
|
if (existing->data[OPT_LEN] + length >= 255)
|
||||||
|
return;
|
||||||
|
/* add space separator between STRING options in a list */
|
||||||
|
existing->data[existing->data[OPT_LEN] + 2] = ' ';
|
||||||
|
existing->data[OPT_LEN]++;
|
||||||
|
}
|
||||||
|
memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length);
|
||||||
|
existing->data[OPT_LEN] += length;
|
||||||
|
} /* else, ignore the data, we could put this in a second option in the future */
|
||||||
|
} /* else, ignore the new data */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ const struct dhcp_option dhcp_options[] = {
|
|||||||
{"lprsvr", OPTION_IP | OPTION_LIST, 0x09},
|
{"lprsvr", OPTION_IP | OPTION_LIST, 0x09},
|
||||||
{"hostname", OPTION_STRING | OPTION_REQ, 0x0c},
|
{"hostname", OPTION_STRING | OPTION_REQ, 0x0c},
|
||||||
{"bootsize", OPTION_U16, 0x0d},
|
{"bootsize", OPTION_U16, 0x0d},
|
||||||
{"domain", OPTION_STRING | OPTION_REQ, 0x0f},
|
{"domain", OPTION_STRING | OPTION_LIST | OPTION_REQ, 0x0f},
|
||||||
{"swapsvr", OPTION_IP, 0x10},
|
{"swapsvr", OPTION_IP, 0x10},
|
||||||
{"rootpath", OPTION_STRING, 0x11},
|
{"rootpath", OPTION_STRING, 0x11},
|
||||||
{"ipttl", OPTION_U8, 0x17},
|
{"ipttl", OPTION_U8, 0x17},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user