0a1ec6c8a3bc76441fdd50205189c752c777979b
2 #Experimental BASH script to compile DHCP options
5 echo 'obase=16; '"$1" |
bc
9 echo -n $
(while true
; do echo -n 0; done |
head -c "$2")$
(dec_to_hex
"$1") |
tail -c "$2"
14 [ -n "$i" ] && echo -n '\x'"$i";
19 sed -e 's/^\\x//g' |
sed -e 's/\\x/:/g'
27 len
=$
(echo -n "$option_data" |
wc -c)
28 dec_to_hex_right
$option_id 2 | escape
29 dec_to_hex_right
$len 2 | escape
30 printf "$option_data" | xxd
-ps -c 256 | escape
34 #Generate prefix sub-option to be included in PD option of DHCPv6
37 lifetime_preferred
='\x00\x00\x01\x2C'
38 lifetime_valid
='\x00\x00\x01\x2C'
42 prefix
='\x20\x01\x06\x7c\x21\x90\x1a\x01''\x00\x00\x00\x00\x00\x00\x00\x00'
44 prefix_length_hex
=$
(dec_to_hex
$prefix_length)
46 #echo $prefix_length_hex
47 dhcp_option
$option_id "$lifetime_preferred$lifetime_valid$prefix_length_hex$prefix"
51 #Generate data of PF option of DHCPv6
53 iaid
='\x00\x00\x00\x00'
56 ia_pd_opts
="$(pd_prefix)"
57 echo -n "$iaid$t1$t2$ia_pd_opts"
61 #Generate PD option of DHCPv6 (including header)
64 dhcp_option
$option_id "$(pd)"
This page took 0.299227 seconds and 4 git commands to generate.