OCV: Move "OCV failed" prefix to callers

Make reporting of OCV validation failure reasons more flexible by
removing the fixed prefix from ocv_verify_tx_params() output in
ocv_errorstr so that the caller can use whatever prefix or encapsulation
that is most appropriate for each case.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2020-05-25 18:33:00 +03:00 committed by Jouni Malinen
parent 2d118f557a
commit 52579be860
11 changed files with 26 additions and 22 deletions

View file

@ -3509,7 +3509,8 @@ static int check_assoc_ies(struct hostapd_data *hapd, struct sta_info *sta,
if (ocv_verify_tx_params(elems.oci, elems.oci_len, &ci,
tx_chanwidth, tx_seg1_idx) != 0) {
wpa_printf(MSG_WARNING, "FILS: %s", ocv_errorstr);
wpa_printf(MSG_WARNING, "FILS: OCV failed: %s",
ocv_errorstr);
return WLAN_STATUS_UNSPECIFIED_FAILURE;
}
}

View file

@ -255,7 +255,7 @@ void ieee802_11_sa_query_action(struct hostapd_data *hapd,
if (ocv_verify_tx_params(elems.oci, elems.oci_len, &ci,
tx_chanwidth, tx_seg1_idx) != 0) {
wpa_printf(MSG_WARNING, "%s", ocv_errorstr);
wpa_printf(MSG_WARNING, "OCV failed: %s", ocv_errorstr);
return;
}
}

View file

@ -318,7 +318,8 @@ static void ieee802_11_rx_wnmsleep_req(struct hostapd_data *hapd,
if (ocv_verify_tx_params(oci_ie, oci_ie_len, &ci,
channel_width_to_int(ci.chanwidth),
ci.seg1_idx) != 0) {
wpa_msg(hapd, MSG_WARNING, "WNM: %s", ocv_errorstr);
wpa_msg(hapd, MSG_WARNING, "WNM: OCV failed: %s",
ocv_errorstr);
return;
}
}

View file

@ -3042,8 +3042,8 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)
if (ocv_verify_tx_params(kde.oci, kde.oci_len, &ci,
tx_chanwidth, tx_seg1_idx) != 0) {
wpa_auth_logger(wpa_auth, sm->addr, LOGGER_INFO,
ocv_errorstr);
wpa_auth_vlogger(wpa_auth, sm->addr, LOGGER_INFO,
"OCV failed: %s", ocv_errorstr);
return;
}
}
@ -3880,8 +3880,8 @@ SM_STATE(WPA_PTK_GROUP, REKEYESTABLISHED)
if (ocv_verify_tx_params(kde.oci, kde.oci_len, &ci,
tx_chanwidth, tx_seg1_idx) != 0) {
wpa_auth_logger(wpa_auth, sm->addr, LOGGER_INFO,
ocv_errorstr);
wpa_auth_vlogger(wpa_auth, sm->addr, LOGGER_INFO,
"OCV failed: %s", ocv_errorstr);
return;
}
}

View file

@ -3466,7 +3466,7 @@ int wpa_ft_validate_reassoc(struct wpa_state_machine *sm, const u8 *ies,
if (ocv_verify_tx_params(parse.oci, parse.oci_len, &ci,
tx_chanwidth, tx_seg1_idx) != 0) {
wpa_printf(MSG_WARNING, "%s", ocv_errorstr);
wpa_printf(MSG_WARNING, "OCV failed: %s", ocv_errorstr);
return WLAN_STATUS_UNSPECIFIED_FAILURE;
}
}

View file

