Message stringification supports more detailed EAP payload information

This commit is contained in:
Martin Willi
2009-11-18 10:37:46 +01:00
parent 1860bfa2ea
commit 80b44cd71a
3 changed files with 65 additions and 0 deletions
+29
View 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);
@@ -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",
@@ -66,6 +66,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.
*
@@ -89,6 +94,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.
*