Patch: Initialisation Process

Gunter Burchardt gbur at informatik.uni-rostock.de
Tue Aug 24 05:10:09 EDT 2004


Hello,

Next Patch to enable hostap to work with other "drivers". This Patch is
for the initialisation process. I added a configuration parameter in
hostapd.conf to configure which driver should be used. Hostap is standard 
driver. Empty functions for (de)initialisation of driver wired were added.

Secondly the patch removes some headers (driver.h) from files which are
driver independent now.

regards
gunter 
-------------- next part --------------
diff -Nur hostap.old/hostapd/accounting.c hostap/hostapd/accounting.c
--- hostap.old/hostapd/accounting.c	2004-07-26 05:58:29.000000000 +0200
+++ hostap/hostapd/accounting.c	2004-08-24 10:43:35.000000000 +0200
@@ -27,7 +27,6 @@
 #include "radius_client.h"
 #include "eloop.h"
 #include "accounting.h"
-#include "driver.h"
 #include "ieee802_1x.h"
 
 
diff -Nur hostap.old/hostapd/config.c hostap/hostapd/config.c
--- hostap.old/hostapd/config.c	2004-08-13 11:33:09.000000000 +0200
+++ hostap/hostapd/config.c	2004-08-24 10:48:05.000000000 +0200
@@ -34,6 +34,7 @@
 	}
 	memset(conf, 0, sizeof(*conf));
 
+	conf->driver = HOSTAPD_DRIVER_HOSTAP;
 	conf->ssid_len = 4;
 	memcpy(conf->ssid, "test", 4);
 	conf->wep_rekeying_period = 300;
