summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/net80211/ieee80211.c19
-rw-r--r--sys/net80211/ieee80211_node.c28
-rw-r--r--sys/net80211/ieee80211_node.h3
3 files changed, 32 insertions, 18 deletions
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
index 0639908ee76..28eaabe9b43 100644
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211.c,v 1.9 2005/09/07 05:40:11 jsg Exp $ */
+/* $OpenBSD: ieee80211.c,v 1.10 2005/09/08 08:36:12 reyk Exp $ */
/* $NetBSD: ieee80211.c,v 1.19 2004/06/06 05:45:29 dyoung Exp $ */
/*-
@@ -648,6 +648,7 @@ int
ieee80211_setmode(struct ieee80211com *ic, enum ieee80211_phymode mode)
{
#define N(a) (sizeof(a) / sizeof(a[0]))
+ struct ifnet *ifp = &ic->ic_if;
static const u_int chanflags[] = {
0, /* IEEE80211_MODE_AUTO */
IEEE80211_CHAN_A, /* IEEE80211_MODE_11A */
@@ -726,6 +727,12 @@ ieee80211_setmode(struct ieee80211com *ic, enum ieee80211_phymode mode)
}
/*
+ * Reset the scan state for the new mode. This avoids scanning
+ * of invalid channels, ie. 5GHz channels in 11b mode.
+ */
+ ieee80211_reset_scan(ifp);
+
+ /*
* Set/reset state flags that influence beacon contents, etc.
*
* XXX what if we have stations already associated???
@@ -756,8 +763,14 @@ ieee80211_next_mode(struct ifnet *ifp)
{
struct ieee80211com *ic = (void *)ifp;
- if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) != IFM_AUTO)
- return (IEEE80211_MODE_AUTO); /* Indicate a wrap around */
+ if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) != IFM_AUTO) {
+ /*
+ * Reset the scan state and indicate a wrap around
+ * if we're running in a fixed, user-specified phy mode.
+ */
+ ieee80211_reset_scan(ifp);
+ return (IEEE80211_MODE_AUTO);
+ }
/*
* Get the next supported mode
diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index 44a1923898a..61be2b07f00 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.c,v 1.6 2005/09/07 05:40:11 jsg Exp $ */
+/* $OpenBSD: ieee80211_node.c,v 1.7 2005/09/08 08:36:12 reyk Exp $ */
/* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */
/*-
@@ -165,7 +165,7 @@ ieee80211_node_detach(struct ifnet *ifp)
* Initialize the active channel set based on the set
* of available channels and the current PHY mode.
*/
-static void
+void
ieee80211_reset_scan(struct ifnet *ifp)
{
struct ieee80211com *ic = (void *)ifp;
@@ -173,7 +173,7 @@ ieee80211_reset_scan(struct ifnet *ifp)
memcpy(ic->ic_chan_scan, ic->ic_chan_active,
sizeof(ic->ic_chan_active));
/* NB: hack, setup so next_scan starts with the first channel */
- if (ic->ic_bss->ni_chan == IEEE80211_CHAN_ANYC)
+ if (ic->ic_bss != NULL && ic->ic_bss->ni_chan == IEEE80211_CHAN_ANYC)
ic->ic_bss->ni_chan = &ic->ic_channels[IEEE80211_CHAN_MAX];
}
@@ -202,21 +202,22 @@ ieee80211_begin_scan(struct ifnet *ifp)
if_printf(ifp, "begin %s scan\n",
(ic->ic_flags & IEEE80211_F_ASCAN) ?
"active" : "passive");
+
/*
- * Clear scan state and flush any previously seen
- * AP's. Note that the latter assumes we don't act
- * as both an AP and a station, otherwise we'll
- * potentially flush state of stations associated
- * with us.
+ * Flush any previously seen AP's. Note that the latter
+ * assumes we don't act as both an AP and a station,
+ * otherwise we'll potentially flush state of stations
+ * associated with us.
*/
- ieee80211_reset_scan(ifp);
ieee80211_free_allnodes(ic);
- /* Reset the current mode. */
- if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) == IFM_AUTO) {
+ /*
+ * Reset the current mode. Setting the current mode will also
+ * reset scan state.
+ */
+ if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) == IFM_AUTO)
ic->ic_curmode = IEEE80211_MODE_AUTO;
- ieee80211_setmode(ic, ic->ic_curmode);
- }
+ ieee80211_setmode(ic, ic->ic_curmode);
ic->ic_scan_count = 0;
@@ -436,7 +437,6 @@ ieee80211_end_scan(struct ifnet *ifp)
/*
* Reset the list of channels to scan and start again.
*/
- ieee80211_reset_scan(ifp);
ieee80211_next_scan(ifp);
return;
}
diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h
index c4e4658214e..b13a3c50d8f 100644
--- a/sys/net80211/ieee80211_node.h
+++ b/sys/net80211/ieee80211_node.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.h,v 1.5 2005/09/07 05:40:11 jsg Exp $ */
+/* $OpenBSD: ieee80211_node.h,v 1.6 2005/09/08 08:36:12 reyk Exp $ */
/* $NetBSD: ieee80211_node.h,v 1.9 2004/04/30 22:57:32 dyoung Exp $ */
/*-
@@ -182,6 +182,7 @@ extern void ieee80211_node_detach(struct ifnet *);
extern void ieee80211_begin_scan(struct ifnet *);
extern void ieee80211_next_scan(struct ifnet *);
extern void ieee80211_end_scan(struct ifnet *);
+extern void ieee80211_reset_scan(struct ifnet *);
extern struct ieee80211_node *ieee80211_alloc_node(struct ieee80211com *,
u_int8_t *);
extern struct ieee80211_node *ieee80211_dup_bss(struct ieee80211com *,