aboutsummaryrefslogtreecommitdiffstats
path: root/Source/lib/utils/identification.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2006-04-27 11:38:24 +0000
committerMartin Willi <martin@strongswan.org>2006-04-27 11:38:24 +0000
commiteea353466ec86ad5fd3fc4fb7ac560ebced64f3d (patch)
treeaa0908775b34dbce4b98526c1cfce7fd82a34074 /Source/lib/utils/identification.c
parentf1e87b9022fa68ea4cc38317eea1a59a41a5ae3d (diff)
downloadstrongswan-eea353466ec86ad5fd3fc4fb7ac560ebced64f3d.tar.bz2
strongswan-eea353466ec86ad5fd3fc4fb7ac560ebced64f3d.tar.xz
- 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
Diffstat (limited to 'Source/lib/utils/identification.c')
-rw-r--r--Source/lib/utils/identification.c34
1 files changed, 31 insertions, 3 deletions
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
@@ -808,6 +808,19 @@ static char *get_string(private_identification_t *this)
}
/**
+ * 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 */