diff options
author | Michael Mann <mmann78@netscape.net> | 2014-06-20 21:35:40 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2014-06-22 21:08:21 +0000 |
commit | 9356d5c689fa911b0b13d4b2a0cd6e9208d60f6d (patch) | |
tree | f3265efe4137c8a09995b448bf0c4bcdecf4e5a9 /asn1 | |
parent | 2c0214efff7b3421355e42ee7f3075c2f3181d3e (diff) |
convert to proto_tree_add_subtree[_format] for ASN.1 dissectors
Change-Id: I753ca95e2e1b38bad2c09955317e648c525e40ef
Reviewed-on: https://code.wireshark.org/review/2509
Tested-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'asn1')
31 files changed, 243 insertions, 398 deletions
diff --git a/asn1/ansi_tcap/packet-ansi_tcap-template.c b/asn1/ansi_tcap/packet-ansi_tcap-template.c index 8c2114a805..439a64cafa 100644 --- a/asn1/ansi_tcap/packet-ansi_tcap-template.c +++ b/asn1/ansi_tcap/packet-ansi_tcap-template.c @@ -397,9 +397,8 @@ dissect_ansi_tcap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) #if 0 /* Skip this part for now it will be rewritten */ if (g_ansi_tcap_HandleSRT && !tcap_subdissector_used ) { if (gtcap_DisplaySRT && tree) { - stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat"); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, 0, ett_ansi_tcap_stat, &stat_item, "Stat"); PROTO_ITEM_SET_GENERATED(stat_item); - stat_tree = proto_item_add_subtree(stat_item, ett_ansi_tcap_stat); } p_tcap_context=tcapsrt_call_matching(tvb, pinfo, stat_tree, gp_tcapsrt_info); ansi_tcap_private.context=p_tcap_context; diff --git a/asn1/atn-cm/packet-atn-cm-template.c b/asn1/atn-cm/packet-atn-cm-template.c index a666293c2f..a514322004 100644 --- a/asn1/atn-cm/packet-atn-cm-template.c +++ b/asn1/atn-cm/packet-atn-cm-template.c @@ -75,19 +75,10 @@ dissect_atn_cm( void *data _U_) { int type; - proto_item *ti; proto_tree *sub_tree; - ti = proto_tree_add_text( - tree, - tvb, - 0, - tvb_reported_length_remaining(tvb, 0) , - ATN_CM_PROTO); - - sub_tree = proto_item_add_subtree( - ti, - ett_atn_cm); + sub_tree = proto_tree_add_subtree( + tree, tvb, 0, -1, ett_atn_cm, NULL, ATN_CM_PROTO); /* ti = proto_tree_add_item(tree, proto_atn_cm, tvb, 0, 0 , ENC_NA); */ /* sub_tree = proto_item_add_subtree(ti, ett_atn_cm_pdu); */ diff --git a/asn1/atn-cpdlc/packet-atn-cpdlc-template.c b/asn1/atn-cpdlc/packet-atn-cpdlc-template.c index b0ba23c4d9..d08223f586 100644 --- a/asn1/atn-cpdlc/packet-atn-cpdlc-template.c +++ b/asn1/atn-cpdlc/packet-atn-cpdlc-template.c @@ -162,17 +162,10 @@ dissect_atn_cpdlc( if(!atn_cv){ /* atn conversation not found */ return 0; } - ti = proto_tree_add_text( - tree, - tvb, - 0, - tvb_reported_length_remaining(tvb, 0) , + atn_cpdlc_tree = proto_tree_add_subtree( + tree, tvb, 0, -1, ett_atn_cpdlc, NULL, ATN_CPDLC_PROTO ); - atn_cpdlc_tree = proto_item_add_subtree( - ti, - ett_atn_cpdlc); - switch(atn_cv->ae_qualifier){ case pmcpdlc: if( check_heur_msg_type(pinfo) == um ) { diff --git a/asn1/atn-ulcs/atn-ulcs.cnf b/asn1/atn-ulcs/atn-ulcs.cnf index 4307146488..f3f01aeed3 100644 --- a/asn1/atn-ulcs/atn-ulcs.cnf +++ b/asn1/atn-ulcs/atn-ulcs.cnf @@ -68,13 +68,9 @@ PDV-list/presentation-data-values/arbitrary pdv-list_presentation-data-values_ar /* call appropiate dissector for bitstring data */ switch(ulcs_context_value){ case 1: /* ACSE PDU*/ - ti = proto_tree_add_text( - root_tree, - tvb, - offset, - 0, - ATN_ACSE_PROTO ); - atn_ulcs_tree = proto_item_add_subtree(ti, ett_atn_acse); + atn_ulcs_tree = proto_tree_add_subtree( + root_tree, tvb, offset, 0, + ett_atn_acse, NULL, ATN_ACSE_PROTO ); dissect_ACSE_apdu_PDU( tvb_new_subset_remaining(tvb_usr, 0), diff --git a/asn1/atn-ulcs/packet-atn-ulcs-template.c b/asn1/atn-ulcs/packet-atn-ulcs-template.c index 5b67456ece..37322a3a0c 100644 --- a/asn1/atn-ulcs/packet-atn-ulcs-template.c +++ b/asn1/atn-ulcs/packet-atn-ulcs-template.c @@ -616,16 +616,9 @@ dissect_atn_ulcs( value_ses_pres = tvb_get_ntohs(tvb, offset); /* SPDU: dissect session layer */ - ti = proto_tree_add_text( - tree, - tvb, - offset, - 0, - ATN_SES_PROTO ); - - atn_ulcs_tree = proto_item_add_subtree( - ti, - ett_atn_ses); + atn_ulcs_tree = proto_tree_add_subtree( + tree, tvb, offset, 0, + ett_atn_ses, NULL, ATN_SES_PROTO ); /* get SPDU (1 octet) */ value_ses = tvb_get_guint8(tvb, offset); @@ -675,14 +668,9 @@ dissect_atn_ulcs( offset++; /* PPDU: dissect presentation layer */ - ti = proto_tree_add_text( - tree, - tvb, - offset, - 0, - ATN_PRES_PROTO ); - - atn_ulcs_tree = proto_item_add_subtree(ti, ett_atn_pres); + atn_ulcs_tree = proto_tree_add_subtree( + tree, tvb, offset, 0, + ett_atn_pres, NULL, ATN_PRES_PROTO ); value_pres = tvb_get_guint8(tvb, offset); @@ -718,16 +706,9 @@ dissect_atn_ulcs( offset++; /* ACSE PDU: dissect application layer */ - ti = proto_tree_add_text( - tree, - tvb, - offset, - 0, - ATN_ACSE_PROTO ); - - atn_ulcs_tree = proto_item_add_subtree( - ti, - ett_atn_acse); + atn_ulcs_tree = proto_tree_add_subtree( + tree, tvb, offset, 0, + ett_atn_acse, NULL, ATN_ACSE_PROTO ); dissect_ACSE_apdu_PDU( tvb_new_subset_remaining(tvb, offset), diff --git a/asn1/camel/packet-camel-template.c b/asn1/camel/packet-camel-template.c index 0a64de3386..1bbee0e1a8 100644 --- a/asn1/camel/packet-camel-template.c +++ b/asn1/camel/packet-camel-template.c @@ -1072,7 +1072,7 @@ dissect_camel_camelPDU(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn static int dissect_camel_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { - proto_item *item, *stat_item; + proto_item *item; proto_tree *tree = NULL, *stat_tree = NULL; struct tcap_private_t * p_private_tcap = (struct tcap_private_t*)data; asn1_ctx_t asn1_ctx; @@ -1097,8 +1097,7 @@ dissect_camel_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi if (gcamel_HandleSRT && gp_camelsrt_info->tcap_context ) { if (gcamel_DisplaySRT && tree) { - stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat"); - stat_tree = proto_item_add_subtree(stat_item, ett_camel_stat); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, 0, ett_camel_stat, NULL, "Stat"); } camelsrt_call_matching(tvb, pinfo, stat_tree, gp_camelsrt_info); tap_queue_packet(camel_tap, pinfo, gp_camelsrt_info); @@ -1110,7 +1109,7 @@ dissect_camel_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi static int dissect_camel_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { - proto_item *item, *stat_item; + proto_item *item; proto_tree *tree = NULL, *stat_tree = NULL; struct tcap_private_t * p_private_tcap = (struct tcap_private_t*)data; asn1_ctx_t asn1_ctx; @@ -1135,8 +1134,7 @@ dissect_camel_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi if (gcamel_HandleSRT && gp_camelsrt_info->tcap_context ) { if (gcamel_DisplaySRT && tree) { - stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat"); - stat_tree = proto_item_add_subtree(stat_item, ett_camel_stat); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, 0, ett_camel_stat, NULL, "Stat"); } camelsrt_call_matching(tvb, pinfo, stat_tree, gp_camelsrt_info); tap_queue_packet(camel_tap, pinfo, gp_camelsrt_info); @@ -1148,7 +1146,7 @@ dissect_camel_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi static int dissect_camel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data) { - proto_item *item, *stat_item; + proto_item *item; proto_tree *tree, *stat_tree = NULL; struct tcap_private_t * p_private_tcap = (struct tcap_private_t*)data; asn1_ctx_t asn1_ctx; @@ -1172,8 +1170,7 @@ dissect_camel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* if (gcamel_HandleSRT && gp_camelsrt_info->tcap_context ) { if (gcamel_DisplaySRT && tree) { - stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat"); - stat_tree = proto_item_add_subtree(stat_item, ett_camel_stat); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, 0, ett_camel_stat, NULL, "Stat"); } camelsrt_call_matching(tvb, pinfo, stat_tree, gp_camelsrt_info); tap_queue_packet(camel_tap, pinfo, gp_camelsrt_info); diff --git a/asn1/charging_ase/packet-charging_ase-template.c b/asn1/charging_ase/packet-charging_ase-template.c index 20efe7ed94..7b378801d7 100644 --- a/asn1/charging_ase/packet-charging_ase-template.c +++ b/asn1/charging_ase/packet-charging_ase-template.c @@ -55,7 +55,7 @@ dissect_charging_ase(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *it; proto_tree *tr; - it=proto_tree_add_protocol_format(tree, proto_charging_ase, tvb, 0, tvb_captured_length(tvb), "Charging ASE"); + it=proto_tree_add_protocol_format(tree, proto_charging_ase, tvb, 0, -1, "Charging ASE"); tr=proto_item_add_subtree(it, ett_charging_ase); if(tvb_reported_length(tvb)>0) diff --git a/asn1/cmp/packet-cmp-template.c b/asn1/cmp/packet-cmp-template.c index 036b8c3bbe..995693efe2 100644 --- a/asn1/cmp/packet-cmp-template.c +++ b/asn1/cmp/packet-cmp-template.c @@ -133,8 +133,7 @@ static int dissect_cmp_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pa proto_tree_add_item(tree, hf_cmp_tcptrans_type, tvb, offset++, 1, ENC_BIG_ENDIAN); } else { /* post RFC2510 TCP transport - the former "type" field is now "version" */ - ti = proto_tree_add_text(tree, tvb, offset, 7, "TCP transport"); - tcptrans_tree = proto_item_add_subtree(ti, ett_cmp); + tcptrans_tree = proto_tree_add_subtree(tree, tvb, offset, 7, ett_cmp, NULL, "TCP transport"); pdu_type=tvb_get_guint8(tvb, 6); proto_tree_add_item(tcptrans_tree, hf_cmp_tcptrans_len, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; diff --git a/asn1/dop/packet-dop-template.c b/asn1/dop/packet-dop-template.c index 8e4ed75f05..f26c14ea18 100644 --- a/asn1/dop/packet-dop-template.c +++ b/asn1/dop/packet-dop-template.c @@ -97,13 +97,12 @@ call_dop_oid_callback(const char *base_string, tvbuff_t *tvb, int offset, packet if (dissector_try_string(dop_dissector_table, binding_param, tvb, pinfo, tree, data)) { offset = tvb_reported_length (tvb); } else { - proto_item *item=NULL; - proto_tree *next_tree=NULL; + proto_item *item; + proto_tree *next_tree; + + next_tree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett_dop_unknown, &item, + "Dissector for parameter %s OID:%s not implemented. Contact Wireshark developers if you want this supported", base_string, binding_type ? binding_type : "<empty>"); - item = proto_tree_add_text(tree, tvb, 0, tvb_length_remaining(tvb, offset), "Dissector for parameter %s OID:%s not implemented. Contact Wireshark developers if you want this supported", base_string, binding_type ? binding_type : "<empty>"); - if (item) { - next_tree = proto_item_add_subtree(item, ett_dop_unknown); - } offset = dissect_unknown_ber(pinfo, tvb, offset, next_tree); expert_add_info(pinfo, item, &ei_dop_unknown_binding_parameter); } diff --git a/asn1/gsm_map/packet-gsm_map-template.c b/asn1/gsm_map/packet-gsm_map-template.c index dca213843f..f507161db0 100644 --- a/asn1/gsm_map/packet-gsm_map-template.c +++ b/asn1/gsm_map/packet-gsm_map-template.c @@ -1850,67 +1850,51 @@ static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset, /* Private extension container for PLMN Data */ static void dissect_gsm_mapext_PlmnContainer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "MAP Ext. Plmn Container"); - tree = proto_item_add_subtree(item, ett_gsm_old_PlmnContainer_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_gsm_old_PlmnContainer_U, NULL, "MAP Ext. Plmn Container"); + dissect_gsm_old_PlmnContainer(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_SriResExtension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_SriResExtension_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_SriResExtension_U, NULL, "Nokia Extension"); dissect_NokiaMAP_Extensions_SriResExtension(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_CanLocArgExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_CanLocArgExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_CanLocArgExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_CanLocArgExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_ATMargExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_ATMargExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_ATMargExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_ATMargExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_DTMargExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_DTMargExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_DTMargExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_DTMargExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } @@ -1922,15 +1906,12 @@ static void dissect_NokiaMAP_ext_NumberPorted(tvbuff_t *tvb, packet_info *pinfo, } static void dissect_NokiaMAP_ext_ATMresExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_ATMresExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_ATMresExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_ATMresExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } @@ -1942,106 +1923,82 @@ static void dissect_NokiaMAP_ext_AbsentSubscriberExt(tvbuff_t *tvb, packet_info } static void dissect_NokiaMAP_ext_SriForSMArgExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_SriForSMArgExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_SriForSMArgExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_SriForSMArgExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_ReportSMDelStatArgExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_ReportSMDelStatArgExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_ReportSMDelStatArgExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_ReportSMDelStatArgExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_UdlArgExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_UdlArgExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_UdlArgExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_UdlArgExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_RoamNotAllowedExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_RoamNotAllowedExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_RoamNotAllowedExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_RoamNotAllowedExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_MO_ForwardSM_ArgExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_MO_ForwardSM_ArgExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_MO_ForwardSM_ArgExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_MO_ForwardSM_ArgExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_ErrOlcmInfoTableExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_ErrOlcmInfoTableExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_ErrOlcmInfoTableExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_ErrOlcmInfoTableExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_RoutingCategoryExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_RoutingCategoryExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_RoutingCategoryExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_RoutingCategoryExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_AnyTimeModArgExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_AnyTimeModArgExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_AnyTimeModArgExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_AnyTimeModArgExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } @@ -2073,94 +2030,73 @@ static void dissect_NokiaMAP_ext_AllowedServiceData(tvbuff_t *tvb, packet_info * } static void dissect_NokiaMAP_ext_SriExtension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_SriExtension_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_SriExtension_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_SriExtension(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ExtraSignalInfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_ExtraSignalInfo_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_ExtraSignalInfo_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_ExtraSignalInfo(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_SS_DataExtension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_SS_DataExtension_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_SS_DataExtension_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_SS_DataExtension(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_HOExtension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_HO_Ext_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_HO_Ext_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_HO_Ext(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_UlResExtension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_UlResExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_UlResExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_UlResExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_IsdArgExtension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_IsdArgExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_IsdArgExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_IsdArgExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } static void dissect_NokiaMAP_ext_DsdArgExt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); /* create display subtree for the protocol */ - if(parent_tree){ - item = proto_tree_add_text(parent_tree, tvb, 0, -1, "Nokia Extension"); - tree = proto_item_add_subtree(item, ett_NokiaMAP_Extensions_DsdArgExt_U); - } + tree = proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_NokiaMAP_Extensions_DsdArgExt_U, NULL, "Nokia Extension"); + dissect_NokiaMAP_Extensions_DsdArgExt(FALSE, tvb, 0, &asn1_ctx, tree, -1); } diff --git a/asn1/h225/packet-h225-template.c b/asn1/h225/packet-h225-template.c index 26ef8a16ff..74b01aa89e 100644 --- a/asn1/h225/packet-h225-template.c +++ b/asn1/h225/packet-h225-template.c @@ -159,7 +159,7 @@ dissect_h225_H323UserInformation(tvbuff_t *tvb, packet_info *pinfo, proto_tree * col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME); col_clear(pinfo->cinfo, COL_INFO); - it=proto_tree_add_protocol_format(tree, proto_h225, tvb, 0, tvb_captured_length(tvb), PSNAME" CS"); + it=proto_tree_add_protocol_format(tree, proto_h225, tvb, 0, -1, PSNAME" CS"); tr=proto_item_add_subtree(it, ett_h225); offset = dissect_H323_UserInformation_PDU(tvb, pinfo, tr, NULL); @@ -194,7 +194,7 @@ dissect_h225_h225_RasMessage(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME); - it=proto_tree_add_protocol_format(tree, proto_h225, tvb, offset, tvb_captured_length(tvb), PSNAME" RAS"); + it=proto_tree_add_protocol_format(tree, proto_h225, tvb, offset, -1, PSNAME" RAS"); tr=proto_item_add_subtree(it, ett_h225); offset = dissect_RasMessage_PDU(tvb, pinfo, tr, NULL); diff --git a/asn1/h245/h245.cnf b/asn1/h245/h245.cnf index bb8dc7ff8d..4368d27621 100644 --- a/asn1/h245/h245.cnf +++ b/asn1/h245/h245.cnf @@ -997,8 +997,7 @@ NonStandardIdentifier/h221NonStandard/manufacturerCode VAL_PTR = &manufacturerC if (next_tvb && tvb_length(next_tvb)) { saved_h245_pi = h245_pi; h245_pi = NULL; - item = proto_tree_add_text(tree, next_tvb, 0, -1,"The returned function"); - subtree = proto_item_add_subtree(item, ett_h245_returnedFunction); + subtree = proto_tree_add_subtree(tree, next_tvb, 0, -1, ett_h245_returnedFunction, &item, "The returned function"); PROTO_ITEM_SET_GENERATED(item); dissect_h245_MultimediaSystemControlMessage(next_tvb, 0, actx, subtree, hf_h245_pdu_type); h245_pi = saved_h245_pi; diff --git a/asn1/h245/packet-h245-template.c b/asn1/h245/packet-h245-template.c index 451e85f8f9..5fd7a7ae60 100644 --- a/asn1/h245/packet-h245-template.c +++ b/asn1/h245/packet-h245-template.c @@ -425,7 +425,7 @@ dissect_h245_h245(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME); - it=proto_tree_add_protocol_format(parent_tree, proto_h245, tvb, 0, tvb_captured_length(tvb), PSNAME); + it=proto_tree_add_protocol_format(parent_tree, proto_h245, tvb, 0, -1, PSNAME); tr=proto_item_add_subtree(it, ett_h245); /* assume that whilst there is more tvb data, there are more h245 commands */ diff --git a/asn1/isdn-sup/packet-isdn-sup-template.c b/asn1/isdn-sup/packet-isdn-sup-template.c index 214a0ed411..235b3595f0 100644 --- a/asn1/isdn-sup/packet-isdn-sup-template.c +++ b/asn1/isdn-sup/packet-isdn-sup-template.c @@ -161,7 +161,7 @@ dissect_isdn_sup_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * if (!op_ptr) return offset; - ti = proto_tree_add_item(tree, proto_isdn_sup, tvb, offset, tvb_captured_length(tvb), ENC_NA); + ti = proto_tree_add_item(tree, proto_isdn_sup, tvb, offset, -1, ENC_NA); isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_operation, tvb, 0, 0, opcode); @@ -210,7 +210,7 @@ dissect_isdn_sup_res(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * if (!op_ptr) return offset; - ti = proto_tree_add_item(tree, proto_isdn_sup, tvb, offset, tvb_captured_length(tvb), ENC_NA); + ti = proto_tree_add_item(tree, proto_isdn_sup, tvb, offset, -1, ENC_NA); isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_operation, tvb, 0, 0, opcode); @@ -260,7 +260,7 @@ dissect_isdn_sup_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void * if (!err_ptr) return offset; - ti = proto_tree_add_item(tree, proto_isdn_sup, tvb, offset, tvb_captured_length(tvb), ENC_NA); + ti = proto_tree_add_item(tree, proto_isdn_sup, tvb, offset, -1, ENC_NA); isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup); proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_error, tvb, 0, 0, errcode); diff --git a/asn1/ldap/ldap.cnf b/asn1/ldap/ldap.cnf index dfad13183f..f4938c5622 100644 --- a/asn1/ldap/ldap.cnf +++ b/asn1/ldap/ldap.cnf @@ -571,11 +571,9 @@ ldap_conv_info_t *ldap_info; const char *old_and_filter_string=and_filter_string; and_filter_string=NULL; - if(tree){ - it=proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "and: "); - tr=proto_item_add_subtree(it, ett_ldap_T_and); - tree = tr; - } + + tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_T_and, &it, "and: "); + tree = tr; %(DEFAULT_BODY)s @@ -594,16 +592,14 @@ ldap_conv_info_t *ldap_info; #.FN_BODY Filter/or - proto_tree *tr=NULL; - proto_item *it=NULL; + proto_tree *tr; + proto_item *it; const char *old_or_filter_string=or_filter_string; or_filter_string=NULL; - if(tree){ - it=proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "or: "); - tr=proto_item_add_subtree(it, ett_ldap_T_or); - tree = tr; - } + tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_T_or, &it, "or: "); + tree = tr; + %(DEFAULT_BODY)s if(or_filter_string) { proto_item_append_text(it, "%%s", or_filter_string); @@ -655,8 +651,8 @@ offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &v } #.FN_BODY SubstringFilter - proto_tree *tr=NULL; - proto_item *it=NULL; + proto_tree *tr; + proto_item *it; const char *old_substring_value=substring_value; attr_type=NULL; @@ -664,11 +660,10 @@ offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &v substring_item_init=NULL; substring_item_any=NULL; substring_item_final=NULL; - if(tree){ - it=proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "substring: "); - tr=proto_item_add_subtree(it, ett_ldap_SubstringFilter); - tree = tr; - } + + tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_SubstringFilter, &it, "substring: "); + tree = tr; + %(DEFAULT_BODY)s Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(%%s=%%s)", string_or_null(attr_type), @@ -677,8 +672,8 @@ offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &v substring_value=old_substring_value; #.FN_BODY Filter - proto_tree *tr=NULL; - proto_item *it=NULL; + proto_tree *tr; + proto_item *it; attributedesc_string=NULL; if (Filter_length++ > MAX_FILTER_LEN) { @@ -691,11 +686,9 @@ offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &v THROW(ReportedBoundsError); } - if(tree){ - it=proto_tree_add_text(tree, tvb, offset, tvb_length_remaining(tvb, offset), "Filter: "); - tr=proto_item_add_subtree(it, ett_ldap_Filter); - tree = tr; - } + tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_Filter, &it, "Filter: "); + tree = tr; + %(DEFAULT_BODY)s if(Filter_string) proto_item_append_text(it, "%%s", string_or_null(Filter_string)); @@ -796,10 +789,9 @@ offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &v hfinfo = proto_registrar_get_nth(hf_index); if (val >0) { - proto_tree *subtree = NULL; - proto_item *item = NULL; - item = proto_tree_add_text(tree, tvb, otheroffset+1, len, "%s: 0x%08x", hfinfo->name, val); - subtree = proto_item_add_subtree(item, ett_ldap_DirSyncFlagsSubEntry); + proto_tree *subtree; + subtree = proto_tree_add_subtree_format(tree, tvb, otheroffset+1, len, + ett_ldap_DirSyncFlagsSubEntry, NULL, "%s: 0x%08x", hfinfo->name, val); if (val & 0x1) { proto_tree_add_text(subtree, tvb, otheroffset+1, len, "Flag Object_Security"); diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c index 2d386f4014..60dc7953f9 100644 --- a/asn1/ldap/packet-ldap-template.c +++ b/asn1/ldap/packet-ldap-template.c @@ -1,7 +1,7 @@ -/* packet-ldap.c +/* packet-ldap-template.c * Routines for ldap packet dissection * - * See RFC 1777 (LDAP v2), RFC 4511 (LDAP v3), and RFC 2222 (SASL). + * See RFC 1777 (LDtAP v2), RFC 4511 (LDAP v3), and RFC 2222 (SASL). * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> @@ -1120,8 +1120,7 @@ static void */ if (doing_sasl_security && tvb_get_guint8(tvb, offset) == 0) { - proto_item *sasl_item = NULL; - proto_tree *sasl_tree = NULL; + proto_tree *sasl_tree; tvbuff_t *sasl_tvb; guint sasl_len, sasl_msg_len, length; /* @@ -1167,13 +1166,10 @@ static void if (length > sasl_msg_len) length = sasl_msg_len; sasl_tvb = tvb_new_subset(tvb, offset, length, sasl_msg_len); - if (ldap_tree) { - proto_tree_add_uint(ldap_tree, hf_ldap_sasl_buffer_length, sasl_tvb, 0, 4, + proto_tree_add_uint(ldap_tree, hf_ldap_sasl_buffer_length, sasl_tvb, 0, 4, sasl_len); - sasl_item = proto_tree_add_text(ldap_tree, sasl_tvb, 0, sasl_msg_len, "SASL Buffer"); - sasl_tree = proto_item_add_subtree(sasl_item, ett_ldap_sasl_blob); - } + sasl_tree = proto_tree_add_subtree(ldap_tree, sasl_tvb, 0, sasl_msg_len, ett_ldap_sasl_blob, NULL, "SASL Buffer"); if (ldap_info->auth_mech != NULL && ((strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) || @@ -1232,8 +1228,7 @@ static void } if (decr_tvb) { - proto_item *enc_item = NULL; - proto_tree *enc_tree = NULL; + proto_tree *enc_tree; /* * The LDAP message was encrypted in the packet, and has @@ -1242,16 +1237,14 @@ static void col_set_str(pinfo->cinfo, COL_INFO, "SASL GSS-API Privacy (decrypted): "); if (sasl_tree) { - enc_item = proto_tree_add_text(sasl_tree, gssapi_tvb, ver_len, -1, - "GSS-API Encrypted payload (%d byte%s)", + enc_tree = proto_tree_add_subtree_format(sasl_tree, gssapi_tvb, ver_len, -1, + ett_ldap_payload, NULL, "GSS-API Encrypted payload (%d byte%s)", sasl_len - ver_len, plurality(sasl_len - ver_len, "", "s")); - enc_tree = proto_item_add_subtree(enc_item, ett_ldap_payload); } dissect_ldap_payload(decr_tvb, pinfo, enc_tree, ldap_info, is_mscldap); } else if (plain_tvb) { - proto_item *plain_item = NULL; - proto_tree *plain_tree = NULL; + proto_tree *plain_tree; /* * The LDAP message wasn't encrypted in the packet; @@ -1260,11 +1253,10 @@ static void col_set_str(pinfo->cinfo, COL_INFO, "SASL GSS-API Integrity: "); if (sasl_tree) { - plain_item = proto_tree_add_text(sasl_tree, gssapi_tvb, ver_len, -1, - "GSS-API payload (%d byte%s)", + plain_tree = proto_tree_add_subtree_format(sasl_tree, gssapi_tvb, ver_len, -1, + ett_ldap_payload, NULL, "GSS-API payload (%d byte%s)", sasl_len - ver_len, plurality(sasl_len - ver_len, "", "s")); - plain_tree = proto_item_add_subtree(plain_item, ett_ldap_payload); } dissect_ldap_payload(plain_tvb, pinfo, plain_tree, ldap_info, is_mscldap); @@ -1374,7 +1366,7 @@ static int dissect_mscldap_netlogon_flags(proto_tree *parent_tree, tvbuff_t *tvb { guint32 flags; proto_item *item; - proto_tree *tree=NULL; + proto_tree *tree; guint *field; header_field_info *hfi; gboolean one_bit_set = FALSE; @@ -1398,9 +1390,7 @@ static int dissect_mscldap_netlogon_flags(proto_tree *parent_tree, tvbuff_t *tvb flags=tvb_get_letohl(tvb, offset); item=proto_tree_add_item(parent_tree, hf_mscldap_netlogon_flags, tvb, offset, 4, ENC_LITTLE_ENDIAN); - if(parent_tree){ - tree = proto_item_add_subtree(item, ett_mscldap_netlogon_flags); - } + tree = proto_item_add_subtree(item, ett_mscldap_netlogon_flags); proto_item_append_text(item, " ("); diff --git a/asn1/lte-rrc/lte-rrc.cnf b/asn1/lte-rrc/lte-rrc.cnf index 9068a07887..f8e11dfa30 100644 --- a/asn1/lte-rrc/lte-rrc.cnf +++ b/asn1/lte-rrc/lte-rrc.cnf @@ -138,8 +138,8 @@ if(ue_cap_tvb){ case RAT_Type_geran_cs: /* geran-cs */ /* Mobile Station Classmark 2 is formatted as TLV with the two first bytes set to 0x33 0x03 */ - item = proto_tree_add_text(subtree, ue_cap_tvb, 0, 5, "Mobile Station Classmark 2"); - subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container); + subtree2 = proto_tree_add_subtree(subtree, ue_cap_tvb, 0, 5, + ett_lte_rrc_UE_CapabilityRAT_Container, &item, "Mobile Station Classmark 2"); byte = tvb_get_guint8(ue_cap_tvb, 0); if (byte != 0x33) { expert_add_info_format(actx->pinfo, item, &ei_lte_rrc_unexpected_type_value, @@ -153,16 +153,16 @@ if(ue_cap_tvb){ de_ms_cm_2(ue_cap_tvb, subtree2, actx->pinfo, 2, 3, NULL, 0); /* Mobile Station Classmark 3 is formatted as V */ length = tvb_reported_length_remaining(ue_cap_tvb, 5); - item = proto_tree_add_text(subtree, ue_cap_tvb, 5, length, "Mobile Station Classmark 3"); - subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container); + subtree2 = proto_tree_add_subtree(subtree, ue_cap_tvb, 5, length, + ett_lte_rrc_UE_CapabilityRAT_Container, NULL, "Mobile Station Classmark 3"); de_ms_cm_3(ue_cap_tvb, subtree2, actx->pinfo, 5, length, NULL, 0); break; case RAT_Type_geran_ps: /* geran-ps */ /* MS Radio Access Capability is formatted as V */ length = tvb_reported_length(ue_cap_tvb); - item = proto_tree_add_text(subtree, ue_cap_tvb, 0, length, "MS Radio Access Capability"); - subtree2 = proto_item_add_subtree(item, ett_lte_rrc_UE_CapabilityRAT_Container); + subtree2 = proto_tree_add_subtree(subtree, ue_cap_tvb, 0, length, + ett_lte_rrc_UE_CapabilityRAT_Container, NULL, "MS Radio Access Capability"); de_gmm_ms_radio_acc_cap(ue_cap_tvb, subtree2, actx->pinfo, 0, length, NULL, 0); break; case RAT_Type_cdma2000_1XRTT: diff --git a/asn1/p1/p1.cnf b/asn1/p1/p1.cnf index b08f2b6c59..a212e3ad74 100644 --- a/asn1/p1/p1.cnf +++ b/asn1/p1/p1.cnf @@ -539,12 +539,11 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" if (dissector_try_uint(p1_extension_dissector_table, actx->external.indirect_reference, tvb, actx->pinfo, tree)) { offset = tvb_length(tvb); } else { - proto_item *item = NULL; - proto_tree *next_tree = NULL; + proto_item *item; + proto_tree *next_tree; - item = proto_tree_add_text(tree, tvb, 0, tvb_length_remaining(tvb, offset), + next_tree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett_p1_unknown_standard_extension, &item, "Dissector for standard-extension %%d not implemented. Contact Wireshark developers if you want this supported", actx->external.indirect_reference); - next_tree = proto_item_add_subtree(item, ett_p1_unknown_standard_extension); offset = dissect_unknown_ber(actx->pinfo, tvb, offset, next_tree); expert_add_info(actx->pinfo, item, &ei_p1_unknown_standard_extension); } @@ -578,12 +577,11 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" if (dissector_try_uint(p1_extension_attribute_dissector_table, actx->external.indirect_reference, tvb, actx->pinfo, tree)) { offset =tvb_length(tvb); } else { - proto_item *item = NULL; - proto_tree *next_tree = NULL; + proto_item *item; + proto_tree *next_tree; - item = proto_tree_add_text(tree, tvb, 0, tvb_length_remaining(tvb, offset), + next_tree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett_p1_unknown_extension_attribute_type, &item, "Dissector for extension-attribute-type %%d not implemented. Contact Wireshark developers if you want this supported", actx->external.indirect_reference); - next_tree = proto_item_add_subtree(item, ett_p1_unknown_extension_attribute_type); offset = dissect_unknown_ber(actx->pinfo, tvb, offset, next_tree); expert_add_info(actx->pinfo, item, &ei_p1_unknown_extension_attribute_type); } @@ -674,16 +672,15 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" if (next_tvb) { if (ctx && ctx->content_type_id) { (void) call_ber_oid_callback(ctx->content_type_id, next_tvb, 0, actx->pinfo, actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->private_data); - } else if (ctx && ctx->report_unknown_content_type) { - proto_item *item = NULL; - proto_tree *next_tree = NULL; + } else if (ctx && ctx->report_unknown_content_type) { + proto_item *item; + proto_tree *next_tree; - proto_tree_add_expert(actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->pinfo, &ei_p1_unknown_built_in_content_type, + item = proto_tree_add_expert(actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->pinfo, &ei_p1_unknown_built_in_content_type, next_tvb, 0, tvb_length_remaining(tvb, offset)); - if (item) { next_tree=proto_item_add_subtree(item, ett_p1_content_unknown); - } - dissect_unknown_ber(actx->pinfo, next_tvb, 0, next_tree); + + dissect_unknown_ber(actx->pinfo, next_tvb, 0, next_tree); } else { proto_item_append_text (actx->created_item, " (unknown content-type)"); } @@ -1176,12 +1173,11 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" if (dissector_try_uint(p1_tokendata_dissector_table, actx->external.indirect_reference, tvb, actx->pinfo, tree)) { offset = tvb_length(tvb); } else { - proto_item *item = NULL; - proto_tree *next_tree = NULL; + proto_item *item; + proto_tree *next_tree; - item = proto_tree_add_text(tree, tvb, 0, tvb_length_remaining(tvb, offset), + next_tree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett_p1_unknown_tokendata_type, &item, "Dissector for tokendata-type %%d not implemented. Contact Wireshark developers if you want this supported", actx->external.indirect_reference); - next_tree = proto_item_add_subtree(item, ett_p1_unknown_tokendata_type); offset = dissect_unknown_ber(actx->pinfo, tvb, offset, next_tree); expert_add_info(actx->pinfo, item, &ei_p1_unknown_tokendata_type); } diff --git a/asn1/q932/packet-q932-template.c b/asn1/q932/packet-q932-template.c index 925d370fc6..8fe66eac00 100644 --- a/asn1/q932/packet-q932-template.c +++ b/asn1/q932/packet-q932-template.c @@ -238,7 +238,7 @@ dissect_q932_ni_ie(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree static void dissect_q932_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { gint offset; - proto_item *ti, *ti_ie; + proto_item *ti; proto_tree *ie_tree; guint8 ie_type, ie_len; @@ -250,9 +250,9 @@ dissect_q932_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { ie_type = tvb_get_guint8(tvb, offset); ie_len = tvb_get_guint8(tvb, offset + 1); - ti_ie = proto_tree_add_text(tree, tvb, offset, -1, "%s", + ie_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_q932_ie, NULL, val_to_str(ie_type, VALS(q932_str_ie_type), "unknown (0x%02X)")); - ie_tree = proto_item_add_subtree(ti_ie, ett_q932_ie); + proto_tree_add_item(ie_tree, hf_q932_ie_type, tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_item(ie_tree, hf_q932_ie_len, tvb, offset + 1, 1, ENC_BIG_ENDIAN); offset += 2; @@ -267,7 +267,7 @@ dissect_q932_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { break; default: if (ie_len > 0) { - if (tree) proto_tree_add_item(ie_tree, hf_q932_ie_data, tvb, offset, ie_len, ENC_NA); + proto_tree_add_item(ie_tree, hf_q932_ie_data, tvb, offset, ie_len, ENC_NA); } } } diff --git a/asn1/qsig/packet-qsig-template.c b/asn1/qsig/packet-qsig-template.c index cfd70c60cf..cad737acff 100644 --- a/asn1/qsig/packet-qsig-template.c +++ b/asn1/qsig/packet-qsig-template.c @@ -549,7 +549,7 @@ dissect_qsig_party_category_ie(tvbuff_t *tvb, int offset, packet_info *pinfo _U static void dissect_qsig_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int codeset) { gint offset; - proto_item *ti, *ti_ie, *hidden_item; + proto_item *ti, *hidden_item; proto_tree *ie_tree; guint8 ie_type, ie_len; @@ -561,9 +561,9 @@ dissect_qsig_ie(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int codeset ie_type = tvb_get_guint8(tvb, offset); ie_len = tvb_get_guint8(tvb, offset + 1); - ti_ie = proto_tree_add_text(tree, tvb, offset, -1, "%s", + ie_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_qsig_ie, NULL, val_to_str(ie_type, VALS(qsig_str_ie_type[codeset]), "unknown (0x%02X)")); - ie_tree = proto_item_add_subtree(ti_ie, ett_qsig_ie); + proto_tree_add_item(ie_tree, *hf_qsig_ie_type_arr[codeset], tvb, offset, 1, ENC_BIG_ENDIAN); hidden_item = proto_tree_add_item(ie_tree, hf_qsig_ie_type, tvb, offset, 1, ENC_BIG_ENDIAN); PROTO_ITEM_SET_HIDDEN(hidden_item); diff --git a/asn1/qsig/qsig.cnf b/asn1/qsig/qsig.cnf index 1d77bad080..547cc31ec1 100644 --- a/asn1/qsig/qsig.cnf +++ b/asn1/qsig/qsig.cnf @@ -145,13 +145,11 @@ NameData TYPE = FT_STRING DISPLAY = BASE_NONE next_tvb = tvb_new_subset_remaining(tvb, offset); if (!dissector_try_string(extension_dissector_table, extension_oid, next_tvb, actx->pinfo, tree, NULL)) { - proto_item *item=NULL; - proto_tree *next_tree=NULL; + proto_tree *next_tree; + + next_tree=proto_tree_add_subtree_format(tree, next_tvb, 0, -1, ett_qsig_unknown_extension, NULL, + "QSIG: Dissector for extension with OID:%%s not implemented.", extension_oid); - item=proto_tree_add_text(tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "QSIG: Dissector for extension with OID:%%s not implemented.", extension_oid); - if(item){ - next_tree=proto_item_add_subtree(item, ett_qsig_unknown_extension); - } dissect_unknown_ber(actx->pinfo, next_tvb, offset, next_tree); } diff --git a/asn1/ros/packet-ros-template.c b/asn1/ros/packet-ros-template.c index 17097d1363..4f1b79114d 100644 --- a/asn1/ros/packet-ros-template.c +++ b/asn1/ros/packet-ros-template.c @@ -210,8 +210,11 @@ call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *p if(!ros_try_string(oid, next_tvb, pinfo, tree, session) && !dissector_try_string(ros_oid_dissector_table, oid, next_tvb, pinfo, tree, session)){ - proto_item *item=proto_tree_add_text(tree, next_tvb, 0, tvb_length_remaining(tvb, offset), "ROS: Dissector for OID:%s not implemented. Contact Wireshark developers if you want this supported", oid); - proto_tree *next_tree=proto_item_add_subtree(item, ett_ros_unknown); + proto_item *item; + proto_tree *next_tree; + + next_tree = proto_tree_add_subtree_format(tree, next_tvb, 0, -1, ett_ros_unknown, &item, + "ROS: Dissector for OID:%s not implemented. Contact Wireshark developers if you want this supported", oid); expert_add_info_format(pinfo, item, &ei_ros_dissector_oid_not_implemented, "ROS: Dissector for OID %s not implemented", oid); @@ -420,14 +423,10 @@ dissect_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da old_offset=offset; offset=dissect_ros_ROS(FALSE, tvb, offset, &asn1_ctx , tree, -1); if(offset == old_offset){ - item = proto_tree_add_text(tree, tvb, offset, -1,"Unknown ROS PDU"); - - if(item){ - expert_add_info(pinfo, item, &ei_ros_unknown_ros_pdu); - next_tree=proto_item_add_subtree(item, ett_ros_unknown); - dissect_unknown_ber(pinfo, tvb, offset, next_tree); - } + next_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_ros_unknown, &item, "Unknown ROS PDU"); + expert_add_info(pinfo, item, &ei_ros_unknown_ros_pdu); + dissect_unknown_ber(pinfo, tvb, offset, next_tree); break; } } diff --git a/asn1/rrc/rrc.cnf b/asn1/rrc/rrc.cnf index 531400fceb..f53486278e 100644 --- a/asn1/rrc/rrc.cnf +++ b/asn1/rrc/rrc.cnf @@ -676,7 +676,6 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE #.FN_BODY NAS-SystemInformationGSM-MAP VAL_PTR = &nas_sys_info_gsm_map_tvb tvbuff_t *nas_sys_info_gsm_map_tvb = NULL; guint32 length; - proto_item *item; proto_tree *subtree; %(DEFAULT_BODY)s @@ -685,18 +684,18 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE if (actx->private_data) { switch (GPOINTER_TO_UINT(actx->private_data)-1) { case RRC_NAS_SYS_INFO_CN_COMMON: - item = proto_tree_add_text(tree, nas_sys_info_gsm_map_tvb, 0, length, "CN Common GSM-MAP NAS system information"); - subtree = proto_item_add_subtree(item, ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo); + subtree = proto_tree_add_subtree(tree, nas_sys_info_gsm_map_tvb, 0, length, + ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo, NULL, "CN Common GSM-MAP NAS system information"); de_cn_common_gsm_map_nas_sys_info(nas_sys_info_gsm_map_tvb, subtree, actx->pinfo, 0, length, NULL, 0); break; case RRC_NAS_SYS_INFO_CS: - item = proto_tree_add_text(tree, nas_sys_info_gsm_map_tvb, 0, length, "CS domain specific system information"); - subtree = proto_item_add_subtree(item, ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo); + subtree = proto_tree_add_subtree(tree, nas_sys_info_gsm_map_tvb, 0, length, + ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo, NULL, "CS domain specific system information"); de_cs_domain_spec_sys_info(nas_sys_info_gsm_map_tvb, subtree, actx->pinfo, 0, length, NULL, 0); break; case RRC_NAS_SYS_INFO_PS: - item = proto_tree_add_text(tree, nas_sys_info_gsm_map_tvb, 0, length, "PS domain specific system information"); - subtree = proto_item_add_subtree(item, ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo); + subtree = proto_tree_add_subtree(tree, nas_sys_info_gsm_map_tvb, 0, length, + ett_rrc_cn_CommonGSM_MAP_NAS_SysInfo, NULL, "PS domain specific system information"); de_ps_domain_spec_sys_info(nas_sys_info_gsm_map_tvb, subtree, actx->pinfo, 0, length, NULL, 0); break; default: diff --git a/asn1/rtse/packet-rtse-template.c b/asn1/rtse/packet-rtse-template.c index 45132ff225..6386278b3f 100644 --- a/asn1/rtse/packet-rtse-template.c +++ b/asn1/rtse/packet-rtse-template.c @@ -1,4 +1,4 @@ -/* packet-rtse_asn1.c +/* packet-rtse-template.c * Routines for RTSE packet dissection * Graeme Lunt 2005 * @@ -147,8 +147,10 @@ call_rtse_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info * next_tvb = tvb_new_subset_remaining(tvb, offset); if(!dissector_try_string(rtse_oid_dissector_table, oid, next_tvb, pinfo, tree, data)){ - proto_item *item=proto_tree_add_text(tree, next_tvb, 0, tvb_captured_length_remaining(tvb, offset), "RTSE: Dissector for OID:%s not implemented. Contact Wireshark developers if you want this supported", oid); - proto_tree *next_tree=proto_item_add_subtree(item, ett_rtse_unknown); + proto_item *item; + proto_tree *next_tree; + next_tree = proto_tree_add_subtree_format(tree, next_tvb, 0, -1, ett_rtse_unknown, &item, + "RTSE: Dissector for OID:%s not implemented. Contact Wireshark developers if you want this supported", oid); expert_add_info_format(pinfo, item, &ei_rtse_dissector_oid_not_implemented, "RTSE: Dissector for OID %s not implemented", oid); @@ -285,10 +287,9 @@ dissect_rtse(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* d old_offset=offset; offset=dissect_rtse_RTSE_apdus(TRUE, tvb, offset, &asn1_ctx, tree, -1); if(offset == old_offset){ - item = proto_tree_add_text(tree, tvb, offset, -1, "Unknown RTSE PDU"); - + next_tree = proto_tree_add_subtree(tree, tvb, offset, -1, + ett_rtse_unknown, &item, "Unknown RTSE PDU"); expert_add_info (pinfo, item, &ei_rtse_unknown_rtse_pdu); - next_tree=proto_item_add_subtree(item, ett_rtse_unknown); dissect_unknown_ber(pinfo, tvb, offset, next_tree); break; } diff --git a/asn1/sabp/packet-sabp-template.c b/asn1/sabp/packet-sabp-template.c index 0f544c0f5b..d6d8bc0b3d 100644 --- a/asn1/sabp/packet-sabp-template.c +++ b/asn1/sabp/packet-sabp-template.c @@ -1,4 +1,4 @@ -/* packet-sabp.c +/* packet-sabp-template.c * Routines for UTRAN Iu-BC Interface: Service Area Broadcast Protocol (SABP) packet dissection * Copyright 2007, Tomas Kukosa <tomas.kukosa@siemens.com> * @@ -125,7 +125,7 @@ static int dissect_UnsuccessfulOutcomeValue(tvbuff_t *tvb, packet_info *pinfo, p static void dissect_sabp_cb_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - proto_item *item, *cbs_page_item; + proto_item *cbs_page_item; proto_tree *subtree; tvbuff_t *page_tvb, *unpacked_tvb; int offset = 0; @@ -145,8 +145,8 @@ dissect_sabp_cb_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) return; } for (n = 0; n < nr_pages; n++) { - item = proto_tree_add_text(tree, tvb, offset, 83, "CB page %u data", n+1); - subtree = proto_item_add_subtree(item, ett_sabp_cbs_page); + subtree = proto_tree_add_subtree_format(tree, tvb, offset, 83, ett_sabp_cbs_page, NULL, + "CB page %u data", n+1); /* octet 2 - 83 CBS-Message-Information-Page 1 */ cbs_page_item = proto_tree_add_item(subtree, hf_sabp_cb_msg_inf_page, tvb, offset, 82, ENC_NA); cb_inf_msg_len = tvb_get_guint8(tvb,offset+82); diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c index a430717648..971c90bb7b 100644 --- a/asn1/snmp/packet-snmp-template.c +++ b/asn1/snmp/packet-snmp-template.c @@ -549,15 +549,17 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, seq_len += offset - seq_offset; if (!pc && ber_class==BER_CLASS_UNI && tag==BER_UNI_TAG_SEQUENCE) { - proto_item* pi = proto_tree_add_text(tree, tvb, seq_offset, seq_len,"VarBind must be an universal class sequence"); - pt = proto_item_add_subtree(pi,ett_decoding_error); + proto_item* pi; + pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len, + ett_decoding_error, &pi, "VarBind must be an universal class sequence"); expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_not_uni_class_seq); return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt); } if (ind) { - proto_item* pi = proto_tree_add_text(tree, tvb, seq_offset, seq_len,"Indicator must be clear in VarBind"); - pt = proto_item_add_subtree(pi,ett_decoding_error); + proto_item* pi; + pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len, + ett_decoding_error, &pi, "Indicator must be clear in VarBind"); expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_has_indicator); return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt); } @@ -568,15 +570,17 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, name_offset = offset = get_ber_length(tvb, offset, &name_len, &ind); if (! ( !pc && ber_class==BER_CLASS_UNI && tag==BER_UNI_TAG_OID) ) { - proto_item* pi = proto_tree_add_text(tree, tvb, seq_offset, seq_len,"ObjectName must be an OID in primitive encoding"); - pt = proto_item_add_subtree(pi,ett_decoding_error); + proto_item* pi; + pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len, + ett_decoding_error, &pi, "ObjectName must be an OID in primitive encoding"); expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_not_oid); return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt); } if (ind) { - proto_item* pi = proto_tree_add_text(tree, tvb, seq_offset, seq_len,"Indicator must be clear in ObjectName"); - pt = proto_item_add_subtree(pi,ett_decoding_error); + proto_item* pi; + pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len, + ett_decoding_error, &pi, "Indicator must be clear in ObjectName"); expert_add_info(actx->pinfo, pi, &ei_snmp_objectname_has_indicator); return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt); } @@ -589,8 +593,9 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, value_offset = get_ber_length(tvb, offset, &value_len, &ind); if (! (!pc) ) { - proto_item* pi = proto_tree_add_text(tree, tvb, seq_offset, seq_len,"the value must be in primitive encoding"); - pt = proto_item_add_subtree(pi,ett_decoding_error); + proto_item* pi; + pt = proto_tree_add_subtree(tree, tvb, seq_offset, seq_len, + ett_decoding_error, &pi, "the value must be in primitive encoding"); expert_add_info(actx->pinfo, pi, &ei_snmp_value_not_primitive_encoding); return dissect_unknown_ber(actx->pinfo, tvb, seq_offset, pt); } @@ -600,8 +605,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, /* we add the varbind tree root with a dummy label we'll fill later on */ - pi_varbind = proto_tree_add_text(tree,tvb,seq_offset,seq_len,"VarBind"); - pt_varbind = proto_item_add_subtree(pi_varbind,ett_varbind); + pt_varbind = proto_tree_add_subtree(tree,tvb,seq_offset,seq_len,ett_varbind,&pi_varbind,"VarBind"); *label = '\0'; pi_name = proto_tree_add_item(pt_varbind,hf_snmp_objectname,tvb,name_offset,name_len,ENC_NA); @@ -617,8 +621,7 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, proto_item* pi; repr = oid_encoded2string(oid_bytes, name_len); - pi = proto_tree_add_text(pt_name,tvb, 0, 0, "invalid oid: %s", repr); - pt = proto_item_add_subtree(pi, ett_decoding_error); + pt = proto_tree_add_subtree_format(pt_name,tvb, 0, 0, ett_decoding_error, &pi, "invalid oid: %s", repr); expert_add_info_format(actx->pinfo, pi, &ei_snmp_invalid_oid, "invalid oid: %s", repr); return dissect_unknown_ber(actx->pinfo, tvb, name_offset, pt); } @@ -651,8 +654,8 @@ dissect_snmp_VarBind(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, note = "endOfMibView"; break; default: { - pi = proto_tree_add_text(pt_varbind,tvb,0,0,"Wrong tag for Error Value: expected 0, 1, or 2 but got: %d",tag); - pt = proto_item_add_subtree(pi,ett_decoding_error); + pt = proto_tree_add_subtree_format(pt_varbind,tvb,0,0,ett_decoding_error,&pi, + "Wrong tag for Error Value: expected 0, 1, or 2 but got: %d",tag); expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_tag); return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt); } @@ -1065,19 +1068,21 @@ set_label: switch (format_error) { case BER_WRONG_LENGTH: { + proto_item* pi; proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error); - proto_item* pi = proto_tree_add_text(p_tree,tvb,0,0,"Wrong value length: %u expecting: %u <= len <= %u", + pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi, + "Wrong value length: %u expecting: %u <= len <= %u", value_len, min_len, max_len == -1 ? 0xFFFFFF : max_len); - pt = proto_item_add_subtree(pi,ett_decoding_error); expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_length_value); return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt); } case BER_WRONG_TAG: { + proto_item* pi; proto_tree* p_tree = proto_item_add_subtree(pi_value,ett_decoding_error); - proto_item* pi = proto_tree_add_text(p_tree,tvb,0,0,"Wrong class/tag for Value expected: %d,%d got: %d,%d", + pt = proto_tree_add_subtree_format(p_tree,tvb,0,0,ett_decoding_error,&pi, + "Wrong class/tag for Value expected: %d,%d got: %d,%d", oid_info->value_type->ber_class, oid_info->value_type->ber_tag, ber_class, tag); - pt = proto_item_add_subtree(pi,ett_decoding_error); expert_add_info(actx->pinfo, pi, &ei_snmp_varbind_wrong_class_tag); return dissect_unknown_ber(actx->pinfo, tvb, value_start, pt); } diff --git a/asn1/spnego/packet-spnego-template.c b/asn1/spnego/packet-spnego-template.c index b03277f336..56d2610c1c 100644 --- a/asn1/spnego/packet-spnego-template.c +++ b/asn1/spnego/packet-spnego-template.c @@ -1,4 +1,4 @@ -/* packet-spnego.c +/* packet-spnego-template.c * Routines for the simple and protected GSS-API negotiation mechanism * as described in RFC 2478. * Copyright 2002, Tim Potter <tpot@samba.org> @@ -940,15 +940,13 @@ dissect_spnego_krb5_cfx_flags(tvbuff_t *tvb, int offset, proto_tree *spnego_krb5_tree, guint8 cfx_flags) { - proto_tree *cfx_flags_tree = NULL; - proto_item *tf = NULL; + proto_tree *cfx_flags_tree; + proto_item *tf; - if (spnego_krb5_tree) { - tf = proto_tree_add_uint(spnego_krb5_tree, + tf = proto_tree_add_uint(spnego_krb5_tree, hf_spnego_krb5_cfx_flags, tvb, offset, 1, cfx_flags); - cfx_flags_tree = proto_item_add_subtree(tf, ett_spnego_krb5_cfx_flags); - } + cfx_flags_tree = proto_item_add_subtree(tf, ett_spnego_krb5_cfx_flags); proto_tree_add_boolean(cfx_flags_tree, hf_spnego_krb5_cfx_flags_04, diff --git a/asn1/sv/packet-sv-template.c b/asn1/sv/packet-sv-template.c index 8cad39b18b..2af3318772 100644 --- a/asn1/sv/packet-sv-template.c +++ b/asn1/sv/packet-sv-template.c @@ -131,7 +131,7 @@ dissect_PhsMeas1(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tv gint32 tag; guint32 len; proto_item *it; - proto_tree *subtree = NULL; + proto_tree *subtree; gint32 value; guint32 qual; guint32 i; @@ -160,10 +160,7 @@ dissect_PhsMeas1(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tv len=tvb_length_remaining(tvb, offset); } - if (tree) { - it = proto_tree_add_text(tree, tvb, offset, len, "PhsMeas1"); - subtree = proto_item_add_subtree(it, ett_phsmeas); - } + subtree = proto_tree_add_subtree(tree, tvb, offset, len, ett_phsmeas, NULL, "PhsMeas1"); sv_data.num_phsMeas = 0; for (i = 0; i < len/8; i++) { @@ -198,16 +195,15 @@ dissect_sv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree) { int offset = 0; int old_offset; - proto_item *item = NULL; - proto_tree *tree = NULL; + proto_item *item; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); - if (parent_tree){ - item = proto_tree_add_item(parent_tree, proto_sv, tvb, 0, -1, ENC_NA); - tree = proto_item_add_subtree(item, ett_sv); - } + item = proto_tree_add_item(parent_tree, proto_sv, tvb, 0, -1, ENC_NA); + tree = proto_item_add_subtree(item, ett_sv); + col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME); col_clear(pinfo->cinfo, COL_INFO); diff --git a/asn1/tcap/packet-tcap-template.c b/asn1/tcap/packet-tcap-template.c index a75b6eb7ad..815242f6ac 100644 --- a/asn1/tcap/packet-tcap-template.c +++ b/asn1/tcap/packet-tcap-template.c @@ -1089,9 +1089,8 @@ tcaphash_begin_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, #endif p_tcaphash_context=p_tcaphash_begincall->context; if (gtcap_DisplaySRT && tree) { - stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat"); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett_tcap_stat, &stat_item, "Stat"); PROTO_ITEM_SET_GENERATED(stat_item); - stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat); pi = proto_tree_add_uint_format(stat_tree, hf_tcapsrt_Duplicate, tvb, 0, 0, p_tcaphash_context->first_frame, "Duplicate with session %u in frame %u", @@ -1132,9 +1131,8 @@ tcaphash_begin_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if ( gtcap_DisplaySRT && tree && p_tcaphash_context && p_tcaphash_context->session_id) { - stat_item = proto_tree_add_text(tree, tvb, 0, 0, "Stat"); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, 0, ett_tcap_stat, &stat_item, "Stat"); PROTO_ITEM_SET_GENERATED(stat_item); - stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat); pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id); PROTO_ITEM_SET_GENERATED(pi); @@ -1281,9 +1279,8 @@ tcaphash_cont_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if (gtcap_DisplaySRT && tree && p_tcaphash_context && p_tcaphash_context->session_id) { - stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat"); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett_tcap_stat, &stat_item, "Stat"); PROTO_ITEM_SET_GENERATED(stat_item); - stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat); pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id); PROTO_ITEM_SET_GENERATED(pi); } @@ -1385,9 +1382,8 @@ tcaphash_end_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, dbg(12,"Found, req=%d ",p_tcaphash_context->first_frame); #endif if (gtcap_DisplaySRT && tree) { - stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat"); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett_tcap_stat, &stat_item, "Stat"); PROTO_ITEM_SET_GENERATED(stat_item); - stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat); pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id); PROTO_ITEM_SET_GENERATED(pi); @@ -1509,9 +1505,8 @@ tcaphash_ansi_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, isResponse=TRUE; if (gtcap_DisplaySRT && tree) { - stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat"); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett_tcap_stat, &stat_item, "Stat"); PROTO_ITEM_SET_GENERATED(stat_item); - stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat); pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id); PROTO_ITEM_SET_GENERATED(pi); @@ -1602,9 +1597,8 @@ tcaphash_ansi_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, #endif if (gtcap_DisplaySRT && tree) { - stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat"); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett_tcap_stat, &stat_item, "Stat"); PROTO_ITEM_SET_GENERATED(stat_item); - stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat); pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id); PROTO_ITEM_SET_GENERATED(pi); @@ -1655,9 +1649,8 @@ tcaphash_ansi_matching(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, if ( gtcap_DisplaySRT && tree && p_tcaphash_context && p_tcaphash_context->session_id) { - stat_item = proto_tree_add_text(tree, tvb, 0, -1, "Stat"); + stat_tree = proto_tree_add_subtree(tree, tvb, 0, -1, ett_tcap_stat, &stat_item, "Stat"); PROTO_ITEM_SET_GENERATED(stat_item); - stat_tree = proto_item_add_subtree(stat_item, ett_tcap_stat); pi = proto_tree_add_uint(stat_tree, hf_tcapsrt_SessionId, tvb, 0,0, p_tcaphash_context->session_id); PROTO_ITEM_SET_GENERATED(pi); } @@ -2253,7 +2246,6 @@ dissect_tcap_param(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset gint tag_offset, saved_offset, len_offset; tvbuff_t *next_tvb; proto_tree *subtree; - proto_item *pi; gint8 ber_class; gboolean pc; gint32 tag; @@ -2276,10 +2268,9 @@ dissect_tcap_param(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset if (pc) { - pi = proto_tree_add_text(tree, tvb, saved_offset, - len + (len_offset - saved_offset), + subtree = proto_tree_add_subtree(tree, tvb, saved_offset, + len + (len_offset - saved_offset), ett_param, NULL, "CONSTRUCTOR"); - subtree = proto_item_add_subtree(pi, ett_param); proto_tree_add_uint_format(subtree, hf_tcap_tag, tvb, saved_offset, tag_length, tag, "CONSTRUCTOR Tag"); @@ -2302,12 +2293,10 @@ dissect_tcap_param(asn1_ctx_t *actx, proto_tree *tree, tvbuff_t *tvb, int offset } else { - pi = proto_tree_add_text(tree, tvb, saved_offset, - len + (len_offset - saved_offset), + subtree = proto_tree_add_subtree_format(tree, tvb, saved_offset, + len + (len_offset - saved_offset), ett_param, NULL, "Parameter (0x%.2x)", tag); - subtree = proto_item_add_subtree(pi, ett_param); - proto_tree_add_uint(subtree, hf_tcap_tag, tvb, saved_offset, tag_length, tag); diff --git a/asn1/tcap/tcap.cnf b/asn1/tcap/tcap.cnf index 91392af735..5df3b0dbf0 100644 --- a/asn1/tcap/tcap.cnf +++ b/asn1/tcap/tcap.cnf @@ -125,10 +125,8 @@ ENDTRY; #.FN_BODY OrigTransactionID tvbuff_t *parameter_tvb; guint8 len, i; -proto_item *tid_item; proto_tree *subtree; -tid_item = proto_tree_add_text(tree, tvb, offset, -1, "Source Transaction ID"); -subtree = proto_item_add_subtree(tid_item, ett_otid); +subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_otid, NULL, "Source Transaction ID"); dissect_ber_octet_string(implicit_tag, actx, subtree, tvb, offset, hf_tcap_tid, NULL); PROTO_ITEM_SET_HIDDEN(actx->created_item); @@ -166,10 +164,8 @@ if (parameter_tvb){ #.FN_BODY DestTransactionID tvbuff_t *parameter_tvb; guint8 len , i; -proto_item *tid_item; proto_tree *subtree; -tid_item = proto_tree_add_text(tree, tvb, offset, -1, "Destination Transaction ID"); -subtree = proto_item_add_subtree(tid_item, ett_dtid); +subtree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_dtid, NULL, "Destination Transaction ID"); dissect_ber_octet_string(implicit_tag, actx, subtree, tvb, offset, hf_tcap_tid, NULL); PROTO_ITEM_SET_HIDDEN(actx->created_item); diff --git a/asn1/x509af/packet-x509af-template.c b/asn1/x509af/packet-x509af-template.c index b64a474ae2..8e854f5da9 100644 --- a/asn1/x509af/packet-x509af-template.c +++ b/asn1/x509af/packet-x509af-template.c @@ -62,8 +62,7 @@ const char *x509af_get_last_algorithm_id(void) { static int dissect_pkix_crl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_) { - proto_item *item=NULL; - proto_tree *tree=NULL; + proto_tree *tree; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); @@ -72,10 +71,7 @@ dissect_pkix_crl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, voi col_set_str(pinfo->cinfo, COL_INFO, "Certificate Revocation List"); - if(parent_tree){ - item=proto_tree_add_text(parent_tree, tvb, 0, -1, "Certificate Revocation List"); - tree = proto_item_add_subtree(item, ett_pkix_crl); - } + tree=proto_tree_add_subtree(parent_tree, tvb, 0, -1, ett_pkix_crl, NULL, "Certificate Revocation List"); return dissect_x509af_CertificateList(FALSE, tvb, 0, &asn1_ctx, tree, -1); } |