mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-31 01:04:03 -05:00
wpa_cli: Add support for remote access
wpa_cli can be used now as a client for remote access to ctrl_interface of wpa_supplicant when UDP and remote options are used. You can simply run: wpa_cli -i <hostname>:[port] wpa_cli -i <IP>:[port] Signed-hostap: Janusz Dziedzic <janusz.dziedzic@tieto.com>
This commit is contained in:
parent
afadf423db
commit
d302edd3c4
@ -15,6 +15,9 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif /* CONFIG_CTRL_IFACE_UNIX */
|
#endif /* CONFIG_CTRL_IFACE_UNIX */
|
||||||
|
#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
|
||||||
|
#include <netdb.h>
|
||||||
|
#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@ -246,6 +249,9 @@ struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path)
|
|||||||
struct wpa_ctrl *ctrl;
|
struct wpa_ctrl *ctrl;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
size_t len;
|
size_t len;
|
||||||
|
#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
|
||||||
|
struct hostent *h;
|
||||||
|
#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
|
||||||
|
|
||||||
ctrl = os_malloc(sizeof(*ctrl));
|
ctrl = os_malloc(sizeof(*ctrl));
|
||||||
if (ctrl == NULL)
|
if (ctrl == NULL)
|
||||||
@ -260,7 +266,11 @@ struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctrl->local.sin_family = AF_INET;
|
ctrl->local.sin_family = AF_INET;
|
||||||
|
#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
|
||||||
|
ctrl->local.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
#else /* CONFIG_CTRL_IFACE_UDP_REMOTE */
|
||||||
ctrl->local.sin_addr.s_addr = htonl((127 << 24) | 1);
|
ctrl->local.sin_addr.s_addr = htonl((127 << 24) | 1);
|
||||||
|
#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
|
||||||
if (bind(ctrl->s, (struct sockaddr *) &ctrl->local,
|
if (bind(ctrl->s, (struct sockaddr *) &ctrl->local,
|
||||||
sizeof(ctrl->local)) < 0) {
|
sizeof(ctrl->local)) < 0) {
|
||||||
close(ctrl->s);
|
close(ctrl->s);
|
||||||
@ -271,6 +281,40 @@ struct wpa_ctrl * wpa_ctrl_open(const char *ctrl_path)
|
|||||||
ctrl->dest.sin_family = AF_INET;
|
ctrl->dest.sin_family = AF_INET;
|
||||||
ctrl->dest.sin_addr.s_addr = htonl((127 << 24) | 1);
|
ctrl->dest.sin_addr.s_addr = htonl((127 << 24) | 1);
|
||||||
ctrl->dest.sin_port = htons(WPA_CTRL_IFACE_PORT);
|
ctrl->dest.sin_port = htons(WPA_CTRL_IFACE_PORT);
|
||||||
|
|
||||||
|
#ifdef CONFIG_CTRL_IFACE_UDP_REMOTE
|
||||||
|
if (ctrl_path) {
|
||||||
|
char *port, *name;
|
||||||
|
int port_id;
|
||||||
|
|
||||||
|
name = os_strdup(ctrl_path);
|
||||||
|
if (name == NULL) {
|
||||||
|
close(ctrl->s);
|
||||||
|
os_free(ctrl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
port = os_strchr(name, ':');
|
||||||
|
|
||||||
|
if (port) {
|
||||||
|
port_id = atoi(&port[1]);
|
||||||
|
port[0] = '\0';
|
||||||
|
} else
|
||||||
|
port_id = WPA_CTRL_IFACE_PORT;
|
||||||
|
|
||||||
|
h = gethostbyname(name);
|
||||||
|
os_free(name);
|
||||||
|
if (h == NULL) {
|
||||||
|
perror("gethostbyname");
|
||||||
|
close(ctrl->s);
|
||||||
|
os_free(ctrl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
ctrl->dest.sin_port = htons(port_id);
|
||||||
|
os_memcpy(h->h_addr, (char *) &ctrl->dest.sin_addr.s_addr,
|
||||||
|
h->h_length);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CTRL_IFACE_UDP_REMOTE */
|
||||||
|
|
||||||
if (connect(ctrl->s, (struct sockaddr *) &ctrl->dest,
|
if (connect(ctrl->s, (struct sockaddr *) &ctrl->dest,
|
||||||
sizeof(ctrl->dest)) < 0) {
|
sizeof(ctrl->dest)) < 0) {
|
||||||
perror("connect");
|
perror("connect");
|
||||||
|
Loading…
Reference in New Issue
Block a user