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);
147 hostapd_driver_init(struct hostapd_data *hapd)
149 if (hapd->driver == NULL || hapd->driver->init == NULL)
151 return hapd->driver->init(hapd);
155 hostapd_driver_deinit(struct hostapd_data *hapd)
157 if (hapd->driver == NULL || hapd->driver->deinit == NULL)
159 hapd->driver->deinit(hapd->driver);
163 hostapd_wireless_event_init(struct hostapd_data *hapd)
165 if (hapd->driver == NULL ||
166 hapd->driver->wireless_event_init == NULL)
168 return hapd->driver->wireless_event_init(hapd->driver);
172 hostapd_wireless_event_deinit(struct hostapd_data *hapd)
174 if (hapd->driver == NULL ||
175 hapd->driver->wireless_event_deinit == NULL)
177 hapd->driver->wireless_event_deinit(hapd->driver);
181 hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
184 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
186 return hapd->driver->set_ieee8021x(ifname, hapd->driver, enabled);
190 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
192 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
194 return hapd->driver->set_privacy(hapd->conf->iface, hapd->driver,
199 hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
200 const char *alg, const u8 *addr, int idx,
201 u8 *key, size_t key_len, int txkey)
203 if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
205 return hapd->driver->set_encryption(ifname, hapd->driver, alg, addr,
206 idx, key, key_len, txkey);
210 hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
211 const u8 *addr, int idx, u8 *seq)
213 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
215 return hapd->driver->get_seqnum(ifname, hapd->driver, addr, idx, seq);
219 hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
220 const u8 *addr, int idx, u8 *seq)
222 if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
224 return hapd->driver->get_seqnum_igtk(ifname, hapd->driver, addr, idx,
229 hostapd_flush(struct hostapd_data *hapd)
231 if (hapd->driver == NULL || hapd->driver->flush == NULL)
233 return hapd->driver->flush(hapd->driver);
237 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
240 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
242 return hapd->driver->set_generic_elem(hapd->conf->iface, hapd->driver,
247 hostapd_read_sta_data(struct hostapd_data *hapd,
248 struct hostap_sta_driver_data *data, const u8 *addr)
250 if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
252 return hapd->driver->read_sta_data(hapd->driver, data, addr);
256 hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
257 size_t data_len, int encrypt)
259 if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
261 return hapd->driver->send_eapol(hapd->driver, addr, data, data_len,
262 encrypt, hapd->own_addr);
266 hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
268 if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
270 return hapd->driver->sta_deauth(hapd->driver, addr, reason);
274 hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
276 if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
278 return hapd->driver->sta_disassoc(hapd->driver, addr, reason);
282 hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
284 if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
286 return hapd->driver->sta_remove(hapd->driver, addr);
290 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
292 if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
294 return hapd->driver->get_ssid(hapd->conf->iface, hapd->driver, buf,
299 hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
301 if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
303 return hapd->driver->set_ssid(hapd->conf->iface, hapd->driver, buf,
308 hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
311 if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
313 return hapd->driver->send_mgmt_frame(hapd->driver, msg, len, flags);
317 hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
319 if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
321 return hapd->driver->set_assoc_ap(hapd->driver, addr);
325 hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
327 if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
329 return hapd->driver->set_countermeasures(hapd->driver, enabled);
333 hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
334 u16 aid, u16 capability, u8 *supp_rates, size_t supp_rates_len,
337 if (hapd->driver == NULL || hapd->driver->sta_add == NULL)
339 return hapd->driver->sta_add(ifname, hapd->driver, addr, aid,
340 capability, supp_rates, supp_rates_len,
345 hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
347 if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
349 return hapd->driver->get_inact_sec(hapd->driver, addr);
353 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq)
355 if (hapd->driver == NULL || hapd->driver->set_freq == NULL)
357 return hapd->driver->set_freq(hapd->driver, mode, freq);
361 hostapd_set_rts(struct hostapd_data *hapd, int rts)
363 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
365 return hapd->driver->set_rts(hapd->driver, rts);
369 hostapd_get_rts(struct hostapd_data *hapd, int *rts)
371 if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
373 return hapd->driver->get_rts(hapd->driver, rts);
377 hostapd_set_frag(struct hostapd_data *hapd, int frag)
379 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
381 return hapd->driver->set_frag(hapd->driver, frag);
385 hostapd_get_frag(struct hostapd_data *hapd, int *frag)
387 if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
389 return hapd->driver->get_frag(hapd->driver, frag);
393 hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
395 if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
397 return hapd->driver->set_retry(hapd->driver, short_retry, long_retry);
401 hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
403 if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
405 return hapd->driver->get_retry(hapd->driver, short_retry, long_retry);
409 hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
410 int flags_or, int flags_and)
412 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
414 return hapd->driver->sta_set_flags(hapd->driver, addr, flags_or,
419 hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
420 int *basic_rates, int mode)
422 if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
424 return hapd->driver->set_rate_sets(hapd->driver, supp_rates,
429 hostapd_set_channel_flag(struct hostapd_data *hapd, int mode, int chan,
430 int flag, unsigned char power_level,
431 unsigned char antenna_max)
433 if (hapd->driver == NULL || hapd->driver->set_channel_flag == NULL)
435 return hapd->driver->set_channel_flag(hapd->driver, mode, chan, flag,
436 power_level, antenna_max);
440 hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
442 if (hapd->driver == NULL ||
443 hapd->driver->set_regulatory_domain == NULL)
445 return hapd->driver->set_regulatory_domain(hapd->driver, rd);
449 hostapd_set_country(struct hostapd_data *hapd, const char *country)
451 if (hapd->driver == NULL ||
452 hapd->driver->set_country == NULL)
454 return hapd->driver->set_country(hapd->driver, country);
458 hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
460 if (hapd->driver == NULL ||
461 hapd->driver->set_ieee80211d == NULL)
463 return hapd->driver->set_ieee80211d(hapd->driver, enabled);
466 void driver_register(const char *name, const struct driver_ops *ops);
467 void driver_unregister(const char *name);
468 const struct driver_ops *driver_lookup(const char *name);
471 hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
473 if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
475 return hapd->driver->sta_clear_stats(hapd->driver, addr);
479 hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
480 u8 *head, size_t head_len,
481 u8 *tail, size_t tail_len)
483 if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
485 return hapd->driver->set_beacon(ifname, hapd->driver, head, head_len,
490 hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
492 if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
494 return hapd->driver->set_internal_bridge(hapd->driver, value);
498 hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
500 if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
502 return hapd->driver->set_beacon_int(hapd->driver, value);
506 hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
508 if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
510 return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->driver,
515 hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
517 if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
519 return hapd->driver->set_broadcast_ssid(hapd->driver, value);
523 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
525 if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
527 return hapd->driver->set_cts_protect(hapd->driver, value);
531 hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
533 if (hapd->driver == NULL ||
534 hapd->driver->set_key_tx_rx_threshold == NULL)
536 return hapd->driver->set_key_tx_rx_threshold(hapd->driver, value);
540 hostapd_set_preamble(struct hostapd_data *hapd, int value)
542 if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
544 return hapd->driver->set_preamble(hapd->driver, value);
548 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
550 if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
552 return hapd->driver->set_short_slot_time(hapd->driver, value);
556 hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
557 int cw_min, int cw_max, int burst_time)
559 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
561 return hapd->driver->set_tx_queue_params(hapd->driver, queue, aifs,
562 cw_min, cw_max, burst_time);
566 hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
568 if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
570 return hapd->driver->bss_add(hapd->driver, ifname, bssid);
574 hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
576 if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
578 return hapd->driver->bss_remove(hapd->driver, ifname);
582 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
585 if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
587 return hapd->driver->valid_bss_mask(hapd->driver, addr, mask);
591 hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
592 char *ifname, const u8 *addr)
594 if (hapd->driver == NULL || hapd->driver->if_add == NULL)
596 return hapd->driver->if_add(hapd->conf->iface, hapd->driver, type,
601 hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
602 char *ifname, const u8 *addr)
604 if (hapd->driver == NULL || hapd->driver->if_update == NULL)
606 return hapd->driver->if_update(hapd->driver, type, ifname, addr);
610 hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
611 char *ifname, const u8 *addr)
613 if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
615 return hapd->driver->if_remove(hapd->driver, type, ifname, addr);
619 hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
620 int interval, int _listen, int *channel,
623 if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
625 return hapd->driver->passive_scan(hapd->driver, now, our_mode_only,
626 interval, _listen, channel, last_rx);
629 static inline struct hostapd_hw_modes *
630 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
633 if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
635 return hapd->driver->get_hw_feature_data(hapd->driver, num_modes,
640 hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
641 const u8 *addr, int vlan_id)
643 if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
645 return hapd->driver->set_sta_vlan(hapd->driver, addr, ifname, vlan_id);
649 hostapd_driver_commit(struct hostapd_data *hapd)
651 if (hapd->driver == NULL || hapd->driver->commit == NULL)
653 return hapd->driver->commit(hapd->driver);
656 #endif /* DRIVER_H */