diff options
author | Christian Mehlis <christian@m3hlis.de> | 2014-08-12 14:58:06 +0200 |
---|---|---|
committer | Christian Mehlis <christian@m3hlis.de> | 2014-08-12 14:58:06 +0200 |
commit | f2cda6c15b55c80be8739f492a8ee7b4dbd1cf52 (patch) | |
tree | a2095d9dec4fb67c6de995e47c9664013bbd2aec /src/dhcpv4.c | |
parent | 634d9fe9142f62b7b2e7647ef88d6606e54ab155 (diff) |
dhcpv4: implement router configuration option
RFC 2132 defines:
3.5. Router Option
The router option specifies a list of IP addresses for routers on the
client's subnet. Routers SHOULD be listed in order of preference.
The code for the router option is 3. The minimum length for the
router option is 4 octets, and the length MUST always be a multiple
of 4.
Code Len Address 1 Address 2
+-----+-----+-----+-----+-----+-----+-----+-----+--
| 3 | n | a1 | a2 | a3 | a4 | a1 | a2 | ...
+-----+-----+-----+-----+-----+-----+-----+-----+--
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r-- | src/dhcpv4.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 2093ecd..7b200cd 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -384,8 +384,11 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, len, search_buf); } - dhcpv4_put(&reply, &cookie, DHCPV4_OPT_ROUTER, 4, &ifaddr.sin_addr); - + if (iface->dhcpv4_router_cnt == 0) + dhcpv4_put(&reply, &cookie, DHCPV4_OPT_ROUTER, 4, &ifaddr.sin_addr); + else + dhcpv4_put(&reply, &cookie, DHCPV4_OPT_ROUTER, + 4 * iface->dhcpv4_router_cnt, iface->dhcpv4_router); if (iface->dhcpv4_dns_cnt == 0) |