contrib/hostapd/hostapd/ieee802_1x.c
void ieee802_1x_new_station(struct hostapd_data *hapd, struct sta_info *sta)
{
	struct rsn_pmksa_cache_entry *pmksa;
	int reassoc = 1;
	int force_1x = 0;

#ifdef CONFIG_WPS
	if (hapd->conf->wps_state && hapd->conf->wpa &&
	    (sta->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS))) {
		/*
		 * Need to enable IEEE 802.1X/EAPOL state machines for possible
		 * WPS handshake even if IEEE 802.1X/EAPOL is not used for
		 * authentication in this BSS.
		 */
		force_1x = 1;
	}
#endif /* CONFIG_WPS */

	if ((!force_1x && !hapd->conf->ieee802_1x) ||
	    wpa_key_mgmt_wpa_psk(wpa_auth_sta_key_mgmt(sta->wpa_sm)))
		return;

	if (sta->eapol_sm == NULL) {
		hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
			       HOSTAPD_LEVEL_DEBUG, "start authentication");
		sta->eapol_sm = eapol_auth_alloc(hapd->eapol_auth, sta->addr,
						 sta->flags & WLAN_STA_PREAUTH,
						 sta);
		if (sta->eapol_sm == NULL) {
			hostapd_logger(hapd, sta->addr,
				       HOSTAPD_MODULE_IEEE8021X,
				       HOSTAPD_LEVEL_INFO,
				       "failed to allocate state machine");
			return;
		}
		reassoc = 0;
	}

#ifdef CONFIG_WPS
	sta->eapol_sm->flags &= ~EAPOL_SM_WAIT_START;
	if (!hapd->conf->ieee802_1x && !(sta->flags & WLAN_STA_WPS)) {
		/*
		 * Delay EAPOL frame transmission until a possible WPS
		 * initiates the handshake with EAPOL-Start.
		 */
		sta->eapol_sm->flags |= EAPOL_SM_WAIT_START;
	}
#endif /* CONFIG_WPS */

	sta->eapol_sm->eap_if->portEnabled = TRUE;

	pmksa = wpa_auth_sta_get_pmksa(sta->wpa_sm);
	if (pmksa) {
		int old_vlanid;

		hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
			       HOSTAPD_LEVEL_DEBUG,
			       "PMK from PMKSA cache - skip IEEE 802.1X/EAP");
		/* Setup EAPOL state machines to already authenticated state
		 * because of existing PMKSA information in the cache. */
		sta->eapol_sm->keyRun = TRUE;
		sta->eapol_sm->eap_if->eapKeyAvailable = TRUE;
		sta->eapol_sm->auth_pae_state = AUTH_PAE_AUTHENTICATING;
		sta->eapol_sm->be_auth_state = BE_AUTH_SUCCESS;
		sta->eapol_sm->authSuccess = TRUE;
		if (sta->eapol_sm->eap)
			eap_sm_notify_cached(sta->eapol_sm->eap);
		old_vlanid = sta->vlan_id;
		pmksa_cache_to_eapol_data(pmksa, sta->eapol_sm);
		if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
			sta->vlan_id = 0;
		ap_sta_bind_vlan(hapd, sta, old_vlanid);
	} else {
		if (reassoc) {
			/*
			 * Force EAPOL state machines to start
			 * re-authentication without having to wait for the
			 * Supplicant to send EAPOL-Start.
			 */
			sta->eapol_sm->reAuthenticate = TRUE;
		}
		eapol_auth_step(sta->eapol_sm);
	}
}
/**
 * ieee802_1x_new_station - Start IEEE 802.1X authentication
 * @hapd: hostapd BSS data
 * @sta: The station
 *
 * This function is called to start IEEE 802.1X authentication when a new
 * station completes IEEE 802.11 association.
 */
Start IEEE 802.1X authentication
@hapd: hostapd BSS data
@sta: The station

This function is called to start IEEE 802.1X authentication when a new
station completes IEEE 802.11 association.
Start IEEE 802 . 1X authentication @hapd : hostapd BSS data @sta : The station This function is called to start IEEE 802 . 1X authentication when a new station completes IEEE 802 . 11 association .
void ieee802_1x_new_station(struct hostapd_data *hapd, struct sta_info *sta)
{
	struct rsn_pmksa_cache_entry *pmksa;
	int reassoc = 1;
	int force_1x = 0;
#ifdef CONFIG_WPS
	if (hapd->conf->wps_state && hapd->conf->wpa &&
	    (sta->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS))) {
		force_1x = 1;
	}
#endif 
	if ((!force_1x && !hapd->conf->ieee802_1x) ||
	    wpa_key_mgmt_wpa_psk(wpa_auth_sta_key_mgmt(sta->wpa_sm)))
		return;
	if (sta->eapol_sm == NULL) {
		hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
			       HOSTAPD_LEVEL_DEBUG, "start authentication");
		sta->eapol_sm = eapol_auth_alloc(hapd->eapol_auth, sta->addr,
						 sta->flags & WLAN_STA_PREAUTH,
						 sta);
		if (sta->eapol_sm == NULL) {
			hostapd_logger(hapd, sta->addr,
				       HOSTAPD_MODULE_IEEE8021X,
				       HOSTAPD_LEVEL_INFO,
				       "failed to allocate state machine");
			return;
		}
		reassoc = 0;
	}
