mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2026-03-03 12:39:35 +00:00
global-functions: $NetMask6: implement simple caching
This commit is contained in:
parent
8f328b4804
commit
7bfdd5a994
1 changed files with 13 additions and 1 deletions
|
|
@ -1008,11 +1008,23 @@
|
||||||
:global MAX;
|
:global MAX;
|
||||||
:global MIN;
|
:global MIN;
|
||||||
|
|
||||||
|
:global NetMask6Cache;
|
||||||
|
|
||||||
|
:if ([ :typeof ($NetMask6Cache->$CIDR) ] = "ip6") do={
|
||||||
|
:return ($NetMask6Cache->$CIDR);
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ([ :typeof $NetMask6Cache ] = "nothing") do={
|
||||||
|
:set NetMask6Cache ({});
|
||||||
|
}
|
||||||
|
|
||||||
:local Mask "";
|
:local Mask "";
|
||||||
:for I from=0 to=7 do={
|
: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 ($Mask . [ :convert from=num to=hex (0xffff - (0xffff >> [ :tonum [ $MIN [ $MAX ($CIDR - ((16 * $I))) 0 ] 16 ] ])) ] . [ $IfThenElse ($I < 7) ":" ]);
|
||||||
}
|
}
|
||||||
:return [ :toip6 $Mask ];
|
: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