/* This function will be called whenever a station associates with the AP */ void hostapd_new_assoc_sta(hostapd *hapd, struct sta_info *sta, int reassoc) { if (hapd->tkip_countermeasures) { hostapd_sta_deauth(hapd, sta->addr, WLAN_REASON_MICHAEL_MIC_FAILURE); return; } /* IEEE 802.11F (IAPP) */ if (hapd->conf->ieee802_11f) iapp_new_station(hapd->iapp, sta); /* Start accounting here, if IEEE 802.1X and WPA are not used. * IEEE 802.1X/WPA code will start accounting after the station has * been authorized. */ if (!hapd->conf->ieee802_1x && !hapd->conf->wpa) accounting_sta_start(hapd, sta); /* Start IEEE 802.1X authentication process for new stations */ ieee802_1x_new_station(hapd, sta); if (reassoc) wpa_sm_event(hapd, sta, WPA_REAUTH); else wpa_new_station(hapd, sta); }
static void rsn_preauth_receive(void *ctx, const u8 *src_addr, const u8 *buf, size_t len) { struct rsn_preauth_interface *piface = ctx; struct asd_data *wasd = piface->wasd; struct ieee802_1x_hdr *hdr; struct sta_info *sta; struct l2_ethhdr *ethhdr; asd_printf(ASD_DEFAULT,MSG_DEBUG, "RSN: receive pre-auth packet " "from interface '%s'", piface->ifname); if (len < sizeof(*ethhdr) + sizeof(*hdr)) { asd_printf(ASD_DEFAULT,MSG_DEBUG, "RSN: too short pre-auth packet " "(len=%lu)", (unsigned long) len); return; } ethhdr = (struct l2_ethhdr *) buf; hdr = (struct ieee802_1x_hdr *) (ethhdr + 1); if (os_memcmp(ethhdr->h_dest, wasd->own_addr, ETH_ALEN) != 0) { asd_printf(ASD_DEFAULT,MSG_DEBUG, "RSN: pre-auth for foreign address " MACSTR, MAC2STR(ethhdr->h_dest)); return; } sta = ap_get_sta(wasd, ethhdr->h_source); if (sta && (sta->flags & WLAN_STA_ASSOC)) { asd_printf(ASD_DEFAULT,MSG_DEBUG, "RSN: pre-auth for already association " "STA " MACSTR, MAC2STR(sta->addr)); return; } if (!sta && hdr->type == IEEE802_1X_TYPE_EAPOL_START) { sta = ap_sta_add(wasd, ethhdr->h_source ,0); if (sta == NULL) return; sta->flags = WLAN_STA_PREAUTH; ieee802_1x_new_station(wasd, sta); if (sta->eapol_sm == NULL) { //UpdateStaInfoToWSM(wasd, sta->addr, WID_DEL); if(ASD_WLAN[wasd->WlanID]!=NULL&&ASD_WLAN[wasd->WlanID]->balance_switch == 1&&ASD_WLAN[wasd->WlanID]->balance_method==1) ap_free_sta_without_wsm(wasd, sta,1); else ap_free_sta_without_wsm(wasd, sta,0); sta = NULL; } else { sta->eapol_sm->radius_identifier = -1; sta->eapol_sm->portValid = TRUE; sta->eapol_sm->flags |= EAPOL_SM_PREAUTH; } } if (sta == NULL) return; sta->preauth_iface = piface; ieee802_1x_receive(wasd, ethhdr->h_source, (u8 *) (ethhdr + 1), len - sizeof(*ethhdr)); }
static void rsn_preauth_receive(void *ctx, const u8 *src_addr, const u8 *buf, size_t len) { struct rsn_preauth_interface *piface = ctx; struct hostapd_data *hapd = piface->hapd; struct ieee802_1x_hdr *hdr; struct sta_info *sta; struct l2_ethhdr *ethhdr; HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "RSN: receive pre-auth packet " "from interface '%s'\n", piface->ifname); if (len < sizeof(*ethhdr) + sizeof(*hdr)) { HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "RSN: too short pre-auth " "packet (len=%lu)\n", (unsigned long) len); return; } ethhdr = (struct l2_ethhdr *) buf; hdr = (struct ieee802_1x_hdr *) (ethhdr + 1); if (memcmp(ethhdr->h_dest, hapd->own_addr, ETH_ALEN) != 0) { HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "RSN: pre-auth for " "foreign address " MACSTR "\n", MAC2STR(ethhdr->h_dest)); return; } sta = ap_get_sta(hapd, ethhdr->h_source); if (sta && (sta->flags & WLAN_STA_ASSOC)) { HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "RSN: pre-auth for " "already association STA " MACSTR "\n", MAC2STR(sta->addr)); return; } if (!sta && hdr->type == IEEE802_1X_TYPE_EAPOL_START) { sta = ap_sta_add(hapd, ethhdr->h_source); if (sta == NULL) return; sta->flags = WLAN_STA_PREAUTH; ieee802_1x_new_station(hapd, sta); if (sta->eapol_sm == NULL) { ap_free_sta(hapd, sta); sta = NULL; } else { sta->eapol_sm->radius_identifier = -1; sta->eapol_sm->portValid = TRUE; sta->eapol_sm->flags |= EAPOL_SM_PREAUTH; } } if (sta == NULL) return; sta->preauth_iface = piface; ieee802_1x_receive(hapd, ethhdr->h_source, (u8 *) (ethhdr + 1), len - sizeof(*ethhdr)); }
void hostapd_reassoc_sta(hostapd *hapd, struct sta_info *sta) { /* IEEE 802.11F (IAPP) */ if (hapd->conf->ieee802_11f) iapp_new_station(hapd->iapp, sta); /* Start accounting here, if IEEE 802.1X is not used. IEEE 802.1X code * will start accounting after the station has been authorized. */ if (!hapd->conf->ieee802_1x) accounting_sta_start(hapd, sta); /* Let 802.1x decide wether it should run or not */ ieee802_1x_new_station(hapd, sta); }
/* This function will be called whenever a station associates with the AP */ void hostapd_new_assoc_sta(hostapd *hapd, struct sta_info *sta) { /* IEEE 802.11f (IAPP) */ if (hapd->conf->ieee802_11f) iapp_new_station(hapd, sta); /* Start accounting here, if IEEE 802.1X is not used. IEEE 802.1X code * will start accounting after the station has been authorized. */ if (!hapd->conf->ieee802_1x) accounting_sta_start(hapd, sta); /* Start IEEE 802.1x authentication process for new stations */ ieee802_1x_new_station(hapd, sta); wpa_new_station(hapd, sta); }
/* This function will be called whenever a station associates with the AP */ void hostapd_new_assoc_sta(hostapd *hapd, struct sta_info *sta) { if (hapd->tkip_countermeasures) { hostapd_sta_deauth(hapd, sta->addr, WLAN_REASON_MICHAEL_MIC_FAILURE); return; } /* IEEE 802.11F (IAPP) */ if (hapd->conf->ieee802_11f) iapp_new_station(hapd->iapp, sta); /* Start accounting here, if IEEE 802.1X is not used. IEEE 802.1X code * will start accounting after the station has been authorized. */ if (!hapd->conf->ieee802_1x) accounting_sta_start(hapd, sta); #ifdef JUMPSTART if (hapd->conf->js_p1) { /* Only one STA at a time to attempt Jumpstart */ if (!hapd->jsw_profile->p1_in_progress) { hapd->jsw_profile->p1_in_progress = 1; HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "JUMPSTART: " MACSTR " %s: starting P1\n", MAC2STR(sta->addr), __func__); js_p1_new_station(hapd, sta); /* Start the JS state machine */ smSendEvent(sta->js_session, JSW_EVENT_ASSOC); } else { HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "JUMPSTART: " MACSTR "%s: P1 running with another STA." " Disassoc\n", MAC2STR(sta->addr), __func__); hostapd_sta_disassoc(hapd, sta->addr, WLAN_REASON_UNSPECIFIED); } return; } #endif /* JUMPSTART */ /* Start IEEE 802.1x authentication process for new stations */ ieee802_1x_new_station(hapd, sta); wpa_new_station(hapd, sta); }
void rsn_preauth_receive_thinap(void *ctx, const u8 *src_addr,const u8 *des_addr, const u8 *buf, size_t len) { struct asd_data *now_wasd = ctx; struct ieee802_1x_hdr *hdr; struct sta_info *sta; struct asd_data * wasd; struct PreAuth_BSSINFO *bss; struct wasd_interfaces *interfaces = (struct wasd_interfaces*) circle.user_data; unsigned int RadioID; unsigned char BSS_L_ID; bss = PreAuth_wlan_get_bss(ASD_WLAN[now_wasd->WlanID],des_addr); if(bss == NULL){ asd_printf(ASD_DEFAULT,MSG_DEBUG,"something wrong in finding bss: "MACSTR, MAC2STR(des_addr)); return; } asd_printf(ASD_DEFAULT,MSG_DEBUG,"we got bss index:%d",bss->BSSIndex); RadioID = bss->BSSIndex/L_BSS_NUM; BSS_L_ID = bss->BSSIndex%L_BSS_NUM; if((interfaces->iface[RadioID]!=NULL)&&(interfaces->iface[RadioID]->bss[BSS_L_ID]!=NULL)) wasd = interfaces->iface[RadioID]->bss[BSS_L_ID]; else return; if (len < sizeof(*hdr)) { asd_printf(ASD_DEFAULT,MSG_DEBUG, "RSN: too short pre-auth packet " "(len=%lu)", (unsigned long) len); asd_printf(ASD_DEFAULT,MSG_DEBUG,"rsn_preauth_receive_thinap RSN: too short pre-auth packet " "(len=%lu)", (unsigned long) len); return; } hdr = (struct ieee802_1x_hdr *) (buf); if (os_memcmp(des_addr, wasd->own_addr, ETH_ALEN) != 0) { asd_printf(ASD_DEFAULT,MSG_DEBUG, "RSN: pre-auth for foreign address " MACSTR, MAC2STR(des_addr)); asd_printf(ASD_DEFAULT,MSG_DEBUG,"rsn_preauth_receive_thinap RSN: pre-auth for foreign address " MACSTR, MAC2STR(des_addr)); return; } sta = ap_get_sta(wasd, src_addr); if (sta && (sta->flags & WLAN_STA_ASSOC)) { asd_printf(ASD_DEFAULT,MSG_DEBUG, "RSN: pre-auth for already association " "STA " MACSTR, MAC2STR(sta->addr)); asd_printf(ASD_DEFAULT,MSG_DEBUG,"rsn_preauth_receive_thinap RSN: pre-auth for already association " "STA " MACSTR, MAC2STR(sta->addr)); return; } if (!sta && hdr->type == IEEE802_1X_TYPE_EAPOL_START) { asd_printf(ASD_DEFAULT,MSG_DEBUG,"IEEE802_1X_TYPE_EAPOL_START\n"); sta = ap_sta_add(wasd, src_addr,0); if (sta == NULL) return; sta->flags = WLAN_STA_PREAUTH; ieee802_1x_new_station(wasd, sta); if (sta->eapol_sm == NULL) { ap_free_sta(wasd, sta,0); sta = NULL; } else { sta->eapol_sm->radius_identifier = -1; sta->eapol_sm->portValid = TRUE; sta->eapol_sm->flags |= EAPOL_SM_PREAUTH; } } if (sta == NULL) return; memcpy(sta->PreAuth_BSSID,now_wasd->own_addr,6); sta->PreAuth_BSSIndex = now_wasd->BSSIndex; asd_printf(ASD_DEFAULT,MSG_DEBUG,"ieee802_1x_receive \n"); ieee802_1x_receive(wasd, src_addr, (u8 *) (buf), len); }