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
= "nfs.pcap"
12 def test_eq_1(self
, checkDFilterCount
):
13 dfilter
= "ip.src == 172.25.100.14"
14 checkDFilterCount(dfilter
, 1)
16 def test_eq_2(self
, checkDFilterCount
):
17 dfilter
= "ip.src == 255.255.255.255"
18 checkDFilterCount(dfilter
, 0)
20 def test_ne_1(self
, checkDFilterCount
):
21 dfilter
= "ip.src != 172.25.100.14"
22 checkDFilterCount(dfilter
, 1)
24 def test_ne_2(self
, checkDFilterCount
):
25 dfilter
= "ip.src != 255.255.255.255"
26 checkDFilterCount(dfilter
, 2)
28 def test_gt_1(self
, checkDFilterCount
):
29 dfilter
= "ip.dst > 198.95.230.200"
30 checkDFilterCount(dfilter
, 0)
32 def test_gt_2(self
, checkDFilterCount
):
33 dfilter
= "ip.dst > 198.95.230.20"
34 checkDFilterCount(dfilter
, 0)
36 def test_gt_3(self
, checkDFilterCount
):
37 dfilter
= "ip.dst > 198.95.230.10"
38 checkDFilterCount(dfilter
, 1)
40 def test_ge_1(self
, checkDFilterCount
):
41 dfilter
= "ip.dst >= 198.95.230.200"
42 checkDFilterCount(dfilter
, 0)
44 def test_ge_2(self
, checkDFilterCount
):
45 dfilter
= "ip.dst >= 198.95.230.20"
46 checkDFilterCount(dfilter
, 1)
48 def test_ge_3(self
, checkDFilterCount
):
49 dfilter
= "ip.dst >= 198.95.230.10"
50 checkDFilterCount(dfilter
, 1)
52 def test_lt_1(self
, checkDFilterCount
):
53 dfilter
= "ip.src < 172.25.100.140"
54 checkDFilterCount(dfilter
, 1)
56 def test_lt_2(self
, checkDFilterCount
):
57 dfilter
= "ip.src < 172.25.100.14"
58 checkDFilterCount(dfilter
, 0)
60 def test_lt_3(self
, checkDFilterCount
):
61 dfilter
= "ip.src < 172.25.100.10"
62 checkDFilterCount(dfilter
, 0)
64 def test_le_1(self
, checkDFilterCount
):
65 dfilter
= "ip.src <= 172.25.100.140"
66 checkDFilterCount(dfilter
, 1)
68 def test_le_2(self
, checkDFilterCount
):
69 dfilter
= "ip.src <= 172.25.100.14"
70 checkDFilterCount(dfilter
, 1)
72 def test_le_3(self
, checkDFilterCount
):
73 dfilter
= "ip.src <= 172.25.100.10"
74 checkDFilterCount(dfilter
, 0)
76 def test_cidr_eq_1(self
, checkDFilterCount
):
77 dfilter
= "ip.src == 172.25.100.14/32"
78 checkDFilterCount(dfilter
, 1)
80 def test_cidr_eq_2(self
, checkDFilterCount
):
81 dfilter
= "ip.src == 172.25.100.0/24"
82 checkDFilterCount(dfilter
, 1)
84 def test_cidr_eq_3(self
, checkDFilterCount
):
85 dfilter
= "ip.src == 172.25.0.0/16"
86 checkDFilterCount(dfilter
, 1)
88 def test_cidr_eq_4(self
, checkDFilterCount
):
89 dfilter
= "ip.src == 172.0.0.0/8"
90 checkDFilterCount(dfilter
, 1)
92 def test_cidr_ne_1(self
, checkDFilterCount
):
93 dfilter
= "ip.src != 172.25.100.14/32"
94 checkDFilterCount(dfilter
, 1)
96 def test_cidr_ne_2(self
, checkDFilterCount
):
97 dfilter
= "ip.src != 172.25.100.0/24"
98 checkDFilterCount(dfilter
, 1)
100 def test_cidr_ne_3(self
, checkDFilterCount
):
101 dfilter
= "ip.src != 172.25.0.0/16"
102 checkDFilterCount(dfilter
, 1)
104 def test_cidr_ne_4(self
, checkDFilterCount
):
105 dfilter
= "ip.src != 200.0.0.0/8"
106 checkDFilterCount(dfilter
, 2)
108 def test_slice_1(self
, checkDFilterCount
):
109 dfilter
= "ip.src[0:2] == ac:19"
110 checkDFilterCount(dfilter
, 1)
112 def test_slice_2(self
, checkDFilterCount
):
113 dfilter
= "ip.src[0:2] == 00:00"
114 checkDFilterCount(dfilter
, 0)
116 def test_slice_3(self
, checkDFilterCount
):
117 dfilter
= "ip.src[2:2] == 64:0e"
118 checkDFilterCount(dfilter
, 1)
120 def test_slice_4(self
, checkDFilterCount
):
121 dfilter
= "ip.src[2:2] == ff:ff"
122 checkDFilterCount(dfilter
, 0)
124 def test_count_1(self
, checkDFilterCount
):
125 dfilter
= "count(ip.src) == 1"
126 checkDFilterCount(dfilter
, 2)
128 def test_count_2(self
, checkDFilterCount
):
129 dfilter
= "count(ip.addr) == 2"
130 checkDFilterCount(dfilter
, 2)