From ed159ad41bfb132b7da02a389633280f5d029eac Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 25 Oct 2010 21:59:25 +0300 Subject: [PATCH] WPS ER: Add more details to wps_er_pbc failure returns Indicate the reason for the failure when wps_er_pbc is rejected. --- src/wps/wps_er.c | 9 +++++++-- wpa_supplicant/ctrl_iface.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/wps/wps_er.c b/src/wps/wps_er.c index df556722d..0d0100d0c 100644 --- a/src/wps/wps_er.c +++ b/src/wps/wps_er.c @@ -1455,7 +1455,7 @@ int wps_er_pbc(struct wps_er *er, const u8 *uuid) if (wps_registrar_pbc_overlap(er->wps->registrar, NULL, NULL)) { wpa_printf(MSG_DEBUG, "WPS ER: PBC overlap - do not start PBC " "mode"); - return -1; + return -2; } ap = wps_er_ap_get(er, NULL, uuid); @@ -1469,7 +1469,12 @@ int wps_er_pbc(struct wps_er *er, const u8 *uuid) } } if (sta == NULL) - return -1; /* Unknown UUID */ + return -3; /* Unknown UUID */ + } + + if (ap->ap_settings == NULL) { + wpa_printf(MSG_DEBUG, "WPS ER: AP settings not known"); + return -4; } er->set_sel_reg_uuid_filter = uuid; diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index a67eb36ed..8a2395abd 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2809,7 +2809,17 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, if (wpa_supplicant_ctrl_iface_wps_er_pin(wpa_s, buf + 11)) reply_len = -1; } else if (os_strncmp(buf, "WPS_ER_PBC ", 11) == 0) { - if (wpas_wps_er_pbc(wpa_s, buf + 11)) + int ret = wpas_wps_er_pbc(wpa_s, buf + 11); + if (ret == -2) { + os_memcpy(reply, "FAIL-PBC-OVERLAP\n", 17); + reply_len = 17; + } else if (ret == -3) { + os_memcpy(reply, "FAIL-UNKNOWN-UUID\n", 18); + reply_len = 18; + } else if (ret == -4) { + os_memcpy(reply, "FAIL-NO-AP-SETTINGS\n", 20); + reply_len = 20; + } else if (ret) reply_len = -1; } else if (os_strncmp(buf, "WPS_ER_LEARN ", 13) == 0) { if (wpa_supplicant_ctrl_iface_wps_er_learn(wpa_s, buf + 13))