odhcpd: Support for Option NTP and SNTP
[project/odhcpd.git] / src / dhcpv4.c
index a3b0e33c7540df34af8a0b4c2c6e5ff54366df0d..f0780876ebbe47c71a71a6d460fa9084508c2e44 100644 (file)
@@ -849,6 +849,14 @@ void dhcpv4_handle_msg(void *addr, void *data, size_t len,
                dhcpv4_put(&reply, &cookie, DHCPV4_OPT_DNSSERVER,
                                4 * iface->dhcpv4_dns_cnt, iface->dhcpv4_dns);
 
+       if (a->reqopts && iface->dhcpv4_ntp_cnt != 0) {
+               for(size_t opts = 0; a->reqopts[opts]; opts++) {
+                       if (a->reqopts[opts] == DHCPV4_OPT_NTPSERVER) {
+                               dhcpv4_put(&reply, &cookie, DHCPV4_OPT_NTPSERVER,
+                                               4 * iface->dhcpv4_ntp_cnt, iface->dhcpv4_ntp);
+                       }
+               }
+       }
 
        dhcpv4_put(&reply, &cookie, DHCPV4_OPT_END, 0, NULL);