WPS: Share a common function for error strings

This makes it easier to maintain the list of WPS_EI_* error values and
matching strings.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2013-07-31 17:30:45 +03:00 committed by Jouni Malinen
parent 30158a0d80
commit 961750c1e8
4 changed files with 19 additions and 15 deletions

View file

@ -734,12 +734,6 @@ static void hostapd_wps_ap_pin_success(struct hostapd_data *hapd)
}
static const char * wps_event_fail_reason[NUM_WPS_EI_VALUES] = {
"No Error", /* WPS_EI_NO_ERROR */
"TKIP Only Prohibited", /* WPS_EI_SECURITY_TKIP_ONLY_PROHIBITED */
"WEP Prohibited" /* WPS_EI_SECURITY_WEP_PROHIBITED */
};
static void hostapd_wps_event_fail(struct hostapd_data *hapd,
struct wps_event_fail *fail)
{
@ -748,7 +742,7 @@ static void hostapd_wps_event_fail(struct hostapd_data *hapd,
wpa_msg(hapd->msg_ctx, MSG_INFO,
WPS_EVENT_FAIL "msg=%d config_error=%d reason=%d (%s)",
fail->msg, fail->config_error, fail->error_indication,
wps_event_fail_reason[fail->error_indication]);
wps_ei_str(fail->error_indication));
} else {
wpa_msg(hapd->msg_ctx, MSG_INFO,
WPS_EVENT_FAIL "msg=%d config_error=%d",

View file

@ -640,3 +640,18 @@ int wps_attr_text(struct wpabuf *data, char *buf, char *end)
return pos - buf;
}
const char * wps_ei_str(enum wps_error_indication ei)
{
switch (ei) {
case WPS_EI_NO_ERROR:
return "No Error";
case WPS_EI_SECURITY_TKIP_ONLY_PROHIBITED:
return "TKIP Only Prohibited";
case WPS_EI_SECURITY_WEP_PROHIBITED:
return "WEP Prohibited";
default:
return "Unknown";
}
}

View file

@ -786,6 +786,7 @@ void wps_free_pending_msgs(struct upnp_pending_message *msgs);
struct wpabuf * wps_get_oob_cred(struct wps_context *wps);
int wps_oob_use_cred(struct wps_context *wps, struct wps_parse_attr *attr);
int wps_attr_text(struct wpabuf *data, char *buf, char *end);
const char * wps_ei_str(enum wps_error_indication ei);
struct wps_er * wps_er_init(struct wps_context *wps, const char *ifname,
const char *filter);

View file

@ -567,12 +567,6 @@ static void wpa_supplicant_wps_event_m2d(struct wpa_supplicant *wpa_s,
}
static const char * wps_event_fail_reason[NUM_WPS_EI_VALUES] = {
"No Error", /* WPS_EI_NO_ERROR */
"TKIP Only Prohibited", /* WPS_EI_SECURITY_TKIP_ONLY_PROHIBITED */
"WEP Prohibited" /* WPS_EI_SECURITY_WEP_PROHIBITED */
};
static void wpa_supplicant_wps_event_fail(struct wpa_supplicant *wpa_s,
struct wps_event_fail *fail)
{
@ -581,13 +575,13 @@ static void wpa_supplicant_wps_event_fail(struct wpa_supplicant *wpa_s,
wpa_msg(wpa_s, MSG_INFO,
WPS_EVENT_FAIL "msg=%d config_error=%d reason=%d (%s)",
fail->msg, fail->config_error, fail->error_indication,
wps_event_fail_reason[fail->error_indication]);
wps_ei_str(fail->error_indication));
if (wpa_s->parent && wpa_s->parent != wpa_s)
wpa_msg(wpa_s->parent, MSG_INFO, WPS_EVENT_FAIL
"msg=%d config_error=%d reason=%d (%s)",
fail->msg, fail->config_error,
fail->error_indication,
wps_event_fail_reason[fail->error_indication]);
wps_ei_str(fail->error_indication));
} else {
wpa_msg(wpa_s, MSG_INFO,
WPS_EVENT_FAIL "msg=%d config_error=%d",