add ieee80211_find_channel_byieee to lookup a channel by ieee channel #

Reviewed by:	thompsa
MFC after:	1 week
This commit is contained in:
Sam Leffler 2007-11-23 05:57:20 +00:00
parent 727fe7f862
commit a557c018f5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=173861
2 changed files with 28 additions and 0 deletions

View File

@ -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)
{

View File

@ -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 *);