Passive Client Taxonomy
[mech_eap.git] / src / ap / ctrl_iface_ap.c
index 8a9965b..3680fda 100644 (file)
@@ -23,6 +23,7 @@
 #include "ctrl_iface_ap.h"
 #include "ap_drv_ops.h"
 #include "mbo_ap.h"
+#include "taxonomy.h"
 
 
 static int hostapd_get_sta_tx_rx(struct hostapd_data *hapd,
@@ -258,7 +259,7 @@ static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
        int ret;
        u8 *pos;
 
-       if (hapd->driver->send_frame == NULL)
+       if (!hapd->drv_priv || !hapd->driver->send_frame)
                return -1;
 
        mgmt = os_zalloc(sizeof(*mgmt) + 100);
@@ -269,7 +270,7 @@ static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
        wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "P2P: Disconnect STA " MACSTR
                " with minor reason code %u (stype=%u (%s))",
                MAC2STR(addr), minor_reason_code, stype,
-               fc2str(mgmt->frame_control));
+               fc2str(le_to_host16(mgmt->frame_control)));
 
        os_memcpy(mgmt->da, addr, ETH_ALEN);
        os_memcpy(mgmt->sa, hapd->own_addr, ETH_ALEN);
@@ -325,7 +326,7 @@ int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
        if (pos) {
                struct ieee80211_mgmt mgmt;
                int encrypt;
-               if (hapd->driver->send_frame == NULL)
+               if (!hapd->drv_priv || !hapd->driver->send_frame)
                        return -1;
                pos += 6;
                encrypt = atoi(pos);
@@ -352,7 +353,10 @@ int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
        }
 #endif /* CONFIG_P2P_MANAGER */
 
-       hostapd_drv_sta_deauth(hapd, addr, reason);
+       if (os_strstr(txtaddr, " tx=0"))
+               hostapd_drv_sta_remove(hapd, addr);
+       else
+               hostapd_drv_sta_deauth(hapd, addr, reason);
        sta = ap_get_sta(hapd, addr);
        if (sta)
                ap_sta_deauthenticate(hapd, sta, reason);
@@ -385,7 +389,7 @@ int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
        if (pos) {
                struct ieee80211_mgmt mgmt;
                int encrypt;
-               if (hapd->driver->send_frame == NULL)
+               if (!hapd->drv_priv || !hapd->driver->send_frame)
                        return -1;
                pos += 6;
                encrypt = atoi(pos);
@@ -412,7 +416,10 @@ int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
        }
 #endif /* CONFIG_P2P_MANAGER */
 
-       hostapd_drv_sta_disassoc(hapd, addr, reason);
+       if (os_strstr(txtaddr, " tx=0"))
+               hostapd_drv_sta_remove(hapd, addr);
+       else
+               hostapd_drv_sta_disassoc(hapd, addr, reason);
        sta = ap_get_sta(hapd, addr);
        if (sta)
                ap_sta_disassociate(hapd, sta, reason);
@@ -423,6 +430,49 @@ int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
 }
 
 
+#ifdef CONFIG_TAXONOMY
+int hostapd_ctrl_iface_signature(struct hostapd_data *hapd,
+                                const char *txtaddr,
+                                char *buf, size_t buflen)
+{
+       u8 addr[ETH_ALEN];
+       struct sta_info *sta;
+
+       wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "CTRL_IFACE SIGNATURE %s", txtaddr);
+
+       if (hwaddr_aton(txtaddr, addr))
+               return -1;
+
+       sta = ap_get_sta(hapd, addr);
+       if (!sta)
+               return -1;
+
+       return retrieve_sta_taxonomy(hapd, sta, buf, buflen);
+}
+#endif /* CONFIG_TAXONOMY */
+
+
+int hostapd_ctrl_iface_poll_sta(struct hostapd_data *hapd,
+                               const char *txtaddr)
+{
+       u8 addr[ETH_ALEN];
+       struct sta_info *sta;
+
+       wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "CTRL_IFACE POLL_STA %s", txtaddr);
+
+       if (hwaddr_aton(txtaddr, addr))
+               return -1;
+
+       sta = ap_get_sta(hapd, addr);
+       if (!sta)
+               return -1;
+
+       hostapd_drv_poll_client(hapd, hapd->own_addr, addr,
+                               sta->flags & WLAN_STA_WMM);
+       return 0;
+}
+
+
 int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
                              size_t buflen)
 {
@@ -487,20 +537,28 @@ int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
                          "channel=%u\n"
                          "secondary_channel=%d\n"
                          "ieee80211n=%d\n"
-                         "ieee80211ac=%d\n"
-                         "vht_oper_chwidth=%d\n"
-                         "vht_oper_centr_freq_seg0_idx=%d\n"
-                         "vht_oper_centr_freq_seg1_idx=%d\n",
+                         "ieee80211ac=%d\n",
                          iface->conf->channel,
-                         iface->conf->secondary_channel,
-                         iface->conf->ieee80211n,
-                         iface->conf->ieee80211ac,
-                         iface->conf->vht_oper_chwidth,
-                         iface->conf->vht_oper_centr_freq_seg0_idx,
-                         iface->conf->vht_oper_centr_freq_seg1_idx);
+                         iface->conf->ieee80211n && !hapd->conf->disable_11n ?
+                         iface->conf->secondary_channel : 0,
+                         iface->conf->ieee80211n && !hapd->conf->disable_11n,
+                         iface->conf->ieee80211ac &&
+                         !hapd->conf->disable_11ac);
        if (os_snprintf_error(buflen - len, ret))
                return len;
        len += ret;
+       if (iface->conf->ieee80211ac && !hapd->conf->disable_11ac) {
+               ret = os_snprintf(buf + len, buflen - len,
+                                 "vht_oper_chwidth=%d\n"
+                                 "vht_oper_centr_freq_seg0_idx=%d\n"
+                                 "vht_oper_centr_freq_seg1_idx=%d\n",
+                                 iface->conf->vht_oper_chwidth,
+                                 iface->conf->vht_oper_centr_freq_seg0_idx,
+                                 iface->conf->vht_oper_centr_freq_seg1_idx);
+               if (os_snprintf_error(buflen - len, ret))
+                       return len;
+               len += ret;
+       }
 
        for (i = 0; i < iface->num_bss; i++) {
                struct hostapd_data *bss = iface->bss[i];