mod/ipcalc: use $NetMask4

This commit is contained in:
Christian Hesse 2025-10-16 10:42:23 +02:00
parent def540c965
commit 9fa11cb79a

View file

@ -34,9 +34,12 @@
# calculate and return netmask, network, min host, max host and broadcast # calculate and return netmask, network, min host, max host and broadcast
:set IPCalcReturn do={ :set IPCalcReturn do={
:local Input [ :tostr $1 ]; :local Input [ :tostr $1 ];
:global NetMask4;
:local Address [ :toip [ :pick $Input 0 [ :find $Input "/" ] ] ]; :local Address [ :toip [ :pick $Input 0 [ :find $Input "/" ] ] ];
:local Bits [ :tonum [ :pick $Input ([ :find $Input "/" ] + 1) [ :len $Input ] ] ]; :local Bits [ :tonum [ :pick $Input ([ :find $Input "/" ] + 1) [ :len $Input ] ] ];
:local Mask ((255.255.255.255 << (32 - $Bits)) & 255.255.255.255); :local Mask [ $NetMask4 $Bits ];
:local Return { :local Return {
"address"=$Address; "address"=$Address;