tls_wireless.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. #ifndef TLS_WIRELESS_H
  2. #define TLS_WIRELESS_H
  3. #include "tls_common.h"
  4. #include "wm_osal.h"
  5. #include "list.h"
  6. //#include "netif.h"
  7. struct tls_wif;
  8. struct wpa_supplicant;
  9. /* Maximum size of the SSID */
  10. #define IW_SSID_MAX_SIZE 32
  11. #if 0
  12. #define IEEE80211_MODE_INFRA 0
  13. #define IEEE80211_MODE_IBSS 1
  14. #define IEEE80211_MODE_AP 2
  15. #endif
  16. //#define IEEE80211_RATE_MODE_B BIT(0)
  17. //#define IEEE80211_RATE_MODE_G BIT(1)
  18. //#define IEEE80211_RATE_MODE_BG BIT(2)
  19. //#define IEEE80211_RATE_MODE_N BIT(3)
  20. //#define IEEE80211_RATE_MODE_BGN BIT(4)
  21. enum ieee80211_wireless_mode {
  22. IEEE80211_MODE_11B = 0,
  23. IEEE80211_MODE_11G,
  24. IEEE80211_MODE_11NG_HT20,
  25. IEEE80211_MODE_11NG_HT40PLUS,
  26. IEEE80211_MODE_11NG_HT40MINUS,
  27. IEEE80211_MODE_MAX,
  28. };
  29. #define IW_AUTH_INDEX 0x0FFF
  30. #define IW_AUTH_FLAGS 0xF000
  31. #define IW_AUTH_WPA_VERSION 0
  32. #define IW_AUTH_CIPHER_PAIRWISE 1
  33. #define IW_AUTH_CIPHER_GROUP 2
  34. #define IW_AUTH_KEY_MGMT 3
  35. #define IW_AUTH_TKIP_COUNTERMEASURES 4
  36. #define IW_AUTH_DROP_UNENCRYPTED 5
  37. #define IW_AUTH_80211_AUTH_ALG 6
  38. #define IW_AUTH_WPA_ENABLED 7
  39. #define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
  40. #define IW_AUTH_ROAMING_CONTROL 9
  41. #define IW_AUTH_PRIVACY_INVOKED 10
  42. #define IW_AUTH_CIPHER_GROUP_MGMT 11
  43. #define IW_AUTH_MFP 12
  44. /* IW_AUTH_WPA_VERSION values (bit field) */
  45. #define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
  46. #define IW_AUTH_WPA_VERSION_WPA 0x00000002
  47. #define IW_AUTH_WPA_VERSION_WPA2 0x00000004
  48. /* IW_AUTH_PAIRWISE_CIPHER, IW_AUTH_GROUP_CIPHER, and IW_AUTH_CIPHER_GROUP_MGMT
  49. * values (bit field) */
  50. #define IW_AUTH_CIPHER_NONE 0x00000001
  51. #define IW_AUTH_CIPHER_WEP40 0x00000002
  52. #define IW_AUTH_CIPHER_TKIP 0x00000004
  53. #define IW_AUTH_CIPHER_CCMP 0x00000008
  54. #define IW_AUTH_CIPHER_WEP104 0x00000010
  55. #define IW_AUTH_CIPHER_AES_CMAC 0x00000020
  56. /* IW_AUTH_KEY_MGMT values (bit field) */
  57. #define IW_AUTH_KEY_MGMT_802_1X 1
  58. #define IW_AUTH_KEY_MGMT_PSK 2
  59. /* IW_AUTH_80211_AUTH_ALG values (bit field) */
  60. #define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
  61. #define IW_AUTH_ALG_SHARED_KEY 0x00000002
  62. #define IW_AUTH_ALG_LEAP 0x00000004
  63. #define IW_ENCODE_ALG_NONE 0
  64. #define IW_ENCODE_ALG_WEP 1
  65. #define IW_ENCODE_ALG_TKIP 2
  66. #define IW_ENCODE_ALG_CCMP 3
  67. #define IW_ENCODE_ALG_PMK 4
  68. #define IW_ENCODE_ALG_AES_CMAC 5
  69. #define IW_MAX_FREQUENCIES 32
  70. #define IW_SCAN_TYPE_ACTIVE 0
  71. #define IW_SCAN_TYPE_PASSIVE 1
  72. struct iw_scan_req {
  73. u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
  74. u8 ssid_len;
  75. u8 num_channels; /* num entries in channel_list;
  76. * 0 = scan all allowed channels */
  77. u8 bssid[ETH_ALEN]; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
  78. * individual address of a specific BSS */
  79. u8 ssid[IW_SSID_MAX_SIZE];
  80. u32 extra_ies_len;
  81. u8 extra_ies[0];
  82. //struct iw_freq channel_list[IW_MAX_FREQUENCIES];
  83. };
  84. #if 0
  85. struct iw_bssid_ex {
  86. u32 length;
  87. u8 bssid[ETH_ALEN];
  88. u16 freq;
  89. u32 ssid_len;
  90. u8 ssid[IW_SSID_MAX_SIZE];
  91. u32 privacy;
  92. int rssi;
  93. u8 tsf[8];
  94. u16 beacon_int;
  95. u16 capabilities;
  96. u32 ie_len;
  97. u8 ies[0];
  98. } __attribute__ ((packed));
  99. struct iw_bss_info {
  100. u8 bssid[ETH_ALEN];
  101. u8 mode;
  102. u8 channel;
  103. u8 privacy;
  104. u8 ssid_len;
  105. u8 rssi;
  106. u8 ssid[32];
  107. };
  108. struct iw_scan_results {
  109. u32 count;
  110. struct iw_bssid_ex bssid[1];
  111. };
  112. struct iw_scan_bss {
  113. u32 count;
  114. u32 length; /* bss info total length */
  115. struct iw_bss_info bss[1];
  116. };
  117. #endif
  118. /**
  119. * struct beacon_parameters - beacon parameters
  120. *
  121. * Used to configure the beacon for an interface.
  122. *
  123. * @head: head portion of beacon (before TIM IE)
  124. * or %NULL if not changed
  125. * @tail: tail portion of beacon (after TIM IE)
  126. * or %NULL if not changed
  127. * @interval: beacon interval or zero if not changed
  128. * @dtim_period: DTIM period or zero if not changed
  129. * @head_len: length of @head
  130. * @tail_len: length of @tail
  131. */
  132. struct iw_beacon_parameters {
  133. u8 *head, *tail;
  134. int interval, dtim_period;
  135. int head_len, tail_len;
  136. };
  137. struct iw_ssid_params {
  138. u8 ssid[IW_SSID_MAX_SIZE];
  139. u8 ssid_len;
  140. u32 ie_len;
  141. u8 *ie;
  142. };
  143. struct iw_key_params {
  144. u8 key[32];
  145. u8 tsc[32];
  146. u32 key_len;
  147. u32 tsc_len;
  148. u16 cipher;
  149. bool pairwise;
  150. bool default_key;
  151. u32 key_idx;
  152. u8 addr[ETH_ALEN];
  153. };
  154. struct iw_sta_add_params {
  155. const u8 *addr;
  156. u16 aid;
  157. u16 capability;
  158. u16 listen_interval;
  159. u8 mode;
  160. const u8 *supp_rates;
  161. u32 supp_rates_len;
  162. u32 flags; /* bitmask of WPA_STA_* flags */
  163. };
  164. /**
  165. * struct beacon_parameters - beacon parameters
  166. *
  167. * Used to configure the beacon for an interface.
  168. *
  169. * @head: head portion of beacon (before TIM IE)
  170. * or %NULL if not changed
  171. * @tail: tail portion of beacon (after TIM IE)
  172. * or %NULL if not changed
  173. * @interval: beacon interval or zero if not changed
  174. * @dtim_period: DTIM period or zero if not changed
  175. * @head_len: length of @head
  176. * @tail_len: length of @tail
  177. */
  178. struct beacon_parameters {
  179. u8 *head, *tail;
  180. int interval, dtim_period;
  181. int head_len, tail_len;
  182. };
  183. struct wl_event_reload {
  184. bool reload;
  185. };
  186. struct wl_event_join_ibss_info {
  187. u8 bssid[ETH_ALEN];
  188. u32 freq;
  189. };
  190. struct wl_event_mic_err {
  191. u8 bssid[ETH_ALEN];
  192. u8 addr[ETH_ALEN];
  193. bool group_mic_err; /* TRUE: group, FALSE: pairwise */
  194. };
  195. struct wl_event_rx_eapol {
  196. u8 *src_addr;
  197. u8 *eapol_body;
  198. u32 eapol_body_len;
  199. #if TLS_CONFIG_AP
  200. u8 mode;
  201. #endif
  202. };
  203. struct wl_event_rx_mgmt {
  204. u8 *mgmt;
  205. u32 mgmt_len;
  206. };
  207. struct wl_event_rx_from_unknown {
  208. u8 addr[ETH_ALEN];
  209. };
  210. struct wl_event_assoc_info {
  211. /**
  212. * reassoc - Flag to indicate association or reassociation
  213. */
  214. int reassoc;
  215. /**
  216. * req_ies - (Re)Association Request IEs
  217. *
  218. * If the driver generates WPA/RSN IE, this event data must be
  219. * returned for WPA handshake to have needed information. If
  220. * wpa_supplicant-generated WPA/RSN IE is used, this
  221. * information event is optional.
  222. *
  223. * This should start with the first IE (fixed fields before IEs
  224. * are not included).
  225. */
  226. const u8 *req_ies;
  227. /**
  228. * req_ies_len - Length of req_ies in bytes
  229. */
  230. u32 req_ies_len;
  231. /**
  232. * resp_ies - (Re)Association Response IEs
  233. *
  234. * Optional association data from the driver. This data is not
  235. * required WPA, but may be useful for some protocols and as
  236. * such, should be reported if this is available to the driver
  237. * interface.
  238. *
  239. * This should start with the first IE (fixed fields before IEs
  240. * are not included).
  241. */
  242. u8 *resp_ies;
  243. /**
  244. * resp_ies_len - Length of resp_ies in bytes
  245. */
  246. u32 resp_ies_len;
  247. /**
  248. * addr - Station address (for AP mode)
  249. */
  250. u8 *addr;
  251. u8 *bssid;
  252. /**
  253. * freq - Frequency of the operational channel in MHz
  254. */
  255. unsigned int freq;
  256. };
  257. struct tls_wl_event_ops {
  258. int (*ibss_joined)(struct tls_wif *wif,
  259. struct wl_event_join_ibss_info *info);
  260. int (*assoc)(struct tls_wif *wif,
  261. struct wl_event_assoc_info *info);
  262. int (*disassoc)(struct tls_wif *wif);
  263. int (*scan_completed)(struct tls_wif *wif);
  264. int (*mic_err)(struct tls_wif *wif,
  265. struct wl_event_mic_err *info);
  266. int (*rx_eapol)(struct tls_wif *wif,
  267. struct wl_event_rx_eapol *eapol);
  268. int (*rx_mgmt)(struct tls_wif *wif,
  269. struct wl_event_rx_mgmt *mgmt);
  270. int (*mac_wdg)(struct tls_wif *wif);
  271. int (*chip_wakeup)(struct tls_wif *wif);
  272. #if TLS_CONFIG_AP_OPT_PS
  273. int (*beacon_done)(struct tls_wif *wif);
  274. int (*rx_ps)(struct tls_wif *wif,
  275. struct wl_event_rx_mgmt *mgmt);
  276. int (*rx_pspoll)(struct tls_wif *wif,
  277. struct wl_event_rx_from_unknown *rx_pspoll);
  278. int (*sta_active)(struct tls_wif *wif,
  279. struct wl_event_rx_from_unknown *rx_pspoll);
  280. #endif
  281. int (*rx_from_unknown_sta)(struct tls_wif *wif,
  282. struct wl_event_rx_from_unknown *rx_from_unknown);
  283. int (*net_down)(struct tls_wif *wif);
  284. int (*net_fail)(struct tls_wif *wif);
  285. int (*net_up)(struct tls_wif *wif);
  286. int (*update_stat)(struct tls_wif *wif, void *cur_bss);/* struct ieee80211_bss *cur_bss */
  287. };
  288. /* sk_buff allocated by wlan driver */
  289. struct sk_buff {
  290. struct dl_list list;
  291. u8 *buf;
  292. u32 buf_len;
  293. u32 flags;
  294. };
  295. struct tls_wif {
  296. //void *priv;
  297. struct ieee80211_if_data *priv;
  298. struct wpa_supplicant *wpa_s;
  299. struct tls_wl_event_ops *ops;
  300. #if TLS_CONFIG_SOFTAP_11N
  301. struct hostapd_iface *apif;
  302. #endif
  303. //struct netif *ethif;
  304. //bool net_up;
  305. bool wlan_create;
  306. int (*rx_data_cb)(const u8 *bssid, u8 *buf, u32 buf_len);
  307. #if TLS_CONFIG_AP
  308. bool wmm_set;
  309. void *client_event_callback;
  310. #if TLS_CONFIG_AP_OPT_FWD
  311. int (*rx_ip_cb)(const u8 *bssid, u8 *buf, u32 buf_len);
  312. #endif
  313. #endif
  314. #if 0
  315. int (*send)(struct tls_wif *wif, struct sk_buff *skb);
  316. int (*rx_data_cb)(struct tls_wif *wif, struct sk_buff *skb);
  317. int (*tx_mgmt)(struct tls_wif *wif, struct sk_buff *skb);
  318. int (*send_eapol)(struct tls_wif *wif, struct sk_buff *skb);
  319. int (*send_beacon)(struct tls_wif *wif, struct sk_buff *skb);
  320. #endif
  321. };
  322. void tls_wl_print_stats(struct tls_wif *wif);
  323. int tls_wl_if_scan(struct tls_wif *wif,
  324. struct iw_scan_req *scan_req, u16 size);
  325. int tls_wl_if_scan_result2(struct tls_wif *wif,
  326. u8 *ssid, u32 ssid_len, u8 *buf, u32 buf_size);
  327. int tls_wl_if_scan_result(struct tls_wif *wif, u8 *buf, u32 buf_size);
  328. void tls_wl_if_sta_flush(struct tls_wif *wif, u8 mode);
  329. int tls_wl_if_sta_deauth(struct tls_wif *wif, u8 *own_addr,
  330. const u8 *addr, int reason);
  331. int tls_wl_if_sta_disassoc(struct tls_wif *wif, u8 *own_addr,
  332. const u8 *addr, int reason);
  333. #if TLS_CONFIG_AP
  334. int tls_wl_if_set_tx_queue_params(struct tls_wif *wif, int queue,
  335. int aifs, int cw_min, int cw_max, int burst_time);
  336. void tls_wl_if_set_sta_flags(struct tls_wif *wif, u8 *addr, u32 flags);
  337. int tls_wl_if_send_channel_switch(struct tls_wif *wif, u8 *ownaddr, u8 newch);
  338. void tls_wl_if_switch_channel_width(struct tls_wif *wif, u8 *ownaddr);
  339. void tls_wl_if_channel_info_updata(struct tls_wif *wif);
  340. #if TLS_CONFIG_SOFTAP_11N
  341. void tls_wl_if_get_ht_param(struct tls_wif *wif, u16 *cap, u8 *mcs, u8 *mpdu);
  342. void tls_wl_if_set_sta_ht_param(struct tls_wif *wif, u8 *mac, u8 *ht);
  343. #endif
  344. #endif
  345. int tls_wl_if_set_mode(struct tls_wif *wif, u16 mode);
  346. int tls_wl_if_clear_mode(struct tls_wif *wif, u16 mode);
  347. int tls_wl_if_set_bssid(struct tls_wif *wif, const u8 *addr, u32 mode);
  348. int tls_wl_if_set_ssid(struct tls_wif *wif, struct iw_ssid_params *params);
  349. int tls_wl_if_set_auth(struct tls_wif *wif, u16 flag, u32 value, u8 mode);
  350. int tls_wl_if_set_ps_mode(struct tls_wif *wif, int powersave);
  351. int tls_wl_if_set_freq(struct tls_wif *wif,
  352. int freq);
  353. int tls_wl_if_send_eapol(struct tls_wif *wif,
  354. u8 *buf, u32 len, bool is_apsta);
  355. int tls_wl_if_xmit(struct tls_wif *wif, void *buf, int len, bool is_apsta, bool not_delay);
  356. int tls_wl_if_add_key(struct tls_wif *wif,
  357. struct iw_key_params *params);
  358. int tls_wl_if_remove_key(struct tls_wif *wif,
  359. u32 cipher,
  360. u32 key_idx,
  361. bool pairwise,
  362. u8 *addr);
  363. int tls_wl_if_send_mlme(struct tls_wif *wif,
  364. u8 *buf, u32 len);
  365. int tls_wl_if_set_rate_mode(struct tls_wif *wif,
  366. u32 rate_mode);
  367. int tls_wl_if_set_beacon(struct tls_wif *wif,
  368. struct iw_beacon_parameters *params);
  369. int tls_wl_if_del_beacon(struct tls_wif *wif);
  370. int tls_wl_if_sta_add(struct tls_wif *wif,
  371. struct iw_sta_add_params *params);
  372. int tls_wl_if_sta_remove(struct tls_wif *wif, u8 *addr);
  373. int tls_wl_if_get_inact_sec(struct tls_wif *wif, const u8 *addr);
  374. int tls_wl_if_get_scan_res(struct tls_wif *wif, u8 *buf, u32 buf_size);
  375. int tls_wl_if_get_scan_res_format2(struct tls_wif *wif, u8 *buf, u32 buf_size);
  376. int tls_wl_if_disconnect(struct tls_wif *wif);
  377. int tls_wl_if_tx(struct tls_wif *wif,
  378. u8 *buf, u32 buflen, bool last_packet, bool is_apsta, bool not_delay);
  379. int tls_wl_if_set_max_rate(struct tls_wif *wif, u8 max_rate_idx);
  380. int tls_wl_if_get_max_rate(struct tls_wif *wif, u8 *max_rate_idx);
  381. #if TLS_CONFIG_IBSS
  382. int tls_wl_if_set_adhoc(struct tls_wif *wif, int adhoc_automode);
  383. #endif
  384. int tls_wl_if_ps(int wake_up);
  385. void tls_wl_if_set_errno(int eno);
  386. int tls_wl_if_get_errno(void);
  387. void tls_wl_if_perror(const char *info);
  388. const char *tls_wl_if_get_errinfo(int eno);
  389. #endif /* end of TLS_WIRELESS_H */