diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index b605a193f..63a3589cd 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -50,19 +50,22 @@ void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, * BSSID from the driver. */ if (wpa_sm_get_bssid(sm, sm->bssid) < 0) { - wpa_printf(MSG_DEBUG, "WPA: Failed to read BSSID for " - "EAPOL-Key destination address"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Failed to read BSSID for " + "EAPOL-Key destination address"); } else { dest = sm->bssid; - wpa_printf(MSG_DEBUG, "WPA: Use BSSID (" MACSTR - ") as the destination for EAPOL-Key", - MAC2STR(dest)); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Use BSSID (" MACSTR + ") as the destination for EAPOL-Key", + MAC2STR(dest)); } } if (key_mic && wpa_eapol_key_mic(kck, ver, msg, msg_len, key_mic)) { - wpa_printf(MSG_ERROR, "WPA: Failed to generate EAPOL-Key " - "version %d MIC", ver); + wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, + "WPA: Failed to generate EAPOL-Key " + "version %d MIC", ver); goto out; } wpa_hexdump_key(MSG_DEBUG, "WPA: KCK", kck, 16); @@ -100,8 +103,8 @@ void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise) ver = WPA_KEY_INFO_TYPE_HMAC_MD5_RC4; if (wpa_sm_get_bssid(sm, bssid) < 0) { - wpa_printf(MSG_WARNING, "Failed to read BSSID for EAPOL-Key " - "request"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "Failed to read BSSID for EAPOL-Key request"); return; } @@ -127,9 +130,10 @@ void wpa_sm_key_request(struct wpa_sm *sm, int error, int pairwise) WPA_PUT_BE16(reply->key_data_length, 0); - wpa_printf(MSG_INFO, "WPA: Sending EAPOL-Key Request (error=%d " - "pairwise=%d ptk_set=%d len=%lu)", - error, pairwise, sm->ptk_set, (unsigned long) rlen); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: Sending EAPOL-Key Request (error=%d " + "pairwise=%d ptk_set=%d len=%lu)", + error, pairwise, sm->ptk_set, (unsigned long) rlen); wpa_eapol_key_send(sm, sm->ptk.kck, ver, bssid, ETH_P_EAPOL, rbuf, rlen, key_info & WPA_KEY_INFO_MIC ? reply->key_mic : NULL); @@ -149,10 +153,11 @@ static int wpa_supplicant_get_pmk(struct wpa_sm *sm, * matching PMKSA cache entry here. */ sm->cur_pmksa = pmksa_cache_get(sm->pmksa, src_addr, pmkid); if (sm->cur_pmksa) { - wpa_printf(MSG_DEBUG, "RSN: found matching PMKID from " - "PMKSA cache"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: found matching PMKID from PMKSA cache"); } else { - wpa_printf(MSG_DEBUG, "RSN: no matching PMKID found"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: no matching PMKID found"); abort_cached = 1; } } @@ -200,19 +205,20 @@ static int wpa_supplicant_get_pmk(struct wpa_sm *sm, } if (!sm->cur_pmksa && pmkid && pmksa_cache_get(sm->pmksa, src_addr, pmkid)) { - wpa_printf(MSG_DEBUG, "RSN: the new PMK " - "matches with the PMKID"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: the new PMK matches with the " + "PMKID"); abort_cached = 0; } } else { wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "WPA: Failed to get master session key from " - "EAPOL state machines"); - wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, - "WPA: Key handshake aborted"); + "EAPOL state machines - key handshake " + "aborted"); if (sm->cur_pmksa) { - wpa_printf(MSG_DEBUG, "RSN: Cancelled PMKSA " - "caching attempt"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: Cancelled PMKSA caching " + "attempt"); sm->cur_pmksa = NULL; abort_cached = 1; } else if (!abort_cached) { @@ -226,8 +232,9 @@ static int wpa_supplicant_get_pmk(struct wpa_sm *sm, u8 *buf; size_t buflen; - wpa_printf(MSG_DEBUG, "RSN: no PMKSA entry found - trigger " - "full EAP authentication"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: no PMKSA entry found - trigger " + "full EAP authentication"); buf = wpa_sm_alloc_eapol(sm, IEEE802_1X_TYPE_EAPOL_START, NULL, 0, &buflen, NULL); if (buf) { @@ -268,8 +275,8 @@ int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst, u8 *rsn_ie_buf = NULL; if (wpa_ie == NULL) { - wpa_printf(MSG_WARNING, "WPA: No wpa_ie set - cannot " - "generate msg 2/4"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "WPA: No wpa_ie set - " + "cannot generate msg 2/4"); return -1; } @@ -333,7 +340,7 @@ int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst, os_memcpy(reply->key_nonce, nonce, WPA_NONCE_LEN); - wpa_printf(MSG_DEBUG, "WPA: Sending EAPOL-Key 2/4"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 2/4"); wpa_eapol_key_send(sm, ptk->kck, ver, dst, ETH_P_EAPOL, rbuf, rlen, reply->key_mic); @@ -370,14 +377,14 @@ static void wpa_supplicant_process_1_of_4(struct wpa_sm *sm, int res; if (wpa_sm_get_network_ctx(sm) == NULL) { - wpa_printf(MSG_WARNING, "WPA: No SSID info found (msg 1 of " - "4)."); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "WPA: No SSID info " + "found (msg 1 of 4)"); return; } wpa_sm_set_state(sm, WPA_4WAY_HANDSHAKE); - wpa_printf(MSG_DEBUG, "WPA: RX message 1 of 4-Way Handshake from " - MACSTR " (ver=%d)", MAC2STR(src_addr), ver); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: RX message 1 of 4-Way " + "Handshake from " MACSTR " (ver=%d)", MAC2STR(src_addr), ver); os_memset(&ie, 0, sizeof(ie)); @@ -397,8 +404,8 @@ static void wpa_supplicant_process_1_of_4(struct wpa_sm *sm, res = wpa_supplicant_get_pmk(sm, src_addr, ie.pmkid); if (res == -2) { - wpa_printf(MSG_DEBUG, "RSN: Do not reply to msg 1/4 - " - "requesting full EAP authentication"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "RSN: Do not reply to " + "msg 1/4 - requesting full EAP authentication"); return; } if (res) @@ -474,8 +481,9 @@ static void wpa_supplicant_key_neg_complete(struct wpa_sm *sm, } if (sm->cur_pmksa && sm->cur_pmksa->opportunistic) { - wpa_printf(MSG_DEBUG, "RSN: Authenticator accepted " - "opportunistic PMKSA entry - marking it valid"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: Authenticator accepted " + "opportunistic PMKSA entry - marking it valid"); sm->cur_pmksa->opportunistic = 0; } @@ -491,7 +499,7 @@ static void wpa_supplicant_key_neg_complete(struct wpa_sm *sm, static void wpa_sm_rekey_ptk(void *eloop_ctx, void *timeout_ctx) { struct wpa_sm *sm = eloop_ctx; - wpa_printf(MSG_DEBUG, "WPA: Request PTK rekeying"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Request PTK rekeying"); wpa_sm_key_request(sm, 0, 1); } @@ -504,7 +512,8 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm, const u8 *key_rsc; u8 null_rsc[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - wpa_printf(MSG_DEBUG, "WPA: Installing PTK to the driver."); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Installing PTK to the driver"); switch (sm->pairwise_cipher) { case WPA_CIPHER_CCMP: @@ -518,12 +527,13 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm, rsclen = 6; break; case WPA_CIPHER_NONE: - wpa_printf(MSG_DEBUG, "WPA: Pairwise Cipher Suite: " - "NONE - do not use pairwise keys"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Pairwise Cipher " + "Suite: NONE - do not use pairwise keys"); return 0; default: - wpa_printf(MSG_WARNING, "WPA: Unsupported pairwise cipher %d", - sm->pairwise_cipher); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Unsupported pairwise cipher %d", + sm->pairwise_cipher); return -1; } @@ -536,9 +546,10 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm, if (wpa_sm_set_key(sm, alg, sm->bssid, 0, 1, key_rsc, rsclen, (u8 *) sm->ptk.tk1, keylen) < 0) { - wpa_printf(MSG_WARNING, "WPA: Failed to set PTK to the " - "driver (alg=%d keylen=%d bssid=" MACSTR ")", - alg, keylen, MAC2STR(sm->bssid)); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Failed to set PTK to the " + "driver (alg=%d keylen=%d bssid=" MACSTR ")", + alg, keylen, MAC2STR(sm->bssid)); return -1; } @@ -552,7 +563,8 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm, } -static int wpa_supplicant_check_group_cipher(int group_cipher, +static int wpa_supplicant_check_group_cipher(struct wpa_sm *sm, + int group_cipher, int keylen, int maxkeylen, int *key_rsc_len, enum wpa_alg *alg) @@ -593,15 +605,16 @@ static int wpa_supplicant_check_group_cipher(int group_cipher, *alg = WPA_ALG_WEP; break; default: - wpa_printf(MSG_WARNING, "WPA: Unsupported Group Cipher %d", - group_cipher); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Unsupported Group Cipher %d", + group_cipher); return -1; } if (ret < 0 ) { - wpa_printf(MSG_WARNING, "WPA: Unsupported %s Group Cipher key " - "length %d (%d).", - wpa_cipher_txt(group_cipher), keylen, maxkeylen); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Unsupported %s Group Cipher key length %d (%d)", + wpa_cipher_txt(group_cipher), keylen, maxkeylen); } return ret; @@ -624,9 +637,9 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *sm, u8 gtk_buf[32]; wpa_hexdump_key(MSG_DEBUG, "WPA: Group Key", gd->gtk, gd->gtk_len); - wpa_printf(MSG_DEBUG, "WPA: Installing GTK to the driver " - "(keyidx=%d tx=%d len=%d).", gd->keyidx, gd->tx, - gd->gtk_len); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Installing GTK to the driver (keyidx=%d tx=%d len=%d)", + gd->keyidx, gd->tx, gd->gtk_len); wpa_hexdump(MSG_DEBUG, "WPA: RSC", key_rsc, gd->key_rsc_len); if (sm->group_cipher == WPA_CIPHER_TKIP) { /* Swap Tx/Rx keys for Michael MIC */ @@ -639,16 +652,18 @@ static int wpa_supplicant_install_gtk(struct wpa_sm *sm, if (wpa_sm_set_key(sm, gd->alg, NULL, gd->keyidx, 1, key_rsc, gd->key_rsc_len, _gtk, gd->gtk_len) < 0) { - wpa_printf(MSG_WARNING, "WPA: Failed to set " - "GTK to the driver (Group only)."); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Failed to set GTK to the driver " + "(Group only)"); return -1; } } else if (wpa_sm_set_key(sm, gd->alg, broadcast_ether_addr, gd->keyidx, gd->tx, key_rsc, gd->key_rsc_len, _gtk, gd->gtk_len) < 0) { - wpa_printf(MSG_WARNING, "WPA: Failed to set GTK to " - "the driver (alg=%d keylen=%d keyidx=%d)", - gd->alg, gd->gtk_len, gd->keyidx); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Failed to set GTK to " + "the driver (alg=%d keylen=%d keyidx=%d)", + gd->alg, gd->gtk_len, gd->keyidx); return -1; } @@ -665,8 +680,9 @@ static int wpa_supplicant_gtk_tx_bit_workaround(const struct wpa_sm *sm, * doing Group Key only APs) and without this workaround, the * data connection does not work because wpa_supplicant * configured non-zero keyidx to be used for unicast. */ - wpa_printf(MSG_INFO, "WPA: Tx bit set for GTK, but pairwise " - "keys are used - ignore Tx bit"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: Tx bit set for GTK, but pairwise " + "keys are used - ignore Tx bit"); return 0; } return tx; @@ -705,11 +721,12 @@ static int wpa_supplicant_pairwise_gtk(struct wpa_sm *sm, os_memcpy(gd.gtk, gtk, gtk_len); gd.gtk_len = gtk_len; - if (wpa_supplicant_check_group_cipher(sm->group_cipher, + if (wpa_supplicant_check_group_cipher(sm, sm->group_cipher, gtk_len, gtk_len, &gd.key_rsc_len, &gd.alg) || wpa_supplicant_install_gtk(sm, &gd, key->key_rsc)) { - wpa_printf(MSG_DEBUG, "RSN: Failed to install GTK"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: Failed to install GTK"); return -1; } @@ -736,21 +753,21 @@ static int ieee80211w_set_keys(struct wpa_sm *sm, return -1; igtk = (const struct wpa_igtk_kde *) ie->igtk; keyidx = WPA_GET_LE16(igtk->keyid); - wpa_printf(MSG_DEBUG, "WPA: IGTK keyid %d " - "pn %02x%02x%02x%02x%02x%02x", - keyidx, MAC2STR(igtk->pn)); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: IGTK keyid %d " + "pn %02x%02x%02x%02x%02x%02x", + keyidx, MAC2STR(igtk->pn)); wpa_hexdump_key(MSG_DEBUG, "WPA: IGTK", igtk->igtk, WPA_IGTK_LEN); if (keyidx > 4095) { - wpa_printf(MSG_WARNING, "WPA: Invalid IGTK KeyID %d", - keyidx); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Invalid IGTK KeyID %d", keyidx); return -1; } if (wpa_sm_set_key(sm, WPA_ALG_IGTK, broadcast_ether_addr, keyidx, 0, igtk->pn, sizeof(igtk->pn), igtk->igtk, WPA_IGTK_LEN) < 0) { - wpa_printf(MSG_WARNING, "WPA: Failed to configure IGTK" - " to the driver"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Failed to configure IGTK to the driver"); return -1; } } @@ -776,8 +793,8 @@ static void wpa_report_ie_mismatch(struct wpa_sm *sm, } if (wpa_ie) { if (!sm->ap_wpa_ie) { - wpa_printf(MSG_INFO, "WPA: No WPA IE in " - "Beacon/ProbeResp"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: No WPA IE in Beacon/ProbeResp"); } wpa_hexdump(MSG_INFO, "WPA: WPA IE in 3/4 msg", wpa_ie, wpa_ie_len); @@ -789,8 +806,8 @@ static void wpa_report_ie_mismatch(struct wpa_sm *sm, } if (rsn_ie) { if (!sm->ap_rsn_ie) { - wpa_printf(MSG_INFO, "WPA: No RSN IE in " - "Beacon/ProbeResp"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: No RSN IE in Beacon/ProbeResp"); } wpa_hexdump(MSG_INFO, "WPA: RSN IE in 3/4 msg", rsn_ie, rsn_ie_len); @@ -813,15 +830,15 @@ static int ft_validate_mdie(struct wpa_sm *sm, if (ie->mdie == NULL || ie->mdie_len < 2 + sizeof(*mdie) || os_memcmp(mdie->mobility_domain, sm->mobility_domain, MOBILITY_DOMAIN_ID_LEN) != 0) { - wpa_printf(MSG_DEBUG, "FT: MDIE in msg 3/4 did not " - "match with the current mobility domain"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "FT: MDIE in msg 3/4 did " + "not match with the current mobility domain"); return -1; } if (assoc_resp_mdie && (assoc_resp_mdie[1] != ie->mdie[1] || os_memcmp(assoc_resp_mdie, ie->mdie, 2 + ie->mdie[1]) != 0)) { - wpa_printf(MSG_DEBUG, "FT: MDIE mismatch"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "FT: MDIE mismatch"); wpa_hexdump(MSG_DEBUG, "FT: MDIE in EAPOL-Key msg 3/4", ie->mdie, 2 + ie->mdie[1]); wpa_hexdump(MSG_DEBUG, "FT: MDIE in (Re)Association Response", @@ -839,7 +856,8 @@ static int ft_validate_ftie(struct wpa_sm *sm, const u8 *assoc_resp_ftie) { if (ie->ftie == NULL) { - wpa_printf(MSG_DEBUG, "FT: No FTIE in EAPOL-Key msg 3/4"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "FT: No FTIE in EAPOL-Key msg 3/4"); return -1; } @@ -848,7 +866,7 @@ static int ft_validate_ftie(struct wpa_sm *sm, if (assoc_resp_ftie[1] != ie->ftie[1] || os_memcmp(assoc_resp_ftie, ie->ftie, 2 + ie->ftie[1]) != 0) { - wpa_printf(MSG_DEBUG, "FT: FTIE mismatch"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "FT: FTIE mismatch"); wpa_hexdump(MSG_DEBUG, "FT: FTIE in EAPOL-Key msg 3/4", ie->ftie, 2 + ie->ftie[1]); wpa_hexdump(MSG_DEBUG, "FT: FTIE in (Re)Association Response", @@ -875,14 +893,15 @@ static int ft_validate_rsnie(struct wpa_sm *sm, */ if (wpa_parse_wpa_ie_rsn(ie->rsn_ie, ie->rsn_ie_len, &rsn) < 0 || rsn.num_pmkid != 1 || rsn.pmkid == NULL) { - wpa_printf(MSG_DEBUG, "FT: No PMKR1Name in " - "FT 4-way handshake message 3/4"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "FT: No PMKR1Name in " + "FT 4-way handshake message 3/4"); return -1; } if (os_memcmp(rsn.pmkid, sm->pmk_r1_name, WPA_PMK_NAME_LEN) != 0) { - wpa_printf(MSG_DEBUG, "FT: PMKR1Name mismatch in " - "FT 4-way handshake message 3/4"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "FT: PMKR1Name mismatch in " + "FT 4-way handshake message 3/4"); wpa_hexdump(MSG_DEBUG, "FT: PMKR1Name from Authenticator", rsn.pmkid, WPA_PMK_NAME_LEN); wpa_hexdump(MSG_DEBUG, "FT: Derived PMKR1Name", @@ -934,14 +953,17 @@ static int wpa_supplicant_validate_ie(struct wpa_sm *sm, struct wpa_eapol_ie_parse *ie) { if (sm->ap_wpa_ie == NULL && sm->ap_rsn_ie == NULL) { - wpa_printf(MSG_DEBUG, "WPA: No WPA/RSN IE for this AP known. " - "Trying to get from scan results"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: No WPA/RSN IE for this AP known. " + "Trying to get from scan results"); if (wpa_sm_get_beacon_ie(sm) < 0) { - wpa_printf(MSG_WARNING, "WPA: Could not find AP from " - "the scan results"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Could not find AP from " + "the scan results"); } else { - wpa_printf(MSG_DEBUG, "WPA: Found the current AP from " - "updated scan results"); + wpa_msg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Found the current AP from " + "updated scan results"); } } @@ -1036,7 +1058,7 @@ int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst, if (kde) os_memcpy(reply + 1, kde, kde_len); - wpa_printf(MSG_DEBUG, "WPA: Sending EAPOL-Key 4/4"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 4/4"); wpa_eapol_key_send(sm, ptk->kck, ver, dst, ETH_P_EAPOL, rbuf, rlen, reply->key_mic); @@ -1053,8 +1075,8 @@ static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm, struct wpa_eapol_ie_parse ie; wpa_sm_set_state(sm, WPA_4WAY_HANDSHAKE); - wpa_printf(MSG_DEBUG, "WPA: RX message 3 of 4-Way Handshake from " - MACSTR " (ver=%d)", MAC2STR(sm->bssid), ver); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: RX message 3 of 4-Way " + "Handshake from " MACSTR " (ver=%d)", MAC2STR(sm->bssid), ver); key_info = WPA_GET_BE16(key->key_info); @@ -1063,19 +1085,21 @@ static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm, wpa_hexdump(MSG_DEBUG, "WPA: IE KeyData", pos, len); wpa_supplicant_parse_ies(pos, len, &ie); if (ie.gtk && !(key_info & WPA_KEY_INFO_ENCR_KEY_DATA)) { - wpa_printf(MSG_WARNING, "WPA: GTK IE in unencrypted key data"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: GTK IE in unencrypted key data"); goto failed; } #ifdef CONFIG_IEEE80211W if (ie.igtk && !(key_info & WPA_KEY_INFO_ENCR_KEY_DATA)) { - wpa_printf(MSG_WARNING, "WPA: IGTK KDE in unencrypted key " - "data"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: IGTK KDE in unencrypted key data"); goto failed; } if (ie.igtk && ie.igtk_len != sizeof(struct wpa_igtk_kde)) { - wpa_printf(MSG_WARNING, "WPA: Invalid IGTK KDE length %lu", - (unsigned long) ie.igtk_len); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Invalid IGTK KDE length %lu", + (unsigned long) ie.igtk_len); goto failed; } #endif /* CONFIG_IEEE80211W */ @@ -1084,9 +1108,10 @@ static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm, goto failed; if (os_memcmp(sm->anonce, key->key_nonce, WPA_NONCE_LEN) != 0) { - wpa_printf(MSG_WARNING, "WPA: ANonce from message 1 of 4-Way " - "Handshake differs from 3 of 4-Way Handshake - drop" - " packet (src=" MACSTR ")", MAC2STR(sm->bssid)); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: ANonce from message 1 of 4-Way Handshake " + "differs from 3 of 4-Way Handshake - drop packet (src=" + MACSTR ")", MAC2STR(sm->bssid)); goto failed; } @@ -1094,17 +1119,17 @@ static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm, switch (sm->pairwise_cipher) { case WPA_CIPHER_CCMP: if (keylen != 16) { - wpa_printf(MSG_WARNING, "WPA: Invalid CCMP key length " - "%d (src=" MACSTR ")", - keylen, MAC2STR(sm->bssid)); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Invalid CCMP key length %d (src=" MACSTR + ")", keylen, MAC2STR(sm->bssid)); goto failed; } break; case WPA_CIPHER_TKIP: if (keylen != 32) { - wpa_printf(MSG_WARNING, "WPA: Invalid TKIP key length " - "%d (src=" MACSTR ")", - keylen, MAC2STR(sm->bssid)); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Invalid TKIP key length %d (src=" MACSTR + ")", keylen, MAC2STR(sm->bssid)); goto failed; } break; @@ -1136,12 +1161,14 @@ static void wpa_supplicant_process_3_of_4(struct wpa_sm *sm, if (ie.gtk && wpa_supplicant_pairwise_gtk(sm, key, ie.gtk, ie.gtk_len, key_info) < 0) { - wpa_printf(MSG_INFO, "RSN: Failed to configure GTK"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "RSN: Failed to configure GTK"); goto failed; } if (ieee80211w_set_keys(sm, &ie) < 0) { - wpa_printf(MSG_INFO, "RSN: Failed to configure IGTK"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "RSN: Failed to configure IGTK"); goto failed; } @@ -1164,16 +1191,18 @@ static int wpa_supplicant_process_1_of_2_rsn(struct wpa_sm *sm, wpa_hexdump(MSG_DEBUG, "RSN: msg 1/2 key data", keydata, keydatalen); wpa_supplicant_parse_ies(keydata, keydatalen, &ie); if (ie.gtk && !(key_info & WPA_KEY_INFO_ENCR_KEY_DATA)) { - wpa_printf(MSG_WARNING, "WPA: GTK IE in unencrypted key data"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: GTK IE in unencrypted key data"); return -1; } if (ie.gtk == NULL) { - wpa_printf(MSG_INFO, "WPA: No GTK IE in Group Key msg 1/2"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: No GTK IE in Group Key msg 1/2"); return -1; } maxkeylen = gd->gtk_len = ie.gtk_len - 2; - if (wpa_supplicant_check_group_cipher(sm->group_cipher, + if (wpa_supplicant_check_group_cipher(sm, sm->group_cipher, gd->gtk_len, maxkeylen, &gd->key_rsc_len, &gd->alg)) return -1; @@ -1184,14 +1213,16 @@ static int wpa_supplicant_process_1_of_2_rsn(struct wpa_sm *sm, gd->tx = wpa_supplicant_gtk_tx_bit_workaround(sm, !!(ie.gtk[0] & BIT(2))); if (ie.gtk_len - 2 > sizeof(gd->gtk)) { - wpa_printf(MSG_INFO, "RSN: Too long GTK in GTK IE " - "(len=%lu)", (unsigned long) ie.gtk_len - 2); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "RSN: Too long GTK in GTK IE (len=%lu)", + (unsigned long) ie.gtk_len - 2); return -1; } os_memcpy(gd->gtk, ie.gtk + 2, ie.gtk_len - 2); if (ieee80211w_set_keys(sm, &ie) < 0) - wpa_printf(MSG_INFO, "RSN: Failed to configure IGTK"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "RSN: Failed to configure IGTK"); return 0; } @@ -1209,22 +1240,23 @@ static int wpa_supplicant_process_1_of_2_wpa(struct wpa_sm *sm, gd->gtk_len = WPA_GET_BE16(key->key_length); maxkeylen = keydatalen; if (keydatalen > extra_len) { - wpa_printf(MSG_INFO, "WPA: Truncated EAPOL-Key packet:" - " key_data_length=%lu > extra_len=%lu", - (unsigned long) keydatalen, - (unsigned long) extra_len); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: Truncated EAPOL-Key packet: " + "key_data_length=%lu > extra_len=%lu", + (unsigned long) keydatalen, (unsigned long) extra_len); return -1; } if (ver == WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) { if (maxkeylen < 8) { - wpa_printf(MSG_INFO, "WPA: Too short maxkeylen (%lu)", - (unsigned long) maxkeylen); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: Too short maxkeylen (%lu)", + (unsigned long) maxkeylen); return -1; } maxkeylen -= 8; } - if (wpa_supplicant_check_group_cipher(sm->group_cipher, + if (wpa_supplicant_check_group_cipher(sm, sm->group_cipher, gd->gtk_len, maxkeylen, &gd->key_rsc_len, &gd->alg)) return -1; @@ -1235,38 +1267,42 @@ static int wpa_supplicant_process_1_of_2_wpa(struct wpa_sm *sm, os_memcpy(ek, key->key_iv, 16); os_memcpy(ek + 16, sm->ptk.kek, 16); if (keydatalen > sizeof(gd->gtk)) { - wpa_printf(MSG_WARNING, "WPA: RC4 key data " - "too long (%lu)", - (unsigned long) keydatalen); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: RC4 key data too long (%lu)", + (unsigned long) keydatalen); return -1; } os_memcpy(gd->gtk, key + 1, keydatalen); if (rc4_skip(ek, 32, 256, gd->gtk, keydatalen)) { - wpa_printf(MSG_ERROR, "WPA: RC4 failed"); + wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, + "WPA: RC4 failed"); return -1; } } else if (ver == WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) { if (keydatalen % 8) { - wpa_printf(MSG_WARNING, "WPA: Unsupported AES-WRAP " - "len %lu", (unsigned long) keydatalen); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Unsupported AES-WRAP len %lu", + (unsigned long) keydatalen); return -1; } if (maxkeylen > sizeof(gd->gtk)) { - wpa_printf(MSG_WARNING, "WPA: AES-WRAP key data " - "too long (keydatalen=%lu maxkeylen=%lu)", - (unsigned long) keydatalen, - (unsigned long) maxkeylen); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: AES-WRAP key data " + "too long (keydatalen=%lu maxkeylen=%lu)", + (unsigned long) keydatalen, + (unsigned long) maxkeylen); return -1; } if (aes_unwrap(sm->ptk.kek, maxkeylen / 8, (const u8 *) (key + 1), gd->gtk)) { - wpa_printf(MSG_WARNING, "WPA: AES unwrap " - "failed - could not decrypt GTK"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: AES unwrap failed - could not decrypt " + "GTK"); return -1; } } else { - wpa_printf(MSG_WARNING, "WPA: Unsupported key_info type %d", - ver); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Unsupported key_info type %d", ver); return -1; } gd->tx = wpa_supplicant_gtk_tx_bit_workaround( @@ -1302,7 +1338,7 @@ static int wpa_supplicant_send_2_of_2(struct wpa_sm *sm, WPA_PUT_BE16(reply->key_data_length, 0); - wpa_printf(MSG_DEBUG, "WPA: Sending EAPOL-Key 2/2"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 2/2"); wpa_eapol_key_send(sm, sm->ptk.kck, ver, sm->bssid, ETH_P_EAPOL, rbuf, rlen, reply->key_mic); @@ -1322,8 +1358,8 @@ static void wpa_supplicant_process_1_of_2(struct wpa_sm *sm, os_memset(&gd, 0, sizeof(gd)); rekey = wpa_sm_get_state(sm) == WPA_COMPLETED; - wpa_printf(MSG_DEBUG, "WPA: RX message 1 of Group Key Handshake from " - MACSTR " (ver=%d)", MAC2STR(src_addr), ver); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: RX message 1 of Group Key " + "Handshake from " MACSTR " (ver=%d)", MAC2STR(src_addr), ver); key_info = WPA_GET_BE16(key->key_info); keydatalen = WPA_GET_BE16(key->key_data_length); @@ -1380,8 +1416,9 @@ static int wpa_supplicant_verify_eapol_key_mic(struct wpa_sm *sm, wpa_eapol_key_mic(sm->tptk.kck, ver, buf, len, key->key_mic); if (os_memcmp(mic, key->key_mic, 16) != 0) { - wpa_printf(MSG_WARNING, "WPA: Invalid EAPOL-Key MIC " - "when using TPTK - ignoring TPTK"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Invalid EAPOL-Key MIC " + "when using TPTK - ignoring TPTK"); } else { ok = 1; sm->tptk_set = 0; @@ -1395,16 +1432,18 @@ static int wpa_supplicant_verify_eapol_key_mic(struct wpa_sm *sm, wpa_eapol_key_mic(sm->ptk.kck, ver, buf, len, key->key_mic); if (os_memcmp(mic, key->key_mic, 16) != 0) { - wpa_printf(MSG_WARNING, "WPA: Invalid EAPOL-Key MIC " - "- dropping packet"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Invalid EAPOL-Key MIC - " + "dropping packet"); return -1; } ok = 1; } if (!ok) { - wpa_printf(MSG_WARNING, "WPA: Could not verify EAPOL-Key MIC " - "- dropping packet"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Could not verify EAPOL-Key MIC - " + "dropping packet"); return -1; } @@ -1424,8 +1463,9 @@ static int wpa_supplicant_decrypt_key_data(struct wpa_sm *sm, wpa_hexdump(MSG_DEBUG, "RSN: encrypted key data", (u8 *) (key + 1), keydatalen); if (!sm->ptk_set) { - wpa_printf(MSG_WARNING, "WPA: PTK not available, " - "cannot decrypt EAPOL-Key key data."); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: PTK not available, cannot decrypt EAPOL-Key Key " + "Data"); return -1; } @@ -1436,37 +1476,40 @@ static int wpa_supplicant_decrypt_key_data(struct wpa_sm *sm, os_memcpy(ek, key->key_iv, 16); os_memcpy(ek + 16, sm->ptk.kek, 16); if (rc4_skip(ek, 32, 256, (u8 *) (key + 1), keydatalen)) { - wpa_printf(MSG_ERROR, "WPA: RC4 failed"); + wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, + "WPA: RC4 failed"); return -1; } } else if (ver == WPA_KEY_INFO_TYPE_HMAC_SHA1_AES || ver == WPA_KEY_INFO_TYPE_AES_128_CMAC) { u8 *buf; if (keydatalen % 8) { - wpa_printf(MSG_WARNING, "WPA: Unsupported " - "AES-WRAP len %d", keydatalen); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Unsupported AES-WRAP len %d", + keydatalen); return -1; } keydatalen -= 8; /* AES-WRAP adds 8 bytes */ buf = os_malloc(keydatalen); if (buf == NULL) { - wpa_printf(MSG_WARNING, "WPA: No memory for " - "AES-UNWRAP buffer"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: No memory for AES-UNWRAP buffer"); return -1; } if (aes_unwrap(sm->ptk.kek, keydatalen / 8, (u8 *) (key + 1), buf)) { os_free(buf); - wpa_printf(MSG_WARNING, "WPA: AES unwrap failed - " - "could not decrypt EAPOL-Key key data"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: AES unwrap failed - " + "could not decrypt EAPOL-Key key data"); return -1; } os_memcpy(key + 1, buf, keydatalen); os_free(buf); WPA_PUT_BE16(key->key_data_length, keydatalen); } else { - wpa_printf(MSG_WARNING, "WPA: Unsupported key_info type %d", - ver); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Unsupported key_info type %d", ver); return -1; } wpa_hexdump_key(MSG_DEBUG, "WPA: decrypted EAPOL-Key key data", @@ -1482,35 +1525,38 @@ static int wpa_supplicant_decrypt_key_data(struct wpa_sm *sm, void wpa_sm_aborted_cached(struct wpa_sm *sm) { if (sm && sm->cur_pmksa) { - wpa_printf(MSG_DEBUG, "RSN: Cancelling PMKSA caching attempt"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: Cancelling PMKSA caching attempt"); sm->cur_pmksa = NULL; } } -static void wpa_eapol_key_dump(const struct wpa_eapol_key *key) +static void wpa_eapol_key_dump(struct wpa_sm *sm, + const struct wpa_eapol_key *key) { #ifndef CONFIG_NO_STDOUT_DEBUG u16 key_info = WPA_GET_BE16(key->key_info); - wpa_printf(MSG_DEBUG, " EAPOL-Key type=%d", key->type); - wpa_printf(MSG_DEBUG, " key_info 0x%x (ver=%d keyidx=%d rsvd=%d %s" - "%s%s%s%s%s%s%s)", - key_info, key_info & WPA_KEY_INFO_TYPE_MASK, - (key_info & WPA_KEY_INFO_KEY_INDEX_MASK) >> - WPA_KEY_INFO_KEY_INDEX_SHIFT, - (key_info & (BIT(13) | BIT(14) | BIT(15))) >> 13, - key_info & WPA_KEY_INFO_KEY_TYPE ? "Pairwise" : "Group", - key_info & WPA_KEY_INFO_INSTALL ? " Install" : "", - key_info & WPA_KEY_INFO_ACK ? " Ack" : "", - key_info & WPA_KEY_INFO_MIC ? " MIC" : "", - key_info & WPA_KEY_INFO_SECURE ? " Secure" : "", - key_info & WPA_KEY_INFO_ERROR ? " Error" : "", - key_info & WPA_KEY_INFO_REQUEST ? " Request" : "", - key_info & WPA_KEY_INFO_ENCR_KEY_DATA ? " Encr" : ""); - wpa_printf(MSG_DEBUG, " key_length=%u key_data_length=%u", - WPA_GET_BE16(key->key_length), - WPA_GET_BE16(key->key_data_length)); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, " EAPOL-Key type=%d", key->type); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + " key_info 0x%x (ver=%d keyidx=%d rsvd=%d %s%s%s%s%s%s%s%s)", + key_info, key_info & WPA_KEY_INFO_TYPE_MASK, + (key_info & WPA_KEY_INFO_KEY_INDEX_MASK) >> + WPA_KEY_INFO_KEY_INDEX_SHIFT, + (key_info & (BIT(13) | BIT(14) | BIT(15))) >> 13, + key_info & WPA_KEY_INFO_KEY_TYPE ? "Pairwise" : "Group", + key_info & WPA_KEY_INFO_INSTALL ? " Install" : "", + key_info & WPA_KEY_INFO_ACK ? " Ack" : "", + key_info & WPA_KEY_INFO_MIC ? " MIC" : "", + key_info & WPA_KEY_INFO_SECURE ? " Secure" : "", + key_info & WPA_KEY_INFO_ERROR ? " Error" : "", + key_info & WPA_KEY_INFO_REQUEST ? " Request" : "", + key_info & WPA_KEY_INFO_ENCR_KEY_DATA ? " Encr" : ""); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + " key_length=%u key_data_length=%u", + WPA_GET_BE16(key->key_length), + WPA_GET_BE16(key->key_data_length)); wpa_hexdump(MSG_DEBUG, " replay_counter", key->replay_counter, WPA_REPLAY_COUNTER_LEN); wpa_hexdump(MSG_DEBUG, " key_nonce", key->key_nonce, WPA_NONCE_LEN); @@ -1554,10 +1600,11 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, #endif /* CONFIG_IEEE80211R */ if (len < sizeof(*hdr) + sizeof(*key)) { - wpa_printf(MSG_DEBUG, "WPA: EAPOL frame too short to be a WPA " - "EAPOL-Key (len %lu, expecting at least %lu)", - (unsigned long) len, - (unsigned long) sizeof(*hdr) + sizeof(*key)); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: EAPOL frame too short to be a WPA " + "EAPOL-Key (len %lu, expecting at least %lu)", + (unsigned long) len, + (unsigned long) sizeof(*hdr) + sizeof(*key)); return 0; } @@ -1570,40 +1617,45 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, key = (struct wpa_eapol_key *) (hdr + 1); plen = be_to_host16(hdr->length); data_len = plen + sizeof(*hdr); - wpa_printf(MSG_DEBUG, "IEEE 802.1X RX: version=%d type=%d length=%lu", - hdr->version, hdr->type, (unsigned long) plen); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "IEEE 802.1X RX: version=%d type=%d length=%lu", + hdr->version, hdr->type, (unsigned long) plen); if (hdr->version < EAPOL_VERSION) { /* TODO: backwards compatibility */ } if (hdr->type != IEEE802_1X_TYPE_EAPOL_KEY) { - wpa_printf(MSG_DEBUG, "WPA: EAPOL frame (type %u) discarded, " + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: EAPOL frame (type %u) discarded, " "not a Key frame", hdr->type); ret = 0; goto out; } if (plen > len - sizeof(*hdr) || plen < sizeof(*key)) { - wpa_printf(MSG_DEBUG, "WPA: EAPOL frame payload size %lu " - "invalid (frame size %lu)", - (unsigned long) plen, (unsigned long) len); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: EAPOL frame payload size %lu " + "invalid (frame size %lu)", + (unsigned long) plen, (unsigned long) len); ret = 0; goto out; } if (key->type != EAPOL_KEY_TYPE_WPA && key->type != EAPOL_KEY_TYPE_RSN) { - wpa_printf(MSG_DEBUG, "WPA: EAPOL-Key type (%d) unknown, " - "discarded", key->type); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: EAPOL-Key type (%d) unknown, discarded", + key->type); ret = 0; goto out; } - wpa_eapol_key_dump(key); + wpa_eapol_key_dump(sm, key); eapol_sm_notify_lower_layer_success(sm->eapol, 0); wpa_hexdump(MSG_MSGDUMP, "WPA: RX EAPOL-Key", tmp, len); if (data_len < len) { - wpa_printf(MSG_DEBUG, "WPA: ignoring %lu bytes after the IEEE " - "802.1X data", (unsigned long) len - data_len); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: ignoring %lu bytes after the IEEE 802.1X data", + (unsigned long) len - data_len); } key_info = WPA_GET_BE16(key->key_info); ver = key_info & WPA_KEY_INFO_TYPE_MASK; @@ -1612,8 +1664,9 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, ver != WPA_KEY_INFO_TYPE_AES_128_CMAC && #endif /* CONFIG_IEEE80211R || CONFIG_IEEE80211W */ ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) { - wpa_printf(MSG_INFO, "WPA: Unsupported EAPOL-Key descriptor " - "version %d.", ver); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: Unsupported EAPOL-Key descriptor version %d", + ver); goto out; } @@ -1621,8 +1674,8 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, if (wpa_key_mgmt_ft(sm->key_mgmt)) { /* IEEE 802.11r uses a new key_info type (AES-128-CMAC). */ if (ver != WPA_KEY_INFO_TYPE_AES_128_CMAC) { - wpa_printf(MSG_INFO, "FT: AP did not use " - "AES-128-CMAC."); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "FT: AP did not use AES-128-CMAC"); goto out; } } else @@ -1630,25 +1683,27 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, #ifdef CONFIG_IEEE80211W if (wpa_key_mgmt_sha256(sm->key_mgmt)) { if (ver != WPA_KEY_INFO_TYPE_AES_128_CMAC) { - wpa_printf(MSG_INFO, "WPA: AP did not use the " - "negotiated AES-128-CMAC."); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: AP did not use the " + "negotiated AES-128-CMAC"); goto out; } } else #endif /* CONFIG_IEEE80211W */ if (sm->pairwise_cipher == WPA_CIPHER_CCMP && ver != WPA_KEY_INFO_TYPE_HMAC_SHA1_AES) { - wpa_printf(MSG_INFO, "WPA: CCMP is used, but EAPOL-Key " - "descriptor version (%d) is not 2.", ver); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: CCMP is used, but EAPOL-Key " + "descriptor version (%d) is not 2", ver); if (sm->group_cipher != WPA_CIPHER_CCMP && !(key_info & WPA_KEY_INFO_KEY_TYPE)) { /* Earlier versions of IEEE 802.11i did not explicitly * require version 2 descriptor for all EAPOL-Key * packets, so allow group keys to use version 1 if * CCMP is not used for them. */ - wpa_printf(MSG_INFO, "WPA: Backwards compatibility: " - "allow invalid version for non-CCMP group " - "keys"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: Backwards compatibility: allow invalid " + "version for non-CCMP group keys"); } else goto out; } @@ -1663,9 +1718,9 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, if (!peerkey->initiator && peerkey->replay_counter_set && os_memcmp(key->replay_counter, peerkey->replay_counter, WPA_REPLAY_COUNTER_LEN) <= 0) { - wpa_printf(MSG_WARNING, "RSN: EAPOL-Key Replay " - "Counter did not increase (STK) - dropping " - "packet"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "RSN: EAPOL-Key Replay Counter did not " + "increase (STK) - dropping packet"); goto out; } else if (peerkey->initiator) { u8 _tmp[WPA_REPLAY_COUNTER_LEN]; @@ -1674,16 +1729,18 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, inc_byte_array(_tmp, WPA_REPLAY_COUNTER_LEN); if (os_memcmp(_tmp, peerkey->replay_counter, WPA_REPLAY_COUNTER_LEN) != 0) { - wpa_printf(MSG_DEBUG, "RSN: EAPOL-Key Replay " - "Counter did not match (STK) - " - "dropping packet"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: EAPOL-Key Replay " + "Counter did not match (STK) - " + "dropping packet"); goto out; } } } if (peerkey && peerkey->initiator && (key_info & WPA_KEY_INFO_ACK)) { - wpa_printf(MSG_INFO, "RSN: Ack bit in key_info from STK peer"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "RSN: Ack bit in key_info from STK peer"); goto out; } #endif /* CONFIG_PEERKEY */ @@ -1691,8 +1748,9 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, if (!peerkey && sm->rx_replay_counter_set && os_memcmp(key->replay_counter, sm->rx_replay_counter, WPA_REPLAY_COUNTER_LEN) <= 0) { - wpa_printf(MSG_WARNING, "WPA: EAPOL-Key Replay Counter did not" - " increase - dropping packet"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: EAPOL-Key Replay Counter did not increase - " + "dropping packet"); goto out; } @@ -1701,13 +1759,14 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, && (peerkey == NULL || !peerkey->initiator) #endif /* CONFIG_PEERKEY */ ) { - wpa_printf(MSG_INFO, "WPA: No Ack bit in key_info"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: No Ack bit in key_info"); goto out; } if (key_info & WPA_KEY_INFO_REQUEST) { - wpa_printf(MSG_INFO, "WPA: EAPOL-Key with Request bit - " - "dropped"); + wpa_msg(sm->ctx->msg_ctx, MSG_INFO, + "WPA: EAPOL-Key with Request bit - dropped"); goto out; } @@ -1741,8 +1800,9 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, if (key_info & WPA_KEY_INFO_KEY_TYPE) { if (key_info & WPA_KEY_INFO_KEY_INDEX_MASK) { - wpa_printf(MSG_WARNING, "WPA: Ignored EAPOL-Key " - "(Pairwise) with non-zero key index"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: Ignored EAPOL-Key (Pairwise) with " + "non-zero key index"); goto out; } if (peerkey) { @@ -1766,8 +1826,9 @@ int wpa_sm_rx_eapol(struct wpa_sm *sm, const u8 *src_addr, wpa_supplicant_process_1_of_2(sm, src_addr, key, extra_len, ver); } else { - wpa_printf(MSG_WARNING, "WPA: EAPOL-Key (Group) " - "without Mic bit - dropped"); + wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, + "WPA: EAPOL-Key (Group) without Mic bit - " + "dropped"); } } @@ -1942,7 +2003,8 @@ static void wpa_sm_pmksa_free_cb(struct rsn_pmksa_cache_entry *entry, if (sm->cur_pmksa == entry || (sm->pmk_len == entry->pmk_len && os_memcmp(sm->pmk, entry->pmk, sm->pmk_len) == 0)) { - wpa_printf(MSG_DEBUG, "RSN: removed current PMKSA entry"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "RSN: removed current PMKSA entry"); sm->cur_pmksa = NULL; if (replace) { @@ -1984,8 +2046,8 @@ struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx) sm->pmksa = pmksa_cache_init(wpa_sm_pmksa_free_cb, sm, sm); if (sm->pmksa == NULL) { - wpa_printf(MSG_ERROR, "RSN: PMKSA cache initialization " - "failed"); + wpa_msg(sm->ctx->msg_ctx, MSG_ERROR, + "RSN: PMKSA cache initialization failed"); os_free(sm); return NULL; } @@ -2032,7 +2094,8 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) if (sm == NULL) return; - wpa_printf(MSG_DEBUG, "WPA: Association event - clear replay counter"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: Association event - clear replay counter"); os_memcpy(sm->bssid, bssid, ETH_ALEN); os_memset(sm->rx_replay_counter, 0, WPA_REPLAY_COUNTER_LEN); sm->rx_replay_counter_set = 0; @@ -2061,7 +2124,7 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) * IEEE 802.11, 8.4.10: Delete PTK SA on (re)association if * this is not part of a Fast BSS Transition. */ - wpa_printf(MSG_DEBUG, "WPA: Clear old PTK"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Clear old PTK"); sm->ptk_set = 0; sm->tptk_set = 0; } @@ -2432,7 +2495,8 @@ int wpa_sm_set_assoc_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len) os_free(sm->assoc_wpa_ie); if (ie == NULL || len == 0) { - wpa_printf(MSG_DEBUG, "WPA: clearing own WPA/RSN IE"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: clearing own WPA/RSN IE"); sm->assoc_wpa_ie = NULL; sm->assoc_wpa_ie_len = 0; } else { @@ -2466,7 +2530,8 @@ int wpa_sm_set_ap_wpa_ie(struct wpa_sm *sm, const u8 *ie, size_t len) os_free(sm->ap_wpa_ie); if (ie == NULL || len == 0) { - wpa_printf(MSG_DEBUG, "WPA: clearing AP WPA IE"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: clearing AP WPA IE"); sm->ap_wpa_ie = NULL; sm->ap_wpa_ie_len = 0; } else { @@ -2500,7 +2565,8 @@ int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len) os_free(sm->ap_rsn_ie); if (ie == NULL || len == 0) { - wpa_printf(MSG_DEBUG, "WPA: clearing AP RSN IE"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: clearing AP RSN IE"); sm->ap_rsn_ie = NULL; sm->ap_rsn_ie_len = 0; } else { @@ -2529,8 +2595,8 @@ int wpa_sm_set_ap_rsn_ie(struct wpa_sm *sm, const u8 *ie, size_t len) int wpa_sm_parse_own_wpa_ie(struct wpa_sm *sm, struct wpa_ie_data *data) { if (sm == NULL || sm->assoc_wpa_ie == NULL) { - wpa_printf(MSG_DEBUG, "WPA: No WPA/RSN IE available from " - "association info"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, + "WPA: No WPA/RSN IE available from association info"); return -1; } if (wpa_parse_wpa_ie(sm->assoc_wpa_ie, sm->assoc_wpa_ie_len, data)) @@ -2551,7 +2617,7 @@ int wpa_sm_pmksa_cache_list(struct wpa_sm *sm, char *buf, size_t len) void wpa_sm_drop_sa(struct wpa_sm *sm) { - wpa_printf(MSG_DEBUG, "WPA: Clear old PMK and PTK"); + wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Clear old PMK and PTK"); sm->ptk_set = 0; sm->tptk_set = 0; os_memset(sm->pmk, 0, sizeof(sm->pmk)); diff --git a/src/utils/wpa_debug.h b/src/utils/wpa_debug.h index ee258ffec..018d63423 100644 --- a/src/utils/wpa_debug.h +++ b/src/utils/wpa_debug.h @@ -36,6 +36,7 @@ enum { #define wpa_hexdump_ascii_key(l,t,b,le) do { } while (0) #define wpa_debug_open_file(p) do { } while (0) #define wpa_debug_close_file() do { } while (0) +#define wpa_dbg(args...) do { } while (0) #else /* CONFIG_NO_STDOUT_DEBUG */ @@ -141,6 +142,14 @@ void wpa_hexdump_ascii(int level, const char *title, const u8 *buf, void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf, size_t len); +/* + * wpa_dbg() behaves like wpa_msg(), but it can be removed from build to reduce + * binary size. As such, it should be used with debugging messages that are not + * needed in the control interface while wpa_msg() has to be used for anything + * that needs to shown to control interface monitors. + */ +#define wpa_dbg(args...) wpa_msg(args) + #endif /* CONFIG_NO_STDOUT_DEBUG */ diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index dc978afae..07f92f1ea 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -65,9 +65,9 @@ static void wpa_bss_remove(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) dl_list_del(&bss->list); dl_list_del(&bss->list_id); wpa_s->num_bss--; - wpa_printf(MSG_DEBUG, "BSS: Remove id %u BSSID " MACSTR " SSID '%s'", - bss->id, MAC2STR(bss->bssid), - wpa_ssid_txt(bss->ssid, bss->ssid_len)); + wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Remove id %u BSSID " MACSTR + " SSID '%s'", bss->id, MAC2STR(bss->bssid), + wpa_ssid_txt(bss->ssid, bss->ssid_len)); wpas_notify_bss_removed(wpa_s, bss->bssid, bss->id); os_free(bss); } @@ -133,8 +133,9 @@ static void wpa_bss_add(struct wpa_supplicant *wpa_s, dl_list_add_tail(&wpa_s->bss, &bss->list); dl_list_add_tail(&wpa_s->bss_id, &bss->list_id); wpa_s->num_bss++; - wpa_printf(MSG_DEBUG, "BSS: Add new id %u BSSID " MACSTR " SSID '%s'", - bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len)); + wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Add new id %u BSSID " MACSTR + " SSID '%s'", + bss->id, MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len)); wpas_notify_bss_added(wpa_s, bss->bssid, bss->id); if (wpa_s->num_bss > wpa_s->conf->bss_max_count) { /* Remove the oldest entry */ @@ -317,8 +318,8 @@ static int wpa_bss_in_use(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) void wpa_bss_update_start(struct wpa_supplicant *wpa_s) { wpa_s->bss_update_idx++; - wpa_printf(MSG_DEBUG, "BSS: Start scan result update %u", - wpa_s->bss_update_idx); + wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Start scan result update %u", + wpa_s->bss_update_idx); } @@ -330,13 +331,13 @@ void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s, ssid = wpa_scan_get_ie(res, WLAN_EID_SSID); if (ssid == NULL) { - wpa_printf(MSG_DEBUG, "BSS: No SSID IE included for " MACSTR, - MAC2STR(res->bssid)); + wpa_dbg(wpa_s, MSG_DEBUG, "BSS: No SSID IE included for " + MACSTR, MAC2STR(res->bssid)); return; } if (ssid[1] > 32) { - wpa_printf(MSG_DEBUG, "BSS: Too long SSID IE included for " - MACSTR, MAC2STR(res->bssid)); + wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Too long SSID IE included for " + MACSTR, MAC2STR(res->bssid)); return; } @@ -412,8 +413,8 @@ void wpa_bss_update_end(struct wpa_supplicant *wpa_s, struct scan_info *info, if (bss->last_update_idx < wpa_s->bss_update_idx) bss->scan_miss_count++; if (bss->scan_miss_count >= WPA_BSS_EXPIRATION_SCAN_COUNT) { - wpa_printf(MSG_DEBUG, "BSS: Expire BSS %u due to no " - "match in scan", bss->id); + wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Expire BSS %u due to " + "no match in scan", bss->id); wpa_bss_remove(wpa_s, bss); } } @@ -437,8 +438,8 @@ static void wpa_bss_timeout(void *eloop_ctx, void *timeout_ctx) continue; if (os_time_before(&bss->last_update, &t)) { - wpa_printf(MSG_DEBUG, "BSS: Expire BSS %u due to age", - bss->id); + wpa_dbg(wpa_s, MSG_DEBUG, "BSS: Expire BSS %u due to " + "age", bss->id); wpa_bss_remove(wpa_s, bss); } else break; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index e8735e6b5..b03c52b95 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -53,22 +53,22 @@ static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s) if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid) return 0; - wpa_printf(MSG_DEBUG, "Select network based on association " - "information"); + wpa_dbg(wpa_s, MSG_DEBUG, "Select network based on association " + "information"); ssid = wpa_supplicant_get_ssid(wpa_s); if (ssid == NULL) { - wpa_printf(MSG_INFO, "No network configuration found for the " - "current AP"); + wpa_msg(wpa_s, MSG_INFO, + "No network configuration found for the current AP"); return -1; } if (ssid->disabled) { - wpa_printf(MSG_DEBUG, "Selected network is disabled"); + wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is disabled"); return -1; } - wpa_printf(MSG_DEBUG, "Network configuration found for the current " - "AP"); + wpa_dbg(wpa_s, MSG_DEBUG, "Network configuration found for the " + "current AP"); if (ssid->key_mgmt & (WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_IEEE8021X | WPA_KEY_MGMT_WPA_NONE | WPA_KEY_MGMT_FT_PSK | WPA_KEY_MGMT_FT_IEEE8021X | @@ -153,8 +153,8 @@ static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s) } } - wpa_printf(MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from PMKSA " - "cache", pmksa_set == 0 ? "" : "not "); + wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from " + "PMKSA cache", pmksa_set == 0 ? "" : "not "); } @@ -162,14 +162,15 @@ static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s, union wpa_event_data *data) { if (data == NULL) { - wpa_printf(MSG_DEBUG, "RSN: No data in PMKID candidate event"); + wpa_dbg(wpa_s, MSG_DEBUG, "RSN: No data in PMKID candidate " + "event"); return; } - wpa_printf(MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR - " index=%d preauth=%d", - MAC2STR(data->pmkid_candidate.bssid), - data->pmkid_candidate.index, - data->pmkid_candidate.preauth); + wpa_dbg(wpa_s, MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR + " index=%d preauth=%d", + MAC2STR(data->pmkid_candidate.bssid), + data->pmkid_candidate.index, + data->pmkid_candidate.preauth); pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid, data->pmkid_candidate.index, @@ -240,13 +241,14 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s, aka = 0; if (!sim && !aka) { - wpa_printf(MSG_DEBUG, "Selected network is configured to use " - "SIM, but neither EAP-SIM nor EAP-AKA are enabled"); + wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to " + "use SIM, but neither EAP-SIM nor EAP-AKA are " + "enabled"); return 0; } - wpa_printf(MSG_DEBUG, "Selected network is configured to use SIM " - "(sim=%d aka=%d) - initialize PCSC", sim, aka); + wpa_dbg(wpa_s, MSG_DEBUG, "Selected network is configured to use SIM " + "(sim=%d aka=%d) - initialize PCSC", sim, aka); if (sim && aka) type = SCARD_TRY_BOTH; else if (aka) @@ -256,8 +258,8 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s, wpa_s->scard = scard_init(type); if (wpa_s->scard == NULL) { - wpa_printf(MSG_WARNING, "Failed to initialize SIM " - "(pcsc-lite)"); + wpa_msg(wpa_s, MSG_WARNING, "Failed to initialize SIM " + "(pcsc-lite)"); return -1; } wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard); @@ -326,52 +328,53 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s, proto_match++; if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) { - wpa_printf(MSG_DEBUG, " skip RSN IE - parse failed"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - parse " + "failed"); break; } if (wep_ok && (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104))) { - wpa_printf(MSG_DEBUG, " selected based on TSN in " - "RSN IE"); + wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN " + "in RSN IE"); return 1; } if (!(ie.proto & ssid->proto)) { - wpa_printf(MSG_DEBUG, " skip RSN IE - proto " - "mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - proto " + "mismatch"); break; } if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) { - wpa_printf(MSG_DEBUG, " skip RSN IE - PTK cipher " - "mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - PTK " + "cipher mismatch"); break; } if (!(ie.group_cipher & ssid->group_cipher)) { - wpa_printf(MSG_DEBUG, " skip RSN IE - GTK cipher " - "mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - GTK " + "cipher mismatch"); break; } if (!(ie.key_mgmt & ssid->key_mgmt)) { - wpa_printf(MSG_DEBUG, " skip RSN IE - key mgmt " - "mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - key mgmt " + "mismatch"); break; } #ifdef CONFIG_IEEE80211W if (!(ie.capabilities & WPA_CAPABILITY_MFPC) && ssid->ieee80211w == MGMT_FRAME_PROTECTION_REQUIRED) { - wpa_printf(MSG_DEBUG, " skip RSN IE - no mgmt frame " - "protection"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip RSN IE - no mgmt " + "frame protection"); break; } #endif /* CONFIG_IEEE80211W */ - wpa_printf(MSG_DEBUG, " selected based on RSN IE"); + wpa_dbg(wpa_s, MSG_DEBUG, " selected based on RSN IE"); return 1; } @@ -380,49 +383,50 @@ static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s, proto_match++; if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) { - wpa_printf(MSG_DEBUG, " skip WPA IE - parse failed"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - parse " + "failed"); break; } if (wep_ok && (ie.group_cipher & (WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104))) { - wpa_printf(MSG_DEBUG, " selected based on TSN in " - "WPA IE"); + wpa_dbg(wpa_s, MSG_DEBUG, " selected based on TSN " + "in WPA IE"); return 1; } if (!(ie.proto & ssid->proto)) { - wpa_printf(MSG_DEBUG, " skip WPA IE - proto " - "mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - proto " + "mismatch"); break; } if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) { - wpa_printf(MSG_DEBUG, " skip WPA IE - PTK cipher " - "mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - PTK " + "cipher mismatch"); break; } if (!(ie.group_cipher & ssid->group_cipher)) { - wpa_printf(MSG_DEBUG, " skip WPA IE - GTK cipher " - "mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - GTK " + "cipher mismatch"); break; } if (!(ie.key_mgmt & ssid->key_mgmt)) { - wpa_printf(MSG_DEBUG, " skip WPA IE - key mgmt " - "mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip WPA IE - key mgmt " + "mismatch"); break; } - wpa_printf(MSG_DEBUG, " selected based on WPA IE"); + wpa_dbg(wpa_s, MSG_DEBUG, " selected based on WPA IE"); return 1; } if ((ssid->proto & (WPA_PROTO_WPA | WPA_PROTO_RSN)) && wpa_key_mgmt_wpa(ssid->key_mgmt) && proto_match == 0) { - wpa_printf(MSG_DEBUG, " skip - no WPA/RSN proto match"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - no WPA/RSN proto match"); return 0; } @@ -466,12 +470,11 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, ie = wpa_scan_get_ie(bss, WLAN_EID_RSN); rsn_ie_len = ie ? ie[1] : 0; - wpa_printf(MSG_DEBUG, "%d: " MACSTR " ssid='%s' " - "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s", - i, MAC2STR(bss->bssid), wpa_ssid_txt(ssid_, ssid_len), - wpa_ie_len, rsn_ie_len, bss->caps, bss->level, - wpa_scan_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? - " wps" : ""); + wpa_dbg(wpa_s, MSG_DEBUG, "%d: " MACSTR " ssid='%s' " + "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x level=%d%s", + i, MAC2STR(bss->bssid), wpa_ssid_txt(ssid_, ssid_len), + wpa_ie_len, rsn_ie_len, bss->caps, bss->level, + wpa_scan_get_vendor_ie(bss, WPS_IE_VENDOR_TYPE) ? " wps" : ""); e = wpa_blacklist_get(wpa_s, bss->bssid); if (e) { @@ -488,14 +491,14 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, limit = 0; } if (e->count > limit) { - wpa_printf(MSG_DEBUG, " skip - blacklisted " - "(count=%d limit=%d)", e->count, limit); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted " + "(count=%d limit=%d)", e->count, limit); return 0; } } if (ssid_len == 0) { - wpa_printf(MSG_DEBUG, " skip - SSID not known"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID not known"); return 0; } @@ -505,13 +508,14 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, int check_ssid = wpa ? 1 : (ssid->ssid_len != 0); if (ssid->disabled) { - wpa_printf(MSG_DEBUG, " skip - disabled"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - disabled"); continue; } #ifdef CONFIG_WPS if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && e && e->count > 0) { - wpa_printf(MSG_DEBUG, " skip - blacklisted (WPS)"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - blacklisted " + "(WPS)"); continue; } @@ -533,13 +537,13 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, if (check_ssid && (ssid_len != ssid->ssid_len || os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) { - wpa_printf(MSG_DEBUG, " skip - SSID mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID mismatch"); continue; } if (ssid->bssid_set && os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0) { - wpa_printf(MSG_DEBUG, " skip - BSSID mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - BSSID mismatch"); continue; } @@ -550,25 +554,26 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, !(ssid->key_mgmt & WPA_KEY_MGMT_NONE) && !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) && !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA)) { - wpa_printf(MSG_DEBUG, " skip - non-WPA network not " - "allowed"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - non-WPA network " + "not allowed"); continue; } if (!wpa && !wpa_supplicant_match_privacy(bss, ssid)) { - wpa_printf(MSG_DEBUG, " skip - privacy mismatch"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - privacy " + "mismatch"); continue; } if (!wpa && (bss->caps & IEEE80211_CAP_IBSS)) { - wpa_printf(MSG_DEBUG, " skip - IBSS (adhoc) " - "network"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - IBSS (adhoc) " + "network"); continue; } if (!freq_allowed(ssid->freq_list, bss->freq)) { - wpa_printf(MSG_DEBUG, " skip - frequency not " - "allowed"); + wpa_dbg(wpa_s, MSG_DEBUG, " skip - frequency not " + "allowed"); continue; } @@ -597,8 +602,8 @@ wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, { size_t i; - wpa_printf(MSG_DEBUG, "Selecting BSS from priority group %d", - group->priority); + wpa_dbg(wpa_s, MSG_DEBUG, "Selecting BSS from priority group %d", + group->priority); for (i = 0; i < scan_res->num; i++) { struct wpa_scan_res *bss = scan_res->res[i]; @@ -613,8 +618,9 @@ wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, ssid = ie ? ie + 2 : (u8 *) ""; ssid_len = ie ? ie[1] : 0; - wpa_printf(MSG_DEBUG, " selected BSS " MACSTR " ssid='%s'", - MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len)); + wpa_dbg(wpa_s, MSG_DEBUG, " selected BSS " MACSTR + " ssid='%s'", + MAC2STR(bss->bssid), wpa_ssid_txt(ssid, ssid_len)); return wpa_bss_get(wpa_s, bss->bssid, ssid, ssid_len); } @@ -640,8 +646,8 @@ wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s, } if (selected == NULL && wpa_s->blacklist) { - wpa_printf(MSG_DEBUG, "No APs found - clear blacklist " - "and try again"); + wpa_dbg(wpa_s, MSG_DEBUG, "No APs found - clear " + "blacklist and try again"); wpa_blacklist_clear(wpa_s); wpa_s->blacklist_cleared++; } else if (selected == NULL) @@ -702,8 +708,8 @@ void wpa_supplicant_connect(struct wpa_supplicant *wpa_s, } wpa_supplicant_associate(wpa_s, selected, ssid); } else { - wpa_printf(MSG_DEBUG, "Already associated with the selected " - "AP"); + wpa_dbg(wpa_s, MSG_DEBUG, "Already associated with the " + "selected AP"); } } @@ -795,17 +801,17 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, if (!current_bss) return 1; /* current BSS not seen in scan results */ - wpa_printf(MSG_DEBUG, "Considering within-ESS reassociation"); - wpa_printf(MSG_DEBUG, "Current BSS: " MACSTR " level=%d", - MAC2STR(current_bss->bssid), current_bss->level); - wpa_printf(MSG_DEBUG, "Selected BSS: " MACSTR " level=%d", - MAC2STR(selected->bssid), selected->level); + wpa_dbg(wpa_s, MSG_DEBUG, "Considering within-ESS reassociation"); + wpa_dbg(wpa_s, MSG_DEBUG, "Current BSS: " MACSTR " level=%d", + MAC2STR(current_bss->bssid), current_bss->level); + wpa_dbg(wpa_s, MSG_DEBUG, "Selected BSS: " MACSTR " level=%d", + MAC2STR(selected->bssid), selected->level); if (wpa_s->current_ssid->bssid_set && os_memcmp(selected->bssid, wpa_s->current_ssid->bssid, ETH_ALEN) == 0) { - wpa_printf(MSG_DEBUG, "Allow reassociation - selected BSS has " - "preferred BSSID"); + wpa_dbg(wpa_s, MSG_DEBUG, "Allow reassociation - selected BSS " + "has preferred BSSID"); return 1; } @@ -823,8 +829,8 @@ static int wpa_supplicant_need_to_roam(struct wpa_supplicant *wpa_s, min_diff = 5; } if (abs(current_bss->level - selected->level) < min_diff) { - wpa_printf(MSG_DEBUG, "Skip roam - too small difference in " - "signal level"); + wpa_dbg(wpa_s, MSG_DEBUG, "Skip roam - too small difference " + "in signal level"); return 0; } @@ -853,8 +859,8 @@ static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, if (scan_res == NULL) { if (wpa_s->conf->ap_scan == 2 || ap) return; - wpa_printf(MSG_DEBUG, "Failed to get scan results - try " - "scanning again"); + wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results - try " + "scanning again"); wpa_supplicant_req_new_scan(wpa_s, 1, 0); return; } @@ -889,12 +895,12 @@ static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, } if (ap) { - wpa_printf(MSG_DEBUG, "Ignore scan results in AP mode"); + wpa_dbg(wpa_s, MSG_DEBUG, "Ignore scan results in AP mode"); wpa_scan_results_free(scan_res); return; } - wpa_printf(MSG_DEBUG, "%s: New scan results available", wpa_s->ifname); + wpa_dbg(wpa_s, MSG_DEBUG, "New scan results available"); wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS); wpas_notify_scan_results(wpa_s); @@ -930,10 +936,10 @@ static void _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, wpa_supplicant_connect(wpa_s, selected, ssid); } else { wpa_scan_results_free(scan_res); - wpa_printf(MSG_DEBUG, "No suitable network found"); + wpa_dbg(wpa_s, MSG_DEBUG, "No suitable network found"); ssid = wpa_supplicant_pick_new_network(wpa_s); if (ssid) { - wpa_printf(MSG_DEBUG, "Setup a new network"); + wpa_dbg(wpa_s, MSG_DEBUG, "Setup a new network"); wpa_supplicant_associate(wpa_s, NULL, ssid); } else { int timeout_sec = 5; @@ -974,9 +980,8 @@ static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, if (rn == NULL || rn[0] == '\0') return; - wpa_printf(MSG_DEBUG, "%s: Checking for other virtual interfaces " - "sharing same radio (%s) in event_scan_results", - wpa_s->ifname, rn); + wpa_dbg(wpa_s, MSG_DEBUG, "Checking for other virtual interfaces " + "sharing same radio (%s) in event_scan_results", rn); for (ifs = wpa_s->global->ifaces; ifs; ifs = ifs->next) { if (ifs == wpa_s || !ifs->driver->get_radio_name) @@ -1000,7 +1005,7 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s, int l, len, found = 0, wpa_found, rsn_found; const u8 *p; - wpa_printf(MSG_DEBUG, "Association info event"); + wpa_dbg(wpa_s, MSG_DEBUG, "Association info event"); if (data->assoc_info.req_ies) wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies, data->assoc_info.req_ies_len); @@ -1012,7 +1017,8 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s, data->assoc_info.beacon_ies, data->assoc_info.beacon_ies_len); if (data->assoc_info.freq) - wpa_printf(MSG_DEBUG, "freq=%u MHz", data->assoc_info.freq); + wpa_dbg(wpa_s, MSG_DEBUG, "freq=%u MHz", + data->assoc_info.freq); p = data->assoc_info.req_ies; l = data->assoc_info.req_ies_len; @@ -1049,8 +1055,8 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s, data->assoc_info.resp_ies, data->assoc_info.resp_ies_len, bssid) < 0) { - wpa_printf(MSG_DEBUG, "FT: Validation of " - "Reassociation Response failed"); + wpa_dbg(wpa_s, MSG_DEBUG, "FT: Validation of " + "Reassociation Response failed"); wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_INVALID_IE); return -1; @@ -1066,8 +1072,8 @@ static int wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s, struct wpabuf *wps; wps = ieee802_11_vendor_ie_concat(p, l, WPS_IE_VENDOR_TYPE); if (wps == NULL) { - wpa_printf(MSG_INFO, "WPS-STRICT: AP did not include " - "WPS IE in (Re)Association Response"); + wpa_msg(wpa_s, MSG_INFO, "WPS-STRICT: AP did not " + "include WPS IE in (Re)Association Response"); return -1; } @@ -1177,7 +1183,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME) || (wpa_drv_get_bssid(wpa_s, bssid) >= 0 && os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0)) { - wpa_msg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID=" + wpa_dbg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID=" MACSTR, MAC2STR(bssid)); random_add_randomness(bssid, ETH_ALEN); bssid_changed = os_memcmp(wpa_s->bssid, bssid, ETH_ALEN); @@ -1280,9 +1286,9 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, if (age.sec == 0 && age.usec < 100000 && os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) == 0) { - wpa_printf(MSG_DEBUG, "Process pending EAPOL frame " - "that was received just before association " - "notification"); + wpa_dbg(wpa_s, MSG_DEBUG, "Process pending EAPOL " + "frame that was received just before " + "association notification"); wpa_supplicant_rx_eapol( wpa_s, wpa_s->pending_eapol_rx_src, wpabuf_head(wpa_s->pending_eapol_rx), @@ -1297,8 +1303,8 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, bgscan_deinit(wpa_s); if (wpa_s->current_ssid && wpa_s->current_ssid->bgscan) { if (bgscan_init(wpa_s, wpa_s->current_ssid)) { - wpa_printf(MSG_DEBUG, "Failed to initialize " - "bgscan"); + wpa_dbg(wpa_s, MSG_DEBUG, "Failed to " + "initialize bgscan"); /* * Live without bgscan; it is only used as a * roaming optimization, so the initial @@ -1347,8 +1353,8 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s, * generating streams of disconnected events when configuring * IBSS for WPA-None. Ignore them for now. */ - wpa_printf(MSG_DEBUG, "Disconnect event - ignore in " - "IBSS/WPA-None mode"); + wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - ignore in " + "IBSS/WPA-None mode"); return; } @@ -1359,14 +1365,14 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s, } if (!wpa_s->auto_reconnect_disabled || wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) { - wpa_printf(MSG_DEBUG, "WPA: Auto connect enabled: try to " - "reconnect (wps=%d)", - wpa_s->key_mgmt == WPA_KEY_MGMT_WPS); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Auto connect enabled: try to " + "reconnect (wps=%d)", + wpa_s->key_mgmt == WPA_KEY_MGMT_WPS); if (wpa_s->wpa_state >= WPA_ASSOCIATING) wpa_supplicant_req_scan(wpa_s, 0, 100000); } else { - wpa_printf(MSG_DEBUG, "WPA: Auto connect disabled: do not try " - "to re-connect"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Auto connect disabled: do not " + "try to re-connect"); wpa_s->reassociate = 0; wpa_s->disconnected = 1; } @@ -1379,7 +1385,7 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s, " reason=%d", MAC2STR(bssid), reason_code); if (wpa_supplicant_dynamic_keys(wpa_s)) { - wpa_printf(MSG_DEBUG, "Disconnect event - remove keys"); + wpa_dbg(wpa_s, MSG_DEBUG, "Disconnect event - remove keys"); wpa_s->keys_cleared = 0; wpa_clear_keys(wpa_s, wpa_s->bssid); } @@ -1394,8 +1400,8 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s, * requires us to remain in authenticating state to allow the * second authentication attempt to be continued properly. */ - wpa_printf(MSG_DEBUG, "SME: Allow pending authentication to " - "proceed after disconnection event"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Allow pending authentication " + "to proceed after disconnection event"); wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING); os_memcpy(wpa_s->pending_bssid, prev_pending_bssid, ETH_ALEN); } @@ -1412,7 +1418,7 @@ static void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx, if (!wpa_s->pending_mic_error_report) return; - wpa_printf(MSG_DEBUG, "WPA: Sending pending MIC error report"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Sending pending MIC error report"); wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise); wpa_s->pending_mic_error_report = 0; } @@ -1487,8 +1493,8 @@ wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s, sec = os_random() % 60; else sec = WPA_GET_BE32(rval) % 60; - wpa_printf(MSG_DEBUG, "WPA: Delay MIC error report %d " - "seconds", sec); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Delay MIC error " + "report %d seconds", sec); wpa_s->pending_mic_error_report = 1; wpa_s->pending_mic_error_pairwise = pairwise; eloop_cancel_timeout( @@ -1535,14 +1541,14 @@ wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s, if (!wpa_s->interface_removed) break; wpa_s->interface_removed = 0; - wpa_printf(MSG_DEBUG, "Configured interface was added."); + wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was added"); if (wpa_supplicant_driver_init(wpa_s) < 0) { - wpa_printf(MSG_INFO, "Failed to initialize the driver " - "after interface was added."); + wpa_msg(wpa_s, MSG_INFO, "Failed to initialize the " + "driver after interface was added"); } break; case EVENT_INTERFACE_REMOVED: - wpa_printf(MSG_DEBUG, "Configured interface was removed."); + wpa_dbg(wpa_s, MSG_DEBUG, "Configured interface was removed"); wpa_s->interface_removed = 1; wpa_supplicant_mark_disassoc(wpa_s); l2_packet_deinit(wpa_s->l2); @@ -1624,19 +1630,19 @@ static void ft_rx_action(struct wpa_supplicant *wpa_s, const u8 *data, sta_addr = data + 1; target_ap_addr = data + 1 + ETH_ALEN; status = WPA_GET_LE16(data + 1 + 2 * ETH_ALEN); - wpa_printf(MSG_DEBUG, "FT: Received FT Action Response: STA " MACSTR - " TargetAP " MACSTR " status %u", - MAC2STR(sta_addr), MAC2STR(target_ap_addr), status); + wpa_dbg(wpa_s, MSG_DEBUG, "FT: Received FT Action Response: STA " + MACSTR " TargetAP " MACSTR " status %u", + MAC2STR(sta_addr), MAC2STR(target_ap_addr), status); if (os_memcmp(sta_addr, wpa_s->own_addr, ETH_ALEN) != 0) { - wpa_printf(MSG_DEBUG, "FT: Foreign STA Address " MACSTR - " in FT Action Response", MAC2STR(sta_addr)); + wpa_dbg(wpa_s, MSG_DEBUG, "FT: Foreign STA Address " MACSTR + " in FT Action Response", MAC2STR(sta_addr)); return; } if (status) { - wpa_printf(MSG_DEBUG, "FT: FT Action Response indicates " - "failure (status code %d)", status); + wpa_dbg(wpa_s, MSG_DEBUG, "FT: FT Action Response indicates " + "failure (status code %d)", status); /* TODO: report error to FT code(?) */ return; } @@ -1696,13 +1702,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED && event != EVENT_INTERFACE_ENABLED && event != EVENT_INTERFACE_STATUS) { - wpa_printf(MSG_DEBUG, "Ignore event %d while interface is " - "disabled", event); + wpa_dbg(wpa_s, MSG_DEBUG, "Ignore event %d while interface is " + "disabled", event); return; } - wpa_printf(MSG_DEBUG, "Event %d received on interface %s", - event, wpa_s->ifname); + wpa_dbg(wpa_s, MSG_DEBUG, "Event %d received on interface %s", + event, wpa_s->ifname); switch (event) { case EVENT_AUTH: @@ -1712,13 +1718,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, wpa_supplicant_event_assoc(wpa_s, data); break; case EVENT_DISASSOC: - wpa_printf(MSG_DEBUG, "Disassociation notification"); + wpa_dbg(wpa_s, MSG_DEBUG, "Disassociation notification"); if (data) { - wpa_printf(MSG_DEBUG, " * reason %u", - data->disassoc_info.reason_code); + wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u", + data->disassoc_info.reason_code); if (data->disassoc_info.addr) - wpa_printf(MSG_DEBUG, " * address " MACSTR, - MAC2STR(data->disassoc_info.addr)); + wpa_dbg(wpa_s, MSG_DEBUG, " * address " MACSTR, + MAC2STR(data->disassoc_info.addr)); } #ifdef CONFIG_AP if (wpa_s->ap_iface && data && data->disassoc_info.addr) { @@ -1744,16 +1750,17 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, /* fall through */ case EVENT_DEAUTH: if (event == EVENT_DEAUTH) { - wpa_printf(MSG_DEBUG, "Deauthentication notification"); + wpa_dbg(wpa_s, MSG_DEBUG, + "Deauthentication notification"); if (data) { reason_code = data->deauth_info.reason_code; - wpa_printf(MSG_DEBUG, " * reason %u", - data->deauth_info.reason_code); + wpa_dbg(wpa_s, MSG_DEBUG, " * reason %u", + data->deauth_info.reason_code); if (data->deauth_info.addr) { - wpa_printf(MSG_DEBUG, " * address " - MACSTR, - MAC2STR(data->deauth_info. - addr)); + wpa_dbg(wpa_s, MSG_DEBUG, " * address " + MACSTR, + MAC2STR(data->deauth_info. + addr)); } wpa_hexdump(MSG_DEBUG, "Deauthentication frame IE(s)", @@ -1832,10 +1839,10 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, break; #ifdef CONFIG_AP case EVENT_TX_STATUS: - wpa_printf(MSG_DEBUG, "EVENT_TX_STATUS on %s dst=" MACSTR - " type=%d stype=%d", - wpa_s->ifname, MAC2STR(data->tx_status.dst), - data->tx_status.type, data->tx_status.stype); + wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS dst=" MACSTR + " type=%d stype=%d", + MAC2STR(data->tx_status.dst), + data->tx_status.type, data->tx_status.stype); if (wpa_s->ap_iface == NULL) { #ifdef CONFIG_P2P if (data->tx_status.type == WLAN_FC_TYPE_MGMT && @@ -1851,8 +1858,8 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, break; } #ifdef CONFIG_P2P - wpa_printf(MSG_DEBUG, "EVENT_TX_STATUS pending_dst=" MACSTR, - MAC2STR(wpa_s->parent->pending_action_dst)); + wpa_dbg(wpa_s, MSG_DEBUG, "EVENT_TX_STATUS pending_dst=" + MACSTR, MAC2STR(wpa_s->parent->pending_action_dst)); /* * Catch TX status events for Action frames we sent via group * interface in GO mode. @@ -1912,19 +1919,19 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, break; } #endif /* CONFIG_P2P */ - wpa_printf(MSG_DEBUG, "AP: ignore received management " - "frame in non-AP mode"); + wpa_dbg(wpa_s, MSG_DEBUG, "AP: ignore received " + "management frame in non-AP mode"); break; } ap_mgmt_rx(wpa_s, &data->rx_mgmt); break; #endif /* CONFIG_AP */ case EVENT_RX_ACTION: - wpa_printf(MSG_DEBUG, "Received Action frame: SA=" MACSTR - " Category=%u DataLen=%d freq=%d MHz", - MAC2STR(data->rx_action.sa), - data->rx_action.category, (int) data->rx_action.len, - data->rx_action.freq); + wpa_dbg(wpa_s, MSG_DEBUG, "Received Action frame: SA=" MACSTR + " Category=%u DataLen=%d freq=%d MHz", + MAC2STR(data->rx_action.sa), + data->rx_action.category, (int) data->rx_action.len, + data->rx_action.freq); #ifdef CONFIG_IEEE80211R if (data->rx_action.category == WLAN_ACTION_FT) { ft_rx_action(wpa_s, data->rx_action.data, @@ -2047,7 +2054,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, data->signal_change.current_txrate); break; case EVENT_INTERFACE_ENABLED: - wpa_printf(MSG_DEBUG, "Interface was enabled"); + wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled"); if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) { #ifdef CONFIG_AP if (!wpa_s->ap_iface) { @@ -2064,7 +2071,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, } break; case EVENT_INTERFACE_DISABLED: - wpa_printf(MSG_DEBUG, "Interface was disabled"); + wpa_dbg(wpa_s, MSG_DEBUG, "Interface was disabled"); wpa_supplicant_mark_disassoc(wpa_s); wpa_supplicant_set_state(wpa_s, WPA_INTERFACE_DISABLED); break; @@ -2081,9 +2088,10 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, #endif /* CONFIG_P2P */ break; case EVENT_BEST_CHANNEL: - wpa_printf(MSG_DEBUG, "Best channel event received (%d %d %d)", - data->best_chan.freq_24, data->best_chan.freq_5, - data->best_chan.freq_overall); + wpa_dbg(wpa_s, MSG_DEBUG, "Best channel event received " + "(%d %d %d)", + data->best_chan.freq_24, data->best_chan.freq_5, + data->best_chan.freq_overall); wpa_s->best_24_freq = data->best_chan.freq_24; wpa_s->best_5_freq = data->best_chan.freq_5; wpa_s->best_overall_freq = data->best_chan.freq_overall; @@ -2109,7 +2117,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, #endif /* CONFIG_AP */ break; default: - wpa_printf(MSG_INFO, "Unknown event %d", event); + wpa_msg(wpa_s, MSG_INFO, "Unknown event %d", event); break; } } diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 074d75ba6..5982ed4e5 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -44,8 +44,8 @@ static void wpa_supplicant_gen_assoc_event(struct wpa_supplicant *wpa_s) wpas_notify_network_changed(wpa_s); } wpa_supplicant_initiate_eapol(wpa_s); - wpa_printf(MSG_DEBUG, "Already associated with a configured network - " - "generating associated event"); + wpa_dbg(wpa_s, MSG_DEBUG, "Already associated with a configured " + "network - generating associated event"); os_memset(&data, 0, sizeof(data)); wpa_supplicant_event(wpa_s, EVENT_ASSOC, &data); } @@ -100,8 +100,8 @@ static void wpa_supplicant_assoc_try(struct wpa_supplicant *wpa_s, /* ap_scan=2 mode - try to associate with each SSID. */ if (ssid == NULL) { - wpa_printf(MSG_DEBUG, "wpa_supplicant_scan: Reached " - "end of scan list - go back to beginning"); + wpa_dbg(wpa_s, MSG_DEBUG, "wpa_supplicant_assoc_try: Reached " + "end of scan list - go back to beginning"); wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; wpa_supplicant_req_scan(wpa_s, 0, 0); return; @@ -255,7 +255,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) enum wpa_states prev_state; if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) { - wpa_printf(MSG_DEBUG, "Skip scan - interface disabled"); + wpa_dbg(wpa_s, MSG_DEBUG, "Skip scan - interface disabled"); return; } @@ -266,15 +266,15 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) if (!wpa_supplicant_enabled_networks(wpa_s->conf) && !wpa_s->scan_req) { - wpa_printf(MSG_DEBUG, "No enabled networks - do not scan"); + wpa_dbg(wpa_s, MSG_DEBUG, "No enabled networks - do not scan"); wpa_supplicant_set_state(wpa_s, WPA_INACTIVE); return; } if (wpa_s->conf->ap_scan != 0 && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED)) { - wpa_printf(MSG_DEBUG, "Using wired authentication - " - "overriding ap_scan configuration"); + wpa_dbg(wpa_s, MSG_DEBUG, "Using wired authentication - " + "overriding ap_scan configuration"); wpa_s->conf->ap_scan = 0; wpas_notify_ap_scan_changed(wpa_s); } @@ -373,15 +373,17 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) if (ssid) { wpa_s->prev_scan_ssid = ssid; if (max_ssids > 1) { - wpa_printf(MSG_DEBUG, "Include wildcard SSID in the " - "scan request"); + wpa_dbg(wpa_s, MSG_DEBUG, "Include wildcard SSID in " + "the scan request"); params.num_ssids++; } - wpa_printf(MSG_DEBUG, "Starting AP scan for specific SSID(s)"); + wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for specific " + "SSID(s)"); } else { wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; params.num_ssids++; - wpa_printf(MSG_DEBUG, "Starting AP scan for wildcard SSID"); + wpa_dbg(wpa_s, MSG_DEBUG, "Starting AP scan for wildcard " + "SSID"); } #ifdef CONFIG_P2P @@ -396,16 +398,16 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) /* Optimize provisioning state scan based on GO information */ if (wpa_s->p2p_in_provisioning < 5 && wpa_s->go_params->freq > 0) { - wpa_printf(MSG_DEBUG, "P2P: Scan only GO preferred " - "frequency %d MHz", - wpa_s->go_params->freq); + wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO " + "preferred frequency %d MHz", + wpa_s->go_params->freq); params.freqs = os_zalloc(2 * sizeof(int)); if (params.freqs) params.freqs[0] = wpa_s->go_params->freq; } else if (wpa_s->p2p_in_provisioning < 8 && wpa_s->go_params->freq_list[0]) { - wpa_printf(MSG_DEBUG, "P2P: Scan only common " - "channels"); + wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only common " + "channels"); int_array_concat(¶ms.freqs, wpa_s->go_params->freq_list); if (params.freqs) @@ -421,8 +423,8 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) * Optimize post-provisioning scan based on channel used * during provisioning. */ - wpa_printf(MSG_DEBUG, "WPS: Scan only frequency %u MHz that " - "was used during provisioning", wpa_s->wps_freq); + wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz " + "that was used during provisioning", wpa_s->wps_freq); params.freqs = os_zalloc(2 * sizeof(int)); if (params.freqs) params.freqs[0] = wpa_s->wps_freq; @@ -450,8 +452,8 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) #endif /* CONFIG_P2P */ if (params.freqs == NULL && wpa_s->next_scan_freqs) { - wpa_printf(MSG_DEBUG, "Optimize scan based on previously " - "generated frequency list"); + wpa_dbg(wpa_s, MSG_DEBUG, "Optimize scan based on previously " + "generated frequency list"); params.freqs = wpa_s->next_scan_freqs; } else os_free(wpa_s->next_scan_freqs); @@ -467,7 +469,7 @@ static void wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) os_free(params.filter_ssids); if (ret) { - wpa_printf(MSG_WARNING, "Failed to initiate AP scan."); + wpa_msg(wpa_s, MSG_WARNING, "Failed to initiate AP scan"); if (prev_state != wpa_s->wpa_state) wpa_supplicant_set_state(wpa_s, prev_state); wpa_supplicant_req_scan(wpa_s, 1, 0); @@ -502,13 +504,13 @@ void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec) ssid = ssid->next; } if (ssid) { - wpa_msg(wpa_s, MSG_DEBUG, "Not rescheduling scan to " + wpa_dbg(wpa_s, MSG_DEBUG, "Not rescheduling scan to " "ensure that specific SSID scans occur"); return; } } - wpa_msg(wpa_s, MSG_DEBUG, "Setting scan request: %d sec %d usec", + wpa_dbg(wpa_s, MSG_DEBUG, "Setting scan request: %d sec %d usec", sec, usec); eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL); eloop_register_timeout(sec, usec, wpa_supplicant_scan, wpa_s, NULL); @@ -524,7 +526,7 @@ void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec) */ void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s) { - wpa_msg(wpa_s, MSG_DEBUG, "Cancelling scan request"); + wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling scan request"); eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL); } @@ -787,14 +789,14 @@ wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s, else scan_res = wpa_drv_get_scan_results2(wpa_s); if (scan_res == NULL) { - wpa_printf(MSG_DEBUG, "Failed to get scan results"); + wpa_dbg(wpa_s, MSG_DEBUG, "Failed to get scan results"); return NULL; } #ifdef CONFIG_WPS if (wpas_wps_in_progress(wpa_s)) { - wpa_printf(MSG_DEBUG, "WPS: Order scan results with WPS " - "provisioning rules"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Order scan results with WPS " + "provisioning rules"); compar = wpa_scan_result_wps_compar; } #endif /* CONFIG_WPS */ diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 60c67522d..e6a49241c 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -48,8 +48,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, int i, bssid_changed; if (bss == NULL) { - wpa_printf(MSG_ERROR, "SME: No scan result available for the " - "network"); + wpa_msg(wpa_s, MSG_ERROR, "SME: No scan result available for " + "the network"); return; } @@ -82,12 +82,12 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, } } #endif /* IEEE8021X_EAPOL */ - wpa_printf(MSG_DEBUG, "Automatic auth_alg selection: 0x%x", - params.auth_alg); + wpa_dbg(wpa_s, MSG_DEBUG, "Automatic auth_alg selection: 0x%x", + params.auth_alg); if (ssid->auth_alg) { params.auth_alg = ssid->auth_alg; - wpa_printf(MSG_DEBUG, "Overriding auth_alg selection: 0x%x", - params.auth_alg); + wpa_dbg(wpa_s, MSG_DEBUG, "Overriding auth_alg selection: " + "0x%x", params.auth_alg); } for (i = 0; i < NUM_WEP_KEYS; i++) { @@ -121,8 +121,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, if (wpa_supplicant_set_suites(wpa_s, bss, ssid, wpa_s->sme.assoc_req_ie, &wpa_s->sme.assoc_req_ie_len)) { - wpa_printf(MSG_WARNING, "SME: Failed to set WPA key " - "management and encryption suites"); + wpa_msg(wpa_s, MSG_WARNING, "SME: Failed to set WPA " + "key management and encryption suites"); return; } } else if (ssid->key_mgmt & @@ -134,9 +134,9 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, if (wpa_supplicant_set_suites(wpa_s, NULL, ssid, wpa_s->sme.assoc_req_ie, &wpa_s->sme.assoc_req_ie_len)) { - wpa_printf(MSG_WARNING, "SME: Failed to set WPA key " - "management and encryption suites (no scan " - "results)"); + wpa_msg(wpa_s, MSG_WARNING, "SME: Failed to set WPA " + "key management and encryption suites (no " + "scan results)"); return; } #ifdef CONFIG_WPS @@ -187,8 +187,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, if (wpa_s->sme.ft_used && os_memcmp(md, wpa_s->sme.mobility_domain, 2) == 0 && wpa_sm_has_ptk(wpa_s->wpa)) { - wpa_printf(MSG_DEBUG, "SME: Trying to use FT " - "over-the-air"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying to use FT " + "over-the-air"); params.auth_alg = WPA_AUTH_ALG_FT; params.ie = wpa_s->sme.ft_ies; params.ie_len = wpa_s->sme.ft_ies_len; @@ -204,8 +204,8 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, if (rsn && wpa_parse_wpa_ie(rsn, 2 + rsn[1], &_ie) == 0 && _ie.capabilities & (WPA_CAPABILITY_MFPC | WPA_CAPABILITY_MFPR)) { - wpa_printf(MSG_DEBUG, "WPA: Selected AP supports MFP: " - "require MFP"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Selected AP supports " + "MFP: require MFP"); wpa_s->sme.mfp = MGMT_FRAME_PROTECTION_REQUIRED; } } @@ -229,7 +229,7 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, wpa_supplicant_cancel_scan(wpa_s); - wpa_msg(wpa_s, MSG_INFO, "Trying to authenticate with " MACSTR + wpa_msg(wpa_s, MSG_INFO, "SME: Trying to authenticate with " MACSTR " (SSID='%s' freq=%d MHz)", MAC2STR(params.bssid), wpa_ssid_txt(params.ssid, params.ssid_len), params.freq); @@ -244,7 +244,7 @@ void sme_authenticate(struct wpa_supplicant *wpa_s, wpa_s->sme.auth_alg = params.auth_alg; if (wpa_drv_authenticate(wpa_s, ¶ms) < 0) { - wpa_msg(wpa_s, MSG_INFO, "Authentication request to the " + wpa_msg(wpa_s, MSG_INFO, "SME: Authentication request to the " "driver failed"); wpa_supplicant_req_scan(wpa_s, 1, 0); return; @@ -264,34 +264,34 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data) struct wpa_ssid *ssid = wpa_s->current_ssid; if (ssid == NULL) { - wpa_printf(MSG_DEBUG, "SME: Ignore authentication event when " - "network is not selected"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication event " + "when network is not selected"); return; } if (wpa_s->wpa_state != WPA_AUTHENTICATING) { - wpa_printf(MSG_DEBUG, "SME: Ignore authentication event when " - "not in authenticating state"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication event " + "when not in authenticating state"); return; } if (os_memcmp(wpa_s->pending_bssid, data->auth.peer, ETH_ALEN) != 0) { - wpa_printf(MSG_DEBUG, "SME: Ignore authentication with " - "unexpected peer " MACSTR, - MAC2STR(data->auth.peer)); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication with " + "unexpected peer " MACSTR, + MAC2STR(data->auth.peer)); return; } - wpa_printf(MSG_DEBUG, "SME: Authentication response: peer=" MACSTR - " auth_type=%d status_code=%d", - MAC2STR(data->auth.peer), data->auth.auth_type, - data->auth.status_code); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication response: peer=" MACSTR + " auth_type=%d status_code=%d", + MAC2STR(data->auth.peer), data->auth.auth_type, + data->auth.status_code); wpa_hexdump(MSG_MSGDUMP, "SME: Authentication response IEs", data->auth.ies, data->auth.ies_len); if (data->auth.status_code != WLAN_STATUS_SUCCESS) { - wpa_printf(MSG_DEBUG, "SME: Authentication failed (status " - "code %d)", data->auth.status_code); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication failed (status " + "code %d)", data->auth.status_code); if (data->auth.status_code != WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG || @@ -305,7 +305,7 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data) case WLAN_AUTH_OPEN: wpa_s->current_ssid->auth_alg = WPA_AUTH_ALG_SHARED; - wpa_printf(MSG_DEBUG, "SME: Trying SHARED auth"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying SHARED auth"); wpa_supplicant_associate(wpa_s, wpa_s->current_bss, wpa_s->current_ssid); return; @@ -313,7 +313,7 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data) case WLAN_AUTH_SHARED_KEY: wpa_s->current_ssid->auth_alg = WPA_AUTH_ALG_LEAP; - wpa_printf(MSG_DEBUG, "SME: Trying LEAP auth"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying LEAP auth"); wpa_supplicant_associate(wpa_s, wpa_s->current_bss, wpa_s->current_ssid); return; @@ -376,7 +376,7 @@ void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode, if (params.wpa_ie == NULL || ieee802_11_parse_elems(params.wpa_ie, params.wpa_ie_len, &elems, 0) < 0) { - wpa_printf(MSG_DEBUG, "SME: Could not parse own IEs?!"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Could not parse own IEs?!"); os_memset(&elems, 0, sizeof(elems)); } if (elems.rsn_ie) @@ -397,8 +397,8 @@ void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode, params.uapsd = -1; if (wpa_drv_associate(wpa_s, ¶ms) < 0) { - wpa_msg(wpa_s, MSG_INFO, "Association request to the driver " - "failed"); + wpa_msg(wpa_s, MSG_INFO, "SME: Association request to the " + "driver failed"); wpas_connection_failed(wpa_s, wpa_s->pending_bssid); os_memset(wpa_s->pending_bssid, 0, ETH_ALEN); return; @@ -412,7 +412,7 @@ int sme_update_ft_ies(struct wpa_supplicant *wpa_s, const u8 *md, const u8 *ies, size_t ies_len) { if (md == NULL || ies == NULL) { - wpa_printf(MSG_DEBUG, "SME: Remove mobility domain"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Remove mobility domain"); os_free(wpa_s->sme.ft_ies); wpa_s->sme.ft_ies = NULL; wpa_s->sme.ft_ies_len = 0; @@ -437,9 +437,9 @@ void sme_event_assoc_reject(struct wpa_supplicant *wpa_s, { int bssid_changed; - wpa_printf(MSG_DEBUG, "SME: Association with " MACSTR " failed: " - "status code %d", MAC2STR(wpa_s->pending_bssid), - data->assoc_reject.status_code); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association with " MACSTR " failed: " + "status code %d", MAC2STR(wpa_s->pending_bssid), + data->assoc_reject.status_code); bssid_changed = !is_zero_ether_addr(wpa_s->bssid); @@ -452,8 +452,8 @@ void sme_event_assoc_reject(struct wpa_supplicant *wpa_s, */ if (wpa_drv_deauthenticate(wpa_s, wpa_s->pending_bssid, WLAN_REASON_DEAUTH_LEAVING) < 0) { - wpa_msg(wpa_s, MSG_INFO, - "Deauth request to the driver failed"); + wpa_msg(wpa_s, MSG_INFO, "SME: Deauth request to the driver " + "failed"); } wpa_s->sme.prev_bssid_set = 0; @@ -469,7 +469,7 @@ void sme_event_assoc_reject(struct wpa_supplicant *wpa_s, void sme_event_auth_timed_out(struct wpa_supplicant *wpa_s, union wpa_event_data *data) { - wpa_printf(MSG_DEBUG, "SME: Authentication timed out"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication timed out"); wpas_connection_failed(wpa_s, wpa_s->pending_bssid); } @@ -477,7 +477,7 @@ void sme_event_auth_timed_out(struct wpa_supplicant *wpa_s, void sme_event_assoc_timed_out(struct wpa_supplicant *wpa_s, union wpa_event_data *data) { - wpa_printf(MSG_DEBUG, "SME: Association timed out"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association timed out"); wpas_connection_failed(wpa_s, wpa_s->pending_bssid); wpa_supplicant_mark_disassoc(wpa_s); } @@ -486,7 +486,7 @@ void sme_event_assoc_timed_out(struct wpa_supplicant *wpa_s, void sme_event_disassoc(struct wpa_supplicant *wpa_s, union wpa_event_data *data) { - wpa_printf(MSG_DEBUG, "SME: Disassociation event received"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Disassociation event received"); if (wpa_s->sme.prev_bssid_set && !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)) { /* @@ -495,8 +495,8 @@ void sme_event_disassoc(struct wpa_supplicant *wpa_s, * state. For now, force the state to be cleared to avoid * confusing errors if we try to associate with the AP again. */ - wpa_printf(MSG_DEBUG, "SME: Deauthenticate to clear driver " - "state"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Deauthenticate to clear " + "driver state"); wpa_drv_deauthenticate(wpa_s, wpa_s->sme.prev_bssid, WLAN_REASON_DEAUTH_LEAVING); } @@ -516,7 +516,7 @@ static int sme_check_sa_query_timeout(struct wpa_supplicant *wpa_s) os_time_sub(&now, &wpa_s->sme.sa_query_start, &passed); tu = (passed.sec * 1000000 + passed.usec) / 1024; if (sa_query_max_timeout < tu) { - wpa_printf(MSG_DEBUG, "SME: SA Query timed out"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: SA Query timed out"); sme_stop_sa_query(wpa_s); wpa_supplicant_deauthenticate( wpa_s, WLAN_REASON_PREV_AUTH_NOT_VALID); @@ -531,8 +531,8 @@ static void sme_send_sa_query_req(struct wpa_supplicant *wpa_s, const u8 *trans_id) { u8 req[2 + WLAN_SA_QUERY_TR_ID_LEN]; - wpa_printf(MSG_DEBUG, "SME: Sending SA Query Request to " - MACSTR, MAC2STR(wpa_s->bssid)); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Sending SA Query Request to " + MACSTR, MAC2STR(wpa_s->bssid)); wpa_hexdump(MSG_DEBUG, "SME: SA Query Transaction ID", trans_id, WLAN_SA_QUERY_TR_ID_LEN); req[0] = WLAN_ACTION_SA_QUERY; @@ -541,7 +541,8 @@ static void sme_send_sa_query_req(struct wpa_supplicant *wpa_s, if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid, req, sizeof(req)) < 0) - wpa_printf(MSG_INFO, "SME: Failed to send SA Query Request"); + wpa_msg(wpa_s, MSG_INFO, "SME: Failed to send SA Query " + "Request"); } @@ -575,8 +576,8 @@ static void sme_sa_query_timer(void *eloop_ctx, void *timeout_ctx) usec = (timeout % 1000) * 1024; eloop_register_timeout(sec, usec, sme_sa_query_timer, wpa_s, NULL); - wpa_printf(MSG_DEBUG, "SME: Association SA Query attempt %d", - wpa_s->sme.sa_query_count); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association SA Query attempt %d", + wpa_s->sme.sa_query_count); sme_send_sa_query_req(wpa_s, trans_id); } @@ -617,8 +618,8 @@ void sme_event_unprot_disconnect(struct wpa_supplicant *wpa_s, const u8 *sa, if (wpa_s->sme.sa_query_count > 0) return; - wpa_printf(MSG_DEBUG, "SME: Unprotected disconnect dropped - possible " - "AP/STA state mismatch - trigger SA Query"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Unprotected disconnect dropped - " + "possible AP/STA state mismatch - trigger SA Query"); sme_start_sa_query(wpa_s); } @@ -632,9 +633,8 @@ void sme_sa_query_rx(struct wpa_supplicant *wpa_s, const u8 *sa, len < 1 + WLAN_SA_QUERY_TR_ID_LEN || data[0] != WLAN_SA_QUERY_RESPONSE) return; - wpa_printf(MSG_DEBUG, "SME: Received SA Query response from " MACSTR - " (trans_id %02x%02x)", - MAC2STR(sa), data[1], data[2]); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Received SA Query response from " + MACSTR " (trans_id %02x%02x)", MAC2STR(sa), data[1], data[2]); if (os_memcmp(sa, wpa_s->bssid, ETH_ALEN) != 0) return; @@ -647,13 +647,13 @@ void sme_sa_query_rx(struct wpa_supplicant *wpa_s, const u8 *sa, } if (i >= wpa_s->sme.sa_query_count) { - wpa_printf(MSG_DEBUG, "SME: No matching SA Query " - "transaction identifier found"); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: No matching SA Query " + "transaction identifier found"); return; } - wpa_printf(MSG_DEBUG, "SME: Reply to pending SA Query received from " - MACSTR, MAC2STR(sa)); + wpa_dbg(wpa_s, MSG_DEBUG, "SME: Reply to pending SA Query received " + "from " MACSTR, MAC2STR(sa)); sme_stop_sa_query(wpa_s); } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index aad6c1988..c32f01c1e 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -153,13 +153,14 @@ static int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s, * sending unicast and multicast packets. */ if (ssid->mode != WPAS_MODE_IBSS) { - wpa_printf(MSG_INFO, "WPA: Invalid mode %d (not IBSS/ad-hoc) " - "for WPA-None", ssid->mode); + wpa_msg(wpa_s, MSG_INFO, "WPA: Invalid mode %d (not " + "IBSS/ad-hoc) for WPA-None", ssid->mode); return -1; } if (!ssid->psk_set) { - wpa_printf(MSG_INFO, "WPA: No PSK configured for WPA-None"); + wpa_msg(wpa_s, MSG_INFO, "WPA: No PSK configured for " + "WPA-None"); return -1; } @@ -177,8 +178,8 @@ static int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s, alg = WPA_ALG_TKIP; break; default: - wpa_printf(MSG_INFO, "WPA: Invalid group cipher %d for " - "WPA-None", wpa_s->group_cipher); + wpa_msg(wpa_s, MSG_INFO, "WPA: Invalid group cipher %d for " + "WPA-None", wpa_s->group_cipher); return -1; } @@ -221,7 +222,7 @@ void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s, (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED)) return; - wpa_msg(wpa_s, MSG_DEBUG, "Setting authentication timeout: %d sec " + wpa_dbg(wpa_s, MSG_DEBUG, "Setting authentication timeout: %d sec " "%d usec", sec, usec); eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL); eloop_register_timeout(sec, usec, wpa_supplicant_timeout, wpa_s, NULL); @@ -238,7 +239,7 @@ void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s, */ void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s) { - wpa_msg(wpa_s, MSG_DEBUG, "Cancelling authentication timeout"); + wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling authentication timeout"); eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL); wpa_blacklist_del(wpa_s, wpa_s->bssid); } @@ -458,8 +459,8 @@ void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr) * client not receiving the first encrypted packets correctly. * Skipping some of the extra key clearing steps seems to help * in completing group key handshake more reliably. */ - wpa_printf(MSG_DEBUG, "No keys have been configured - " - "skip key clearing"); + wpa_dbg(wpa_s, MSG_DEBUG, "No keys have been configured - " + "skip key clearing"); return; } @@ -532,9 +533,9 @@ void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, { enum wpa_states old_state = wpa_s->wpa_state; - wpa_printf(MSG_DEBUG, "%s: State: %s -> %s", - wpa_s->ifname, wpa_supplicant_state_txt(wpa_s->wpa_state), - wpa_supplicant_state_txt(state)); + wpa_dbg(wpa_s, MSG_DEBUG, "State: %s -> %s", + wpa_supplicant_state_txt(wpa_s->wpa_state), + wpa_supplicant_state_txt(state)); if (state != WPA_SCANNING) wpa_supplicant_notify_scanning(wpa_s, 0); @@ -695,7 +696,7 @@ int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s) wpa_s->reassociate = 1; wpa_supplicant_req_scan(wpa_s, 0, 0); } - wpa_msg(wpa_s, MSG_DEBUG, "Reconfiguration completed"); + wpa_dbg(wpa_s, MSG_DEBUG, "Reconfiguration completed"); return 0; } @@ -704,8 +705,9 @@ static void wpa_supplicant_reconfig(int sig, void *signal_ctx) { struct wpa_global *global = signal_ctx; struct wpa_supplicant *wpa_s; - wpa_printf(MSG_DEBUG, "Signal %d received - reconfiguring", sig); for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) { + wpa_dbg(wpa_s, MSG_DEBUG, "Signal %d received - reconfiguring", + sig); if (wpa_supplicant_reload_configuration(wpa_s) < 0) { wpa_supplicant_terminate_proc(global); } @@ -772,8 +774,8 @@ static int wpa_supplicant_suites_from_ai(struct wpa_supplicant *wpa_s, return -1; } - wpa_printf(MSG_DEBUG, "WPA: Using WPA IE from AssocReq to set cipher " - "suites"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Using WPA IE from AssocReq to set " + "cipher suites"); if (!(ie->group_cipher & ssid->group_cipher)) { wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled group " "cipher 0x%x (mask 0x%x) - reject", @@ -840,14 +842,14 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s, (ie.group_cipher & ssid->group_cipher) && (ie.pairwise_cipher & ssid->pairwise_cipher) && (ie.key_mgmt & ssid->key_mgmt)) { - wpa_msg(wpa_s, MSG_DEBUG, "RSN: using IEEE 802.11i/D9.0"); + wpa_dbg(wpa_s, MSG_DEBUG, "RSN: using IEEE 802.11i/D9.0"); proto = WPA_PROTO_RSN; } else if (bss_wpa && (ssid->proto & WPA_PROTO_WPA) && wpa_parse_wpa_ie(bss_wpa, 2 +bss_wpa[1], &ie) == 0 && (ie.group_cipher & ssid->group_cipher) && (ie.pairwise_cipher & ssid->pairwise_cipher) && (ie.key_mgmt & ssid->key_mgmt)) { - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using IEEE 802.11i/D3.0"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using IEEE 802.11i/D3.0"); proto = WPA_PROTO_WPA; } else if (bss) { wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select WPA/RSN"); @@ -867,19 +869,19 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s, ssid->ieee80211w != NO_MGMT_FRAME_PROTECTION ? WPA_CIPHER_AES_128_CMAC : 0; #endif /* CONFIG_IEEE80211W */ - wpa_printf(MSG_DEBUG, "WPA: Set cipher suites based " - "on configuration"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Set cipher suites " + "based on configuration"); } else proto = ie.proto; } - wpa_printf(MSG_DEBUG, "WPA: Selected cipher suites: group %d " - "pairwise %d key_mgmt %d proto %d", - ie.group_cipher, ie.pairwise_cipher, ie.key_mgmt, proto); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected cipher suites: group %d " + "pairwise %d key_mgmt %d proto %d", + ie.group_cipher, ie.pairwise_cipher, ie.key_mgmt, proto); #ifdef CONFIG_IEEE80211W if (ssid->ieee80211w) { - wpa_printf(MSG_DEBUG, "WPA: Selected mgmt group cipher %d", - ie.mgmt_group_cipher); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected mgmt group cipher %d", + ie.mgmt_group_cipher); } #endif /* CONFIG_IEEE80211W */ @@ -898,34 +900,35 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s, sel = ie.group_cipher & ssid->group_cipher; if (sel & WPA_CIPHER_CCMP) { wpa_s->group_cipher = WPA_CIPHER_CCMP; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using GTK CCMP"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK CCMP"); } else if (sel & WPA_CIPHER_TKIP) { wpa_s->group_cipher = WPA_CIPHER_TKIP; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using GTK TKIP"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK TKIP"); } else if (sel & WPA_CIPHER_WEP104) { wpa_s->group_cipher = WPA_CIPHER_WEP104; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using GTK WEP104"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK WEP104"); } else if (sel & WPA_CIPHER_WEP40) { wpa_s->group_cipher = WPA_CIPHER_WEP40; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using GTK WEP40"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK WEP40"); } else { - wpa_printf(MSG_WARNING, "WPA: Failed to select group cipher."); + wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select group " + "cipher"); return -1; } sel = ie.pairwise_cipher & ssid->pairwise_cipher; if (sel & WPA_CIPHER_CCMP) { wpa_s->pairwise_cipher = WPA_CIPHER_CCMP; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using PTK CCMP"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using PTK CCMP"); } else if (sel & WPA_CIPHER_TKIP) { wpa_s->pairwise_cipher = WPA_CIPHER_TKIP; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using PTK TKIP"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using PTK TKIP"); } else if (sel & WPA_CIPHER_NONE) { wpa_s->pairwise_cipher = WPA_CIPHER_NONE; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using PTK NONE"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using PTK NONE"); } else { - wpa_printf(MSG_WARNING, "WPA: Failed to select pairwise " - "cipher."); + wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select pairwise " + "cipher"); return -1; } @@ -934,33 +937,33 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s, #ifdef CONFIG_IEEE80211R } else if (sel & WPA_KEY_MGMT_FT_IEEE8021X) { wpa_s->key_mgmt = WPA_KEY_MGMT_FT_IEEE8021X; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/802.1X"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/802.1X"); } else if (sel & WPA_KEY_MGMT_FT_PSK) { wpa_s->key_mgmt = WPA_KEY_MGMT_FT_PSK; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/PSK"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/PSK"); #endif /* CONFIG_IEEE80211R */ #ifdef CONFIG_IEEE80211W } else if (sel & WPA_KEY_MGMT_IEEE8021X_SHA256) { wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_SHA256; - wpa_msg(wpa_s, MSG_DEBUG, + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT 802.1X with SHA256"); } else if (sel & WPA_KEY_MGMT_PSK_SHA256) { wpa_s->key_mgmt = WPA_KEY_MGMT_PSK_SHA256; - wpa_msg(wpa_s, MSG_DEBUG, + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT PSK with SHA256"); #endif /* CONFIG_IEEE80211W */ } else if (sel & WPA_KEY_MGMT_IEEE8021X) { wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT 802.1X"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT 802.1X"); } else if (sel & WPA_KEY_MGMT_PSK) { wpa_s->key_mgmt = WPA_KEY_MGMT_PSK; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-PSK"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-PSK"); } else if (sel & WPA_KEY_MGMT_WPA_NONE) { wpa_s->key_mgmt = WPA_KEY_MGMT_WPA_NONE; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-NONE"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-NONE"); } else { - wpa_printf(MSG_WARNING, "WPA: Failed to select authenticated " - "key management type."); + wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select " + "authenticated key management type"); return -1; } @@ -976,11 +979,11 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s, sel = 0; if (sel & WPA_CIPHER_AES_128_CMAC) { wpa_s->mgmt_group_cipher = WPA_CIPHER_AES_128_CMAC; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher " + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher " "AES-128-CMAC"); } else { wpa_s->mgmt_group_cipher = 0; - wpa_msg(wpa_s, MSG_DEBUG, "WPA: not using MGMT group cipher"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: not using MGMT group cipher"); } wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MGMT_GROUP, wpa_s->mgmt_group_cipher); @@ -988,7 +991,7 @@ int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s, #endif /* CONFIG_IEEE80211W */ if (wpa_sm_set_assoc_wpa_ie_default(wpa_s->wpa, wpa_ie, wpa_ie_len)) { - wpa_printf(MSG_WARNING, "WPA: Failed to generate WPA IE."); + wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to generate WPA IE"); return -1; } @@ -1028,15 +1031,15 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, ssid->mode == WPAS_MODE_P2P_GROUP_FORMATION) { #ifdef CONFIG_AP if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP)) { - wpa_printf(MSG_INFO, "Driver does not support AP " - "mode"); + wpa_msg(wpa_s, MSG_INFO, "Driver does not support AP " + "mode"); return; } wpa_supplicant_create_ap(wpa_s, ssid); wpa_s->current_bss = bss; #else /* CONFIG_AP */ - wpa_printf(MSG_ERROR, "AP mode support not included in the " - "build"); + wpa_msg(wpa_s, MSG_ERROR, "AP mode support not included in " + "the build"); #endif /* CONFIG_AP */ return; } @@ -1103,11 +1106,11 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, } } #endif /* IEEE8021X_EAPOL */ - wpa_printf(MSG_DEBUG, "Automatic auth_alg selection: 0x%x", algs); + wpa_dbg(wpa_s, MSG_DEBUG, "Automatic auth_alg selection: 0x%x", algs); if (ssid->auth_alg) { algs = ssid->auth_alg; - wpa_printf(MSG_DEBUG, "Overriding auth_alg selection: 0x%x", - algs); + wpa_dbg(wpa_s, MSG_DEBUG, "Overriding auth_alg selection: " + "0x%x", algs); } if (bss && (wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) || @@ -1127,8 +1130,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, wpa_ie_len = sizeof(wpa_ie); if (wpa_supplicant_set_suites(wpa_s, bss, ssid, wpa_ie, &wpa_ie_len)) { - wpa_printf(MSG_WARNING, "WPA: Failed to set WPA key " - "management and encryption suites"); + wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to set WPA " + "key management and encryption suites"); return; } } else if (ssid->key_mgmt & @@ -1139,9 +1142,9 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, wpa_ie_len = sizeof(wpa_ie); if (wpa_supplicant_set_suites(wpa_s, NULL, ssid, wpa_ie, &wpa_ie_len)) { - wpa_printf(MSG_WARNING, "WPA: Failed to set WPA key " - "management and encryption suites (no scan " - "results)"); + wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to set WPA " + "key management and encryption suites (no " + "scan results)"); return; } #ifdef CONFIG_WPS @@ -1187,10 +1190,10 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, wpa_s->cross_connect_disallowed = p2p_get_cross_connect_disallowed(p2p); wpabuf_free(p2p); - wpa_printf(MSG_DEBUG, "P2P: WLAN AP %s cross " - "connection", - wpa_s->cross_connect_disallowed ? - "disallows" : "allows"); + wpa_dbg(wpa_s, MSG_DEBUG, "P2P: WLAN AP %s cross " + "connection", + wpa_s->cross_connect_disallowed ? + "disallows" : "allows"); } } #endif /* CONFIG_P2P */ @@ -1277,8 +1280,8 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, if (rsn && wpa_parse_wpa_ie(rsn, 2 + rsn[1], &ie) == 0 && ie.capabilities & (WPA_CAPABILITY_MFPC | WPA_CAPABILITY_MFPR)) { - wpa_printf(MSG_DEBUG, "WPA: Selected AP supports MFP: " - "require MFP"); + wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected AP supports " + "MFP: require MFP"); params.mgmt_frame_protection = MGMT_FRAME_PROTECTION_REQUIRED; } @@ -1662,15 +1665,15 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s) if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME) { if (ieee80211_sta_get_ssid(wpa_s, ssid, &ssid_len)) { - wpa_printf(MSG_WARNING, "Could not read SSID from " - "MLME."); + wpa_msg(wpa_s, MSG_WARNING, "Could not read SSID from " + "MLME"); return NULL; } } else { res = wpa_drv_get_ssid(wpa_s, ssid); if (res < 0) { - wpa_printf(MSG_WARNING, "Could not read SSID from " - "driver."); + wpa_msg(wpa_s, MSG_WARNING, "Could not read SSID from " + "driver"); return NULL; } ssid_len = res; @@ -1679,7 +1682,8 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s) if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME) os_memcpy(bssid, wpa_s->bssid, ETH_ALEN); else if (wpa_drv_get_bssid(wpa_s, bssid) < 0) { - wpa_printf(MSG_WARNING, "Could not read BSSID from driver."); + wpa_msg(wpa_s, MSG_WARNING, "Could not read BSSID from " + "driver"); return NULL; } @@ -1720,8 +1724,8 @@ static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s, return -1; if (wpa_drivers[0] == NULL) { - wpa_printf(MSG_ERROR, "No driver interfaces build into " - "wpa_supplicant."); + wpa_msg(wpa_s, MSG_ERROR, "No driver interfaces build into " + "wpa_supplicant"); return -1; } @@ -1753,7 +1757,7 @@ static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s, driver = pos + 1; } while (pos); - wpa_printf(MSG_ERROR, "Unsupported driver '%s'.", name); + wpa_msg(wpa_s, MSG_ERROR, "Unsupported driver '%s'", name); return -1; } @@ -1777,7 +1781,7 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr, { struct wpa_supplicant *wpa_s = ctx; - wpa_printf(MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr)); + wpa_dbg(wpa_s, MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr)); wpa_hexdump(MSG_MSGDUMP, "RX EAPOL", buf, len); if (wpa_s->wpa_state < WPA_ASSOCIATED) { @@ -1789,8 +1793,8 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr, * association information, lets queue it for processing until * the association event is received. */ - wpa_printf(MSG_DEBUG, "Not associated - Delay processing of " - "received EAPOL frame"); + wpa_dbg(wpa_s, MSG_DEBUG, "Not associated - Delay processing " + "of received EAPOL frame"); wpabuf_free(wpa_s->pending_eapol_rx); wpa_s->pending_eapol_rx = wpabuf_alloc_copy(buf, len); if (wpa_s->pending_eapol_rx) { @@ -1809,8 +1813,8 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr, #endif /* CONFIG_AP */ if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) { - wpa_printf(MSG_DEBUG, "Ignored received EAPOL frame since " - "no key management is configured"); + wpa_dbg(wpa_s, MSG_DEBUG, "Ignored received EAPOL frame since " + "no key management is configured"); return; } @@ -1831,8 +1835,8 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr, wpa_s->eapol_received++; if (wpa_s->countermeasures) { - wpa_printf(MSG_INFO, "WPA: Countermeasures - dropped EAPOL " - "packet"); + wpa_msg(wpa_s, MSG_INFO, "WPA: Countermeasures - dropped " + "EAPOL packet"); return; } @@ -1901,25 +1905,25 @@ int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s) } if (wpa_s->l2 && l2_packet_get_own_addr(wpa_s->l2, wpa_s->own_addr)) { - wpa_printf(MSG_ERROR, "Failed to get own L2 address"); + wpa_msg(wpa_s, MSG_ERROR, "Failed to get own L2 address"); return -1; } - wpa_printf(MSG_DEBUG, "Own MAC address: " MACSTR, - MAC2STR(wpa_s->own_addr)); + wpa_dbg(wpa_s, MSG_DEBUG, "Own MAC address: " MACSTR, + MAC2STR(wpa_s->own_addr)); if (wpa_s->bridge_ifname[0]) { - wpa_printf(MSG_DEBUG, "Receiving packets from bridge interface" - " '%s'", wpa_s->bridge_ifname); + wpa_dbg(wpa_s, MSG_DEBUG, "Receiving packets from bridge " + "interface '%s'", wpa_s->bridge_ifname); wpa_s->l2_br = l2_packet_init(wpa_s->bridge_ifname, wpa_s->own_addr, ETH_P_EAPOL, wpa_supplicant_rx_eapol, wpa_s, 0); if (wpa_s->l2_br == NULL) { - wpa_printf(MSG_ERROR, "Failed to open l2_packet " - "connection for the bridge interface '%s'", - wpa_s->bridge_ifname); + wpa_msg(wpa_s, MSG_ERROR, "Failed to open l2_packet " + "connection for the bridge interface '%s'", + wpa_s->bridge_ifname); return -1; } } @@ -1930,7 +1934,7 @@ int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s) * happen if wpa_supplicant is killed during countermeasures. */ wpa_drv_set_countermeasures(wpa_s, 0); - wpa_printf(MSG_DEBUG, "RSN: flushing PMKID list in the driver"); + wpa_dbg(wpa_s, MSG_DEBUG, "RSN: flushing PMKID list in the driver"); wpa_drv_flush_pmkid(wpa_s); wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN; @@ -2064,24 +2068,25 @@ next_driver: const char *pos; pos = driver ? os_strchr(driver, ',') : NULL; if (pos) { - wpa_printf(MSG_DEBUG, "Failed to initialize driver " - "interface - try next driver wrapper"); + wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize " + "driver interface - try next driver wrapper"); driver = pos + 1; goto next_driver; } - wpa_printf(MSG_ERROR, "Failed to initialize driver interface"); + wpa_msg(wpa_s, MSG_ERROR, "Failed to initialize driver " + "interface"); return -1; } if (wpa_drv_set_param(wpa_s, wpa_s->conf->driver_param) < 0) { - wpa_printf(MSG_ERROR, "Driver interface rejected " - "driver_param '%s'", wpa_s->conf->driver_param); + wpa_msg(wpa_s, MSG_ERROR, "Driver interface rejected " + "driver_param '%s'", wpa_s->conf->driver_param); return -1; } ifname = wpa_drv_get_ifname(wpa_s); if (ifname && os_strcmp(ifname, wpa_s->ifname) != 0) { - wpa_printf(MSG_DEBUG, "Driver interface replaced interface " - "name with '%s'", ifname); + wpa_dbg(wpa_s, MSG_DEBUG, "Driver interface replaced " + "interface name with '%s'", ifname); os_strlcpy(wpa_s->ifname, ifname, sizeof(wpa_s->ifname)); } @@ -2096,15 +2101,15 @@ next_driver: if (wpa_s->conf->dot11RSNAConfigPMKLifetime && wpa_sm_set_param(wpa_s->wpa, RSNA_PMK_LIFETIME, wpa_s->conf->dot11RSNAConfigPMKLifetime)) { - wpa_printf(MSG_ERROR, "Invalid WPA parameter value for " - "dot11RSNAConfigPMKLifetime"); + wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for " + "dot11RSNAConfigPMKLifetime"); return -1; } if (wpa_s->conf->dot11RSNAConfigPMKReauthThreshold && wpa_sm_set_param(wpa_s->wpa, RSNA_PMK_REAUTH_THRESHOLD, wpa_s->conf->dot11RSNAConfigPMKReauthThreshold)) { - wpa_printf(MSG_ERROR, "Invalid WPA parameter value for " + wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for " "dot11RSNAConfigPMKReauthThreshold"); return -1; } @@ -2112,8 +2117,8 @@ next_driver: if (wpa_s->conf->dot11RSNAConfigSATimeout && wpa_sm_set_param(wpa_s->wpa, RSNA_SA_TIMEOUT, wpa_s->conf->dot11RSNAConfigSATimeout)) { - wpa_printf(MSG_ERROR, "Invalid WPA parameter value for " - "dot11RSNAConfigSATimeout"); + wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for " + "dot11RSNAConfigSATimeout"); return -1; } @@ -2135,7 +2140,7 @@ next_driver: if (wpa_s->conf->country[0] && wpa_s->conf->country[1] && wpa_drv_set_country(wpa_s, wpa_s->conf->country)) { - wpa_printf(MSG_DEBUG, "Failed to set country"); + wpa_dbg(wpa_s, MSG_DEBUG, "Failed to set country"); return -1; } @@ -2165,14 +2170,14 @@ next_driver: #ifdef CONFIG_IBSS_RSN wpa_s->ibss_rsn = ibss_rsn_init(wpa_s); if (!wpa_s->ibss_rsn) { - wpa_printf(MSG_DEBUG, "Failed to init IBSS RSN"); + wpa_dbg(wpa_s, MSG_DEBUG, "Failed to init IBSS RSN"); return -1; } #endif /* CONFIG_IBSS_RSN */ #ifdef CONFIG_P2P if (wpas_p2p_init(wpa_s->global, wpa_s) < 0) { - wpa_printf(MSG_ERROR, "Failed to init P2P"); + wpa_msg(wpa_s, MSG_ERROR, "Failed to init P2P"); return -1; } #endif /* CONFIG_P2P */ @@ -2269,7 +2274,7 @@ struct wpa_supplicant * wpa_supplicant_add_iface(struct wpa_global *global, wpa_s->next = global->ifaces; global->ifaces = wpa_s; - wpa_printf(MSG_DEBUG, "Added interface %s", wpa_s->ifname); + wpa_dbg(wpa_s, MSG_DEBUG, "Added interface %s", wpa_s->ifname); return wpa_s; } @@ -2303,7 +2308,7 @@ int wpa_supplicant_remove_iface(struct wpa_global *global, prev->next = wpa_s->next; } - wpa_printf(MSG_DEBUG, "Removing interface %s", wpa_s->ifname); + wpa_dbg(wpa_s, MSG_DEBUG, "Removing interface %s", wpa_s->ifname); if (global->p2p_group_formation == wpa_s) global->p2p_group_formation = NULL; @@ -2637,8 +2642,8 @@ void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid) */ freqs = get_bss_freqs_in_ess(wpa_s); if (freqs) { - wpa_printf(MSG_DEBUG, "Another BSS in this ESS has " - "been seen; try it next"); + wpa_dbg(wpa_s, MSG_DEBUG, "Another BSS in this ESS " + "has been seen; try it next"); wpa_blacklist_add(wpa_s, bssid); /* * On the next scan, go through only the known channels