2 * hostapd - Driver operations
3 * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
23 static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd,
24 const struct wpabuf *beacon,
25 const struct wpabuf *proberesp)
27 if (hapd->driver == NULL || hapd->driver->set_ap_wps_ie == NULL)
29 return hapd->driver->set_ap_wps_ie(hapd->conf->iface, hapd->drv_priv,
34 static int hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg,
37 if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
39 return hapd->driver->send_mlme(hapd->drv_priv, msg, len);
43 static int hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr,
44 const u8 *data, size_t data_len, int encrypt)
46 if (hapd->driver == NULL || hapd->driver->hapd_send_eapol == NULL)
48 return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
54 static int hostapd_set_authorized(struct hostapd_data *hapd,
55 struct sta_info *sta, int authorized)
58 return hostapd_sta_set_flags(hapd, sta->addr,
59 hostapd_sta_flags_to_drv(
61 WPA_STA_AUTHORIZED, ~0);
64 return hostapd_sta_set_flags(hapd, sta->addr,
65 hostapd_sta_flags_to_drv(sta->flags),
66 0, ~WPA_STA_AUTHORIZED);
70 static int hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
71 wpa_alg alg, const u8 *addr, int key_idx,
72 int set_tx, const u8 *seq, size_t seq_len,
73 const u8 *key, size_t key_len)
75 if (hapd->driver == NULL || hapd->driver->set_key == NULL)
77 return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
78 key_idx, set_tx, seq, seq_len, key,
83 static int hostapd_read_sta_data(struct hostapd_data *hapd,
84 struct hostap_sta_driver_data *data,
87 if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
89 return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
93 static int hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
95 if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
97 return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
101 void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
103 ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
104 ops->send_mgmt_frame = hostapd_send_mgmt_frame;
105 ops->send_eapol = hostapd_send_eapol;
106 ops->set_authorized = hostapd_set_authorized;
107 ops->set_key = hostapd_set_key;
108 ops->read_sta_data = hostapd_read_sta_data;
109 ops->sta_clear_stats = hostapd_sta_clear_stats;