Add some debug messages to ieee80211_notify_node_{join,leave}.

Change the way we walk 802.11 peers/clients: for each eligible
interface, walk the ic_sta (peers/clients) table, first; walk the
ic_scan (scan results) table, second; then visit the ic_bss (node
for the network joined/created by the interface).
This commit is contained in:
dyoung 2005-06-26 04:34:43 +00:00
parent 74988b0f25
commit 9a7ebfdde9
2 changed files with 54 additions and 24 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_netbsd.c,v 1.2 2005/06/22 06:16:02 dyoung Exp $ */
/* $NetBSD: ieee80211_netbsd.c,v 1.3 2005/06/26 04:34:43 dyoung Exp $ */
/*-
* Copyright (c) 2003-2005 Sam Leffler, Errno Consulting
* All rights reserved.
@ -30,7 +30,7 @@
#ifdef __FreeBSD__
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_freebsd.c,v 1.6 2005/01/22 20:29:23 sam Exp $");
#else
__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.2 2005/06/22 06:16:02 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ieee80211_netbsd.c,v 1.3 2005/06/26 04:34:43 dyoung Exp $");
#endif
/*
@ -230,23 +230,31 @@ ieee80211_sysctl_detach(struct ieee80211com *ic)
* must not return NULL.
*/
static struct ieee80211_node *
ieee80211_node_walkfirst(struct ieee80211_node_walk *nw,
u_short if_index)
ieee80211_node_walkfirst(struct ieee80211_node_walk *nw, u_short if_index)
{
struct ieee80211com *ic;
(void)memset(nw, 0, sizeof(*nw));
nw->nw_ifindex = if_index;
LIST_FOREACH(ic, &ieee80211com_head, ic_list) {
if (if_index != 0 && ic->ic_ifp->if_index != if_index)
LIST_FOREACH(nw->nw_ic, &ieee80211com_head, ic_list) {
if (if_index != 0 && nw->nw_ic->ic_ifp->if_index != if_index)
continue;
if (!TAILQ_EMPTY(&nw->nw_ic->ic_sta.nt_node))
nw->nw_nt = &nw->nw_ic->ic_sta;
else if (!TAILQ_EMPTY(&nw->nw_ic->ic_scan.nt_node))
nw->nw_nt = &nw->nw_ic->ic_scan;
else if (nw->nw_ic->ic_bss == NULL)
continue;
nw->nw_ic = ic;
nw->nw_ni = TAILQ_FIRST(&nw->nw_ic->ic_sta.nt_node);
break;
}
KASSERT(LOGICALLY_EQUAL(nw->nw_ni == NULL, nw->nw_ic == NULL));
if (nw->nw_ic == NULL)
return NULL;
if (nw->nw_nt == NULL)
nw->nw_ni = nw->nw_ic->ic_bss;
else
nw->nw_ni = TAILQ_FIRST(&nw->nw_nt->nt_node);
return nw->nw_ni;
}
@ -254,14 +262,22 @@ ieee80211_node_walkfirst(struct ieee80211_node_walk *nw,
static struct ieee80211_node *
ieee80211_node_walknext(struct ieee80211_node_walk *nw)
{
KASSERT(LOGICALLY_EQUAL(nw->nw_ni == NULL, nw->nw_ic == NULL));
if (nw->nw_nt != NULL)
nw->nw_ni = TAILQ_NEXT(nw->nw_ni, ni_list);
else
nw->nw_ni = NULL;
if (nw->nw_ic == NULL && nw->nw_ni == NULL)
return NULL;
nw->nw_ni = TAILQ_NEXT(nw->nw_ni, ni_list);
if (nw->nw_ni == NULL) {
while (nw->nw_ni == NULL) {
if (nw->nw_nt == &nw->nw_ic->ic_sta) {
nw->nw_nt = &nw->nw_ic->ic_scan;
nw->nw_ni = TAILQ_FIRST(&nw->nw_nt->nt_node);
continue;
} else if (nw->nw_nt == &nw->nw_ic->ic_scan) {
nw->nw_nt = NULL;
nw->nw_ni = nw->nw_ic->ic_bss;
continue;
}
KASSERT(nw->nw_nt == NULL);
if (nw->nw_ifindex != 0)
return NULL;
@ -269,11 +285,10 @@ ieee80211_node_walknext(struct ieee80211_node_walk *nw)
if (nw->nw_ic == NULL)
return NULL;
nw->nw_ni = TAILQ_FIRST(&nw->nw_ic->ic_sta.nt_node);
nw->nw_nt = &nw->nw_ic->ic_sta;
nw->nw_ni = TAILQ_FIRST(&nw->nw_nt->nt_node);
}
KASSERT(LOGICALLY_EQUAL(nw->nw_ni == NULL, nw->nw_ic == NULL));
return nw->nw_ni;
}
@ -582,6 +597,10 @@ ieee80211_notify_node_join(struct ieee80211com *ic, struct ieee80211_node *ni, i
struct ifnet *ifp = ic->ic_ifp;
struct ieee80211_join_event iev;
IEEE80211_DPRINTF(ic, IEEE80211_MSG_NODE, "%s: %snode %s join\n",
ifp->if_xname, (ni == ic->ic_bss) ? "bss " : "",
ether_sprintf(ni->ni_macaddr));
if (ni == ic->ic_bss) {
memset(&iev, 0, sizeof(iev));
IEEE80211_ADDR_COPY(iev.iev_addr, ni->ni_bssid);
@ -603,6 +622,10 @@ ieee80211_notify_node_leave(struct ieee80211com *ic, struct ieee80211_node *ni)
struct ifnet *ifp = ic->ic_ifp;
struct ieee80211_leave_event iev;
IEEE80211_DPRINTF(ic, IEEE80211_MSG_NODE, "%s: %snode %s leave\n",
ifp->if_xname, (ni == ic->ic_bss) ? "bss " : "",
ether_sprintf(ni->ni_macaddr));
if (ni == ic->ic_bss) {
rt_ieee80211msg(ifp, RTM_IEEE80211_DISASSOC, NULL, 0);
if_link_state_change(ifp, LINK_STATE_DOWN);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_sysctl.h,v 1.3 2005/06/22 06:16:02 dyoung Exp $ */
/* $NetBSD: ieee80211_sysctl.h,v 1.4 2005/06/26 04:34:43 dyoung Exp $ */
/*-
* Copyright (c) 2005 David Young. All rights reserved.
*
@ -105,10 +105,17 @@ struct ieee80211_node_sysctl {
} __attribute__((__packed__));
#ifdef __NetBSD__
enum ieee80211_node_walk_state {
IEEE80211_WALK_BSS = 0,
IEEE80211_WALK_SCAN,
IEEE80211_WALK_STA
};
struct ieee80211_node_walk {
struct ieee80211com *nw_ic;
struct ieee80211_node *nw_ni;
u_short nw_ifindex;
struct ieee80211com *nw_ic;
struct ieee80211_node_table *nw_nt;
struct ieee80211_node *nw_ni;
u_short nw_ifindex;
};
#endif /* __NetBSD__ */