mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-01-27 19:39:34 +00:00
global-functions: $NetMask6: use shift operator...
... and drop the workaround. This requires RouterOS 7.22beta3.
This commit is contained in:
parent
4c388903cb
commit
e27bfbdfe5
1 changed files with 2 additions and 24 deletions
|
|
@ -1014,31 +1014,9 @@
|
||||||
|
|
||||||
# return an IPv6 netmask for CIDR
|
# return an IPv6 netmask for CIDR
|
||||||
:set NetMask6 do={
|
:set NetMask6 do={
|
||||||
:local CIDR [ :tostr $1 ];
|
:local CIDR [ :tonum $1 ];
|
||||||
|
|
||||||
:global IfThenElse;
|
:return (((~::) << (128 - $CIDR)) & (~::));
|
||||||
:global MAX;
|
|
||||||
:global MIN;
|
|
||||||
|
|
||||||
:global NetMask6Cache;
|
|
||||||
|
|
||||||
:if ([ :typeof ($NetMask6Cache->$CIDR) ] = "ip6") do={
|
|
||||||
:return ($NetMask6Cache->$CIDR);
|
|
||||||
}
|
|
||||||
|
|
||||||
:if ([ :typeof $NetMask6Cache ] = "nothing") do={
|
|
||||||
:set NetMask6Cache ({});
|
|
||||||
}
|
|
||||||
|
|
||||||
: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) ":" ]);
|
|
||||||
}
|
|
||||||
:set Mask [ :toip6 $Mask ];
|
|
||||||
:set ($NetMask6Cache->$CIDR) $Mask;
|
|
||||||
:return $Mask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# prepare NotificationFunctions array
|
# prepare NotificationFunctions array
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue