⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wt_frm.c

📁 mini-PCI driver for LHWT chipsets
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "wtprecomp.h"/*--------------------------------------------------------------* p80211addr_to_str** Formats a 6 byte IEEE 802 address as a string of the form* xx:xx:xx:xx:xx:xx  where the bytes are in hex.  No library* functions are used to enhance portability.** Arguments:*	buf	char buffer, destination for string format*		48 bit address.  Must be at least 18 bytes long.*	addr	UINT8 buffer containing the ieee802 48 bit address*		we're converting from.** Returns:*	nothing** Side effects:*	the contents of the space pointed to by buf is filled*	with the textual representation of addr.* * STATUS: UNVERIFIED. NONV3.* --------------------------------------------------------------*/void p802addr_to_str(char *buf, UINT8 * addr){	int strindex = 0;	int addrindex;	for (addrindex = 0; addrindex < 6; addrindex++) {		buf[strindex] = ((addr[addrindex] & 0xf0) >> 4) > 9 ?		    'a' + (((addr[addrindex] & 0xf0) >> 4) - 10) :		    '0' + ((addr[addrindex] & 0xf0) >> 4);		buf[strindex + 1] = (addr[addrindex] & 0x0f) > 9 ?		    'a' + ((addr[addrindex] & 0x0f) - 10) :		    '0' + (addr[addrindex] & 0x0f);		buf[strindex + 2] = ':';		strindex += 3;	}	buf[strindex] = '\0';	return;}/*--------------------------------------------------------------* wt_mgmt_encode_beacon** Receives an fr_mgmt struct with its len and buf set.  Fills* in the rest of the members as far as possible.  On entry len* is the length of the buffer, on return len is the actual length* of the frame with all the currently encoded fields.  For * frames where the caller adds variable/optional IEs, the caller* will have to update the len field.* On entry Assumptions:*	1) f->len and f->buf are already set*	2) f->len is the length of the MAC header + data, the CRC*	   is NOT included*	3) all members except len, buf, and priv are zero** Arguments:*	f	frame structure** Returns:*	nothing** Side effects:*	frame  structure members are pointing at their*	respective portions of the frame buffer.* * STATUS: UNVERIFIED. NONV3.* --------------------------------------------------------------*/void wt_mgmt_encode_beacon(wlan_fr_beacon_t * f){	f->type = WLAN_FSTYPE_BEACON;	f->hdr = (p80211_hdr_t *) f->buf;	ASSERT(f->len >= WLAN_BEACON_FR_MAXLEN);	/*-- Fixed Fields ----*/	f->ts = (UINT64 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))			    + WLAN_BEACON_OFF_TS);	f->bcn_int = (UINT16 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				 + WLAN_BEACON_OFF_BCN_INT);	f->cap_info = (UINT16 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				  + WLAN_BEACON_OFF_CAPINFO);	f->len =	    WLAN_HDR_A3_LEN + WLAN_BEACON_OFF_CAPINFO +	    sizeof(*(f->cap_info));	return;}/*--------------------------------------------------------------* wt_mgmt_decode_beacon** Given a complete frame in f->buf, sets the pointers in f to * the areas that correspond to the parts of the frame.** Assumptions:*	1) f->len and f->buf are already set*	2) f->len is the length of the MAC header + data, the CRC*	   is NOT included*	3) all members except len and buf are zero* Arguments:*	f	frame structure ** Returns:*	nothing** Side effects:*	frame  structure members are pointing at their*	respective portions of the frame buffer.* * STATUS: UNVERIFIED.* --------------------------------------------------------------*/BOOL wt_mgmt_decode_beacon(wlan_fr_beacon_t * f){	wlan_ie_t *ie_ptr;	UINT8 *body;	PWTWLAN_RXBUF pWtRxBuf;	        //printk(LEVEL " Now we entered  function %s  !!!\n", __FUNCTION__);		f->type = WLAN_FSTYPE_BEACON;	pWtRxBuf = (PWTWLAN_RXBUF)f->buf;	body = (UINT8 *)pWtRxBuf->RXHwBuf.pHwRxBuf->Buffer;	f->len = ieee2host16(pWtRxBuf->RXHwBuf.pHwRxBuf->RxStatus.RecvBodyLen);	f->hdr = (p80211_hdr_t *)pWtRxBuf->RXHwBuf.pHwRxBuf->dot11Head;	/*        ASSERT(WLAN_FTYPE_MGMT ==                    WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));        ASSERT(WLAN_FSTYPE_BEACON ==                    WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc))); */	/*-- Fixed Fields ----*/	f->ts = (UINT64 *) ( body + WLAN_BEACON_OFF_TS );	f->bcn_int = (UINT16 *) ( body + WLAN_BEACON_OFF_BCN_INT);	f->cap_info = (UINT16 *) ( body + WLAN_BEACON_OFF_CAPINFO);	/*-- Information elements */	ie_ptr = (wlan_ie_t *) ( body	+ WLAN_BEACON_OFF_SSID);	while (((UINT8 *) ie_ptr) < ( body + f->len)) {		switch (ie_ptr->eid) {		case WLAN_EID_SSID:			f->ssid = (wlan_ie_ssid_t *) ie_ptr;			break;		case WLAN_EID_SUPP_RATES:			f->supp_rates = (wlan_ie_supp_rates_t *) ie_ptr;			break;		case WLAN_EID_DS_PARMS:			f->ds_parms = (wlan_ie_ds_parms_t *) ie_ptr;			break;		case WLAN_EID_CF_PARMS:			f->cf_parms = (wlan_ie_cf_parms_t *) ie_ptr;			break;		case WLAN_EID_IBSS_PARMS:			f->ibss_parms = (wlan_ie_ibss_parms_t *) ie_ptr;			break;		case WLAN_EID_ERP :                			f->erp_parms = (wlan_ie_erp_t *) ie_ptr;			break;		case WLAN_EID_EXT_RATES	:          			f->ext_rates = (wlan_ie_extend_rates_t *) ie_ptr;			break;		case WLAN_EID_TIM:			f->tim = (wlan_ie_tim_t *) ie_ptr;			break;				case WLAN_EID_COUNTRY :			f->contry_parms = (wlan_ie_country_t *) ie_ptr;			break;		case WLAN_EID_FH_PARMS:			f->fh_parms = (wlan_ie_fh_parms_t *) ie_ptr;			break;		case WLAN_EID_FH_PATTERN :         			f->fh_pattern = (wlan_ie_fhpattern_t *) ie_ptr;			break;		case WLAN_EID_FH_PATTERN_TABLE :   			f->fh_patterntable = (wlan_ie_fhpatterntable_t *) ie_ptr;			break;		case WLAN_EID_POWER_CONSTRAINT :   			f->powerconstraint = (wlan_ie_powerconstraint_t *) ie_ptr;			break;		case WLAN_EID_TPC_REPORT :         			f->tpc_report = (wlan_ie_tpcreport_t *) ie_ptr;			break;		case WLAN_EID_SW_CHAN_ANN :        			f->channelswa = (wlan_ie_channelswa_t *) ie_ptr;			break;		case WLAN_EID_QUIET :              			f->quiet_parms = (wlan_ie_quiet_t *) ie_ptr;			break;		case WLAN_EID_IBSS_DFS :           			f->ibbss_dfs = (wlan_ie_ibssdfs_t *) ie_ptr;			break;		default:/*                        WLAN_LOG_WARNING1(                                                                "Unrecognized EID=%dd in beacon decode.\n",ie_ptr->eid);                        WLAN_HEX_DUMP(3, "frm w/ bad eid:", f->buf, f->len );                        */			break;		}		ie_ptr =		    (wlan_ie_t *) (((UINT8 *) ie_ptr) + 2 + ie_ptr->len);	}	{		if(((UINT8 *) ie_ptr) != ( body + f->len))			{				//printk(LEVEL " Bad EID length in beacon .\n");				return FALSE;			}		else			return TRUE;	}}/*--------------------------------------------------------------* wt_mgmt_encode_ibssatim** Receives an fr_mgmt struct with its len and buf set.  Fills* in the rest of the members as far as possible.  On entry len* is the length of the buffer, on return len is the actual length* of the frame with all the currently encoded fields.  For * frames where the caller adds variable/optional IEs, the caller* will have to update the len field.* On entry Assumptions:*	1) f->len and f->buf are already set*	2) f->len is the length of the MAC header + data, the CRC*	   is NOT included*	3) all members except len, buf, and priv are zero** Arguments:*	f	frame structure ** Returns:*	nothing** Side effects:*	frame  structure members are pointing at their*	respective portions of the frame buffer.* * STATUS: UNVERIFIED. NONV3.* --------------------------------------------------------------*/void wt_mgmt_encode_ibssatim(wlan_fr_ibssatim_t * f){	f->type = WLAN_FSTYPE_ATIM;	f->hdr = (p80211_hdr_t *) f->buf;	ASSERT(f->len >= WLAN_ATIM_FR_MAXLEN);	/*-- Fixed Fields ----*/	/*-- Information elements */	f->len = WLAN_HDR_A3_LEN;	return;}/*--------------------------------------------------------------* wt_mgmt_decode_ibssatim** Given a complete frame in f->buf, sets the pointers in f to * the areas that correspond to the parts of the frame.** Assumptions:*	1) f->len and f->buf are already set*	2) f->len is the length of the MAC header + data, the CRC*	   is NOT included*	3) all members except len and buf are zero** Arguments:*	f	frame structure ** Returns:*	nothing** Side effects:*	frame  structure members are pointing at their*	respective portions of the frame buffer.* * STATUS: UNVERIFIED. NONV3.* --------------------------------------------------------------*/void wt_mgmt_decode_ibssatim(wlan_fr_ibssatim_t * f){	f->type = WLAN_FSTYPE_ATIM;	f->hdr = (p80211_hdr_t *) f->buf;	ASSERT(WLAN_FTYPE_MGMT ==		    WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	ASSERT(WLAN_FSTYPE_ATIM ==		    WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	/*-- Information elements */	return;}/*--------------------------------------------------------------* wt_mgmt_encode_disassoc** Receives an fr_mgmt struct with its len and buf set.  Fills* in the rest of the members as far as possible.  On entry len* is the length of the buffer, on return len is the actual length* of the frame with all the currently encoded fields.  For * frames where the caller adds variable/optional IEs, the caller* will have to update the len field.* On entry Assumptions:*	1) f->len and f->buf are already set*	2) f->len is the length of the MAC header + data, the CRC*	   is NOT included*	3) all members except len, buf, and priv are zero** Arguments:*	f	frame structure ** Returns:*	nothing** Side effects:*	frame  structure members are pointing at their*	respective portions of the frame buffer.* * STATUS: UNVERIFIED. NONV3.* --------------------------------------------------------------*/void wt_mgmt_encode_disassoc(wlan_fr_disassoc_t * f){	//printk(LEVEL " %s: UNVERIFIED. NONV3.\n", __FUNCTION__);	f->type = WLAN_FSTYPE_DISASSOC;	f->hdr = (p80211_hdr_t *) f->buf;	ASSERT(f->len >= WLAN_DISASSOC_FR_MAXLEN);	/*-- Fixed Fields ----*/	f->reason = (UINT16 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				+ WLAN_DISASSOC_OFF_REASON);	f->len =	    WLAN_HDR_A3_LEN + WLAN_DISASSOC_OFF_REASON +	    sizeof(*(f->reason));	return;}/*--------------------------------------------------------------* wt_mgmt_decode_disassoc** Given a complete frame in f->buf, sets the pointers in f to * the areas that correspond to the parts of the frame.** Assumptions:*	1) f->len and f->buf are already set*	2) f->len is the length of the MAC header + data, the CRC*	   is NOT included*	3) all members except len and buf are zero** Arguments:*	f	frame structure ** Returns:*	nothing** Side effects:*	frame  structure members are pointing at their*	respective portions of the frame buffer.--------------------------------------------------------------*/void wt_mgmt_decode_disassoc(wlan_fr_disassoc_t * f){//	printk(LEVEL " %s: UNVERIFIED. NONV3.\n", __FUNCTION__);	f->type = WLAN_FSTYPE_DISASSOC;	f->hdr = (p80211_hdr_t *) f->buf;	ASSERT(WLAN_FTYPE_MGMT ==		    WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	ASSERT(WLAN_FSTYPE_DISASSOC ==		    WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	f->reason = (UINT16 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				+ WLAN_DISASSOC_OFF_REASON);	/*-- Information elements */	return;}/*--------------------------------------------------------------* wt_mgmt_encode_assocreq** Receives an fr_mgmt struct with its len and buf set.  Fills* in the rest of the members as far as possible.  On entry len* is the length of the buffer, on return len is the actual length* of the frame with all the currently encoded fields.  For * frames where the caller adds variable/optional IEs, the caller* will have to update the len field.* On entry Assumptions:*	1) f->len and f->buf are already set*	2) f->len is the length of the MAC header + data, the CRC*	   is NOT included*	3) all members except len, buf, and priv are zero** Arguments:*	f	frame structure ** Returns:*	nothing** Side effects:*	frame  structure members are pointing at their*	respective portions of the frame buffer.* * STATUS: UNVERIFIED. NONV3.* --------------------------------------------------------------*/void wt_mgmt_encode_assocreq(wlan_fr_assocreq_t * f){//	printk(LEVEL " %s: UNVERIFIED. NONV3.\n", __FUNCTION__);	f->type = WLAN_FSTYPE_ASSOCREQ;	f->hdr = (p80211_hdr_t *) f->buf;	ASSERT(f->len >= WLAN_ASSOCREQ_FR_MAXLEN);	/*-- Fixed Fields ----*/	f->cap_info = (UINT16 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				  + WLAN_ASSOCREQ_OFF_CAP_INFO);	f->listen_int = (UINT16 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				    + WLAN_ASSOCREQ_OFF_LISTEN_INT);	f->len = WLAN_HDR_A3_LEN +	    WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(f->listen_int));	return;}/*--------------------------------------------------------------* wt_mgmt_decode_assocreq** Given a complete frame in f->buf, sets the pointers in f to * the areas that correspond to the parts of the frame.** Assumptions:*	1) f->len and f->buf are already set*	2) f->len is the length of the MAC header + data, the CRC*	   is NOT included*	3) all members except len and buf are zero** Arguments:*	f	frame structure ** Returns:*	nothing** Side effects:*	frame  structure members are pointing at their*	respective portions of the frame buffer.* * STATUS: UNVERIFIED. NONV3.* --------------------------------------------------------------*/void wt_mgmt_decode_assocreq(wlan_fr_assocreq_t * f){	wlan_ie_t *ie_ptr;//	printk(LEVEL " %s: UNVERIFIED. NONV3.\n", __FUNCTION__);	f->type = WLAN_FSTYPE_ASSOCREQ;	f->hdr = (p80211_hdr_t *) f->buf;	ASSERT(WLAN_FTYPE_MGMT ==		    WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	ASSERT(WLAN_FSTYPE_ASSOCREQ ==		    WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	f->cap_info = (UINT16 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				  + WLAN_ASSOCREQ_OFF_CAP_INFO);	f->listen_int = (UINT16 *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				    + WLAN_ASSOCREQ_OFF_LISTEN_INT);	/*-- Information elements */	ie_ptr = (wlan_ie_t *) (WLAN_HDR_A3_DATAP(&(f->hdr->a3))				+ WLAN_ASSOCREQ_OFF_SSID);	while (((UINT8 *) ie_ptr) < (f->buf + f->len)) {		switch (ie_ptr->eid) {		case WLAN_EID_SSID:			f->ssid = (wlan_ie_ssid_t *) ie_ptr;			break;		case WLAN_EID_SUPP_RATES:			f->supp_rates = (wlan_ie_supp_rates_t *) ie_ptr;			break;		default:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -