aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'sysconfig/network-scripts')
-rw-r--r--sysconfig/network-scripts/network-functions-ipv696
1 files changed, 5 insertions, 91 deletions
diff --git a/sysconfig/network-scripts/network-functions-ipv6 b/sysconfig/network-scripts/network-functions-ipv6
index facc0171..1bf230b7 100644
--- a/sysconfig/network-scripts/network-functions-ipv6
+++ b/sysconfig/network-scripts/network-functions-ipv6
@@ -691,103 +691,17 @@ ipv6_del_addr_on_device() {
## Test a given IPv6 address for validity
# $1: <IPv6 address>
-# $2: [quiet] : (optional) don't display error message
-# return code: 0=ok 1=argument error 10=not valid
+# return code: 0=ok 1=not valid
ipv6_test_ipv6_addr_valid() {
- local fn="ipv6_test_ipv6_addr_valid"
-
- local testipv6addr_valid=$1
- local modequiet=$2
-
- if [ -z "$testipv6addr_valid" ]; then
- return 1
- fi
- if [ -n "$modequiet" ]; then
- if [ "$modequiet" != "quiet" ]; then
- ipv6_log $"Parameter '$modequiet' for 'quiet' mode is not valid (arg 2)" err $fn
- return 1
- fi
- fi
-
- # Extract parts
- local prefixlength_implicit="`echo $testipv6addr_valid | awk -F/ '{ print $2 }'`"
- local address_implicit="`echo $testipv6addr_valid | awk -F/ '{ print $1 }'`"
-
- # Test for a valid format
- if ! echo "$address_implicit" | LC_ALL=C egrep -q '^[[:xdigit:]:.]*$'; then
- if [ "$modequiet" != "quiet" ]; then
- ipv6_log $"Given IPv6 address '$testipv6addr_valid' is not valid" err $fn
- fi
- return 10
- fi
-
- # Test for prefix length
- if [ -z "$prefixlength_implicit" ]; then
- if echo "$testipv6addr_valid" | LC_ALL=C grep "/$"; then
- # Trailing "/", but no value
- if [ "$modequiet" != "quiet" ]; then
- ipv6_log $"Missing prefix length for given address '$testipv6addr_valid'" err $fn
- fi
- return 10
- else
- return 0
- fi
- elif [ $prefixlength_implicit -lt 0 -o $prefixlength_implicit -gt 128 ]; then
- if [ "$modequiet" != "quiet" ]; then
- ipv6_log $"On given address '$testipv6addr_valid' the prefix length is out of range (valid: 0-128)" err $fn
- fi
- return 10
- fi
-
- return 0
+ ipcalc -cs6 $1
}
## Test a given IPv4 address for validity
# $1: <IPv4 address>
-# $2: [quiet] : (optional) don't display error message
-# return code: 0=ok 1=argument error 10=not valid
+# return code: 0=ok 1=not valid
ipv6_test_ipv4_addr_valid() {
- local fn="ipv6_test_ipv4_addr_valid"
-
- local testipv4addr_valid=$1
- local modequiet=$2
-
- if [ -z "$testipv4addr_valid" ]; then
- return 1
- fi
- if [ -n "$modequiet" ]; then
- if [ "$modequiet" != "quiet" ]; then
- ipv6_log $"Parameter '$modequiet' for 'quiet' mode is not valid (arg 2)" err $fn
- return 1
- fi
- fi
-
- # Test for a valid format
- if echo "$testipv4addr_valid" | LC_ALL=C egrep -q -v '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'; then
- if [ "$modequiet" != "quiet" ]; then
- ipv6_log $"Given IPv4 address '$testipv4addr_valid' has no proper format" err $fn
- fi
- return 10
- fi
-
- # Test for valid IPv4 address parts
- local number1="`echo $testipv4addr_valid | awk -F. '{ print $1 }'`"
- local number2="`echo $testipv4addr_valid | awk -F. '{ print $2 }'`"
- local number3="`echo $testipv4addr_valid | awk -F. '{ print $3 }'`"
- local number4="`echo $testipv4addr_valid | awk -F. '{ print $4 }'`"
- local c=1
- for number in "$number1" "$number2" "$number3" "$number4"; do
- if [ $number -lt 0 -o $number -gt 255 ]; then
- if [ "$modequiet" != "quiet" ]; then
- ipv6_log $"Part $c of given IPv4 address '$testipv4addr_valid' is out of range" err $fn
- fi
- return 10
- fi
- local c=$[ $c + 1 ]
- done
-
- return 0
+ ipcalc -cs4 $1
}
@@ -909,7 +823,7 @@ ipv6_create_6to4_relay_address() {
fi
# Check
- if ipv6_test_ipv4_addr_valid $addr quiet; then
+ if ipv6_test_ipv4_addr_valid $addr ; then
# ok, a IPv4 one
if ipv6_test_ipv4_addr_global_usable $addr; then
# IPv4 globally usable