summaryrefslogtreecommitdiff
path: root/src/caches/shibari_whitelist_ip4_match.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/caches/shibari_whitelist_ip4_match.c')
-rw-r--r--src/caches/shibari_whitelist_ip4_match.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/caches/shibari_whitelist_ip4_match.c b/src/caches/shibari_whitelist_ip4_match.c
new file mode 100644
index 0000000..fbf11ac
--- /dev/null
+++ b/src/caches/shibari_whitelist_ip4_match.c
@@ -0,0 +1,15 @@
+/* ISC license. */
+
+#include <stdint.h>
+
+#include <skalibs/uint32.h>
+
+#include "shibari-internal.h"
+
+int shibari_whitelist_ip4_match (diuint32 const *s, size_t len, char const *ip)
+{
+ uint32_t ip4 ;
+ uint32_unpack_big(ip, &ip4) ;
+ for (; len-- ; s++) if ((ip4 & s->right) == s->left) return 1 ;
+ return 0 ;
+}