Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/net80211 More debug consolidation.
details: https://anonhg.NetBSD.org/src-all/rev/cc14e2b505c9
branches: trunk
changeset: 989810:cc14e2b505c9
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Wed Dec 30 17:37:53 2020 +0100
description:
More debug consolidation.
diffstat:
sys/net80211/ieee80211_node.c | 43 +++++++++++++------------
sys/net80211/ieee80211_scan.c | 64 ++++++++++++++++++++++++++------------
sys/net80211/ieee80211_scan.h | 3 +-
sys/net80211/ieee80211_scan_sta.c | 28 +++++++++-------
4 files changed, 83 insertions(+), 55 deletions(-)
diffs (263 lines):
diff -r 0d4bf93953a4 -r cc14e2b505c9 sys/net80211/ieee80211_node.c
--- a/sys/net80211/ieee80211_node.c Tue Dec 29 20:54:38 2020 +0100
+++ b/sys/net80211/ieee80211_node.c Wed Dec 30 17:37:53 2020 +0100
@@ -487,10 +487,11 @@
} else
IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_myaddr);
#ifdef IEEE80211_DEBUG
- char temp[40];
- strcpy(temp, ether_sprintf(ni->ni_macaddr));
- printf ("reset_bss: macaddr %s, bssid %s\n",
- temp, ether_sprintf(ni->ni_bssid));
+ char mac[IEEE80211_ADDR_PRINT_LEN], bssid[IEEE80211_ADDR_PRINT_LEN];
+ IEEE80211_DPRINTF(vap, IEEE80211_MSG_DEBUG,
+ "reset_bss: macaddr %s, bssid %s\n",
+ ether_snprintf(mac, sizeof(mac), ni->ni_macaddr),
+ ether_snprintf(bssid, sizeof(bssid), ni->ni_bssid));
#endif
}
@@ -555,7 +556,8 @@
check_bss_debug(struct ieee80211vap *vap, struct ieee80211_node *ni)
{
struct ieee80211com *ic = ni->ni_ic;
- char essid[IEEE80211_NWID_PRINT_LEN];
+ char essid[IEEE80211_NWID_PRINT_LEN],
+ bssid[IEEE80211_ADDR_PRINT_LEN], mac[IEEE80211_ADDR_PRINT_LEN];
uint8_t rate;
int fail;
@@ -588,18 +590,16 @@
!IEEE80211_ADDR_EQ(vap->iv_des_bssid, ni->ni_bssid))
fail |= 0x20;
- printf(" %c %s", fail ? '-' : '+', ether_sprintf(ni->ni_macaddr));
- printf(" %s%c", ether_sprintf(ni->ni_bssid), fail & 0x20 ? '!' : ' ');
- printf(" %3d%c",
- ieee80211_chan2ieee(ic, ni->ni_chan), fail & 0x01 ? '!' : ' ');
- printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2,
- fail & 0x08 ? '!' : ' ');
- printf(" %4s%c",
+ IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
+ " %c %s %s%c %3d%c %2dM%c %4s%c %3s%c %s %s",
+ fail ? '-' : '+', ether_snprintf(mac, sizeof(mac), ni->ni_macaddr),
+ ether_snprintf(bssid, sizeof(bssid), ni->ni_bssid),
+ fail & 0x20 ? '!' : ' ',
+ ieee80211_chan2ieee(ic, ni->ni_chan), fail & 0x01 ? '!' : ' ',
+ (rate & IEEE80211_RATE_VAL) / 2, fail & 0x08 ? '!' : ' ',
(ni->ni_capinfo & IEEE80211_CAPINFO_ESS) ? "ess" :
- (ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) ? "ibss" :
- "????",
- fail & 0x02 ? '!' : ' ');
- printf(" %3s%c %s %s\n",
+ (ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) ? "ibss" : "????",
+ fail & 0x02 ? '!' : ' ',
(ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) ? "wep" : "no",
fail & 0x04 ? '!' : ' ',
ieee80211_sprint_essid(essid, ni->ni_essid, ni->ni_esslen),
@@ -1076,11 +1076,12 @@
ieee80211_ratectl_node_init(ni);
#ifdef IEEE80211_DEBUG
- char temp[40];
- strcpy(temp, ether_sprintf(ni->ni_macaddr));
- printf ("At end of ieee80211_sta_join, ni is 0x%lx\n", (long)ni);
- printf (" macaddr is %s, bss is %s\n", temp,
- ether_sprintf(ni->ni_bssid));
+ char temp1[IEEE80211_ADDR_PRINT_LEN], temp2[IEEE80211_ADDR_PRINT_LEN];
+ IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
+ "at end of ieee80211_sta_join, ni is %p\n"
+ " macaddr is %s, bss is %s",
+ ni, ether_snprintf(temp1, sizeof(temp1), ni->ni_macaddr),
+ ether_snprintf(temp2, sizeof(temp2), ni->ni_bssid));
#endif
return ieee80211_sta_join1(ieee80211_ref_node(ni));
diff -r 0d4bf93953a4 -r cc14e2b505c9 sys/net80211/ieee80211_scan.c
--- a/sys/net80211/ieee80211_scan.c Tue Dec 29 20:54:38 2020 +0100
+++ b/sys/net80211/ieee80211_scan.c Wed Dec 30 17:37:53 2020 +0100
@@ -317,18 +317,23 @@
}
void
-ieee80211_scan_dump_channels(const struct ieee80211_scan_state *ss)
+ieee80211_scan_dump_channels(char *out, size_t len,
+ const struct ieee80211_scan_state *ss)
{
struct ieee80211com *ic = ss->ss_ic;
const char *sep;
- int i;
+ int i, cnt;
sep = "";
for (i = ss->ss_next; i < ss->ss_last; i++) {
const struct ieee80211_channel *c = ss->ss_chans[i];
- printf("%s%u%c", sep, ieee80211_chan2ieee(ic, c),
+ cnt = snprintf(out, len, "%s%u%c", sep,
+ ieee80211_chan2ieee(ic, c),
ieee80211_channel_type_char(c));
+ if (cnt < 0 || cnt >= len)
+ break;
+ len -= cnt; out += cnt;
sep = ", ";
}
}
@@ -338,10 +343,11 @@
ieee80211_scan_dump(struct ieee80211_scan_state *ss)
{
struct ieee80211vap *vap = ss->ss_vap;
+ char chans[200];
- if_printf(vap->iv_ifp, "scan set ");
- ieee80211_scan_dump_channels(ss);
- printf(" dwell min %lums max %lums\n",
+ ieee80211_scan_dump_channels(chans, sizeof(chans), ss);
+ IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
+ "scan set %s dwell min %lums max %lums", chans,
ticks_to_msecs(ss->ss_mindwell), ticks_to_msecs(ss->ss_maxdwell));
}
#endif /* IEEE80211_DEBUG */
@@ -574,28 +580,39 @@
#ifdef IEEE80211_DEBUG
static void
-dump_country(struct ieee80211vap *vap, const uint8_t *ie)
+dump_country(char *out, size_t len,
+ struct ieee80211vap *vap, const uint8_t *ie)
{
const struct ieee80211_country_ie *cie =
(const struct ieee80211_country_ie *) ie;
- int i, nbands, schan, nchan;
+ int i, nbands, schan, nchan, cnt;
if (cie->len < 3) {
- printf(" <bogus country ie, len %d>", cie->len);
+ snprintf(out, len, " <bogus country ie, len %d>", cie->len);
return;
}
- printf(" country [%c%c%c", cie->cc[0], cie->cc[1], cie->cc[2]);
+ cnt = snprintf(out, len, " country [%c%c%c",
+ cie->cc[0], cie->cc[1], cie->cc[2]);
+ if (cnt < 0 || cnt >= len)
+ return;
+ len -= cnt; out += cnt;
nbands = (cie->len - 3) / sizeof(cie->band[0]);
for (i = 0; i < nbands; i++) {
schan = cie->band[i].schan;
nchan = cie->band[i].nchan;
if (nchan != 1)
- printf(" %u-%u,%u", schan, schan + nchan-1,
+ cnt = snprintf(out, len, " %u-%u,%u",
+ schan, schan + nchan-1,
cie->band[i].maxtxpwr);
else
- printf(" %u,%u", schan, cie->band[i].maxtxpwr);
+ snprintf(out, len, " %u,%u",
+ schan, cie->band[i].maxtxpwr);
+ if (cnt < 0 || cnt >= len)
+ return;
+ len -= cnt; out += cnt;
}
- printf("]");
+ if (len >= 2)
+ strcpy(out, "]");
}
void
@@ -604,20 +621,27 @@
const uint8_t mac[IEEE80211_ADDR_LEN],
const struct ieee80211_scanparams *sp, int rssi)
{
- char ssid[IEEE80211_NWID_PRINT_LEN];
+ char ssid[IEEE80211_NWID_PRINT_LEN], macstr[IEEE80211_ADDR_PRINT_LEN],
+ country[200];
- printf("[%s] %s%s on chan %u (bss chan %u) %s rssi %d\n",
- ether_sprintf(mac), isnew ? "new " : "",
+ IEEE80211_DPRINTF(vap, IEEE80211_F_SCAN,
+ "[%s] %s%s on chan %u (bss chan %u) %s rssi %d",
+ ether_snprintf(macstr, sizeof(macstr), mac), isnew ? "new " : "",
ieee80211_mgt_subtype_name(subtype), sp->chan, sp->bchan,
ieee80211_sprint_essid(ssid, sp->ssid + 2, sp->ssid[1]),
rssi);
if (isnew) {
- printf("[%s] caps 0x%x bintval %u erp 0x%x",
- ether_sprintf(mac), sp->capinfo, sp->bintval, sp->erp);
if (sp->country != NULL)
- dump_country(vap, sp->country);
- printf("\n");
+ dump_country(country, sizeof(country),
+ vap, sp->country);
+ else
+ country[0] = 0;
+
+ IEEE80211_DPRINTF(vap, IEEE80211_F_SCAN,
+ "[%s] caps 0x%x bintval %u erp 0x%x %s",
+ ether_sprintf(mac), sp->capinfo, sp->bintval, sp->erp,
+ country);
}
}
#endif /* IEEE80211_DEBUG */
diff -r 0d4bf93953a4 -r cc14e2b505c9 sys/net80211/ieee80211_scan.h
--- a/sys/net80211/ieee80211_scan.h Tue Dec 29 20:54:38 2020 +0100
+++ b/sys/net80211/ieee80211_scan.h Wed Dec 30 17:37:53 2020 +0100
@@ -165,7 +165,8 @@
void ieee80211_scan_vattach(struct ieee80211vap *);
void ieee80211_scan_vdetach(struct ieee80211vap *);
-void ieee80211_scan_dump_channels(const struct ieee80211_scan_state *);
+void ieee80211_scan_dump_channels(char *, size_t,
+ const struct ieee80211_scan_state *);
#define IEEE80211_SCAN_FOREVER 0x7fffffff
int ieee80211_start_scan(struct ieee80211vap *, int flags,
diff -r 0d4bf93953a4 -r cc14e2b505c9 sys/net80211/ieee80211_scan_sta.c
--- a/sys/net80211/ieee80211_scan_sta.c Tue Dec 29 20:54:38 2020 +0100
+++ b/sys/net80211/ieee80211_scan_sta.c Wed Dec 30 17:37:53 2020 +0100
@@ -1210,9 +1210,12 @@
fail |= MATCH_RSSI;
#ifdef IEEE80211_DEBUG
if (ieee80211_msg(vap, debug)) {
- char ssid[IEEE80211_NWID_PRINT_LEN];
+ char ssid[IEEE80211_NWID_PRINT_LEN],
+ mac[IEEE80211_ADDR_PRINT_LEN],
+ bssid[IEEE80211_ADDR_PRINT_LEN];
- printf(" %c %s",
+ IEEE80211_DPRINTF(vap, debug,
+ " %c %s %s%c %3d%c %+4d%c %2dM%c %4s%c %3s%c %s %s",
fail & MATCH_FAILS ? '=' :
fail & MATCH_NOTSEEN ? '^' :
fail & MATCH_CC ? '$' :
@@ -1224,19 +1227,18 @@
fail & MATCH_TDMA_LOCAL ? 'l' :
#endif
fail & MATCH_MESH_NOID ? 'm' :
- fail ? '-' : '+', ether_sprintf(se->se_macaddr));
- printf(" %s%c", ether_sprintf(se->se_bssid),
- fail & MATCH_BSSID ? '!' : ' ');
- printf(" %3d%c", ieee80211_chan2ieee(ic, se->se_chan),
- fail & MATCH_CHANNEL ? '!' : ' ');
- printf(" %+4d%c", se->se_rssi, fail & MATCH_RSSI ? '!' : ' ');
- printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2,
- fail & MATCH_RATE ? '!' : ' ');
- printf(" %4s%c",
+ fail ? '-' : '+', ether_snprintf(mac, sizeof(mac),
+ se->se_macaddr),
+ ether_snprintf(bssid, sizeof(bssid), se->se_bssid),
+ fail & MATCH_BSSID ? '!' : ' ',
+ ieee80211_chan2ieee(ic, se->se_chan),
+ fail & MATCH_CHANNEL ? '!' : ' ',
+ se->se_rssi, fail & MATCH_RSSI ? '!' : ' ',
+ (rate & IEEE80211_RATE_VAL) / 2,
+ fail & MATCH_RATE ? '!' : ' ',
(se->se_capinfo & IEEE80211_CAPINFO_ESS) ? "ess" :
(se->se_capinfo & IEEE80211_CAPINFO_IBSS) ? "ibss" : "",
- fail & MATCH_CAPINFO ? '!' : ' ');
- printf(" %3s%c %s %s\n",
+ fail & MATCH_CAPINFO ? '!' : ' ',
(se->se_capinfo & IEEE80211_CAPINFO_PRIVACY) ?
"wep" : "no",
fail & MATCH_PRIVACY ? '!' : ' ',
Home |
Main Index |
Thread Index |
Old Index