driver.h 23 KB

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