本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例10: DBGMSG_M
void WiFiNode::close() {
if (wpaCtrl) {
DBGMSG_M("Closing [%p]", wpaCtrl);
wpa_ctrl_close(wpaCtrl);
wpaCtrl = nullptr;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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 */
}