xref: /freebsd/contrib/wpa/src/drivers/driver_hostap.h (revision 95eb4b873b6a8b527c5bd78d7191975dfca38998)
1 /*
2  * Driver interaction with Linux Host AP driver
3  * Copyright (c) 2002-2006, Jouni Malinen <j@w1.fi>
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8 
9 #ifndef HOSTAP_DRIVER_H
10 #define HOSTAP_DRIVER_H
11 
12 /* netdevice private ioctls (used, e.g., with iwpriv from user space) */
13 
14 /* New wireless extensions API - SET/GET convention (even ioctl numbers are
15  * root only)
16  */
17 #define PRISM2_IOCTL_PRISM2_PARAM (SIOCIWFIRSTPRIV + 0)
18 #define PRISM2_IOCTL_GET_PRISM2_PARAM (SIOCIWFIRSTPRIV + 1)
19 #define PRISM2_IOCTL_WRITEMIF (SIOCIWFIRSTPRIV + 2)
20 #define PRISM2_IOCTL_READMIF (SIOCIWFIRSTPRIV + 3)
21 #define PRISM2_IOCTL_MONITOR (SIOCIWFIRSTPRIV + 4)
22 #define PRISM2_IOCTL_RESET (SIOCIWFIRSTPRIV + 6)
23 #define PRISM2_IOCTL_INQUIRE (SIOCIWFIRSTPRIV + 8)
24 #define PRISM2_IOCTL_WDS_ADD (SIOCIWFIRSTPRIV + 10)
25 #define PRISM2_IOCTL_WDS_DEL (SIOCIWFIRSTPRIV + 12)
26 #define PRISM2_IOCTL_SET_RID_WORD (SIOCIWFIRSTPRIV + 14)
27 #define PRISM2_IOCTL_MACCMD (SIOCIWFIRSTPRIV + 16)
28 #define PRISM2_IOCTL_ADDMAC (SIOCIWFIRSTPRIV + 18)
29 #define PRISM2_IOCTL_DELMAC (SIOCIWFIRSTPRIV + 20)
30 #define PRISM2_IOCTL_KICKMAC (SIOCIWFIRSTPRIV + 22)
31 
32 /* following are not in SIOCGIWPRIV list; check permission in the driver code
33  */
34 #define PRISM2_IOCTL_DOWNLOAD (SIOCDEVPRIVATE + 13)
35 #define PRISM2_IOCTL_HOSTAPD (SIOCDEVPRIVATE + 14)
36 
37 
38 /* PRISM2_IOCTL_PRISM2_PARAM ioctl() subtypes: */
39 enum {
40 	/* PRISM2_PARAM_PTYPE = 1, */ /* REMOVED 2003-10-22 */
41 	PRISM2_PARAM_TXRATECTRL = 2,
42 	PRISM2_PARAM_BEACON_INT = 3,
43 	PRISM2_PARAM_PSEUDO_IBSS = 4,
44 	PRISM2_PARAM_ALC = 5,
45 	/* PRISM2_PARAM_TXPOWER = 6, */ /* REMOVED 2003-10-22 */
46 	PRISM2_PARAM_DUMP = 7,
47 	PRISM2_PARAM_OTHER_AP_POLICY = 8,
48 	PRISM2_PARAM_AP_MAX_INACTIVITY = 9,
49 	PRISM2_PARAM_AP_BRIDGE_PACKETS = 10,
50 	PRISM2_PARAM_DTIM_PERIOD = 11,
51 	PRISM2_PARAM_AP_NULLFUNC_ACK = 12,
52 	PRISM2_PARAM_MAX_WDS = 13,
53 	PRISM2_PARAM_AP_AUTOM_AP_WDS = 14,
54 	PRISM2_PARAM_AP_AUTH_ALGS = 15,
55 	PRISM2_PARAM_MONITOR_ALLOW_FCSERR = 16,
56 	PRISM2_PARAM_HOST_ENCRYPT = 17,
57 	PRISM2_PARAM_HOST_DECRYPT = 18,
58 	PRISM2_PARAM_HOST_ROAMING = 21,
59 	PRISM2_PARAM_BCRX_STA_KEY = 22,
60 	PRISM2_PARAM_IEEE_802_1X = 23,
61 	PRISM2_PARAM_ANTSEL_TX = 24,
62 	PRISM2_PARAM_ANTSEL_RX = 25,
63 	PRISM2_PARAM_MONITOR_TYPE = 26,
64 	PRISM2_PARAM_WDS_TYPE = 27,
65 	PRISM2_PARAM_HOSTSCAN = 28,
66 	PRISM2_PARAM_AP_SCAN = 29,
67 	PRISM2_PARAM_ENH_SEC = 30,
68 	PRISM2_PARAM_IO_DEBUG = 31,
69 	PRISM2_PARAM_BASIC_RATES = 32,
70 	PRISM2_PARAM_OPER_RATES = 33,
71 	PRISM2_PARAM_HOSTAPD = 34,
72 	PRISM2_PARAM_HOSTAPD_STA = 35,
73 	PRISM2_PARAM_WPA = 36,
74 	PRISM2_PARAM_PRIVACY_INVOKED = 37,
75 	PRISM2_PARAM_TKIP_COUNTERMEASURES = 38,
76 	PRISM2_PARAM_DROP_UNENCRYPTED = 39,
77 	PRISM2_PARAM_SCAN_CHANNEL_MASK = 40,
78 };
79 
80 enum { HOSTAP_ANTSEL_DO_NOT_TOUCH = 0, HOSTAP_ANTSEL_DIVERSITY = 1,
81        HOSTAP_ANTSEL_LOW = 2, HOSTAP_ANTSEL_HIGH = 3 };
82 
83 
84 /* PRISM2_IOCTL_MACCMD ioctl() subcommands: */
85 enum { AP_MAC_CMD_POLICY_OPEN = 0, AP_MAC_CMD_POLICY_ALLOW = 1,
86        AP_MAC_CMD_POLICY_DENY = 2, AP_MAC_CMD_FLUSH = 3,
87        AP_MAC_CMD_KICKALL = 4 };
88 
89 
90 /* PRISM2_IOCTL_DOWNLOAD ioctl() dl_cmd: */
91 enum {
92 	PRISM2_DOWNLOAD_VOLATILE = 1 /* RAM */,
93 	/* Note! Old versions of prism2_srec have a fatal error in CRC-16
94 	 * calculation, which will corrupt all non-volatile downloads.
95 	 * PRISM2_DOWNLOAD_NON_VOLATILE used to be 2, but it is now 3 to
96 	 * prevent use of old versions of prism2_srec for non-volatile
97 	 * download. */
98 	PRISM2_DOWNLOAD_NON_VOLATILE = 3 /* FLASH */,
99 	PRISM2_DOWNLOAD_VOLATILE_GENESIS = 4 /* RAM in Genesis mode */,
100 	/* Persistent versions of volatile download commands (keep firmware
101 	 * data in memory and automatically re-download after hw_reset */
102 	PRISM2_DOWNLOAD_VOLATILE_PERSISTENT = 5,
103 	PRISM2_DOWNLOAD_VOLATILE_GENESIS_PERSISTENT = 6,
104 };
105 
106 struct prism2_download_param {
107 	u32 dl_cmd;
108 	u32 start_addr;
109 	u32 num_areas;
110 	struct prism2_download_area {
111 		u32 addr; /* wlan card address */
112 		u32 len;
113 		caddr_t ptr; /* pointer to data in user space */
114 	} data[0];
115 };
116 
117 #define PRISM2_MAX_DOWNLOAD_AREA_LEN 131072
118 #define PRISM2_MAX_DOWNLOAD_LEN 262144
119 
120 
121 /* PRISM2_IOCTL_HOSTAPD ioctl() cmd: */
122 enum {
123 	PRISM2_HOSTAPD_FLUSH = 1,
124 	PRISM2_HOSTAPD_ADD_STA = 2,
125 	PRISM2_HOSTAPD_REMOVE_STA = 3,
126 	PRISM2_HOSTAPD_GET_INFO_STA = 4,
127 	/* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */
128 	PRISM2_SET_ENCRYPTION = 6,
129 	PRISM2_GET_ENCRYPTION = 7,
130 	PRISM2_HOSTAPD_SET_FLAGS_STA = 8,
131 	PRISM2_HOSTAPD_GET_RID = 9,
132 	PRISM2_HOSTAPD_SET_RID = 10,
133 	PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR = 11,
134 	PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12,
135 	PRISM2_HOSTAPD_MLME = 13,
136 	PRISM2_HOSTAPD_SCAN_REQ = 14,
137 	PRISM2_HOSTAPD_STA_CLEAR_STATS = 15,
138 };
139 
140 #define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
141 #define PRISM2_HOSTAPD_RID_HDR_LEN \
142 ((size_t) (&((struct prism2_hostapd_param *) 0)->u.rid.data))
143 #define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
144 ((size_t) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
145 
146 /* Maximum length for algorithm names (-1 for nul termination) used in ioctl()
147  */
148 #define HOSTAP_CRYPT_ALG_NAME_LEN 16
149 
150 
151 struct prism2_hostapd_param {
152 	u32 cmd;
153 	u8 sta_addr[ETH_ALEN];
154 	union {
155 		struct {
156 			u16 aid;
157 			u16 capability;
158 			u8 tx_supp_rates;
159 		} add_sta;
160 		struct {
161 			u32 inactive_sec;
162 		} get_info_sta;
163 		struct {
164 			u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN];
165 			u32 flags;
166 			u32 err;
167 			u8 idx;
168 			u8 seq[8]; /* sequence counter (set: RX, get: TX) */
169 			u16 key_len;
170 			u8 key[0];
171 		} crypt;
172 		struct {
173 			u32 flags_and;
174 			u32 flags_or;
175 		} set_flags_sta;
176 		struct {
177 			u16 rid;
178 			u16 len;
179 			u8 data[0];
180 		} rid;
181 		struct {
182 			u8 len;
183 			u8 data[0];
184 		} generic_elem;
185 		struct {
186 #define MLME_STA_DEAUTH 0
187 #define MLME_STA_DISASSOC 1
188 			u16 cmd;
189 			u16 reason_code;
190 		} mlme;
191 		struct {
192 			u8 ssid_len;
193 			u8 ssid[SSID_MAX_LEN];
194 		} scan_req;
195 	} u;
196 };
197 
198 #define HOSTAP_CRYPT_FLAG_SET_TX_KEY BIT(0)
199 #define HOSTAP_CRYPT_FLAG_PERMANENT BIT(1)
200 
201 #define HOSTAP_CRYPT_ERR_UNKNOWN_ALG 2
202 #define HOSTAP_CRYPT_ERR_UNKNOWN_ADDR 3
203 #define HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED 4
204 #define HOSTAP_CRYPT_ERR_KEY_SET_FAILED 5
205 #define HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED 6
206 #define HOSTAP_CRYPT_ERR_CARD_CONF_FAILED 7
207 
208 #endif /* HOSTAP_DRIVER_H */
209