Raise a bus alert when IKE message body parsing fails
authorMartin Willi <martin@revosec.ch>
Mon, 8 Oct 2012 09:19:54 +0000 (11:19 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 24 Oct 2012 09:34:30 +0000 (11:34 +0200)
src/libcharon/bus/bus.h
src/libcharon/sa/ikev1/task_manager_v1.c
src/libcharon/sa/ikev2/task_manager_v2.c

index 2cd04cf..485b1dc 100644 (file)
@@ -96,6 +96,9 @@ enum alert_t {
        ALERT_INVALID_IKE_SPI,
        /** received IKE message with invalid header, argument is message_t* */
        ALERT_PARSE_ERROR_HEADER,
+       /** received IKE message with invalid body, argument is message_t*,
+        *  followed by a status_t result returned by message_t.parse_body(). */
+       ALERT_PARSE_ERROR_BODY,
 };
 
 /**
index 5b7258f..2ea6361 100644 (file)
@@ -1076,6 +1076,8 @@ static status_t parse_message(private_task_manager_t *this, message_t *msg)
                         msg->get_request(msg) ? "request" : "response",
                         msg->get_message_id(msg));
 
+               charon->bus->alert(charon->bus, ALERT_PARSE_ERROR_BODY, msg, status);
+
                if (this->ike_sa->get_state(this->ike_sa) == IKE_CREATED)
                {       /* invalid initiation attempt, close SA */
                        return DESTROY_ME;
index 5890ba5..5245404 100644 (file)
@@ -1045,6 +1045,8 @@ static status_t parse_message(private_task_manager_t *this, message_t *msg)
                         is_request ? "request" : "response",
                         msg->get_message_id(msg));
 
+               charon->bus->alert(charon->bus, ALERT_PARSE_ERROR_BODY, msg, status);
+
                if (this->ike_sa->get_state(this->ike_sa) == IKE_CREATED)
                {       /* invalid initiation attempt, close SA */
                        return DESTROY_ME;