Home | History | Annotate | Download | only in drivers
      1 /*
      2  * WPA Supplicant - driver_ralink exported functions
      3  * Copyright (c) 2003-2005, Jouni Malinen <j (at) w1.fi>
      4  * Copyright (c) 2007, Snowpin Lee <snowpin_lee (at) ralinktech.com.tw>
      5  *
      6  * This program is free software; you can redistribute it and/or modify
      7  * it under the terms of the GNU General Public License version 2 as
      8  * published by the Free Software Foundation.
      9  *
     10  * Alternatively, this software may be distributed under the terms of BSD
     11  * license.
     12  *
     13  * See README and COPYING for more details.
     14  */
     15 
     16 // Ralink defined OIDs
     17 #if WIRELESS_EXT <= 11
     18 #ifndef SIOCDEVPRIVATE
     19 #define SIOCDEVPRIVATE                              0x8BE0
     20 #endif
     21 #define SIOCIWFIRSTPRIV								SIOCDEVPRIVATE
     22 #endif
     23 
     24 #define RT_PRIV_IOCTL								(SIOCIWFIRSTPRIV + 0x0E)
     25 #define RTPRIV_IOCTL_SET							(SIOCIWFIRSTPRIV + 0x02)
     26 
     27 // IEEE 802.11 OIDs  &  Ralink defined OIDs  ******
     28 
     29 // (RaConfig Set/QueryInform) ==>
     30 #define OID_GET_SET_TOGGLE							0x8000
     31 
     32 #define OID_802_11_ADD_WEP                          0x0112
     33 #define OID_802_11_REMOVE_WEP                       0x0113
     34 #define OID_802_11_DISASSOCIATE                     0x0114
     35 #define OID_802_11_PRIVACY_FILTER                   0x0118
     36 #define OID_802_11_ASSOCIATION_INFORMATION          0x011E
     37 #define OID_802_11_BSSID_LIST_SCAN                  0x0508
     38 #define OID_802_11_SSID                             0x0509
     39 #define OID_802_11_BSSID                            0x050A
     40 #define OID_802_11_WEP_STATUS                       0x0510
     41 #define OID_802_11_AUTHENTICATION_MODE              0x0511
     42 #define OID_802_11_INFRASTRUCTURE_MODE              0x0512
     43 #define OID_802_11_TX_POWER_LEVEL                   0x0517
     44 #define OID_802_11_REMOVE_KEY                       0x0519
     45 #define OID_802_11_ADD_KEY                          0x0520
     46 #define OID_802_11_DEAUTHENTICATION                 0x0526
     47 #define OID_802_11_DROP_UNENCRYPTED                 0x0527
     48 #define OID_802_11_BSSID_LIST                       0x0609
     49 #define OID_802_3_CURRENT_ADDRESS                   0x060A
     50 #define OID_SET_COUNTERMEASURES                     0x0616
     51 #define OID_802_11_SET_IEEE8021X                    0x0617	// For IEEE8021x mode
     52 #define OID_802_11_SET_IEEE8021X_REQUIRE_KEY        0x0618  // For DynamicWEP in IEEE802.1x mode
     53 #define OID_802_11_PMKID                            0x0620
     54 #define RT_OID_WPA_SUPPLICANT_SUPPORT               0x0621  // for trigger driver enable/disable wpa_supplicant support
     55 #define RT_OID_WE_VERSION_COMPILED                  0x0622
     56 #define RT_OID_NEW_DRIVER                           0x0623
     57 
     58 #define PACKED  __attribute__ ((packed))
     59 
     60 //wpa_supplicant event flags
     61 #define	RT_ASSOC_EVENT_FLAG                         0x0101
     62 #define	RT_DISASSOC_EVENT_FLAG                      0x0102
     63 #define	RT_REQIE_EVENT_FLAG                         0x0103
     64 #define	RT_RESPIE_EVENT_FLAG                        0x0104
     65 #define	RT_ASSOCINFO_EVENT_FLAG                     0x0105
     66 #define RT_PMKIDCAND_FLAG                           0x0106
     67 #define RT_INTERFACE_DOWN                           0x0107
     68 #define RT_REPORT_AP_INFO                           0x0108
     69 
     70 //
     71 // IEEE 802.11 Structures and definitions
     72 //
     73 // new types for Media Specific Indications
     74 
     75 #ifndef ULONG
     76 #define CHAR            char
     77 #define INT             int
     78 #define SHORT           int
     79 #define UINT            u32
     80 #undef  ULONG
     81 //#define ULONG           u32
     82 #define ULONG           unsigned long /* 32-bit in 32-bit CPU or 64-bit in 64-bit CPU */
     83 #define USHORT          unsigned short
     84 #define UCHAR           unsigned char
     85 
     86 #define uint32		u32
     87 #define uint8		u8
     88 
     89 
     90 #define BOOLEAN         u8
     91 //#define LARGE_INTEGER s64
     92 #define VOID            void
     93 #define LONG            long
     94 #define LONGLONG        s64
     95 #define ULONGLONG       u64
     96 typedef VOID            *PVOID;
     97 typedef CHAR            *PCHAR;
     98 typedef UCHAR           *PUCHAR;
     99 typedef USHORT          *PUSHORT;
    100 typedef LONG            *PLONG;
    101 typedef ULONG           *PULONG;
    102 
    103 typedef union _LARGE_INTEGER {
    104     struct {
    105         ULONG LowPart;
    106         LONG HighPart;
    107     }vv;
    108     struct {
    109         ULONG LowPart;
    110         LONG HighPart;
    111     } u;
    112     s64 QuadPart;
    113 } LARGE_INTEGER;
    114 
    115 #endif
    116 
    117 #define NDIS_802_11_LENGTH_SSID         32
    118 #define NDIS_802_11_LENGTH_RATES        8
    119 #define NDIS_802_11_LENGTH_RATES_EX     16
    120 #define MAX_LEN_OF_SSID                 32
    121 #define MAC_ADDR_LEN                    6
    122 
    123 typedef UCHAR   NDIS_802_11_MAC_ADDRESS[6];
    124 
    125 // mask for authentication/integrity fields
    126 #define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS        0x0f
    127 
    128 #define NDIS_802_11_AUTH_REQUEST_REAUTH             0x01
    129 #define NDIS_802_11_AUTH_REQUEST_KEYUPDATE          0x02
    130 #define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR     0x06
    131 #define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR        0x0E
    132 
    133 // Added new types for OFDM 5G and 2.4G
    134 typedef enum _NDIS_802_11_NETWORK_TYPE
    135 {
    136     Ndis802_11FH,
    137     Ndis802_11DS,
    138     Ndis802_11OFDM5,
    139     Ndis802_11OFDM24,
    140     Ndis802_11Automode,
    141     Ndis802_11NetworkTypeMax    // not a real type, defined as an upper bound
    142 } NDIS_802_11_NETWORK_TYPE, *PNDIS_802_11_NETWORK_TYPE;
    143 
    144 //
    145 // Received Signal Strength Indication
    146 //
    147 typedef LONG    NDIS_802_11_RSSI;           // in dBm
    148 
    149 typedef struct _NDIS_802_11_CONFIGURATION_FH
    150 {
    151    ULONG           Length;            // Length of structure
    152    ULONG           HopPattern;        // As defined by 802.11, MSB set
    153    ULONG           HopSet;            // to one if non-802.11
    154    ULONG           DwellTime;         // units are Kusec
    155 } NDIS_802_11_CONFIGURATION_FH, *PNDIS_802_11_CONFIGURATION_FH;
    156 
    157 typedef struct _NDIS_802_11_CONFIGURATION
    158 {
    159    ULONG                           Length;             // Length of structure
    160    ULONG                           BeaconPeriod;       // units are Kusec
    161    ULONG                           ATIMWindow;         // units are Kusec
    162    ULONG                           DSConfig;           // Frequency, units are kHz
    163    NDIS_802_11_CONFIGURATION_FH    FHConfig;
    164 } NDIS_802_11_CONFIGURATION, *PNDIS_802_11_CONFIGURATION;
    165 
    166 typedef  ULONG  NDIS_802_11_KEY_INDEX;
    167 typedef ULONGLONG   NDIS_802_11_KEY_RSC;
    168 
    169 // Key mapping keys require a BSSID
    170 typedef struct _NDIS_802_11_KEY
    171 {
    172     UINT           Length;             // Length of this structure
    173     UINT           KeyIndex;
    174     UINT           KeyLength;          // length of key in bytes
    175     NDIS_802_11_MAC_ADDRESS BSSID;
    176     NDIS_802_11_KEY_RSC KeyRSC;
    177     UCHAR           KeyMaterial[1];     // variable length depending on above field
    178 } NDIS_802_11_KEY, *PNDIS_802_11_KEY;
    179 
    180 typedef struct _NDIS_802_11_REMOVE_KEY
    181 {
    182     UINT                   Length;        // Length of this structure
    183     UINT                   KeyIndex;
    184     NDIS_802_11_MAC_ADDRESS BSSID;
    185 } NDIS_802_11_REMOVE_KEY, *PNDIS_802_11_REMOVE_KEY;
    186 
    187 typedef struct PACKED _NDIS_802_11_WEP
    188 {
    189    UINT     Length;        // Length of this structure
    190    UINT           KeyIndex;           // 0 is the per-client key, 1-N are the
    191                                         // global keys
    192    UINT     KeyLength;     // length of key in bytes
    193    UCHAR     KeyMaterial[1];// variable length depending on above field
    194 } NDIS_802_11_WEP, *PNDIS_802_11_WEP;
    195 
    196 
    197 typedef enum _NDIS_802_11_NETWORK_INFRASTRUCTURE
    198 {
    199    Ndis802_11IBSS,
    200    Ndis802_11Infrastructure,
    201    Ndis802_11AutoUnknown,
    202    Ndis802_11InfrastructureMax     // Not a real value, defined as upper bound
    203 } NDIS_802_11_NETWORK_INFRASTRUCTURE, *PNDIS_802_11_NETWORK_INFRASTRUCTURE;
    204 
    205 // PMKID Structures
    206 typedef UCHAR   NDIS_802_11_PMKID_VALUE[16];
    207 
    208 typedef struct _BSSID_INFO
    209 {
    210 	NDIS_802_11_MAC_ADDRESS BSSID;
    211 	NDIS_802_11_PMKID_VALUE PMKID;
    212 } BSSID_INFO, *PBSSID_INFO;
    213 
    214 typedef struct _NDIS_802_11_PMKID
    215 {
    216 	ULONG Length;
    217 	ULONG BSSIDInfoCount;
    218 	BSSID_INFO BSSIDInfo[1];
    219 } NDIS_802_11_PMKID, *PNDIS_802_11_PMKID;
    220 
    221 //Added new types for PMKID Candidate lists.
    222 typedef struct _PMKID_CANDIDATE {
    223 	NDIS_802_11_MAC_ADDRESS BSSID;
    224 	ULONG Flags;
    225 } PMKID_CANDIDATE, *PPMKID_CANDIDATE;
    226 
    227 typedef struct _NDIS_802_11_PMKID_CANDIDATE_LIST
    228 {
    229 	ULONG Version;       // Version of the structure
    230 	ULONG NumCandidates; // No. of pmkid candidates
    231 	PMKID_CANDIDATE CandidateList[1];
    232 } NDIS_802_11_PMKID_CANDIDATE_LIST, *PNDIS_802_11_PMKID_CANDIDATE_LIST;
    233 
    234 //Flags for PMKID Candidate list structure
    235 #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED	0x01
    236 
    237 // Add new authentication modes
    238 typedef enum _NDIS_802_11_AUTHENTICATION_MODE
    239 {
    240    Ndis802_11AuthModeOpen,
    241    Ndis802_11AuthModeShared,
    242    Ndis802_11AuthModeAutoSwitch,
    243    Ndis802_11AuthModeWPA,
    244    Ndis802_11AuthModeWPAPSK,
    245    Ndis802_11AuthModeWPANone,
    246    Ndis802_11AuthModeWPA2,
    247    Ndis802_11AuthModeWPA2PSK,
    248    Ndis802_11AuthModeMax           // Not a real mode, defined as upper bound
    249 } NDIS_802_11_AUTHENTICATION_MODE, *PNDIS_802_11_AUTHENTICATION_MODE;
    250 
    251 typedef UCHAR  NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES];        // Set of 8 data rates
    252 typedef UCHAR  NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX];  // Set of 16 data rates
    253 
    254 typedef struct PACKED _NDIS_802_11_SSID
    255 {
    256     INT   SsidLength;         // length of SSID field below, in bytes;
    257                                 // this can be zero.
    258     UCHAR   Ssid[NDIS_802_11_LENGTH_SSID];           // SSID information field
    259 } NDIS_802_11_SSID, *PNDIS_802_11_SSID;
    260 
    261 
    262 typedef struct PACKED _NDIS_WLAN_BSSID
    263 {
    264    ULONG                               Length;     // Length of this structure
    265    NDIS_802_11_MAC_ADDRESS             MacAddress; // BSSID
    266    UCHAR                               Reserved[2];
    267    NDIS_802_11_SSID                    Ssid;       // SSID
    268    ULONG                               Privacy;    // WEP encryption requirement
    269     NDIS_802_11_RSSI                    Rssi;               // receive signal
    270                                                             // strength in dBm
    271    NDIS_802_11_NETWORK_TYPE            NetworkTypeInUse;
    272    NDIS_802_11_CONFIGURATION           Configuration;
    273    NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
    274    NDIS_802_11_RATES                   SupportedRates;
    275 } NDIS_WLAN_BSSID, *PNDIS_WLAN_BSSID;
    276 
    277 typedef struct PACKED _NDIS_802_11_BSSID_LIST
    278 {
    279    UINT             NumberOfItems;      // in list below, at least 1
    280    NDIS_WLAN_BSSID Bssid[1];
    281 } NDIS_802_11_BSSID_LIST, *PNDIS_802_11_BSSID_LIST;
    282 
    283 // Added Capabilities, IELength and IEs for each BSSID
    284 typedef struct PACKED _NDIS_WLAN_BSSID_EX
    285 {
    286     ULONG                               Length;             // Length of this structure
    287     NDIS_802_11_MAC_ADDRESS             MacAddress;         // BSSID
    288     UCHAR                               Reserved[2];
    289     NDIS_802_11_SSID                    Ssid;               // SSID
    290     UINT                                Privacy;            // WEP encryption requirement
    291     NDIS_802_11_RSSI                    Rssi;               // receive signal
    292                                                             // strength in dBm
    293     NDIS_802_11_NETWORK_TYPE            NetworkTypeInUse;
    294     NDIS_802_11_CONFIGURATION           Configuration;
    295     NDIS_802_11_NETWORK_INFRASTRUCTURE  InfrastructureMode;
    296     NDIS_802_11_RATES_EX                SupportedRates;
    297     ULONG                               IELength;
    298     UCHAR                               IEs[1];
    299 } NDIS_WLAN_BSSID_EX, *PNDIS_WLAN_BSSID_EX;
    300 
    301 typedef struct PACKED _NDIS_802_11_BSSID_LIST_EX
    302 {
    303     UINT                   NumberOfItems;      // in list below, at least 1
    304     NDIS_WLAN_BSSID_EX      Bssid[1];
    305 } NDIS_802_11_BSSID_LIST_EX, *PNDIS_802_11_BSSID_LIST_EX;
    306 
    307 typedef struct PACKED _NDIS_802_11_FIXED_IEs
    308 {
    309     UCHAR Timestamp[8];
    310     USHORT BeaconInterval;
    311     USHORT Capabilities;
    312 } NDIS_802_11_FIXED_IEs, *PNDIS_802_11_FIXED_IEs;
    313 
    314 // Added new encryption types
    315 // Also aliased typedef to new name
    316 typedef enum _NDIS_802_11_WEP_STATUS
    317 {
    318    Ndis802_11WEPEnabled,
    319    Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
    320    Ndis802_11WEPDisabled,
    321    Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
    322    Ndis802_11WEPKeyAbsent,
    323    Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
    324    Ndis802_11WEPNotSupported,
    325    Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
    326    Ndis802_11Encryption2Enabled,
    327    Ndis802_11Encryption2KeyAbsent,
    328    Ndis802_11Encryption3Enabled,
    329    Ndis802_11Encryption3KeyAbsent
    330 } NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
    331   NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
    332 
    333 typedef enum _NDIS_802_11_RELOAD_DEFAULTS
    334 {
    335    Ndis802_11ReloadWEPKeys
    336 } NDIS_802_11_RELOAD_DEFAULTS, *PNDIS_802_11_RELOAD_DEFAULTS;
    337 
    338 #define NDIS_802_11_AI_REQFI_CAPABILITIES      1
    339 #define NDIS_802_11_AI_REQFI_LISTENINTERVAL    2
    340 #define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS  4
    341 
    342 #define NDIS_802_11_AI_RESFI_CAPABILITIES      1
    343 #define NDIS_802_11_AI_RESFI_STATUSCODE        2
    344 #define NDIS_802_11_AI_RESFI_ASSOCIATIONID     4
    345 
    346 typedef struct _NDIS_802_11_AI_REQFI
    347 {
    348     USHORT Capabilities;
    349     USHORT ListenInterval;
    350     NDIS_802_11_MAC_ADDRESS  CurrentAPAddress;
    351 } NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI;
    352 
    353 typedef struct _NDIS_802_11_AI_RESFI
    354 {
    355     USHORT Capabilities;
    356     USHORT StatusCode;
    357     USHORT AssociationId;
    358 } NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI;
    359 
    360 typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION
    361 {
    362     ULONG                   Length;
    363     USHORT                  AvailableRequestFixedIEs;
    364     NDIS_802_11_AI_REQFI    RequestFixedIEs;
    365     ULONG                   RequestIELength;
    366     ULONG                   OffsetRequestIEs;
    367     USHORT                  AvailableResponseFixedIEs;
    368     NDIS_802_11_AI_RESFI    ResponseFixedIEs;
    369     ULONG                   ResponseIELength;
    370     ULONG                   OffsetResponseIEs;
    371 } NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION;
    372 
    373 struct ndis_pmkid_entry {
    374 	struct ndis_pmkid_entry *next;
    375 	u8 bssid[ETH_ALEN];
    376 	u8 pmkid[16];
    377 };
    378 
    379 typedef struct _MLME_DEAUTH_REQ_STRUCT {
    380     UCHAR        Addr[MAC_ADDR_LEN];
    381     USHORT       Reason;
    382 } MLME_DEAUTH_REQ_STRUCT, *PMLME_DEAUTH_REQ_STRUCT;
    383