]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Track interface state
authorJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 15:25:05 +0000 (17:25 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 17:51:06 +0000 (19:51 +0200)
The new hostapd_iface::state enum is used to track the current state of
the hostapd interface (a radio/wiphy).

Signed-hostap: Jouni Malinen <j@w1.fi>

src/ap/acs.c
src/ap/dfs.c
src/ap/hostapd.c
src/ap/hostapd.h
src/ap/hw_features.c

index 12b955c72f4bf549c6bb0231bf8f1a8f863e9119..9ef221ed94986a37dd012f585e8a0341b5bdcec8 100644 (file)
@@ -795,6 +795,7 @@ enum hostapd_chan_status acs_init(struct hostapd_iface *iface)
        if (err < 0)
                return HOSTAPD_CHAN_INVALID;
 
+       hostapd_set_state(iface, HAPD_IFACE_ACS);
        wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, ACS_EVENT_STARTED);
 
        return HOSTAPD_CHAN_ACS;
index 202076a1816812e271330cba8ad3f9bb75a4e076..0ecd2527b53f5677e5491facb327438d1cf98602 100644 (file)
@@ -568,6 +568,7 @@ int hostapd_handle_dfs(struct hostapd_data *hapd)
        } while (res);
 
        /* Finally start CAC */
+       hostapd_set_state(hapd->iface, HAPD_IFACE_DFS);
        wpa_printf(MSG_DEBUG, "DFS start CAC on %d MHz", hapd->iface->freq);
        wpa_msg(hapd->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
                "freq=%d chan=%d sec_chan=%d",
index f41cb145b82ac8e218728c4ba1e0b7eaee58c191..afad8efaab1056a252dec3c339aa3010bcd5037f 100644 (file)
@@ -987,6 +987,7 @@ static int setup_interface(struct hostapd_iface *iface)
        if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
                char country[4], previous_country[4];
 
+               hostapd_set_state(iface, HAPD_IFACE_COUNTRY_UPDATE);
                if (hostapd_get_country(hapd, previous_country) < 0)
                        previous_country[0] = '\0';
 
@@ -1056,6 +1057,7 @@ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
 
        if (err) {
                wpa_printf(MSG_ERROR, "Interface initialization failed");
+               hostapd_set_state(iface, HAPD_IFACE_DISABLED);
                eloop_terminate();
                return -1;
        }
@@ -1153,6 +1155,7 @@ int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err)
                        return -1;
        }
 
+       hostapd_set_state(iface, HAPD_IFACE_ENABLED);
        if (hapd->setup_complete_cb)
                hapd->setup_complete_cb(hapd->setup_complete_cb_ctx);
 
@@ -1535,6 +1538,7 @@ int hostapd_disable_iface(struct hostapd_iface *hapd_iface)
 
        wpa_printf(MSG_DEBUG, "Interface %s disabled",
                   hapd_iface->bss[0]->conf->iface);
+       hostapd_set_state(hapd_iface, HAPD_IFACE_DISABLED);
        return 0;
 }
 
@@ -1890,3 +1894,35 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
        eloop_register_timeout(hapd->conf->ap_max_inactivity, 0,
                               ap_handle_timer, hapd, sta);
 }
+
+
+static const char * hostapd_state_text(enum hostapd_iface_state s)
+{
+       switch (s) {
+       case HAPD_IFACE_UNINITIALIZED:
+               return "UNINITIALIZED";
+       case HAPD_IFACE_DISABLED:
+               return "DISABLED";
+       case HAPD_IFACE_COUNTRY_UPDATE:
+               return "COUNTRY_UPDATE";
+       case HAPD_IFACE_ACS:
+               return "ACS";
+       case HAPD_IFACE_HT_SCAN:
+               return "HT_SCAN";
+       case HAPD_IFACE_DFS:
+               return "DFS";
+       case HAPD_IFACE_ENABLED:
+               return "ENABLED";
+       }
+
+       return "UNKNOWN";
+}
+
+
+void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s)
+{
+       wpa_printf(MSG_INFO, "%s: interface state %s->%s",
+                  iface->conf->bss[0]->iface, hostapd_state_text(iface->state),
+                  hostapd_state_text(s));
+       iface->state = s;
+}
index dacdfa7da1b92d4323f03fe0e1a410f3014e9aec..02f45af6e42da15d93f33b7d6f74592945c9ce7e 100644 (file)
@@ -251,6 +251,16 @@ struct hostapd_iface {
        struct hostapd_config *conf;
        char phy[16]; /* Name of the PHY (radio) */
 
+       enum hostapd_iface_state {
+               HAPD_IFACE_UNINITIALIZED,
+               HAPD_IFACE_DISABLED,
+               HAPD_IFACE_COUNTRY_UPDATE,
+               HAPD_IFACE_ACS,
+               HAPD_IFACE_HT_SCAN,
+               HAPD_IFACE_DFS,
+               HAPD_IFACE_ENABLED
+       } state;
+
        size_t num_bss;
        struct hostapd_data **bss;
 
@@ -364,6 +374,7 @@ int hostapd_disable_iface(struct hostapd_iface *hapd_iface);
 int hostapd_add_iface(struct hapd_interfaces *ifaces, char *buf);
 int hostapd_remove_iface(struct hapd_interfaces *ifaces, char *buf);
 void hostapd_channel_list_updated(struct hostapd_iface *iface);
+void hostapd_set_state(struct hostapd_iface *iface, enum hostapd_iface_state s);
 
 /* utils.c */
 int hostapd_register_probereq_cb(struct hostapd_data *hapd,
index 908d91ebd84db974bf15dca08af0877057f4b589..7c4ef12ca8ad0ff750374dbc40b26cce777bdc70 100644 (file)
@@ -539,6 +539,7 @@ static int ieee80211n_check_40mhz(struct hostapd_iface *iface)
        if (!iface->conf->secondary_channel)
                return 0; /* HT40 not used */
 
+       hostapd_set_state(iface, HAPD_IFACE_HT_SCAN);
        wpa_printf(MSG_DEBUG, "Scan for neighboring BSSes prior to enabling "
                   "40 MHz channel");
        os_memset(&params, 0, sizeof(params));