aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>2015-08-31 18:11:41 +0100
committerJo-Philipp Wich <jo@mein.io>2016-06-10 18:16:47 +0200
commite8150364608e38e6b30ea0859ffa17ccb1fcc890 (patch)
tree28cfa4236bd6e116a162f48eb1b4192c76f1e43b
parent4b8f0a2d26e5477b2dc4542ec7438665a906b756 (diff)
downloadupstream-e8150364608e38e6b30ea0859ffa17ccb1fcc890.tar.gz
upstream-e8150364608e38e6b30ea0859ffa17ccb1fcc890.tar.bz2
upstream-e8150364608e38e6b30ea0859ffa17ccb1fcc890.zip
dnsmasq: support hostid ipv6 address suffix option
Add support for hostid dhcp config entry to dnsmasq. This allows specification of dhcpv6 hostid suffix and works in the same way as odhcpd. Entries in auto generated dnsmasq.conf should conform to: dhcp-host=mm:mm:mm:mm:mm:mm,IPv4addr,[::V6su:ffix],hostname example based on sample config/dhcp entry: config host option name 'Kermit' option mac 'E0:3F:49:A1:D4:AA' option ip '192.168.235.4' option hostid '4' dhcp-host=E0:3F:49:A1:D4:AA,192.168.235.4,[::0:4],Kermit Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
-rw-r--r--package/network/services/dnsmasq/files/dnsmasq.init30
1 files changed, 29 insertions, 1 deletions
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index ecf83622be..1a9903e50d 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -23,6 +23,25 @@ xappend() {
echo "${value#--}" >> $CONFIGFILE
}
+hex_to_hostid() {
+ local var="$1"
+ local hex="${2#0x}" # strip optional "0x" prefix
+
+ if [ -n "${hex//[0-9a-fA-F]/}" ]; then
+ # is invalid hex literal
+ return 1
+ fi
+
+ # convert into host id
+ export "$var=$(
+ printf "%0x:%0x" \
+ $(((0x$hex >> 16) % 65536)) \
+ $(( 0x$hex % 256))
+ )"
+
+ return 0
+}
+
dhcp_calc() {
local ip="$1"
local res=0
@@ -353,12 +372,19 @@ dhcp_host_add() {
config_get tag "$cfg" tag
+ if [ "$DHCPv6CAPABLE" -eq 1 ]; then
+ config_get hostid "$cfg" hostid
+ if [ -n "$hostid" ]; then
+ hex_to_hostid hostid "$hostid"
+ fi
+ fi
+
config_get_bool broadcast "$cfg" broadcast 0
[ "$broadcast" = "0" ] && broadcast=
config_get leasetime "$cfg" leasetime
- xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}${leasetime:+,$leasetime}"
+ xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}${leasetime:+,$leasetime}"
}
dhcp_tag_add() {
@@ -614,6 +640,8 @@ start_service() {
xappend "--conf-file=/etc/dnsmasq.conf"
}
+ $PROG --version | grep -osqE "^Compile time options:.* DHCPv6( |$)" && DHCPv6CAPABLE=1 || DHCPv6CAPABLE=0
+
args=""
config_foreach dnsmasq dnsmasq
config_foreach dhcp_host_add host