summaryrefslogtreecommitdiff
path: root/src/validators/ipv4-range-mask
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-01-11 06:48:06 +0100
committerGitHub <noreply@github.com>2024-01-11 06:48:06 +0100
commitd0145bfc824099cb17ad6dc2cc2f81cace4f430d (patch)
treea439f0baf9a2d2310d72b58688cf0c30ba93f9c5 /src/validators/ipv4-range-mask
parentd0dcbfa475fae4817b0bc4d0718ecf65eae85270 (diff)
parentb588e0784626ca42bf0da84a766213bda725305e (diff)
downloadvyos-1x-d0145bfc824099cb17ad6dc2cc2f81cace4f430d.tar.gz
vyos-1x-d0145bfc824099cb17ad6dc2cc2f81cace4f430d.zip
Merge pull request #2789 from vyos/mergify/bp/sagitta/pr-2777
T5688: Changed 'range' to multi in 'client-ip-pool' for accell-ppp (backport #2777)
Diffstat (limited to 'src/validators/ipv4-range-mask')
-rwxr-xr-xsrc/validators/ipv4-range-mask36
1 files changed, 2 insertions, 34 deletions
diff --git a/src/validators/ipv4-range-mask b/src/validators/ipv4-range-mask
index 7bb4539af..9373328ff 100755
--- a/src/validators/ipv4-range-mask
+++ b/src/validators/ipv4-range-mask
@@ -1,12 +1,5 @@
#!/bin/bash
-# snippet from https://stackoverflow.com/questions/10768160/ip-address-converter
-ip2dec () {
- local a b c d ip=$@
- IFS=. read -r a b c d <<< "$ip"
- printf '%d\n' "$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))"
-}
-
error_exit() {
echo "Error: $1 is not a valid IPv4 address range or these IPs are not under /$2"
exit 1
@@ -22,37 +15,12 @@ do
r) range=${OPTARG}
esac
done
-if [[ "${range}" =~ "-" ]]&&[[ ! -z ${mask} ]]; then
- # This only works with real bash (<<<) - split IP addresses into array with
- # hyphen as delimiter
- readarray -d - -t strarr <<< ${range}
-
- ipaddrcheck --is-ipv4-single ${strarr[0]}
- if [ $? -gt 0 ]; then
- error_exit ${range} ${mask}
- fi
- ipaddrcheck --is-ipv4-single ${strarr[1]}
+if [[ "${range}" =~ "-" ]]&&[[ ! -z ${mask} ]]; then
+ ipaddrcheck --range-prefix-length ${mask} --is-ipv4-range ${range}
if [ $? -gt 0 ]; then
error_exit ${range} ${mask}
fi
-
- ${vyos_validators_dir}/numeric --range 0-32 ${mask} > /dev/null
- if [ $? -ne 0 ]; then
- error_exit ${range} ${mask}
- fi
-
- is_in_24=$( grepcidr ${strarr[0]}"/"${mask} <(echo ${strarr[1]}) )
- if [ -z $is_in_24 ]; then
- error_exit ${range} ${mask}
- fi
-
- start=$(ip2dec ${strarr[0]})
- stop=$(ip2dec ${strarr[1]})
- if [ $start -ge $stop ]; then
- error_exit ${range} ${mask}
- fi
-
exit 0
fi