Setter for src and destination address of ipsec_sa_t added
authorTobias Brunner <tobias@strongswan.org>
Wed, 10 Oct 2012 13:29:25 +0000 (15:29 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 16 Oct 2012 12:16:17 +0000 (14:16 +0200)
src/libipsec/ipsec_sa.c
src/libipsec/ipsec_sa.h

index cccd164..6685225 100644 (file)
@@ -95,6 +95,20 @@ METHOD(ipsec_sa_t, get_destination, host_t*,
        return this->dst;
 }
 
+METHOD(ipsec_sa_t, set_source, void,
+       private_ipsec_sa_t *this, host_t *addr)
+{
+       this->src->destroy(this->src);
+       this->src = addr->clone(addr);
+}
+
+METHOD(ipsec_sa_t, set_destination, void,
+       private_ipsec_sa_t *this, host_t *addr)
+{
+       this->dst->destroy(this->dst);
+       this->dst = addr->clone(addr);
+}
+
 METHOD(ipsec_sa_t, get_spi, u_int32_t,
        private_ipsec_sa_t *this)
 {
@@ -202,6 +216,8 @@ ipsec_sa_t *ipsec_sa_create(u_int32_t spi, host_t *src, host_t *dst,
                        .destroy = _destroy,
                        .get_source = _get_source,
                        .get_destination = _get_destination,
+                       .set_source = _set_source,
+                       .set_destination = _set_destination,
                        .get_spi = _get_spi,
                        .get_reqid = _get_reqid,
                        .get_protocol = _get_protocol,
index 5fd03b6..271e012 100644 (file)
@@ -52,6 +52,20 @@ struct ipsec_sa_t {
        host_t *(*get_destination)(ipsec_sa_t *this);
 
        /**
+        * Set the source address for this SA
+        *
+        * @param addr          source address of this SA (gets cloned)
+        */
+       void (*set_source)(ipsec_sa_t *this, host_t *addr);
+
+       /**
+        * Set the destination address for this SA
+        *
+        * @param addr          destination address of this SA (gets cloned)
+        */
+       void (*set_destination)(ipsec_sa_t *this, host_t *addr);
+
+       /**
         * Get the SPI for this SA
         *
         * @return                      SPI of this SA