X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=wpa_supplicant%2Fwmm_ac.c;h=5625d36638b5c33dc60e1517b2f0a91c8365e9ee;hb=e55df99ee6281f43de620c6bd46faee2ca0252a2;hp=b26b8aa1146f7db4846a2aa6acda0ec64db266ef;hpb=8506ea6f17e6389bfcdbcbfd93baa34a3d10f416;p=mech_eap.git diff --git a/wpa_supplicant/wmm_ac.c b/wpa_supplicant/wmm_ac.c index b26b8aa..5625d36 100644 --- a/wpa_supplicant/wmm_ac.c +++ b/wpa_supplicant/wmm_ac.c @@ -427,7 +427,7 @@ wmm_ac_process_param_elem(struct wpa_supplicant *wpa_s, const u8 *ies, int i; /* Parsing WMM Parameter Element */ - if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) != ParseOK) { + if (ieee802_11_parse_elems(ies, ies_len, &elems, 1) == ParseFailed) { wpa_printf(MSG_DEBUG, "WMM AC: could not parse assoc ies"); return NULL; } @@ -438,7 +438,7 @@ wmm_ac_process_param_elem(struct wpa_supplicant *wpa_s, const u8 *ies, } if (elems.wmm_len != sizeof(*wmm_params)) { - wpa_printf(MSG_WARNING, "WMM AC: Invalid WMM ie length"); + wpa_printf(MSG_DEBUG, "WMM AC: Invalid WMM ie length"); return NULL; } @@ -556,7 +556,7 @@ void wmm_ac_notify_disassoc(struct wpa_supplicant *wpa_s) int wpas_wmm_ac_delts(struct wpa_supplicant *wpa_s, u8 tsid) { - struct wmm_tspec_element *tspec; + struct wmm_tspec_element tspec; int ac; enum ts_dir_idx dir; @@ -572,11 +572,12 @@ int wpas_wmm_ac_delts(struct wpa_supplicant *wpa_s, u8 tsid) return -1; } - tspec = wpa_s->tspecs[ac][dir]; - wmm_ac_send_delts(wpa_s, tspec, wpa_s->bssid); + tspec = *wpa_s->tspecs[ac][dir]; wmm_ac_del_ts_idx(wpa_s, ac, dir); + wmm_ac_send_delts(wpa_s, &tspec, wpa_s->bssid); + return 0; } @@ -657,7 +658,7 @@ static void wmm_ac_handle_delts(struct wpa_supplicant *wpa_s, const u8 *sa, wmm_ac_del_ts_idx(wpa_s, ac, idx); - wpa_printf(MSG_INFO, + wpa_printf(MSG_DEBUG, "TS was deleted successfully (tsid=%u address=" MACSTR ")", tsid, MAC2STR(sa)); } @@ -678,7 +679,7 @@ static void wmm_ac_handle_addts_resp(struct wpa_supplicant *wpa_s, const u8 *sa, /* make sure we have a matching addts request */ if (!req || req->dialog_token != resp_dialog_token) { - wpa_printf(MSG_ERROR, + wpa_printf(MSG_DEBUG, "WMM AC: no req with dialog=%u, ignoring frame", resp_dialog_token); return; @@ -689,7 +690,7 @@ static void wmm_ac_handle_addts_resp(struct wpa_supplicant *wpa_s, const u8 *sa, tsid != wmm_ac_get_tsid(&req->tspec) || up != wmm_ac_get_user_priority(&req->tspec) || dir != wmm_ac_get_direction(&req->tspec)) { - wpa_printf(MSG_ERROR, + wpa_printf(MSG_DEBUG, "WMM AC: ADDTS params do not match, ignoring frame"); return; } @@ -697,7 +698,7 @@ static void wmm_ac_handle_addts_resp(struct wpa_supplicant *wpa_s, const u8 *sa, /* delete pending request */ wmm_ac_del_req(wpa_s, 0); - wpa_printf(MSG_INFO, + wpa_printf(MSG_DEBUG, "ADDTS response status=%d tsid=%u up=%u direction=%u", status_code, tsid, up, dir); @@ -746,7 +747,7 @@ void wmm_ac_rx_action(struct wpa_supplicant *wpa_s, const u8 *da, struct wmm_tspec_element *tspec; if (wpa_s->wmm_ac_assoc_info == NULL) { - wpa_printf(MSG_WARNING, + wpa_printf(MSG_DEBUG, "WMM AC: WMM AC is disabled, ignoring action frame"); return; } @@ -755,7 +756,7 @@ void wmm_ac_rx_action(struct wpa_supplicant *wpa_s, const u8 *da, if (action != WMM_ACTION_CODE_ADDTS_RESP && action != WMM_ACTION_CODE_DELTS) { - wpa_printf(MSG_WARNING, + wpa_printf(MSG_DEBUG, "WMM AC: Unknown action (%d), ignoring action frame", action); return; @@ -856,7 +857,7 @@ 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; + u8 ac, up; if (!assoc_info) { return wpa_scnprintf(buf, buflen - pos, @@ -888,13 +889,14 @@ int wpas_wmm_ac_status(struct wpa_supplicant *wpa_s, char *buf, size_t buflen) dir = wmm_ac_get_direction(tspec); dir_str = get_direction_str(dir); tsid = wmm_ac_get_tsid(tspec); + up = wmm_ac_get_user_priority(tspec); pos += wpa_scnprintf(buf + pos, buflen - pos, - "\tTSID = %u\n" + "\tTSID=%u UP=%u\n" "\tAddress = "MACSTR"\n" "\tWMM AC dir = %s\n" "\tTotal admitted time = %u\n\n", - tsid, + tsid, up, MAC2STR(wpa_s->bssid), dir_str, le_to_host16(tspec->medium_time)); @@ -908,3 +910,86 @@ int wpas_wmm_ac_status(struct wpa_supplicant *wpa_s, char *buf, size_t buflen) return pos; } + + +static u8 wmm_ac_get_tspecs_count(struct wpa_supplicant *wpa_s) +{ + int ac, dir, tspecs_count = 0; + + for (ac = 0; ac < WMM_AC_NUM; ac++) { + for (dir = 0; dir < TS_DIR_IDX_COUNT; dir++) { + if (wpa_s->tspecs[ac][dir]) + tspecs_count++; + } + } + + return tspecs_count; +} + + +void wmm_ac_save_tspecs(struct wpa_supplicant *wpa_s) +{ + int ac, dir, tspecs_count; + + wpa_printf(MSG_DEBUG, "WMM AC: Save last configured tspecs"); + + if (!wpa_s->wmm_ac_assoc_info) + return; + + tspecs_count = wmm_ac_get_tspecs_count(wpa_s); + if (!tspecs_count) { + wpa_printf(MSG_DEBUG, "WMM AC: No configured TSPECs"); + return; + } + + wpa_printf(MSG_DEBUG, "WMM AC: Saving tspecs"); + + wmm_ac_clear_saved_tspecs(wpa_s); + wpa_s->last_tspecs = os_calloc(tspecs_count, + sizeof(*wpa_s->last_tspecs)); + if (!wpa_s->last_tspecs) { + wpa_printf(MSG_ERROR, "WMM AC: Failed to save tspecs!"); + return; + } + + for (ac = 0; ac < WMM_AC_NUM; ac++) { + for (dir = 0; dir < TS_DIR_IDX_COUNT; dir++) { + if (!wpa_s->tspecs[ac][dir]) + continue; + + wpa_s->last_tspecs[wpa_s->last_tspecs_count++] = + *wpa_s->tspecs[ac][dir]; + } + } + + wpa_printf(MSG_DEBUG, "WMM AC: Successfully saved %d TSPECs", + wpa_s->last_tspecs_count); +} + + +void wmm_ac_clear_saved_tspecs(struct wpa_supplicant *wpa_s) +{ + if (wpa_s->last_tspecs) { + wpa_printf(MSG_DEBUG, "WMM AC: Clear saved tspecs"); + os_free(wpa_s->last_tspecs); + wpa_s->last_tspecs = NULL; + wpa_s->last_tspecs_count = 0; + } +} + + +int wmm_ac_restore_tspecs(struct wpa_supplicant *wpa_s) +{ + unsigned int i; + + if (!wpa_s->wmm_ac_assoc_info || !wpa_s->last_tspecs_count) + return 0; + + wpa_printf(MSG_DEBUG, "WMM AC: Restore %u saved tspecs", + wpa_s->last_tspecs_count); + + for (i = 0; i < wpa_s->last_tspecs_count; i++) + wmm_ac_add_ts(wpa_s, wpa_s->bssid, &wpa_s->last_tspecs[i]); + + return 0; +}