PERFORCE change 66366 for review
Sam Leffler
sam at FreeBSD.org
Fri Dec 3 14:34:33 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=66366
Change 66366 by sam at sam_ebb on 2004/12/03 22:34:02
overhaul debugging msgs for consistency and to shrink
code size a bit
Affected files ...
.. //depot/projects/wifi/sys/net80211/ieee80211_input.c#22 edit
.. //depot/projects/wifi/sys/net80211/ieee80211_node.c#23 edit
Differences ...
==== //depot/projects/wifi/sys/net80211/ieee80211_input.c#22 (text+ko) ====
@@ -51,14 +51,9 @@
#include <net/bpf.h>
-static struct mbuf *ieee80211_defrag(struct ieee80211com *,
- struct ieee80211_node *, struct mbuf *);
-static struct mbuf *ieee80211_decap(struct ieee80211com *, struct mbuf *);
-static void ieee80211_node_pwrsave(struct ieee80211_node *, int enable);
-static void ieee80211_recv_pspoll(struct ieee80211com *,
- struct ieee80211_node *, struct mbuf *);
+#ifdef IEEE80211_DEBUG
+#include <machine/stdarg.h>
-#ifdef IEEE80211_DEBUG
/*
* Decide if a received management frame should be
* printed when debugging is enabled. This filters some
@@ -76,22 +71,47 @@
}
return 1;
}
-#endif
/*
- * Return the bssid of a frame.
+ * Emit a debug message about discarding a frame or information
+ * element. One format is for extracting the mac address from
+ * the frame header; the other is for when a header is not
+ * available or otherwise appropriate.
*/
-static const u_int8_t *
-ieee80211_getbssid(struct ieee80211com *ic, const struct ieee80211_frame *wh)
-{
- if (ic->ic_opmode == IEEE80211_M_STA)
- return wh->i_addr2;
- if ((wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) != IEEE80211_FC1_DIR_NODS)
- return wh->i_addr1;
- if ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == IEEE80211_FC0_SUBTYPE_PS_POLL)
- return wh->i_addr1;
- return wh->i_addr3;
-}
+#define IEEE80211_DISCARD(_ic, _m, _wh, _type, _fmt, ...) do { \
+ if ((_ic)->ic_debug & (_m)) \
+ ieee80211_discard_frame(_ic, _wh, _type, _fmt, __VA_ARGS__);\
+} while (0)
+#define IEEE80211_DISCARD_IE(_ic, _m, _wh, _type, _fmt, ...) do { \
+ if ((_ic)->ic_debug & (_m)) \
+ ieee80211_discard_ie(_ic, _wh, _type, _fmt, __VA_ARGS__);\
+} while (0)
+#define IEEE80211_DISCARD_MAC(_ic, _m, _mac, _type, _fmt, ...) do { \
+ if ((_ic)->ic_debug & (_m)) \
+ ieee80211_discard_mac(_ic, _mac, _type, _fmt, __VA_ARGS__);\
+} while (0)
+
+static const u_int8_t *ieee80211_getbssid(struct ieee80211com *,
+ const struct ieee80211_frame *);
+static void ieee80211_discard_frame(struct ieee80211com *,
+ const struct ieee80211_frame *, const char *type, const char *fmt, ...);
+static void ieee80211_discard_ie(struct ieee80211com *,
+ const struct ieee80211_frame *, const char *type, const char *fmt, ...);
+static void ieee80211_discard_mac(struct ieee80211com *,
+ const u_int8_t mac[IEEE80211_ADDR_LEN], const char *type,
+ const char *fmt, ...);
+#else
+#define IEEE80211_DISCARD(_ic, _m, _wh, _type, _fmt, ...)
+#define IEEE80211_DISCARD_IE(_ic, _m, _wh, _type, _fmt, ...)
+#define IEEE80211_DISCARD_MAC(_ic, _m, _mac, _type, _fmt, ...)
+#endif /* IEEE80211_DEBUG */
+
+static struct mbuf *ieee80211_defrag(struct ieee80211com *,
+ struct ieee80211_node *, struct mbuf *);
+static struct mbuf *ieee80211_decap(struct ieee80211com *, struct mbuf *);
+static void ieee80211_node_pwrsave(struct ieee80211_node *, int enable);
+static void ieee80211_recv_pspoll(struct ieee80211com *,
+ struct ieee80211_node *, struct mbuf *);
/*
* Process a received frame. The node associated with the sender
@@ -137,9 +157,9 @@
goto out;
if (m->m_pkthdr.len < sizeof(struct ieee80211_frame_min)) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
- "%s: frame too short, len %u\n",
- __func__, m->m_pkthdr.len);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_ANY,
+ ni->ni_macaddr, NULL,
+ "too short (1): len %u", m->m_pkthdr.len);
ic->ic_stats.is_rx_tooshort++;
goto out;
}
@@ -153,8 +173,8 @@
if ((wh->i_fc[0] & IEEE80211_FC0_VERSION_MASK) !=
IEEE80211_FC0_VERSION_0) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
- "receive packet with wrong version: %x\n", wh->i_fc[0]);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_ANY,
+ ni->ni_macaddr, NULL, "wrong version %x", wh->i_fc[0]);
ic->ic_stats.is_rx_badversion++;
goto err;
}
@@ -168,9 +188,8 @@
bssid = wh->i_addr2;
if (!IEEE80211_ADDR_EQ(bssid, ni->ni_bssid)) {
/* not interested in */
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard frame not to bss\n",
- ether_sprintf(bssid));
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_INPUT,
+ bssid, NULL, "%s", "not to bss");
ic->ic_stats.is_rx_wrongbss++;
goto out;
}
@@ -184,9 +203,10 @@
bssid = wh->i_addr1;
else {
if (m->m_pkthdr.len < sizeof(struct ieee80211_frame)) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
- "%s: frame too short, len %u\n",
- __func__, m->m_pkthdr.len);
+ IEEE80211_DISCARD_MAC(ic,
+ IEEE80211_MSG_ANY, ni->ni_macaddr,
+ NULL, "too short (2): len %u",
+ m->m_pkthdr.len);
ic->ic_stats.is_rx_tooshort++;
goto out;
}
@@ -200,9 +220,8 @@
if (!IEEE80211_ADDR_EQ(bssid, ic->ic_bss->ni_bssid) &&
!IEEE80211_ADDR_EQ(bssid, ifp->if_broadcastaddr)) {
/* not interested in */
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard data frame not to bss\n",
- ether_sprintf(bssid));
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_INPUT,
+ bssid, NULL, "%s", "not to bss");
ic->ic_stats.is_rx_wrongbss++;
goto out;
}
@@ -244,18 +263,16 @@
if ((wh->i_fc[1] & IEEE80211_FC1_RETRY) &&
SEQ_LEQ(rxseq, ni->ni_rxseqs[tid])) {
/* duplicate, discard */
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard duplicate frame, "
- "seqno <%u,%u> fragno <%u,%u> tid %u\n"
- , ether_sprintf(bssid)
- , rxseq >> IEEE80211_SEQ_SEQ_SHIFT
- , ni->ni_rxseqs[tid] >>
- IEEE80211_SEQ_SEQ_SHIFT
- , rxseq & IEEE80211_SEQ_FRAG_MASK
- , ni->ni_rxseqs[tid] &
- IEEE80211_SEQ_FRAG_MASK
- , tid
- );
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_INPUT,
+ bssid, "duplicate",
+ "seqno <%u,%u> fragno <%u,%u> tid %u",
+ rxseq >> IEEE80211_SEQ_SEQ_SHIFT,
+ ni->ni_rxseqs[tid] >>
+ IEEE80211_SEQ_SEQ_SHIFT,
+ rxseq & IEEE80211_SEQ_FRAG_MASK,
+ ni->ni_rxseqs[tid] &
+ IEEE80211_SEQ_FRAG_MASK,
+ tid);
ic->ic_stats.is_rx_dup++;
IEEE80211_NODE_STAT(ni, rx_dup);
goto out;
@@ -271,9 +288,8 @@
hdrsize = roundup(hdrsize, sizeof(u_int32_t));
if (m->m_len < hdrsize &&
(m = m_pullup(m, hdrsize)) == NULL) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
- "[%s] data frame too short, len %u, expecting %u\n",
- ether_sprintf(ieee80211_getbssid(ic, wh)),
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_ANY,
+ wh, "data", "too short: len %u, expecting %u",
m->m_pkthdr.len, hdrsize);
ic->ic_stats.is_rx_tooshort++;
goto out; /* XXX */
@@ -309,8 +325,8 @@
* It should be silently discarded for
* SIMPLEX interface.
*/
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "%s: discard multicast echo\n", __func__);
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_INPUT,
+ wh, NULL, "%s", "multicast echo");
ic->ic_stats.is_rx_mcastecho++;
goto out;
}
@@ -330,9 +346,8 @@
}
/* check if source STA is associated */
if (ni == ic->ic_bss) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard data from unknown src\n",
- ether_sprintf(wh->i_addr2));
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_INPUT,
+ wh, "data", "%s", "unknown src");
/* NB: caller deals with reference */
ni = ieee80211_dup_bss(ic->ic_sta, wh->i_addr2);
if (ni != NULL) {
@@ -345,9 +360,8 @@
goto err;
}
if (ni->ni_associd == 0) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard data from unassoc src\n",
- ether_sprintf(wh->i_addr2));
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_INPUT,
+ wh, "data", "%s", "unassoc src");
IEEE80211_SEND_MGMT(ic, ni,
IEEE80211_FC0_SUBTYPE_DISASSOC,
IEEE80211_REASON_NOT_ASSOCED);
@@ -381,9 +395,8 @@
/*
* Discard encrypted frames when privacy is off.
*/
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard WEP frame 'cuz PRIVACY "
- "off\n", ether_sprintf(wh->i_addr2));
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_INPUT,
+ wh, "WEP", "%s", "PRIVACY off");
ic->ic_stats.is_rx_noprivacy++;
IEEE80211_NODE_STAT(ni, rx_noprivacy);
goto out;
@@ -415,8 +428,8 @@
* Next strip any MSDU crypto bits.
*/
if (key != NULL && !ieee80211_crypto_demic(ic, key, m)) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "%s: discard frame on demic error\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_INPUT,
+ ni->ni_macaddr, "data", "%s", "demic error");
IEEE80211_NODE_STAT(ni, rx_demicfail);
goto out;
}
@@ -433,8 +446,8 @@
/* don't count Null data frames as errors */
if (subtype == IEEE80211_FC0_SUBTYPE_NODATA)
goto out;
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "%s: decapsulation error\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_INPUT,
+ ni->ni_macaddr, "data", "%s", "decap error");
ic->ic_stats.is_rx_decap++;
IEEE80211_NODE_STAT(ni, rx_decap);
goto err;
@@ -450,10 +463,9 @@
* authenticator until the handshake has completed.
*/
if (eh->ether_type != htons(ETHERTYPE_PAE)) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard data (ether type 0x%x len %u)"
- " on unauthorized port\n",
- ether_sprintf(eh->ether_shost),
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_INPUT,
+ eh->ether_shost, "data",
+ "unauthorized port: ether type 0x%x len %u",
eh->ether_type, m->m_pkthdr.len);
ic->ic_stats.is_rx_unauth++;
IEEE80211_NODE_STAT(ni, rx_unauth);
@@ -531,9 +543,9 @@
goto err;
}
if (m->m_pkthdr.len < sizeof(struct ieee80211_frame)) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
- "%s: mgt data frame too short, len %u\n",
- __func__, m->m_pkthdr.len);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_ANY,
+ ni->ni_macaddr, "mgt", "too short: len %u",
+ m->m_pkthdr.len);
ic->ic_stats.is_rx_tooshort++;
goto out;
}
@@ -552,11 +564,10 @@
* Only shared key auth frames with a challenge
* should be encrypted, discard all others.
*/
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard %s with WEP\n",
- ether_sprintf(wh->i_addr2),
- ieee80211_mgt_subtype_name[subtype >>
- IEEE80211_FC0_SUBTYPE_SHIFT]);
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_INPUT,
+ wh, ieee80211_mgt_subtype_name[subtype >>
+ IEEE80211_FC0_SUBTYPE_SHIFT],
+ "%s", "WEP set but not permitted");
ic->ic_stats.is_rx_mgtdiscard++; /* XXX */
goto out;
}
@@ -564,10 +575,8 @@
/*
* Discard encrypted frames when privacy is off.
*/
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_INPUT,
- "[%s] discard WEP mgt frame 'cuz "
- "PRIVACY off\n",
- ether_sprintf(wh->i_addr2));
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_INPUT,
+ wh, "mgt", "%s", "WEP set but PRIVACY off");
ic->ic_stats.is_rx_noprivacy++;
goto out;
}
@@ -595,8 +604,8 @@
}
goto out;
default:
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
- "%s: bad frame type %x\n", __func__, type);
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_ANY,
+ wh, NULL, "bad frame type 0x%x", type);
/* should not come here */
break;
}
@@ -737,8 +746,8 @@
break;
case IEEE80211_FC1_DIR_DSTODS:
/* not yet supported */
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ANY,
- "%s: discard DS to DS frame\n", __func__);
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_ANY,
+ &wh, "data", "%s", "DS to DS not supported");
m_freem(m);
return NULL;
}
@@ -821,9 +830,9 @@
if (rs->rs_nrates + nxrates > IEEE80211_RATE_MAXSIZE) {
nxrates = IEEE80211_RATE_MAXSIZE - rs->rs_nrates;
IEEE80211_DPRINTF(ic, IEEE80211_MSG_XRATE,
- "%s: extended rate set too large;"
- " only using %u of %u rates\n",
- __func__, nxrates, xrates[1]);
+ "[%s] extended rate set too large;"
+ " only using %u of %u rates\n",
+ ether_sprintf(ni->ni_macaddr), nxrates, xrates[1]);
ic->ic_stats.is_rx_rstoobig++;
}
memcpy(rs->rs_rates + rs->rs_nrates, xrates+2, nxrates);
@@ -869,8 +878,8 @@
IEEE80211_SEND_MGMT(ic, ni,
IEEE80211_FC0_SUBTYPE_AUTH, seq + 1);
IEEE80211_DPRINTF(ic, IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH,
- "station %s authenticated (open)\n",
- ether_sprintf(ni->ni_macaddr));
+ "[%s] station authenticated (open)\n",
+ ether_sprintf(ni->ni_macaddr));
break;
case IEEE80211_M_STA:
@@ -882,9 +891,8 @@
if (status != 0) {
IEEE80211_DPRINTF(ic,
IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH,
- "open authentication failed (reason %d) for %s\n",
- status,
- ether_sprintf(wh->i_addr3));
+ "[%s] open authentication failed (reason %d)\n",
+ ether_sprintf(ni->ni_macaddr), status);
/* XXX can this happen? */
if (ni != ic->ic_bss)
ni->ni_fails++;
@@ -907,7 +915,8 @@
M_DEVBUF, M_NOWAIT);
if (ni->ni_challenge == NULL) {
IEEE80211_DPRINTF(ic, IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH,
- "%s: challenge alloc failed\n", __func__);
+ "[%s] shared key challenge alloc failed\n",
+ ether_sprintf(ni->ni_macaddr));
/* XXX statistic */
}
return (ni->ni_challenge != NULL);
@@ -931,8 +940,9 @@
* for sanity/consistency.
*/
if ((ic->ic_flags & IEEE80211_F_PRIVACY) == 0) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: WEP is off\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key auth",
+ "%s", " PRIVACY is disabled");
estatus = IEEE80211_STATUS_ALG;
goto bad;
}
@@ -943,9 +953,9 @@
*/
if (ni->ni_authmode != IEEE80211_AUTH_AUTO &&
ni->ni_authmode != IEEE80211_AUTH_SHARED) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: operating in %u mode, reject\n",
- __func__, ni->ni_authmode);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key auth",
+ "bad sta auth mode %u", ni->ni_authmode);
ic->ic_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */
estatus = IEEE80211_STATUS_ALG;
goto bad;
@@ -954,9 +964,10 @@
challenge = NULL;
if (frm + 1 < efrm) {
if ((frm[1] + 2) > (efrm - frm)) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: elt %d %d bytes too long\n", __func__,
- frm[0], (frm[1] + 2) - (efrm - frm));
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key auth",
+ "ie %d/%d too long",
+ frm[0], (frm[1] + 2) - (efrm - frm));
ic->ic_stats.is_rx_bad_auth++;
estatus = IEEE80211_STATUS_CHALLENGE;
goto bad;
@@ -969,16 +980,17 @@
case IEEE80211_AUTH_SHARED_CHALLENGE:
case IEEE80211_AUTH_SHARED_RESPONSE:
if (challenge == NULL) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: no challenge sent\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key auth",
+ "%s", "no challenge");
ic->ic_stats.is_rx_bad_auth++;
estatus = IEEE80211_STATUS_CHALLENGE;
goto bad;
}
if (challenge[1] != IEEE80211_CHALLENGE_LEN) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: bad challenge len %d\n",
- __func__, challenge[1]);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key auth",
+ "bad challenge len %d", challenge[1]);
ic->ic_stats.is_rx_bad_auth++;
estatus = IEEE80211_STATUS_CHALLENGE;
goto bad;
@@ -990,13 +1002,15 @@
case IEEE80211_M_MONITOR:
case IEEE80211_M_AHDEMO:
case IEEE80211_M_IBSS:
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: unexpected operating mode\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key auth",
+ "bad operating mode %u", ic->ic_opmode);
return;
case IEEE80211_M_HOSTAP:
if (ic->ic_state != IEEE80211_S_RUN) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: not running\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key auth",
+ "bad state %u", ic->ic_state);
estatus = IEEE80211_STATUS_ALG; /* XXX */
goto bad;
}
@@ -1021,42 +1035,45 @@
IEEE80211_CHALLENGE_LEN);
IEEE80211_DPRINTF(ic,
IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH,
- "shared key %sauth request from station %s\n",
+ "[%s] shared key %sauth request\n",
ether_sprintf(ni->ni_macaddr),
allocbs ? "" : "re");
break;
case IEEE80211_AUTH_SHARED_RESPONSE:
if (ni == ic->ic_bss) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: unknown STA\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key response",
+ "%s", "unknown station");
/* NB: don't send a response */
return;
}
if (ni->ni_challenge == NULL) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: no challenge recorded\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key response",
+ "%s", "no challenge recorded");
ic->ic_stats.is_rx_bad_auth++;
estatus = IEEE80211_STATUS_CHALLENGE;
goto bad;
}
if (memcmp(ni->ni_challenge, &challenge[2],
challenge[1]) != 0) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: challenge mismatch\n", __func__);
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key response",
+ "%s", "challenge mismatch");
ic->ic_stats.is_rx_auth_fail++;
estatus = IEEE80211_STATUS_CHALLENGE;
goto bad;
}
ni->ni_inact_reload = ic->ic_inact_auth;
IEEE80211_DPRINTF(ic,
- IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH,
- "station %s authenticated (shared key)\n",
- ether_sprintf(ni->ni_macaddr));
+ IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH,
+ "[%s] station authenticated (shared key)\n",
+ ether_sprintf(ni->ni_macaddr));
break;
default:
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: bad shared key auth seq %d from %s\n",
- __func__, seq, ether_sprintf(wh->i_addr2));
+ IEEE80211_DISCARD_MAC(ic, IEEE80211_MSG_AUTH,
+ ni->ni_macaddr, "shared key auth",
+ "bad seq %d", seq);
ic->ic_stats.is_rx_bad_auth++;
estatus = IEEE80211_STATUS_SEQUENCE;
goto bad;
@@ -1077,9 +1094,9 @@
if (status != 0) {
IEEE80211_DPRINTF(ic,
IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH,
- "%s: auth failed (reason %d) for %s\n",
- __func__, status,
- ether_sprintf(wh->i_addr3));
+ "[%s] shared key auth failed (reason %d)\n",
+ ether_sprintf(ieee80211_getbssid(ic, wh)),
+ status);
/* XXX can this happen? */
if (ni != ic->ic_bss)
ni->ni_fails++;
@@ -1098,9 +1115,8 @@
IEEE80211_FC0_SUBTYPE_AUTH, seq + 1);
break;
default:
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: bad seq %d from %s\n",
- __func__, seq, ether_sprintf(wh->i_addr2));
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_AUTH,
+ wh, "shared key auth", "bad seq %d", seq);
ic->ic_stats.is_rx_bad_auth++;
return;
}
@@ -1122,20 +1138,18 @@
/* Verify the existence and length of __elem or get out. */
#define IEEE80211_VERIFY_ELEMENT(__elem, __maxlen) do { \
if ((__elem) == NULL) { \
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID, \
- "%s: no " #__elem "in %s frame\n", \
- __func__, ieee80211_mgt_subtype_name[subtype >> \
- IEEE80211_FC0_SUBTYPE_SHIFT]); \
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_ELEMID, \
+ wh, ieee80211_mgt_subtype_name[subtype >> \
+ IEEE80211_FC0_SUBTYPE_SHIFT], \
+ "%s", "no " #__elem ); \
ic->ic_stats.is_rx_elem_missing++; \
return; \
} \
if ((__elem)[1] > (__maxlen)) { \
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID, \
- "%s: bad " #__elem " len %d in %s frame from %s\n",\
- __func__, (__elem)[1], \
- ieee80211_mgt_subtype_name[subtype >> \
- IEEE80211_FC0_SUBTYPE_SHIFT], \
- ether_sprintf(wh->i_addr2)); \
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_ELEMID, \
+ wh, ieee80211_mgt_subtype_name[subtype >> \
+ IEEE80211_FC0_SUBTYPE_SHIFT], \
+ "bad " #__elem " len %d", (__elem)[1]); \
ic->ic_stats.is_rx_elem_toobig++; \
return; \
} \
@@ -1143,12 +1157,10 @@
#define IEEE80211_VERIFY_LENGTH(_len, _minlen) do { \
if ((_len) < (_minlen)) { \
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID, \
- "%s: %s frame too short from %s\n", \
- __func__, \
- ieee80211_mgt_subtype_name[subtype >> \
- IEEE80211_FC0_SUBTYPE_SHIFT], \
- ether_sprintf(wh->i_addr2)); \
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_ELEMID, \
+ wh, ieee80211_mgt_subtype_name[subtype >> \
+ IEEE80211_FC0_SUBTYPE_SHIFT], \
+ "%s", "ie too short"); \
ic->ic_stats.is_rx_elem_toosmall++; \
return; \
} \
@@ -1159,24 +1171,27 @@
ieee80211_ssid_mismatch(struct ieee80211com *ic, const char *tag,
u_int8_t mac[IEEE80211_ADDR_LEN], u_int8_t *ssid)
{
- printf("[%s] %s req ssid mismatch: ", ether_sprintf(mac), tag);
+ printf("[%s] discard %s frame, ssid mismatch: ",
+ ether_sprintf(mac), tag);
ieee80211_print_essid(ssid + 2, ssid[1]);
printf("\n");
}
-#define IEEE80211_VERIFY_SSID(_ni, _ssid, _packet_type) do { \
+#define IEEE80211_VERIFY_SSID(_ni, _ssid) do { \
if ((_ssid)[1] != 0 && \
((_ssid)[1] != (_ni)->ni_esslen || \
memcmp((_ssid) + 2, (_ni)->ni_essid, (_ssid)[1]) != 0)) { \
if (ieee80211_msg_input(ic)) \
- ieee80211_ssid_mismatch(ic, _packet_type, \
+ ieee80211_ssid_mismatch(ic, \
+ ieee80211_mgt_subtype_name[subtype >> \
+ IEEE80211_FC0_SUBTYPE_SHIFT], \
wh->i_addr2, _ssid); \
ic->ic_stats.is_rx_ssidmismatch++; \
return; \
} \
} while (0)
#else /* !IEEE80211_DEBUG */
-#define IEEE80211_VERIFY_SSID(_ni, _ssid, _packet_type) do { \
+#define IEEE80211_VERIFY_SSID(_ni, _ssid) do { \
if ((_ssid)[1] != 0 && \
((_ssid)[1] != (_ni)->ni_esslen || \
memcmp((_ssid) + 2, (_ni)->ni_essid, (_ssid)[1]) != 0)) { \
@@ -1289,7 +1304,8 @@
* configured for the system.
*/
static int
-ieee80211_parse_wpa(struct ieee80211com *ic, u_int8_t *frm, struct ieee80211_rsnparms *rsn)
+ieee80211_parse_wpa(struct ieee80211com *ic, u_int8_t *frm,
+ struct ieee80211_rsnparms *rsn, const struct ieee80211_frame *wh)
{
u_int8_t len = frm[1];
u_int32_t w;
@@ -1303,16 +1319,18 @@
KASSERT(ic->ic_flags & IEEE80211_F_WPA1,
("not WPA, flags 0x%x", ic->ic_flags));
if (len < 14) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: length %u too short\n", __func__, len);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "WPA", "too short, len %u", len);
return IEEE80211_REASON_IE_INVALID;
}
frm += 6, len -= 4; /* NB: len is payload only */
/* NB: iswapoui already validated the OUI and type */
w = LE_READ_2(frm);
if (w != WPA_VERSION) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: bad version %u\n", __func__, w);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "WPA", "bad version %u", w);
return IEEE80211_REASON_IE_INVALID;
}
frm += 2, len -= 2;
@@ -1320,9 +1338,10 @@
/* multicast/group cipher */
w = wpa_cipher(frm, &rsn->rsn_mcastkeylen);
if (w != rsn->rsn_mcastcipher) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: mcast cipher mismatch; got %u, expected %u\n",
- __func__, w, rsn->rsn_mcastcipher);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "WPA", "mcast cipher mismatch; got %u, expected %u",
+ w, rsn->rsn_mcastcipher);
return IEEE80211_REASON_IE_INVALID;
}
frm += 4, len -= 4;
@@ -1331,9 +1350,10 @@
n = LE_READ_2(frm);
frm += 2, len -= 2;
if (len < n*4+2) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: not enough data for ucast ciphers; len %u, n %u\n",
- __func__, len, n);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "WPA", "ucast cipher data too short; len %u, n %u",
+ len, n);
return IEEE80211_REASON_IE_INVALID;
}
w = 0;
@@ -1343,8 +1363,9 @@
}
w &= rsn->rsn_ucastcipherset;
if (w == 0) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: ucast cipher set empty\n", __func__);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "WPA", "%s", "ucast cipher set empty");
return IEEE80211_REASON_IE_INVALID;
}
if (w & (1<<IEEE80211_CIPHER_TKIP))
@@ -1356,9 +1377,10 @@
n = LE_READ_2(frm);
frm += 2, len -= 2;
if (len < n*4) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: not enough data for key mgmt algorithms; len %u, n %u\n",
- __func__, len, n);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "WPA", "key mgmt alg data too short; len %u, n %u",
+ len, n);
return IEEE80211_REASON_IE_INVALID;
}
w = 0;
@@ -1368,8 +1390,9 @@
}
w &= rsn->rsn_keymgmtset;
if (w == 0) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: no acceptable key mgmt algorithms\n", __func__);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "WPA", "%s", "no acceptable key mgmt alg");
return IEEE80211_REASON_IE_INVALID;
}
if (w & WPA_ASE_8021X_UNSPEC)
@@ -1444,7 +1467,8 @@
* configured for the system.
*/
static int
-ieee80211_parse_rsn(struct ieee80211com *ic, u_int8_t *frm, struct ieee80211_rsnparms *rsn)
+ieee80211_parse_rsn(struct ieee80211com *ic, u_int8_t *frm,
+ struct ieee80211_rsnparms *rsn, const struct ieee80211_frame *wh)
{
u_int8_t len = frm[1];
u_int32_t w;
@@ -1458,14 +1482,16 @@
KASSERT(ic->ic_flags & IEEE80211_F_WPA2,
("not RSN, flags 0x%x", ic->ic_flags));
if (len < 10) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: length %u too short\n", __func__, len);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "RSN", "too short, len %u", len);
return IEEE80211_REASON_IE_INVALID;
}
w = LE_READ_2(frm);
if (w != RSN_VERSION) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: bad version %u\n", __func__, w);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "RSN", "bad version %u", w);
return IEEE80211_REASON_IE_INVALID;
}
frm += 2, len -= 2;
@@ -1473,9 +1499,10 @@
/* multicast/group cipher */
w = rsn_cipher(frm, &rsn->rsn_mcastkeylen);
if (w != rsn->rsn_mcastcipher) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: mcast cipher mismatch; got %u, expected %u\n",
- __func__, w, rsn->rsn_mcastcipher);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "RSN", "mcast cipher mismatch; got %u, expected %u",
+ w, rsn->rsn_mcastcipher);
return IEEE80211_REASON_IE_INVALID;
}
frm += 4, len -= 4;
@@ -1484,9 +1511,10 @@
n = LE_READ_2(frm);
frm += 2, len -= 2;
if (len < n*4+2) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: not enough data for ucast ciphers; len %u, n %u\n",
- __func__, len, n);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "RSN", "ucast cipher data too short; len %u, n %u",
+ len, n);
return IEEE80211_REASON_IE_INVALID;
}
w = 0;
@@ -1496,8 +1524,9 @@
}
w &= rsn->rsn_ucastcipherset;
if (w == 0) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: ucast cipher set empty\n", __func__);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "RSN", "%s", "ucast cipher set empty");
return IEEE80211_REASON_IE_INVALID;
}
if (w & (1<<IEEE80211_CIPHER_TKIP))
@@ -1509,9 +1538,10 @@
n = LE_READ_2(frm);
frm += 2, len -= 2;
if (len < n*4) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: not enough data for key mgmt algorithms; len %u, n %u\n",
- __func__, len, n);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "RSN", "key mgmt alg data too short; len %u, n %u",
+ len, n);
return IEEE80211_REASON_IE_INVALID;
}
w = 0;
@@ -1521,8 +1551,9 @@
}
w &= rsn->rsn_keymgmtset;
if (w == 0) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
- "%s: no acceptable key mgmt algorithms\n", __func__);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WPA,
+ wh, "RSN", "%s", "no acceptable key mgmt alg");
return IEEE80211_REASON_IE_INVALID;
}
if (w & RSN_ASE_8021X_UNSPEC)
@@ -1539,7 +1570,8 @@
}
static int
-ieee80211_parse_wmeparams(struct ieee80211com *ic, u_int8_t *frm)
+ieee80211_parse_wmeparams(struct ieee80211com *ic, u_int8_t *frm,
+ const struct ieee80211_frame *wh)
{
#define MS(_v, _f) (((_v) & _f) >> _f##_S)
struct ieee80211_wme_state *wme = &ic->ic_wme;
@@ -1547,8 +1579,9 @@
int i;
if (len < sizeof(struct ieee80211_wme_param)-2) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID | IEEE80211_MSG_WME,
- "%s: length %u too short\n", __func__, len);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID | IEEE80211_MSG_WME,
+ wh, "WME", "too short, len %u", len);
return 0;
}
qosinfo = frm[__offsetof(struct ieee80211_wme_param, param_qosInfo)];
@@ -1587,6 +1620,7 @@
}
if (*iep != NULL)
memcpy(*iep, ie, ielen);
+ /* XXX note failure */
}
#ifdef IEEE80211_DEBUG
@@ -1598,7 +1632,7 @@
{
printf("[%s] %s%s on chan %u (bss chan %u) ",
ether_sprintf(mac), isnew ? "new " : "",
- (subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP) ? "probe response" : "beacon",
+ ieee80211_mgt_subtype_name[subtype >> IEEE80211_FC0_SUBTYPE_SHIFT],
chan, bchan);
ieee80211_print_essid(ssid + 2, ssid[1]);
printf("\n");
@@ -1729,11 +1763,9 @@
break;
case IEEE80211_ELEMID_ERP:
if (frm[1] != 1) {
- IEEE80211_DPRINTF(ic,
- IEEE80211_MSG_ELEMID,
- "%s: invalid ERP element; "
- "length %u, expecting 1\n",
- __func__, frm[1]);
+ IEEE80211_DISCARD_IE(ic,
+ IEEE80211_MSG_ELEMID, wh, "ERP",
+ "bad len %u", frm[1]);
ic->ic_stats.is_rx_elem_toobig++;
break;
}
@@ -1750,9 +1782,9 @@
/* XXX Atheros OUI support */
break;
default:
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID,
- "%s: element id %u/len %u ignored\n",
- __func__, *frm, frm[1]);
+ IEEE80211_DISCARD_IE(ic, IEEE80211_MSG_ELEMID,
+ wh, "unhandled",
+ "id %u, len %u", *frm, frm[1]);
ic->ic_stats.is_rx_elem_unknown++;
break;
}
@@ -1765,11 +1797,10 @@
chan > IEEE80211_CHAN_MAX ||
#endif
isclr(ic->ic_chan_active, chan)) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID,
- "%s: ignore %s with invalid channel %u\n",
- __func__,
- ISPROBE(subtype) ? "probe response" : "beacon",
- chan);
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_ELEMID,
+ wh, ieee80211_mgt_subtype_name[subtype >>
+ IEEE80211_FC0_SUBTYPE_SHIFT],
+ "invalid channel %u", chan);
ic->ic_stats.is_rx_badchan++;
return;
}
@@ -1784,11 +1815,10 @@
* the rssi value should be correct even for
* different hop pattern in FH.
*/
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_ELEMID,
- "%s: ignore %s on channel %u marked "
- "for channel %u\n", __func__,
- ISPROBE(subtype) ? "probe response" : "beacon",
- bchan, chan);
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_ELEMID,
+ wh, ieee80211_mgt_subtype_name[subtype >>
+ IEEE80211_FC0_SUBTYPE_SHIFT],
+ "for off-channel %u\n", chan);
ic->ic_stats.is_rx_chanmismatch++;
return;
}
@@ -1804,7 +1834,7 @@
IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_bssid))) {
if (ni->ni_erp != erp) {
IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
- "erp change from %s: was 0x%x, now 0x%x\n",
+ "[%s] erp change: was 0x%x, now 0x%x\n",
ether_sprintf(wh->i_addr2),
ni->ni_erp, erp);
if (erp & IEEE80211_ERP_USE_PROTECTION)
@@ -1816,8 +1846,9 @@
}
if ((ni->ni_capinfo ^ capinfo) & IEEE80211_CAPINFO_SHORT_SLOTTIME) {
IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
- "capabilities change from %s: before 0x%x,"
- " now 0x%x\n", ether_sprintf(wh->i_addr2),
+ "[%s] capabilities change: before 0x%x,"
+ " now 0x%x\n",
+ ether_sprintf(wh->i_addr2),
ni->ni_capinfo, capinfo);
/*
* NB: we assume short preamble doesn't
@@ -1829,7 +1860,8 @@
ni->ni_capinfo = capinfo;
/* XXX statistic */
}
- if (wme != NULL && ieee80211_parse_wmeparams(ic, wme))
+ if (wme != NULL &&
+ ieee80211_parse_wmeparams(ic, wme, wh))
ieee80211_wme_updateparams(ic);
/* NB: don't need the rest of this */
return;
@@ -1947,7 +1979,7 @@
}
IEEE80211_VERIFY_ELEMENT(rates, IEEE80211_RATE_MAXSIZE);
IEEE80211_VERIFY_ELEMENT(ssid, IEEE80211_NWID_LEN);
- IEEE80211_VERIFY_SSID(ic->ic_bss, ssid, "probe");
+ IEEE80211_VERIFY_SSID(ic->ic_bss, ssid);
if (ni == ic->ic_bss) {
if (ic->ic_opmode == IEEE80211_M_IBSS) {
@@ -1967,17 +1999,17 @@
} else
allocbs = 0;
IEEE80211_DPRINTF(ic, IEEE80211_MSG_ASSOC,
- "%s: probe req from %s\n", __func__,
- ether_sprintf(wh->i_addr2));
+ "[%s] recv probe req\n", ether_sprintf(wh->i_addr2));
ni->ni_rssi = rssi;
ni->ni_rstamp = rstamp;
rate = ieee80211_setup_rates(ic, ni, rates, xrates,
IEEE80211_F_DOSORT | IEEE80211_F_DOFRATE
| IEEE80211_F_DONEGO | IEEE80211_F_DODEL);
if (rate & IEEE80211_RATE_BASIC) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_XRATE,
- "[%s] received rate set invalid\n",
- ether_sprintf(wh->i_addr2));
+ IEEE80211_DISCARD(ic, IEEE80211_MSG_XRATE,
+ wh, ieee80211_mgt_subtype_name[subtype >>
+ IEEE80211_FC0_SUBTYPE_SHIFT],
+ "%s", "recv'd rate set invalid");
if (allocbs) /* reclaim immediately */
ieee80211_free_node(ni);
} else {
@@ -2001,26 +2033,22 @@
seq = le16toh(*(u_int16_t *)(frm + 2));
status = le16toh(*(u_int16_t *)(frm + 4));
IEEE80211_DPRINTF(ic, IEEE80211_MSG_AUTH,
- "%s: algorithm %d seq %d from %s\n",
- __func__, algo, seq, ether_sprintf(wh->i_addr2));
+ "[%s] recv auth frame with algorithm %d seq %d\n",
+ ether_sprintf(wh->i_addr2), algo, seq);
/*
* Consult the ACL policy module if setup.
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list