ap_drv_ops.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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_build_ap_extra_ies(struct hostapd_data *hapd,
  22. struct wpabuf **beacon,
  23. struct wpabuf **proberesp,
  24. struct wpabuf **assocresp);
  25. void hostapd_free_ap_extra_ies(struct hostapd_data *hapd, struct wpabuf *beacon,
  26. struct wpabuf *proberesp,
  27. struct wpabuf *assocresp);
  28. int hostapd_set_ap_wps_ie(struct hostapd_data *hapd);
  29. int hostapd_set_authorized(struct hostapd_data *hapd,
  30. struct sta_info *sta, int authorized);
  31. int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta);
  32. int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
  33. int enabled);
  34. int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname);
  35. int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname);
  36. int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid,
  37. int val);
  38. int hostapd_sta_add(struct hostapd_data *hapd,
  39. const u8 *addr, u16 aid, u16 capability,
  40. const u8 *supp_rates, size_t supp_rates_len,
  41. u16 listen_interval,
  42. const struct ieee80211_ht_capabilities *ht_capab,
  43. u32 flags);
  44. int hostapd_set_privacy(struct hostapd_data *hapd, int enabled);
  45. int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
  46. size_t elem_len);
  47. int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len);
  48. int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len);
  49. int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
  50. const char *ifname, const u8 *addr, void *bss_ctx,
  51. void **drv_priv, char *force_ifname, u8 *if_addr,
  52. const char *bridge);
  53. int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
  54. const char *ifname);
  55. int hostapd_set_ieee8021x(struct hostapd_data *hapd,
  56. struct wpa_bss_params *params);
  57. int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
  58. const u8 *addr, int idx, u8 *seq);
  59. int hostapd_flush(struct hostapd_data *hapd);
  60. int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq,
  61. int channel, int ht_enabled, int sec_channel_offset);
  62. int hostapd_set_rts(struct hostapd_data *hapd, int rts);
  63. int hostapd_set_frag(struct hostapd_data *hapd, int frag);
  64. int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
  65. int total_flags, int flags_or, int flags_and);
  66. int hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
  67. int *basic_rates, int mode);
  68. int hostapd_set_country(struct hostapd_data *hapd, const char *country);
  69. int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
  70. int cw_min, int cw_max, int burst_time);
  71. int hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
  72. const u8 *mask);
  73. struct hostapd_hw_modes *
  74. hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
  75. u16 *flags);
  76. int hostapd_driver_commit(struct hostapd_data *hapd);
  77. int hostapd_drv_none(struct hostapd_data *hapd);
  78. int hostapd_driver_scan(struct hostapd_data *hapd,
  79. struct wpa_driver_scan_params *params);
  80. struct wpa_scan_results * hostapd_driver_get_scan_results(
  81. struct hostapd_data *hapd);
  82. int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
  83. int duration);
  84. int hostapd_drv_set_key(const char *ifname,
  85. struct hostapd_data *hapd,
  86. enum wpa_alg alg, const u8 *addr,
  87. int key_idx, int set_tx,
  88. const u8 *seq, size_t seq_len,
  89. const u8 *key, size_t key_len);
  90. int hostapd_drv_send_mlme(struct hostapd_data *hapd,
  91. const void *msg, size_t len);
  92. int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
  93. const u8 *addr, int reason);
  94. int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
  95. const u8 *addr, int reason);
  96. int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr,
  97. u16 auth_alg);
  98. int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr,
  99. u16 seq, u16 status, const u8 *ie, size_t len);
  100. int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr,
  101. int reassoc, u16 status, const u8 *ie, size_t len);
  102. int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr,
  103. u8 *tspec_ie, size_t tspec_ielen);
  104. #include "drivers/driver.h"
  105. static inline int hostapd_drv_set_countermeasures(struct hostapd_data *hapd,
  106. int enabled)
  107. {
  108. if (hapd->driver == NULL ||
  109. hapd->driver->hapd_set_countermeasures == NULL)
  110. return 0;
  111. return hapd->driver->hapd_set_countermeasures(hapd->drv_priv, enabled);
  112. }
  113. static inline int hostapd_drv_set_sta_vlan(const char *ifname,
  114. struct hostapd_data *hapd,
  115. const u8 *addr, int vlan_id)
  116. {
  117. if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
  118. return 0;
  119. return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname,
  120. vlan_id);
  121. }
  122. static inline int hostapd_drv_get_inact_sec(struct hostapd_data *hapd,
  123. const u8 *addr)
  124. {
  125. if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
  126. return 0;
  127. return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
  128. }
  129. static inline int hostapd_drv_sta_remove(struct hostapd_data *hapd,
  130. const u8 *addr)
  131. {
  132. if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
  133. return 0;
  134. return hapd->driver->sta_remove(hapd->drv_priv, addr);
  135. }
  136. static inline int hostapd_drv_hapd_send_eapol(struct hostapd_data *hapd,
  137. const u8 *addr, const u8 *data,
  138. size_t data_len, int encrypt,
  139. u32 flags)
  140. {
  141. if (hapd->driver == NULL || hapd->driver->hapd_send_eapol == NULL)
  142. return 0;
  143. return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
  144. data_len, encrypt,
  145. hapd->own_addr, flags);
  146. }
  147. static inline int hostapd_drv_read_sta_data(
  148. struct hostapd_data *hapd, struct hostap_sta_driver_data *data,
  149. const u8 *addr)
  150. {
  151. if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
  152. return -1;
  153. return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
  154. }
  155. static inline int hostapd_drv_sta_clear_stats(struct hostapd_data *hapd,
  156. const u8 *addr)
  157. {
  158. if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
  159. return 0;
  160. return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
  161. }
  162. static inline int hostapd_drv_set_ap(struct hostapd_data *hapd,
  163. struct wpa_driver_ap_params *params)
  164. {
  165. if (hapd->driver == NULL || hapd->driver->set_ap == NULL)
  166. return 0;
  167. return hapd->driver->set_ap(hapd->drv_priv, params);
  168. }
  169. static inline int hostapd_drv_set_radius_acl_auth(struct hostapd_data *hapd,
  170. const u8 *mac, int accepted,
  171. u32 session_timeout)
  172. {
  173. if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
  174. return 0;
  175. return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
  176. session_timeout);
  177. }
  178. static inline int hostapd_drv_set_radius_acl_expire(struct hostapd_data *hapd,
  179. const u8 *mac)
  180. {
  181. if (hapd->driver == NULL ||
  182. hapd->driver->set_radius_acl_expire == NULL)
  183. return 0;
  184. return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
  185. }
  186. static inline int hostapd_drv_set_authmode(struct hostapd_data *hapd,
  187. int auth_algs)
  188. {
  189. if (hapd->driver == NULL || hapd->driver->set_authmode == NULL)
  190. return 0;
  191. return hapd->driver->set_authmode(hapd->drv_priv, auth_algs);
  192. }
  193. #endif /* AP_DRV_OPS */