/* * Wireless utility functions * * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net> */#include<linux/export.h>#include<linux/bitops.h>#include<linux/etherdevice.h>#include<linux/slab.h>#include<net/cfg80211.h>#include<net/ip.h>#include<net/dsfield.h>#include"core.h"structieee80211_rate*ieee80211_get_response_rate(structieee80211_supported_band*sband,u32basic_rates,intbitrate){structieee80211_rate*result=&sband->bitrates[0];inti;for(i=0;i<sband->n_bitrates;i++){if(!(basic_rates&BIT(i)))continue;if(sband->bitrates[i].bitrate>bitrate)continue;result=&sband->bitrates[i];}returnresult;}EXPORT_SYMBOL(ieee80211_get_response_rate);intieee80211_channel_to_frequency(intchan,enumieee80211_bandband){/* see 802.11 17.3.8.3.2 and Annex J * there are overlapping channel numbers in 5GHz and 2GHz bands */if(chan<=0)return0;/* not supported */switch(band){caseIEEE80211_BAND_2GHZ:if(chan==14)return2484;elseif(chan<14)return2407+chan*5;break;caseIEEE80211_BAND_5GHZ:if(chan>=182&&chan<=196)return4000+chan*5;elsereturn5000+chan*5;break;caseIEEE80211_BAND_60GHZ:if(chan<5)return56160+chan*2160;break;default:;}return0;/* not supported */}EXPORT_SYMBOL(ieee80211_channel_to_frequency);intieee80211_frequency_to_channel(intfreq){/* see 802.11 17.3.8.3.2 and Annex J */if(freq==2484)return14;elseif(freq<2484)return(freq-2407)/5;elseif(freq>=4910&&freq<=4980)return(freq-4000)/5;elseif(freq<=45000)/* DMG band lower limit */return(freq-5000)/5;elseif(freq>=58320&&freq<=64800)return(freq-56160)/2160;elsereturn0;}EXPORT_SYMBOL(ieee80211_frequency_to_channel);structieee80211_channel*__ieee80211_get_channel(structwiphy*wiphy,intfreq){enumieee80211_bandband;structieee80211_supported_band*sband;inti;for(band=0;band<IEEE80211_NUM_BANDS;band++){