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

📄 prframe.c

📁 Linux Wireless LAN Project 的目标是开发一个完整的
💻 C
📖 第 1 页 / 共 4 页
字号:
	info_elements[MGMT_IE_IBSS_PARMS].exists = TRUE;	info_elements[MGMT_IE_IBSS_PARMS].info = (void *)frame.ibss_parms;	print_fixed_fields( fixed_fields, len );	print_info_elements( info_elements, len );}/*----------------------------------------------------------------*	print_mgmt_reassocreq**	This function decodes and prints management frames of subtype*	reassociation request.**	Arguments:*		pbuf - pointer to the frame buffer*		index	- index into the global array of frame types for a*		        particular frame type and subtype*		len	- the number of bytes in the frame**	returns: nothing*----------------------------------------------------------------*/void print_mgmt_reassocreq( UINT8 *pbuf, int index, UINT16 len ){	wlan_fr_reassocreq_t			frame; 	wlan_p80211_frame_fields_t		fixed_fields[TOTAL_MGMT_FIXED_FIELDS]; 	wlan_p80211_frame_fields_t		info_elements[TOTAL_MGMT_INFO_ELEMENTS];	/* print 802.11 frame header */	print_80211_mgmt_header( (p80211_hdr_t *)pbuf, index, len );	/* print management frame body for this management frame subtype */	memset( (void *)fixed_fields, 0,		(sizeof(wlan_p80211_frame_fields_t) * TOTAL_MGMT_FIXED_FIELDS));	memset( (void *)info_elements, 0,		(sizeof(wlan_p80211_frame_fields_t) * TOTAL_MGMT_INFO_ELEMENTS));	memset( (void *)&frame, 0, sizeof(wlan_fr_reassocreq_t) );	frame.buf = pbuf;	/* decode functions assume the 4 trailing bytes for the FCS aren't	   included in the length */	frame.len = len - 4;	wlan_mgmt_decode_reassocreq( &frame );	fixed_fields[MGMT_FF_CAP_INFO].exists = TRUE;	fixed_fields[MGMT_FF_CAP_INFO].info = (void *)frame.cap_info;	fixed_fields[MGMT_FF_LISTEN_INT].exists = TRUE;	fixed_fields[MGMT_FF_LISTEN_INT].info = (void *)frame.listen_int;	fixed_fields[MGMT_FF_CURR_AP].exists = TRUE;	fixed_fields[MGMT_FF_CURR_AP].info = (void *)frame.curr_ap;	info_elements[MGMT_IE_SSID].exists = TRUE;	info_elements[MGMT_IE_SSID].info = (void *)frame.ssid;	info_elements[MGMT_IE_SUPP_RATES].exists = TRUE;	info_elements[MGMT_IE_SUPP_RATES].info = (void *)frame.supp_rates;	print_fixed_fields( fixed_fields, len );	print_info_elements( info_elements, len );}/*----------------------------------------------------------------*	print_mgmt_reassocresp**	This function decodes and prints management frames of subtype*	reassociation response.**	Arguments:*		pbuf - pointer to the frame buffer*		index	- index into the global array of frame types for a*		        particular frame type and subtype*		len	- the number of bytes in the frame**	returns: nothing*----------------------------------------------------------------*/void print_mgmt_reassocresp( UINT8 *pbuf, int index, UINT16 len ){	wlan_fr_reassocresp_t			frame; 	wlan_p80211_frame_fields_t		fixed_fields[TOTAL_MGMT_FIXED_FIELDS]; 	wlan_p80211_frame_fields_t		info_elements[TOTAL_MGMT_INFO_ELEMENTS];	/* print 802.11 frame header */	print_80211_mgmt_header( (p80211_hdr_t *)pbuf, index, len );	/* print management frame body for this management frame subtype */	memset( (void *)fixed_fields, 0,		(sizeof(wlan_p80211_frame_fields_t) * TOTAL_MGMT_FIXED_FIELDS));	memset( (void *)info_elements, 0,		(sizeof(wlan_p80211_frame_fields_t) * TOTAL_MGMT_INFO_ELEMENTS));	memset( (void *)&frame, 0, sizeof(wlan_fr_reassocresp_t) );	frame.buf = pbuf;	/* decode functions assume the 4 trailing bytes for the FCS aren't	   included in the length */	frame.len = len - 4;	wlan_mgmt_decode_reassocresp( &frame );	fixed_fields[MGMT_FF_CAP_INFO].exists = TRUE;	fixed_fields[MGMT_FF_CAP_INFO].info = (void *)frame.cap_info;	fixed_fields[MGMT_FF_STATUS].exists = TRUE;	fixed_fields[MGMT_FF_STATUS].info = (void *)frame.status;	fixed_fields[MGMT_FF_AID].exists = TRUE;	fixed_fields[MGMT_FF_AID].info = (void *)frame.aid;	info_elements[MGMT_IE_SUPP_RATES].exists = TRUE;	info_elements[MGMT_IE_SUPP_RATES].info = (void *)frame.supp_rates;	print_fixed_fields( fixed_fields, len );	print_info_elements( info_elements, len );}/*----------------------------------------------------------------*	print_fixed_fields**	This function looks in the array of fixed fields and prints the*	information for only those fixed fields that exist.	**	Arguments:*		ff - array of all the fixed field types and associated info*		len - length of the frame**	returns: nothing*----------------------------------------------------------------*/void print_fixed_fields( wlan_p80211_frame_fields_t  *ff, UINT16 len ){	int		i;	UINT8	*byte;	UINT16	info;	for ( i = 0; i < TOTAL_MGMT_FIXED_FIELDS; i++ )	{		switch( i )		{			case	MGMT_FF_AUTH_ALG:					if ( ff[MGMT_FF_AUTH_ALG].exists )					{						printf("|authAlg=%u",						*((UINT16 *)ff[MGMT_FF_AUTH_ALG].info));					}					break;			case	MGMT_FF_AUTH_SEQ:					if ( ff[MGMT_FF_AUTH_SEQ].exists )					{						printf("|authSeq=%u",						*((UINT16 *)ff[MGMT_FF_AUTH_SEQ].info));					}					break;			case	MGMT_FF_BCN_INT:					if ( ff[MGMT_FF_BCN_INT].exists )					{						printf("|bcn_int=%u",						*((UINT16 *)ff[MGMT_FF_BCN_INT].info));					}					break;			case	MGMT_FF_CAP_INFO:					if ( ff[MGMT_FF_CAP_INFO].exists )					{						info = *((UINT16 *)ff[MGMT_FF_CAP_INFO].info);						printf("|capInfo=0x%02x", info);						if ( WLAN_GET_MGMT_CAP_INFO_ESS( info ) )							printf(",capInfo_ess");						if ( WLAN_GET_MGMT_CAP_INFO_IBSS( info ) )							printf(",capInfo_ibss");						if ( WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE( info ) )							printf(",capInfo_cfpollable");						if ( WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ( info ) )							printf(",capInfo_cfpollreq");						if ( WLAN_GET_MGMT_CAP_INFO_PRIVACY( info ) )							printf(",capInfo_privacy");					}					break;			case	MGMT_FF_CURR_AP:					if ( ff[MGMT_FF_CURR_AP].exists )					{						byte = (UINT8 *)ff[MGMT_FF_CURR_AP].info;						printf("|currAPadd=%02x:%02x:%02x:%02x:%02x:%02x",						*byte, *(byte + 1), *(byte + 2),						*(byte + 3), *(byte + 4), *(byte + 5) );					}					break;			case	MGMT_FF_LISTEN_INT:					if ( ff[MGMT_FF_LISTEN_INT].exists )					{						printf("|listenInt=%u",						*((UINT16 *)ff[MGMT_FF_LISTEN_INT].info));					}					break;			case	MGMT_FF_REASON:					if ( ff[MGMT_FF_REASON].exists )					{						printf("|reason=%u",						*((UINT16 *)ff[MGMT_FF_REASON].info));					}					break;			case	MGMT_FF_AID:					if ( ff[MGMT_FF_AID].exists )					{						printf("|aid=%u",						*((UINT16 *)ff[MGMT_FF_AID].info));					}					break;			case	MGMT_FF_STATUS:					if ( ff[MGMT_FF_STATUS].exists )					{						printf("|status=%u",						*((UINT16 *)ff[MGMT_FF_STATUS].info));					}					break;			case	MGMT_FF_TS:					if ( ff[MGMT_FF_TS].exists )					{						printf("|ts=0x");						byte = (UINT8 *)ff[MGMT_FF_TS].info;						printf("%02x%02x%02x%02x%02x%02x%02x%02x", *byte,							*(byte+1), *(byte+2), *(byte+3), *(byte+4),							*(byte+5), *(byte+6), *(byte+7));					}					break;		}	}	printf("\n");}/*----------------------------------------------------------------*	print_info_elements**	This function looks in the array of information elements and prints the*	information for only those information elements that exist.	**	Arguments:*		ie - array of all the information element types and associated info*		len - length of the frame**	returns: nothing*----------------------------------------------------------------*/void print_info_elements( wlan_p80211_frame_fields_t  *ie, UINT16 len ){	int		index;	int		i;	UINT16	n;	for ( index = 0; index < TOTAL_MGMT_INFO_ELEMENTS; index++ )	{		switch ( index )		{			case MGMT_IE_SSID:				if ( ie[MGMT_IE_SSID].exists )				{					wlan_ie_ssid_t	*info;					info = (wlan_ie_ssid_t *)(ie[MGMT_IE_SSID].info);					if ( info != NULL )					{						char	ssid_str[ WLAN_SSID_MAXLEN + 2 ];						n = info->len;						printf("ssid:elemID=%u,len=%u,", info->eid, n );						memcpy( (void *)ssid_str, (void *)info->ssid, n );						ssid_str[n] = '\0';						printf("%s\n", ssid_str );					}				}				break;			case MGMT_IE_SUPP_RATES:				if ( ie[MGMT_IE_SUPP_RATES].exists )				{					wlan_ie_supp_rates_t	*info;					info = (wlan_ie_supp_rates_t *)(ie[MGMT_IE_SUPP_RATES].info);					if (info != NULL)					{						n = info->len;						printf("suppRates:elemID=%u,len=%u,0x", info->eid, n);						for ( i = 0; i < n; i++ )						{							printf("%02x", info->rates[i]);						}						printf("\n");					}				}				break;			case MGMT_IE_FH_PARMS:				if ( ie[MGMT_IE_FH_PARMS].exists )				{					wlan_ie_fh_parms_t	*info;					info = (wlan_ie_fh_parms_t *)(ie[MGMT_IE_FH_PARMS].info);					if (info != NULL)					{						printf("fhParms:elemID=%u,len=%u,dwell=%u",							info->eid, info->len, info->dwell);						printf("hopset=%u,hoppattern=%u,hopindex=%u\n",							info->hopset, info->hoppattern, info->hopindex);					}				}				break;			case MGMT_IE_DS_PARMS:				if ( ie[MGMT_IE_DS_PARMS].exists )				{					wlan_ie_ds_parms_t	*info;					info = (wlan_ie_ds_parms_t *)(ie[MGMT_IE_DS_PARMS].info);					if (info != NULL)					{						printf("dsParms:elemID=%u,len=%u,currChannel=%u\n",							info->eid, info->len, info->curr_ch);					}				}				break;			case MGMT_IE_CF_PARMS:				if ( ie[MGMT_IE_CF_PARMS].exists )				{					wlan_ie_cf_parms_t	*info;					info = (wlan_ie_cf_parms_t *)(ie[MGMT_IE_CF_PARMS].info);					if (info != NULL)					{						printf("cfParms:elemID=%u,len=%u,cfpCnt=%u",							info->eid, info->len, info->cfp_cnt);						printf("cfpPeriod=%u,cfpMaxdur=%u,cfpDurRemain=%u\n",							info->cfp_period, info->cfp_maxdur,							info->cfp_durremaining );					}				}				break;			case MGMT_IE_TIM:				if ( ie[MGMT_IE_TIM].exists )				{					wlan_ie_tim_t	*info;					info = (wlan_ie_tim_t *)(ie[MGMT_IE_TIM].info);					if (info != NULL)					{						n = info->len;						printf("tim:elemID=%u,len=%u,dtimCnt=%u,",							info->eid, n, info->dtim_cnt);						printf("dtimPer=%u,bitmapCtl=%u,virtBitmap=0x",							info->dtim_period, info->bitmap_ctl);						n = n - 3; 						for ( i = 0; i < n; i++ )						{							printf("%02x", info->virt_bm[i]);						}						printf("\n");					}				}				break;			case MGMT_IE_IBSS_PARMS:				if ( ie[MGMT_IE_IBSS_PARMS].exists )				{					wlan_ie_ibss_parms_t	*info;					info=(wlan_ie_ibss_parms_t *)(ie[MGMT_IE_IBSS_PARMS].info);					if (info != NULL)					{						printf("ibssParms:elemID=%u,len=%u,atimWin=%u\n",							info->eid, info->len, info->atim_win);					}				}				break;			case MGMT_IE_CHALLENGE:				if ( ie[MGMT_IE_CHALLENGE].exists )				{					wlan_ie_challenge_t	*info;					info = (wlan_ie_challenge_t *)(ie[MGMT_IE_CHALLENGE].info);					if (info != NULL)					{						n = info->len;						printf("ChallengeText:elemID=%u,len=%u,challenge=0x\n",							info->eid, n );						for ( i = 0; i < n; i++ )						{							printf("%02x", info->challenge[i]);						}					}				}				break;		}	}}

⌨️ 快捷键说明

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