X-Git-Url: https://git.archive.openwrt.org/?p=openwrt.git;a=blobdiff_plain;f=package%2Fnetwork%2Fconfig%2Fnetifd%2Ffiles%2Flib%2Fnetifd%2Fproto%2Fdhcp.sh;h=0e88af9e96ad85e7c51ff0b497ce71342d2d1568;hp=a270c681d78edab9a907ff7a7f4a1e84a9f3dcdf;hb=4bc459a8452c309ba6eeb5df7e8f441bb52df793;hpb=a1e89c2ef68e5182a61afa95bce22282332598b6;ds=sidebyside diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh index a270c681d7..0e88af9e96 100755 --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh @@ -5,31 +5,48 @@ init_proto "$@" proto_dhcp_init_config() { - proto_config_add_string "ipaddr" - proto_config_add_string "netmask" - proto_config_add_string "hostname" - proto_config_add_string "clientid" - proto_config_add_string "vendorid" - proto_config_add_boolean "broadcast" - proto_config_add_string "reqopts" - proto_config_add_string "iface6rd" + renew_handler=1 + + proto_config_add_string 'ipaddr:ipaddr' + proto_config_add_string 'hostname:hostname' + proto_config_add_string clientid + proto_config_add_string vendorid + proto_config_add_boolean 'broadcast:bool' + proto_config_add_string 'reqopts:list(string)' + proto_config_add_string iface6rd + proto_config_add_string sendopts + proto_config_add_boolean delegate + proto_config_add_string zone6rd + proto_config_add_string zone + proto_config_add_string mtu6rd + proto_config_add_string customroutes } proto_dhcp_setup() { local config="$1" local iface="$2" - local ipaddr hostname clientid vendorid broadcast reqopts iface6rd - json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd + local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes + json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes local opt dhcpopts for opt in $reqopts; do append dhcpopts "-O $opt" done + for opt in $sendopts; do + append dhcpopts "-x $opt" + done + [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C" [ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd" + [ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212" + [ -n "$zone6rd" ] && proto_export "ZONE6RD=$zone6rd" + [ -n "$zone" ] && proto_export "ZONE=$zone" + [ -n "$mtu6rd" ] && proto_export "MTU6RD=$mtu6rd" + [ -n "$customroutes" ] && proto_export "CUSTOMROUTES=$customroutes" + [ "$delegate" = "0" ] && proto_export "IFACE6RD_DELEGATE=0" proto_export "INTERFACE=$config" proto_run_command "$config" udhcpc \ @@ -42,10 +59,16 @@ proto_dhcp_setup() { $clientid $broadcast $dhcpopts } +proto_dhcp_renew() { + local interface="$1" + # SIGUSR1 forces udhcpc to renew its lease + local sigusr1="$(kill -l SIGUSR1)" + [ -n "$sigusr1" ] && proto_kill_command "$interface" $sigusr1 +} + proto_dhcp_teardown() { local interface="$1" proto_kill_command "$interface" } add_protocol dhcp -