driver.h 21 KB

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