aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-06-29 19:04:11 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-06-29 19:04:11 +0000
commit477607f2e14d11f7afd1616ef508e68a3af35ef3 (patch)
tree8759923b5b2ecb1574e4431308dd53e4211b4b6a /package/base-files
parentc22330770e70477cc25dcf0684e5be8dfc5d2432 (diff)
downloadupstream-477607f2e14d11f7afd1616ef508e68a3af35ef3.tar.gz
upstream-477607f2e14d11f7afd1616ef508e68a3af35ef3.tar.bz2
upstream-477607f2e14d11f7afd1616ef508e68a3af35ef3.zip
[package] base-files: implement network_get_dnsserver() and network_get_dnssearch() in /lib/functions/network.sh
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32531 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files')
-rw-r--r--package/base-files/files/lib/functions/network.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh
index c6b98e6e1c..d2d4aae0d9 100644
--- a/package/base-files/files/lib/functions/network.sh
+++ b/package/base-files/files/lib/functions/network.sh
@@ -82,6 +82,37 @@ network_get_gateway() { __network_gateway "$1" "$2" 4; }
network_get_gateway6() { __network_gateway "$1" "$2" 6; }
+__network_dns() {
+ local __var="$1"
+ local __iface="$2"
+ local __field="$3"
+
+ local __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)"
+ local __dns=""
+ local __idx=1
+
+ json_load "${__tmp:-{}}"
+
+ if json_get_type __tmp "$__field" && [ "$__tmp" = array ]; then
+
+ json_select "$__field"
+
+ while json_get_type __tmp "$__idx" && [ "$__tmp" = string ]; do
+
+ json_get_var __tmp "$((__idx++))"
+ __dns="${__dns:+$__dns }$__tmp"
+
+ done
+ fi
+
+ eval "export -- \"$__var=$__dns\""
+ [ -n "$__dns" ]
+}
+
+network_get_dnsserver() { __network_dns "$1" "$2" dns_server; }
+network_get_dnssearch() { __network_dns "$1" "$2" dns_search; }
+
+
__network_wan() {
local __var="$1"
local __family="$2"