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

📄 ieee80211_common.h

📁 该系统是基于Linux平台的WLAN应用
💻 H
字号:
#ifndef _IEEE80211_COMMON_H_#define _IEEE80211_COMMON_H_#include "PlatformInterface.h"#define uint16_t u16
#define uint8_t u8
#define uint32_t u32#define BIT(x) (1 << (x))
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x\n"#define WLAN_FC_GET_TYPE(fc) (((fc) & (BIT(3) | BIT(2))) >> 2)#define WLAN_FC_GET_STYPE(fc) \	(((fc) & (BIT(7) | BIT(6) | BIT(5) | BIT(4))) >> 4)#define WLAN_FC_GET_VERSION(fc) ( (fc) & (BIT(1) | BIT(0)) )#define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))#define WLAN_GET_SEQ_SEQ(seq) \	(((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)
/*define frame type*/
#define WLAN_MANAGEMENT_FRAME	0
#define WLAN_CONTROL_FRAME		1
#define WLAN_DATA_FRAME			2

#define WLAN_ALL_FRAME			4

/* management */#define WLAN_FC_STYPE_ASSOC_REQ 0#define WLAN_FC_STYPE_ASSOC_RESP 1#define WLAN_FC_STYPE_REASSOC_REQ 2#define WLAN_FC_STYPE_REASSOC_RESP 3#define WLAN_FC_STYPE_PROBE_REQ 4#define WLAN_FC_STYPE_PROBE_RESP 5#define WLAN_FC_STYPE_BEACON 8#define WLAN_FC_STYPE_ATIM 9#define WLAN_FC_STYPE_DISASSOC 10#define WLAN_FC_STYPE_AUTH 11#define WLAN_FC_STYPE_DEAUTH 12/* control */#define WLAN_FC_STYPE_PSPOLL 10#define WLAN_FC_STYPE_RTS 11#define WLAN_FC_STYPE_CTS 12#define WLAN_FC_STYPE_ACK 13#define WLAN_FC_STYPE_CFEND 14#define WLAN_FC_STYPE_CFENDACK 15/* data */#define WLAN_FC_STYPE_DATA 0#define WLAN_FC_STYPE_DATA_CFACK 1#define WLAN_FC_STYPE_DATA_CFPOLL 2#define WLAN_FC_STYPE_DATA_CFACKPOLL 3#define WLAN_FC_STYPE_NULLFUNC 4#define WLAN_FC_STYPE_CFACK 5#define WLAN_FC_STYPE_CFPOLL 6#define WLAN_FC_STYPE_CFACKPOLL 7/* Authentication algorithms */#define WLAN_AUTH_OPEN 0#define WLAN_AUTH_SHARED_KEY 1#define WLAN_AUTH_CHALLENGE_LEN 128#define WLAN_CAPABILITY_ESS BIT(0)#define WLAN_CAPABILITY_IBSS BIT(1)#define WLAN_CAPABILITY_CF_POLLABLE BIT(2)#define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)#define WLAN_CAPABILITY_PRIVACY BIT(4)/* Status codes */#define WLAN_STATUS_SUCCESS 0#define WLAN_STATUS_UNSPECIFIED_FAILURE 1#define WLAN_STATUS_CAPS_UNSUPPORTED 10#define WLAN_STATUS_REASSOC_NO_ASSOC 11#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14#define WLAN_STATUS_CHALLENGE_FAIL 15#define WLAN_STATUS_AUTH_TIMEOUT 16#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17#define WLAN_STATUS_ASSOC_DENIED_RATES 18/* 802.11b */#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21/* IEEE 802.11i */#define WLAN_STATUS_INVALID_IE 40#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42#define WLAN_STATUS_AKMP_NOT_VALID 43#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46/* Reason codes */#define WLAN_REASON_UNSPECIFIED 1#define WLAN_REASON_PREV_AUTH_NOT_VALID 2#define WLAN_REASON_DEAUTH_LEAVING 3#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4#define WLAN_REASON_DISASSOC_AP_BUSY 5#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9/* IEEE 802.11i */#define WLAN_REASON_INVALID_IE 13#define WLAN_REASON_MICHAEL_MIC_FAILURE 14#define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15#define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16#define WLAN_REASON_IE_IN_4WAY_DIFFERS 17#define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18#define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19#define WLAN_REASON_AKMP_NOT_VALID 20#define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21#define WLAN_REASON_INVALID_RSN_IE_CAPAB 22#define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23#define WLAN_REASON_CIPHER_SUITE_REJECTED 24/* Information Element IDs */#define WLAN_EID_SSID 0#define WLAN_EID_SUPP_RATES 1#define WLAN_EID_FH_PARAMS 2#define WLAN_EID_DS_PARAMS 3#define WLAN_EID_CF_PARAMS 4#define WLAN_EID_TIM 5#define WLAN_EID_IBSS_PARAMS 6#define WLAN_EID_CHALLENGE 16#define WLAN_EID_RSN 48#define WLAN_EID_GENERIC 221

