summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-08-10 20:33:01 +0000
committerGerald Combs <gerald@wireshark.org>2012-08-10 20:33:01 +0000
commitcd3cca7edca2c52fea2afce5f248370f5fdcbd4f (patch)
tree2def04abc1c80331776942f588ecae42cfe85291 /epan
parentf464eb4b5839cc1a9a222c6a5e3f701af4cb1305 (diff)
downloadwireshark-cd3cca7edca2c52fea2afce5f248370f5fdcbd4f.tar.gz
Make the corresponding packet_info available to each tree item. This
lets us pass a NULL pinfo to expert_add_info_format() and expert_add_undecoded_item(), which makes it possible to use those routines deep in the bowels of many dissectors. As a proof of concept remove the recent pinfo additions to packet-afp.c. This should also make it easier to fix bug 3884. svn path=/trunk/; revision=44435
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-afp.c16
-rw-r--r--epan/dissectors/packet-ncp2222.inc7
-rw-r--r--epan/epan.c2
-rw-r--r--epan/expert.c7
-rw-r--r--epan/expert.h23
-rw-r--r--epan/proto.c5
-rw-r--r--epan/proto.h9
7 files changed, 38 insertions, 31 deletions
diff --git a/epan/dissectors/packet-afp.c b/epan/dissectors/packet-afp.c
index 53b7dfb146..8f55ba40cc 100644
--- a/epan/dissectors/packet-afp.c
+++ b/epan/dissectors/packet-afp.c
@@ -4666,7 +4666,7 @@ decode_kauth_ace(tvbuff_t *tvb, proto_tree *tree, gint offset)
#define AFP_MAX_ACL_ENTRIES 500 /* Arbitrary. */
static gint
-decode_kauth_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
+decode_kauth_acl(tvbuff_t *tvb, proto_tree *tree, gint offset)
{
int entries;
int i;
@@ -4681,11 +4681,11 @@ decode_kauth_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offse
sub_tree = proto_item_add_subtree(item, ett_afp_ace_entries);
offset += 4;
- item = proto_tree_add_item(tree, hf_afp_acl_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_item(tree, hf_afp_acl_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
if (entries > AFP_MAX_ACL_ENTRIES) {
- expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN, "Too many ACL entries (%u). Stopping dissection.", entries);
+ expert_add_info_format(NULL, item, PI_UNDECODED, PI_WARN, "Too many ACL entries (%u). Stopping dissection.", entries);
THROW(ReportedBoundsError);
}
@@ -4700,7 +4700,7 @@ decode_kauth_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offse
}
static gint
-decode_uuid_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, guint16 bitmap)
+decode_uuid_acl(tvbuff_t *tvb, proto_tree *tree, gint offset, guint16 bitmap)
{
if ((offset & 1))
PAD(1);
@@ -4716,7 +4716,7 @@ decode_uuid_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset
}
if ((bitmap & kFileSec_ACL)) {
- offset = decode_kauth_acl(tvb, pinfo, tree, offset);
+ offset = decode_kauth_acl(tvb, tree, offset);
}
return offset;
@@ -4736,7 +4736,7 @@ dissect_query_afp_set_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
offset = decode_name(tree, pinfo, tvb, offset);
- offset = decode_uuid_acl(tvb, pinfo, tree, offset, bitmap);
+ offset = decode_uuid_acl(tvb, tree, offset, bitmap);
return offset;
}
@@ -4768,7 +4768,7 @@ dissect_reply_afp_get_acl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre
bitmap = decode_acl_list_bitmap(tvb, tree, offset);
offset += 2;
- offset = decode_uuid_acl(tvb, pinfo, tree, offset, bitmap);
+ offset = decode_uuid_acl(tvb, tree, offset, bitmap);
return offset;
}
@@ -6550,7 +6550,7 @@ proto_register_afp(void)
{ &hf_afp_acl_entrycount,
{ "ACEs count", "afp.acl_entrycount",
- FT_UINT32, BASE_DEC, NULL, 0,
+ FT_UINT32, BASE_HEX, NULL, 0,
"Number of ACL entries", HFILL }},
{ &hf_afp_acl_flags,
diff --git a/epan/dissectors/packet-ncp2222.inc b/epan/dissectors/packet-ncp2222.inc
index 7b676f9622..dba265c1a4 100644
--- a/epan/dissectors/packet-ncp2222.inc
+++ b/epan/dissectors/packet-ncp2222.inc
@@ -7510,7 +7510,7 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo,
if ((run_info_str || run_req_cond) && !ncp_tree) {
proto_item *ti;
- temp_tree = proto_tree_create_root();
+ temp_tree = proto_tree_create_root(pinfo);
proto_tree_set_visible(temp_tree, FALSE);
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
ncp_tree = proto_item_add_subtree(ti, ett_ncp);
@@ -11538,7 +11538,7 @@ dissect_nds_request(tvbuff_t *tvb, packet_info *pinfo,
if ((run_info_str || run_req_cond) && !ncp_tree) {
proto_item *ti;
- temp_tree = proto_tree_create_root();
+ temp_tree = proto_tree_create_root(pinfo);
proto_tree_set_visible(temp_tree, FALSE);
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
ncp_tree = proto_item_add_subtree(ti, ett_ncp);
@@ -11854,7 +11854,7 @@ dissect_ping_req(tvbuff_t *tvb, packet_info *pinfo,
if (ncp_rec && !ncp_tree) {
proto_item *ti;
- temp_tree = proto_tree_create_root();
+ temp_tree = proto_tree_create_root(pinfo);
proto_tree_set_visible(temp_tree, FALSE);
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
ncp_tree = proto_item_add_subtree(ti, ett_ncp);
@@ -12005,4 +12005,3 @@ dissect_ping_req(tvbuff_t *tvb, packet_info *pinfo,
CLEANUP_CALL_AND_POP;
}
}
-
diff --git a/epan/epan.c b/epan/epan.c
index 28b583a218..9b5840069c 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -168,7 +168,7 @@ epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const g
g_assert(edt);
if (create_proto_tree) {
- edt->tree = proto_tree_create_root();
+ edt->tree = proto_tree_create_root(&edt->pi);
proto_tree_set_visible(edt->tree, proto_tree_visible);
}
else {
diff --git a/epan/expert.c b/epan/expert.c
index 147537b0dc..414b42320a 100644
--- a/epan/expert.c
+++ b/epan/expert.c
@@ -166,6 +166,10 @@ expert_set_info_vformat(packet_info *pinfo, proto_item *pi, int group, int sever
proto_tree *tree;
proto_item *ti;
+ if (pinfo == NULL && pi->tree_data) {
+ pinfo = PTREE_DATA(pi)->pinfo;
+ }
+
/* if this packet isn't loaded because of a read filter, don't output anything */
if (pinfo == NULL || PINFO_FD_NUM(pinfo) == 0) {
return;
@@ -232,7 +236,7 @@ void
expert_add_undecoded_item(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int length, const int severity)
{
- proto_item *expert_item;
+ proto_item *expert_item;
expert_item = proto_tree_add_text(tree, tvb, offset, length, "Not dissected yet");
@@ -240,4 +244,3 @@ expert_add_undecoded_item(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i
PROTO_ITEM_SET_GENERATED(expert_item); \
}
-
diff --git a/epan/expert.h b/epan/expert.h
index 4db64ad66f..86478bb66d 100644
--- a/epan/expert.h
+++ b/epan/expert.h
@@ -63,11 +63,12 @@ expert_get_highest_severity(void);
/** Add an expert info.
Add an expert info tree to a protocol item, with classification and message.
- @param pinfo packet info of the currently processed packet
- @param pi current protocol item (or NULL)
- @param group the expert group (like PI_CHECKSUM - see: proto.h)
- @param severity the expert severity (like PI_WARN - see: proto.h)
- @param format printf like format string with further infos
+ @param pinfo Packet info of the currently processed packet. May be NULL if
+ pi is supplied
+ @param pi Current protocol item (or NULL)
+ @param group The expert group (like PI_CHECKSUM - see: proto.h)
+ @param severity The expert severity (like PI_WARN - see: proto.h)
+ @param format Printf-style format string for additional arguments
*/
extern void
expert_add_info_format(packet_info *pinfo, proto_item *pi, int group,
@@ -76,12 +77,12 @@ expert_add_info_format(packet_info *pinfo, proto_item *pi, int group,
/** Add an expert info about not dissected "item"
Add an expert info tree to a not dissected protocol item.
- @patam tvb the tvb with the item.
- @param pinfo packet info of the currently processed packet
- @param tree tree to add the item to
- @param offset in tvb
- @param length the length of the item.
- @param severity the expert severity (like PI_WARN - see: proto.h)
+ @patam tvb The tvb associated with the item.
+ @param pinfo Packet info of the currently processed packet. May be NULL.
+ @param tree Tree to add the item to
+ @param offset Offset in tvb
+ @param length The length of the item.
+ @param severity The expert severity (like PI_WARN - see: proto.h)
*/
extern void
diff --git a/epan/proto.c b/epan/proto.c
index 6bb833d007..a024176a79 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -4186,7 +4186,7 @@ proto_item_set_expert_flags(proto_item *pi, const int group, const guint severit
}
proto_tree *
-proto_tree_create_root(void)
+proto_tree_create_root(packet_info *pinfo)
{
proto_node *pnode;
@@ -4196,6 +4196,9 @@ proto_tree_create_root(void)
PNODE_FINFO(pnode) = NULL;
pnode->tree_data = g_new(tree_data_t, 1);
+ /* Make sure we can access pinfo everywhere */
+ pnode->tree_data->pinfo = pinfo;
+
/* Don't initialize the tree_data_t. Wait until we know we need it */
pnode->tree_data->interesting_hfids = NULL;
diff --git a/epan/proto.h b/epan/proto.h
index 5412125279..5a689ee846 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -467,9 +467,10 @@ typedef struct
* in the protocol tree points to the same copy. */
typedef struct {
GHashTable *interesting_hfids;
- gboolean visible;
- gboolean fake_protocols;
- gint count;
+ gboolean visible;
+ gboolean fake_protocols;
+ gint count;
+ struct _packet_info *pinfo;
} tree_data_t;
/** Each proto_tree, proto_item is one of these. */
@@ -697,7 +698,7 @@ extern gboolean proto_item_set_expert_flags(proto_item *ti, const int group, con
/** Creates a new proto_tree root.
@return the new tree root */
-extern proto_tree* proto_tree_create_root(void);
+extern proto_tree* proto_tree_create_root(struct _packet_info *pinfo);
/** Clear memory for entry proto_tree. Clears proto_tree struct also.
@param tree the tree to free */