ap_drv_ops.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * hostapd - Driver operations
  3. * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef AP_DRV_OPS
  15. #define AP_DRV_OPS
  16. enum wpa_driver_if_type;
  17. struct wpa_bss_params;
  18. struct wpa_driver_scan_params;
  19. struct ieee80211_ht_capabilities;
  20. u32 hostapd_sta_flags_to_drv(u32 flags);
  21. int hostapd_set_ap_wps_ie(struct hostapd_data *hapd);
  22. int hostapd_set_authorized(struct hostapd_data *hapd,
  23. struct sta_info *sta, int authorized);
  24. int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta);
  25. int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
  26. int enabled);
  27. int hostapd_set_bss_params(struct hostapd_data *hapd, int use_protection);
  28. int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname);
  29. int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname);
  30. int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid,
  31. int val);
  32. int hostapd_sta_add(struct hostapd_data *hapd,
  33. const u8 *addr, u16 aid, u16 capability,
  34. const u8 *supp_rates, size_t supp_rates_len,
  35. u16 listen_interval,
  36. const struct ieee80211_ht_capabilities *ht_capab);
  37. int hostapd_set_privacy(struct hostapd_data *hapd, int enabled);
  38. int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
  39. size_t elem_len);
  40. int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len);
  41. int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len);
  42. int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
  43. const char *ifname, const u8 *addr, void *bss_ctx,
  44. void **drv_priv, char *force_ifname, u8 *if_addr,
  45. const char *bridge);
  46. int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
  47. const char *ifname);
  48. int hostapd_set_ieee8021x(struct hostapd_data *hapd,
  49. struct wpa_bss_params *params);
  50. int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
  51. const u8 *addr, int idx, u8 *seq);
  52. int hostapd_flush(struct hostapd_data *hapd);
  53. int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq,
  54. int channel, int ht_enabled, int sec_channel_offset);
  55. int hostapd_set_rts(struct hostapd_data *hapd, int rts);
  56. int hostapd_set_frag(struct hostapd_data *hapd, int frag);
  57. int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
  58. int total_flags, int flags_or, int flags_and);
  59. int hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
  60. int *basic_rates, int mode);
  61. int hostapd_set_country(struct hostapd_data *hapd, const char *country);
  62. int hostapd_set_cts_protect(struct hostapd_data *hapd, int value);
  63. int hostapd_set_preamble(struct hostapd_data *hapd, int value);
  64. int hostapd_set_short_slot_time(struct hostapd_data *hapd, int value);
  65. int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
  66. int cw_min, int cw_max, int burst_time);
  67. int hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
  68. const u8 *mask);
  69. struct hostapd_hw_modes *
  70. hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
  71. u16 *flags);
  72. int hostapd_driver_commit(struct hostapd_data *hapd);
  73. int hostapd_set_ht_params(struct hostapd_data *hapd,
  74. const u8 *ht_capab, size_t ht_capab_len,
  75. const u8 *ht_oper, size_t ht_oper_len);
  76. int hostapd_drv_none(struct hostapd_data *hapd);
  77. int hostapd_driver_scan(struct hostapd_data *hapd,
  78. struct wpa_driver_scan_params *params);
  79. struct wpa_scan_results * hostapd_driver_get_scan_results(
  80. struct hostapd_data *hapd);
  81. int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
  82. int duration);
  83. int hostapd_drv_set_key(const char *ifname,
  84. struct hostapd_data *hapd,
  85. enum wpa_alg alg, const u8 *addr,
  86. int key_idx, int set_tx,
  87. const u8 *seq, size_t seq_len,
  88. const u8 *key, size_t key_len);
  89. int hostapd_drv_send_mlme(struct hostapd_data *hapd,
  90. const void *msg, size_t len);
  91. int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
  92. const u8 *addr, int reason);
  93. int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
  94. const u8 *addr, int reason);
  95. #include "drivers/driver.h"
  96. static inline int hostapd_drv_set_countermeasures(struct hostapd_data *hapd,
  97. int enabled)
  98. {
  99. if (hapd->driver == NULL ||
  100. hapd->driver->hapd_set_countermeasures == NULL)
  101. return 0;
  102. return hapd->driver->hapd_set_countermeasures(hapd->drv_priv, enabled);
  103. }
  104. static inline int hostapd_drv_set_sta_vlan(const char *ifname,
  105. struct hostapd_data *hapd,
  106. const u8 *addr, int vlan_id)
  107. {
  108. if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
  109. return 0;
  110. return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname,
  111. vlan_id);
  112. }
  113. static inline int hostapd_drv_get_inact_sec(struct hostapd_data *hapd,
  114. const u8 *addr)
  115. {
  116. if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
  117. return 0;
  118. return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
  119. }
  120. static inline int hostapd_drv_sta_remove(struct hostapd_data *hapd,
  121. const u8 *addr)
  122. {
  123. if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
  124. return 0;
  125. return hapd->driver->sta_remove(hapd->drv_priv, addr);
  126. }
  127. static inline int hostapd_drv_hapd_send_eapol(struct hostapd_data *hapd,
  128. const u8 *addr, const u8 *data,
  129. size_t data_len, int encrypt,
  130. u32 flags)
  131. {
  132. if (hapd->driver == NULL || hapd->driver->hapd_send_eapol == NULL)
  133. return 0;
  134. return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
  135. data_len, encrypt,
  136. hapd->own_addr, flags);
  137. }
  138. static inline int hostapd_drv_read_sta_data(
  139. struct hostapd_data *hapd, struct hostap_sta_driver_data *data,
  140. const u8 *addr)
  141. {
  142. if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
  143. return -1;
  144. return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
  145. }
  146. static inline int hostapd_drv_sta_clear_stats(struct hostapd_data *hapd,
  147. const u8 *addr)
  148. {
  149. if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
  150. return 0;
  151. return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
  152. }
  153. static inline int hostapd_drv_set_beacon(struct hostapd_data *hapd,
  154. const u8 *head, size_t head_len,
  155. const u8 *tail, size_t tail_len,
  156. int dtim_period, int beacon_int)
  157. {
  158. if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
  159. return 0;
  160. return hapd->driver->set_beacon(hapd->drv_priv,
  161. head, head_len, tail, tail_len,
  162. dtim_period, beacon_int);
  163. }
  164. static inline int hostapd_drv_set_radius_acl_auth(struct hostapd_data *hapd,
  165. const u8 *mac, int accepted,
  166. u32 session_timeout)
  167. {
  168. if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
  169. return 0;
  170. return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
  171. session_timeout);
  172. }
  173. static inline int hostapd_drv_set_radius_acl_expire(struct hostapd_data *hapd,
  174. const u8 *mac)
  175. {
  176. if (hapd->driver == NULL ||
  177. hapd->driver->set_radius_acl_expire == NULL)
  178. return 0;
  179. return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
  180. }
  181. #endif /* AP_DRV_OPS */