Added method to get encoded version if ID_V1 payload.
authorTobias Brunner <tobias@strongswan.org>
Tue, 13 Dec 2011 16:12:23 +0000 (17:12 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 20 Mar 2012 16:31:21 +0000 (17:31 +0100)
src/libcharon/encoding/payloads/id_payload.c
src/libcharon/encoding/payloads/id_payload.h

index 4d5cd05..02b07d6 100755 (executable)
@@ -327,6 +327,15 @@ METHOD(id_payload_t, get_ts, traffic_selector_t*,
        return NULL;
 }
 
+METHOD(id_payload_t, get_encoded, chunk_t,
+       private_id_payload_t *this)
+{
+       u_int16_t port = htons(this->port);
+       return chunk_cat("cccc", chunk_from_thing(this->id_type),
+                                        chunk_from_thing(this->protocol_id),
+                                        chunk_from_thing(port), this->id_data);
+}
+
 METHOD2(payload_t, id_payload_t, destroy, void,
        private_id_payload_t *this)
 {
@@ -354,6 +363,7 @@ id_payload_t *id_payload_create(payload_type_t type)
                                .destroy = _destroy,
                        },
                        .get_identification = _get_identification,
+                       .get_encoded = _get_encoded,
                        .get_ts = _get_ts,
                        .destroy = _destroy,
                },
index 22016bc..94ed1cb 100644 (file)
@@ -55,6 +55,13 @@ struct id_payload_t {
        traffic_selector_t* (*get_ts)(id_payload_t *this);
 
        /**
+        * Get encoded payload without fixed payload header (used for IKEv1).
+        *
+        * @return                              encoded payload (gets allocated)
+        */
+       chunk_t (*get_encoded)(id_payload_t *this);
+
+       /**
         * Destroys an id_payload_t object.
         */
        void (*destroy) (id_payload_t *this);