driver.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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. };
  168. static inline void *
  169. hostapd_driver_init(struct hostapd_data *hapd)
  170. {
  171. if (hapd->driver == NULL || hapd->driver->init == NULL)
  172. return NULL;
  173. return hapd->driver->init(hapd);
  174. }
  175. static inline void *
  176. hostapd_driver_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
  177. {
  178. if (hapd->driver == NULL || hapd->driver->init_bssid == NULL)
  179. return NULL;
  180. return hapd->driver->init_bssid(hapd, bssid);
  181. }
  182. static inline void
  183. hostapd_driver_deinit(struct hostapd_data *hapd)
  184. {
  185. if (hapd->driver == NULL || hapd->driver->deinit == NULL)
  186. return;
  187. hapd->driver->deinit(hapd->drv_priv);
  188. }
  189. static inline int
  190. hostapd_wireless_event_init(struct hostapd_data *hapd)
  191. {
  192. if (hapd->driver == NULL ||
  193. hapd->driver->wireless_event_init == NULL)
  194. return 0;
  195. return hapd->driver->wireless_event_init(hapd->drv_priv);
  196. }
  197. static inline void
  198. hostapd_wireless_event_deinit(struct hostapd_data *hapd)
  199. {
  200. if (hapd->driver == NULL ||
  201. hapd->driver->wireless_event_deinit == NULL)
  202. return;
  203. hapd->driver->wireless_event_deinit(hapd->drv_priv);
  204. }
  205. static inline int
  206. hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
  207. int enabled)
  208. {
  209. if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
  210. return 0;
  211. return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
  212. }
  213. static inline int
  214. hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
  215. {
  216. if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
  217. return 0;
  218. return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
  219. enabled);
  220. }
  221. static inline int
  222. hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
  223. const char *alg, const u8 *addr, int idx,
  224. u8 *key, size_t key_len, int txkey)
  225. {
  226. if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
  227. return 0;
  228. return hapd->driver->set_encryption(ifname, hapd->drv_priv, alg, addr,
  229. idx, key, key_len, txkey);
  230. }
  231. static inline int
  232. hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
  233. const u8 *addr, int idx, u8 *seq)
  234. {
  235. if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
  236. return 0;
  237. return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
  238. seq);
  239. }
  240. static inline int
  241. hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
  242. const u8 *addr, int idx, u8 *seq)
  243. {
  244. if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
  245. return -1;
  246. return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
  247. seq);
  248. }
  249. static inline int
  250. hostapd_flush(struct hostapd_data *hapd)
  251. {
  252. if (hapd->driver == NULL || hapd->driver->flush == NULL)
  253. return 0;
  254. return hapd->driver->flush(hapd->drv_priv);
  255. }
  256. static inline int
  257. hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
  258. size_t elem_len)
  259. {
  260. if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
  261. return 0;
  262. return hapd->driver->set_generic_elem(hapd->conf->iface,
  263. hapd->drv_priv, elem, elem_len);
  264. }
  265. static inline int
  266. hostapd_read_sta_data(struct hostapd_data *hapd,
  267. struct hostap_sta_driver_data *data, const u8 *addr)
  268. {
  269. if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
  270. return -1;
  271. return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
  272. }
  273. static inline int
  274. hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
  275. size_t data_len, int encrypt)
  276. {
  277. if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
  278. return 0;
  279. return hapd->driver->send_eapol(hapd->drv_priv, addr, data, data_len,
  280. encrypt, hapd->own_addr);
  281. }
  282. static inline int
  283. hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
  284. {
  285. if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
  286. return 0;
  287. return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason);
  288. }
  289. static inline int
  290. hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
  291. {
  292. if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
  293. return 0;
  294. return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason);
  295. }
  296. static inline int
  297. hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
  298. {
  299. if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
  300. return 0;
  301. return hapd->driver->sta_remove(hapd->drv_priv, addr);
  302. }
  303. static inline int
  304. hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
  305. {
  306. if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
  307. return 0;
  308. return hapd->driver->get_ssid(hapd->conf->iface, hapd->drv_priv, buf,
  309. len);
  310. }
  311. static inline int
  312. hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
  313. {
  314. if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
  315. return 0;
  316. return hapd->driver->set_ssid(hapd->conf->iface, hapd->drv_priv, buf,
  317. len);
  318. }
  319. static inline int
  320. hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
  321. int flags)
  322. {
  323. if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
  324. return 0;
  325. return hapd->driver->send_mgmt_frame(hapd->drv_priv, msg, len, flags);
  326. }
  327. static inline int
  328. hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
  329. {
  330. if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
  331. return 0;
  332. return hapd->driver->set_assoc_ap(hapd->drv_priv, addr);
  333. }
  334. static inline int
  335. hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
  336. {
  337. if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
  338. return 0;
  339. return hapd->driver->set_countermeasures(hapd->drv_priv, enabled);
  340. }
  341. static inline int
  342. hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
  343. u16 aid, u16 capability, const u8 *supp_rates,
  344. size_t supp_rates_len, int flags, u16 listen_interval,
  345. const struct ht_cap_ie *ht_capabilities)
  346. {
  347. if (hapd->driver == NULL)
  348. return 0;
  349. if (hapd->driver->sta_add2) {
  350. struct hostapd_sta_add_params params;
  351. os_memset(&params, 0, sizeof(params));
  352. params.addr = addr;
  353. params.aid = aid;
  354. params.capability = capability;
  355. params.supp_rates = supp_rates;
  356. params.supp_rates_len = supp_rates_len;
  357. params.flags = flags;
  358. params.listen_interval = listen_interval;
  359. params.ht_capabilities = ht_capabilities;
  360. return hapd->driver->sta_add2(ifname, hapd->drv_priv, &params);
  361. }
  362. if (hapd->driver->sta_add == NULL)
  363. return 0;
  364. return hapd->driver->sta_add(ifname, hapd->drv_priv, addr, aid,
  365. capability, (u8 *) supp_rates,
  366. supp_rates_len,
  367. flags, listen_interval);
  368. }
  369. static inline int
  370. hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
  371. {
  372. if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
  373. return 0;
  374. return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
  375. }
  376. static inline int
  377. hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq)
  378. {
  379. if (hapd->driver == NULL || hapd->driver->set_freq == NULL)
  380. return 0;
  381. return hapd->driver->set_freq(hapd->drv_priv, mode, freq);
  382. }
  383. static inline int
  384. hostapd_set_rts(struct hostapd_data *hapd, int rts)
  385. {
  386. if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
  387. return 0;
  388. return hapd->driver->set_rts(hapd->drv_priv, rts);
  389. }
  390. static inline int
  391. hostapd_get_rts(struct hostapd_data *hapd, int *rts)
  392. {
  393. if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
  394. return 0;
  395. return hapd->driver->get_rts(hapd->drv_priv, rts);
  396. }
  397. static inline int
  398. hostapd_set_frag(struct hostapd_data *hapd, int frag)
  399. {
  400. if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
  401. return 0;
  402. return hapd->driver->set_frag(hapd->drv_priv, frag);
  403. }
  404. static inline int
  405. hostapd_get_frag(struct hostapd_data *hapd, int *frag)
  406. {
  407. if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
  408. return 0;
  409. return hapd->driver->get_frag(hapd->drv_priv, frag);
  410. }
  411. static inline int
  412. hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
  413. {
  414. if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
  415. return 0;
  416. return hapd->driver->set_retry(hapd->drv_priv, short_retry,
  417. long_retry);
  418. }
  419. static inline int
  420. hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
  421. {
  422. if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
  423. return 0;
  424. return hapd->driver->get_retry(hapd->drv_priv, short_retry,
  425. long_retry);
  426. }
  427. static inline int
  428. hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
  429. int total_flags, int flags_or, int flags_and)
  430. {
  431. if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
  432. return 0;
  433. return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
  434. flags_or, flags_and);
  435. }
  436. static inline int
  437. hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
  438. int *basic_rates, int mode)
  439. {
  440. if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
  441. return 0;
  442. return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
  443. basic_rates, mode);
  444. }
  445. static inline int
  446. hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
  447. {
  448. if (hapd->driver == NULL ||
  449. hapd->driver->set_regulatory_domain == NULL)
  450. return 0;
  451. return hapd->driver->set_regulatory_domain(hapd->drv_priv, rd);
  452. }
  453. static inline int
  454. hostapd_set_country(struct hostapd_data *hapd, const char *country)
  455. {
  456. if (hapd->driver == NULL ||
  457. hapd->driver->set_country == NULL)
  458. return 0;
  459. return hapd->driver->set_country(hapd->drv_priv, country);
  460. }
  461. static inline int
  462. hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
  463. {
  464. if (hapd->driver == NULL ||
  465. hapd->driver->set_ieee80211d == NULL)
  466. return 0;
  467. return hapd->driver->set_ieee80211d(hapd->drv_priv, enabled);
  468. }
  469. static inline int
  470. hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
  471. {
  472. if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
  473. return 0;
  474. return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
  475. }
  476. static inline int
  477. hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
  478. u8 *head, size_t head_len,
  479. u8 *tail, size_t tail_len)
  480. {
  481. if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
  482. return 0;
  483. return hapd->driver->set_beacon(ifname, hapd->drv_priv, head, head_len,
  484. tail, tail_len);
  485. }
  486. static inline int
  487. hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
  488. {
  489. if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
  490. return 0;
  491. return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
  492. }
  493. static inline int
  494. hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
  495. {
  496. if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
  497. return 0;
  498. return hapd->driver->set_beacon_int(hapd->drv_priv, value);
  499. }
  500. static inline int
  501. hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
  502. {
  503. if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
  504. return 0;
  505. return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->drv_priv,
  506. value);
  507. }
  508. static inline int
  509. hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
  510. {
  511. if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
  512. return 0;
  513. return hapd->driver->set_broadcast_ssid(hapd->drv_priv, value);
  514. }
  515. static inline int
  516. hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
  517. {
  518. if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
  519. return 0;
  520. return hapd->driver->set_cts_protect(hapd->drv_priv, value);
  521. }
  522. static inline int
  523. hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
  524. {
  525. if (hapd->driver == NULL ||
  526. hapd->driver->set_key_tx_rx_threshold == NULL)
  527. return 0;
  528. return hapd->driver->set_key_tx_rx_threshold(hapd->drv_priv, value);
  529. }
  530. static inline int
  531. hostapd_set_preamble(struct hostapd_data *hapd, int value)
  532. {
  533. if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
  534. return 0;
  535. return hapd->driver->set_preamble(hapd->drv_priv, value);
  536. }
  537. static inline int
  538. hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
  539. {
  540. if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
  541. return 0;
  542. return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
  543. }
  544. static inline int
  545. hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
  546. int cw_min, int cw_max, int burst_time)
  547. {
  548. if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
  549. return 0;
  550. return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
  551. cw_min, cw_max, burst_time);
  552. }
  553. static inline int
  554. hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
  555. {
  556. if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
  557. return 0;
  558. return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
  559. }
  560. static inline int
  561. hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
  562. {
  563. if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
  564. return 0;
  565. return hapd->driver->bss_remove(hapd->drv_priv, ifname);
  566. }
  567. static inline int
  568. hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
  569. const u8 *mask)
  570. {
  571. if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
  572. return 1;
  573. return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
  574. }
  575. static inline int
  576. hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
  577. char *ifname, const u8 *addr)
  578. {
  579. if (hapd->driver == NULL || hapd->driver->if_add == NULL)
  580. return -1;
  581. return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
  582. ifname, addr);
  583. }
  584. static inline int
  585. hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
  586. char *ifname, const u8 *addr)
  587. {
  588. if (hapd->driver == NULL || hapd->driver->if_update == NULL)
  589. return -1;
  590. return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
  591. }
  592. static inline int
  593. hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
  594. char *ifname, const u8 *addr)
  595. {
  596. if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
  597. return -1;
  598. return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
  599. }
  600. static inline int
  601. hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
  602. int interval, int _listen, int *channel,
  603. int *last_rx)
  604. {
  605. if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
  606. return -1;
  607. return hapd->driver->passive_scan(hapd->drv_priv, now, our_mode_only,
  608. interval, _listen, channel, last_rx);
  609. }
  610. static inline struct hostapd_hw_modes *
  611. hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
  612. u16 *flags)
  613. {
  614. if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
  615. return NULL;
  616. return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
  617. flags);
  618. }
  619. static inline int
  620. hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
  621. const u8 *addr, int vlan_id)
  622. {
  623. if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
  624. return 0;
  625. return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
  626. }
  627. static inline int
  628. hostapd_driver_commit(struct hostapd_data *hapd)
  629. {
  630. if (hapd->driver == NULL || hapd->driver->commit == NULL)
  631. return 0;
  632. return hapd->driver->commit(hapd->drv_priv);
  633. }
  634. static inline int
  635. hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
  636. int accepted, u32 session_timeout)
  637. {
  638. if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
  639. return 0;
  640. return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
  641. session_timeout);
  642. }
  643. static inline int
  644. hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
  645. {
  646. if (hapd->driver == NULL ||
  647. hapd->driver->set_radius_acl_expire == NULL)
  648. return 0;
  649. return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
  650. }
  651. #ifdef CONFIG_IEEE80211N
  652. static inline int
  653. hostapd_set_ht_capability(const char *ifname, struct hostapd_data *hapd,
  654. const u8 *ht_cap)
  655. {
  656. if (hapd->driver == NULL || hapd->driver->set_ht_capability == NULL ||
  657. ht_cap == NULL)
  658. return 0;
  659. return hapd->driver->set_ht_capability(
  660. ifname, hapd->drv_priv, ht_cap,
  661. sizeof(struct ieee80211_ht_capability));
  662. }
  663. static inline int
  664. hostapd_set_ht_operation(const char *ifname, struct hostapd_data *hapd,
  665. const u8 *ht_operation)
  666. {
  667. if (hapd->driver == NULL || hapd->driver->set_ht_operation == NULL ||
  668. ht_operation == NULL)
  669. return 0;
  670. return hapd->driver->set_ht_operation(
  671. ifname, hapd->drv_priv, ht_operation,
  672. sizeof(struct ieee80211_ht_operation));
  673. }
  674. #endif /* CONFIG_IEEE80211N */
  675. static inline int
  676. hostapd_drv_none(struct hostapd_data *hapd)
  677. {
  678. return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
  679. }
  680. #endif /* DRIVER_H */