mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-03-03 04:29:37 +00:00
global-functions: introduce $NetMask6
This commit is contained in:
parent
47309e5c03
commit
8f328b4804
1 changed files with 17 additions and 0 deletions
|
|
@ -62,6 +62,7 @@
|
|||
:global MIN;
|
||||
:global MkDir;
|
||||
:global NetMask4;
|
||||
:global NetMask6;
|
||||
:global NotificationFunctions;
|
||||
:global ParseDate;
|
||||
:global ParseKeyValueStore;
|
||||
|
|
@ -998,6 +999,22 @@
|
|||
:return ((255.255.255.255 << (32 - $CIDR)) & 255.255.255.255);
|
||||
}
|
||||
|
||||
# return an IPv6 netmask for CIDR
|
||||
:set NetMask6 do={
|
||||
:local FuncName $0;
|
||||
:local CIDR [ :tostr $1 ];
|
||||
|
||||
:global IfThenElse;
|
||||
:global MAX;
|
||||
:global MIN;
|
||||
|
||||
:local Mask "";
|
||||
:for I from=0 to=7 do={
|
||||
:set Mask ($Mask . [ :convert from=num to=hex (0xffff - (0xffff >> [ :tonum [ $MIN [ $MAX ($CIDR - ((16 * $I))) 0 ] 16 ] ])) ] . [ $IfThenElse ($I < 7) ":" ]);
|
||||
}
|
||||
:return [ :toip6 $Mask ];
|
||||
}
|
||||
|
||||
# prepare NotificationFunctions array
|
||||
:if ([ :typeof $NotificationFunctions ] != "array") do={
|
||||
:set NotificationFunctions ({});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue