static void usage(void)
{
- fprintf(stderr, "Usage: netgrind [<switches>] <capture-file>\n\
+ fprintf(stderr, "Usage: netgrind [<switches>] <capture-files>\n\
\n\
-a TCP: Record arrival times instead of processing times\n\
-c <count> Stop after processing <count> packets\n\
default:
usage();
}
- if (optind != argc - 1)
+ if (optind == argc)
usage();
tcp_init();
- if (!(pcap = pcap_open_offline(argv[optind], errbuf)))
- die("Unable to open %s", errbuf);
- dlt = pcap_datalink(pcap);
- if (!link_setup_handler(dlt))
- die("Don't know how to handle data link type %d", dlt);
- if (filter)
+ while (optind < argc)
{
- if (pcap_compile(pcap, &filter_prog, filter, 1, 0) < 0)
- die("Error compiling filter: %s", pcap_geterr(pcap));
- pcap_setfilter(pcap, &filter_prog);
+ fprintf(stderr, "Processing %s...\n", argv[optind]);
+ if (!(pcap = pcap_open_offline(argv[optind], errbuf)))
+ die("Unable to open %s", errbuf);
+ dlt = pcap_datalink(pcap);
+ if (!link_setup_handler(dlt))
+ die("Don't know how to handle data link type %d", dlt);
+ if (filter)
+ {
+ if (pcap_compile(pcap, &filter_prog, filter, 1, 0) < 0)
+ die("Error compiling filter: %s", pcap_geterr(pcap));
+ pcap_setfilter(pcap, &filter_prog);
+ pcap_freecode(&filter_prog);
+ }
+ if (pcap_loop(pcap, max_packets, got_pcap_packet, NULL) < 0)
+ die("Capture failed: %s", pcap_geterr(pcap));
+ pcap_close(pcap);
+ optind++;
}
- if (pcap_loop(pcap, max_packets, got_pcap_packet, NULL) < 0)
- die("Capture failed: %s", pcap_geterr(pcap));
tcp_cleanup(last_timestamp);
printf("# Netgrind statistics:\n");
printf("# Pcap: %Ld(%Ld) in, %Ld(%Ld) incomplete\n",
printf("# Flows: %d total: %d closed, %d reset, %d timed out, %d overlap end, %d corrupted\n",
cnt_tcp_flows, cnt_tcp_causes[CAUSE_CLOSE], cnt_tcp_causes[CAUSE_RESET],
cnt_tcp_causes[CAUSE_TIMEOUT], cnt_tcp_causes[CAUSE_DOOMSDAY], cnt_tcp_causes[CAUSE_CORRUPT]);
- pcap_close(pcap);
return 0;
}