From eea353466ec86ad5fd3fc4fb7ac560ebced64f3d Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Thu, 27 Apr 2006 11:38:24 +0000 Subject: - reworked usage of IDs in various states - using ID_ANY for any, not NULL as before - initiator sends IDr payload in IKE_AUTH when ID unique --- Source/lib/utils/identification.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'Source/lib/utils/identification.c') diff --git a/Source/lib/utils/identification.c b/Source/lib/utils/identification.c index d99d0e453..33f3d92cd 100644 --- a/Source/lib/utils/identification.c +++ b/Source/lib/utils/identification.c @@ -807,6 +807,19 @@ static char *get_string(private_identification_t *this) return this->string; } +/** + * Implementation of identification_t.contains_wildcards. + */ +static bool contains_wildcards(private_identification_t *this) +{ + if (this->type == ID_ANY || + memchr(this->encoded.ptr, '*', this->encoded.len) != NULL) + { + return TRUE; + } + return FALSE; +} + /** * Default implementation of identification_t.equals and identification_t.belongs_to. * compares encoded chunk for equality. @@ -840,6 +853,11 @@ static bool belongs_to_wc_string(private_identification_t *this, private_identif { char *this_str, *other_str, *pos; + if (other->type == ID_ANY) + { + return TRUE; + } + if (this->type == other->type) { /* try a binary comparison first */ @@ -875,11 +893,15 @@ static bool belongs_to_wc_string(private_identification_t *this, private_identif /** * Special implementation of identification_t.belongs_to for ID_ANY. - * ANY matches any, even ANY, thats why its there... + * ANY matches only another ANY, but nothing other */ static bool belongs_to_any(private_identification_t *this, private_identification_t *other) -{ - return TRUE; +{ + if (other->type == ID_ANY) + { + return TRUE; + } + return FALSE; } /** @@ -890,6 +912,11 @@ static bool belongs_to_dn(private_identification_t *this, private_identification { int wildcards; + if (other->type == ID_ANY) + { + return TRUE; + } + if (this->type == other->type) { return match_dn(this->encoded, other->encoded, &wildcards); @@ -932,6 +959,7 @@ static private_identification_t *identification_create() this->public.get_encoding = (chunk_t (*) (identification_t*))get_encoding; this->public.get_type = (id_type_t (*) (identification_t*))get_type; this->public.get_string = (char* (*) (identification_t*))get_string; + this->public.contains_wildcards = (bool (*) (identification_t *this))contains_wildcards; this->public.clone = (identification_t* (*) (identification_t*))clone; this->public.destroy = (void (*) (identification_t*))destroy; /* we use these as defaults, the may be overloaded for special ID types */ -- cgit v1.2.3