@@ -319,6 +320,13 @@
 
 		if (strcmp(buf, "interface") == 0) {
 			snprintf(conf->iface, sizeof(conf->iface), "%s", pos);
+		} else if (strcmp(buf, "driver") == 0) {
+			if (strcmp(pos, "hostap") == 0) {
+				conf->driver = HOSTAPD_DRIVER_HOSTAP;
+			} else if (strcmp(pos, "wired") == 0) {
+				conf->driver = HOSTAPD_DRIVER_WIRED;
+			} else 
+				errors++;
 		} else if (strcmp(buf, "debug") == 0) {
 			conf->debug = atoi(pos);
 		} else if (strcmp(buf, "logger_syslog_level") == 0) {
diff -Nur hostap.old/hostapd/config.h hostap/hostapd/config.h
--- hostap.old/hostapd/config.h	2004-07-30 06:05:31.000000000 +0200
+++ hostap/hostapd/config.h	2004-08-24 10:43:35.000000000 +0200
@@ -34,6 +34,11 @@
 	char iface[IFNAMSIZ + 1];
 
 	enum {
+		HOSTAPD_DRIVER_HOSTAP = 0,
+		HOSTAPD_DRIVER_WIRED = 1
+	} driver;
+	
+	enum {
 		HOSTAPD_LEVEL_DEBUG_VERBOSE = 0,
 		HOSTAPD_LEVEL_DEBUG = 1,
 		HOSTAPD_LEVEL_INFO = 2,
diff -Nur hostap.old/hostapd/hostapd.c hostap/hostapd/hostapd.c
--- hostap.old/hostapd/hostapd.c	2004-08-23 05:55:53.000000000 +0200
+++ hostap/hostapd/hostapd.c	2004-08-24 11:05:54.000000000 +0200
@@ -341,7 +341,7 @@
 }
 
 
-static void hostapd_cleanup(hostapd *hapd)
+static void hostapd_cleanup_driver_hostap(hostapd *hapd)
 {
 	free(hapd->default_wep_key);
 	if (hapd->conf->ieee802_11f)
@@ -363,6 +363,26 @@
 }
 
 
+static void hostapd_cleanup_driver_wired(hostapd *hapd)
+{
+}
+
+
+static void hostapd_cleanup(hostapd *hapd)
+{
+	switch (hapd->conf->driver) {
+	case HOSTAPD_DRIVER_HOSTAP:
+		hostapd_cleanup_driver_hostap(hapd);
+		break;
+	case HOSTAPD_DRIVER_WIRED:
+		hostapd_cleanup_driver_wired(hapd);
+		break;
+	default:
+		return;
+	}
+}
+
+
 static int hostapd_flush_old_stations(hostapd *hapd)
 {
 	int ret = 0;
@@ -411,9 +431,9 @@
 }
 
 
-static int hostapd_setup_interface(hostapd *hapd)
+static int hostapd_init_driver_hostap(hostapd *hapd)
 {
-    if (hostapd_driver_init(hapd)) {
+	if (hostapd_driver_init(hapd)) {
 		printf("Host AP driver initialization failed.\n");
 		return -1;
 	}
@@ -472,6 +492,34 @@
 }
 
 
+static int hostapd_init_driver_wired(hostapd *hapd)
+{
+	printf("Wired driver not suported yet.\n");
+	return -1;
+}
+
+
+static int hostapd_setup_interface(hostapd *hapd)
+{
+	int ret = 0;
+	
+	switch (hapd->conf->driver) {
+	case HOSTAPD_DRIVER_HOSTAP:
+		ret = hostapd_init_driver_hostap(hapd);
+		break;
+	case HOSTAPD_DRIVER_WIRED:
+		ret = hostapd_init_driver_wired(hapd);
+		break;
+	default:
+		printf("Unknown driver.\n");
+		return -1;
+		break;
+	}
+
+	return ret;
+}
+
+
 static void usage(void)
 {
 	fprintf(stderr,
diff -Nur hostap.old/hostapd/iapp.c hostap/hostapd/iapp.c
--- hostap.old/hostapd/iapp.c	2004-08-23 07:21:37.000000000 +0200
+++ hostap/hostapd/iapp.c	2004-08-24 10:43:35.000000000 +0200
@@ -39,7 +39,6 @@
 #include "iapp.h"
 #include "eloop.h"
 #include "sta_info.h"
-#include "driver.h"
 
 
 static void iapp_send_add(hostapd *hapd, struct sta_info *sta)
diff -Nur hostap.old/hostapd/ieee802_11.c hostap/hostapd/ieee802_11.c
--- hostap.old/hostapd/ieee802_11.c	2004-08-03 09:35:24.000000000 +0200
+++ hostap/hostapd/ieee802_11.c	2004-08-24 10:43:35.000000000 +0200
@@ -23,7 +23,6 @@
 #include "radius_client.h"
 #include "ieee802_11_auth.h"
 #include "sta_info.h"
-#include "driver.h"
 #include "eapol_sm.h"
 #include "rc4.h"
 #include "ieee802_1x.h"
diff -Nur hostap.old/hostapd/ieee802_1x.c hostap/hostapd/ieee802_1x.c
--- hostap.old/hostapd/ieee802_1x.c	2004-08-23 05:53:26.000000000 +0200
+++ hostap/hostapd/ieee802_1x.c	2004-08-24 10:43:35.000000000 +0200
@@ -32,7 +32,6 @@
 #include "rc4.h"
 #include "eloop.h"
 #include "sta_info.h"
-#include "driver.h"
 #include "wpa.h"
 
 
diff -Nur hostap.old/hostapd/sta_info.c hostap/hostapd/sta_info.c
--- hostap.old/hostapd/sta_info.c	2004-08-01 20:06:56.000000000 +0200
+++ hostap/hostapd/sta_info.c	2004-08-24 10:43:35.000000000 +0200
@@ -23,7 +23,6 @@
 #include "ieee802_1x.h"
 #include "ieee802_11.h"
 #include "radius.h"
-#include "driver.h"
 #include "eapol_sm.h"
 #include "wpa.h"
 #include "radius_client.h"


More information about the HostAP mailing list