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


C++ wpa_ctrl_close函数代码示例

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


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

示例1: wifi_close_supplicant_connection

void wifi_close_supplicant_connection()
{
    char supp_status[PROPERTY_VALUE_MAX] = {'\0'};
    int count = 50; /* wait at most 5 seconds to ensure init has stopped stupplicant */

    if (ctrl_conn != NULL) {
        wpa_ctrl_close(ctrl_conn);
        ctrl_conn = NULL;
    }
    if (monitor_conn != NULL) {
        wpa_ctrl_close(monitor_conn);
        monitor_conn = NULL;
    }

    if (exit_sockets[0] >= 0) {
        close(exit_sockets[0]);
        exit_sockets[0] = -1;
    }

    if (exit_sockets[1] >= 0) {
        close(exit_sockets[1]);
        exit_sockets[1] = -1;
    }

    while (count-- > 0) {
        if (property_get(SUPP_PROP_NAME, supp_status, NULL)) {
            if (strcmp(supp_status, "stopped") == 0)
                return;
        }
        usleep(100000);
    }
}
开发者ID:classicnerd,项目名称:android_hardware_libhardware_legacy,代码行数:32,代码来源:wifi.c

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

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

示例4: wifi_close_supplicant_connection

void wifi_close_supplicant_connection()
{
    if (ctrl_conn != NULL) {
        wpa_ctrl_close(ctrl_conn);
        ctrl_conn = NULL;
    }
    if (monitor_conn != NULL) {
        wpa_ctrl_close(monitor_conn);
        monitor_conn = NULL;
    }
}
开发者ID:TooLogic,项目名称:allwinner_board_files,代码行数:11,代码来源:wifi.c

示例5: wpa_ctrl_detach

WpaGui::~WpaGui()
{
	delete msgNotifier;

	if (monitor_conn) {
		wpa_ctrl_detach(monitor_conn);
		wpa_ctrl_close(monitor_conn);
		monitor_conn = NULL;
	}
	if (ctrl_conn) {
		wpa_ctrl_close(ctrl_conn);
		ctrl_conn = NULL;
	}

	if (eh) {
		eh->close();
		delete eh;
		eh = NULL;
	}

	if (scanres) {
		scanres->close();
		delete scanres;
		scanres = NULL;
	}

	if (peers) {
		peers->close();
		delete peers;
		peers = NULL;
	}

	if (add_iface) {
		add_iface->close();
		delete add_iface;
		add_iface = NULL;
	}

	if (udr) {
		udr->close();
		delete udr;
		udr = NULL;
	}

	free(ctrl_iface);
	ctrl_iface = NULL;

	free(ctrl_iface_dir);
	ctrl_iface_dir = NULL;
}
开发者ID:OSLL,项目名称:avmconf,代码行数:50,代码来源:wpagui.cpp

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

示例7: wpa_cli_close_connection

