diff options
author | Mark Michelson <mmichels@redhat.com> | 2018-10-05 12:52:40 -0400 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-10-05 17:35:07 -0700 |
commit | b6e840aed03e3f6d1aa726b482140d895f60f90f (patch) | |
tree | 1893a7a3b24917591591874441db5136c4e7b946 /utilities | |
parent | 2b2532dd4cec6175973aeb34e6e445d59812c1ab (diff) | |
download | openvswitch-b6e840aed03e3f6d1aa726b482140d895f60f90f.tar.gz |
pcap-file: Add nanosecond resolution pcap support.
PCAP header magic numbers are different for microsecond and nanosecond
resolution timestamps. This patch adds support for understanding the
difference and reporting the time correctly with ovs_pcap_read().
When writing pcap files, OVS will always use microsecond resolution, so
no new calculations were added to those functions.
Signed-off-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'utilities')
-rw-r--r-- | utilities/ovs-ofctl.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 82bc0cad6..aa8f6971c 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -2743,12 +2743,12 @@ static void ofctl_ofp_parse_pcap(struct ovs_cmdl_context *ctx) { struct tcp_reader *reader; - FILE *file; + struct pcap_file *p_file; int error; bool first; - file = ovs_pcap_open(ctx->argv[1], "rb"); - if (!file) { + p_file = ovs_pcap_open(ctx->argv[1], "rb"); + if (!p_file) { ovs_fatal(errno, "%s: open failed", ctx->argv[1]); } @@ -2759,7 +2759,7 @@ ofctl_ofp_parse_pcap(struct ovs_cmdl_context *ctx) long long int when; struct flow flow; - error = ovs_pcap_read(file, &packet, &when); + error = ovs_pcap_read(p_file, &packet, &when); if (error) { break; } @@ -2809,7 +2809,7 @@ ofctl_ofp_parse_pcap(struct ovs_cmdl_context *ctx) dp_packet_delete(packet); } tcp_reader_close(reader); - fclose(file); + ovs_pcap_close(p_file); } static void @@ -4456,7 +4456,7 @@ ofctl_parse_pcap(struct ovs_cmdl_context *ctx) int error = 0; for (int i = 1; i < ctx->argc; i++) { const char *filename = ctx->argv[i]; - FILE *pcap = ovs_pcap_open(filename, "rb"); + struct pcap_file *pcap = ovs_pcap_open(filename, "rb"); if (!pcap) { error = errno; ovs_error(error, "%s: open failed", filename); @@ -4482,7 +4482,7 @@ ofctl_parse_pcap(struct ovs_cmdl_context *ctx) putchar('\n'); dp_packet_delete(packet); } - fclose(pcap); + ovs_pcap_close(pcap); } exit(error); } @@ -4783,8 +4783,10 @@ ofctl_compose_packet(struct ovs_cmdl_context *ctx) free(l7); if (print_pcap) { - ovs_pcap_write_header(stdout); - ovs_pcap_write(stdout, &p); + struct pcap_file *p_file = ovs_pcap_stdout(); + ovs_pcap_write_header(p_file); + ovs_pcap_write(p_file, &p); + ovs_pcap_close(p_file); } else { ovs_hex_dump(stdout, dp_packet_data(&p), dp_packet_size(&p), 0, false); } |