X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=package%2Fnetwork%2Fconfig%2Fnetifd%2Ffiles%2Flib%2Fnetifd%2Fproto%2Fdhcp.sh;h=143e4451b6648ac2048b782989f7bb1c50f800d8;hb=abdf0dea3ab6470b596096635a60fbe2e8d0dfff;hp=38308785df5b30e16399e687253875b8a81b79c5;hpb=611b2e8bb38a4d9b4a85e8766d38c4eb1b93df25;p=openwrt%2Fstaging%2Fchunkeey.git 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 38308785df..143e4451b6 100755 --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh @@ -5,29 +5,54 @@ 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" + 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_boolean 'release: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_config_add_boolean classlessroute } proto_dhcp_setup() { local config="$1" local iface="$2" - local ipaddr hostname clientid vendorid broadcast reqopts - json_get_vars ipaddr hostname clientid vendorid broadcast reqopts + local ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute + json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute local opt dhcpopts for opt in $reqopts; do append dhcpopts "-O $opt" done + for opt in $sendopts; do + append dhcpopts "-x $opt" + done + + [ -z "$hostname" ] && hostname="$(cat /proc/sys/kernel/hostname)" [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= + [ "$release" = 1 ] && release="-R" || release= [ -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" + # Request classless route option (see RFC 3442) by default + [ "$classlessroute" = "0" ] || append dhcpopts "-O 121" proto_export "INTERFACE=$config" proto_run_command "$config" udhcpc \ @@ -35,9 +60,16 @@ proto_dhcp_setup() { -s /lib/netifd/dhcp.script \ -f -t 0 -i "$iface" \ ${ipaddr:+-r $ipaddr} \ - ${hostname:+-H $hostname} \ - ${vendorid:+-V $vendorid} \ - $clientid $broadcast $dhcpopts + ${hostname:+-x "hostname:$hostname"} \ + ${vendorid:+-V "$vendorid"} \ + $clientid $broadcast $release $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() { @@ -46,4 +78,3 @@ proto_dhcp_teardown() { } add_protocol dhcp -