1 .
/usr
/share
/libubox
/jshn.sh
8 local __prefix
="${4:-0}"
10 local __tmp
="$(ubus call network.interface."$__iface" status 2>/dev/null)"
12 json_load
"${__tmp:-{}}"
13 json_get_type __tmp
"ipv${__family}_address"
15 if [ "$__tmp" = array
]; then
17 json_select
"ipv${__family}_address"
20 if [ "$__tmp" = object
]; then
23 json_get_var
$__var address
25 [ $__prefix -gt 0 ] && {
26 json_get_var __tmp mask
27 eval "export -- \"$__var=\${$__var}/$__tmp\""
37 network_get_ipaddr
() { __network_ipaddr
"$1" "$2" 4 0; }
38 network_get_ipaddr6
() { __network_ipaddr
"$1" "$2" 6 0; }
40 network_get_subnet
() { __network_ipaddr
"$1" "$2" 4 1; }
41 network_get_subnet6
() { __network_ipaddr
"$1" "$2" 6 1; }
50 local __tmp
="$(ubus call network.interface."$__iface" status 2>/dev/null)"
54 json_load
"${__tmp:-{}}"
56 if json_get_type __tmp route
&& [ "$__tmp" = array
]; then
60 while json_get_type __tmp
"$__idx" && [ "$__tmp" = object
]; do
62 json_select
"$((__idx++))"
63 json_get_var __tmp target
64 json_get_var __enabled enabled
66 case "${__enabled}/${__family}/${__tmp}" in
68 json_get_var
"$__var" nexthop
81 network_get_gateway
() { __network_gateway
"$1" "$2" 4; }
82 network_get_gateway6
() { __network_gateway
"$1" "$2" 6; }
90 for __iface
in $
(ubus list |
sed -ne 's/^network\.interface\.//p'); do
91 if __network_gateway
"$__var" "$__iface" "$__family"; then
92 eval "export -- \"$__var=$__iface\""
97 eval "export -- \"$__var=\""
101 network_find_wan
() { __network_wan
"$1" 4; }
102 network_find_wan6
() { __network_wan
"$1" 6; }
111 local __tmp
="$(ubus call network.interface."$__iface" status 2>/dev/null)"
112 [ -n "$__tmp" ] ||
return 1
115 json_get_var
"$__var" "$__field"
121 __network_device __up
"$1" up
&& [ $__up -eq 1 ]
124 network_get_device
() { __network_device
"$1" "$2" l3_device
; }
125 network_get_physdev
() { __network_device
"$1" "$2" device
; }
134 json_add_string name
"$__device"
135 json_add_boolean defer
"$__defer"
137 ubus call network.device set_state
"$(json_dump)" 2>/dev
/null
140 network_defer_device
() { __network_defer
"$1" 1; }
141 network_ready_device
() { __network_defer
"$1" 0; }