[RFC 04/13] nl80211: Convert some wpa_printf to wpa_msg methods (3).

greearb at candelatech.com greearb at candelatech.com
Fri Oct 14 18:34:28 EDT 2011


From: Ben Greear <greearb at candelatech.com>

This helps debugging when you have multiple interfaces
handled by a single process.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 d44089d... 0457616... M	src/drivers/driver_nl80211.c
 src/drivers/driver_nl80211.c |   98 +++++++++++++++++++++---------------------
 1 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index d44089d..0457616 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -3943,7 +3943,7 @@ static int wpa_driver_nl80211_send_frame(struct wpa_driver_nl80211_data *drv,
 
 	res = sendmsg(drv->monitor_sock, &msg, 0);
 	if (res < 0) {
-		wpa_printf(MSG_INFO, "nl80211: sendmsg: %s", strerror(errno));
+		wpa_msg(drv->ctx, MSG_INFO, "nl80211: sendmsg: %s", strerror(errno));
 		return -1;
 	}
 	return 0;
@@ -4174,8 +4174,8 @@ static int wpa_driver_nl80211_set_freq(struct wpa_driver_nl80211_data *drv,
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	if (ret == 0)
 		return 0;
-	wpa_printf(MSG_DEBUG, "nl80211: Failed to set channel (freq=%d): "
-		   "%d (%s)", freq, ret, strerror(-ret));
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Failed to set channel (freq=%d): "
+		"%d (%s)", freq, ret, strerror(-ret));
 nla_put_failure:
 	return -1;
 }
@@ -4234,8 +4234,8 @@ static int wpa_driver_nl80211_sta_add(void *priv,
 
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	if (ret)
-		wpa_printf(MSG_DEBUG, "nl80211: NL80211_CMD_NEW_STATION "
-			   "result: %d (%s)", ret, strerror(-ret));
+		wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: NL80211_CMD_NEW_STATION "
+			"result: %d (%s)", ret, strerror(-ret));
 	if (ret == -EEXIST)
 		ret = 0;
  nla_put_failure:
