hostapd: Use separate driver operations abstraction
authorJouni Malinen <j@w1.fi>
Thu, 24 Dec 2009 14:15:22 +0000 (16:15 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 24 Dec 2009 14:15:22 +0000 (16:15 +0200)
It would be bettet to avoid including driver_i.h, i.e., direct driver
operation calls from hostapd components. This is an initial step in
that direction for WPS IE updates.

hostapd/Makefile
hostapd/ap_drv_ops.c [new file with mode: 0644]
hostapd/hostapd.c
hostapd/hostapd.h
hostapd/wps_hostapd.c
wpa_supplicant/Makefile

index ad4ad05..9d9acec 100644 (file)
@@ -39,6 +39,7 @@ OBJS =        hostapd.o main.o ieee802_1x.o \
        drv_callbacks.o \
        tkip_countermeasures.o \
        mlme.o wpa_auth_ie.o
+OBJS += ap_drv_ops.o
 NEED_RC4=y
 NEED_AES=y
 NEED_MD5=y
diff --git a/hostapd/ap_drv_ops.c b/hostapd/ap_drv_ops.c
new file mode 100644 (file)
index 0000000..6fba78b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * hostapd - Driver operations
+ * Copyright (c) 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
+ * 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.
+ */
+
+#include "includes.h"
+
+#include "common.h"
+#include "hostapd.h"
+#include "driver_i.h"
+
+
+static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd,
+                                const u8 *beacon_ie, size_t beacon_ie_len,
+                                const u8 *probe_resp_ie,
+                                size_t probe_resp_ie_len)
+{
+       if (hostapd_set_wps_beacon_ie(hapd, hapd->wps_beacon_ie,
+                                     hapd->wps_beacon_ie_len) < 0 ||
+           hostapd_set_wps_probe_resp_ie(hapd, hapd->wps_probe_resp_ie,
+                                         hapd->wps_probe_resp_ie_len) < 0)
+               return -1;
+       return 0;
+}
+
+
+void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
+{
+       ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
+}
index f3d1e4c..57154e0 100644 (file)
@@ -1384,6 +1384,7 @@ hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface,
        if (hapd == NULL)
                return NULL;
 
+       hostapd_set_driver_ops(&hapd->drv);
        hapd->iconf = conf;
        hapd->conf = bss;
        hapd->iface = hapd_iface;
index c9ee3dd..63f45c1 100644 (file)
@@ -22,6 +22,7 @@ struct wpa_ctrl_dst;
 struct radius_server_data;
 struct upnp_wps_device_sm;
 struct hapd_interfaces;
+struct hostapd_data;
 
 #ifdef CONFIG_FULL_DYNAMIC_VLAN
 struct full_dynamic_vlan;
@@ -40,6 +41,13 @@ struct hostapd_rate_data {
 };
 
 
+struct hostapd_driver_ops {
+       int (*set_ap_wps_ie)(struct hostapd_data *hapd,
+                            const u8 *beacon_ie, size_t beacon_ie_len,
+                            const u8 *probe_resp_ie,
+                            size_t probe_resp_ie_len);
+};
+
 /**
  * struct hostapd_data - hostapd per-BSS data structure
  */
@@ -67,6 +75,7 @@ struct hostapd_data {
 
        const struct wpa_driver_ops *driver;
        void *drv_priv;
+       struct hostapd_driver_ops drv;
 
        void *msg_ctx; /* ctx for wpa_msg() calls */
 
@@ -195,5 +204,6 @@ int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
 int hostapd_sta_flags_to_drv(int flags);
 
 int eap_server_register_methods(void);
+void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);
 
 #endif /* HOSTAPD_H */
index 4cb980d..a00b8ef 100644 (file)
@@ -27,7 +27,7 @@
 #include "wps/wps_defs.h"
 #include "wps/wps_dev_attr.h"
 #include "hostapd.h"
-#include "driver_i.h"
+#include "config.h"
 #include "sta_info.h"
 #include "wps_hostapd.h"
 
@@ -109,8 +109,6 @@ static int hostapd_wps_set_ie_cb(void *ctx, const u8 *beacon_ie,
                os_memcpy(hapd->wps_beacon_ie, beacon_ie, beacon_ie_len);
                hapd->wps_beacon_ie_len = beacon_ie_len;
        }
-       hostapd_set_wps_beacon_ie(hapd, hapd->wps_beacon_ie,
-                                 hapd->wps_beacon_ie_len);
 
        os_free(hapd->wps_probe_resp_ie);
        if (probe_resp_ie_len == 0) {
@@ -126,8 +124,10 @@ static int hostapd_wps_set_ie_cb(void *ctx, const u8 *beacon_ie,
                          probe_resp_ie_len);
                hapd->wps_probe_resp_ie_len = probe_resp_ie_len;
        }
-       hostapd_set_wps_probe_resp_ie(hapd, hapd->wps_probe_resp_ie,
-                                     hapd->wps_probe_resp_ie_len);
+       hapd->drv.set_ap_wps_ie(hapd, hapd->wps_beacon_ie,
+                               hapd->wps_beacon_ie_len,
+                               hapd->wps_probe_resp_ie,
+                               hapd->wps_probe_resp_ie_len);
 
        return 0;
 }
@@ -480,12 +480,12 @@ static void hostapd_wps_clear_ies(struct hostapd_data *hapd)
        os_free(hapd->wps_beacon_ie);
        hapd->wps_beacon_ie = NULL;
        hapd->wps_beacon_ie_len = 0;
-       hostapd_set_wps_beacon_ie(hapd, NULL, 0);
 
        os_free(hapd->wps_probe_resp_ie);
        hapd->wps_probe_resp_ie = NULL;
        hapd->wps_probe_resp_ie_len = 0;
-       hostapd_set_wps_probe_resp_ie(hapd, NULL, 0);
+
+       hapd->drv.set_ap_wps_ie(hapd, NULL, 0, NULL, 0);
 }
 
 
index f2c3148..725d51f 100644 (file)
@@ -597,6 +597,7 @@ OBJS += ../hostapd/ieee802_1x.o
 OBJS += ../src/eapol_auth/eapol_auth_sm.o
 OBJS += ../hostapd/ieee802_11_auth.o
 OBJS += ../hostapd/drv_callbacks.o
+OBJS += ../hostapd/ap_drv_ops.o
 ifdef CONFIG_CTRL_IFACE
 OBJS += ../hostapd/ctrl_iface_ap.o
 endif