]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
addrfilt: remove TEST code
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 5 Feb 2016 10:10:44 +0000 (11:10 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 5 Feb 2016 14:20:40 +0000 (15:20 +0100)
A test of the address filter is now included in unit tests.

addrfilt.c

index 8ed15749fd86a8f9e8c1a7bd12f1b926701165e2..dd1670035194ecd10f2ec5885eecd1855f1e2cf2 100644 (file)
@@ -401,117 +401,3 @@ ADF_IsAnyAllowed(ADF_AuthTable table, int family)
       return 0;
   }
 }
-
-/* ================================================== */
-
-#if defined TEST
-
-static void print_node(TableNode *node, uint32_t *addr, int ip_len, int shift, int subnet_bits)
-{
-  uint32_t new_addr[4];
-  int i;
-  TableNode *sub_node;
-
-  for (i=0; i<subnet_bits; i++) putchar(' ');
-
-  if (ip_len == 1)
-      printf("%d.%d.%d.%d",
-          ((addr[0] >> 24) & 255),
-          ((addr[0] >> 16) & 255),
-          ((addr[0] >>  8) & 255),
-          ((addr[0]      ) & 255));
-  else {
-    for (i=0; i<4; i++) {
-      if (addr[i])
-        printf("%d.%d.%d.%d",
-            ((addr[i] >> 24) & 255),
-            ((addr[i] >> 16) & 255),
-            ((addr[i] >>  8) & 255),
-            ((addr[i]      ) & 255));
-      putchar(i < 3 ? ':' : '\0');
-    }
-  }
-  printf("/%d : %s\n",
-         subnet_bits,
-         (node->state == ALLOW) ? "allow" :
-         (node->state == DENY)  ? "deny" : "as parent");
-  if (node->extended) {
-    for (i=0; i<16; i++) {
-      sub_node = &(node->extended[i]);
-      new_addr[0] = addr[0];
-      new_addr[1] = addr[1];
-      new_addr[2] = addr[2];
-      new_addr[3] = addr[3];
-      new_addr[ip_len - 1 - shift / 32] |= ((uint32_t)i << (shift % 32));
-      print_node(sub_node, new_addr, ip_len, shift - 4, subnet_bits + 4);
-    }
-  }
-}
-
-
-static void print_table(ADF_AuthTable table)
-{
-  uint32_t addr[4];
-
-  memset(addr, 0, sizeof (addr));
-  printf("IPv4 table:\n");
-  print_node(&table->base4, addr, 1, 28, 0);
-
-  memset(addr, 0, sizeof (addr));
-  printf("IPv6 table:\n");
-  print_node(&table->base6, addr, 4, 124, 0);
-}
-
-/* ================================================== */
-
-int main (int argc, char **argv)
-{
-  IPAddr ip;
-  ADF_AuthTable table;
-  table = ADF_CreateTable();
-
-  ip.family = IPADDR_INET4;
-
-  ip.addr.in4 = 0x7e800000;
-  ADF_Allow(table, &ip, 9);
-  ip.addr.in4 = 0x7ecc0000;
-  ADF_Deny(table, &ip, 14);
-#if 0
-  ip.addr.in4 = 0x7f000001;
-  ADF_Deny(table, &ip, 32);
-  ip.addr.in4 = 0x7f000000;
-  ADF_Allow(table, &ip, 8);
-#endif
-
-  printf("allowed: %d\n", ADF_IsAllowed(table, &ip));
-  ip.addr.in4 ^= 1;
-  printf("allowed: %d\n", ADF_IsAllowed(table, &ip));
-
-  ip.family = IPADDR_INET6;
-
-  memcpy(ip.addr.in6, "abcdefghijklmnop", 16);
-  ADF_Deny(table, &ip, 66);
-  ADF_Allow(table, &ip, 59);
-
-  memcpy(ip.addr.in6, "xbcdefghijklmnop", 16);
-  ADF_Deny(table, &ip, 128);
-  ip.addr.in6[15] ^= 3;
-  ADF_Allow(table, &ip, 127);
-
-  printf("allowed: %d\n", ADF_IsAllowed(table, &ip));
-  ip.addr.in4 ^= 1;
-  printf("allowed: %d\n", ADF_IsAllowed(table, &ip));
-
-  print_table(table);
-
-  ADF_DestroyTable(table);
-  return 0;
-}
-
-
-
-#endif /* defined TEST */
-
-
-
-