X-Git-Url: http://www.project-moonshot.org/gitweb/?p=mech_eap.git;a=blobdiff_plain;f=libeap%2Fwpa_supplicant%2Fmain.c;h=d5d47e1d77b2485ce962177b3c0146429493245f;hp=c0aa59c4ee0a5486a18efcd4e2aba299d2787228;hb=4f319dde67a76fe0aaf33f6d2788968012584ada;hpb=ed09b5e64dd485851310307979d5eed14678087b diff --git a/libeap/wpa_supplicant/main.c b/libeap/wpa_supplicant/main.c index c0aa59c..d5d47e1 100644 --- a/libeap/wpa_supplicant/main.c +++ b/libeap/wpa_supplicant/main.c @@ -1,15 +1,9 @@ /* * WPA Supplicant / main() function for UNIX like OSes and MinGW - * Copyright (c) 2003-2007, Jouni Malinen + * Copyright (c) 2003-2013, Jouni Malinen * - * 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. + * This software may be distributed under the terms of the BSD license. + * See README for more details. */ #include "includes.h" @@ -18,10 +12,10 @@ #endif /* __linux__ */ #include "common.h" +#include "fst/fst.h" #include "wpa_supplicant_i.h" #include "driver_i.h" - -extern struct wpa_driver_ops *wpa_drivers[]; +#include "p2p_supplicant.h" static void usage(void) @@ -29,15 +23,32 @@ static void usage(void) int i; printf("%s\n\n%s\n" "usage:\n" - " wpa_supplicant [-BddhKLqqstuvW] [-P] " + " wpa_supplicant [-BddhKLqq" +#ifdef CONFIG_DEBUG_SYSLOG + "s" +#endif /* CONFIG_DEBUG_SYSLOG */ + "t" +#ifdef CONFIG_DBUS + "u" +#endif /* CONFIG_DBUS */ + "vW] [-P] " "[-g] \\\n" + " [-G] \\\n" " -i -c [-C] [-D] " "[-p] \\\n" - " [-b] [-f] \\\n" + " [-b] [-e]" +#ifdef CONFIG_DEBUG_FILE + " [-f]" +#endif /* CONFIG_DEBUG_FILE */ + " \\\n" " [-o] [-O] \\\n" " [-N -i -c [-C] " "[-D] \\\n" - " [-p] [-b] ...]\n" +#ifdef CONFIG_P2P + " [-m] \\\n" +#endif /* CONFIG_P2P */ + " [-p] [-b] [-I] " + "...]\n" "\n" "drivers:\n", wpa_supplicant_version, wpa_supplicant_license); @@ -55,19 +66,26 @@ static void usage(void) " -c = Configuration file\n" " -C = ctrl_interface parameter (only used if -c is not)\n" " -i = interface name\n" + " -I = additional configuration file\n" " -d = increase debugging verbosity (-dd even more)\n" - " -D = driver name (can be multiple drivers: nl80211,wext)\n"); + " -D = driver name (can be multiple drivers: nl80211,wext)\n" + " -e = entropy file\n"); #ifdef CONFIG_DEBUG_FILE printf(" -f = log output to debug file instead of stdout\n"); #endif /* CONFIG_DEBUG_FILE */ printf(" -g = global ctrl_interface\n" + " -G = global ctrl_interface group\n" " -K = include keys (passwords, etc.) in debug output\n"); #ifdef CONFIG_DEBUG_SYSLOG printf(" -s = log output to syslog instead of stdout\n"); #endif /* CONFIG_DEBUG_SYSLOG */ +#ifdef CONFIG_DEBUG_LINUX_TRACING + printf(" -T = record to Linux tracing in addition to logging\n"); + printf(" (records all messages regardless of debug verbosity)\n"); +#endif /* CONFIG_DEBUG_LINUX_TRACING */ printf(" -t = include timestamp in debug messages\n" " -h = show this help text\n" - " -L = show license (GPL and BSD)\n" + " -L = show license (BSD)\n" " -o = override driver parameter for new interfaces\n" " -O = override ctrl_interface parameter for new interfaces\n" " -p = driver parameters\n" @@ -78,11 +96,14 @@ static void usage(void) #endif /* CONFIG_DBUS */ printf(" -v = show version\n" " -W = wait for a control interface monitor before starting\n" +#ifdef CONFIG_P2P + " -m = Configuration file for the P2P Device interface\n" +#endif /* CONFIG_P2P */ " -N = start describing new interface\n"); printf("example:\n" " wpa_supplicant -D%s -iwlan0 -c/etc/wpa_supplicant.conf\n", - wpa_drivers[i] ? wpa_drivers[i]->name : "wext"); + wpa_drivers[0] ? wpa_drivers[0]->name : "nl80211"); #endif /* CONFIG_NO_STDOUT_DEBUG */ } @@ -101,20 +122,31 @@ static void license(void) } -static void wpa_supplicant_fd_workaround(void) +static void wpa_supplicant_fd_workaround(int start) { #ifdef __linux__ - int s, i; + static int fd[3] = { -1, -1, -1 }; + int i; /* When started from pcmcia-cs scripts, wpa_supplicant might start with * fd 0, 1, and 2 closed. This will cause some issues because many * places in wpa_supplicant are still printing out to stdout. As a * workaround, make sure that fd's 0, 1, and 2 are not used for other * sockets. */ - for (i = 0; i < 3; i++) { - s = open("/dev/null", O_RDWR); - if (s > 2) { - close(s); - break; + if (start) { + for (i = 0; i < 3; i++) { + fd[i] = open("/dev/null", O_RDWR); + if (fd[i] > 2) { + close(fd[i]); + fd[i] = -1; + break; + } + } + } else { + for (i = 0; i < 3; i++) { + if (fd[i] >= 0) { + close(fd[i]); + fd[i] = -1; + } } } #endif /* __linux__ */ @@ -140,10 +172,11 @@ int main(int argc, char *argv[]) return -1; iface_count = 1; - wpa_supplicant_fd_workaround(); + wpa_supplicant_fd_workaround(1); for (;;) { - c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNo:O:p:P:qstuvW"); + c = getopt(argc, argv, + "b:Bc:C:D:de:f:g:G:hi:I:KLm:No:O:p:P:qsTtuvW"); if (c < 0) break; switch (c) { @@ -172,6 +205,9 @@ int main(int argc, char *argv[]) params.wpa_debug_level--; break; #endif /* CONFIG_NO_STDOUT_DEBUG */ + case 'e': + params.entropy_file = optarg; + break; #ifdef CONFIG_DEBUG_FILE case 'f': params.wpa_debug_file_path = optarg; @@ -180,6 +216,9 @@ int main(int argc, char *argv[]) case 'g': params.ctrl_interface = optarg; break; + case 'G': + params.ctrl_interface_group = optarg; + break; case 'h': usage(); exitcode = 0; @@ -187,6 +226,9 @@ int main(int argc, char *argv[]) case 'i': iface->ifname = optarg; break; + case 'I': + iface->confanother = optarg; + break; case 'K': params.wpa_debug_show_keys++; break; @@ -194,6 +236,11 @@ int main(int argc, char *argv[]) license(); exitcode = 0; goto out; +#ifdef CONFIG_P2P + case 'm': + params.conf_p2p_dev = optarg; + break; +#endif /* CONFIG_P2P */ case 'o': params.override_driver = optarg; break; @@ -215,6 +262,11 @@ int main(int argc, char *argv[]) params.wpa_debug_syslog++; break; #endif /* CONFIG_DEBUG_SYSLOG */ +#ifdef CONFIG_DEBUG_LINUX_TRACING + case 'T': + params.wpa_debug_tracing++; + break; +#endif /* CONFIG_DEBUG_LINUX_TRACING */ case 't': params.wpa_debug_timestamp++; break; @@ -232,12 +284,12 @@ int main(int argc, char *argv[]) break; case 'N': iface_count++; - iface = os_realloc(ifaces, iface_count * - sizeof(struct wpa_interface)); + iface = os_realloc_array(ifaces, iface_count, + sizeof(struct wpa_interface)); if (iface == NULL) goto out; ifaces = iface; - iface = &ifaces[iface_count - 1]; + iface = &ifaces[iface_count - 1]; os_memset(iface, 0, sizeof(*iface)); break; default: @@ -253,9 +305,25 @@ int main(int argc, char *argv[]) wpa_printf(MSG_ERROR, "Failed to initialize wpa_supplicant"); exitcode = -1; goto out; + } else { + wpa_printf(MSG_INFO, "Successfully initialized " + "wpa_supplicant"); } + if (fst_global_init()) { + wpa_printf(MSG_ERROR, "Failed to initialize FST"); + exitcode = -1; + goto out; + } + +#if defined(CONFIG_FST) && defined(CONFIG_CTRL_IFACE) + if (!fst_global_add_ctrl(fst_ctrl_cli)) + wpa_printf(MSG_WARNING, "Failed to add CLI FST ctrl"); +#endif + for (i = 0; exitcode == 0 && i < iface_count; i++) { + struct wpa_supplicant *wpa_s; + if ((ifaces[i].confname == NULL && ifaces[i].ctrl_interface == NULL) || ifaces[i].ifname == NULL) { @@ -266,8 +334,11 @@ int main(int argc, char *argv[]) exitcode = -1; break; } - if (wpa_supplicant_add_iface(global, &ifaces[i]) == NULL) + wpa_s = wpa_supplicant_add_iface(global, &ifaces[i], NULL); + if (wpa_s == NULL) { exitcode = -1; + break; + } } if (exitcode == 0) @@ -275,7 +346,10 @@ int main(int argc, char *argv[]) wpa_supplicant_deinit(global); + fst_global_deinit(); + out: + wpa_supplicant_fd_workaround(0); os_free(ifaces); os_free(params.pid_file);