X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fodhcpd.git;a=blobdiff_plain;f=src%2Fdhcpv4.c;h=62ddab866ea5cc608f1596e7a99130db0f77818a;hp=ad14e3495a4a648c3abee109fdc758cd7410e07b;hb=da2657472b642a266c8a80763a51868e2af6b050;hpb=4f4de590ce3bf6f44a6783559479f5055571fe44 diff --git a/src/dhcpv4.c b/src/dhcpv4.c index ad14e34..62ddab8 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -129,9 +129,12 @@ int setup_dhcpv4_interface(struct interface *iface, bool enable) } else if (ntohl(mask.s_addr) <= 0xffffffc0) { iface->dhcpv4_start.s_addr = start | htonl(10); iface->dhcpv4_end.s_addr = end | htonl(60); - } else { + } else if (ntohl(mask.s_addr) <= 0xffffffe0) { iface->dhcpv4_start.s_addr = start | htonl(10); iface->dhcpv4_end.s_addr = end | htonl(30); + } else { + iface->dhcpv4_start.s_addr = start | htonl(3); + iface->dhcpv4_end.s_addr = end | htonl(12); } } @@ -359,14 +362,16 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, dhcpv4_put(&reply, &cookie, DHCPV4_OPT_MTU, 2, &mtu); } - if (iface->search) { - char b[256]; - if (dn_expand(iface->search, iface->search + iface->search_len, - iface->search, b, sizeof(b)) > 0) - dhcpv4_put(&reply, &cookie, DHCPV4_OPT_DOMAIN, strlen(b), b); + if (iface->search && iface->search_len <= 255) { + dhcpv4_put(&reply, &cookie, DHCPV4_OPT_SEARCH_DOMAIN, + iface->search_len, iface->search); } else if (!res_init() && _res.dnsrch[0] && _res.dnsrch[0][0]) { - dhcpv4_put(&reply, &cookie, DHCPV4_OPT_DOMAIN, - strlen(_res.dnsrch[0]), _res.dnsrch[0]); + uint8_t search_buf[256]; + int len = dn_comp(_res.dnsrch[0], search_buf, + sizeof(search_buf), NULL, NULL); + if (len > 0) + dhcpv4_put(&reply, &cookie, DHCPV4_OPT_SEARCH_DOMAIN, + len, search_buf); } dhcpv4_put(&reply, &cookie, DHCPV4_OPT_ROUTER, 4, &ifaddr.sin_addr); @@ -514,6 +519,9 @@ static struct dhcpv4_assignment* dhcpv4_lease(struct interface *iface, a = NULL; } + if (a) + update_state = true; + if (assigned && a) lease = a; } else if (msg == DHCPV4_MSG_RELEASE) {