prism2_send_mgmt(dev, WLAN_FC_TYPE_MGMT, (send_deauth ? WLAN_FC_STYPE_DEAUTH : (reassoc ? WLAN_FC_STYPE_REASSOC_RESP : WLAN_FC_STYPE_ASSOC_RESP)), 
prism2_send_mgmt(dev, IEEE80211_FTYPE_MGMT | (send_deauth ? IEEE80211_STYPE_DEAUTH : (reassoc ? IEEE80211_STYPE_REASSOC_RESP : IEEE80211_STYPE_ASSOC_RESP)), 
static void handle_assoc(local_info_t *local, struct sk_buff *skb,			 struct hostap_80211_rx_status *rx_stats, int reassoc){	struct net_device *dev = local->dev;	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;	char body[12], *p, *lpos;	int len, left;	u16 *pos;	u16 resp = WLAN_STATUS_SUCCESS;	struct sta_info *sta = NULL;	int send_deauth = 0;	char *txt = "";	u8 prev_ap[ETH_ALEN];	left = len = skb->len - IEEE80211_MGMT_HDR_LEN;	if (len < (reassoc ? 10 : 4)) {		PDEBUG(DEBUG_AP, "%s: handle_assoc - too short payload "		       "(len=%d, reassoc=%d) from " MACSTR "\n",		       dev->name, len, reassoc, MAC2STR(hdr->addr2));		return;	}	spin_lock_bh(&local->ap->sta_table_lock);	sta = ap_get_sta(local->ap, hdr->addr2);	if (sta == NULL || (sta->flags & WLAN_STA_AUTH) == 0) {		spin_unlock_bh(&local->ap->sta_table_lock);		txt = "trying to associate before authentication";		send_deauth = 1;		resp = WLAN_STATUS_UNSPECIFIED_FAILURE;		sta = NULL; /* do not decrement sta->users */		goto fail;	}	atomic_inc(&sta->users);	spin_unlock_bh(&local->ap->sta_table_lock);	pos = (u16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);	sta->capability = __le16_to_cpu(*pos);	pos++; left -= 2;	sta->listen_interval = __le16_to_cpu(*pos);	pos++; left -= 2;	if (reassoc) {		memcpy(prev_ap, pos, ETH_ALEN);		pos++; pos++; pos++; left -= 6;	} else		memset(prev_ap, 0, ETH_ALEN);	if (left >= 2) {		unsigned int ileft;		unsigned char *u = (unsigned char *) pos;		if (*u == WLAN_EID_SSID) {			u++; left--;			ileft = *u;			u++; left--;			if (ileft > left || ileft > MAX_SSID_LEN) {				txt = "SSID overflow";				resp = WLAN_STATUS_UNSPECIFIED_FAILURE;				goto fail;			}			if (ileft != strlen(local->essid) ||			    memcmp(local->essid, u, ileft) != 0) {				txt = "not our SSID";				resp = WLAN_STATUS_ASSOC_DENIED_UNSPEC;				goto fail;			}			u += ileft;			left -= ileft;		}		if (left >= 2 && *u == WLAN_EID_SUPP_RATES) {			u++; left--;			ileft = *u;			u++; left--;			if (ileft > left || ileft == 0 ||			    ileft > WLAN_SUPP_RATES_MAX) {				txt = "SUPP_RATES len error";				resp = WLAN_STATUS_UNSPECIFIED_FAILURE;				goto fail;			}			memset(sta->supported_rates, 0,			       sizeof(sta->supported_rates));			memcpy(sta->supported_rates, u, ileft);			prism2_check_tx_rates(sta);			u += ileft;			left -= ileft;		}		if (left > 0) {			PDEBUG(DEBUG_AP, "%s: assoc from " MACSTR " with extra"			       " data (%d bytes) [",			       dev->name, MAC2STR(hdr->addr2), left);			while (left > 0) {				PDEBUG2(DEBUG_AP, "<%02x>", *u);				u++; left--;			}			PDEBUG2(DEBUG_AP, "]\n");		}	} else {		txt = "frame underflow";		resp = WLAN_STATUS_UNSPECIFIED_FAILURE;		goto fail;	}	/* get a unique AID */	if (sta->aid > 0)		txt = "OK, old AID";	else {		spin_lock_bh(&local->ap->sta_table_lock);		for (sta->aid = 1; sta->aid <= MAX_AID_TABLE_SIZE; sta->aid++)			if (local->ap->sta_aid[sta->aid - 1] == NULL)				break;		if (sta->aid > MAX_AID_TABLE_SIZE) {			sta->aid = 0;			spin_unlock_bh(&local->ap->sta_table_lock);			resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;			txt = "no room for more AIDs";		} else {			local->ap->sta_aid[sta->aid - 1] = sta;			spin_unlock_bh(&local->ap->sta_table_lock);			txt = "OK, new AID";		}	} fail:	pos = (u16 *) body;	if (send_deauth) {		*pos = __constant_cpu_to_le16(			WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH);		pos++;	} else {		/* FIX: CF-Pollable and CF-PollReq should be set to match the		 * values in beacons/probe responses */		/* FIX: how about privacy and WEP? */		/* capability */		*pos = __constant_cpu_to_le16(WLAN_CAPABILITY_ESS);		pos++;		/* status_code */		*pos = __cpu_to_le16(resp);		pos++;		*pos = __cpu_to_le16((sta && sta->aid > 0 ? sta->aid : 0) |				     BIT(14) | BIT(15)); /* AID */		pos++;		/* Supported rates (Information element) */		p = (char *) pos;		*p++ = WLAN_EID_SUPP_RATES;		lpos = p;		*p++ = 0; /* len */		if (local->tx_rate_control & WLAN_RATE_1M) {			*p++ = local->basic_rates & WLAN_RATE_1M ? 0x82 : 0x02;			(*lpos)++;		}		if (local->tx_rate_control & WLAN_RATE_2M) {			*p++ = local->basic_rates & WLAN_RATE_2M ? 0x84 : 0x04;			(*lpos)++;		}		if (local->tx_rate_control & WLAN_RATE_5M5) {			*p++ = local->basic_rates & WLAN_RATE_5M5 ?				0x8b : 0x0b;			(*lpos)++;		}		if (local->tx_rate_control & WLAN_RATE_11M) {			*p++ = local->basic_rates & WLAN_RATE_11M ?				0x96 : 0x16;			(*lpos)++;		}		pos = (u16 *) p;	}	prism2_send_mgmt(dev, WLAN_FC_TYPE_MGMT,			 (send_deauth ? WLAN_FC_STYPE_DEAUTH :			  (reassoc ? WLAN_FC_STYPE_REASSOC_RESP :			   WLAN_FC_STYPE_ASSOC_RESP)),			 body, (u8 *) pos - (u8 *) body,			 hdr->addr2,			 send_deauth ? 0 : local->ap->tx_callback_assoc);	if (sta) {		if (resp == WLAN_STATUS_SUCCESS) {			sta->last_rx = jiffies;			/* STA will be marked associated from TX callback, if			 * AssocResp is ACKed */		}		atomic_dec(&sta->users);	}#if 0	PDEBUG(DEBUG_AP, "%s: " MACSTR " %sassoc (len=%d prev_ap=" MACSTR	       ") => %d(%d) (%s)\n",	       dev->name, MAC2STR(hdr->addr2), reassoc ? "re" : "", len,	       MAC2STR(prev_ap), resp, send_deauth, txt);#endif}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/4339d328631aa815fe2181b9164b3690ca2db4da/hostap_ap.c/clean/drivers/net/wireless/hostap/hostap_ap.c