4 enum hostapd_driver_if_type {
5 HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
9 const char *name; /* as appears in the config file */
11 int (*init)(struct hostapd_data *hapd);
12 void (*deinit)(void *priv);
14 int (*wireless_event_init)(void *priv);
15 void (*wireless_event_deinit)(void *priv);
18 * set_8021x - enable/disable IEEE 802.1X support
19 * @ifname: Interface name (for multi-SSID/VLAN support)
20 * @priv: driver private data
21 * @enabled: 1 = enable, 0 = disable
23 * Returns: 0 on success, -1 on failure
25 * Configure the kernel driver to enable/disable 802.1X support.
26 * This may be an empty function if 802.1X support is always enabled.
28 int (*set_ieee8021x)(const char *ifname, void *priv, int enabled);
31 * set_privacy - enable/disable privacy
32 * @priv: driver private data
33 * @enabled: 1 = privacy enabled, 0 = disabled
35 * Return: 0 on success, -1 on failure
39 int (*set_privacy)(const char *ifname, void *priv, int enabled);
41 int (*set_encryption)(const char *ifname, void *priv, const char *alg,
42 const u8 *addr, int idx,
43 const u8 *key, size_t key_len, int txkey);
44 int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
46 int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
48 int (*flush)(void *priv);
49 int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
52 int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
54 int (*send_eapol)(void *priv, const u8 *addr, const u8 *data,
55 size_t data_len, int encrypt, const u8 *own_addr);
56 int (*sta_deauth)(void *priv, const u8 *addr, int reason);
57 int (*sta_disassoc)(void *priv, const u8 *addr, int reason);
58 int (*sta_remove)(void *priv, const u8 *addr);
59 int (*get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
60 int (*set_ssid)(const char *ifname, void *priv, const u8 *buf,
62 int (*set_countermeasures)(void *priv, int enabled);
63 int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
65 int (*set_assoc_ap)(void *priv, const u8 *addr);
66 int (*sta_add)(const char *ifname, void *priv, const u8 *addr, u16 aid,
67 u16 capability, u8 *supp_rates, size_t supp_rates_len,
69 int (*get_inact_sec)(void *priv, const u8 *addr);
70 int (*sta_clear_stats)(void *priv, const u8 *addr);
72 int (*set_freq)(void *priv, int mode, int freq);
73 int (*set_rts)(void *priv, int rts);
74 int (*get_rts)(void *priv, int *rts);
75 int (*set_frag)(void *priv, int frag);
76 int (*get_frag)(void *priv, int *frag);
77 int (*set_retry)(void *priv, int short_retry, int long_retry);
78 int (*get_retry)(void *priv, int *short_retry, int *long_retry);
80 int (*sta_set_flags)(void *priv, const u8 *addr,
81 int flags_or, int flags_and);
82 int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
84 int (*set_channel_flag)(void *priv, int mode, int chan, int flag,
85 unsigned char power_level,
86 unsigned char antenna_max);
87 int (*set_regulatory_domain)(void *priv, unsigned int rd);
88 int (*set_country)(void *priv, const char *country);
89 int (*set_ieee80211d)(void *priv, int enabled);
90 int (*set_beacon)(const char *ifname, void *priv,
91 u8 *head, size_t head_len,
92 u8 *tail, size_t tail_len);
94 /* Configure internal bridge:
95 * 0 = disabled, i.e., client separation is enabled (no bridging of
96 * packets between associated STAs
97 * 1 = enabled, i.e., bridge packets between associated STAs (default)
99 int (*set_internal_bridge)(void *priv, int value);
100 int (*set_beacon_int)(void *priv, int value);
101 int (*set_dtim_period)(const char *ifname, void *priv, int value);
102 /* Configure broadcast SSID mode:
103 * 0 = include SSID in Beacon frames and reply to Probe Request frames
104 * that use broadcast SSID
105 * 1 = hide SSID from Beacon frames and ignore Probe Request frames for
108 int (*set_broadcast_ssid)(void *priv, int value);
109 int (*set_cts_protect)(void *priv, int value);
110 int (*set_key_tx_rx_threshold)(void *priv, int value);
111 int (*set_preamble)(void *priv, int value);
112 int (*set_short_slot_time)(void *priv, int value);
113 int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
114 int cw_max, int burst_time);
115 int (*bss_add)(void *priv, const char *ifname, const u8 *bssid);
116 int (*bss_remove)(void *priv, const char *ifname);
117 int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
118 int (*passive_scan)(void *priv, int now, int our_mode_only,
119 int interval, int _listen, int *channel,
121 struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
124 int (*if_add)(const char *iface, void *priv,
125 enum hostapd_driver_if_type type, char *ifname,
127 int (*if_update)(void *priv, enum hostapd_driver_if_type type,
128 char *ifname, const u8 *addr);
129 int (*if_remove)(void *priv, enum hostapd_driver_if_type type,
130 const char *ifname, const u8 *addr);
131 int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
134 * commit - Optional commit changes handler
135 * @priv: driver private data
136 * Returns: 0 on success, -1 on failure
138 * This optional handler function can be registered if the driver
139 * interface implementation needs to commit changes (e.g., by setting
140 * network interface up) at the end of initial configuration. If set,
141 * this handler will be called after initial setup has been completed.
143 int (*commit)(void *priv);
145 int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
146 u32 session_timeout);
147 int (*set_radius_acl_expire)(void *priv, const u8 *mac);
151 hostapd_driver_init(struct hostapd_data *hapd)
153 if (hapd->driver == NULL || hapd->driver->init == NULL)
155 return hapd->driver->init(hapd);
159 hostapd_driver_deinit(struct hostapd_data *hapd)
161 if (hapd->driver == NULL || hapd->driver->deinit == NULL)
163 hapd->driver->deinit(hapd->driver);
167 hostapd_wireless_event_init(struct hostapd_data *hapd)
169 if (hapd->driver == NULL ||
170 hapd->driver->wireless_event_init == NULL)
172 return hapd->driver->wireless_event_init(hapd->driver);
176 hostapd_wireless_event_deinit(struct hostapd_data *hapd)
178 if (hapd->driver == NULL ||
179 hapd->driver->wireless_event_deinit == NULL)
181 hapd->driver->wireless_event_deinit(hapd->driver);
185 hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
188 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
190 return hapd->driver->set_ieee8021x(ifname, hapd->driver, enabled);
194 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
196 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
198 return hapd->driver->set_privacy(hapd->conf->iface, hapd->driver,
203 hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
204 const char *alg, const u8 *addr, int idx,
205 u8 *key, size_t key_len, int txkey)
207 if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
209 return hapd->driver->set_encryption(ifname, hapd->driver, alg, addr,
210 idx, key, key_len, txkey);
214 hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
215 const u8 *addr, int idx, u8 *seq)
217 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
219 return hapd->driver->get_seqnum(ifname, hapd->driver, addr, idx, seq);
223 hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
224 const u8 *addr, int idx, u8 *seq)
226 if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
228 return hapd->driver->get_seqnum_igtk(ifname, hapd->driver, addr, idx,
233 hostapd_flush(struct hostapd_data *hapd)
235 if (hapd->driver == NULL || hapd->driver->flush == NULL)
237 return hapd->driver->flush(hapd->driver);
241 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
244 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
246 return hapd->driver->set_generic_elem(hapd->conf->iface, hapd->driver,
251 hostapd_read_sta_data(struct hostapd_data *hapd,
252 struct hostap_sta_driver_data *data, const u8 *addr)
254 if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
256 return hapd->driver->read_sta_data(hapd->driver, data, addr);
260 hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
261 size_t data_len, int encrypt)
263 if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
265 return hapd->driver->send_eapol(hapd->driver, addr, data, data_len,
266 encrypt, hapd->own_addr);
270 hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
272 if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
274 return hapd->driver->sta_deauth(hapd->driver, addr, reason);
278 hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
280 if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
282 return hapd->driver->sta_disassoc(hapd->driver, addr, reason);
286 hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
288 if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
290 return hapd->driver->sta_remove(hapd->driver, addr);
294 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
296 if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
298 return hapd->driver->get_ssid(hapd->conf->iface, hapd->driver, buf,
303 hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
305 if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
307 return hapd->driver->set_ssid(hapd->conf->iface, hapd->driver, buf,
312 hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
315 if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
317 return hapd->driver->send_mgmt_frame(hapd->driver, msg, len, flags);
321 hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
323 if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
325 return hapd->driver->set_assoc_ap(hapd->driver, addr);
329 hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
331 if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
333 return hapd->driver->set_countermeasures(hapd->driver, enabled);
337 hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
338 u16 aid, u16 capability, u8 *supp_rates, size_t supp_rates_len,
341 if (hapd->driver == NULL || hapd->driver->sta_add == NULL)
343 return hapd->driver->sta_add(ifname, hapd->driver, addr, aid,
344 capability, supp_rates, supp_rates_len,
349 hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
351 if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
353 return hapd->driver->get_inact_sec(hapd->driver, addr);
357 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq)
359 if (hapd->driver == NULL || hapd->driver->set_freq == NULL)
361 return hapd->driver->set_freq(hapd->driver, mode, freq);
365 hostapd_set_rts(struct hostapd_data *hapd, int rts)
367 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
369 return hapd->driver->set_rts(hapd->driver, rts);
373 hostapd_get_rts(struct hostapd_data *hapd, int *rts)
375 if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
377 return hapd->driver->get_rts(hapd->driver, rts);
381 hostapd_set_frag(struct hostapd_data *hapd, int frag)
383 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
385 return hapd->driver->set_frag(hapd->driver, frag);
389 hostapd_get_frag(struct hostapd_data *hapd, int *frag)
391 if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
393 return hapd->driver->get_frag(hapd->driver, frag);
397 hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
399 if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
401 return hapd->driver->set_retry(hapd->driver, short_retry, long_retry);
405 hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
407 if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
409 return hapd->driver->get_retry(hapd->driver, short_retry, long_retry);
413 hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
414 int flags_or, int flags_and)
416 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
418 return hapd->driver->sta_set_flags(hapd->driver, addr, flags_or,
423 hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
424 int *basic_rates, int mode)
426 if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
428 return hapd->driver->set_rate_sets(hapd->driver, supp_rates,
433 hostapd_set_channel_flag(struct hostapd_data *hapd, int mode, int chan,
434 int flag, unsigned char power_level,
435 unsigned char antenna_max)
437 if (hapd->driver == NULL || hapd->driver->set_channel_flag == NULL)
439 return hapd->driver->set_channel_flag(hapd->driver, mode, chan, flag,
440 power_level, antenna_max);
444 hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
446 if (hapd->driver == NULL ||
447 hapd->driver->set_regulatory_domain == NULL)
449 return hapd->driver->set_regulatory_domain(hapd->driver, rd);
453 hostapd_set_country(struct hostapd_data *hapd, const char *country)
455 if (hapd->driver == NULL ||
456 hapd->driver->set_country == NULL)
458 return hapd->driver->set_country(hapd->driver, country);
462 hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
464 if (hapd->driver == NULL ||
465 hapd->driver->set_ieee80211d == NULL)
467 return hapd->driver->set_ieee80211d(hapd->driver, enabled);
470 void driver_register(const char *name, const struct driver_ops *ops);
471 void driver_unregister(const char *name);
472 const struct driver_ops *driver_lookup(const char *name);
475 hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
477 if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
479 return hapd->driver->sta_clear_stats(hapd->driver, addr);
483 hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
484 u8 *head, size_t head_len,
485 u8 *tail, size_t tail_len)
487 if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
489 return hapd->driver->set_beacon(ifname, hapd->driver, head, head_len,
494 hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
496 if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
498 return hapd->driver->set_internal_bridge(hapd->driver, value);
502 hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
504 if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
506 return hapd->driver->set_beacon_int(hapd->driver, value);
510 hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
512 if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
514 return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->driver,
519 hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
521 if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
523 return hapd->driver->set_broadcast_ssid(hapd->driver, value);
527 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
529 if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
531 return hapd->driver->set_cts_protect(hapd->driver, value);
535 hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
537 if (hapd->driver == NULL ||
538 hapd->driver->set_key_tx_rx_threshold == NULL)
540 return hapd->driver->set_key_tx_rx_threshold(hapd->driver, value);
544 hostapd_set_preamble(struct hostapd_data *hapd, int value)
546 if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
548 return hapd->driver->set_preamble(hapd->driver, value);
552 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
554 if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
556 return hapd->driver->set_short_slot_time(hapd->driver, value);
560 hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
561 int cw_min, int cw_max, int burst_time)
563 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
565 return hapd->driver->set_tx_queue_params(hapd->driver, queue, aifs,
566 cw_min, cw_max, burst_time);
570 hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
572 if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
574 return hapd->driver->bss_add(hapd->driver, ifname, bssid);
578 hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
580 if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
582 return hapd->driver->bss_remove(hapd->driver, ifname);
586 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
589 if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
591 return hapd->driver->valid_bss_mask(hapd->driver, addr, mask);
595 hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
596 char *ifname, const u8 *addr)
598 if (hapd->driver == NULL || hapd->driver->if_add == NULL)
600 return hapd->driver->if_add(hapd->conf->iface, hapd->driver, type,
605 hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
606 char *ifname, const u8 *addr)
608 if (hapd->driver == NULL || hapd->driver->if_update == NULL)
610 return hapd->driver->if_update(hapd->driver, type, ifname, addr);
614 hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
615 char *ifname, const u8 *addr)
617 if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
619 return hapd->driver->if_remove(hapd->driver, type, ifname, addr);
623 hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
624 int interval, int _listen, int *channel,
627 if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
629 return hapd->driver->passive_scan(hapd->driver, now, our_mode_only,
630 interval, _listen, channel, last_rx);
633 static inline struct hostapd_hw_modes *
634 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
637 if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
639 return hapd->driver->get_hw_feature_data(hapd->driver, num_modes,
644 hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
645 const u8 *addr, int vlan_id)
647 if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
649 return hapd->driver->set_sta_vlan(hapd->driver, addr, ifname, vlan_id);
653 hostapd_driver_commit(struct hostapd_data *hapd)
655 if (hapd->driver == NULL || hapd->driver->commit == NULL)
657 return hapd->driver->commit(hapd->driver);
661 hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac, int accepted,
664 if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
666 return hapd->driver->set_radius_acl_auth(hapd->driver, mac, accepted,
671 hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
673 if (hapd->driver == NULL || hapd->driver->set_radius_acl_expire == NULL)
675 return hapd->driver->set_radius_acl_expire(hapd->driver, mac);
678 #endif /* DRIVER_H */