diff options
author | Michael Tüxen <tuexen@fh-muenster.de> | 2012-02-21 17:19:45 +0000 |
---|---|---|
committer | Michael Tüxen <tuexen@fh-muenster.de> | 2012-02-21 17:19:45 +0000 |
commit | 2764d9977ba25c6cbbcc47135c42e4a86d5ab401 (patch) | |
tree | 6492a44609026eae105fe3fb33011b22a7c32092 | |
parent | acb9414db942b3ca0c584646fbef137e538f3ed4 (diff) |
Use wtap_dump_open_ng() in tshark.
svn path=/trunk/; revision=41123
-rw-r--r-- | tshark.c | 22 | ||||
-rw-r--r-- | wiretap/file_access.c | 2 |
2 files changed, 12 insertions, 12 deletions
@@ -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); |