drv_wlan.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-7-10 tyx the first version
  9. */
  10. #ifndef __DRV_WLAN_H__
  11. #define __DRV_WLAN_H__
  12. typedef enum
  13. {
  14. RTHW_MODE_NONE = 0,
  15. RTHW_MODE_STA,
  16. RTHW_MODE_AP,
  17. RTHW_MODE_STA_AP,
  18. RTHW_MODE_PROMISC,
  19. RTHW_MODE_P2P
  20. }rthw_mode_t;
  21. #define SHARED_ENABLED 0x00008000
  22. #define WPA_SECURITY 0x00200000
  23. #define WPA2_SECURITY 0x00400000
  24. #define WPS_ENABLED 0x10000000
  25. #define WEP_ENABLED 0x0001
  26. #define TKIP_ENABLED 0x0002
  27. #define AES_ENABLED 0x0004
  28. #define WSEC_SWFLAG 0x0008
  29. typedef enum {
  30. RTHW_SECURITY_OPEN = 0, /**< Open security */
  31. RTHW_SECURITY_WEP_PSK = WEP_ENABLED, /**< WEP Security with open authentication */
  32. RTHW_SECURITY_WEP_SHARED = ( WEP_ENABLED | SHARED_ENABLED ), /**< WEP Security with shared authentication */
  33. RTHW_SECURITY_WPA_TKIP_PSK = ( WPA_SECURITY | TKIP_ENABLED ), /**< WPA Security with TKIP */
  34. RTHW_SECURITY_WPA_AES_PSK = ( WPA_SECURITY | AES_ENABLED ), /**< WPA Security with AES */
  35. RTHW_SECURITY_WPA2_AES_PSK = ( WPA2_SECURITY | AES_ENABLED ), /**< WPA2 Security with AES */
  36. RTHW_SECURITY_WPA2_TKIP_PSK = ( WPA2_SECURITY | TKIP_ENABLED ), /**< WPA2 Security with TKIP */
  37. RTHW_SECURITY_WPA2_MIXED_PSK = ( WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED ), /**< WPA2 Security with AES & TKIP */
  38. RTHW_SECURITY_WPA_WPA2_MIXED = ( WPA_SECURITY | WPA2_SECURITY ), /**< WPA/WPA2 Security */
  39. RTHW_SECURITY_WPS_OPEN = WPS_ENABLED, /**< WPS with open security */
  40. RTHW_SECURITY_WPS_SECURE = (WPS_ENABLED | AES_ENABLED), /**< WPS with AES security */
  41. RTHW_SECURITY_UNKNOWN = -1, /**< May be returned by scan function if security is unknown. Do not pass this to the join function! */
  42. RTHW_SECURITY_FORCE_32_BIT = 0x7fffffff /**< Exists only to force rtw_security_t type to 32 bits */
  43. } rthw_security_t;
  44. typedef enum {
  45. RTHW_WIFI_EVENT_CONNECT = 0,
  46. RTHW_WIFI_EVENT_DISCONNECT = 1,
  47. RTHW_WIFI_EVENT_FOURWAY_HANDSHAKE_DONE = 2,
  48. RTHW_WIFI_EVENT_SCAN_RESULT_REPORT = 3,
  49. RTHW_WIFI_EVENT_SCAN_DONE = 4,
  50. RTHW_WIFI_EVENT_RECONNECTION_FAIL = 5,
  51. RTHW_WIFI_EVENT_SEND_ACTION_DONE = 6,
  52. RTHW_WIFI_EVENT_RX_MGNT = 7,
  53. RTHW_WIFI_EVENT_STA_ASSOC = 8,
  54. RTHW_WIFI_EVENT_STA_DISASSOC = 9,
  55. RTHW_WIFI_EVENT_STA_WPS_START = 10,
  56. RTHW_WIFI_EVENT_WPS_FINISH = 11,
  57. RTHW_WIFI_EVENT_EAPOL_START = 12,
  58. RTHW_WIFI_EVENT_EAPOL_RECVD = 13,
  59. RTHW_WIFI_EVENT_NO_NETWORK = 14,
  60. RTHW_WIFI_EVENT_BEACON_AFTER_DHCP = 15,
  61. RTHW_WIFI_EVENT_MAX,
  62. }rthw_event_indicate_t;
  63. typedef enum {
  64. RTHW_802_11_BAND_5GHZ = 0, /**< Denotes 5GHz radio band */
  65. RTHW_802_11_BAND_2_4GHZ = 1 /**< Denotes 2.4GHz radio band */
  66. } rthw_802_11_band_t;
  67. struct rthw_wlan_info
  68. {
  69. char *ssid;
  70. rt_uint8_t *bssid;
  71. rthw_802_11_band_t band;
  72. rt_uint32_t datarate;
  73. rt_uint16_t channel;
  74. rt_int16_t rssi;
  75. rthw_security_t security;
  76. };
  77. typedef void (*scan_callback_fn)(struct rthw_wlan_info *info, void *user_data);
  78. typedef void (*rthw_wlan_monitor_callback_t)(rt_uint8_t *data, int len, void *user_data);
  79. rthw_mode_t rthw_wifi_mode_get(void);
  80. int rthw_wifi_stop(void);
  81. int rthw_wifi_start(rthw_mode_t mode);
  82. int rthw_wifi_connect(char *ssid, int ssid_len, char *password, int pass_len, rthw_security_t security_type);
  83. int rthw_wifi_connect_bssid(char *bssid, char *ssid, int ssid_len, char *password, int pass_len, rthw_security_t security_type);
  84. int rthw_wifi_ap_start(char *ssid, char *password, int channel);
  85. int rthw_wifi_rssi_get(void);
  86. void rthw_wifi_channel_set(int channel);
  87. int rthw_wifi_channel_get(void);
  88. int rthw_wifi_sta_disconnect(void);
  89. int rthw_wifi_ap_disconnect(void);
  90. int rthw_wifi_scan(scan_callback_fn fun, void *data);
  91. void rthw_wifi_monitor_enable(int enable);
  92. void rthw_wifi_monitor_callback_set(rthw_wlan_monitor_callback_t callback);
  93. #endif