2 [ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
5 . /lib/netifd/netifd-proto.sh
7 set_classless_routes() {
9 while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
10 proto_add_ipv4_route "${1%%/*}" "${1##*/}" "$2" "$ip"
17 proto_init_update "*" 1
18 proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}"
19 # TODO: apply $broadcast
22 proto_add_ipv4_route 0.0.0.0 0 "$i" "$ip"
25 # CIDR STATIC ROUTES (rfc3442)
26 [ -n "$staticroutes" ] && set_classless_routes $staticroutes
27 [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes
30 proto_add_dns_server "$dns"
32 for domain in $domain; do
33 proto_add_dns_search "$domain"
37 [ -n "$ZONE" ] && json_add_string zone "$ZONE"
38 [ -n "$ntpsrv" ] && json_add_string ntpserver "$ntpsrv"
39 [ -n "$timesvr" ] && json_add_string timeserver "$timesvr"
40 [ -n "$hostname" ] && json_add_string hostname "$hostname"
41 [ -n "$message" ] && json_add_string message "$message"
42 [ -n "$timezone" ] && json_add_int timezone "$timezone"
43 [ -n "$lease" ] && json_add_int leasetime "$lease"
46 proto_send_update "$INTERFACE"
49 if [ "$IFACE6RD" != 0 -a -n "$ip6rd" ]; then
50 local v4mask="${ip6rd%% *}"
52 local ip6rdprefixlen="${ip6rd%% *}"
54 local ip6rdprefix="${ip6rd%% *}"
56 local ip6rdbr="${ip6rd%% *}"
58 [ -n "$ZONE" ] || ZONE=$(fw3 -q network $INTERFACE)
59 [ -z "$IFACE6RD" -o "$IFACE6RD" = 1 ] && IFACE6RD=${INTERFACE}_6rd
62 json_add_string name "$IFACE6RD"
63 json_add_string ifname "@$INTERFACE"
64 json_add_string proto "6rd"
65 json_add_string peeraddr "$ip6rdbr"
66 json_add_int ip4prefixlen "$v4mask"
67 json_add_string ip6prefix "$ip6rdprefix"
68 json_add_int ip6prefixlen "$ip6rdprefixlen"
69 json_add_string tunlink "$INTERFACE"
70 [ -n "$IFACE6RD_DELEGATE" ] && json_add_boolean delegate "$IFACE6RD_DELEGATE"
71 [ -n "$ZONE6RD" ] || ZONE6RD=$ZONE
72 [ -n "$ZONE6RD" ] && json_add_string zone "$ZONE6RD"
73 [ -n "$MTU6RD" ] && json_add_string mtu "$MTU6RD"
76 ubus call network add_dynamic "$(json_dump)"
80 deconfig_interface() {
81 proto_init_update "*" 0
82 proto_send_update "$INTERFACE"
95 [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user