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 | |
parent | eda5142b5c21541295c3ad6a41f63c90cc6578c3 (diff) |
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>
-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) memset(found_opts, 0, sizeof(found_opts)); - /* We need 6 elements for: + /* We need 7 elements for: * "interface=IFACE" * "ip=N.N.N.N" from packet->yiaddr + * "giaddr=IP" from packet->gateway_nip (unless 0) * "siaddr=IP" from packet->siaddr_nip (unless 0) * "boot_file=FILE" from packet->file (unless overloaded) * "sname=SERVER_HOSTNAME" from packet->sname (unless overloaded) * terminating NULL */ - envc = 6; + envc = 7; /* +1 element for each option, +2 for subnet option: */ if (packet) { /* note: do not search for "pad" (0) and "end" (255) options */ @@ -493,9 +494,7 @@ static char **fill_envp(struct dhcp_packet *packet) * uint16_t flags; // only one flag so far: bcast. Never set by server * uint32_t ciaddr; // client IP (usually == yiaddr. can it be different * // if during renew server wants to give us different IP?) - * uint32_t gateway_nip; // relay agent IP address * uint8_t chaddr[16]; // link-layer client hardware address (MAC) - * TODO: export gateway_nip as $giaddr? */ /* Most important one: yiaddr as $ip */ *curr = xmalloc(sizeof("ip=255.255.255.255")); @@ -507,6 +506,12 @@ static char **fill_envp(struct dhcp_packet *packet) sprint_nip(*curr, "siaddr=", (uint8_t *) &packet->siaddr_nip); putenv(*curr++); } + if (packet->gateway_nip) { + /* IP address of DHCP relay agent to use in bootstrap */ + *curr = xmalloc(sizeof("giaddr=255.255.255.255")); + sprint_nip(*curr, "giaddr=", (uint8_t *) &packet->gateway_nip); + putenv(*curr++); + } if (!(overload & FILE_FIELD) && packet->file[0]) { /* watch out for invalid packets */ *curr = xasprintf("boot_file=%."DHCP_PKT_FILE_LEN_STR"s", packet->file); |