• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ os_program_deinit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中os_program_deinit函数的典型用法代码示例。如果您正苦于以下问题:C++ os_program_deinit函数的具体用法?C++ os_program_deinit怎么用?C++ os_program_deinit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了os_program_deinit函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    struct radius_ctx ctx;
    struct hostapd_radius_server *srv;

    if (os_program_init())
        return -1;

    hostapd_logger_register_cb(hostapd_logger_cb);

    os_memset(&ctx, 0, sizeof(ctx));
    inet_aton("127.0.0.1", &ctx.own_ip_addr);

    if (eloop_init()) {
        printf("Failed to initialize event loop\n");
        return -1;
    }

    srv = os_zalloc(sizeof(*srv));
    if (srv == NULL)
        return -1;

    srv->addr.af = AF_INET;
    srv->port = 1812;
    if (hostapd_parse_ip_addr("127.0.0.1", &srv->addr) < 0) {
        printf("Failed to parse IP address\n");
        return -1;
    }
    srv->shared_secret = (u8 *) os_strdup("radius");
    srv->shared_secret_len = 6;

    ctx.conf.auth_server = ctx.conf.auth_servers = srv;
    ctx.conf.num_auth_servers = 1;
    ctx.conf.msg_dumps = 1;

    ctx.radius = radius_client_init(&ctx, &ctx.conf);
    if (ctx.radius == NULL) {
        printf("Failed to initialize RADIUS client\n");
        return -1;
    }

    if (radius_client_register(ctx.radius, RADIUS_AUTH, receive_auth,
                               &ctx) < 0) {
        printf("Failed to register RADIUS authentication handler\n");
        return -1;
    }

    eloop_register_timeout(0, 0, start_example, &ctx, NULL);

    eloop_run();

    radius_client_deinit(ctx.radius);
    os_free(srv->shared_secret);
    os_free(srv);

    eloop_destroy();
    os_program_deinit();

    return 0;
}
开发者ID:avchinch,项目名称:hostap-1,代码行数:60,代码来源:radius_example.c


示例2: hostapd_cli_cleanup

static void hostapd_cli_cleanup(void)
{
	hostapd_cli_close_connection();
	if (pid_file)
		os_daemonize_terminate(pid_file);

	os_program_deinit();
}
开发者ID:cococorp,项目名称:hostap-upstream,代码行数:8,代码来源:hostapd_cli.c


示例3: main

int main(int argc, char *argv[])
{
	struct wpa_supplicant wpa_s;
	int ret = -1;
	struct wpabuf *buf = NULL, *ndef = NULL;
	char txt[1000];

	if (os_program_init())
		return -1;
	random_init(NULL);

	os_memset(&wpa_s, 0, sizeof(wpa_s));
	wpa_s.conf = os_zalloc(sizeof(*wpa_s.conf));
	if (wpa_s.conf == NULL)
		goto fail;

	buf = wpas_wps_nfc_token(&wpa_s, 0);
	if (buf == NULL)
		goto fail;

	ndef = ndef_build_wifi(buf);
	if (ndef == NULL)
		goto fail;

	wpa_snprintf_hex_uppercase(txt, sizeof(txt), wpabuf_head(buf),
				   wpabuf_len(buf));
	printf("#WPS=%s\n", txt);

	wpa_snprintf_hex_uppercase(txt, sizeof(txt), wpabuf_head(ndef),
				   wpabuf_len(ndef));
	printf("#NDEF=%s\n", txt);

	printf("wps_nfc_dev_pw_id=%d\n", wpa_s.conf->wps_nfc_dev_pw_id);
	print_bin("wps_nfc_dh_pubkey", wpa_s.conf->wps_nfc_dh_pubkey);
	print_bin("wps_nfc_dh_privkey", wpa_s.conf->wps_nfc_dh_privkey);
	print_bin("wps_nfc_dev_pw", wpa_s.conf->wps_nfc_dev_pw);

	ret = 0;
fail:
	wpabuf_free(ndef);
	wpabuf_free(buf);
	wpa_config_free(wpa_s.conf);
	random_deinit();
	os_program_deinit();

	return ret;
}
开发者ID:0x000000FF,项目名称:wpa_supplicant_for_edison,代码行数:47,代码来源:nfc_pw_token.c


