Message stringification supports more detailed EAP payload information
authorMartin Willi <martin@strongswan.org>
Wed, 18 Nov 2009 09:37:46 +0000 (10:37 +0100)
committerMartin Willi <martin@strongswan.org>
Wed, 18 Nov 2009 09:37:46 +0000 (10:37 +0100)
src/charon/encoding/message.c
src/charon/sa/authenticators/eap/eap_method.c
src/charon/sa/authenticators/eap/eap_method.h

index b39c076..397a3c6 100644 (file)
@@ -946,6 +946,35 @@ static char* get_string(private_message_t *this, char *buf, int len)
                        pos += written;
                        len -= written;
                }
+               if (payload->get_type(payload) == EXTENSIBLE_AUTHENTICATION)
+               {
+                       eap_payload_t *eap = (eap_payload_t*)payload;
+                       u_int32_t vendor;
+                       eap_type_t type;
+                       char method[64] = "";
+
+                       type = eap->get_type(eap, &vendor);
+                       if (type)
+                       {
+                               if (vendor)
+                               {
+                                       snprintf(method, sizeof(method), "/%d-%d", type, vendor);
+                               }
+                               else
+                               {
+                                       snprintf(method, sizeof(method), "/%N",
+                                                        eap_type_short_names, type);
+                               }
+                       }
+                       written = snprintf(pos, len, "/%N%s", eap_code_short_names,
+                                                          eap->get_code(eap), method);
+                       if (written >= len || written < 0)
+                       {
+                               return buf;
+                       }
+                       pos += written;
+                       len -= written;
+               }
        }
        enumerator->destroy(enumerator);
 
index 791ab2d..91fa530 100644 (file)
@@ -34,6 +34,25 @@ ENUM_NEXT(eap_type_names, EAP_RADIUS, EAP_EXPERIMENTAL, EAP_MSCHAPV2,
        "EAP_EXPERIMENTAL");
 ENUM_END(eap_type_names, EAP_EXPERIMENTAL);
 
+ENUM_BEGIN(eap_type_short_names, EAP_IDENTITY, EAP_GTC,
+       "ID",
+       "NTF",
+       "NAK",
+       "MD5",
+       "OTP",
+       "GTC");
+ENUM_NEXT(eap_type_short_names, EAP_SIM, EAP_SIM, EAP_GTC,
+       "SIM");
+ENUM_NEXT(eap_type_short_names, EAP_AKA, EAP_AKA, EAP_SIM,
+       "AKA");
+ENUM_NEXT(eap_type_short_names, EAP_MSCHAPV2, EAP_MSCHAPV2, EAP_AKA,
+       "MSCHAPV2");
+ENUM_NEXT(eap_type_short_names, EAP_RADIUS, EAP_EXPERIMENTAL, EAP_MSCHAPV2,
+       "RAD",
+       "EXP",
+       "XP");
+ENUM_END(eap_type_short_names, EAP_EXPERIMENTAL);
+
 /*
  * See header
  */
@@ -71,6 +90,13 @@ ENUM(eap_code_names, EAP_REQUEST, EAP_FAILURE,
        "EAP_FAILURE",
 );
 
+ENUM(eap_code_short_names, EAP_REQUEST, EAP_FAILURE,
+       "REQ",
+       "RES",
+       "SUCC",
+       "FAIL",
+);
+
 ENUM(eap_role_names, EAP_SERVER, EAP_PEER,
        "EAP_SERVER",
        "EAP_PEER",
index 61e8e2c..4cab845 100644 (file)
@@ -67,6 +67,11 @@ enum eap_type_t {
 extern enum_name_t *eap_type_names;
 
 /**
+ * short string enum names for eap_type_t.
+ */
+extern enum_name_t *eap_type_short_names;
+
+/**
  * Lookup the EAP method type from a string.
  *
  * @param name         EAP method name (such as "md5", "aka")
@@ -90,6 +95,11 @@ enum eap_code_t {
 extern enum_name_t *eap_code_names;
 
 /**
+ * short string enum names for eap_code_t.
+ */
+extern enum_name_t *eap_code_short_names;
+
+/**
  * Interface of an EAP method for server and client side.
  *
  * An EAP method initiates an EAP exchange and processes requests and