aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-11-04 18:16:15 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-04 18:16:15 (GMT)
commitd27df100b587dd95f3256a8baf9db0c5d4380089 (patch)
tree394c5e612ee63af8453ef0214e7becd6bb101ea2 /wpa_supplicant
parent0ae7b0869107d4ae1b28bc417cfe4c5b0fc9e0ed (diff)
downloadhostap-d27df100b587dd95f3256a8baf9db0c5d4380089.zip
hostap-d27df100b587dd95f3256a8baf9db0c5d4380089.tar.gz
hostap-d27df100b587dd95f3256a8baf9db0c5d4380089.tar.bz2
Allow driver and ctrl_interface parameters to be overridden
New wpa_supplicant command line options -o<driver> and -O<ctrl> can now be used to override the parameters received in add interface command from dbus or global ctrl_interface. This can be used, e.g., to enable control interface when using NetworkManager (add -O/var/run/wpa_supplicant into the Exec parameter in /usr/share/dbus-1/system-services/fi.epitest.hostap.WPASupplicant.service). Similarly, this can be used to use another driver wrapper with NetworkManager (e.g., -onl80211 to replace WEXT with nl80211).
Diffstat (limited to 'wpa_supplicant')
-rw-r--r--wpa_supplicant/main.c11
-rw-r--r--wpa_supplicant/wpa_supplicant.c26
-rw-r--r--wpa_supplicant/wpa_supplicant_i.h18
3 files changed, 53 insertions, 2 deletions
diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c
index 7e77e3f..bb3dcd8 100644
--- a/wpa_supplicant/main.c
+++ b/wpa_supplicant/main.c
@@ -34,6 +34,7 @@ static void usage(void)
" -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
"[-p<driver_param>] \\\n"
" [-b<br_ifname>] [-f<debug file>] \\\n"
+ " [-o<override driver>] [-O<override ctrl>] \\\n"
" [-N -i<ifname> -c<conf> [-C<ctrl>] "
"[-D<driver>] \\\n"
" [-p<driver_param>] [-b<br_ifname>] ...]\n"
@@ -67,6 +68,8 @@ static void usage(void)
printf(" -t = include timestamp in debug messages\n"
" -h = show this help text\n"
" -L = show license (GPL and BSD)\n"
+ " -o = override driver parameter for new interfaces\n"
+ " -O = override ctrl_interface parameter for new interfaces\n"
" -p = driver parameters\n"
" -P = PID file\n"
" -q = decrease debugging verbosity (-qq even less)\n");
@@ -140,7 +143,7 @@ int main(int argc, char *argv[])
wpa_supplicant_fd_workaround();
for (;;) {
- c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNp:P:qstuvW");
+ c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNo:O:p:P:qstuvW");
if (c < 0)
break;
switch (c) {
@@ -191,6 +194,12 @@ int main(int argc, char *argv[])
license();
exitcode = 0;
goto out;
+ case 'o':
+ params.override_driver = optarg;
+ break;
+ case 'O':
+ params.override_ctrl_interface = optarg;
+ break;
case 'p':
iface->driver_param = optarg;
break;
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 681a9d9..78fa04b 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -2246,6 +2246,7 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
struct wpa_interface *iface)
{
struct wpa_supplicant *wpa_s;
+ struct wpa_interface t_iface;
if (global == NULL || iface == NULL)
return NULL;
@@ -2254,7 +2255,22 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global,
if (wpa_s == NULL)
return NULL;
- if (wpa_supplicant_init_iface(wpa_s, iface)) {
+ t_iface = *iface;
+ if (global->params.override_driver) {
+ wpa_printf(MSG_DEBUG, "Override interface parameter: driver "
+ "('%s' -> '%s')",
+ iface->driver, global->params.override_driver);
+ t_iface.driver = global->params.override_driver;
+ }
+ if (global->params.override_ctrl_interface) {
+ wpa_printf(MSG_DEBUG, "Override interface parameter: "
+ "ctrl_interface ('%s' -> '%s')",
+ iface->ctrl_interface,
+ global->params.override_ctrl_interface);
+ t_iface.ctrl_interface =
+ global->params.override_ctrl_interface;
+ }
+ if (wpa_supplicant_init_iface(wpa_s, &t_iface)) {
wpa_printf(MSG_DEBUG, "Failed to add interface %s",
iface->ifname);
wpa_supplicant_deinit_iface(wpa_s);
@@ -2388,6 +2404,12 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
if (params->ctrl_interface)
global->params.ctrl_interface =
os_strdup(params->ctrl_interface);
+ if (params->override_driver)
+ global->params.override_driver =
+ os_strdup(params->override_driver);
+ if (params->override_ctrl_interface)
+ global->params.override_ctrl_interface =
+ os_strdup(params->override_ctrl_interface);
wpa_debug_level = global->params.wpa_debug_level =
params->wpa_debug_level;
wpa_debug_show_keys = global->params.wpa_debug_show_keys =
@@ -2514,6 +2536,8 @@ void wpa_supplicant_deinit(struct wpa_global *global)
os_free(global->params.pid_file);
}
os_free(global->params.ctrl_interface);
+ os_free(global->params.override_driver);
+ os_free(global->params.override_ctrl_interface);
os_free(global);
wpa_debug_close_syslog();
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 699fc0d..d426aaa 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -160,6 +160,24 @@ struct wpa_params {
* wpa_debug_syslog - Enable log output through syslog
*/
int wpa_debug_syslog;
+
+ /**
+ * override_driver - Optional driver parameter override
+ *
+ * This parameter can be used to override the driver parameter in
+ * dynamic interface addition to force a specific driver wrapper to be
+ * used instead.
+ */
+ char *override_driver;
+
+ /**
+ * override_ctrl_interface - Optional ctrl_interface override
+ *
+ * This parameter can be used to override the ctrl_interface parameter
+ * in dynamic interface addition to force a control interface to be
+ * created.
+ */
+ char *override_ctrl_interface;
};
/**