From 87a217f9f1640ed08dbe06564f6fbcd3cdfdeefb Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Mon, 20 Mar 2006 15:43:26 +0000 Subject: - works quite well now with ipsec.conf & ipsec starter --- Source/charon/utils/identification.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Source/charon/utils/identification.c') diff --git a/Source/charon/utils/identification.c b/Source/charon/utils/identification.c index 73f218874..72d1610af 100644 --- a/Source/charon/utils/identification.c +++ b/Source/charon/utils/identification.c @@ -115,6 +115,28 @@ static bool equals (private_identification_t *this,private_identification_t *oth return FALSE; } +/** + * Implementation of identification_t.belongs_to. + */ +static bool belongs_to(private_identification_t *this, private_identification_t *other) +{ + if (this->public.equals(&this->public, &other->public)) + { + return TRUE; + } + + if (this->type == other->type && this->type == ID_IPV4_ADDR) + { + /* is this %any (0.0.0.0)?*/ + if (*((u_int32_t*)this->encoded.ptr) == 0) + { + return TRUE; + } + /* TODO: Do we need subnet support? */ + } + return FALSE; +} + /** * Implementation of identification_t.clone. */ @@ -150,6 +172,7 @@ static private_identification_t *identification_create() private_identification_t *this = allocator_alloc_thing(private_identification_t); this->public.equals = (bool (*) (identification_t*,identification_t*))equals; + this->public.belongs_to = (bool (*) (identification_t*,identification_t*))belongs_to; 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; -- cgit v1.2.3