Move more driver ops into struct hostapd_driver_ops
[libeap.git] / hostapd / ap_drv_ops.c
index c560f1e..d663115 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "common.h"
 #include "hostapd.h"
+#include "sta_info.h"
 #include "driver_i.h"
 
 
@@ -39,8 +40,51 @@ static int hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg,
 }
 
 
+static 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->hapd_send_eapol == NULL)
+               return 0;
+       return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
+                                            data_len, encrypt,
+                                            hapd->own_addr);
+}
+
+
+static int hostapd_set_authorized(struct hostapd_data *hapd,
+                                 struct sta_info *sta, int authorized)
+{
+       if (authorized) {
+               return hostapd_sta_set_flags(hapd, sta->addr,
+                                            hostapd_sta_flags_to_drv(
+                                                    sta->flags),
+                                            WPA_STA_AUTHORIZED, ~0);
+       }
+
+       return hostapd_sta_set_flags(hapd, sta->addr,
+                                    hostapd_sta_flags_to_drv(sta->flags),
+                                    0, ~WPA_STA_AUTHORIZED);
+}
+
+
+static int hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
+                          wpa_alg alg, const u8 *addr, int key_idx,
+                          int set_tx, const u8 *seq, size_t seq_len,
+                          const u8 *key, size_t key_len)
+{
+       if (hapd->driver == NULL || hapd->driver->set_key == NULL)
+               return 0;
+       return hapd->driver->set_key(ifname, hapd->drv_priv, alg, addr,
+                                    key_idx, set_tx, seq, seq_len, key,
+                                    key_len);
+}
+
+
 void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
 {
        ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
        ops->send_mgmt_frame = hostapd_send_mgmt_frame;
+       ops->send_eapol = hostapd_send_eapol;
+       ops->set_authorized = hostapd_set_authorized;
+       ops->set_key = hostapd_set_key;
 }