# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1270069209 -10800 # Node ID e9cc36e353d441f9691e46ea5436b9ab82ef3aa5 # Parent db85996de7c4851018975c59523e0b8b02c7f2b4 Revision: 201013 Kit: 201013 diff -r db85996de7c4 -r e9cc36e353d4 linklayercontrol/networkinterfacemgr/agentpr/src/agenttiermanagerselector.cpp --- a/linklayercontrol/networkinterfacemgr/agentpr/src/agenttiermanagerselector.cpp Mon Mar 15 12:46:10 2010 +0200 +++ b/linklayercontrol/networkinterfacemgr/agentpr/src/agenttiermanagerselector.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -148,7 +148,7 @@ __CFLOG_VAR((KAgentTierMgrTag, KAgentTierMgrSubTag, _L8("CAgentMetaCprSelectorBase::\tNewL()"))); __ASSERT_DEBUG(aSelectionPreferences.IsTypeOf(TSelectionPrefs::TypeId()), User::Panic(KSpecAssert_NifManAgtPrgntrm, 4)); CMDBSession* dbs = CMDBSession::NewLC(KCDVersion1_2); - ASimpleSelectorBase* self = new (ELeave) CAgentProviderSelector(aSelectionPreferences); + CAgentProviderSelector* self = new (ELeave) CAgentProviderSelector(aSelectionPreferences); CleanupStack::PushL(self); __ASSERT_DEBUG(self->iTierRecord==NULL, User::Panic(KSpecAssert_NifManAgtPrgntrm, 5)); self->iTierRecord = TierManagerUtils::LoadTierRecordL(TUid::Uid(CAgentTierManagerFactory::iUid),*dbs); diff -r db85996de7c4 -r e9cc36e353d4 linklayercontrol/networkinterfacemgr/netcfgext/src/netcfgextnbase.cpp --- a/linklayercontrol/networkinterfacemgr/netcfgext/src/netcfgextnbase.cpp Mon Mar 15 12:46:10 2010 +0200 +++ b/linklayercontrol/networkinterfacemgr/netcfgext/src/netcfgextnbase.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -579,6 +579,9 @@ iAsynchDaemonCancel = NULL; } } + + // Clear out outstanding RMessage2 as it is no longer outstanding (it will be completed elsewhere) + iMessage = ESock::RLegacyResponseMsg(); } //the RunL method will be called on the original request cancellation } @@ -733,8 +736,13 @@ } else { - // should never get here. - __ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_NifManNetCfgExtn, 10)); + + // Async cancel must have completed + // Start deregistration if it was queued up + if (iDeregisterOnCompletionOfRequest) + { + Deregister(iDeregistrationCauseCode); + } } // ******************************************** // CAREFUL... consider the possible deletion of diff -r db85996de7c4 -r e9cc36e353d4 linklayerprotocols/ethernetnif/EtherPkt/CardCtl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linklayerprotocols/ethernetnif/EtherPkt/CardCtl.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -0,0 +1,463 @@ +// Copyright (c) 1997-2009 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" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// Control engine for ethernet packet driver +// +// + +/** + @file +*/ + +#include +#include +#include +#include +#include +#include +#include "PKTDRV.H" +#include "ETHINTER.H" +#include "Cardctl.h" +#include +#include + +//#define __DebugCardCtl__ 1 + +#if defined(__DebugCardCtl__) +#include + #define DPRINT(x) RDebug::Print x + #pragma message ("Warning: this code contains RDebug::Print statements! Do not submit to the mainline with __DebugCardCtl__ defined.") +#else + #define DPRINT(x) +#endif + +/** +Create a new CPcCardControlEngine object. +@param aPktDrv Pointer to PC Card Packet Driver. +@return A pointer to CPcCardControlEngine object. +*/ +CPcCardControlEngine *CPcCardControlEngine::NewL(CPcCardPktDrv* aPktDrv) +{ + CPcCardControlEngine *cc=new (ELeave) CPcCardControlEngine(aPktDrv); + CleanupStack::PushL(cc); + cc->ConstructL(); + CleanupStack::Pop(); + return cc; +} + +/** +Physical device driver settings +@internalComponent +*/ +_LIT(KPddSection,"pdd_settings"); + +/** +PCMCIA Socket Number +@internalComponent +*/ +_LIT(KSocketNumber,"PCMCIA_socket"); + +/** +Create the CPcCardControlEngine object. +*/ +void CPcCardControlEngine::ConstructL() +{ + iSender = CPcCardSender::NewL(this); + iReceiver = CPcCardReceiver::NewL(this); + iEventHandler = CPcCardEventHandler::NewL(this); + + LoadDeviceDriversL(); + + CESockIniData* ini = CESockIniData::NewL(ETHER802_CONFIG_FILENAME); + CleanupStack::PushL(ini); + + TInt socket; + if(!ini->FindVar(KPddSection,KSocketNumber,socket)) + { + User::Leave(KErrNotFound); + } + + CleanupStack::PopAndDestroy(ini); + + TInt error = iCard.Open(socket); + User::LeaveIfError(error); +} + +/** +Open the Card LDD +*/ +void CPcCardControlEngine::StartL() +{ + iCardOpen = ETrue; + iReceiver->QueueRead(); + LinkLayerUp(); +} + +/** +Find and loads the LDD and the PDD if the logical device driver loaded OK. +The driver names are read from the LAN bearer table in commdb. +*/ +void CPcCardControlEngine::LoadDeviceDriversL() +{ + TInt err; + + // + // Get the device driver filenames for loading + // + TBuf pddOrLddFileName; + + // LDD first... + TBuf columnName=TPtrC(LAN_BEARER); + columnName.Append(TChar(KSlashChar)); + columnName.Append(TPtrC(LAN_BEARER_LDD_FILENAME)); + + err = iNotify->NifNotify()->ReadDes(columnName, pddOrLddFileName); // Get the LDD name from commdb + + if(err!=KErrNone) + { + __FLOG_STATIC(KEther802LogTag1,KEthLogTag3, _L("Could not find LDD filename in commdb - is .cfg file up-to-date? See ether802.ini for information on required fields in commdb.")); + User::Leave(err); + } + + err=User::LoadLogicalDevice(pddOrLddFileName); + if(err != KErrNone && err != KErrAlreadyExists) + { + User::Leave(err); + } + + // ...and now the PDD + columnName.Zero(); + columnName.Append(TPtrC(LAN_BEARER)); + columnName.Append(TChar(KSlashChar)); + columnName.Append(TPtrC(LAN_BEARER_PDD_FILENAME)); + + err = iNotify->NifNotify()->ReadDes(columnName, pddOrLddFileName); // Get the PDD filename from commdb + + if(err!=KErrNone) + { + __FLOG_STATIC(KEther802LogTag1,KEthLogTag3, _L("Could not find PDD filename in commdb - is .cfg file up-to-date? See ether802.ini for information on required fields in commdb.")); + User::Leave(err); + } + + err = User::LoadPhysicalDevice(pddOrLddFileName); + if (err != KErrNone && err != KErrAlreadyExists) + { + User::Leave(err); + } + + // + // Get device driver names for unloading + // + columnName.Zero(); + columnName.Append(TPtrC(LAN_BEARER)); + columnName.Append(TChar(KSlashChar)); + columnName.Append(TPtrC(LAN_BEARER_PDD_NAME)); + + err = iNotify->NifNotify()->ReadDes(columnName, iPDDName); // Get the PDD name from commdb (so we can close it when we've finished with it) + + if(err!=KErrNone) + { + __FLOG_STATIC(KEther802LogTag1,KEthLogTag3, _L("Could not find PDD name in commdb - is .cfg file up-to-date? See ether802.ini for information on required fields in commdb.")); + +#ifdef _DEBUG + // Not being able to unload the device drivers is not a fatal error, so don't worry too + // much if we can't read the field out of commdb in release builds, but if the user is + // using a debug nif they ought to get it right... + User::Leave(err); +#endif // _DEBUG + } + + // Rather than fiddle around trying to reuse the contents of the descriptor (problems with field name lengths), just zero and start again + columnName.Zero(); + columnName.Append(TPtrC(LAN_BEARER)); + columnName.Append(TChar(KSlashChar)); + columnName.Append(TPtrC(LAN_BEARER_LDD_NAME)); + + err = iNotify->NifNotify()->ReadDes(columnName, iLDDName); // Get the LDD name from commdb (so we can close it when we've finished with it) + + if(err!=KErrNone) + { + __FLOG_STATIC(KEther802LogTag1,KEthLogTag3, _L("Could not find LDD name in commdb - is .cfg file up-to-date? See ether802.ini for information on required fields in commdb.")); + +#ifdef _DEBUG + User::Leave(err); // see reasoning for LDD above +#endif // _DEBUG + } + + __FLOG_STATIC(KEther802LogTag1,KEthLogTag3, _L("Device drivers loaded")); +} + +/** +Cancel I/O and close the Card LDD. +*/ +void CPcCardControlEngine::Stop() +{ + // LDD Performs status checks on Read and Write + // Completes requests with an error code if they are pending + iCard.WriteCancel(); + iSender->EmptyQueue(); + iSender->Cancel(); + + iCard.ReadCancel(); + iCardOpen = EFalse; + iCard.Close(); +} + +CPcCardControlEngine::CPcCardControlEngine(CPcCardPktDrv* aPktDrv) +:iCardOpen(EFalse), iNotify(aPktDrv) +/** +Constructor. +@param aPktDrv Pointer to PC Card Packet Driver. +*/ +{ + +} + +/** +Destructor. +*/ +CPcCardControlEngine::~CPcCardControlEngine() +{ +#ifdef _DEBUG + // see reasoning for only doing this in debug builds in LoadPacketDrivers() + User::FreeLogicalDevice(iLDDName); + User::FreePhysicalDevice(iPDDName); +#endif + + delete iReceiver; + delete iSender; + delete iEventHandler; +} + +/** +Upwards notify +@param aBuffer A Reference to a buffer holding data. +*/ +void CPcCardControlEngine::ProcessReceivedPacket(TDesC8& aBuffer) +{ + iNotify->ReadDataAvailable(aBuffer); +} + +/** +Resume Sending is a notification call into NIF from the lower layer telling the NIF that a +previous sending congestion situation has been cleared and it can accept more downstack data. +*/ +void CPcCardControlEngine::ResumeSending() +{ + iNotify->ResumeSending(); +} + +/** +Resume Sending is a notification call into NIF from the lower layer telling the NIF that +the interface is now up and can accept and transmit data. NIF subsequently calls all the +bearers' StartSending() methods directly. +*/ +void CPcCardControlEngine::LinkLayerUp() +{ + iNotify->LinkLayerUp(); +} + +/** +Sender class handles queueing and takes ownership of the HBuf and the CIOBuffer. +@param aBuffer The data to be send is set. +@return 0 Tells the higher layer to send no more data. + 1 Tells higher layer that it can send more data. +*/ +TInt CPcCardControlEngine::Send(HBufC8* aBuffer) +{ + DPRINT((_L(">CPcCardControlEngine::Send"))); + CIOBuffer* buf = NULL; + TRAPD(err,buf = CIOBuffer::NewL(aBuffer)); + if(err != KErrNone) + { + DPRINT((_L(">CPcCardControlEngine::Send No Buffer."))); + delete aBuffer; + } + else + { + DPRINT((_L(">CPcCardControlEngine::Send About to iSender."))); + err = iSender->Send(buf); + } + DPRINT((_L(" controlBuf; // the size of this is defined in the driver as 64. + TBuf8<12> macAddress = 0; + RFile macFile; + RFs fileSrv; + + User::LeaveIfError(fileSrv.Connect()); + User::LeaveIfError(macFile.Open(fileSrv,KEtherMacFileName,EFileRead)); + User::LeaveIfError(macFile.Read(macAddress,12)); + macFile.Close(); + fileSrv.Close(); + controlBuf.SetLength(8); + controlBuf[0] = KEthSpeed10BaseT; + controlBuf[1] = KEthDuplexHalf; + + TBuf<20> validChars(_L("0123456789abcdef")); + TUint8 value; + TUint8 upper=0; + TChar c; + TInt pos; + iConfig.SetMax(); // MAC Address fix + for(TInt i=0; i<6; i++) + { + c = macAddress[2*i]; + c.LowerCase(); + if((pos = validChars.Locate(c))==KErrNotFound) + { + pos = upper; + break; + } + upper = (TUint8)pos; + c = macAddress[(2*i)+1]; + c.LowerCase(); + if((pos = validChars.Locate(c))==KErrNotFound) + { + User::Leave(KErrNotFound); + } + value = (TUint8)pos; + value = (TUint8)((upper<<4) | value); + controlBuf.Append(value); + iConfig[i+2]=value; // MAC Address fix 21/05/01 + } + TRequestStatus status = 0; + DPRINT((_L("ParseMACFromFileL(), iConfig MAC set to %x %x %x %x %x %x"), + iConfig[2],iConfig[3],iConfig[4],iConfig[5],iConfig[6],iConfig[7])); + User::LeaveIfError(iCard.SetMAC(controlBuf)); + + User::WaitForRequest(status); + User::LeaveIfError(status.Int()); +} +#endif + +/** +Constructor. Generic Buffer class +Currently used for transmit buffers +*/ +CIOBuffer::CIOBuffer() : iBufPtr(NULL,0) +{ +} + +/** +Destructor. Free the HBuf if there is one +*/ +CIOBuffer::~CIOBuffer() +{ + FreeData(); +} + +/** +Creation where we new the HBuf. +@param aSize Length of the Buffer. +@return A pointer to CIOBuffer object. +*/ +CIOBuffer* CIOBuffer::NewL(const TInt aSize) +{ + CIOBuffer * self = new (ELeave) CIOBuffer; + CleanupStack::PushL(self); + self->ConstructL(aSize); + CleanupStack::Pop(); + return self; +} + +/** +Construction where we new the HBuf +@param aSize Length of the Buffer. +*/ +void CIOBuffer::ConstructL(const TInt aSize) +{ + iBuf = HBufC8::NewL(aSize); + TPtr8 temp=iBuf->Des(); + iBufPtr.Set(temp); +} + +/** +HBuf provided. +@param aBuf The data to be assigned +@return A pointer to CIOBuffer object. +*/ +CIOBuffer* CIOBuffer::NewL(HBufC8* aBuf) +{ + CIOBuffer * self = new (ELeave) CIOBuffer; + self->Assign(aBuf); + return self; +} + +/** +Offset +*/ +TInt CIOBuffer::LinkOffset() +{ + return _FOFF(CIOBuffer,iLink); +} + +/** +Assigns the data from buffer to pointer. + +@param aBuffer The data to be assigned +*/ +void CIOBuffer::Assign(HBufC8* aBuffer) +{ + FreeData(); + iBuf = aBuffer; + if(aBuffer) + { + TPtr8 temp=iBuf->Des(); + iBufPtr.Set(temp); + } +} + +/** +Frees the data. +*/ +void CIOBuffer::FreeData() +{ + if(iBuf) + { + delete iBuf; + iBuf = NULL; + } +} + diff -r db85996de7c4 -r e9cc36e353d4 linklayerprotocols/ethernetnif/EtherPkt/CardDll.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linklayerprotocols/ethernetnif/EtherPkt/CardDll.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -0,0 +1,365 @@ +// Copyright (c) 1997-2009 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" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + +#include +#include +#include +#include +#include +#include "PKTDRV.H" +#include "ETHINTER.H" +#include "Cardctl.h" + + +/** +@internalComponent +*/ +extern "C" +{ + IMPORT_C CPktDrvFactory * NewPcCardPktDrvFactoryL(); //< Force export +} + +/** +Library file is opened and this is the the first and only export. +@internalComponent +@return A pointer to CPktDrvFactory object. +*/ +EXPORT_C CPktDrvFactory* NewPcCardPktDrvFactoryL() +{ + CPktDrvFactory *f=new (ELeave) CPcCardPktDrvFactory; + return f; +} + +/** +Create the packet driver object +@param aParent Pointer to the parent Ethint NIF class. +@return A pointer to CPktDrvBase object. +*/ +CPktDrvBase* CPcCardPktDrvFactory::NewDriverL(CLANLinkCommon* aParent) +{ + CPktDrvBase *drv = new (ELeave) CPcCardPktDrv(*this); + CleanupStack::PushL(drv); + drv->ConstructL(aParent); + CleanupStack::Pop(); + return drv; +} + +/** +Constructor. +*/ +CPcCardPktDrvFactory::CPcCardPktDrvFactory() +{ + +} + +/** +Packet Driver version number. +@return Version number of the Packet Driver +*/ +TVersion CPcCardPktDrvFactory::Version() const +{ + return(TVersion(KPcCardDrvMajorVersionNumber,KPcCardDrvMinorVersionNumber,KPcCardDrvBuildVersionNumber)); +} + + +/** +Constructor. Packet Driver object. +*/ +CPcCardPktDrv::CPcCardPktDrv(CPktDrvFactory& aFactory) : CPktDrvBase(aFactory) +{ + +} + +/** +Only one object owned +Destructor. +*/ +CPcCardPktDrv::~CPcCardPktDrv() +{ + delete iControl; +} + +/** +Pure Virtual Construction of the CPktDrvBase object +@param aParent Pointer to the CLANLinkCommon class. +*/ +void CPcCardPktDrv::ConstructL(CLANLinkCommon* aParent) +{ + iParent = aParent; + // Card control engine + iControl=CPcCardControlEngine::NewL(this); +} + +/** +Pure Virtual Downstack call. " Call to LDD or subordinate object to start/initialise the +Physical device +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::StartInterface() +{ + // Opens the card and queues a read + // Control engine validates + TRAPD(err,iControl->StartL()); + return err; +} + +/** +Call to LDD or subordinate object to stop/de-initialise the Physical device +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::StopInterface() +{ + // Closes the card + // Control engine validates + iControl->Stop(); + return KErrNone; +} + +/** +Call to LDD or subordinate object to reset/re-initialise the Physical device +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::ResetInterface() +{ + iControl->Stop(); + TRAPD(err,iControl->StartL()); + return err; +} + +/** +Sender Class is generic and does not want to know about RMBuf's +Copy to a Heap Buffer and Free the packet. EtherII MAC layer comments +Say we should free the packet buffer +RMBuf could contain a chain so get into a contiguous buffer +@param aPacket Reference to a chain of data buffers to be passed to the line. +@return 0 Tells the higher layer to send no more data. + 1 Tells higher layer that it can send more data. +*/ +TInt CPcCardPktDrv::Send(RMBufChain &aPacket) +{ + if(!iControl->CardOpen()) + { + aPacket.Free(); + return KErrNotReady; + } + HBufC8 * buf = NULL; + TRAPD(err,buf = HBufC8::NewMaxL(aPacket.Length())); + if(err != KErrNone) + { + aPacket.Free(); + return err; + } + TPtr8 ptr = buf->Des(); + aPacket.CopyOut(ptr); + aPacket.Free(); + return(iControl->Send(buf)); +} + +/** +Read the Available data. +@param aBuffer A Reference to a buffer holding data. +*/ +void CPcCardPktDrv::ReadDataAvailable(TDesC8& aBuffer) +{ + RMBufPacket frame; + TRAPD(ret,frame.CreateL(aBuffer,0)); + if (ret == KErrNone) + { + frame.Pack(); + iParent->Process(frame); + } +} + +/** +Resume Sending is a notification call into NIF from the lower layer telling the NIF that a +previous sending congestion situation has been cleared and it can accept more downstack data. +*/ +void CPcCardPktDrv::ResumeSending() +{ + iParent->ResumeSending(); +} + +/** +Call to LDD or subordinate object to set the receive mode of the LAN Device +@param aMode The mode to be set for the LAN Device. +@return KErrNotSupported LAN Device does not support. +*/ +TInt CPcCardPktDrv::SetRxMode(TRxMode /*aMode*/) +{ + return KErrNotSupported; +} + +/** +Call to LDD or subordinate object to Get the receive mode of the LAN Device +@return KErrNotSupported LAN Device does not support. +*/ +TInt CPcCardPktDrv::GetRxMode() const +{ + return KErrNotSupported; +} + +/** +Specifies the AccessType. +@return KErrNotSupported LAN Device does not support. +*/ +TInt CPcCardPktDrv::AccessType() +{ + return KErrNotSupported; +} + +/** +Specifies the ReleaseType. +@return KErrNotSupported LAN Device does not support. +*/ +TInt CPcCardPktDrv::ReleaseType() +{ + return KErrNotSupported; +} + +/** +Call to LDD or subordinate object to get the Hardware address of the LAN Device +@return NULL Failure. + (NULL Terminated Binary String) The Hardware Address of the interface. LAN Device + Specific +*/ +TUint8* CPcCardPktDrv::GetInterfaceAddress()const +{ + return (iControl->GetInterfaceAddress()); +} + +/** +Call to LDD or subordinate object to set the Hardware address of the LAN Device. +@param THWAddr Address of where the Multicast list should be written. +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::SetInterfaceAddress(const THWAddr&) +{ + return KErrNotSupported; +} + +/** +Call to LDD or subordinate object to retrieve the Multicast List from the LAN Device +@param aAddr Address of where the Multicast list should be written. +@param n Output Parameter , number of Addresses written +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::GetMulticastList(const THWAddr* /*aAddr*/, TInt& /*n*/) const +{ + return KErrNotSupported; +} + +/** +Call to LDD or subordinate object to set the Multicast List for the LAN Device. +@param aAddr Address of where the Multicast list should be written. +@param n Output Parameter , number of Addresses written +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::SetMulticastList(const THWAddr* /*aAddr*/, TInt /*n*/) +{ + return KErrNotSupported; +} + +/** +Call to LDD or subordinate object to power up the LAN Device. +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::InterfacePowerUp() +{ + return KErrNotSupported; +} + +/** +Call to LDD or subordinate object to power down the LAN Device +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::InterfacePowerDown() +{ + return KErrNotSupported; +} + +/** +Call to LDD or subordinate object to suspend the LAN Device. +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::InterfaceSleep() +{ + return KErrNotSupported; +} + +/** +Call to LDD or subordinate object to resume the LAN Device. +@return KErrNone if Successful + KErrNotSupported LAN Device does not support. + Implementation specific Error Code Failure +*/ +TInt CPcCardPktDrv::InterfaceResume() +{ + return KErrNotSupported; +} + +/** +Resume Sending is a notification call into NIF from the lower layer telling the NIF that +the interface is now up and can accept and transmit data. NIF subsequently calls all the +bearers' StartSending() methods directly. +*/ +void CPcCardPktDrv::LinkLayerUp() +{ + iParent->LinkLayerUp(); +} + +/** +Receive notifications from agent +*/ +TInt CPcCardPktDrv::Notification(enum TAgentToNifEventType /*aEvent*/, void* /*aInfo*/) +{ + return KErrNotSupported; +} + +/** +Receive Control() calls from agent/nifman/connection +*/ +TInt CPcCardPktDrv::Control(TUint /*aLevel*/,TUint /*aName*/,TDes8& /*aOption*/, TAny* /*aSource*/) +{ + return KErrNotSupported; +} + +/** +Return the pointer to the ethernet nif. +Purely for access to commdb reading functionality +*/ +CLANLinkCommon* CPcCardPktDrv::NifNotify() +{ + return iParent; +} + diff -r db85996de7c4 -r e9cc36e353d4 linklayerprotocols/ethernetnif/EtherPkt/CardIo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linklayerprotocols/ethernetnif/EtherPkt/CardIo.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -0,0 +1,488 @@ +// Copyright (c) 1997-2009 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" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// +// + +/** + @file +*/ + +#include +#include +#include +#include +#include "PKTDRV.H" +#include "ETHINTER.H" +#include "Cardctl.h" + +//#define __DebugCardLo__ 1 +#if defined(__DebugCardLo__) +#include + #define DPRINT(x) RDebug::Print x + #pragma message ("Warning: this code contains RDebug::Print statements! Do not submit to the mainline with __DebugCardCtl__ defined.") +#else + #define DPRINT(x) +#endif + +#ifdef __DebugCardLo__ +// TCP packet tracing debug +const TUint8 ETHER2_TYPE_IP_MSB = 0x08; +const TUint8 ETHER2_TYPE_IP_LSB = 0x00; +const TUint8 IP_TYPE_TCP = 0x06; +static inline TBool IsTcp(TDesC8 &aFrame) +{ + return (aFrame[12] == ETHER2_TYPE_IP_MSB && aFrame[13] == ETHER2_TYPE_IP_LSB && aFrame[23] == IP_TYPE_TCP); +} +static TInt GetTcpSeqNumber(TDesC8 &aFrame) + { + TInt seqNum = 0; + if (IsTcp(aFrame)) + seqNum = aFrame[38] << 24 | aFrame[39] << 16 | aFrame[40] << 8| aFrame[41]; + return seqNum; + } +static TInt GetTcpAckNumber(TDesC8 &aFrame) + { + TInt ackNum = 0; + if (IsTcp(aFrame)) + ackNum = aFrame[42] << 24 | aFrame[43] << 16 | aFrame[44] << 8| aFrame[45]; + return ackNum; + } +#endif + + +/** +Send active object class +When CIOBuffer's are passed to SendL() the class takes ownership and is +therefore resposible for freeing them in the RunL() +@internalComponent +*/ +const TInt KTxQueueThreshold = 40; + +/** +Constructor. +*/ +CPcCardSender::CPcCardSender() : CActive(EPriorityStandard) +{ + +} + +/** +Destructor. +Could be buffers on the transmit queue, free them as this class should be sole owner. +*/ +CPcCardSender::~CPcCardSender() +{ + EmptyQueue(); + Cancel(); +} + +/** +Standard CActive construction. +@param aParent Pointer to the parent CPcCardControlEngine class. +@return A pointer to CPcCardSender object. +*/ +CPcCardSender* CPcCardSender::NewL(CPcCardControlEngine* aParent) +{ + CPcCardSender *sd=new (ELeave) CPcCardSender; + CleanupStack::PushL(sd); + sd->InitL(aParent); + CActiveScheduler::Add(sd); + CleanupStack::Pop(); + return sd; +} + +/** +Add the newly created object to an object container. +@param aParent Pointer to the parent CPcCardControlEngine class. +*/ +void CPcCardSender::InitL(CPcCardControlEngine* aParent) +{ + iParent=aParent; + iTxQueue.SetOffset(CIOBuffer::LinkOffset()); + iQueueLength = 0; + iStopSending = EFalse; +} + +/** +Protocol inspects return +It blocks sending if it receives a return <= 0 +This value should be propogated up through the stack +@internalComponent +*/ +const TInt KStopSending = 0; + +/** +Protocol inspects return to indicate Keep sending the data. +@internalComponent +*/ +const TInt KContinueSending = 1; + +/** +Writes the data to buffer. + +@param aBuffer The data to be send. +@return 0 Tells the higher layer to stop sending the data. + 1 Tells higher layer that it can continue sending more data. +*/ +TInt CPcCardSender::Send(CIOBuffer *aBuffer) +{ + DPRINT((_L(">pkt tx: requested write - tcp seq=%u ack=%u iQueueLength=%d threadId=%d"), + GetTcpSeqNumber(aBuffer->Ptr()), GetTcpAckNumber(aBuffer->Ptr()), iQueueLength, (TInt)RThread().Id() )); + + // Check to see if we need to start transmission + // Pseudo interrupt queue + TBool startTx = iTxQueue.IsEmpty(); + + iTxQueue.AddLast(*aBuffer); + iQueueLength++; + if(startTx) + { + // Transmitter was idle start next transmit + DPRINT((_L(">pkt tx: PRE write - tcp seq=%u ack=%u iQueueLength=%d threadId=%d"), + GetTcpSeqNumber(aBuffer->Ptr()), GetTcpAckNumber(aBuffer->Ptr()), iQueueLength, (TInt)RThread().Id() )); + iParent->iCard.Write(iStatus,aBuffer->Ptr()); + SetActive(); + //DPRINT((_L(">pkt tx: PST write - tcp seq=%u ack=%u iQueueLength=%d threadId=%d"), GetTcpSeqNumber(aBuffer->Ptr()), GetTcpAckNumber(aBuffer->Ptr()), iQueueLength, RThread().Id() )); + } + else + { + DPRINT((_L(">pkt tx: PST skipped write queuing (leave for runl) - tcp seq=%u ack=%u iQueueLength=%d threadId=%d"), + GetTcpSeqNumber(aBuffer->Ptr()), GetTcpAckNumber(aBuffer->Ptr()), iQueueLength, (TInt)RThread().Id() )); + } + // The stack could saturate us with data + // Tell the stack to send no more + // We will unblock the stack when the queue size drops below + // the the threshold + if(iQueueLength >= KTxQueueThreshold) + { + iStopSending = ETrue; + return KStopSending; + } + else + { + return KContinueSending; + } +} + +/** +Free all queued buffers. Should be safe as this class owns them +*/ +void CPcCardSender::EmptyQueue() +{ + DPRINT((_L(">pkt tx: emptying driver..."))); + while(!iTxQueue.IsEmpty()) + { + CIOBuffer* buf = iTxQueue.First(); + iTxQueue.Remove(*buf); + delete buf; + } + iQueueLength = 0; + iStopSending = EFalse; +} + +/** +Write completion from the LDD. Pseudo transmit interrupt handler +*/ +void CPcCardSender::RunL() +{ + DPRINT((_L(">pkt tx runl: completion - tcp seq=%u ack=%u iQueueLength=%d threadId=%d"), + GetTcpSeqNumber(iTxQueue.First()->Ptr()), GetTcpAckNumber(iTxQueue.First()->Ptr()), iQueueLength, (TInt)RThread().Id() )); + // Check for error, all we can do is free the buffers + if(iStatus.Int()!=KErrNone) + { + DPRINT((_L(">pkt tx runl error... emptying queue: - tcp seq=%u ack=%u iQueueLength=%d threadId=%d"), + GetTcpSeqNumber(iTxQueue.First()->Ptr()), GetTcpAckNumber(iTxQueue.First()->Ptr()), iQueueLength, (TInt)RThread().Id() )); + EmptyQueue(); + return; + } + + if(!iTxQueue.IsEmpty()) + { + // Head of the queue has been transmitted + // Remove it and free it + CIOBuffer* buf = iTxQueue.First(); + iTxQueue.Remove(*buf); + iQueueLength--; + delete buf; + + + // Check to see if there are still buffers queued. + // Start next transmit if there are + TBool startTx; + (iTxQueue.IsEmpty()) ? (startTx = EFalse) : (startTx = ETrue); + if(startTx) + { + buf = iTxQueue.First(); + DPRINT((_L(">pkt tx runl PRE write...: - tcp seq=%u ack=%u iQueueLength=%d threadId=%d"), + GetTcpSeqNumber(buf->Ptr()), GetTcpAckNumber(buf->Ptr()), iQueueLength, (TInt)RThread().Id() )); + iParent->iCard.Write(iStatus,buf->Ptr()); + SetActive(); + } + else + { + DPRINT((_L(">pkt tx runl skipped writing (queue empty)...:"))); + } + // Resume sending if the protocol was previously blocked + if(iStopSending && iQueueLength < KTxQueueThreshold) + { + DPRINT((_L(">pkt tx runl resume sending notification...: - tcp seq=%u ack=%u iQueueLength=%d threadId=%d"), + GetTcpSeqNumber(iTxQueue.First()->Ptr()), GetTcpAckNumber(iTxQueue.First()->Ptr()), iQueueLength, (TInt)RThread().Id() )); + + iStopSending = EFalse; + iParent->ResumeSending(); + } + } +} + +/** +cancellation of an outstanding request. +*/ +void CPcCardSender::DoCancel() +{ + iParent->iCard.WriteCancel(); +} + +/** +Read active object class. +Read kept permanently on the LDD +Read completion is notified immediately up through the stack +with the one receive buffer therefore no Q. +*/ +CPcCardReceiver::CPcCardReceiver() : CActive(EPriorityMore) , iRecvBufPtr(NULL,0) +{ + +} + +/** +Constructor. +*/ +CPcCardReceiver::~CPcCardReceiver() +{ + Cancel(); + // One buffer only + delete iRecvBuffer; +} + +/** +Standard CActive construction. +@param aParent Pointer to the parent CPcCardControlEngine class. +@return A pointer to CPcCardReceiver object. +*/ +CPcCardReceiver* CPcCardReceiver::NewL(CPcCardControlEngine* aParent) +{ + CPcCardReceiver *rv=new (ELeave) CPcCardReceiver; + CleanupStack::PushL(rv); + rv->InitL(aParent); + CActiveScheduler::Add(rv); + CleanupStack::Pop(); + return rv; +} + +/** +Allocate the one and only read buffer. +@param aParent Pointer to the parent CPcCardControlEngine class. +*/ +void CPcCardReceiver::InitL(CPcCardControlEngine* aParent) +{ + iParent=aParent; + iRecvBufLength=KEtherBufSize; + iRecvBuffer=HBufC8::NewMaxL(iRecvBufLength); + TPtr8 temp=iRecvBuffer->Des(); + iRecvBufPtr.Set(temp); +} + +/** +Pass the receive buffer to the Card. +*/ +void CPcCardReceiver::QueueRead() +{ + iRecvBufPtr.SetMax(); + DPRINT((_L(">pkt queuing read..."))); + iParent->iCard.Read(iStatus,iRecvBufPtr); + SetActive(); +} + +/** +Pseudo read interrupt handler. +*/ +void CPcCardReceiver::RunL() +{ + if (iParent->CardOpen()) + { + if (iStatus.Int()!=KErrNone) + { + DPRINT((_L(">pkt tx runl: bad status=%d tcp seq=%u ack=%u threadId=%d"), + iStatus.Int(), GetTcpSeqNumber(iRecvBufPtr), GetTcpAckNumber(iRecvBufPtr), (TInt)RThread().Id() )); + QueueRead(); + return; + } + // Pass the buffer up the stack + // and queue the next read, safe to reuse the buffer. + if(iRecvBufPtr.Length()) + { + DPRINT((_L(">pkt rx runl: tcp seq=%u ack=%u threadId=%d"), + GetTcpSeqNumber(iRecvBufPtr), GetTcpAckNumber(iRecvBufPtr), (TInt)RThread().Id() )); + iParent->ProcessReceivedPacket(iRecvBufPtr); + } + QueueRead(); + } + else + { + DPRINT((_L(">CPcCardReceiver::RunL Card NOT open"))); + } +} + +/** +Cancellation of an outstanding request. +*/ +void CPcCardReceiver::DoCancel() +{ + iParent->iCard.ReadCancel(); +} + +/** +Constructor. +*/ +CPcCardEventHandler::CPcCardEventHandler() : CActive(EPriorityStandard) +{ + +} + +/** +Destructor. +*/ +CPcCardEventHandler::~CPcCardEventHandler() +{ + Cancel(); +} + +/** +Allocate the one and only read buffer. +@param aParent Pointer to the parent CPcCardControlEngine class. +*/ +void CPcCardEventHandler::InitL(CPcCardControlEngine* aParent) +{ + iParent = aParent; +} + +/** +Standard CActive construction +@param aParent Pointer to the parent CPcCardControlEngine class. +@return A pointer to the CPcCardEventHandler object. +*/ +CPcCardEventHandler* CPcCardEventHandler::NewL(CPcCardControlEngine* aParent) +{ + CPcCardEventHandler *p=new (ELeave) CPcCardEventHandler; + CleanupStack::PushL(p); + p->InitL(aParent); + CActiveScheduler::Add(p); + CleanupStack::Pop(); + return p; +} + +/** +Handles an active object’s request completion event. +*/ +void CPcCardEventHandler::RunL() +{ + // TODO Parse code in iStatus for type of event +} + +/** +Cancellation of an outstanding request. +*/ +void CPcCardEventHandler::DoCancel() +{ +} + +/** +Gets the Event generated by the device drivers. +*/ +void CPcCardEventHandler::GetEvent() +{ + // Tell the device driver we want ALL Events + iEventBuffer.SetLength(1); + iEventBuffer[0] = 0xFF; + SetActive(); +} + +/** +Constructor. +*/ +CPcCardIOCTL::CPcCardIOCTL() : CActive(EPriorityStandard) +{ + +} + +/** +Destructor. +*/ +CPcCardIOCTL::~CPcCardIOCTL() +{ + Cancel(); +} + +/** +Add the newly created object to an object container. +@param aParent Pointer to the parent CPcCardControlEngine class. +*/ +void CPcCardIOCTL::InitL(CPcCardControlEngine* aParent) +{ + iParent = aParent; +} + +TInt CPcCardIOCTL::Ioctl(const TUint8 aIOCTLCode) +{ + if(IsActive()) + return KErrNotReady; + iIOCTLBuffer.SetLength(1); + iIOCTLBuffer[0] = aIOCTLCode; + iCurrentIOCTL = aIOCTLCode; + SetActive(); + return KErrNone; +} + + +/** +Standard CActive construction. +@param aParent Pointer to the parent CPcCardControlEngine class. +@return A pointer to CPcCardIOCTL object. +*/ +CPcCardIOCTL* CPcCardIOCTL::NewL(CPcCardControlEngine* aParent) +{ + CPcCardIOCTL *p=new (ELeave) CPcCardIOCTL; + CleanupStack::PushL(p); + p->InitL(aParent); + CActiveScheduler::Add(p); + CleanupStack::Pop(); + return p; +} + +/** +Handles an active object’s request completion event. +*/ +void CPcCardIOCTL::RunL() +{ + { + iParent->iReceiver->QueueRead(); + iParent->LinkLayerUp(); + } +} + +/** +Cancellation of an outstanding request. +*/ +void CPcCardIOCTL::DoCancel() +{ +} diff -r db85996de7c4 -r e9cc36e353d4 linklayerprotocols/ethernetnif/EtherPkt/Cardctl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linklayerprotocols/ethernetnif/EtherPkt/Cardctl.h Thu Apr 01 00:00:09 2010 +0300 @@ -0,0 +1,201 @@ +// Copyright (c) 1997-2009 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" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** + @file + @internalComponent +*/ + +#if !defined(__CARDCTL_H__) +#define __CARDCTL_H__ + +#include + +#include "carddrv.h" +#include // for KSlashChar + +const TInt KConfigBufferSize = 12; + + +NONSHARABLE_CLASS(CIOBuffer) : public CBase +/** +Generic buffer class +Enables HBufC8 pointers to be queued +@internalComponent +*/ +{ +public: + ~CIOBuffer(); + inline HBufC8* Data() const {return iBuf;}; + void FreeData(); + inline TPtr8& Ptr() {return iBufPtr;}; + void Assign(HBufC8* aBuffer = NULL); + static CIOBuffer* NewL(HBufC8* aBuf = NULL); + static CIOBuffer* NewL(const TInt aSize); + static TInt LinkOffset(); + +private: + CIOBuffer(); + void ConstructL(const TInt aSize); + // void Construct(HBufC8* aBuffer); + + TSglQueLink iLink; + HBufC8* iBuf; + TPtr8 iBufPtr; +}; + + +// Main Card Control class. Controls open, close, read, write etc +class CPcCardSender; +class CPcCardReceiver; +class CPcCardIOCTL; +class CPcCardEventHandler; + +NONSHARABLE_CLASS(CPcCardControlEngine) : public CBase +/** +@internalComponent +*/ +{ +public: + friend class CPcCardSender; + friend class CPcCardReceiver; + friend class CPcCardIOCTL; + friend class CPcCardEventHandler; + + static CPcCardControlEngine *NewL(CPcCardPktDrv* aPktDrv); + ~CPcCardControlEngine(); + void StartL(); + void Stop(); + TUint8* GetInterfaceAddress(); + TInt Send(HBufC8* aBuffer); + TBool CardOpen(){return iCardOpen;}; + +#if (!defined __WINS__) + void ParseMACFromFileL(); +#endif + + +private: + CPcCardControlEngine(CPcCardPktDrv* aPktDrv); + void ConstructL(); + void ProcessReceivedPacket(TDesC8 &aBuffer); + void ResumeSending(); + void LinkLayerUp(); + void LoadDeviceDriversL(); + +private: + TBool iCardOpen; + CPcCardPktDrv* iNotify; + + TBuf8 iConfig; + + CPcCardSender* iSender; + CPcCardReceiver* iReceiver; + CPcCardEventHandler* iEventHandler; + RBusDevEthernet iCard; + TInt iPcmciaSocket; + + TBuf iPDDName; + TBuf iLDDName; +}; + +NONSHARABLE_CLASS(CPcCardSender) : public CActive +/** +Writer Active object class +Queues buffers for transmit +@internalComponent +*/ +{ +public: + static CPcCardSender* NewL(CPcCardControlEngine* aParent); + ~CPcCardSender(); + TInt Send(CIOBuffer* aBuffer); + void EmptyQueue(); + +private: + virtual void RunL(); + virtual void DoCancel(); + CPcCardSender(); + void InitL(CPcCardControlEngine* aParent); + + TInt iQueueLength; + CPcCardControlEngine* iParent; + TSglQue iTxQueue; + TBool iStopSending; +}; + +NONSHARABLE_CLASS(CPcCardReceiver) : public CActive +/** +Reader active object +One receive buffer only, read queue handled by LDD +@internalComponent +*/ +{ +public: + static CPcCardReceiver* NewL(CPcCardControlEngine* aParent); + ~CPcCardReceiver(); + void QueueRead(); +private: + virtual void RunL(); + virtual void DoCancel(); + CPcCardReceiver(); + void InitL(CPcCardControlEngine* aParent); + + CPcCardControlEngine* iParent; + HBufC8* iRecvBuffer; + TUint iRecvBufLength; + TPtr8 iRecvBufPtr; +}; + +NONSHARABLE_CLASS(CPcCardEventHandler) : public CActive +/** +@internalComponent +*/ +{ +public: + ~CPcCardEventHandler(); + static CPcCardEventHandler* NewL(CPcCardControlEngine* aParent); + void GetEvent(); +private: + virtual void RunL(); + virtual void DoCancel(); + CPcCardEventHandler(); + void InitL(CPcCardControlEngine* aParent); + + TBuf8<32> iEventBuffer; + CPcCardControlEngine* iParent; +}; + +NONSHARABLE_CLASS(CPcCardIOCTL) : public CActive +/** +@internalComponent +*/ +{ +public: + ~CPcCardIOCTL(); + static CPcCardIOCTL* NewL(CPcCardControlEngine* aParent); + TInt Ioctl(const TUint8 aIOCTLCode); +private: + virtual void RunL(); + virtual void DoCancel(); + CPcCardIOCTL(); + void InitL(CPcCardControlEngine* aParent); + TBuf8<32> iIOCTLBuffer; + TUint8 iCurrentIOCTL; + + CPcCardControlEngine* iParent; +}; + +#endif diff -r db85996de7c4 -r e9cc36e353d4 networkcontrol/ipnetworklayer/inc/IPProtoCprStates.h --- a/networkcontrol/ipnetworklayer/inc/IPProtoCprStates.h Mon Mar 15 12:46:10 2010 +0200 +++ b/networkcontrol/ipnetworklayer/inc/IPProtoCprStates.h Thu Apr 01 00:00:09 2010 +0300 @@ -53,6 +53,10 @@ virtual void DoL(); DECLARE_SMELEMENT_FOOTER( THandleProvisionError ) +DECLARE_SMELEMENT_HEADER( TAwaitingStop, MeshMachine::TState, NetStateMachine::MState, IpProtoCpr::TContext) + virtual TBool Accept(); +DECLARE_SMELEMENT_FOOTER( TAwaitingStop ) + DECLARE_SMELEMENT_HEADER( TStoreAndFilterDeprecatedAndForwardStateChange, MeshMachine::TStateTransition, NetStateMachine::MStateTransition, IpProtoCpr::TContext ) virtual void DoL(); diff -r db85996de7c4 -r e9cc36e353d4 networkcontrol/ipnetworklayer/src/IPProtoCPR.cpp --- a/networkcontrol/ipnetworklayer/src/IPProtoCPR.cpp Mon Mar 15 12:46:10 2010 +0200 +++ b/networkcontrol/ipnetworklayer/src/IPProtoCPR.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -225,7 +225,7 @@ namespace IPProtoCprStopActivity { DECLARE_DEFINE_CUSTOM_NODEACTIVITY(ECFActivityStop, IPProtoCprStop, TCFServiceProvider::TStop, MeshMachine::CNodeRetryActivity::NewL) - FIRST_NODEACTIVITY_ENTRY(CoreNetStates::TAwaitingStop, CoreNetStates::TActiveOrNoTagBlockedByBindTo) + FIRST_NODEACTIVITY_ENTRY(IpProtoCpr::TAwaitingStop, CoreNetStates::TActiveOrNoTagBlockedByBindTo) THROUGH_NODEACTIVITY_ENTRY(KActiveTag, CoreNetStates::TCancelDataClientStart, MeshMachine::TNoTag) NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TStopSelf, CoreNetStates::TAwaitingDataClientStopped, CoreNetStates::TNoTagOrNoBearer) NODEACTIVITY_ENTRY(KNoTag, CoreNetStates::TSendStop, CoreNetStates::TAwaitingStopped, MeshMachine::TNoTag) @@ -755,7 +755,8 @@ { iTimerExpired = ETrue; CancelTimer(); - if (CountActivities(ECFActivityStop) == 0) + if (CountActivities(ECFActivityStop) == 0 && ++ CountActivities(ECFActivityDestroy) == 0) { RClientInterface::OpenPostMessageClose(Id(), TNodeCtxId(ECFActivityStop, Id()), TCFServiceProvider::TStop(KErrTimedOut).CRef()); } diff -r db85996de7c4 -r e9cc36e353d4 networkcontrol/ipnetworklayer/src/IPProtoCprStates.cpp --- a/networkcontrol/ipnetworklayer/src/IPProtoCprStates.cpp Mon Mar 15 12:46:10 2010 +0200 +++ b/networkcontrol/ipnetworklayer/src/IPProtoCprStates.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -221,6 +221,33 @@ } } + +DEFINE_SMELEMENT(TAwaitingStop, NetStateMachine::MState, IpProtoCpr::TContext) +TBool TAwaitingStop::Accept() + { + /* + Please note, in order for this to work, ESock needs to export the Accept function + of the CoreNetStates::TAwaitingStop. + */ + CoreNetStates::TAwaitingStop state(iContext); + if (state.Accept()) + { + if (iContext.Node().CountActivities(ECFActivityDestroy) == 0) + { + return ETrue; + } + else + { + //The messageId is cleared so the CoreNetStates::TAwaitingStop is not picking up this TStop message after this Accept has rejected it. + //If this activity is kicked off while there is a Destroy activity, most probably the phone will crash, as there will be a SelfStop + //which will arrive after the node has destructed. + iContext.iMessage.ClearMessageId(); + } + } + return EFalse; + } + + DEFINE_SMELEMENT(TAwaitingDataMonitoringNotification, NetStateMachine::MState, IpProtoCpr::TContext) TBool TAwaitingDataMonitoringNotification::Accept() { diff -r db85996de7c4 -r e9cc36e353d4 networkcontrol/ipnetworklayer/src/ipprotodeftscprstates.cpp --- a/networkcontrol/ipnetworklayer/src/ipprotodeftscprstates.cpp Mon Mar 15 12:46:10 2010 +0200 +++ b/networkcontrol/ipnetworklayer/src/ipprotodeftscprstates.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -264,6 +264,13 @@ DEFINE_SMELEMENT(TSendNetworkConfigured, NetStateMachine::MStateTransition, IPProtoDeftSCpr::TContext) void IPProtoDeftSCpr::TSendNetworkConfigured::DoL() { + TCFMessage::TStateChange& msg = message_cast(iContext.iMessage); + if (msg.iStateChange.iStage == KLinkLayerOpen) + { + // After network get configured if the last state change massage is KLinklayerOpen fwd the + // massage to control provider. + iContext.Node().PostToClients(TNodeCtxId(iContext.ActivityId(), iContext.NodeId()), iContext.iMessage, TClientType(TCFClientType::ECtrlProvider)); + } TCFIPProtoMessage::TNetworkConfigured resp(iContext.iNodeActivity->Error()); iContext.iNodeActivity->SetError(KErrNone); iContext.iNodeActivity->PostToOriginators(resp); diff -r db85996de7c4 -r e9cc36e353d4 networkprotocols/tcpipv4v6prt/data/tcpip.arm.ini --- a/networkprotocols/tcpipv4v6prt/data/tcpip.arm.ini Mon Mar 15 12:46:10 2010 +0200 +++ b/networkprotocols/tcpipv4v6prt/data/tcpip.arm.ini Thu Apr 01 00:00:09 2010 +0300 @@ -26,3 +26,6 @@ [ip] maxholdtime= 90 + +//Default TCP receive Window size 128 * 1024 = 128K, Optimal for 3G bearers +tcp_recv_buf = 131072 diff -r db85996de7c4 -r e9cc36e353d4 networkprotocols/tcpipv4v6prt/data/tcpip.eka2.ini --- a/networkprotocols/tcpipv4v6prt/data/tcpip.eka2.ini Mon Mar 15 12:46:10 2010 +0200 +++ b/networkprotocols/tcpipv4v6prt/data/tcpip.eka2.ini Thu Apr 01 00:00:09 2010 +0300 @@ -30,3 +30,6 @@ [tcp] tcp_alignopt= 1 + +//Default TCP receive Window size 128 * 1024 = 128K, Optimal for 3G bearers +tcp_recv_buf = 131072 \ No newline at end of file diff -r db85996de7c4 -r e9cc36e353d4 networkprotocols/tcpipv4v6prt/data/tcpip.wins.ini --- a/networkprotocols/tcpipv4v6prt/data/tcpip.wins.ini Mon Mar 15 12:46:10 2010 +0200 +++ b/networkprotocols/tcpipv4v6prt/data/tcpip.wins.ini Thu Apr 01 00:00:09 2010 +0300 @@ -26,3 +26,6 @@ [ip] maxholdtime= 90 + +//Default TCP receive Window size 128 * 1024 = 128K, Optimal for 3G bearers +tcp_recv_buf = 131072 diff -r db85996de7c4 -r e9cc36e353d4 networkprotocols/tcpipv4v6prt/inc/tcp.h --- a/networkprotocols/tcpipv4v6prt/inc/tcp.h Mon Mar 15 12:46:10 2010 +0200 +++ b/networkprotocols/tcpipv4v6prt/inc/tcp.h Thu Apr 01 00:00:09 2010 +0300 @@ -632,8 +632,10 @@ void ReadDestinationCache(); void StoreDestinationCache(); - - void DetachIfDead(); + + //TSW error:JHAA-82JBNG -- FIN retransmission + //Modifying the function to return TBool + TBool DetachIfDead(); void DetachFromInterface(); /** diff -r db85996de7c4 -r e9cc36e353d4 networkprotocols/tcpipv4v6prt/src/tcp_sap.cpp --- a/networkprotocols/tcpipv4v6prt/src/tcp_sap.cpp Mon Mar 15 12:46:10 2010 +0200 +++ b/networkprotocols/tcpipv4v6prt/src/tcp_sap.cpp Thu Apr 01 00:00:09 2010 +0300 @@ -2580,9 +2580,15 @@ if (InState(ETcpFinWait1|ETcpClosing|ETcpLastAck)) { // If the server doesn't respond because of broken NAT/FW or other, don't keep interface up. - DetachIfDead(); + + //TSW error:JHAA-82JBNG -- FIN retransmission + //Depending on the function return value the decision to + //retransmitt FIN is decided + + TBool continue_send = DetachIfDead(); // Retransmit FIN - SendSegment(KTcpCtlFIN|KTcpCtlACK, iSND.UNA); + if(continue_send == EFalse) + SendSegment(KTcpCtlFIN|KTcpCtlACK, iSND.UNA); return; } @@ -2753,7 +2759,7 @@ // // Detach the SAP if the application has closed and we seem to keep resending stuff. // -void CProviderTCP6::DetachIfDead() +TBool CProviderTCP6::DetachIfDead() { if (iSockFlags.iRecvClose && iSockFlags.iSendClose && Protocol()->FinPersistency() && iBackoff >= Protocol()->FinPersistency()) @@ -2761,7 +2767,15 @@ LOG(Log::Printf(_L("\ttcp SAP[%u] Peer looks dead while %d bytes unacked data. Detach!"), (TInt)this, Min(iSND.NXT - iSND.UNA, iSockOutQLen))); DetachFromInterface(); + + //TSW error:JHAA-82JBNG -- FIN retransmission + //The FinPersistency value read from the tcpip.ini file determines + //the number of times FIN should be retransmitted + //Once we reach the maximum value the DetachFromInterface() is called + //and we return ETrue. + return ETrue; } + return EFalse; } void CProviderTCP6::DetachFromInterface()