1296 // CProcessorWlan::SetExpandedEapListL |
1291 // CProcessorWlan::SetExpandedEapListL |
1297 // --------------------------------------------------------- |
1292 // --------------------------------------------------------- |
1298 // |
1293 // |
1299 void CProcessorWlan::SetExpandedEapListL( CMDBGenericRecord* generic ) |
1294 void CProcessorWlan::SetExpandedEapListL( CMDBGenericRecord* generic ) |
1300 { |
1295 { |
|
1296 CLOG_WRITE( "CProcessorWlan::SetExpandedEapListL" ) |
1301 // Gets the text format eap list |
1297 // Gets the text format eap list |
1302 HBufC16* eapList = WPAFieldData( EWPAListOfEAPs ); |
1298 HBufC16* eapList = WPAFieldData( EWPAEapMethod ); |
1303 |
1299 |
1304 if ( eapList != NULL && 0 < eapList->Length() ) |
1300 if ( eapList != NULL && 0 < eapList->Length() ) |
1305 { |
1301 { |
1306 |
1302 |
1307 // Creates the expanded eap lists |
1303 // Read EAP method and save it as enabled eap list. |
1308 HBufC8* enabledEapList = ExpandedEapListLC( eapList, ETrue ); |
1304 // Fills expandedForm with 8 bytes: 0xFE, 6 zeros and EAP ID. |
1309 HBufC8* disabledEapList = ExpandedEapListLC( eapList, EFalse ); |
1305 // That's the format expected by EAPOL. |
1310 |
1306 TBuf8<8> expandedForm; |
1311 // Save enabled EAP list |
1307 expandedForm.AppendFill( 0xFE, 1 ); |
|
1308 expandedForm.AppendFill( 0x00, 6 ); |
|
1309 |
|
1310 TUint8 resultByte; |
|
1311 TLex16 lex( eapList->Ptr() ); |
|
1312 User::LeaveIfError( lex.Val( resultByte, EDecimal ) ); |
|
1313 expandedForm.AppendFill( resultByte, 1 ); |
|
1314 CLOG_WRITE_FORMAT( "CProcessorWlan::SetExpandedEapListL: EAP %d", |
|
1315 (int)resultByte) |
|
1316 |
1312 CMDBField<TDesC8>* wlanEnabledEapsField = static_cast<CMDBField<TDesC8>*> |
1317 CMDBField<TDesC8>* wlanEnabledEapsField = static_cast<CMDBField<TDesC8>*> |
1313 ( generic->GetFieldByIdL( KCDTIdWlanEnabledEaps ) ); |
1318 ( generic->GetFieldByIdL( KCDTIdWlanEnabledEaps ) ); |
1314 wlanEnabledEapsField->SetL( enabledEapList->Des() ); |
1319 wlanEnabledEapsField->SetL( expandedForm ); |
1315 |
1320 |
1316 // Save disabled EAP list |
1321 // Save empty disabled EAP list |
|
1322 HBufC8* disabledEapList = HBufC8::NewLC(0); |
1317 CMDBField<TDesC8>* wlanDisabledEapsField = static_cast<CMDBField<TDesC8>*> |
1323 CMDBField<TDesC8>* wlanDisabledEapsField = static_cast<CMDBField<TDesC8>*> |
1318 ( generic->GetFieldByIdL( KCDTIdWlanDisabledEaps ) ); |
1324 ( generic->GetFieldByIdL( KCDTIdWlanDisabledEaps ) ); |
1319 wlanDisabledEapsField->SetL( disabledEapList->Des() ); |
1325 wlanDisabledEapsField->SetL( disabledEapList->Des() ); |
1320 |
|
1321 CleanupStack::PopAndDestroy( disabledEapList ); |
1326 CleanupStack::PopAndDestroy( disabledEapList ); |
1322 CleanupStack::PopAndDestroy( enabledEapList ); |
1327 } |
1323 |
|
1324 } |
|
1325 } |
|
1326 |
|
1327 // --------------------------------------------------------- |
|
1328 // CProcessorWlan::ExpandedEapListLC |
|
1329 // --------------------------------------------------------- |
|
1330 // |
|
1331 HBufC8* CProcessorWlan::ExpandedEapListLC( HBufC16* aEapList, TBool aEnabledNeed ) |
|
1332 { |
|
1333 // The eap list has a well defined form |
|
1334 // so this parser supposes this concrete form like this: |
|
1335 // "+018,-023,+026,-021,-006" |
|
1336 |
|
1337 // Lenght of a 3 digit long signed number |
|
1338 const TInt sliceLength = 4; |
|
1339 |
|
1340 // Max lenght of the resulted list. |
|
1341 // Adding one "," then divide the lenght of a slice+1 |
|
1342 TInt maxLenght = ( ( aEapList->Length()+1 ) / 5 ) * 8; |
|
1343 |
|
1344 HBufC8* expandedEapList = HBufC8::NewLC( maxLenght ); |
|
1345 |
|
1346 TInt pos = 0; |
|
1347 while ( pos + sliceLength <= aEapList->Length() ) |
|
1348 { |
|
1349 // Getting a slice |
|
1350 TPtrC16 slice = aEapList->Mid( pos, sliceLength ); |
|
1351 |
|
1352 // Checks the sign |
|
1353 if( slice[0] == '+' ) |
|
1354 { |
|
1355 if( aEnabledNeed ) |
|
1356 { |
|
1357 AddToList( expandedEapList, slice ); |
|
1358 } |
|
1359 } |
|
1360 else if( slice[0] == '-' ) |
|
1361 { |
|
1362 if( !aEnabledNeed ) |
|
1363 { |
|
1364 AddToList( expandedEapList, slice ); |
|
1365 } |
|
1366 } |
|
1367 else |
|
1368 { |
|
1369 CLOG_WRITE_FORMAT( "! Error : Wrong Eap list format %S", aEapList ); |
|
1370 } |
|
1371 |
|
1372 // Step over one slice and "," e.g. "+023," |
|
1373 pos+=5; |
|
1374 |
|
1375 } |
|
1376 if( pos != aEapList->Length() + 1) |
|
1377 { |
|
1378 CLOG_WRITE_FORMAT( "! Warning : possible wrong Eap list format %S", aEapList ); |
|
1379 } |
|
1380 |
|
1381 return expandedEapList; |
|
1382 } |
|
1383 |
|
1384 // --------------------------------------------------------- |
|
1385 // CProcessorWlan::AddToList |
|
1386 // --------------------------------------------------------- |
|
1387 // |
|
1388 void CProcessorWlan::AddToList( HBufC8* aExpandedEapList, TPtrC16 aSlice ) |
|
1389 { |
|
1390 // Fills the 8 byte form with "0xFE000000000000" |
|
1391 TBuf8<8> expandedForm; |
|
1392 expandedForm.AppendFill( 0xFE, 1 ); |
|
1393 expandedForm.AppendFill( 0x00, 6 ); |
|
1394 |
|
1395 // Leave the "sign" |
|
1396 TPtrC16 number = aSlice.Mid( 1 ); |
|
1397 TUint8 resultByte; |
|
1398 TLex16 lex( number ); |
|
1399 |
|
1400 if( KErrNone == lex.Val( resultByte, EDecimal ) ) |
|
1401 { |
|
1402 expandedForm.AppendFill( resultByte, 1 ); |
|
1403 } |
|
1404 else |
|
1405 { |
|
1406 expandedForm.AppendFill( 0x00, 1 ); |
|
1407 CLOG_WRITE( "! Error : Unlexed Eap number. 0 is addded" ); |
|
1408 } |
|
1409 |
|
1410 aExpandedEapList->Des().Append( expandedForm ); |
|
1411 } |
1328 } |
1412 |
1329 |
1413 |
1330 |
1414 // --------------------------------------------------------- |
1331 // --------------------------------------------------------- |
1415 // CProcessorWlan::WPAIndex |
1332 // CProcessorWlan::WPAIndex |