Allow bigger snapshot lengths for D-Bus captures.
authorGuy Harris <guy@alum.mit.edu>
Mon, 5 Jun 2017 01:58:40 +0000 (18:58 -0700)
committerGuy Harris <guy@alum.mit.edu>
Mon, 5 Jun 2017 05:28:26 +0000 (05:28 +0000)
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except
for D-Bus captures.  Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for
them, because that's the largest possible D-Bus message size.  See

https://bugs.freedesktop.org/show_bug.cgi?id=100220

for an example of the problems caused by limiting the snapshot length to
256KB for D-Bus.

Have a snapshot length of 0 in a capture_file structure mean "there is
no snapshot length for the file"; we don't need the has_snap field in
that case, a value of 0 mean "no, we don't have a snapshot length".

In dumpcap, start out with a pipe buffer size of 2KB, and grow it as
necessary.  When checking for a too-big packet from a pipe, check
against the appropriate maximum - 128MB for DLT_DBUS, 256KB for
everything else.

Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20
Reviewed-on: https://code.wireshark.org/review/21952
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
84 files changed:
capture_opts.c
caputils/capture-pcap-util.c
cfile.c
cfile.h
dumpcap.c
epan/dissectors/packet-snort.c
epan/wslua/wslua_capture_info.c
file.c
rawshark.c
sharkd.c
summary.c
summary.h
text2pcap.c
tfshark.c
tshark.c
ui/capture_ui_utils.c
ui/commandline.c
ui/gtk/capture_dlg.c
ui/gtk/file_import_dlg.c
ui/gtk/gsm_map_summary.c
ui/gtk/mtp3_summary.c
ui/gtk/prefs_capture.c
ui/gtk/summary_dlg.c
ui/qt/capture_file_properties_dialog.cpp
ui/qt/capture_interfaces_dialog.cpp
ui/qt/compiled_filter_output.cpp
ui/qt/gsm_map_summary_dialog.cpp
ui/qt/interface_tree_cache_model.cpp
ui/qt/mtp3_summary_dialog.cpp
ui/tap_export_pdu.c
ui/text_import.h
wiretap/5views.c
wiretap/aethra.c
wiretap/ascendtext.h
wiretap/btsnoop.c
wiretap/camins.c
wiretap/capsa.c
wiretap/catapult_dct2000.c
wiretap/commview.c
wiretap/cosine.c
wiretap/csids.c
wiretap/daintree-sna.c
wiretap/dbs-etherwatch.c
wiretap/erf.c
wiretap/eyesdn.c
wiretap/file_access.c
wiretap/hcidump.c
wiretap/i4btrace.c
wiretap/ipfix.c
wiretap/iptrace.c
wiretap/iseries.c
wiretap/k12.c
wiretap/k12text.l
wiretap/lanalyzer.c
wiretap/libpcap.c
wiretap/logcat.c
wiretap/logcat_text.c
wiretap/merge.c
wiretap/mime_file.c
wiretap/mp2t.c
wiretap/netmon.c
wiretap/netscaler.c
wiretap/netscreen.c
wiretap/nettl.c
wiretap/nettrace_3gpp_32_423.c
wiretap/network_instruments.c
wiretap/netxray.c
wiretap/ngsniffer.c
wiretap/packetlogger.c
wiretap/pcap-common.c
wiretap/pcap-common.h
wiretap/pcapng.c
wiretap/peekclassic.c
wiretap/peektagged.c
wiretap/pppdump.c
wiretap/radcom.c
wiretap/snoop.c
wiretap/stanag4607.c
wiretap/tnef.c
wiretap/toshiba.c
wiretap/visual.c
wiretap/vms.c
wiretap/vwr.c
wiretap/wtap.h

index 4a7c8f2ac200d9db0698003d940df58619479281..ef3e659850623d87bdbaaf8c8218fc0ad45d01ed 100644 (file)
@@ -58,7 +58,7 @@ capture_opts_init(capture_options *capture_opts)
     capture_opts->default_options.descr           = NULL;
     capture_opts->default_options.cfilter         = NULL;
     capture_opts->default_options.has_snaplen     = FALSE;
-    capture_opts->default_options.snaplen         = WTAP_MAX_PACKET_SIZE;
+    capture_opts->default_options.snaplen         = WTAP_MAX_PACKET_SIZE_STANDARD;
     capture_opts->default_options.linktype        = -1; /* use interface default */
     capture_opts->default_options.promisc_mode    = TRUE;
     capture_opts->default_options.if_type         = IF_WIRED;
@@ -865,7 +865,7 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
          * length, mirroring what tcpdump does.
          */
         if (snaplen == 0)
-            snaplen = WTAP_MAX_PACKET_SIZE;
+            snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
         if (capture_opts->ifaces->len > 0) {
             interface_options interface_opts;
 
@@ -994,14 +994,14 @@ capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min)
             interface_opts = g_array_index(capture_opts->ifaces, interface_options, 0);
             capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, 0);
             if (interface_opts.snaplen < 1)
-                interface_opts.snaplen = WTAP_MAX_PACKET_SIZE;
+                interface_opts.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
             else if (interface_opts.snaplen < snaplen_min)
                 interface_opts.snaplen = snaplen_min;
             g_array_append_val(capture_opts->ifaces, interface_opts);
         }
     } else {
         if (capture_opts->default_options.snaplen < 1)
-            capture_opts->default_options.snaplen = WTAP_MAX_PACKET_SIZE;
+            capture_opts->default_options.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
         else if (capture_opts->default_options.snaplen < snaplen_min)
             capture_opts->default_options.snaplen = snaplen_min;
     }
