aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/ldap
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2014-06-20 21:35:40 -0400
committerMichael Mann <mmann78@netscape.net>2014-06-22 21:08:21 +0000
commit9356d5c689fa911b0b13d4b2a0cd6e9208d60f6d (patch)
treef3265efe4137c8a09995b448bf0c4bcdecf4e5a9 /asn1/ldap
parent2c0214efff7b3421355e42ee7f3075c2f3181d3e (diff)
downloadwireshark-9356d5c689fa911b0b13d4b2a0cd6e9208d60f6d.tar.gz
wireshark-9356d5c689fa911b0b13d4b2a0cd6e9208d60f6d.tar.bz2
wireshark-9356d5c689fa911b0b13d4b2a0cd6e9208d60f6d.zip
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/ldap')
-rw-r--r--asn1/ldap/ldap.cnf52
-rw-r--r--asn1/ldap/packet-ldap-template.c36
2 files changed, 35 insertions, 53 deletions
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, " (");