iocmd.h 8.9 KB

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