Restructure project and organize code.
This commit is contained in:
15
src/xdp/utils/helpers.c
Normal file
15
src/xdp/utils/helpers.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <xdp/utils/helpers.h>
|
||||
|
||||
/**
|
||||
* Checks if an IP is within a specific CIDR range.
|
||||
*
|
||||
* @param src_ip The source/main IP to check against.
|
||||
* @param net_ip The network IP.
|
||||
* @param cidr The CIDR range.
|
||||
*
|
||||
* @return 1 on yes, 0 on no.
|
||||
*/
|
||||
static __always_inline u8 IsIpInRange(u32 src_ip, u32 net_ip, u8 cidr)
|
||||
{
|
||||
return !((src_ip ^ net_ip) & htonl(0xFFFFFFFFu << (32 - cidr)));
|
||||
}
|
||||
Reference in New Issue
Block a user