global-functions: $NetMask6: use shift operator...

... and drop the workaround. This requires RouterOS 7.22beta3.
This commit is contained in:
Christian Hesse 2026-01-21 07:35:32 +01:00
parent 4c388903cb
commit e27bfbdfe5

View file

@ -1014,31 +1014,9 @@
# return an IPv6 netmask for CIDR
:set NetMask6 do={
:local CIDR [ :tostr $1 ];
:local CIDR [ :tonum $1 ];
:global IfThenElse;
: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;
:return (((~::) << (128 - $CIDR)) & (~::));
}
# prepare NotificationFunctions array