@@ -4275,7 +4275,7 @@ static void nl80211_remove_iface(struct wpa_driver_nl80211_data *drv,
 {
 	struct nl_msg *msg;
 
-	wpa_printf(MSG_DEBUG, "nl80211: Remove interface ifindex=%d", ifidx);
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Remove interface ifindex=%d", ifidx);
 
 #ifdef HOSTAPD
 	/* stop listening for EAPOL on this interface */
@@ -4293,7 +4293,7 @@ static void nl80211_remove_iface(struct wpa_driver_nl80211_data *drv,
 	if (send_and_recv_msgs(drv, msg, NULL, NULL) == 0)
 		return;
  nla_put_failure:
-	wpa_printf(MSG_ERROR, "Failed to remove interface (ifidx=%d)", ifidx);
+	wpa_msg(drv->ctx, MSG_ERROR, "Failed to remove interface (ifidx=%d)", ifidx);
 }
 
 
@@ -4362,14 +4362,14 @@ static int nl80211_create_iface_once(struct wpa_driver_nl80211_data *drv,
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	if (ret) {
  nla_put_failure:
-		wpa_printf(MSG_ERROR, "Failed to create interface %s: %d (%s)",
-			   ifname, ret, strerror(-ret));
+		wpa_msg(drv->ctx, MSG_ERROR, "Failed to create interface %s: %d (%s)",
+			ifname, ret, strerror(-ret));
 		return ret;
 	}
 
 	ifidx = if_nametoindex(ifname);
-	wpa_printf(MSG_DEBUG, "nl80211: New interface %s created: ifindex=%d",
-		   ifname, ifidx);
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: New interface %s created: ifindex=%d",
+		ifname, ifidx);
 
 	if (ifidx <= 0)
 		return -1;
@@ -4399,7 +4399,7 @@ static int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
 
 	/* if error occurred and interface exists already */
 	if (ret == -ENFILE && if_nametoindex(ifname)) {
-		wpa_printf(MSG_INFO, "Try to remove and re-create %s", ifname);
+		wpa_msg(drv->ctx, MSG_INFO, "Try to remove and re-create %s", ifname);
 
 		/* Try to remove the interface that was already there. */
 		nl80211_remove_iface(drv, if_nametoindex(ifname));
@@ -4468,7 +4468,7 @@ static void handle_frame(struct wpa_driver_nl80211_data *drv,
 		break;
 	case WLAN_FC_TYPE_CTRL:
 		/* can only get here with PS-Poll frames */
-		wpa_printf(MSG_DEBUG, "CTRL");
+		wpa_msg(drv->ctx, MSG_DEBUG, "CTRL");
 		from_unknown_sta(drv, buf, len);
 		break;
 	case WLAN_FC_TYPE_DATA:
@@ -4749,8 +4749,8 @@ nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv)
 	}
 
 	if (add_monitor_filter(drv->monitor_sock)) {
-		wpa_printf(MSG_INFO, "Failed to set socket filter for monitor "
-			   "interface; do filtering in user space");
+		wpa_msg(drv->ctx, MSG_INFO, "Failed to set socket filter for monitor "
+			"interface; do filtering in user space");
 		/* This works, but will cost in performance. */
 	}
 
@@ -4857,9 +4857,9 @@ static int wpa_driver_nl80211_hapd_send_eapol(
 
 	res = wpa_driver_nl80211_send_frame(drv, (u8 *) hdr, len, encrypt);
 	if (res < 0) {
-		wpa_printf(MSG_ERROR, "i802_send_eapol - packet len: %lu - "
-			   "failed: %d (%s)",
-			   (unsigned long) len, errno, strerror(errno));
+		wpa_msg(drv->ctx, MSG_ERROR, "i802_send_eapol - packet len: %lu - "
+			"failed: %d (%s)",
+			(unsigned long) len, errno, strerror(errno));
 	}
 	os_free(hdr);
 
@@ -4974,13 +4974,13 @@ static int nl80211_leave_ibss(struct wpa_driver_nl80211_data *drv)
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	msg = NULL;
 	if (ret) {
-		wpa_printf(MSG_DEBUG, "nl80211: Leave IBSS failed: ret=%d "
-			   "(%s)", ret, strerror(-ret));
+		wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Leave IBSS failed: ret=%d "
+			"(%s)", ret, strerror(-ret));
 		goto nla_put_failure;
 	}
 
 	ret = 0;
-	wpa_printf(MSG_DEBUG, "nl80211: Leave IBSS request sent successfully");
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Leave IBSS request sent successfully");
 
 nla_put_failure:
 	nlmsg_free(msg);
@@ -4995,12 +4995,12 @@ static int wpa_driver_nl80211_ibss(struct wpa_driver_nl80211_data *drv,
 	int ret = -1;
 	int count = 0;
 
-	wpa_printf(MSG_DEBUG, "nl80211: Join IBSS (ifindex=%d)", drv->ifindex);
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Join IBSS (ifindex=%d)", drv->ifindex);
 
 	if (wpa_driver_nl80211_set_mode(&drv->first_bss,
 					NL80211_IFTYPE_ADHOC)) {
-		wpa_printf(MSG_INFO, "nl80211: Failed to set interface into "
-			   "IBSS mode");
+		wpa_msg(drv->ctx, MSG_INFO,
+			"nl80211: Failed to set interface into IBSS mode");
 		return -1;
 	}
 
@@ -5023,7 +5023,7 @@ retry:
 	os_memcpy(drv->ssid, params->ssid, params->ssid_len);
 	drv->ssid_len = params->ssid_len;
 
-	wpa_printf(MSG_DEBUG, "  * freq=%d", params->freq);
+	wpa_msg(drv->ctx, MSG_DEBUG, "  * freq=%d", params->freq);
 	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, params->freq);
 
 	ret = nl80211_set_conn_keys(params, msg);
@@ -5041,12 +5041,12 @@ retry:
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	msg = NULL;
 	if (ret) {
-		wpa_printf(MSG_DEBUG, "nl80211: Join IBSS failed: ret=%d (%s)",
-			   ret, strerror(-ret));
+		wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Join IBSS failed: ret=%d (%s)",
+			ret, strerror(-ret));
 		count++;
 		if (ret == -EALREADY && count == 1) {
-			wpa_printf(MSG_DEBUG, "nl80211: Retry IBSS join after "
-				   "forced leave");
+			wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Retry IBSS join after "
+				"forced leave");
 			nl80211_leave_ibss(drv);
 			nlmsg_free(msg);
 			goto retry;
@@ -5055,7 +5055,7 @@ retry:
 		goto nla_put_failure;
 	}
 	ret = 0;
-	wpa_printf(MSG_DEBUG, "nl80211: Join IBSS request sent successfully");
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Join IBSS request sent successfully");
 
 nla_put_failure:
 	nlmsg_free(msg);
@@ -5126,18 +5126,18 @@ static int wpa_driver_nl80211_connect(
 	if (!msg)
 		return -1;
 
-	wpa_printf(MSG_DEBUG, "nl80211: Connect (ifindex=%d)", drv->ifindex);
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Connect (ifindex=%d)", drv->ifindex);
 	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
 		    NL80211_CMD_CONNECT, 0);
 
 	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
 	if (params->bssid) {
-		wpa_printf(MSG_DEBUG, "  * bssid=" MACSTR,
-			   MAC2STR(params->bssid));
+		wpa_msg(drv->ctx, MSG_DEBUG, "  * bssid=" MACSTR,
+			MAC2STR(params->bssid));
 		NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, params->bssid);
 	}
 	if (params->freq) {
-		wpa_printf(MSG_DEBUG, "  * freq=%d", params->freq);
+		wpa_msg(drv->ctx, MSG_DEBUG, "  * freq=%d", params->freq);
 		NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, params->freq);
 	}
 	if (params->ssid) {
@@ -5179,7 +5179,7 @@ static int wpa_driver_nl80211_connect(
 	else
 		goto nla_put_failure;
 
-	wpa_printf(MSG_DEBUG, "  * Auth Type %d", type);
+	wpa_msg(drv->ctx, MSG_DEBUG, "  * Auth Type %d", type);
 	NLA_PUT_U32(msg, NL80211_ATTR_AUTH_TYPE, type);
 
 skip_auth_type:
@@ -5191,7 +5191,7 @@ skip_auth_type:
 		if (params->wpa_proto & WPA_PROTO_RSN)
 			ver |= NL80211_WPA_VERSION_2;
 
-		wpa_printf(MSG_DEBUG, "  * WPA Versions 0x%x", ver);
+		wpa_msg(drv->ctx, MSG_DEBUG, "  * WPA Versions 0x%x", ver);
 		NLA_PUT_U32(msg, NL80211_ATTR_WPA_VERSIONS, ver);
 	}
 
@@ -5273,7 +5273,7 @@ skip_auth_type:
 		goto nla_put_failure;
 	}
 	ret = 0;
