Add alerts for sent/received message retransmissions and timeout
authorMartin Willi <martin@revosec.ch>
Fri, 19 Oct 2012 09:32:20 +0000 (11:32 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 29 Nov 2012 09:22:51 +0000 (10:22 +0100)
src/libcharon/bus/bus.h
src/libcharon/sa/ikev1/task_manager_v1.c
src/libcharon/sa/ikev2/task_manager_v2.c

index 8a6382f..cc378b4 100644 (file)
@@ -99,6 +99,12 @@ enum alert_t {
        /** 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,
+       /** sending a retransmit for a message, argument is packet_t */
+       ALERT_RETRANSMIT_SEND,
+       /** sending retransmits timed out, argument is packet_t */
+       ALERT_RETRANSMIT_SEND_TIMEOUT,
+       /** received a retransmit for a message, argument is message_t */
+       ALERT_RETRANSMIT_RECEIVE,
 };
 
 /**
index 2ea6361..1ee833c 100644 (file)
@@ -293,6 +293,7 @@ static status_t retransmit_packet(private_task_manager_t *this, u_int32_t seqnr,
        if (retransmitted > this->retransmit_tries)
        {
                DBG1(DBG_IKE, "giving up after %u retransmits", retransmitted - 1);
+               charon->bus->alert(charon->bus, ALERT_RETRANSMIT_SEND_TIMEOUT, packet);
                return DESTROY_ME;
        }
        t = (u_int32_t)(this->retransmit_timeout * 1000.0 *
@@ -302,6 +303,7 @@ static status_t retransmit_packet(private_task_manager_t *this, u_int32_t seqnr,
                DBG1(DBG_IKE, "sending retransmit %u of %s message ID %u, seq %u",
                         retransmitted, seqnr < RESPONDING_SEQ ? "request" : "response",
                         mid, seqnr < RESPONDING_SEQ ? seqnr : seqnr - RESPONDING_SEQ);
+               charon->bus->alert(charon->bus, ALERT_RETRANSMIT_SEND, packet);
        }
        charon->sender->send(charon->sender, packet->clone(packet));
        lib->scheduler->schedule_job_ms(lib->scheduler, (job_t*)
@@ -1167,6 +1169,7 @@ METHOD(task_manager_t, process_message, status_t,
                                DBG1(DBG_IKE, "received retransmit of request with ID %u, "
                                         "but no response to retransmit", mid);
                        }
+                       charon->bus->alert(charon->bus, ALERT_RETRANSMIT_RECEIVE, msg);
                        return SUCCESS;
                }
                if (msg->get_exchange_type(msg) == TRANSACTION &&
index 5245404..5cb1490 100644 (file)
@@ -257,6 +257,8 @@ METHOD(task_manager_t, retransmit, status_t,
                        {
                                DBG1(DBG_IKE, "giving up after %d retransmits",
                                         this->initiating.retransmitted - 1);
+                               charon->bus->alert(charon->bus, ALERT_RETRANSMIT_SEND_TIMEOUT,
+                                                                  this->initiating.packet);
                                return DESTROY_ME;
                        }
 
@@ -264,6 +266,8 @@ METHOD(task_manager_t, retransmit, status_t,
                        {
                                DBG1(DBG_IKE, "retransmit %d of request with message ID %d",
                                         this->initiating.retransmitted, message_id);
+                               charon->bus->alert(charon->bus, ALERT_RETRANSMIT_SEND,
+                                                                  this->initiating.packet);
                        }
                        packet = this->initiating.packet->clone(this->initiating.packet);
                        charon->sender->send(charon->sender, packet);
@@ -1136,6 +1140,7 @@ METHOD(task_manager_t, process_message, status_t,
 
                        DBG1(DBG_IKE, "received retransmit of request with ID %d, "
                                 "retransmitting response", mid);
+                       charon->bus->alert(charon->bus, ALERT_RETRANSMIT_RECEIVE, msg);
                        clone = this->responding.packet->clone(this->responding.packet);
                        host = msg->get_destination(msg);
                        clone->set_source(clone, host->clone(host));