1 //------------------------------------------------------------------------------
2 // Copyright (c) 2004-2010 Atheros Communications Inc.
3 // All rights reserved.
4 //
5 //
6 //
7 // Permission to use, copy, modify, and/or distribute this software for any
8 // purpose with or without fee is hereby granted, provided that the above
9 // copyright notice and this permission notice appear in all copies.
10 //
11 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 //
19 //
20 //
21 // Author(s): ="Atheros"
22 //------------------------------------------------------------------------------
23 
24 #ifndef _IEEE80211_IOCTL_H_
25 #define _IEEE80211_IOCTL_H_
26 
27 #include <linux/version.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * Extracted from the MADWIFI net80211/ieee80211_ioctl.h
35  */
36 
37 /*
38  * WPA/RSN get/set key request.  Specify the key/cipher
39  * type and whether the key is to be used for sending and/or
40  * receiving.  The key index should be set only when working
41  * with global keys (use IEEE80211_KEYIX_NONE for ``no index'').
42  * Otherwise a unicast/pairwise key is specified by the bssid
43  * (on a station) or mac address (on an ap).  They key length
44  * must include any MIC key data; otherwise it should be no
45  more than IEEE80211_KEYBUF_SIZE.
46  */
47 struct ieee80211req_key {
48     u_int8_t    ik_type;    /* key/cipher type */
49     u_int8_t    ik_pad;
50     u_int16_t   ik_keyix;   /* key index */
51     u_int8_t    ik_keylen;  /* key length in bytes */
52     u_int8_t    ik_flags;
53 #define IEEE80211_KEY_XMIT  0x01
54 #define IEEE80211_KEY_RECV  0x02
55 #define IEEE80211_KEY_DEFAULT   0x80    /* default xmit key */
56     u_int8_t    ik_macaddr[IEEE80211_ADDR_LEN];
57     u_int64_t   ik_keyrsc;  /* key receive sequence counter */
58     u_int64_t   ik_keytsc;  /* key transmit sequence counter */
59     u_int8_t    ik_keydata[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE];
60 };
61 /*
62  * Delete a key either by index or address.  Set the index
63  * to IEEE80211_KEYIX_NONE when deleting a unicast key.
64  */
65 struct ieee80211req_del_key {
66     u_int8_t    idk_keyix;  /* key index */
67     u_int8_t    idk_macaddr[IEEE80211_ADDR_LEN];
68 };
69 /*
70  * MLME state manipulation request.  IEEE80211_MLME_ASSOC
71  * only makes sense when operating as a station.  The other
72  * requests can be used when operating as a station or an
73  * ap (to effect a station).
74  */
75 struct ieee80211req_mlme {
76     u_int8_t    im_op;      /* operation to perform */
77 #define IEEE80211_MLME_ASSOC        1   /* associate station */
78 #define IEEE80211_MLME_DISASSOC     2   /* disassociate station */
79 #define IEEE80211_MLME_DEAUTH       3   /* deauthenticate station */
80 #define IEEE80211_MLME_AUTHORIZE    4   /* authorize station */
81 #define IEEE80211_MLME_UNAUTHORIZE  5   /* unauthorize station */
82     u_int16_t   im_reason;  /* 802.11 reason code */
83     u_int8_t    im_macaddr[IEEE80211_ADDR_LEN];
84 };
85 
86 struct ieee80211req_addpmkid {
87     u_int8_t    pi_bssid[IEEE80211_ADDR_LEN];
88     u_int8_t    pi_enable;
89     u_int8_t    pi_pmkid[16];
90 };
91 
92 #define AUTH_ALG_OPEN_SYSTEM    0x01
93 #define AUTH_ALG_SHARED_KEY 0x02
94 #define AUTH_ALG_LEAP       0x04
95 
96 struct ieee80211req_authalg {
97    u_int8_t auth_alg;
98 };
99 
100 /*
101  * Request to add an IE to a Management Frame
102  */
103 enum{
104     IEEE80211_APPIE_FRAME_BEACON     = 0,
105     IEEE80211_APPIE_FRAME_PROBE_REQ  = 1,
106     IEEE80211_APPIE_FRAME_PROBE_RESP = 2,
107     IEEE80211_APPIE_FRAME_ASSOC_REQ  = 3,
108     IEEE80211_APPIE_FRAME_ASSOC_RESP = 4,
109     IEEE80211_APPIE_NUM_OF_FRAME     = 5
110 };
111 
112 /*
113  * The Maximum length of the IE that can be added to a Management frame
114  */
115 #define IEEE80211_APPIE_FRAME_MAX_LEN  200
116 
117 struct ieee80211req_getset_appiebuf {
118     u_int32_t app_frmtype; /* management frame type for which buffer is added */
119     u_int32_t app_buflen;  /*application supplied buffer length */
120     u_int8_t  app_buf[];
121 };
122 
123 /*
124  * The following definitions are used by an application to set filter
125  * for receiving management frames
126  */
127 enum {
128      IEEE80211_FILTER_TYPE_BEACON      =   0x1,
129      IEEE80211_FILTER_TYPE_PROBE_REQ   =   0x2,
130      IEEE80211_FILTER_TYPE_PROBE_RESP  =   0x4,
131      IEEE80211_FILTER_TYPE_ASSOC_REQ   =   0x8,
132      IEEE80211_FILTER_TYPE_ASSOC_RESP  =   0x10,
133      IEEE80211_FILTER_TYPE_AUTH        =   0x20,
134      IEEE80211_FILTER_TYPE_DEAUTH      =   0x40,
135      IEEE80211_FILTER_TYPE_DISASSOC    =   0x80,
136      IEEE80211_FILTER_TYPE_ALL         =   0xFF  /* used to check the valid filter bits */
137 };
138 
139 struct ieee80211req_set_filter {
140       u_int32_t app_filterype; /* management frame filter type */
141 };
142 
143 enum {
144     IEEE80211_PARAM_AUTHMODE = 3,   /* Authentication Mode */
145     IEEE80211_PARAM_MCASTCIPHER = 5,
146     IEEE80211_PARAM_MCASTKEYLEN = 6,    /* multicast key length */
147     IEEE80211_PARAM_UCASTCIPHER = 8,
148     IEEE80211_PARAM_UCASTKEYLEN = 9,    /* unicast key length */
149     IEEE80211_PARAM_WPA     = 10,   /* WPA mode (0,1,2) */
150     IEEE80211_PARAM_ROAMING     = 12,   /* roaming mode */
151     IEEE80211_PARAM_PRIVACY     = 13,   /* privacy invoked */
152     IEEE80211_PARAM_COUNTERMEASURES = 14,   /* WPA/TKIP countermeasures */
153     IEEE80211_PARAM_DROPUNENCRYPTED = 15,   /* discard unencrypted frames */
154     IEEE80211_PARAM_WAPI = 16,   /* WAPI policy from wapid */
155 };
156 
157 /*
158  * Values for IEEE80211_PARAM_WPA
159  */
160 #define WPA_MODE_WPA1   1
161 #define WPA_MODE_WPA2   2
162 #define WPA_MODE_AUTO   3
163 #define WPA_MODE_NONE   4
164 
165 struct ieee80211req_wpaie {
166     u_int8_t    wpa_macaddr[IEEE80211_ADDR_LEN];
167     u_int8_t    wpa_ie[IEEE80211_MAX_IE];
168     u_int8_t    rsn_ie[IEEE80211_MAX_IE];
169 };
170 
171 #ifndef IW_ENCODE_ALG_PMK
172 #define IW_ENCODE_ALG_PMK       4
173 #endif
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* _IEEE80211_IOCTL_H_ */
180