Allow tshark to read a pcap file and either save it as a new pcap file or for packets...
authorcmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 5 Jun 2013 03:07:57 +0000 (03:07 +0000)
committercmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7>
Wed, 5 Jun 2013 03:07:57 +0000 (03:07 +0000)
#BACKPORT(1.10)

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@49780 f5534014-38df-0310-8fa8-9805f1628bb7

tshark.c

index a852b8355cd98a6849df228aac5ebad23e2669ee..6d61bb9cad6d7c5f48d7ad7c3a9a16a17b7cb8b6 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -2867,7 +2867,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
   shb_hdr = wtap_file_get_shb_info(cf->wth);
   idb_inf = wtap_file_get_idb_info(cf->wth);
 #ifdef PCAP_NG_DEFAULT
-  if (idb_inf->number_of_interfaces > 0) {
+  if (idb_inf->number_of_interfaces > 1) {
     linktype = WTAP_ENCAP_PER_PACKET;
   } else {
     linktype = wtap_file_encap(cf->wth);
@@ -2891,8 +2891,12 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
         shb_hdr->shb_user_appl = appname;
     }
 
-    pdh = wtap_dump_open_ng(save_file, out_file_type, linktype, snapshot_length,
-        FALSE /* compressed */, shb_hdr, idb_inf, &err);
+    if (linktype != WTAP_ENCAP_PER_PACKET && out_file_type == WTAP_FILE_PCAP)
+        pdh = wtap_dump_open(save_file, out_file_type, linktype,
+            snapshot_length, FALSE /* compressed */, &err);
+    else
+        pdh = wtap_dump_open_ng(save_file, out_file_type, linktype,
+            snapshot_length, FALSE /* compressed */, shb_hdr, idb_inf, &err);
 
     g_free(idb_inf);
     idb_inf = NULL;