Browse Source

isc-dhcp: add support for RFC-3442 classless routes to hosts

Also avoid forward references to functions.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
lilik-openwrt-22.03
Philip Prindeville 4 years ago
parent
commit
cdd5af4b21
2 changed files with 66 additions and 65 deletions
  1. +1
    -1
      net/isc-dhcp/Makefile
  2. +65
    -64
      net/isc-dhcp/files/dhcpd.init

+ 1
- 1
net/isc-dhcp/Makefile View File

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=isc-dhcp
UPSTREAM_NAME:=dhcp
PKG_VERSION:=4.4.1
PKG_RELEASE:=8
PKG_RELEASE:=9
PKG_LICENSE:=BSD-3-Clause
PKG_LICENSE_FILES:=LICENSE


+ 65
- 64
net/isc-dhcp/files/dhcpd.init View File

@ -57,70 +57,6 @@ hex_to_hostid() {
return 0
}
static_host_add() {
local cfg="$1"
local broadcast hostid macn macs mac name ip leasetime
config_get macs "$cfg" "mac"
[ -n "$macs" ] || return 0
config_get name "$cfg" "name"
[ -n "$name" ] || return 0
config_get ip "$cfg" "ip"
[ -n "$ip" ] || return 0
config_get_bool broadcast "$cfg" "broadcast" 0
config_get dns "$cfg" "dns"
config_get gateway "$cfg" "gateway"
config_get leasetime "$cfg" "leasetime"
if [ -n "$leasetime" ] ; then
leasetime="$(time2seconds "$leasetime")"
[ "$?" -ne 0 ] && return 1
fi
config_get hostid "$cfg" "hostid"
if [ -n "$hostid" ] ; then
hex_to_hostid hostid "$hostid" || return 1
fi
macn=0
for mac in $macs; do
macn=$(( macn + 1 ))
done
for mac in $macs; do
local secname="$name"
if [ $macn -gt 1 ] ; then
secname="${name}-${mac//:}"
fi
echo "host $secname {"
echo " hardware ethernet $mac;"
echo " fixed-address $ip;"
echo " option host-name \"$name\";"
if [ "$broadcast" -eq 1 ] ; then
echo " always-broadcast true;"
fi
if [ -n "$leasetime" ] ; then
echo " default-lease-time $leasetime;"
echo " max-lease-time $leasetime;"
fi
if [ -n "$hostid" ] ; then
echo " option dhcp-client-identifier $hostid;"
fi
if [ -n "$dns" ] ; then
echo " option domain-name-servers $dns;"
fi
if [ -n "$gateway" ] ; then
echo " option routers $gateway;"
fi
config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
echo "}"
done
}
static_hosts() {
config_foreach static_host_add host "$@"
}
typeof() {
echo "$1" | awk '
/^\d+\.\d+\.\d+\.\d+$/ { print "ip\n"; next; }
@ -186,6 +122,71 @@ append_dhcp_options() {
echo " option $tag $formatted;"
}
static_host_add() {
local cfg="$1"
local broadcast hostid macn macs mac name ip leasetime
config_get macs "$cfg" "mac"
[ -n "$macs" ] || return 0
config_get name "$cfg" "name"
[ -n "$name" ] || return 0
config_get ip "$cfg" "ip"
[ -n "$ip" ] || return 0
config_get_bool broadcast "$cfg" "broadcast" 0
config_get dns "$cfg" "dns"
config_get gateway "$cfg" "gateway"
config_get leasetime "$cfg" "leasetime"
if [ -n "$leasetime" ] ; then
leasetime="$(time2seconds "$leasetime")"
[ "$?" -ne 0 ] && return 1
fi
config_get hostid "$cfg" "hostid"
if [ -n "$hostid" ] ; then
hex_to_hostid hostid "$hostid" || return 1
fi
macn=0
for mac in $macs; do
macn=$(( macn + 1 ))
done
for mac in $macs; do
local secname="$name"
if [ $macn -gt 1 ] ; then
secname="${name}-${mac//:}"
fi
echo "host $secname {"
echo " hardware ethernet $mac;"
echo " fixed-address $ip;"
echo " option host-name \"$name\";"
if [ "$broadcast" -eq 1 ] ; then
echo " always-broadcast true;"
fi
if [ -n "$leasetime" ] ; then
echo " default-lease-time $leasetime;"
echo " max-lease-time $leasetime;"
fi
if [ -n "$hostid" ] ; then
echo " option dhcp-client-identifier $hostid;"
fi
if [ -n "$dns" ] ; then
echo " option domain-name-servers $dns;"
fi
if [ -n "$gateway" ] ; then
echo " option routers $gateway;"
fi
config_list_foreach "$cfg" "routes" append_routes
config_list_foreach "$cfg" "dhcp_option" append_dhcp_options
echo "}"
done
}
static_hosts() {
config_foreach static_host_add host "$@"
}
gen_dhcp_subnet() {
local cfg="$1"


Loading…
Cancel
Save