netifd: Add renew handler for proto dhcp
[openwrt/openwrt.git] / package / network / config / netifd / files / lib / netifd / proto / dhcp.sh
index 93f4a5e09a5cf0b9fe4be98811ff519a69325c80..2e58c19c44ec1af7b0270d459564d5f7d05046d3 100755 (executable)
@@ -5,12 +5,13 @@
 init_proto "$@"
 
 proto_dhcp_init_config() {
+       renew_handler=1
+
        proto_config_add_string 'ipaddr:ipaddr'
-       proto_config_add_string 'netmask:ipaddr'
        proto_config_add_string 'hostname:hostname'
        proto_config_add_string clientid
        proto_config_add_string vendorid
-       proto_config_add_boolean 'broadcast:ipaddr'
+       proto_config_add_boolean 'broadcast:bool'
        proto_config_add_string 'reqopts:list(string)'
        proto_config_add_string iface6rd
        proto_config_add_string sendopts
@@ -52,6 +53,13 @@ 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"