driver.h 8.8 KB

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