1 # Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from suite_dfilter
.dfiltertest
import *
10 trace_file
= "ipv6.pcap"
12 def test_eq_1(self
, checkDFilterCount
):
13 dfilter
= "ipv6.dst == ff05::9999"
14 checkDFilterCount(dfilter
, 1)
16 def test_eq_2(self
, checkDFilterCount
):
17 dfilter
= "ipv6.dst == ff05::9990"
18 checkDFilterCount(dfilter
, 0)
20 def test_ne_1(self
, checkDFilterCount
):
21 dfilter
= "ipv6.dst != ff05::9990"
22 checkDFilterCount(dfilter
, 1)
24 def test_ne_2(self
, checkDFilterCount
):
25 dfilter
= "ipv6.dst != ff05::9999"
26 checkDFilterCount(dfilter
, 0)
28 def test_gt_1(self
, checkDFilterCount
):
29 dfilter
= "ipv6.dst > ff05::0000"
30 checkDFilterCount(dfilter
, 1)
32 def test_gt_2(self
, checkDFilterCount
):
33 dfilter
= "ipv6.dst > ff05::9999"
34 checkDFilterCount(dfilter
, 0)
36 def test_ge_1(self
, checkDFilterCount
):
37 dfilter
= "ipv6.dst >= ff05::9999"
38 checkDFilterCount(dfilter
, 1)
40 def test_ge_2(self
, checkDFilterCount
):
41 dfilter
= "ipv6.dst >= ff05::a000"
42 checkDFilterCount(dfilter
, 0)
44 def test_lt_1(self
, checkDFilterCount
):
45 dfilter
= "ipv6.dst < ff05::a000"
46 checkDFilterCount(dfilter
, 1)
48 def test_lt_2(self
, checkDFilterCount
):
49 dfilter
= "ipv6.dst < ff05::9999"
50 checkDFilterCount(dfilter
, 0)
52 def test_le_1(self
, checkDFilterCount
):
53 dfilter
= "ipv6.dst <= ff05::9999"
54 checkDFilterCount(dfilter
, 1)
56 def test_le_2(self
, checkDFilterCount
):
57 dfilter
= "ipv6.dst <= ff05::9998"
58 checkDFilterCount(dfilter
, 0)
60 def test_cidr_eq_1(self
, checkDFilterCount
):
61 dfilter
= "ipv6.dst == ff05::9999/128"
62 checkDFilterCount(dfilter
, 1)
64 def test_cidr_eq_2(self
, checkDFilterCount
):
65 dfilter
= "ipv6.dst == ff05::0/64"
66 checkDFilterCount(dfilter
, 1)
68 def test_cidr_eq_3(self
, checkDFilterCount
):
69 dfilter
= "ipv6.dst == ff05::ffff/112"
70 checkDFilterCount(dfilter
, 1)
72 def test_cidr_eq_4(self
, checkDFilterCount
):
73 dfilter
= "ipv6.dst == ff04::0/64"
74 checkDFilterCount(dfilter
, 0)
76 def test_cidr_ne_1(self
, checkDFilterCount
):
77 dfilter
= "ipv6.dst != ff05::9999/128"
78 checkDFilterCount(dfilter
, 0)
80 def test_cidr_ne_2(self
, checkDFilterCount
):
81 dfilter
= "ipv6.dst != ff05::0/64"
82 checkDFilterCount(dfilter
, 0)
84 def test_cidr_ne_3(self
, checkDFilterCount
):
85 dfilter
= "ipv6.dst != ff05::ffff/112"
86 checkDFilterCount(dfilter
, 0)
88 def test_cidr_ne_4(self
, checkDFilterCount
):
89 dfilter
= "ipv6.dst != ff04::00/64"
90 checkDFilterCount(dfilter
, 1)
92 def test_slice_1(self
, checkDFilterCount
):
93 dfilter
= "ipv6.dst[14:2] == 99:99"
94 checkDFilterCount(dfilter
, 1)
96 def test_slice_2(self
, checkDFilterCount
):
97 dfilter
= "ipv6.dst[14:2] == 00:00"
98 checkDFilterCount(dfilter
, 0)
100 def test_slice_3(self
, checkDFilterCount
):
101 dfilter
= "ipv6.dst[15:1] == 153"
102 checkDFilterCount(dfilter
, 1)
104 def test_slice_4(self
, checkDFilterCount
):
105 dfilter
= "ipv6.dst[15:1] == 99:"
106 checkDFilterCount(dfilter
, 1)
109 # Test some addresses are parsed correctly
112 def test_unspecified_1(self
, checkDFilterSucceed
):
113 dfilter
= "ipv6.dst == ::"
114 checkDFilterSucceed(dfilter
)
116 def test_unspecified_2(self
, checkDFilterSucceed
):
117 dfilter
= "ipv6.dst == ::/128"
118 checkDFilterSucceed(dfilter
)
120 def test_loopback_1(self
, checkDFilterSucceed
):
121 dfilter
= "ipv6.dst == ::1"
122 checkDFilterSucceed(dfilter
)
124 def test_loopback_2(self
, checkDFilterSucceed
):
125 dfilter
= "ipv6.dst == ::1/128"
126 checkDFilterSucceed(dfilter
)
128 def test_compress_1(self
, checkDFilterSucceed
):
129 dfilter
= "ipv6.dst == ::2000"
130 checkDFilterSucceed(dfilter
)
132 def test_compress_2(self
, checkDFilterSucceed
):
133 dfilter
= "ipv6.dst == ::2000/64"
134 checkDFilterSucceed(dfilter
)
136 def test_compress_3(self
, checkDFilterSucceed
):
137 dfilter
= "ipv6.dst == ::1:2000"
138 checkDFilterSucceed(dfilter
)
140 def test_compress_4(self
, checkDFilterSucceed
):
141 dfilter
= "ipv6.dst == 2000::"
142 checkDFilterSucceed(dfilter
)
144 def test_compress_5(self
, checkDFilterSucceed
):
145 dfilter
= "ipv6.dst == 2000::/120"
146 checkDFilterSucceed(dfilter
)
148 def test_compress_6(self
, checkDFilterSucceed
):
149 dfilter
= "ipv6.dst == 2000:1::"
150 checkDFilterSucceed(dfilter
)
152 def test_ula_1(self
, checkDFilterSucceed
):
153 dfilter
= "ipv6.dst == fd93:c15b:7ae0:2e41:0000:0000:0000:0000"
154 checkDFilterSucceed(dfilter
)
156 def test_ula_2(self
, checkDFilterSucceed
):
157 dfilter
= "ipv6.dst == fd93:c15b:7ae0:2e41:ffff:ffff:ffff:ffff"
158 checkDFilterSucceed(dfilter
)
160 def test_ula_3(self
, checkDFilterSucceed
):
161 dfilter
= "ipv6.dst == fd93:c15b:7ae0:2e41:3f32:35c9:40aa:1243"
162 checkDFilterSucceed(dfilter
)
164 def test_ula_4(self
, checkDFilterSucceed
):
165 dfilter
= "ipv6.dst == fd93:c15b:7ae0:2e41::2:1"
166 checkDFilterSucceed(dfilter
)
168 def test_mapped_ipv4_1(self
, checkDFilterSucceed
):
169 dfilter
= "ipv6.dst == ::13.1.68.3"
170 checkDFilterSucceed(dfilter
)
172 def test_mapped_ipv4_2(self
, checkDFilterSucceed
):
173 dfilter
= "ipv6.dst == ::FFFF:129.144.52.38"
174 checkDFilterSucceed(dfilter
)