diff options
author | Martin Lewis <martin.lewis.x84@gmail.com> | 2019-06-10 17:06:17 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-06-11 17:18:28 +0200 |
commit | d378fa170ac7c63b05b8bf06dbc7e262e5b52a3d (patch) | |
tree | 82bf30129553984a351b1825eaf0c4a2dd188ec4 /networking/udhcp | |
parent | eda5142b5c21541295c3ad6a41f63c90cc6578c3 (diff) | |
download | busybox-w32-d378fa170ac7c63b05b8bf06dbc7e262e5b52a3d.tar.gz busybox-w32-d378fa170ac7c63b05b8bf06dbc7e262e5b52a3d.tar.bz2 busybox-w32-d378fa170ac7c63b05b8bf06dbc7e262e5b52a3d.zip |
dhcpc.c: Added support for relay server parameter.
Resolved a TODO by adding support for gateway_nip parameter.
function old new delta
udhcp_run_script 792 835 +43
Signed-off-by: Martin Lewis <martin.lewis.x84@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/dhcpc.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 739870bee..80391f606 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -449,15 +449,16 @@ static char **fill_envp(struct dhcp_packet *packet) | |||
449 | 449 | ||
450 | memset(found_opts, 0, sizeof(found_opts)); | 450 | memset(found_opts, 0, sizeof(found_opts)); |
451 | 451 | ||
452 | /* We need 6 elements for: | 452 | /* We need 7 elements for: |
453 | * "interface=IFACE" | 453 | * "interface=IFACE" |
454 | * "ip=N.N.N.N" from packet->yiaddr | 454 | * "ip=N.N.N.N" from packet->yiaddr |
455 | * "giaddr=IP" from packet->gateway_nip (unless 0) | ||
455 | * "siaddr=IP" from packet->siaddr_nip (unless 0) | 456 | * "siaddr=IP" from packet->siaddr_nip (unless 0) |
456 | * "boot_file=FILE" from packet->file (unless overloaded) | 457 | * "boot_file=FILE" from packet->file (unless overloaded) |
457 | * "sname=SERVER_HOSTNAME" from packet->sname (unless overloaded) | 458 | * "sname=SERVER_HOSTNAME" from packet->sname (unless overloaded) |
458 | * terminating NULL | 459 | * terminating NULL |
459 | */ | 460 | */ |
460 | envc = 6; | 461 | envc = 7; |
461 | /* +1 element for each option, +2 for subnet option: */ | 462 | /* +1 element for each option, +2 for subnet option: */ |
462 | if (packet) { | 463 | if (packet) { |
463 | /* note: do not search for "pad" (0) and "end" (255) options */ | 464 | /* note: do not search for "pad" (0) and "end" (255) options */ |
@@ -493,9 +494,7 @@ static char **fill_envp(struct dhcp_packet *packet) | |||
493 | * uint16_t flags; // only one flag so far: bcast. Never set by server | 494 | * uint16_t flags; // only one flag so far: bcast. Never set by server |
494 | * uint32_t ciaddr; // client IP (usually == yiaddr. can it be different | 495 | * uint32_t ciaddr; // client IP (usually == yiaddr. can it be different |
495 | * // if during renew server wants to give us different IP?) | 496 | * // if during renew server wants to give us different IP?) |
496 | * uint32_t gateway_nip; // relay agent IP address | ||
497 | * uint8_t chaddr[16]; // link-layer client hardware address (MAC) | 497 | * uint8_t chaddr[16]; // link-layer client hardware address (MAC) |
498 | * TODO: export gateway_nip as $giaddr? | ||
499 | */ | 498 | */ |
500 | /* Most important one: yiaddr as $ip */ | 499 | /* Most important one: yiaddr as $ip */ |
501 | *curr = xmalloc(sizeof("ip=255.255.255.255")); | 500 | *curr = xmalloc(sizeof("ip=255.255.255.255")); |
@@ -507,6 +506,12 @@ static char **fill_envp(struct dhcp_packet *packet) | |||
507 | sprint_nip(*curr, "siaddr=", (uint8_t *) &packet->siaddr_nip); | 506 | sprint_nip(*curr, "siaddr=", (uint8_t *) &packet->siaddr_nip); |
508 | putenv(*curr++); | 507 | putenv(*curr++); |
509 | } | 508 | } |
509 | if (packet->gateway_nip) { | ||
510 | /* IP address of DHCP relay agent to use in bootstrap */ | ||
511 | *curr = xmalloc(sizeof("giaddr=255.255.255.255")); | ||
512 | sprint_nip(*curr, "giaddr=", (uint8_t *) &packet->gateway_nip); | ||
513 | putenv(*curr++); | ||
514 | } | ||
510 | if (!(overload & FILE_FIELD) && packet->file[0]) { | 515 | if (!(overload & FILE_FIELD) && packet->file[0]) { |
511 | /* watch out for invalid packets */ | 516 | /* watch out for invalid packets */ |
512 | *curr = xasprintf("boot_file=%."DHCP_PKT_FILE_LEN_STR"s", packet->file); | 517 | *curr = xasprintf("boot_file=%."DHCP_PKT_FILE_LEN_STR"s", packet->file); |