aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/dissectors/packet-frame.c13
-rw-r--r--wiretap/pcapng.c9
-rw-r--r--wiretap/wtap.c7
-rw-r--r--wiretap/wtap.h10
4 files changed, 35 insertions, 4 deletions
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index f8b59a41d0..b2bc02abcb 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -75,6 +75,7 @@ static int hf_frame_drop_count = -1;
static int hf_frame_protocols = -1;
static int hf_frame_color_filter_name = -1;
static int hf_frame_color_filter_text = -1;
+static int hf_frame_section_number = -1;
static int hf_frame_interface_id = -1;
static int hf_frame_interface_name = -1;
static int hf_frame_interface_description = -1;
@@ -663,6 +664,13 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
fh_tree = proto_item_add_subtree(ti, ett_frame);
+ if (pinfo->rec->presence_flags & WTAP_HAS_SECTION_NUMBER &&
+ (proto_field_is_referenced(tree, hf_frame_section_number))) {
+ /* Show it as 1-origin */
+ proto_tree_add_uint(fh_tree, hf_frame_section_number, tvb,
+ 0, 0, pinfo->rec->section_number + 1);
+ }
+
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID &&
(proto_field_is_referenced(tree, hf_frame_interface_id) || proto_field_is_referenced(tree, hf_frame_interface_name) || proto_field_is_referenced(tree, hf_frame_interface_description))) {
const char *interface_name = epan_get_interface_name(pinfo->epan, pinfo->rec->rec_header.packet_header.interface_id);
@@ -1272,6 +1280,11 @@ proto_register_frame(void)
FT_STRING, BASE_NONE, NULL, 0x0,
"The frame matched this coloring rule string", HFILL }},
+ { &hf_frame_section_number,
+ { "Section number", "frame.section_number",
+ FT_UINT32, BASE_DEC, NULL, 0x0,
+ "The number of the file section this frame is in", HFILL }},
+
{ &hf_frame_interface_id,
{ "Interface id", "frame.interface_id",
FT_UINT32, BASE_DEC, NULL, 0x0,
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) */