PCAP API Tests
(self)
| 106 | os.remove("/tmp/filt.pcap") |
| 107 | |
| 108 | def test_pcap_trace_api(self): |
| 109 | """PCAP API Tests""" |
| 110 | |
| 111 | pkt = ( |
| 112 | Ether(src=self.pg0.local_mac, dst=self.pg0.remote_mac) |
| 113 | / IP(src=self.pg0.local_ip4, dst=self.pg0.remote_ip4, ttl=2) |
| 114 | / UDP(sport=1234, dport=2345) |
| 115 | / Raw(b"\xa5" * 128) |
| 116 | ) |
| 117 | |
| 118 | self.vapi.pcap_trace_on( |
| 119 | capture_rx=True, |
| 120 | capture_tx=True, |
| 121 | max_packets=1000, |
| 122 | sw_if_index=0, |
| 123 | filename="trace_any.pcap", |
| 124 | ) |
| 125 | self.pg_send(self.pg0, pkt * 10) |
| 126 | self.vapi.pcap_trace_off() |
| 127 | |
| 128 | # Launching trace with filter & no classifier table specified |
| 129 | # should result in no packet capture |
| 130 | self.vapi.pcap_trace_on( |
| 131 | capture_rx=True, |
| 132 | capture_tx=True, |
| 133 | max_packets=1000, |
| 134 | filter=True, |
| 135 | sw_if_index=0, |
| 136 | filename="trace_any_invalid_filter.pcap", |
| 137 | ) |
| 138 | self.pg_send(self.pg0, pkt * 10) |
| 139 | with self.vapi.assert_negative_api_retval(): |
| 140 | self.vapi.pcap_trace_off() |
| 141 | self.assertFalse(os.path.exists("/tmp/trace_any_invalid_filter.pcap")) |
| 142 | |
| 143 | self.vapi.cli( |
| 144 | f"classify filter pcap mask l3 ip4 src match l3 ip4 src {self.pg0.local_ip4}" |
| 145 | ) |
| 146 | self.vapi.pcap_trace_on( |
| 147 | capture_rx=True, |
| 148 | capture_tx=True, |
| 149 | filter=True, |
| 150 | max_packets=1000, |
| 151 | sw_if_index=0, |
| 152 | filename="trace_any_filter.pcap", |
| 153 | ) |
| 154 | self.pg_send(self.pg0, pkt * 10) |
| 155 | self.vapi.pcap_trace_off() |
| 156 | self.vapi.cli("classify filter pcap del mask l3 ip4 src") |
| 157 | |
| 158 | pkt = ( |
| 159 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 160 | # wrong destination address |
| 161 | / IP(src=self.pg0.local_ip4, dst=self.pg0.local_ip4, ttl=2) |
| 162 | / UDP(sport=1234, dport=2345) |
| 163 | / Raw(b"\xa5" * 128) |
| 164 | ) |
| 165 |
nothing calls this directly
no test coverage detected