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

📄 p80211.c

📁 Linux Wireless LAN Project 的目标是开发一个完整的
💻 C
📖 第 1 页 / 共 2 页
字号:
	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--------------------------------------------------------------*/void wlan_mgmt_encode_reassocreq( wlan_fr_reassocreq_t  *f ){	f->type = WLAN_FSTYPE_REASSOCREQ;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT( f->len >= WLAN_REASSOCREQ_FR_MAXLEN );	/*-- Fixed Fields ----*/	f->cap_info		=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCREQ_OFF_CAP_INFO);	f->listen_int	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCREQ_OFF_LISTEN_INT);	f->curr_ap		=(UINT8*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCREQ_OFF_CURR_AP);	f->len = WLAN_HDR_A3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(f->curr_ap));	return;}/*--------------------------------------------------------------	Decode Reassociation Request	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--------------------------------------------------------------*/void wlan_mgmt_decode_reassocreq( wlan_fr_reassocreq_t  *f ){	wlan_ie_t	*ie_ptr; 	f->type = WLAN_FSTYPE_REASSOCREQ;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT(WLAN_FTYPE_MGMT == 					WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	WLAN_ASSERT(WLAN_FSTYPE_REASSOCREQ == 					WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	f->cap_info		=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCREQ_OFF_CAP_INFO);	f->listen_int	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCREQ_OFF_LISTEN_INT);	f->curr_ap		=(UINT8*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCREQ_OFF_CURR_AP);	/*-- Information elements */	ie_ptr = (wlan_ie_t*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_REASSOCREQ_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:				WLAN_LOG_WARNING1(						"Unrecognized EID=%dd in reassocreq 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);	}	return;}/*--------------------------------------------------------------	Encode Reassociation Response	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--------------------------------------------------------------*/void wlan_mgmt_encode_reassocresp( wlan_fr_reassocresp_t  *f ){	f->type = WLAN_FSTYPE_REASSOCRESP;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT( f->len >= WLAN_REASSOCRESP_FR_MAXLEN );	/*-- Fixed Fields ----*/	f->cap_info		= (UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCRESP_OFF_CAP_INFO);	f->status		= (UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCRESP_OFF_STATUS);	f->aid			= (UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCRESP_OFF_AID);	f->len = WLAN_HDR_A3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(f->aid));	return;}/*--------------------------------------------------------------	Decode Reassociation Response	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--------------------------------------------------------------*/void wlan_mgmt_decode_reassocresp( wlan_fr_reassocresp_t  *f ){	f->type = WLAN_FSTYPE_REASSOCRESP;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT(WLAN_FTYPE_MGMT == 					WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	WLAN_ASSERT(WLAN_FSTYPE_REASSOCRESP == 					WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	f->cap_info		= (UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCRESP_OFF_CAP_INFO);	f->status		= (UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCRESP_OFF_STATUS);	f->aid			= (UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))								+ WLAN_REASSOCRESP_OFF_AID);	/*-- Information elements */	f->supp_rates	= (wlan_ie_supp_rates_t*)					(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) + 						WLAN_REASSOCRESP_OFF_SUPP_RATES);	return;}/*--------------------------------------------------------------	Encode Probe Request	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--------------------------------------------------------------*/void wlan_mgmt_encode_probereq( wlan_fr_probereq_t  *f ){	f->type = WLAN_FSTYPE_PROBEREQ;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT( f->len >= WLAN_PROBEREQ_FR_MAXLEN );	f->len = WLAN_HDR_A3_LEN;	return;}/*--------------------------------------------------------------	Decode Probe Request	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--------------------------------------------------------------*/void wlan_mgmt_decode_probereq( wlan_fr_probereq_t  *f ){	wlan_ie_t	*ie_ptr; 	f->type = WLAN_FSTYPE_PROBEREQ;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT(WLAN_FTYPE_MGMT == 					WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	WLAN_ASSERT(WLAN_FSTYPE_PROBEREQ == 					WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	/*-- Information elements */	ie_ptr = (wlan_ie_t*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) 							+ WLAN_PROBEREQ_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:				WLAN_LOG_WARNING1(						"Unrecognized EID=%dd in probereq 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);	}	return;}/*--------------------------------------------------------------	Encode Probe Response	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--------------------------------------------------------------*/void wlan_mgmt_encode_proberesp( wlan_fr_proberesp_t  *f ){	f->type = WLAN_FSTYPE_PROBERESP;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT( f->len >= WLAN_PROBERESP_FR_MAXLEN );	/*-- Fixed Fields ----*/	f->ts		=(UINT64*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) 							+ WLAN_PROBERESP_OFF_TS);	f->bcn_int	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_PROBERESP_OFF_BCN_INT);	f->cap_info	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_PROBERESP_OFF_CAP_INFO);	f->len = WLAN_HDR_A3_LEN + WLAN_PROBERESP_OFF_CAP_INFO + 			sizeof(*(f->cap_info));	return;}/*--------------------------------------------------------------	Decode Probe Response	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--------------------------------------------------------------*/void wlan_mgmt_decode_proberesp( wlan_fr_proberesp_t  *f ){	wlan_ie_t	*ie_ptr; 	f->type = WLAN_FSTYPE_PROBERESP;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT(WLAN_FTYPE_MGMT == 					WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	WLAN_ASSERT(WLAN_FSTYPE_PROBERESP == 					WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	f->ts		=(UINT64*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_PROBERESP_OFF_TS);	f->bcn_int	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_PROBERESP_OFF_BCN_INT);	f->cap_info	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_PROBERESP_OFF_CAP_INFO);	/*-- Information elements */	ie_ptr = (wlan_ie_t*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_PROBERESP_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;			case WLAN_EID_FH_PARMS:				f->fh_parms = (wlan_ie_fh_parms_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;			default:				WLAN_LOG_WARNING2(						"Bad EID=%dd in proberesp, off=%d .\n",						ie_ptr->eid, f->buf - (UINT8*)ie_ptr);				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);	}	return;}/*--------------------------------------------------------------	Encode Authentication	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--------------------------------------------------------------*/void wlan_mgmt_encode_authen( wlan_fr_authen_t  *f ){	f->type = WLAN_FSTYPE_AUTHEN;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT( f->len >= WLAN_AUTHEN_FR_MAXLEN );	/*-- Fixed Fields ----*/	f->auth_alg	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_AUTHEN_OFF_AUTH_ALG);	f->auth_seq	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) 							+ WLAN_AUTHEN_OFF_AUTH_SEQ);	f->status	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_AUTHEN_OFF_STATUS);	f->len = WLAN_HDR_A3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(f->status));	return;}/*--------------------------------------------------------------	Decode Authentication	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--------------------------------------------------------------*/void wlan_mgmt_decode_authen( wlan_fr_authen_t  *f ){	wlan_ie_t	*ie_ptr; 	f->type = WLAN_FSTYPE_AUTHEN;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT(WLAN_FTYPE_MGMT == 					WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	WLAN_ASSERT(WLAN_FSTYPE_AUTHEN == 					WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	f->auth_alg	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3)) 							+ WLAN_AUTHEN_OFF_AUTH_ALG);	f->auth_seq	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_AUTHEN_OFF_AUTH_SEQ);	f->status	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_AUTHEN_OFF_STATUS);	/*-- Information elements */	ie_ptr = (wlan_ie_t*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_AUTHEN_OFF_CHALLENGE);	if ((((UINT8*)ie_ptr) < (f->buf + f->len)) && 		(ie_ptr->eid == WLAN_EID_CHALLENGE) )	{		f->challenge = (wlan_ie_challenge_t*)ie_ptr;	}	return;}/*--------------------------------------------------------------	Encode Deauthentication	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--------------------------------------------------------------*/void wlan_mgmt_encode_deauthen( wlan_fr_deauthen_t  *f ){	f->type = WLAN_FSTYPE_DEAUTHEN;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT( f->len >= WLAN_DEAUTHEN_FR_MAXLEN );	/*-- Fixed Fields ----*/	f->reason	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_DEAUTHEN_OFF_REASON);	f->len = WLAN_HDR_A3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(f->reason));	return;}/*--------------------------------------------------------------	Decode Deauthentication	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--------------------------------------------------------------*/void wlan_mgmt_decode_deauthen( wlan_fr_deauthen_t  *f ){	f->type = WLAN_FSTYPE_DEAUTHEN;	f->hdr = (p80211_hdr_t*)f->buf;	WLAN_ASSERT(WLAN_FTYPE_MGMT == 					WLAN_GET_FC_FTYPE(ieee2host16(f->hdr->a3.fc)));	WLAN_ASSERT(WLAN_FSTYPE_DEAUTHEN == 					WLAN_GET_FC_FSTYPE(ieee2host16(f->hdr->a3.fc)));	/*-- Fixed Fields ----*/	f->reason	=(UINT16*)(WLAN_HDR_A3_DATAP(&(f->hdr->a3))							+ WLAN_DEAUTHEN_OFF_REASON);	/*-- Information elements */	return;}

⌨️ 快捷键说明

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