struct wpa_supplicant * wapi_supplicant_init(struct wpa_supplicant *wpa_s) { g_wpa_s = wpa_s; for (;;) { wpa_s->l2_wapi = l2_packet_init( wpa_s->ifname, wpa_drv_get_mac_addr(wpa_s), ETH_P_WAI, wapi_supplicant_rx_wai, wpa_s, 0); wpa_printf(MSG_INFO, "%s: Init WAPI packet %s\n", __func__, wpa_s->ifname); if (wpa_s->l2_wapi) { break; } sleep(5); } if (l2_packet_get_own_addr(wpa_s->l2_wapi, wpa_s->own_addr)) { fprintf(stderr, "Failed to get own L2 address\n"); return NULL; } wpa_printf(MSG_DEBUG, "Own MAC address: " MACSTR, MAC2STR(wpa_s->own_addr)); WIFI_lib_init(); return wpa_s; }
int rsn_preauth_init(struct wpa_supplicant *wpa_s, u8 *dst) { struct eapol_config eapol_conf; struct eapol_ctx *ctx; if (wpa_s->preauth_eapol) return -1; wpa_msg(wpa_s, MSG_DEBUG, "RSN: starting pre-authentication with " MACSTR, MAC2STR(dst)); wpa_s->l2_preauth = l2_packet_init(wpa_s->ifname, wpa_drv_get_mac_addr(wpa_s), ETH_P_RSN_PREAUTH, rsn_preauth_receive, wpa_s); if (wpa_s->l2_preauth == NULL) { wpa_printf(MSG_WARNING, "RSN: Failed to initialize L2 packet " "processing for pre-authentication"); return -2; } ctx = malloc(sizeof(*ctx)); if (ctx == NULL) { wpa_printf(MSG_WARNING, "Failed to allocate EAPOL context."); return -4; } memset(ctx, 0, sizeof(*ctx)); ctx->ctx = wpa_s; ctx->preauth = 1; ctx->cb = rsn_preauth_eapol_cb; ctx->cb_ctx = wpa_s; ctx->scard_ctx = wpa_s->scard; ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done; ctx->eapol_send = wpa_eapol_send_preauth; wpa_s->preauth_eapol = eapol_sm_init(ctx); if (wpa_s->preauth_eapol == NULL) { free(ctx); wpa_printf(MSG_WARNING, "RSN: Failed to initialize EAPOL " "state machines for pre-authentication"); return -3; } memset(&eapol_conf, 0, sizeof(eapol_conf)); eapol_conf.accept_802_1x_keys = 0; eapol_conf.required_keys = 0; eapol_conf.fast_reauth = wpa_s->conf->fast_reauth; if (wpa_s->current_ssid) eapol_conf.workaround = wpa_s->current_ssid->eap_workaround; eapol_sm_notify_config(wpa_s->preauth_eapol, wpa_s->current_ssid, &eapol_conf); memcpy(wpa_s->preauth_bssid, dst, ETH_ALEN); eapol_sm_notify_portValid(wpa_s->preauth_eapol, TRUE); /* 802.1X::portControl = Auto */ eapol_sm_notify_portEnabled(wpa_s->preauth_eapol, TRUE); eloop_register_timeout(60, 0, rsn_preauth_timeout, wpa_s, NULL); return 0; }