1 #ifndef __INC_DOT11D_H
2 #define __INC_DOT11D_H
3 
4 #include "ieee80211.h"
5 
6 
7 //#define DOT11D_MAX_CHNL_NUM 83
8 
9 typedef struct _CHNL_TXPOWER_TRIPLE {
10 	u8 FirstChnl;
11 	u8  NumChnls;
12 	u8  MaxTxPowerInDbm;
13 }CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE;
14 
15 typedef enum _DOT11D_STATE {
16 	DOT11D_STATE_NONE = 0,
17 	DOT11D_STATE_LEARNED,
18 	DOT11D_STATE_DONE,
19 }DOT11D_STATE;
20 
21 typedef struct _RT_DOT11D_INFO {
22 	//DECLARE_RT_OBJECT(RT_DOT11D_INFO);
23 
24 	bool bEnabled; // dot11MultiDomainCapabilityEnabled
25 
26 	u16 CountryIeLen; // > 0 if CountryIeBuf[] contains valid country information element.
27 	u8  CountryIeBuf[MAX_IE_LEN];
28 	u8  CountryIeSrcAddr[6]; // Source AP of the country IE.
29 	u8  CountryIeWatchdog;
30 
31 	u8  channel_map[MAX_CHANNEL_NUMBER+1];  //!!!Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan)
32 	//u8  ChnlListLen; // #Bytes valid in ChnlList[].
33 	//u8  ChnlList[DOT11D_MAX_CHNL_NUM];
34 	u8  MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1];
35 
36 	DOT11D_STATE State;
37 }RT_DOT11D_INFO, *PRT_DOT11D_INFO;
38 #define eqMacAddr(a,b)		( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
39 #define cpMacAddr(des,src)	      ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5])
40 #define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo))
41 
42 #define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled
43 #define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
44 
45 #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
46 #define UPDATE_CIE_SRC(__pIeeeDev, __pTa) cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
47 
48 #define IS_COUNTRY_IE_CHANGED(__pIeeeDev, __Ie) \
49 	(((__Ie).Length == 0 || (__Ie).Length != GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen) ? \
50 	FALSE : \
51 	(!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length)))
52 
53 #define CIE_WATCHDOG_TH 1
54 #define GET_CIE_WATCHDOG(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog
55 #define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0
56 #define UPDATE_CIE_WATCHDOG(__pIeeeDev) ++GET_CIE_WATCHDOG(__pIeeeDev)
57 
58 #define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE)
59 
60 
61 void
62 Dot11d_Init(
63 	struct ieee80211_device *dev
64 	);
65 
66 void
67 Dot11d_Reset(
68 	struct ieee80211_device *dev
69 	);
70 
71 void
72 Dot11d_UpdateCountryIe(
73 	struct ieee80211_device *dev,
74 	u8 *		pTaddr,
75 	u16	CoutryIeLen,
76 	u8 * pCoutryIe
77 	);
78 
79 u8
80 DOT11D_GetMaxTxPwrInDbm(
81 	struct ieee80211_device *dev,
82 	u8 Channel
83 	);
84 
85 void
86 DOT11D_ScanComplete(
87 	struct ieee80211_device * dev
88 	);
89 
90 int IsLegalChannel(
91 	struct ieee80211_device * dev,
92 	u8 channel
93 );
94 
95 int ToLegalChannel(
96 	struct ieee80211_device * dev,
97 	u8 channel
98 );
99 #endif // #ifndef __INC_DOT11D_H
100