wpa_supplicant: Fix CONFIG_IBSS_RSN=y build without CONFIG_AP=y
[mech_eap.git] / wpa_supplicant / main.c
index 39b837e..3ab80a5 100644 (file)
 #endif /* __linux__ */
 
 #include "common.h"
+#include "fst/fst.h"
 #include "wpa_supplicant_i.h"
 #include "driver_i.h"
 #include "p2p_supplicant.h"
 
-extern struct wpa_driver_ops *wpa_drivers[];
-
 
 static void usage(void)
 {
        int i;
        printf("%s\n\n%s\n"
               "usage:\n"
-              "  wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
+              "  wpa_supplicant [-BddhKLqq"
+#ifdef CONFIG_DEBUG_SYSLOG
+              "s"
+#endif /* CONFIG_DEBUG_SYSLOG */
+              "t"
+#ifdef CONFIG_DBUS
+              "u"
+#endif /* CONFIG_DBUS */
+              "vW] [-P<pid file>] "
               "[-g<global ctrl>] \\\n"
               "        [-G<group>] \\\n"
               "        -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
               "[-p<driver_param>] \\\n"
-              "        [-b<br_ifname>] [-f<debug file>] [-e<entropy file>] "
-              "\\\n"
+              "        [-b<br_ifname>] [-e<entropy file>]"
+#ifdef CONFIG_DEBUG_FILE
+              " [-f<debug file>]"
+#endif /* CONFIG_DEBUG_FILE */
+              " \\\n"
               "        [-o<override driver>] [-O<override ctrl>] \\\n"
               "        [-N -i<ifname> -c<conf> [-C<ctrl>] "
               "[-D<driver>] \\\n"
+#ifdef CONFIG_P2P
+              "        [-m<P2P Device config file>] \\\n"
+#endif /* CONFIG_P2P */
               "        [-p<driver_param>] [-b<br_ifname>] [-I<config file>] "
               "...]\n"
               "\n"
@@ -52,38 +65,41 @@ static void usage(void)
               "  -B = run daemon in the background\n"
               "  -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"
-              "  -e = entropy file\n");
+              "  -e = entropy file\n"
 #ifdef CONFIG_DEBUG_FILE
-       printf("  -f = log output to debug file instead of stdout\n");
+              "  -f = log output to debug file instead of stdout\n"
 #endif /* CONFIG_DEBUG_FILE */
-       printf("  -g = global ctrl_interface\n"
+              "  -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"
+              "  -i = interface name\n"
+              "  -I = additional configuration file\n"
+              "  -K = include keys (passwords, etc.) in debug output\n"
               "  -L = show license (BSD)\n"
+#ifdef CONFIG_P2P
+              "  -m = Configuration file for the P2P Device interface\n"
+#endif /* CONFIG_P2P */
+              "  -N = start describing new interface\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");
+              "  -q = decrease debugging verbosity (-qq even less)\n"
+#ifdef CONFIG_DEBUG_SYSLOG
+              "  -s = log output to syslog instead of stdout\n"
+#endif /* CONFIG_DEBUG_SYSLOG */
+              "  -t = include timestamp in debug messages\n"
+#ifdef CONFIG_DEBUG_LINUX_TRACING
+              "  -T = record to Linux tracing in addition to logging\n"
+              "       (records all messages regardless of debug verbosity)\n"
+#endif /* CONFIG_DEBUG_LINUX_TRACING */
 #ifdef CONFIG_DBUS
-       printf("  -u = enable DBus control interface\n");
+              "  -u = enable DBus control interface\n"
 #endif /* CONFIG_DBUS */
-       printf("  -v = show version\n"
-              "  -W = wait for a control interface monitor before starting\n"
-              "  -N = start describing new interface\n");
+              "  -v = show version\n"
+              "  -W = wait for a control interface monitor before starting\n");
 
        printf("example:\n"
               "  wpa_supplicant -D%s -iwlan0 -c/etc/wpa_supplicant.conf\n",
@@ -160,7 +176,7 @@ int main(int argc, char *argv[])
 
        for (;;) {
                c = getopt(argc, argv,
-                          "b:Bc:C:D:de:f:g:G:hi:I:KLNo:O:p:P:qsTtuvW");
+                          "b:Bc:C:D:de:f:g:G:hi:I:KLm:No:O:p:P:qsTtuvW");
                if (c < 0)
                        break;
                switch (c) {
@@ -220,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;
@@ -268,7 +289,7 @@ int main(int argc, char *argv[])
                        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:
@@ -289,6 +310,17 @@ int main(int argc, char *argv[])
                           "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;
 
@@ -302,18 +334,11 @@ int main(int argc, char *argv[])
                        exitcode = -1;
                        break;
                }
-               wpa_s = wpa_supplicant_add_iface(global, &ifaces[i]);
+               wpa_s = wpa_supplicant_add_iface(global, &ifaces[i], NULL);
                if (wpa_s == NULL) {
                        exitcode = -1;
                        break;
                }
-#ifdef CONFIG_P2P
-               if (wpa_s->global->p2p == NULL &&
-                   (wpa_s->drv_flags &
-                    WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) &&
-                   wpas_p2p_add_p2pdev_interface(wpa_s) < 0)
-                       exitcode = -1;
-#endif /* CONFIG_P2P */
        }
 
        if (exitcode == 0)
@@ -321,6 +346,8 @@ int main(int argc, char *argv[])
 
        wpa_supplicant_deinit(global);
 
+       fst_global_deinit();
+
 out:
        wpa_supplicant_fd_workaround(0);
        os_free(ifaces);