summaryrefslogtreecommitdiff
path: root/src/caches/shibari_whitelist_ip4_match.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-01-27 15:46:06 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-01-27 15:46:06 +0000
commitb5eba018a0a948d7757448d4cd70fe33cb6b71a0 (patch)
tree7a00533384303e4802df1e935d50397decb9395b /src/caches/shibari_whitelist_ip4_match.c
parent7e3beac8435b957a583559d13f7666631719d15f (diff)
downloads6-dns-b5eba018a0a948d7757448d4cd70fe33cb6b71a0.tar.xz
Add shibari, prepare for 2.3.2.0dcache
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 ;
+}