这篇教程C++ wpa_ctrl_attach函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wpa_ctrl_attach函数的典型用法代码示例。如果您正苦于以下问题:C++ wpa_ctrl_attach函数的具体用法?C++ wpa_ctrl_attach怎么用?C++ wpa_ctrl_attach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wpa_ctrl_attach函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: WPACtrl_attach/* ------------------------------------------------------------------------------ WPACtrl_attach */static PyObject* WPACtrl_attach(WPACtrl* self){ int ret; if (self->attached == 1) Py_RETURN_NONE; ret = wpa_ctrl_attach(self->ctrl_iface); switch (ret) { case 0: self->attached = 1; Py_RETURN_NONE; case -1: PyErr_SetString(WPACtrl_error, "wpa_ctrl_attach failed"); break; case -2: PyErr_SetString(WPACtrl_error, "wpa_ctrl_attach timed out"); break; default: PyErr_SetString(WPACtrl_error, "wpa_ctrl_attach returned unknown error"); break; } return NULL;}
开发者ID:Saij,项目名称:pywpactrl,代码行数:27,
示例2: LOGWint Supplicant::connectToSupplicant() { if (!isStarted()) LOGW("Supplicant service not running"); mCtrl = wpa_ctrl_open("tiwlan0"); // XXX: if (mCtrl == NULL) { LOGE("Unable to open connection to supplicant on /"%s/": %s", "tiwlan0", strerror(errno)); return -1; } mMonitor = wpa_ctrl_open("tiwlan0"); if (mMonitor == NULL) { wpa_ctrl_close(mCtrl); mCtrl = NULL; return -1; } if (wpa_ctrl_attach(mMonitor) != 0) { wpa_ctrl_close(mMonitor); wpa_ctrl_close(mCtrl); mCtrl = mMonitor = NULL; return -1; } mListener = new SupplicantListener(mHandlers, mMonitor); if (mListener->startListener()) { LOGE("Error - unable to start supplicant listener"); stop(); return -1; } return 0;}
开发者ID:SuperTeam,项目名称:android_system_core,代码行数:32,
示例3: DBGMSG_ERRbool WiFiNode::open() { bool result = false; do { if (!ctrlIfaceName) { DBGMSG_ERR("ctrlIfaceName is [%p]", ctrlIfaceName); break; } const size_t wpaPathLength = strlen(ctrlIfaceBasePath) + strlen(ctrlIfaceName) + 1; char path[wpaPathLength]; snprintf(path, wpaPathLength, "%s%s", ctrlIfaceBasePath, ctrlIfaceName); DBGMSG_M("Trying to open [%s]", path); wpaCtrl = wpa_ctrl_open(path); if (!wpaCtrl) { DBGMSG_ERR("Failed to Open Interface"); break; } if (wpa_ctrl_attach(wpaCtrl)) { DBGMSG_ERR("Failed to Attach To Interface %d"); break; } result = true; } while (0); DBGMSG_M("Result %s", result ? "Ok" : "Error"); return result;}
开发者ID:schapa,项目名称:OrangeWiFi,代码行数:27,
示例4: wifi_connect_to_supplicantint wifi_connect_to_supplicant(){ char ifname[256]; char supp_status[PROPERTY_VALUE_MAX] = {'/0'}; /* Make sure supplicant is running */ if (!property_get(SUPP_PROP_NAME, supp_status, NULL) || strcmp(supp_status, "running") != 0) { LOGE("Supplicant not running, cannot connect"); return -1; } if (access(IFACE_DIR, F_OK) == 0) { snprintf(ifname, sizeof(ifname), "%s/%s", IFACE_DIR, iface); } else { strlcpy(ifname, iface, sizeof(ifname)); } if (cur_module == ATHEROS_ATH6K) { LOGD ("execute the chmod_ath0 shell/n"); usleep(100000); property_set("ctl.start", "chmod_ath0"); } ctrl_conn = wpa_ctrl_open(ifname); if (ctrl_conn == NULL) { LOGE("Unable to open connection to supplicant on /"%s/": %s", ifname, strerror(errno)); return -1; } monitor_conn = wpa_ctrl_open(ifname); if (monitor_conn == NULL) { wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; return -1; } if (wpa_ctrl_attach(monitor_conn) != 0) { wpa_ctrl_close(monitor_conn); wpa_ctrl_close(ctrl_conn); ctrl_conn = monitor_conn = NULL; return -1; } if (socketpair(AF_UNIX, SOCK_STREAM, 0, exit_sockets) == -1) { wpa_ctrl_close(monitor_conn); wpa_ctrl_close(ctrl_conn); ctrl_conn = monitor_conn = NULL; return -1; } { char ifname[IFNAMSIZ]; char buf[256]; strlcpy(ifname, iface, sizeof(ifname)); rtw_issue_driver_cmd(ifname, "BLOCK 0", buf, 256); } return 0;}
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:60,
示例5: hostapd_cli_cmd_interfacestatic int hostapd_cli_cmd_interface(struct wpa_ctrl *ctrl, int argc, char *argv[]){ if (argc < 1) { hostapd_cli_list_interfaces(ctrl); return 0; } hostapd_cli_close_connection(); os_free(ctrl_ifname); ctrl_ifname = os_strdup(argv[0]); if (ctrl_ifname == NULL) return -1; if (hostapd_cli_open_connection(ctrl_ifname)) { printf("Connected to interface '%s./n", ctrl_ifname); if (wpa_ctrl_attach(ctrl_conn) == 0) { hostapd_cli_attached = 1; } else { printf("Warning: Failed to attach to " "hostapd./n"); } } else { printf("Could not connect to interface '%s' - re-trying/n", ctrl_ifname); } return 0;}
开发者ID:vidya-sagar-kushwaha,项目名称:hostap,代码行数:28,
示例6: wpa_cli_cmd_interfacestatic int wpa_cli_cmd_interface(struct wpa_ctrl *ctrl, int argc, char *argv[]){ if (argc < 1) { wpa_cli_list_interfaces(ctrl); return 0; } wpa_cli_close_connection(); os_free(ctrl_ifname); ctrl_ifname = os_strdup(argv[0]); if ((ctrl_conn = wpa_cli_open_connection(ctrl_ifname)) != NULL) { printf("Connected to interface '%s./n", ctrl_ifname); if (wpa_ctrl_attach(monitor_conn) == 0) { wpa_cli_attached = 1; } else { printf("Warning: Failed to attach to " "wpa_supplicant./n"); } } else { printf("Could not connect to interface '%s' - re-trying/n", ctrl_ifname); } return 0;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:25,
示例7: wpa_ctrl_openbool wifi_manager::init(const char* path) { bool ret = false; do { if(_buffer == NULL) _buffer = new char[WIFI_BUFFER_LEN]; _ctrl = wpa_ctrl_open(path); if(!_ctrl) { printf("wifi open %s failed/n",path); break; } _event_ctrl = wpa_ctrl_open(path); if(!_event_ctrl) { printf("wifi open %s failed/n",path); break; } if(wpa_ctrl_attach(_event_ctrl)) break; _is_running = true; if (0 != pthread_create(&_thread, NULL, wifi_manager::_wifi_recv_thread, (void*)this)) { printf("error when create pthread in wifi_manager,%d/n", errno); break; } ret = true; }while(0); return ret;}
开发者ID:ChangerR,项目名称:Amusement-Machine-Software,代码行数:35,
示例8: hostapd_cli_reconnectstatic int hostapd_cli_reconnect(const char *ifname){ char *next_ctrl_ifname; hostapd_cli_close_connection(); if (!ifname) return -1; next_ctrl_ifname = os_strdup(ifname); os_free(ctrl_ifname); ctrl_ifname = next_ctrl_ifname; if (!ctrl_ifname) return -1; ctrl_conn = hostapd_cli_open_connection(ctrl_ifname); if (!ctrl_conn) return -1; if (!interactive && !action_file) return 0; if (wpa_ctrl_attach(ctrl_conn) == 0) { hostapd_cli_attached = 1; register_event_handler(ctrl_conn); update_stations(ctrl_conn); } else { printf("Warning: Failed to attach to hostapd./n"); } return 0;}
开发者ID:cococorp,项目名称:hostap-upstream,代码行数:29,
示例9: wpatalk_reconnect/* wpatalk_reconnect -- maybe reconnect. * If previously connected, disconnects and aborts unless "keep_going" * is set (-k option). */static void wpatalk_reconnect(void){ if (ctrl_conn) { wpatalk_close_connection(); if (!keep_going) { wpatalk_fatal("Exiting due to lost connection"); } } for (;;) { if (wpatalk_get_socket_path() == 0) { #ifdef CONFIG_CTRL_IFACE_UNIX ctrl_conn = wpa_ctrl_open(socket_path); #else #error "wpatalk_open_connection configuration error" #endif } if (ctrl_conn) { if (wpa_ctrl_attach(ctrl_conn) == 0) { if (warning_displayed || verbose) { wpatalk_info( "Connection (re)established to daemon=%s interface=%s", daemon_name, ctrl_ifname); wpatalk_info("... using socket-file=%s", socket_path); warning_displayed = 0; } wpatalk_attached = 1; return; } else { if (!warning_displayed) { wpatalk_warning( "Failed to attach to daemon %s", daemon_name); } wpatalk_close_connection(); ctrl_conn = NULL; } } if (!keep_going) { wpatalk_fatal("Failed to connect to daemon %s errno %d " "using socket file %s", daemon_name, errno, socket_path); return; } if (!warning_displayed) { wpatalk_info("Could not connect to daemon %s -- re-trying", daemon_name); warning_displayed = 1; } os_sleep(1, 0); } return;}
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:56,
示例10: open_wpa_monstruct wpa_ctrl * open_wpa_mon(const char *ifname){ struct wpa_ctrl *ctrl; ctrl = wpa_open_ctrl(ifname); if (ctrl == NULL) return NULL; if (wpa_ctrl_attach(ctrl) < 0) { wpa_ctrl_close(ctrl); return NULL; } return ctrl;}
开发者ID:2asoft,项目名称:freebsd,代码行数:14,
示例11: wpa_cli_reconnectstatic void wpa_cli_reconnect(void){ wpa_cli_close_connection(); ctrl_conn = wpa_cli_open_connection(ctrl_ifname); if (ctrl_conn) { printf("Connection to wpa_supplicant re-established/n"); if (wpa_ctrl_attach(monitor_conn) == 0) { wpa_cli_attached = 1; } else { printf("Warning: Failed to attach to " "wpa_supplicant./n"); } }}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:14,
示例12: wifi_connect_to_supplicantint wifi_connect_to_supplicant(){ char ifname[256]; static int cleaned_up = 0; property_get("wifi.interface", iface, "sta"); if (access(IFACE_DIR, F_OK) == 0) { snprintf(ifname, sizeof(ifname), "%s/%s", IFACE_DIR, iface); } else { strlcpy(ifname, iface, sizeof(ifname)); } ctrl_conn = wpa_ctrl_open(ifname); if (ctrl_conn == NULL) { LOGD("Unable to open connection to supplicant on /"%s/": %s", ifname, strerror(errno)); /* * errno == ENOENT means the supplicant daemon isn't * running. Take this opportunity to clear out any * stale socket files that might be left over. Note * there's a possible race with the command line client * trying to connect to the daemon, but it would require * that the supplicant be started and the command line * client connect to it during the window between the * error check and the removal of the files. And in * any event, the remedy is that the user would simply * have to run the command line program again. */ if (!cleaned_up && (errno == ENOENT || errno == EADDRINUSE)) { cleaned_up = 1; /* do this just once */ wpa_ctrl_cleanup(); } return -1; } monitor_conn = wpa_ctrl_open(ifname); if (monitor_conn == NULL) { wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; return -1; } if (wpa_ctrl_attach(monitor_conn) != 0) { wpa_ctrl_close(monitor_conn); wpa_ctrl_close(ctrl_conn); ctrl_conn = monitor_conn = NULL; return -1; } return 0;}
开发者ID:cypher099,项目名称:platform_hardware,代码行数:49,
示例13: wifi_connect_to_supplicantint wifi_connect_to_supplicant(){ char ifname[256]; char supp_status[PROPERTY_VALUE_MAX] = {'/0'}; int supplicant_timeout = SUPPLICANT_TIMEOUT; LOGD("[wifiHW] wifi connect to supplicant"); /* Make sure supplicant is running */ if (!property_get(SUPP_PROP_NAME, supp_status, NULL) || strcmp(supp_status, "running") != 0) { LOGE("Supplicant not running, cannot connect"); return -1; } property_get("wifi.interface", iface, WIFI_TEST_INTERFACE); if (access(IFACE_DIR, F_OK) == 0) { snprintf(ifname, sizeof(ifname), "%s/%s", IFACE_DIR, iface); } else { strlcpy(ifname, iface, sizeof(ifname)); } ctrl_conn = wpa_ctrl_open(ifname); while (ctrl_conn == NULL && supplicant_timeout > 0) { usleep(SUPPLICANT_TIMEOUT_STEP); supplicant_timeout -= SUPPLICANT_TIMEOUT_STEP; ctrl_conn = wpa_ctrl_open(ifname); } if (ctrl_conn == NULL) { LOGE("Unable to open connection to supplicant on /"%s/": %s", ifname, strerror(errno)); return -1; } monitor_conn = wpa_ctrl_open(ifname); if (monitor_conn == NULL) { wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; return -1; } if (wpa_ctrl_attach(monitor_conn) != 0) { wpa_ctrl_close(monitor_conn); wpa_ctrl_close(ctrl_conn); ctrl_conn = monitor_conn = NULL; return -1; } return 0;}
开发者ID:TooLogic,项目名称:allwinner_board_files,代码行数:48,
示例14: mainint main(int argc, char *argv[]){ if (argc != 2) errx(EXIT_FAILURE, "%s <path to supplicant control pipe>", argv[0]); ctrl = wpa_ctrl_open(argv[1]); if (!ctrl) err(EXIT_FAILURE, "Couldn't open '%s'", argv[1]); if (wpa_ctrl_attach(ctrl) < 0) err(EXIT_FAILURE, "wpa_ctrl_attach"); int wpa_fd = wpa_ctrl_get_fd(ctrl); for (;;) { struct pollfd fdset[2]; fdset[0].fd = STDIN_FILENO; fdset[0].events = POLLIN; fdset[0].revents = 0; fdset[1].fd = wpa_fd; fdset[1].events = POLLIN; fdset[1].revents = 0; debug("waiting on poll/n"); int rc = poll(fdset, 2, -1); if (rc < 0) { // Retry if EINTR if (errno == EINTR) continue; err(EXIT_FAILURE, "poll"); } debug("poll: revents[0]=%08x, revents[1]=%08x/n", fdset[0].revents, fdset[1].revents); if (fdset[0].revents & (POLLIN | POLLHUP)) process_erl(); if (fdset[1].revents & POLLIN) process_wpa(); } return 0;}
开发者ID:bsmr-nerves-project,项目名称:nerves_wpa_supplicant,代码行数:46,
示例15: wifi_connect_to_supplicantint wifi_connect_to_supplicant(){ char ifname[256]; char supp_status[PROPERTY_VALUE_MAX] = {'/0'}; /* Make sure supplicant is running */ if (!property_get(SUPP_PROP_NAME, supp_status, NULL) || strcmp(supp_status, "running") != 0) { LOGE("Supplicant not running, cannot connect"); return -1; } if (access(IFACE_DIR, F_OK) == 0) { snprintf(ifname, sizeof(ifname), "%s/%s", IFACE_DIR, iface); } else { strlcpy(ifname, iface, sizeof(ifname)); } ctrl_conn = wpa_ctrl_open(ifname); if (ctrl_conn == NULL) { LOGE("Unable to open connection to supplicant on /"%s/": %s", ifname, strerror(errno)); return -1; } monitor_conn = wpa_ctrl_open(ifname); if (monitor_conn == NULL) { wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; return -1; } if (wpa_ctrl_attach(monitor_conn) != 0) { wpa_ctrl_close(monitor_conn); wpa_ctrl_close(ctrl_conn); ctrl_conn = monitor_conn = NULL; return -1; } if (socketpair(AF_UNIX, SOCK_STREAM, 0, exit_sockets) == -1) { wpa_ctrl_close(monitor_conn); wpa_ctrl_close(ctrl_conn); ctrl_conn = monitor_conn = NULL; return -1; } return 0;}
开发者ID:classicnerd,项目名称:android_hardware_libhardware_legacy,代码行数:46,
示例16: wifi_connect_on_socket_pathint wifi_connect_on_socket_path(int index, const char *path){ char supp_status[PROPERTY_VALUE_MAX] = {'/0'}; ALOGI("Connect socket path:%s", path); /* Make sure supplicant is running */ if (!property_get(supplicant_prop_name, supp_status, NULL) || strcmp(supp_status, "running") != 0) { ALOGE("Supplicant not running, cannot connect"); return -1; } ctrl_conn[index] = wpa_ctrl_open(path); if (ctrl_conn[index] == NULL) { ALOGE("Unable to open connection to supplicant on /"%s/": %s", path, strerror(errno)); return -1; } monitor_conn[index] = wpa_ctrl_open(path); if (monitor_conn[index] == NULL) { wpa_ctrl_close(ctrl_conn[index]); ctrl_conn[index] = NULL; return -1; } if (wpa_ctrl_attach(monitor_conn[index]) != 0) { wpa_ctrl_close(monitor_conn[index]); wpa_ctrl_close(ctrl_conn[index]); ctrl_conn[index] = monitor_conn[index] = NULL; return -1; } if (socketpair(AF_UNIX, SOCK_STREAM, 0, exit_sockets[index]) == -1) { wpa_ctrl_close(monitor_conn[index]); wpa_ctrl_close(ctrl_conn[index]); ctrl_conn[index] = monitor_conn[index] = NULL; return -1; } return 0;}
开发者ID:XuQiufeng,项目名称:CWifimanger,代码行数:40,
示例17: hostapd_cli_alarmstatic void hostapd_cli_alarm(int sig){ if (ctrl_conn && _wpa_ctrl_command(ctrl_conn, "PING", 0)) { printf("Connection to hostapd lost - trying to reconnect/n"); hostapd_cli_close_connection(); } if (!ctrl_conn) { ctrl_conn = hostapd_cli_open_connection(ctrl_ifname); if (ctrl_conn) { printf("Connection to hostapd re-established/n"); if (wpa_ctrl_attach(ctrl_conn) == 0) { hostapd_cli_attached = 1; } else { printf("Warning: Failed to attach to " "hostapd./n"); } } } if (ctrl_conn) hostapd_cli_recv_pending(ctrl_conn, 1); alarm(ping_interval);}
开发者ID:Austrie,项目名称:android_external_hostapd,代码行数:22,
示例18: hostapd_cli_pingstatic void hostapd_cli_ping(void *eloop_ctx, void *timeout_ctx){ if (ctrl_conn && _wpa_ctrl_command(ctrl_conn, "PING", 0)) { printf("Connection to hostapd lost - trying to reconnect/n"); hostapd_cli_close_connection(); } if (!ctrl_conn) { ctrl_conn = hostapd_cli_open_connection(ctrl_ifname); if (ctrl_conn) { printf("Connection to hostapd re-established/n"); if (wpa_ctrl_attach(ctrl_conn) == 0) { hostapd_cli_attached = 1; } else { printf("Warning: Failed to attach to " "hostapd./n"); } } } if (ctrl_conn) hostapd_cli_recv_pending(ctrl_conn, 1, 0); eloop_register_timeout(ping_interval, 0, hostapd_cli_ping, NULL, NULL);}
开发者ID:vidya-sagar-kushwaha,项目名称:hostap,代码行数:22,
示例19: wpa_cli_alarmstatic void wpa_cli_alarm(int sig){ if (ctrl_conn && _wpa_ctrl_command(ctrl_conn, "PING", 0)) { printf("Connection to wpa_supplicant lost - trying to " "reconnect/n"); wpa_cli_close_connection(); } if (!ctrl_conn) { ctrl_conn = wpa_cli_open_connection(ctrl_ifname); if (ctrl_conn) { printf("Connection to wpa_supplicant " "re-established/n"); if (wpa_ctrl_attach(ctrl_conn) == 0) { wpa_cli_attached = 1; } else { printf("Warning: Failed to attach to " "wpa_supplicant./n"); } } } if (ctrl_conn) wpa_cli_recv_pending(ctrl_conn, 1, 0); alarm(1);}
开发者ID:vutukurikishore,项目名称:wpa_supplicant,代码行数:24,
示例20: main//.........这里部分代码省略......... } interactive = (argc == optind) && (action_file == NULL); if (interactive) printf("%s/n/n%s/n/n", wpa_cli_version, wpa_cli_license); if (global) { ctrl_conn = wpa_ctrl_open(global); if (ctrl_conn == NULL) { perror("Failed to connect to wpa_supplicant - " "wpa_ctrl_open"); return -1; } } for (; !global;) {#ifndef CONFIG_CTRL_IFACE_UDP if (ctrl_ifname == NULL) { struct dirent *dent; DIR *dir = opendir(ctrl_iface_dir); if (dir) { while ((dent = readdir(dir))) {#ifdef _DIRENT_HAVE_D_TYPE /* Skip the file if it is not a socket. * Also accept DT_UNKNOWN (0) in case * the C library or underlying file * system does not support d_type. */ if (dent->d_type != DT_SOCK && dent->d_type != DT_UNKNOWN) continue;#endif /* _DIRENT_HAVE_D_TYPE */ if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; printf("Selected interface '%s'/n", dent->d_name); ctrl_ifname = strdup(dent->d_name); break; } closedir(dir); } }#endif /* CONFIG_CTRL_IFACE_UDP */ ctrl_conn = wpa_cli_open_connection(ctrl_ifname); if (ctrl_conn) { if (warning_displayed) printf("Connection established./n"); break; } if (!interactive) { perror("Failed to connect to wpa_supplicant - " "wpa_ctrl_open"); return -1; } if (!warning_displayed) { printf("Could not connect to wpa_supplicant - " "re-trying/n"); warning_displayed = 1; } os_sleep(1, 0); continue; }#ifndef _WIN32_WCE signal(SIGINT, wpa_cli_terminate); signal(SIGTERM, wpa_cli_terminate);#endif /* _WIN32_WCE */#ifndef CONFIG_NATIVE_WINDOWS signal(SIGALRM, wpa_cli_alarm);#endif /* CONFIG_NATIVE_WINDOWS */ if (interactive || action_file) { if (wpa_ctrl_attach(ctrl_conn) == 0) { wpa_cli_attached = 1; } else { printf("Warning: Failed to attach to " "wpa_supplicant./n"); if (!interactive) return -1; } } if (daemonize && os_daemonize(pid_file)) return -1; if (interactive) wpa_cli_interactive(); else if (action_file) wpa_cli_action(ctrl_conn); else wpa_request(ctrl_conn, argc - optind, &argv[optind]); free(ctrl_ifname); wpa_cli_cleanup(); return 0;}
开发者ID:vutukurikishore,项目名称:wpa_supplicant,代码行数:101,
示例21: main//.........这里部分代码省略......... break; case 'h': usage(); return 0; case 'v': printf("%s/n", wpa_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; default: usage(); return -1; } } interactive = (argc == optind) && (action_file == NULL); if (interactive) printf("%s/n/n%s/n/n", wpa_cli_version, wpa_cli_license); if (global) {#ifdef CONFIG_CTRL_IFACE_NAMED_PIPE ctrl_conn = wpa_ctrl_open(NULL);#else /* CONFIG_CTRL_IFACE_NAMED_PIPE */ ctrl_conn = wpa_ctrl_open(global);#endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */ if (ctrl_conn == NULL) { perror("Failed to connect to wpa_supplicant - " "wpa_ctrl_open"); return -1; } } for (; !global;) { if (ctrl_ifname == NULL) ctrl_ifname = wpa_cli_get_default_ifname(); ctrl_conn = wpa_cli_open_connection(ctrl_ifname); if (ctrl_conn) { if (warning_displayed) printf("Connection established./n"); break; } if (!interactive) { perror("Failed to connect to wpa_supplicant - " "wpa_ctrl_open"); return -1; } if (!warning_displayed) { printf("Could not connect to wpa_supplicant - " "re-trying/n"); warning_displayed = 1; } os_sleep(1, 0); continue; }#ifndef _WIN32_WCE signal(SIGINT, wpa_cli_terminate); signal(SIGTERM, wpa_cli_terminate);#endif /* _WIN32_WCE */#ifndef CONFIG_NATIVE_WINDOWS signal(SIGALRM, wpa_cli_alarm);#endif /* CONFIG_NATIVE_WINDOWS */ if (interactive || action_file) { if (wpa_ctrl_attach(monitor_conn) == 0) { wpa_cli_attached = 1; } else { printf("Warning: Failed to attach to " "wpa_supplicant./n"); if (!interactive) return -1; } } if (daemonize && os_daemonize(pid_file)) return -1; if (interactive) wpa_cli_interactive(); else if (action_file) wpa_cli_action(ctrl_conn); else ret = wpa_request(ctrl_conn, argc - optind, &argv[optind]); os_free(ctrl_ifname); wpa_cli_cleanup(); return ret;}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:101,
示例22: wpa_cli_reconnectstatic void wpa_cli_reconnect(void){ wpa_cli_close_connection(); ctrl_conn = wpa_cli_open_connection(ctrl_ifname); if (ctrl_conn) { printf("Connection to wpa_supplicant re-established/n");#ifdef ANDROID if (wpa_ctrl_attach(monitor_conn) == 0) {#else if (wpa_ctrl_attach(ctrl_conn) == 0) {#endif wpa_cli_attached = 1; } else { printf("Warning: Failed to attach to " "wpa_supplicant./n"); } }}static void wpa_cli_recv_pending(struct wpa_ctrl *ctrl, int in_read, int action_monitor){ int first = 1;#ifdef ANDROID if (ctrl == NULL) {#else if (ctrl_conn == NULL) {#endif wpa_cli_reconnect(); return; } while (wpa_ctrl_pending(ctrl) > 0) { char buf[256]; size_t len = sizeof(buf) - 1; if (wpa_ctrl_recv(ctrl, buf, &len) == 0) { buf[len] = '/0'; if (action_monitor) wpa_cli_action_process(buf); else { if (in_read && first) printf("/n"); first = 0; printf("%s/n", buf); } } else { printf("Could not read pending message./n"); break; } } if (wpa_ctrl_pending(ctrl) < 0) { printf("Connection to wpa_supplicant lost - trying to " "reconnect/n"); wpa_cli_reconnect(); }}#ifdef CONFIG_READLINEstatic char * wpa_cli_cmd_gen(const char *text, int state){ static int i, len; const char *cmd; if (state == 0) { i = 0; len = os_strlen(text); } while ((cmd = wpa_cli_commands[i].cmd)) { i++; if (os_strncasecmp(cmd, text, len) == 0) return os_strdup(cmd); } return NULL;}static char * wpa_cli_dummy_gen(const char *text, int state){ return NULL;}static char ** wpa_cli_completion(const char *text, int start, int end){ return rl_completion_matches(text, start == 0 ? wpa_cli_cmd_gen : wpa_cli_dummy_gen);}#endif /* CONFIG_READLINE */static void wpa_cli_interactive(void){#define max_args 10 char cmdbuf[256], *cmd, *argv[max_args], *pos; int argc;#ifdef CONFIG_READLINE//.........这里部分代码省略.........
开发者ID:dharix,项目名称:android_external_wpa_supplicant_ath,代码行数:101,
示例23: free//.........这里部分代码省略......... ctrl_iface = NULL; ctrl = wpa_ctrl_open(NULL); if (ctrl) { len = sizeof(buf) - 1; ret = wpa_ctrl_request(ctrl, "INTERFACES", 10, buf, &len, NULL); if (ret >= 0) { buf[len] = '/0'; pos = strchr(buf, '/n'); if (pos) *pos = '/0'; ctrl_iface = strdup(buf); } wpa_ctrl_close(ctrl); }#endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */ } if (ctrl_iface == NULL) return -1;#ifdef CONFIG_CTRL_IFACE_UNIX flen = strlen(ctrl_iface_dir) + strlen(ctrl_iface) + 2; cfile = (char *) malloc(flen); if (cfile == NULL) return -1; snprintf(cfile, flen, "%s/%s", ctrl_iface_dir, ctrl_iface);#else /* CONFIG_CTRL_IFACE_UNIX */ flen = strlen(ctrl_iface) + 1; cfile = (char *) malloc(flen); if (cfile == NULL) return -1; snprintf(cfile, flen, "%s", ctrl_iface);#endif /* CONFIG_CTRL_IFACE_UNIX */ if (ctrl_conn) { wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; } if (monitor_conn) { delete msgNotifier; msgNotifier = NULL; wpa_ctrl_detach(monitor_conn); wpa_ctrl_close(monitor_conn); monitor_conn = NULL; } printf("Trying to connect to '%s'/n", cfile); ctrl_conn = wpa_ctrl_open(cfile); if (ctrl_conn == NULL) { free(cfile); return -1; } monitor_conn = wpa_ctrl_open(cfile); free(cfile); if (monitor_conn == NULL) { wpa_ctrl_close(ctrl_conn); return -1; } if (wpa_ctrl_attach(monitor_conn)) { printf("Failed to attach to wpa_supplicant/n"); wpa_ctrl_close(monitor_conn); monitor_conn = NULL; wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; return -1; }#if defined(CONFIG_CTRL_IFACE_UNIX) || defined(CONFIG_CTRL_IFACE_UDP) msgNotifier = new QSocketNotifier(wpa_ctrl_get_fd(monitor_conn), QSocketNotifier::Read, this); connect(msgNotifier, SIGNAL(activated(int)), SLOT(receiveMsgs()));#endif adapterSelect->clear(); adapterSelect->insertItem(ctrl_iface); adapterSelect->setCurrentItem(0); len = sizeof(buf) - 1; if (wpa_ctrl_request(ctrl_conn, "INTERFACES", 10, buf, &len, NULL) >= 0) { buf[len] = '/0'; pos = buf; while (*pos) { pos2 = strchr(pos, '/n'); if (pos2) *pos2 = '/0'; if (strcmp(pos, ctrl_iface) != 0) adapterSelect->insertItem(pos); if (pos2) pos = pos2 + 1; else break; } } return 0;}
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,
示例24: wpa_cli_cmd_interfacestatic int wpa_cli_cmd_interface(struct wpa_ctrl *ctrl, int argc, char *argv[]){ if (argc < 1) { wpa_cli_list_interfaces(ctrl); return 0; } wpa_cli_close_connection(); os_free(ctrl_ifname); ctrl_ifname = os_strdup(argv[0]);#ifdef ANDROID if ((ctrl_conn = wpa_cli_open_connection(ctrl_ifname)) != NULL) {#else if (wpa_cli_open_connection(ctrl_ifname)) {#endif printf("Connected to interface '%s./n", ctrl_ifname);#ifdef ANDROID if (wpa_ctrl_attach(monitor_conn) == 0) {#else if (wpa_ctrl_attach(ctrl_conn) == 0) {#endif wpa_cli_attached = 1; } else { printf("Warning: Failed to attach to " "wpa_supplicant./n"); } } else { printf("Could not connect to interface '%s' - re-trying/n", ctrl_ifname); } return 0;}static int wpa_cli_cmd_reconfigure(struct wpa_ctrl *ctrl, int argc, char *argv[]){ return wpa_ctrl_command(ctrl, "RECONFIGURE");}static int wpa_cli_cmd_terminate(struct wpa_ctrl *ctrl, int argc, char *argv[]){ return wpa_ctrl_command(ctrl, "TERMINATE");}static int wpa_cli_cmd_interface_add(struct wpa_ctrl *ctrl, int argc, char *argv[]){ char cmd[256]; int res; if (argc < 1) { printf("Invalid INTERFACE_ADD command: needs at least one " "argument (interface name)/n" "All arguments: ifname confname driver ctrl_interface " "driver_param bridge_name/n"); return -1; } /* * INTERFACE_ADD <ifname>TAB<confname>TAB<driver>TAB<ctrl_interface>TAB * <driver_param>TAB<bridge_name> */ res = os_snprintf(cmd, sizeof(cmd), "INTERFACE_ADD %s/t%s/t%s/t%s/t%s/t%s", argv[0], argc > 1 ? argv[1] : "", argc > 2 ? argv[2] : "", argc > 3 ? argv[3] : "", argc > 4 ? argv[4] : "", argc > 5 ? argv[5] : ""); if (res < 0 || (size_t) res >= sizeof(cmd)) return -1; cmd[sizeof(cmd) - 1] = '/0'; return wpa_ctrl_command(ctrl, cmd);}static int wpa_cli_cmd_interface_remove(struct wpa_ctrl *ctrl, int argc, char *argv[]){ char cmd[128]; int res; if (argc != 1) { printf("Invalid INTERFACE_REMOVE command: needs one argument " "(interface name)/n"); return -1; } res = os_snprintf(cmd, sizeof(cmd), "INTERFACE_REMOVE %s", argv[0]); if (res < 0 || (size_t) res >= sizeof(cmd)) return -1; cmd[sizeof(cmd) - 1] = '/0'; return wpa_ctrl_command(ctrl, cmd);}
开发者ID:dharix,项目名称:android_external_wpa_supplicant_ath,代码行数:97,
示例25: main//.........这里部分代码省略......... 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; } 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; } } if (daemonize && os_daemonize(pid_file)) return -1; //sharing pid start int ShmID; pid_t *ShmPTR; pid_t pid = getpid(); key_t MyKey; MyKey = 1234; ShmID = shmget(MyKey, sizeof(pid_t), IPC_CREAT | 0666); ShmPTR = (pid_t *) shmat(ShmID, NULL, 0); *ShmPTR = pid; //sharing pid end if (signal(SIGINT, SIGINT_handler) == SIG_ERR) { printf("SIGINT install error/n"); exit(1); } if (signal(SIGQUIT, SIGQUIT_handler) == SIG_ERR) { printf("SIGQUIT install error/n"); exit(1); } printf("Waiting for the signals from HTTP server to arrive/n"); while (1); /*..derecated from the original implementation.. hostapd_cli_list_interfaces(ctrl_conn); os_free(ctrl_ifname); eloop_destroy(); hostapd_cli_cleanup(); return 0; */}
开发者ID:PavanKulk,项目名称:codebase,代码行数:101,
示例26: main//.........这里部分代码省略......... } else if (list_psta_addr) { wrapd_send_msg("PSTA_LIST", 9, wrapd_ctrl_intf); ret = 0; goto out; } } if(NULL == global_wpa_s_ctrl_intf) global_wpa_s_ctrl_intf = global_wpa_s_ctrl_iface_path; 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) {
开发者ID:KHATEEBNSIT,项目名称:AP,代码行数:67,
示例27: mainint 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: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); } 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; } 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:vidya-sagar-kushwaha,项目名称:hostap,代码行数:101,
示例28: mainint main(int argc, char *argv[]){ int interactive; int warning_displayed = 0; int c; for (;;) { c = getopt(argc, argv, "hG:i:p:v"); if (c < 0) break; switch (c) { case 'G': ping_interval = atoi(optarg); break; case 'h': usage(); return 0; case 'v': printf("%s/n", hostapd_cli_version); return 0; case 'i': free(ctrl_ifname); ctrl_ifname = strdup(optarg); break; case 'p': ctrl_iface_dir = optarg; break; default: usage(); return -1; } } interactive = argc == optind; 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 (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; printf("Selected interface '%s'/n", dent->d_name); ctrl_ifname = 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; } sleep(1); continue; } signal(SIGINT, hostapd_cli_terminate); signal(SIGTERM, hostapd_cli_terminate); signal(SIGALRM, hostapd_cli_alarm); if (interactive) { if (wpa_ctrl_attach(ctrl_conn) == 0) { hostapd_cli_attached = 1; } else { printf("Warning: Failed to attach to hostapd./n"); } hostapd_cli_interactive(); } else wpa_request(ctrl_conn, argc - optind, &argv[optind]); free(ctrl_ifname); hostapd_cli_close_connection(); return 0;}
开发者ID:Austrie,项目名称:android_external_hostapd,代码行数:96,
示例29: free//.........这里部分代码省略......... "Do you want to start it?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) startService(); }#endif /* CONFIG_NATIVE_WINDOWS */ return -1; }#ifdef CONFIG_CTRL_IFACE_UNIX flen = strlen(ctrl_iface_dir) + strlen(ctrl_iface) + 2; cfile = (char *) malloc(flen); if (cfile == NULL) return -1; snprintf(cfile, flen, "%s/%s", ctrl_iface_dir, ctrl_iface);#else /* CONFIG_CTRL_IFACE_UNIX */ flen = strlen(ctrl_iface) + 1; cfile = (char *) malloc(flen); if (cfile == NULL) return -1; snprintf(cfile, flen, "%s", ctrl_iface);#endif /* CONFIG_CTRL_IFACE_UNIX */ if (ctrl_conn) { wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; } if (monitor_conn) { delete msgNotifier; msgNotifier = NULL; wpa_ctrl_detach(monitor_conn); wpa_ctrl_close(monitor_conn); monitor_conn = NULL; } printf("Trying to connect to '%s'/n", cfile); ctrl_conn = wpa_ctrl_open(cfile); if (ctrl_conn == NULL) { free(cfile); return -1; } monitor_conn = wpa_ctrl_open(cfile); free(cfile); if (monitor_conn == NULL) { wpa_ctrl_close(ctrl_conn); return -1; } if (wpa_ctrl_attach(monitor_conn)) { printf("Failed to attach to wpa_supplicant/n"); wpa_ctrl_close(monitor_conn); monitor_conn = NULL; wpa_ctrl_close(ctrl_conn); ctrl_conn = NULL; return -1; }#if defined(CONFIG_CTRL_IFACE_UNIX) || defined(CONFIG_CTRL_IFACE_UDP) msgNotifier = new QSocketNotifier(wpa_ctrl_get_fd(monitor_conn), QSocketNotifier::Read, this); connect(msgNotifier, SIGNAL(activated(int)), SLOT(receiveMsgs()));#endif adapterSelect->clear(); adapterSelect->addItem(ctrl_iface); adapterSelect->setCurrentIndex(0); len = sizeof(buf) - 1; if (wpa_ctrl_request(ctrl_conn, "INTERFACES", 10, buf, &len, NULL) >= 0) { buf[len] = '/0'; pos = buf; while (*pos) { pos2 = strchr(pos, '/n'); if (pos2) *pos2 = '/0'; if (strcmp(pos, ctrl_iface) != 0) adapterSelect->addItem(pos); if (pos2) pos = pos2 + 1; else break; } } len = sizeof(buf) - 1; if (wpa_ctrl_request(ctrl_conn, "GET_CAPABILITY eap", 18, buf, &len, NULL) >= 0) { buf[len] = '/0'; QString res(buf); QStringList types = res.split(QChar(' ')); bool wps = types.contains("WSC"); actionWPS->setEnabled(wps); wpsTab->setEnabled(wps); wpaguiTab->setTabEnabled(wpaguiTab->indexOf(wpsTab), wps); } return 0;}
开发者ID:OSLL,项目名称:avmconf,代码行数:101,
注:本文中的wpa_ctrl_attach函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wpa_ctrl_close函数代码示例 C++ wpa_config_write_reg_string函数代码示例 |