- 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
This commit is contained in:
Martin Willi
2006-04-27 11:38:24 +00:00
parent f1e87b9022
commit eea353466e
15 changed files with 248 additions and 135 deletions
+31 -3
View File
@@ -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 */