Hi all, I noticed that fairly recently the ipcalc.sh script here (included in package/base-files) has been re-rewritten by @pprindeville in pure shell. I also noticed that it only implements ipv4 functions. I'm not sure what this script is actually used for in OpenWrt, but in case a similar implementation of ipv6 functionality is needed, I will be happy to contribute my code which implements some rudimentary ipv6 calculation, and should be fairly easy to extend in case more functions are needed. I would be happy to make a PR, but I'll need some context on what is actually needed and the expected API.
1 Like
Well, it does some ip4 conversions
# ipcalc.sh 127.1.1.1/8
IP=127.1.1.1
NETMASK=255.0.0.0
BROADCAST=127.255.255.255
NETWORK=127.0.0.0
PREFIX=8
COUNT=16777216
# ipcalc.sh 127.011/8
Not a dotted quad (127.011) # this is 127.0.0.9
in not a very intelligent ways
Is this valid notation?
Hundred percent valid, mid elements omitted are zeros and last is in octal.