2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Purpose: Handles the Basic Service Set & Node Database functions
28 * Author: Yiching Chen
37 static int msglevel
=MSG_LEVEL_INFO
;
38 //static int msglevel =MSG_LEVEL_DEBUG;
40 static const u8 abyOUIGK
[4] = { 0x00, 0x0F, 0xAC, 0x00 };
41 static const u8 abyOUIWEP40
[4] = { 0x00, 0x0F, 0xAC, 0x01 };
42 static const u8 abyOUIWEP104
[4] = { 0x00, 0x0F, 0xAC, 0x05 };
43 static const u8 abyOUITKIP
[4] = { 0x00, 0x0F, 0xAC, 0x02 };
44 static const u8 abyOUICCMP
[4] = { 0x00, 0x0F, 0xAC, 0x04 };
46 static const u8 abyOUI8021X
[4] = { 0x00, 0x0F, 0xAC, 0x01 };
47 static const u8 abyOUIPSK
[4] = { 0x00, 0x0F, 0xAC, 0x02 };
52 * Clear RSN information in BSSList.
56 * pBSSNode - BSS list.
70 pBSSNode
->bWPA2Valid
= false;
72 pBSSNode
->byCSSGK
= WLAN_11i_CSS_CCMP
;
73 for (ii
=0; ii
< 4; ii
++)
74 pBSSNode
->abyCSSPK
[ii
] = WLAN_11i_CSS_CCMP
;
75 pBSSNode
->wCSSPKCount
= 1;
76 for (ii
=0; ii
< 4; ii
++)
77 pBSSNode
->abyAKMSSAuthType
[ii
] = WLAN_11i_AKMSS_802_1X
;
78 pBSSNode
->wAKMSSAuthCount
= 1;
79 pBSSNode
->sRSNCapObj
.bRSNCapExist
= false;
80 pBSSNode
->sRSNCapObj
.wRSNCap
= 0;
90 * pBSSNode - BSS list.
91 * pRSN - Pointer to the RSN IE.
109 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"WPA2_ParseRSN: [%d]\n", pRSN
->len
);
111 WPA2_ClearRSN(pBSSNode
);
113 if (pRSN
->len
== 2) { // ver(2)
114 if ((pRSN
->byElementID
== WLAN_EID_RSN
) && (pRSN
->wVersion
== 1)) {
115 pBSSNode
->bWPA2Valid
= true;
120 if (pRSN
->len
< 6) { // ver(2) + GK(4)
121 // invalid CSS, P802.11i/D10.0, p31
125 // information element header makes sense
126 if ((pRSN
->byElementID
== WLAN_EID_RSN
) &&
127 (pRSN
->wVersion
== 1)) {
129 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Legal 802.11i RSN\n");
131 pbyOUI
= &(pRSN
->abyRSN
[0]);
132 if ( !memcmp(pbyOUI
, abyOUIWEP40
, 4))
133 pBSSNode
->byCSSGK
= WLAN_11i_CSS_WEP40
;
134 else if ( !memcmp(pbyOUI
, abyOUITKIP
, 4))
135 pBSSNode
->byCSSGK
= WLAN_11i_CSS_TKIP
;
136 else if ( !memcmp(pbyOUI
, abyOUICCMP
, 4))
137 pBSSNode
->byCSSGK
= WLAN_11i_CSS_CCMP
;
138 else if ( !memcmp(pbyOUI
, abyOUIWEP104
, 4))
139 pBSSNode
->byCSSGK
= WLAN_11i_CSS_WEP104
;
140 else if ( !memcmp(pbyOUI
, abyOUIGK
, 4)) {
141 // invalid CSS, P802.11i/D10.0, p32
144 // any vendor checks here
145 pBSSNode
->byCSSGK
= WLAN_11i_CSS_UNKNOWN
;
147 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"802.11i CSS: %X\n", pBSSNode
->byCSSGK
);
149 if (pRSN
->len
== 6) {
150 pBSSNode
->bWPA2Valid
= true;
154 if (pRSN
->len
>= 8) { // ver(2) + GK(4) + PK count(2)
155 pBSSNode
->wCSSPKCount
= *((u16
*) &(pRSN
->abyRSN
[4]));
157 pbyOUI
= &(pRSN
->abyRSN
[6]);
159 for (i
= 0; (i
< pBSSNode
->wCSSPKCount
) && (j
< sizeof(pBSSNode
->abyCSSPK
)/sizeof(u8
)); i
++) {
161 if (pRSN
->len
>= 8+i
*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*i)
162 if ( !memcmp(pbyOUI
, abyOUIGK
, 4)) {
163 pBSSNode
->abyCSSPK
[j
++] = WLAN_11i_CSS_USE_GROUP
;
165 } else if ( !memcmp(pbyOUI
, abyOUIWEP40
, 4)) {
166 // Invalid CSS, continue parsing
167 } else if ( !memcmp(pbyOUI
, abyOUITKIP
, 4)) {
168 if (pBSSNode
->byCSSGK
!= WLAN_11i_CSS_CCMP
)
169 pBSSNode
->abyCSSPK
[j
++] = WLAN_11i_CSS_TKIP
;
171 ; // Invalid CSS, continue parsing
172 } else if ( !memcmp(pbyOUI
, abyOUICCMP
, 4)) {
173 pBSSNode
->abyCSSPK
[j
++] = WLAN_11i_CSS_CCMP
;
174 } else if ( !memcmp(pbyOUI
, abyOUIWEP104
, 4)) {
175 // Invalid CSS, continue parsing
177 // any vendor checks here
178 pBSSNode
->abyCSSPK
[j
++] = WLAN_11i_CSS_UNKNOWN
;
181 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"abyCSSPK[%d]: %X\n", j
-1, pBSSNode
->abyCSSPK
[j
-1]);
186 if (bUseGK
== true) {
188 // invalid CSS, This should be only PK CSS.
191 if (pBSSNode
->byCSSGK
== WLAN_11i_CSS_CCMP
) {
192 // invalid CSS, If CCMP is enable , PK can't be CSSGK.
196 if ((pBSSNode
->wCSSPKCount
!= 0) && (j
== 0)) {
197 // invalid CSS, No valid PK.
200 pBSSNode
->wCSSPKCount
= (u16
)j
;
201 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wCSSPKCount: %d\n", pBSSNode
->wCSSPKCount
);
204 m
= *((u16
*) &(pRSN
->abyRSN
[4]));
206 if (pRSN
->len
>= 10+m
*4) { // ver(2) + GK(4) + PK count(2) + PKS(4*m) + AKMSS count(2)
207 pBSSNode
->wAKMSSAuthCount
= *((u16
*) &(pRSN
->abyRSN
[6+4*m
]));
209 pbyOUI
= &(pRSN
->abyRSN
[8+4*m
]);
210 for (i
= 0; (i
< pBSSNode
->wAKMSSAuthCount
) && (j
< sizeof(pBSSNode
->abyAKMSSAuthType
)/sizeof(u8
)); i
++) {
211 if (pRSN
->len
>= 10+(m
+i
)*4+4) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSS(2)+AKS(4*i)
212 if ( !memcmp(pbyOUI
, abyOUI8021X
, 4))
213 pBSSNode
->abyAKMSSAuthType
[j
++] = WLAN_11i_AKMSS_802_1X
;
214 else if ( !memcmp(pbyOUI
, abyOUIPSK
, 4))
215 pBSSNode
->abyAKMSSAuthType
[j
++] = WLAN_11i_AKMSS_PSK
;
217 // any vendor checks here
218 pBSSNode
->abyAKMSSAuthType
[j
++] = WLAN_11i_AKMSS_UNKNOWN
;
219 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"abyAKMSSAuthType[%d]: %X\n", j
-1, pBSSNode
->abyAKMSSAuthType
[j
-1]);
223 pBSSNode
->wAKMSSAuthCount
= (u16
)j
;
224 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"wAKMSSAuthCount: %d\n", pBSSNode
->wAKMSSAuthCount
);
226 n
= *((u16
*) &(pRSN
->abyRSN
[6+4*m
]));
227 if (pRSN
->len
>= 12+4*m
+4*n
) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSSCnt(2)+AKMSS(4*n)+Cap(2)
228 pBSSNode
->sRSNCapObj
.bRSNCapExist
= true;
229 pBSSNode
->sRSNCapObj
.wRSNCap
= *((u16
*) &(pRSN
->abyRSN
[8+4*m
+4*n
]));
232 //ignore PMKID lists bcs only (Re)Assocrequest has this field
233 pBSSNode
->bWPA2Valid
= true;