diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-06-29 21:04:37 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-06-29 21:04:37 +0000 |
commit | d0aae6dd3e9f53ec37c351b60fe8765ed31a0b05 (patch) | |
tree | abf41a252d4ba35ae78fc2e2a7b6f3e7e63d0397 /asn1 | |
parent | 18c69d17b0d304b72dcafa37b0ea7d3a4551a85e (diff) |
from metze
prettify dissection of filters containing substring and extensiblematch
svn path=/trunk/; revision=18617
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/ldap/ldap.cnf | 100 | ||||
-rw-r--r-- | asn1/ldap/packet-ldap-template.c | 8 |
2 files changed, 87 insertions, 21 deletions
diff --git a/asn1/ldap/ldap.cnf b/asn1/ldap/ldap.cnf index fc12c47030..3646d102e9 100644 --- a/asn1/ldap/ldap.cnf +++ b/asn1/ldap/ldap.cnf @@ -274,6 +274,18 @@ ldap_conv_info_t *ldap_info; } else if (hf_index == hf_ldap_attributeDesc){ /* remember the attribute description */ attributedesc_string=ldapstring; + } else if (hf_index == hf_ldap_initial){ + /* remember the substring item */ + substring_item_init=ldapstring; + } else if (hf_index == hf_ldap_any){ + /* remember the substring item */ + substring_item_any=ldapstring; + } else if (hf_index == hf_ldap_final){ + /* remember the substring item */ + substring_item_final=ldapstring; + } else if (hf_index == hf_ldap_matchingRule){ + /* remember the matching rule */ + matching_rule_string=ldapstring; } else if (hf_index == hf_ldap_present){ /* remember the present name */ Filter_string=ldapstring; @@ -454,11 +466,9 @@ ldap_conv_info_t *ldap_info; #.FN_FTR Filter/approxMatch Filter_string=ep_strdup_printf("(%s~=%s)",attributedesc_string,assertionvalue_string); -#.FN_BODY Filter/and/_item - offset=dissect_ldap_Filter(FALSE, tvb, offset, pinfo, tree, hf_ldap_and_item); - +#.FN_FTR Filter/and/_item if(and_filter_string){ - and_filter_string=ep_strdup_printf("(&%%s%%s)",and_filter_string,Filter_string); + and_filter_string=ep_strdup_printf("(&%s%s)",and_filter_string,Filter_string); } else { and_filter_string=Filter_string; } @@ -478,17 +488,15 @@ ldap_conv_info_t *ldap_info; offset = dissect_ber_set_of(implicit_tag, pinfo, tr, tvb, offset, and_set_of, -1, ett_ldap_T_and); - proto_item_append_text(it, " %%s", and_filter_string); + proto_item_append_text(it, "%%s", and_filter_string); Filter_string=ep_strdup_printf("%%s",and_filter_string); and_filter_string=old_and_filter_string; -#.FN_BODY Filter/or/_item - offset=dissect_ldap_Filter(FALSE, tvb, offset, pinfo, tree, hf_ldap_or_item); - - if(and_filter_string){ - and_filter_string=ep_strdup_printf("(|%%s%%s)",and_filter_string,Filter_string); +#.FN_FTR Filter/or/_item + if(or_filter_string){ + or_filter_string=ep_strdup_printf("(|%s%s)",or_filter_string,Filter_string); } else { - and_filter_string=Filter_string; + or_filter_string=Filter_string; } @@ -497,9 +505,9 @@ ldap_conv_info_t *ldap_info; }; proto_tree *tr=NULL; proto_item *it=NULL; - char *old_and_filter_string=and_filter_string; + char *old_or_filter_string=or_filter_string; - and_filter_string=NULL; + 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); @@ -507,9 +515,9 @@ ldap_conv_info_t *ldap_info; offset = dissect_ber_set_of(implicit_tag, pinfo, tr, tvb, offset, or_set_of, -1, ett_ldap_T_or); - proto_item_append_text(it, " %%s", and_filter_string); - Filter_string=ep_strdup_printf("%%s",and_filter_string); - and_filter_string=old_and_filter_string; + proto_item_append_text(it, "%%s", or_filter_string); + Filter_string=ep_strdup_printf("%%s",or_filter_string); + or_filter_string=old_or_filter_string; #.FN_FTR Filter/present Filter_string=ep_strdup_printf("(%s=*)",Filter_string); @@ -517,11 +525,63 @@ ldap_conv_info_t *ldap_info; #.FN_FTR Filter/not Filter_string=ep_strdup_printf("(!%s)",Filter_string); +#.FN_BODY BOOLEAN + gboolean val; + + offset = dissect_ber_boolean_value(implicit_tag, pinfo, tree, tvb, offset, hf_index, &val); + + if (hf_index == hf_ldap_dnAttributes) { + matching_rule_dnattr = val; + } + +#.FN_HDR Filter/extensibleMatch + attr_type=NULL; + matching_rule_string=NULL; + assertionvalue_string=NULL; + matching_rule_dnattr=FALSE; + #.FN_FTR Filter/extensibleMatch - Filter_string="<extensibleMatch is not yet prettified>"; + Filter_string=ep_strdup_printf("(%s:%s%s%s=%s)", + (attr_type?attr_type:""), + (matching_rule_dnattr?"dn:":""), + (matching_rule_string?matching_rule_string:""), + (matching_rule_string?":":""), + assertionvalue_string); + +#.FN_FTR SubstringFilter/substrings/_item + if (substring_item_final) { + substring_value=ep_strdup_printf("%s%s", + (substring_value?substring_value:"*"), + substring_item_final); + } else if (substring_item_any) { + substring_value=ep_strdup_printf("%s%s*", + (substring_value?substring_value:"*"), + substring_item_any); + } else if (substring_item_init) { + substring_value=ep_strdup_printf("%s*", + substring_item_init); + } -#.FN_FTR Filter/substrings - Filter_string="<substrings are not yet prettified>"; +#.FN_BODY SubstringFilter + proto_tree *tr=NULL; + proto_item *it=NULL; + char *old_substring_value=substring_value; + + substring_value=NULL; + 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); + } + offset = dissect_ber_sequence(implicit_tag, pinfo, tr, tvb, offset, + SubstringFilter_sequence, hf_index, + ett_ldap_SubstringFilter); + + Filter_string=ep_strdup_printf("(%%s=%%s)",attr_type,substring_value); + proto_item_append_text(it, "%%s", Filter_string); + substring_value=old_substring_value; #.FN_BODY Filter proto_tree *tr=NULL; @@ -530,7 +590,7 @@ ldap_conv_info_t *ldap_info; 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); - } + } offset = dissect_ber_choice(pinfo, tr, tvb, offset, Filter_choice, -1, ett_ldap_Filter, NULL); diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c index c6e1aa6faa..a9d0e0312c 100644 --- a/asn1/ldap/packet-ldap-template.c +++ b/asn1/ldap/packet-ldap-template.c @@ -315,7 +315,13 @@ static char *attributedesc_string=NULL; /* This string contains the last Filter item that was decoded */ static char *Filter_string=NULL; static char *and_filter_string=NULL; - +static char *or_filter_string=NULL; +static char *substring_value=NULL; +static char *substring_item_init=NULL; +static char *substring_item_any=NULL; +static char *substring_item_final=NULL; +static char *matching_rule_string=NULL; +static gboolean matching_rule_dnattr=FALSE; /* Global variables */ char *mechanism = NULL; |