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
21 local ip_net IP PREFIX NETWORK NETMASK BROADCAST
22 ipcalc
"$ip/$mask" && ip_net
="$NETWORK"
27 ipcalc
"$i/$mask" && gw_net
="$NETWORK"
29 [ "$ip_net" != "$gw_net" ] && proto_add_ipv4_route
"$i" 32 "" "$ip"
30 proto_add_ipv4_route
0.0.0.0 0 "$i" "$ip"
33 for r
in $CUSTOMROUTES; do
34 proto_add_ipv4_route
"${r%%/*}" "${r##*/}" "$i" "$ip"
38 # CIDR STATIC ROUTES (rfc3442)
39 [ -n "$staticroutes" ] && set_classless_routes
$staticroutes
40 [ -n "$msstaticroutes" ] && set_classless_routes
$msstaticroutes
43 proto_add_dns_server
"$i"
46 proto_add_dns_search
"$i"
49 # TODO: Deprecate timesvr in favor of timesrv
50 if [ -n "$timesvr" -a -z "$timesrv" ]; then
52 echo "Environment variable 'timesvr' will be deprecated; use 'timesrv' instead."
56 [ -n "$ZONE" ] && json_add_string zone
"$ZONE"
57 [ -n "$ntpsrv" ] && json_add_string ntpserver
"$ntpsrv"
58 [ -n "$timesrv" ] && json_add_string timeserver
"$timesrv"
59 [ -n "$hostname" ] && json_add_string hostname
"$hostname"
60 [ -n "$message" ] && json_add_string message
"$message"
61 [ -n "$timezone" ] && json_add_int timezone
"$timezone"
62 [ -n "$lease" ] && json_add_int leasetime
"$lease"
63 [ -n "$serverid" ] && json_add_string dhcpserver
"$serverid"
66 proto_send_update
"$INTERFACE"
69 if [ "$IFACE6RD" != 0 -a -n "$ip6rd" ]; then
70 local v4mask
="${ip6rd%% *}"
72 local ip6rdprefixlen
="${ip6rd%% *}"
74 local ip6rdprefix
="${ip6rd%% *}"
76 local ip6rdbr
="${ip6rd%% *}"
78 [ -n "$ZONE" ] || ZONE
=$
(fw3
-q network
$INTERFACE 2>/dev
/null
)
79 [ -z "$IFACE6RD" -o "$IFACE6RD" = 1 ] && IFACE6RD
=${INTERFACE}_6
82 json_add_string name
"$IFACE6RD"
83 json_add_string ifname
"@$INTERFACE"
84 json_add_string proto
"6rd"
85 json_add_string peeraddr
"$ip6rdbr"
86 json_add_int ip4prefixlen
"$v4mask"
87 json_add_string ip6prefix
"$ip6rdprefix"
88 json_add_int ip6prefixlen
"$ip6rdprefixlen"
89 json_add_string tunlink
"$INTERFACE"
90 [ -n "$IFACE6RD_DELEGATE" ] && json_add_boolean delegate
"$IFACE6RD_DELEGATE"
91 [ -n "$ZONE6RD" ] || ZONE6RD
=$ZONE
92 [ -n "$ZONE6RD" ] && json_add_string zone
"$ZONE6RD"
93 [ -n "$MTU6RD" ] && json_add_string mtu
"$MTU6RD"
96 ubus call network add_dynamic
"$(json_dump)"
100 deconfig_interface
() {
101 proto_init_update
"*" 0
102 proto_send_update
"$INTERFACE"
115 [ -f /etc
/udhcpc.user
] && .
/etc
/udhcpc.user
"$@"
116 for f
in /etc
/udhcpc.user.d
/*; do
117 [ -f "$f" ] && (.
"$f" "$@")