• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * File: iocmd.h
20  *
21  * Purpose: Handles the viawget ioctl private interface functions
22  *
23  * Author: Lyndon Chen
24  *
25  * Date: May 8, 2002
26  *
27  */
28 
29 #ifndef __IOCMD_H__
30 #define __IOCMD_H__
31 
32 #include "ttype.h"
33 
34 /*---------------------  Export Definitions -------------------------*/
35 
36 // ioctl Command code
37 #define MAGIC_CODE	                 0x3142
38 #define IOCTL_CMD_TEST	            (SIOCDEVPRIVATE + 0)
39 #define IOCTL_CMD_SET			    (SIOCDEVPRIVATE + 1)
40 #define IOCTL_CMD_HOSTAPD           (SIOCDEVPRIVATE + 2)
41 #define IOCTL_CMD_WPA               (SIOCDEVPRIVATE + 3)
42 
43 typedef enum tagWMAC_CMD {
44 
45     WLAN_CMD_BSS_SCAN,
46     WLAN_CMD_BSS_JOIN,
47     WLAN_CMD_DISASSOC,
48     WLAN_CMD_SET_WEP,
49     WLAN_CMD_GET_LINK,
50     WLAN_CMD_GET_LISTLEN,
51     WLAN_CMD_GET_LIST,
52     WLAN_CMD_GET_MIB,
53     WLAN_CMD_GET_STAT,
54     WLAN_CMD_STOP_MAC,
55     WLAN_CMD_START_MAC,
56     WLAN_CMD_AP_START,
57     WLAN_CMD_SET_HOSTAPD,
58     WLAN_CMD_SET_HOSTAPD_STA,
59     WLAN_CMD_SET_802_1X,
60     WLAN_CMD_SET_HOST_WEP,
61     WLAN_CMD_SET_WPA,
62     WLAN_CMD_GET_NODE_CNT,
63     WLAN_CMD_ZONETYPE_SET,
64     WLAN_CMD_GET_NODE_LIST
65 
66 } WMAC_CMD, *PWMAC_CMD;
67 
68 typedef enum tagWZONETYPE {
69   ZoneType_USA = 0,
70   ZoneType_Japan = 1,
71   ZoneType_Europe = 2
72 } WZONETYPE;
73 
74 #define ADHOC	0
75 #define INFRA	1
76 #define BOTH	2
77 #define AP	    3
78 
79 #define ADHOC_STARTED	   1
80 #define ADHOC_JOINTED	   2
81 
82 #define PHY80211a 0
83 #define PHY80211b 1
84 #define PHY80211g 2
85 
86 #define SSID_ID                0
87 #define SSID_MAXLEN            32
88 #define BSSID_LEN              6
89 #define WEP_NKEYS              4
90 #define WEP_KEYMAXLEN          29
91 #define WEP_40BIT_LEN          5
92 #define WEP_104BIT_LEN         13
93 #define WEP_232BIT_LEN         16
94 
95 // Ioctl interface structure
96 // Command structure
97 //
98 typedef struct tagSCmdRequest {
99 	u8 name[16];
100 	void	*data;
101 	u16	    wResult;
102 	u16     wCmdCode;
103 } __packed SCmdRequest, *PSCmdRequest;
104 
105 //
106 // Scan
107 //
108 
109 typedef struct tagSCmdScan {
110 
111     u8	    ssid[SSID_MAXLEN + 2];
112 
113 } __packed SCmdScan, *PSCmdScan;
114 
115 //
116 // BSS Join
117 //
118 
119 typedef struct tagSCmdBSSJoin {
120 
121     u16	    wBSSType;
122     u16     wBBPType;
123     u8	    ssid[SSID_MAXLEN + 2];
124     u32	    uChannel;
125     BOOL    bPSEnable;
126     BOOL    bShareKeyAuth;
127 
128 } __packed SCmdBSSJoin, *PSCmdBSSJoin;
129 
130 //
131 // Zonetype Setting
132 //
133 
134 typedef struct tagSCmdZoneTypeSet {
135 
136  BOOL       bWrite;
137  WZONETYPE  ZoneType;
138 
139 } __packed SCmdZoneTypeSet, *PSCmdZoneTypeSet;
140 
141 typedef struct tagSWPAResult {
142          char	ifname[100];
143 	u8 proto;
144 	u8 key_mgmt;
145 	u8 eap_type;
146          BOOL authenticated;
147 } __packed SWPAResult, *PSWPAResult;
148 
149 typedef struct tagSCmdStartAP {
150 
151     u16	    wBSSType;
152     u16     wBBPType;
153     u8	    ssid[SSID_MAXLEN + 2];
154 	u32 uChannel;
155 	u32 uBeaconInt;
156     BOOL    bShareKeyAuth;
157     u8      byBasicRate;
158 
159 } __packed SCmdStartAP, *PSCmdStartAP;
160 
161 typedef struct tagSCmdSetWEP {
162 
163     BOOL    bEnableWep;
164     u8      byKeyIndex;
165     u8      abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN];
166     BOOL    bWepKeyAvailable[WEP_NKEYS];
167     u32     auWepKeyLength[WEP_NKEYS];
168 
169 } __packed SCmdSetWEP, *PSCmdSetWEP;
170 
171 typedef struct tagSBSSIDItem {
172 
173 	u32	    uChannel;
174     u8      abyBSSID[BSSID_LEN];
175     u8      abySSID[SSID_MAXLEN + 1];
176     u16	    wBeaconInterval;
177     u16	    wCapInfo;
178     u8      byNetType;
179     BOOL    bWEPOn;
180     u32     uRSSI;
181 
182 } __packed SBSSIDItem;
183 
184 
185 typedef struct tagSBSSIDList {
186 
187 	u32		    uItem;
188 	SBSSIDItem	sBSSIDList[0];
189 } __packed SBSSIDList, *PSBSSIDList;
190 
191 
192 typedef struct tagSNodeItem {
193     // STA info
194     u16            wAID;
195     u8             abyMACAddr[6];
196     u16            wTxDataRate;
197     u16            wInActiveCount;
198     u16            wEnQueueCnt;
199     u16            wFlags;
200     BOOL           bPWBitOn;
201     u8             byKeyIndex;
202     u16            wWepKeyLength;
203     u8            abyWepKey[WEP_KEYMAXLEN];
204     // Auto rate fallback vars
205     BOOL           bIsInFallback;
206     u32            uTxFailures;
207     u32            uTxAttempts;
208     u16            wFailureRatio;
209 
210 } __packed SNodeItem;
211 
212 
213 typedef struct tagSNodeList {
214 
215 	u32		    uItem;
216 	SNodeItem	sNodeList[0];
217 
218 } __packed SNodeList, *PSNodeList;
219 
220 
221 typedef struct tagSCmdLinkStatus {
222 
223     BOOL    bLink;
224 	u16	    wBSSType;
225 	u8      byState;
226     u8      abyBSSID[BSSID_LEN];
227     u8      abySSID[SSID_MAXLEN + 2];
228     u32     uChannel;
229     u32     uLinkRate;
230 
231 } __packed SCmdLinkStatus, *PSCmdLinkStatus;
232 
233 //
234 // 802.11 counter
235 //
236 typedef struct tagSDot11MIBCount {
237     u32 TransmittedFragmentCount;
238     u32 MulticastTransmittedFrameCount;
239     u32 FailedCount;
240     u32 RetryCount;
241     u32 MultipleRetryCount;
242     u32 RTSSuccessCount;
243     u32 RTSFailureCount;
244     u32 ACKFailureCount;
245     u32 FrameDuplicateCount;
246     u32 ReceivedFragmentCount;
247     u32 MulticastReceivedFrameCount;
248     u32 FCSErrorCount;
249 } __packed SDot11MIBCount, *PSDot11MIBCount;
250 
251 
252 
253 //
254 // statistic counter
255 //
256 typedef struct tagSStatMIBCount {
257     //
258     // ISR status count
259     //
260     u32   dwIsrTx0OK;
261     u32   dwIsrTx1OK;
262     u32   dwIsrBeaconTxOK;
263     u32   dwIsrRxOK;
264     u32   dwIsrTBTTInt;
265     u32   dwIsrSTIMERInt;
266     u32   dwIsrUnrecoverableError;
267     u32   dwIsrSoftInterrupt;
268     u32   dwIsrRxNoBuf;
269     /////////////////////////////////////
270 
271 	u32 dwIsrUnknown; /* unknown interrupt count */
272 
273     // RSR status count
274     //
275     u32   dwRsrFrmAlgnErr;
276     u32   dwRsrErr;
277     u32   dwRsrCRCErr;
278     u32   dwRsrCRCOk;
279     u32   dwRsrBSSIDOk;
280     u32   dwRsrADDROk;
281     u32   dwRsrICVOk;
282     u32   dwNewRsrShortPreamble;
283     u32   dwRsrLong;
284     u32   dwRsrRunt;
285 
286     u32   dwRsrRxControl;
287     u32   dwRsrRxData;
288     u32   dwRsrRxManage;
289 
290     u32   dwRsrRxPacket;
291     u32   dwRsrRxOctet;
292     u32   dwRsrBroadcast;
293     u32   dwRsrMulticast;
294     u32   dwRsrDirected;
295     // 64-bit OID
296     u32   ullRsrOK;
297 
298     // for some optional OIDs (64 bits) and DMI support
299     u32   ullRxBroadcastBytes;
300     u32   ullRxMulticastBytes;
301     u32   ullRxDirectedBytes;
302     u32   ullRxBroadcastFrames;
303     u32   ullRxMulticastFrames;
304     u32   ullRxDirectedFrames;
305 
306     u32   dwRsrRxFragment;
307     u32   dwRsrRxFrmLen64;
308     u32   dwRsrRxFrmLen65_127;
309     u32   dwRsrRxFrmLen128_255;
310     u32   dwRsrRxFrmLen256_511;
311     u32   dwRsrRxFrmLen512_1023;
312     u32   dwRsrRxFrmLen1024_1518;
313 
314     // TSR0,1 status count
315     //
316 	u32 dwTsrTotalRetry[2];        /* total collision retry count */
317 	u32 dwTsrOnceRetry[2];         /* this packet had one collision */
318 	u32 dwTsrMoreThanOnceRetry[2]; /* this packet had many collisions */
319 	u32 dwTsrRetry[2];             /* this packet has ever occur collision,
320 					* that is (dwTsrOnceCollision0 plus
321 					* dwTsrMoreThanOnceCollision0) */
322     u32   dwTsrACKData[2];
323     u32   dwTsrErr[2];
324     u32   dwAllTsrOK[2];
325     u32   dwTsrRetryTimeout[2];
326     u32   dwTsrTransmitTimeout[2];
327 
328     u32   dwTsrTxPacket[2];
329     u32   dwTsrTxOctet[2];
330     u32   dwTsrBroadcast[2];
331     u32   dwTsrMulticast[2];
332     u32   dwTsrDirected[2];
333 
334     // RD/TD count
335     u32   dwCntRxFrmLength;
336     u32   dwCntTxBufLength;
337 
338     u8    abyCntRxPattern[16];
339     u8    abyCntTxPattern[16];
340 
341 	/* Software check.... */
342 	u32 dwCntRxDataErr;  /* rx buffer data CRC err count */
343 	u32 dwCntDecryptErr; /* rx buffer data CRC err count */
344 	u32 dwCntRxICVErr;   /* rx buffer data CRC err count */
345 	u32 idxRxErrorDesc;  /* index for rx data error RD */
346 
347 	/* 64-bit OID */
348 	u32   ullTsrOK[2];
349 
350     // for some optional OIDs (64 bits) and DMI support
351     u32   ullTxBroadcastFrames[2];
352     u32   ullTxMulticastFrames[2];
353     u32   ullTxDirectedFrames[2];
354     u32   ullTxBroadcastBytes[2];
355     u32   ullTxMulticastBytes[2];
356     u32   ullTxDirectedBytes[2];
357 } __packed SStatMIBCount, *PSStatMIBCount;
358 
359 typedef struct tagSCmdValue {
360 
361     u32     dwValue;
362 
363 } __packed SCmdValue,  *PSCmdValue;
364 
365 //
366 // hostapd & viawget ioctl related
367 //
368 
369 // VIAGWET_IOCTL_HOSTAPD ioctl() cmd:
370 enum {
371 	VIAWGET_HOSTAPD_FLUSH = 1,
372 	VIAWGET_HOSTAPD_ADD_STA = 2,
373 	VIAWGET_HOSTAPD_REMOVE_STA = 3,
374 	VIAWGET_HOSTAPD_GET_INFO_STA = 4,
375 	VIAWGET_HOSTAPD_SET_ENCRYPTION = 5,
376 	VIAWGET_HOSTAPD_GET_ENCRYPTION = 6,
377 	VIAWGET_HOSTAPD_SET_FLAGS_STA = 7,
378 	VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR = 8,
379 	VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT = 9,
380 	VIAWGET_HOSTAPD_MLME = 10,
381 	VIAWGET_HOSTAPD_SCAN_REQ = 11,
382 	VIAWGET_HOSTAPD_STA_CLEAR_STATS = 12,
383 };
384 
385 #define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
386 ((int) (&((struct viawget_hostapd_param *) 0)->u.generic_elem.data))
387 
388 // Maximum length for algorithm names (-1 for nul termination) used in ioctl()
389 
390 struct viawget_hostapd_param {
391 	u32 cmd;
392 	u8 sta_addr[6];
393 	union {
394 		struct {
395 			u16 aid;
396 			u16 capability;
397 			u8 tx_supp_rates;
398 		} add_sta;
399 		struct {
400 			u32 inactive_sec;
401 		} get_info_sta;
402 		struct {
403 			u8 alg;
404 			u32 flags;
405 			u32 err;
406 			u8 idx;
407 			u8 seq[8];
408 			u16 key_len;
409 			u8 key[0];
410 		} crypt;
411 		struct {
412 			u32 flags_and;
413 			u32 flags_or;
414 		} set_flags_sta;
415 		struct {
416 			u16 rid;
417 			u16 len;
418 			u8 data[0];
419 		} rid;
420 		struct {
421 			u8 len;
422 			u8 data[0];
423 		} generic_elem;
424 		struct {
425 			u16 cmd;
426 			u16 reason_code;
427 		} mlme;
428 		struct {
429 			u8 ssid_len;
430 			u8 ssid[32];
431 		} scan_req;
432 	} u;
433 } __packed;
434 
435 /*---------------------  Export Classes  ----------------------------*/
436 
437 /*---------------------  Export Variables  --------------------------*/
438 
439 /*---------------------  Export Types  ------------------------------*/
440 
441 /*---------------------  Export Functions  --------------------------*/
442 
443 #endif /* __IOCMD_H__ */
444