summaryrefslogtreecommitdiff
path: root/src/caches/shibari_whitelist_add6.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_add6.c
parent7e3beac8435b957a583559d13f7666631719d15f (diff)
downloads6-dns-b5eba018a0a948d7757448d4cd70fe33cb6b71a0.tar.xz
Add shibari, prepare for 2.3.2.0dcache
Diffstat (limited to 'src/caches/shibari_whitelist_add6.c')
-rw-r--r--src/caches/shibari_whitelist_add6.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/caches/shibari_whitelist_add6.c b/src/caches/shibari_whitelist_add6.c
new file mode 100644
index 0000000..0c9e53a
--- /dev/null
+++ b/src/caches/shibari_whitelist_add6.c
@@ -0,0 +1,28 @@
+/* ISC license. */
+
+#include <stdint.h>
+
+#include <skalibs/uint64.h>
+#include <skalibs/genalloc.h>
+
+#include "shibari-internal.h"
+
+int shibari_whitelist_add6 (genalloc *g, char const *ip6, uint16_t mask)
+{
+ shibari_ip6_t shix ;
+ if (mask >= 64)
+ {
+ shix.mask0 = ~(uint64_t)0 ;
+ shix.mask1 = ((uint64_t)1 << (mask - 64)) - 1 ;
+ }
+ else
+ {
+ shix.mask0 = ((uint64_t)1 << mask) - 1 ;
+ shix.mask1 = 0 ;
+ }
+ uint64_unpack_big(ip6, &shix.addr0) ;
+ shix.addr0 &= shix.mask0 ;
+ uint64_unpack_big(ip6 + 8, &shix.addr1) ;
+ shix.addr1 &= shix.mask1 ;
+ return genalloc_append(shibari_ip6_t, g, &shix) ;
+}