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;
49 pDot11dInfo
->State
= DOT11D_STATE_NONE
;
50 pDot11dInfo
->CountryIeLen
= 0;
51 RESET_CIE_WATCHDOG(ieee
);
53 //printk("Dot11d_Reset()\n");
58 // Update country IE from Beacon or Probe Resopnse
59 // and configure PHY for operation in the regulatory domain.
62 // Configure Tx power.
65 // 1. IS_DOT11D_ENABLE() is TRUE.
66 // 2. Input IE is an valid one.
69 Dot11d_UpdateCountryIe(
70 struct ieee80211_device
*dev
,
76 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
77 u8 i
, j
, NumTriples
, MaxChnlNum
;
78 PCHNL_TXPOWER_TRIPLE pTriple
;
80 if((CoutryIeLen
- 3)%3 != 0)
82 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
87 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
88 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
90 NumTriples
= (CoutryIeLen
- 3) / 3; // skip 3-byte country string.
91 pTriple
= (PCHNL_TXPOWER_TRIPLE
)(pCoutryIe
+ 3);
92 for(i
= 0; i
< NumTriples
; i
++)
94 if(MaxChnlNum
>= pTriple
->FirstChnl
)
95 { // It is not in a monotonically increasing order, so stop processing.
96 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
100 if(MAX_CHANNEL_NUMBER
< (pTriple
->FirstChnl
+ pTriple
->NumChnls
))
101 { // It is not a valid set of channel id, so stop processing.
102 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
107 for(j
= 0 ; j
< pTriple
->NumChnls
; j
++)
109 pDot11dInfo
->channel_map
[pTriple
->FirstChnl
+ j
] = 1;
110 pDot11dInfo
->MaxTxPwrDbmList
[pTriple
->FirstChnl
+ j
] = pTriple
->MaxTxPowerInDbm
;
111 MaxChnlNum
= pTriple
->FirstChnl
+ j
;
114 pTriple
= (PCHNL_TXPOWER_TRIPLE
)((u8
*)pTriple
+ 3);
117 //printk("Dot11d_UpdateCountryIe(): Channel List:\n");
118 printk("Channel List:");
119 for(i
=1; i
<= MAX_CHANNEL_NUMBER
; i
++)
120 if(pDot11dInfo
->channel_map
[i
] > 0)
125 UPDATE_CIE_SRC(dev
, pTaddr
);
127 pDot11dInfo
->CountryIeLen
= CoutryIeLen
;
128 memcpy(pDot11dInfo
->CountryIeBuf
, pCoutryIe
,CoutryIeLen
);
129 pDot11dInfo
->State
= DOT11D_STATE_LEARNED
;
133 DOT11D_GetMaxTxPwrInDbm(
134 struct ieee80211_device
*dev
,
138 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
139 u8 MaxTxPwrInDbm
= 255;
141 if(MAX_CHANNEL_NUMBER
< Channel
)
143 printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
144 return MaxTxPwrInDbm
;
146 if(pDot11dInfo
->channel_map
[Channel
])
148 MaxTxPwrInDbm
= pDot11dInfo
->MaxTxPwrDbmList
[Channel
];
151 return MaxTxPwrInDbm
;
157 struct ieee80211_device
* dev
160 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
162 switch(pDot11dInfo
->State
)
164 case DOT11D_STATE_LEARNED
:
165 pDot11dInfo
->State
= DOT11D_STATE_DONE
;
168 case DOT11D_STATE_DONE
:
169 if( GET_CIE_WATCHDOG(dev
) == 0 )
170 { // Reset country IE if previous one is gone.
174 case DOT11D_STATE_NONE
:
180 struct ieee80211_device
* dev
,
184 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
186 if(MAX_CHANNEL_NUMBER
< channel
)
188 printk("IsLegalChannel(): Invalid Channel\n");
191 if(pDot11dInfo
->channel_map
[channel
] > 0)
197 struct ieee80211_device
* dev
,
201 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
205 for (i
=1; i
<= MAX_CHANNEL_NUMBER
; i
++)
207 if(pDot11dInfo
->channel_map
[i
] > 0)
214 if(MAX_CHANNEL_NUMBER
< channel
)
216 printk("IsLegalChannel(): Invalid Channel\n");
220 if(pDot11dInfo
->channel_map
[channel
] > 0)