+
+ # 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 ".."
+
+ done
+
+ json_select ".."
+
+ fi
+
+ # parse dns info
+ local __field
+ for __field in "dns_server" "dns_search"; do
+ if json_is_a "$__field" array; then
+
+ json_select "$__field"
+
+ local __idx=1
+ local __dns=""
+
+ while json_is_a "$__idx" string; do
+
+ json_get_var __tmp "$((__idx++))"
+ __dns="${__dns:+$__dns }$__tmp"
+
+ done
+
+ json_select ".."
+
+ if [ -n "$__dns" ]; then
+ __network_set_cache "${__key}_${__field}" "" "$__dns"
+ fi
+ fi
+ done
+
+ # parse up state, device and physdev
+ for __field in "up" "l3_device" "device"; do
+ if json_get_type __tmp "$__field"; then
+ __network_set_cache "${__key}_${__field}" "$__field"
+ fi
+ done
+
+ # descend into inactive table
+ json_is_a "inactive" object && json_select "inactive"
+
+ done
+
+ json_cleanup
+ json_set_namespace "$__old_ns"
+
+ return 0
+}
+
+
+__network_ipaddr()
+{
+ local __var="$1"
+ local __iface="$2"
+ local __family="$3"
+ local __prefix="$4"
+ local __tmp
+
+ __network_parse_ifstatus "$__iface" || return 1
+
+ if [ $__prefix -eq 1 ]; then
+ __network_export __tmp "${__iface}_mask${__family}" && \
+ __network_export "$__var" "${__iface}_address${__family}" "/$__tmp"
+ return $?