2 * Wi-Fi Multimedia Admission Control (WMM-AC)
3 * Copyright(c) 2014, Intel Mobile Communication GmbH.
4 * Copyright(c) 2014, Intel Corporation. All rights reserved.
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
12 #include "utils/common.h"
13 #include "common/ieee802_11_common.h"
14 #include "wpa_supplicant_i.h"
19 static struct wmm_ac_assoc_data *
20 wmm_ac_process_param_elem(struct wpa_supplicant *wpa_s, const u8 *ies,
23 struct ieee802_11_elems elems;
24 struct wmm_parameter_element *wmm_params;
25 struct wmm_ac_assoc_data *assoc_data;
28 /* Parsing WMM Parameter Element */
29 if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) != ParseOK) {
30 wpa_printf(MSG_DEBUG, "WMM AC: could not parse assoc ies");
35 wpa_printf(MSG_DEBUG, "WMM AC: No WMM IE");
39 if (elems.wmm_len != sizeof(*wmm_params)) {
40 wpa_printf(MSG_WARNING, "WMM AC: Invalid WMM ie length");
44 wmm_params = (struct wmm_parameter_element *)(elems.wmm);
46 assoc_data = os_zalloc(sizeof(*assoc_data));
50 for (i = 0; i < WMM_AC_NUM; i++)
51 assoc_data->ac_params[i].acm =
52 !!(wmm_params->ac[i].aci_aifsn & WMM_AC_ACM);
55 "WMM AC: AC mandatory: AC_BE=%u AC_BK=%u AC_VI=%u AC_VO=%u",
56 assoc_data->ac_params[WMM_AC_BE].acm,
57 assoc_data->ac_params[WMM_AC_BK].acm,
58 assoc_data->ac_params[WMM_AC_VI].acm,
59 assoc_data->ac_params[WMM_AC_VO].acm);
65 static int wmm_ac_init(struct wpa_supplicant *wpa_s, const u8 *ies,
66 size_t ies_len, const struct wmm_params *wmm_params)
68 struct wmm_ac_assoc_data *assoc_data;
71 if (wpa_s->wmm_ac_assoc_info) {
72 wpa_printf(MSG_ERROR, "WMM AC: Already initialized");
77 wpa_printf(MSG_ERROR, "WMM AC: Missing IEs");
81 if (!(wmm_params->info_bitmap & WMM_PARAMS_UAPSD_QUEUES_INFO)) {
82 wpa_printf(MSG_DEBUG, "WMM AC: Missing U-APSD configuration");
86 assoc_data = wmm_ac_process_param_elem(wpa_s, ies, ies_len);
90 wpa_printf(MSG_DEBUG, "WMM AC: U-APSD queues=0x%x",
91 wmm_params->uapsd_queues);
93 for (ac = 0; ac < WMM_AC_NUM; ac++) {
94 assoc_data->ac_params[ac].uapsd =
95 !!(wmm_params->uapsd_queues & BIT(ac));
98 wpa_s->wmm_ac_assoc_info = assoc_data;
103 static void wmm_ac_deinit(struct wpa_supplicant *wpa_s)
105 os_free(wpa_s->wmm_ac_assoc_info);
106 wpa_s->wmm_ac_assoc_info = NULL;
110 void wmm_ac_notify_assoc(struct wpa_supplicant *wpa_s, const u8 *ies,
111 size_t ies_len, const struct wmm_params *wmm_params)
113 if (wmm_ac_init(wpa_s, ies, ies_len, wmm_params))
116 wpa_printf(MSG_DEBUG,
117 "WMM AC: Valid WMM association, WMM AC is enabled");
121 void wmm_ac_notify_disassoc(struct wpa_supplicant *wpa_s)
123 if (!wpa_s->wmm_ac_assoc_info)
126 wmm_ac_deinit(wpa_s);
127 wpa_printf(MSG_DEBUG, "WMM AC: WMM AC is disabled");