aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
authorAnton Nayshtut <qca_antonn@qca.qualcomm.com>2015-07-16 13:29:29 +0300
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:19:44 -0600
commit7e3a07cccaf3fafd17bd25e9f83f956448280340 (patch)
tree171023bbd05013cf0d022ba4fa7ae02ee59740ff /hostapd
parentd408683a5f11dfc3406afac6ac427ccfd73832cf (diff)
downloadandroid_external_wpa_supplicant_8-7e3a07cccaf3fafd17bd25e9f83f956448280340.tar.gz
android_external_wpa_supplicant_8-7e3a07cccaf3fafd17bd25e9f83f956448280340.tar.bz2
android_external_wpa_supplicant_8-7e3a07cccaf3fafd17bd25e9f83f956448280340.zip
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. Change-Id: I3787dd0fbccc010dddff0f4e57717e7861e186ec Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com> Git-commit: 6990d41a748b827f6b5f71b214c579191b41dbd7 Git-repo: git://w1.fi/srv/git/hostap.git CRs-Fixed: 891455
Diffstat (limited to 'hostapd')
-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 94073937..f83d3c04 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -2489,6 +2489,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)
@@ -2525,6 +2559,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;
@@ -2573,6 +2619,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;