Split hostapd/driver.h into two files
authorJouni Malinen <j@w1.fi>
Thu, 8 Jan 2009 17:48:52 +0000 (19:48 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 8 Jan 2009 18:02:56 +0000 (20:02 +0200)
driver.h contains the definitions needed in driver wrapper
implementations (driver_*.c) and driver_i.h contains the definitions
that are used in core hostapd code to interact with the driver wrappers.

16 files changed:
hostapd/accounting.c
hostapd/beacon.c
hostapd/driver.h
hostapd/driver_hostap.c
hostapd/driver_i.h [new file with mode: 0644]
hostapd/driver_nl80211.c
hostapd/driver_prism54.c
hostapd/hostapd.c
hostapd/hw_features.c
hostapd/ieee802_11.c
hostapd/ieee802_11_auth.c
hostapd/ieee802_1x.c
hostapd/sta_info.c
hostapd/vlan_init.c
hostapd/wme.c
hostapd/wps_hostapd.c

index ce71678..10656f1 100644 (file)
@@ -20,7 +20,7 @@
 #include "eloop.h"
 #include "accounting.h"
 #include "ieee802_1x.h"
-#include "driver.h"
+#include "driver_i.h"
 
 
 /* Default interval in seconds for polling TX/RX octets from the driver if
index 31323e8..d76586a 100644 (file)
@@ -25,7 +25,7 @@
 #include "wme.h"
 #include "beacon.h"
 #include "hw_features.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "sta_info.h"
 #include "wps_hostapd.h"
 
index a7a96e4..8a6d91b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * hostapd - driver interface definition
- * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
  * Copyright (c) 2007-2008, Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
@@ -197,602 +197,4 @@ struct wpa_driver_ops {
                                     const u8 *ie, size_t len);
 };
 
-static inline void *
-hostapd_driver_init(struct hostapd_data *hapd)
-{
-       if (hapd->driver == NULL || hapd->driver->init == NULL)
-               return NULL;
-       return hapd->driver->init(hapd);
-}
-
-static inline void *
-hostapd_driver_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
-{
-       if (hapd->driver == NULL || hapd->driver->init_bssid == NULL)
-               return NULL;
-       return hapd->driver->init_bssid(hapd, bssid);
-}
-
-static inline void
-hostapd_driver_deinit(struct hostapd_data *hapd)
-{
-       if (hapd->driver == NULL || hapd->driver->deinit == NULL)
-               return;
-       hapd->driver->deinit(hapd->drv_priv);
-}
-
-static inline int
-hostapd_wireless_event_init(struct hostapd_data *hapd)
-{
-       if (hapd->driver == NULL ||
-           hapd->driver->wireless_event_init == NULL)
-               return 0;
-       return hapd->driver->wireless_event_init(hapd->drv_priv);
-}
-
-static inline void
-hostapd_wireless_event_deinit(struct hostapd_data *hapd)
-{
-       if (hapd->driver == NULL ||
-           hapd->driver->wireless_event_deinit == NULL)
-               return;
-       hapd->driver->wireless_event_deinit(hapd->drv_priv);
-}
-
-static inline int
-hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
-                     int enabled)
-{
-       if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
-               return 0;
-       return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
-}
-
-static inline int
-hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
-{
-       if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
-               return 0;
-       return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
-                                        enabled);
-}
-
-static inline int
-hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
-                      const char *alg, const u8 *addr, int idx,
-                      u8 *key, size_t key_len, int txkey)
-{
-       if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
-               return 0;
-       return hapd->driver->set_encryption(ifname, hapd->drv_priv, alg, addr,
-                                           idx, key, key_len, txkey);
-}
-
-static inline int
-hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
-                  const u8 *addr, int idx, u8 *seq)
-{
-       if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
-               return 0;
-       return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
-                                       seq);
-}
-
-static inline int
-hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
-                       const u8 *addr, int idx, u8 *seq)
-{
-       if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
-               return -1;
-       return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
-                                            seq);
-}
-
-static inline int
-hostapd_flush(struct hostapd_data *hapd)
-{
-       if (hapd->driver == NULL || hapd->driver->flush == NULL)
-               return 0;
-       return hapd->driver->flush(hapd->drv_priv);
-}
-
-static inline int
-hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
-                        size_t elem_len)
-{
-       if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
-               return 0;
-       return hapd->driver->set_generic_elem(hapd->conf->iface,
-                                             hapd->drv_priv, elem, elem_len);
-}
-
-static inline int
-hostapd_read_sta_data(struct hostapd_data *hapd,
-                     struct hostap_sta_driver_data *data, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
-               return -1;
-       return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
-}
-
-static inline int
-hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
-                  size_t data_len, int encrypt)
-{
-       if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
-               return 0;
-       return hapd->driver->send_eapol(hapd->drv_priv, addr, data, data_len,
-                                       encrypt, hapd->own_addr);
-}
-
-static inline int
-hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
-{
-       if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
-               return 0;
-       return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason);
-}
-
-static inline int
-hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
-{
-       if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
-               return 0;
-       return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason);
-}
-
-static inline int
-hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
-               return 0;
-       return hapd->driver->sta_remove(hapd->drv_priv, addr);
-}
-
-static inline int
-hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
-{
-       if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
-               return 0;
-       return hapd->driver->get_ssid(hapd->conf->iface, hapd->drv_priv, buf,
-                                     len);
-}
-
-static inline int
-hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
-{
-       if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
-               return 0;
-       return hapd->driver->set_ssid(hapd->conf->iface, hapd->drv_priv, buf,
-                                     len);
-}
-
-static inline int
-hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
-                       int flags)
-{
-       if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
-               return 0;
-       return hapd->driver->send_mgmt_frame(hapd->drv_priv, msg, len, flags);
-}
-
-static inline int
-hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
-               return 0;
-       return hapd->driver->set_assoc_ap(hapd->drv_priv, addr);
-}
-
-static inline int
-hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
-{
-       if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
-               return 0;
-       return hapd->driver->set_countermeasures(hapd->drv_priv, enabled);
-}
-
-static inline int
-hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
-               u16 aid, u16 capability, const u8 *supp_rates,
-               size_t supp_rates_len, int flags, u16 listen_interval,
-               const struct ht_cap_ie *ht_capabilities)
-{
-       if (hapd->driver == NULL)
-               return 0;
-
-       if (hapd->driver->sta_add2) {
-               struct hostapd_sta_add_params params;
-               os_memset(&params, 0, sizeof(params));
-               params.addr = addr;
-               params.aid = aid;
-               params.capability = capability;
-               params.supp_rates = supp_rates;
-               params.supp_rates_len = supp_rates_len;
-               params.flags = flags;
-               params.listen_interval = listen_interval;
-               params.ht_capabilities = ht_capabilities;
-               return hapd->driver->sta_add2(ifname, hapd->drv_priv, &params);
-       }
-
-       if (hapd->driver->sta_add == NULL)
-               return 0;
-       return hapd->driver->sta_add(ifname, hapd->drv_priv, addr, aid,
-                                    capability, (u8 *) supp_rates,
-                                    supp_rates_len,
-                                    flags, listen_interval);
-}
-
-static inline int
-hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
-               return 0;
-       return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
-}
-
-static inline int
-hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int ht_enabled,
-                int sec_channel_offset)
-{
-       if (hapd->driver == NULL)
-               return 0;
-       if (hapd->driver->set_freq2) {
-               struct hostapd_freq_params data;
-               os_memset(&data, 0, sizeof(data));
-               data.mode = mode;
-               data.freq = freq;
-               data.ht_enabled = ht_enabled;
-               data.sec_channel_offset = sec_channel_offset;
-               return hapd->driver->set_freq2(hapd->drv_priv, &data);
-       }
-
-       if (hapd->driver->set_freq == NULL)
-               return 0;
-       return hapd->driver->set_freq(hapd->drv_priv, mode, freq);
-}
-
-static inline int
-hostapd_set_rts(struct hostapd_data *hapd, int rts)
-{
-       if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
-               return 0;
-       return hapd->driver->set_rts(hapd->drv_priv, rts);
-}
-
-static inline int
-hostapd_get_rts(struct hostapd_data *hapd, int *rts)
-{
-       if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
-               return 0;
-       return hapd->driver->get_rts(hapd->drv_priv, rts);
-}
-
-static inline int
-hostapd_set_frag(struct hostapd_data *hapd, int frag)
-{
-       if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
-               return 0;
-       return hapd->driver->set_frag(hapd->drv_priv, frag);
-}
-
-static inline int
-hostapd_get_frag(struct hostapd_data *hapd, int *frag)
-{
-       if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
-               return 0;
-       return hapd->driver->get_frag(hapd->drv_priv, frag);
-}
-
-static inline int
-hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
-{
-       if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
-               return 0;
-       return hapd->driver->set_retry(hapd->drv_priv, short_retry,
-                                      long_retry);
-}
-
-static inline int
-hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
-{
-       if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
-               return 0;
-       return hapd->driver->get_retry(hapd->drv_priv, short_retry,
-                                      long_retry);
-}
-
-static inline int
-hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
-                     int total_flags, int flags_or, int flags_and)
-{
-       if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
-               return 0;
-       return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
-                                          flags_or, flags_and);
-}
-
-static inline int
-hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
-                     int *basic_rates, int mode)
-{
-       if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
-               return 0;
-       return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
-                                          basic_rates, mode);
-}
-
-static inline int
-hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
-{
-       if (hapd->driver == NULL ||
-           hapd->driver->set_regulatory_domain == NULL)
-               return 0;
-       return hapd->driver->set_regulatory_domain(hapd->drv_priv, rd);
-}
-
-static inline int
-hostapd_set_country(struct hostapd_data *hapd, const char *country)
-{
-       if (hapd->driver == NULL ||
-           hapd->driver->set_country == NULL)
-               return 0;
-       return hapd->driver->set_country(hapd->drv_priv, country);
-}
-
-static inline int
-hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
-{
-       if (hapd->driver == NULL ||
-           hapd->driver->set_ieee80211d == NULL)
-               return 0;
-       return hapd->driver->set_ieee80211d(hapd->drv_priv, enabled);
-}
-
-static inline int
-hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
-               return 0;
-       return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
-}
-
-static inline int
-hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
-                  u8 *head, size_t head_len,
-                  u8 *tail, size_t tail_len)
-{
-       if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
-               return 0;
-       return hapd->driver->set_beacon(ifname, hapd->drv_priv, head, head_len,
-                                       tail, tail_len);
-}
-
-static inline int
-hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
-{
-       if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
-               return 0;
-       return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
-{
-       if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
-               return 0;
-       return hapd->driver->set_beacon_int(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
-{
-       if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
-               return 0;
-       return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->drv_priv,
-                                            value);
-}
-
-static inline int
-hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
-{
-       if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
-               return 0;
-       return hapd->driver->set_broadcast_ssid(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
-{
-       if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
-               return 0;
-       return hapd->driver->set_cts_protect(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
-{
-       if (hapd->driver == NULL ||
-           hapd->driver->set_key_tx_rx_threshold == NULL)
-               return 0;
-       return hapd->driver->set_key_tx_rx_threshold(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_preamble(struct hostapd_data *hapd, int value)
-{
-       if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
-               return 0;
-       return hapd->driver->set_preamble(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
-{
-       if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
-               return 0;
-       return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
-}
-
-static inline int
-hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
-                           int cw_min, int cw_max, int burst_time)
-{
-       if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
-               return 0;
-       return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
-                                                cw_min, cw_max, burst_time);
-}
-
-static inline int
-hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
-{
-       if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
-               return 0;
-       return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
-}
-
-static inline int
-hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
-{
-       if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
-               return 0;
-       return hapd->driver->bss_remove(hapd->drv_priv, ifname);
-}
-
-static inline int
-hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
-                      const u8 *mask)
-{
-       if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
-               return 1;
-       return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
-}
-
-static inline int
-hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
-              char *ifname, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->if_add == NULL)
-               return -1;
-       return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
-                                   ifname, addr);
-}
-
-static inline int
-hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
-                 char *ifname, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->if_update == NULL)
-               return -1;
-       return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
-}
-
-static inline int
-hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
-                 char *ifname, const u8 *addr)
-{
-       if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
-               return -1;
-       return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
-}
-
-static inline int
-hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
-                    int interval, int _listen, int *channel,
-                    int *last_rx)
-{
-       if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
-               return -1;
-       return hapd->driver->passive_scan(hapd->drv_priv, now, our_mode_only,
-                                         interval, _listen, channel, last_rx);
-}
-
-static inline struct hostapd_hw_modes *
-hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
-                           u16 *flags)
-{
-       if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
-               return NULL;
-       return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
-                                                flags);
-}
-
-static inline int
-hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
-                    const u8 *addr, int vlan_id)
-{
-       if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
-               return 0;
-       return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
-}
-
-static inline int
-hostapd_driver_commit(struct hostapd_data *hapd)
-{
-       if (hapd->driver == NULL || hapd->driver->commit == NULL)
-               return 0;
-       return hapd->driver->commit(hapd->drv_priv);
-}
-
-static inline int
-hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
-                           int accepted, u32 session_timeout)
-{
-       if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
-               return 0;
-       return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
-                                                session_timeout);
-}
-
-static inline int
-hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
-{
-       if (hapd->driver == NULL ||
-           hapd->driver->set_radius_acl_expire == NULL)
-               return 0;
-       return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
-}
-
-#ifdef CONFIG_IEEE80211N
-static inline int
-hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
-                     const u8 *ht_capab, size_t ht_capab_len,
-                     const u8 *ht_oper, size_t ht_oper_len)
-{
-       if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
-           ht_capab == NULL || ht_oper == NULL)
-               return 0;
-       return hapd->driver->set_ht_params(
-               ifname, hapd->drv_priv, ht_capab, ht_capab_len,
-               ht_oper, ht_oper_len);
-}
-#endif /* CONFIG_IEEE80211N */
-
-static inline int
-hostapd_drv_none(struct hostapd_data *hapd)
-{
-       return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
-}
-
-static inline int
-hostapd_set_wps_beacon_ie(struct hostapd_data *hapd, const u8 *ie, size_t len)
-{
-       if (hapd->driver == NULL || hapd->driver->set_wps_beacon_ie == NULL)
-               return 0;
-       return hapd->driver->set_wps_beacon_ie(hapd->conf->iface,
-                                              hapd->drv_priv, ie, len);
-}
-
-static inline int
-hostapd_set_wps_probe_resp_ie(struct hostapd_data *hapd, const u8 *ie,
-                             size_t len)
-{
-       if (hapd->driver == NULL ||
-           hapd->driver->set_wps_probe_resp_ie == NULL)
-               return 0;
-       return hapd->driver->set_wps_probe_resp_ie(hapd->conf->iface,
-                                                  hapd->drv_priv, ie, len);
-}
-
 #endif /* DRIVER_H */
index ceff099..6586372 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * hostapd / Kernel driver communication with Linux Host AP driver
- * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -63,8 +63,10 @@ struct hostap_driver_data {
 static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
                         int len);
 static int hostap_set_iface_flags(void *priv, int dev_up);
+static int hostap_sta_disassoc(void *priv, const u8 *addr, int reason);
+static int hostap_sta_deauth(void *priv, const u8 *addr, int reason);
 
-static void handle_data(struct hostapd_data *hapd, u8 *buf, size_t len,
+static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len,
                        u16 stype)
 {
        struct ieee80211_hdr *hdr;
@@ -85,17 +87,17 @@ static void handle_data(struct hostapd_data *hapd, u8 *buf, size_t len,
        }
 
        sa = hdr->addr2;
-       sta = ap_get_sta(hapd, sa);
+       sta = ap_get_sta(drv->hapd, sa);
        if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
                printf("Data frame from not associated STA " MACSTR "\n",
                       MAC2STR(sa));
                if (sta && (sta->flags & WLAN_STA_AUTH))
-                       hostapd_sta_disassoc(
-                               hapd, sa,
+                       hostap_sta_disassoc(
+                               drv, sa,
                                WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
                else
-                       hostapd_sta_deauth(
-                               hapd, sa,
+                       hostap_sta_deauth(
+                               drv, sa,
                                WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
                return;
        }
@@ -125,7 +127,7 @@ static void handle_data(struct hostapd_data *hapd, u8 *buf, size_t len,
        left -= 2;
        switch (ethertype) {
        case ETH_P_PAE:
-               ieee802_1x_receive(hapd, sa, pos, left);
+               ieee802_1x_receive(drv->hapd, sa, pos, left);
                break;
 
        default:
@@ -135,8 +137,8 @@ static void handle_data(struct hostapd_data *hapd, u8 *buf, size_t len,
 }
 
 
-static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
-                              int ok)
+static void handle_tx_callback(struct hostap_driver_data *drv, u8 *buf,
+                              size_t len, int ok)
 {
        struct ieee80211_hdr *hdr;
        u16 fc, type, stype;
@@ -152,7 +154,7 @@ static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
        case WLAN_FC_TYPE_MGMT:
                wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s",
                           ok ? "ACK" : "fail");
-               ieee802_11_mgmt_cb(hapd, buf, len, stype, ok);
+               ieee802_11_mgmt_cb(drv->hapd, buf, len, stype, ok);
                break;
        case WLAN_FC_TYPE_CTRL:
                wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s",
@@ -161,7 +163,7 @@ static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
        case WLAN_FC_TYPE_DATA:
                wpa_printf(MSG_DEBUG, "DATA (TX callback) %s",
                           ok ? "ACK" : "fail");
-               sta = ap_get_sta(hapd, hdr->addr1);
+               sta = ap_get_sta(drv->hapd, hdr->addr1);
                if (sta && sta->flags & WLAN_STA_PENDING_POLL) {
                        wpa_printf(MSG_DEBUG, "STA " MACSTR
                                   " %s pending activity poll",
@@ -171,7 +173,7 @@ static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
                                sta->flags &= ~WLAN_STA_PENDING_POLL;
                }
                if (sta)
-                       ieee802_1x_tx_status(hapd, sta, buf, len, ok);
+                       ieee802_1x_tx_status(drv->hapd, sta, buf, len, ok);
                break;
        default:
                printf("unknown TX callback frame type %d\n", type);
@@ -180,7 +182,7 @@ static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
 }
 
 
-static void handle_frame(struct hostapd_data *hapd, u8 *buf, size_t len)
+static void handle_frame(struct hostap_driver_data *drv, u8 *buf, size_t len)
 {
        struct ieee80211_hdr *hdr;
        u16 fc, extra_len, type, stype;
@@ -222,7 +224,7 @@ static void handle_frame(struct hostapd_data *hapd, u8 *buf, size_t len)
                len -= extra_len + 2;
                extra = buf + len;
        } else if (ver == 1 || ver == 2) {
-               handle_tx_callback(hapd, buf, data_len, ver == 2 ? 1 : 0);
+               handle_tx_callback(drv, buf, data_len, ver == 2 ? 1 : 0);
                return;
        } else if (ver != 0) {
                printf("unknown protocol version %d\n", ver);
@@ -233,14 +235,14 @@ static void handle_frame(struct hostapd_data *hapd, u8 *buf, size_t len)
        case WLAN_FC_TYPE_MGMT:
                if (stype != WLAN_FC_STYPE_BEACON)
                        wpa_printf(MSG_MSGDUMP, "MGMT");
-               ieee802_11_mgmt(hapd, buf, data_len, stype, NULL);
+               ieee802_11_mgmt(drv->hapd, buf, data_len, stype, NULL);
                break;
        case WLAN_FC_TYPE_CTRL:
                wpa_printf(MSG_DEBUG, "CTRL");
                break;
        case WLAN_FC_TYPE_DATA:
                wpa_printf(MSG_DEBUG, "DATA");
-               handle_data(hapd, buf, data_len, stype);
+               handle_data(drv, buf, data_len, stype);
                break;
        default:
                wpa_printf(MSG_DEBUG, "unknown frame type %d", type);
@@ -251,7 +253,7 @@ static void handle_frame(struct hostapd_data *hapd, u8 *buf, size_t len)
 
 static void handle_read(int sock, void *eloop_ctx, void *sock_ctx)
 {
-       struct hostapd_data *hapd = (struct hostapd_data *) eloop_ctx;
+       struct hostap_driver_data *drv = eloop_ctx;
        int len;
        unsigned char buf[3000];
 
@@ -261,7 +263,7 @@ static void handle_read(int sock, void *eloop_ctx, void *sock_ctx)
                return;
        }
 
-       handle_frame(hapd, buf, len);
+       handle_frame(drv, buf, len);
 }
 
 
@@ -276,8 +278,7 @@ static int hostap_init_sockets(struct hostap_driver_data *drv)
                return -1;
        }
 
-       if (eloop_register_read_sock(drv->sock, handle_read, drv->hapd, NULL))
-       {
+       if (eloop_register_read_sock(drv->sock, handle_read, drv, NULL)) {
                printf("Could not register read socket\n");
                return -1;
        }
diff --git a/hostapd/driver_i.h b/hostapd/driver_i.h
new file mode 100644 (file)
index 0000000..1eb65db
--- /dev/null
@@ -0,0 +1,619 @@
+/*
+ * hostapd - internal driver interface wrappers
+ * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2007-2008, Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#ifndef DRIVER_I_H
+#define DRIVER_I_H
+
+#include "driver.h"
+
+static inline void *
+hostapd_driver_init(struct hostapd_data *hapd)
+{
+       if (hapd->driver == NULL || hapd->driver->init == NULL)
+               return NULL;
+       return hapd->driver->init(hapd);
+}
+
+static inline void *
+hostapd_driver_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
+{
+       if (hapd->driver == NULL || hapd->driver->init_bssid == NULL)
+               return NULL;
+       return hapd->driver->init_bssid(hapd, bssid);
+}
+
+static inline void
+hostapd_driver_deinit(struct hostapd_data *hapd)
+{
+       if (hapd->driver == NULL || hapd->driver->deinit == NULL)
+               return;
+       hapd->driver->deinit(hapd->drv_priv);
+}
+
+static inline int
+hostapd_wireless_event_init(struct hostapd_data *hapd)
+{
+       if (hapd->driver == NULL ||
+           hapd->driver->wireless_event_init == NULL)
+               return 0;
+       return hapd->driver->wireless_event_init(hapd->drv_priv);
+}
+
+static inline void
+hostapd_wireless_event_deinit(struct hostapd_data *hapd)
+{
+       if (hapd->driver == NULL ||
+           hapd->driver->wireless_event_deinit == NULL)
+               return;
+       hapd->driver->wireless_event_deinit(hapd->drv_priv);
+}
+
+static inline int
+hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
+                     int enabled)
+{
+       if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
+               return 0;
+       return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
+}
+
+static inline int
+hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
+{
+       if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
+               return 0;
+       return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
+                                        enabled);
+}
+
+static inline int
+hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
+                      const char *alg, const u8 *addr, int idx,
+                      u8 *key, size_t key_len, int txkey)
+{
+       if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
+               return 0;
+       return hapd->driver->set_encryption(ifname, hapd->drv_priv, alg, addr,
+                                           idx, key, key_len, txkey);
+}
+
+static inline int
+hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
+                  const u8 *addr, int idx, u8 *seq)
+{
+       if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
+               return 0;
+       return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
+                                       seq);
+}
+
+static inline int
+hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
+                       const u8 *addr, int idx, u8 *seq)
+{
+       if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
+               return -1;
+       return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
+                                            seq);
+}
+
+static inline int
+hostapd_flush(struct hostapd_data *hapd)
+{
+       if (hapd->driver == NULL || hapd->driver->flush == NULL)
+               return 0;
+       return hapd->driver->flush(hapd->drv_priv);
+}
+
+static inline int
+hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
+                        size_t elem_len)
+{
+       if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
+               return 0;
+       return hapd->driver->set_generic_elem(hapd->conf->iface,
+                                             hapd->drv_priv, elem, elem_len);
+}
+
+static inline int
+hostapd_read_sta_data(struct hostapd_data *hapd,
+                     struct hostap_sta_driver_data *data, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
+               return -1;
+       return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
+}
+
+static inline int
+hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
+                  size_t data_len, int encrypt)
+{
+       if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
+               return 0;
+       return hapd->driver->send_eapol(hapd->drv_priv, addr, data, data_len,
+                                       encrypt, hapd->own_addr);
+}
+
+static inline int
+hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
+{
+       if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
+               return 0;
+       return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason);
+}
+
+static inline int
+hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
+{
+       if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
+               return 0;
+       return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason);
+}
+
+static inline int
+hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
+               return 0;
+       return hapd->driver->sta_remove(hapd->drv_priv, addr);
+}
+
+static inline int
+hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
+{
+       if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
+               return 0;
+       return hapd->driver->get_ssid(hapd->conf->iface, hapd->drv_priv, buf,
+                                     len);
+}
+
+static inline int
+hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
+{
+       if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
+               return 0;
+       return hapd->driver->set_ssid(hapd->conf->iface, hapd->drv_priv, buf,
+                                     len);
+}
+
+static inline int
+hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
+                       int flags)
+{
+       if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
+               return 0;
+       return hapd->driver->send_mgmt_frame(hapd->drv_priv, msg, len, flags);
+}
+
+static inline int
+hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
+               return 0;
+       return hapd->driver->set_assoc_ap(hapd->drv_priv, addr);
+}
+
+static inline int
+hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
+{
+       if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
+               return 0;
+       return hapd->driver->set_countermeasures(hapd->drv_priv, enabled);
+}
+
+static inline int
+hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
+               u16 aid, u16 capability, const u8 *supp_rates,
+               size_t supp_rates_len, int flags, u16 listen_interval,
+               const struct ht_cap_ie *ht_capabilities)
+{
+       if (hapd->driver == NULL)
+               return 0;
+
+       if (hapd->driver->sta_add2) {
+               struct hostapd_sta_add_params params;
+               os_memset(&params, 0, sizeof(params));
+               params.addr = addr;
+               params.aid = aid;
+               params.capability = capability;
+               params.supp_rates = supp_rates;
+               params.supp_rates_len = supp_rates_len;
+               params.flags = flags;
+               params.listen_interval = listen_interval;
+               params.ht_capabilities = ht_capabilities;
+               return hapd->driver->sta_add2(ifname, hapd->drv_priv, &params);
+       }
+
+       if (hapd->driver->sta_add == NULL)
+               return 0;
+       return hapd->driver->sta_add(ifname, hapd->drv_priv, addr, aid,
+                                    capability, (u8 *) supp_rates,
+                                    supp_rates_len,
+                                    flags, listen_interval);
+}
+
+static inline int
+hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
+               return 0;
+       return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
+}
+
+static inline int
+hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int ht_enabled,
+                int sec_channel_offset)
+{
+       if (hapd->driver == NULL)
+               return 0;
+       if (hapd->driver->set_freq2) {
+               struct hostapd_freq_params data;
+               os_memset(&data, 0, sizeof(data));
+               data.mode = mode;
+               data.freq = freq;
+               data.ht_enabled = ht_enabled;
+               data.sec_channel_offset = sec_channel_offset;
+               return hapd->driver->set_freq2(hapd->drv_priv, &data);
+       }
+
+       if (hapd->driver->set_freq == NULL)
+               return 0;
+       return hapd->driver->set_freq(hapd->drv_priv, mode, freq);
+}
+
+static inline int
+hostapd_set_rts(struct hostapd_data *hapd, int rts)
+{
+       if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
+               return 0;
+       return hapd->driver->set_rts(hapd->drv_priv, rts);
+}
+
+static inline int
+hostapd_get_rts(struct hostapd_data *hapd, int *rts)
+{
+       if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
+               return 0;
+       return hapd->driver->get_rts(hapd->drv_priv, rts);
+}
+
+static inline int
+hostapd_set_frag(struct hostapd_data *hapd, int frag)
+{
+       if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
+               return 0;
+       return hapd->driver->set_frag(hapd->drv_priv, frag);
+}
+
+static inline int
+hostapd_get_frag(struct hostapd_data *hapd, int *frag)
+{
+       if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
+               return 0;
+       return hapd->driver->get_frag(hapd->drv_priv, frag);
+}
+
+static inline int
+hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
+{
+       if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
+               return 0;
+       return hapd->driver->set_retry(hapd->drv_priv, short_retry,
+                                      long_retry);
+}
+
+static inline int
+hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
+{
+       if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
+               return 0;
+       return hapd->driver->get_retry(hapd->drv_priv, short_retry,
+                                      long_retry);
+}
+
+static inline int
+hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
+                     int total_flags, int flags_or, int flags_and)
+{
+       if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
+               return 0;
+       return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
+                                          flags_or, flags_and);
+}
+
+static inline int
+hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
+                     int *basic_rates, int mode)
+{
+       if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
+               return 0;
+       return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
+                                          basic_rates, mode);
+}
+
+static inline int
+hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
+{
+       if (hapd->driver == NULL ||
+           hapd->driver->set_regulatory_domain == NULL)
+               return 0;
+       return hapd->driver->set_regulatory_domain(hapd->drv_priv, rd);
+}
+
+static inline int
+hostapd_set_country(struct hostapd_data *hapd, const char *country)
+{
+       if (hapd->driver == NULL ||
+           hapd->driver->set_country == NULL)
+               return 0;
+       return hapd->driver->set_country(hapd->drv_priv, country);
+}
+
+static inline int
+hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
+{
+       if (hapd->driver == NULL ||
+           hapd->driver->set_ieee80211d == NULL)
+               return 0;
+       return hapd->driver->set_ieee80211d(hapd->drv_priv, enabled);
+}
+
+static inline int
+hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
+               return 0;
+       return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
+}
+
+static inline int
+hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
+                  u8 *head, size_t head_len,
+                  u8 *tail, size_t tail_len)
+{
+       if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
+               return 0;
+       return hapd->driver->set_beacon(ifname, hapd->drv_priv, head, head_len,
+                                       tail, tail_len);
+}
+
+static inline int
+hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
+{
+       if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
+               return 0;
+       return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
+}
+
+static inline int
+hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
+{
+       if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
+               return 0;
+       return hapd->driver->set_beacon_int(hapd->drv_priv, value);
+}
+
+static inline int
+hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
+{
+       if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
+               return 0;
+       return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->drv_priv,
+                                            value);
+}
+
+static inline int
+hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
+{
+       if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
+               return 0;
+       return hapd->driver->set_broadcast_ssid(hapd->drv_priv, value);
+}
+
+static inline int
+hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
+{
+       if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
+               return 0;
+       return hapd->driver->set_cts_protect(hapd->drv_priv, value);
+}
+
+static inline int
+hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
+{
+       if (hapd->driver == NULL ||
+           hapd->driver->set_key_tx_rx_threshold == NULL)
+               return 0;
+       return hapd->driver->set_key_tx_rx_threshold(hapd->drv_priv, value);
+}
+
+static inline int
+hostapd_set_preamble(struct hostapd_data *hapd, int value)
+{
+       if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
+               return 0;
+       return hapd->driver->set_preamble(hapd->drv_priv, value);
+}
+
+static inline int
+hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
+{
+       if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
+               return 0;
+       return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
+}
+
+static inline int
+hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
+                           int cw_min, int cw_max, int burst_time)
+{
+       if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
+               return 0;
+       return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
+                                                cw_min, cw_max, burst_time);
+}
+
+static inline int
+hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
+{
+       if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
+               return 0;
+       return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
+}
+
+static inline int
+hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
+{
+       if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
+               return 0;
+       return hapd->driver->bss_remove(hapd->drv_priv, ifname);
+}
+
+static inline int
+hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
+                      const u8 *mask)
+{
+       if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
+               return 1;
+       return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
+}
+
+static inline int
+hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
+              char *ifname, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->if_add == NULL)
+               return -1;
+       return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
+                                   ifname, addr);
+}
+
+static inline int
+hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
+                 char *ifname, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->if_update == NULL)
+               return -1;
+       return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
+}
+
+static inline int
+hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
+                 char *ifname, const u8 *addr)
+{
+       if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
+               return -1;
+       return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
+}
+
+static inline int
+hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
+                    int interval, int _listen, int *channel,
+                    int *last_rx)
+{
+       if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
+               return -1;
+       return hapd->driver->passive_scan(hapd->drv_priv, now, our_mode_only,
+                                         interval, _listen, channel, last_rx);
+}
+
+static inline struct hostapd_hw_modes *
+hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
+                           u16 *flags)
+{
+       if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
+               return NULL;
+       return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
+                                                flags);
+}
+
+static inline int
+hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
+                    const u8 *addr, int vlan_id)
+{
+       if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
+               return 0;
+       return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
+}
+
+static inline int
+hostapd_driver_commit(struct hostapd_data *hapd)
+{
+       if (hapd->driver == NULL || hapd->driver->commit == NULL)
+               return 0;
+       return hapd->driver->commit(hapd->drv_priv);
+}
+
+static inline int
+hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
+                           int accepted, u32 session_timeout)
+{
+       if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
+               return 0;
+       return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
+                                                session_timeout);
+}
+
+static inline int
+hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
+{
+       if (hapd->driver == NULL ||
+           hapd->driver->set_radius_acl_expire == NULL)
+               return 0;
+       return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
+}
+
+#ifdef CONFIG_IEEE80211N
+static inline int
+hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
+                     const u8 *ht_capab, size_t ht_capab_len,
+                     const u8 *ht_oper, size_t ht_oper_len)
+{
+       if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
+           ht_capab == NULL || ht_oper == NULL)
+               return 0;
+       return hapd->driver->set_ht_params(
+               ifname, hapd->drv_priv, ht_capab, ht_capab_len,
+               ht_oper, ht_oper_len);
+}
+#endif /* CONFIG_IEEE80211N */
+
+static inline int
+hostapd_drv_none(struct hostapd_data *hapd)
+{
+       return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
+}
+
+static inline int
+hostapd_set_wps_beacon_ie(struct hostapd_data *hapd, const u8 *ie, size_t len)
+{
+       if (hapd->driver == NULL || hapd->driver->set_wps_beacon_ie == NULL)
+               return 0;
+       return hapd->driver->set_wps_beacon_ie(hapd->conf->iface,
+                                              hapd->drv_priv, ie, len);
+}
+
+static inline int
+hostapd_set_wps_probe_resp_ie(struct hostapd_data *hapd, const u8 *ie,
+                             size_t len)
+{
+       if (hapd->driver == NULL ||
+           hapd->driver->set_wps_probe_resp_ie == NULL)
+               return 0;
+       return hapd->driver->set_wps_probe_resp_ie(hapd->conf->iface,
+                                                  hapd->drv_priv, ie, len);
+}
+
+#endif /* DRIVER_I_H */
index 5d039c7..9f26d5d 100644 (file)
@@ -81,6 +81,10 @@ struct i802_driver_data {
 };
 
 
+static int i802_sta_deauth(void *priv, const u8 *addr, int reason);
+static int i802_sta_disassoc(void *priv, const u8 *addr, int reason);
+
+
 static void add_ifidx(struct i802_driver_data *drv, int ifidx)
 {
        int i;
@@ -1631,21 +1635,21 @@ static int i802_set_country(void *priv, const char *country)
 }
 
 
-static void handle_unknown_sta(struct hostapd_data *hapd, u8 *ta)
+static void handle_unknown_sta(struct i802_driver_data *drv, u8 *ta)
 {
        struct sta_info *sta;
 
-       sta = ap_get_sta(hapd, ta);
+       sta = ap_get_sta(drv->hapd, ta);
        if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
                printf("Data/PS-poll frame from not associated STA "
                       MACSTR "\n", MAC2STR(ta));
                if (sta && (sta->flags & WLAN_STA_AUTH))
-                       hostapd_sta_disassoc(
-                               hapd, ta,
+                       i802_sta_disassoc(
+                               drv, ta,
                                WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
                else
-                       hostapd_sta_deauth(
-                               hapd, ta,
+                       i802_sta_deauth(
+                               drv, ta,
                                WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
        }
 }
@@ -1695,7 +1699,8 @@ static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
 }
 
 
-static void handle_frame(struct hostapd_iface *iface, u8 *buf, size_t len,
+static void handle_frame(struct i802_driver_data *drv,
+                        struct hostapd_iface *iface, u8 *buf, size_t len,
                         struct hostapd_frame_info *hfi,
                         enum ieee80211_msg_type msg_type)
 {
@@ -1801,10 +1806,10 @@ static void handle_frame(struct hostapd_iface *iface, u8 *buf, size_t len,
        case WLAN_FC_TYPE_CTRL:
                /* can only get here with PS-Poll frames */
                wpa_printf(MSG_DEBUG, "CTRL");
-               handle_unknown_sta(hapd, hdr->addr2);
+               handle_unknown_sta(drv, hdr->addr2);
                break;
        case WLAN_FC_TYPE_DATA:
-               handle_unknown_sta(hapd, hdr->addr2);
+               handle_unknown_sta(drv, hdr->addr2);
                break;
        }
 }
@@ -1903,7 +1908,7 @@ static void handle_monitor_read(int sock, void *eloop_ctx, void *sock_ctx)
        else
                msg_type = ieee80211_msg_tx_callback_ack;
 
-       handle_frame(hapd->iface, buf + iter.max_length,
+       handle_frame(drv, hapd->iface, buf + iter.max_length,
                     len - iter.max_length, &hfi, msg_type);
 }
 
index 76bfcd2..4e2189a 100644 (file)
@@ -1052,7 +1052,7 @@ static void * prism54_driver_init(struct hostapd_data *hapd)
        }
        prism54_init_1x(drv);
        /* must clean previous elems */
-       hostapd_set_generic_elem(hapd, NULL, 0);
+       prism54_set_generic_elem(drv->iface, drv, NULL, 0);
 
        return drv;
 }
index afff924..f5fe132 100644 (file)
@@ -30,7 +30,7 @@
 #include "ieee802_11_auth.h"
 #include "ap_list.h"
 #include "sta_info.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "radius/radius_client.h"
 #include "radius/radius_server.h"
 #include "wpa.h"
index 7d41803..23febdf 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "hostapd.h"
 #include "hw_features.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "config.h"
 
 
index 9e6485f..34b823f 100644 (file)
@@ -34,7 +34,7 @@
 #include "wme.h"
 #include "ap_list.h"
 #include "accounting.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "mlme.h"
 
 
index 3ccb3c7..3abbc64 100644 (file)
@@ -27,7 +27,6 @@
 #include "radius/radius.h"
 #include "radius/radius_client.h"
 #include "eloop.h"
-#include "driver.h"
 
 #define RADIUS_ACL_TIMEOUT 30
 
index 3dcf701..b3118df 100644 (file)
@@ -27,7 +27,7 @@
 #include "wpa.h"
 #include "preauth.h"
 #include "pmksa_cache.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "hw_features.h"
 #include "eap_server/eap.h"
 #include "ieee802_11_defs.h"
index bd873f6..0d8f4b1 100644 (file)
@@ -25,7 +25,7 @@
 #include "wpa.h"
 #include "preauth.h"
 #include "radius/radius_client.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "beacon.h"
 #include "hw_features.h"
 #include "mlme.h"
index 87c61e2..2af786f 100644 (file)
@@ -16,7 +16,7 @@
 #include "includes.h"
 
 #include "hostapd.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "vlan_init.h"
 
 
index 727ee7e..f991f86 100644 (file)
@@ -19,7 +19,7 @@
 #include "ieee802_11.h"
 #include "wme.h"
 #include "sta_info.h"
-#include "driver.h"
+#include "driver_i.h"
 
 
 /* TODO: maintain separate sequence and fragment numbers for each AC
index 14966d9..74c2d88 100644 (file)
@@ -15,7 +15,7 @@
 #include "includes.h"
 
 #include "hostapd.h"
-#include "driver.h"
+#include "driver_i.h"
 #include "eloop.h"
 #include "uuid.h"
 #include "wpa_ctrl.h"