diff options
author | Steven Barth <steven@midlink.org> | 2013-01-15 13:07:51 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2013-01-15 13:07:51 +0000 |
commit | b04bf87a8d6669eeb12028952e8fa77c274d2db8 (patch) | |
tree | 11f6277374b2a6d34a02b63b610b1eb99d34e68f /package/base-files/files/lib/functions | |
parent | ddc921275cfdfb10f76ddebd89be4327e94dfc2b (diff) | |
download | upstream-b04bf87a8d6669eeb12028952e8fa77c274d2db8.tar.gz upstream-b04bf87a8d6669eeb12028952e8fa77c274d2db8.tar.bz2 upstream-b04bf87a8d6669eeb12028952e8fa77c274d2db8.zip |
base-files: add support for ipv6-prefixes in connection with netifd
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35168 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files/files/lib/functions')
-rw-r--r-- | package/base-files/files/lib/functions/network.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh index 424965acb5..8f87d1d0be 100644 --- a/package/base-files/files/lib/functions/network.sh +++ b/package/base-files/files/lib/functions/network.sh @@ -57,6 +57,20 @@ __network_parse_ifstatus() fi done + # parse prefixes + if json_is_a "ipv6_prefix" array; then + json_select "ipv6_prefix" + + if json_is_a 1 object; then + json_select 1 + __network_set_cache "${__key}_prefix6_address" address + __network_set_cache "${__key}_prefix6_mask" mask + json_select ".." + fi + + json_select ".." + fi + # parse routes if json_is_a route array; then @@ -170,6 +184,22 @@ network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; } # 2: interface network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; } +# determine IPv6 prefix +network_get_prefix6() { + local __prefix="$1" + local __iface="$2" + local __address + local __mask + + __network_parse_ifstatus "$__iface" || return 1 + __network_export __address "${__iface}_prefix6_address" + local return="$?" + [ "$return" -eq 0 ] || return $? + __network_export __mask "${__iface}_prefix6_mask" + eval "$__prefix=$__address/$__mask" + return 0 +} + __network_gateway() { |