driver.h 24 KB

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