From def540c965c40c28cce5ceef00e25132f5ab2d3f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Thu, 16 Oct 2025 10:26:50 +0200 Subject: [PATCH] global-functions: introduce $NetMask4 --- global-functions.rsc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/global-functions.rsc b/global-functions.rsc index 55b5292..5c98a20 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -61,6 +61,7 @@ :global MAX; :global MIN; :global MkDir; +:global NetMask4; :global NotificationFunctions; :global ParseDate; :global ParseKeyValueStore; @@ -990,6 +991,13 @@ :return true; } +# return an IPv4 netmask for CIDR +:set NetMask4 do={ + :local CIDR [ :tonum $1 ]; + + :return ((255.255.255.255 << (32 - $CIDR)) & 255.255.255.255); +} + # prepare NotificationFunctions array :if ([ :typeof $NotificationFunctions ] != "array") do={ :set NotificationFunctions ({});