From 2764d9977ba25c6cbbcc47135c42e4a86d5ab401 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20T=C3=BCxen?= Date: Tue, 21 Feb 2012 17:19:45 +0000 Subject: [PATCH] Use wtap_dump_open_ng() in tshark. svn path=/trunk/; revision=41123 --- tshark.c | 22 +++++++++++----------- wiretap/file_access.c | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tshark.c b/tshark.c index 08f8956448..3707f08004 100644 --- a/tshark.c +++ b/tshark.c @@ -2677,9 +2677,17 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, char *save_file_string = NULL; gboolean filtering_tap_listeners; guint tap_flags; + wtapng_section_t *shb_hdr; + wtapng_iface_descriptions_t *idb_inf; + shb_hdr = wtap_file_get_shb_info(cf->wth); + idb_inf = wtap_file_get_idb_info(cf->wth); #ifdef PCAP_NG_DEFAULT - linktype = WTAP_ENCAP_PER_PACKET; + if (idb_inf->number_of_interfaces > 0) { + linktype = WTAP_ENCAP_PER_PACKET; + } else { + linktype = wtap_file_encap(cf->wth); + } #else linktype = wtap_file_encap(cf->wth); #endif @@ -2693,16 +2701,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type, /* Snapshot length of input file not known. */ snapshot_length = WTAP_MAX_PACKET_SIZE; } - /* - * XXX - * As long as we don't use wtap_dump_open_ng(), we can't use - * WTAP_ENCAP_PER_PACKET since there is no way to write out - * an IDB. - * So overwrite the above assignment for now! - */ - linktype = wtap_file_encap(cf->wth); - pdh = wtap_dump_open(save_file, out_file_type, linktype, snapshot_length, - FALSE /* compressed */, &err); + pdh = wtap_dump_open_ng(save_file, out_file_type, linktype, snapshot_length, + FALSE /* compressed */, shb_hdr, idb_inf, &err); if (pdh == NULL) { /* We couldn't set up to write to the capture file. */ diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 5347971876..3b604217b5 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -998,7 +998,7 @@ wtap_dumper* wtap_dump_open_ng(const char *filename, int filetype, int encap, /* Set Section Header Block data */ wdh->shb_hdr = shb_hdr; /* Set Interface Description Block data */ - if (idb_inf != NULL) { + if ((idb_inf != NULL) && (idb_inf->number_of_interfaces > 0)) { wdh->number_of_interfaces = idb_inf->number_of_interfaces; wdh->interface_data = idb_inf->interface_data; g_free(idb_inf); -- 2.34.1