-82.130.64.0/18 MATCH
-86.119.0.0/16 MATCH
-89.206.64.0/18 MATCH
-128.178.0.0/15 MATCH
-129.129.0.0/16 MATCH
-129.132.0.0/16 MATCH
-129.194.0.0/15 MATCH
-130.59.0.0/16 MATCH
-130.60.0.0/16 MATCH
-130.82.0.0/16 MATCH
-130.92.0.0/16 MATCH
-130.125.0.0/16 MATCH
-130.223.0.0/16 MATCH
-131.152.0.0/16 MATCH
-134.21.0.0/16 MATCH
-138.131.0.0/16 MATCH
-141.249.0.0/16 MATCH
-144.200.0.0/16 MATCH
-146.136.0.0/16 MATCH
-147.86.0.0/16 MATCH
-147.87.0.0/16 MATCH
-147.88.0.0/16 MATCH
-148.187.0.0/16 MATCH
-148.196.0.0/16 MATCH
-152.88.0.0/16 MATCH
-152.96.0.0/16 MATCH
-153.109.0.0/16 MATCH
-155.105.0.0/16 MATCH
-155.228.0.0/16 MATCH
-156.25.0.0/16 MATCH
-156.135.0.0/21 MATCH
-156.135.12.0/22 MATCH
-156.135.16.0/21 MATCH
-156.135.28.0/22 MATCH
-156.135.32.0/19 MATCH
-156.135.64.0/18 MATCH
-156.135.128.0/17 MATCH
-157.26.0.0/16 MATCH
-160.85.0.0/16 MATCH
-160.98.0.0/16 MATCH
-161.62.0.0/16 MATCH
-185.51.68.0/22 MATCH
-185.133.44.0/22 MATCH
-185.144.36.0/22 MATCH
-185.194.180.0/22 MATCH
-185.225.92.0/22 MATCH
-192.12.247.0/24 MATCH
-192.26.28.0/22 MATCH
-192.26.32.0/21 MATCH
-192.26.40.0/22 MATCH
-192.26.44.0/24 MATCH
-192.26.46.0/23 MATCH
-192.33.87.0/24 MATCH
-192.33.88.0/21 MATCH
-192.33.96.0/21 MATCH
-192.33.104.0/22 MATCH
-192.33.108.0/23 MATCH
-192.33.110.0/24 MATCH
-192.33.118.0/23 MATCH
-192.33.120.0/21 MATCH
-192.33.192.0/19 MATCH
-192.33.224.0/21 MATCH
-192.41.132.0/22 MATCH
-192.41.136.0/24 MATCH
-192.41.149.0/24 MATCH
-192.41.150.0/23 MATCH
-192.41.152.0/21 MATCH
-192.41.160.0/24 MATCH
-192.42.42.0/23 MATCH
-192.42.44.0/22 MATCH
-192.42.180.0/22 MATCH
-192.42.184.0/21 MATCH
-192.42.192.0/21 MATCH
-192.42.200.0/23 MATCH
-192.43.192.0/22 MATCH
-192.43.196.0/24 MATCH
-192.47.244.0/22 MATCH
-192.47.248.0/23 MATCH
-192.65.92.0/23 MATCH
-192.101.176.0/24 MATCH
-192.135.150.0/23 MATCH
-192.135.151.0/24 MATCH
-192.135.152.0/21 MATCH
-192.152.98.0/24 MATCH
-193.5.22.0/24 MATCH
-193.5.26.0/23 MATCH
-193.5.54.0/23 MATCH
-193.5.58.0/24 MATCH
-193.5.60.0/24 MATCH
-193.5.80.0/21 MATCH
-193.5.152.0/22 MATCH
-193.5.168.0/22 MATCH
-193.5.180.0/24 MATCH
-193.5.182.0/24 MATCH
-193.5.186.0/24 MATCH
-193.5.188.0/24 MATCH
-193.8.136.0/23 MATCH
-193.36.32.0/24 MATCH
-193.73.125.0/24 MATCH
-193.134.200.0/21 MATCH
-193.134.216.0/21 MATCH
-193.135.168.0/22 MATCH
-193.135.172.0/24 MATCH
-193.135.240.0/21 MATCH
-193.138.69.0/24 MATCH
-193.222.112.0/20 MATCH
-193.222.241.0/24 MATCH
-193.222.242.0/23 MATCH
-193.222.244.0/22 MATCH
-193.222.248.0/23 MATCH
-193.222.250.0/24 MATCH
-193.246.121.0/24 MATCH
-193.246.124.0/23 MATCH
-193.246.176.0/20 MATCH
-193.247.190.0/23 MATCH
-193.247.203.0/24 MATCH
-193.247.240.0/22 MATCH
-193.247.248.0/23 MATCH
-193.247.254.0/24 MATCH
-194.153.96.0/24 MATCH
-195.176.0.0/17 MATCH
-195.176.160.0/19 MATCH
-195.176.224.0/19 MATCH
-198.21.18.0/24 miss
-2001:620::/29 MATCH
-2001:620::/32 MATCH
-2001:678:678::/48 MATCH
-2001:67c:10ec::/48 MATCH
-2001:67c:13c0::/48 MATCH
-2001:67c:16dc::/48 MATCH
-2a02:7dc0::/32 MATCH
-2a07:290a::/32 MATCH
-2a07:3e00::/29 MATCH
-2a07:6b40::/29 MATCH
-2a0a:4ec0::/29 MATCH
-2a0b:2040::/29 MATCH
-199.185.136.0/23 miss
-199.185.178.0/24 miss
-199.185.230.0/23 miss
-204.174.115.0/24 miss
-204.209.252.0/24 miss
-204.209.253.0/24 miss
-2620:3d:c000::/48 miss
+82.130.64.0/18 MATCH 0
+86.119.0.0/16 MATCH 0
+89.206.64.0/18 MATCH 0
+128.178.0.0/15 MATCH 0
+129.129.0.0/16 MATCH 0
+129.132.0.0/16 MATCH 0
+129.194.0.0/15 MATCH 0
+130.59.0.0/16 MATCH 0
+130.60.0.0/16 MATCH 0
+130.82.0.0/16 MATCH 0
+130.92.0.0/16 MATCH 0
+130.125.0.0/16 MATCH 0
+130.223.0.0/16 MATCH 0
+131.152.0.0/16 MATCH 0
+134.21.0.0/16 MATCH 0
+138.131.0.0/16 MATCH 0
+141.249.0.0/16 MATCH 0
+144.200.0.0/16 MATCH 0
+146.136.0.0/16 MATCH 0
+147.86.0.0/16 MATCH 0
+147.87.0.0/16 MATCH 0
+147.88.0.0/16 MATCH 0
+148.187.0.0/16 MATCH 0
+148.196.0.0/16 MATCH 0
+152.88.0.0/16 MATCH 0
+152.96.0.0/16 MATCH 0
+153.109.0.0/16 MATCH 0
+155.105.0.0/16 MATCH 0
+155.228.0.0/16 MATCH 0
+156.25.0.0/16 MATCH 0
+156.135.0.0/21 MATCH 0
+156.135.12.0/22 MATCH 0
+156.135.16.0/21 MATCH 0
+156.135.28.0/22 MATCH 0
+156.135.32.0/19 MATCH 0
+156.135.64.0/18 MATCH 0
+156.135.128.0/17 MATCH 0
+157.26.0.0/16 MATCH 0
+160.85.0.0/16 MATCH 0
+160.98.0.0/16 MATCH 0
+161.62.0.0/16 MATCH 0
+185.51.68.0/22 MATCH 0
+185.133.44.0/22 MATCH 0
+185.144.36.0/22 MATCH 0
+185.194.180.0/22 MATCH 0
+185.225.92.0/22 MATCH 0
+192.12.247.0/24 MATCH 0
+192.26.28.0/22 MATCH 0
+192.26.32.0/21 MATCH 0
+192.26.40.0/22 MATCH 0
+192.26.44.0/24 MATCH 0
+192.26.46.0/23 MATCH 0
+192.33.87.0/24 MATCH 0
+192.33.88.0/21 MATCH 0
+192.33.96.0/21 MATCH 0
+192.33.104.0/22 MATCH 0
+192.33.108.0/23 MATCH 0
+192.33.110.0/24 MATCH 0
+192.33.118.0/23 MATCH 0
+192.33.120.0/21 MATCH 0
+192.33.192.0/19 MATCH 0
+192.33.224.0/21 MATCH 0
+192.41.132.0/22 MATCH 0
+192.41.136.0/24 MATCH 0
+192.41.149.0/24 MATCH 0
+192.41.150.0/23 MATCH 0
+192.41.152.0/21 MATCH 0
+192.41.160.0/24 MATCH 0
+192.42.42.0/23 MATCH 0
+192.42.44.0/22 MATCH 0
+192.42.180.0/22 MATCH 0
+192.42.184.0/21 MATCH 0
+192.42.192.0/21 MATCH 0
+192.42.200.0/23 MATCH 0
+192.43.192.0/22 MATCH 0
+192.43.196.0/24 MATCH 0
+192.47.244.0/22 MATCH 0
+192.47.248.0/23 MATCH 0
+192.65.92.0/23 MATCH 0
+192.101.176.0/24 MATCH 0
+192.135.150.0/23 MATCH 0
+192.135.151.0/24 MATCH 0
+192.135.152.0/21 MATCH 0
+192.152.98.0/24 MATCH 0
+193.5.22.0/24 MATCH 0
+193.5.26.0/23 MATCH 0
+193.5.54.0/23 MATCH 0
+193.5.58.0/24 MATCH 0
+193.5.60.0/24 MATCH 0
+193.5.80.0/21 MATCH 0
+193.5.152.0/22 MATCH 0
+193.5.168.0/22 MATCH 0
+193.5.180.0/24 MATCH 0
+193.5.182.0/24 MATCH 0
+193.5.186.0/24 MATCH 0
+193.5.188.0/24 MATCH 0
+193.8.136.0/23 MATCH 0
+193.36.32.0/24 MATCH 0
+193.73.125.0/24 MATCH 0
+193.134.200.0/21 MATCH 0
+193.134.216.0/21 MATCH 0
+193.135.168.0/22 MATCH 0
+193.135.172.0/24 MATCH 0
+193.135.240.0/21 MATCH 0
+193.138.69.0/24 MATCH 0
+193.222.112.0/20 MATCH 0
+193.222.241.0/24 MATCH 0
+193.222.242.0/23 MATCH 0
+193.222.244.0/22 MATCH 0
+193.222.248.0/23 MATCH 0
+193.222.250.0/24 MATCH 0
+193.246.121.0/24 MATCH 0
+193.246.124.0/23 MATCH 0
+193.246.176.0/20 MATCH 0
+193.247.190.0/23 MATCH 0
+193.247.203.0/24 MATCH 0
+193.247.240.0/22 MATCH 0
+193.247.248.0/23 MATCH 0
+193.247.254.0/24 MATCH 0
+194.153.96.0/24 MATCH 0
+195.176.0.0/17 MATCH 0
+195.176.160.0/19 MATCH 0
+195.176.224.0/19 MATCH 0
+198.21.18.0/24 miss 0
+2001:620::/29 MATCH 0
+2001:620::/32 MATCH 0
+2001:678:678::/48 MATCH 0
+2001:67c:10ec::/48 MATCH 0
+2001:67c:13c0::/48 MATCH 0
+2001:67c:16dc::/48 MATCH 0
+2a02:7dc0::/32 MATCH 0
+2a07:290a::/32 MATCH 0
+2a07:3e00::/29 MATCH 0
+2a07:6b40::/29 MATCH 0
+2a0a:4ec0::/29 MATCH 0
+2a0b:2040::/29 MATCH 0
+199.185.136.0/23 miss 0
+199.185.178.0/24 miss 0
+199.185.230.0/23 miss 0
+204.174.115.0/24 miss 0
+204.209.252.0/24 miss 0
+204.209.253.0/24 miss 0
+2620:3d:c000::/48 miss 0
-/* $OpenBSD: rde_trie_test.c,v 1.2 2018/09/09 12:39:51 claudio Exp $ */
+/* $OpenBSD: rde_trie_test.c,v 1.3 2018/09/10 20:51:59 benno Exp $ */
/*
* Copyright (c) 2018 Claudio Jeker <claudio@openbsd.org>
static int
-host_v4(const char *s, struct bgpd_addr *h, u_int8_t *len)
+host_v4(const char *s, struct bgpd_addr *h, u_int8_t *len, int *orl)
{
struct in_addr ina = { 0 };
int bits = 32;
}
static int
-host_v6(char *s, struct bgpd_addr *h, u_int8_t *len)
+host_v6(const char *s, struct bgpd_addr *h, u_int8_t *len, int *orl)
{
struct addrinfo hints, *res;
const char *errstr;
char *p;
int mask = 128;
+ memset(h, 0, sizeof(*h));
if ((p = strrchr(s, '/')) != NULL) {
mask = strtonum(p + 1, 0, 128, &errstr);
if (errstr)
}
static int
-host_l(char *s, struct bgpd_addr *h, u_int8_t *len)
+host_l(char *s, struct bgpd_addr *h, u_int8_t *len, int *orl)
{
- if (host_v4(s, h, len))
+ char *c, *t;
+
+ *orl = 0;
+ if ((c = strchr(s, '\t')) != NULL) {
+ if (c[1] == '1') {
+ *orl = 1;
+ }
+ *c = '\0';
+ }
+
+ if (host_v4(s, h, len, orl))
return (1);
- if (host_v6(s, h, len))
+ if (host_v6(s, h, len, orl))
return (1);
return (0);
}
char *line, *s;
struct bgpd_addr prefix;
u_int8_t plen, min, max, maskmax;
-
+ int foo;
while ((line = fparseln(in, NULL, NULL, NULL, FPARSELN_UNESCALL))) {
int state = 0;
break;
switch (state) {
case 0:
- if (!host_l(s, &prefix, &plen))
+ if (!host_l(s, &prefix, &plen, &foo))
errx(1, "could not parse prefix \"%s\"",
s);
break;
char *line;
struct bgpd_addr prefix;
u_int8_t plen;
+ int orlonger;
while ((line = fparseln(in, NULL, NULL, NULL, FPARSELN_UNESCALL))) {
- if (!host_l(line, &prefix, &plen))
+ if (!host_l(line, &prefix, &plen, &orlonger))
errx(1, "could not parse prefix \"%s\"", line);
printf("%s ", line);
- if (trie_match(th, &prefix, plen, 0))
- printf("MATCH\n");
+ if (trie_match(th, &prefix, plen, orlonger))
+ printf("MATCH %i\n", orlonger);
else
- printf("miss\n");
+ printf("miss %i\n", orlonger);
free(line);
}
}