summaryrefslogtreecommitdiff
path: root/src/caches/shibari_whitelist_ip6_match.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/caches/shibari_whitelist_ip6_match.c')
-rw-r--r--src/caches/shibari_whitelist_ip6_match.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/caches/shibari_whitelist_ip6_match.c b/src/caches/shibari_whitelist_ip6_match.c
new file mode 100644
index 0000000..c728081
--- /dev/null
+++ b/src/caches/shibari_whitelist_ip6_match.c
@@ -0,0 +1,16 @@
+/* ISC license. */
+
+#include <stdint.h>
+
+#include <skalibs/uint64.h>
+
+#include "shibari-internal.h"
+
+int shibari_whitelist_ip6_match (shibari_ip6_t const *s, size_t len, char const *ip)
+{
+ uint64_t addr0, addr1 ;
+ uint64_unpack_big(ip, &addr0) ;
+ uint64_unpack_big(ip + 8, &addr1) ;
+ for (; len-- ; s++) if ((addr0 & s->mask0) == s->addr0 && (addr1 & s->mask1) == s->addr1) return 1 ;
+ return 0 ;
+}