From 92d5c03ef86fbd21a84d9425c456f01e6c513817 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 30 Jul 2024 13:12:52 +0000 Subject: Fix small bugs, add autodelegation for IOPAUSE_EXCEPT Signed-off-by: Laurent Bercot --- src/libstddjb/ip4_netmask.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/libstddjb/ip4_netmask.c (limited to 'src/libstddjb/ip4_netmask.c') diff --git a/src/libstddjb/ip4_netmask.c b/src/libstddjb/ip4_netmask.c new file mode 100644 index 0000000..19f485f --- /dev/null +++ b/src/libstddjb/ip4_netmask.c @@ -0,0 +1,14 @@ +/* ISC license. */ + +#include +#include + +int ip4_netmask (char *ip, uint8_t netmask) +{ + uint32_t u ; + if (netmask > 32) return 0 ; + uint32_unpack_big(ip, &u) ; + u &= netmask ? ~((1u << 32 - netmask) - 1) : 0 ; + uint32_pack_big(ip, u) ; + return 1 ; +} -- cgit v1.2.3