示例4: main

int main(int argc, char *argv[])
{
	struct wpa wpa;

	if (os_program_init())
		return -1;

	os_memset(&wpa, 0, sizeof(wpa));
	os_memset(wpa.auth_addr, 0x12, ETH_ALEN);
	os_memset(wpa.supp_addr, 0x32, ETH_ALEN);
	os_memset(wpa.psk, 0x44, PMK_LEN);

	wpa_debug_level = 0;
	wpa_debug_show_keys = 1;

	if (eloop_init()) {
		wpa_printf(MSG_ERROR, "Failed to initialize event loop");
		return -1;
	}

	if (auth_init_group(&wpa) < 0)
		return -1;

	if (supp_init(&wpa) < 0)
		return -1;

	if (auth_init(&wpa) < 0)
		return -1;

	wpa_printf(MSG_DEBUG, "Starting eloop");
	eloop_run();
	wpa_printf(MSG_DEBUG, "eloop done");

	deinit(&wpa);

	eloop_destroy();

	os_program_deinit();

	return 0;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:41,代码来源:test_wpa.c


示例5: main

int main(int argc, char *argv[])
{
    int s;
    struct sockaddr_un addr;
    int ret = 0;

    if (os_program_init())
        return -1;

    s = socket(AF_UNIX, SOCK_SEQPACKET, 0);
    if (s < 0) {
        perror("socket");
        return -1;
    }

    os_memset(&addr, 0, sizeof(addr));
    addr.sun_family = AF_UNIX;
    os_strlcpy(addr.sun_path + 1, WLANTEST_SOCK_NAME,
               sizeof(addr.sun_path) - 1);
    if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
        perror("connect");
        close(s);
        return -1;
    }

    if (argc > 1) {
        ret = ctrl_command(s, argc - 1, &argv[1]);
        if (ret < 0)
            printf("FAIL\n");
    } else {
        wlantest_cli_interactive(s);
    }

    close(s);

    os_program_deinit();

    return ret;
}
开发者ID:mpthompson,项目名称:rtl8188_hostap,代码行数:39,代码来源:wlantest_cli.c


示例6: main


//.........这里部分代码省略.........
		return -1;
	}

	/* Allocate and parse configuration for full interface files */
	for (i = 0; i < interfaces.count; i++) {
		interfaces.iface[i] = hostapd_interface_init(&interfaces,
							     argv[optind + i],
							     debug);
		if (!interfaces.iface[i]) {
			wpa_printf(MSG_ERROR, "Failed to initialize interface");
			goto out;
		}
	}

	/* Allocate and parse configuration for per-BSS files */
	for (i = 0; i < num_bss_configs; i++) {
		struct hostapd_iface *iface;
		char *fname;

		wpa_printf(MSG_INFO, "BSS config: %s", bss_config[i]);
		fname = os_strchr(bss_config[i], ':');
		if (fname == NULL) {
			wpa_printf(MSG_ERROR,
				   "Invalid BSS config identifier '%s'",
				   bss_config[i]);
			goto out;
		}
		*fname++ = '\0';
		iface = hostapd_interface_init_bss(&interfaces, bss_config[i],
						   fname, debug);
		if (iface == NULL)
			goto out;
		for (j = 0; j < interfaces.count; j++) {
			if (interfaces.iface[j] == iface)
				break;
		}
		if (j == interfaces.count) {
			struct hostapd_iface **tmp;
			tmp = os_realloc_array(interfaces.iface,
					       interfaces.count + 1,
					       sizeof(struct hostapd_iface *));
			if (tmp == NULL) {
				hostapd_interface_deinit_free(iface);
				goto out;
			}
			interfaces.iface = tmp;
			interfaces.iface[interfaces.count++] = iface;
		}
	}

	/*
	 * Enable configured interfaces. Depending on channel configuration,
	 * this may complete full initialization before returning or use a
	 * callback mechanism to complete setup in case of operations like HT
	 * co-ex scans, ACS, or DFS are needed to determine channel parameters.
	 * In such case, the interface will be enabled from eloop context within
	 * hostapd_global_run().
	 */
	interfaces.terminate_on_error = interfaces.count;
	for (i = 0; i < interfaces.count; i++) {
		if (hostapd_driver_init(interfaces.iface[i]) ||
		    hostapd_setup_interface(interfaces.iface[i]))
			goto out;
	}

	hostapd_global_ctrl_iface_init(&interfaces);

	if (hostapd_global_run(&interfaces, daemonize, pid_file)) {
		wpa_printf(MSG_ERROR, "Failed to start eloop");
		goto out;
	}

	ret = 0;

 out:
	hostapd_global_ctrl_iface_deinit(&interfaces);
	/* Deinitialize all interfaces */
	for (i = 0; i < interfaces.count; i++) {
		if (!interfaces.iface[i])
			continue;
		interfaces.iface[i]->driver_ap_teardown =
			!!(interfaces.iface[i]->drv_flags &
			   WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT);
		hostapd_interface_deinit_free(interfaces.iface[i]);
	}
	os_free(interfaces.iface);

	hostapd_global_deinit(pid_file);
	os_free(pid_file);

	if (log_file)
		wpa_debug_close_file();
	wpa_debug_close_linux_tracing();

	os_free(bss_config);

	os_program_deinit();

	return ret;
}
开发者ID:imw,项目名称:hapd,代码行数:101,代码来源:main.c


