/* FIX: * I do not know how this is possible, but iwe_stream_add_event * seems to re-order memcpy execution so that len is set only * after copying.. Pre-setting len here "fixes" this, but real * problems should be solved (after which these iwe.len * settings could be removed from this function). */ iwe.len = IW_EV_ADDR_LEN; 
static char * __prism2_translate_scan(local_info_t *local,				      struct hfa384x_hostscan_result *scan,				      struct hostap_bss_info *bss,				      char *current_ev, char *end_buf){	int i, chan;	struct iw_event iwe;	char *current_val;	u16 capabilities;	u8 *pos;	u8 *ssid, *bssid;	size_t ssid_len;	char *buf;	if (bss) {		ssid = bss->ssid;		ssid_len = bss->ssid_len;		bssid = bss->bssid;	} else {		ssid = scan->ssid;		ssid_len = le16_to_cpu(scan->ssid_len);		bssid = scan->bssid;	}	if (ssid_len > 32)		ssid_len = 32;	/* First entry *MUST* be the AP MAC address */	memset(&iwe, 0, sizeof(iwe));	iwe.cmd = SIOCGIWAP;	iwe.u.ap_addr.sa_family = ARPHRD_ETHER;	memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN);	/* FIX:	 * I do not know how this is possible, but iwe_stream_add_event	 * seems to re-order memcpy execution so that len is set only	 * after copying.. Pre-setting len here "fixes" this, but real	 * problems should be solved (after which these iwe.len	 * settings could be removed from this function). */	iwe.len = IW_EV_ADDR_LEN;	current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,					  IW_EV_ADDR_LEN);	/* Other entries will be displayed in the order we give them */	memset(&iwe, 0, sizeof(iwe));	iwe.cmd = SIOCGIWESSID;	iwe.u.data.length = ssid_len;	iwe.u.data.flags = 1;	iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;	current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ssid);	memset(&iwe, 0, sizeof(iwe));	iwe.cmd = SIOCGIWMODE;	if (bss) {		capabilities = bss->capab_info;	} else {		capabilities = le16_to_cpu(scan->capability);	}	if (capabilities & (WLAN_CAPABILITY_ESS |			    WLAN_CAPABILITY_IBSS)) {		if (capabilities & WLAN_CAPABILITY_ESS)			iwe.u.mode = IW_MODE_MASTER;		else			iwe.u.mode = IW_MODE_ADHOC;		iwe.len = IW_EV_UINT_LEN;		current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,						  IW_EV_UINT_LEN);	}	memset(&iwe, 0, sizeof(iwe));	iwe.cmd = SIOCGIWFREQ;	if (scan) {		chan = scan->chid;	} else if (bss) {		chan = bss->chan;	} else {		chan = 0;	}	if (chan > 0) {		iwe.u.freq.m = freq_list[le16_to_cpu(chan - 1)] * 100000;		iwe.u.freq.e = 1;		iwe.len = IW_EV_FREQ_LEN;		current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,						  IW_EV_FREQ_LEN);	}	if (scan) {		memset(&iwe, 0, sizeof(iwe));		iwe.cmd = IWEVQUAL;		if (local->last_scan_type == PRISM2_HOSTSCAN) {			iwe.u.qual.level = le16_to_cpu(scan->sl);			iwe.u.qual.noise = le16_to_cpu(scan->anl);		} else {			iwe.u.qual.level =				HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl));			iwe.u.qual.noise =				HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->anl));		}		iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED			| IW_QUAL_NOISE_UPDATED			| IW_QUAL_QUAL_INVALID			| IW_QUAL_DBM;		iwe.len = IW_EV_QUAL_LEN;		current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,						  IW_EV_QUAL_LEN);	}	memset(&iwe, 0, sizeof(iwe));	iwe.cmd = SIOCGIWENCODE;	if (capabilities & WLAN_CAPABILITY_PRIVACY)		iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;	else		iwe.u.data.flags = IW_ENCODE_DISABLED;	iwe.u.data.length = 0;	iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;	current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");	/* TODO: add SuppRates into BSS table */	if (scan) {		memset(&iwe, 0, sizeof(iwe));		iwe.cmd = SIOCGIWRATE;		current_val = current_ev + IW_EV_LCP_LEN;		pos = scan->sup_rates;		for (i = 0; i < sizeof(scan->sup_rates); i++) {			if (pos[i] == 0)				break;			/* Bit rate given in 500 kb/s units (+ 0x80) */			iwe.u.bitrate.value = ((pos[i] & 0x7f) * 500000);			current_val = iwe_stream_add_value(				current_ev, current_val, end_buf, &iwe,				IW_EV_PARAM_LEN);		}		/* Check if we added any event */		if ((current_val - current_ev) > IW_EV_LCP_LEN)			current_ev = current_val;	}	/* TODO: add BeaconInt,resp_rate,atim into BSS table */	buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_ATOMIC);	if (buf && scan) {		memset(&iwe, 0, sizeof(iwe));		iwe.cmd = IWEVCUSTOM;		sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));		iwe.u.data.length = strlen(buf);		current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,						  buf);		memset(&iwe, 0, sizeof(iwe));		iwe.cmd = IWEVCUSTOM;		sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));		iwe.u.data.length = strlen(buf);		current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,						  buf);		if (local->last_scan_type == PRISM2_HOSTSCAN &&		    (capabilities & WLAN_CAPABILITY_IBSS)) {			memset(&iwe, 0, sizeof(iwe));			iwe.cmd = IWEVCUSTOM;			sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));			iwe.u.data.length = strlen(buf);			current_ev = iwe_stream_add_point(current_ev, end_buf,							  &iwe, buf);		}	}	kfree(buf);	if (bss && bss->wpa_ie_len > 0 && bss->wpa_ie_len <= MAX_WPA_IE_LEN) {		memset(&iwe, 0, sizeof(iwe));		iwe.cmd = IWEVGENIE;		iwe.u.data.length = bss->wpa_ie_len;		current_ev = iwe_stream_add_point(			current_ev, end_buf, &iwe, bss->wpa_ie);	}	if (bss && bss->rsn_ie_len > 0 && bss->rsn_ie_len <= MAX_WPA_IE_LEN) {		memset(&iwe, 0, sizeof(iwe));		iwe.cmd = IWEVGENIE;		iwe.u.data.length = bss->rsn_ie_len;		current_ev = iwe_stream_add_point(			current_ev, end_buf, &iwe, bss->rsn_ie);	}	return current_ev;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/596ff2e7c8db39c700e277f0bc267244be253f5b/hostap_ioctl.c/clean/drivers/net/wireless/hostap/hostap_ioctl.c