Support reading in and storing multiple Section Header and Name Resolution blocks.
authorMichael Mann <mmann78@netscape.net>
Fri, 3 Jun 2016 00:03:06 +0000 (20:03 -0400)
committerAnders Broman <a.broman58@gmail.com>
Wed, 8 Jun 2016 03:39:49 +0000 (03:39 +0000)
The data is not applied anywhere, just stored.  The first Section Header block
is still the only one that is used to read a pcapng file.

Change-Id: If9546401101d2fe79b2325bacbd597b92127e86e
Reviewed-on: https://code.wireshark.org/review/15705
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
wiretap/pcapng.c

index a91b35c8c8f70bc80aaa17e15e8e153ca8b8f86d..761c53554904f28c30e173aab44464f5ef60cec8 100644 (file)
@@ -223,7 +223,7 @@ typedef struct interface_info_s {
 } interface_info_t;
 
 typedef struct {
-    gboolean shb_read;           /**< Set when first SHB read, second read will fail */
+    gboolean shb_read;           /**< Set when first SHB read */
     gboolean byte_swapped;
     guint16 version_major;
     guint16 version_minor;
@@ -559,13 +559,6 @@ pcapng_read_section_header_block(FILE_T fh, pcapng_block_header_t *bh,
         return PCAPNG_BLOCK_ERROR;
     }
 
-    /* We currently only suport one SHB */
-    if (pn->shb_read == TRUE) {
-        *err = WTAP_ERR_UNSUPPORTED;
-        *err_info = g_strdup("pcapng_read_section_header_block: multiple section header blocks not supported");
-        return PCAPNG_BLOCK_ERROR;
-    }
-
     /* we currently only understand SHB V1.0 */
     if (version_major != 1 || version_minor > 0) {
         *err = WTAP_ERR_UNSUPPORTED;
@@ -2580,12 +2573,9 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
         switch (wblock.type) {
 
             case(BLOCK_TYPE_SHB):
-                /* We don't currently support multi-section files. */
-                wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN;
-                wth->phdr.pkt_tsprec = WTAP_TSPREC_UNKNOWN;
-                *err = WTAP_ERR_UNSUPPORTED;
-                *err_info = g_strdup("pcapng: multi-section files not currently supported");
-                return FALSE;
+                pcapng_debug("pcapng_read: another section header block");
+                g_array_append_val(wth->shb_hdrs, wblock.block);
+                break;
 
             case(BLOCK_TYPE_PB):
             case(BLOCK_TYPE_SPB):
@@ -2604,6 +2594,10 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
             case(BLOCK_TYPE_NRB):
                 /* More name resolution entries */
                 pcapng_debug("pcapng_read: block type BLOCK_TYPE_NRB");
+                if (wth->nrb_hdrs == NULL) {
+                    wth->nrb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
+                }
+                g_array_append_val(wth->nrb_hdrs, wblock.block);
                 break;
 
             case(BLOCK_TYPE_ISB):