mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-12-07 02:19:29 +00:00
mod/ipcalc: use $NetMask4
This commit is contained in:
parent
def540c965
commit
9fa11cb79a
1 changed files with 4 additions and 1 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue