Allow creation of message_t objects for IKEv1 packets.
[strongswan.git] / src / conftest / hooks / unencrypted_notify.c
index 7db9296..507f30c 100644 (file)
@@ -75,12 +75,12 @@ METHOD(listener_t, ike_updown, bool,
                                return TRUE;
                        }
                }
-               if (strncasecmp(this->data, "0x", 2) == 0)
+               if (strncaseeq(this->data, "0x", 2))
                {
                        data = chunk_skip(chunk_create(this->data, strlen(this->data)), 2);
                        data = chunk_from_hex(data, NULL);
                }
-               else if (data.len)
+               else if (this->data && strlen(this->data))
                {
                        data = chunk_clone(chunk_create(this->data, strlen(this->data)));
                }
@@ -95,7 +95,7 @@ METHOD(listener_t, ike_updown, bool,
 
                DBG1(DBG_CFG, "injecting unencrypted INFORMATIONAL message");
 
-               message = message_create();
+               message = message_create(IKEV2_MAJOR_VERSION, IKEV2_MINOR_VERSION);
                message->set_message_id(message, this->id);
                message->set_ike_sa_id(message, ike_sa->get_id(ike_sa));
                message->set_exchange_type(message, INFORMATIONAL);
@@ -126,7 +126,7 @@ METHOD(hook_t, destroy, void,
 /**
  * Create the IKE_AUTH fill hook
  */
-hook_t *unencrypted_notify_hook_create(void)
+hook_t *unencrypted_notify_hook_create(char *name)
 {
        private_unencrypted_notify_t *this;
 
@@ -138,15 +138,15 @@ hook_t *unencrypted_notify_hook_create(void)
                        .destroy = _destroy,
                },
                .id = conftest->test->get_int(conftest->test,
-                                                                               "hooks.unencrypted_notify.id", 2),
+                                                                               "hooks.%s.id", 2, name),
                .type = conftest->test->get_str(conftest->test,
-                                                                               "hooks.unencrypted_notify.type", ""),
+                                                                               "hooks.%s.type", "", name),
                .data = conftest->test->get_str(conftest->test,
-                                                                               "hooks.unencrypted_notify.data", ""),
+                                                                               "hooks.%s.data", "", name),
                .spi = conftest->test->get_int(conftest->test,
-                                                                               "hooks.unencrypted_notify.spi", 0),
+                                                                               "hooks.%s.spi", 0, name),
                .esp = conftest->test->get_bool(conftest->test,
-                                                                               "hooks.unencrypted_notify.esp", FALSE),
+                                                                               "hooks.%s.esp", FALSE, name),
        );
 
        return &this->hook;