driver.h 8.5 KB

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