driver.h 21 KB

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