From a557c018f559886566a1d4f541d70edbcd50f37b Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Fri, 23 Nov 2007 05:57:20 +0000 Subject: [PATCH] add ieee80211_find_channel_byieee to lookup a channel by ieee channel # Reviewed by: thompsa MFC after: 1 week --- sys/net80211/ieee80211.c | 26 ++++++++++++++++++++++++++ sys/net80211/ieee80211_var.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 33b83d591f22..38acb546fb6e 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -440,6 +440,32 @@ ieee80211_find_channel(struct ieee80211com *ic, int freq, int flags) return NULL; } +/* + * Locate a channel given a channel number+flags. We cache + * the previous lookup to optimize switching between two + * channels--as happens with dynamic turbo. + */ +struct ieee80211_channel * +ieee80211_find_channel_byieee(struct ieee80211com *ic, int ieee, int flags) +{ + struct ieee80211_channel *c; + int i; + + flags &= IEEE80211_CHAN_ALLTURBO; + c = ic->ic_prevchan; + if (c != NULL && c->ic_ieee == ieee && + (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) + return c; + /* brute force search */ + for (i = 0; i < ic->ic_nchans; i++) { + c = &ic->ic_channels[i]; + if (c->ic_ieee == ieee && + (c->ic_flags & IEEE80211_CHAN_ALLTURBO) == flags) + return c; + } + return NULL; +} + static void addmedia(struct ieee80211com *ic, int mode, int mword) { diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index cd8403074b3d..3171ceff4794 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -422,6 +422,8 @@ int ieee80211_chan2ieee(struct ieee80211com *, u_int ieee80211_ieee2mhz(u_int, u_int); struct ieee80211_channel *ieee80211_find_channel(struct ieee80211com *, int freq, int flags); +struct ieee80211_channel *ieee80211_find_channel_byieee(struct ieee80211com *, + int ieee, int flags); int ieee80211_setmode(struct ieee80211com *, enum ieee80211_phymode); enum ieee80211_phymode ieee80211_chan2mode(const struct ieee80211_channel *);