1 //-----------------------------------------------------------------------------
8 //-----------------------------------------------------------------------------
13 Dot11d_Init(struct ieee80211_device *ieee)
15 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
17 pDot11dInfo->bEnabled = 0;
19 pDot11dInfo->State = DOT11D_STATE_NONE;
20 pDot11dInfo->CountryIeLen = 0;
21 memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
22 memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
23 RESET_CIE_WATCHDOG(ieee);
25 printk("Dot11d_Init()\n");
30 // Reset to the state as we are just entering a regulatory domain.
33 Dot11d_Reset(struct ieee80211_device *ieee)
36 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(ieee);
38 // Clear old channel map
39 memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
40 memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
41 // Set new channel map
42 for (i = 1; i <= 11; i++)
43 (pDot11dInfo->channel_map)[i] = 1;
45 for (i = 12; i <= 14; i++)
46 (pDot11dInfo->channel_map)[i] = 2;
48 pDot11dInfo->State = DOT11D_STATE_NONE;
49 pDot11dInfo->CountryIeLen = 0;
50 RESET_CIE_WATCHDOG(ieee);
52 //printk("Dot11d_Reset()\n");
57 // Update country IE from Beacon or Probe Response
58 // and configure PHY for operation in the regulatory domain.
61 // Configure Tx power.
64 // 1. IS_DOT11D_ENABLE() is TRUE.
65 // 2. Input IE is an valid one.
68 Dot11d_UpdateCountryIe(
69 struct ieee80211_device *dev,
75 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
76 u8 i, j, NumTriples, MaxChnlNum;
77 PCHNL_TXPOWER_TRIPLE pTriple;
79 if ((CoutryIeLen - 3)%3 != 0) {
80 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
85 memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER+1);
86 memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER+1);
88 NumTriples = (CoutryIeLen - 3) / 3; // skip 3-byte country string.
89 pTriple = (PCHNL_TXPOWER_TRIPLE)(pCoutryIe + 3);
90 for (i = 0; i < NumTriples; i++) {
91 if (MaxChnlNum >= pTriple->FirstChnl) {
92 // It is not in a monotonically increasing order, so stop processing.
93 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
97 if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl + pTriple->NumChnls)) {
98 // It is not a valid set of channel id, so stop processing.
99 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
104 for (j = 0 ; j < pTriple->NumChnls; j++) {
105 pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1;
106 pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] = pTriple->MaxTxPowerInDbm;
107 MaxChnlNum = pTriple->FirstChnl + j;
110 pTriple = (PCHNL_TXPOWER_TRIPLE)((u8 *)pTriple + 3);
113 //printk("Dot11d_UpdateCountryIe(): Channel List:\n");
114 printk("Channel List:");
115 for (i = 1; i <= MAX_CHANNEL_NUMBER; i++)
116 if (pDot11dInfo->channel_map[i] > 0)
121 UPDATE_CIE_SRC(dev, pTaddr);
123 pDot11dInfo->CountryIeLen = CoutryIeLen;
124 memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe, CoutryIeLen);
125 pDot11dInfo->State = DOT11D_STATE_LEARNED;
129 DOT11D_GetMaxTxPwrInDbm(
130 struct ieee80211_device *dev,
134 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
135 u8 MaxTxPwrInDbm = 255;
137 if (MAX_CHANNEL_NUMBER < Channel) {
138 printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
139 return MaxTxPwrInDbm;
141 if (pDot11dInfo->channel_map[Channel]) {
142 MaxTxPwrInDbm = pDot11dInfo->MaxTxPwrDbmList[Channel];
145 return MaxTxPwrInDbm;
151 struct ieee80211_device *dev
154 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
156 switch (pDot11dInfo->State) {
157 case DOT11D_STATE_LEARNED:
158 pDot11dInfo->State = DOT11D_STATE_DONE;
161 case DOT11D_STATE_DONE:
162 if (GET_CIE_WATCHDOG(dev) == 0) {
163 // Reset country IE if previous one is gone.
167 case DOT11D_STATE_NONE:
173 struct ieee80211_device *dev,
177 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
179 if (MAX_CHANNEL_NUMBER < channel) {
180 printk("IsLegalChannel(): Invalid Channel\n");
183 if (pDot11dInfo->channel_map[channel] > 0)
189 struct ieee80211_device *dev,
193 PRT_DOT11D_INFO pDot11dInfo = GET_DOT11D_INFO(dev);
197 for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) {
198 if (pDot11dInfo->channel_map[i] > 0) {
204 if (MAX_CHANNEL_NUMBER < channel) {
205 printk("IsLegalChannel(): Invalid Channel\n");
209 if (pDot11dInfo->channel_map[channel] > 0)