- local __old_ns
-
- __network_export __tmp "${__key}__parsed" && return 0
- __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
- [ -n "$__tmp" ] || return 1
-
- json_set_namespace "network" __old_ns
- json_load "$__tmp"
-
- __network_set_cache "${__key}__parsed" "" "1"
-
- for __tmp in "" "_inactive"; do
-
- __key="${__key}${__tmp}"
-
- # parse addresses
- local __family
- for __family in 4 6; do
- if json_is_a "ipv${__family}_address" array; then
-
- json_select "ipv${__family}_address"
-
- if json_is_a 1 object; then
-
- json_select 1
- __network_set_cache "${__key}_address${__family}" address
- __network_set_cache "${__key}_mask${__family}" mask
- json_select ".."
-
- fi
-
- json_select ".."
-
- fi
- done
-
- # parse routes
- if json_is_a route array; then
-
- json_select "route"
-
- local __idx=1
- while json_is_a "$__idx" object; do
-
- json_select "$((__idx++))"
- json_get_var __tmp target
-
- case "${__tmp}" in
- 0.0.0.0)
- __network_set_cache "${__key}_gateway4" nexthop
- ;;
- ::)
- __network_set_cache "${__key}_gateway6" nexthop
- ;;
- esac
-
- json_select ".."