Browse Source

base-files: add network_get_device() to network.sh

SVN-Revision: 31937
Jo-Philipp Wich 13 years ago
parent
commit
8ef9450b37
1 changed files with 15 additions and 0 deletions
  1. 15 0
      package/base-files/files/lib/functions/network.sh

+ 15 - 0
package/base-files/files/lib/functions/network.sh

@@ -39,3 +39,18 @@ network_get_ipaddr6() { __network_ipaddr "$1" "$2" 6 0; }
 
 network_get_subnet()  { __network_ipaddr "$1" "$2" 4 1; }
 network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; }
+
+
+network_get_device()
+{
+	local __var="$1"
+	local __iface="$2"
+
+	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
+}