[PATCH v5 13/25] hostapd: add INTERFACES ctrl command

Janusz Dziedzic janusz.dziedzic at tieto.com
Fri Mar 4 01:20:29 PST 2016


Print available interfaces with ctrl_iface when
INTERFACES ctrl param send.
This is useful in case we using UDP CTRL and add
interface using ADD command. After that we need to
know which udp port we should use for this new
added interface.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 hostapd/ctrl_iface.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 795a5e5..767a508 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -2931,6 +2931,44 @@ error_return:
 
 
 static int
+hostapd_global_ctrl_iface_interfaces(struct hapd_interfaces *interfaces,
+				     const char *input,
+				     char *reply, int reply_size)
+{
+	int i, j, 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++) {
+			if (show_ctrl)
+				res = os_snprintf(pos, end - pos, "%s ctrl_iface=%s\n",
+						  iface->conf->bss[j]->iface,
+						  iface->conf->bss[j]->ctrl_interface);
+			else
+				res = os_snprintf(pos, end - pos, "%s\n",
+						  iface->conf->bss[j]->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)
 {
@@ -3132,6 +3170,11 @@ 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");
-- 
1.9.1




More information about the Hostap mailing list