WMM AC: Add wmm_ac_status control interface command
authorMoshe Benji <Moshe.Benji@intel.com>
Wed, 22 Oct 2014 12:04:02 +0000 (08:04 -0400)
committerJouni Malinen <j@w1.fi>
Sun, 16 Nov 2014 19:40:51 +0000 (21:40 +0200)
This wmm_ac_status command will show the current status for WMM AC.

Signed-off-by: Moshe Benji <moshe.benji@intel.com>
Signed-off-by: Eliad Peller <eliad@wizery.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/wmm_ac.c
wpa_supplicant/wmm_ac.h
wpa_supplicant/wpa_cli.c

index 607a61b..4bd9986 100644 (file)
@@ -7354,6 +7354,8 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s,
                if (wpa_supplicant_ctrl_iface_tdls_teardown(wpa_s, buf + 14))
                        reply_len = -1;
 #endif /* CONFIG_TDLS */
+       } else if (os_strcmp(buf, "WMM_AC_STATUS") == 0) {
+               reply_len = wpas_wmm_ac_status(wpa_s, reply, reply_size);
        } else if (os_strncmp(buf, "WMM_AC_ADDTS ", 13) == 0) {
                if (wmm_ac_ctrl_addts(wpa_s, buf + 13))
                        reply_len = -1;
index b576abe..b26b8aa 100644 (file)
@@ -817,3 +817,94 @@ void wmm_ac_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
                break;
        }
 }
+
+
+static const char * get_ac_str(u8 ac)
+{
+       switch (ac) {
+       case WMM_AC_BE:
+               return "BE";
+       case WMM_AC_BK:
+               return "BK";
+       case WMM_AC_VI:
+               return "VI";
+       case WMM_AC_VO:
+               return "VO";
+       default:
+               return "N/A";
+       }
+}
+
+
+static const char * get_direction_str(u8 direction)
+{
+       switch (direction) {
+       case WMM_AC_DIR_DOWNLINK:
+               return "Downlink";
+       case WMM_AC_DIR_UPLINK:
+               return "Uplink";
+       case WMM_AC_DIR_BIDIRECTIONAL:
+               return "Bi-directional";
+       default:
+               return "N/A";
+       }
+}
+
+
+int wpas_wmm_ac_status(struct wpa_supplicant *wpa_s, char *buf, size_t buflen)
+{
+       struct wmm_ac_assoc_data *assoc_info = wpa_s->wmm_ac_assoc_info;
+       enum ts_dir_idx idx;
+       int pos = 0;
+       u8 ac;
+
+       if (!assoc_info) {
+               return wpa_scnprintf(buf, buflen - pos,
+                                    "Not associated to a WMM AP, WMM AC is Disabled\n");
+       }
+
+       pos += wpa_scnprintf(buf + pos, buflen - pos, "WMM AC is Enabled\n");
+
+       for (ac = 0; ac < WMM_AC_NUM; ac++) {
+               int ts_count = 0;
+
+               pos += wpa_scnprintf(buf + pos, buflen - pos,
+                                    "%s: acm=%d uapsd=%d\n",
+                                    get_ac_str(ac),
+                                    assoc_info->ac_params[ac].acm,
+                                    assoc_info->ac_params[ac].uapsd);
+
+               for (idx = 0; idx < TS_DIR_IDX_COUNT; idx++) {
+                       struct wmm_tspec_element *tspec;
+                       u8 dir, tsid;
+                       const char *dir_str;
+
+                       tspec = wpa_s->tspecs[ac][idx];
+                       if (!tspec)
+                               continue;
+
+                       ts_count++;
+
+                       dir = wmm_ac_get_direction(tspec);
+                       dir_str = get_direction_str(dir);
+                       tsid = wmm_ac_get_tsid(tspec);
+
+                       pos += wpa_scnprintf(buf + pos, buflen - pos,
+                                            "\tTSID = %u\n"
+                                            "\tAddress = "MACSTR"\n"
+                                            "\tWMM AC dir = %s\n"
+                                            "\tTotal admitted time = %u\n\n",
+                                            tsid,
+                                            MAC2STR(wpa_s->bssid),
+                                            dir_str,
+                                            le_to_host16(tspec->medium_time));
+               }
+
+               if (!ts_count) {
+                       pos += wpa_scnprintf(buf + pos, buflen - pos,
+                                            "\t(No Traffic Stream)\n\n");
+               }
+       }
+
+       return pos;
+}
index c831e5b..2b02025 100644 (file)
@@ -168,5 +168,6 @@ int wpas_wmm_ac_addts(struct wpa_supplicant *wpa_s,
 int wpas_wmm_ac_delts(struct wpa_supplicant *wpa_s, u8 tsid);
 void wmm_ac_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
                        const u8 *sa, const u8 *data, size_t len);
+int wpas_wmm_ac_status(struct wpa_supplicant *wpa_s, char *buf, size_t buflen);
 
 #endif /* WMM_AC_H */
index 311cd1f..7d456ae 100644 (file)
@@ -2412,6 +2412,13 @@ static int wpa_cli_cmd_wmm_ac_delts(struct wpa_ctrl *ctrl, int argc,
 }
 
 
+static int wpa_cli_cmd_wmm_ac_status(struct wpa_ctrl *ctrl, int argc,
+                                   char *argv[])
+{
+       return wpa_ctrl_command(ctrl, "WMM_AC_STATUS");
+}
+
+
 static int wpa_cli_cmd_signal_poll(struct wpa_ctrl *ctrl, int argc,
                                   char *argv[])
 {
@@ -2969,6 +2976,9 @@ static struct wpa_cli_cmd wpa_cli_commands[] = {
        { "wmm_ac_delts", wpa_cli_cmd_wmm_ac_delts, NULL,
          cli_cmd_flag_none,
          "<tsid> = delete WMM-AC traffic stream" },
+       { "wmm_ac_status", wpa_cli_cmd_wmm_ac_status, NULL,
+         cli_cmd_flag_none,
+         "= show status for Wireless Multi-Media Admission-Control" },
        { "signal_poll", wpa_cli_cmd_signal_poll, NULL,
          cli_cmd_flag_none,
          "= get signal parameters" },