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
);
37 // Clear old channel map
38 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
39 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
40 // Set new channel map
41 for (i
=1; i
<=11; i
++) {
42 (pDot11dInfo
->channel_map
)[i
] = 1;
44 for (i
=12; i
<=14; i
++) {
45 (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 Resopnse
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 memset(pDot11dInfo
->channel_map
, 0, MAX_CHANNEL_NUMBER
+1);
80 memset(pDot11dInfo
->MaxTxPwrDbmList
, 0xFF, MAX_CHANNEL_NUMBER
+1);
82 NumTriples
= (CoutryIeLen
- 3) / 3; // skip 3-byte country string.
83 pTriple
= (PCHNL_TXPOWER_TRIPLE
)(pCoutryIe
+ 3);
84 for(i
= 0; i
< NumTriples
; i
++)
86 if(MaxChnlNum
>= pTriple
->FirstChnl
)
87 { // It is not in a monotonically increasing order, so stop processing.
88 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........1\n");
91 if(MAX_CHANNEL_NUMBER
< (pTriple
->FirstChnl
+ pTriple
->NumChnls
))
92 { // It is not a valid set of channel id, so stop processing.
93 printk("Dot11d_UpdateCountryIe(): Invalid country IE, skip it........2\n");
97 for(j
= 0 ; j
< pTriple
->NumChnls
; j
++)
99 pDot11dInfo
->channel_map
[pTriple
->FirstChnl
+ j
] = 1;
100 pDot11dInfo
->MaxTxPwrDbmList
[pTriple
->FirstChnl
+ j
] = pTriple
->MaxTxPowerInDbm
;
101 MaxChnlNum
= pTriple
->FirstChnl
+ j
;
104 pTriple
= (PCHNL_TXPOWER_TRIPLE
)((u8
*)pTriple
+ 3);
106 //printk("Dot11d_UpdateCountryIe(): Channel List:\n");
107 printk("Channel List:");
108 for(i
=1; i
<= MAX_CHANNEL_NUMBER
; i
++)
109 if(pDot11dInfo
->channel_map
[i
] > 0)
113 UPDATE_CIE_SRC(dev
, pTaddr
);
115 pDot11dInfo
->CountryIeLen
= CoutryIeLen
;
116 memcpy(pDot11dInfo
->CountryIeBuf
, pCoutryIe
,CoutryIeLen
);
117 pDot11dInfo
->State
= DOT11D_STATE_LEARNED
;
122 DOT11D_GetMaxTxPwrInDbm(
123 struct ieee80211_device
*dev
,
127 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
128 u8 MaxTxPwrInDbm
= 255;
130 if(MAX_CHANNEL_NUMBER
< Channel
)
132 printk("DOT11D_GetMaxTxPwrInDbm(): Invalid Channel\n");
133 return MaxTxPwrInDbm
;
135 if(pDot11dInfo
->channel_map
[Channel
])
137 MaxTxPwrInDbm
= pDot11dInfo
->MaxTxPwrDbmList
[Channel
];
140 return MaxTxPwrInDbm
;
146 struct ieee80211_device
* dev
149 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
151 switch(pDot11dInfo
->State
)
153 case DOT11D_STATE_LEARNED
:
154 pDot11dInfo
->State
= DOT11D_STATE_DONE
;
157 case DOT11D_STATE_DONE
:
158 if( GET_CIE_WATCHDOG(dev
) == 0 )
159 { // Reset country IE if previous one is gone.
163 case DOT11D_STATE_NONE
:
169 struct ieee80211_device
* dev
,
173 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
175 if(MAX_CHANNEL_NUMBER
< channel
)
177 printk("IsLegalChannel(): Invalid Channel\n");
180 if(pDot11dInfo
->channel_map
[channel
] > 0)
186 struct ieee80211_device
* dev
,
190 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(dev
);
194 for (i
=1; i
<= MAX_CHANNEL_NUMBER
; i
++)
196 if(pDot11dInfo
->channel_map
[i
] > 0)
203 if(MAX_CHANNEL_NUMBER
< channel
)
205 printk("IsLegalChannel(): Invalid Channel\n");
209 if(pDot11dInfo
->channel_map
[channel
] > 0)
214 EXPORT_SYMBOL(Dot11d_Init
);
215 EXPORT_SYMBOL(Dot11d_Reset
);
216 EXPORT_SYMBOL(Dot11d_UpdateCountryIe
);
217 EXPORT_SYMBOL(DOT11D_GetMaxTxPwrInDbm
);
218 EXPORT_SYMBOL(DOT11D_ScanComplete
);
219 EXPORT_SYMBOL(IsLegalChannel
);
220 EXPORT_SYMBOL(ToLegalChannel
);