3 [ -L /sbin
/udhcpc
] ||
exit 0
9 proto_dhcp_init_config
() {
12 proto_config_add_string
'ipaddr:ipaddr'
13 proto_config_add_string
'hostname:hostname'
14 proto_config_add_string clientid
15 proto_config_add_string vendorid
16 proto_config_add_boolean
'broadcast:bool'
17 proto_config_add_boolean
'release:bool'
18 proto_config_add_string
'reqopts:list(string)'
19 proto_config_add_boolean
'defaultreqopts:bool'
20 proto_config_add_string iface6rd
21 proto_config_add_array
'sendopts:list(string)'
22 proto_config_add_boolean delegate
23 proto_config_add_string zone6rd
24 proto_config_add_string zone
25 proto_config_add_string mtu6rd
26 proto_config_add_string customroutes
27 proto_config_add_boolean classlessroute
30 proto_dhcp_add_sendopts
() {
31 [ -n "$1" ] && append
"$3" "-x $1"
38 local ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
39 json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute
42 for opt
in $reqopts; do
43 append dhcpopts
"-O $opt"
46 json_for_each_item proto_dhcp_add_sendopts sendopts dhcpopts
48 [ -z "$hostname" ] && hostname
="$(cat /proc/sys/kernel/hostname)"
49 [ "$defaultreqopts" = 0 ] && defaultreqopts
="-o" || defaultreqopts
=
50 [ "$broadcast" = 1 ] && broadcast
="-B" || broadcast
=
51 [ "$release" = 1 ] && release
="-R" || release
=
52 [ -n "$clientid" ] && clientid
="-x 0x3d:${clientid//:/}" || clientid
="-C"
53 [ -n "$iface6rd" ] && proto_export
"IFACE6RD=$iface6rd"
54 [ "$iface6rd" != 0 -a -f /lib
/netifd
/proto
/6rd.sh
] && append dhcpopts
"-O 212"
55 [ -n "$zone6rd" ] && proto_export
"ZONE6RD=$zone6rd"
56 [ -n "$zone" ] && proto_export
"ZONE=$zone"
57 [ -n "$mtu6rd" ] && proto_export
"MTU6RD=$mtu6rd"
58 [ -n "$customroutes" ] && proto_export
"CUSTOMROUTES=$customroutes"
59 [ "$delegate" = "0" ] && proto_export
"IFACE6RD_DELEGATE=0"
60 # Request classless route option (see RFC 3442) by default
61 [ "$classlessroute" = "0" ] || append dhcpopts
"-O 121"
63 proto_export
"INTERFACE=$config"
64 proto_run_command
"$config" udhcpc \
65 -p /var
/run
/udhcpc-
$iface.pid \
66 -s /lib
/netifd
/dhcp.
script \
68 ${ipaddr:+-r $ipaddr} \
69 ${hostname:+-x "hostname:$hostname"} \
70 ${vendorid:+-V "$vendorid"} \
71 $clientid $defaultreqopts $broadcast $release $dhcpopts
76 # SIGUSR1 forces udhcpc to renew its lease
77 local sigusr1
="$(kill -l SIGUSR1)"
78 [ -n "$sigusr1" ] && proto_kill_command
"$interface" $sigusr1
81 proto_dhcp_teardown
() {
83 proto_kill_command
"$interface"