本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}