-	wpa_printf(MSG_DEBUG, "nl80211: Connect request send successfully");
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Connect request send successfully");
 
 nla_put_failure:
 	nlmsg_free(msg);
@@ -5311,19 +5311,19 @@ static int wpa_driver_nl80211_associate(
 	if (!msg)
 		return -1;
 
-	wpa_printf(MSG_DEBUG, "nl80211: Associate (ifindex=%d)",
-		   drv->ifindex);
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Associate (ifindex=%d)",
+		drv->ifindex);
 	genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0, 0,
 		    NL80211_CMD_ASSOCIATE, 0);
 
 	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
 	if (params->bssid) {
-		wpa_printf(MSG_DEBUG, "  * bssid=" MACSTR,
-			   MAC2STR(params->bssid));
+		wpa_msg(drv->ctx, MSG_DEBUG, "  * bssid=" MACSTR,
+			MAC2STR(params->bssid));
 		NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, params->bssid);
 	}
 	if (params->freq) {
-		wpa_printf(MSG_DEBUG, "  * freq=%d", params->freq);
+		wpa_msg(drv->ctx, MSG_DEBUG, "  * freq=%d", params->freq);
 		NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, params->freq);
 		drv->assoc_freq = params->freq;
 	} else
@@ -5395,26 +5395,26 @@ static int wpa_driver_nl80211_associate(
 	NLA_PUT_FLAG(msg, NL80211_ATTR_CONTROL_PORT);
 
 	if (params->prev_bssid) {
-		wpa_printf(MSG_DEBUG, "  * prev_bssid=" MACSTR,
-			   MAC2STR(params->prev_bssid));
+		wpa_msg(drv->ctx, MSG_DEBUG, "  * prev_bssid=" MACSTR,
+			MAC2STR(params->prev_bssid));
 		NLA_PUT(msg, NL80211_ATTR_PREV_BSSID, ETH_ALEN,
 			params->prev_bssid);
 	}
 
 	if (params->p2p)
-		wpa_printf(MSG_DEBUG, "  * P2P group");
+		wpa_msg(drv->ctx, MSG_DEBUG, "  * P2P group");
 
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	msg = NULL;
 	if (ret) {
-		wpa_printf(MSG_DEBUG, "nl80211: MLME command failed: ret=%d "
-			   "(%s)", ret, strerror(-ret));
+		wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: MLME command failed: ret=%d "
+			"(%s)", ret, strerror(-ret));
 		nl80211_dump_scan(drv);
 		goto nla_put_failure;
 	}
 	ret = 0;
-	wpa_printf(MSG_DEBUG, "nl80211: Association request send "
-		   "successfully");
+	wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Association request send "
+		"successfully");
 
 nla_put_failure:
 	nlmsg_free(msg);
-- 
1.7.3.4



More information about the HostAP mailing list