Eliminate proto_tree_add_text from packet-mate.c
Change-Id: I3f4b3eb23b91b219df373b3012fbefa63abfa4d3 Reviewed-on: https://code.wireshark.org/review/5350 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
61b0638e94
commit
c62dac1a77
|
@ -29,6 +29,7 @@
|
|||
**************************************************************************/
|
||||
|
||||
#include "mate.h"
|
||||
#include <epan/expert.h>
|
||||
|
||||
void proto_register_mate(void);
|
||||
void proto_reg_handoff_mate(void);
|
||||
|
@ -38,12 +39,20 @@ static mate_config* mc = NULL;
|
|||
|
||||
static int proto_mate = -1;
|
||||
|
||||
static int hf_mate_released_time = -1;
|
||||
static int hf_mate_duration = -1;
|
||||
static int hf_mate_number_of_pdus = -1;
|
||||
static int hf_mate_started_at = -1;
|
||||
static int hf_mate_gop_key = -1;
|
||||
|
||||
static expert_field ei_mate_undefined_attribute = EI_INIT;
|
||||
|
||||
static const gchar* pref_mate_config_filename = "";
|
||||
static const gchar* current_mate_config_filename = NULL;
|
||||
|
||||
static proto_item *mate_i = NULL;
|
||||
|
||||
static void pdu_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_pdu* pdu) {
|
||||
static void pdu_attrs_tree(proto_tree* tree, packet_info *pinfo, tvbuff_t *tvb, mate_pdu* pdu) {
|
||||
AVPN* c;
|
||||
proto_tree *avpl_t;
|
||||
int* hfi_p;
|
||||
|
@ -56,13 +65,12 @@ static void pdu_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_pdu* pdu) {
|
|||
if (hfi_p) {
|
||||
proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v);
|
||||
} else {
|
||||
g_warning("MATE: error: undefined attribute: mate.%s.%s",pdu->cfg->name,c->avp->n);
|
||||
proto_tree_add_text(avpl_t,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
proto_tree_add_expert_format(avpl_t,pinfo,&ei_mate_undefined_attribute,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void gop_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
||||
static void gop_attrs_tree(proto_tree* tree, packet_info *pinfo, tvbuff_t *tvb, mate_gop* gop) {
|
||||
AVPN* c;
|
||||
proto_tree *avpl_t;
|
||||
int* hfi_p;
|
||||
|
@ -75,13 +83,12 @@ static void gop_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
|||
if (hfi_p) {
|
||||
proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v);
|
||||
} else {
|
||||
g_warning("MATE: error: undefined attribute: mate.%s.%s",gop->cfg->name,c->avp->n);
|
||||
proto_tree_add_text(avpl_t,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
proto_tree_add_expert_format(avpl_t,pinfo,&ei_mate_undefined_attribute,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void gog_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog) {
|
||||
static void gog_attrs_tree(proto_tree* tree, packet_info *pinfo, tvbuff_t *tvb, mate_gog* gog) {
|
||||
AVPN* c;
|
||||
proto_tree *avpl_t;
|
||||
int* hfi_p;
|
||||
|
@ -94,15 +101,14 @@ static void gog_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog) {
|
|||
if (hfi_p) {
|
||||
proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v);
|
||||
} else {
|
||||
g_warning("MATE: error: undefined attribute: mate.%s.%s",gog->cfg->name,c->avp->n);
|
||||
proto_tree_add_text(avpl_t,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
proto_tree_add_expert_format(avpl_t,pinfo,&ei_mate_undefined_attribute,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mate_gop_tree(proto_tree* pdu_tree, tvbuff_t *tvb, mate_gop* gop);
|
||||
static void mate_gop_tree(proto_tree* pdu_tree, packet_info *pinfo, tvbuff_t *tvb, mate_gop* gop);
|
||||
|
||||
static void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_gop* gop) {
|
||||
static void mate_gog_tree(proto_tree* tree, packet_info *pinfo, tvbuff_t *tvb, mate_gog* gog, mate_gop* gop) {
|
||||
proto_item *gog_item;
|
||||
proto_tree *gog_tree;
|
||||
proto_tree *gog_time_tree;
|
||||
|
@ -116,7 +122,7 @@ static void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_g
|
|||
gog_item = proto_tree_add_uint(tree,gog->cfg->hfid,tvb,0,0,gog->id);
|
||||
gog_tree = proto_item_add_subtree(gog_item,gog->cfg->ett);
|
||||
|
||||
gog_attrs_tree(gog_tree,tvb,gog);
|
||||
gog_attrs_tree(gog_tree,pinfo,tvb,gog);
|
||||
|
||||
if (gog->cfg->show_times) {
|
||||
gog_time_tree = proto_tree_add_subtree_format(gog_tree,tvb,0,0,gog->cfg->ett_times,NULL,"%s Times",gog->cfg->name);
|
||||
|
@ -134,24 +140,23 @@ static void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_g
|
|||
|
||||
if (gop != gog_gops) {
|
||||
if (gog->cfg->gop_tree_mode == GOP_FULL_TREE) {
|
||||
mate_gop_tree(gog_gops_tree, tvb, gog_gops);
|
||||
mate_gop_tree(gog_gops_tree, pinfo, tvb, gog_gops);
|
||||
} else {
|
||||
gog_gop_item = proto_tree_add_uint(gog_gops_tree,gog_gops->cfg->hfid,tvb,0,0,gog_gops->id);
|
||||
|
||||
if (gog->cfg->gop_tree_mode == GOP_BASIC_TREE) {
|
||||
gog_gop_tree = proto_item_add_subtree(gog_gop_item, gog->cfg->ett_gog_gop);
|
||||
|
||||
proto_tree_add_text(gog_gop_tree, tvb,0,0, "Started at: %f", gog_gops->start_time);
|
||||
proto_tree_add_float(gog_gop_tree, hf_mate_started_at, tvb,0,0,gog_gops->start_time);
|
||||
|
||||
|
||||
proto_tree_add_text(gog_gop_tree, tvb,0,0, "%s Duration: %f",
|
||||
gog_gops->cfg->name, gog_gops->last_time - gog_gops->start_time);
|
||||
proto_tree_add_float_format(gog_gop_tree, hf_mate_duration, tvb,0,0, gog_gops->last_time - gog_gops->start_time,
|
||||
"%s Duration: %f", gog_gops->cfg->name, gog_gops->last_time - gog_gops->start_time);
|
||||
|
||||
if (gog_gops->released)
|
||||
proto_tree_add_text(gog_gop_tree, tvb,0,0, "%s has been released, Time: %f",
|
||||
gog_gops->cfg->name, gog_gops->release_time - gog_gops->start_time);
|
||||
proto_tree_add_float_format(gog_gop_tree, hf_mate_released_time, tvb,0,0, gog_gops->release_time - gog_gops->start_time,
|
||||
"%s has been released, Time: %f", gog_gops->cfg->name, gog_gops->release_time - gog_gops->start_time);
|
||||
|
||||
proto_tree_add_text(gog_gop_tree, tvb,0,0, "Number of Pdus: %u",gog_gops->num_of_pdus);
|
||||
proto_tree_add_uint(gog_gop_tree, hf_mate_number_of_pdus, tvb,0,0, gog_gops->num_of_pdus);
|
||||
|
||||
if (gop->pdus && gop->cfg->pdu_tree_mode != GOP_NO_TREE) {
|
||||
proto_tree_add_uint(gog_gop_tree,gog->cfg->hfid_gog_gopstart,tvb,0,0,gog_gops->pdus->frame);
|
||||
|
@ -172,7 +177,7 @@ static void mate_gog_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog, mate_g
|
|||
}
|
||||
}
|
||||
|
||||
static void mate_gop_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
||||
static void mate_gop_tree(proto_tree* tree, packet_info *pinfo, tvbuff_t *tvb, mate_gop* gop) {
|
||||
proto_item *gop_item;
|
||||
proto_tree *gop_time_tree;
|
||||
proto_tree *gop_tree;
|
||||
|
@ -188,9 +193,9 @@ static void mate_gop_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
|||
gop_item = proto_tree_add_uint(tree,gop->cfg->hfid,tvb,0,0,gop->id);
|
||||
gop_tree = proto_item_add_subtree(gop_item, gop->cfg->ett);
|
||||
|
||||
if (gop->gop_key) proto_tree_add_text(gop_tree,tvb,0,0,"GOP Key: %s",gop->gop_key);
|
||||
if (gop->gop_key) proto_tree_add_string(gop_tree,hf_mate_gop_key,tvb,0,0,gop->gop_key);
|
||||
|
||||
gop_attrs_tree(gop_tree,tvb,gop);
|
||||
gop_attrs_tree(gop_tree,pinfo,tvb,gop);
|
||||
|
||||
if (gop->cfg->show_times) {
|
||||
gop_time_tree = proto_tree_add_subtree_format(gop_tree,tvb,0,0,gop->cfg->ett_times,NULL,"%s Times",gop->cfg->name);
|
||||
|
@ -243,7 +248,7 @@ static void mate_gop_tree(proto_tree* tree, tvbuff_t *tvb, mate_gop* gop) {
|
|||
}
|
||||
|
||||
|
||||
static void mate_pdu_tree(mate_pdu *pdu, tvbuff_t *tvb, proto_tree* tree) {
|
||||
static void mate_pdu_tree(mate_pdu *pdu, packet_info *pinfo, tvbuff_t *tvb, proto_tree* tree) {
|
||||
proto_item *pdu_item;
|
||||
proto_tree *pdu_tree;
|
||||
|
||||
|
@ -268,14 +273,14 @@ static void mate_pdu_tree(mate_pdu *pdu, tvbuff_t *tvb, proto_tree* tree) {
|
|||
|
||||
if (pdu->gop) {
|
||||
proto_tree_add_float(pdu_tree,pdu->cfg->hfid_pdu_time_in_gop, tvb, 0, 0, pdu->time_in_gop);
|
||||
mate_gop_tree(tree,tvb,pdu->gop);
|
||||
mate_gop_tree(tree,pinfo,tvb,pdu->gop);
|
||||
|
||||
if (pdu->gop->gog)
|
||||
mate_gog_tree(tree,tvb,pdu->gop->gog,pdu->gop);
|
||||
mate_gog_tree(tree,pinfo,tvb,pdu->gop->gog,pdu->gop);
|
||||
}
|
||||
|
||||
if (pdu->avpl) {
|
||||
pdu_attrs_tree(pdu_tree,tvb,pdu);
|
||||
pdu_attrs_tree(pdu_tree,pinfo,tvb,pdu);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,7 +296,7 @@ static void mate_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
|
|||
for ( ; pdus; pdus = pdus->next_in_frame) {
|
||||
mate_i = proto_tree_add_protocol_format(tree,mc->hfid_mate,tvb,0,0,"MATE");
|
||||
mate_t = proto_item_add_subtree(mate_i, mc->ett_root);
|
||||
mate_pdu_tree(pdus,tvb,mate_t);
|
||||
mate_pdu_tree(pdus,pinfo,tvb,mate_t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,10 +356,27 @@ extern
|
|||
void
|
||||
proto_register_mate(void)
|
||||
{
|
||||
static hf_register_info hf[] = {
|
||||
{ &hf_mate_started_at, { "Started at", "mate.started_at", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_mate_duration, { "Duration", "mate.duration", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_mate_released_time, { "Release time", "mate.released_time", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_mate_number_of_pdus, { "Number of Pdus", "mate.number_of_pdus", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_mate_gop_key, { "GOP Key", "mate.gop_key", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
};
|
||||
|
||||
static ei_register_info ei[] = {
|
||||
{ &ei_mate_undefined_attribute, { "mate.undefined_attribute", PI_PROTOCOL, PI_ERROR, "Undefined attribute", EXPFILL }},
|
||||
};
|
||||
|
||||
expert_module_t* expert_mate;
|
||||
module_t *mate_module;
|
||||
dissector_handle_t mate_handle;
|
||||
|
||||
proto_mate = proto_register_protocol("Meta Analysis Tracing Engine", "MATE", "mate");
|
||||
proto_register_field_array(proto_mate, hf, array_length(hf));
|
||||
expert_mate = expert_register_protocol(proto_mate);
|
||||
expert_register_field_array(expert_mate, ei, array_length(ei));
|
||||
|
||||
register_dissector("mate",mate_tree,proto_mate);
|
||||
mate_module = prefs_register_protocol(proto_mate, proto_reg_handoff_mate);
|
||||
prefs_register_filename_preference(mate_module, "config",
|
||||
|
|
Loading…
Reference in New Issue