示例7: main


//.........这里部分代码省略.........
		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);
}
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:101,代码来源:main.c


示例8: main

int main(int argc, char *argv[])
{
	int c, i;
	int ret = -1;
	char *pid_file = NULL;
	int daemonize = 0;
	char *ctrl_dir = "/var/run/wpa_priv";
	struct wpa_priv_interface *interfaces = NULL, *iface;

	if (os_program_init())
		return -1;

	wpa_priv_fd_workaround();

	for (;;) {
		c = getopt(argc, argv, "Bc:dP:");
		if (c < 0)
			break;
		switch (c) {
		case 'B':
			daemonize++;
			break;
		case 'c':
			ctrl_dir = optarg;
			break;
		case 'd':
			wpa_debug_level--;
			break;
		case 'P':
			pid_file = os_rel2abs_path(optarg);
			break;
		default:
			usage();
			goto out;
		}
	}

	if (optind >= argc) {
		usage();
		goto out;
	}

	wpa_printf(MSG_DEBUG, "wpa_priv control directory: '%s'", ctrl_dir);

	if (eloop_init(NULL)) {
		wpa_printf(MSG_ERROR, "Failed to initialize event loop");
		goto out;
	}

	for (i = optind; i < argc; i++) {
		wpa_printf(MSG_DEBUG, "Adding driver:interface %s", argv[i]);
		iface = wpa_priv_interface_init(ctrl_dir, argv[i]);
		if (iface == NULL)
			goto out;
		iface->next = interfaces;
		interfaces = iface;
	}

	if (daemonize && os_daemonize(pid_file))
		goto out;

	eloop_register_signal_terminate(wpa_priv_terminate, NULL);
	eloop_run();

	ret = 0;

out:
	iface = interfaces;
	while (iface) {
		struct wpa_priv_interface *prev = iface;
		iface = iface->next;
		wpa_priv_interface_deinit(prev);
	}

	eloop_destroy();

	os_daemonize_terminate(pid_file);
	os_free(pid_file);
	os_program_deinit();

	return ret;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:82,代码来源:wpa_priv.c


示例9: main


//.........这里部分代码省略.........
					  &argv[optind + 1]);
	}

	if (conf == NULL) {
		usage();
		printf("Configuration file is required.\n");
		return -1;
	}

	if (eap_register_methods()) {
		wpa_printf(MSG_ERROR, "Failed to register EAP methods");
		return -1;
	}

	if (eloop_init()) {
		wpa_printf(MSG_ERROR, "Failed to initialize event loop");
		return -1;
	}

	os_memset(&wpa_s, 0, sizeof(wpa_s));
	eapol_test.wpa_s = &wpa_s;
	wpa_s.conf = wpa_config_read(conf);
	if (wpa_s.conf == NULL) {
		printf("Failed to parse configuration file '%s'.\n", conf);
		return -1;
	}
	if (wpa_s.conf->ssid == NULL) {
		printf("No networks defined.\n");
		return -1;
	}

	wpa_init_conf(&eapol_test, &wpa_s, as_addr, as_port, as_secret,
		      cli_addr);
	wpa_s.ctrl_iface = wpa_supplicant_ctrl_iface_init(&wpa_s);
	if (wpa_s.ctrl_iface == NULL) {
		printf("Failed to initialize control interface '%s'.\n"
		       "You may have another eapol_test process already "
		       "running or the file was\n"
		       "left by an unclean termination of eapol_test in "
		       "which case you will need\n"
		       "to manually remove this file before starting "
		       "eapol_test again.\n",
		       wpa_s.conf->ctrl_interface);
		return -1;
	}
	if (wpa_supplicant_scard_init(&wpa_s, wpa_s.conf->ssid))
		return -1;

	if (test_eapol(&eapol_test, &wpa_s, wpa_s.conf->ssid))
		return -1;

	if (wait_for_monitor)
		wpa_supplicant_ctrl_iface_wait(wpa_s.ctrl_iface);

	eloop_register_timeout(timeout, 0, eapol_test_timeout, &eapol_test,
			       NULL);
	eloop_register_timeout(0, 0, send_eap_request_identity, &wpa_s, NULL);
	eloop_register_signal_terminate(eapol_test_terminate, &wpa_s);
	eloop_register_signal_reconfig(eapol_test_terminate, &wpa_s);
	eloop_run();

	eloop_cancel_timeout(eapol_test_timeout, &eapol_test, NULL);
	eloop_cancel_timeout(eapol_sm_reauth, &eapol_test, NULL);

	if (eapol_test_compare_pmk(&eapol_test) == 0 ||
	    eapol_test.no_mppe_keys)
		ret = 0;
	if (eapol_test.auth_timed_out)
		ret = -2;
	if (eapol_test.radius_access_reject_received)
		ret = -3;

	if (save_config)
		wpa_config_write(conf, wpa_s.conf);

	test_eapol_clean(&eapol_test, &wpa_s);

	eap_peer_unregister_methods();
