2 //-----------------------------------------------------------------------------
\r
7 // Implement 802.11d.
\r
9 //-----------------------------------------------------------------------------
\r
14 Dot11d_Init(struct ieee80211_device *ieee)
\r
16 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
\r
18 pDot11dInfo->bEnabled = 0;
\r
20 pDot11dInfo->State = DOT11D_STATE_NONE;
\r
21 pDot11dInfo->CountryIeLen = 0;
\r
22 memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
\r
23 memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
\r
24 RESET_CIE_WATCHDOG(ieee);
\r
26 printk("Dot11d_Init()\n");
\r
31 // Reset to the state as we are just entering a regulatory domain.
\r
34 Dot11d_Reset(struct ieee80211_device *ieee)
\r
37 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
\r
39 // Clear old channel map
\r
40 memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
\r
41 memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
\r
42 // Set new channel map
\r
43 for (i=1; i<=11; i++) {
\r
44 (pDot11dInfo->channel_map)[i] = 1;
\r
46 for (i=12; i<=14; i++) {
\r
47 (pDot11dInfo->channel_map)[i] = 2;
\r
50 pDot11dInfo->State = DOT11D_STATE_NONE;
\r
51 pDot11dInfo->CountryIeLen = 0;
\r
52 RESET_CIE_WATCHDOG(ieee);
\r
54 //printk("Dot11d_Reset()\n");
\r
59 // Update country IE from Beacon or Probe Resopnse
\r
60 // and configure PHY for operation in the regulatory domain.
\r
63 // Configure Tx power.
\r
66 // 1. IS_DOT11D_ENABLE() is TRUE.
\r
67 // 2. Input IE is an valid one.
\r
70 Dot11d_UpdateCountryIe(
\r
71 struct ieee80211_device *dev,
\r
77 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
\r
78 u8 i, j, NumTriples, MaxChnlNum;
\r
79 PCHNL_TXPOWER_TRIPLE pTriple;
\r
81 if((CoutryIeLen - 3)%3 != 0)
\r
83 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
\r
88 memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
\r
89 memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
\r
91 NumTriples = (CoutryIeLen - 3) / 3; // skip 3-byte country string.
\r
92 pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3);
\r
93 for(i = 0; i < NumTriples; i++)
\r
95 if(MaxChnlNum >= pTriple->FirstChnl)
\r
96 { // It is not in a monotonically increasing order, so stop processing.
\r
97 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
\r
101 if(MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls))
\r
102 { // It is not a valid set of channel id, so stop processing.
\r
103 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
\r
108 for(j = 0 ; j < pTriple->NumChnls; j++)
\r
110 pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1;
\r
111 pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm;
\r
112 MaxChnlNum = pTriple->FirstChnl + j;
\r
115 pTriple = (PCHNL_TXPOWER_TRIPLE)((u8*)pTriple + 3);
\r
118 //printk("Dot11d_UpdateCountryIe(): Channel List:\n");
\r
119 printk("Channel List:");
\r
120 for(i=1; i<= MAX_CHANNEL_NUMBER; i++)
\r
121 if(pDot11dInfo->channel_map[i] > 0)
\r
126 UPDATE_CIE_SRC(dev, pTaddr);
\r
128 pDot11dInfo->CountryIeLen = CoutryIeLen;
\r
129 memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe,CoutryIeLen);
\r
130 pDot11dInfo->State = DOT11D_STATE_LEARNED;
\r
133 void dump_chnl_map(u8 * channel_map)
\r
136 printk("Channel List:");
\r
137 for(i=1; i<= MAX_CHANNEL_NUMBER; i++)
\r
138 if(channel_map[i] > 0)
\r
139 printk(" %d(%d)", i, channel_map[i]);
\r
144 DOT11D_GetMaxTxPwrInDbm(
\r
145 struct ieee80211_device *dev,
\r
149 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
\r
150 u8 MaxTxPwrInDbm = 255;
\r
152 if(MAX_CHANNEL_NUMBER < Channel)
\r
154 printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
\r
155 return MaxTxPwrInDbm;
\r
157 if(pDot11dInfo->channel_map[Channel])
\r
159 MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel];
\r
162 return MaxTxPwrInDbm;
\r
167 DOT11D_ScanComplete(
\r
168 struct ieee80211_device * dev
\r
171 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
\r
173 switch(pDot11dInfo->State)
\r
175 case DOT11D_STATE_LEARNED:
\r
176 pDot11dInfo->State = DOT11D_STATE_DONE;
\r
179 case DOT11D_STATE_DONE:
\r
180 if( GET_CIE_WATCHDOG(dev) == 0 )
\r
181 { // Reset country IE if previous one is gone.
\r
182 Dot11d_Reset(dev);
\r
185 case DOT11D_STATE_NONE:
\r
190 int IsLegalChannel(
\r
191 struct ieee80211_device * dev,
\r
195 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
\r
197 if(MAX_CHANNEL_NUMBER < channel)
\r
199 printk("IsLegalChannel(): Invalid Channel\n");
\r
202 if(pDot11dInfo->channel_map[channel] > 0)
\r
207 int ToLegalChannel(
\r
208 struct ieee80211_device * dev,
\r
212 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
\r
213 u8 default_chn = 0;
\r
216 for (i=1; i<= MAX_CHANNEL_NUMBER; i++)
\r
218 if(pDot11dInfo->channel_map[i] > 0)
\r
225 if(MAX_CHANNEL_NUMBER < channel)
\r
227 printk("IsLegalChannel(): Invalid Channel\n");
\r
228 return default_chn;
\r
231 if(pDot11dInfo->channel_map[channel] > 0)
\r
234 return default_chn;
\r
238 EXPORT_SYMBOL(Dot11d_Init);
\r
239 EXPORT_SYMBOL(Dot11d_Reset);
\r
240 EXPORT_SYMBOL(Dot11d_UpdateCountryIe);
\r
241 EXPORT_SYMBOL(DOT11D_GetMaxTxPwrInDbm);
\r
242 EXPORT_SYMBOL(DOT11D_ScanComplete);
\r
243 EXPORT_SYMBOL(IsLegalChannel);
\r
244 EXPORT_SYMBOL(ToLegalChannel);
\r