aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2008-11-28 18:02:32 (GMT)
committerJouni Malinen <j@w1.fi>2008-11-28 18:02:32 (GMT)
commitbcbbc7af45cc4b84a5c10e65f4283fdf68cd785a (patch)
tree7d110829491964ba3094be1adab76dfd1bfc8b93 /src
parentfa201b694f55194331d99877b6c64058c1ebd990 (diff)
downloadhostap-bcbbc7af45cc4b84a5c10e65f4283fdf68cd785a.zip
hostap-bcbbc7af45cc4b84a5c10e65f4283fdf68cd785a.tar.gz
hostap-bcbbc7af45cc4b84a5c10e65f4283fdf68cd785a.tar.bz2
WPS: Merged two cred_cb variables into the same one
Previously, wpa_supplicant as Enrollee case was handled using a different callback function pointer. However, now that the wps_context structure is allocated for all cases, the same variable can be used in all cases.
Diffstat (limited to 'src')
-rw-r--r--src/eap_peer/eap.h2
-rw-r--r--src/eap_peer/eap_wsc.c8
-rw-r--r--src/eapol_supp/eapol_supp_sm.c2
-rw-r--r--src/eapol_supp/eapol_supp_sm.h2
-rw-r--r--src/wps/wps.c3
-rw-r--r--src/wps/wps.h3
-rw-r--r--src/wps/wps_enrollee.c4
-rw-r--r--src/wps/wps_i.h3
-rw-r--r--src/wps/wps_registrar.c4
9 files changed, 9 insertions, 22 deletions
diff --git a/src/eap_peer/eap.h b/src/eap_peer/eap.h
index a23f88a..00a8f76 100644
--- a/src/eap_peer/eap.h
+++ b/src/eap_peer/eap.h
@@ -223,7 +223,7 @@ struct eapol_callbacks {
* new credentials. This can be left %NULL if no WPS functionality is
* enabled.
*/
- int (*wps_cred)(void *ctx, struct wps_credential *cred);
+ int (*wps_cred)(void *ctx, const struct wps_credential *cred);
/**
* eap_param_needed - Notify that EAP parameter is needed
diff --git a/src/eap_peer/eap_wsc.c b/src/eap_peer/eap_wsc.c
index dd47e9c..13bd768 100644
--- a/src/eap_peer/eap_wsc.c
+++ b/src/eap_peer/eap_wsc.c
@@ -68,8 +68,6 @@ static void eap_wsc_state(struct eap_wsc_data *data, int state)
static int eap_wsc_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
size_t psk_len)
{
- /* struct eap_wsc_data *data = ctx; */
-
wpa_printf(MSG_DEBUG, "EAP-WSC: Received new WPA/WPA2-PSK from WPS for"
" STA " MACSTR, MAC2STR(mac_addr));
wpa_hexdump_key(MSG_DEBUG, "Per-device PSK", psk, psk_len);
@@ -83,7 +81,6 @@ static int eap_wsc_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
static void eap_wsc_pin_needed_cb(void *ctx, const u8 *uuid_e,
const struct wps_device_data *dev)
{
- /* struct eap_wsc_data *data = ctx; */
char uuid[40], txt[400];
int len;
if (uuid_bin2str(uuid_e, uuid, sizeof(uuid)))
@@ -138,7 +135,8 @@ static void * eap_wsc_init(struct eap_sm *sm)
}
data->wps_ctx = wps;
- wps->cb_ctx = data;
+ wps->cb_ctx = sm->eapol_ctx;
+ wps->cred_cb = sm->eapol_cb->wps_cred;
/* TODO: store wps_context at higher layer and make the device data
* configurable */
@@ -212,8 +210,6 @@ static void * eap_wsc_init(struct eap_sm *sm)
os_memcpy(wps->uuid, sm->uuid, UUID_LEN);
else
cfg.uuid = sm->uuid;
- cfg.wps_cred_cb = sm->eapol_cb->wps_cred;
- cfg.cb_ctx = sm->eapol_ctx;
data->wps = wps_init(&cfg);
if (data->wps == NULL) {
os_free(data);
diff --git a/src/eapol_supp/eapol_supp_sm.c b/src/eapol_supp/eapol_supp_sm.c
index 3ae5e15..5c06987 100644
--- a/src/eapol_supp/eapol_supp_sm.c
+++ b/src/eapol_supp/eapol_supp_sm.c
@@ -1743,7 +1743,7 @@ static void eapol_sm_notify_pending(void *ctx)
#ifdef CONFIG_WPS
-static int eapol_sm_wps_cred(void *ctx, struct wps_credential *cred)
+static int eapol_sm_wps_cred(void *ctx, const struct wps_credential *cred)
{
struct eapol_sm *sm = ctx;
wpa_printf(MSG_DEBUG, "EAPOL: received new WPS credential");
diff --git a/src/eapol_supp/eapol_supp_sm.h b/src/eapol_supp/eapol_supp_sm.h
index 637a1a4..601ff38 100644
--- a/src/eapol_supp/eapol_supp_sm.h
+++ b/src/eapol_supp/eapol_supp_sm.h
@@ -223,7 +223,7 @@ struct eapol_ctx {
* new credentials. This can be left %NULL if no WPS functionality is
* enabled.
*/
- int (*wps_cred)(void *ctx, struct wps_credential *cred);
+ int (*wps_cred)(void *ctx, const struct wps_credential *cred);
/**
* eap_param_needed - Notify that EAP parameter is needed
diff --git a/src/wps/wps.c b/src/wps/wps.c
index 0c95a38..2b3751d 100644
--- a/src/wps/wps.c
+++ b/src/wps/wps.c
@@ -58,9 +58,6 @@ struct wps_data * wps_init(const struct wps_config *cfg)
data->dev_password_len = 8;
}
- data->wps_cred_cb = cfg->wps_cred_cb;
- data->cb_ctx = cfg->cb_ctx;
-
data->state = data->registrar ? RECV_M1 : SEND_M1;
return data;
diff --git a/src/wps/wps.h b/src/wps/wps.h
index 68b000a..3965acb 100644
--- a/src/wps/wps.h
+++ b/src/wps/wps.h
@@ -47,9 +47,6 @@ struct wps_config {
size_t pin_len;
const u8 *uuid; /* 128-bit Enrollee UUID (NULL for Registrar) */
int pbc;
-
- int (*wps_cred_cb)(void *ctx, struct wps_credential *cred);
- void *cb_ctx;
};
struct wps_data * wps_init(const struct wps_config *cfg);
diff --git a/src/wps/wps_enrollee.c b/src/wps/wps_enrollee.c
index 840ec09..d89ca3d 100644
--- a/src/wps/wps_enrollee.c
+++ b/src/wps/wps_enrollee.c
@@ -674,8 +674,8 @@ static int wps_process_cred_e(struct wps_data *wps, const u8 *cred,
wps_process_cred(&attr, &wps->cred))
return -1;
- if (wps->wps_cred_cb)
- wps->wps_cred_cb(wps->cb_ctx, &wps->cred);
+ if (wps->wps->cred_cb)
+ wps->wps->cred_cb(wps->wps->cb_ctx, &wps->cred);
return 0;
}
diff --git a/src/wps/wps_i.h b/src/wps/wps_i.h
index 8a057db..806ba9f 100644
--- a/src/wps/wps_i.h
+++ b/src/wps/wps_i.h
@@ -67,9 +67,6 @@ struct wps_data {
int wps_pin_revealed;
struct wps_credential cred;
- int (*wps_cred_cb)(void *ctx, struct wps_credential *cred);
- void *cb_ctx;
-
struct wps_device_data peer_dev;
};
diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c
index d1eba82..7f32702 100644
--- a/src/wps/wps_registrar.c
+++ b/src/wps/wps_registrar.c
@@ -1986,8 +1986,8 @@ static enum wps_process_res wps_process_wsc_done(struct wps_data *wps,
if (!wps->wps->ap) {
wpa_printf(MSG_DEBUG, "WPS: Update local configuration based "
"on the modified AP configuration");
- if (wps->wps_cred_cb)
- wps->wps_cred_cb(wps->cb_ctx, &wps->cred);
+ if (wps->wps->cred_cb)
+ wps->wps->cred_cb(wps->wps->cb_ctx, &wps->cred);
}
if (wps->new_psk) {