aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/ldap
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2006-06-12 08:30:07 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2006-06-12 08:30:07 +0000
commitb501e15fe98083a641e4000f8b7bb66a5ce771da (patch)
tree879a4843dc224a7f0fa5972f91b95784c17b60f1 /asn1/ldap
parent81bda938ff8571653af84c20888b53eb05cb4f1b (diff)
prettify dissection of LDAP search filters.
svn path=/trunk/; revision=18431
Diffstat (limited to 'asn1/ldap')
-rw-r--r--asn1/ldap/ldap.cnf119
-rw-r--r--asn1/ldap/packet-ldap-template.c28
2 files changed, 135 insertions, 12 deletions
diff --git a/asn1/ldap/ldap.cnf b/asn1/ldap/ldap.cnf
index b35b57ebc5..8059256e42 100644
--- a/asn1/ldap/ldap.cnf
+++ b/asn1/ldap/ldap.cnf
@@ -248,7 +248,7 @@ ldap_conv_info_t *ldap_info;
ldap_do_protocolop(pinfo);
if(parameter_tvb)
- ldapstring = tvb_get_string(parameter_tvb, 0, tvb_length_remaining(parameter_tvb, 0));
+ ldapstring = tvb_get_ephemeral_string(parameter_tvb, 0, tvb_length_remaining(parameter_tvb, 0));
else
ldapstring = "<ROOT>";
@@ -271,6 +271,12 @@ ldap_conv_info_t *ldap_info;
if(ldm_tree)
proto_item_append_text(ldm_tree, " \"%%s\"", ldapstring);
+ } else if (hf_index == hf_ldap_attributeDesc){
+ /* remember the attribute description */
+ attributedesc_string=ldapstring;
+ } else if (hf_index == hf_ldap_present){
+ /* remember the present name */
+ Filter_string=ldapstring;
} else if (hf_index == hf_ldap_type) {
/* remember attribute type name */
attr_type = ep_strdup(ldapstring);
@@ -290,8 +296,6 @@ ldap_conv_info_t *ldap_info;
}
- if(parameter_tvb && ldapstring)
- g_free(ldapstring);
}
#.FN_PARS T_scope VAL_PTR = &scope
@@ -424,6 +428,115 @@ ldap_conv_info_t *ldap_info;
ldap_do_protocolop(pinfo);
+
+
+
+
+#.FN_HDR SearchRequest/filter
+ Filter_string=NULL;
+
+#.FN_FTR SearchRequest/filter
+ Filter_string=NULL;
+ and_filter_string=NULL;
+
+#.FN_FTR Filter/equalityMatch
+ Filter_string=ep_strdup_printf("(%s==%s)",attributedesc_string,assertionvalue_string);
+
+
+#.FN_FTR Filter/greaterOrEqual
+ Filter_string=ep_strdup_printf("(%s>=%s)",attributedesc_string,assertionvalue_string);
+
+
+#.FN_FTR Filter/lessOrEqual
+ Filter_string=ep_strdup_printf("(%s<=%s)",attributedesc_string,assertionvalue_string);
+
+
+#.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);
+
+ if(and_filter_string){
+ and_filter_string=ep_strdup_printf("%%s and %%s",and_filter_string,Filter_string);
+ } else {
+ and_filter_string=Filter_string;
+ }
+
+#.FN_BODY Filter/and
+ const ber_sequence_t and_set_of[1] = { { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_and_item },
+};
+ proto_tree *tr=NULL;
+ proto_item *it=NULL;
+ 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);
+ }
+ 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);
+ 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 and %%s",and_filter_string,Filter_string);
+ } else {
+ and_filter_string=Filter_string;
+ }
+
+
+#.FN_BODY Filter/or
+ const ber_sequence_t or_set_of[1] = { { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_or_item },
+};
+ proto_tree *tr=NULL;
+ proto_item *it=NULL;
+ 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), "or: ");
+ tr=proto_item_add_subtree(it, ett_ldap_T_or);
+ }
+ 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;
+
+#.FN_FTR Filter/present
+ Filter_string=ep_strdup_printf("is_present %s",Filter_string);
+
+#.FN_FTR Filter/not
+ Filter_string=ep_strdup_printf("not (%s)",Filter_string);
+
+#.FN_FTR Filter/extensibleMatch
+ Filter_string="<extensibleMatch is not yet prettified>";
+
+#.FN_FTR Filter/substrings
+ Filter_string="<substrings are not yet prettified>";
+
+#.FN_BODY Filter
+ proto_tree *tr=NULL;
+ proto_item *it=NULL;
+
+ 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);
+
+ proto_item_append_text(it, "%%s", Filter_string);
+
#.NO_EMIT
AttributeType
Attribute
diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c
index e77eac364a..6b2a894807 100644
--- a/asn1/ldap/packet-ldap-template.c
+++ b/asn1/ldap/packet-ldap-template.c
@@ -246,6 +246,8 @@ ldap_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
return key1->messageId==key2->messageId;
}
+/* This string contains the last AssertionValue that was decoded */
+static char *assertionvalue_string=NULL;
/* if the octet string contain all ascii characters then display it as
* a string othervise just display it in hex.
*/
@@ -256,7 +258,7 @@ dissect_ldap_AssertionValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset
gboolean pc, ind, is_ascii;
gint32 tag;
guint32 len, i;
- char *str, *new_str;
+ char *str;
offset=get_ber_identifier(tvb, offset, &class, &pc, &tag);
offset=get_ber_length(NULL, tvb, offset, &len, &ind);
@@ -276,26 +278,34 @@ dissect_ldap_AssertionValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset
/* convert the string into a printable string */
if(is_ascii){
- new_str=ep_alloc(len+1);
+ assertionvalue_string=ep_alloc(len+1);
for(i=0;i<len;i++){
- new_str[i]=str[i];
+ assertionvalue_string[i]=str[i];
}
- new_str[i]=0;
+ assertionvalue_string[i]=0;
} else {
- new_str=ep_alloc(3*len);
+ assertionvalue_string=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]=':';
+ g_snprintf(assertionvalue_string+i*3,3,"%02x",str[i]&0xff);
+ assertionvalue_string[3*i+2]=':';
}
- new_str[3*len-1]=0;
+ assertionvalue_string[3*len-1]=0;
}
- proto_tree_add_string(tree, hf_index, tvb, offset, len, new_str);
+ proto_tree_add_string(tree, hf_index, tvb, offset, len, assertionvalue_string);
offset+=len;
return offset;
}
+/* This string contains the last LDAPString that was decoded */
+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;
+
+
/* Global variables */
char *mechanism = NULL;
static gint MessageID =-1;