aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-04-22 18:14:29 -0700
committerGuy Harris <gharris@sonic.net>2022-04-22 18:14:29 -0700
commit1ee8ead845e8cee449f9dad87fd69a0f21bc6160 (patch)
treecfe9d9348b26d9bca54a42dfabcbf4873b16efbc /wiretap
parent7286e2982accea447d6d971d4821c2d316228133 (diff)
Provide the section number for blocks, and show it.
Add a "section number" field to wtap_rec, with a presence flag, and provide the section number (0-based) for pcapng files. Display it (1-based) if present.
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/pcapng.c9
-rw-r--r--wiretap/wtap.c7
-rw-r--r--wiretap/wtap.h10
3 files changed, 22 insertions, 4 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 7e60cfc040..8e96ebe38a 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -3710,6 +3710,10 @@ pcapng_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
/*ws_debug("Read length: %u Packet length: %u", bytes_read, rec->rec_header.packet_header.caplen);*/
ws_debug("data_offset is finally %" PRId64, *data_offset);
+ /* Provide the section number */
+ rec->presence_flags |= WTAP_HAS_SECTION_NUMBER;
+ rec->section_number = pcapng->current_section_number;
+
return TRUE;
}
@@ -3781,6 +3785,11 @@ pcapng_seek_read(wtap *wth, gint64 seek_off,
}
wtap_block_unref(wblock.block);
+
+ /* Provide the section number */
+ rec->presence_flags |= WTAP_HAS_SECTION_NUMBER;
+ rec->section_number = section_number;
+
return TRUE;
}
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 7af38a8977..847bbd54ab 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1524,6 +1524,13 @@ wtap_init_rec(wtap *wth, wtap_rec *rec)
rec->tsprec = wth->file_tsprec;
rec->block = NULL;
rec->block_was_modified = FALSE;
+
+ /*
+ * Assume the file has only one section; the module for the
+ * file type needs to indicate the section number if there's
+ * more than one section.
+ */
+ rec->section_number = 0;
}
gboolean
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index fb6de882fa..162f8b7228 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1338,6 +1338,7 @@ typedef struct {
typedef struct {
guint rec_type; /* what type of record is this? */
guint32 presence_flags; /* what stuff do we have? */
+ guint section_number; /* section, within file, containing this record */
nstime_t ts; /* time stamp */
int tsprec; /* WTAP_TSPREC_ value for this record */
union {
@@ -1378,11 +1379,12 @@ typedef struct {
* absent, use the file encapsulation - but it's not clear that's useful;
* we currently do that in the module for the file format.
*
- * Only WTAP_HAS_TS applies to all record types.
+ * Only WTAP_HAS_TS and WTAP_HAS_SECTION_NUMBER apply to all record types.
*/
-#define WTAP_HAS_TS 0x00000001 /**< time stamp */
-#define WTAP_HAS_CAP_LEN 0x00000002 /**< captured length separate from on-the-network length */
-#define WTAP_HAS_INTERFACE_ID 0x00000004 /**< interface ID */
+#define WTAP_HAS_TS 0x00000001 /**< time stamp */
+#define WTAP_HAS_CAP_LEN 0x00000002 /**< captured length separate from on-the-network length */
+#define WTAP_HAS_INTERFACE_ID 0x00000004 /**< interface ID */
+#define WTAP_HAS_SECTION_NUMBER 0x00000008 /**< section number */
#ifndef MAXNAMELEN
#define MAXNAMELEN 64 /* max name length (hostname and port name) */