static void wpa_cli_close_connection(void)
{
	if (ctrl_conn == NULL)
		return;

	if (wpa_cli_attached) {
		wpa_ctrl_detach(monitor_conn);
		wpa_cli_attached = 0;
	}
#ifdef CTRL_INTERFACE_2_SOCKETS
	wpa_ctrl_close(monitor_conn);
#endif
	wpa_ctrl_close(ctrl_conn);
	ctrl_conn = monitor_conn = NULL;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:15,代码来源:wpa_cli.c

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

示例9: wait_ip_addr

int wait_ip_addr(const char *ifname, int timeout)
{
	char ip[30];
	int count = timeout;
	struct wpa_ctrl *ctrl;

	while (count > 0) {
		printf("%s: ifname='%s' - %d seconds remaining\n",
		       __func__, ifname, count);
		count--;
		if (get_wpa_status(ifname, "ip_address", ip, sizeof(ip)) == 0
		    && strlen(ip) > 0) {
			printf("IP address found: '%s'\n", ip);
			return 0;
		}
		ctrl = wpa_open_ctrl(ifname);
		if (ctrl == NULL)
			return -1;
		wpa_ctrl_close(ctrl);
		sleep(1);
	}
	printf("%s: Could not get IP address for ifname='%s'", __func__,
	       ifname);
	return -1;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:25,代码来源:wpa_helpers.c

示例10: DBGMSG_M

void WiFiNode::close() {
	if (wpaCtrl) {
		DBGMSG_M("Closing [%p]", wpaCtrl);
		wpa_ctrl_close(wpaCtrl);
		wpaCtrl = nullptr;
	}
}
开发者ID:schapa,项目名称:OrangeWiFi,代码行数:7,代码来源:WiFiNode.cpp

示例11: get_wpa_status

int get_wpa_status(const char *ifname, const char *field, char *obuf,
		   size_t obuf_size)
{
	struct wpa_ctrl *ctrl;
	char buf[4096];
	char *pos, *end;
	size_t len, flen;

	ctrl = wpa_open_ctrl(ifname);
	if (ctrl == NULL)
		return -1;
	len = sizeof(buf);
	if (wpa_ctrl_request(ctrl, "STATUS", 6, buf, &len, NULL) < 0) {
		wpa_ctrl_close(ctrl);
		return -1;
	}
	wpa_ctrl_close(ctrl);
	buf[len] = '\0';

	flen = strlen(field);
	pos = buf;
	while (pos + flen < buf + len) {
		if (pos > buf) {
			if (*pos != '\n') {
				pos++;
				continue;
			}
			pos++;
		}
		if (strncmp(pos, field, flen) != 0 || pos[flen] != '=') {
			pos++;
			continue;
		}
		pos += flen + 1;
		end = strchr(pos, '\n');
		if (end == NULL)
			return -1;
		*end++ = '\0';
		if (end - pos > (int) obuf_size)
			return -1;
		memcpy(obuf, pos, end - pos);
		return 0;
	}

	return -1;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:46,代码来源:wpa_helpers.c

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

示例13: pthread_join

wifi_manager::~wifi_manager() {

	_is_running = false;

	pthread_join(_thread,NULL);

	clear();

	if(_ctrl)
		wpa_ctrl_close(_ctrl);
	
	if(_event_ctrl)
		wpa_ctrl_close(_event_ctrl);
	
	if(_buffer)
		delete[] _buffer;
}
开发者ID:ChangerR,项目名称:Amusement-Machine-Software,代码行数:17,代码来源:wifi_manager.cpp

示例14: snprintf

void AddInterface::interfaceSelected(QTreeWidgetItem *sel)
{
	if (!sel)
		return;

#ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
	struct wpa_ctrl *ctrl;
	int ret;
	char buf[20], cmd[256];
	size_t len;

	/*
	 * INTERFACE_ADD <ifname>TAB<confname>TAB<driver>TAB<ctrl_interface>TAB
	 * <driver_param>TAB<bridge_name>
	 */
	snprintf(cmd, sizeof(cmd),
		 "INTERFACE_ADD %s\t%s\t%s\t%s\t%s\t%s",
		 sel->text(1).toAscii().constData(),
		 "default",
		 sel->text(0).toAscii().constData(),
		 "yes", "", "");
	cmd[sizeof(cmd) - 1] = '\0';

	ctrl = wpa_ctrl_open(NULL);
	if (ctrl == NULL)
		return;

	len = sizeof(buf) - 1;
	ret = wpa_ctrl_request(ctrl, cmd, strlen(cmd), buf, &len, NULL);
	wpa_ctrl_close(ctrl);

	if (ret < 0) {
		QMessageBox::warning(this, "wpa_gui",
				     tr("Add interface command could not be "
					"completed."));
		return;
	}

	buf[len] = '\0';
	if (buf[0] != 'O' || buf[1] != 'K') {
		QMessageBox::warning(this, "wpa_gui",
				     tr("Failed to add the interface."));
		return;
	}

#endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */

#ifdef CONFIG_NATIVE_WINDOWS
	if (!addRegistryInterface(sel->text(1))) {
		QMessageBox::information(this, "wpa_gui",
					 tr("Failed to add the interface into "
					    "registry."));
	}
#endif /* CONFIG_NATIVE_WINDOWS */

	wpagui->selectAdapter(sel->text(1));
	close();
}
开发者ID:pliniofpa,项目名称:wpa_gui,代码行数:58,代码来源:addinterface.cpp

示例15: wpa_ctrl_open

void AddInterface::addInterfaces()
{
#ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
	struct wpa_ctrl *ctrl;
	int ret;
	char buf[2048];
	size_t len;

	ctrl = wpa_ctrl_open(NULL);
	if (ctrl == NULL)
		return;

	len = sizeof(buf) - 1;
	ret = wpa_ctrl_request(ctrl, "INTERFACE_LIST", 14, buf, &len, NULL);
	if (ret < 0) {
		wpa_ctrl_close(ctrl);
		return;
	}
	buf[len] = '\0';

	wpa_ctrl_close(ctrl);

	QString ifaces(buf);
	QStringList lines = ifaces.split(QRegExp("\\n"));
	for (QStringList::Iterator it = lines.begin();
	     it != lines.end(); it++) {
		QStringList arg = (*it).split(QChar('\t'));
		if (arg.size() < 3)
			continue;
		QTreeWidgetItem *item = new QTreeWidgetItem(interfaceWidget);
		if (!item)
			break;

		item->setText(0, arg[0]);
		item->setText(1, arg[1]);
		item->setText(2, arg[2]);
	}

	interfaceWidget->resizeColumnToContents(0);
	interfaceWidget->resizeColumnToContents(1);
	interfaceWidget->resizeColumnToContents(2);
#endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */
}
开发者ID:pliniofpa,项目名称:wpa_gui,代码行数:43,代码来源:addinterface.cpp


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