aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/network
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2005-12-01 07:35:03 +0000
committerMartin Willi <martin@strongswan.org>2005-12-01 07:35:03 +0000
commitd45ec1dedfa06155c344f5cce0ac7b2ec331c825 (patch)
treede2a74ae64525e4d45c3178ab7d16484297ce1dd /Source/charon/network
parent2ef11339c720d06215f44555de020ea5ebdfd641 (diff)
downloadstrongswan-d45ec1dedfa06155c344f5cce0ac7b2ec331c825.tar.bz2
strongswan-d45ec1dedfa06155c344f5cce0ac7b2ec331c825.tar.xz
- implemented sa_config
- uses identification - and host - untested - ts need further tuning
Diffstat (limited to 'Source/charon/network')
-rw-r--r--Source/charon/network/host.c25
-rw-r--r--Source/charon/network/host.h9
2 files changed, 34 insertions, 0 deletions
diff --git a/Source/charon/network/host.c b/Source/charon/network/host.c
index 43861238f..f78e7b810 100644
--- a/Source/charon/network/host.c
+++ b/Source/charon/network/host.c
@@ -153,6 +153,30 @@ static private_host_t *clone(private_host_t *this)
}
+/**
+ * Impelements host_t.equals
+ */
+static bool equals(private_host_t *this, private_host_t *other)
+{
+ switch (this->family)
+ {
+ /* IPv4 */
+ case AF_INET:
+ {
+ struct sockaddr_in *sin1 = (struct sockaddr_in*)&(this->address);
+ struct sockaddr_in *sin2 = (struct sockaddr_in*)&(other->address);
+ if ((sin1->sin_family == sin2->sin_family) &&
+ (sin1->sin_port == sin2->sin_port) &&
+ (sin1->sin_addr.s_addr == sin2->sin_addr.s_addr))
+ {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+
/*
* Described in header.
*/
@@ -200,6 +224,7 @@ host_t *host_create_from_chunk(int family, chunk_t address, u_int16_t port)
this->public.get_address = (char* (*) (host_t *))get_address;
this->public.get_address_as_chunk = (chunk_t (*) (host_t *)) get_address_as_chunk;
this->public.get_port = (u_int16_t (*) (host_t *))get_port;
+ this->public.equals = (bool (*) (host_t *,host_t *))equals;
this->public.destroy = (void (*) (host_t*))destroy;
this->family = family;
diff --git a/Source/charon/network/host.h b/Source/charon/network/host.h
index fa06b1474..379eab02e 100644
--- a/Source/charon/network/host.h
+++ b/Source/charon/network/host.h
@@ -105,6 +105,15 @@ struct host_t {
* @return port number
*/
u_int16_t (*get_port) (host_t *this);
+
+ /**
+ * @brief Compare two hosts.
+ *
+ * @param this object to compare
+ * @param other the other to compare
+ * @return TRUE if port and address are equal
+ */
+ bool (*equals) (host_t *this, host_t *other);
/**
* @brief Destroy this host object