Пример #1
0
int main(int argc, char *argv[])
{
	struct wpa_interface iface;
	int exitcode = 0;
	struct wpa_params params;
	struct wpa_global *global;

	memset(&params, 0, sizeof(params));
	params.wpa_debug_level = MSG_INFO;

	global = wpa_supplicant_init(&params);
	if (global == NULL)
		return -1;

	memset(&iface, 0, sizeof(iface));
	/* TODO: set interface parameters */

	if (wpa_supplicant_add_iface(global, &iface) == NULL)
		exitcode = -1;

	if (exitcode == 0)
		exitcode = wpa_supplicant_run(global);

	wpa_supplicant_deinit(global);

	return exitcode;
}
Пример #2
0
int32
WPASupplicantApp::_SupplicantThread(void *data)
{
	WPASupplicantApp *app = (WPASupplicantApp *)data;

	// Register our notify socket with the polling event loop.
	if (eloop_register_read_sock(app->fNotifySockets[0],
			_EventLoopProcessEvents, app->fWPAGlobal, app) != 0) {
		return B_ERROR;
	}

	wpa_supplicant_run(app->fWPAGlobal);

	eloop_unregister_read_sock(app->fNotifySockets[0]);

	// There are two reasons why the supplicant thread quit:
	// 1.	The event loop was terminated because of a signal or error and the
	//		application is still there and running.
	// 2.	The app has quit and stopped the event loop.
	//
	// In case of 2. we're done, but in case of 1. we need to quit the still
	// running application. We use the app messenger to reach the app if it is
	// still running. If it already quit the SendMessage() will simply fail.

	be_app_messenger.SendMessage(B_QUIT_REQUESTED);
	return B_OK;
}
Пример #3
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   CMDLINE lpCmdLine, int nShowCmd)
{
    int i;
    struct wpa_interface *ifaces, *iface;
    int iface_count, exitcode = -1;
    struct wpa_params params;
    struct wpa_global *global;

    if (os_program_init())
        return -1;

    os_memset(&params, 0, sizeof(params));
    params.wpa_debug_level = MSG_MSGDUMP;
    params.wpa_debug_use_file = 1;
    params.wpa_debug_show_keys = 1;

    iface = ifaces = os_zalloc(sizeof(struct wpa_interface));
    if (ifaces == NULL)
        return -1;
    iface_count = 1;

    iface->confname = "default";
    iface->driver = "ndis";
    iface->ifname = "";

    exitcode = 0;
    global = wpa_supplicant_init(&params);
    if (global == NULL) {
        printf("Failed to initialize wpa_supplicant\n");
        exitcode = -1;
    }

    for (i = 0; exitcode == 0 && i < iface_count; i++) {
        if ((ifaces[i].confname == NULL &&
                ifaces[i].ctrl_interface == NULL) ||
                ifaces[i].ifname == NULL) {
            if (iface_count == 1 && (params.ctrl_interface ||
                                     params.dbus_ctrl_interface))
                break;
            exitcode = -1;
            break;
        }
        if (wpa_supplicant_add_iface(global, &ifaces[i]) == NULL)
            exitcode = -1;
    }

    if (exitcode == 0)
        exitcode = wpa_supplicant_run(global);

    wpa_supplicant_deinit(global);

    os_free(ifaces);

    os_program_deinit();

    return exitcode;
}
Пример #4
0
int main(int argc, char *argv[])
{
	int c, i;
	struct wpa_interface *ifaces, *iface;
	int iface_count, exitcode = -1;
	struct wpa_params params;
	struct wpa_global *global;

	if (os_program_init())
		return -1;

	os_memset(&params, 0, sizeof(params));
	params.wpa_debug_level = MSG_INFO;

	iface = ifaces = os_zalloc(sizeof(struct wpa_interface));
	if (ifaces == NULL)
		return -1;
	iface_count = 1;

	wpa_supplicant_fd_workaround();

	for (;;) {
		c = getopt(argc, argv, "b:Bc:C:D:dg:hi:KLNp:P:qtuvwW");
		if (c < 0)
			break;
		switch (c) {
		case 'b':
			iface->bridge_ifname = optarg;
			break;
		case 'B':
			params.daemonize++;
			break;
		case 'c':
			iface->confname = optarg;
			break;
		case 'C':
			iface->ctrl_interface = optarg;
			break;
		case 'D':
			iface->driver = optarg;
			break;
		case 'd':
#ifdef CONFIG_NO_STDOUT_DEBUG
			printf("Debugging disabled with "
			       "CONFIG_NO_STDOUT_DEBUG=y build time "
			       "option.\n");
			goto out;
#else /* CONFIG_NO_STDOUT_DEBUG */
			params.wpa_debug_level--;
			break;
#endif /* CONFIG_NO_STDOUT_DEBUG */
		case 'g':
			params.ctrl_interface = optarg;
			break;
		case 'h':
			usage();
			goto out;
		case 'i':
			iface->ifname = optarg;
			break;
		case 'K':
			params.wpa_debug_show_keys++;
			break;
		case 'L':
			license();
			goto out;
		case 'p':
			iface->driver_param = optarg;
			break;
		case 'P':
			os_free(params.pid_file);
			params.pid_file = os_rel2abs_path(optarg);
			break;
		case 'q':
			params.wpa_debug_level++;
			break;
		case 't':
			params.wpa_debug_timestamp++;
			break;
#ifdef CONFIG_CTRL_IFACE_DBUS
		case 'u':
			params.dbus_ctrl_interface = 1;
			break;
#endif /* CONFIG_CTRL_IFACE_DBUS */
		case 'v':
			printf("%s\n", wpa_supplicant_version);
			goto out;
		case 'w':
			params.wait_for_interface++;
			break;
		case 'W':
			params.wait_for_monitor++;
			break;
		case 'N':
			iface_count++;
			iface = os_realloc(ifaces, iface_count *
					   sizeof(struct wpa_interface));
			if (iface == NULL)
				goto out;
			ifaces = iface;
			iface = &ifaces[iface_count - 1]; 
			os_memset(iface, 0, sizeof(*iface));
			break;
		default:
			usage();
			goto out;
		}
	}

	exitcode = 0;
	global = wpa_supplicant_init(&params);
	if (global == NULL) {
		printf("Failed to initialize wpa_supplicant\n");
		exitcode = -1;
		goto out;
	}

	for (i = 0; exitcode == 0 && i < iface_count; i++) {
		if ((ifaces[i].confname == NULL &&
		     ifaces[i].ctrl_interface == NULL) ||
		    ifaces[i].ifname == NULL) {
			if (iface_count == 1 && (params.ctrl_interface ||
						 params.dbus_ctrl_interface))
				break;
			usage();
			exitcode = -1;
			break;
		}
		if (wpa_supplicant_add_iface(global, &ifaces[i]) == NULL)
			exitcode = -1;
	}

	if (exitcode == 0)
		exitcode = wpa_supplicant_run(global);

	wpa_supplicant_deinit(global);

out:
	os_free(ifaces);
	os_free(params.pid_file);

	os_program_deinit();

	return exitcode;
}
Пример #5
0
int main(int argc, char *argv[])
{
	int c, i;
	struct wpa_interface *ifaces, *iface;
	int iface_count, exitcode = -1;
	struct wpa_params params;
	struct wpa_global *global;

	if (os_program_init())
		return -1;

	os_memset(&params, 0, sizeof(params));
	params.wpa_debug_level = MSG_INFO;

	iface = ifaces = os_zalloc(sizeof(struct wpa_interface));
	if (ifaces == NULL)
		return -1;
	iface_count = 1;

	wpa_supplicant_fd_workaround(1);

	for (;;) {
		c = getopt(argc, argv,
			   "b:Bc:C:D:de:f:g:G:hi:I:KLMm:No:O:p:P:qsTtuvW");
		if (c < 0)
			break;
		switch (c) {
		case 'b':
			iface->bridge_ifname = optarg;
			break;
		case 'B':
			params.daemonize++;
			break;
		case 'c':
			iface->confname = optarg;
			break;
		case 'C':
			iface->ctrl_interface = optarg;
			break;
		case 'D':
			iface->driver = optarg;
			break;
		case 'd':
#ifdef CONFIG_NO_STDOUT_DEBUG
			printf("Debugging disabled with "
			       "CONFIG_NO_STDOUT_DEBUG=y build time "
			       "option.\n");
			goto out;
#else /* CONFIG_NO_STDOUT_DEBUG */
			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;
			break;
#endif /* CONFIG_DEBUG_FILE */
		case 'g':
			params.ctrl_interface = optarg;
			break;
		case 'G':
			params.ctrl_interface_group = optarg;
			break;
		case 'h':
			usage();
			exitcode = 0;
			goto out;
		case 'i':
			iface->ifname = optarg;
			break;
		case 'I':
			iface->confanother = optarg;
			break;
		case 'K':
			params.wpa_debug_show_keys++;
			break;
		case 'L':
			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;
		case 'O':
			params.override_ctrl_interface = optarg;
			break;
		case 'p':
			iface->driver_param = optarg;
			break;
		case 'P':
			os_free(params.pid_file);
			params.pid_file = os_rel2abs_path(optarg);
			break;
		case 'q':
			params.wpa_debug_level++;
			break;
#ifdef CONFIG_DEBUG_SYSLOG
		case 's':
			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;
#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
		case 'u':
			params.dbus_ctrl_interface = 1;
			break;
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
		case 'v':
			printf("%s\n", wpa_supplicant_version);
			exitcode = 0;
			goto out;
		case 'W':
			params.wait_for_monitor++;
			break;
#ifdef CONFIG_MATCH_IFACE
		case 'M':
			params.match_iface_count++;
			iface = os_realloc_array(params.match_ifaces,
						 params.match_iface_count,
						 sizeof(struct wpa_interface));
			if (!iface)
				goto out;
			params.match_ifaces = iface;
			iface = &params.match_ifaces[params.match_iface_count -
						     1];
			os_memset(iface, 0, sizeof(*iface));
			break;
#endif /* CONFIG_MATCH_IFACE */
		case 'N':
			iface_count++;
			iface = os_realloc_array(ifaces, iface_count,
						 sizeof(struct wpa_interface));
			if (iface == NULL)
				goto out;
			ifaces = iface;
			iface = &ifaces[iface_count - 1];
			os_memset(iface, 0, sizeof(*iface));
			break;
		default:
			usage();
			exitcode = 0;
			goto out;
		}
	}

	exitcode = 0;
	global = wpa_supplicant_init(&params);
	if (global == NULL) {
		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) {
			if (iface_count == 1 && (params.ctrl_interface ||
#ifdef CONFIG_MATCH_IFACE
						 params.match_iface_count ||
#endif /* CONFIG_MATCH_IFACE */
						 params.dbus_ctrl_interface))
				break;
			usage();
			exitcode = -1;
			break;
		}
		wpa_s = wpa_supplicant_add_iface(global, &ifaces[i], NULL);
		if (wpa_s == NULL) {
			exitcode = -1;
			break;
		}
	}

