?? wlanproto.h
字號:
/*
* Copyright ?2000-2002 Atheros Communications, Inc., All Rights Reserved.
*
* wlanproto.h - Data structures for 802.11 protocol
*
*/
#ifndef __INCwlanprotoh
#define __INCwlanprotoh
/*
* This file has the declarations specific to the 802.11 protocol.
* It has all the fields and frames (that we will use) and also
* mnemonic defines for constants. Although the MLME/PLME is part
* of the protocol too, we have kept it in a separate file for
* convenience.
*/
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "wlantype.h"
#ifdef WIN32
#pragma pack (push, 1)
#endif
/* PHY related definitions */
/* Predefined PHY types from dot11PHYType field of 802.11 MIB specification */
typedef enum phyType {
PHY_FHSS = 1, // Frequency hopping
PHY_DSSS, // Direct Sequence Spread Spectrum (original 1, 2 Mbps)
PHY_IR, // Infra Red Baseband
PHY_OFDM, // OFDM
PHY_HRDSSS, // High Rate DSSS, 11b with extensions for 5.5 and 11 Mbps
PHY_CCK = PHY_HRDSSS, // 11b is commonly called CCK in our code
PHY_ERP
} PHY_TYPE;
/* MAC related definitions */
/* MAC Address prefix allocated for Atheros devices */
#define Atheros_MACADDR0 0x00
#define Atheros_MACADDR1 0x03
#define Atheros_MACADDR2 0x7f
#define Atheros_MACADDR3 0x00
#define Atheros_MACADDR4 0x00
#define Atheros_MACADDR5 0x00
/* List of Element IDs */
#define ELE_SSID 0 /* SSID */
#define ELE_SUPPORTED_RATES 1 /* Supported Rates */
#define ELE_FH_PARAM_SET 2 /* FH Parameter set */
#define ELE_DS_PARAM_SET 3 /* DS Parameter set */
#define ELE_CF_PARAM_SET 4 /* CF Parameter set */
#define ELE_TIM 5 /* TIM vector */
#define ELE_IBSS_PARAM_SET 6 /* IBSS parameter set */
#define ELE_COUNTRY_INFO 7 /* Country Information */
#define ELE_CHLG_TEXT 16 /* Challenge text */
/* 17-31 reserved for challenge txt extension */
#define ELE_CCX_MEAS_REQUEST 38
#define ELE_CCX_MEAS_REPORT 39
#define ELE_NONERP 42 /* NOERP indication, 11g Spec Draft 5 */
#define ELE_EXT_SUPPORTED_RATES 50 /* Extended Supported Rates, 11g D6.1 */
#define ELE_NPLUSI 51 /* N + I demo element */
#define ELE_AIRONET 133 /* CCX: Aironet element */
#define ELE_CCX_AP_ADDR 149 /* CCX: AP IP Address */
#define ELE_TPC 150 /* Transmit Power Control */
#define ELE_CCKM 156 /* CCKM Request and Response elements */
#define ELE_WPA 221 /* WiFi Protected Access element */
#define ELE_CCX_RM_CAP 221 /* CCX Radio measurements */
#define ELE_VENDOR_PRIVATE 221 /* Vendor private space; must demux OUI */
/* Max sizes of variable size information elements */
#define ELE_INFO_SIZE 255 /* Max possible size for any element */
#define ELE_SSID_SIZE 32 /* SSID 0 - 32 octets */
#define ELE_RATE_SIZE 12 /* Supported rates 1 - 12 */
#define ELE_RATE_SIZE_11B 8 /* Supported rates 1 - 8 for 11b only */
#define ELE_EXT_RATE_SIZE 253 /* Extended Supported rates */
#define ELE_BITMAP_SIZE 251 /* TIM bitmap */
#define ELE_CHLG_TEXT_SIZE 253 /* Challenge text size */
#define ELE_CF_PARAM_SIZE 6 /* CF param element size */
#define ELE_IBSS_PARAM_SIZE 2 /* IBSS param element size */
#define ELE_UCSE_SIZE 32 /* unicast/pairwise key cipher suite size */
#define ELE_MCSE_SIZE 4 /* multicast/group key cipher suite size */
#define ELE_AUTHSE_SIZE 32 /* Authentication suite size */
#define ELE_COUNTRY_SIZE 3 /* Country string size */
#define ELE_TPC_SIZE 6 /* Transmit Power Control length */
/* The elements are mapped into seq ID which are used to
* represent them. This is avoid a sparse array when we
* not using the most of the Element IDs, get rid of this
* and the mapping table when the elementIDs move away from
* being sparse.
*/
typedef enum {
MAP_ELE_SSID,
MAP_ELE_SUPPORTED_RATES,
MAP_ELE_FH_PARAM_SET,
MAP_ELE_DS_PARAM_SET,
MAP_ELE_CF_PARAM_SET,
MAP_ELE_TIM,
MAP_ELE_IBSS_PARAM_SET,
MAP_ELE_COUNTRY_INFO,
MAP_ELE_CHLG_TEXT,
MAP_ELE_NONERP,
MAP_ELE_EXT_SUPPORTED_RATES,
MAP_ELE_CKIP_CSN,
MAP_ELE_TPC,
MAP_ELE_CCX_APADDR,
MAP_ELE_ESCAPE
} WLAN_ELEM_ID_MAP;
/* Frame control field of the MAC header */
/* values for the protocol version field */
#define PROTOCOL_VER_0 0 /* Standard specifies version 0 */
/* Values for frame type */
#define FRAME_MGT 0 /* Managemnt frame */
#define FRAME_CTRL 1 /* Control frame */
#define FRAME_DATA 2 /* Data frame */
#define FRAME_RESERVED 3 /* 3 is reserved value */
/* Values for frame subtype */
#define SUBT_ASSOC_REQ 0 /* Association request */
#define SUBT_ASSOC_RESP 1 /* Association response */
#define SUBT_REASSOC_REQ 2 /* Reassociation request */
#define SUBT_REASSOC_RESP 3 /* Reassociation response */
#define SUBT_PROBE_REQ 4 /* Probe request */
#define SUBT_PROBE_RESP 5 /* Probe response */
#define SUBT_BEACON 8 /* Beacon frame */
#define SUBT_ATIM 9 /* ATIM message */
#define SUBT_DISASSOC 10 /* Disassociation */
#define SUBT_AUTH 11 /* Authentication */
#define SUBT_DEAUTH 12 /* Deauthentication */
#define SUBT_ACTION 13 /* Action */
#define SUBT_PSPOLL 10 /* Power save poll */
#define SUBT_RTS 11 /* Request to Send */
#define SUBT_CTS 12 /* Clear to Send */
#define SUBT_ACK 13 /* ACK frame */
#define SUBT_CFEND 14 /* Contention-free end */
#define SUBT_CFENDACK 15 /* CF-End + CF-ACK */
#define SUBT_DATA 0 /* Just data */
#define SUBT_DATA_CFACK 1 /* Data + CF-Ack */
#define SUBT_DATA_CFPOLL 2 /* Data + CF-Poll */
#define SUBT_DATA_CFACK_CFPOLL 3 /* Data + CF-Ack + CF-Poll */
#define SUBT_NODATA 4 /* Null function, no data */
#define SUBT_NODATA_CFACK 5 /* No data + CF-Ack */
#define SUBT_NODATA_CFPOLL 6 /* No data + CF-Poll */
#define SUBT_NODATA_CFACK_CFPOLL 7 /* No data + CF-Ack + */
/* CF-Poll */
#define SUBT_QOS 8 /* The QoS dimension */
#define SUBT_QOS_NULL 12 /* SUBT_NODATA | SUBT_QOS */
/* MAC Address definitions */
#define WLAN_MAC_ADDR_SIZE 6
union wlanMACAddr {
A_UINT8 octets[WLAN_MAC_ADDR_SIZE];
A_UINT16 words[WLAN_MAC_ADDR_SIZE/2];
struct {
A_UINT32 word;
A_UINT16 half;
} __ATTRIB_PACK st;
};
/*
* Define the frame size related constants for ethernet and 802.11 frames
*/
#define MAX_ETHER_FRAME_SIZE 1514 /* max length for Ethernet/802.3 frame */
#define ETHER_HDR_SIZE 14 /* Ethernet/802.3 header length */
#define MAX_ETHER_BODY_SIZE 1500 /* max body length for Ethernet/802.3 */
#define ETHER_TYPE_SIZE 2 /* size of type or length for Ethernet/802.3 */
#define MAX_WLAN_FRAME_SIZE 2342 /* max length for 802.11 frame */
#define WLAN_HDR_SIZE 24 /* length for 802.11 frame header without address 4 */
#define WLAN_HDR4_SIZE 32 /* length for 802.11 frame header with adress 4 */
#define MAX_WLAN_BODY_SIZE 2312 /* max length for 802.11 frame body */
#define WLAN_CTRL_FRAME_SIZE (sizeof(WLAN_FRAME_ACK) + FCS_FIELD_SIZE)
#define FCS_FIELD_SIZE 4 /* size of FCS */
#define WEP_IV_FIELD_SIZE 4 /* wep IV field size */
#define AES_IV_FIELD_SIZE 4 /* aes IV field size */
#define EXT_IV_FIELD_SIZE 4 /* ext IV field size */
#define EXT_IV_BIT (1 << 29) /* ext IV bit */
#define WEP_ICV_FIELD_SIZE 4 /* wep ICV field size */
#define AES_ICV_FIELD_SIZE 8 /* AES ICV field size */
#define WEP_FIELDS_SIZE (WEP_IV_FIELD_SIZE + WEP_ICV_FIELD_SIZE) /* total size of wep fields needed */
#define MAX_IV_FIELD_SIZE (WEP_IV_FIELD_SIZE + EXT_IV_FIELD_SIZE)
#define MAX_ICV_FIELD_SIZE AES_ICV_FIELD_SIZE
#define AES_KEY_SIZE_BYTES 16 /* 128 bits */
#define TKIP_KEY_SIZE_BYTES 32 /* 256 bits */
#define CKIP_MIC_FIELD_SIZE 8 /* includes both MIC and SEQ fields */
#define TKIP_MIC_FIELD_SIZE 8 /* added at end of frame */
/* EAPOL/802.1x frames are identified by their EAPOL typeOrLen field in SNAP header. */
#define EAPOL_TYPEORLEN 0x888e // deprecate this name
#define ETHERTYPE_EAPOL EAPOL_TYPEORLEN
#define DDP_SNAP 0x0000 // only valid with Aironet SNAP
/*
* A conservative estimate of the max encap header size
* needed here would be 32 bytes for WLAN - assume four
* addr bridge mode with QoS (or just word aligned); max
* 8 bytes of IV, and another 10 bytes of overhead for
* CKIP encapsulation - all rounded up.
*/
#define MAX_ENCAP_HDRLEN 52
typedef struct EapolSNAPhdr_s {
A_UINT8 snapHeader[8];
} EAPOL_SNAP_HDR;
/* MAC header sizes in octets for various types of frames */
#define MAC_HDR_MGT_SIZE 24 /* All management frames */
#define MAC_HDR_DATA3_SIZE 24 /* Data frames with 3 addr */
#define MAC_HDR_DATA4_SIZE 30 /* Data frames with 4 addr */
/* when ToDS and FromDS are set */
#define MAC_HDR_CTRL1_SIZE 10 /* Control frames with 1 addr */
/* CTS, ACK types */
#define MAC_HDR_CTRL2_SIZE 16 /* Control frames with 2 addr */
/* all other types */
/* Power management modes */
#define PS_MODE_ACTIVE 0 /* Station is active */
#define PS_MODE_POWER_SAVE 1 /* Station going in power save mode */
/* Type of wireless lan service - access point or station */
typedef enum {
WLAN_STA_SERVICE = 0,
WLAN_AP_SERVICE = 1
} WLAN_SERVICE;
#define WLAN_OK A_OK
#ifdef BIG_ENDIAN
typedef struct wlanFrameControl {
A_UINT8 fSubtype:4, /* frame subtype */
fType:2, /* frame type - contro, mgt, data */
protoVer:2; /* protocol version */
A_UINT8 order:1, /* True for StrictOrdered service class */
wep:1, /* True for WEP encrypted body */
moreData:1, /* True if more DUs are buffered */
pwrMgt:1, /* True if STA going into PS mode */
retry:1, /* True if frame is being retransmitted */
moreFrag:1, /* True if more fragments still to come */
FromDS:1, /* FromDS bit, frame coming from DS */
ToDS:1; /* ToDS bit, frame going to DS */
} __ATTRIB_PACK FRAME_CONTROL;
typedef union wlanSeqCtrl {
struct {
A_UINT8 seqNumLo:4, /* Lower bits of the sequence number 0-4095 */
fragNum:4; /* Fragment number */
A_UINT8 seqNumHi; /* High bits of the sequence number 0-4095 */
} sc;
A_UINT16 data;
} __ATTRIB_PACK SEQ_CONTROL;
#define WLAN_GET_SEQNUM(_sc) \
(((A_UINT16)((_sc).sc.seqNumHi) << 4) | (A_UINT16)((_sc).sc.seqNumLo))
#define WLAN_SET_SEQNUM(_sc, _num) { \
(_sc).sc.seqNumHi = (A_UINT8)((_num) >> 4); \
(_sc).sc.seqNumLo = (A_UINT8)((_num) & 0x0f); \
}
#else /* Little_Endian */
typedef struct wlanFrameControl {
A_UINT8 protoVer:2, /* protocol version */
fType:2, /* frame type - contro, mgt, data */
fSubtype:4; /* frame subtype */
A_UINT8 ToDS:1, /* ToDS bit, frame going to DS */
FromDS:1, /* FromDS bit, frame coming from DS */
moreFrag:1, /* True if more fragments still to come */
retry:1, /* True if frame is being retransmitted */
pwrMgt:1, /* True if STA going into PS mode */
moreData:1, /* True if more DUs are buffered */
wep:1, /* True for WEP encrypted body */
order:1; /* True for StrictOrdered service class */
} __ATTRIB_PACK FRAME_CONTROL;
typedef union wlanSeqCtrl {
struct {
A_UINT16 fragNum:4, /* Fragment number */
seqNum:12; /* Sequence number 0-4095 */
} sc;
A_UINT16 data;
} __ATTRIB_PACK SEQ_CONTROL;
#define WLAN_GET_SEQNUM(_sc) ((_sc).sc.seqNum)
#define WLAN_SET_SEQNUM(_sc, _num) { \
(_sc).sc.seqNum = (_num); \
}
#endif /* Endianness */
#define WLAN_GET_FRAGNUM(_sc) ((_sc).sc.fragNum)
#define WLAN_SET_FRAGNUM(_sc, _num) { \
(_sc).sc.fragNum = (_num); \
}
/*
* Duration field is used in two different ways.
* When bit 15 is 0, bits 0:14 are used to update NAV.
* When bit 15 is 1 and bit 14 is 1, bits 0:13 are Association ID.
* Bit 15 and 14 are 1 during CFP
*/
typedef A_UINT16 DURATION;
#define WLAN_GET_DURATION(_dur) le2cpu16(_dur)
#define WLAN_SET_DURATION_NAV(_dur, _nav) do { \
A_UINT16 val = _nav; \
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -