summaryrefslogtreecommitdiff
path: root/src/caches/shibari_whitelist_ip4_match.c
blob: fbf11acacea1e63f87939e6c8e791f11f04ad940 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 ;
}