@ -103,13 +103,13 @@ int ocv_verify_tx_params(const u8 *oci_ie, size_t oci_ie_len,
if (!oci_ie) {
os_snprintf(ocv_errorstr, sizeof(ocv_errorstr),
"OCV failed: did not receive mandatory OCI");
"did not receive mandatory OCI");
return -1;
}
if (oci_ie_len != 3) {
os_snprintf(ocv_errorstr, sizeof(ocv_errorstr),
"OCV failed: received OCI of unexpected length (%d)",
"received OCI of unexpected length (%d)",
(int) oci_ie_len);
return -1;
}
@ -120,14 +120,14 @@ int ocv_verify_tx_params(const u8 *oci_ie, size_t oci_ie_len,
oci.seg1_idx = oci_ie[2];
if (ocv_derive_all_parameters(&oci) != 0) {
os_snprintf(ocv_errorstr, sizeof(ocv_errorstr),
"OCV failed: unable to interpret received OCI");
"unable to interpret received OCI");
return -1;
}
/* Primary frequency used to send frames to STA must match the STA's */
if ((int) ci->frequency != oci.freq) {
os_snprintf(ocv_errorstr, sizeof(ocv_errorstr),
"OCV failed: primary channel mismatch in received OCI (we use %d but receiver is using %d)",
"primary channel mismatch in received OCI (we use %d but receiver is using %d)",
ci->frequency, oci.freq);
return -1;
}
@ -136,7 +136,7 @@ int ocv_verify_tx_params(const u8 *oci_ie, size_t oci_ie_len,
*/
if (tx_chanwidth > oci.chanwidth) {
os_snprintf(ocv_errorstr, sizeof(ocv_errorstr),
"OCV failed: channel bandwidth mismatch in received OCI (we use %d but receiver only supports %d)",
"channel bandwidth mismatch in received OCI (we use %d but receiver only supports %d)",
tx_chanwidth, oci.chanwidth);
return -1;
}
@ -150,7 +150,7 @@ int ocv_verify_tx_params(const u8 *oci_ie, size_t oci_ie_len,
if (tx_chanwidth == 40 && ci->frequency < 2500 &&
ci->sec_channel != oci.sec_channel) {
os_snprintf(ocv_errorstr, sizeof(ocv_errorstr),
"OCV failed: secondary channel mismatch in received OCI (we use %d but receiver is using %d)",
"secondary channel mismatch in received OCI (we use %d but receiver is using %d)",
ci->sec_channel, oci.sec_channel);
return -1;
}
@ -163,7 +163,7 @@ int ocv_verify_tx_params(const u8 *oci_ie, size_t oci_ie_len,
ci->chanwidth == CHAN_WIDTH_80P80) &&
tx_seg1_idx != oci.seg1_idx) {
os_snprintf(ocv_errorstr, sizeof(ocv_errorstr),
"OCV failed: frequency segment 1 mismatch in received OCI (we use %d but receiver is using %d)",
"frequency segment 1 mismatch in received OCI (we use %d but receiver is using %d)",
tx_seg1_idx, oci.seg1_idx);
return -1;
}

View file

@ -1717,7 +1717,7 @@ static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm,
if (ocv_verify_tx_params(ie.oci, ie.oci_len, &ci,
channel_width_to_int(ci.chanwidth),
ci.seg1_idx) != 0) {
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "%s",
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "OCV failed: %s",
ocv_errorstr);
return;
}
@ -1864,7 +1864,7 @@ static int wpa_supplicant_process_1_of_2_rsn(struct wpa_sm *sm,
if (ocv_verify_tx_params(ie.oci, ie.oci_len, &ci,
channel_width_to_int(ci.chanwidth),
ci.seg1_idx) != 0) {
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "%s",
wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "OCV failed: %s",
ocv_errorstr);
return -1;
}
@ -4764,7 +4764,8 @@ int fils_process_assoc_resp(struct wpa_sm *sm, const u8 *resp, size_t len)
if (ocv_verify_tx_params(elems.oci, elems.oci_len, &ci,
channel_width_to_int(ci.chanwidth),
ci.seg1_idx) != 0) {
wpa_printf(MSG_WARNING, "FILS: %s", ocv_errorstr);
wpa_printf(MSG_WARNING, "FILS: OCV failed: %s",
ocv_errorstr);
goto fail;
}
}

View file

@ -1159,7 +1159,7 @@ int wpa_ft_validate_reassoc_resp(struct wpa_sm *sm, const u8 *ies,
if (ocv_verify_tx_params(parse.oci, parse.oci_len, &ci,
channel_width_to_int(ci.chanwidth),
ci.seg1_idx) != 0) {
wpa_printf(MSG_WARNING, "%s", ocv_errorstr);
wpa_printf(MSG_WARNING, "OCV failed: %s", ocv_errorstr);
return -1;
}
}

View file

@ -1291,7 +1291,7 @@ void mesh_mpm_action_rx(struct wpa_supplicant *wpa_s,
if (ocv_verify_tx_params(elems.oci, elems.oci_len, &ci,
tx_chanwidth, tx_seg1_idx) !=
0) {
wpa_printf(MSG_WARNING, "MPM: %s",
wpa_printf(MSG_WARNING, "MPM: OCV failed: %s",
ocv_errorstr);
return;
}

View file

@ -2827,7 +2827,7 @@ void sme_sa_query_rx(struct wpa_supplicant *wpa_s, const u8 *sa,
if (ocv_verify_tx_params(elems.oci, elems.oci_len, &ci,
channel_width_to_int(ci.chanwidth),
ci.seg1_idx) != 0) {
wpa_printf(MSG_WARNING, "%s", ocv_errorstr);
wpa_printf(MSG_WARNING, "OCV failed: %s", ocv_errorstr);
return;
}
}

View file

@ -375,7 +375,8 @@ static void ieee802_11_rx_wnmsleep_resp(struct wpa_supplicant *wpa_s,
if (ocv_verify_tx_params(oci_ie, oci_ie_len, &ci,
channel_width_to_int(ci.chanwidth),
ci.seg1_idx) != 0) {
wpa_msg(wpa_s, MSG_WARNING, "WNM: %s", ocv_errorstr);
wpa_msg(wpa_s, MSG_WARNING, "WNM: OCV failed: %s",
ocv_errorstr);
return;
}
}