[OpenWrt-Devel] [PATCH] dnsmasq: support hostid ipv6 address suffix option
Kevin Darbyshire-Bryant
kevin at darbyshire-bryant.me.uk
Tue Sep 1 18:38:04 EDT 2015
Please ignore the patch. Just woken in middle of night and realised I've done something mind numbingly stupid. Will fix tomorrow!
--
Cheers,
Kevin at Darbyshire-Bryant.me.uk
Sent from my phone, apologies for brevity, spelling & top posting
> On 1 Sep 2015, at 21:03, Kevin Darbyshire-Bryant <kevin at darbyshire-bryant.me.uk> wrote:
>
> 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,[::V6:su:ff:ix],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,[::00:00:00:04],Kermit
>
> Signed-off-by: Kevin Darbyshire-Bryant <kevin at darbyshire-bryant.me.uk>
> ---
> Proper thanks to jow_laptop for lots of help with this
>
> .../network/services/dnsmasq/files/dnsmasq.init | 29 +++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
> index ab64e88..58c301f 100644
> --- a/package/network/services/dnsmasq/files/dnsmasq.init
> +++ b/package/network/services/dnsmasq/files/dnsmasq.init
> @@ -23,6 +23,27 @@ 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 "%02x:%02x:%02x:%02x\n" \
> + $(((0x$hex >> 24) % 256)) \
> + $(((0x$hex >> 16) % 256)) \
> + $(((0x$hex >> 8) % 256)) \
> + $(( 0x$hex % 256))
> + )"
> +
> + return 0
> +}
> +
> dhcp_calc() {
> local ip="$1"
> local res=0
> @@ -329,10 +350,16 @@ dhcp_host_add() {
>
> config_get tag "$cfg" tag
>
> + config_get hostid "$cfg" hostid
> +
> + if [ -n "$hostid" ]; then
> + hex_to_hostid hostid "$hostid"
> + fi
> +
> config_get_bool broadcast "$cfg" broadcast 0
> [ "$broadcast" = "0" ] && broadcast=
>
> - xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip}${name:+,$name}"
> + xappend "--dhcp-host=$macs${networkid:+,net:$networkid}${broadcast:+,set:needs-broadcast}${tag:+,set:$tag}${ip:+,$ip${hostid:+,[::$hostid]}}${name:+,$name}"
> }
>
> dhcp_tag_add() {
> --
> 1.9.1
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3089 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20150901/5b6e883a/attachment.p7s>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list