#ifdef CONFIG_MATCH_IFACE
	if (exitcode == 0)
		exitcode = wpa_supplicant_init_match(global);
#endif /* CONFIG_MATCH_IFACE */

	if (exitcode == 0)
		exitcode = wpa_supplicant_run(global);

	wpa_supplicant_deinit(global);

	fst_global_deinit();

out:
	wpa_supplicant_fd_workaround(0);
	os_free(ifaces);
#ifdef CONFIG_MATCH_IFACE
	os_free(params.match_ifaces);
#endif /* CONFIG_MATCH_IFACE */
	os_free(params.pid_file);

	os_program_deinit();

	return exitcode;
}
static int wpa_supplicant_thread(void)
{
        int exitcode;
        struct wpa_params params;
        struct wpa_global *global;
        HKEY hk, ihk;
        DWORD val, buflen, i;
        LONG ret;

        if (os_program_init())
                return -1;

        os_memset(&params, 0, sizeof(params));
        params.wpa_debug_level = MSG_INFO;

        ret = RegOpenKeyEx(WPA_KEY_ROOT, WPA_KEY_PREFIX,
                           0, KEY_QUERY_VALUE, &hk);
        if (ret != ERROR_SUCCESS) {
                printf("Could not open wpa_supplicant registry key\n");
                return -1;
        }

        buflen = sizeof(val);
        ret = RegQueryValueEx(hk, TEXT("debug_level"), NULL, NULL,
                              (LPBYTE) &val, &buflen);
        if (ret == ERROR_SUCCESS && buflen == sizeof(val)) {
                params.wpa_debug_level = val;
        }

        buflen = sizeof(val);
        ret = RegQueryValueEx(hk, TEXT("debug_show_keys"), NULL, NULL,
                              (LPBYTE) &val, &buflen);
        if (ret == ERROR_SUCCESS && buflen == sizeof(val)) {
                params.wpa_debug_show_keys = val;
        }

        buflen = sizeof(val);
        ret = RegQueryValueEx(hk, TEXT("debug_timestamp"), NULL, NULL,
                              (LPBYTE) &val, &buflen);
        if (ret == ERROR_SUCCESS && buflen == sizeof(val)) {
                params.wpa_debug_timestamp = val;
        }

        buflen = sizeof(val);
        ret = RegQueryValueEx(hk, TEXT("debug_use_file"), NULL, NULL,
                              (LPBYTE) &val, &buflen);
        if (ret == ERROR_SUCCESS && buflen == sizeof(val) && val) {
                params.wpa_debug_file_path = "\\Temp\\wpa_supplicant-log.txt";
        }

        exitcode = 0;
        global = wpa_supplicant_init(&params);
        if (global == NULL) {
                printf("Failed to initialize wpa_supplicant\n");
                exitcode = -1;
        }

        ret = RegOpenKeyEx(hk, TEXT("interfaces"), 0, KEY_ENUMERATE_SUB_KEYS,
                           &ihk);
        RegCloseKey(hk);
        if (ret != ERROR_SUCCESS) {
                printf("Could not open wpa_supplicant interfaces registry "
                       "key\n");
                return -1;
        }

        for (i = 0; ; i++) {
                TCHAR name[255];
                DWORD namelen;

                namelen = 255;
                ret = RegEnumKeyEx(ihk, i, name, &namelen, NULL, NULL, NULL,
                                   NULL);

                if (ret == ERROR_NO_MORE_ITEMS)
                        break;

                if (ret != ERROR_SUCCESS) {
                        printf("RegEnumKeyEx failed: 0x%x\n",
                               (unsigned int) ret);
                        break;
                }

                if (namelen >= 255)
                        namelen = 255 - 1;
                name[namelen] = '\0';

                wpa_printf(MSG_DEBUG, "interface %d: %s\n", (int) i, name);
                if (read_interface(global, ihk, name) < 0)
                        exitcode = -1;
        }

        RegCloseKey(ihk);

        if (exitcode == 0)
                exitcode = wpa_supplicant_run(global);

        wpa_supplicant_deinit(global);

        os_program_deinit();

        return exitcode;
}
Пример #7
0
int main(int argc, char *argv[])
{
	int c;
        #if 0   /* WAS */
	struct wpa_interface *ifaces, *iface;
	int iface_count;
        #endif  /* WAS */
        int exitcode = 1;
	struct wpa_params params;
	struct wpa_global *global;

#ifdef MODIFIED_BY_SONY
#ifndef CONFIG_NATIVE_WINDOWS
	setvbuf(stdout, 0, _IOLBF, 0);
	setvbuf(stderr, 0, _IOLBF, 0);
#else /* CONFIG_NATIVE_WINDOWS */
	setbuf(stdout, 0);
	setbuf(stderr, 0);
#endif /* CONFIG_NATIVE_WINDOWS */
#endif /* MODIFIED_BY_SONY */

	if (os_program_init())
		return 1;

	os_memset(&params, 0, sizeof(params));
	params.wpa_debug_level = MSG_INFO;

        #if 0   /* WAS */
	iface = ifaces = os_zalloc(sizeof(struct wpa_interface));
	if (ifaces == NULL)
		return 1;
	iface_count = 1;
        #endif  /* WAS */

	wpa_supplicant_fd_workaround();

	for (;;) {
#ifndef WPS_OPT_NFC
                #if 0   /* WAS */
		c = getopt(argc, argv, "b:Bc:C:D:dg:hi:KLNp:P:qtuvwW");
                #else
		c = getopt(argc, argv, "BC:dg:hKLp:P:qtuvwW");
                #endif
#else /* WPS_OPT_NFC */
                #if 0   /* WAS */
		c = getopt(argc, argv, "b:Bc:C:D:dg:hi:KLn:Np:P:qtuvwW");
                #else
		c = getopt(argc, argv, "BC:dg:hKLn:p:P:qtuvwW");
                #endif
#endif /* WPS_OPT_NFC */
		if (c < 0)
			break;
		switch (c) {
        #if 0   /* WAS */
		case 'b':
			iface->bridge_ifname = optarg;
			break;
        #endif  /* WAS */
		case 'B':
			params.daemonize++;
			break;
        #if 0   /* WAS */
		case 'c':
			iface->confname = optarg;
			break;
        #endif  /* WAS */
        #if 0   /* WAS */
		case 'C':
			iface->ctrl_interface = optarg;
			break;
        #endif  /* WAS */
        #if 0   /* WAS */
		case 'D':
			iface->driver = optarg;
			break;
        #endif  /* WAS */
		case 'd':
#ifdef CONFIG_NO_STDOUT_DEBUG
			printf("Debugging disabled with "
			       "CONFIG_NO_STDOUT_DEBUG=y build time "
			       "option.\n");
			goto out;
#else /* CONFIG_NO_STDOUT_DEBUG */
			params.wpa_debug_level--;
			break;
#endif /* CONFIG_NO_STDOUT_DEBUG */
		case 'g':
			params.ctrl_interface = optarg;
			break;
		case 'h':
			usage();
			exitcode = 0;
			goto out;
        #if 0   /* WAS */
		case 'i':
			iface->ifname = optarg;
			break;
        #endif  /* WAS */
		case 'K':
			params.wpa_debug_show_keys++;
			break;
		case 'L':
			license();
			exitcode = 0;
			goto out;
        #if 0   /* WAS */
		case 'p':
			iface->driver_param = optarg;
			break;
        #endif  /* WAS */
		case 'P':
			os_free(params.pid_file);
			params.pid_file = os_rel2abs_path(optarg);
			break;
		case 'q':
			params.wpa_debug_level++;
			break;
		case 't':
			params.wpa_debug_timestamp++;
			break;
#ifdef CONFIG_CTRL_IFACE_DBUS
		case 'u':
			params.dbus_ctrl_interface = 1;
			break;
#endif /* CONFIG_CTRL_IFACE_DBUS */
		case 'v':
			printf("%s\n", wpa_supplicant_version);
#ifdef MODIFIED_BY_SONY
			printf("%s\n", modified_by_sony_version);
#endif /* MODIFIED_BY_SONY */
			exitcode = 0;
			goto out;
		case 'w':
			params.wait_for_interface++;
			break;
		case 'W':
			params.wait_for_monitor++;
			break;
#ifdef WPS_OPT_NFC
		case 'n':
			iface->nfcname = optarg;
			break;
#endif /* WPS_OPT_NFC */
        #if 0   /* WAS */
		case 'N':
			iface_count++;
			iface = os_realloc(ifaces, iface_count *
					   sizeof(struct wpa_interface));
			if (iface == NULL)
				goto out;
			ifaces = iface;
			iface = &ifaces[iface_count - 1]; 
			os_memset(iface, 0, sizeof(*iface));
			break;
        #endif  /* WAS */
		default:
			usage();
			exitcode = 0;
			goto out;
		}
	}

	exitcode = 0;
	global = wpa_supplicant_init(&params);
	if (global == NULL) {
		printf("Failed to initialize wpa_supplicant\n");
		exitcode = 1;
		goto out;
	}

        #if 0   /* WAS */
	for (i = 0; exitcode == 0 && i < iface_count; i++) {
		if ((ifaces[i].confname == NULL &&
		     ifaces[i].ctrl_interface == NULL) ||
		    ifaces[i].ifname == NULL) {
			if (iface_count == 1 && (params.ctrl_interface ||
						 params.dbus_ctrl_interface))
				break;
			usage();
			exitcode = 1;
			break;
		}
		if (wpa_supplicant_add_iface(global, &ifaces[i]) == NULL)
			exitcode = 1;
	}
        #endif  /* WAS */

        /* One or more topology files may be specified 
         * (one should be enough, but...)
         */
        if (argv[optind] == NULL) {
                printf("Need topology file as argument, or use -h for help\n");
                exitcode = 1;
                goto out;
        }
        if (wpa_supplicant_config_read_topology_files(global, argv+optind)) {
                exitcode = 1;
        }

	if (exitcode == 0)
		exitcode = wpa_supplicant_run(global);

	wpa_supplicant_deinit(global);

out:
        #if 0   /* WAS */
	os_free(ifaces);
        #endif  /* WAS */
	os_free(params.pid_file);

	os_program_deinit();

	return (exitcode != 0);
}
Пример #8
0
int main(int argc, char *argv[])
{
    int c, i;
    struct wpa_interface *ifaces, *iface;
    int iface_count, exitcode = -1;
    struct wpa_params params;
    struct wpa_global *global;
    char supp_dbg[PROPERTY_VALUE_MAX] = {'\0'};  //CONN-FY-WIFI-PortingSupplicantDebugTool

    if (os_program_init())
        return -1;

    os_memset(&params, 0, sizeof(params));
    params.wpa_debug_level = MSG_INFO;

    iface = ifaces = os_zalloc(sizeof(struct wpa_interface));
    if (ifaces == NULL)
        return -1;
    iface_count = 1;

    wpa_supplicant_fd_workaround(1);

    for (;;) {
        c = getopt(argc, argv,
                   "b:Bc:C:D:de:f:g:G:hi:I:KLm:No:O:p:P:qsS:TtuvW");
        if (c < 0)
            break;
        switch (c) {
        case 'b':
            iface->bridge_ifname = optarg;
            break;
        case 'B':
            params.daemonize++;
            break;
        case 'c':
            iface->confname = optarg;
            break;
        case 'C':
            iface->ctrl_interface = optarg;
            break;
        case 'D':
            iface->driver = optarg;
            break;
        case 'd':
#ifdef CONFIG_NO_STDOUT_DEBUG
            printf("Debugging disabled with "
                   "CONFIG_NO_STDOUT_DEBUG=y build time "
                   "option.\n");
            goto out;
#else /* CONFIG_NO_STDOUT_DEBUG */
            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;
            break;
#endif /* CONFIG_DEBUG_FILE */
        case 'g':
            params.ctrl_interface = optarg;
            break;
        case 'G':
            params.ctrl_interface_group = optarg;
            break;
        case 'h':
            usage();
            exitcode = 0;
            goto out;
        case 'i':
            iface->ifname = optarg;
            break;
        case 'I':
            iface->confanother = optarg;
            break;
        case 'K':
            params.wpa_debug_show_keys++;
            break;
        case 'L':
            license();
            exitcode = 0;
            goto out;
#ifdef CONFIG_P2P
        case 'm':
            iface->conf_p2p_dev = optarg;
            break;
#endif /* CONFIG_P2P */
        case 'o':
            params.override_driver = optarg;
            break;
        case 'O':
            params.override_ctrl_interface = optarg;
            break;
        case 'p':
            iface->driver_param = optarg;
            break;
        case 'P':
            os_free(params.pid_file);
            params.pid_file = os_rel2abs_path(optarg);
            break;
        case 'q':
            params.wpa_debug_level++;
            break;
#ifdef CONFIG_DEBUG_SYSLOG
        case 's':
            params.wpa_debug_syslog++;
            break;
#endif /* CONFIG_DEBUG_SYSLOG */
        case 'S':
            params.first_scan_delay_msec = atoi(optarg);
            break;
#ifdef CONFIG_DEBUG_LINUX_TRACING
        case 'T':
            params.wpa_debug_tracing++;
            break;
#endif /* CONFIG_DEBUG_LINUX_TRACING */
        case 't':
            params.wpa_debug_timestamp++;
            break;
#ifdef CONFIG_DBUS
        case 'u':
            params.dbus_ctrl_interface = 1;
            break;
#endif /* CONFIG_DBUS */
        case 'v':
            printf("%s\n", wpa_supplicant_version);
            exitcode = 0;
            goto out;
        case 'W':
            params.wait_for_monitor++;
            break;
        case 'N':
            iface_count++;
            iface = os_realloc_array(ifaces, iface_count,
                                     sizeof(struct wpa_interface));
            if (iface == NULL)
                goto out;
            ifaces = iface;
            iface = &ifaces[iface_count - 1];
            os_memset(iface, 0, sizeof(*iface));
            break;
        default:
            usage();
            exitcode = 0;
            goto out;
        }
    }

    //CONN-FY-WIFI-PortingSupplicantDebugTool++
    property_get("persist.supp.dbg", supp_dbg, "false");
    if (strcmp(supp_dbg, "true") == 0) {
        params.wpa_debug_level = MSG_EXCESSIVE;
        wpa_printf(MSG_INFO, "persist.supp.dbg true debug level MSG_EXCESSIVE");
    } else {
        params.wpa_debug_level = MSG_INFO;
        wpa_printf(MSG_INFO, "persist.supp.dbg false debug level MSG_INFO");
    }
    //CONN-FY-WIFI-PortingSupplicantDebugTool--

    exitcode = 0;
    global = wpa_supplicant_init(&params);
    if (global == NULL) {
        wpa_printf(MSG_ERROR, "Failed to initialize wpa_supplicant");
        exitcode = -1;
        goto out;
    } else {
        wpa_printf(MSG_INFO, "Successfully initialized "
                   "wpa_supplicant");
    }

    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) {
            if (iface_count == 1 && (params.ctrl_interface ||
                                     params.dbus_ctrl_interface))
                break;
            usage();
            exitcode = -1;
            break;
        }
        wpa_s = wpa_supplicant_add_iface(global, &ifaces[i]);
        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)
        exitcode = wpa_supplicant_run(global);

    wpa_supplicant_deinit(global);

out:
    wpa_supplicant_fd_workaround(0);
    os_free(ifaces);
    os_free(params.pid_file);

    os_program_deinit();

    return exitcode;
}