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


C++ wpa_ctrl_attach函数代码示例

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


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

示例2: LOGW

int 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,代码来源:Supplicant.cpp

示例3: DBGMSG_ERR

bool 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,代码来源:WiFiNode.cpp

示例4: wifi_connect_to_supplicant

int 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,代码来源:wifi_realtek.c

示例5: hostapd_cli_cmd_interface

static 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,代码来源:hostapd_cli.c

示例6: wpa_cli_cmd_interface

static 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,代码来源:wpa_cli.c

示例7: wpa_ctrl_open

bool 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,代码来源:wifi_manager.cpp

示例8: hostapd_cli_reconnect

static 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,代码来源:hostapd_cli.c

示例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,代码来源:wpatalk.c

示例10: open_wpa_mon

struct 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,代码来源:wpa_helpers.c

示例11: wpa_cli_reconnect

static 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,代码来源:wpa_cli.c

示例12: wifi_connect_to_supplicant

int 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,代码来源:wifi_unifi.c

示例13: wifi_connect_to_supplicant

int 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,代码来源:wifi.c

示例14: main

int 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,代码来源:wpa_ex.c

示例15: wifi_connect_to_supplicant

int 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,代码来源:wifi.c


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