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