driver.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. * hostapd - driver interface definition
  3. * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
  4. * Copyright (c) 2007-2008, Intel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * Alternatively, this software may be distributed under the terms of BSD
  11. * license.
  12. *
  13. * See README and COPYING for more details.
  14. */
  15. #ifndef DRIVER_H
  16. #define DRIVER_H
  17. #include "sta_flags.h"
  18. struct hostapd_data;
  19. struct hostap_sta_driver_data {
  20. unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
  21. unsigned long current_tx_rate;
  22. unsigned long inactive_msec;
  23. unsigned long flags;
  24. unsigned long num_ps_buf_frames;
  25. unsigned long tx_retry_failed;
  26. unsigned long tx_retry_count;
  27. int last_rssi;
  28. int last_ack_rssi;
  29. };
  30. struct hostapd_sta_add_params {
  31. const u8 *addr;
  32. u16 aid;
  33. u16 capability;
  34. const u8 *supp_rates;
  35. size_t supp_rates_len;
  36. int flags;
  37. u16 listen_interval;
  38. const struct ht_cap_ie *ht_capabilities;
  39. };
  40. struct hostapd_freq_params {
  41. int mode;
  42. int freq;
  43. int ht_enabled;
  44. int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
  45. * secondary channel below primary, 1 = HT40
  46. * enabled, secondary channel above primary */
  47. };
  48. enum hostapd_driver_if_type {
  49. HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
  50. };
  51. struct hostapd_neighbor_bss {
  52. u8 bssid[ETH_ALEN];
  53. int freq; /* MHz */
  54. unsigned int ht:1;
  55. int pri_chan;
  56. int sec_chan; /* 0 for 20 MHz channels */
  57. };
  58. struct wpa_driver_ops {
  59. const char *name; /* as appears in the config file */
  60. void * (*init)(struct hostapd_data *hapd);
  61. void * (*init_bssid)(struct hostapd_data *hapd, const u8 *bssid);
  62. void (*deinit)(void *priv);
  63. int (*wireless_event_init)(void *priv);
  64. void (*wireless_event_deinit)(void *priv);
  65. /**
  66. * set_8021x - enable/disable IEEE 802.1X support
  67. * @ifname: Interface name (for multi-SSID/VLAN support)
  68. * @priv: driver private data
  69. * @enabled: 1 = enable, 0 = disable
  70. *
  71. * Returns: 0 on success, -1 on failure
  72. *
  73. * Configure the kernel driver to enable/disable 802.1X support.
  74. * This may be an empty function if 802.1X support is always enabled.
  75. */
  76. int (*set_ieee8021x)(const char *ifname, void *priv, int enabled);
  77. /**
  78. * set_privacy - enable/disable privacy
  79. * @priv: driver private data
  80. * @enabled: 1 = privacy enabled, 0 = disabled
  81. *
  82. * Return: 0 on success, -1 on failure
  83. *
  84. * Configure privacy.
  85. */
  86. int (*set_privacy)(const char *ifname, void *priv, int enabled);
  87. int (*set_encryption)(const char *ifname, void *priv, const char *alg,
  88. const u8 *addr, int idx,
  89. const u8 *key, size_t key_len, int txkey);
  90. int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
  91. int idx, u8 *seq);
  92. int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
  93. int idx, u8 *seq);
  94. int (*flush)(void *priv);
  95. int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
  96. size_t elem_len);
  97. int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
  98. const u8 *addr);
  99. int (*send_eapol)(void *priv, const u8 *addr, const u8 *data,
  100. size_t data_len, int encrypt, const u8 *own_addr);
  101. int (*sta_deauth)(void *priv, const u8 *addr, int reason);
  102. int (*sta_disassoc)(void *priv, const u8 *addr, int reason);
  103. int (*sta_remove)(void *priv, const u8 *addr);
  104. int (*get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
  105. int (*set_ssid)(const char *ifname, void *priv, const u8 *buf,
  106. int len);
  107. int (*set_countermeasures)(void *priv, int enabled);
  108. int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
  109. int flags);
  110. int (*set_assoc_ap)(void *priv, const u8 *addr);
  111. /* note: sta_add() is deprecated; use sta_add2() instead */
  112. int (*sta_add)(const char *ifname, void *priv, const u8 *addr, u16 aid,
  113. u16 capability, u8 *supp_rates, size_t supp_rates_len,
  114. int flags, u16 listen_interval);
  115. int (*sta_add2)(const char *ifname, void *priv,
  116. struct hostapd_sta_add_params *params);
  117. int (*get_inact_sec)(void *priv, const u8 *addr);
  118. int (*sta_clear_stats)(void *priv, const u8 *addr);
  119. /* note: set_freq() is deprecated; use set_freq2() instead */
  120. int (*set_freq)(void *priv, int mode, int freq);
  121. int (*set_freq2)(void *priv, struct hostapd_freq_params *freq);
  122. int (*set_rts)(void *priv, int rts);
  123. int (*get_rts)(void *priv, int *rts);
  124. int (*set_frag)(void *priv, int frag);
  125. int (*get_frag)(void *priv, int *frag);
  126. int (*set_retry)(void *priv, int short_retry, int long_retry);
  127. int (*get_retry)(void *priv, int *short_retry, int *long_retry);
  128. int (*sta_set_flags)(void *priv, const u8 *addr,
  129. int total_flags, int flags_or, int flags_and);
  130. int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
  131. int mode);
  132. int (*set_country)(void *priv, const char *country);
  133. int (*set_ieee80211d)(void *priv, int enabled);
  134. int (*set_beacon)(const char *ifname, void *priv,
  135. u8 *head, size_t head_len,
  136. u8 *tail, size_t tail_len);
  137. /* Configure internal bridge:
  138. * 0 = disabled, i.e., client separation is enabled (no bridging of
  139. * packets between associated STAs
  140. * 1 = enabled, i.e., bridge packets between associated STAs (default)
  141. */
  142. int (*set_internal_bridge)(void *priv, int value);
  143. int (*set_beacon_int)(void *priv, int value);
  144. int (*set_dtim_period)(const char *ifname, void *priv, int value);
  145. /* Configure broadcast SSID mode:
  146. * 0 = include SSID in Beacon frames and reply to Probe Request frames
  147. * that use broadcast SSID
  148. * 1 = hide SSID from Beacon frames and ignore Probe Request frames for
  149. * broadcast SSID
  150. */
  151. int (*set_broadcast_ssid)(void *priv, int value);
  152. int (*set_cts_protect)(void *priv, int value);
  153. int (*set_key_tx_rx_threshold)(void *priv, int value);
  154. int (*set_preamble)(void *priv, int value);
  155. int (*set_short_slot_time)(void *priv, int value);
  156. int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
  157. int cw_max, int burst_time);
  158. int (*bss_add)(void *priv, const char *ifname, const u8 *bssid);
  159. int (*bss_remove)(void *priv, const char *ifname);
  160. int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
  161. int (*passive_scan)(void *priv, int now, int our_mode_only,
  162. int interval, int _listen, int *channel,
  163. int *last_rx);
  164. struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
  165. u16 *num_modes,
  166. u16 *flags);
  167. int (*if_add)(const char *iface, void *priv,
  168. enum hostapd_driver_if_type type, char *ifname,
  169. const u8 *addr);
  170. int (*if_update)(void *priv, enum hostapd_driver_if_type type,
  171. char *ifname, const u8 *addr);
  172. int (*if_remove)(void *priv, enum hostapd_driver_if_type type,
  173. const char *ifname, const u8 *addr);
  174. int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
  175. int vlan_id);
  176. /**
  177. * commit - Optional commit changes handler
  178. * @priv: driver private data
  179. * Returns: 0 on success, -1 on failure
  180. *
  181. * This optional handler function can be registered if the driver
  182. * interface implementation needs to commit changes (e.g., by setting
  183. * network interface up) at the end of initial configuration. If set,
  184. * this handler will be called after initial setup has been completed.
  185. */
  186. int (*commit)(void *priv);
  187. int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
  188. const u8 *data, size_t data_len);
  189. int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
  190. u32 session_timeout);
  191. int (*set_radius_acl_expire)(void *priv, const u8 *mac);
  192. int (*set_ht_params)(const char *ifname, void *priv,
  193. const u8 *ht_capab, size_t ht_capab_len,
  194. const u8 *ht_oper, size_t ht_oper_len);
  195. int (*set_wps_beacon_ie)(const char *ifname, void *priv,
  196. const u8 *ie, size_t len);
  197. int (*set_wps_probe_resp_ie)(const char *ifname, void *priv,
  198. const u8 *ie, size_t len);
  199. const struct hostapd_neighbor_bss *
  200. (*get_neighbor_bss)(void *priv, size_t *num);
  201. };
  202. void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  203. int reassoc);
  204. void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
  205. const u8 *buf, size_t len, int ack);
  206. void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, const u8 *addr);
  207. int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
  208. const u8 *ie, size_t ielen);
  209. void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
  210. void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa,
  211. const u8 *buf, size_t len);
  212. struct hostapd_frame_info {
  213. u32 phytype;
  214. u32 channel;
  215. u32 datarate;
  216. u32 ssi_signal;
  217. unsigned int passive_scan:1;
  218. };
  219. void hostapd_mgmt_rx(struct hostapd_data *hapd, u8 *buf, size_t len,
  220. u16 stype, struct hostapd_frame_info *fi);
  221. void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
  222. u16 stype, int ok);
  223. void hostapd_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr);
  224. #endif /* DRIVER_H */