If boot verbose, print asicrev, chiprev and bus type.
[dragonfly.git] / contrib / hostapd-0.5.8 / driver.h
blob4fd262c1ff143177fcfbedce8c28072de608047e
1 #ifndef DRIVER_H
2 #define DRIVER_H
4 enum hostapd_driver_if_type {
5 HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
6 };
8 struct driver_ops {
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);
17 /**
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);
30 /**
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
37 * Configure privacy.
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,
45 int idx, u8 *seq);
46 int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
47 int idx, u8 *seq);
48 int (*flush)(void *priv);
49 int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
50 size_t elem_len);
52 int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
53 const u8 *addr);
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,
61 int len);
62 int (*set_countermeasures)(void *priv, int enabled);
63 int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
64 int flags);
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,
68 int flags);
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,
83 int mode);
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
106 * broadcast SSID
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,
120 int *last_rx);
121 struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
122 u16 *num_modes,
123 u16 *flags);
124 int (*if_add)(const char *iface, void *priv,
125 enum hostapd_driver_if_type type, char *ifname,
126 const u8 *addr);
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,
132 int vlan_id);
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);
146 static inline int
147 hostapd_driver_init(struct hostapd_data *hapd)
149 if (hapd->driver == NULL || hapd->driver->init == NULL)
150 return -1;
151 return hapd->driver->init(hapd);
154 static inline void
155 hostapd_driver_deinit(struct hostapd_data *hapd)
157 if (hapd->driver == NULL || hapd->driver->deinit == NULL)
158 return;
159 hapd->driver->deinit(hapd->driver);
162 static inline int
163 hostapd_wireless_event_init(struct hostapd_data *hapd)
165 if (hapd->driver == NULL ||
166 hapd->driver->wireless_event_init == NULL)
167 return 0;
168 return hapd->driver->wireless_event_init(hapd->driver);
171 static inline void
172 hostapd_wireless_event_deinit(struct hostapd_data *hapd)
174 if (hapd->driver == NULL ||
175 hapd->driver->wireless_event_deinit == NULL)
176 return;
177 hapd->driver->wireless_event_deinit(hapd->driver);
180 static inline int
181 hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
182 int enabled)
184 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
185 return 0;
186 return hapd->driver->set_ieee8021x(ifname, hapd->driver, enabled);
189 static inline int
190 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
192 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
193 return 0;
194 return hapd->driver->set_privacy(hapd->conf->iface, hapd->driver,
195 enabled);
198 static inline int
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)
204 return 0;
205 return hapd->driver->set_encryption(ifname, hapd->driver, alg, addr,
206 idx, key, key_len, txkey);
209 static inline int
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)
214 return 0;
215 return hapd->driver->get_seqnum(ifname, hapd->driver, addr, idx, seq);
218 static inline int
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)
223 return -1;
224 return hapd->driver->get_seqnum_igtk(ifname, hapd->driver, addr, idx,
225 seq);
228 static inline int
229 hostapd_flush(struct hostapd_data *hapd)
231 if (hapd->driver == NULL || hapd->driver->flush == NULL)
232 return 0;
233 return hapd->driver->flush(hapd->driver);
236 static inline int
237 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
238 size_t elem_len)
240 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
241 return 0;
242 return hapd->driver->set_generic_elem(hapd->conf->iface, hapd->driver,
243 elem, elem_len);
246 static inline int
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)
251 return -1;
252 return hapd->driver->read_sta_data(hapd->driver, data, addr);
255 static inline int
256 hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
257 size_t data_len, int encrypt)
259 if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
260 return 0;
261 return hapd->driver->send_eapol(hapd->driver, addr, data, data_len,
262 encrypt, hapd->own_addr);
265 static inline int
266 hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
268 if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
269 return 0;
270 return hapd->driver->sta_deauth(hapd->driver, addr, reason);
273 static inline int
274 hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
276 if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
277 return 0;
278 return hapd->driver->sta_disassoc(hapd->driver, addr, reason);
281 static inline int
282 hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
284 if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
285 return 0;
286 return hapd->driver->sta_remove(hapd->driver, addr);
289 static inline int
290 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
292 if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
293 return 0;
294 return hapd->driver->get_ssid(hapd->conf->iface, hapd->driver, buf,
295 len);
298 static inline int
299 hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
301 if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
302 return 0;
303 return hapd->driver->set_ssid(hapd->conf->iface, hapd->driver, buf,
304 len);
307 static inline int
308 hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
309 int flags)
311 if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
312 return 0;
313 return hapd->driver->send_mgmt_frame(hapd->driver, msg, len, flags);
316 static inline int
317 hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
319 if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
320 return 0;
321 return hapd->driver->set_assoc_ap(hapd->driver, addr);
324 static inline int
325 hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
327 if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
328 return 0;
329 return hapd->driver->set_countermeasures(hapd->driver, enabled);
332 static inline int
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,
335 int flags)
337 if (hapd->driver == NULL || hapd->driver->sta_add == NULL)
338 return 0;
339 return hapd->driver->sta_add(ifname, hapd->driver, addr, aid,
340 capability, supp_rates, supp_rates_len,
341 flags);
344 static inline int
345 hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
347 if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
348 return 0;
349 return hapd->driver->get_inact_sec(hapd->driver, addr);
352 static inline int
353 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq)
355 if (hapd->driver == NULL || hapd->driver->set_freq == NULL)
356 return 0;
357 return hapd->driver->set_freq(hapd->driver, mode, freq);
360 static inline int
361 hostapd_set_rts(struct hostapd_data *hapd, int rts)
363 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
364 return 0;
365 return hapd->driver->set_rts(hapd->driver, rts);
368 static inline int
369 hostapd_get_rts(struct hostapd_data *hapd, int *rts)
371 if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
372 return 0;
373 return hapd->driver->get_rts(hapd->driver, rts);
376 static inline int
377 hostapd_set_frag(struct hostapd_data *hapd, int frag)
379 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
380 return 0;
381 return hapd->driver->set_frag(hapd->driver, frag);
384 static inline int
385 hostapd_get_frag(struct hostapd_data *hapd, int *frag)
387 if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
388 return 0;
389 return hapd->driver->get_frag(hapd->driver, frag);
392 static inline int
393 hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
395 if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
396 return 0;
397 return hapd->driver->set_retry(hapd->driver, short_retry, long_retry);
400 static inline int
401 hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
403 if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
404 return 0;
405 return hapd->driver->get_retry(hapd->driver, short_retry, long_retry);
408 static inline int
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)
413 return 0;
414 return hapd->driver->sta_set_flags(hapd->driver, addr, flags_or,
415 flags_and);
418 static inline int
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)
423 return 0;
424 return hapd->driver->set_rate_sets(hapd->driver, supp_rates,
425 basic_rates, mode);
428 static inline int
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)
434 return 0;
435 return hapd->driver->set_channel_flag(hapd->driver, mode, chan, flag,
436 power_level, antenna_max);
439 static inline int
440 hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
442 if (hapd->driver == NULL ||
443 hapd->driver->set_regulatory_domain == NULL)
444 return 0;
445 return hapd->driver->set_regulatory_domain(hapd->driver, rd);
448 static inline int
449 hostapd_set_country(struct hostapd_data *hapd, const char *country)
451 if (hapd->driver == NULL ||
452 hapd->driver->set_country == NULL)
453 return 0;
454 return hapd->driver->set_country(hapd->driver, country);
457 static inline int
458 hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
460 if (hapd->driver == NULL ||
461 hapd->driver->set_ieee80211d == NULL)
462 return 0;
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);
470 static inline int
471 hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
473 if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
474 return 0;
475 return hapd->driver->sta_clear_stats(hapd->driver, addr);
478 static inline int
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)
484 return 0;
485 return hapd->driver->set_beacon(ifname, hapd->driver, head, head_len,
486 tail, tail_len);
489 static inline int
490 hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
492 if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
493 return 0;
494 return hapd->driver->set_internal_bridge(hapd->driver, value);
497 static inline int
498 hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
500 if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
501 return 0;
502 return hapd->driver->set_beacon_int(hapd->driver, value);
505 static inline int
506 hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
508 if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
509 return 0;
510 return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->driver,
511 value);
514 static inline int
515 hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
517 if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
518 return 0;
519 return hapd->driver->set_broadcast_ssid(hapd->driver, value);
522 static inline int
523 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
525 if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
526 return 0;
527 return hapd->driver->set_cts_protect(hapd->driver, value);
530 static inline int
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)
535 return 0;
536 return hapd->driver->set_key_tx_rx_threshold(hapd->driver, value);
539 static inline int
540 hostapd_set_preamble(struct hostapd_data *hapd, int value)
542 if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
543 return 0;
544 return hapd->driver->set_preamble(hapd->driver, value);
547 static inline int
548 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
550 if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
551 return 0;
552 return hapd->driver->set_short_slot_time(hapd->driver, value);
555 static inline int
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)
560 return 0;
561 return hapd->driver->set_tx_queue_params(hapd->driver, queue, aifs,
562 cw_min, cw_max, burst_time);
565 static inline int
566 hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
568 if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
569 return 0;
570 return hapd->driver->bss_add(hapd->driver, ifname, bssid);
573 static inline int
574 hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
576 if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
577 return 0;
578 return hapd->driver->bss_remove(hapd->driver, ifname);
581 static inline int
582 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
583 const u8 *mask)
585 if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
586 return 1;
587 return hapd->driver->valid_bss_mask(hapd->driver, addr, mask);
590 static inline int
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)
595 return -1;
596 return hapd->driver->if_add(hapd->conf->iface, hapd->driver, type,
597 ifname, addr);
600 static inline int
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)
605 return -1;
606 return hapd->driver->if_update(hapd->driver, type, ifname, addr);
609 static inline int
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)
614 return -1;
615 return hapd->driver->if_remove(hapd->driver, type, ifname, addr);
618 static inline int
619 hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
620 int interval, int _listen, int *channel,
621 int *last_rx)
623 if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
624 return -1;
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,
631 u16 *flags)
633 if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
634 return NULL;
635 return hapd->driver->get_hw_feature_data(hapd->driver, num_modes,
636 flags);
639 static inline int
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)
644 return 0;
645 return hapd->driver->set_sta_vlan(hapd->driver, addr, ifname, vlan_id);
648 static inline int
649 hostapd_driver_commit(struct hostapd_data *hapd)
651 if (hapd->driver == NULL || hapd->driver->commit == NULL)
652 return 0;
653 return hapd->driver->commit(hapd->driver);
656 #endif /* DRIVER_H */