From 29377555bf74dc436af8fd9276acb61f0958bdbd Mon Sep 17 00:00:00 2001 From: jow Date: Tue, 29 May 2012 00:20:16 +0000 Subject: [package] base-files: let network_get_device() return the l3 interface, introduce network_get_physdev() to obtain the underlying iface (if applicable) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31960 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/lib/functions/network.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 159da09a0..e038c94e1 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -41,16 +41,18 @@ network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; } network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; } -network_get_device() +__network_device() { local __var="$1" local __iface="$2" + local __field="$3" local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" [ -n "$__tmp" ] || return 1 json_load "$__tmp" - json_get_var "$__var" device - - return 0 + json_get_var "$__var" "$__field" } + +network_get_device() { __network_device "$1" "$2" l3_device; } +network_get_physdev() { __network_device "$1" "$2" device; } -- cgit v1.2.3