options is a pretty common symbol, bad idea to use as a global in udhcp when compiling into busybox
This commit is contained in:
parent
a1fece2c70
commit
4a9e34c148
@ -90,9 +90,9 @@ static void add_requests(struct dhcpMessage *packet)
|
|||||||
int i, len = 0;
|
int i, len = 0;
|
||||||
|
|
||||||
packet->options[end + OPT_CODE] = DHCP_PARAM_REQ;
|
packet->options[end + OPT_CODE] = DHCP_PARAM_REQ;
|
||||||
for (i = 0; options[i].code; i++)
|
for (i = 0; dhcp_options[i].code; i++)
|
||||||
if (options[i].flags & OPTION_REQ)
|
if (dhcp_options[i].flags & OPTION_REQ)
|
||||||
packet->options[end + OPT_DATA + len++] = options[i].code;
|
packet->options[end + OPT_DATA + len++] = dhcp_options[i].code;
|
||||||
packet->options[end + OPT_LEN] = len;
|
packet->options[end + OPT_LEN] = len;
|
||||||
packet->options[end + OPT_DATA + len] = DHCP_END;
|
packet->options[end + OPT_DATA + len] = DHCP_END;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ static int read_opt(const char *const_line, void *arg)
|
|||||||
|
|
||||||
if ((opt = strtok(strcpy(line, const_line), " \t="))) {
|
if ((opt = strtok(strcpy(line, const_line), " \t="))) {
|
||||||
|
|
||||||
for (option = options; option->code; option++)
|
for (option = dhcp_options; option->code; option++)
|
||||||
if (!strcasecmp(option->name, opt))
|
if (!strcasecmp(option->name, opt))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* supported options are easily added here */
|
/* supported options are easily added here */
|
||||||
struct dhcp_option options[] = {
|
struct dhcp_option dhcp_options[] = {
|
||||||
/* name[10] flags code */
|
/* name[10] flags code */
|
||||||
{"subnet", OPTION_IP | OPTION_REQ, 0x01},
|
{"subnet", OPTION_IP | OPTION_REQ, 0x01},
|
||||||
{"timezone", OPTION_S32, 0x02},
|
{"timezone", OPTION_S32, 0x02},
|
||||||
@ -158,9 +158,9 @@ int add_simple_option(unsigned char *optionptr, unsigned char code, u_int32_t da
|
|||||||
u16 = (u_int16_t *) &aligned;
|
u16 = (u_int16_t *) &aligned;
|
||||||
u32 = &aligned;
|
u32 = &aligned;
|
||||||
|
|
||||||
for (i = 0; options[i].code; i++)
|
for (i = 0; dhcp_options[i].code; i++)
|
||||||
if (options[i].code == code) {
|
if (dhcp_options[i].code == code) {
|
||||||
length = option_lengths[options[i].flags & TYPE_MASK];
|
length = option_lengths[dhcp_options[i].flags & TYPE_MASK];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!length) {
|
if (!length) {
|
||||||
|
@ -27,7 +27,7 @@ struct dhcp_option {
|
|||||||
unsigned char code;
|
unsigned char code;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct dhcp_option options[];
|
extern struct dhcp_option dhcp_options[];
|
||||||
extern int option_lengths[];
|
extern int option_lengths[];
|
||||||
|
|
||||||
unsigned char *get_option(struct dhcpMessage *packet, int code);
|
unsigned char *get_option(struct dhcpMessage *packet, int code);
|
||||||
|
@ -160,8 +160,8 @@ static char **fill_envp(struct dhcpMessage *packet)
|
|||||||
if (packet == NULL)
|
if (packet == NULL)
|
||||||
num_options = 0;
|
num_options = 0;
|
||||||
else {
|
else {
|
||||||
for (i = 0; options[i].code; i++)
|
for (i = 0; dhcp_options[i].code; i++)
|
||||||
if (get_option(packet, options[i].code))
|
if (get_option(packet, dhcp_options[i].code))
|
||||||
num_options++;
|
num_options++;
|
||||||
if (packet->siaddr) num_options++;
|
if (packet->siaddr) num_options++;
|
||||||
if ((temp = get_option(packet, DHCP_OPTION_OVER)))
|
if ((temp = get_option(packet, DHCP_OPTION_OVER)))
|
||||||
@ -184,14 +184,15 @@ static char **fill_envp(struct dhcpMessage *packet)
|
|||||||
asprintip(&envp[j++], "ip=", (unsigned char *) &packet->yiaddr);
|
asprintip(&envp[j++], "ip=", (unsigned char *) &packet->yiaddr);
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; options[i].code; i++) {
|
for (i = 0; dhcp_options[i].code; i++) {
|
||||||
if (!(temp = get_option(packet, options[i].code)))
|
if (!(temp = get_option(packet, dhcp_options[i].code)))
|
||||||
continue;
|
continue;
|
||||||
envp[j] = xmalloc(upper_length(temp[OPT_LEN - 2], options[i].flags & TYPE_MASK) + strlen(options[i].name) + 2);
|
envp[j] = xmalloc(upper_length(temp[OPT_LEN - 2],
|
||||||
fill_options(envp[j++], temp, &options[i]);
|
dhcp_options[i].flags & TYPE_MASK) + strlen(dhcp_options[i].name) + 2);
|
||||||
|
fill_options(envp[j++], temp, &dhcp_options[i]);
|
||||||
|
|
||||||
/* Fill in a subnet bits option for things like /24 */
|
/* Fill in a subnet bits option for things like /24 */
|
||||||
if (options[i].code == DHCP_SUBNET) {
|
if (dhcp_options[i].code == DHCP_SUBNET) {
|
||||||
memcpy(&subnet, temp, 4);
|
memcpy(&subnet, temp, 4);
|
||||||
asprintf(&envp[j++], "mask=%d", mton(&subnet));
|
asprintf(&envp[j++], "mask=%d", mton(&subnet));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user