aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/ctrl_iface.c
diff options
context:
space:
mode:
authorJanusz Dziedzic <janusz.dziedzic@tieto.com>2016-03-04 09:20:29 (GMT)
committerJouni Malinen <j@w1.fi>2016-03-05 15:44:50 (GMT)
commit618f5d01b0cf1fa3a591470c90a6a69f92880ecf (patch)
tree7461521d2a00153de6d1f42c7c0bdd8890aa4709 /hostapd/ctrl_iface.c
parent180e5b96c3c880296292558342760be0530b90db (diff)
downloadhostap-618f5d01b0cf1fa3a591470c90a6a69f92880ecf.zip
hostap-618f5d01b0cf1fa3a591470c90a6a69f92880ecf.tar.gz
hostap-618f5d01b0cf1fa3a591470c90a6a69f92880ecf.tar.bz2
hostapd: Add INTERFACES ctrl_iface command
Return a list of the available interfaces (the main BSS) and optionally with ctrl_iface when the optional "ctrl" parameter is included. This is useful when using UDP ctrl_iface and add interfaces using the ADD command. After that we need to know which UDP port was assigned for the control interface for the added interface. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
Diffstat (limited to 'hostapd/ctrl_iface.c')
-rw-r--r--hostapd/ctrl_iface.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index b54d013..debf28c 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -2921,6 +2921,51 @@ error_return:
static int
+hostapd_global_ctrl_iface_interfaces(struct hapd_interfaces *interfaces,
+ const char *input,
+ char *reply, int reply_size)
+{
+ size_t i, j;
+ int res;
+ char *pos, *end;
+ struct hostapd_iface *iface;
+ int show_ctrl = 0;
+
+ if (input)
+ show_ctrl = !!os_strstr(input, "ctrl");
+
+ pos = reply;
+ end = reply + reply_size;
+
+ for (i = 0; i < interfaces->count; i++) {
+ iface = interfaces->iface[i];
+
+ for (j = 0; j < iface->num_bss; j++) {
+ struct hostapd_bss_config *conf;
+
+ conf = iface->conf->bss[j];
+ if (show_ctrl)
+ res = os_snprintf(pos, end - pos,
+ "%s ctrl_iface=%s\n",
+ conf->iface,
+ conf->ctrl_interface ?
+ conf->ctrl_interface : "N/A");
+ else
+ res = os_snprintf(pos, end - pos, "%s\n",
+ conf->iface);
+ if (os_snprintf_error(end - pos, res)) {
+ *pos = '\0';
+ return pos - reply;
+ }
+ pos += res;
+ }
+ }
+
+ return pos - reply;
+}
+
+
+static int
hostapd_global_ctrl_iface_dup_network(struct hapd_interfaces *interfaces,
char *cmd)
{
@@ -3116,6 +3161,9 @@ static void hostapd_global_ctrl_iface_receive(int sock, void *eloop_ctx,
reply_len = os_snprintf(reply, reply_size, "OK\n");
else
reply_len = -1;
+ } else if (os_strncmp(buf, "INTERFACES", 10) == 0) {
+ reply_len = hostapd_global_ctrl_iface_interfaces(
+ interfaces, buf + 10, reply, sizeof(buffer));
} else {
wpa_printf(MSG_DEBUG, "Unrecognized global ctrl_iface command "
"ignored");