]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Verify hostapd_setup_bss calls
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 6 Nov 2013 11:39:41 +0000 (13:39 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 6 Nov 2013 13:41:05 +0000 (15:41 +0200)
Reject multiple calls to hostapd_setup_bss() for any specific interface.
hostapd_cleanup() must have been called first before trying to restart a
BSS.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/ap/hostapd.c
src/ap/hostapd.h

index a04307cb8b38d6ce332d30df726bbec248e74531..9306f50e5d04448ed0c83f718a268ced937a4f02 100644 (file)
@@ -300,11 +300,13 @@ static void hostapd_free_hapd_data(struct hostapd_data *hapd)
  */
 static void hostapd_cleanup(struct hostapd_data *hapd)
 {
-       wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
+       wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s))", __func__, hapd,
+                  hapd->conf->iface);
        if (hapd->iface->interfaces &&
            hapd->iface->interfaces->ctrl_iface_deinit)
                hapd->iface->interfaces->ctrl_iface_deinit(hapd);
        hostapd_free_hapd_data(hapd);
+       hapd->started = 0;
 }
 
 
@@ -621,6 +623,16 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
        char force_ifname[IFNAMSIZ];
        u8 if_addr[ETH_ALEN];
 
+       wpa_printf(MSG_DEBUG, "%s(hapd=%p (%s), first=%d)",
+                  __func__, hapd, hapd->conf->iface, first);
+
+       if (hapd->started) {
+               wpa_printf(MSG_ERROR, "%s: Interface %s was already started",
+                          __func__, hapd->conf->iface);
+               return -1;
+       }
+       hapd->started = 1;
+
        if (!first || first == -1) {
                if (hostapd_mac_comp_empty(hapd->conf->bssid) == 0) {
                        /* Allocate the next available BSSID. */
index e39a1fdb9c6653917115004bd7bef6900377e3ac..1887531f9364777844d4afe4387a657f9581b448 100644 (file)
@@ -102,6 +102,7 @@ struct hostapd_data {
        struct hostapd_config *iconf;
        struct hostapd_bss_config *conf;
        int interface_added; /* virtual interface added for this BSS */
+       unsigned int started:1;
 
        u8 own_addr[ETH_ALEN];