+
+ if [ -x /usr/sbin/odhcpd -a -x /etc/init.d/odhcpd ] ; then
+ local odhcpd_is_main odhcpd_is_enabled
+ config_get odhcpd_is_main odhcpd maindhcp 0
+ /etc/init.d/odhcpd enabled && odhcpd_is_enabled=1 || odhcpd_is_enabled=0
+
+
+ if [ "$odhcpd_is_enabled" -eq 0 -a "$DHCPv6CAPABLE" -eq 1 ] ; then
+ # DHCP V4 and V6 in DNSMASQ
+ DNSMASQ_DHCP_VER=6
+ elif [ "$odhcpd_is_main" -gt 0 ] ; then
+ # ODHCPD is doing it all
+ DNSMASQ_DHCP_VER=0
+ else
+ # You have ODHCPD but use DNSMASQ for DHCPV4
+ DNSMASQ_DHCP_VER=4
+ fi
+
+ elif [ "$DHCPv6CAPABLE" -eq 1 ] ; then
+ # DHCP V4 and V6 in DNSMASQ
+ DNSMASQ_DHCP_VER=6
+ else
+ DNSMASQ_DHCP_VER=4
+ fi
+
+ # Allow DHCP/DHCPv6 to be handled by ISC DHCPD
+ if [ -x /usr/sbin/dhcpd ] ; then
+ if [ -x /etc/init.d/dhcpd ] ; then
+ /etc/init.d/dhcpd enabled && DNSMASQ_DHCP_VER=0
+ fi
+ if [ -x /etc/init.d/dhcpd6 -a "$DNSMASQ_DHCP_VER" -gt 0 ] ; then
+ /etc/init.d/dhcpd6 enabled && DNSMASQ_DHCP_VER=4
+ fi
+ fi
+
+ append_bool "$cfg" authoritative "--dhcp-authoritative"
+ append_bool "$cfg" nodaemon "--no-daemon"
+ append_bool "$cfg" domainneeded "--domain-needed"
+ append_bool "$cfg" filterwin2k "--filterwin2k"
+ append_bool "$cfg" nohosts "--no-hosts"
+ append_bool "$cfg" nonegcache "--no-negcache"
+ append_bool "$cfg" strictorder "--strict-order"
+ append_bool "$cfg" logqueries "--log-queries=extra"
+ append_bool "$cfg" noresolv "--no-resolv"
+ append_bool "$cfg" localise_queries "--localise-queries"
+ append_bool "$cfg" readethers "--read-ethers"
+ append_bool "$cfg" dbus "--enable-dbus"
+ append_bool "$cfg" expandhosts "--expand-hosts"
+ config_get tftp_root "$cfg" "tftp_root"
+ [ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" enable_tftp "--enable-tftp"
+ append_bool "$cfg" tftp_no_fail "--tftp-no-fail"
+ append_bool "$cfg" nonwildcard "--bind-dynamic" 1
+ append_bool "$cfg" fqdn "--dhcp-fqdn"
+ append_bool "$cfg" proxydnssec "--proxy-dnssec"
+ append_bool "$cfg" localservice "--local-service"
+ append_bool "$cfg" logdhcp "--log-dhcp"
+ append_bool "$cfg" quietdhcp "--quiet-dhcp"
+ append_bool "$cfg" sequential_ip "--dhcp-sequential-ip"
+ append_bool "$cfg" allservers "--all-servers"
+ append_bool "$cfg" noping "--no-ping"
+
+ append_parm "$cfg" logfacility "--log-facility"
+
+ append_parm "$cfg" cachesize "--cache-size"
+ append_parm "$cfg" dnsforwardmax "--dns-forward-max"
+ append_parm "$cfg" port "--port"
+ append_parm "$cfg" ednspacket_max "--edns-packet-max"
+ append_parm "$cfg" dhcpleasemax "--dhcp-lease-max"
+ append_parm "$cfg" "queryport" "--query-port"
+ append_parm "$cfg" "minport" "--min-port"
+ append_parm "$cfg" "maxport" "--max-port"
+ append_parm "$cfg" "domain" "--domain"
+ append_parm "$cfg" "local" "--server"
+ config_list_foreach "$cfg" "listen_address" append_listenaddress
+ config_list_foreach "$cfg" "server" append_server
+ config_list_foreach "$cfg" "rev_server" append_rev_server
+ config_list_foreach "$cfg" "address" append_address
+ config_list_foreach "$cfg" "ipset" append_ipset
+ config_list_foreach "$cfg" "interface" append_interface
+ config_list_foreach "$cfg" "notinterface" append_notinterface
+ config_list_foreach "$cfg" "addnhosts" append_addnhosts
+ config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain
+ append_parm "$cfg" "leasefile" "--dhcp-leasefile" "/tmp/dhcp.leases"
+ append_parm "$cfg" "serversfile" "--servers-file"
+ append_parm "$cfg" "tftp_root" "--tftp-root"
+ append_parm "$cfg" "dhcp_boot" "--dhcp-boot"
+ append_parm "$cfg" "local_ttl" "--local-ttl"
+ append_parm "$cfg" "pxe_prompt" "--pxe-prompt"
+ config_list_foreach "$cfg" "pxe_service" append_pxe_service
+ config_get DOMAIN "$cfg" domain
+
+ config_get_bool ADD_LOCAL_DOMAIN "$cfg" add_local_domain 1
+ config_get_bool ADD_LOCAL_HOSTNAME "$cfg" add_local_hostname 1
+ config_get ADD_LOCAL_FQDN "$cfg" add_local_fqdn ""
+ config_get ADD_WAN_FQDN "$cfg" add_wan_fqdn 0
+
+ if [ -z "$ADD_LOCAL_FQDN" ] ; then
+ # maintain support for previous UCI
+ ADD_LOCAL_FQDN="$ADD_LOCAL_HOSTNAME"
+ fi
+
+ config_get_bool readethers "$cfg" readethers
+ [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
+
+ config_get user_dhcpscript $cfg dhcpscript
+ if has_handler || [ -n "$user_dhcpscript" ]; then
+ xappend "--dhcp-script=$DHCPSCRIPT"
+ fi
+
+ config_get leasefile $cfg leasefile "/tmp/dhcp.leases"
+ [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile"
+ config_get_bool cachelocal "$cfg" cachelocal 1
+
+ config_get_bool noresolv "$cfg" noresolv 0
+ if [ "$noresolv" != "1" ]; then
+ config_get resolvfile "$cfg" resolvfile "/tmp/resolv.conf.auto"
+ # So jail doesn't complain if file missing
+ [ -n "$resolvfile" -a \! -e "$resolvfile" ] && touch "$resolvfile"
+ fi
+
+ [ -n "$resolvfile" ] && xappend "--resolv-file=$resolvfile"
+
+ config_get hostsfile "$cfg" dhcphostsfile
+ [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile"
+
+ local rebind
+ config_get_bool rebind "$cfg" rebind_protection 1
+ [ $rebind -gt 0 ] && {
+ log_once \
+ "DNS rebinding protection is active," \
+ "will discard upstream RFC1918 responses!"
+ xappend "--stop-dns-rebind"
+
+ local rebind_localhost
+ config_get_bool rebind_localhost "$cfg" rebind_localhost 0
+ [ $rebind_localhost -gt 0 ] && {
+ log_once "Allowing 127.0.0.0/8 responses"
+ xappend "--rebind-localhost-ok"