added functions for getting/setting ISAKMP SPI to notify payload
authorClavister OpenSource <opensource@clavister.com>
Fri, 9 Dec 2011 14:43:36 +0000 (15:43 +0100)
committerClavister OpenSource <opensource@clavister.com>
Tue, 20 Mar 2012 16:31:14 +0000 (17:31 +0100)
src/libcharon/encoding/payloads/notify_payload.c [changed mode: 0644->0755]
src/libcharon/encoding/payloads/notify_payload.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index a72a0f3..6b6c28d
@@ -600,6 +600,37 @@ METHOD(notify_payload_t, set_spi, void,
        compute_length(this);
 }
 
        compute_length(this);
 }
 
+METHOD(notify_payload_t, get_spi_data, chunk_t,
+       private_notify_payload_t *this)
+{
+       switch (this->protocol_id)
+       {
+               case PROTO_IKE:
+                       if (this->spi.len == 16)
+                       {
+                               return this->spi;
+                       }
+               default:
+                       break;
+       }
+       return chunk_empty;
+}
+
+METHOD(notify_payload_t, set_spi_data, void,
+       private_notify_payload_t *this, chunk_t spi)
+{
+       chunk_free(&this->spi);
+       switch (this->protocol_id)
+       {
+               case PROTO_IKE:
+                       this->spi = chunk_clone(spi);
+               default:
+                       break;
+       }
+       this->spi_size = this->spi.len;
+       compute_length(this);
+}
+
 METHOD(notify_payload_t, get_notification_data, chunk_t,
        private_notify_payload_t *this)
 {
 METHOD(notify_payload_t, get_notification_data, chunk_t,
        private_notify_payload_t *this)
 {
@@ -647,6 +678,8 @@ notify_payload_t *notify_payload_create(payload_type_t type)
                        .set_notify_type = _set_notify_type,
                        .get_spi = _get_spi,
                        .set_spi = _set_spi,
                        .set_notify_type = _set_notify_type,
                        .get_spi = _get_spi,
                        .set_spi = _set_spi,
+                       .get_spi_data = _get_spi_data,
+                       .set_spi_data = _set_spi_data,
                        .get_notification_data = _get_notification_data,
                        .set_notification_data = _set_notification_data,
                        .destroy = _destroy,
                        .get_notification_data = _get_notification_data,
                        .set_notification_data = _set_notification_data,
                        .destroy = _destroy,
old mode 100644 (file)
new mode 100755 (executable)
index 9539231..2f5294e
@@ -210,6 +210,24 @@ struct notify_payload_t {
        void (*set_spi) (notify_payload_t *this, u_int32_t spi);
 
        /**
        void (*set_spi) (notify_payload_t *this, u_int32_t spi);
 
        /**
+        * Returns the currently set spi of this payload.
+        *
+        * This is only valid for notifys with protocol ISAKMP
+        *
+        * @return              SPI value
+        */
+       chunk_t (*get_spi_data) (notify_payload_t *this);
+
+       /**
+        * Sets the spi of this payload.
+        *
+        * This is only valid for notifys with protocol ISAKMP
+        *
+        * @param spi   SPI value
+        */
+       void (*set_spi_data) (notify_payload_t *this, chunk_t spi);
+
+       /**
         * Returns the currently set notification data of payload.
         *
         * Returned data are not copied.
         * Returns the currently set notification data of payload.
         *
         * Returned data are not copied.