From eb907e038f98e779f41cbac74424d73a48dcb9a6 Mon Sep 17 00:00:00 2001 From: Tomas Mudrunka Date: Sat, 2 Nov 2013 14:44:21 +0100 Subject: [PATCH] Next version of DHCP prefix delegation compiler --- bash/dhcp-option.sh | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/bash/dhcp-option.sh b/bash/dhcp-option.sh index c9c5a76..0a1ec6c 100755 --- a/bash/dhcp-option.sh +++ b/bash/dhcp-option.sh @@ -30,13 +30,38 @@ dhcp_option() { printf "$option_data" | xxd -ps -c 256 | escape } +pd_prefix() { + #Generate prefix sub-option to be included in PD option of DHCPv6 + + option_id=26 + lifetime_preferred='\x00\x00\x01\x2C' + lifetime_valid='\x00\x00\x01\x2C' + + prefix_length='64' + #prefix = 16 octets: + prefix='\x20\x01\x06\x7c\x21\x90\x1a\x01''\x00\x00\x00\x00\x00\x00\x00\x00' + + prefix_length_hex=$(dec_to_hex $prefix_length) + + #echo $prefix_length_hex + dhcp_option $option_id "$lifetime_preferred$lifetime_valid$prefix_length_hex$prefix" +} + pd() { - option_id=25 + #Generate data of PF option of DHCPv6 + iaid='\x00\x00\x00\x00' t1='\x00\x00\x01\x2C' t2='\x00\x00\x01\x2C' - ia_pd_opts='' - dhcp_option $option_id "$iaid$t1$t2$id_pd_opts" + ia_pd_opts="$(pd_prefix)" + echo -n "$iaid$t1$t2$ia_pd_opts" +} + +pd_option() { + #Generate PD option of DHCPv6 (including header) + + option_id=25 + dhcp_option $option_id "$(pd)" } pd | dnsmasq -- 2.30.2