Browse Source

Use wpa_msg() instead of wpa_printf()

This converts number of debugging messages to use wpa_msg() in order
to allow the interface name to be shown with the messages.

A new function, wpa_dbg(), is introduced to allow
CONFIG_NO_STDOUT_DEBUG=y builds to remove the debug strings. This is
otherwise identical with wpa_msg(), but it gets compiled out if stdout
debugging is disabled.
Ben Greear 14 years ago
parent
commit
f049052b9e
7 changed files with 660 additions and 580 deletions
  1. 258 203
      src/rsn_supp/wpa.c
  2. 9 0
      src/utils/wpa_debug.h
  3. 16 15
      wpa_supplicant/bss.c
  4. 173 165
      wpa_supplicant/events.c
  5. 30 28
      wpa_supplicant/scan.c
  6. 61 61
      wpa_supplicant/sme.c
  7. 113 108
      wpa_supplicant/wpa_supplicant.c

File diff suppressed because it is too large
+ 258 - 203
src/rsn_supp/wpa.c


+ 9 - 0
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 */
 
 

+ 16 - 15
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;

+ 173 - 165
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;
 	}
 }

+ 30 - 28
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(&params.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 */

+ 61 - 61
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, &params) < 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, &params) < 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);
 }
 

+ 113 - 108
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

Some files were not shown because too many files changed in this diff