diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-05-28 03:24:56 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-05-28 03:24:56 +0000 |
commit | 8ef9450b37df3b96f3054075ba56b8eb49bb2cfc (patch) | |
tree | 16fcf45fd871c16b23087908f8d2b8366140b9f2 /package/base-files | |
parent | 963a0cd98beabbf748ec766939696f82221af044 (diff) | |
download | mtk-20170518-8ef9450b37df3b96f3054075ba56b8eb49bb2cfc.zip mtk-20170518-8ef9450b37df3b96f3054075ba56b8eb49bb2cfc.tar.gz mtk-20170518-8ef9450b37df3b96f3054075ba56b8eb49bb2cfc.tar.bz2 |
base-files: add network_get_device() to network.sh
SVN-Revision: 31937
Diffstat (limited to 'package/base-files')
-rw-r--r-- | package/base-files/files/lib/functions/network.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 1b42133..159da09 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/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 +} |