#ifdef CONFIG_AP
	eap_server_unregister_methods();
#endif /* CONFIG_AP */

	eloop_destroy();

	if (eapol_test.server_cert_file)
		fclose(eapol_test.server_cert_file);

	printf("MPPE keys OK: %d  mismatch: %d\n",
	       eapol_test.num_mppe_ok, eapol_test.num_mppe_mismatch);
	if (eapol_test.num_mppe_mismatch)
		ret = -4;
	if (ret)
		printf("FAILURE\n");
	else
		printf("SUCCESS\n");

	os_program_deinit();

	return ret;
}
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:101,代码来源:eapol_test.c


示例10: main


//.........这里部分代码省略.........
			return -1;
		}
	}

	if (argc > optind && os_strcmp(argv[optind], "scard") == 0) {
		return scard_test();
	}

	if (argc > optind && os_strcmp(argv[optind], "sim") == 0) {
		return scard_get_triplets(argc - optind - 1,
					  &argv[optind + 1]);
	}

	if (conf == NULL) {
		usage();
		printf("Configuration file is required.\n");
		return -1;
	}

	if (eap_peer_register_methods()) {
		wpa_printf(MSG_ERROR, "Failed to register EAP methods");
		return -1;
	}

	if (eloop_init(&wpa_s)) {
		wpa_printf(MSG_ERROR, "Failed to initialize event loop");
		return -1;
	}

	os_memset(&wpa_s, 0, sizeof(wpa_s));
	eapol_test.wpa_s = &wpa_s;
	wpa_s.conf = wpa_config_read(conf);
	if (wpa_s.conf == NULL) {
		printf("Failed to parse configuration file '%s'.\n", conf);
		return -1;
	}
	if (wpa_s.conf->ssid == NULL) {
		printf("No networks defined.\n");
		return -1;
	}

	wpa_init_conf(&eapol_test, &wpa_s, as_addr, as_port, as_secret);
	wpa_s.ctrl_iface = wpa_supplicant_ctrl_iface_init(&wpa_s);
	if (wpa_s.ctrl_iface == NULL) {
		printf("Failed to initialize control interface '%s'.\n"
		       "You may have another eapol_test process already "
		       "running or the file was\n"
		       "left by an unclean termination of eapol_test in "
		       "which case you will need\n"
		       "to manually remove this file before starting "
		       "eapol_test again.\n",
		       wpa_s.conf->ctrl_interface);
		return -1;
	}
	if (wpa_supplicant_scard_init(&wpa_s, wpa_s.conf->ssid))
		return -1;

	if (test_eapol(&eapol_test, &wpa_s, wpa_s.conf->ssid))
		return -1;

	if (wait_for_monitor)
		wpa_supplicant_ctrl_iface_wait(wpa_s.ctrl_iface);

	eloop_register_timeout(timeout, 0, eapol_test_timeout, &eapol_test,
			       NULL);
	eloop_register_timeout(0, 0, send_eap_request_identity, &wpa_s, NULL);
	eloop_register_signal_terminate(eapol_test_terminate, NULL);
	eloop_register_signal_reconfig(eapol_test_terminate, NULL);
	eloop_run();

	if (eapol_test_compare_pmk(&eapol_test) == 0 ||
	    eapol_test.no_mppe_keys)
		ret = 0;
	if (eapol_test.auth_timed_out)
		ret = -2;
	if (eapol_test.radius_access_reject_received)
		ret = -3;

	if (save_config)
		wpa_config_write(conf, wpa_s.conf);

	test_eapol_clean(&eapol_test, &wpa_s);

	eap_peer_unregister_methods();

	eloop_destroy();

	printf("MPPE keys OK: %d  mismatch: %d\n",
	       eapol_test.num_mppe_ok, eapol_test.num_mppe_mismatch);
	if (eapol_test.num_mppe_mismatch)
		ret = -4;
	if (ret)
		printf("FAILURE\n");
	else
		printf("SUCCESS\n");

	os_program_deinit();

	return ret;
}
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,代码来源:eapol_test.c


