Add option for selecting WiFi/Supplicant driver from command line
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 20 May 2009 22:17:40 +0000 (15:17 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 20 May 2009 22:17:40 +0000 (15:17 -0700)
include/Makefile.am
include/option.h [new file with mode: 0644]
plugins/supplicant.c
src/connman.h
src/main.c

index dce9b36..86845ac 100644 (file)
@@ -7,7 +7,7 @@ include_HEADERS = types.h log.h plugin.h security.h notifier.h \
 nodist_include_HEADERS = version.h
 
 noinst_HEADERS = driver.h element.h property.h ipv4.h rtnl.h dbus.h \
-                                       resolver.h ipconfig.h service.h
+                               resolver.h ipconfig.h service.h option.h
 
 MAINTAINERCLEANFILES = Makefile.in
 
diff --git a/include/option.h b/include/option.h
new file mode 100644 (file)
index 0000000..b80c8c9
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *
+ *  Connection Manager
+ *
+ *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
+ *
+ *  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.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __CONNMAN_OPTION_H
+#define __CONNMAN_OPTION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const char *connman_option_get_string(const char *key);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CONNMAN_OPTION_H */
index 43d667a..70af60a 100644 (file)
@@ -33,6 +33,7 @@
 
 #define CONNMAN_API_SUBJECT_TO_CHANGE
 #include <connman/device.h>
+#include <connman/option.h>
 #include <connman/dbus.h>
 #include <connman/log.h>
 
@@ -260,7 +261,7 @@ done:
 
 static int add_interface(struct supplicant_task *task)
 {
-       const char *driver = "wext";
+       const char *driver = connman_option_get_string("wifi");
        DBusMessage *message;
        DBusMessageIter array, dict;
        DBusPendingCall *call;
index 5f1b1bd..b2522a1 100644 (file)
@@ -72,6 +72,8 @@ void __connman_log_cleanup(void);
 void __connman_toggle_debug(void);
 gboolean __connman_debug_enabled(void);
 
+#include <connman/option.h>
+
 #include <connman/plugin.h>
 
 int __connman_plugin_init(const char *pattern, const char *exclude);
index 56537e1..df0309a 100644 (file)
@@ -59,6 +59,7 @@ static gchar *option_device = NULL;
 static gchar *option_plugin = NULL;
 static gchar *option_nodevice = NULL;
 static gchar *option_noplugin = NULL;
+static gchar *option_wifi = NULL;
 static gboolean option_detach = TRUE;
 static gboolean option_compat = FALSE;
 static gboolean option_debug = FALSE;
@@ -74,6 +75,8 @@ static GOptionEntry options[] = {
                                "Specify plugins to load", "NAME" },
        { "noplugin", 'P', 0, G_OPTION_ARG_STRING, &option_noplugin,
                                "Specify plugins not to load", "NAME" },
+       { "wifi", 'W', 0, G_OPTION_ARG_STRING, &option_wifi,
+                               "Specify driver for WiFi/Supplicant", "NAME" },
        { "nodaemon", 'n', G_OPTION_FLAG_REVERSE,
                                G_OPTION_ARG_NONE, &option_detach,
                                "Don't fork daemon to background" },
@@ -88,6 +91,18 @@ static GOptionEntry options[] = {
        { NULL },
 };
 
+const char *connman_option_get_string(const char *key)
+{
+       if (g_strcmp0(key, "wifi") == 0) {
+               if (option_wifi == NULL)
+                       return "nl80211,wext";
+               else
+                       return option_wifi;
+       }
+
+       return NULL;
+}
+
 int main(int argc, char *argv[])
 {
        GOptionContext *context;