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
This commit is contained in:
parent
f464eb4b58
commit
cd3cca7edc
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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); \
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue