-static void ieee802_11_sta_authenticate(void *eloop_ctx, void *timeout_ctx)
-{
- struct hostapd_data *hapd = eloop_ctx;
- struct ieee80211_mgmt mgmt;
- char ssid_txt[33];
-
- if (hapd->assoc_ap_state == WAIT_BEACON)
- hapd->assoc_ap_state = AUTHENTICATE;
- if (hapd->assoc_ap_state != AUTHENTICATE)
- return;
-
- ieee802_11_print_ssid(ssid_txt, (u8 *) hapd->assoc_ap_ssid,
- hapd->assoc_ap_ssid_len);
- printf("Authenticate with AP " MACSTR " SSID=%s (as station)\n",
- MAC2STR(hapd->conf->assoc_ap_addr), ssid_txt);
-
- os_memset(&mgmt, 0, sizeof(mgmt));
- mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
- WLAN_FC_STYPE_AUTH);
- /* Request TX callback */
- mgmt.frame_control |= host_to_le16(BIT(1));
- os_memcpy(mgmt.da, hapd->conf->assoc_ap_addr, ETH_ALEN);
- os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
- os_memcpy(mgmt.bssid, hapd->conf->assoc_ap_addr, ETH_ALEN);
- mgmt.u.auth.auth_alg = host_to_le16(WLAN_AUTH_OPEN);
- mgmt.u.auth.auth_transaction = host_to_le16(1);
- mgmt.u.auth.status_code = host_to_le16(0);
- if (hostapd_send_mgmt_frame(hapd, &mgmt, IEEE80211_HDRLEN +
- sizeof(mgmt.u.auth), 0) < 0)
- perror("ieee802_11_sta_authenticate: send");
-
- /* Try to authenticate again, if this attempt fails or times out. */
- eloop_register_timeout(5, 0, ieee802_11_sta_authenticate, hapd, NULL);
-}
-
-
-static void ieee802_11_sta_associate(void *eloop_ctx, void *timeout_ctx)
-{
- struct hostapd_data *hapd = eloop_ctx;
- u8 buf[256];
- struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) buf;
- u8 *p;
- char ssid_txt[33];
-
- if (hapd->assoc_ap_state == AUTHENTICATE)
- hapd->assoc_ap_state = ASSOCIATE;
- if (hapd->assoc_ap_state != ASSOCIATE)
- return;
-
- ieee802_11_print_ssid(ssid_txt, (u8 *) hapd->assoc_ap_ssid,
- hapd->assoc_ap_ssid_len);
- printf("Associate with AP " MACSTR " SSID=%s (as station)\n",
- MAC2STR(hapd->conf->assoc_ap_addr), ssid_txt);
-
- os_memset(mgmt, 0, sizeof(*mgmt));
- mgmt->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
- WLAN_FC_STYPE_ASSOC_REQ);
- /* Request TX callback */
- mgmt->frame_control |= host_to_le16(BIT(1));
- os_memcpy(mgmt->da, hapd->conf->assoc_ap_addr, ETH_ALEN);
- os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
- os_memcpy(mgmt->bssid, hapd->conf->assoc_ap_addr, ETH_ALEN);
- mgmt->u.assoc_req.capab_info = host_to_le16(0);
- mgmt->u.assoc_req.listen_interval = host_to_le16(1);
- p = &mgmt->u.assoc_req.variable[0];
-
- *p++ = WLAN_EID_SSID;
- *p++ = hapd->assoc_ap_ssid_len;
- os_memcpy(p, hapd->assoc_ap_ssid, hapd->assoc_ap_ssid_len);
- p += hapd->assoc_ap_ssid_len;
-
- p = hostapd_eid_supp_rates(hapd, p);
- p = hostapd_eid_ext_supp_rates(hapd, p);
-
- if (hostapd_send_mgmt_frame(hapd, mgmt, p - (u8 *) mgmt, 0) < 0)
- perror("ieee802_11_sta_associate: send");
-
- /* Try to authenticate again, if this attempt fails or times out. */
- eloop_register_timeout(5, 0, ieee802_11_sta_associate, hapd, NULL);
-}
-
-