hostapd: Introduce hostapd_interfaces_get_hapd()
authorAnton Nayshtut <qca_antonn@qca.qualcomm.com>
Sun, 19 Jul 2015 09:13:23 +0000 (12:13 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 21 Jul 2015 10:24:36 +0000 (13:24 +0300)
This function will be used in DUP_NETWORK command implementation.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hostapd/ctrl_iface.c

index 5ef3597..43ed6d7 100644 (file)
@@ -2589,27 +2589,39 @@ 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)
+
+static struct hostapd_data *
+hostapd_interfaces_get_hapd(struct hapd_interfaces *interfaces,
+                           const char *ifname)
 {
        size_t i, j;
-       struct hostapd_data *hapd = NULL;
 
-       for (i = 0; hapd == NULL && i < interfaces->count; i++) {
+       for (i = 0; i < interfaces->count; i++) {
                struct hostapd_iface *iface = interfaces->iface[i];
 
                for (j = 0; j < iface->num_bss; j++) {
+                       struct hostapd_data *hapd;
+
                        hapd = iface->bss[j];
                        if (os_strcmp(ifname, hapd->conf->iface) == 0)
-                               break;
-                       hapd = NULL;
+                               return hapd;
                }
        }
 
+       return NULL;
+}
+
+
+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)
+{
+       struct hostapd_data *hapd;
+
+       hapd = hostapd_interfaces_get_hapd(interfaces, ifname);
        if (hapd == NULL) {
                int res;