当前位置: 首页>>代码示例>>C++>>正文


C++ os_program_init函数代码示例

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


在下文中一共展示了os_program_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: main

int main(int argc, char *argv[])
{
    int i, j; 
    int c, res, ret = -1;
    const char *global_wpa_s_ctrl_intf = NULL;
    const char *wrapd_ctrl_intf = NULL;
    const char *vma_conf_file = NULL;
    const char *wpa_s_conf_file = NULL;
    const char *add_psta_addr = NULL;
    const char *remove_psta_addr = NULL;

    int daemonize = 0;
    int hostapd_num = 0;
    int list_psta_addr = 0;
    int do_mat = 0;
    int do_isolation = 0;
    int do_timer = 0;
    int conn_cnt = 0;
    int slave_mode = 0;
    char msg[128] = {0};
    
    if (os_program_init())
        return -1;

    for (i = 0; i < HOSTAPD_CNT; i ++) { 
        ap_ifname[i] = NULL;
        wrapd_hostapd_conn[i] = NULL;
    }

    for (;;) {
        c = getopt(argc, argv, "g:a:p:w:A:R:BLMSITc:v:d:h");
        if (c < 0)
            break;
        switch (c) {
            case 'g':  
                wrapd_ctrl_intf = optarg;
                break;            
            case 'w':
                global_wpa_s_ctrl_intf = optarg;
                break;
            case 'a':
                if (hostapd_num >= HOSTAPD_CNT) {
                    usage(); 
                    goto out;
                }                    
                ap_ifname[hostapd_num ++] = os_strdup(optarg);
                break;
            case 'p':
                mpsta_ifname = os_strdup(optarg);
                break;       
            case 'd':
                dbdc_ifname = os_strdup(optarg);
                break;                      
		    case 'B':
			    daemonize++;
			    break;                
            case 'A':
                add_psta_addr = optarg;
                break;
            case 'R':
                remove_psta_addr = optarg;
                break;  
            case 'L':     
                list_psta_addr = 1;
                break;  
            case 'M':     
                do_mat = 1;
                break;    
            case 'I':     
                do_isolation = 1;
                break;  
            case 'S':     
                slave_mode = 1;
                break;    
            case 'T':
                do_timer = 1;
                break;               
            case 'c':
                wpa_s_conf_file = optarg;
                break;
            case 'v':
                vma_conf_file = optarg;
                break;   
            case 'h':
                usage(); 
                ret = 0;
                goto out;
            default:
                usage();
                goto out;

        }
    }

    for (i = 0; i < hostapd_num - 1; i ++) {
        for (j = i + 1; j < hostapd_num; j ++) {
            if (os_strcmp(ap_ifname[i], ap_ifname[j]) == 0) {
                wrapd_printf("duplicated ap_ifname[%d] of ap_ifname[%d]", i, j);
                goto out;
            }
//.........这里部分代码省略.........
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:101,代码来源:main.c

示例6: main

int main(int argc, char *argv[])
{
	int warning_displayed = 0;
	int c;
	int daemonize = 0;

	if (os_program_init())
		return -1;

	for (;;) {
		c = getopt(argc, argv, "a:BhG:i:p:P:s:v");
		if (c < 0)
			break;
		switch (c) {
		case 'a':
			action_file = optarg;
			break;
		case 'B':
			daemonize = 1;
			break;
		case 'G':
			ping_interval = atoi(optarg);
			break;
		case 'h':
			usage();
			return 0;
		case 'v':
			printf("%s\n", hostapd_cli_version);
			return 0;
		case 'i':
			os_free(ctrl_ifname);
			ctrl_ifname = os_strdup(optarg);
			break;
		case 'p':
			ctrl_iface_dir = optarg;
			break;
		case 'P':
			pid_file = optarg;
			break;
		case 's':
			client_socket_dir = optarg;
			break;
		default:
			usage();
			return -1;
		}
	}

	interactive = (argc == optind) && (action_file == NULL);

	if (interactive) {
		printf("%s\n\n%s\n\n", hostapd_cli_version, cli_license);
	}

	if (eloop_init())
		return -1;

	for (;;) {
		if (ctrl_ifname == NULL) {
			struct dirent *dent;
			DIR *dir = opendir(ctrl_iface_dir);
			if (dir) {
				while ((dent = readdir(dir))) {
					if (os_strcmp(dent->d_name, ".") == 0
					    ||
					    os_strcmp(dent->d_name, "..") == 0)
						continue;
					printf("Selected interface '%s'\n",
					       dent->d_name);
					ctrl_ifname = os_strdup(dent->d_name);
					break;
				}
				closedir(dir);
			}
		}
		hostapd_cli_reconnect(ctrl_ifname);
		if (ctrl_conn) {
			if (warning_displayed)
				printf("Connection established.\n");
			break;
		}

		if (!interactive) {
			perror("Failed to connect to hostapd - "
			       "wpa_ctrl_open");
			return -1;
		}

		if (!warning_displayed) {
			printf("Could not connect to hostapd - re-trying\n");
			warning_displayed = 1;
		}
		os_sleep(1, 0);
		continue;
	}

	if (action_file && !hostapd_cli_attached)
		return -1;
	if (daemonize && os_daemonize(pid_file) && eloop_sock_requeue())
		return -1;
//.........这里部分代码省略.........
开发者ID:cococorp,项目名称:hostap-upstream,代码行数:101,代码来源:hostapd_cli.c

示例7: main

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

示例8: main

int main(int argc, char *argv[])
{
	struct wpa_supplicant wpa_s;
	int c, ret = 1, wait_for_monitor = 0, save_config = 0;
	char *as_addr = "127.0.0.1";
	int as_port = 1812;
	char *as_secret = "radius";
	char *cli_addr = NULL;
	char *conf = NULL;
	int timeout = 30;
	char *pos;
	struct extra_radius_attr *p = NULL, *p1;

	if (os_program_init())
		return -1;

	hostapd_logger_register_cb(hostapd_logger_cb);

	os_memset(&eapol_test, 0, sizeof(eapol_test));
	eapol_test.connect_info = "CONNECT 11Mbps 802.11b";
	os_memcpy(eapol_test.own_addr, "\x02\x00\x00\x00\x00\x01", ETH_ALEN);

	wpa_debug_level = 0;
	wpa_debug_show_keys = 1;

	for (;;) {
		c = getopt(argc, argv, "a:A:c:C:M:nN:o:p:r:s:St:W");
		if (c < 0)
			break;
		switch (c) {
		case 'a':
			as_addr = optarg;
			break;
		case 'A':
			cli_addr = optarg;
			break;
		case 'c':
			conf = optarg;
			break;
		case 'C':
			eapol_test.connect_info = optarg;
			break;
		case 'M':
			if (hwaddr_aton(optarg, eapol_test.own_addr)) {
				usage();
				return -1;
			}
			break;
		case 'n':
			eapol_test.no_mppe_keys++;
			break;
		case 'o':
			if (eapol_test.server_cert_file)
				fclose(eapol_test.server_cert_file);
			eapol_test.server_cert_file = fopen(optarg, "w");
			if (eapol_test.server_cert_file == NULL) {
				printf("Could not open '%s' for writing\n",
				       optarg);
				return -1;
			}
			break;
		case 'p':
			as_port = atoi(optarg);
			break;
		case 'r':
			eapol_test.eapol_test_num_reauths = atoi(optarg);
			break;
		case 's':
			as_secret = optarg;
			break;
		case 'S':
			save_config++;
			break;
		case 't':
			timeout = atoi(optarg);
			break;
		case 'W':
			wait_for_monitor++;
			break;
		case 'N':
			p1 = os_zalloc(sizeof(p1));
			if (p1 == NULL)
				break;
			if (!p)
				eapol_test.extra_attrs = p1;
			else
				p->next = p1;
			p = p1;

			p->type = atoi(optarg);
			pos = os_strchr(optarg, ':');
			if (pos == NULL) {
				p->syntax = 'n';
				p->data = NULL;
				break;
			}

			pos++;
			if (pos[0] == '\0' || pos[1] != ':') {
				printf("Incorrect format of attribute "
//.........这里部分代码省略.........
开发者ID:MultiNet-80211,项目名称:Hostapd,代码行数:101,代码来源:eapol_test.c

示例9: main

int main(int argc, char *argv[])
{
	int interactive;
	int warning_displayed = 0;
	int c;
	int daemonize = 0;

	if (os_program_init())
		return -1;

	for (;;) {
		c = getopt(argc, argv, "a:BhG:i:p:v");
		if (c < 0)
			break;
		switch (c) {
		case 'a':
			action_file = optarg;
			break;
		case 'B':
			daemonize = 1;
			break;
		case 'G':
			ping_interval = atoi(optarg);
			break;
		case 'h':
			usage();
			return 0;
		case 'v':
			printf("%s\n", hostapd_cli_version);
			return 0;
		case 'i':
			os_free(ctrl_ifname);
			ctrl_ifname = os_strdup(optarg);
			break;
		case 'p':
			ctrl_iface_dir = optarg;
			break;
		default:
			usage();
			return -1;
		}
	}

	interactive = (argc == optind) && (action_file == NULL);

	if (interactive) {
		printf("%s\n\n%s\n\n", hostapd_cli_version,
		       hostapd_cli_license);
	}

	for (;;) {
		if (ctrl_ifname == NULL) {
			struct dirent *dent;
			DIR *dir = opendir(ctrl_iface_dir);
			if (dir) {
				while ((dent = readdir(dir))) {
					if (os_strcmp(dent->d_name, ".") == 0
					    ||
					    os_strcmp(dent->d_name, "..") == 0)
						continue;
					printf("Selected interface '%s'\n",
					       dent->d_name);
					ctrl_ifname = os_strdup(dent->d_name);
					break;
				}
				closedir(dir);
			}
		}
		ctrl_conn = hostapd_cli_open_connection(ctrl_ifname);
		if (ctrl_conn) {
			if (warning_displayed)
				printf("Connection established.\n");
			break;
		}

		if (!interactive) {
			perror("Failed to connect to hostapd - "
			       "wpa_ctrl_open");
			return -1;
		}

		if (!warning_displayed) {
			printf("Could not connect to hostapd - re-trying\n");
			warning_displayed = 1;
		}
		os_sleep(1, 0);
		continue;
	}

	signal(SIGINT, hostapd_cli_terminate);
	signal(SIGTERM, hostapd_cli_terminate);
	signal(SIGALRM, hostapd_cli_alarm);

	if (interactive || action_file) {
		if (wpa_ctrl_attach(ctrl_conn) == 0) {
			hostapd_cli_attached = 1;
		} else {
			printf("Warning: Failed to attach to hostapd.\n");
			if (action_file)
				return -1;
//.........这里部分代码省略.........
开发者ID:embest-tech,项目名称:android_external_hostapd,代码行数:101,代码来源:hostapd_cli.c

示例10: main

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

示例11: main

int main(int argc, char *argv[])
{
	int warning_displayed = 0;
	int c;
	int daemonize = 0;

        printf("In hostapd cli main\n");

	if (os_program_init())
		return -1;

	for (;;) {
		c = getopt(argc, argv, "a:BhG:i:p:P:s:v");
		if (c < 0) {
			break;
                        printf("c<0 getting out of for loop\n");
                }
		switch (c) {
		case 'a':
			action_file = optarg;
			break;
		case 'B':
			daemonize = 1;
			break;
		case 'G':
			ping_interval = atoi(optarg);
			break;
		case 'h':
			usage();
			return 0;
		case 'v':
			printf("%s\n", hostapd_cli_version);
			return 0;
		case 'i':
			os_free(ctrl_ifname);
			ctrl_ifname = os_strdup(optarg);
			break;
		case 'p':
			ctrl_iface_dir = optarg;
			break;
		case 'P':
			pid_file = optarg;
			break;
		case 's':
			client_socket_dir = optarg;
			break;
		default:
			usage();
			return -1;
		}
	}

	interactive = (argc == optind) && (action_file == NULL);

	if (interactive) {
		printf("%s\n\n%s\n\n", hostapd_cli_version,
		       hostapd_cli_license);
	}

	if (eloop_init())
		return -1;

	for (;;) {
		if (ctrl_ifname == NULL) {
			struct dirent *dent;
			DIR *dir = opendir(ctrl_iface_dir);
			if (dir) {
				while ((dent = readdir(dir))) {
					if (os_strcmp(dent->d_name, ".") == 0
					    ||
					    os_strcmp(dent->d_name, "..") == 0)
						continue;
					printf("Selected interface '%s'\n",
					       dent->d_name);
					ctrl_ifname = os_strdup(dent->d_name);
					break;
				}
				closedir(dir);
			}
		}
		ctrl_conn = hostapd_cli_open_connection(ctrl_ifname);
		if (ctrl_conn) {
			if (warning_displayed)
				printf("Connection established.\n");
			break;
		}

		if (!interactive) {
			perror("Failed to connect to hostapd - "
			       "wpa_ctrl_open");
			return -1;
		}

		if (!warning_displayed) {
			printf("Could not connect to hostapd - re-trying\n");
			warning_displayed = 1;
		}
		os_sleep(1, 0);
		continue;
	}
//.........这里部分代码省略.........
开发者ID:PavanKulk,项目名称:codebase,代码行数:101,代码来源:hostapd_cli.c

示例12: main

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

示例13: main

int main(int argc, char *argv[])
{
	struct wpa_supplicant wpa_s;
	int c, ret = 1, wait_for_monitor = 0, save_config = 0;
	char *as_addr = "127.0.0.1";
	int as_port = 1812;
	char *as_secret = "radius";
	char *conf = NULL;
	int timeout = 30;

	if (os_program_init())
		return -1;

	os_memset(&eapol_test, 0, sizeof(eapol_test));
	eapol_test.connect_info = "CONNECT 11Mbps 802.11b";
	os_memcpy(eapol_test.own_addr, "\x02\x00\x00\x00\x00\x01", ETH_ALEN);

	wpa_debug_level = 0;
	wpa_debug_show_keys = 1;

	for (;;) {
		c = getopt(argc, argv, "a:c:C:M:np:r:s:St:W");
		if (c < 0)
			break;
		switch (c) {
		case 'a':
			as_addr = optarg;
			break;
		case 'c':
			conf = optarg;
			break;
		case 'C':
			eapol_test.connect_info = optarg;
			break;
		case 'M':
			if (hwaddr_aton(optarg, eapol_test.own_addr)) {
				usage();
				return -1;
			}
			break;
		case 'n':
			eapol_test.no_mppe_keys++;
			break;
		case 'p':
			as_port = atoi(optarg);
			break;
		case 'r':
			eapol_test.eapol_test_num_reauths = atoi(optarg);
			break;
		case 's':
			as_secret = optarg;
			break;
		case 'S':
			save_config++;
			break;
		case 't':
			timeout = atoi(optarg);
			break;
		case 'W':
			wait_for_monitor++;
			break;
		default:
			usage();
			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) {
//.........这里部分代码省略.........
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,代码来源:eapol_test.c

示例14: 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

示例15: 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


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