driver.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 channel;
  45. int ht_enabled;
  46. int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
  47. * secondary channel below primary, 1 = HT40
  48. * enabled, secondary channel above primary */
  49. };
  50. enum hostapd_driver_if_type {
  51. HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
  52. };
  53. struct hostapd_neighbor_bss {
  54. u8 bssid[ETH_ALEN];
  55. int freq; /* MHz */
  56. unsigned int ht:1;
  57. int pri_chan;
  58. int sec_chan; /* 0 for 20 MHz channels */
  59. };
  60. struct hapd_driver_ops {
  61. const char *name; /* as appears in the config file */
  62. void * (*init)(struct hostapd_data *hapd);
  63. void * (*init_bssid)(struct hostapd_data *hapd, const u8 *bssid);
  64. void (*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_key)(const char *ifname, void *priv, wpa_alg alg,
  88. const u8 *addr, int key_idx, int set_tx, const u8 *seq,
  89. size_t seq_len, const u8 *key, size_t key_len);
  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 (*sta_add)(const char *ifname, void *priv,
  111. struct hostapd_sta_add_params *params);
  112. int (*get_inact_sec)(void *priv, const u8 *addr);
  113. int (*sta_clear_stats)(void *priv, const u8 *addr);
  114. int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
  115. int (*set_rts)(void *priv, int rts);
  116. int (*set_frag)(void *priv, int frag);
  117. int (*set_retry)(void *priv, int short_retry, int long_retry);
  118. int (*sta_set_flags)(void *priv, const u8 *addr,
  119. int total_flags, int flags_or, int flags_and);
  120. int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
  121. int mode);
  122. int (*set_country)(void *priv, const char *country);
  123. int (*set_ieee80211d)(void *priv, int enabled);
  124. int (*set_beacon)(const char *ifname, void *priv,
  125. const u8 *head, size_t head_len,
  126. const u8 *tail, size_t tail_len, int dtim_period);
  127. /* Configure internal bridge:
  128. * 0 = disabled, i.e., client separation is enabled (no bridging of
  129. * packets between associated STAs
  130. * 1 = enabled, i.e., bridge packets between associated STAs (default)
  131. */
  132. int (*set_internal_bridge)(void *priv, int value);
  133. int (*set_beacon_int)(void *priv, int value);
  134. /* Configure broadcast SSID mode:
  135. * 0 = include SSID in Beacon frames and reply to Probe Request frames
  136. * that use broadcast SSID
  137. * 1 = hide SSID from Beacon frames and ignore Probe Request frames for
  138. * broadcast SSID
  139. */
  140. int (*set_broadcast_ssid)(void *priv, int value);
  141. int (*set_cts_protect)(void *priv, int value);
  142. int (*set_preamble)(void *priv, int value);
  143. int (*set_short_slot_time)(void *priv, int value);
  144. int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
  145. int cw_max, int burst_time);
  146. int (*bss_add)(void *priv, const char *ifname, const u8 *bssid);
  147. int (*bss_remove)(void *priv, const char *ifname);
  148. int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
  149. int (*passive_scan)(void *priv, int now, int our_mode_only,
  150. int interval, int _listen, int *channel,
  151. int *last_rx);
  152. struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
  153. u16 *num_modes,
  154. u16 *flags);
  155. int (*if_add)(const char *iface, void *priv,
  156. enum hostapd_driver_if_type type, char *ifname,
  157. const u8 *addr);
  158. int (*if_update)(void *priv, enum hostapd_driver_if_type type,
  159. char *ifname, const u8 *addr);
  160. int (*if_remove)(void *priv, enum hostapd_driver_if_type type,
  161. const char *ifname, const u8 *addr);
  162. int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
  163. int vlan_id);
  164. /**
  165. * commit - Optional commit changes handler
  166. * @priv: driver private data
  167. * Returns: 0 on success, -1 on failure
  168. *
  169. * This optional handler function can be registered if the driver
  170. * interface implementation needs to commit changes (e.g., by setting
  171. * network interface up) at the end of initial configuration. If set,
  172. * this handler will be called after initial setup has been completed.
  173. */
  174. int (*commit)(void *priv);
  175. int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
  176. const u8 *data, size_t data_len);
  177. int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
  178. u32 session_timeout);
  179. int (*set_radius_acl_expire)(void *priv, const u8 *mac);
  180. int (*set_ht_params)(const char *ifname, void *priv,
  181. const u8 *ht_capab, size_t ht_capab_len,
  182. const u8 *ht_oper, size_t ht_oper_len);
  183. int (*set_wps_beacon_ie)(const char *ifname, void *priv,
  184. const u8 *ie, size_t len);
  185. int (*set_wps_probe_resp_ie)(const char *ifname, void *priv,
  186. const u8 *ie, size_t len);
  187. const struct hostapd_neighbor_bss *
  188. (*get_neighbor_bss)(void *priv, size_t *num);
  189. };
  190. struct sta_info;
  191. void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
  192. int reassoc);
  193. void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
  194. const u8 *buf, size_t len, int ack);
  195. void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, const u8 *addr);
  196. int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
  197. const u8 *ie, size_t ielen);
  198. void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
  199. void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa,
  200. const u8 *buf, size_t len);
  201. struct hostapd_frame_info {
  202. u32 phytype;
  203. u32 channel;
  204. u32 datarate;
  205. u32 ssi_signal;
  206. unsigned int passive_scan:1;
  207. };
  208. void hostapd_mgmt_rx(struct hostapd_data *hapd, u8 *buf, size_t len,
  209. u16 stype, struct hostapd_frame_info *fi);
  210. void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
  211. u16 stype, int ok);
  212. void hostapd_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr);
  213. #endif /* HOSTAPD_DRIVER_H */