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