Skip to content
Snippets Groups Projects
Commit 68f0766e authored by cyrus's avatar cyrus
Browse files

base-files: add network_get_ipaddrs_all()


Return all IPv4 and IPv6 addresses.

Signed-off-by: default avatarMathias Kresin <openwrt@kresin.me>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@42856 3c298f89-4303-0410-b956-a3cf2f4a3e73
parent 9490b617
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,29 @@ network_get_ipaddrs6() {
return 1
}
# determine all IP addresses of given logical interface
# 1: destination variable
# 2: interface
network_get_ipaddrs_all() {
local __addr
local __list=""
if __network_ifstatus "__addr" "$2" "['ipv4-address','ipv6-address','ipv6-prefix-assignment'][*].address"; then
for __addr in $__addr; do
case "$__addr" in
*:) __list="${__list:+$__list }${__addr}1" ;;
*) __list="${__list:+$__list }${__addr}" ;;
esac
done
export "$1=$__list"
return 0
fi
unset "$1"
return 1
}
# determine all IPv4 subnets of given logical interface
# 1: destination variable
# 2: interface
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment