ap_drv_ops.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*
  2. * hostapd - Driver operations
  3. * Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #include "utils/includes.h"
  9. #include "utils/common.h"
  10. #include "drivers/driver.h"
  11. #include "common/ieee802_11_defs.h"
  12. #include "wps/wps.h"
  13. #include "p2p/p2p.h"
  14. #include "hostapd.h"
  15. #include "ieee802_11.h"
  16. #include "sta_info.h"
  17. #include "ap_config.h"
  18. #include "p2p_hostapd.h"
  19. #include "hs20.h"
  20. #include "ap_drv_ops.h"
  21. u32 hostapd_sta_flags_to_drv(u32 flags)
  22. {
  23. int res = 0;
  24. if (flags & WLAN_STA_AUTHORIZED)
  25. res |= WPA_STA_AUTHORIZED;
  26. if (flags & WLAN_STA_WMM)
  27. res |= WPA_STA_WMM;
  28. if (flags & WLAN_STA_SHORT_PREAMBLE)
  29. res |= WPA_STA_SHORT_PREAMBLE;
  30. if (flags & WLAN_STA_MFP)
  31. res |= WPA_STA_MFP;
  32. return res;
  33. }
  34. int hostapd_build_ap_extra_ies(struct hostapd_data *hapd,
  35. struct wpabuf **beacon_ret,
  36. struct wpabuf **proberesp_ret,
  37. struct wpabuf **assocresp_ret)
  38. {
  39. struct wpabuf *beacon = NULL, *proberesp = NULL, *assocresp = NULL;
  40. u8 buf[200], *pos;
  41. *beacon_ret = *proberesp_ret = *assocresp_ret = NULL;
  42. pos = buf;
  43. pos = hostapd_eid_time_adv(hapd, pos);
  44. if (pos != buf) {
  45. if (wpabuf_resize(&beacon, pos - buf) != 0)
  46. goto fail;
  47. wpabuf_put_data(beacon, buf, pos - buf);
  48. }
  49. pos = hostapd_eid_time_zone(hapd, pos);
  50. if (pos != buf) {
  51. if (wpabuf_resize(&proberesp, pos - buf) != 0)
  52. goto fail;
  53. wpabuf_put_data(proberesp, buf, pos - buf);
  54. }
  55. pos = buf;
  56. pos = hostapd_eid_ext_capab(hapd, pos);
  57. if (pos != buf) {
  58. if (wpabuf_resize(&assocresp, pos - buf) != 0)
  59. goto fail;
  60. wpabuf_put_data(assocresp, buf, pos - buf);
  61. }
  62. pos = hostapd_eid_interworking(hapd, pos);
  63. pos = hostapd_eid_adv_proto(hapd, pos);
  64. pos = hostapd_eid_roaming_consortium(hapd, pos);
  65. if (pos != buf) {
  66. if (wpabuf_resize(&beacon, pos - buf) != 0)
  67. goto fail;
  68. wpabuf_put_data(beacon, buf, pos - buf);
  69. if (wpabuf_resize(&proberesp, pos - buf) != 0)
  70. goto fail;
  71. wpabuf_put_data(proberesp, buf, pos - buf);
  72. }
  73. if (hapd->wps_beacon_ie) {
  74. if (wpabuf_resize(&beacon, wpabuf_len(hapd->wps_beacon_ie)) <
  75. 0)
  76. goto fail;
  77. wpabuf_put_buf(beacon, hapd->wps_beacon_ie);
  78. }
  79. if (hapd->wps_probe_resp_ie) {
  80. if (wpabuf_resize(&proberesp,
  81. wpabuf_len(hapd->wps_probe_resp_ie)) < 0)
  82. goto fail;
  83. wpabuf_put_buf(proberesp, hapd->wps_probe_resp_ie);
  84. }
  85. #ifdef CONFIG_P2P
  86. if (hapd->p2p_beacon_ie) {
  87. if (wpabuf_resize(&beacon, wpabuf_len(hapd->p2p_beacon_ie)) <
  88. 0)
  89. goto fail;
  90. wpabuf_put_buf(beacon, hapd->p2p_beacon_ie);
  91. }
  92. if (hapd->p2p_probe_resp_ie) {
  93. if (wpabuf_resize(&proberesp,
  94. wpabuf_len(hapd->p2p_probe_resp_ie)) < 0)
  95. goto fail;
  96. wpabuf_put_buf(proberesp, hapd->p2p_probe_resp_ie);
  97. }
  98. #endif /* CONFIG_P2P */
  99. #ifdef CONFIG_P2P_MANAGER
  100. if (hapd->conf->p2p & P2P_MANAGE) {
  101. if (wpabuf_resize(&beacon, 100) == 0) {
  102. u8 *start, *p;
  103. start = wpabuf_put(beacon, 0);
  104. p = hostapd_eid_p2p_manage(hapd, start);
  105. wpabuf_put(beacon, p - start);
  106. }
  107. if (wpabuf_resize(&proberesp, 100) == 0) {
  108. u8 *start, *p;
  109. start = wpabuf_put(proberesp, 0);
  110. p = hostapd_eid_p2p_manage(hapd, start);
  111. wpabuf_put(proberesp, p - start);
  112. }
  113. }
  114. #endif /* CONFIG_P2P_MANAGER */
  115. #ifdef CONFIG_WPS2
  116. if (hapd->conf->wps_state) {
  117. struct wpabuf *a = wps_build_assoc_resp_ie();
  118. if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0)
  119. wpabuf_put_buf(assocresp, a);
  120. wpabuf_free(a);
  121. }
  122. #endif /* CONFIG_WPS2 */
  123. #ifdef CONFIG_P2P_MANAGER
  124. if (hapd->conf->p2p & P2P_MANAGE) {
  125. if (wpabuf_resize(&assocresp, 100) == 0) {
  126. u8 *start, *p;
  127. start = wpabuf_put(assocresp, 0);
  128. p = hostapd_eid_p2p_manage(hapd, start);
  129. wpabuf_put(assocresp, p - start);
  130. }
  131. }
  132. #endif /* CONFIG_P2P_MANAGER */
  133. #ifdef CONFIG_WIFI_DISPLAY
  134. if (hapd->p2p_group) {
  135. struct wpabuf *a;
  136. a = p2p_group_assoc_resp_ie(hapd->p2p_group, P2P_SC_SUCCESS);
  137. if (a && wpabuf_resize(&assocresp, wpabuf_len(a)) == 0)
  138. wpabuf_put_buf(assocresp, a);
  139. wpabuf_free(a);
  140. }
  141. #endif /* CONFIG_WIFI_DISPLAY */
  142. #ifdef CONFIG_HS20
  143. pos = buf;
  144. pos = hostapd_eid_hs20_indication(hapd, pos);
  145. if (pos != buf) {
  146. if (wpabuf_resize(&beacon, pos - buf) != 0)
  147. goto fail;
  148. wpabuf_put_data(beacon, buf, pos - buf);
  149. if (wpabuf_resize(&proberesp, pos - buf) != 0)
  150. goto fail;
  151. wpabuf_put_data(proberesp, buf, pos - buf);
  152. }
  153. #endif /* CONFIG_HS20 */
  154. *beacon_ret = beacon;
  155. *proberesp_ret = proberesp;
  156. *assocresp_ret = assocresp;
  157. return 0;
  158. fail:
  159. wpabuf_free(beacon);
  160. wpabuf_free(proberesp);
  161. wpabuf_free(assocresp);
  162. return -1;
  163. }
  164. void hostapd_free_ap_extra_ies(struct hostapd_data *hapd,
  165. struct wpabuf *beacon,
  166. struct wpabuf *proberesp,
  167. struct wpabuf *assocresp)
  168. {
  169. wpabuf_free(beacon);
  170. wpabuf_free(proberesp);
  171. wpabuf_free(assocresp);
  172. }
  173. int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
  174. {
  175. struct wpabuf *beacon, *proberesp, *assocresp;
  176. int ret;
  177. if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
  178. return 0;
  179. if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
  180. 0)
  181. return -1;
  182. ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
  183. assocresp);
  184. hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
  185. return ret;
  186. }
  187. int hostapd_set_authorized(struct hostapd_data *hapd,
  188. struct sta_info *sta, int authorized)
  189. {
  190. if (authorized) {
  191. return hostapd_sta_set_flags(hapd, sta->addr,
  192. hostapd_sta_flags_to_drv(
  193. sta->flags),
  194. WPA_STA_AUTHORIZED, ~0);
  195. }
  196. return hostapd_sta_set_flags(hapd, sta->addr,
  197. hostapd_sta_flags_to_drv(sta->flags),
  198. 0, ~WPA_STA_AUTHORIZED);
  199. }
  200. int hostapd_set_sta_flags(struct hostapd_data *hapd, struct sta_info *sta)
  201. {
  202. int set_flags, total_flags, flags_and, flags_or;
  203. total_flags = hostapd_sta_flags_to_drv(sta->flags);
  204. set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
  205. if (((!hapd->conf->ieee802_1x && !hapd->conf->wpa) ||
  206. sta->auth_alg == WLAN_AUTH_FT) &&
  207. sta->flags & WLAN_STA_AUTHORIZED)
  208. set_flags |= WPA_STA_AUTHORIZED;
  209. flags_or = total_flags & set_flags;
  210. flags_and = total_flags | ~set_flags;
  211. return hostapd_sta_set_flags(hapd, sta->addr, total_flags,
  212. flags_or, flags_and);
  213. }
  214. int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
  215. int enabled)
  216. {
  217. struct wpa_bss_params params;
  218. os_memset(&params, 0, sizeof(params));
  219. params.ifname = ifname;
  220. params.enabled = enabled;
  221. if (enabled) {
  222. params.wpa = hapd->conf->wpa;
  223. params.ieee802_1x = hapd->conf->ieee802_1x;
  224. params.wpa_group = hapd->conf->wpa_group;
  225. params.wpa_pairwise = hapd->conf->wpa_pairwise;
  226. params.wpa_key_mgmt = hapd->conf->wpa_key_mgmt;
  227. params.rsn_preauth = hapd->conf->rsn_preauth;
  228. #ifdef CONFIG_IEEE80211W
  229. params.ieee80211w = hapd->conf->ieee80211w;
  230. #endif /* CONFIG_IEEE80211W */
  231. }
  232. return hostapd_set_ieee8021x(hapd, &params);
  233. }
  234. int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
  235. {
  236. char force_ifname[IFNAMSIZ];
  237. u8 if_addr[ETH_ALEN];
  238. return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, hapd->own_addr,
  239. NULL, NULL, force_ifname, if_addr, NULL);
  240. }
  241. int hostapd_vlan_if_remove(struct hostapd_data *hapd, const char *ifname)
  242. {
  243. return hostapd_if_remove(hapd, WPA_IF_AP_VLAN, ifname);
  244. }
  245. int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid,
  246. int val)
  247. {
  248. const char *bridge = NULL;
  249. if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
  250. return 0;
  251. if (hapd->conf->wds_bridge[0])
  252. bridge = hapd->conf->wds_bridge;
  253. else if (hapd->conf->bridge[0])
  254. bridge = hapd->conf->bridge;
  255. return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val,
  256. bridge);
  257. }
  258. int hostapd_add_sta_node(struct hostapd_data *hapd, const u8 *addr,
  259. u16 auth_alg)
  260. {
  261. if (hapd->driver == NULL || hapd->driver->add_sta_node == NULL)
  262. return 0;
  263. return hapd->driver->add_sta_node(hapd->drv_priv, addr, auth_alg);
  264. }
  265. int hostapd_sta_auth(struct hostapd_data *hapd, const u8 *addr,
  266. u16 seq, u16 status, const u8 *ie, size_t len)
  267. {
  268. if (hapd->driver == NULL || hapd->driver->sta_auth == NULL)
  269. return 0;
  270. return hapd->driver->sta_auth(hapd->drv_priv, hapd->own_addr, addr,
  271. seq, status, ie, len);
  272. }
  273. int hostapd_sta_assoc(struct hostapd_data *hapd, const u8 *addr,
  274. int reassoc, u16 status, const u8 *ie, size_t len)
  275. {
  276. if (hapd->driver == NULL || hapd->driver->sta_assoc == NULL)
  277. return 0;
  278. return hapd->driver->sta_assoc(hapd->drv_priv, hapd->own_addr, addr,
  279. reassoc, status, ie, len);
  280. }
  281. int hostapd_sta_add(struct hostapd_data *hapd,
  282. const u8 *addr, u16 aid, u16 capability,
  283. const u8 *supp_rates, size_t supp_rates_len,
  284. u16 listen_interval,
  285. const struct ieee80211_ht_capabilities *ht_capab,
  286. u32 flags, u8 qosinfo)
  287. {
  288. struct hostapd_sta_add_params params;
  289. if (hapd->driver == NULL)
  290. return 0;
  291. if (hapd->driver->sta_add == NULL)
  292. return 0;
  293. os_memset(&params, 0, sizeof(params));
  294. params.addr = addr;
  295. params.aid = aid;
  296. params.capability = capability;
  297. params.supp_rates = supp_rates;
  298. params.supp_rates_len = supp_rates_len;
  299. params.listen_interval = listen_interval;
  300. params.ht_capabilities = ht_capab;
  301. params.flags = hostapd_sta_flags_to_drv(flags);
  302. params.qosinfo = qosinfo;
  303. return hapd->driver->sta_add(hapd->drv_priv, &params);
  304. }
  305. int hostapd_add_tspec(struct hostapd_data *hapd, const u8 *addr,
  306. u8 *tspec_ie, size_t tspec_ielen)
  307. {
  308. if (hapd->driver == NULL || hapd->driver->add_tspec == NULL)
  309. return 0;
  310. return hapd->driver->add_tspec(hapd->drv_priv, addr, tspec_ie,
  311. tspec_ielen);
  312. }
  313. int hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
  314. {
  315. if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
  316. return 0;
  317. return hapd->driver->set_privacy(hapd->drv_priv, enabled);
  318. }
  319. int hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
  320. size_t elem_len)
  321. {
  322. if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
  323. return 0;
  324. return hapd->driver->set_generic_elem(hapd->drv_priv, elem, elem_len);
  325. }
  326. int hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
  327. {
  328. if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
  329. return 0;
  330. return hapd->driver->hapd_get_ssid(hapd->drv_priv, buf, len);
  331. }
  332. int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
  333. {
  334. if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
  335. return 0;
  336. return hapd->driver->hapd_set_ssid(hapd->drv_priv, buf, len);
  337. }
  338. int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
  339. const char *ifname, const u8 *addr, void *bss_ctx,
  340. void **drv_priv, char *force_ifname, u8 *if_addr,
  341. const char *bridge)
  342. {
  343. if (hapd->driver == NULL || hapd->driver->if_add == NULL)
  344. return -1;
  345. return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr,
  346. bss_ctx, drv_priv, force_ifname, if_addr,
  347. bridge);
  348. }
  349. int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
  350. const char *ifname)
  351. {
  352. if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
  353. return -1;
  354. return hapd->driver->if_remove(hapd->drv_priv, type, ifname);
  355. }
  356. int hostapd_set_ieee8021x(struct hostapd_data *hapd,
  357. struct wpa_bss_params *params)
  358. {
  359. if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
  360. return 0;
  361. return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
  362. }
  363. int hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
  364. const u8 *addr, int idx, u8 *seq)
  365. {
  366. if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
  367. return 0;
  368. return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
  369. seq);
  370. }
  371. int hostapd_flush(struct hostapd_data *hapd)
  372. {
  373. if (hapd->driver == NULL || hapd->driver->flush == NULL)
  374. return 0;
  375. return hapd->driver->flush(hapd->drv_priv);
  376. }
  377. int hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq,
  378. int channel, int ht_enabled, int sec_channel_offset)
  379. {
  380. struct hostapd_freq_params data;
  381. if (hapd->driver == NULL)
  382. return 0;
  383. if (hapd->driver->set_freq == NULL)
  384. return 0;
  385. os_memset(&data, 0, sizeof(data));
  386. data.mode = mode;
  387. data.freq = freq;
  388. data.channel = channel;
  389. data.ht_enabled = ht_enabled;
  390. data.sec_channel_offset = sec_channel_offset;
  391. return hapd->driver->set_freq(hapd->drv_priv, &data);
  392. }
  393. int hostapd_set_rts(struct hostapd_data *hapd, int rts)
  394. {
  395. if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
  396. return 0;
  397. return hapd->driver->set_rts(hapd->drv_priv, rts);
  398. }
  399. int hostapd_set_frag(struct hostapd_data *hapd, int frag)
  400. {
  401. if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
  402. return 0;
  403. return hapd->driver->set_frag(hapd->drv_priv, frag);
  404. }
  405. int hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
  406. int total_flags, int flags_or, int flags_and)
  407. {
  408. if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
  409. return 0;
  410. return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
  411. flags_or, flags_and);
  412. }
  413. int hostapd_set_country(struct hostapd_data *hapd, const char *country)
  414. {
  415. if (hapd->driver == NULL ||
  416. hapd->driver->set_country == NULL)
  417. return 0;
  418. return hapd->driver->set_country(hapd->drv_priv, country);
  419. }
  420. int hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
  421. int cw_min, int cw_max, int burst_time)
  422. {
  423. if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
  424. return 0;
  425. return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
  426. cw_min, cw_max, burst_time);
  427. }
  428. struct hostapd_hw_modes *
  429. hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
  430. u16 *flags)
  431. {
  432. if (hapd->driver == NULL ||
  433. hapd->driver->get_hw_feature_data == NULL)
  434. return NULL;
  435. return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
  436. flags);
  437. }
  438. int hostapd_driver_commit(struct hostapd_data *hapd)
  439. {
  440. if (hapd->driver == NULL || hapd->driver->commit == NULL)
  441. return 0;
  442. return hapd->driver->commit(hapd->drv_priv);
  443. }
  444. int hostapd_drv_none(struct hostapd_data *hapd)
  445. {
  446. return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
  447. }
  448. int hostapd_driver_scan(struct hostapd_data *hapd,
  449. struct wpa_driver_scan_params *params)
  450. {
  451. if (hapd->driver && hapd->driver->scan2)
  452. return hapd->driver->scan2(hapd->drv_priv, params);
  453. return -1;
  454. }
  455. struct wpa_scan_results * hostapd_driver_get_scan_results(
  456. struct hostapd_data *hapd)
  457. {
  458. if (hapd->driver && hapd->driver->get_scan_results2)
  459. return hapd->driver->get_scan_results2(hapd->drv_priv);
  460. return NULL;
  461. }
  462. int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start,
  463. int duration)
  464. {
  465. if (hapd->driver && hapd->driver->set_noa)
  466. return hapd->driver->set_noa(hapd->drv_priv, count, start,
  467. duration);
  468. return -1;
  469. }
  470. int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd,
  471. enum wpa_alg alg, const u8 *addr,
  472. int key_idx, int set_tx,
  473. const u8 *seq, size_t seq_len,
  474. const u8 *key, size_t key_len)
  475. {
  476. if (hapd->driver == NULL || hapd->driver->set_key == NULL)
  477. return 0;
  478. return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
  479. key_idx, set_tx, seq, seq_len, key,
  480. key_len);
  481. }
  482. int hostapd_drv_send_mlme(struct hostapd_data *hapd,
  483. const void *msg, size_t len, int noack)
  484. {
  485. if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
  486. return 0;
  487. return hapd->driver->send_mlme(hapd->drv_priv, msg, len, noack);
  488. }
  489. int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
  490. const u8 *addr, int reason)
  491. {
  492. if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
  493. return 0;
  494. return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
  495. reason);
  496. }
  497. int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
  498. const u8 *addr, int reason)
  499. {
  500. if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
  501. return 0;
  502. return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
  503. reason);
  504. }
  505. int hostapd_drv_wnm_oper(struct hostapd_data *hapd, enum wnm_oper oper,
  506. const u8 *peer, u8 *buf, u16 *buf_len)
  507. {
  508. if (hapd->driver == NULL || hapd->driver->wnm_oper == NULL)
  509. return 0;
  510. return hapd->driver->wnm_oper(hapd->drv_priv, oper, peer, buf,
  511. buf_len);
  512. }
  513. int hostapd_drv_send_action(struct hostapd_data *hapd, unsigned int freq,
  514. unsigned int wait, const u8 *dst, const u8 *data,
  515. size_t len)
  516. {
  517. if (hapd->driver == NULL || hapd->driver->send_action == NULL)
  518. return 0;
  519. return hapd->driver->send_action(hapd->drv_priv, freq, wait, dst,
  520. hapd->own_addr, hapd->own_addr, data,
  521. len, 0);
  522. }