From e27bfbdfe587cc20a86b54e093163fbf210ed1d9 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 21 Jan 2026 07:35:32 +0100 Subject: [PATCH] global-functions: $NetMask6: use shift operator... ... and drop the workaround. This requires RouterOS 7.22beta3. --- global-functions.rsc | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/global-functions.rsc b/global-functions.rsc index 22579f90..e6638154 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -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