summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaterina Kubecova <katerina.kubecova@nic.cz>2024-01-19 11:54:25 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2024-01-22 07:08:11 +0100
commit472be46f7ab211f38e7662543f1436df30dca753 (patch)
tree127ad15ee45e5103356359b521db67cdfaa6dda1
parent13c6cf8a7430a6b133e46525256eb5554b3f0a2b (diff)
Filter: Tests for net_addr
Minor changes by committer.
-rw-r--r--filter/test.conf177
1 files changed, 138 insertions, 39 deletions
diff --git a/filter/test.conf b/filter/test.conf
index f9289189..02857eac 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -496,6 +496,9 @@ prefix px;
{
px = 1.2.0.0/18;
bt_assert(format(px) = "1.2.0.0/18");
+ bt_assert(px.ip = 1.2.0.0);
+ bt_assert(px.len = 18);
+
bt_assert(192.168.0.0/16 ~ 192.168.0.0/16);
bt_assert(192.168.0.0/17 ~ 192.168.0.0/16);
bt_assert(192.168.254.0/24 ~ 192.168.0.0/16);
@@ -633,9 +636,11 @@ bt_test_suite(t_prefix_set, "Testing prefix sets");
function t_prefix6()
{
- prefix px;
- px = 1020::/18;
+ prefix px = 1020::/18;
bt_assert(format(px) = "1020::/18");
+ bt_assert(px.ip = 1020::);
+ bt_assert(px.len = 18);
+
bt_assert(1020:3040:5060:: ~ 1020:3040:5000::/40);
bt_assert(1020:3040::/32 ~ 1020:3040::/32);
bt_assert(1020:3040::/33 ~ 1020:3040::/32);
@@ -717,33 +722,6 @@ bt_test_suite(t_prefix6_set, "Testing prefix IPv6 sets");
-function t_flowspec()
-prefix p;
-{
- p = flow4 { dst 10.0.0.0/8; };
- bt_assert(p !~ [ 10.0.0.0/8 ] );
-
- bt_assert(format(flow4 { dst 10.0.0.0/8; proto = 23; }) = "flow4 { dst 10.0.0.0/8; proto 23; }");
- bt_assert(format(flow6 { dst ::1/128; src ::2/127; }) = "flow6 { dst ::1/128; src ::2/127; }");
- bt_assert(format(flow6 { next header false 42; }) = "flow6 { next header false 42; }");
- bt_assert(format(flow6 { port 80; }) = "flow6 { port 80; }");
- bt_assert(format(flow6 { dport > 24 && < 30 || 40..50,60..70,80 && >= 90; }) = "flow6 { dport > 24 && < 30 || 40..50,60..70,80 && >= 90; }");
- bt_assert(format(flow6 { sport 0..0x400; }) = "flow6 { sport 0..1024; }");
- bt_assert(format(flow6 { icmp type 80; }) = "flow6 { icmp type 80; }");
- bt_assert(format(flow6 { icmp code 90; }) = "flow6 { icmp code 90; }");
- bt_assert(format(flow6 { tcp flags 0x03/0x0f; }) = "flow6 { tcp flags 0x3/0x3 && 0x0/0xc; }");
- bt_assert(format(flow6 { length 0..65535; }) = "flow6 { length 0..65535; }");
- bt_assert(format(flow6 { dscp = 63; }) = "flow6 { dscp 63; }");
- bt_assert(format(flow6 { fragment is_fragment || !first_fragment; }) = "flow6 { fragment is_fragment || !first_fragment; }");
- bt_assert(format(flow6 { label 1000..2000; }) = "flow6 { label 1000..2000; }");
- bt_assert(format(flow6 { }) = "flow6 { }");
-}
-
-bt_test_suite(t_flowspec, "Testing flowspec routes");
-
-
-
-
/*
* Testing Paths
* -------------
@@ -1722,6 +1700,137 @@ bt_test_suite(t_rd_set, "Testing sets of route distinguishers");
/*
+ * Testing VPN nets
+ * ----------------
+ */
+
+function t_net_vpn()
+{
+ prefix p;
+
+ p = 100:200 10.0.1.0/24;
+ bt_assert(format(p) = "100:200 10.0.1.0/24");
+ bt_assert(p.type = NET_VPN4);
+ bt_assert(p.len = 24);
+ bt_assert(p.ip = 10.0.1.0);
+ bt_assert(p.rd = 100:200);
+
+ p = 1012:2024 fe80:386c::/32;
+ bt_assert(format(p) = "1012:2024 fe80:386c::/32");
+ bt_assert(p.type = NET_VPN6);
+ bt_assert(p.len = 32);
+ bt_assert(p.ip = fe80:386c::);
+ bt_assert(p.rd = 1012:2024);
+}
+
+bt_test_suite(t_net_vpn, "Testing VPN nets");
+
+
+
+
+/*
+ * Testing ROA nets
+ * ----------------
+ */
+
+
+function t_net_roa()
+{
+ prefix p;
+
+ p = 12.13.0.0/16 max 24 as 1234;
+ bt_assert(format(p) = "12.13.0.0/16-24 AS1234");
+ bt_assert(p.type = NET_ROA4);
+ bt_assert(p.ip = 12.13.0.0);
+ bt_assert(p.len = 16);
+ bt_assert(p.maxlen = 24);
+ bt_assert(p.asn = 1234);
+
+ p = 1000::/8 max 32 as 1234;
+ bt_assert(format(p) = "1000::/8-32 AS1234");
+ bt_assert(p.type = NET_ROA6);
+ bt_assert(p.ip = 1000::);
+ bt_assert(p.len = 8);
+ bt_assert(p.maxlen = 32);
+ bt_assert(p.asn = 1234);
+}
+
+bt_test_suite(t_net_roa, "Testing ROA nets");
+
+
+
+
+/*
+ * Testing Flowspec nets
+ * ---------------------
+ */
+
+function t_net_flowspec()
+{
+ prefix p;
+
+ p = flow4 { dst 10.0.0.0/8; };
+ bt_assert(p.type = NET_FLOW4);
+ bt_assert(p.ip = 10.0.0.0);
+ bt_assert(p.len = 8);
+ bt_assert(p.src = 0.0.0.0/0);
+ bt_assert(p.dst = 10.0.0.0/8);
+
+ bt_assert(p !~ [ 10.0.0.0/8 ] );
+ bt_assert(p.dst ~ [ 10.0.0.0/8 ] );
+
+ p = flow6 { dst ::1/128; };
+ bt_assert(p.type = NET_FLOW6);
+ bt_assert(p.ip = ::1);
+ bt_assert(p.len = 128);
+ bt_assert(p.src = ::/0);
+ bt_assert(p.dst = ::1/128);
+
+ bt_assert(format(flow4 { dst 10.0.0.0/8; proto = 23; }) = "flow4 { dst 10.0.0.0/8; proto 23; }");
+ bt_assert(format(flow6 { dst ::1/128; src ::2/127; }) = "flow6 { dst ::1/128; src ::2/127; }");
+ bt_assert(format(flow6 { next header false 42; }) = "flow6 { next header false 42; }");
+ bt_assert(format(flow6 { port 80; }) = "flow6 { port 80; }");
+ bt_assert(format(flow6 { dport > 24 && < 30 || 40..50,60..70,80 && >= 90; }) = "flow6 { dport > 24 && < 30 || 40..50,60..70,80 && >= 90; }");
+ bt_assert(format(flow6 { sport 0..0x400; }) = "flow6 { sport 0..1024; }");
+ bt_assert(format(flow6 { icmp type 80; }) = "flow6 { icmp type 80; }");
+ bt_assert(format(flow6 { icmp code 90; }) = "flow6 { icmp code 90; }");
+ bt_assert(format(flow6 { tcp flags 0x03/0x0f; }) = "flow6 { tcp flags 0x3/0x3 && 0x0/0xc; }");
+ bt_assert(format(flow6 { length 0..65535; }) = "flow6 { length 0..65535; }");
+ bt_assert(format(flow6 { dscp = 63; }) = "flow6 { dscp 63; }");
+ bt_assert(format(flow6 { fragment is_fragment || !first_fragment; }) = "flow6 { fragment is_fragment || !first_fragment; }");
+ bt_assert(format(flow6 { label 1000..2000; }) = "flow6 { label 1000..2000; }");
+ bt_assert(format(flow6 { }) = "flow6 { }");
+
+}
+
+bt_test_suite(t_net_flowspec, "Testing flowspec networks");
+
+
+
+
+/*
+ * Testing IPv6 SADR nets
+ * ----------------------
+ */
+
+function t_net_sadr()
+{
+ prefix p;
+ p = fe80:386c::/32 from 2001:db8:1:13::/64;
+ bt_assert(format(p) = "fe80:386c::/32 from 2001:db8:1:13::/64");
+ bt_assert(p.type = NET_IP6_SADR);
+ bt_assert(p.ip = fe80:386c::);
+ bt_assert(p.len = 32);
+ bt_assert(p.src = 2001:db8:1:13::/64);
+ bt_assert(p.dst = fe80:386c::/32);
+}
+
+bt_test_suite(t_net_sadr, "Testing IPv6 SADR nets");
+
+
+
+
+/*
* Testing defined() function
* --------------------------
*/
@@ -2109,16 +2218,6 @@ prefix pfx;
bt_assert(2001:0db8:85a3:8a2e::/64 ~ ::/0);
bt_assert(10.130.130.0/24 !~ ::/0);
bt_assert(2001:0db8:85a3:8a2e::/64 !~ 0.0.0.0/0);
-
- pfx = 12.13.0.0/16 max 24 as 1234;
- bt_assert(pfx.len = 16);
- bt_assert(pfx.maxlen = 24);
- bt_assert(pfx.asn = 1234);
-
- pfx = 1000::/8 max 32 as 1234;
- bt_assert(pfx.len = 8);
- bt_assert(pfx.maxlen = 32);
- bt_assert(pfx.asn = 1234);
}
bt_test_suite(t_roa_check, "Testing ROA");