[PATCH 3/6] Add wpa_supplicant_ctrl_req_from_string()
Dan Williams
dcbw
Mon Oct 24 09:04:40 PDT 2011
Converts from a string to a control request enum when input
from a control interface is received. Will be used by a
subsequent patch.
Signed-off-by: Dan Williams <dcbw at redhat.com>
---
src/common/defs.h | 1 +
wpa_supplicant/wpas_glue.c | 17 +++++++++++++++++
wpa_supplicant/wpas_glue.h | 3 +++
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/common/defs.h b/src/common/defs.h
index 839b981..21cce20 100644
--- a/src/common/defs.h
+++ b/src/common/defs.h
@@ -271,6 +271,7 @@ enum hostapd_hw_mode {
* enum wpa_ctrl_req - Control interface requests
*/
typedef enum {
+ WPA_CTRL_REQ_UNKNOWN,
WPA_CTRL_REQ_EAP_IDENTITY,
WPA_CTRL_REQ_EAP_PASSWORD,
WPA_CTRL_REQ_EAP_NEW_PASSWORD,
diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c
index 4f6884d..635bd5b 100644
--- a/wpa_supplicant/wpas_glue.c
+++ b/wpa_supplicant/wpas_glue.c
@@ -586,6 +586,23 @@ static int wpa_supplicant_tdls_peer_addset(
#endif /* CONFIG_TDLS */
+wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field)
+{
+ if (os_strcmp(field, "IDENTITY") == 0)
+ return WPA_CTRL_REQ_EAP_IDENTITY;
+ else if (os_strcmp(field, "PASSWORD") == 0)
+ return WPA_CTRL_REQ_EAP_PASSWORD;
+ else if (os_strcmp(field, "NEW_PASSWORD") == 0)
+ return WPA_CTRL_REQ_EAP_NEW_PASSWORD;
+ else if (os_strcmp(field, "PIN") == 0)
+ return WPA_CTRL_REQ_EAP_PIN;
+ else if (os_strcmp(field, "OTP") == 0)
+ return WPA_CTRL_REQ_EAP_OTP;
+ else if (os_strcmp(field, "PASSPHRASE") == 0)
+ return WPA_CTRL_REQ_EAP_PASSPHRASE;
+ return WPA_CTRL_REQ_UNKNOWN;
+}
+
const char *wpa_supplicant_ctrl_req_to_string(wpa_ctrl_req_type field,
const char *default_txt, const char **txt)
diff --git a/wpa_supplicant/wpas_glue.h b/wpa_supplicant/wpas_glue.h
index 4f66be9..fb67721 100644
--- a/wpa_supplicant/wpas_glue.h
+++ b/wpa_supplicant/wpas_glue.h
@@ -15,6 +15,8 @@
#ifndef WPAS_GLUE_H
#define WPAS_GLUE_H
+#include "common/defs.h"
+
int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s);
int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s);
void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
@@ -22,4 +24,5 @@ void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
const char *wpa_supplicant_ctrl_req_to_string(wpa_ctrl_req_type field,
const char *default_txt, const char **txt);
+wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field);
#endif /* WPAS_GLUE_H */
--
1.7.6.4
More information about the Hostap
mailing list