aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/libwireshark0.symbols1
-rw-r--r--epan/dissectors/file-file.c11
-rw-r--r--epan/dissectors/packet-frame.c33
-rw-r--r--epan/epan.h2
-rw-r--r--epan/packet.c27
-rw-r--r--epan/packet.h7
-rw-r--r--epan/packet_info.h1
-rw-r--r--epan/wslua/wslua_dumper.c8
-rw-r--r--ui/tap_export_pdu.c10
9 files changed, 66 insertions, 34 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols
index b425017e37..936d6fb5e1 100644
--- a/debian/libwireshark0.symbols
+++ b/debian/libwireshark0.symbols
@@ -473,6 +473,7 @@ libwireshark.so.0 libwireshark0 #MINVER#
epan_free@Base 1.12.0~rc1
epan_get_compiled_version_info@Base 1.9.1
epan_get_runtime_version_info@Base 1.9.1
+ epan_get_user_comment@Base 1.99.2
epan_get_version@Base 1.9.1
epan_init@Base 1.9.1
epan_memmem@Base 1.9.1
diff --git a/epan/dissectors/file-file.c b/epan/dissectors/file-file.c
index 16e234654d..3956bc4131 100644
--- a/epan/dissectors/file-file.c
+++ b/epan/dissectors/file-file.c
@@ -85,8 +85,9 @@ call_file_record_end_routine(gpointer routine, gpointer dummy _U_)
(*func)();
}
-static void
-dissect_file_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
+/* XXX - "packet comment" is passed into dissector as data, but currently doesn't have a use */
+static int
+dissect_file_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
{
proto_item *volatile ti = NULL;
guint cap_len = 0, frame_len = 0;
@@ -184,7 +185,7 @@ dissect_file_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
/* Ignored package, stop handling here */
col_set_str(pinfo->cinfo, COL_INFO, "<Ignored>");
proto_tree_add_text (tree, tvb, 0, -1, "This record is marked as ignored");
- return;
+ return tvb_captured_length(tvb);
}
/* Portable Exception Handling to trap Wireshark specific exceptions like BoundsError exceptions */
@@ -311,6 +312,8 @@ dissect_file_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
g_slist_free(pinfo->frame_end_routines);
pinfo->frame_end_routines = NULL;
}
+
+ return tvb_captured_length(tvb);
}
void
@@ -382,7 +385,7 @@ proto_register_file(void)
proto_file = proto_register_protocol("File", "File", "file");
proto_register_field_array(proto_file, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
- register_dissector("file",dissect_file_record,proto_file);
+ new_register_dissector("file",dissect_file_record,proto_file);
/* You can't disable dissection of "Frame", as that would be
tantamount to not doing any dissection whatsoever. */
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index b8767108e1..0ac617a089 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -176,12 +176,9 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
proto_tree *comments_tree;
proto_item *item;
const gchar *cap_plurality, *frame_plurality;
- int file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_UNKNOWN;
+ frame_data_t *fr_data = (frame_data_t*)data;
tree=parent_tree;
- if (data != NULL) {
- file_type_subtype = GPOINTER_TO_INT(data);
- }
switch (pinfo->phdr->rec_type) {
@@ -251,14 +248,14 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
break;
}
- if (pinfo->pkt_comment) {
+ if (fr_data && fr_data->pkt_comment) {
item = proto_tree_add_item(tree, proto_pkt_comment, tvb, 0, 0, ENC_NA);
comments_tree = proto_item_add_subtree(item, ett_comments);
comment_item = proto_tree_add_string_format(comments_tree, hf_comments_text, tvb, 0, 0,
- pinfo->pkt_comment, "%s",
- pinfo->pkt_comment);
+ fr_data->pkt_comment, "%s",
+ fr_data->pkt_comment);
expert_add_info_format(pinfo, comment_item, &ei_comments_text,
- "%s", pinfo->pkt_comment);
+ "%s", fr_data->pkt_comment);
}
@@ -507,13 +504,21 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
case REC_TYPE_FT_SPECIFIC_EVENT:
case REC_TYPE_FT_SPECIFIC_REPORT:
- if (!dissector_try_uint(wtap_fts_rec_dissector_table, file_type_subtype,
- tvb, pinfo, parent_tree)) {
+ {
+ int file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_UNKNOWN;
+
+ if (fr_data) {
+ file_type_subtype = fr_data->file_type_subtype;
+ }
+
+ if (!dissector_try_uint(wtap_fts_rec_dissector_table, file_type_subtype,
+ tvb, pinfo, parent_tree)) {
- col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
- col_add_fstr(pinfo->cinfo, COL_INFO, "WTAP_ENCAP = %d",
- file_type_subtype);
- call_dissector(data_handle,tvb, pinfo, parent_tree);
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
+ col_add_fstr(pinfo->cinfo, COL_INFO, "WTAP_ENCAP = %d",
+ file_type_subtype);
+ call_dissector(data_handle,tvb, pinfo, parent_tree);
+ }
}
break;
}
diff --git a/epan/epan.h b/epan/epan.h
index a5a08df86c..cf431e34fb 100644
--- a/epan/epan.h
+++ b/epan/epan.h
@@ -132,7 +132,7 @@ typedef struct epan_session epan_t;
WS_DLL_PUBLIC epan_t *epan_new(void);
-const char *epan_get_user_comment(const epan_t *session, const frame_data *fd);
+WS_DLL_PUBLIC const char *epan_get_user_comment(const epan_t *session, const frame_data *fd);
const char *epan_get_interface_name(const epan_t *session, guint32 interface_id);
diff --git a/epan/packet.c b/epan/packet.c
index a61f75260a..7f50b3c2f6 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -431,6 +431,7 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
{
const char *volatile record_type;
+ frame_data_t frame_dissector_data;
switch (phdr->rec_type) {
@@ -485,9 +486,12 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
/* pkt comment use first user, later from phdr */
if (fd->flags.has_user_comment)
- edt->pi.pkt_comment = epan_get_user_comment(edt->session, fd);
+ frame_dissector_data.pkt_comment = epan_get_user_comment(edt->session, fd);
else if (fd->flags.has_phdr_comment)
- edt->pi.pkt_comment = phdr->opt_comment;
+ frame_dissector_data.pkt_comment = phdr->opt_comment;
+ else
+ frame_dissector_data.pkt_comment = NULL;
+ frame_dissector_data.file_type_subtype = file_type_subtype;
EP_CHECK_CANARY(("before dissecting record %d",fd->num));
@@ -499,7 +503,7 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
* sub-dissector can throw, dissect_frame() itself may throw
* a ReportedBoundsError in bizarre cases. Thus, we catch the exception
* in this function. */
- call_dissector_with_data(frame_handle, edt->tvb, &edt->pi, edt->tree, GINT_TO_POINTER(file_type_subtype));
+ call_dissector_with_data(frame_handle, edt->tvb, &edt->pi, edt->tree, &frame_dissector_data);
}
CATCH(BoundsError) {
g_assert_not_reached();
@@ -547,15 +551,20 @@ dissect_file(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
frame_delta_abs_time(edt->session, fd, fd->frame_ref_num, &edt->pi.rel_ts);
- /* pkt comment use first user, later from phdr */
- if (fd->flags.has_user_comment)
- edt->pi.pkt_comment = epan_get_user_comment(edt->session, fd);
- else if (fd->flags.has_phdr_comment)
- edt->pi.pkt_comment = phdr->opt_comment;
EP_CHECK_CANARY(("before dissecting file %d",fd->num));
TRY {
+ const gchar *pkt_comment;
+
+ /* pkt comment use first user, later from phdr */
+ if (fd->flags.has_user_comment)
+ pkt_comment = epan_get_user_comment(edt->session, fd);
+ else if (fd->flags.has_phdr_comment)
+ pkt_comment = phdr->opt_comment;
+ else
+ pkt_comment = NULL;
+
/* Add this tvbuffer into the data_src list */
add_new_data_source(&edt->pi, edt->tvb, "File");
@@ -563,7 +572,7 @@ dissect_file(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
* sub-dissector can throw, dissect_frame() itself may throw
* a ReportedBoundsError in bizarre cases. Thus, we catch the exception
* in this function. */
- call_dissector(file_handle, edt->tvb, &edt->pi, edt->tree);
+ call_dissector_with_data(file_handle, edt->tvb, &edt->pi, edt->tree, (void*)pkt_comment);
}
CATCH(BoundsError) {
diff --git a/epan/packet.h b/epan/packet.h
index 398eaced25..4e5aff1644 100644
--- a/epan/packet.h
+++ b/epan/packet.h
@@ -595,6 +595,13 @@ extern void free_data_sources(packet_info *pinfo);
*/
WS_DLL_PUBLIC void mark_frame_as_depended_upon(packet_info *pinfo, guint32 frame_num);
+/* Structure passed to the frame dissector */
+typedef struct frame_data_s
+{
+ int file_type_subtype;
+ const gchar *pkt_comment; /**< NULL if not available */
+} frame_data_t;
+
/*
* Dissectors should never modify the record data.
*/
diff --git a/epan/packet_info.h b/epan/packet_info.h
index 581617134a..79a5e546b2 100644
--- a/epan/packet_info.h
+++ b/epan/packet_info.h
@@ -168,7 +168,6 @@ typedef struct _packet_info {
wmem_allocator_t *pool; /**< Memory pool scoped to the pinfo struct */
struct epan_session *epan;
nstime_t rel_ts; /**< Relative timestamp (yes, it can be negative) */
- const gchar *pkt_comment; /**< NULL if not available */
const gchar *heur_list_name; /**< name of heur list if this packet is being heuristically dissected */
} packet_info;
diff --git a/epan/wslua/wslua_dumper.c b/epan/wslua/wslua_dumper.c
index 747bb700f2..dba5e7cf7b 100644
--- a/epan/wslua/wslua_dumper.c
+++ b/epan/wslua/wslua_dumper.c
@@ -436,12 +436,14 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
pkthdr.ts.secs = lua_pinfo->fd->abs_ts.secs;
pkthdr.ts.nsecs = lua_pinfo->fd->abs_ts.nsecs;
pkthdr.len = tvb_reported_length(tvb);
- pkthdr.caplen = tvb_length(tvb);
+ pkthdr.caplen = tvb_captured_length(tvb);
pkthdr.pkt_encap = lua_pinfo->fd->lnk_t;
pkthdr.pseudo_header = *lua_pinfo->pseudo_header;
- if (lua_pinfo->pkt_comment)
- pkthdr.opt_comment = wmem_strdup(wmem_packet_scope(), lua_pinfo->pkt_comment);
+ if (lua_pinfo->fd->flags.has_user_comment)
+ pkthdr.opt_comment = wmem_strdup(wmem_packet_scope(), epan_get_user_comment(lua_pinfo->epan, lua_pinfo->fd));
+ else if (lua_pinfo->fd->flags.has_phdr_comment)
+ pkthdr.opt_comment = wmem_strdup(wmem_packet_scope(), lua_pinfo->phdr->opt_comment);
data = (const guchar *)tvb_memdup(wmem_packet_scope(),tvb,0,pkthdr.caplen);
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c
index e724cd5cbe..6744a32d96 100644
--- a/ui/tap_export_pdu.c
+++ b/ui/tap_export_pdu.c
@@ -31,6 +31,7 @@
#include <epan/tap.h>
#include <epan/exported_pdu.h>
+#include <epan/epan_dissect.h>
#include "ui/alert_box.h"
#include "ui/simple_dialog.h"
@@ -38,7 +39,7 @@
/* Main entry point to the tap */
static int
-export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data)
+export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const void *data)
{
const exp_pdu_data_t *exp_pdu_data = (const exp_pdu_data_t *)data;
exp_pdu_t *exp_pdu_tap_data = (exp_pdu_t *)tapdata;
@@ -66,7 +67,12 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co
pkthdr.len = exp_pdu_data->tvb_reported_length + exp_pdu_data->tlv_buffer_len;
pkthdr.pkt_encap = exp_pdu_tap_data->pkt_encap;
- pkthdr.opt_comment = g_strdup(pinfo->pkt_comment);
+
+ if (pinfo->fd->flags.has_user_comment)
+ pkthdr.opt_comment = g_strdup(epan_get_user_comment(edt->session, pinfo->fd));
+ else if (pinfo->fd->flags.has_phdr_comment)
+ pkthdr.opt_comment = g_strdup(pinfo->phdr->opt_comment);
+
pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
/* XXX: should the pkthdr.pseudo_header be set to the pinfo's pseudo-header? */