Lines Matching refs:wpa

21 #include "wpa.h"
23 #include "../hostapd/wpa.h"
30 struct wpa {
56 struct wpa *wpa = ctx;
58 return &wpa->ssid;
64 struct wpa *wpa = ctx;
66 os_memcpy(bssid, wpa->auth_addr, ETH_ALEN);
79 struct wpa *wpa = eloop_data;
82 wpa_receive(wpa->auth_group, wpa->auth, wpa->supp_eapol,
83 wpa->supp_eapol_len);
90 struct wpa *wpa = ctx;
96 os_free(wpa->supp_eapol);
97 wpa->supp_eapol = os_malloc(len);
98 if (wpa->supp_eapol == NULL)
100 os_memcpy(wpa->supp_eapol, buf, len);
101 wpa->supp_eapol_len = len;
102 eloop_register_timeout(0, 0, auth_eapol_rx, wpa, NULL);
139 struct wpa *wpa = ctx;
145 ie = wpa_auth_get_wpa_ie(wpa->auth_group, &ielen);
149 return wpa_sm_set_ap_rsn_ie(wpa->supp, ie, 2 + ie[1]);
150 return wpa_sm_set_ap_wpa_ie(wpa->supp, ie, 2 + ie[1]);
190 static int supp_init(struct wpa *wpa)
196 ctx->ctx = wpa;
207 wpa->supp = wpa_sm_init(ctx);
208 if (wpa->supp == NULL) {
213 wpa_sm_set_own_addr(wpa->supp, wpa->supp_addr);
214 wpa_sm_set_param(wpa->supp, WPA_PARAM_RSN_ENABLED, 1);
215 wpa_sm_set_param(wpa->supp, WPA_PARAM_PROTO, WPA_PROTO_RSN);
216 wpa_sm_set_param(wpa->supp, WPA_PARAM_PAIRWISE, WPA_CIPHER_CCMP);
217 wpa_sm_set_param(wpa->supp, WPA_PARAM_GROUP, WPA_CIPHER_CCMP);
218 wpa_sm_set_param(wpa->supp, WPA_PARAM_KEY_MGMT, WPA_KEY_MGMT_PSK);
219 wpa_sm_set_pmk(wpa->supp, wpa->psk, PMK_LEN);
221 wpa->supp_ie_len = sizeof(wpa->supp_ie);
222 if (wpa_sm_set_assoc_wpa_ie_default(wpa->supp, wpa->supp_ie,
223 &wpa->supp_ie_len) < 0) {
229 wpa_sm_notify_assoc(wpa->supp, wpa->auth_addr);
248 struct wpa *wpa = eloop_data;
251 wpa_sm_rx_eapol(wpa->supp, wpa->auth_addr, wpa->auth_eapol,
252 wpa->auth_eapol_len);
259 struct wpa *wpa = ctx;
265 os_free(wpa->auth_eapol);
266 wpa->auth_eapol = os_malloc(data_len);
267 if (wpa->auth_eapol == NULL)
269 os_memcpy(wpa->auth_eapol_dst, addr, ETH_ALEN);
270 os_memcpy(wpa->auth_eapol, data, data_len);
271 wpa->auth_eapol_len = data_len;
272 eloop_register_timeout(0, 0, supp_eapol_rx, wpa, NULL);
280 struct wpa *wpa = ctx;
285 return wpa->psk;
289 static int auth_init_group(struct wpa *wpa)
297 conf.wpa = 2;
305 cb.ctx = wpa;
310 wpa->auth_group = wpa_init(wpa->auth_addr, &conf, &cb);
311 if (wpa->auth_group == NULL) {
320 static int auth_init(struct wpa *wpa)
322 wpa->auth = wpa_auth_sta_init(wpa->auth_group, wpa->supp_addr);
323 if (wpa->auth == NULL) {
328 if (wpa_validate_wpa_ie(wpa->auth_group, wpa->auth, wpa->supp_ie,
329 wpa->supp_ie_len, NULL, 0) != WPA_IE_OK) {
334 wpa_auth_sm_event(wpa->auth, WPA_ASSOC);
336 wpa_auth_sta_associated(wpa->auth_group, wpa->auth);
342 static void deinit(struct wpa *wpa)
344 wpa_auth_sta_deinit(wpa->auth);
345 wpa_sm_deinit(wpa->supp);
346 wpa_deinit(wpa->auth_group);
347 os_free(wpa->auth_eapol);
348 wpa->auth_eapol = NULL;
349 os_free(wpa->supp_eapol);
350 wpa->supp_eapol = NULL;
356 struct wpa wpa;
361 os_memset(&wpa, 0, sizeof(wpa));
362 os_memset(wpa.auth_addr, 0x12, ETH_ALEN);
363 os_memset(wpa.supp_addr, 0x32, ETH_ALEN);
364 os_memset(wpa.psk, 0x44, PMK_LEN);
369 if (eloop_init(&wpa)) {
374 if (auth_init_group(&wpa) < 0)
377 if (supp_init(&wpa) < 0)
380 if (auth_init(&wpa) < 0)
387 deinit(&wpa);