!(fc & WLAN_FC_ISWEP)) { 
!(fc & IEEE80211_FCTL_WEP)) { 
static void handle_authen(local_info_t *local, struct sk_buff *skb,			  struct hostap_80211_rx_status *rx_stats){	struct net_device *dev = local->dev;	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;	size_t hdrlen;	struct ap_data *ap = local->ap;	char body[8 + WLAN_AUTH_CHALLENGE_LEN], *challenge = NULL;	int len, olen;	u16 auth_alg, auth_transaction, status_code, *pos;	u16 resp = WLAN_STATUS_SUCCESS, fc;	struct sta_info *sta = NULL;	struct ieee80211_crypt_data *crypt;	char *txt = "";	len = skb->len - IEEE80211_MGMT_HDR_LEN;	fc = le16_to_cpu(hdr->frame_ctl);	hdrlen = hostap_80211_get_hdrlen(fc);	if (len < 6) {		PDEBUG(DEBUG_AP, "%s: handle_authen - too short payload "		       "(len=%d) from " MACSTR "\n", dev->name, len,		       MAC2STR(hdr->addr2));		return;	}	spin_lock_bh(&local->ap->sta_table_lock);	sta = ap_get_sta(local->ap, hdr->addr2);	if (sta)		atomic_inc(&sta->users);	spin_unlock_bh(&local->ap->sta_table_lock);	if (sta && sta->crypt)		crypt = sta->crypt;	else {		int idx = 0;		if (skb->len >= hdrlen + 3)			idx = skb->data[hdrlen + 3] >> 6;		crypt = local->crypt[idx];	}	pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);	auth_alg = __le16_to_cpu(*pos);	pos++;	auth_transaction = __le16_to_cpu(*pos);	pos++;	status_code = __le16_to_cpu(*pos);	pos++;	if (memcmp(dev->dev_addr, hdr->addr2, ETH_ALEN) == 0 ||	    ap_control_mac_deny(&ap->mac_restrictions, hdr->addr2)) {		txt = "authentication denied";		resp = WLAN_STATUS_UNSPECIFIED_FAILURE;		goto fail;	}	if (((local->auth_algs & PRISM2_AUTH_OPEN) &&	     auth_alg == WLAN_AUTH_OPEN) ||	    ((local->auth_algs & PRISM2_AUTH_SHARED_KEY) &&	     crypt && auth_alg == WLAN_AUTH_SHARED_KEY)) {	} else {		txt = "unsupported algorithm";		resp = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;		goto fail;	}	if (len >= 8) {		u8 *u = (u8 *) pos;		if (*u == WLAN_EID_CHALLENGE) {			if (*(u + 1) != WLAN_AUTH_CHALLENGE_LEN) {				txt = "invalid challenge len";				resp = WLAN_STATUS_CHALLENGE_FAIL;				goto fail;			}			if (len - 8 < WLAN_AUTH_CHALLENGE_LEN) {				txt = "challenge underflow";				resp = WLAN_STATUS_CHALLENGE_FAIL;				goto fail;			}			challenge = (char *) (u + 2);		}	}	if (sta && sta->ap) {		if (time_after(jiffies, sta->u.ap.last_beacon +			       (10 * sta->listen_interval * HZ) / 1024)) {			PDEBUG(DEBUG_AP, "%s: no beacons received for a while,"			       " assuming AP " MACSTR " is now STA\n",			       dev->name, MAC2STR(sta->addr));			sta->ap = 0;			sta->flags = 0;			sta->u.sta.challenge = NULL;		} else {			txt = "AP trying to authenticate?";			resp = WLAN_STATUS_UNSPECIFIED_FAILURE;			goto fail;		}	}	if ((auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) ||	    (auth_alg == WLAN_AUTH_SHARED_KEY &&	     (auth_transaction == 1 ||	      (auth_transaction == 3 && sta != NULL &&	       sta->u.sta.challenge != NULL)))) {	} else {		txt = "unknown authentication transaction number";		resp = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION;		goto fail;	}	if (sta == NULL) {		txt = "new STA";		if (local->ap->num_sta >= MAX_STA_COUNT) {			/* FIX: might try to remove some old STAs first? */			txt = "no more room for new STAs";			resp = WLAN_STATUS_UNSPECIFIED_FAILURE;			goto fail;		}		sta = ap_add_sta(local->ap, hdr->addr2);		if (sta == NULL) {			txt = "ap_add_sta failed";			resp = WLAN_STATUS_UNSPECIFIED_FAILURE;			goto fail;		}	}	switch (auth_alg) {	case WLAN_AUTH_OPEN:		txt = "authOK";		/* IEEE 802.11 standard is not completely clear about		 * whether STA is considered authenticated after		 * authentication OK frame has been send or after it		 * has been ACKed. In order to reduce interoperability		 * issues, mark the STA authenticated before ACK. */		sta->flags |= WLAN_STA_AUTH;		break;	case WLAN_AUTH_SHARED_KEY:		if (auth_transaction == 1) {			if (sta->u.sta.challenge == NULL) {				sta->u.sta.challenge =					ap_auth_make_challenge(local->ap);				if (sta->u.sta.challenge == NULL) {					resp = WLAN_STATUS_UNSPECIFIED_FAILURE;					goto fail;				}			}		} else {			if (sta->u.sta.challenge == NULL ||			    challenge == NULL ||			    memcmp(sta->u.sta.challenge, challenge,				   WLAN_AUTH_CHALLENGE_LEN) != 0 ||			    !(fc & WLAN_FC_ISWEP)) {				txt = "challenge response incorrect";				resp = WLAN_STATUS_CHALLENGE_FAIL;				goto fail;			}			txt = "challenge OK - authOK";			/* IEEE 802.11 standard is not completely clear about			 * whether STA is considered authenticated after			 * authentication OK frame has been send or after it			 * has been ACKed. In order to reduce interoperability			 * issues, mark the STA authenticated before ACK. */			sta->flags |= WLAN_STA_AUTH;			kfree(sta->u.sta.challenge);			sta->u.sta.challenge = NULL;		}		break;	} fail:	pos = (u16 *) body;	*pos = cpu_to_le16(auth_alg);	pos++;	*pos = cpu_to_le16(auth_transaction + 1);	pos++;	*pos = cpu_to_le16(resp); /* status_code */	pos++;	olen = 6;	if (resp == WLAN_STATUS_SUCCESS && sta != NULL &&	    sta->u.sta.challenge != NULL &&	    auth_alg == WLAN_AUTH_SHARED_KEY && auth_transaction == 1) {		u8 *tmp = (u8 *) pos;		*tmp++ = WLAN_EID_CHALLENGE;		*tmp++ = WLAN_AUTH_CHALLENGE_LEN;		pos++;		memcpy(pos, sta->u.sta.challenge, WLAN_AUTH_CHALLENGE_LEN);		olen += 2 + WLAN_AUTH_CHALLENGE_LEN;	}	prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH,			 body, olen, hdr->addr2, ap->tx_callback_auth);	if (sta) {		sta->last_rx = jiffies;		atomic_dec(&sta->users);	}	if (resp) {		PDEBUG(DEBUG_AP, "%s: " MACSTR " auth (alg=%d trans#=%d "		       "stat=%d len=%d fc=%04x) ==> %d (%s)\n",		       dev->name, MAC2STR(hdr->addr2), auth_alg,		       auth_transaction, status_code, len, fc, resp, txt);	}}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/b2f4a2e3b1620667da9654f9e220c92ea52bdbe4/hostap_ap.c/clean/drivers/net/wireless/hostap/hostap_ap.c