--- a/telephonyprotocols/pdplayer/src/PDPConfig.cpp Fri Apr 16 16:12:37 2010 +0300
+++ b/telephonyprotocols/pdplayer/src/PDPConfig.cpp Mon May 03 13:37:20 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
@@ -20,8 +20,6 @@
@internalComponent
*/
-#include <hash.h>
-#include <e32math.h>
#include <comms-infras/ss_log.h>
#include <in_sock.h>
#include <comms-infras/metadata.h>
@@ -38,9 +36,6 @@
_LIT8(KPDPMCprSubTag, "pdpmcpr");
#endif
-const TUint8 KGenericNifChallengeSize = 8;
-const TUint KGenericNifIdLength = 1;
-
//
// Attribute table for provisioning structure passed to CFProtocol
//
@@ -210,7 +205,7 @@
TInt getErr;
__CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL()"), this));
-
+
getErr = aIapView->GetText(KCDTIdWCDMAIfAuthName | KCDTIdOutgoingGprsRecord, buf);
if ( getErr == KErrNone )
{
@@ -218,112 +213,31 @@
aProtocolConfigOption.iAuthInfo.iUsername.Copy(*buf);
delete buf;
buf = NULL;
-
+
__CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL() KCDTIdWCDMAIfAuthName [%S] "), this, &aProtocolConfigOption.iAuthInfo.iUsername));
-
- aProtocolConfigOption.iId = 1;
-
- TBool isDisableAuth = EFalse;
- getErr = aIapView->GetBool(KCDTIdWCDMADisablePlainTextAuth | KCDTIdOutgoingGprsRecord,isDisableAuth);
- __CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL() KCDTIdWCDMADisablePlainTextAuth [%d]"), this, isDisableAuth));
- if (getErr == KErrNone)
+
+ aProtocolConfigOption.iId = 1;
+ getErr = aIapView->GetText(KCDTIdWCDMAIfAuthPass | KCDTIdOutgoingGprsRecord, buf);
+ if ( getErr == KErrNone )
{
- getErr = aIapView->GetText(KCDTIdWCDMAIfAuthPass | KCDTIdOutgoingGprsRecord, buf);
- if ( getErr == KErrNone )
- {
- ASSERT(buf);
- aProtocolConfigOption.iAuthInfo.iPassword.Copy(*buf);
- delete buf;
- buf = NULL;
-
- __CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL() KCDTIdWCDMAIfAuthPass [%S]"), this, &aProtocolConfigOption.iAuthInfo.iPassword));
-
- if (isDisableAuth) //If Disable, CHAP will be used.
- {
- aProtocolConfigOption.iAuthInfo.iProtocol = RPacketContext::EProtocolCHAP;
- CreateChallengeAndResponseForChapL(aProtocolConfigOption);
- }
- else
- {
- aProtocolConfigOption.iAuthInfo.iProtocol = RPacketContext::EProtocolPAP;
- }
- }
- else if (getErr == KErrNotFound)
- {
- if (isDisableAuth) //ERROR: CHAP used without password???
- {
- User::Leave(KErrArgument);
- }
- else //PAP used without password.
- {
- aProtocolConfigOption.iAuthInfo.iProtocol = RPacketContext::EProtocolPAP;
- }
- }
- else //getErr != KErrNotFound
- {
- User::Leave(getErr);
- }
+ ASSERT(buf);
+ aProtocolConfigOption.iAuthInfo.iPassword.Copy(*buf);
+ delete buf;
+ buf = NULL;
+
+ __CFLOG_VAR((KPDPMCprTag, KPDPMCprSubTag, _L8("CGPRSProvision [this=%08x]::RetrieveAuthenticationInfoL() KCDTIdWCDMAIfAuthPass [%S]"), this, &aProtocolConfigOption.iAuthInfo.iPassword));
}
- else
+ else if (getErr != KErrNotFound)
{
User::Leave(getErr);
}
}
- else if (getErr == KErrNotFound ) //No Authentication Required.
- {
- aProtocolConfigOption.iAuthInfo.iProtocol = RPacketContext::EProtocolNone;
- }
- else //getErr != KErrNotFound
+ else if (getErr != KErrNotFound)
{
User::Leave(getErr);
}
}
-void CGPRSProvision::CreateChallengeAndResponseForChapL(RPacketContext::TProtocolConfigOptionV2& aProtocolConfigOption)
- {
- //Challenge
- TTime currentTime;
- currentTime.UniversalTime();
-
- TInt64 seedValue = currentTime.Int64();
-
- TUint8 challenge[KGenericNifChallengeSize] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
- TUint8 i=0;
- while(i < KGenericNifChallengeSize)
- {
- challenge[i] = (TUint8)(Math::Rand(seedValue)%256);
- aProtocolConfigOption.iChallenge.Append(challenge[i++]);
- }
-
- //Response
- TBuf8<KGenericNifIdLength+KCommsDbSvrMaxColumnNameLength+KGenericNifChallengeSize> message;
- message.Append(aProtocolConfigOption.iId);
- message.Append(aProtocolConfigOption.iAuthInfo.iPassword);
- message.Append(aProtocolConfigOption.iChallenge);
-
- TInt length = 1 /*iId length */ + aProtocolConfigOption.iAuthInfo.iPassword.Length() + KGenericNifChallengeSize;
-
- HBufC8* buf = HBufC8::NewL(length);
-
- CleanupStack::PushL(buf);
-
- TPtr8 ptr((TUint8*)buf->Des().Ptr(),length);
-
- ptr.Copy(message);
-
- CMD5* md5=0;
- md5 = CMD5::NewL();
-
- CleanupStack::PushL(md5);
-
- TPtrC8 Response = md5->Hash(ptr);
-
- aProtocolConfigOption.iResponse.Copy(Response);
-
- CleanupStack::PopAndDestroy(2);
- }
-
void CGPRSProvision::RetrieveIPAndDnsSettingsL(TDes8& aPdpAddress, TDes8& aDns1, TDes8& aDns2, ESock::CCommsDatIapView* aIapView) const
{
HBufC* buf = NULL;
@@ -337,6 +251,9 @@
if (!fromServer)
{
aIapView->GetTextL(KCDTIdWCDMAIPAddr | KCDTIdOutgoingGprsRecord, buf);
+ TInetAddr addr;
+ User::LeaveIfError(addr.Input(*buf));
+ // sending ASCII to MA but checking the validity of the address above.
aPdpAddress.Copy(*buf);
delete buf;
buf = NULL;
@@ -363,10 +280,15 @@
if (!fromServer)
{
aIapView->GetTextL(KCDTIdWCDMAIPNameServer1 | KCDTIdOutgoingGprsRecord, buf);
+ TInetAddr addr;
+ User::LeaveIfError(addr.Input(*buf));
+ // sending ASCII to MA but checking the validity of the address above.
aDns1.Copy(*buf);
delete buf;
buf = NULL;
aIapView->GetTextL(KCDTIdWCDMAIPNameServer2 | KCDTIdOutgoingGprsRecord, buf);
+ User::LeaveIfError(addr.Input(*buf));
+ // sending ASCII to MA but checking the validity of the address above.
aDns2.Copy(*buf);
delete buf;
buf = NULL;
@@ -379,10 +301,15 @@
if (!fromServer)
{
aIapView->GetTextL(KCDTIdWCDMAIP6NameServer1 | KCDTIdOutgoingGprsRecord, buf);
- aDns1.Copy(*buf);
+ TInetAddr addr;
+ User::LeaveIfError(addr.Input(*buf));
+ // sending ASCII to MA but checking the validity of the address above.
+ aDns1.Copy(*buf);
delete buf;
buf = NULL;
aIapView->GetTextL(KCDTIdWCDMAIP6NameServer2 | KCDTIdOutgoingGprsRecord, buf);
+ User::LeaveIfError(addr.Input(*buf));
+ // sending ASCII to MA but checking the validity of the address above.
aDns2.Copy(*buf);
delete buf;
buf = NULL;