Cleanup of ieee80211_node from madwifi:
* Don't use ifp pointers; use ieee80211com. * Implement the locking macros that are used under FreeBSD and Linux.
This commit is contained in:
parent
e08729e055
commit
f526e7326b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ath.c,v 1.29 2004/07/23 08:34:11 mycroft Exp $ */
|
||||
/* $NetBSD: ath.c,v 1.30 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
|
||||
@ -41,7 +41,7 @@
|
||||
__FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.54 2004/04/05 04:42:42 sam Exp $");
|
||||
#endif
|
||||
#ifdef __NetBSD__
|
||||
__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.29 2004/07/23 08:34:11 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.30 2004/07/23 10:15:13 mycroft Exp $");
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -3068,14 +3068,13 @@ ath_next_scan(void *arg)
|
||||
{
|
||||
struct ath_softc *sc = arg;
|
||||
struct ieee80211com *ic = &sc->sc_ic;
|
||||
struct ifnet *ifp = &ic->ic_if;
|
||||
int s;
|
||||
|
||||
/* don't call ath_start w/o network interrupts blocked */
|
||||
s = splnet();
|
||||
|
||||
if (ic->ic_state == IEEE80211_S_SCAN)
|
||||
ieee80211_next_scan(ifp);
|
||||
ieee80211_next_scan(ic);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: atw.c,v 1.72 2004/07/23 08:36:01 mycroft Exp $ */
|
||||
/* $NetBSD: atw.c,v 1.73 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
|
||||
@ -41,7 +41,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.72 2004/07/23 08:36:01 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.73 2004/07/23 10:15:13 mycroft Exp $");
|
||||
|
||||
#include "bpfilter.h"
|
||||
|
||||
@ -2542,13 +2542,12 @@ atw_next_scan(void *arg)
|
||||
{
|
||||
struct atw_softc *sc = arg;
|
||||
struct ieee80211com *ic = &sc->sc_ic;
|
||||
struct ifnet *ifp = &ic->ic_if;
|
||||
int s;
|
||||
|
||||
/* don't call atw_start w/o network interrupts blocked */
|
||||
s = splnet();
|
||||
if (ic->ic_state == IEEE80211_S_SCAN)
|
||||
ieee80211_next_scan(ifp);
|
||||
ieee80211_next_scan(ic);
|
||||
splx(s);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: awi.c,v 1.63 2004/07/23 08:34:11 mycroft Exp $ */
|
||||
/* $NetBSD: awi.c,v 1.64 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc.
|
||||
@ -86,7 +86,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifdef __NetBSD__
|
||||
__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.63 2004/07/23 08:34:11 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.64 2004/07/23 10:15:13 mycroft Exp $");
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
__FBSDID("$FreeBSD: src/sys/dev/awi/awi.c,v 1.30 2004/01/15 13:30:06 onoe Exp $");
|
||||
@ -524,7 +524,7 @@ awi_intr(void *arg)
|
||||
if (status & AWI_INT_SCAN_CMPLT) {
|
||||
if (sc->sc_ic.ic_state == IEEE80211_S_SCAN &&
|
||||
sc->sc_substate == AWI_ST_NONE)
|
||||
ieee80211_next_scan(&sc->sc_ic.ic_if);
|
||||
ieee80211_next_scan(&sc->sc_ic);
|
||||
}
|
||||
}
|
||||
sc->sc_cansleep = ocansleep;
|
||||
@ -1927,7 +1927,7 @@ awi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
|
||||
case IEEE80211_S_AUTH:
|
||||
case IEEE80211_S_ASSOC:
|
||||
case IEEE80211_S_INIT:
|
||||
ieee80211_begin_scan(ifp);
|
||||
ieee80211_begin_scan(ic);
|
||||
/* FALLTHRU */
|
||||
case IEEE80211_S_SCAN:
|
||||
/* scan next */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211.c,v 1.27 2004/07/23 09:22:15 mycroft Exp $ */
|
||||
/* $NetBSD: ieee80211.c,v 1.28 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
|
||||
@ -35,7 +35,7 @@
|
||||
#ifdef __FreeBSD__
|
||||
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211.c,v 1.11 2004/04/02 20:19:20 sam Exp $");
|
||||
#else
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.27 2004/07/23 09:22:15 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211.c,v 1.28 2004/07/23 10:15:13 mycroft Exp $");
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -195,7 +195,7 @@ ieee80211_ifattach(struct ifnet *ifp)
|
||||
ic->ic_bmisstimeout = 7*ic->ic_lintval; /* default 7 beacons */
|
||||
|
||||
LIST_INSERT_HEAD(&ieee80211com_head, ic, ic_list);
|
||||
ieee80211_node_attach(ifp);
|
||||
ieee80211_node_attach(ic);
|
||||
ieee80211_proto_attach(ifp);
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ ieee80211_ifdetach(struct ifnet *ifp)
|
||||
|
||||
ieee80211_proto_detach(ifp);
|
||||
ieee80211_crypto_detach(ifp);
|
||||
ieee80211_node_detach(ifp);
|
||||
ieee80211_node_detach(ic);
|
||||
LIST_REMOVE(ic, ic_list);
|
||||
#ifdef __FreeBSD__
|
||||
ifmedia_removeall(&ic->ic_media);
|
||||
@ -313,7 +313,7 @@ ieee80211_media_init(struct ifnet *ifp,
|
||||
* Do late attach work that must wait for any subclass
|
||||
* (i.e. driver) work such as overriding methods.
|
||||
*/
|
||||
ieee80211_node_lateattach(ifp);
|
||||
ieee80211_node_lateattach(ic);
|
||||
|
||||
/*
|
||||
* Fill in media characteristics.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211_input.c,v 1.29 2004/07/23 09:22:15 mycroft Exp $ */
|
||||
/* $NetBSD: ieee80211_input.c,v 1.30 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
|
||||
@ -35,7 +35,7 @@
|
||||
#ifdef __FreeBSD__
|
||||
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_input.c,v 1.20 2004/04/02 23:35:24 sam Exp $");
|
||||
#else
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.29 2004/07/23 09:22:15 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_input.c,v 1.30 2004/07/23 10:15:13 mycroft Exp $");
|
||||
#endif
|
||||
|
||||
#include "opt_inet.h"
|
||||
@ -1094,7 +1094,7 @@ ieee80211_recv_mgmt(struct ieee80211com *ic, struct mbuf *m0,
|
||||
* This may result in a bloat of the scanned AP list but
|
||||
* it shouldn't be too much.
|
||||
*/
|
||||
ni = ieee80211_lookup_node(ic, wh->i_addr2,
|
||||
ni = ieee80211_find_node_with_channel(ic, wh->i_addr2,
|
||||
&ic->ic_channels[chan]);
|
||||
#ifdef IEEE80211_DEBUG
|
||||
if (ieee80211_debug &&
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211_node.c,v 1.22 2004/07/23 09:22:15 mycroft Exp $ */
|
||||
/* $NetBSD: ieee80211_node.c,v 1.23 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002-2004 Sam Leffler, Errno Consulting
|
||||
@ -35,7 +35,7 @@
|
||||
#ifdef __FreeBSD__
|
||||
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_node.c,v 1.22 2004/04/05 04:15:55 sam Exp $");
|
||||
#else
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.22 2004/07/23 09:22:15 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_node.c,v 1.23 2004/07/23 10:15:13 mycroft Exp $");
|
||||
#endif
|
||||
|
||||
#include "opt_inet.h"
|
||||
@ -99,14 +99,11 @@ static void _ieee80211_free_node(struct ieee80211com *,
|
||||
MALLOC_DEFINE(M_80211_NODE, "80211node", "802.11 node state");
|
||||
|
||||
void
|
||||
ieee80211_node_attach(struct ifnet *ifp)
|
||||
ieee80211_node_attach(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211com *ic = (void *)ifp;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* XXX need unit */
|
||||
IEEE80211_NODE_LOCK_INIT(ic, ifp->if_xname);
|
||||
#endif
|
||||
IEEE80211_NODE_LOCK_INIT(ic, ic->ic_ifp->if_xname);
|
||||
TAILQ_INIT(&ic->ic_node);
|
||||
ic->ic_node_alloc = ieee80211_node_alloc;
|
||||
ic->ic_node_free = ieee80211_node_free;
|
||||
@ -129,9 +126,8 @@ ieee80211_node_attach(struct ifnet *ifp)
|
||||
}
|
||||
|
||||
void
|
||||
ieee80211_node_lateattach(struct ifnet *ifp)
|
||||
ieee80211_node_lateattach(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211com *ic = (void *)ifp;
|
||||
struct ieee80211_node *ni;
|
||||
|
||||
ni = (*ic->ic_node_alloc)(ic);
|
||||
@ -142,16 +138,15 @@ ieee80211_node_lateattach(struct ifnet *ifp)
|
||||
}
|
||||
|
||||
void
|
||||
ieee80211_node_detach(struct ifnet *ifp)
|
||||
ieee80211_node_detach(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211com *ic = (void *)ifp;
|
||||
|
||||
if (ic->ic_bss != NULL)
|
||||
if (ic->ic_bss != NULL) {
|
||||
(*ic->ic_node_free)(ic, ic->ic_bss);
|
||||
ic->ic_bss = NULL;
|
||||
}
|
||||
ieee80211_free_allnodes(ic);
|
||||
#ifdef __FreeBSD__
|
||||
IEEE80211_NODE_LOCK_DESTROY(ic);
|
||||
#endif
|
||||
if (ic->ic_aid_bitmap != NULL)
|
||||
FREE(ic->ic_aid_bitmap, M_DEVBUF);
|
||||
}
|
||||
@ -165,9 +160,8 @@ ieee80211_node_detach(struct ifnet *ifp)
|
||||
* of available channels and the current PHY mode.
|
||||
*/
|
||||
static void
|
||||
ieee80211_reset_scan(struct ifnet *ifp)
|
||||
ieee80211_reset_scan(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211com *ic = (void *)ifp;
|
||||
|
||||
memcpy(ic->ic_chan_scan, ic->ic_chan_active,
|
||||
sizeof(ic->ic_chan_active));
|
||||
@ -180,9 +174,8 @@ ieee80211_reset_scan(struct ifnet *ifp)
|
||||
* Begin an active scan.
|
||||
*/
|
||||
void
|
||||
ieee80211_begin_scan(struct ifnet *ifp)
|
||||
ieee80211_begin_scan(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211com *ic = (void *)ifp;
|
||||
|
||||
/*
|
||||
* In all but hostap mode scanning starts off in
|
||||
@ -202,20 +195,19 @@ ieee80211_begin_scan(struct ifnet *ifp)
|
||||
* potentially flush state of stations associated
|
||||
* with us.
|
||||
*/
|
||||
ieee80211_reset_scan(ifp);
|
||||
ieee80211_reset_scan(ic);
|
||||
ieee80211_free_allnodes(ic);
|
||||
|
||||
/* Scan the next channel. */
|
||||
ieee80211_next_scan(ifp);
|
||||
ieee80211_next_scan(ic);
|
||||
}
|
||||
|
||||
/*
|
||||
* Switch to the next channel marked for scanning.
|
||||
*/
|
||||
void
|
||||
ieee80211_next_scan(struct ifnet *ifp)
|
||||
ieee80211_next_scan(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211com *ic = (void *)ifp;
|
||||
struct ieee80211_channel *chan;
|
||||
|
||||
chan = ic->ic_bss->ni_chan;
|
||||
@ -232,7 +224,7 @@ ieee80211_next_scan(struct ifnet *ifp)
|
||||
break;
|
||||
}
|
||||
if (chan == ic->ic_bss->ni_chan) {
|
||||
ieee80211_end_scan(ifp);
|
||||
ieee80211_end_scan(ic);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -347,12 +339,14 @@ ieee80211_match_bss(struct ieee80211com *ic, struct ieee80211_node *ni)
|
||||
* Complete a scan of potential channels.
|
||||
*/
|
||||
void
|
||||
ieee80211_end_scan(struct ifnet *ifp)
|
||||
ieee80211_end_scan(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211com *ic = (void *)ifp;
|
||||
struct ieee80211_node *ni, *nextbs, *selbs;
|
||||
int i, fail;
|
||||
|
||||
IEEE80211_DPRINTF(ic, IEEE80211_MSG_SCAN, ("end %s scan\n",
|
||||
(ic->ic_flags & IEEE80211_F_ASCAN) ? "active" : "passive"));
|
||||
|
||||
ic->ic_flags &= ~IEEE80211_F_ASCAN;
|
||||
ni = TAILQ_FIRST(&ic->ic_node);
|
||||
|
||||
@ -397,8 +391,8 @@ ieee80211_end_scan(struct ifnet *ifp)
|
||||
/*
|
||||
* Reset the list of channels to scan and start again.
|
||||
*/
|
||||
ieee80211_reset_scan(ifp);
|
||||
ieee80211_next_scan(ifp);
|
||||
ieee80211_reset_scan(ic);
|
||||
ieee80211_next_scan(ic);
|
||||
return;
|
||||
}
|
||||
selbs = NULL;
|
||||
@ -520,12 +514,14 @@ ieee80211_setup_node(struct ieee80211com *ic,
|
||||
struct ieee80211_node *ni, u_int8_t *macaddr)
|
||||
{
|
||||
int hash;
|
||||
ieee80211_node_critsec_decl(s);
|
||||
|
||||
IEEE80211_DPRINTF(ic, IEEE80211_MSG_NODE,
|
||||
("%s %s\n", __func__, ether_sprintf(macaddr)));
|
||||
IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr);
|
||||
hash = IEEE80211_NODE_HASH(macaddr);
|
||||
ni->ni_refcnt = 1; /* mark referenced */
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
|
||||
IEEE80211_NODE_LOCK_BH(ic);
|
||||
TAILQ_INSERT_TAIL(&ic->ic_node, ni, ni_list);
|
||||
LIST_INSERT_HEAD(&ic->ic_hash[hash], ni, ni_hash);
|
||||
/*
|
||||
@ -539,7 +535,7 @@ ieee80211_setup_node(struct ieee80211com *ic,
|
||||
*/
|
||||
if (ic->ic_opmode != IEEE80211_M_STA)
|
||||
ic->ic_inact_timer = IEEE80211_INACT_WAIT;
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK_BH(ic);
|
||||
}
|
||||
|
||||
struct ieee80211_node *
|
||||
@ -575,9 +571,7 @@ _ieee80211_find_node(struct ieee80211com *ic, u_int8_t *macaddr)
|
||||
struct ieee80211_node *ni;
|
||||
int hash;
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
IEEE80211_NODE_LOCK_ASSERT(ic);
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
hash = IEEE80211_NODE_HASH(macaddr);
|
||||
LIST_FOREACH(ni, &ic->ic_hash[hash], ni_hash) {
|
||||
@ -593,11 +587,10 @@ struct ieee80211_node *
|
||||
ieee80211_find_node(struct ieee80211com *ic, u_int8_t *macaddr)
|
||||
{
|
||||
struct ieee80211_node *ni;
|
||||
ieee80211_node_critsec_decl(s);
|
||||
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
IEEE80211_NODE_LOCK(ic);
|
||||
ni = _ieee80211_find_node(ic, macaddr);
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK(ic);
|
||||
return ni;
|
||||
}
|
||||
|
||||
@ -609,7 +602,6 @@ struct ieee80211_node *
|
||||
ieee80211_find_txnode(struct ieee80211com *ic, u_int8_t *macaddr)
|
||||
{
|
||||
struct ieee80211_node *ni;
|
||||
ieee80211_node_critsec_decl(s);
|
||||
|
||||
/*
|
||||
* The destination address should be in the node table
|
||||
@ -620,9 +612,9 @@ ieee80211_find_txnode(struct ieee80211com *ic, u_int8_t *macaddr)
|
||||
return ic->ic_bss;
|
||||
|
||||
/* XXX can't hold lock across dup_bss 'cuz of recursive locking */
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
IEEE80211_NODE_LOCK(ic);
|
||||
ni = _ieee80211_find_node(ic, macaddr);
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK(ic);
|
||||
if (ni == NULL &&
|
||||
(ic->ic_opmode == IEEE80211_M_IBSS ||
|
||||
ic->ic_opmode == IEEE80211_M_AHDEMO)) {
|
||||
@ -727,14 +719,13 @@ ieee80211_find_rxnode(struct ieee80211com *ic, struct ieee80211_frame *wh)
|
||||
struct ieee80211_node *ni;
|
||||
const static u_int8_t zero[IEEE80211_ADDR_LEN];
|
||||
u_int8_t *bssid;
|
||||
ieee80211_node_critsec_decl(s);
|
||||
|
||||
if (!ieee80211_needs_rxnode(ic, wh, &bssid))
|
||||
return ieee80211_ref_node(ic->ic_bss);
|
||||
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
IEEE80211_NODE_LOCK(ic);
|
||||
ni = _ieee80211_find_node(ic, wh->i_addr2);
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK(ic);
|
||||
|
||||
if (ni != NULL)
|
||||
return ni;
|
||||
@ -764,15 +755,14 @@ ieee80211_find_rxnode(struct ieee80211com *ic, struct ieee80211_frame *wh)
|
||||
* Like find but search based on the channel too.
|
||||
*/
|
||||
struct ieee80211_node *
|
||||
ieee80211_lookup_node(struct ieee80211com *ic,
|
||||
u_int8_t *macaddr, struct ieee80211_channel *chan)
|
||||
ieee80211_find_node_with_channel(struct ieee80211com *ic, u_int8_t *macaddr,
|
||||
struct ieee80211_channel *chan)
|
||||
{
|
||||
struct ieee80211_node *ni;
|
||||
int hash;
|
||||
ieee80211_node_critsec_decl(s);
|
||||
|
||||
hash = IEEE80211_NODE_HASH(macaddr);
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
IEEE80211_NODE_LOCK(ic);
|
||||
LIST_FOREACH(ni, &ic->ic_hash[hash], ni_hash) {
|
||||
if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr) &&
|
||||
ni->ni_chan == chan) {
|
||||
@ -780,7 +770,7 @@ ieee80211_lookup_node(struct ieee80211com *ic,
|
||||
break;
|
||||
}
|
||||
}
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK(ic);
|
||||
return ni;
|
||||
}
|
||||
|
||||
@ -807,14 +797,15 @@ _ieee80211_free_node(struct ieee80211com *ic, struct ieee80211_node *ni)
|
||||
void
|
||||
ieee80211_free_node(struct ieee80211com *ic, struct ieee80211_node *ni)
|
||||
{
|
||||
ieee80211_node_critsec_decl(s);
|
||||
|
||||
IASSERT(ni != ic->ic_bss, ("freeing ic_bss"));
|
||||
|
||||
IEEE80211_DPRINTF(ic, IEEE80211_MSG_NODE,
|
||||
("%s %s refcnt %d\n", __func__,
|
||||
ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni)));
|
||||
if (ieee80211_node_decref(ni) == 0) {
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
IEEE80211_NODE_LOCK_BH(ic);
|
||||
_ieee80211_free_node(ic, ni);
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK_BH(ic);
|
||||
}
|
||||
}
|
||||
|
||||
@ -822,13 +813,12 @@ void
|
||||
ieee80211_free_allnodes(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211_node *ni;
|
||||
ieee80211_node_critsec_decl(s);
|
||||
|
||||
IEEE80211_DPRINTF(ic, IEEE80211_MSG_NODE, ("free all nodes\n"));
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
IEEE80211_NODE_LOCK_BH(ic);
|
||||
while ((ni = TAILQ_FIRST(&ic->ic_node)) != NULL)
|
||||
_ieee80211_free_node(ic, ni);
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK_BH(ic);
|
||||
|
||||
if (ic->ic_bss != NULL)
|
||||
node_cleanup(ic, ic->ic_bss); /* for station mode */
|
||||
@ -847,11 +837,10 @@ void
|
||||
ieee80211_timeout_nodes(struct ieee80211com *ic)
|
||||
{
|
||||
struct ieee80211_node *ni;
|
||||
ieee80211_node_critsec_decl(s);
|
||||
u_int gen = ic->ic_scangen++; /* NB: ok 'cuz single-threaded*/
|
||||
|
||||
restart:
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
IEEE80211_NODE_LOCK(ic);
|
||||
TAILQ_FOREACH(ni, &ic->ic_node, ni_list) {
|
||||
if (ni->ni_scangen == gen) /* previously handled */
|
||||
continue;
|
||||
@ -869,7 +858,7 @@ restart:
|
||||
* a lock, as this will result in a LOR between the
|
||||
* node lock and the driver lock.
|
||||
*/
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK(ic);
|
||||
IEEE80211_SEND_MGMT(ic, ni,
|
||||
IEEE80211_FC0_SUBTYPE_DEAUTH,
|
||||
IEEE80211_REASON_AUTH_EXPIRE);
|
||||
@ -880,19 +869,18 @@ restart:
|
||||
}
|
||||
if (!TAILQ_EMPTY(&ic->ic_node))
|
||||
ic->ic_inact_timer = IEEE80211_INACT_WAIT;
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK(ic);
|
||||
}
|
||||
|
||||
void
|
||||
ieee80211_iterate_nodes(struct ieee80211com *ic, ieee80211_iter_func *f, void *arg)
|
||||
{
|
||||
struct ieee80211_node *ni;
|
||||
ieee80211_node_critsec_decl(s);
|
||||
|
||||
ieee80211_node_critsec_begin(ic, s);
|
||||
IEEE80211_NODE_LOCK(ic);
|
||||
TAILQ_FOREACH(ni, &ic->ic_node, ni_list)
|
||||
(*f)(arg, ni);
|
||||
ieee80211_node_critsec_end(ic, s);
|
||||
IEEE80211_NODE_UNLOCK(ic);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211_node.h,v 1.11 2004/07/23 09:22:15 mycroft Exp $ */
|
||||
/* $NetBSD: ieee80211_node.h,v 1.12 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
|
||||
@ -159,29 +159,21 @@ ieee80211_unref_node(struct ieee80211_node **ni)
|
||||
*ni = NULL; /* guard against use */
|
||||
}
|
||||
|
||||
#define IEEE80211_NODE_LOCK_INIT(_ic, _name) \
|
||||
mtx_init(&(_ic)->ic_nodelock, _name, "802.11 node table", MTX_DEF)
|
||||
#define IEEE80211_NODE_LOCK_DESTROY(_ic) mtx_destroy(&(_ic)->ic_nodelock)
|
||||
#define IEEE80211_NODE_LOCK(_ic) mtx_lock(&(_ic)->ic_nodelock)
|
||||
#define IEEE80211_NODE_UNLOCK(_ic) mtx_unlock(&(_ic)->ic_nodelock)
|
||||
#define IEEE80211_NODE_LOCK_ASSERT(_ic) \
|
||||
mtx_assert(&(_ic)->ic_nodelock, MA_OWNED)
|
||||
|
||||
struct ieee80211com;
|
||||
|
||||
#ifdef MALLOC_DECLARE
|
||||
MALLOC_DECLARE(M_80211_NODE);
|
||||
#endif
|
||||
|
||||
extern void ieee80211_node_attach(struct ifnet *);
|
||||
extern void ieee80211_node_lateattach(struct ifnet *);
|
||||
extern void ieee80211_node_detach(struct ifnet *);
|
||||
extern void ieee80211_node_attach(struct ieee80211com *);
|
||||
extern void ieee80211_node_lateattach(struct ieee80211com *);
|
||||
extern void ieee80211_node_detach(struct ieee80211com *);
|
||||
|
||||
extern void ieee80211_begin_scan(struct ifnet *);
|
||||
extern void ieee80211_next_scan(struct ifnet *);
|
||||
extern void ieee80211_begin_scan(struct ieee80211com *);
|
||||
extern void ieee80211_next_scan(struct ieee80211com *);
|
||||
extern void ieee80211_create_ibss(struct ieee80211com *,
|
||||
struct ieee80211_channel *);
|
||||
extern void ieee80211_end_scan(struct ifnet *);
|
||||
extern void ieee80211_end_scan(struct ieee80211com *);
|
||||
extern struct ieee80211_node *ieee80211_alloc_node(struct ieee80211com *,
|
||||
u_int8_t *);
|
||||
extern struct ieee80211_node *ieee80211_dup_bss(struct ieee80211com *,
|
||||
@ -192,8 +184,9 @@ extern struct ieee80211_node *ieee80211_find_rxnode(struct ieee80211com *,
|
||||
struct ieee80211_frame *);
|
||||
extern struct ieee80211_node *ieee80211_find_txnode(struct ieee80211com *,
|
||||
u_int8_t *);
|
||||
extern struct ieee80211_node * ieee80211_lookup_node(struct ieee80211com *,
|
||||
u_int8_t *macaddr, struct ieee80211_channel *);
|
||||
extern struct ieee80211_node *ieee80211_find_node_with_channel(
|
||||
struct ieee80211com *, u_int8_t *macaddr,
|
||||
struct ieee80211_channel *);
|
||||
extern void ieee80211_free_node(struct ieee80211com *,
|
||||
struct ieee80211_node *);
|
||||
extern void ieee80211_free_allnodes(struct ieee80211com *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211_proto.c,v 1.14 2004/07/23 08:38:08 mycroft Exp $ */
|
||||
/* $NetBSD: ieee80211_proto.c,v 1.15 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
|
||||
@ -35,7 +35,7 @@
|
||||
#ifdef __FreeBSD__
|
||||
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_proto.c,v 1.8 2004/04/02 20:22:25 sam Exp $");
|
||||
#else
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_proto.c,v 1.14 2004/07/23 08:38:08 mycroft Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ieee80211_proto.c,v 1.15 2004/07/23 10:15:13 mycroft Exp $");
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -432,7 +432,7 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int mgt
|
||||
*/
|
||||
ieee80211_create_ibss(ic, ic->ic_des_chan);
|
||||
} else {
|
||||
ieee80211_begin_scan(ifp);
|
||||
ieee80211_begin_scan(ic);
|
||||
}
|
||||
break;
|
||||
case IEEE80211_S_SCAN:
|
||||
@ -458,7 +458,7 @@ ieee80211_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int mgt
|
||||
ni->ni_fails++;
|
||||
ieee80211_unref_node(&ni);
|
||||
}
|
||||
ieee80211_begin_scan(ifp);
|
||||
ieee80211_begin_scan(ic);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ieee80211_var.h,v 1.14 2004/07/23 09:22:15 mycroft Exp $ */
|
||||
/* $NetBSD: ieee80211_var.h,v 1.15 2004/07/23 10:15:13 mycroft Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2001 Atsushi Onoe
|
||||
* Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
|
||||
@ -39,6 +39,19 @@
|
||||
* Definitions for IEEE 802.11 drivers.
|
||||
*/
|
||||
|
||||
/* NB: portability glue must go first */
|
||||
#ifdef __NetBSD__
|
||||
#include <net80211/ieee80211_netbsd.h>
|
||||
#elif __FreeBSD__
|
||||
#include <net80211/ieee80211_freebsd.h>
|
||||
#elif __linux__
|
||||
#include <net80211/ieee80211_linux.h>
|
||||
#else
|
||||
#error "No support for your operating system!"
|
||||
#endif
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <net80211/ieee80211.h>
|
||||
#include <net80211/ieee80211_crypto.h>
|
||||
#include <net80211/ieee80211_ioctl.h> /* for ieee80211_stats */
|
||||
@ -146,9 +159,7 @@ struct ieee80211com {
|
||||
int ic_fixed_rate; /* index to ic_sup_rates[] */
|
||||
u_int16_t ic_rtsthreshold;
|
||||
u_int16_t ic_fragthreshold;
|
||||
#ifdef __FreeBSD__
|
||||
struct mtx ic_nodelock; /* on node table */
|
||||
#endif
|
||||
ieee80211_node_lock_t ic_nodelock; /* on node table */
|
||||
u_int ic_scangen; /* gen# for timeout scan */
|
||||
struct ieee80211_node *(*ic_node_alloc)(struct ieee80211com *);
|
||||
void (*ic_node_free)(struct ieee80211com *,
|
||||
|
Loading…
Reference in New Issue
Block a user