index 0f95f7827c0f50951c2dc4ccd9da0e72766943bb..4da5579e3d4952737ecb0216640687a123a6b8c5 100644 (file)
@@ -1213,13 +1213,13 @@ open_capture_device_pcap_open_live(interface_options *interface_opts,
                snaplen = interface_opts->snaplen;
        else {
                /*
-                * Default - use the old maximum snapshot length, which
-                * should be big enough (libpcap didn't get D-Bus support
-                * until after it goet pcap_create()/pcap_activate(), so
-                * we don't have D-Bus support and don't have to worry
-                * about really huge packets).
+                * Default - use the non-D-Bus maximum snapshot length of
+                * 256KB, which should be big enough (libpcap didn't get
+                * D-Bus support until after it goet pcap_create() and
+                * pcap_activate(), so we don't have D-Bus support and
+                * don't have to worry about really huge packets).
                 */
-               snaplen = 262144;
+               snaplen = 256*1024;
        }
        g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
            "pcap_open_live() calling using name %s, snaplen %d, promisc_mode %d.",
@@ -1344,10 +1344,10 @@ open_capture_device(capture_options *capture_opts,
                        snaplen = interface_opts->snaplen;
                else {
                        /*
-                        * Default - use the old maximum snapshot length,
+                        * Default - use the non-D-Bus maximum snapshot length,
                         * which should be big enough, except for D-Bus.
                         */
-                       snaplen = 262144;
+                       snaplen = 256*1024;
                }
                g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
                    "Calling pcap_open() using name %s, snaplen %d, promisc_mode %d, datatx_udp %d, nocap_rpcap %d.",
diff --git a/cfile.c b/cfile.c
index cf30f3b899bc3e9e768e55c8ef1ac0bdacb22c2b..265190b3b50ac777b0b662f58e2ac9601c987a87 100644 (file)
--- a/cfile.c
+++ b/cfile.c
@@ -81,7 +81,6 @@ cap_file_init(capture_file *cf)
 {
   /* Initialize the capture file struct */
   memset(cf, 0, sizeof(capture_file));
-  cf->snap            = WTAP_MAX_PACKET_SIZE;
 }
 
 /*
diff --git a/cfile.h b/cfile.h
index d406c22f217b255cc4eab7a31ca5901406cf36cf..2a22a1397538533d3e2dcfb8051c401ee47e3327 100644 (file)
--- a/cfile.h
+++ b/cfile.h
@@ -87,8 +87,7 @@ typedef struct _capture_file {
   gboolean     drops_known;          /* TRUE if we know how many packets were dropped */
   guint32      drops;                /* Dropped packets */
   nstime_t     elapsed_time;         /* Elapsed time */
-  gboolean     has_snap;             /* TRUE if maximum capture packet length is known */
-  int          snap;                 /* Maximum captured packet length */
+  int          snap;                 /* Maximum captured packet length; 0 if unknown */
   wtap        *wth;                  /* Wiretap session */
   dfilter_t   *rfcode;               /* Compiled read filter program */
   dfilter_t   *dfcode;               /* Compiled display filter program */
index 862402fec2ef86bcc28f58359fa5f281f896aa4f..6c7e26c22cd072f7b0b587128e0d099e32a48878 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -295,6 +295,8 @@ typedef struct _capture_src {
     gboolean                     cap_pipe_modified;      /**< TRUE if data in the pipe uses modified pcap headers */
     gboolean                     cap_pipe_byte_swapped;  /**< TRUE if data in the pipe is byte swapped */
     char *                       cap_pipe_databuf;       /**< Pointer to the data buffer we've allocated */
+    size_t                       cap_pipe_databuf_size;  /**< Current size of the data buffer */
+    guint                        cap_pipe_max_pkt_size;  /**< Maximum packet size allowed */
 #if defined(_WIN32)
     char *                       cap_pipe_buf;           /**< Pointer to the buffer we read into */
     DWORD                        cap_pipe_bytes_to_read; /**< Used by cap_pipe_dispatch */
@@ -478,7 +480,11 @@ print_usage(FILE *output)
                     "                               rpcap://<host>/<interface>\n"
                     "                               TCP@<host>:<port>\n");
     fprintf(output, "  -f <capture filter>      packet filter in libpcap filter syntax\n");
-    fprintf(output, "  -s <snaplen>             packet snapshot length (def: %u)\n", WTAP_MAX_PACKET_SIZE);
+#ifdef HAVE_PCAP_CREATE
+    fprintf(output, "  -s <snaplen>             packet snapshot length (def: appropriate maximum)\n");
+#else
+    fprintf(output, "  -s <snaplen>             packet snapshot length (def: %u)\n", WTAP_MAX_PACKET_SIZE_STANDARD);
+#endif
     fprintf(output, "  -p                       don't capture in promiscuous mode\n");
 #ifdef HAVE_PCAP_CREATE
     fprintf(output, "  -I                       capture in monitor mode, if available\n");
@@ -1677,7 +1683,14 @@ cap_pipe_open_live(char *pipename,
     }
 
     pcap_src->from_cap_pipe = TRUE;
-    pcap_src->cap_pipe_databuf = (guchar*)g_malloc(WTAP_MAX_PACKET_SIZE);
+
+    /*
+     * We start with a 2KB buffer for packet data, which should be
+     * large enough for most regular network packets.  We increase it,
+     * up to the maximum size we allow, as necessary.
+     */
+    pcap_src->cap_pipe_databuf = (guchar*)g_malloc(2048);
+    pcap_src->cap_pipe_databuf_size = 2048;
 
 #ifdef _WIN32
     if (pcap_src->from_cap_socket)
@@ -1842,6 +1855,16 @@ cap_pipe_open_live(char *pipename,
         hdr->network = GUINT32_SWAP_LE_BE(hdr->network);
     }
     pcap_src->linktype = hdr->network;
+#ifdef DLT_DBUS
+    if (pcap_src->linktype == DLT_DBUS) {
+        /*
+         * The maximum D-Bus message size is 128MB, so allow packets up
+         * to that size.
+         */
+        pcap_src->cap_pipe_max_pkt_size = WTAP_MAX_PACKET_SIZE_DBUS;
+    } else
+#endif
+        pcap_src->cap_pipe_max_pkt_size = WTAP_MAX_PACKET_SIZE_STANDARD;
 
     if (hdr->version_major < 2) {
         g_snprintf(errmsg, errmsgl, "Unable to read old libpcap format");
@@ -1880,6 +1903,7 @@ cap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, int errmsg
     wchar_t  *err_str;
 #endif
     ssize_t   b;
+    guint new_bufsize;
 
 #ifdef LOG_CAPTURE_VERBOSE
     g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "cap_pipe_dispatch");
@@ -2024,7 +2048,7 @@ cap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, int errmsg
         /* We've read the header. Take care of byte order. */
         cap_pipe_adjust_header(pcap_src->cap_pipe_byte_swapped, &pcap_src->cap_pipe_hdr,
                                &pcap_src->cap_pipe_rechdr.hdr);
-        if (pcap_src->cap_pipe_rechdr.hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
+        if (pcap_src->cap_pipe_rechdr.hdr.incl_len > pcap_src->cap_pipe_max_pkt_size) {
             g_snprintf(errmsg, errmsgl, "Frame %u too long (%d bytes)",
                        ld->packet_count+1, pcap_src->cap_pipe_rechdr.hdr.incl_len);
             break;
@@ -2034,6 +2058,26 @@ cap_pipe_dispatch(loop_data *ld, capture_src *pcap_src, char *errmsg, int errmsg
             pcap_src->cap_pipe_state = STATE_EXPECT_DATA;
             return 0;
         }
+
+        if (pcap_src->cap_pipe_rechdr.hdr.incl_len > pcap_src->cap_pipe_databuf_size) {
+            /*
+             * Grow the buffer to the packet size, rounded up to a power of
+             * 2.
+             */
+            new_bufsize = pcap_src->cap_pipe_rechdr.hdr.incl_len;
+            /*
+             * http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
+             */
+            new_bufsize--;
+            new_bufsize |= new_bufsize >> 1;
+            new_bufsize |= new_bufsize >> 2;
+            new_bufsize |= new_bufsize >> 4;
+            new_bufsize |= new_bufsize >> 8;
+            new_bufsize |= new_bufsize >> 16;
+            new_bufsize++;
+            pcap_src->cap_pipe_databuf = (guchar*)g_realloc(pcap_src->cap_pipe_databuf, new_bufsize);
+            pcap_src->cap_pipe_databuf_size = new_bufsize;
+        }
         /* no data to read? */
         /* FALLTHROUGH */
     case PD_DATA_READ:
index 1df1a0564ffde6f6de55bbdae0bc6ac819527d58..def0941a63c1624d84e17aa95d3235df4e4820e6 100644 (file)
@@ -1149,7 +1149,7 @@ snort_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
                 current_session.pdh = wtap_dump_fdopen(current_session.in,
                                                        WTAP_FILE_TYPE_SUBTYPE_PCAP,
                                                        pinfo->pkt_encap,
-                                                       WTAP_MAX_PACKET_SIZE,
+                                                       WTAP_MAX_PACKET_SIZE_STANDARD,
                                                        FALSE,                 /* compressed */
                                                        &open_err);
                 if (!current_session.pdh) {
index 690133402b45c5cd0bb93b91a12b63974af4a842..901455274446905c0662e056211d1ab60e02eb0c 100644 (file)
@@ -112,7 +112,7 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,time_precision,wth->file_tsprec,
 
 /* WSLUA_ATTRIBUTE CaptureInfo_snapshot_length RW The maximum packet length that could be recorded.
 
-    Setting it to `0` means unknown.  Wireshark cannot handle anything bigger than WTAP_MAX_PACKET_SIZE (262144) bytes.
+    Setting it to `0` means unknown.
  */
 WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,snapshot_length,wth->snapshot_length);
 WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,snapshot_length,wth->snapshot_length,guint);
diff --git a/file.c b/file.c
index c30839e9bc6c955dd086bf95e16256757a486b3c..7cbab798eed97bf0344e1435065d3a88fa0906aa 100644 (file)
--- a/file.c
+++ b/file.c
@@ -342,12 +342,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
   cf->drops_known = FALSE;
   cf->drops     = 0;
   cf->snap      = wtap_snapshot_length(cf->wth);
-  if (cf->snap == 0) {
-    /* Snapshot length not known. */
-    cf->has_snap = FALSE;
-    cf->snap = WTAP_MAX_PACKET_SIZE;
-  } else
-    cf->has_snap = TRUE;
 
   /* Allocate a frame_data_sequence for the frames in this file */
   cf->frames = new_frame_data_sequence();
@@ -4236,12 +4230,6 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
   cf->linktypes = g_array_sized_new(FALSE, FALSE, (guint) sizeof(int), 1);
 
   cf->snap      = wtap_snapshot_length(cf->wth);
-  if (cf->snap == 0) {
-    /* Snapshot length not known. */
-    cf->has_snap = FALSE;
-    cf->snap = WTAP_MAX_PACKET_SIZE;
-  } else
-    cf->has_snap = TRUE;
 
   name_ptr = g_filename_display_basename(cf->filename);
 
index 6454ab1a78d4dec24edb8440676d64a62fa82327..7612207bc48cb8abd2245ba2d20cf14b317bbebe 100644 (file)
@@ -940,7 +940,7 @@ raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, gchar **err_info,
     printf("caplen: %d (%04x)\n", phdr->caplen, phdr->caplen);
     printf("len: %d (%04x)\n", phdr->len, phdr->len);
 #endif
-    if (bytes_needed > WTAP_MAX_PACKET_SIZE) {
+    if (bytes_needed > WTAP_MAX_PACKET_SIZE_STANDARD) {
         *err = WTAP_ERR_BAD_FILE;
         *err_info = g_strdup_printf("Bad packet length: %lu\n",
                    (unsigned long) bytes_needed);
@@ -981,7 +981,7 @@ load_cap_file(capture_file *cf)
 
     epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
 
-    pd = (guchar*)g_malloc(WTAP_MAX_PACKET_SIZE);
+    pd = (guchar*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
     while (raw_pipe_read(&phdr, pd, &err, &err_info, &data_offset)) {
         process_packet(cf, &edt, data_offset, &phdr, pd);
     }
@@ -1537,8 +1537,7 @@ raw_cf_open(capture_file *cf, const char *fname)
     cf->count     = 0;
     cf->drops_known = FALSE;
     cf->drops     = 0;
-    cf->has_snap = FALSE;
-    cf->snap = WTAP_MAX_PACKET_SIZE;
+    cf->snap      = 0;
     nstime_set_zero(&cf->elapsed_time);
     ref = NULL;
     prev_dis = NULL;
index 00cabfcb56fd80a6e89076e25617e6a85c838bb7..6647189248b46514224a2f23c615f89039883e7b 100644 (file)
--- a/sharkd.c
+++ b/sharkd.c
@@ -465,12 +465,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
   cf->drops_known = FALSE;
   cf->drops     = 0;
   cf->snap      = wtap_snapshot_length(cf->wth);
-  if (cf->snap == 0) {
-    /* Snapshot length not known. */
-    cf->has_snap = FALSE;
-    cf->snap = WTAP_MAX_PACKET_SIZE;
-  } else
-    cf->has_snap = TRUE;
   nstime_set_zero(&cf->elapsed_time);
   ref = NULL;
   prev_dis = NULL;
index cea66872aab06ca55765d548ae57ffcc6527a142..ee0cbb3e2f4287beb02cd3fa1dd9cfc0696ce9fd 100644 (file)
--- a/summary.c
+++ b/summary.c
@@ -148,7 +148,6 @@ summary_fill_in(capture_file *cf, summary_tally *st)
   st->is_tempfile = cf->is_tempfile;
   st->file_encap_type = cf->lnk_t;
   st->packet_encap_types = cf->linktypes;
-  st->has_snap = cf->has_snap;
   st->snap = cf->snap;
   st->elapsed_time = nstime_to_sec(&cf->elapsed_time);
   st->packet_count = cf->count;
@@ -179,7 +178,6 @@ summary_fill_in(capture_file *cf, summary_tally *st)
     iface.drops_known = FALSE;
     iface.drops = 0;
     iface.snap = wtapng_if_descr_mand->snap_len;
-    iface.has_snap = (iface.snap != 65535);
     iface.encap_type = wtapng_if_descr_mand->wtap_encap;
     iface.isb_comment = NULL;
     if(wtapng_if_descr_mand->num_stat_entries == 1){
@@ -222,7 +220,6 @@ summary_fill_in_capture(capture_file *cf,capture_options *capture_opts, summary_
       iface.descr = g_strdup(device.display_name);
       iface.drops_known = cf->drops_known;
       iface.drops = cf->drops;
-      iface.has_snap = device.has_snaplen;
       iface.snap = device.snaplen;
       iface.encap_type = wtap_pcap_encap_to_wtap_encap(device.active_dlt);
       g_array_append_val(st->ifaces, iface);
index 68634ad9d9508822afd215a97db3eaecb9133421..67a6d42ea063e706d2a4c74e061a508ba1396fe6 100644 (file)
--- a/summary.h
+++ b/summary.h
@@ -38,8 +38,7 @@ typedef struct iface_options_tag {
   char     *isb_comment;
   guint64   drops;                 /**< number of packet drops */
   gboolean  drops_known;           /**< TRUE if number of packet drops is known */
-  gboolean  has_snap;              /**< TRUE if maximum capture packet length is known */
-  int       snap;                  /**< Maximum captured packet length */
+  int       snap;                  /**< Maximum captured packet length; 0 if not known */
   int       encap_type;            /**< wiretap encapsulation type */
 } iface_options;
 
@@ -69,8 +68,7 @@ typedef struct _summary_tally {
   int          iscompressed;       /**< TRUE if file is compressed */
   int          file_encap_type;    /**< wiretap encapsulation type for file */
   GArray      *packet_encap_types; /**< wiretap encapsulation types for packets */
-  gboolean     has_snap;           /**< TRUE if maximum capture packet length is known */
-  int          snap;               /**< Maximum captured packet length */
+  int          snap;               /**< Maximum captured packet length; 0 if not known */
   gboolean     drops_known;        /**< TRUE if number of packet drops is known */
   guint64      drops;              /**< number of packet drops */
   const char  *dfilter;            /**< display filter */
index 87a3e90680e1c3fc844a6d39be1c8b50069e1130..3bdd33748f3942db4139df4ef9376bd2eca2482b 100644 (file)
@@ -209,11 +209,11 @@ static guint32 direction = 0;
 /*--- Local date -----------------------------------------------------------------*/
 
 /* This is where we store the packet currently being built */
-static guint8  packet_buf[WTAP_MAX_PACKET_SIZE];
+static guint8  packet_buf[WTAP_MAX_PACKET_SIZE_STANDARD];
 static guint32 header_length;
 static guint32 ip_offset;
 static guint32 curr_offset;
-static guint32 max_offset = WTAP_MAX_PACKET_SIZE;
+static guint32 max_offset = WTAP_MAX_PACKET_SIZE_STANDARD;
 static guint32 packet_start = 0;
 
 static int start_new_packet(gboolean);
@@ -460,7 +460,7 @@ write_bytes (const char bytes[], guint32 nbytes)
 {
     guint32 i;
 
-    if (curr_offset + nbytes < WTAP_MAX_PACKET_SIZE) {
+    if (curr_offset + nbytes < WTAP_MAX_PACKET_SIZE_STANDARD) {
         for (i = 0; i < nbytes; i++) {
             packet_buf[curr_offset] = bytes[i];
             curr_offset++;
@@ -1451,7 +1451,7 @@ print_usage (FILE *output)
             "  -q                     generate no output at all (automatically disables -d).\n"
             "  -n                     use PCAP-NG instead of PCAP as output format.\n"
             "",
-            WTAP_MAX_PACKET_SIZE);
+            WTAP_MAX_PACKET_SIZE_STANDARD);
 }
 
 /*----------------------------------------------------------------------
index b91afb62729c8ef53a642385d9a2ec0bb40b0ab7..551a87bef0dcc580c3a09e7a3d614dd1c380a13a 100644 (file)
--- a/tfshark.c
+++ b/tfshark.c
@@ -2101,12 +2101,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
   cf->drops_known = FALSE;
   cf->drops     = 0;
   cf->snap      = 0; /**** XXX - DOESN'T WORK RIGHT NOW!!!! */
-  if (cf->snap == 0) {
-    /* Snapshot length not known. */
-    cf->has_snap = FALSE;
-    cf->snap = 0;
-  } else
-    cf->has_snap = TRUE;
   nstime_set_zero(&cf->elapsed_time);
   ref = NULL;
   prev_dis = NULL;
index c0fff8768637edbb8fe931e5c8993ac9f1c2f533..726e03ca1577f5b934ea88efb5996e6491d4179d 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -329,7 +329,11 @@ print_usage(FILE *output)
   fprintf(output, "Capture interface:\n");
   fprintf(output, "  -i <interface>           name or idx of interface (def: first non-loopback)\n");
   fprintf(output, "  -f <capture filter>      packet filter in libpcap filter syntax\n");
-  fprintf(output, "  -s <snaplen>             packet snapshot length (def: %u)\n", WTAP_MAX_PACKET_SIZE);
+#ifdef HAVE_PCAP_CREATE
+  fprintf(output, "  -s <snaplen>             packet snapshot length (def: appropriate maximum)\n");
+#else
+  fprintf(output, "  -s <snaplen>             packet snapshot length (def: %u)\n", WTAP_MAX_PACKET_SIZE_STANDARD);
+#endif
   fprintf(output, "  -p                       don't capture in promiscuous mode\n");
 #ifdef HAVE_PCAP_CREATE
   fprintf(output, "  -I                       capture in monitor mode, if available\n");
@@ -3010,7 +3014,7 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
     snapshot_length = wtap_snapshot_length(cf->wth);
     if (snapshot_length == 0) {
       /* Snapshot length of input file not known. */
-      snapshot_length = WTAP_MAX_PACKET_SIZE;
+      snapshot_length = WTAP_MAX_PACKET_SIZE_STANDARD;
     }
     tshark_debug("tshark: snapshot_length = %d", snapshot_length);
 
@@ -3958,12 +3962,6 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
   cf->drops_known = FALSE;
   cf->drops     = 0;
   cf->snap      = wtap_snapshot_length(cf->wth);
-  if (cf->snap == 0) {
-    /* Snapshot length not known. */
-    cf->has_snap = FALSE;
-    cf->snap = WTAP_MAX_PACKET_SIZE;
-  } else
-    cf->has_snap = TRUE;
   nstime_set_zero(&cf->elapsed_time);
   ref = NULL;
   prev_dis = NULL;
index 36e75b37e9480497f3c5081a09dd5a3f224264d2..5655632d91ec715140378f3c352ad827da1dd2b5 100644 (file)
@@ -202,10 +202,10 @@ capture_dev_user_snaplen_find(const gchar *if_name, gboolean *hassnap, int *snap
     if (strcmp(if_tokens[i], if_name) == 0) {
       /* OK, this matches. */
       if (*(colonp + 1) == '0') {
-        /* {hassnap} is false, so just set the snaplen to WTAP_MAX_PACKET_SIZE. */
+        /* {hassnap} is false, so just set the snaplen to WTAP_MAX_PACKET_SIZE_STANDARD. */
         found = TRUE;
         *hassnap = FALSE;
-        *snaplen = WTAP_MAX_PACKET_SIZE;
+        *snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
       } else if (*(colonp + 1) == '1') {
         /* {hassnap} is true, so extract {snaplen} */
         if (*(colonp + 2) != '(') {
index fc4be160101749f515a220bf0abe6a0bed7b2af3..b7c1ef7db46ff7d190dc653d37a8fe4fd60ea2d5 100644 (file)
@@ -93,7 +93,11 @@ commandline_print_usage(gboolean for_help_option) {
     fprintf(output, "Capture interface:\n");
     fprintf(output, "  -i <interface>           name or idx of interface (def: first non-loopback)\n");
     fprintf(output, "  -f <capture filter>      packet filter in libpcap filter syntax\n");
-    fprintf(output, "  -s <snaplen>             packet snapshot length (def: %u)\n", WTAP_MAX_PACKET_SIZE);
+#ifdef HAVE_PCAP_CREATE
+    fprintf(output, "  -s <snaplen>             packet snapshot length (def: appropriate maximum)\n");
+#else
+    fprintf(output, "  -s <snaplen>             packet snapshot length (def: %u)\n", WTAP_MAX_PACKET_SIZE_STANDARD);
+#endif
     fprintf(output, "  -p                       don't capture in promiscuous mode\n");
     fprintf(output, "  -k                       start capturing immediately (def: do nothing)\n");
     fprintf(output, "  -S                       update packet display when new packets are captured\n");
index 870d0e162301c1b4a472dfad1227b19082f7d478..719bcc81b95dac69bf8db0242c5f233a441abf4c 100644 (file)
@@ -2476,7 +2476,7 @@ save_options_cb(GtkWidget *win _U_, gpointer user_data _U_)
     if (device.snaplen < MIN_PACKET_SIZE)
       device.snaplen = MIN_PACKET_SIZE;
   } else {
-    device.snaplen = WTAP_MAX_PACKET_SIZE;
+    device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
   }
   filter_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(filter_cm));
   if (device.cfilter)
@@ -2527,8 +2527,8 @@ adjust_snap_sensitivity(GtkWidget *tb _U_, gpointer parent_w _U_)
       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb)));
   device.has_snaplen = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(snap_cb));
   if (!device.has_snaplen) {
-    gtk_spin_button_set_value(GTK_SPIN_BUTTON (snap_sb), WTAP_MAX_PACKET_SIZE);
-    device.snaplen = WTAP_MAX_PACKET_SIZE;
+    gtk_spin_button_set_value(GTK_SPIN_BUTTON (snap_sb), WTAP_MAX_PACKET_SIZE_STANDARD);
+    device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
   }
   g_array_insert_val(global_capture_opts.all_ifaces, marked_interface, device);
 }
@@ -2654,7 +2654,7 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum
   device.monitor_mode_supported = FALSE;
 #endif
   device.has_snaplen = FALSE;
-  device.snaplen = WTAP_MAX_PACKET_SIZE;
+  device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
   device.cfilter = NULL;
 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
   device.buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
@@ -2897,7 +2897,7 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum
   gtk_box_pack_start(GTK_BOX(snap_hb), snap_cb, FALSE, FALSE, 0);
 
   snap_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) device.snaplen,
-    MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
+    MIN_PACKET_SIZE, WTAP_MAX_PACKET_SIZE_STANDARD, 1.0, 10.0, 0.0);
   snap_sb = gtk_spin_button_new (snap_adj, 0, 0);
   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (snap_sb), TRUE);
   gtk_widget_set_size_request(snap_sb, 80, -1);
@@ -2979,7 +2979,7 @@ void options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColum
   gtk_box_pack_start (GTK_BOX(buffer_size_hb), buffer_size_lb, FALSE, FALSE, 0);
 
   buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new((gfloat) device.buffer,
-    1, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
+    1, WTAP_MAX_PACKET_SIZE_STANDARD, 1.0, 10.0, 0.0);
   buffer_size_sb = gtk_spin_button_new (buffer_size_adj, 0, 0);
   gtk_spin_button_set_value(GTK_SPIN_BUTTON (buffer_size_sb), (gfloat) device.buffer);
   gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (buffer_size_sb), TRUE);
@@ -5752,7 +5752,7 @@ create_and_fill_model(GtkTreeView *view)
         device.has_snaplen = hassnap;
       } else {
         /* No preferences set yet, use default values */
-        device.snaplen = WTAP_MAX_PACKET_SIZE;
+        device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
         device.has_snaplen = FALSE;
       }
 
index 0076fe9bde6487c4140e3cdf999bbf7d7e652052..b5745a6d7e0691417f7c0d335a8cf7a72d482054 100644 (file)
@@ -501,7 +501,7 @@ file_import_open(text_import_info_t *info)
     int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
     int_data_mand->wtap_encap            = info->encapsulation;
     int_data_mand->time_units_per_second = 1000000; /* default microsecond resolution */
-    int_data_mand->snap_len              = WTAP_MAX_PACKET_SIZE;
+    int_data_mand->snap_len              = WTAP_MAX_PACKET_SIZE_STANDARD;
     wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF File->Import", strlen("Fake IF File->Import"));
 
     g_array_append_val(idb_inf->interface_data, int_data);
@@ -1155,7 +1155,7 @@ file_import_dlg_new(void)
 
     framelen_te = gtk_entry_new();
     maxsize_msg = g_strdup_printf("The maximum size of the frames to write to the import capture file (max %u)",
-                                  WTAP_MAX_PACKET_SIZE);
+                                  WTAP_MAX_PACKET_SIZE_STANDARD);
     gtk_widget_set_tooltip_text(framelen_te, maxsize_msg);
     g_free(maxsize_msg);
     gtk_box_pack_start(GTK_BOX(framelen_hb), framelen_te, FALSE, FALSE, 0);
index 15fd6b96449030e792a18b22b8a1a3738da5c4bf..e3dcd57d7b1ff28e1c96a7d032ea03a8a38d8e86 100644 (file)
@@ -128,7 +128,7 @@ void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
   g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", wtap_file_type_subtype_string(summary.file_type));
   add_string_to_box(string_buff, file_box);
 
-  if (summary.has_snap) {
+  if (summary.snap != 0) {
     /* snapshot length */
     g_snprintf(string_buff, SUM_STR_MAX, "Snapshot length: %u", summary.snap);
     add_string_to_box(string_buff, file_box);
index 19177204491816cd8856396d9576da7f8f40b0bc..7e2d4c93c3922a70e36fab2e58d678fd274d0889 100644 (file)
@@ -339,7 +339,7 @@ mtp3_sum_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
     g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", (file_type ? file_type : "N/A"));
     add_string_to_box(string_buff, file_box);
 
-    if (summary.has_snap) {
+    if (summary.snap != 0) {
         /* snapshot length */
         g_snprintf(string_buff, SUM_STR_MAX, "Snapshot length: %u", summary.snap);
         add_string_to_box(string_buff, file_box);
index d12499726c0ca6b404e2317305daf27b722edbb1..ff716c083b5f2db2540af1ef4057405c4ebdbab8 100644 (file)
@@ -677,7 +677,7 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
 
 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
        renderer = gtk_cell_renderer_spin_new ();
-       buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new(DEFAULT_CAPTURE_BUFFER_SIZE, 1, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
+       buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new(DEFAULT_CAPTURE_BUFFER_SIZE, 1, WTAP_MAX_PACKET_SIZE_STANDARD, 1.0, 10.0, 0.0);
        g_object_set(G_OBJECT(renderer), "adjustment", buffer_size_adj, NULL);
        column = gtk_tree_view_column_new_with_attributes ("Default buffer size (MiB)", renderer,
                                                           "text", BUF_COLUMN,
@@ -695,7 +695,7 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
        gtk_tree_view_column_set_resizable(column, FALSE);
        /*gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);*/
        renderer = gtk_cell_renderer_spin_new ();
-       snaplen_adj = (GtkAdjustment *) gtk_adjustment_new(WTAP_MAX_PACKET_SIZE, 1, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
+       snaplen_adj = (GtkAdjustment *) gtk_adjustment_new(WTAP_MAX_PACKET_SIZE_STANDARD, 1, WTAP_MAX_PACKET_SIZE_STANDARD, 1.0, 10.0, 0.0);
        g_object_set(G_OBJECT(renderer), "adjustment", snaplen_adj, NULL);
        column = gtk_tree_view_column_new_with_attributes ("Default snap length", renderer,
                                                           "text", SNAPLEN_COLUMN,
@@ -834,7 +834,7 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
        ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), if_buffersize_lb, 0, row, 1, 1);
        gtk_misc_set_alignment(GTK_MISC(if_buffersize_lb), 1.0f, 0.5f);
        gtk_widget_show(if_buffersize_lb);
-       buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new(DEFAULT_CAPTURE_BUFFER_SIZE, 1, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
+       buffer_size_adj = (GtkAdjustment *) gtk_adjustment_new(DEFAULT_CAPTURE_BUFFER_SIZE, 1, WTAP_MAX_PACKET_SIZE_STANDARD, 1.0, 10.0, 0.0);
        if_buffersize_cb = gtk_spin_button_new (buffer_size_adj, 0, 0);
        g_signal_connect(if_buffersize_cb, "value-changed", G_CALLBACK(ifopts_edit_buffersize_changed_cb),
                        cur_list);
@@ -852,7 +852,7 @@ ifopts_edit_cb(GtkWidget *w, gpointer data _U_)
                        cur_list);
        ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), if_snaplen_tg, 2, row, 1, 1);
        gtk_widget_show(if_snaplen_tg);
-       snaplen_adj = (GtkAdjustment *) gtk_adjustment_new(WTAP_MAX_PACKET_SIZE, 1, WTAP_MAX_PACKET_SIZE, 1.0, 10.0, 0.0);
+       snaplen_adj = (GtkAdjustment *) gtk_adjustment_new(WTAP_MAX_PACKET_SIZE_STANDARD, 1, WTAP_MAX_PACKET_SIZE_STANDARD, 1.0, 10.0, 0.0);
        if_snaplen_cb = gtk_spin_button_new (snaplen_adj, 0, 0);
        g_signal_connect(if_snaplen_cb, "value-changed", G_CALLBACK(ifopts_edit_snaplen_changed_cb),
                        cur_list);
@@ -1449,7 +1449,7 @@ ifopts_edit_snaplen_changed_cb(GtkSpinButton *sb _U_, gpointer udata _U_)
 
        /* get current description text and set value in list_store for currently selected interface */
        snaplen = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(sb));
-       if (snaplen != WTAP_MAX_PACKET_SIZE) {
+       if (snaplen != WTAP_MAX_PACKET_SIZE_STANDARD) {
                hassnap = TRUE;
        } else {
                hassnap = FALSE;
@@ -1656,7 +1656,7 @@ ifopts_options_add(GtkListStore *list_store, if_info_t *if_info)
 #endif
 
         if (!capture_dev_user_snaplen_find(if_info->name, &hassnap, &snaplen)) {
-               snaplen = WTAP_MAX_PACKET_SIZE;
+               snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
                hassnap = FALSE;
        }
 
@@ -2007,7 +2007,7 @@ ifopts_write_new_snaplen(void)
                         * create/cat interface snap length to new string
                         * (leave space for parens, comma and terminator)
                         */
-                       tmp_snaplen = g_strdup_printf("%s:%d(%d)", ifnm, hassnap, (hassnap?snaplen:WTAP_MAX_PACKET_SIZE));
+                       tmp_snaplen = g_strdup_printf("%s:%d(%d)", ifnm, hassnap, (hassnap?snaplen:WTAP_MAX_PACKET_SIZE_STANDARD));
                        g_strlcat(new_snaplen, tmp_snaplen, MAX_VAL_LEN);
                        g_free(tmp_snaplen);
                        g_free(ifnm);
index 41946ca9ea1a0dffb242e30adbed3e02810a6021..e219f6648fd39892b36f31d1d0cc6f250e7d4392 100644 (file)
@@ -268,7 +268,7 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
     g_snprintf(string_buff, SUM_STR_MAX, "%s", wtap_encap_string(summary.file_encap_type));
     add_string_to_grid(grid, &row, "Encapsulation:", string_buff);
   }
-  if (summary.has_snap) {
+  if (summary.snap != 0) {
     /* snapshot length */
     g_snprintf(string_buff, SUM_STR_MAX, "%u bytes", summary.snap);
     add_string_to_grid(grid, &row, "Packet size limit:", string_buff);
@@ -708,7 +708,7 @@ summary_to_texbuff(GtkTextBuffer *buffer)
     g_snprintf(string_buff, SUM_STR_MAX, INDENT "Encapsulation: %s\n", wtap_encap_string(summary.file_encap_type));
     gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
   }
-  if (summary.has_snap) {
+  if (summary.snap != 0) {
     /* snapshot length */
     g_snprintf(string_buff, SUM_STR_MAX, INDENT "Packet size limit: %u bytes\n", summary.snap);
     gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
index 0cf0404fd03ead48ae30fa402064e45741603ae4..dd53edfd32da462081ca4023140d7cad4e517f58 100644 (file)
@@ -192,7 +192,7 @@ QString CaptureFilePropertiesDialog::summaryToHtml()
         << table_data_tmpl.arg(encaps_str)
         << table_row_end;
 
-    if (summary.has_snap) {
+    if (summary.snap != 0) {
         out << table_row_begin
             << table_vheader_tmpl.arg(tr("Snapshot length"))
             << table_data_tmpl.arg(summary.snap)
index 3148e4fccc77840029a34f7291937d3e426b3ce8..d2969c0df71309c2d19b7d54e3be3a84446cc6b0 100644 (file)
@@ -704,10 +704,10 @@ void CaptureInterfacesDialog::updateInterfaces()
             if (capture_dev_user_snaplen_find(device->name, &hassnap, &snaplen)) {
                 /* Default snap length set in preferences */
                 device->snaplen = snaplen;
-                device->has_snaplen = snaplen == WTAP_MAX_PACKET_SIZE ? FALSE : hassnap;
+                device->has_snaplen = snaplen == WTAP_MAX_PACKET_SIZE_STANDARD ? FALSE : hassnap;
             } else {
                 /* No preferences set yet, use default values */
-                device->snaplen = WTAP_MAX_PACKET_SIZE;
+                device->snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
                 device->has_snaplen = FALSE;
             }
 
@@ -1009,7 +1009,7 @@ bool CaptureInterfacesDialog::saveOptionsToPreferences()
                 snaplen_list << QString("%1:%2(%3)")
                                 .arg(device->name)
                                 .arg(device->has_snaplen)
-                                .arg(device->has_snaplen ? device->snaplen : WTAP_MAX_PACKET_SIZE);
+                                .arg(device->has_snaplen ? device->snaplen : WTAP_MAX_PACKET_SIZE_STANDARD);
             }
             g_free(prefs.capture_devices_snaplen);
             prefs.capture_devices_snaplen = qstring_strdup(snaplen_list.join(","));
@@ -1197,7 +1197,7 @@ QWidget* InterfaceTreeDelegate::createEditor(QWidget *parent, const QStyleOption
 #ifdef SHOW_BUFFER_COLUMN
     gint buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
 #endif
-    guint snap = WTAP_MAX_PACKET_SIZE;
+    guint snap = WTAP_MAX_PACKET_SIZE_STANDARD;
     GList *links = NULL;
 
     if (idx.column() > 1 && idx.data().toString().compare(UTF8_EM_DASH)) {
@@ -1247,7 +1247,7 @@ QWidget* InterfaceTreeDelegate::createEditor(QWidget *parent, const QStyleOption
         case col_snaplen_:
         {
             QSpinBox *sb = new QSpinBox(parent);
-            sb->setRange(1, WTAP_MAX_PACKET_SIZE);
+            sb->setRange(1, WTAP_MAX_PACKET_SIZE_STANDARD);
             sb->setValue(snap);
             sb->setWrapping(true);
             connect(sb, SIGNAL(valueChanged(int)), this, SLOT(snapshotLengthChanged(int)));
@@ -1258,7 +1258,7 @@ QWidget* InterfaceTreeDelegate::createEditor(QWidget *parent, const QStyleOption
         case col_buffer_:
         {
             QSpinBox *sb = new QSpinBox(parent);
-            sb->setRange(1, WTAP_MAX_PACKET_SIZE);
+            sb->setRange(1, WTAP_MAX_PACKET_SIZE_STANDARD);
             sb->setValue(buffer);
             sb->setWrapping(true);
             connect(sb, SIGNAL(valueChanged(int)), this, SLOT(bufferSizeChanged(int)));
@@ -1332,12 +1332,12 @@ void InterfaceTreeDelegate::snapshotLengthChanged(int value)
     if (!device) {
         return;
     }
-    if (value != WTAP_MAX_PACKET_SIZE) {
+    if (value != WTAP_MAX_PACKET_SIZE_STANDARD) {
         device->has_snaplen = true;
         device->snaplen = value;
     } else {
         device->has_snaplen = false;
-        device->snaplen = WTAP_MAX_PACKET_SIZE;
+        device->snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
     }
 }
 
index ca718259a43f267a16187bcc84a995f2c53465cd..fda2332a33dff44d49640a65b5ac33af57008186 100644 (file)
@@ -88,7 +88,7 @@ void CompiledFilterOutput::compileFilter()
             if (interfaces.compare(device.display_name)) {
                 continue;
             } else {
-                pcap_t *pd = pcap_open_dead(device.active_dlt, WTAP_MAX_PACKET_SIZE);
+                pcap_t *pd = pcap_open_dead(device.active_dlt, WTAP_MAX_PACKET_SIZE_STANDARD);
                 if (pd == NULL)
                     break;
                 g_mutex_lock(pcap_compile_mtx);
index 4b8c50747d9adb39aeb1a4866f8404e1ffab1c32..a13b116047000334fe235c18aee29e72cac5b838 100644 (file)
@@ -128,7 +128,7 @@ QString GsmMapSummaryDialog::summaryToHtml()
         << table_data_tmpl.arg(format_str)
         << table_row_end;
 
-    if (summary.has_snap) {
+    if (summary.snap != 0) {
         out << table_row_begin
             << table_vheader_tmpl.arg(tr("Snapshot length"))
             << table_data_tmpl.arg(summary.snap)
index e89e266868b938403fe5b66c82ded78c98f77086..5447f80332bb38660830b7bc1001a43814242706 100644 (file)
@@ -210,7 +210,7 @@ void InterfaceTreeCacheModel::save()
                 else if ( col == IFTREE_COL_SNAPLEN )
                 {
                     int iVal = saveValue.toInt();
-                    if ( iVal != WTAP_MAX_PACKET_SIZE )
+                    if ( iVal != WTAP_MAX_PACKET_SIZE_STANDARD )
                     {
                         device.has_snaplen = true;
                         device.snaplen = iVal;
@@ -218,7 +218,7 @@ void InterfaceTreeCacheModel::save()
                     else
                     {
                         device.has_snaplen = false;
-                        device.snaplen = WTAP_MAX_PACKET_SIZE;
+                        device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
                     }
                 }
 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
@@ -270,7 +270,7 @@ void InterfaceTreeCacheModel::save()
                 prefStorage[&prefs.capture_devices_snaplen]  <<
                         QString("%1:%2(%3)").arg(device.name).
                         arg(device.has_snaplen ? 1 : 0).
-                        arg(device.has_snaplen ? value : WTAP_MAX_PACKET_SIZE);
+                        arg(device.has_snaplen ? value : WTAP_MAX_PACKET_SIZE_STANDARD);
             }
 
 #ifdef CAN_SET_CAPTURE_BUFFER_SIZE
index 62fcc7107cb43fbcc43985a5c89a12a1ef25b1ec..3affcc94b29e0a132fa54e6a16ba497cf73e4204 100644 (file)
@@ -133,7 +133,7 @@ QString Mtp3SummaryDialog::summaryToHtml()
         << table_data_tmpl.arg(format_str)
         << table_row_end;
 
-    if (summary.has_snap) {
+    if (summary.snap != 0) {
         out << table_row_begin
             << table_vheader_tmpl.arg(tr("Snapshot length"))
             << table_data_tmpl.arg(summary.snap)
index 76e4326ab39a65b0b396aeaa674fc0526e444e70..3624e88c428b8dab89181016bfb410d390d91244 100644 (file)
@@ -146,7 +146,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
     int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
     int_data_mand->wtap_encap      = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
     int_data_mand->time_units_per_second = 1000000000; /* default nanosecond resolution */
-    int_data_mand->snap_len        = WTAP_MAX_PACKET_SIZE;
+    int_data_mand->snap_len        = WTAP_MAX_PACKET_SIZE_STANDARD;
 
     wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export", strlen("Fake IF, PDU->Export"));
     wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 9);
@@ -156,7 +156,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
     g_array_append_val(shb_hdrs, shb_hdr);
 
     /* Use a random name for the temporary import buffer */
-    exp_pdu_tap_data->wdh = wtap_dump_fdopen_ng(fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE, FALSE,
+    exp_pdu_tap_data->wdh = wtap_dump_fdopen_ng(fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE_STANDARD, FALSE,
         shb_hdrs, idb_inf, NULL, &err);
     if (exp_pdu_tap_data->wdh == NULL) {
         g_assert(err != 0);
index 46f619421c8322f4d4c26edb0210e00d207c7699..71ee2a294851de37693734178c3a5004cf898cbf 100644 (file)
@@ -37,7 +37,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define IMPORT_MAX_PACKET WTAP_MAX_PACKET_SIZE
+#define IMPORT_MAX_PACKET WTAP_MAX_PACKET_SIZE_STANDARD
 
 /* The parameter interface */
 
index 3ee32d17e912994256774d979c6e65255cc66669..349293be116e616343c2f8b4c40bb7487c7e5981 100644 (file)
@@ -215,14 +215,14 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
                        return FALSE;
        } while (1);
 
-       if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE) {
+       if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("5views: File has %u-byte packet, bigger than maximum of %u",
-                   wth->phdr.caplen, WTAP_MAX_PACKET_SIZE);
+                   wth->phdr.caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
@@ -361,7 +361,7 @@ static gboolean _5views_dump(wtap_dumper *wdh,
        }
 
        /* Don't write out something bigger than we can read. */
-       if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+       if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
                *err = WTAP_ERR_PACKET_TOO_LARGE;
                return FALSE;
        }
index beff703bf47395fabc8b5ada47f83e96b90fd18f..d7f50fcd849918b34668db68e348b01c5f1a3a1d 100644 (file)
@@ -313,7 +313,7 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
                    (unsigned int)(sizeof *hdr - sizeof hdr->rec_size));
                return FALSE;
        }
-       if (rec_size > WTAP_MAX_PACKET_SIZE) {
+       if (rec_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; return an error,
                 * so that our caller doesn't blow up trying to allocate
@@ -321,7 +321,7 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("aethra: File has %u-byte packet, bigger than maximum of %u",
-                   rec_size, WTAP_MAX_PACKET_SIZE);
+                   rec_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index 208f8b4ff7f91227c3e0b7ce2fc0261601fc69e3..a2afb3430defef550411416d2bba726230cfd2dd 100644 (file)
@@ -24,7 +24,7 @@
 #include <glib.h>
 
 /*
- * ASCEND_MAX_PKT_LEN is < WTAP_MAX_PACKET_SIZE, so we don't need to
+ * ASCEND_MAX_PKT_LEN is < WTAP_MAX_PACKET_SIZE_STANDARD, so we don't need to
  * check the packet length.
  */
 #define ASCEND_MAX_DATA_ROWS 8
index 998c9589b8bb6180845c4761856ad593ffb5bb18..331beba75fa667ebc88b617e04d12c7866f4dde8 100644 (file)
@@ -183,14 +183,14 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
     packet_size = g_ntohl(hdr.incl_len);
     orig_size = g_ntohl(hdr.orig_len);
     flags = g_ntohl(hdr.flags);
-    if (packet_size > WTAP_MAX_PACKET_SIZE) {
+    if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
         /*
          * Probably a corrupt capture file; don't blow up trying
          * to allocate space for an immensely-large packet.
          */
         *err = WTAP_ERR_BAD_FILE;
         *err_info = g_strdup_printf("btsnoop: File has %u-byte packet, bigger than maximum of %u",
-                                    packet_size, WTAP_MAX_PACKET_SIZE);
+                                    packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
         return FALSE;
     }
 
@@ -326,7 +326,7 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh,
      * Don't write out anything bigger than we can read.
      * (This will also fail on a caplen of 0, as it should.)
      */
-    if (phdr->caplen-1 > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen-1 > WTAP_MAX_PACKET_SIZE_STANDARD) {
         *err = WTAP_ERR_PACKET_TOO_LARGE;
         return FALSE;
     }
@@ -368,7 +368,7 @@ static gboolean btsnoop_dump_h4(wtap_dumper *wdh,
     }
 
     /* Don't write out anything bigger than we can read. */
-    if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
         *err = WTAP_ERR_PACKET_TOO_LARGE;
         return FALSE;
     }
index b52a0ae292d25068312f83795afb39df7c91c7e1..65dda8d2f20dbea669baaec69496c9e39fe3520c 100644 (file)
@@ -317,7 +317,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     /*
      * The maximum value of length is 65535, which, even after
      * DVB_CI_PSEUDO_HDR_LEN is added to it, is less than
-     * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
+     * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check
      * it.
      */
 
index 1d65c1c33b150afc05ace47412083b3a4dc61f9d..f18e0c51bbfa75ca10c94d92e1c01cf545456111 100644 (file)
@@ -371,24 +371,24 @@ capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                *err = WTAP_ERR_INTERNAL;
                return -1;
        }
-       if (orig_size > WTAP_MAX_PACKET_SIZE) {
+       if (orig_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("capsa: File has %u-byte original length, bigger than maximum of %u",
-                   orig_size, WTAP_MAX_PACKET_SIZE);
+                   orig_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return -1;
        }
-       if (packet_size > WTAP_MAX_PACKET_SIZE) {
+       if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("capsa: File has %u-byte packet, bigger than maximum of %u",
-                   packet_size, WTAP_MAX_PACKET_SIZE);
+                   packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return -1;
        }
        if (header_size + packet_size > rec_size) {
index 4264f2ae7297dfa13a632bd858707183581d8aef..04013d5a6e35bb9c487c360b3297fffcf460c4e2 100644 (file)
@@ -1329,7 +1329,7 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
                    1 +                                 /* direction */
                    1 +                                 /* encap */
                    (is_comment ? data_chars : (data_chars/2));
-    if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
         /*
          * Probably a corrupt capture file; return an error,
          * so that our caller doesn't blow up trying to allocate
@@ -1337,7 +1337,7 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
          */
         *err = WTAP_ERR_BAD_FILE;
         *err_info = g_strdup_printf("catapult dct2000: File has %u-byte packet, bigger than maximum of %u",
-                                    phdr->caplen, WTAP_MAX_PACKET_SIZE);
+                                    phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
         return FALSE;
     }
     phdr->len = phdr->caplen;
index e6dbd8101f2aaa63ed0fc7af9273daa215c008bf..77d3a6121e21c0eddd9c5a93fbbacb0081105c72 100644 (file)
@@ -148,7 +148,7 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                return FALSE;
        /*
         * The maximum value of cv_hdr.data_len is 65535, which is less
-        * than WTAP_MAX_PACKET_SIZE will ever be, so we don't need to
+        * than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to
         * check it.
         */
 
index c7f5952294211a2c289b1f40531d3a06d452c620..b7a23b314392d2aa0237076cc3c8722db58fbdf0 100644 (file)
@@ -373,14 +373,14 @@ parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                *err_info = g_strdup("cosine: packet header has a negative packet length");
                return FALSE;
        }
-       if (pkt_len > WTAP_MAX_PACKET_SIZE) {
+       if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("cosine: File has %u-byte packet, bigger than maximum of %u",
-                   pkt_len, WTAP_MAX_PACKET_SIZE);
+                   pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index 3f4b3eefcc62516a4e3b3e30a1f83892191b889b..2d44a10c9379c8c4e9e0e56cea75ea1c8327f241 100644 (file)
@@ -181,7 +181,7 @@ csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr,
   hdr.caplen = pntoh16(&hdr.caplen);
   /*
    * The maximum value of hdr.caplen is 65535, which is less than
-   * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
+   * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check
    * it.
    */
 
index 3deca1dff786e75344dbb15980973035ab9d6bdd..b1016fa072190acdbcd8a0cfbd3a9088390cccc5 100644 (file)
@@ -194,7 +194,7 @@ daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        phdr->ts.nsecs = useconds * 1000; /* convert mS to nS */
 
        /*
-        * READDATA_BUF_SIZE is < WTAP_MAX_PACKET_SIZE, and is the maximum
+        * READDATA_BUF_SIZE is < WTAP_MAX_PACKET_SIZE_STANDARD, and is the maximum
         * number of bytes of packet data we can generate, so we don't
         * need to check the packet length.
         */
index 5c6933ab600bd14f6d08d5b16ddd405c3b833bd8..301ff90ebdf75c0ce288b8c78df7d60010fc6e8e 100644 (file)
@@ -449,7 +449,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
     phdr->caplen = eth_hdr_len + pkt_len;
     phdr->len = eth_hdr_len + pkt_len;
 
-    if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
         /*
          * Probably a corrupt capture file; return an error,
          * so that our caller doesn't blow up trying to allocate
@@ -457,7 +457,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
          */
         *err = WTAP_ERR_BAD_FILE;
         *err_info = g_strdup_printf("dbs_etherwatch: File has %u-byte packet, bigger than maximum of %u",
-                                    phdr->caplen, WTAP_MAX_PACKET_SIZE);
+                                    phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
         return FALSE;
     }
 
index 7b1fe9d5ffcb912ce916e073762d4f6013bbd089..702420b55df9675cfddb70c4c05b4d0482f12054 100644 (file)
@@ -278,7 +278,7 @@ extern wtap_open_return_val erf_open(wtap *wth, int *err, gchar **err_info)
     }
 
     packet_size = rlen - (guint32)sizeof(header);
-    if (packet_size > WTAP_MAX_PACKET_SIZE) {
+    if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
       /*
        * Probably a corrupt capture file or a file that's not an ERF file
        * but that passed earlier tests.
@@ -373,7 +373,7 @@ extern wtap_open_return_val erf_open(wtap *wth, int *err, gchar **err_info)
         break;
     }
 
-    if (packet_size > WTAP_MAX_PACKET_SIZE) {
+    if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
       /*
        * Probably a corrupt capture file or a file that's not an ERF file
        * but that passed earlier tests.
@@ -506,14 +506,14 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
 
   *packet_size =  g_ntohs(erf_header->rlen) - (guint32)sizeof(*erf_header);
 
-  if (*packet_size > WTAP_MAX_PACKET_SIZE) {
+  if (*packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
     /*
      * Probably a corrupt capture file; don't blow up trying
      * to allocate space for an immensely-large packet.
      */
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup_printf("erf: File has %u-byte packet, bigger than maximum of %u",
-                                *packet_size, WTAP_MAX_PACKET_SIZE);
+                                *packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
     return FALSE;
   }
 
@@ -691,14 +691,14 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
                         g_ntohs(erf_header->rlen) - (guint32)sizeof(*erf_header) - skiplen );
   }
 
-  if (*packet_size > WTAP_MAX_PACKET_SIZE) {
+  if (*packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
     /*
      * Probably a corrupt capture file; don't blow up trying
      * to allocate space for an immensely-large packet.
      */
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup_printf("erf: File has %u-byte packet, bigger than maximum of %u",
-                                *packet_size, WTAP_MAX_PACKET_SIZE);
+                                *packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
     return FALSE;
   }
 
@@ -808,7 +808,7 @@ static gboolean erf_dump(
   guint32  crc32        = 0x00000000;
 
   /* Don't write anything bigger than we're willing to read. */
-  if(phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+  if(phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
     *err = WTAP_ERR_PACKET_TOO_LARGE;
     return FALSE;
   }
index c545373ffed37adc76399c128808b1490cee1f4e..4a592714fb97673508740b7ecc05843a0281d93d 100644 (file)
@@ -300,10 +300,10 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
                break;
        }
 
-       if(pkt_len > WTAP_MAX_PACKET_SIZE) {
+       if(pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) {
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("eyesdn: File has %u-byte packet, bigger than maximum of %u",
-                   pkt_len, WTAP_MAX_PACKET_SIZE);
+                   pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index 91fcf718b0050e62e5f3cf2acb54410d33f06f88..3700a9fb44a1b4a712f18c2262f316c7a4e21e7c 100644 (file)
@@ -2228,6 +2228,25 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
                descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(descr);
                descr_mand->wtap_encap = encap;
                descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
+               if (snaplen == 0) {
+                       /*
+                        * No snapshot length was specified.  Pick an
+                        * appropriate snapshot length for this
+                        * link-layer type.
+                        *
+                        * We use WTAP_MAX_PACKET_SIZE_STANDARD for everything except
+                        * D-Bus, which has a maximum packet size of 128MB,
+                        * which is more than we want to put into files
+                        * with other link-layer header types, as that
+                        * might cause some software reading those files
+                        * to allocate an unnecessarily huge chunk of
+                        * memory for a packet buffer.
+                        */
+                       if (encap == WTAP_ENCAP_DBUS)
+                               snaplen = 128*1024*1024;
+                       else
+                               snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
+               }
                descr_mand->snap_len = snaplen;
                descr_mand->num_stat_entries = 0;          /* Number of ISB:s */
                descr_mand->interface_statistics = NULL;
index 3e7ee662729122383749277672c0388344659f40..d89b8359c406aaff5ce2b747a607bab5908ee37b 100644 (file)
@@ -43,14 +43,14 @@ static gboolean hcidump_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
                return FALSE;
 
        packet_size = GUINT16_FROM_LE(dh.len);
-       if (packet_size > WTAP_MAX_PACKET_SIZE) {
+       if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("hcidump: File has %u-byte packet, bigger than maximum of %u",
-                       packet_size, WTAP_MAX_PACKET_SIZE);
+                       packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index 69d2788f54111435d2458f8060b334611b731c0a..106ef647a5f4496075d4599f0e37835925653467 100644 (file)
@@ -164,14 +164,14 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                return FALSE;
        }
        length = hdr.length - (guint32)sizeof(hdr);
-       if (length > WTAP_MAX_PACKET_SIZE) {
+       if (length > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("i4btrace: File has %u-byte packet, bigger than maximum of %u",
-                   length, WTAP_MAX_PACKET_SIZE);
+                   length, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index 64f38764c94937e6d5f62abfd1b62e4073a58065..75987b54b815a0dd799c9e04feeb303227b5cad0 100644 (file)
@@ -161,7 +161,7 @@ ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, g
         return FALSE;
     /*
      * The maximum value of msg_hdr.message_length is 65535, which is
-     * less than WTAP_MAX_PACKET_SIZE will ever be, so we don't need
+     * less than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need
      * to check it.
      */
 
index bfa278b3f55ccc3f637a782cc4b14dcc5cff155f..cba013b06bf5ac6530d33b7f3f2279065322e478 100644 (file)
@@ -181,14 +181,14 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                if (!wtap_read_bytes(fh, NULL, 3, err, err_info))
                        return FALSE;
        }
-       if (packet_size > WTAP_MAX_PACKET_SIZE) {
+       if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("iptrace: File has %u-byte packet, bigger than maximum of %u",
-                   packet_size, WTAP_MAX_PACKET_SIZE);
+                   packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
@@ -374,14 +374,14 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                if (!wtap_read_bytes(fh, NULL, 3, err, err_info))
                        return FALSE;
        }
-       if (packet_size > WTAP_MAX_PACKET_SIZE) {
+       if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("iptrace: File has %u-byte packet, bigger than maximum of %u",
-                   packet_size, WTAP_MAX_PACKET_SIZE);
+                   packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index aec989203d98368bd6e848efcf1973389ba523fc..c14b1eddc53474841e7b0e2d7c76a7e431f29e06 100644 (file)
@@ -720,7 +720,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
            * Check the length first, just in case it's *so* big that, after
            * adding the Ethernet header length, it overflows.
            */
-          if (pkt_len > WTAP_MAX_PACKET_SIZE - 14)
+          if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD - 14)
             {
               /*
                * Probably a corrupt capture file; don't blow up trying
@@ -732,7 +732,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
               *err = WTAP_ERR_BAD_FILE;
               *err_info = g_strdup_printf("iseries: File has %" G_GUINT64_FORMAT "-byte packet, bigger than maximum of %u",
                                           (guint64)pkt_len + 14,
-                                          WTAP_MAX_PACKET_SIZE);
+                                          WTAP_MAX_PACKET_SIZE_STANDARD);
               return FALSE;
             }
           pkt_len += 14;
index 5196a0e1a6a78aefc5b9d85e9ada9f148d06d531..6191f1c9bafe32f004be0b7018a3a5b9b71a494e 100644 (file)
@@ -486,7 +486,7 @@ static gint get_record(k12_t *file_data, FILE_T fh, gint64 file_offset,
      * Record length must be at least large enough for the length
      * and type, hence 8 bytes.
      *
-     * XXX - is WTAP_MAX_PACKET_SIZE the right check for a maximum
+     * XXX - is WTAP_MAX_PACKET_SIZE_STANDARD the right check for a maximum
      * record size?  Should we report this error differently?
      */
     if (left < 8) {
@@ -494,9 +494,9 @@ static gint get_record(k12_t *file_data, FILE_T fh, gint64 file_offset,
         *err_info = g_strdup_printf("k12: Record length %u is less than 8 bytes long",left);
         return -1;
     }
-    if (left > WTAP_MAX_PACKET_SIZE) {
+    if (left > WTAP_MAX_PACKET_SIZE_STANDARD) {
         *err = WTAP_ERR_BAD_FILE;
-        *err_info = g_strdup_printf("k12: Record length %u is greater than the maximum %u",left,WTAP_MAX_PACKET_SIZE);
+        *err_info = g_strdup_printf("k12: Record length %u is greater than the maximum %u",left,WTAP_MAX_PACKET_SIZE_STANDARD);
         return -1;
     }
 
index 8b7a1572be05ca9da0f13ca29b2b16456345b6db..8e8cdca171a42ce298a9e727ccfc1f02c355ccb6 100644 (file)
@@ -145,7 +145,7 @@ typedef struct {
 #define SET_SECONDS(text) yyextra->g_s = (guint) strtoul(text,NULL,10)
 #define SET_MS(text) yyextra->g_ms = (guint) strtoul(text,NULL,10)
 #define SET_NS(text) yyextra->g_ns = (guint) strtoul(text,NULL,10)
-#define ADD_BYTE(text) do {if (yyextra->ii >= WTAP_MAX_PACKET_SIZE) {KERROR("frame too large");} yyextra->bb[yyextra->ii++] = (guint8)strtoul(text,NULL,16); } while(0)
+#define ADD_BYTE(text) do {if (yyextra->ii >= WTAP_MAX_PACKET_SIZE_STANDARD) {KERROR("frame too large");} yyextra->bb[yyextra->ii++] = (guint8)strtoul(text,NULL,16); } while(0)
 #define FINALIZE_FRAME() do { yyextra->ok_frame = TRUE; } while (0)
 /*~ #define ECHO*/
 #define YY_USER_ACTION yyextra->file_bytes_read += yyleng;
@@ -359,7 +359,7 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
        if ( file_seek(wth->fh, k12text->next_frame_offset, SEEK_SET, err) == -1) {
                return FALSE;
        }
-       state.bb = (guint8*)g_malloc(WTAP_MAX_PACKET_SIZE);
+       state.bb = (guint8*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
 
        if (!k12text_run_scanner(&state, wth->fh, NEXT_FRAME, err, err_info)) {
                g_free(state.bb);
@@ -400,7 +400,7 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *
        if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
                return FALSE;
        }
-       state.bb = (guint8*)g_malloc(WTAP_MAX_PACKET_SIZE);
+       state.bb = (guint8*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
 
        if (!k12text_run_scanner(&state, wth->random_fh, NEXT_FRAME, err, err_info)) {
                return FALSE;
@@ -435,7 +435,7 @@ k12text_open(wtap *wth, int *err, gchar **err_info _U_)
        k12text_t *k12text;
        k12text_state_t state;
 
-       state.bb = (guint8*)g_malloc(WTAP_MAX_PACKET_SIZE);
+       state.bb = (guint8*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
        if (!k12text_run_scanner(&state, wth->fh, MAGIC, err, err_info)) {
                g_free(state.bb);
                return WTAP_OPEN_ERROR;
@@ -494,7 +494,7 @@ k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
        struct tm *tmp;
 
        /* Don't write anything bigger than we're willing to read. */
-       if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+       if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
                *err = WTAP_ERR_PACKET_TOO_LARGE;
                return FALSE;
        }
index e18604246e94f6504dd6005582d6d7f60f4d29a7..71d78e4faa90fcf5543ae08826183801e564542b 100644 (file)
@@ -488,7 +488,7 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
       packet_size = pletoh16(&descriptor[6]);
       /*
        * The maximum value of packet_size is 65535, which is less than
-       * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
+       * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check
        * it.
        */
 
index 3d98ff0cbb081cc52447705cabd767aad670803a..c0b90cc5cb24d175e578e9c724509886ac261bd6 100644 (file)
@@ -558,7 +558,7 @@ static int libpcap_try_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
                        ret++;
                break;
        }
-       if (hdr->hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
+       if (hdr->hdr.incl_len > wtap_max_snaplen_for_encap(wth->file_encap)) {
                /*
                 * Probably either a corrupt capture file or a file
                 * of a type different from the one we're trying.
@@ -566,18 +566,19 @@ static int libpcap_try_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
                ret++;
        }
 
-       if (hdr->hdr.orig_len > 64*1024*1024) {
+       if (hdr->hdr.orig_len > 128*1024*1024) {
                /*
                 * In theory I guess the on-the-wire packet size can be
                 * arbitrarily large, and it can certainly be larger than the
                 * maximum snapshot length which bounds the snapshot size,
-                * but any file claiming 64MB in a single packet is *probably*
+                * but any file claiming 128MB in a single packet is *probably*
                 * corrupt, and treating them as such makes the heuristics
                 * much more reliable. See, for example,
                 *
                 *    https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9634
                 *
-                * (64MB is an arbitrary size at this point).
+                * (128MB is an arbitrary size at this point, chosen to be
+                * large enough for the largest D-Bus packet).
                 */
                ret++;
        }
@@ -652,7 +653,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        if (!libpcap_read_header(wth, fh, err, err_info, &hdr))
                return FALSE;
 
-       if (hdr.hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
+       if (hdr.hdr.incl_len > wtap_max_snaplen_for_encap(wth->file_encap)) {
                /*
                 * Probably a corrupt capture file; return an error,
                 * so that our caller doesn't blow up trying to allocate
@@ -661,7 +662,8 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                *err = WTAP_ERR_BAD_FILE;
                if (err_info != NULL) {
                        *err_info = g_strdup_printf("pcap: File has %u-byte packet, bigger than maximum of %u",
-                           hdr.hdr.incl_len, WTAP_MAX_PACKET_SIZE);
+                           hdr.hdr.incl_len,
+                           wtap_max_snaplen_for_encap(wth->file_encap));
                }
                return FALSE;
        }
@@ -874,10 +876,11 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, int *err)
         *
         * A snapshot length of 0, inside Wiretap, means "snapshot length
         * unknown"; if the snapshot length supplied to us is 0, we make
-        * the snapshot length in the header file WTAP_MAX_PACKET_SIZE.
+        * the snapshot length in the header file the maximum for the
+        * link-layer type we'll be writing.
         */
-       file_hdr.snaplen = (wdh->snaplen != 0) ? wdh->snaplen :
-                                                WTAP_MAX_PACKET_SIZE;
+       file_hdr.snaplen = (wdh->snaplen != 0) ? (guint)wdh->snaplen :
+                                                wtap_max_snaplen_for_encap(wdh->encap);
        file_hdr.network = wtap_wtap_encap_to_pcap_encap(wdh->encap);
        if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
                return FALSE;
@@ -905,8 +908,11 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
                return FALSE;
        }
 
-       /* Don't write anything we're not willing to read. */
-       if (phdr->caplen + phdrsize > WTAP_MAX_PACKET_SIZE) {
+       /*
+        * Don't write anything we're not willing to read.
+        * (The cast is to prevent an overflow.)
+        */
+       if ((guint64)phdr->caplen + phdrsize > wtap_max_snaplen_for_encap(wdh->encap)) {
                *err = WTAP_ERR_PACKET_TOO_LARGE;
                return FALSE;
        }
@@ -914,11 +920,6 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
        rec_hdr.hdr.incl_len = phdr->caplen + phdrsize;
        rec_hdr.hdr.orig_len = phdr->len + phdrsize;
 
-       if (rec_hdr.hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
-               *err = WTAP_ERR_BAD_FILE;
-               return FALSE;
-       }
-
        switch (wdh->file_type_subtype) {
 
        case WTAP_FILE_TYPE_SUBTYPE_PCAP:
index f37eda988b8758c9f072511d51e3d08b1974c950..74ac0c6c3084a77bd10f8e66755f36e8b5a29c5f 100644 (file)
@@ -189,7 +189,7 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
     /*
      * The maximum value of payload_length is 65535, which, even after
      * the size of the logger entry structure is added to it, is less
-     * than WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
+     * than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check
      * it.
      */
 
index a0e53bac1b091dc1c08aa39996300b5460f7f2fd..d0da5fc1cc1274af75cf013cf07d128415933962 100644 (file)
@@ -188,9 +188,9 @@ static gboolean logcat_text_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
     gchar *cbuff;
     gchar *ret = NULL;
 
-    cbuff = (gchar*)g_malloc(WTAP_MAX_PACKET_SIZE);
+    cbuff = (gchar*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
     do {
-        ret = file_gets(cbuff, WTAP_MAX_PACKET_SIZE, fh);
+        ret = file_gets(cbuff, WTAP_MAX_PACKET_SIZE_STANDARD, fh);
     } while (NULL != ret && 3 > strlen(cbuff) && !file_eof(fh));
 
     if (NULL == ret || 3 > strlen(cbuff)) {
@@ -205,13 +205,13 @@ static gboolean logcat_text_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
         int err;
         gchar *ret2 = NULL;
 
-        lbuff = (gchar*)g_malloc(WTAP_MAX_PACKET_SIZE);
+        lbuff = (gchar*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
         file_off = file_tell(fh);
-        ret2 = file_gets(lbuff,WTAP_MAX_PACKET_SIZE, fh);
+        ret2 = file_gets(lbuff,WTAP_MAX_PACKET_SIZE_STANDARD, fh);
         while (NULL != ret2 && 2 < strlen(lbuff) && !file_eof(fh)) {
-            g_strlcat(cbuff,lbuff,WTAP_MAX_PACKET_SIZE);
+            g_strlcat(cbuff,lbuff,WTAP_MAX_PACKET_SIZE_STANDARD);
             file_off = file_tell(fh);
-            ret2 = file_gets(lbuff,WTAP_MAX_PACKET_SIZE, fh);
+            ret2 = file_gets(lbuff,WTAP_MAX_PACKET_SIZE_STANDARD, fh);
         }
 
         if(NULL == ret2 || 2 < strlen(lbuff)) {
@@ -278,9 +278,9 @@ wtap_open_return_val logcat_text_open(wtap *wth, int *err, gchar **err_info _U_)
     if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
         return WTAP_OPEN_ERROR;
 
-    cbuff = (gchar*)g_malloc(WTAP_MAX_PACKET_SIZE);
+    cbuff = (gchar*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
     do {
-        ret = file_gets(cbuff, WTAP_MAX_PACKET_SIZE, wth->fh);
+        ret = file_gets(cbuff, WTAP_MAX_PACKET_SIZE_STANDARD, wth->fh);
     } while (NULL != ret && !file_eof(wth->fh)
             && ((3 > strlen(cbuff))
                     || g_regex_match_simple(SPECIAL_STRING, cbuff, (GRegexCompileFlags)((gint) G_REGEX_ANCHORED | (gint) G_REGEX_RAW),
index 0ba1b81a664a557408d3b2586d707b104f596d11..0f3c8017405372a3c48e9ac21a8ca7a855cb457b 100644 (file)
@@ -959,7 +959,7 @@ merge_files(const gchar* out_filename, const int file_type,
 
     if (snaplen == 0) {
         /* Snapshot length not specified - default to the maximum. */
-        snaplen = WTAP_MAX_PACKET_SIZE;
+        snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
     }
 
     /*
@@ -1062,7 +1062,7 @@ merge_files_to_tempfile(gchar **out_filenamep, const char *pfx,
 
     if (snaplen == 0) {
         /* Snapshot length not specified - default to the maximum. */
-        snaplen = WTAP_MAX_PACKET_SIZE;
+        snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
     }
 
     /*
@@ -1161,7 +1161,7 @@ merge_files_to_stdout(const int file_type, const char *const *in_filenames,
 
     if (snaplen == 0) {
         /* Snapshot length not specified - default to the maximum. */
-        snaplen = WTAP_MAX_PACKET_SIZE;
+        snaplen = WTAP_MAX_PACKET_SIZE_STANDARD;
     }
 
     /*
index 17bb9608a5c34f5d43248fb47f2eac39c541a0a9..951be170907127bfe0f6cf9d78284cbe025f364c 100644 (file)
@@ -4,9 +4,9 @@
  *
  * This is for use with Wireshark dissectors that handle file
  * formats (e.g., because they handle a particular MIME media type).
- * It breaks the file into chunks of at most WTAP_MAX_PACKET_SIZE,
+ * It breaks the file into chunks of at most WTAP_MAX_PACKET_SIZE_STANDARD,
  * each of which is reported as a packet, so that files larger than
- * WTAP_MAX_PACKET_SIZE can be handled by reassembly.
+ * WTAP_MAX_PACKET_SIZE_STANDARD can be handled by reassembly.
  *
  * The "MIME file" dissector does the reassembly, and hands the result
  * off to heuristic dissectors to try to identify the file's contents.
index 5507eef3bdebc645886059c5e0162c48dd1a38a2..69a4ef6b3bb0473af4161edae34b09fff5ed3e9f 100644 (file)
@@ -68,7 +68,7 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
     guint64 tmp;
 
     /*
-     * MP2T_SIZE will always be less than WTAP_MAX_PACKET_SIZE, so
+     * MP2T_SIZE will always be less than WTAP_MAX_PACKET_SIZE_STANDARD, so
      * we don't have to worry about the packet being too big.
      */
     ws_buffer_assure_space(buf, MP2T_SIZE);
index f258eac836d8932f2bf8b3d8578ce22847d982cf..84da71f7c0f8819e02b607fd58cda08bc6aa4f81 100644 (file)
@@ -494,14 +494,14 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                packet_size = pletoh32(&hdr.hdr_2_x.incl_len);
                break;
        }
-       if (packet_size > WTAP_MAX_PACKET_SIZE) {
+       if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("netmon: File has %u-byte packet, bigger than maximum of %u",
-                   packet_size, WTAP_MAX_PACKET_SIZE);
+                   packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FAILURE;
        }
 
@@ -998,7 +998,7 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
 
        case WTAP_FILE_TYPE_SUBTYPE_NETMON_2_x:
                /* Don't write anything we're not willing to read. */
-               if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+               if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
                        *err = WTAP_ERR_PACKET_TOO_LARGE;
                        return FALSE;
                }
index 6aa6781421661a1e406237ec83e12505c6b41be2..4b8b48db8b81a971e9e60865266da296a1475499 100644 (file)
@@ -974,7 +974,7 @@ static gboolean nstrace_set_start_time(wtap *wth, int *err, gchar **err_info)
 ** Netscaler trace format read routines.
 **
 ** The maximum value of the record data size is 65535, which is less than
-** WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
+** WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it.
 */
 #define TIMEDEFV10(phdr,fp,type) \
     do {\
@@ -1146,7 +1146,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *
 
 /*
 ** The maximum value of the record data size is 65535, which is less than
-** WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
+** WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it.
 */
 #define PARTSIZEDEFV20(phdr,pp,ver) \
     do {\
@@ -1351,7 +1351,7 @@ static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *
 
 /*
 ** The maximum value of the record data size is 65535, which is less than
-** WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
+** WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it.
 */
 #define FULLSIZEDEFV30(phdr,fp,ver)\
     do {\
@@ -1804,7 +1804,7 @@ static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
     /*
     ** Get the record length.
     ** The maximum value of the record data size is 65535, which is less
-    ** than WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
+    ** than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it.
     */
     record_length = nspr_getv20recordsize(&hdr);
 
index 1a913d6862f0f6408ed3e1f2bd3cb7d00d091278..f3f76a318c7e8d8118f196c19f55cf756dbe7650 100644 (file)
@@ -293,14 +293,14 @@ parse_netscreen_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
                *err_info = g_strdup("netscreen: packet header has a negative packet length");
                return FALSE;
        }
-       if (pkt_len > WTAP_MAX_PACKET_SIZE) {
+       if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("netscreen: File has %u-byte packet, bigger than maximum of %u",
-                   pkt_len, WTAP_MAX_PACKET_SIZE);
+                   pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index 371beb4c01bbceb063fddcfb4b813296a9ada421..533fa8678ef8deba4e530ce18d46b85931ca7d00 100644 (file)
@@ -569,14 +569,14 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     pseudo_header->nettl.pid      = pntoh32(&rec_hdr.pid);
     pseudo_header->nettl.uid      = pntoh16(&rec_hdr.uid);
 
-    if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
         /*
          * Probably a corrupt capture file; don't blow up trying
          * to allocate space for an immensely-large packet.
          */
         *err = WTAP_ERR_BAD_FILE;
         *err_info = g_strdup_printf("nettl: File has %u-byte packet, bigger than maximum of %u",
-            phdr->caplen, WTAP_MAX_PACKET_SIZE);
+            phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
         return FALSE;
     }
 
@@ -695,7 +695,7 @@ static gboolean nettl_dump(wtap_dumper *wdh,
     }
 
     /* Don't write anything we're not willing to read. */
-    if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
         *err = WTAP_ERR_PACKET_TOO_LARGE;
         return FALSE;
     }
index 08c8a3c2587b79ecb1fdb7b0c21606a605776087..25492709403f642843d35972424c87c728aff97c 100644 (file)
@@ -788,7 +788,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
        int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
        int_data_mand->wtap_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
        int_data_mand->time_units_per_second = 1000000; /* default microsecond resolution */
-       int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE;
+       int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE_STANDARD;
        wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF", strlen("Fake IF"));
        int_data_mand->num_stat_entries = 0;          /* Number of ISB:s */
        int_data_mand->interface_statistics = NULL;
@@ -796,7 +796,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
        g_array_append_val(idb_inf->interface_data, int_data);
 
        wdh_exp_pdu = wtap_dump_fdopen_ng(import_file_fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU,
-                                         WTAP_MAX_PACKET_SIZE, FALSE, shb_hdrs, idb_inf, NULL, &exp_pdu_file_err);
+                                         WTAP_MAX_PACKET_SIZE_STANDARD, FALSE, shb_hdrs, idb_inf, NULL, &exp_pdu_file_err);
        if (wdh_exp_pdu == NULL) {
                result = WTAP_OPEN_ERROR;
                goto end;
index a09d1b7f484dcf6f74411ae83a857b7a2c01c4a2..c0d24138c338ef4bcca388781aaae91ce85da6e7 100644 (file)
@@ -493,7 +493,7 @@ process_packet_header(wtap *wth, packet_entry_header *packet_header,
     }
     /*
      * The maximum value of packet_header->captured_size is 65535, which
-     * is less than WTAP_MAX_PACKET_SIZE will ever be, so we don't need
+     * is less than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need
      * to check it.
      */
 
index cf1d6fb41cc8cb024e125af364fcbcaa78b00886..d298d03642d0adb58a0ca37b7e87845428391a79 100644 (file)
@@ -1925,7 +1925,7 @@ netxray_dump_2_0(wtap_dumper *wdh,
        }
 
        /* Don't write anything we're not willing to read. */
-       if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+       if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
                *err = WTAP_ERR_PACKET_TOO_LARGE;
                return FALSE;
        }
index 829ba74526b28e15a63a1c22723dfcada3e5df69..83cf88083a7644926107f91315595e288ac5c849 100644 (file)
@@ -1300,7 +1300,7 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding,
        }
        /*
         * The maximum value of length is 65535, which is less than
-        * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
+        * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check
         * it.
         */
 
index 6094b84cb7da05e934e6c7b2a3121096f69cbe51..909371543b27b3de4e3eb73ea33cc36be2fb8d44 100644 (file)
@@ -183,14 +183,14 @@ packetlogger_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer
                *err_info = g_strdup_printf("packetlogger: record length %u is too small", pl_hdr.len);
                return FALSE;
        }
-       if (pl_hdr.len - 8 > WTAP_MAX_PACKET_SIZE) {
+       if (pl_hdr.len - 8 > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("packetlogger: File has %u-byte packet, bigger than maximum of %u",
-                   pl_hdr.len - 8, WTAP_MAX_PACKET_SIZE);
+                   pl_hdr.len - 8, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index e67cd3956f7e9725162d3fd525fd1428240f576f..0950e5adad0d95f53f39465fb23acf0456f07aa2 100644 (file)
@@ -702,6 +702,27 @@ wtap_wtap_encap_to_pcap_encap(int encap)
        return -1;
 }
 
+/*
+ * For most encapsulations, we use WTAP_MAX_PACKET_SIZE_STANDARD, as
+ * that should be enough for most link-layer types, and shouldn't be
+ * too big.
+ *
+ * For D-Bus, we use WTAP_MAX_PACKET_SIZE_DBUS, because the maximum
+ * D-Bus message size is 128MB, which is bigger than we'd want for
+ * all link-layer types - files with that snapshot length might cause
+ * some programs reading them to allocate a huge and wasteful buffer
+ * and, at least on 32-bit platforms, run the risk of running out of
+ * memory.
+ */
+guint
+wtap_max_snaplen_for_encap(int wtap_encap)
+{
+       if (wtap_encap == WTAP_ENCAP_DBUS)
+               return WTAP_MAX_PACKET_SIZE_DBUS;
+       else
+               return WTAP_MAX_PACKET_SIZE_STANDARD;
+}
+
 gboolean
 wtap_encap_requires_phdr(int wtap_encap)
 {
index fd15ce292a38cf0b73fb6e20d8ae4e1c6a7d599e..da95cf546fa94e8df2b6361e26fd68b293ed3df7 100644 (file)
@@ -29,6 +29,8 @@
 #include "wtap.h"
 #include "ws_symbol_export.h"
 
+extern guint wtap_max_snaplen_for_encap(int wtap_encap);
+
 extern int pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap,
     guint packet_size, gboolean check_packet_size,
     struct wtap_pkthdr *phdr, int *err, gchar **err_info);
index f21e028c941f0a197d8d1a9a648bf864b1def802..9217781341a59fcb21e800db9fa2afdce49de774 100644 (file)
@@ -737,14 +737,14 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh,
                   wtap_encap_string(if_descr_mand->wtap_encap),
                   if_descr_mand->snap_len);
 
-    if (if_descr_mand->snap_len > WTAP_MAX_PACKET_SIZE) {
-        /* This is unrealistic, but text2pcap currently uses 102400.
+    if (if_descr_mand->snap_len > wtap_max_snaplen_for_encap(if_descr_mand->wtap_encap)) {
+        /*
          * We do not use this value, maybe we should check the
          * snap_len of the packets against it. For now, only warn.
          */
         pcapng_debug("pcapng_read_if_descr_block: snapshot length %u unrealistic.",
                       if_descr_mand->snap_len);
-        /*if_descr_mand->snap_len = WTAP_MAX_PACKET_SIZE;*/
+        /*if_descr_mand->snap_len = WTAP_MAX_PACKET_SIZE_STANDARD;*/
     }
 
     /* Options */
@@ -1164,12 +1164,6 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
         }
     }
 
-    if (packet.cap_len > WTAP_MAX_PACKET_SIZE) {
-        *err = WTAP_ERR_BAD_FILE;
-        *err_info = g_strdup_printf("pcapng_read_packet_block: cap_len %u is larger than WTAP_MAX_PACKET_SIZE %u",
-                                    packet.cap_len, WTAP_MAX_PACKET_SIZE);
-        return FALSE;
-    }
     pcapng_debug("pcapng_read_packet_block: packet data: packet_len %u captured_len %u interface_id %u",
                   packet.packet_len,
                   packet.cap_len,
@@ -1184,6 +1178,14 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
     iface_info = g_array_index(pn->interfaces, interface_info_t,
                                packet.interface_id);
 
+    if (packet.cap_len > wtap_max_snaplen_for_encap(iface_info.wtap_encap)) {
+        *err = WTAP_ERR_BAD_FILE;
+        *err_info = g_strdup_printf("pcapng_read_packet_block: cap_len %u is larger than %u",
+                                    packet.cap_len,
+                                    wtap_max_snaplen_for_encap(iface_info.wtap_encap));
+        return FALSE;
+    }
+
     wblock->packet_header->rec_type = REC_TYPE_PACKET;
     wblock->packet_header->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
 
@@ -1466,10 +1468,11 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
         return FALSE;
     }
 
-    if (simple_packet.cap_len > WTAP_MAX_PACKET_SIZE) {
+    if (simple_packet.cap_len > wtap_max_snaplen_for_encap(iface_info.wtap_encap)) {
         *err = WTAP_ERR_BAD_FILE;
-        *err_info = g_strdup_printf("pcapng_read_simple_packet_block: cap_len %u is larger than WTAP_MAX_PACKET_SIZE %u",
-                                    simple_packet.cap_len, WTAP_MAX_PACKET_SIZE);
+        *err_info = g_strdup_printf("pcapng_read_simple_packet_block: cap_len %u is larger than %u",
+                                    simple_packet.cap_len,
+                                    wtap_max_snaplen_for_encap(iface_info.wtap_encap));
         return FALSE;
     }
     pcapng_debug("pcapng_read_simple_packet_block: packet data: packet_len %u",
@@ -2951,7 +2954,7 @@ pcapng_write_enhanced_packet_block(wtap_dumper *wdh,
     wtapng_if_descr_mandatory_t *int_data_mand;
 
     /* Don't write anything we're not willing to read. */
-    if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen > wtap_max_snaplen_for_encap(wdh->encap)) {
         *err = WTAP_ERR_PACKET_TOO_LARGE;
         return FALSE;
     }
@@ -3140,7 +3143,7 @@ pcapng_write_sysdig_event_block(wtap_dumper *wdh,
     guint16 event_type;
 
     /* Don't write anything we're not willing to read. */
-    if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
         *err = WTAP_ERR_PACKET_TOO_LARGE;
         return FALSE;
     }
index 91569e2abbc8e160ef632b8746d1ce2e3091b28f..a0fce6d6f7026dff214765615f7fa1381d0bfc2c 100644 (file)
@@ -437,7 +437,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh,
        }
        /*
         * The maximum value of sliceLength and length are 65535, which
-        * are less than WTAP_MAX_PACKET_SIZE will ever be, so we don't
+        * are less than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't
         * need to check them.
         */
 
@@ -621,7 +621,7 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
        }
        /*
         * The maximum value of sliceLength and length are 65535, which
-        * are less than WTAP_MAX_PACKET_SIZE will ever be, so we don't
+        * are less than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't
         * need to check them.
         */
 
index 943ca0e058fc18dcdb8a49f3a30dcd9810997272..b9f76a3a93b792b6c61bb61cd57c1843db9a464e 100644 (file)
@@ -715,14 +715,14 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     if (sliceLength == 0)
         sliceLength = length;
 
-    if (sliceLength > WTAP_MAX_PACKET_SIZE) {
+    if (sliceLength > WTAP_MAX_PACKET_SIZE_STANDARD) {
         /*
          * Probably a corrupt capture file; don't blow up trying
          * to allocate space for an immensely-large packet.
          */
         *err = WTAP_ERR_BAD_FILE;
         *err_info = g_strdup_printf("peektagged: File has %u-byte packet, bigger than maximum of %u",
-            sliceLength, WTAP_MAX_PACKET_SIZE);
+            sliceLength, WTAP_MAX_PACKET_SIZE_STANDARD);
         return -1;
     }
 
index 0b4f1bca371e3aec5730d7b6ecc0d2f941974e17..ca6177ef0dfc12af69eebae12adb7ae845697cc8 100644 (file)
@@ -85,7 +85,7 @@ Daniel Thompson (STMicroelectronics) <daniel.thompson@st.com>
  * sizeof(lcp_header) + sizeof(ipcp_header).  PPPD_MTU is *very* rarely
  * larger than 1500 so this value is fine.
  *
- * It's less than WTAP_MAX_PACKET_SIZE, so we don't have to worry about
+ * It's less than WTAP_MAX_PACKET_SIZE_STANDARD, so we don't have to worry about
  * too-large packets.
  */
 #define PPPD_BUF_SIZE          8192
index f86b1f3e23de93817fbf53fd6399ed58f12ecf3c..54e5e9b4411fa6a3a0da47efe8358e2fe895b54f 100644 (file)
@@ -316,7 +316,7 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        real_length = pletoh16(&hdr.real_length);
        /*
         * The maximum value of length is 65535, which is less than
-        * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check
+        * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check
         * it.
         */
 
index 1831e422c6a047827d0e807cec903691586ee639..4468028d77ff02e1c84ef8a6d2fb8a760d6a7444 100644 (file)
@@ -484,24 +484,24 @@ snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        rec_size = g_ntohl(hdr.rec_len);
        orig_size = g_ntohl(hdr.orig_len);
        packet_size = g_ntohl(hdr.incl_len);
-       if (orig_size > WTAP_MAX_PACKET_SIZE) {
+       if (orig_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("snoop: File has %u-byte original length, bigger than maximum of %u",
-                   orig_size, WTAP_MAX_PACKET_SIZE);
+                   orig_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return -1;
        }
-       if (packet_size > WTAP_MAX_PACKET_SIZE) {
+       if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("snoop: File has %u-byte packet, bigger than maximum of %u",
-                   packet_size, WTAP_MAX_PACKET_SIZE);
+                   packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
                return -1;
        }
        if (packet_size > rec_size) {
@@ -844,7 +844,7 @@ static gboolean snoop_dump(wtap_dumper *wdh,
        reclen += padlen;
 
        /* Don't write anything we're not willing to read. */
-       if (phdr->caplen + atm_hdrsize > WTAP_MAX_PACKET_SIZE) {
+       if (phdr->caplen + atm_hdrsize > WTAP_MAX_PACKET_SIZE_STANDARD) {
                *err = WTAP_ERR_PACKET_TOO_LARGE;
                return FALSE;
        }
index dfe26823b3fe0dc1092ad409ab83115d5baf847d..731d8200c1bd630f69e6dd9285abbefb87911841 100644 (file)
@@ -76,14 +76,14 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p
 
   /* The next 4 bytes are the packet length */
   packet_size = pntoh32(&stanag_pkt_hdr[2]);
-  if (packet_size > WTAP_MAX_PACKET_SIZE) {
+  if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
     /*
      * Probably a corrupt capture file; don't blow up trying
      * to allocate space for an immensely-large packet.
      */
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup_printf("stanag4607: File has %" G_GUINT32_FORMAT "d-byte packet, "
-      "bigger than maximum of %u", packet_size, WTAP_MAX_PACKET_SIZE);
+      "bigger than maximum of %u", packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
     return FALSE;
   }
   if (packet_size < PKT_HDR_SIZE+SEG_HDR_SIZE) {
index 2b6266596b74df58c29839292e126de056b7ab12..c0f1600aa2687e8bb6af48b2abe6925c726170c2 100644 (file)
@@ -35,14 +35,14 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
   if ((file_size = wtap_file_size(wth, err)) == -1)
     return FALSE;
 
-  if (file_size > WTAP_MAX_PACKET_SIZE) {
+  if (file_size > WTAP_MAX_PACKET_SIZE_STANDARD) {
     /*
      * Probably a corrupt capture file; don't blow up trying
      * to allocate space for an immensely-large packet.
      */
     *err = WTAP_ERR_BAD_FILE;
     *err_info = g_strdup_printf("tnef: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
-                                file_size, WTAP_MAX_PACKET_SIZE);
+                                file_size, WTAP_MAX_PACKET_SIZE_STANDARD);
     return FALSE;
   }
   packet_size = (int)file_size;
index 091b7908840d80c0f482ee0c32b60cc4fee6b933..40e605dfa40cba4ee20460aae929000bf5013342 100644 (file)
@@ -311,14 +311,14 @@ parse_toshiba_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                *err_info = g_strdup("toshiba: packet header has a negative packet length");
                return FALSE;
        }
-       if (pkt_len > WTAP_MAX_PACKET_SIZE) {
+       if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) {
                /*
                 * Probably a corrupt capture file; don't blow up trying
                 * to allocate space for an immensely-large packet.
                 */
                *err = WTAP_ERR_BAD_FILE;
                *err_info = g_strdup_printf("toshiba: File has %u-byte packet, bigger than maximum of %u",
-                   pkt_len, WTAP_MAX_PACKET_SIZE);
+                   pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD);
                return FALSE;
        }
 
index 2bf675a4448065aaacecc899c7f46c29b203ac5a..240e10e6a971a3c42d9265dba1055a0f26cf46b5 100644 (file)
@@ -511,13 +511,13 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     phdr->caplen = packet_size;
 
     /* Check for too-large packet. */
-    if (packet_size > WTAP_MAX_PACKET_SIZE)
+    if (packet_size > WTAP_MAX_PACKET_SIZE_STANDARD)
     {
         /* Probably a corrupt capture file; don't blow up trying
           to allocate space for an immensely-large packet. */
         *err = WTAP_ERR_BAD_FILE;
         *err_info = g_strdup_printf("visual: File has %u-byte packet, bigger than maximum of %u",
-            packet_size, WTAP_MAX_PACKET_SIZE);
+            packet_size, WTAP_MAX_PACKET_SIZE_STANDARD);
         return FALSE;
     }
 
@@ -652,7 +652,7 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
     }
 
     /* Don't write anything we're not willing to read. */
-    if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+    if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
         *err = WTAP_ERR_PACKET_TOO_LARGE;
         return FALSE;
     }
index 9180c0e461af055a10169fef8e4d6228e00fbf97..5ab50223a69ec9b18d788d32424f44853d0891e5 100644 (file)
@@ -397,7 +397,7 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
             break;
         }
     } while (! isdumpline(line));
-    if (pkt_len > WTAP_MAX_PACKET_SIZE) {
+    if (pkt_len > WTAP_MAX_PACKET_SIZE_STANDARD) {
         /*
          * Probably a corrupt capture file; return an error,
          * so that our caller doesn't blow up trying to allocate
@@ -405,7 +405,7 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
          */
         *err = WTAP_ERR_BAD_FILE;
         *err_info = g_strdup_printf("vms: File has %u-byte packet, bigger than maximum of %u",
-                                    pkt_len, WTAP_MAX_PACKET_SIZE);
+                                    pkt_len, WTAP_MAX_PACKET_SIZE_STANDARD);
         return FALSE;
     }
 
index 015a7a02054396b516fc6f7a9e4f3211d9594349..2b04757a792bff018973003746051195e96f3cc6 100644 (file)
@@ -1275,7 +1275,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr,
      *
      * The maximum value of actual_octets is 8191, which, even after
      * adding the lengths of the metadata headers, is less than
-     * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
+     * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it.
      */
     phdr->len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
     phdr->caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
@@ -1688,7 +1688,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr,
      *
      * The maximum value of actual_octets is 8191, which, even after
      * adding the lengths of the metadata headers, is less than
-     * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
+     * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it.
      */
     phdr->len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
     phdr->caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
@@ -1868,7 +1868,7 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr,
          *
          * We include the length of the metadata headers in the packet lengths.
          *
-         * OCTO_MODIFIED_RF_LEN + 1 is less than WTAP_MAX_PACKET_SIZE will
+         * OCTO_MODIFIED_RF_LEN + 1 is less than WTAP_MAX_PACKET_SIZE_STANDARD will
          * ever be, so we don't need to check it.
          */
         phdr->len = OCTO_MODIFIED_RF_LEN + 1;       /* 1st octet is reserved for detecting type of frame while displaying in wireshark */
@@ -2184,14 +2184,14 @@ static gboolean vwr_read_s3_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr,
             phdr->len = OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets;
             phdr->caplen = OCTO_TIMESTAMP_FIELDS_LEN + OCTO_LAYER1TO4_LEN + actual_octets;
         }
-        if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+        if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
             /*
              * Probably a corrupt capture file; return an error,
              * so that our caller doesn't blow up trying to allocate
              * space for an immensely-large packet.
              */
             *err_info = g_strdup_printf("vwr: File has %u-byte packet, bigger than maximum of %u",
-                                        phdr->caplen, WTAP_MAX_PACKET_SIZE);
+                                        phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
             *err = WTAP_ERR_BAD_FILE;
             return FALSE;
         }
@@ -2696,7 +2696,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, struct wtap_pkthdr *phdr,
      *
      * The maximum value of actual_octets is 65535, which, even after
      * adding the lengths of the metadata headers, is less than
-     * WTAP_MAX_PACKET_SIZE will ever be, so we don't need to check it.
+     * WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check it.
      */
     phdr->len = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets;
     phdr->caplen = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets;
index 6b60d51d9df914e0bc2902468e22daed2d36c365..f5e9a13503cb331ac040f872aad3454d7d948b73 100644 (file)
@@ -376,11 +376,15 @@ extern "C" {
 /* if you add to the above, update wtap_tsprec_string() */
 
 /*
- * Maximum packet size we'll support.
- * 262144 is the largest snapshot length that libpcap supports, so we
- * use that.
- */
-#define WTAP_MAX_PACKET_SIZE    262144
+ * We support one maximum packet size for most link-layer header types
+ * and another for D-Bus, because the maximum packet size for D-Bus
+ * is 128MB, and that's a lot bigger than the 256KB that we use elsewhere.
+ * We don't want to write out files that specify a maximum packet size of
+ * 128MB if we don't have to, as software reading those files might
+ * allocate a buffer much larger than necessary, wasting memory.
+ */
+#define WTAP_MAX_PACKET_SIZE_STANDARD    262144
+#define WTAP_MAX_PACKET_SIZE_DBUS        (128*1024*1024)
 
 /*
  * "Pseudo-headers" are used to supply to the clients of wiretap