3 [ -x /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
'norelease: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 norelease reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
39 json_get_vars ipaddr hostname clientid vendorid broadcast norelease 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 [ "$hostname" = "*" ] && hostname
=
51 [ "$defaultreqopts" = 0 ] && defaultreqopts
="-o" || defaultreqopts
=
52 [ "$broadcast" = 1 ] && broadcast
="-B" || broadcast
=
53 [ "$norelease" = 1 ] && norelease
="" || norelease
="-R"
54 [ -n "$clientid" ] && clientid
="-x 0x3d:${clientid//:/}" || clientid
="-C"
55 [ -n "$iface6rd" ] && proto_export
"IFACE6RD=$iface6rd"
56 [ "$iface6rd" != 0 -a -f /lib
/netifd
/proto
/6rd.sh
] && append dhcpopts
"-O 212"
57 [ -n "$zone6rd" ] && proto_export
"ZONE6RD=$zone6rd"
58 [ -n "$zone" ] && proto_export
"ZONE=$zone"
59 [ -n "$mtu6rd" ] && proto_export
"MTU6RD=$mtu6rd"
60 [ -n "$customroutes" ] && proto_export
"CUSTOMROUTES=$customroutes"
61 [ "$delegate" = "0" ] && proto_export
"IFACE6RD_DELEGATE=0"
62 # Request classless route option (see RFC 3442) by default
63 [ "$classlessroute" = "0" ] || append dhcpopts
"-O 121"
65 proto_export
"INTERFACE=$config"
66 proto_run_command
"$config" udhcpc \
67 -p /var
/run
/udhcpc-
$iface.pid \
68 -s /lib
/netifd
/dhcp.
script \
70 ${ipaddr:+-r ${ipaddr/\/*/}} \
71 ${hostname:+-x "hostname:$hostname"} \
72 ${vendorid:+-V "$vendorid"} \
73 $clientid $defaultreqopts $broadcast $norelease $dhcpopts
78 # SIGUSR1 forces udhcpc to renew its lease
79 local sigusr1
="$(kill -l SIGUSR1)"
80 [ -n "$sigusr1" ] && proto_kill_command
"$interface" $sigusr1
83 proto_dhcp_teardown
() {
85 proto_kill_command
"$interface"