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