Added lots of debug to understand & test IBSS merges

from the madwifi-dfs branch (benoit) r3086

Added MAC_FMT & MAC_ADDR macros that can be used as a drop-in
replacement for ether_sprintf(). Fixed some use of ether_sprintf() that
uses the same static buffer twice.

- Without the functional changes.



git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3091 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
br1 2007-12-28 04:35:23 +00:00
parent f23be2b4ce
commit fd0bc7d1b2
5 changed files with 105 additions and 32 deletions

View File

@ -5941,6 +5941,11 @@ ath_recv_mgmt(struct ieee80211_node *ni, struct sk_buff *skb,
u_int64_t hw_tsf, beacon_tsf;
u_int32_t hw_tu;
DPRINTF(sc, ATH_DEBUG_BEACON,
"%s: vap:%p[" MAC_FMT "] ni:%p[" MAC_FMT "]\n",
__func__, vap, MAC_ADDR(vap->iv_bss->ni_bssid),
ni, MAC_ADDR(ni->ni_macaddr));
/*
* Call up first so subsequent work can use information
* potentially stored in the node (e.g. for ibss merge).
@ -6232,6 +6237,27 @@ rx_accept:
sc->sc_hwmap[rs->rs_rate].ieeerate,
rs->rs_rssi);
{
struct ieee80211_frame * wh =
(struct ieee80211_frame *) skb->data;
/* only print beacons */
if ((skb->len >= sizeof(struct ieee80211_frame)) &&
((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK)
== IEEE80211_FC0_TYPE_MGT) &&
((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK)
== IEEE80211_FC0_SUBTYPE_BEACON)) {
DPRINTF(sc, ATH_DEBUG_BEACON,
"%s: RA:" MAC_FMT " TA:" MAC_FMT
" BSSID:" MAC_FMT "\n",
__func__, MAC_ADDR(wh->i_addr1),
MAC_ADDR(wh->i_addr2),
MAC_ADDR(wh->i_addr3));
}
}
/*
* Locate the node for sender, track state, and then
* pass the (referenced) node up to the 802.11 layer
@ -8597,6 +8623,10 @@ ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
if (stamode && nstate == IEEE80211_S_RUN) {
sc->sc_curaid = ni->ni_associd;
IEEE80211_ADDR_COPY(sc->sc_curbssid, ni->ni_bssid);
DPRINTF(sc, ATH_DEBUG_BEACON,
"%s: sc_curbssid " MAC_FMT " from " MAC_FMT "\n",
__func__, MAC_ADDR(sc->sc_curbssid),
MAC_ADDR(ni->ni_macaddr));
} else
sc->sc_curaid = 0;
@ -8605,8 +8635,12 @@ ath_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
sc->sc_curaid);
ath_hal_setrxfilter(ah, rfilt);
if (stamode)
if (stamode) {
DPRINTF(sc, ATH_DEBUG_BEACON,
"%s: setassocid " MAC_FMT "\n",
__func__, MAC_ADDR(sc->sc_curbssid));
ath_hal_setassocid(ah, sc->sc_curbssid, sc->sc_curaid);
}
if ((vap->iv_opmode != IEEE80211_M_STA) &&
(vap->iv_flags & IEEE80211_F_PRIVACY)) {

View File

@ -270,6 +270,9 @@ ieee80211_beacon_alloc(struct ieee80211_node *ni,
IEEE80211_ADDR_COPY(wh->i_addr1, ic->ic_dev->broadcast);
IEEE80211_ADDR_COPY(wh->i_addr2, vap->iv_myaddr);
IEEE80211_ADDR_COPY(wh->i_addr3, vap->iv_bss->ni_bssid);
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
"%s: beacon bssid:" MAC_FMT "\n",
__func__, MAC_ADDR(wh->i_addr3));
*(u_int16_t *)wh->i_seq = 0;
return skb;

View File

@ -2635,6 +2635,11 @@ ieee80211_recv_mgmt(struct ieee80211_node *ni, struct sk_buff *skb,
frm = (u_int8_t *)&wh[1];
efrm = skb->data + skb->len;
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
"%s: vap:%p[" MAC_FMT "] ni:%p[" MAC_FMT "]\n",
__func__, vap, MAC_ADDR(vap->iv_bss->ni_bssid),
ni, MAC_ADDR(ni->ni_macaddr));
/* forward management frame to application */
if (vap->iv_opmode != IEEE80211_M_MONITOR)
forward_mgmt_to_app(vap, subtype, skb, wh);
@ -3814,9 +3819,9 @@ ieee80211_note(struct ieee80211vap *vap, const char *fmt, ...)
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
printk("%s/%s[%s]: %s",
VAP_IC_DEV_NAME(vap), VAP_DEV_NAME(vap),
ether_sprintf(vap->iv_myaddr),
printk("%s/%s[" MAC_FMT "]: %s",
vap->iv_ic->ic_dev->name, vap->iv_dev->name,
MAC_ADDR(vap->iv_myaddr),
buf); /* NB: no \n */
}
EXPORT_SYMBOL(ieee80211_note);
@ -3831,10 +3836,10 @@ ieee80211_note_frame(struct ieee80211vap *vap, const struct ieee80211_frame *wh,
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
printk("%s/%s[%s]: %s %s\n",
VAP_IC_DEV_NAME(vap), VAP_DEV_NAME(vap),
ether_sprintf(vap->iv_myaddr),
ether_sprintf(ieee80211_getbssid(vap, wh)), buf);
printk("%s/%s[" MAC_FMT "]: " MAC_FMT " %s\n",
vap->iv_ic->ic_dev->name, vap->iv_dev->name,
MAC_ADDR(vap->iv_myaddr),
MAC_ADDR(ieee80211_getbssid(vap, wh)), buf);
}
EXPORT_SYMBOL(ieee80211_note_frame);
@ -3848,10 +3853,10 @@ ieee80211_note_mac(struct ieee80211vap *vap, const u_int8_t mac[IEEE80211_ADDR_L
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
printk("%s/%s[%s]: %s %s\n",
VAP_IC_DEV_NAME(vap), VAP_DEV_NAME(vap),
ether_sprintf(vap->iv_myaddr),
ether_sprintf(mac), buf);
printk("%s/%s[" MAC_FMT "]: " MAC_FMT " %s\n",
vap->iv_ic->ic_dev->name, vap->iv_dev->name,
MAC_ADDR(vap->iv_myaddr),
MAC_ADDR(mac), buf);
}
EXPORT_SYMBOL(ieee80211_note_mac);
@ -3865,13 +3870,13 @@ ieee80211_discard_frame(struct ieee80211vap *vap, const struct ieee80211_frame *
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
printk("%s/%s[%s]: %s discard %s%sframe, %s\n",
VAP_IC_DEV_NAME(vap), VAP_DEV_NAME(vap),
ether_sprintf(vap->iv_myaddr),
ether_sprintf(ieee80211_getbssid(vap, wh)),
(type != NULL) ? type : "",
(type != NULL) ? " " : "",
buf);
printk("%s/%s[" MAC_FMT "]: " MAC_FMT " discard %s%sframe, %s\n",
vap->iv_ic->ic_dev->name, vap->iv_dev->name,
MAC_ADDR(vap->iv_myaddr),
MAC_ADDR(wh->i_addr2),
(type != NULL) ? type : "",
(type != NULL) ? " " : "",
buf);
}
static void
@ -3884,12 +3889,13 @@ ieee80211_discard_ie(struct ieee80211vap *vap, const struct ieee80211_frame *wh,
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
printk("%s/%s[%s]: %s discard %s%sinformation element, %s\n",
VAP_IC_DEV_NAME(vap), VAP_DEV_NAME(vap),
ether_sprintf(vap->iv_myaddr),
ether_sprintf(ieee80211_getbssid(vap, wh)),
(type != NULL) ? type : "",
(type != NULL) ? " " : "",
printk("%s/%s[" MAC_FMT "]: "
MAC_FMT " discard %s%sinformation element, %s\n",
vap->iv_ic->ic_dev->name, vap->iv_dev->name,
MAC_ADDR(vap->iv_myaddr),
MAC_ADDR(ieee80211_getbssid(vap, wh)),
(type != NULL) ? type : "",
(type != NULL) ? " " : "",
buf);
}
@ -3903,12 +3909,13 @@ ieee80211_discard_mac(struct ieee80211vap *vap, const u_int8_t mac[IEEE80211_ADD
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
printk("%s/%s[%s]: %s discard %s%sframe, %s\n",
VAP_IC_DEV_NAME(vap), VAP_DEV_NAME(vap),
ether_sprintf(vap->iv_myaddr),
ether_sprintf(mac),
(type != NULL) ? type : "",
(type != NULL) ? " " : "",
printk("%s/%s[" MAC_FMT "]: " MAC_FMT " discard %s%sframe, %s\n",
vap->iv_ic->ic_dev->name,
vap->iv_dev->name,
MAC_ADDR(vap->iv_myaddr),
MAC_ADDR(mac),
(type != NULL) ? type : "",
(type != NULL) ? " " : "",
buf);
}
#endif /* IEEE80211_DEBUG */

View File

@ -306,12 +306,15 @@ ieee80211_create_ibss(struct ieee80211vap* vap, struct ieee80211_channel *chan)
"%s: creating ibss on channel %u\n", __func__,
ieee80211_chan2ieee(ic, chan));
/* Check to see if we already have a node for this mac
/* Check to see if we already have a node for this mac
* NB: we gain a node reference here
*/
ni = ieee80211_find_node(&ic->ic_sta, vap->iv_myaddr);
if (ni == NULL) {
ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr);
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
"%s: ni:%p allocated for " MAC_FMT "\n",
__func__, ni, MAC_ADDR(vap->iv_myaddr));
if (ni == NULL) {
/* XXX recovery? */
return;
@ -401,6 +404,9 @@ ieee80211_reset_bss(struct ieee80211vap *vap)
ieee80211_reset_erp(ic, ic->ic_curmode);
ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr);
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
"%s: ni:%p allocated for " MAC_FMT "\n",
__func__, ni, MAC_ADDR(vap->iv_myaddr));
KASSERT(ni != NULL, ("unable to setup inital BSS node"));
/* New reference for caller */
@ -551,12 +557,17 @@ ieee80211_ibss_merge(struct ieee80211_node *ni)
#ifdef IEEE80211_DEBUG
struct ieee80211com *ic = ni->ni_ic;
#endif
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
"%s: ni:%p[" MAC_FMT "] iv_bss:%p[" MAC_FMT "]\n",
__func__, ni, MAC_ADDR(ni->ni_macaddr),
vap->iv_bss, MAC_ADDR(vap->iv_bss->ni_macaddr));
if (ni == vap->iv_bss ||
IEEE80211_ADDR_EQ(ni->ni_bssid, vap->iv_bss->ni_bssid)) {
/* unchanged, nothing to do */
return 0;
}
if (!check_bss(vap, ni)) {
/* capabilities mismatch */
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
@ -676,6 +687,9 @@ ieee80211_sta_join(struct ieee80211vap *vap,
ni = ieee80211_find_node(&ic->ic_sta, se->se_macaddr);
if (ni == NULL) {
ni = ieee80211_alloc_node_table(vap, se->se_macaddr);
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
"%s: ni:%p allocated for " MAC_FMT "\n",
__func__, ni, MAC_ADDR(se->se_macaddr));
if (ni == NULL) {
IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,
"%s: Unable to allocate node for BSS: %s\n", __func__,
@ -1263,6 +1277,9 @@ ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr,
#else
ni = ieee80211_alloc_node_table(vap, macaddr);
#endif
IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC,
"%s: ni:%p allocated for " MAC_FMT "\n",
__func__, ni, MAC_ADDR(macaddr));
}
if (ni != NULL) {

View File

@ -665,4 +665,16 @@ ieee80211_anyhdrspace(struct ieee80211com *ic, const void *data)
size = roundup(size, sizeof(u_int32_t));
return size;
}
/* Macros to print MAC address used in 802.11 headers */
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
#define MAC_ADDR(addr) \
((unsigned char *)(addr)) [0], \
((unsigned char *)(addr)) [1], \
((unsigned char *)(addr)) [2], \
((unsigned char *)(addr)) [3], \
((unsigned char *)(addr)) [4], \
((unsigned char *)(addr)) [5]
#endif /* _NET80211_IEEE80211_VAR_H_ */