Replace eap_type_text() with EAP server methods function

While this may not include knowledge of all EAP methods since this
depends on build configuration, it is better to not have to include
ieee802_1x.h into eapol_sm.c.
master
Jouni Malinen 15 years ago
parent 4dbfe5c58a
commit 2773ca093e

@ -1,6 +1,6 @@
/*
* hostapd / IEEE 802.1X-2004 Authenticator - EAPOL state machine
* Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
* IEEE 802.1X-2004 Authenticator - EAPOL state machine
* Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@ -15,7 +15,6 @@
#include "includes.h"
#include "common.h"
#include "ieee802_1x.h"
#include "eapol_sm.h"
#include "eloop.h"
#include "wpa.h"
@ -272,12 +271,12 @@ SM_STATE(AUTH_PAE, HELD)
eapol_auth_vlogger(sm->eapol, sm->addr, EAPOL_LOGGER_WARNING,
"authentication failed - EAP type: %d (%s)",
sm->eap_type_authsrv,
eap_type_text(sm->eap_type_authsrv));
eap_server_get_name(0, sm->eap_type_authsrv));
if (sm->eap_type_authsrv != sm->eap_type_supp) {
eapol_auth_vlogger(sm->eapol, sm->addr, EAPOL_LOGGER_INFO,
"Supplicant used different EAP type: "
"%d (%s)", sm->eap_type_supp,
eap_type_text(sm->eap_type_supp));
eap_server_get_name(0, sm->eap_type_supp));
}
sm->eapol->cb.finished(sm->hapd, sm->sta, 0,
sm->flags & EAPOL_SM_PREAUTH);
@ -303,7 +302,8 @@ SM_STATE(AUTH_PAE, AUTHENTICATED)
eapol_auth_vlogger(sm->eapol, sm->addr, EAPOL_LOGGER_INFO,
"authenticated - EAP type: %d (%s)%s",
sm->eap_type_authsrv,
eap_type_text(sm->eap_type_authsrv), extra);
eap_server_get_name(0, sm->eap_type_authsrv),
extra);
sm->eapol->cb.finished(sm->hapd, sm->sta, 1,
sm->flags & EAPOL_SM_PREAUTH);
}

@ -563,28 +563,6 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
#endif /* CONFIG_NO_RADIUS */
char *eap_type_text(u8 type)
{
switch (type) {
case EAP_TYPE_IDENTITY: return "Identity";
case EAP_TYPE_NOTIFICATION: return "Notification";
case EAP_TYPE_NAK: return "Nak";
case EAP_TYPE_MD5: return "MD5-Challenge";
case EAP_TYPE_OTP: return "One-Time Password";
case EAP_TYPE_GTC: return "Generic Token Card";
case EAP_TYPE_TLS: return "TLS";
case EAP_TYPE_TTLS: return "TTLS";
case EAP_TYPE_PEAP: return "PEAP";
case EAP_TYPE_SIM: return "SIM";
case EAP_TYPE_FAST: return "FAST";
case EAP_TYPE_SAKE: return "SAKE";
case EAP_TYPE_PSK: return "PSK";
case EAP_TYPE_PAX: return "PAX";
default: return "Unknown";
}
}
static void handle_eap_response(struct hostapd_data *hapd,
struct sta_info *sta, struct eap_hdr *eap,
size_t len)
@ -607,7 +585,7 @@ static void handle_eap_response(struct hostapd_data *hapd,
HOSTAPD_LEVEL_DEBUG, "received EAP packet (code=%d "
"id=%d len=%d) from STA: EAP Response-%s (%d)",
eap->code, eap->identifier, be_to_host16(eap->length),
eap_type_text(type), type);
eap_server_get_name(0, type), type);
sm->dot1xAuthEapolRespFramesRx++;
@ -993,12 +971,14 @@ static void ieee802_1x_decapsulate_radius(struct hostapd_data *hapd,
if (eap_type >= 0)
sm->eap_type_authsrv = eap_type;
os_snprintf(buf, sizeof(buf), "EAP-Request-%s (%d)",
eap_type >= 0 ? eap_type_text(eap_type) : "??",
eap_type >= 0 ? eap_server_get_name(0, eap_type) :
"??",
eap_type);
break;
case EAP_CODE_RESPONSE:
os_snprintf(buf, sizeof(buf), "EAP Response-%s (%d)",
eap_type >= 0 ? eap_type_text(eap_type) : "??",
eap_type >= 0 ? eap_server_get_name(0, eap_type) :
"??",
eap_type);
break;
case EAP_CODE_SUCCESS:
@ -1424,8 +1404,9 @@ void ieee802_1x_dump_state(FILE *f, const char *prefix, struct sta_info *sta)
fprintf(f, "%slast EAP type: Authentication Server: %d (%s) "
"Supplicant: %d (%s)\n", prefix,
sm->eap_type_authsrv, eap_type_text(sm->eap_type_authsrv),
sm->eap_type_supp, eap_type_text(sm->eap_type_supp));
sm->eap_type_authsrv,
eap_server_get_name(0, sm->eap_type_authsrv),
sm->eap_type_supp, eap_server_get_name(0, sm->eap_type_supp));
fprintf(f, "%scached_packets=%s\n", prefix,
sm->last_recv_radius ? "[RX RADIUS]" : "");

@ -1,6 +1,6 @@
/*
* hostapd / EAP method registration
* Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
* EAP server method registration
* Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@ -306,3 +306,23 @@ void eap_server_unregister_methods(void)
eap_server_method_free(m);
}
}
/**
* eap_server_get_name - Get EAP method name for the given EAP type
* @vendor: EAP Vendor-Id (0 = IETF)
* @type: EAP method type
* Returns: EAP method name, e.g., TLS, or %NULL if not found
*
* This function maps EAP type numbers into EAP type names based on the list of
* EAP methods included in the build.
*/
const char * eap_server_get_name(int vendor, EapType type)
{
struct eap_method *m;
for (m = eap_methods; m; m = m->next) {
if (m->vendor == vendor && m->method == type)
return m->name;
}
return NULL;
}

@ -1,6 +1,6 @@
/*
* hostapd / EAP method registration
* Copyright (c) 2004-2006, Jouni Malinen <j@w1.fi>
* EAP server method registration
* Copyright (c) 2004-2009, Jouni Malinen <j@w1.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@ -25,5 +25,6 @@ int eap_server_method_register(struct eap_method *method);
EapType eap_server_get_type(const char *name, int *vendor);
int eap_server_register_methods(void);
void eap_server_unregister_methods(void);
const char * eap_server_get_name(int vendor, EapType type);
#endif /* EAP_SERVER_METHODS_H */

Loading…
Cancel
Save