diff options
| author | Leon M. Busch-George <leon@georgemail.eu> | 2023-06-16 14:56:39 +0200 |
|---|---|---|
| committer | Leon M. Busch-George <leon@georgemail.eu> | 2023-09-25 15:02:49 +0200 |
| commit | 9b2f8a33b6b247d4232d48a1d18aea3769590083 (patch) | |
| tree | 1d3a3ded1de21f5f934ef1f7962c5d5e8ba8fccd | |
| parent | 9e8bbd4265271612732c0804065ce8bf4939e8c0 (diff) | |
| download | upstream-9b2f8a33b6b247d4232d48a1d18aea3769590083.tar.gz upstream-9b2f8a33b6b247d4232d48a1d18aea3769590083.tar.bz2 upstream-9b2f8a33b6b247d4232d48a1d18aea3769590083.zip | |
base-files: ipcalc.sh: correctly set limit for prefix > 30
For /31 and /32 prefixes, there are only host addresses - no network and
broadcast address with all-zero and all-one bits.
Reflect this when setting the limit.
Signed-off-by: Leon M. Busch-George <leon@georgemail.eu>
| -rwxr-xr-x | package/base-files/files/bin/ipcalc.sh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh index 21f84bcaf2e..c852b5163f4 100755 --- a/package/base-files/files/bin/ipcalc.sh +++ b/package/base-files/files/bin/ipcalc.sh @@ -64,13 +64,21 @@ BEGIN { if (ARGC <= 3) exit(0) + if (prefix<=30) + limit=network+1 + else + limit=network + start=or(network,and(ip2int(ARGV[3]),compl32(netmask))) - limit=network+1 if (start<limit) start=limit if (start==ipaddr) start=ipaddr+1 + if (prefix<=30) + limit=or(network,compl32(netmask))-1 + else + limit=or(network,compl32(netmask)) + end=start+ARGV[4]-1 - limit=or(network,compl32(netmask))-1 if (end>limit) end=limit if (end==ipaddr) end=ipaddr-1 |
