Add 'none' driver as an option for wpa_supplicant
authorJouni Malinen <j@w1.fi>
Fri, 20 Nov 2009 19:12:49 +0000 (21:12 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 20 Nov 2009 19:12:49 +0000 (21:12 +0200)
This can be used, e.g., with WPS ER when no network interface is
actually used for IEEE 802.1X or wireless operations.

src/drivers/driver_none.c
src/drivers/drivers.mak
wpa_supplicant/defconfig

index 31b1076..a5d66c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * hostapd / Driver interface for RADIUS server only (no driver)
+ * Driver interface for RADIUS server or WPS ER only (no driver)
  * Copyright (c) 2008, Atheros Communications
  *
  * This program is free software; you can redistribute it and/or modify
 
 struct none_driver_data {
        struct hostapd_data *hapd;
+       void *ctx;
 };
 
 
-static void * none_driver_init(struct hostapd_data *hapd,
-                              struct wpa_init_params *params)
+static void * none_driver_hapd_init(struct hostapd_data *hapd,
+                                   struct wpa_init_params *params)
 {
        struct none_driver_data *drv;
 
@@ -40,7 +41,7 @@ static void * none_driver_init(struct hostapd_data *hapd,
 }
 
 
-static void none_driver_deinit(void *priv)
+static void none_driver_hapd_deinit(void *priv)
 {
        struct none_driver_data *drv = priv;
 
@@ -55,9 +56,44 @@ static int none_driver_send_ether(void *priv, const u8 *dst, const u8 *src,
 }
 
 
+static void * none_driver_init(void *ctx, const char *ifname)
+{
+       struct none_driver_data *drv;
+
+       drv = os_zalloc(sizeof(struct none_driver_data));
+       if (drv == NULL) {
+               wpa_printf(MSG_ERROR, "Could not allocate memory for none "
+                          "driver data");
+               return NULL;
+       }
+       drv->ctx = ctx;
+
+       return drv;
+}
+
+
+static void none_driver_deinit(void *priv)
+{
+       struct none_driver_data *drv = priv;
+
+       os_free(drv);
+}
+
+
+static int none_driver_send_eapol(void *priv, const u8 *dest, u16 proto,
+                                 const u8 *data, size_t data_len)
+{
+       return -1;
+}
+
+
 const struct wpa_driver_ops wpa_driver_none_ops = {
        .name = "none",
-       .hapd_init = none_driver_init,
-       .hapd_deinit = none_driver_deinit,
+       .desc = "no driver (RADIUS server/WPS ER)",
+       .hapd_init = none_driver_hapd_init,
+       .hapd_deinit = none_driver_hapd_deinit,
        .send_ether = none_driver_send_ether,
+       .init = none_driver_init,
+       .deinit = none_driver_deinit,
+       .send_eapol = none_driver_send_eapol,
 };
index 4d32b2a..7f24ff0 100644 (file)
@@ -60,6 +60,11 @@ DRV_OBJS += ../src/drivers/driver_test.o
 NEED_AP_MLME=y
 endif
 
+ifdef CONFIG_DRIVER_NONE
+DRV_CFLAGS += -DCONFIG_DRIVER_NONE
+DRV_OBJS += ../src/drivers/driver_none.o
+endif
+
 ##### PURE AP DRIVERS
 
 ifdef CONFIG_DRIVER_ATHEROS
@@ -68,11 +73,6 @@ DRV_AP_OBJS += ../src/drivers/driver_atheros.o
 CONFIG_L2_PACKET=linux
 endif
 
-ifdef CONFIG_DRIVER_NONE
-DRV_AP_CFLAGS += -DCONFIG_DRIVER_NONE
-DRV_AP_OBJS += ../src/drivers/driver_none.o
-endif
-
 ##### PURE CLIENT DRIVERS
 
 ifdef CONFIG_DRIVER_WEXT
index 453ffe8..8cb4300 100644 (file)
@@ -120,6 +120,9 @@ CONFIG_DRIVER_WIRED=y
 # Driver interface for the Broadcom RoboSwitch family
 #CONFIG_DRIVER_ROBOSWITCH=y
 
+# Driver interface for no driver (e.g., WPS ER only)
+#CONFIG_DRIVER_NONE=y
+
 # Enable IEEE 802.1X Supplicant (automatically included if any EAP method is
 # included)
 CONFIG_IEEE8021X_EAPOL=y