示例11: main


//.........这里部分代码省略.........
#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;
}
开发者ID:Anik1199,项目名称:tulip,代码行数:101,代码来源:main.c


示例12: main


//.........这里部分代码省略.........
#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;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:101,代码来源:main.c


示例13: main

int main(int argc, char *argv[])
{
	struct hapd_interfaces interfaces;
	int ret = 1;
	size_t i;
	int c, debug = 0, daemonize = 0;
	char *pid_file = NULL;
	const char *log_file = NULL;

	if (os_program_init())
		return -1;

	for (;;) {
		c = getopt(argc, argv, "Bdf:hKP:tv");
		if (c < 0)
			break;
		switch (c) {
		case 'h':
			usage();
			break;
		case 'd':
			debug++;
			if (wpa_debug_level > 0)
				wpa_debug_level--;
			break;
		case 'B':
			daemonize++;
			break;
		case 'f':
			log_file = optarg;
			break;
		case 'K':
			wpa_debug_show_keys++;
			break;
		case 'P':
			os_free(pid_file);
			pid_file = os_rel2abs_path(optarg);
			break;
		case 't':
			wpa_debug_timestamp++;
			break;
		case 'v':
			show_version();
			exit(1);
			break;

		default:
			usage();
			break;
		}
	}

	if (optind == argc)
		usage();

	wpa_msg_register_ifname_cb(hostapd_msg_ifname_cb);

	if (log_file)
		wpa_debug_open_file(log_file);

	interfaces.count = argc - optind;
	interfaces.iface = os_malloc(interfaces.count *
				     sizeof(struct hostapd_iface *));
	if (interfaces.iface == NULL) {
		wpa_printf(MSG_ERROR, "malloc failed\n");
		return -1;
	}

	if (hostapd_global_init(&interfaces))
		return -1;

	/* Initialize interfaces */
	for (i = 0; i < interfaces.count; i++) {
		interfaces.iface[i] = hostapd_interface_init(&interfaces,
							     argv[optind + i],
							     debug);
		if (!interfaces.iface[i])
			goto out;
	}

	if (hostapd_global_run(&interfaces, daemonize, pid_file))
		goto out;

	ret = 0;

 out:
	/* Deinitialize all interfaces */
	for (i = 0; i < interfaces.count; i++)
		hostapd_interface_deinit_free(interfaces.iface[i]);
	os_free(interfaces.iface);

	hostapd_global_deinit(pid_file);
	os_free(pid_file);

	if (log_file)
		wpa_debug_close_file();

	os_program_deinit();

	return ret;
//.........这里部分代码省略.........
开发者ID:cozybit,项目名称:hostap-sae,代码行数:101,代码来源:main.c


示例14: main


//.........这里部分代码省略.........
	if (os_program_init())
		return -1;

	wlantest_init(&wt);

	for (;;) {
		c = getopt(argc, argv, "cdf:hi:I:p:P:qr:R:w:W:");
		if (c < 0)
			break;
		switch (c) {
		case 'c':
			ctrl_iface = 1;
			break;
		case 'd':
			if (wpa_debug_level > 0)
				wpa_debug_level--;
			break;
		case 'f':
			if (add_pmk_file(&wt, optarg) < 0)
				return -1;
			break;
		case 'h':
			usage();
			return 0;
		case 'i':
			ifname = optarg;
			break;
		case 'I':
			ifname_wired = optarg;
			break;
		case 'p':
			add_passphrase(&wt, optarg);
			break;
		case 'P':
			add_secret(&wt, optarg);
			break;
		case 'q':
			wpa_debug_level++;
			break;
		case 'r':
			read_file = optarg;
			break;
		case 'R':
			read_wired_file = optarg;
			break;
		case 'w':
			write_file = optarg;
			break;
		case 'W':
			if (add_wep(&wt, optarg) < 0)
				return -1;
			break;
		default:
			usage();
			return -1;
		}
	}

	if (ifname == NULL && ifname_wired == NULL &&
	    read_file == NULL && read_wired_file == NULL) {
		usage();
		return 0;
	}

	if (eloop_init())
		return -1;

	if (write_file && write_pcap_init(&wt, write_file) < 0)
		return -1;

	if (read_wired_file && read_wired_cap_file(&wt, read_wired_file) < 0)
		return -1;

	if (read_file && read_cap_file(&wt, read_file) < 0)
		return -1;

	if (ifname && monitor_init(&wt, ifname) < 0)
		return -1;

	if (ifname_wired && monitor_init_wired(&wt, ifname_wired) < 0)
		return -1;

	if (ctrl_iface && ctrl_init(&wt) < 0)
		return -1;

	eloop_register_signal_terminate(wlantest_terminate, &wt);

	eloop_run();

	wpa_printf(MSG_INFO, "Processed: rx_mgmt=%u rx_ctrl=%u rx_data=%u "
		   "fcs_error=%u",
		   wt.rx_mgmt, wt.rx_ctrl, wt.rx_data, wt.fcs_error);

	wlantest_deinit(&wt);

	eloop_destroy();
	os_program_deinit();

	return 0;
}
开发者ID:174high,项目名称:wpa_supplicant_8_ti,代码行数:101,代码来源:wlantest.c


