From 61b6520e168fa33702d80839aa5a9a9ca7140b86 Mon Sep 17 00:00:00 2001 From: Jeffin Mammen Date: Fri, 23 Aug 2013 16:38:16 +0300 Subject: [PATCH] WPS: Track result of the latest WPS operation Signed-hostap: Jouni Malinen --- src/ap/hostapd.h | 12 ++++++++++++ src/ap/wps_hostapd.c | 17 +++++++++++++++++ src/wps/wps.c | 2 ++ src/wps/wps_defs.h | 1 + 4 files changed, 32 insertions(+) diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 75d9c66ac..693dad879 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -67,6 +67,16 @@ struct hostapd_frame_info { int ssi_signal; /* dBm */ }; +enum wps_status { + WPS_STATUS_SUCCESS = 1, + WPS_STATUS_FAILURE +}; + +struct wps_stat { + enum wps_status status; + enum wps_error_indication failure_reason; +}; + /** * struct hostapd_data - hostapd per-BSS data structure @@ -147,6 +157,8 @@ struct hostapd_data { unsigned int ap_pin_failures_consecutive; struct upnp_wps_device_sm *wps_upnp; unsigned int ap_pin_lockout_time; + + struct wps_stat wps_stats; #endif /* CONFIG_WPS */ struct hostapd_probereq_cb *probereq_cb; diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index b5ecb6bc2..6abd437f4 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -707,6 +707,11 @@ static int wps_pwd_auth_fail(struct hostapd_data *hapd, void *ctx) static void hostapd_pwd_auth_fail(struct hostapd_data *hapd, struct wps_event_pwd_auth_fail *data) { + /* Update WPS Status - Authentication Failure */ + wpa_printf(MSG_DEBUG, "WPS: Authentication failure update"); + hapd->wps_stats.status = WPS_STATUS_FAILURE; + hapd->wps_stats.failure_reason = WPS_EI_AUTH_FAILURE; + hostapd_wps_for_each(hapd, wps_pwd_auth_fail, data); } @@ -734,9 +739,20 @@ static void hostapd_wps_ap_pin_success(struct hostapd_data *hapd) } +static void hostapd_wps_event_success(struct hostapd_data *hapd) +{ + /* Update WPS status - Success */ + hapd->wps_stats.status = WPS_STATUS_SUCCESS; +} + + static void hostapd_wps_event_fail(struct hostapd_data *hapd, struct wps_event_fail *fail) { + /* Update WPS status - Failure */ + hapd->wps_stats.status = WPS_STATUS_FAILURE; + hapd->wps_stats.failure_reason = fail->error_indication; + if (fail->error_indication > 0 && fail->error_indication < NUM_WPS_EI_VALUES) { wpa_msg(hapd->msg_ctx, MSG_INFO, @@ -764,6 +780,7 @@ static void hostapd_wps_event_cb(void *ctx, enum wps_event event, hostapd_wps_event_fail(hapd, &data->fail); break; case WPS_EV_SUCCESS: + hostapd_wps_event_success(hapd); wpa_msg(hapd->msg_ctx, MSG_INFO, WPS_EVENT_SUCCESS); break; case WPS_EV_PWD_AUTH_FAIL: diff --git a/src/wps/wps.c b/src/wps/wps.c index 96aba4ddb..dd5556679 100644 --- a/src/wps/wps.c +++ b/src/wps/wps.c @@ -651,6 +651,8 @@ const char * wps_ei_str(enum wps_error_indication ei) return "TKIP Only Prohibited"; case WPS_EI_SECURITY_WEP_PROHIBITED: return "WEP Prohibited"; + case WPS_EI_AUTH_FAILURE: + return "Authentication Failure"; default: return "Unknown"; } diff --git a/src/wps/wps_defs.h b/src/wps/wps_defs.h index 2f42603a7..3421ac5f8 100644 --- a/src/wps/wps_defs.h +++ b/src/wps/wps_defs.h @@ -223,6 +223,7 @@ enum wps_error_indication { WPS_EI_NO_ERROR, WPS_EI_SECURITY_TKIP_ONLY_PROHIBITED, WPS_EI_SECURITY_WEP_PROHIBITED, + WPS_EI_AUTH_FAILURE, NUM_WPS_EI_VALUES };