driver.h 8.6 KB

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