📄 dot11lib.h
字号:
/*************************************************************************** DOT11_IE_COUNTRY - 802.11d parmameters***************************************************************************/typedef struct { UINT8 elementId; UINT8 length; char data[DOT11_SSID_LEN]; } _WRS_PACK_ALIGN(1) DOT11_IE_COUNTRY;/*************************************************************************** DOT11_IE_ERP - Extended Rate Phy (802.11g) parameters***************************************************************************/#define DOT11_ERP_NONERP_PRESENT _BIT(0)#define DOT11_ERP_USE_PROTECTION _BIT(1)#define DOT11_ERP_LONG_PREAMBLE _BIT(2)typedef struct { UINT8 elementId; UINT8 length; UINT8 erpInfo; } _WRS_PACK_ALIGN(1) DOT11_IE_ERP;/*************************************************************************** DOT11_ASSOC_RESP_PACKET - An association response packet***************************************************************************/typedef struct { DOT11_HEADER header; /* 802.11 Mgmt Header */ UINT16 capabilities; /* 16 bit capabilities field */ UINT16 status; /* 16 bit Status field */ UINT16 aid; DOT11_IE_SUPP_RATES rates; } _WRS_PACK_ALIGN(1) DOT11_ASSOC_RESP_PACKET;/*************************************************************************** DOT11_PS_POLL_PACKET - A powersave-poll packet***************************************************************************/typedef struct { UINT16 frameCtrl; UINT16 aid; /* Assoc AI with bit 14,15 set */ UINT8 bssid[DOT11_ADDR_LEN]; UINT8 ta[DOT11_ADDR_LEN]; } _WRS_PACK_ALIGN(1) DOT11_PS_POLL_PACKET;/*************************************************************************** DOT11_AUTH_PACKET - An authentication packet***************************************************************************/typedef struct { DOT11_HEADER header; UINT16 authAlg; UINT16 authSeq; UINT16 status; DOT11_IE_CHAL_TEXT challenge; } _WRS_PACK_ALIGN(1) DOT11_AUTH_PACKET;#define DOT11_PTK_LEN 64#define DOT11_GMK_LEN 32#define DOT11_GTK_LEN 32 /* MAX - only 128 bits for AES */#define DOT11_KEK_LEN 16#define DOT11_KCK_LEN 16#define DOT11_TK_LEN 32 /* MAX - only 128 bits for AES */#define DOT11_TK_AES_LEN 16#define DOT11_TK_TKIP_LEN 32#define DOT11_RSN_PASSPHRASE_MAX 63/* The length of the global key counter, in bytes. It should be 256 bits */#define DOT11_GKC_LEN 32#define DOT11_PMK_LEN 32typedef UINT8 DOT11_PMK[DOT11_PMK_LEN];#define DOT11_PRF_KEY_MAX 128#define DOT11_PRF_PREFIX_MAX 64#define DOT11_PRF_DATA_MAX 256/*************************************************************************** DOT11_EAPOL_KEY_PKT - This structure contains the format of an EAPOL-Key* Packet. Most EAPOL packets are parsed in the 802.1X* code, with the exception of this frame. **************************************************************************/#define DOT11_EAPOL_REPLAY_LEN 8#define DOT11_EAPOL_KEYRSC_LEN 8#define DOT11_EAPOL_KEYID_LEN 8#define DOT11_EAPOL_IV_LEN 16#define DOT11_EAPOL_MIC_LEN 16#define DOT11_NONCE_LEN 32/* This structure includes the EAPOL Header. Note that the EAPOL-Key packet ismisaligned due to the <type> field - data should be accessed using byte operations only. */typedef struct { /* EAPOL Packet Header */ UINT8 version; UINT8 eapolType; UINT16 length; /* EAPOL-Key Packet */ UINT8 type; UINT8 keyInfo[sizeof(UINT16)]; UINT8 keyLen[sizeof(UINT16)]; UINT8 replayCtr[DOT11_EAPOL_REPLAY_LEN]; UINT8 nonce[DOT11_NONCE_LEN]; UINT8 iv[DOT11_EAPOL_IV_LEN]; UINT8 rcvSeqCtr[8]; UINT8 keyId[DOT11_EAPOL_KEYID_LEN]; /* Reserved in 802.11 */ UINT8 mic[DOT11_EAPOL_MIC_LEN]; UINT8 keyDataLen[2]; /* The key data would follow here, if any */ } _WRS_PACK_ALIGN(1) DOT11_EAPOL_KEY_PKT;/* The size of the EAPOL packet header */#define DOT11_EAPOL_HEADER_SIZE 4/* The defined EAPOL type for an EAPOL-key packet */#define DOT11_EAPOL_TYPE_KEY 3#define DOT11_EAPOL_VERSION 1/* The defined keytype for IEEE 802.11 */#define DOT11_EAPOL_KEYTYPE_WPA 254#define DOT11_EAPOL_KEYTYPE_11i 2#define DOT11_RSN_MAX_KDE 1024/* The length of the KDE header is calculated as follows: ** type 1 * length 1 does not include type or length fields* OUI 3* dataType 1*/#define DOT11_EAPOL_KDE_HEADER_LEN 6/* A GTK KDE element has additional overhead - 2 bytes for the keyId */#define DOT11_EAPOL_KDE_GTK_HEADER_LEN 8#define DOT11_EAPOL_KDE_TYPE_GTK 1#define DOT11_EAPOL_KDE_TYPE_STAKEY 2#define DOT11_EAPOL_KDE_TYPE_MACADDR 3#define DOT11_EAPOL_KDE_TYPE_PMKID 4#define DOT11_EAPOL_KDE_KEYINDEX 3#define DOT11_EAPOL_KDE_TXENABLE _BIT(2)/* This structure represents a GTK KDE in 802.11i */typedef struct { UINT8 type; UINT8 length; UINT8 oui[3]; UINT8 dataType; UINT8 keyId; UINT8 reserved; UINT8 gtk[DOT11_GTK_LEN]; } DOT11_KDE;#define DOT11_KEYTYPE_PAIRWISE _BIT(3)#define DOT11_KEYTYPE_GROUP 0/* Bit set in the key information field. Note, these use bytes accesses. The below is in the first byte [0] */#define DOT11_EAPOL_INFO_DESC_AES 2#define DOT11_EAPOL_INFO_DESC_RC4 1#define DOT11_EAPOL_INFO_DESC_MASK 0x3#define DOT11_EAPOL_INFO_KEY_MASK 0x30#define DOT11_EAPOL_INFO_KEYTYPE _BIT(3)#define DOT11_EAPOL_INFO_INSTALL _BIT(6)#define DOT11_EAPOL_INFO_NO_INSTALL 0#define DOT11_EAPOL_INFO_ACK _BIT(7)#define DOT11_EAPOL_INFO_NO_ACK 0/* This info is in the second byte [1] */#define DOT11_EAPOL_INFO_MIC _BIT(8)#define DOT11_EAPOL_INFO_NO_MIC 0#define DOT11_EAPOL_INFO_SECURE _BIT(9)#define DOT11_EAPOL_INFO_NO_SECURE 0#define DOT11_EAPOL_INFO_ERROR _BIT(10)#define DOT11_EAPOL_INFO_NO_ERROR 0#define DOT11_EAPOL_INFO_REQUEST _BIT(11)#define DOT11_EAPOL_INFO_NO_REQUEST 0#define DOT11_EAPOL_INFO_ENCRYPT _BIT(12)#define DOT11_EAPOL_INFO_NO_ENCRYPT 0#define DOT11_EAPOL_NO_KEY_RSC NULL#define DOT11_EAPOL_NO_NONCE NULL#define DOT11_EAPOL_NO_RSN_IE NULL#define DOT11_EAPOL_NO_GTK NULL#define DOT11_EAPOL_NO_KEY_DATA NULL/* These are the keyInfo combinations that are tested on in dot11RsnEapolReceive() */#define DOT11_EAPOL_4WAY_MASK DOT11_EAPOL_INFO_KEYTYPE | \ DOT11_EAPOL_INFO_INSTALL | DOT11_EAPOL_INFO_ACK | DOT11_EAPOL_INFO_MIC | \ DOT11_EAPOL_INFO_SECURE | DOT11_EAPOL_INFO_ERROR | \ DOT11_EAPOL_INFO_REQUEST #define DOT11_EAPOL_4WAY_A (DOT11_KEYTYPE_PAIRWISE | DOT11_EAPOL_INFO_ACK)#define DOT11_EAPOL_4WAY_B (DOT11_KEYTYPE_PAIRWISE | DOT11_EAPOL_INFO_MIC)#define DOT11_EAPOL_4WAY_C (DOT11_KEYTYPE_PAIRWISE | DOT11_EAPOL_INFO_ACK | \ DOT11_EAPOL_INFO_MIC)#define DOT11_EAPOL_4WAY_D (DOT11_KEYTYPE_PAIRWISE | DOT11_EAPOL_INFO_MIC)#define DOT11_EAPOL_GROUP_1 (DOT11_KEYTYPE_GROUP | DOT11_EAPOL_INFO_ACK | \ DOT11_EAPOL_INFO_MIC)#define DOT11_EAPOL_GROUP_2 (DOT11_KEYTYPE_GROUP | DOT11_EAPOL_INFO_MIC)#define DOT11_GROUP_REKEY_TIME (sysClkRateGet() * 60 * 2)/* This defines the number of bytes to remove from the front of the RC4 keystream in order to discard bytes that may reveal key bits */#define DOT11_EAPOL_RC4_OFFSET 256/* This is the size of a TSC (for TKIP) or a PN (for AES). They both serve the same function, they just depend on the chosen algorithm */#define DOT11_TSC_LEN 6#define DOT11_BYTEARRAY_INC(ba, numBytes) {\ int iii=-1;\ do {\ ba[++iii]++;\ } while ((ba[iii] == 0) && (iii<(numBytes-1)));}#define DOT11_BYTEARRAY_INC_BE(ba, numBytes) {\ int iii = numBytes;\ do {\ ba[--iii]++;\ } while ((ba[iii] == 0) && (iii >= 0));}/* This copies the given byte array, reversing the order of the bytes */#define DOT11_BE_COPY(src,dst,len) {\ int iii;\ for (iii = 0; iii < len; iii++) {\ (dst)[(len-1)-iii] = (src)[iii];\ }}#define DOT11_KSL_HASH(macAddr) ((macAddr[3]) ^ (macAddr[4]) ^ (macAddr[5]))#define DOT11_KSL_MAX_HASH 256/* The amount of time te KSL entry allocation routines will wait for the semaphore before giving up */#define DOT11_KSL_ALLOC_TIME (sysClkRateGet() / 8)/*************************************************************************** DOT11_FOURWAY_STATE - definitions used in pKsl->fourWayState***************************************************************************//* States that apply to both the AP and the STA */#define DOT11_FOURWAY_INIT 0#define DOT11_FOURWAY_ESTABLISHED 10/* States that apply to the AP */#define DOT11_FOURWAY_SENT_1 1#define DOT11_FOURWAY_GOT_2 2#define DOT11_FOURWAY_SENT_3 3#define DOT11_FOURWAY_GOT_4 4/* States that apply to the STA */#define DOT11_FOURWAY_GOT_1 6#define DOT11_FOURWAY_SENT_2 7#define DOT11_FOURWAY_GOT_3 8#define DOT11_FOURWAY_SENT_4 9/*************************************************************************** DOT11_AUTH_ALGS - Supported MAC layer authentication algorithms***************************************************************************/#define DOT11_AUTH_OPEN 0#define DOT11_AUTH_SHARED_KEY 1#define DOT11_AUTH_NETWORK_EAP 128/* This isn't an official 802.11 authtype, but it is used by the driver to mean "any" authtype */#define DOT11_AUTH_ALL 3/****************************************************************************** DOT11_AUTH_SEQ - macros for ease of reading***************************************************************************/#define DOT11_AUTH_SEQ_1 1#define DOT11_AUTH_SEQ_2 2#define DOT11_AUTH_SEQ_3 3#define DOT11_AUTH_SEQ_4 4/*************************************************************************** RATE CONTROL TASK ***************************************************************************/#define DOT11_RC_DEPTH 256 /* Must be power of two *//* Reevaluate the link this many packets. */#define DOT11_RC_EVAL (DOT11_RC_DEPTH / 2) #define DOT11_RC_STATUS_SUCCESS 1#define DOT11_RC_STATUS_RETRY_OK 2#define DOT11_RC_STATUS_RETRY_FAIL 3#define DOT11_RC_STATUS_FAIL 4/* This determines how often the rate control task runs, in seconds. */#define DOT11_RC_EVAL_TIME 2 /* Seconds */#define DOT11_RC_TASK_NAME "tDot11RC%d"#define DOT11_RC_TASK_PRI 70#define DOT11_RC_STACK_SIZE (10 * 1024)/* These values specify the threshold for a rate change. They are expressed inthe ratio of total packets to failed packets or retries (note: more than one retry per packet is possible) to avoid floating point math. A higher value represents a more stable link*/#define DOT11_RC_DOWN_T_TO_R 6 /* 5 == 20 % retries */#define DOT11_RC_DOWN_T_TO_F 500 /* 1000 == 0.01 % failure */#define DOT11_RC_UP_T_TO_R 50 /* 33 ~= 3% retries */ #define DOT11_RC_UP_T_TO_F 8000 /* 6250 == 0.016 % retries *//* How many retries a failed packet counts as. Adjusting this affects how mucha missed packet affects the rate */#define DOT11_RC_RETRY_FAIL_WEIGHT 16/* The minimum number of packets that need to be received in order for the rate control algorithm to run. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -