driver.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. /*
  2. * hostapd - driver interface definition
  3. * Copyright (c) 2002-2007, 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_sta_add_params {
  18. const u8 *addr;
  19. u16 aid;
  20. u16 capability;
  21. const u8 *supp_rates;
  22. size_t supp_rates_len;
  23. int flags;
  24. u16 listen_interval;
  25. const struct ht_cap_ie *ht_capabilities;
  26. };
  27. enum hostapd_driver_if_type {
  28. HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
  29. };
  30. struct wpa_driver_ops {
  31. const char *name; /* as appears in the config file */
  32. void * (*init)(struct hostapd_data *hapd);
  33. void * (*init_bssid)(struct hostapd_data *hapd, const u8 *bssid);
  34. void (*deinit)(void *priv);
  35. int (*wireless_event_init)(void *priv);
  36. void (*wireless_event_deinit)(void *priv);
  37. /**
  38. * set_8021x - enable/disable IEEE 802.1X support
  39. * @ifname: Interface name (for multi-SSID/VLAN support)
  40. * @priv: driver private data
  41. * @enabled: 1 = enable, 0 = disable
  42. *
  43. * Returns: 0 on success, -1 on failure
  44. *
  45. * Configure the kernel driver to enable/disable 802.1X support.
  46. * This may be an empty function if 802.1X support is always enabled.
  47. */
  48. int (*set_ieee8021x)(const char *ifname, void *priv, int enabled);
  49. /**
  50. * set_privacy - enable/disable privacy
  51. * @priv: driver private data
  52. * @enabled: 1 = privacy enabled, 0 = disabled
  53. *
  54. * Return: 0 on success, -1 on failure
  55. *
  56. * Configure privacy.
  57. */
  58. int (*set_privacy)(const char *ifname, void *priv, int enabled);
  59. int (*set_encryption)(const char *ifname, void *priv, const char *alg,
  60. const u8 *addr, int idx,
  61. const u8 *key, size_t key_len, int txkey);
  62. int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
  63. int idx, u8 *seq);
  64. int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
  65. int idx, u8 *seq);
  66. int (*flush)(void *priv);
  67. int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
  68. size_t elem_len);
  69. int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
  70. const u8 *addr);
  71. int (*send_eapol)(void *priv, const u8 *addr, const u8 *data,
  72. size_t data_len, int encrypt, const u8 *own_addr);
  73. int (*sta_deauth)(void *priv, const u8 *addr, int reason);
  74. int (*sta_disassoc)(void *priv, const u8 *addr, int reason);
  75. int (*sta_remove)(void *priv, const u8 *addr);
  76. int (*get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
  77. int (*set_ssid)(const char *ifname, void *priv, const u8 *buf,
  78. int len);
  79. int (*set_countermeasures)(void *priv, int enabled);
  80. int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
  81. int flags);
  82. int (*set_assoc_ap)(void *priv, const u8 *addr);
  83. /* note: sta_add() is deprecated; use sta_add2() instead */
  84. int (*sta_add)(const char *ifname, void *priv, const u8 *addr, u16 aid,
  85. u16 capability, u8 *supp_rates, size_t supp_rates_len,
  86. int flags, u16 listen_interval);
  87. int (*sta_add2)(const char *ifname, void *priv,
  88. struct hostapd_sta_add_params *params);
  89. int (*get_inact_sec)(void *priv, const u8 *addr);
  90. int (*sta_clear_stats)(void *priv, const u8 *addr);
  91. int (*set_freq)(void *priv, int mode, int freq);
  92. int (*set_rts)(void *priv, int rts);
  93. int (*get_rts)(void *priv, int *rts);
  94. int (*set_frag)(void *priv, int frag);
  95. int (*get_frag)(void *priv, int *frag);
  96. int (*set_retry)(void *priv, int short_retry, int long_retry);
  97. int (*get_retry)(void *priv, int *short_retry, int *long_retry);
  98. int (*sta_set_flags)(void *priv, const u8 *addr,
  99. int total_flags, int flags_or, int flags_and);
  100. int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
  101. int mode);
  102. int (*set_regulatory_domain)(void *priv, unsigned int rd);
  103. int (*set_country)(void *priv, const char *country);
  104. int (*set_ieee80211d)(void *priv, int enabled);
  105. int (*set_beacon)(const char *ifname, void *priv,
  106. u8 *head, size_t head_len,
  107. u8 *tail, size_t tail_len);
  108. /* Configure internal bridge:
  109. * 0 = disabled, i.e., client separation is enabled (no bridging of
  110. * packets between associated STAs
  111. * 1 = enabled, i.e., bridge packets between associated STAs (default)
  112. */
  113. int (*set_internal_bridge)(void *priv, int value);
  114. int (*set_beacon_int)(void *priv, int value);
  115. int (*set_dtim_period)(const char *ifname, void *priv, int value);
  116. /* Configure broadcast SSID mode:
  117. * 0 = include SSID in Beacon frames and reply to Probe Request frames
  118. * that use broadcast SSID
  119. * 1 = hide SSID from Beacon frames and ignore Probe Request frames for
  120. * broadcast SSID
  121. */
  122. int (*set_broadcast_ssid)(void *priv, int value);
  123. int (*set_cts_protect)(void *priv, int value);
  124. int (*set_key_tx_rx_threshold)(void *priv, int value);
  125. int (*set_preamble)(void *priv, int value);
  126. int (*set_short_slot_time)(void *priv, int value);
  127. int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
  128. int cw_max, int burst_time);
  129. int (*bss_add)(void *priv, const char *ifname, const u8 *bssid);
  130. int (*bss_remove)(void *priv, const char *ifname);
  131. int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
  132. int (*passive_scan)(void *priv, int now, int our_mode_only,
  133. int interval, int _listen, int *channel,
  134. int *last_rx);
  135. struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
  136. u16 *num_modes,
  137. u16 *flags);
  138. int (*if_add)(const char *iface, void *priv,
  139. enum hostapd_driver_if_type type, char *ifname,
  140. const u8 *addr);
  141. int (*if_update)(void *priv, enum hostapd_driver_if_type type,
  142. char *ifname, const u8 *addr);
  143. int (*if_remove)(void *priv, enum hostapd_driver_if_type type,
  144. const char *ifname, const u8 *addr);
  145. int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
  146. int vlan_id);
  147. /**
  148. * commit - Optional commit changes handler
  149. * @priv: driver private data
  150. * Returns: 0 on success, -1 on failure
  151. *
  152. * This optional handler function can be registered if the driver
  153. * interface implementation needs to commit changes (e.g., by setting
  154. * network interface up) at the end of initial configuration. If set,
  155. * this handler will be called after initial setup has been completed.
  156. */
  157. int (*commit)(void *priv);
  158. int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
  159. const u8 *data, size_t data_len);
  160. int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
  161. u32 session_timeout);
  162. int (*set_radius_acl_expire)(void *priv, const u8 *mac);
  163. int (*set_ht_capability)(const char *ifname, void *priv,
  164. const u8 *data, size_t data_len);
  165. int (*set_ht_operation)(const char *ifname, void *priv,
  166. const u8 *data, size_t data_len);
  167. int (*set_wps_beacon_ie)(const char *ifname, void *priv,
  168. const u8 *ie, size_t len);
  169. int (*set_wps_probe_resp_ie)(const char *ifname, void *priv,
  170. const u8 *ie, size_t len);
  171. };
  172. static inline void *
  173. hostapd_driver_init(struct hostapd_data *hapd)
  174. {
  175. if (hapd->driver == NULL || hapd->driver->init == NULL)
  176. return NULL;
  177. return hapd->driver->init(hapd);
  178. }
  179. static inline void *
  180. hostapd_driver_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
  181. {
  182. if (hapd->driver == NULL || hapd->driver->init_bssid == NULL)
  183. return NULL;
  184. return hapd->driver->init_bssid(hapd, bssid);
  185. }
  186. static inline void
  187. hostapd_driver_deinit(struct hostapd_data *hapd)
  188. {
  189. if (hapd->driver == NULL || hapd->driver->deinit == NULL)
  190. return;
  191. hapd->driver->deinit(hapd->drv_priv);
  192. }
  193. static inline int
  194. hostapd_wireless_event_init(struct hostapd_data *hapd)
  195. {
  196. if (hapd->driver == NULL ||
  197. hapd->driver->wireless_event_init == NULL)
  198. return 0;
  199. return hapd->driver->wireless_event_init(hapd->drv_priv);
  200. }
  201. static inline void
  202. hostapd_wireless_event_deinit(struct hostapd_data *hapd)
  203. {
  204. if (hapd->driver == NULL ||
  205. hapd->driver->wireless_event_deinit == NULL)
  206. return;
  207. hapd->driver->wireless_event_deinit(hapd->drv_priv);
  208. }
  209. static inline int
  210. hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
  211. int enabled)
  212. {
  213. if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
  214. return 0;
  215. return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
  216. }
  217. static inline int
  218. hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
  219. {
  220. if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
  221. return 0;
  222. return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
  223. enabled);
  224. }
  225. static inline int
  226. hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
  227. const char *alg, const u8 *addr, int idx,
  228. u8 *key, size_t key_len, int txkey)
  229. {
  230. if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
  231. return 0;
  232. return hapd->driver->set_encryption(ifname, hapd->drv_priv, alg, addr,
  233. idx, key, key_len, txkey);
  234. }
  235. static inline int
  236. hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
  237. const u8 *addr, int idx, u8 *seq)
  238. {
  239. if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
  240. return 0;
  241. return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
  242. seq);
  243. }
  244. static inline int
  245. hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
  246. const u8 *addr, int idx, u8 *seq)
  247. {
  248. if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
  249. return -1;
  250. return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
  251. seq);
  252. }
  253. static inline int
  254. hostapd_flush(struct hostapd_data *hapd)
  255. {
  256. if (hapd->driver == NULL || hapd->driver->flush == NULL)
  257. return 0;
  258. return hapd->driver->flush(hapd->drv_priv);
  259. }
  260. static inline int
  261. hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
  262. size_t elem_len)
  263. {
  264. if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
  265. return 0;
  266. return hapd->driver->set_generic_elem(hapd->conf->iface,
  267. hapd->drv_priv, elem, elem_len);
  268. }
  269. static inline int
  270. hostapd_read_sta_data(struct hostapd_data *hapd,
  271. struct hostap_sta_driver_data *data, const u8 *addr)
  272. {
  273. if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
  274. return -1;
  275. return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
  276. }
  277. static inline int
  278. hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
  279. size_t data_len, int encrypt)
  280. {
  281. if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
  282. return 0;
  283. return hapd->driver->send_eapol(hapd->drv_priv, addr, data, data_len,
  284. encrypt, hapd->own_addr);
  285. }
  286. static inline int
  287. hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
  288. {
  289. if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
  290. return 0;
  291. return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason);
  292. }
  293. static inline int
  294. hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
  295. {
  296. if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
  297. return 0;
  298. return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason);
  299. }
  300. static inline int
  301. hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
  302. {
  303. if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
  304. return 0;
  305. return hapd->driver->sta_remove(hapd->drv_priv, addr);
  306. }
  307. static inline int
  308. hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
  309. {
  310. if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
  311. return 0;
  312. return hapd->driver->get_ssid(hapd->conf->iface, hapd->drv_priv, buf,
  313. len);
  314. }
  315. static inline int
  316. hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
  317. {
  318. if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
  319. return 0;
  320. return hapd->driver->set_ssid(hapd->conf->iface, hapd->drv_priv, buf,
  321. len);
  322. }
  323. static inline int
  324. hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
  325. int flags)
  326. {
  327. if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
  328. return 0;
  329. return hapd->driver->send_mgmt_frame(hapd->drv_priv, msg, len, flags);
  330. }
  331. static inline int
  332. hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
  333. {
  334. if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
  335. return 0;
  336. return hapd->driver->set_assoc_ap(hapd->drv_priv, addr);
  337. }
  338. static inline int
  339. hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
  340. {
  341. if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
  342. return 0;
  343. return hapd->driver->set_countermeasures(hapd->drv_priv, enabled);
  344. }
  345. static inline int
  346. hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
  347. u16 aid, u16 capability, const u8 *supp_rates,
  348. size_t supp_rates_len, int flags, u16 listen_interval,
  349. const struct ht_cap_ie *ht_capabilities)
  350. {
  351. if (hapd->driver == NULL)
  352. return 0;
  353. if (hapd->driver->sta_add2) {
  354. struct hostapd_sta_add_params params;
  355. os_memset(&params, 0, sizeof(params));
  356. params.addr = addr;
  357. params.aid = aid;
  358. params.capability = capability;
  359. params.supp_rates = supp_rates;
  360. params.supp_rates_len = supp_rates_len;
  361. params.flags = flags;
  362. params.listen_interval = listen_interval;
  363. params.ht_capabilities = ht_capabilities;
  364. return hapd->driver->sta_add2(ifname, hapd->drv_priv, &params);
  365. }
  366. if (hapd->driver->sta_add == NULL)
  367. return 0;
  368. return hapd->driver->sta_add(ifname, hapd->drv_priv, addr, aid,
  369. capability, (u8 *) supp_rates,
  370. supp_rates_len,
  371. flags, listen_interval);
  372. }
  373. static inline int
  374. hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
  375. {
  376. if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
  377. return 0;
  378. return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
  379. }
  380. static inline int
  381. hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq)
  382. {
  383. if (hapd->driver == NULL || hapd->driver->set_freq == NULL)
  384. return 0;
  385. return hapd->driver->set_freq(hapd->drv_priv, mode, freq);
  386. }
  387. static inline int
  388. hostapd_set_rts(struct hostapd_data *hapd, int rts)
  389. {
  390. if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
  391. return 0;
  392. return hapd->driver->set_rts(hapd->drv_priv, rts);
  393. }
  394. static inline int
  395. hostapd_get_rts(struct hostapd_data *hapd, int *rts)
  396. {
  397. if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
  398. return 0;
  399. return hapd->driver->get_rts(hapd->drv_priv, rts);
  400. }
  401. static inline int
  402. hostapd_set_frag(struct hostapd_data *hapd, int frag)
  403. {
  404. if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
  405. return 0;
  406. return hapd->driver->set_frag(hapd->drv_priv, frag);
  407. }
  408. static inline int
  409. hostapd_get_frag(struct hostapd_data *hapd, int *frag)
  410. {
  411. if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
  412. return 0;
  413. return hapd->driver->get_frag(hapd->drv_priv, frag);
  414. }
  415. static inline int
  416. hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
  417. {
  418. if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
  419. return 0;
  420. return hapd->driver->set_retry(hapd->drv_priv, short_retry,
  421. long_retry);
  422. }
  423. static inline int
  424. hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
  425. {
  426. if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
  427. return 0;
  428. return hapd->driver->get_retry(hapd->drv_priv, short_retry,
  429. long_retry);
  430. }
  431. static inline int
  432. hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
  433. int total_flags, int flags_or, int flags_and)
  434. {
  435. if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
  436. return 0;
  437. return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
  438. flags_or, flags_and);
  439. }
  440. static inline int
  441. hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
  442. int *basic_rates, int mode)
  443. {
  444. if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
  445. return 0;
  446. return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
  447. basic_rates, mode);
  448. }
  449. static inline int
  450. hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
  451. {
  452. if (hapd->driver == NULL ||
  453. hapd->driver->set_regulatory_domain == NULL)
  454. return 0;
  455. return hapd->driver->set_regulatory_domain(hapd->drv_priv, rd);
  456. }
  457. static inline int
  458. hostapd_set_country(struct hostapd_data *hapd, const char *country)
  459. {
  460. if (hapd->driver == NULL ||
  461. hapd->driver->set_country == NULL)
  462. return 0;
  463. return hapd->driver->set_country(hapd->drv_priv, country);
  464. }
  465. static inline int
  466. hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
  467. {
  468. if (hapd->driver == NULL ||
  469. hapd->driver->set_ieee80211d == NULL)
  470. return 0;
  471. return hapd->driver->set_ieee80211d(hapd->drv_priv, enabled);
  472. }
  473. static inline int
  474. hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
  475. {
  476. if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
  477. return 0;
  478. return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
  479. }
  480. static inline int
  481. hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
  482. u8 *head, size_t head_len,
  483. u8 *tail, size_t tail_len)
  484. {
  485. if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
  486. return 0;
  487. return hapd->driver->set_beacon(ifname, hapd->drv_priv, head, head_len,
  488. tail, tail_len);
  489. }
  490. static inline int
  491. hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
  492. {
  493. if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
  494. return 0;
  495. return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
  496. }
  497. static inline int
  498. hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
  499. {
  500. if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
  501. return 0;
  502. return hapd->driver->set_beacon_int(hapd->drv_priv, value);
  503. }
  504. static inline int
  505. hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
  506. {
  507. if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
  508. return 0;
  509. return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->drv_priv,
  510. value);
  511. }
  512. static inline int
  513. hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
  514. {
  515. if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
  516. return 0;
  517. return hapd->driver->set_broadcast_ssid(hapd->drv_priv, value);
  518. }
  519. static inline int
  520. hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
  521. {
  522. if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
  523. return 0;
  524. return hapd->driver->set_cts_protect(hapd->drv_priv, value);
  525. }
  526. static inline int
  527. hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
  528. {
  529. if (hapd->driver == NULL ||
  530. hapd->driver->set_key_tx_rx_threshold == NULL)
  531. return 0;
  532. return hapd->driver->set_key_tx_rx_threshold(hapd->drv_priv, value);
  533. }
  534. static inline int
  535. hostapd_set_preamble(struct hostapd_data *hapd, int value)
  536. {
  537. if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
  538. return 0;
  539. return hapd->driver->set_preamble(hapd->drv_priv, value);
  540. }
  541. static inline int
  542. hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
  543. {
  544. if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
  545. return 0;
  546. return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
  547. }
  548. static inline int
  549. hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
  550. int cw_min, int cw_max, int burst_time)
  551. {
  552. if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
  553. return 0;
  554. return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
  555. cw_min, cw_max, burst_time);
  556. }
  557. static inline int
  558. hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
  559. {
  560. if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
  561. return 0;
  562. return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
  563. }
  564. static inline int
  565. hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
  566. {
  567. if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
  568. return 0;
  569. return hapd->driver->bss_remove(hapd->drv_priv, ifname);
  570. }
  571. static inline int
  572. hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
  573. const u8 *mask)
  574. {
  575. if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
  576. return 1;
  577. return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
  578. }
  579. static inline int
  580. hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
  581. char *ifname, const u8 *addr)
  582. {
  583. if (hapd->driver == NULL || hapd->driver->if_add == NULL)
  584. return -1;
  585. return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
  586. ifname, addr);
  587. }
  588. static inline int
  589. hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
  590. char *ifname, const u8 *addr)
  591. {
  592. if (hapd->driver == NULL || hapd->driver->if_update == NULL)
  593. return -1;
  594. return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
  595. }
  596. static inline int
  597. hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
  598. char *ifname, const u8 *addr)
  599. {
  600. if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
  601. return -1;
  602. return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
  603. }
  604. static inline int
  605. hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
  606. int interval, int _listen, int *channel,
  607. int *last_rx)
  608. {
  609. if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
  610. return -1;
  611. return hapd->driver->passive_scan(hapd->drv_priv, now, our_mode_only,
  612. interval, _listen, channel, last_rx);
  613. }
  614. static inline struct hostapd_hw_modes *
  615. hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
  616. u16 *flags)
  617. {
  618. if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
  619. return NULL;
  620. return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
  621. flags);
  622. }
  623. static inline int
  624. hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
  625. const u8 *addr, int vlan_id)
  626. {
  627. if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
  628. return 0;
  629. return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
  630. }
  631. static inline int
  632. hostapd_driver_commit(struct hostapd_data *hapd)
  633. {
  634. if (hapd->driver == NULL || hapd->driver->commit == NULL)
  635. return 0;
  636. return hapd->driver->commit(hapd->drv_priv);
  637. }
  638. static inline int
  639. hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
  640. int accepted, u32 session_timeout)
  641. {
  642. if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
  643. return 0;
  644. return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
  645. session_timeout);
  646. }
  647. static inline int
  648. hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
  649. {
  650. if (hapd->driver == NULL ||
  651. hapd->driver->set_radius_acl_expire == NULL)
  652. return 0;
  653. return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
  654. }
  655. #ifdef CONFIG_IEEE80211N
  656. static inline int
  657. hostapd_set_ht_capability(const char *ifname, struct hostapd_data *hapd,
  658. const u8 *ht_cap)
  659. {
  660. if (hapd->driver == NULL || hapd->driver->set_ht_capability == NULL ||
  661. ht_cap == NULL)
  662. return 0;
  663. return hapd->driver->set_ht_capability(
  664. ifname, hapd->drv_priv, ht_cap,
  665. sizeof(struct ieee80211_ht_capability));
  666. }
  667. static inline int
  668. hostapd_set_ht_operation(const char *ifname, struct hostapd_data *hapd,
  669. const u8 *ht_operation)
  670. {
  671. if (hapd->driver == NULL || hapd->driver->set_ht_operation == NULL ||
  672. ht_operation == NULL)
  673. return 0;
  674. return hapd->driver->set_ht_operation(
  675. ifname, hapd->drv_priv, ht_operation,
  676. sizeof(struct ieee80211_ht_operation));
  677. }
  678. #endif /* CONFIG_IEEE80211N */
  679. static inline int
  680. hostapd_drv_none(struct hostapd_data *hapd)
  681. {
  682. return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
  683. }
  684. static inline int
  685. hostapd_set_wps_beacon_ie(struct hostapd_data *hapd, const u8 *ie, size_t len)
  686. {
  687. if (hapd->driver == NULL || hapd->driver->set_wps_beacon_ie == NULL)
  688. return 0;
  689. return hapd->driver->set_wps_beacon_ie(hapd->conf->iface,
  690. hapd->drv_priv, ie, len);
  691. }
  692. static inline int
  693. hostapd_set_wps_probe_resp_ie(struct hostapd_data *hapd, const u8 *ie,
  694. size_t len)
  695. {
  696. if (hapd->driver == NULL ||
  697. hapd->driver->set_wps_probe_resp_ie == NULL)
  698. return 0;
  699. return hapd->driver->set_wps_probe_resp_ie(hapd->conf->iface,
  700. hapd->drv_priv, ie, len);
  701. }
  702. #endif /* DRIVER_H */