Dissect SSH over SCTP when using the IANA assigned SCTP port 22.
[obnox/wireshark/wip.git] / tshark.c
index e1b11cef6fe33ef2ad9be436312f07080c2ebdb0..3707f08004d9f548ff2430dae198aa0c7f7876de 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -70,7 +70,7 @@
 #include <epan/column.h>
 #include "print.h"
 #include <epan/addr_resolv.h>
-#include "util.h"
+#include "ui/util.h"
 #include "clopts_common.h"
 #include "console_io.h"
 #include "cmdarg_err.h"
 #include "capture-pcap-util.h"
 #ifdef _WIN32
 #include "capture-wpcap.h"
-#include "capture_errs.h"
 #include <wsutil/unicode-utils.h>
 #endif /* _WIN32 */
 #include "capture_sync.h"
 #endif /* HAVE_LIBPCAP */
 #include "log.h"
 #include <epan/funnel.h>
+#include "capture_opts.h"
 
 /*
  * This is the template for the decode as option; it is shared between the
@@ -292,7 +292,7 @@ print_usage(gboolean print_ver)
   fprintf(output, "  -w <outfile|->           write packets to a pcap-format file named \"outfile\"\n");
   fprintf(output, "                           (or to the standard output for \"-\")\n");
   fprintf(output, "  -C <config profile>      start with specified configuration profile\n");
-  fprintf(output, "  -F <output file type>    set the output file type, default is libpcap\n");
+  fprintf(output, "  -F <output file type>    set the output file type, default is pcapng\n");
   fprintf(output, "                           an empty \"-F\" option will list the file types\n");
   fprintf(output, "  -V                       add output of packet tree        (Packet Details)\n");
   fprintf(output, "  -O <protocols>           Only show packet details of these protocols, comma\n");
@@ -1138,6 +1138,7 @@ main(int argc, char *argv[])
       if (if_list == NULL) {
         switch (err) {
         case CANT_GET_INTERFACE_LIST:
+        case DONT_HAVE_PCAP:
           cmdarg_err("%s", err_str);
           g_free(err_str);
           break;
@@ -1784,19 +1785,6 @@ main(int argc, char *argv[])
        (or get a list of link-layer types for a live capture device);
        do we have support for live captures? */
 #ifdef HAVE_LIBPCAP
-
-#ifdef _WIN32
-    if (!has_wpcap) {
-      char *detailed_err;
-
-      cmdarg_err("WinPcap couldn't be found.");
-      detailed_err = cant_load_winpcap_err("TShark");
-      cmdarg_err_cont("%s", detailed_err);
-      g_free(detailed_err);
-      return 2;
-    }
-#endif
-
     /* trim the interface name and exit if that failed */
     if (!capture_opts_trim_iface(&global_capture_opts,
         (prefs_p->capture_device) ? get_if_name(prefs_p->capture_device) : NULL)) {
@@ -2689,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
@@ -2705,8 +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;
     }
-    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. */
@@ -2923,6 +2919,12 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
 #endif
     switch (err) {
 
+    case WTAP_ERR_UNSUPPORTED:
+      cmdarg_err("The file \"%s\" contains record data that TShark doesn't support.\n(%s)",
+                 cf->filename, err_info);
+      g_free(err_info);
+      break;
+
     case WTAP_ERR_UNSUPPORTED_ENCAP:
       cmdarg_err("The file \"%s\" has a packet with a network type that TShark doesn't support.\n(%s)",
                  cf->filename, err_info);
@@ -3629,6 +3631,11 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
       errmsg = "The file \"%s\" is a \"special file\" or socket or other non-regular file.";
       break;
 
+    case WTAP_ERR_RANDOM_OPEN_PIPE:
+      /* Seen only when opening a capture file for reading. */
+      errmsg = "The file \"%s\" is a pipe or FIFO; TShark can't read pipe or FIFO files in two-pass mode.";
+      break;
+
     case WTAP_ERR_FILE_UNKNOWN_FORMAT:
       /* Seen only when opening a capture file for reading. */
       errmsg = "The file \"%s\" isn't a capture file in a format TShark understands.";
@@ -3705,6 +3712,10 @@ cf_open_error_message(int err, gchar *err_info, gboolean for_writing,
       errmsg = "A full header couldn't be written to the file \"%s\".";
       break;
 
+    case WTAP_ERR_COMPRESSION_NOT_SUPPORTED:
+      errmsg = "This file type cannot be written as a compressed file.";
+      break;
+
     case WTAP_ERR_DECOMPRESS:
       /* Seen only when opening a capture file for reading. */
       g_snprintf(errmsg_errno, sizeof(errmsg_errno),