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 #pragma pack(1) 99 typedef struct tagSCmdRequest { 100 u8 name[16]; 101 void *data; 102 u16 wResult; 103 u16 wCmdCode; 104 } SCmdRequest, *PSCmdRequest; 105 106 // 107 // Scan 108 // 109 110 typedef struct tagSCmdScan { 111 112 u8 ssid[SSID_MAXLEN + 2]; 113 114 } SCmdScan, *PSCmdScan; 115 116 // 117 // BSS Join 118 // 119 120 typedef struct tagSCmdBSSJoin { 121 122 u16 wBSSType; 123 u16 wBBPType; 124 u8 ssid[SSID_MAXLEN + 2]; 125 u32 uChannel; 126 BOOL bPSEnable; 127 BOOL bShareKeyAuth; 128 129 } SCmdBSSJoin, *PSCmdBSSJoin; 130 131 // 132 // Zonetype Setting 133 // 134 135 typedef struct tagSCmdZoneTypeSet { 136 137 BOOL bWrite; 138 WZONETYPE ZoneType; 139 140 } SCmdZoneTypeSet, *PSCmdZoneTypeSet; 141 142 typedef struct tagSWPAResult { 143 char ifname[100]; 144 u8 proto; 145 u8 key_mgmt; 146 u8 eap_type; 147 BOOL authenticated; 148 } SWPAResult, *PSWPAResult; 149 150 typedef struct tagSCmdStartAP { 151 152 u16 wBSSType; 153 u16 wBBPType; 154 u8 ssid[SSID_MAXLEN + 2]; 155 u32 uChannel; 156 u32 uBeaconInt; 157 BOOL bShareKeyAuth; 158 u8 byBasicRate; 159 160 } SCmdStartAP, *PSCmdStartAP; 161 162 typedef struct tagSCmdSetWEP { 163 164 BOOL bEnableWep; 165 u8 byKeyIndex; 166 u8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN]; 167 BOOL bWepKeyAvailable[WEP_NKEYS]; 168 u32 auWepKeyLength[WEP_NKEYS]; 169 170 } SCmdSetWEP, *PSCmdSetWEP; 171 172 typedef struct tagSBSSIDItem { 173 174 u32 uChannel; 175 u8 abyBSSID[BSSID_LEN]; 176 u8 abySSID[SSID_MAXLEN + 1]; 177 u16 wBeaconInterval; 178 u16 wCapInfo; 179 u8 byNetType; 180 BOOL bWEPOn; 181 u32 uRSSI; 182 183 } SBSSIDItem; 184 185 186 typedef struct tagSBSSIDList { 187 188 u32 uItem; 189 SBSSIDItem sBSSIDList[0]; 190 } SBSSIDList, *PSBSSIDList; 191 192 193 typedef struct tagSNodeItem { 194 // STA info 195 u16 wAID; 196 u8 abyMACAddr[6]; 197 u16 wTxDataRate; 198 u16 wInActiveCount; 199 u16 wEnQueueCnt; 200 u16 wFlags; 201 BOOL bPWBitOn; 202 u8 byKeyIndex; 203 u16 wWepKeyLength; 204 u8 abyWepKey[WEP_KEYMAXLEN]; 205 // Auto rate fallback vars 206 BOOL bIsInFallback; 207 u32 uTxFailures; 208 u32 uTxAttempts; 209 u16 wFailureRatio; 210 211 } SNodeItem; 212 213 214 typedef struct tagSNodeList { 215 216 u32 uItem; 217 SNodeItem sNodeList[0]; 218 219 } SNodeList, *PSNodeList; 220 221 222 typedef struct tagSCmdLinkStatus { 223 224 BOOL bLink; 225 u16 wBSSType; 226 u8 byState; 227 u8 abyBSSID[BSSID_LEN]; 228 u8 abySSID[SSID_MAXLEN + 2]; 229 u32 uChannel; 230 u32 uLinkRate; 231 232 } SCmdLinkStatus, *PSCmdLinkStatus; 233 234 // 235 // 802.11 counter 236 // 237 typedef struct tagSDot11MIBCount { 238 u32 TransmittedFragmentCount; 239 u32 MulticastTransmittedFrameCount; 240 u32 FailedCount; 241 u32 RetryCount; 242 u32 MultipleRetryCount; 243 u32 RTSSuccessCount; 244 u32 RTSFailureCount; 245 u32 ACKFailureCount; 246 u32 FrameDuplicateCount; 247 u32 ReceivedFragmentCount; 248 u32 MulticastReceivedFrameCount; 249 u32 FCSErrorCount; 250 } SDot11MIBCount, *PSDot11MIBCount; 251 252 253 254 // 255 // statistic counter 256 // 257 typedef struct tagSStatMIBCount { 258 // 259 // ISR status count 260 // 261 u32 dwIsrTx0OK; 262 u32 dwIsrTx1OK; 263 u32 dwIsrBeaconTxOK; 264 u32 dwIsrRxOK; 265 u32 dwIsrTBTTInt; 266 u32 dwIsrSTIMERInt; 267 u32 dwIsrUnrecoverableError; 268 u32 dwIsrSoftInterrupt; 269 u32 dwIsrRxNoBuf; 270 ///////////////////////////////////// 271 272 u32 dwIsrUnknown; /* unknown interrupt count */ 273 274 // RSR status count 275 // 276 u32 dwRsrFrmAlgnErr; 277 u32 dwRsrErr; 278 u32 dwRsrCRCErr; 279 u32 dwRsrCRCOk; 280 u32 dwRsrBSSIDOk; 281 u32 dwRsrADDROk; 282 u32 dwRsrICVOk; 283 u32 dwNewRsrShortPreamble; 284 u32 dwRsrLong; 285 u32 dwRsrRunt; 286 287 u32 dwRsrRxControl; 288 u32 dwRsrRxData; 289 u32 dwRsrRxManage; 290 291 u32 dwRsrRxPacket; 292 u32 dwRsrRxOctet; 293 u32 dwRsrBroadcast; 294 u32 dwRsrMulticast; 295 u32 dwRsrDirected; 296 // 64-bit OID 297 u32 ullRsrOK; 298 299 // for some optional OIDs (64 bits) and DMI support 300 u32 ullRxBroadcastBytes; 301 u32 ullRxMulticastBytes; 302 u32 ullRxDirectedBytes; 303 u32 ullRxBroadcastFrames; 304 u32 ullRxMulticastFrames; 305 u32 ullRxDirectedFrames; 306 307 u32 dwRsrRxFragment; 308 u32 dwRsrRxFrmLen64; 309 u32 dwRsrRxFrmLen65_127; 310 u32 dwRsrRxFrmLen128_255; 311 u32 dwRsrRxFrmLen256_511; 312 u32 dwRsrRxFrmLen512_1023; 313 u32 dwRsrRxFrmLen1024_1518; 314 315 // TSR0,1 status count 316 // 317 u32 dwTsrTotalRetry[2]; /* total collision retry count */ 318 u32 dwTsrOnceRetry[2]; /* this packet had one collision */ 319 u32 dwTsrMoreThanOnceRetry[2]; /* this packet had many collisions */ 320 u32 dwTsrRetry[2]; /* this packet has ever occur collision, 321 * that is (dwTsrOnceCollision0 plus 322 * dwTsrMoreThanOnceCollision0) */ 323 u32 dwTsrACKData[2]; 324 u32 dwTsrErr[2]; 325 u32 dwAllTsrOK[2]; 326 u32 dwTsrRetryTimeout[2]; 327 u32 dwTsrTransmitTimeout[2]; 328 329 u32 dwTsrTxPacket[2]; 330 u32 dwTsrTxOctet[2]; 331 u32 dwTsrBroadcast[2]; 332 u32 dwTsrMulticast[2]; 333 u32 dwTsrDirected[2]; 334 335 // RD/TD count 336 u32 dwCntRxFrmLength; 337 u32 dwCntTxBufLength; 338 339 u8 abyCntRxPattern[16]; 340 u8 abyCntTxPattern[16]; 341 342 /* Software check.... */ 343 u32 dwCntRxDataErr; /* rx buffer data CRC err count */ 344 u32 dwCntDecryptErr; /* rx buffer data CRC err count */ 345 u32 dwCntRxICVErr; /* rx buffer data CRC err count */ 346 u32 idxRxErrorDesc; /* index for rx data error RD */ 347 348 /* 64-bit OID */ 349 u32 ullTsrOK[2]; 350 351 // for some optional OIDs (64 bits) and DMI support 352 u32 ullTxBroadcastFrames[2]; 353 u32 ullTxMulticastFrames[2]; 354 u32 ullTxDirectedFrames[2]; 355 u32 ullTxBroadcastBytes[2]; 356 u32 ullTxMulticastBytes[2]; 357 u32 ullTxDirectedBytes[2]; 358 } SStatMIBCount, *PSStatMIBCount; 359 360 typedef struct tagSCmdValue { 361 362 u32 dwValue; 363 364 } SCmdValue, *PSCmdValue; 365 366 // 367 // hostapd & viawget ioctl related 368 // 369 370 // VIAGWET_IOCTL_HOSTAPD ioctl() cmd: 371 enum { 372 VIAWGET_HOSTAPD_FLUSH = 1, 373 VIAWGET_HOSTAPD_ADD_STA = 2, 374 VIAWGET_HOSTAPD_REMOVE_STA = 3, 375 VIAWGET_HOSTAPD_GET_INFO_STA = 4, 376 VIAWGET_HOSTAPD_SET_ENCRYPTION = 5, 377 VIAWGET_HOSTAPD_GET_ENCRYPTION = 6, 378 VIAWGET_HOSTAPD_SET_FLAGS_STA = 7, 379 VIAWGET_HOSTAPD_SET_ASSOC_AP_ADDR = 8, 380 VIAWGET_HOSTAPD_SET_GENERIC_ELEMENT = 9, 381 VIAWGET_HOSTAPD_MLME = 10, 382 VIAWGET_HOSTAPD_SCAN_REQ = 11, 383 VIAWGET_HOSTAPD_STA_CLEAR_STATS = 12, 384 }; 385 386 #define VIAWGET_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ 387 ((int) (&((struct viawget_hostapd_param *) 0)->u.generic_elem.data)) 388 389 // Maximum length for algorithm names (-1 for nul termination) used in ioctl() 390 391 struct viawget_hostapd_param { 392 u32 cmd; 393 u8 sta_addr[6]; 394 union { 395 struct { 396 u16 aid; 397 u16 capability; 398 u8 tx_supp_rates; 399 } add_sta; 400 struct { 401 u32 inactive_sec; 402 } get_info_sta; 403 struct { 404 u8 alg; 405 u32 flags; 406 u32 err; 407 u8 idx; 408 u8 seq[8]; 409 u16 key_len; 410 u8 key[0]; 411 } crypt; 412 struct { 413 u32 flags_and; 414 u32 flags_or; 415 } set_flags_sta; 416 struct { 417 u16 rid; 418 u16 len; 419 u8 data[0]; 420 } rid; 421 struct { 422 u8 len; 423 u8 data[0]; 424 } generic_elem; 425 struct { 426 u16 cmd; 427 u16 reason_code; 428 } mlme; 429 struct { 430 u8 ssid_len; 431 u8 ssid[32]; 432 } scan_req; 433 } u; 434 }; 435 436 /*--------------------- Export Classes ----------------------------*/ 437 438 /*--------------------- Export Variables --------------------------*/ 439 440 /*--------------------- Export Types ------------------------------*/ 441 442 /*--------------------- Export Functions --------------------------*/ 443 444 #endif /* __IOCMD_H__ */ 445