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. */
|
#define AFP_MAX_ACL_ENTRIES 500 /* Arbitrary. */
|
||||||
static gint
|
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 entries;
|
||||||
int i;
|
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);
|
sub_tree = proto_item_add_subtree(item, ett_afp_ace_entries);
|
||||||
offset += 4;
|
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;
|
offset += 4;
|
||||||
|
|
||||||
if (entries > AFP_MAX_ACL_ENTRIES) {
|
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);
|
THROW(ReportedBoundsError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4700,7 +4700,7 @@ decode_kauth_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offse
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
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))
|
if ((offset & 1))
|
||||||
PAD(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)) {
|
if ((bitmap & kFileSec_ACL)) {
|
||||||
offset = decode_kauth_acl(tvb, pinfo, tree, offset);
|
offset = decode_kauth_acl(tvb, tree, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 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_name(tree, pinfo, tvb, offset);
|
||||||
|
|
||||||
offset = decode_uuid_acl(tvb, pinfo, tree, offset, bitmap);
|
offset = decode_uuid_acl(tvb, tree, offset, bitmap);
|
||||||
|
|
||||||
return offset;
|
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);
|
bitmap = decode_acl_list_bitmap(tvb, tree, offset);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
offset = decode_uuid_acl(tvb, pinfo, tree, offset, bitmap);
|
offset = decode_uuid_acl(tvb, tree, offset, bitmap);
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
@ -6550,7 +6550,7 @@ proto_register_afp(void)
|
||||||
|
|
||||||
{ &hf_afp_acl_entrycount,
|
{ &hf_afp_acl_entrycount,
|
||||||
{ "ACEs count", "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 }},
|
"Number of ACL entries", HFILL }},
|
||||||
|
|
||||||
{ &hf_afp_acl_flags,
|
{ &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) {
|
if ((run_info_str || run_req_cond) && !ncp_tree) {
|
||||||
proto_item *ti;
|
proto_item *ti;
|
||||||
|
|
||||||
temp_tree = proto_tree_create_root();
|
temp_tree = proto_tree_create_root(pinfo);
|
||||||
proto_tree_set_visible(temp_tree, FALSE);
|
proto_tree_set_visible(temp_tree, FALSE);
|
||||||
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
|
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
|
||||||
ncp_tree = proto_item_add_subtree(ti, ett_ncp);
|
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) {
|
if ((run_info_str || run_req_cond) && !ncp_tree) {
|
||||||
proto_item *ti;
|
proto_item *ti;
|
||||||
|
|
||||||
temp_tree = proto_tree_create_root();
|
temp_tree = proto_tree_create_root(pinfo);
|
||||||
proto_tree_set_visible(temp_tree, FALSE);
|
proto_tree_set_visible(temp_tree, FALSE);
|
||||||
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
|
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
|
||||||
ncp_tree = proto_item_add_subtree(ti, ett_ncp);
|
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) {
|
if (ncp_rec && !ncp_tree) {
|
||||||
proto_item *ti;
|
proto_item *ti;
|
||||||
|
|
||||||
temp_tree = proto_tree_create_root();
|
temp_tree = proto_tree_create_root(pinfo);
|
||||||
proto_tree_set_visible(temp_tree, FALSE);
|
proto_tree_set_visible(temp_tree, FALSE);
|
||||||
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
|
ti = proto_tree_add_item(temp_tree, proto_ncp, tvb, 0, -1, FALSE);
|
||||||
ncp_tree = proto_item_add_subtree(ti, ett_ncp);
|
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;
|
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);
|
g_assert(edt);
|
||||||
|
|
||||||
if (create_proto_tree) {
|
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);
|
proto_tree_set_visible(edt->tree, proto_tree_visible);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -166,6 +166,10 @@ expert_set_info_vformat(packet_info *pinfo, proto_item *pi, int group, int sever
|
||||||
proto_tree *tree;
|
proto_tree *tree;
|
||||||
proto_item *ti;
|
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 this packet isn't loaded because of a read filter, don't output anything */
|
||||||
if (pinfo == NULL || PINFO_FD_NUM(pinfo) == 0) {
|
if (pinfo == NULL || PINFO_FD_NUM(pinfo) == 0) {
|
||||||
return;
|
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)
|
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");
|
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); \
|
PROTO_ITEM_SET_GENERATED(expert_item); \
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,11 +63,12 @@ expert_get_highest_severity(void);
|
||||||
|
|
||||||
/** Add an expert info.
|
/** Add an expert info.
|
||||||
Add an expert info tree to a protocol item, with classification and message.
|
Add an expert info tree to a protocol item, with classification and message.
|
||||||
@param pinfo packet info of the currently processed packet
|
@param pinfo Packet info of the currently processed packet. May be NULL if
|
||||||
@param pi current protocol item (or NULL)
|
pi is supplied
|
||||||
@param group the expert group (like PI_CHECKSUM - see: proto.h)
|
@param pi Current protocol item (or NULL)
|
||||||
@param severity the expert severity (like PI_WARN - see: proto.h)
|
@param group The expert group (like PI_CHECKSUM - see: proto.h)
|
||||||
@param format printf like format string with further infos
|
@param severity The expert severity (like PI_WARN - see: proto.h)
|
||||||
|
@param format Printf-style format string for additional arguments
|
||||||
*/
|
*/
|
||||||
extern void
|
extern void
|
||||||
expert_add_info_format(packet_info *pinfo, proto_item *pi, int group,
|
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 about not dissected "item"
|
||||||
Add an expert info tree to a not dissected protocol item.
|
Add an expert info tree to a not dissected protocol item.
|
||||||
@patam tvb the tvb with the item.
|
@patam tvb The tvb associated with the item.
|
||||||
@param pinfo packet info of the currently processed packet
|
@param pinfo Packet info of the currently processed packet. May be NULL.
|
||||||
@param tree tree to add the item to
|
@param tree Tree to add the item to
|
||||||
@param offset in tvb
|
@param offset Offset in tvb
|
||||||
@param length the length of the item.
|
@param length The length of the item.
|
||||||
@param severity the expert severity (like PI_WARN - see: proto.h)
|
@param severity The expert severity (like PI_WARN - see: proto.h)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
|
|
|
@ -4186,7 +4186,7 @@ proto_item_set_expert_flags(proto_item *pi, const int group, const guint severit
|
||||||
}
|
}
|
||||||
|
|
||||||
proto_tree *
|
proto_tree *
|
||||||
proto_tree_create_root(void)
|
proto_tree_create_root(packet_info *pinfo)
|
||||||
{
|
{
|
||||||
proto_node *pnode;
|
proto_node *pnode;
|
||||||
|
|
||||||
|
@ -4196,6 +4196,9 @@ proto_tree_create_root(void)
|
||||||
PNODE_FINFO(pnode) = NULL;
|
PNODE_FINFO(pnode) = NULL;
|
||||||
pnode->tree_data = g_new(tree_data_t, 1);
|
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 */
|
/* Don't initialize the tree_data_t. Wait until we know we need it */
|
||||||
pnode->tree_data->interesting_hfids = NULL;
|
pnode->tree_data->interesting_hfids = NULL;
|
||||||
|
|
||||||
|
|
|
@ -467,9 +467,10 @@ typedef struct
|
||||||
* in the protocol tree points to the same copy. */
|
* in the protocol tree points to the same copy. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GHashTable *interesting_hfids;
|
GHashTable *interesting_hfids;
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
gboolean fake_protocols;
|
gboolean fake_protocols;
|
||||||
gint count;
|
gint count;
|
||||||
|
struct _packet_info *pinfo;
|
||||||
} tree_data_t;
|
} tree_data_t;
|
||||||
|
|
||||||
/** Each proto_tree, proto_item is one of these. */
|
/** 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.
|
/** Creates a new proto_tree root.
|
||||||
@return the new 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.
|
/** Clear memory for entry proto_tree. Clears proto_tree struct also.
|
||||||
@param tree the tree to free */
|
@param tree the tree to free */
|
||||||
|
|
Loading…
Reference in New Issue