Enable the generation of unencrypted messages (e.g. ME connectivity checks).
authorTobias Brunner <tobias@strongswan.org>
Mon, 30 Aug 2010 15:24:07 +0000 (17:24 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 30 Aug 2010 15:25:12 +0000 (17:25 +0200)
src/libcharon/encoding/message.c

index 0d55b8a..d41ad46 100644 (file)
@@ -954,7 +954,7 @@ static void order_payloads(private_message_t *this)
 }
 
 /**
- * Wrap payloads in a encryption payload, if required
+ * Wrap payloads in a encryption payload
  */
 static encryption_payload_t* wrap_payloads(private_message_t *this)
 {
@@ -962,12 +962,6 @@ static encryption_payload_t* wrap_payloads(private_message_t *this)
        linked_list_t *payloads;
        payload_t *current;
 
-       if (!this->rule->encrypted)
-       {
-               DBG2(DBG_ENC, "not encrypting payloads");
-               return NULL;
-       }
-
        /* copy all payloads in a temporary list */
        payloads = linked_list_create();
        while (this->payloads->remove_first(this->payloads,
@@ -1013,7 +1007,7 @@ METHOD(message_t, generate, status_t,
        generator_t *generator;
        ike_header_t *ike_header;
        payload_t *payload, *next;
-       encryption_payload_t *encryption;
+       encryption_payload_t *encryption = NULL;
        enumerator_t *enumerator;
        chunk_t chunk;
        char str[256];
@@ -1049,7 +1043,14 @@ METHOD(message_t, generate, status_t,
 
        DBG1(DBG_ENC, "generating %s", get_string(this, str, sizeof(str)));
 
-       encryption = wrap_payloads(this);
+       if (aead && this->rule->encrypted)
+       {
+               encryption = wrap_payloads(this);
+       }
+       else
+       {
+               DBG2(DBG_ENC, "not encrypting payloads");
+       }
 
        ike_header = ike_header_create();
        ike_header->set_exchange_type(ike_header, this->exchange_type);