net_wifi.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. #ifndef __NET_WIFI_H__
  2. #define __NET_WIFI_H__
  3. #include <string.h>
  4. #include <types.h>
  5. #include <sys/socket.h>
  6. #include <sys/ioctl.h>
  7. //#include <net_app.h> //YC mark
  8. //#include "platform/status_reg.h" //YC mark
  9. //#include "platform/pl_nvm_if.h" //YC mark
  10. //#include "gsl.h" //YC mark
  11. /*--------------------------------------------------------------------------------------
  12. @ WIFI Version number definition (Major.Minor.Maintain)
  13. Major - 1 Bytes : Major version Update for new module is support
  14. Minor - 2 Bytes : Minor version Update for new feature is support
  15. Maintain - 1 Bytes : Maintenance Update for bug fixing.
  16. ChangeLogs:
  17. 2011.11.15 First released version glenn.tung
  18. ---------------------------------------------------------------------------------------*/
  19. #define WIFI_VERSION 0x01000000
  20. /* Output Message Control */
  21. #define WIFI_IF_ERROR_SUPPORT
  22. //#define WIFI_IF_DEBUG_SUPPORT
  23. //#define WIFI_IF_TRACE_SUPPORT
  24. /*-------------------------------------
  25. @WIFI Driver Debug Level Setting
  26. 0: OFF no debug message display
  27. 1: ERROR display error message
  28. 2: WARN display warning message
  29. 3: TRACE display trace message, usually used.
  30. 4: INFO display informatic message
  31. 5: LOUD display all message
  32. --------------------------------------*/
  33. #define WIFI_DRIVER_DBG_LEVEL 1
  34. /* Interface Name Defines */
  35. #define RALINK_IFNAME "ra0"
  36. #ifdef NET_WIFI_DIRECT_SUPPORT
  37. #define RALINK_P2P_IFNAME "p2p0"
  38. #endif
  39. #define ATHEROS_IFNAME "wlan0"
  40. #define REALTEK_IFNAME "rtk0"
  41. #define DEFAULT_IFNAME "empty"
  42. #define SP_MIRRORBOX_NAME "SP-MirrorBox-"
  43. /* Max AP Number */
  44. #define WIFI_MAX_AP_NUM 64
  45. /* Max SSID Length */
  46. #define WIFI_SSID_MAX_LEN 33
  47. /* Max BSSID Length */
  48. #define WIFI_BSSID_MAX_LEN 32
  49. /* Max IP Address Length */
  50. #define WIFI_IPADDRS_LEN 17
  51. /* Max WEP Key Length */
  52. #define WIFI_WEP_KEY_LEN 27
  53. /* Max WPA Key Length */
  54. #define WIFI_WPA_KEY_LEN 64
  55. /* Max WIFI Interface Name Length */
  56. #define WIFI_MAX_IFNAME_LEN 6
  57. /* Max HW Addr Length */
  58. #define WIFI_MAX_HWADDR_LEN 6
  59. typedef INT32(*WifiEventCallback)(void*);
  60. typedef enum
  61. {
  62. WIFI_ERROR_CONNECT_SAMEAP = -3,
  63. WIFI_UNKNOWN = -2,
  64. WIFI_FAILURE = -1,
  65. WIFI_SUCCESS = 0
  66. }WIFI_OpStatus_e;
  67. typedef enum
  68. {
  69. INTERFACE_TYPE_ETH,
  70. INTERFACE_TYPE_WIFI1,
  71. INTERFACE_TYPE_WIFI2,
  72. INTERFACE_TYPE_WIFI3,
  73. INTERFACE_TYPE_MAX,
  74. }Interface_Type;
  75. typedef enum
  76. {
  77. NO_SECRUITY = 0,
  78. WEP_64bit_ASCII,
  79. WEP_64bit_HEX,
  80. WEP_128bit_ASCII,
  81. WEP_128bit_HEX,
  82. WPA_PSK_TKIP,
  83. WPA_PSK_AES,
  84. WPA2_PSK_TKIP,
  85. WPA2_PSK_AES,
  86. WPA_NONE_TKIP,
  87. WPA_NONE_AES,
  88. ENCRYPT_MODE_MAX,
  89. MODE_ERRORTYPE = 0xff,
  90. }Encrypt_Mode;
  91. typedef enum
  92. {
  93. WIFI_ADDRS_IP,
  94. WIFI_ADDRS_NETMASK,
  95. WIFI_ADDRS_GATEWAY,
  96. WIFI_ADDRS_DNS_SERVER,
  97. WIFI_ADDRS_DHCP_SERVER,
  98. }WIFIAddrsType_e;
  99. typedef enum {
  100. WIFI_VA_NULL=-1, //-1
  101. WIFI_VA_INTERFACE_TYPE = 0,
  102. WIFI_VA_WIFI1_DHCP, // 1
  103. WIFI_VA_WIFI2_DHCP,
  104. WIFI_VA_WIFI3_DHCP,
  105. WIFI_VA_WIFI1_IPSET, // 4 + 17
  106. WIFI_VA_WIFI2_IPSET = 21,
  107. WIFI_VA_WIFI3_IPSET = 38,
  108. WIFI_VA_WIFI1_SSID = 55, // 55 + 33
  109. WIFI_VA_WIFI2_SSID = 88,
  110. WIFI_VA_WIFI3_SSID = 101,
  111. WIFI_VA_WIFI1_NETTYPE = 134,
  112. WIFI_VA_WIFI2_NETTYPE,
  113. WIFI_VA_WIFI3_NETTYPE,
  114. WIFI_VA_WIFI1_AUTHMODE,
  115. WIFI_VA_WIFI2_AUTHMODE,
  116. WIFI_VA_WIFI3_AUTHMODE,
  117. WIFI_VA_WIFI1_ENCRYPTTYPE,
  118. WIFI_VA_WIFI2_ENCRYPTTYPE,
  119. WIFI_VA_WIFI3_ENCRYPTTYPE,
  120. WIFI_VA_WIFI1_WEPKEY, // 143 + 27
  121. WIFI_VA_WIFI2_WEPKEY = 170,
  122. WIFI_VA_WIFI3_WEPKEY = 197,
  123. WIFI_VA_WIFI1_WPAKEY = 224, // 224 + 64
  124. WIFI_VA_WIFI2_WPAKEY = 288,
  125. WIFI_VA_WIFI3_WPAKEY = 352,
  126. WIFI_VA_DEFAULT_CONNECTION = 416,
  127. WIFI_VA_CheckSum // 417 , size = 4 bytes, this should be the last addr
  128. }wifi_section_addr_t;
  129. typedef struct _WIFI_AP_INFO
  130. {
  131. INT8 ssid[33];
  132. UINT8 NetworkType;
  133. UINT8 IsEncryption;
  134. UINT8 SignalStrength;
  135. UINT8 AuthMode;
  136. UINT8 EncrypType;
  137. UINT8 BSSID[6];
  138. UINT8 IsWPSSupport;
  139. }WIFI_AP_INFO; // structure for informations of Access Point
  140. #ifdef NET_WIFI_DIRECT_SUPPORT
  141. typedef enum
  142. {
  143. P2P_STOP_SCAN = 0,
  144. P2P_SCANNING =1,
  145. P2P_STOP_SCAN_AND_LISTEN = 2
  146. }P2P_ScanType_e;
  147. typedef enum _WIFI_P2P_ConnStatus
  148. {
  149. CONNECTING_OR_NO_LINK = 0,
  150. P2P_GO = 1,
  151. P2P_CLIENT = 2,
  152. P2P_DEVICE = 3,
  153. TDLS_LINKED = 4,
  154. #ifdef NET_WFD_SUPPORT
  155. WFD_SESSION_UNAVALIBLE = 5,
  156. WFD_PEER_PC_P2P = 6,
  157. WFD_PEER_TDLS_WEAK_SECURITY = 7,
  158. #endif
  159. }WIFI_P2P_ConnStatus;
  160. #ifdef NET_WFD_SUPPORT
  161. typedef struct _WIFI_WFD_Info_t
  162. {
  163. char pszDeviceName[32];
  164. char pszMAC[17];
  165. INT32 sdTcpPort;
  166. INT32 sdMaxThroughput;
  167. INT32 sdDeviceType;
  168. char *pszPeerAddr;
  169. }WIFI_WFD_Info_t;
  170. #endif
  171. typedef struct _WIFI_P2P_Info_t
  172. {
  173. #ifdef NET_WFD_SUPPORT
  174. WIFI_WFD_Info_t stWfdInfo;
  175. #endif
  176. char szPeerAddr[17];
  177. pid_t dhcpd_pid;
  178. P2P_ScanType_e currScanType;
  179. }WIFI_P2P_Info_t;
  180. #endif
  181. #ifdef NET_WIFI_SUPPORT
  182. INT32 WIFI_Get_SetupProfileID(UINT8* pbvalue);
  183. INT32 WIFI_Set_SetupProfileID(UINT8 bvalue);
  184. INT32 WIFI_Get_SetupProfileIDTemp(UINT8* pbvalue);
  185. INT32 WIFI_Set_SetupProfileIDTemp(UINT8* pbvalue);
  186. INT32 WIFI_IF_SetDHCP(Interface_Type eInterfaceType, UINT8 bDhcp);
  187. INT32 WIFI_IF_GetDHCP(Interface_Type eInterfaceType, UINT8 *pbDhcp);
  188. INT32 WIFI_IF_SetIPAddrs(Interface_Type eInterfaceType, INT8 *pszBuf);
  189. INT32 WIFI_IF_GetIPAddrs(Interface_Type eInterfaceType, INT8 *pszBuf);
  190. INT32 WIFI_IF_SetSSID(Interface_Type eInterfaceType, INT8 *pszbuf);
  191. INT32 WIFI_IF_GetSSID(Interface_Type eInterfaceType, INT8 *pszbuf);
  192. INT32 WIFI_IF_SetNetworkType(Interface_Type eInterfaceType, UINT8 sdNetType);
  193. INT32 WIFI_IF_GetNetworkType(Interface_Type eInterfaceType, UINT8 *psdNetType);
  194. INT32 WIFI_Set_AuthMode(Interface_Type eInterfaceType, INT8 sbvalue);
  195. INT32 WIFI_Get_AuthMode(Interface_Type eInterfaceType, INT8* psbvalue);
  196. INT32 WIFI_Set_EncrypType(Interface_Type eInterfaceType, INT8 sbvalue);
  197. INT32 WIFI_Get_EncrypType(Interface_Type eInterfaceType, INT8* psbvalue);
  198. INT32 WIFI_Set_EncryptionMode(Interface_Type eInterfaceType, UINT32 sdEncryptMode);
  199. INT32 WIFI_Get_EncryptionMode(Interface_Type eInterfaceType, UINT32 *sdEncryptMode);
  200. INT32 WIFI_Set_WEPKey(Interface_Type eInterfaceType, INT8* pszStrBuf);
  201. INT32 WIFI_Get_WEPKey(Interface_Type eInterfaceType, INT8* pszStrBuf);
  202. INT32 WIFI_Set_WPAPSKKey(Interface_Type eInterfaceType, INT8* pszStrBuf);
  203. INT32 WIFI_Get_WPAPSKKey(Interface_Type eInterfaceType, INT8* pszStrBuf);
  204. void WIFI_IF_LoadProfile(void);
  205. void WIFI_IF_AuthEncryConvert(UINT8 bAuthModeIn, UINT8 bEncrypTypeIn, INT8* psbKeyStr, UINT8 *pbAuthModeOut, UINT8 *pbEncrypTypeOut, UINT8* pbUISetting);
  206. INT32 WIFI_IF_EncryptionMode_Drv2UI(UINT8 bAuthMode, UINT8 bEncrypType, char* psbKeyStr, UINT8* pbUISetting);
  207. INT32 WIFI_IF_EncryptionMode_UI2Drv(UINT8 *pbAuthModeOut, UINT8 *pbEncrypTypeOut, UINT8* pbUISetting);
  208. INT32 WIFI_IF_Autodetect_Init(INT32);
  209. char* WIFI_IF_GetIfName(void);
  210. INT32 WIFI_IF_CheckConnectionStatus(void);
  211. INT32 WIFI_IF_Initialize(WifiEventCallback pfEventCallback);
  212. INT32 WIFI_IF_Finalize(void);
  213. INT32 WIFI_IF_RegisterDongle(char *pszDonlgeIfName);
  214. INT32 WIFI_IF_UnregisterDongle(char *pszDonlgeIfName);
  215. void WIFI_GetVersion(UINT32 *pdVersion);
  216. void WIFI_IF_HandleWextEvent(char *pData, INT32 sdLen);
  217. #ifdef NET_WIFI_DIRECT_SUPPORT
  218. INT32 WIFI_IF_SetP2PMode(P2P_ScanType_e operationMode);
  219. void WIFI_P2P_IF_SubscribeCBKFunc(WifiEventCallback pfEventCallBack);
  220. INT32 WIFI_IF_SignalHdrRoutine(void);
  221. #ifdef NET_WFD_SUPPORT
  222. INT32 WIFI_WFD_IF_GetPeerDeviceInfo(WIFI_WFD_Info_t *pstWfdInfo);
  223. #endif /* NET_WFD_SUPPORT */
  224. #endif /* NET_WIFI_DIRECT_SUPPORT */
  225. #endif /* NET_WIFI_SUPPORT */
  226. #endif /* __NET_WIFI_H__ */