diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-06-10 06:48:09 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-06-10 06:48:09 +0000 |
commit | 452226586d1e597af0a890d3fb3c832e8f33a1b5 (patch) | |
tree | 696c002b64278e4b45a63f2e9675d056d51582cf /asn1/ldap/packet-ldap-template.c | |
parent | fcf198a69d3b985907ac84b17aefd8e8dc6a12f0 (diff) |
rework the previous patch slightly since we really need to push a string upward to our callers to be able to generate and display nice filter expressions on the top line as the original ldap dissectopr did
svn path=/trunk/; revision=18421
Diffstat (limited to 'asn1/ldap/packet-ldap-template.c')
-rw-r--r-- | asn1/ldap/packet-ldap-template.c | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c index a74b4d9dba..e77eac364a 100644 --- a/asn1/ldap/packet-ldap-template.c +++ b/asn1/ldap/packet-ldap-template.c @@ -103,8 +103,6 @@ static int hf_ldap_sasl_buffer_length = -1; static int hf_ldap_response_in = -1; static int hf_ldap_response_to = -1; static int hf_ldap_time = -1; -static int hf_ldap_assertionValue_str = -1; /* string AssertionValue*/ -static int hf_ldap_assertionValue_bin = -1; /* binary AssertionValue*/ static int hf_mscldap_netlogon_type = -1; static int hf_mscldap_netlogon_flags = -1; @@ -249,38 +247,53 @@ ldap_info_equal_unmatched(gconstpointer k1, gconstpointer k2) } /* if the octet string contain all ascii characters then display it as - * a string else display it in the defaulkt HEX mode + * a string othervise just display it in hex. */ static int -dissect_ldap_AssertionValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) +dissect_ldap_AssertionValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index) { - tvbuff_t *str_tvb=NULL; - int i, len, is_ascii=0; - char *str; - - /* grab a tvb of the octet string so we can check if it is ascii or binary */ - dissect_ber_octet_string(implicit_tag, pinfo, NULL, tvb, offset, hf_index, &str_tvb); - - if(str_tvb){ - len=tvb_length(str_tvb); - if(len>0){ - str=tvb_get_ptr(str_tvb, 0, len); - is_ascii=1; - for(i=0;i<len;i++){ - if(str[i]<0x20){ - is_ascii=0; - } - } - } - } + gint8 class; + gboolean pc, ind, is_ascii; + gint32 tag; + guint32 len, i; + char *str, *new_str; - if(is_ascii){ - offset=dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_ldap_assertionValue_str, NULL); - } else { - offset=dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_ldap_assertionValue_bin, NULL); - } + offset=get_ber_identifier(tvb, offset, &class, &pc, &tag); + offset=get_ber_length(NULL, tvb, offset, &len, &ind); - return offset; + if(len==0){ + return; + } + + /* check whether the string is ascii or binary */ + str=tvb_get_ptr(tvb, offset, len); + is_ascii=TRUE; + for(i=0;i<len;i++){ + if(str[i]<0x20){ + is_ascii=FALSE; + } + } + + /* convert the string into a printable string */ + if(is_ascii){ + new_str=ep_alloc(len+1); + for(i=0;i<len;i++){ + new_str[i]=str[i]; + } + new_str[i]=0; + } else { + new_str=ep_alloc(3*len); + for(i=0;i<len;i++){ + g_snprintf(new_str+i*3,3,"%02x",str[i]&0xff); + new_str[3*i+2]=':'; + } + new_str[3*len-1]=0; + } + + proto_tree_add_string(tree, hf_index, tvb, offset, len, new_str); + offset+=len; + + return offset; } /* Global variables */ @@ -1204,16 +1217,6 @@ void proto_register_ldap(void) { FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, "The time between the Call and the Reply", HFILL }}, - { &hf_ldap_assertionValue_str, - { "assertionValue", "ldap.assertionValue_str", - FT_STRING, BASE_NONE, NULL, 0, - "AttributeValueAssertion/assertionValue", HFILL }}, - - { &hf_ldap_assertionValue_bin, - { "assertionValue", "ldap.assertionValue_bin", - FT_BYTES, BASE_HEX, NULL, 0, - "AttributeValueAssertion/assertionValue", HFILL }}, - { &hf_mscldap_netlogon_type, { "Type", "mscldap.netlogon.type", FT_UINT32, BASE_DEC, NULL, 0x0, |