iocmd.h 10.0 KB

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