aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/ctrl_iface.c
diff options
context:
space:
mode:
authorAnton Nayshtut <qca_antonn@qca.qualcomm.com>2015-07-16 10:29:29 (GMT)
committerJouni Malinen <j@w1.fi>2015-07-16 17:21:18 (GMT)
commit6990d41a748b827f6b5f71b214c579191b41dbd7 (patch)
tree6eae4b0e72f1aa9d6ec9a0790b5e5cc6229f9ced /hostapd/ctrl_iface.c
parent585478e2b9097df4bf4faebc16f5922a8b2e32b0 (diff)
downloadhostap-6990d41a748b827f6b5f71b214c579191b41dbd7.zip
hostap-6990d41a748b827f6b5f71b214c579191b41dbd7.tar.gz
hostap-6990d41a748b827f6b5f71b214c579191b41dbd7.tar.bz2
hostapd: Add global to local control interface redirection
This patch implements global to local control interface redirection in the same way as it's done for wpa_supplicant. Any global control interface command beginning with "IFNAME=..." will be routed to the corresponding local control interface handler. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'hostapd/ctrl_iface.c')
-rw-r--r--hostapd/ctrl_iface.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 73df223..6e7f4f2 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -2581,6 +2581,40 @@ hostapd_global_ctrl_iface_fst_detach(struct hapd_interfaces *interfaces,
#endif /* CONFIG_FST */
+static int hostapd_global_ctrl_iface_ifname(struct hapd_interfaces *interfaces,
+ const char *ifname,
+ char *buf, char *reply,
+ int reply_size,
+ struct sockaddr_un *from,
+ socklen_t fromlen)
+{
+ size_t i, j;
+ struct hostapd_data *hapd = NULL;
+
+ for (i = 0; hapd == NULL && i < interfaces->count; i++) {
+ struct hostapd_iface *iface = interfaces->iface[i];
+
+ for (j = 0; j < iface->num_bss; j++) {
+ hapd = iface->bss[j];
+ if (os_strcmp(ifname, hapd->conf->iface) == 0)
+ break;
+ hapd = NULL;
+ }
+ }
+
+ if (hapd == NULL) {
+ int res;
+
+ res = os_snprintf(reply, reply_size, "FAIL-NO-IFNAME-MATCH\n");
+ if (os_snprintf_error(reply_size, res))
+ return -1;
+ return res;
+ }
+
+ return hostapd_ctrl_iface_receive_process(hapd, buf, reply,reply_size,
+ from, fromlen);
+}
+
static void hostapd_global_ctrl_iface_receive(int sock, void *eloop_ctx,
void *sock_ctx)
@@ -2617,6 +2651,18 @@ static void hostapd_global_ctrl_iface_receive(int sock, void *eloop_ctx,
os_memcpy(reply, "OK\n", 3);
reply_len = 3;
+ if (os_strncmp(buf, "IFNAME=", 7) == 0) {
+ char *pos = os_strchr(buf + 7, ' ');
+
+ if (pos) {
+ *pos++ = '\0';
+ reply_len = hostapd_global_ctrl_iface_ifname(
+ interfaces, buf + 7, pos, reply, reply_size,
+ &from, fromlen);
+ goto send_reply;
+ }
+ }
+
if (os_strcmp(buf, "PING") == 0) {
os_memcpy(reply, "PONG\n", 5);
reply_len = 5;
@@ -2665,6 +2711,7 @@ static void hostapd_global_ctrl_iface_receive(int sock, void *eloop_ctx,
reply_len = -1;
}
+send_reply:
if (reply_len < 0) {
os_memcpy(reply, "FAIL\n", 5);
reply_len = 5;