show kind of notify contained in messages in log
authorMartin Willi <martin@strongswan.org>
Tue, 3 Jul 2007 08:50:14 +0000 (08:50 -0000)
committerMartin Willi <martin@strongswan.org>
Tue, 3 Jul 2007 08:50:14 +0000 (08:50 -0000)
src/charon/encoding/message.c
src/charon/encoding/payloads/notify_payload.c
src/charon/encoding/payloads/notify_payload.h

index b31b21a..a321659 100644 (file)
@@ -621,16 +621,10 @@ static char* get_string(private_message_t *this, char *buf, int len)
        pos += written;
        len -= written;
        
-       if (this->payloads->get_count(this->payloads) == 0)
-       {
-               snprintf(pos, len, "]");
-               return buf;
-       }
-       
        iterator = this->payloads->create_iterator(this->payloads, TRUE);
        while (iterator->iterate(iterator, (void**)&payload))
        {
-               written = snprintf(pos, len, "%N ", payload_type_short_names,
+               written = snprintf(pos, len, " %N", payload_type_short_names,
                                                   payload->get_type(payload));
                if (written >= len || written < 0)
                {
@@ -638,13 +632,23 @@ static char* get_string(private_message_t *this, char *buf, int len)
                }
                pos += written;
                len -= written;
+               if (payload->get_type(payload) == NOTIFY)
+               {
+                       notify_payload_t *notify = (notify_payload_t*)payload;
+                       written = snprintf(pos, len, "(%N)", notify_type_short_names,
+                                                          notify->get_notify_type(notify));
+                       if (written >= len || written < 0)
+                       {
+                               return buf;
+                       }
+                       pos += written;
+                       len -= written;
+               }
        }
        iterator->destroy(iterator);
        
        /* remove last space */
-       pos--;
-       len++;
-       snprintf(pos, len, "]");
+       snprintf(pos, len, " ]");
        return buf;
 }
 
@@ -734,7 +738,7 @@ static status_t generate(private_message_t *this, crypter_t *crypter, signer_t*
        iterator_t *iterator;
        status_t status;
        chunk_t packet_data;
-       char str[128];
+       char str[256];
        
        if (is_encoded(this))
        {
@@ -1140,7 +1144,7 @@ static status_t parse_body(private_message_t *this, crypter_t *crypter, signer_t
 {
        status_t status = SUCCESS;
        payload_type_t current_payload_type;
-       char str[128];
+       char str[256];
                
        current_payload_type = this->first_payload;     
                
index d700965..e27d3c6 100644 (file)
@@ -81,6 +81,59 @@ ENUM_NEXT(notify_type_names, EAP_ONLY_AUTHENTICATION, EAP_ONLY_AUTHENTICATION, A
        "EAP_ONLY_AUTHENTICATION");
 ENUM_END(notify_type_names, EAP_ONLY_AUTHENTICATION);
 
+
+ENUM_BEGIN(notify_type_short_names, UNSUPPORTED_CRITICAL_PAYLOAD, UNSUPPORTED_CRITICAL_PAYLOAD,
+       "CRIT");
+ENUM_NEXT(notify_type_short_names, INVALID_IKE_SPI, INVALID_MAJOR_VERSION, UNSUPPORTED_CRITICAL_PAYLOAD,
+       "INVAL_IKE_SPI",
+       "INVAL_MAJOR");
+ENUM_NEXT(notify_type_short_names, INVALID_SYNTAX, INVALID_SYNTAX, INVALID_MAJOR_VERSION,
+       "INVAL_SYN");
+ENUM_NEXT(notify_type_short_names, INVALID_MESSAGE_ID, INVALID_MESSAGE_ID, INVALID_SYNTAX,
+       "INVAL_MID");
+ENUM_NEXT(notify_type_short_names, INVALID_SPI, INVALID_SPI, INVALID_MESSAGE_ID,
+       "INVAL_SPI");
+ENUM_NEXT(notify_type_short_names, NO_PROPOSAL_CHOSEN, NO_PROPOSAL_CHOSEN, INVALID_SPI,
+       "NO_PROP");
+ENUM_NEXT(notify_type_short_names, INVALID_KE_PAYLOAD, INVALID_KE_PAYLOAD, NO_PROPOSAL_CHOSEN,
+       "INVAL_KE");
+ENUM_NEXT(notify_type_short_names, AUTHENTICATION_FAILED, AUTHENTICATION_FAILED, INVALID_KE_PAYLOAD,
+       "AUTH_FAILED");
+ENUM_NEXT(notify_type_short_names, SINGLE_PAIR_REQUIRED, UNEXPECTED_NAT_DETECTED, AUTHENTICATION_FAILED,
+       "SINGLE_PAIR",
+       "NO_ADD_SAS",
+       "INT_ADDR_FAIL",
+       "FAIL_CP_REQ",
+       "TS_UNACCEPT",
+       "INVAL_SEL",
+       "UNACCEPT_ADDR",
+       "UNEXPECT_NAT");
+ENUM_NEXT(notify_type_short_names, INITIAL_CONTACT, AUTH_LIFETIME, UNEXPECTED_NAT_DETECTED,
+       "INIT_CONTACT",
+       "SET_WINSIZE",
+       "ADD_TS_POSS",
+       "IPCOMP_SUPP",
+       "NATD_S_IP",
+       "NATD_D_IP",
+       "COOKIE",
+       "USE_TRANSP",
+       "HTTP_CERT_LOOK",
+       "REKEY_SA",
+       "ESP_TFC_PAD_N",
+       "NON_FIRST_FRAG",
+       "MOBIKE_SUP",
+       "ADD_4_ADDR",
+       "ADD_6_ADDR",
+       "NO_ADD_ADDR",
+       "UPD_SA_ADDR",
+       "COOKIE2",
+       "NO_NATS",
+       "AUTH_LFT");
+ENUM_NEXT(notify_type_short_names, EAP_ONLY_AUTHENTICATION, EAP_ONLY_AUTHENTICATION, AUTH_LIFETIME,
+       "EAP_ONLY");
+ENUM_END(notify_type_short_names, EAP_ONLY_AUTHENTICATION);
+
+
 typedef struct private_notify_payload_t private_notify_payload_t;
 
 /**
index ca1fe3a..231d040 100644 (file)
@@ -104,6 +104,13 @@ enum notify_type_t {
 extern enum_name_t *notify_type_names;
 
 /**
+ * enum name for notify_type_t (shorter strings).
+ *
+ * @ingroup payloads
+ */
+extern enum_name_t *notify_type_short_names;
+
+/**
  * @brief Class representing an IKEv2-Notify Payload.
  * 
  * The Notify Payload format is described in Draft section 3.10.