示例15: wpa_supplicant_thread

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();
//.........这里部分代码省略.........
开发者ID:tigerjibo,项目名称:wpa_suppliant_with_openssl,代码行数:101,代码来源:main_winsvc.c


示例16: main


//.........这里部分代码省略.........
			       "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;
}
开发者ID:WiseMan787,项目名称:ralink_sdk,代码行数:101,代码来源:main.c


示例17: main


//.........这里部分代码省略.........

    if (eloop_init()) {
        wrapd_printf("Failed to initialize event loop");
        goto out;
    }
    
    wrapd_handle = wrapd_conn_to_global_wpa_s(global_wpa_s_ctrl_intf, wpa_s_conf_file, do_isolation, do_timer);
    if (wrapd_handle == NULL) 
        goto out;

    wrapd_conn = wrapd_ctrl_open(wrapd_ctrl_intf, wrapd_handle);

    for (i = 0; i < HOSTAPD_CNT; i ++) { 
        if(ap_ifname[i]) {
            for (conn_cnt = 0; conn_cnt < HOSTAPD_CONN_TIMES; conn_cnt ++) {
                wrapd_hostapd_conn[i] = wrapd_conn_to_hostapd(ap_ifname[i]);
                if (wrapd_hostapd_conn[i]) {
                    wrapd_printf("WRAP hostapd(%s) connected", ap_ifname[i]);
                    break;
                }
                os_sleep(1, 0);
            }   
            if(wrapd_hostapd_conn[i]) {
                if (wpa_ctrl_attach((struct wpa_ctrl *)wrapd_hostapd_conn[i]) != 0) {
                    wrapd_printf("Failed to attach to WRAP hostapd(%s)", ap_ifname[i]);;
                    goto out;
                }
                wrapd_printf("WRAP hostapd(%s) attached", ap_ifname[i]);
                eloop_register_read_sock(wrapd_hostapd_conn[i]->sock, wrapd_hostapd_ctrl_iface_receive, wrapd_handle, (void *)ap_ifname[i]); 
            } else {
                wrapd_printf("WRAP hostapd(%s) not exists", ap_ifname[i]);
            }
        }
    }

    if(mpsta_ifname == NULL) {
        wrapd_printf("Failed to connect to MPSTA wpa_s - mpsta_ifname == NULL");
        goto out;
    }    

    for (conn_cnt = 0; conn_cnt < WPA_S_CONN_TIMES; conn_cnt ++) {
        /*
         * Delay to ensure scan doesn't overlap with ht40 intol acs scan, else will cause 
         * scan to fail and will take more time for MPSTA to associate.
         * EV 131644 
         */
        if(conn_cnt == 0)
            os_sleep(3, 0);
        wrapd_wpa_s_conn = wrapd_conn_to_mpsta_wpa_s(mpsta_ifname);
        if (wrapd_wpa_s_conn) {
            wrapd_printf("MPSTA wpa_s(%s) connected", mpsta_ifname);
            break;
        }
        os_sleep(1, 0);
    }   
    if(wrapd_wpa_s_conn) {
        if (wpa_ctrl_attach((struct wpa_ctrl *)wrapd_wpa_s_conn) != 0) {
            wrapd_printf("Failed to attach to MPSTA wpa_s(%s)", mpsta_ifname);
            goto out;
        }
        wrapd_printf("MPSTA wpa_s(%s) attached", mpsta_ifname);
        eloop_register_read_sock(wrapd_wpa_s_conn->sock, wrapd_wpa_s_ctrl_iface_receive, wrapd_handle, NULL); 
    } else {
        wrapd_printf("MPSTA wpa_s(%s) not exists", mpsta_ifname);
    }

    if (vma_conf_file) {
        wrapd_load_vma_list(vma_conf_file, wrapd_handle);
    }

	if (daemonize && os_daemonize(NULL)) {
		wrapd_printf("daemon");
		goto out;
	}

    eloop_run();

out:

    for (i = 0; i < HOSTAPD_CNT; i ++) { 
        if (ap_ifname[i])
            os_free(ap_ifname[i]);
            
        if (wrapd_hostapd_conn[i])
            wpa_ctrl_close((struct wpa_ctrl *)wrapd_hostapd_conn[i]);
    }
        
    if (dbdc_ifname)
        os_free(dbdc_ifname);
    if (mpsta_ifname)
        os_free(mpsta_ifname);

    if (wrapd_wpa_s_conn)
        wpa_ctrl_close((struct wpa_ctrl *)wrapd_wpa_s_conn); 
    
	os_program_deinit();    
    
    return ret;  
    
}
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:101,代码来源:main.c



注:本文中的os_program_deinit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ os_program_init函数代码示例发布时间:2022-05-30
下一篇:
C++ os_printk函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap