[PATCH 5/6] nl80211: Convert some wpa_printf to wpa_msg methods (4).
greearb at candelatech.com
greearb
Wed Oct 19 12:20:18 PDT 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 873126f... ed62cdd... M src/drivers/driver_nl80211.c
src/drivers/driver_nl80211.c | 179 ++++++++++++++++++++++++------------------
1 files changed, 102 insertions(+), 77 deletions(-)
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 873126f..ed62cdd 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -676,13 +676,15 @@ static unsigned int nl80211_get_assoc_freq(struct wpa_driver_nl80211_data *drv)
ret = send_and_recv_msgs(drv, msg, bss_info_handler, &arg);
msg = NULL;
if (ret == 0) {
- wpa_printf(MSG_DEBUG, "nl80211: Operating frequency for the "
- "associated BSS from scan results: %u MHz",
- arg.assoc_freq);
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Operating frequency for the "
+ "associated BSS from scan results: %u MHz",
+ arg.assoc_freq);
return arg.assoc_freq ? arg.assoc_freq : drv->assoc_freq;
}
- wpa_printf(MSG_DEBUG, "nl80211: Scan result fetch failed: ret=%d "
- "(%s)", ret, strerror(-ret));
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Scan result fetch failed: ret=%d "
+ "(%s)", ret, strerror(-ret));
nla_put_failure:
nlmsg_free(msg);
return drv->assoc_freq;
@@ -795,8 +797,8 @@ static void mlme_event_disconnect(struct wpa_driver_nl80211_data *drv,
* Avoid reporting two disassociation events that could
* confuse the core code.
*/
- wpa_printf(MSG_DEBUG, "nl80211: Ignore disconnect "
- "event when using userspace SME");
+ wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Ignore disconnect "
+ "event when using userspace SME");
return;
}
@@ -1439,8 +1441,9 @@ static void nl80211_del_station_event(struct wpa_driver_nl80211_data *drv,
if (tb[NL80211_ATTR_MAC] == NULL)
return;
addr = nla_data(tb[NL80211_ATTR_MAC]);
- wpa_printf(MSG_DEBUG, "nl80211: Delete station " MACSTR,
- MAC2STR(addr));
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Delete station " MACSTR,
+ MAC2STR(addr));
if (is_ap_interface(drv->nlmode) && drv->no_monitor_iface_capab) {
drv_event_disassoc(drv->ctx, addr);
@@ -1488,8 +1491,9 @@ static void nl80211_rekey_offload_event(struct wpa_driver_nl80211_data *drv,
os_memset(&data, 0, sizeof(data));
data.driver_gtk_rekey.bssid = nla_data(tb[NL80211_ATTR_MAC]);
- wpa_printf(MSG_DEBUG, "nl80211: Rekey offload event for BSSID " MACSTR,
- MAC2STR(data.driver_gtk_rekey.bssid));
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Rekey offload event for BSSID " MACSTR,
+ MAC2STR(data.driver_gtk_rekey.bssid));
data.driver_gtk_rekey.replay_ctr =
nla_data(rekey_info[NL80211_REKEY_DATA_REPLAY_CTR]);
wpa_hexdump(MSG_DEBUG, "nl80211: Rekey offload - Replay Counter",
@@ -1633,12 +1637,13 @@ static int process_event(struct nl_msg *msg, void *arg)
nl80211_cqm_event(drv, tb);
break;
case NL80211_CMD_REG_CHANGE:
- wpa_printf(MSG_DEBUG, "nl80211: Regulatory domain change");
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Regulatory domain change");
wpa_supplicant_event(drv->ctx, EVENT_CHANNEL_LIST_CHANGED,
NULL);
break;
case NL80211_CMD_REG_BEACON_HINT:
- wpa_printf(MSG_DEBUG, "nl80211: Regulatory beacon hint");
+ wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Regulatory beacon hint");
wpa_supplicant_event(drv->ctx, EVENT_CHANNEL_LIST_CHANGED,
NULL);
break;
@@ -1655,8 +1660,8 @@ static int process_event(struct nl_msg *msg, void *arg)
nl80211_pmksa_candidate_event(drv, tb);
break;
default:
- wpa_printf(MSG_DEBUG, "nl80211: Ignored unknown event "
- "(cmd=%d)", gnlh->cmd);
+ wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Ignored unknown event "
+ "(cmd=%d)", gnlh->cmd);
break;
}
@@ -1670,7 +1675,7 @@ static void wpa_driver_nl80211_event_receive(int sock, void *eloop_ctx,
struct nl_cb *cb;
struct wpa_driver_nl80211_data *drv = eloop_ctx;
- wpa_printf(MSG_DEBUG, "nl80211: Event message available");
+ wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Event message available");
cb = nl_cb_clone(drv->nl_cb);
if (!cb)
@@ -1933,19 +1938,21 @@ static int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv)
if (info.auth_supported)
drv->capa.flags |= WPA_DRIVER_FLAGS_SME;
else if (!info.connect_supported) {
- wpa_printf(MSG_INFO, "nl80211: Driver does not support "
- "authentication/association or connect commands");
+ wpa_msg(drv->ctx, MSG_INFO,
+ "nl80211: Driver does not support "
+ "authentication/association or connect commands");
return -1;
}
if (info.offchan_tx_supported) {
- wpa_printf(MSG_DEBUG, "nl80211: Using driver-based "
- "off-channel TX");
+ wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Using driver-based "
+ "off-channel TX");
drv->capa.flags |= WPA_DRIVER_FLAGS_OFFCHANNEL_TX;
}
if (info.firmware_roam) {
- wpa_printf(MSG_DEBUG, "nl80211: Using driver-based roaming");
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Using driver-based roaming");
drv->capa.flags |= WPA_DRIVER_FLAGS_BSS_SELECTION;
}
@@ -1954,8 +1961,8 @@ static int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv)
if (info.p2p_supported)
drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CAPABLE;
if (info.p2p_concurrent) {
- wpa_printf(MSG_DEBUG, "nl80211: Use separate P2P group "
- "interface (driver advertised support)");
+ wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Use separate P2P group "
+ "interface (driver advertised support)");
drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CONCURRENT;
drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P;
}
@@ -1975,68 +1982,73 @@ static int wpa_driver_nl80211_init_nl(struct wpa_driver_nl80211_data *drv)
drv->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
if (drv->nl_cb == NULL) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to allocate netlink "
- "callbacks");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: Failed to allocate netlink callbacks");
goto err1;
}
drv->nl_handle = nl80211_handle_alloc(drv->nl_cb);
if (drv->nl_handle == NULL) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to allocate netlink "
- "callbacks");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: Failed to allocate netlink callbacks");
goto err2;
}
drv->nl_handle_event = nl80211_handle_alloc(drv->nl_cb);
if (drv->nl_handle_event == NULL) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to allocate netlink "
- "callbacks (event)");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: Failed to allocate netlink "
+ "callbacks (event)");
goto err2b;
}
if (genl_connect(drv->nl_handle)) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to connect to generic "
- "netlink");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: Failed to connect to generic netlink");
goto err3;
}
if (genl_connect(drv->nl_handle_event)) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to connect to generic "
- "netlink (event)");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: Failed to connect to generic "
+ "netlink (event)");
goto err3;
}
#ifdef CONFIG_LIBNL20
if (genl_ctrl_alloc_cache(drv->nl_handle, &drv->nl_cache) < 0) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
- "netlink cache");
+ wpa_msg(drv->ctx, MSG_ERROR, "nl80211: Failed to allocate generic "
+ "netlink cache");
goto err3;
}
if (genl_ctrl_alloc_cache(drv->nl_handle_event, &drv->nl_cache_event) <
0) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
- "netlink cache (event)");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: Failed to allocate generic "
+ "netlink cache (event)");
goto err3b;
}
#else /* CONFIG_LIBNL20 */
drv->nl_cache = genl_ctrl_alloc_cache(drv->nl_handle);
if (drv->nl_cache == NULL) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
- "netlink cache");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: Failed to allocate generic "
+ "netlink cache");
goto err3;
}
drv->nl_cache_event = genl_ctrl_alloc_cache(drv->nl_handle_event);
if (drv->nl_cache_event == NULL) {
- wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
- "netlink cache (event)");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: Failed to allocate generic "
+ "netlink cache (event)");
goto err3b;
}
#endif /* CONFIG_LIBNL20 */
drv->nl80211 = genl_ctrl_search_by_name(drv->nl_cache, "nl80211");
if (drv->nl80211 == NULL) {
- wpa_printf(MSG_ERROR, "nl80211: 'nl80211' generic netlink not "
- "found");
+ wpa_msg(drv->ctx, MSG_ERROR,
+ "nl80211: 'nl80211' generic netlink not found");
goto err4;
}
@@ -2152,8 +2164,12 @@ static void nl80211_get_phy_name(struct wpa_driver_nl80211_data *drv)
static void nl80211_l2_read(void *ctx, const u8 *src_addr, const u8 *buf,
size_t len)
{
- wpa_printf(MSG_DEBUG, "nl80211: l2_packet read %u",
- (unsigned int) len);
+ /**
+ * NOTE: Not sure what ctx can be here, so don't pass it to
+ * wpa_msg w/out verifying it's OK.
+ */
+ wpa_msg(NULL, MSG_DEBUG, "nl80211: l2_packet read %u",
+ (unsigned int) len);
}
#endif /* CONFIG_AP */
@@ -2588,8 +2604,8 @@ static int wpa_driver_nl80211_scan(void *priv,
if (params->freqs) {
for (i = 0; params->freqs[i]; i++) {
- wpa_printf(MSG_MSGDUMP, "nl80211: Scan frequency %u "
- "MHz", params->freqs[i]);
+ wpa_msg(drv->ctx, MSG_MSGDUMP, "nl80211: Scan frequency %u "
+ "MHz", params->freqs[i]);
NLA_PUT_U32(freqs, i + 1, params->freqs[i]);
}
nla_put_nested(msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs);
@@ -2610,8 +2626,9 @@ static int wpa_driver_nl80211_scan(void *priv,
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
msg = NULL;
if (ret) {
- wpa_printf(MSG_DEBUG, "nl80211: Scan trigger failed: ret=%d "
- "(%s)", ret, strerror(-ret));
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Scan trigger failed: ret=%d (%s)",
+ ret, strerror(-ret));
#ifdef HOSTAPD
if (is_ap_interface(drv->nlmode)) {
/*
@@ -2900,15 +2917,16 @@ static int bss_info_handler(struct nl_msg *msg, void *arg)
bss[NL80211_BSS_FREQUENCY]) {
_arg->assoc_freq =
nla_get_u32(bss[NL80211_BSS_FREQUENCY]);
- wpa_printf(MSG_DEBUG, "nl80211: Associated on %u MHz",
- _arg->assoc_freq);
+ wpa_msg(_arg->drv->ctx, MSG_DEBUG,
+ "nl80211: Associated on %u MHz",
+ _arg->assoc_freq);
}
if (status == NL80211_BSS_STATUS_ASSOCIATED &&
bss[NL80211_BSS_BSSID]) {
os_memcpy(_arg->assoc_bssid,
nla_data(bss[NL80211_BSS_BSSID]), ETH_ALEN);
- wpa_printf(MSG_DEBUG, "nl80211: Associated with "
- MACSTR, MAC2STR(_arg->assoc_bssid));
+ wpa_msg(_arg->drv->ctx, MSG_DEBUG, "nl80211: Associated with "
+ MACSTR, MAC2STR(_arg->assoc_bssid));
}
}
if (!res)
@@ -3003,8 +3021,9 @@ static int bss_info_handler(struct nl_msg *msg, void *arg)
continue;
/* Same BSSID,SSID was already included in scan results */
- wpa_printf(MSG_DEBUG, "nl80211: Remove duplicated scan result "
- "for " MACSTR, MAC2STR(r->bssid));
+ wpa_msg(_arg->drv->ctx, MSG_DEBUG,
+ "nl80211: Remove duplicated scan result for " MACSTR,
+ MAC2STR(r->bssid));
if ((r->flags & WPA_SCAN_ASSOCIATED) &&
!(res->res[i]->flags & WPA_SCAN_ASSOCIATED)) {
@@ -3261,7 +3280,7 @@ static int wpa_driver_nl80211_set_key(const char *ifname, void *priv,
} else if (addr && is_broadcast_ether_addr(addr)) {
struct nl_msg *types;
int err;
- wpa_printf(MSG_DEBUG, " broadcast key");
+ wpa_msg(drv->ctx, MSG_DEBUG, " broadcast key");
types = nlmsg_alloc();
if (!types)
goto nla_put_failure;
@@ -4120,8 +4139,9 @@ static int wpa_driver_nl80211_send_frame(struct wpa_driver_nl80211_data *drv,
rtap_hdr[8] |= IEEE80211_RADIOTAP_F_WEP;
if (drv->monitor_sock < 0) {
- wpa_printf(MSG_DEBUG, "nl80211: No monitor socket available "
- "for %s", __func__);
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: No monitor socket available for %s",
+ __func__);
return -1;
}
@@ -4574,8 +4594,9 @@ static int nl80211_create_iface_once(struct wpa_driver_nl80211_data *drv,
int ifidx;
int ret = -ENOBUFS;
- wpa_printf(MSG_DEBUG, "nl80211: Create interface iftype %d (%s)",
- iftype, nl80211_iftype_str(iftype));
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Create interface iftype %d (%s)",
+ iftype, nl80211_iftype_str(iftype));
msg = nlmsg_alloc();
if (!msg)
@@ -4987,8 +5008,8 @@ nl80211_create_monitor_interface(struct wpa_driver_nl80211_data *drv)
0);
if (drv->monitor_ifidx == -EOPNOTSUPP) {
- wpa_printf(MSG_DEBUG, "nl80211: Driver does not support "
- "monitor interface type - try to run without it");
+ wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Driver does not support "
+ "monitor interface type - try to run without it");
drv->no_monitor_iface_capab = 1;
}
@@ -5045,7 +5066,8 @@ static int nl80211_send_eapol_data(struct i802_bss *bss,
size_t data_len, const u8 *own_addr)
{
if (bss->drv->l2 == NULL) {
- wpa_printf(MSG_DEBUG, "nl80211: No l2_packet to send EAPOL");
+ wpa_msg(bss->drv->ctx, MSG_DEBUG,
+ "nl80211: No l2_packet to send EAPOL");
return -1;
}
@@ -5191,8 +5213,8 @@ static int wpa_driver_nl80211_ap(struct wpa_driver_nl80211_data *drv,
enum nl80211_iftype nlmode;
if (params->p2p) {
- wpa_printf(MSG_DEBUG, "nl80211: Setup AP operations for P2P "
- "group (GO)");
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Setup AP operations for P2P group (GO)");
nlmode = NL80211_IFTYPE_P2P_GO;
} else
nlmode = NL80211_IFTYPE_AP;
@@ -5206,8 +5228,8 @@ static int wpa_driver_nl80211_ap(struct wpa_driver_nl80211_data *drv,
if (drv->no_monitor_iface_capab) {
if (wpa_driver_nl80211_probe_req_report(&drv->first_bss, 1) < 0)
{
- wpa_printf(MSG_DEBUG, "nl80211: Failed to enable "
- "Probe Request frame reporting in AP mode");
+ wpa_msg(drv->ctx, MSG_DEBUG, "nl80211: Failed to enable "
+ "Probe Request frame reporting in AP mode");
/* Try to survive without this */
}
}
@@ -5347,8 +5369,9 @@ static unsigned int nl80211_get_assoc_bssid(struct wpa_driver_nl80211_data *drv,
os_memcpy(bssid, arg.assoc_bssid, ETH_ALEN);
return 0;
}
- wpa_printf(MSG_DEBUG, "nl80211: Scan result fetch failed: ret=%d "
- "(%s)", ret, strerror(-ret));
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Scan result fetch failed: ret=%d (%s)",
+ ret, strerror(-ret));
nla_put_failure:
nlmsg_free(msg);
return drv->assoc_freq;
@@ -5422,8 +5445,8 @@ static int wpa_driver_nl80211_connect(
if (params->auth_alg & WPA_AUTH_ALG_LEAP)
algs++;
if (algs > 1) {
- wpa_printf(MSG_DEBUG, " * Leave out Auth Type for automatic "
- "selection");
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ " * Leave out Auth Type for automatic selection");
goto skip_auth_type;
}
@@ -5519,8 +5542,9 @@ skip_auth_type:
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
msg = NULL;
if (ret) {
- wpa_printf(MSG_DEBUG, "nl80211: MLME connect failed: ret=%d "
- "(%s)", ret, strerror(-ret));
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: MLME connect failed: ret=%d (%s)",
+ ret, strerror(-ret));
/*
* cfg80211 does not currently accept new connection if we are
* already connected. As a workaround, force disconnection and
@@ -5620,7 +5644,7 @@ static int wpa_driver_nl80211_associate(
cipher = WLAN_CIPHER_SUITE_TKIP;
break;
}
- wpa_printf(MSG_DEBUG, " * pairwise=0x%x", cipher);
+ wpa_msg(drv->ctx, MSG_DEBUG, " * pairwise=0x%x", cipher);
NLA_PUT_U32(msg, NL80211_ATTR_CIPHER_SUITES_PAIRWISE, cipher);
}
@@ -5642,7 +5666,7 @@ static int wpa_driver_nl80211_associate(
cipher = WLAN_CIPHER_SUITE_TKIP;
break;
}
- wpa_printf(MSG_DEBUG, " * group=0x%x", cipher);
+ wpa_msg(drv->ctx, MSG_DEBUG, " * group=0x%x", cipher);
NLA_PUT_U32(msg, NL80211_ATTR_CIPHER_SUITE_GROUP, cipher);
}
@@ -5687,8 +5711,9 @@ static int nl80211_set_mode(struct wpa_driver_nl80211_data *drv,
struct nl_msg *msg;
int ret = -ENOBUFS;
- wpa_printf(MSG_DEBUG, "nl80211: Set mode ifindex %d iftype %d (%s)",
- ifindex, mode, nl80211_iftype_str(mode));
+ wpa_msg(drv->ctx, MSG_DEBUG,
+ "nl80211: Set mode ifindex %d iftype %d (%s)",
+ ifindex, mode, nl80211_iftype_str(mode));
msg = nlmsg_alloc();
if (!msg)
--
1.7.3.4
More information about the Hostap
mailing list