aboutsummaryrefslogtreecommitdiffstats
path: root/src/libipsec/ipsec_sa.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-07-13 11:21:25 +0200
committerTobias Brunner <tobias@strongswan.org>2012-08-08 15:41:02 +0200
commit9f7e1899a90c2ffbdbac626d4d58945460eca97c (patch)
tree36eac459d11b85db7c050b50fa5547d859f6356f /src/libipsec/ipsec_sa.c
parentf9b0c0547500d9a0f767a95b1ef821a3742d0ee4 (diff)
downloadstrongswan-9f7e1899a90c2ffbdbac626d4d58945460eca97c.tar.bz2
strongswan-9f7e1899a90c2ffbdbac626d4d58945460eca97c.tar.xz
Add methods to easily compare IPsec SAs
Diffstat (limited to 'src/libipsec/ipsec_sa.c')
-rw-r--r--src/libipsec/ipsec_sa.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libipsec/ipsec_sa.c b/src/libipsec/ipsec_sa.c
index 02fa81354..cccd16404 100644
--- a/src/libipsec/ipsec_sa.c
+++ b/src/libipsec/ipsec_sa.c
@@ -131,6 +131,25 @@ METHOD(ipsec_sa_t, get_esp_context, esp_context_t*,
return this->esp_context;
}
+METHOD(ipsec_sa_t, match_by_spi_dst, bool,
+ private_ipsec_sa_t *this, u_int32_t spi, host_t *dst)
+{
+ return this->spi == spi && this->dst->ip_equals(this->dst, dst);
+}
+
+METHOD(ipsec_sa_t, match_by_spi_src_dst, bool,
+ private_ipsec_sa_t *this, u_int32_t spi, host_t *src, host_t *dst)
+{
+ return this->spi == spi && this->src->ip_equals(this->src, src) &&
+ this->dst->ip_equals(this->dst, dst);
+}
+
+METHOD(ipsec_sa_t, match_by_reqid, bool,
+ private_ipsec_sa_t *this, u_int32_t reqid, bool inbound)
+{
+ return this->reqid == reqid && this->inbound == inbound;
+}
+
METHOD(ipsec_sa_t, destroy, void,
private_ipsec_sa_t *this)
{
@@ -188,6 +207,9 @@ ipsec_sa_t *ipsec_sa_create(u_int32_t spi, host_t *src, host_t *dst,
.get_protocol = _get_protocol,
.get_lifetime = _get_lifetime,
.is_inbound = _is_inbound,
+ .match_by_spi_dst = _match_by_spi_dst,
+ .match_by_spi_src_dst = _match_by_spi_src_dst,
+ .match_by_reqid = _match_by_reqid,
.get_esp_context = _get_esp_context,
},
.spi = spi,