#ifdef CONFIG_WPS
	sta->eapol_sm->flags &= ~EAPOL_SM_WAIT_START;
	if (!hapd->conf->ieee802_1x && !(sta->flags & WLAN_STA_WPS)) {
		sta->eapol_sm->flags |= EAPOL_SM_WAIT_START;
	}
#endif 
	sta->eapol_sm->eap_if->portEnabled = TRUE;
	pmksa = wpa_auth_sta_get_pmksa(sta->wpa_sm);
	if (pmksa) {
		int old_vlanid;
		hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
			       HOSTAPD_LEVEL_DEBUG,
			       "PMK from PMKSA cache - skip IEEE 802.1X/EAP");
		sta->eapol_sm->keyRun = TRUE;
		sta->eapol_sm->eap_if->eapKeyAvailable = TRUE;
		sta->eapol_sm->auth_pae_state = AUTH_PAE_AUTHENTICATING;
		sta->eapol_sm->be_auth_state = BE_AUTH_SUCCESS;
		sta->eapol_sm->authSuccess = TRUE;
		if (sta->eapol_sm->eap)
			eap_sm_notify_cached(sta->eapol_sm->eap);
		old_vlanid = sta->vlan_id;
		pmksa_cache_to_eapol_data(pmksa, sta->eapol_sm);
		if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
			sta->vlan_id = 0;
		ap_sta_bind_vlan(hapd, sta, old_vlanid);
	} else {
		if (reassoc) {
			sta->eapol_sm->reAuthenticate = TRUE;
		}
		eapol_auth_step(sta->eapol_sm);
	}
}
void ieee802_1x_new_station ( struct hostapd_data * hapd , struct sta_info * sta ) { struct rsn_pmksa_cache_entry * pmksa ; int reassoc = 1 ; int force_1x = 0 ; #ifdef CONFIG_WPS if ( hapd -> conf -> wps_state && hapd -> conf -> wpa && ( sta -> flags & ( WLAN_STA_WPS | WLAN_STA_MAYBE_WPS ) ) ) { force_1x = 1 ; } #endif if ( ( ! force_1x && ! hapd -> conf -> ieee802_1x ) || wpa_key_mgmt_wpa_psk ( wpa_auth_sta_key_mgmt ( sta -> wpa_sm ) ) ) return ; if ( sta -> eapol_sm == NULL ) { hostapd_logger ( hapd , sta -> addr , HOSTAPD_MODULE_IEEE8021X , HOSTAPD_LEVEL_DEBUG , " " ) ; sta -> eapol_sm = eapol_auth_alloc ( hapd -> eapol_auth , sta -> addr , sta -> flags & WLAN_STA_PREAUTH , sta ) ; if ( sta -> eapol_sm == NULL ) { hostapd_logger ( hapd , sta -> addr , HOSTAPD_MODULE_IEEE8021X , HOSTAPD_LEVEL_INFO , " " ) ; return ; } reassoc = 0 ; } #ifdef CONFIG_WPS sta -> eapol_sm -> flags &= ~ EAPOL_SM_WAIT_START ; if ( ! hapd -> conf -> ieee802_1x && ! ( sta -> flags & WLAN_STA_WPS ) ) { sta -> eapol_sm -> flags |= EAPOL_SM_WAIT_START ; } #endif sta -> eapol_sm -> eap_if -> portEnabled = TRUE ; pmksa = wpa_auth_sta_get_pmksa ( sta -> wpa_sm ) ; if ( pmksa ) { int old_vlanid ; hostapd_logger ( hapd , sta -> addr , HOSTAPD_MODULE_IEEE8021X , HOSTAPD_LEVEL_DEBUG , " " ) ; sta -> eapol_sm -> keyRun = TRUE ; sta -> eapol_sm -> eap_if -> eapKeyAvailable = TRUE ; sta -> eapol_sm -> auth_pae_state = AUTH_PAE_AUTHENTICATING ; sta -> eapol_sm -> be_auth_state = BE_AUTH_SUCCESS ; sta -> eapol_sm -> authSuccess = TRUE ; if ( sta -> eapol_sm -> eap ) eap_sm_notify_cached ( sta -> eapol_sm -> eap ) ; old_vlanid = sta -> vlan_id ; pmksa_cache_to_eapol_data ( pmksa , sta -> eapol_sm ) ; if ( sta -> ssid -> dynamic_vlan == DYNAMIC_VLAN_DISABLED ) sta -> vlan_id = 0 ; ap_sta_bind_vlan ( hapd , sta , old_vlanid ) ; } else { if ( reassoc ) { sta -> eapol_sm -> reAuthenticate = TRUE ; } eapol_auth_step ( sta -> eapol_sm ) ; } }
ieee802_1x_new_station - Start IEEE 802.1X authentication
 @hapd: hostapd BSS data
 @sta: The station
ieee802_1x_new_station - Start IEEE 802 . 1X authentication @hapd : hostapd BSS data @sta : The station
/*
		 * Need to enable IEEE 802.1X/EAPOL state machines for possible
		 * WPS handshake even if IEEE 802.1X/EAPOL is not used for
		 * authentication in this BSS.
		 */ /* CONFIG_WPS */ /*
		 * Delay EAPOL frame transmission until a possible WPS
		 * initiates the handshake with EAPOL-Start.
		 */ /* CONFIG_WPS */ /* Setup EAPOL state machines to already authenticated state
		 * because of existing PMKSA information in the cache. */ /*
			 * Force EAPOL state machines to start
			 * re-authentication without having to wait for the
			 * Supplicant to send EAPOL-Start.
			 */