/*define bit mask*/
#define WLAN_BITSET_PVER                ((BIT(1) | BIT(0)))
#define WLAN_BITSET_TODS                BIT(8)
#define WLAN_BITSET_FROMDS              BIT(9)
#define WLAN_BITSET_MOREFRAG            BIT(10)
#define WLAN_BITSET_RETRY               BIT(11)
#define WLAN_BITSET_PWRMGT              BIT(12)
#define WLAN_BITSET_MOREDATA            BIT(13)
#define WLAN_BITSET_ISWEP               BIT(14)
#define WLAN_BITSET_ORDER               BIT(15)#define WLAN_FC_GET_TODS(fc) ( (fc) & BIT(0) )#define WLAN_FC_GET_FROMDS(fc) ( ((fc) & BIT(1)) >> 1 )#define WLAN_FC_GET_MOREFRAG(fc) ( ((fc) & BIT(2)) >> 2 )#define WLAN_FC_GET_RETRY(fc) ( ((fc) & BIT(3)) >>3 )#define WLAN_FC_GET_PWRMGT(fc) ( ((fc) & BIT(4)) >>4 )#define WLAN_FC_GET_MOREDATA(fc) ( ((fc) & BIT(5)) >> 5 )#define WLAN_FC_GET_ISWEP(fc) ( ((fc) & BIT(6)) >> 6 )#define WLAN_FC_GET_ORDER(fc) ( ((fc) & BIT(7)) >> 7 )#define IEEE80211_MGMT_HDR_LEN 24#define IEEE80211_DATA_HDR3_LEN 24#define IEEE80211_DATA_HDR4_LEN 30struct platform_ieee80211_mgmt {	union {
		struct {
			uint8_t version:2;
			uint8_t type:2;
			uint8_t subtype:4;
			uint8_t to_ds:1;
			uint8_t from_ds:1;
			uint8_t more_frag:1;
			uint8_t retry:1;
			uint8_t pwrmgmt:1;
			uint8_t more_data:1;
			uint8_t wep:1;
			uint8_t order:1;
		} __attribute__ ((packed)) fc;

		uint16_t fchdr;
	} u1;	u16 duration;	u8 da[6];	u8 sa[6];	u8 bssid[6];	union {                struct {                        u16 fragment:4;                        u16 sequence:12;                } __attribute__ ((packed)) seq;                u16 seqhdr;        } u2;	union {		struct {			u16 auth_alg;			u16 auth_transaction;			u16 status_code;			/* possibly followed by Challenge text */			u8 variable[0];		} __attribute__ ((packed)) auth;		struct {			u16 reason_code;		} __attribute__ ((packed)) deauth;		struct {			u16 capab_info;			u16 listen_interval;			/* followed by SSID and Supported rates */			u8 variable[0];		} __attribute__ ((packed)) assoc_req;		struct {			u16 capab_info;			u16 status_code;			u16 aid;			/* followed by Supported rates */			u8 variable[0];		} __attribute__ ((packed)) assoc_resp, reassoc_resp;		struct {			u16 capab_info;			u16 listen_interval;			u8 current_ap[6];			/* followed by SSID and Supported rates */			u8 variable[0];		} __attribute__ ((packed)) reassoc_req;		struct {			u16 reason_code;		} __attribute__ ((packed)) disassoc;		struct {		} __attribute__ ((packed)) probe_req;		struct {			u8 timestamp[8];			u16 beacon_int;			u16 capab_info;			/* followed by some of SSID, Supported rates,			 * FH Params, DS Params, CF Params, IBSS Params, TIM */			u8 variable[0];		} __attribute__ ((packed)) beacon, probe_resp;	} u;} __attribute__ ((packed));struct platform_ieee80211_control{	union {		struct {			u8 version:2;			u8 type:2;			u8 subtype:4;			u8 to_ds:1;			u8 from_ds:1;			u8 more_frag:1;			u8 retry:1;			u8 pwrmgmt:1;			u8 more_data:1;			u8 wep:1;			u8 order:1;		} __attribute__ ((packed)) fc;				u16 fchdr;	} u1;	union {		u16 duration;		u16 aid;	} u2;		union {		u8 ra[6];		u8 bssid[6];	} u3;		union {		u8 ta[6];		u8 bssid[6];		u8 fcs[4];//for CTS and ACK	} u4;		u8 fcs[4];/*	u8 addr1[6];	u8 addr2[6];	u8 addr3[6];	union {		struct {			u16 fragment:4;			u16 sequence:12;		} __attribute__ ((packed)) seq;				u16 seqhdr;	} u3; */} __attribute__ ((packed));struct platform_ieee80211_data{	union {                struct {                        u8 version:2;                        u8 type:2;                        u8 subtype:4;                        u8 to_ds:1;                        u8 from_ds:1;                        u8 more_frag:1;                        u8 retry:1;                        u8 pwrmgmt:1;                        u8 more_data:1;                        u8 wep:1;                        u8 order:1;                } __attribute__ ((packed)) fc;                u16 fchdr;        } u1;	u16 duration;	u8 addr1[6];	u8 addr2[6];	u8 addr3[6];	union {                struct {                        u16 fragment:4;                        u16 sequence:12;                } __attribute__ ((packed)) seq;                u16 seqhdr;        } u2;	u8 addr4[6];	u8 frame_body[2312];	u8 fcs[4];} __attribute__ ((packed));struct platform_ieee80211_unknown{	union {                struct {                        u8 version:2;                        u8 type:2;                        u8 subtype:4;                        u8 to_ds:1;                        u8 from_ds:1;                        u8 more_frag:1;                        u8 retry:1;                        u8 pwrmgmt:1;                        u8 more_data:1;                        u8 wep:1;                        u8 order:1;                } __attribute__ ((packed)) fc;                u16 fchdr;        } u1;	u8 variable[0];};//define the relation between ie num and ie content//must be defined in the .c file//void frame_type_dump(int frame_type, int frame_subtype);//int wireless_frame_parse();#endif

⌨️ 快捷键说明

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