MCPcopy Create free account
hub / github.com/F-Stack/f-stack / valid_pcapng_file

Function valid_pcapng_file

dpdk/app/test/test_pcapng.c:290–322  ·  view source on GitHub ↗

* Open the resulting pcapng file with libpcap * Would be better to use capinfos from wireshark * but that creates an unwanted dependency. */

Source from the content-addressed store, hash-verified

288 * but that creates an unwanted dependency.
289 */
290static int
291valid_pcapng_file(const char *file_name, uint64_t started, unsigned int expected)
292{
293 char errbuf[PCAP_ERRBUF_SIZE];
294 struct pkt_print_ctx ctx = { };
295 int ret;
296
297 ctx.start_ns = started;
298 ctx.end_ns = current_timestamp();
299
300 ctx.pcap = pcap_open_offline_with_tstamp_precision(file_name,
301 PCAP_TSTAMP_PRECISION_NANO,
302 errbuf);
303 if (ctx.pcap == NULL) {
304 fprintf(stderr, "pcap_open_offline('%s') failed: %s\n",
305 file_name, errbuf);
306 return -1;
307 }
308
309 ret = pcap_loop(ctx.pcap, 0, parse_pcap_packet, (u_char *)&ctx);
310 if (ret != 0) {
311 fprintf(stderr, "pcap_dispatch: failed: %s\n",
312 pcap_geterr(ctx.pcap));
313 } else if (ctx.count != expected) {
314 printf("Only %u packets, expected %u\n",
315 ctx.count, expected);
316 ret = -1;
317 }
318
319 pcap_close(ctx.pcap);
320
321 return ret;
322}
323
324static int
325test_add_interface(void)

Callers 2

test_add_interfaceFunction · 0.85
test_write_packetsFunction · 0.85

Calls 2

current_timestampFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected