networkcontrol/ipnetworklayer/inc/flow.h
changeset 0 af10295192d8
child 10 c64cefac6e99
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 /**
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Header file for the Default SubConnection Flow
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file deftflow.h
       
    24 */
       
    25 
       
    26 #ifndef IPSHIMFLOW_H_INCLUDED_
       
    27 #define IPSHIMFLOW_H_INCLUDED_
       
    28 
       
    29 #include <e32base.h>
       
    30 #include <e32std.h>
       
    31 #include <comms-infras/ss_subconnflow.h>
       
    32 #include <comms-infras/ss_flowbinders.h>
       
    33 #include <comms-infras/ss_protflow.h>
       
    34 #include <cflog.h>
       
    35 
       
    36 #if defined __CFLOG_ACTIVE || defined SYMBIAN_TRACE_ENABLE
       
    37 // CommsDebugUtility logging tags. Use them to enable tracing for ReferenceSCPR
       
    38 _LIT8(KIPProtoTag1,"IPProto");
       
    39 _LIT8(KIPProtoTag2,"IPProtoFlow");
       
    40 #endif
       
    41 
       
    42 class CIPShimIfBase;
       
    43 class MNifIfUser;
       
    44 class CIPShimIncoming;
       
    45 
       
    46 class CIPShimSubConnectionFlow;
       
    47 class CAsyncBinderClose : public CAsyncOneShot
       
    48 /**
       
    49 Class used to asyncronously close binders.
       
    50 
       
    51 Closing a binder can result in it being destroyed, so this asynchronous callback is
       
    52 used to avoid destroying a binder in the same stack frame as a binder Error() upcall.
       
    53 */
       
    54 	{
       
    55 public:
       
    56 	explicit CAsyncBinderClose(CIPShimSubConnectionFlow& aFlow);
       
    57 	void RunL();
       
    58 
       
    59 private:
       
    60 	CIPShimSubConnectionFlow& iFlow;
       
    61 	};
       
    62 
       
    63 class CIPProtoBinder;
       
    64 
       
    65 //-=====================================================================
       
    66 // IPShim PINT and PINT factory
       
    67 //-=====================================================================
       
    68 class CIPShimProtocolIntf : public ESock::CProtocolIntfBase
       
    69 /**
       
    70 @internalTechnology
       
    71 */
       
    72 	{
       
    73     friend class CIPShimSubConnectionFlow;
       
    74 	friend class CIPShimIfBase;
       
    75 
       
    76 public:
       
    77 	CIPShimProtocolIntf(ESock::CProtocolIntfFactoryBase& aFactory,const Messages::TNodeId& aCprId);
       
    78 
       
    79 	// from CProtocolIntfBase
       
    80 	virtual void DoFlowCreated(ESock::CSubConnectionFlowBase& aFlow);
       
    81 	virtual void DoFlowBeingDeleted(ESock::CSubConnectionFlowBase& aFlow);
       
    82 
       
    83 	void OpenRoute();
       
    84 	void CloseRoute();
       
    85 
       
    86 	~CIPShimProtocolIntf();
       
    87 
       
    88 private:
       
    89 	CIPShimIfBase* FindOrCreateNifL(const TDesC8& aProtocol, const TConnectionInfo& aConnectionInfo);
       
    90 	void NifDisappearing(CIPShimIfBase* aNif);
       
    91 
       
    92 private:
       
    93 	RPointerArray<CIPShimIfBase> iNifs;
       
    94 	};
       
    95 
       
    96 class CIPShimProtocolIntfFactory : public ESock::CProtocolIntfFactoryBase
       
    97 /**
       
    98 @internalTechnology
       
    99 */
       
   100 	{
       
   101 public:
       
   102 	static CIPShimProtocolIntfFactory* NewL(TUid aFactoryId, ESock::CProtocolIntfFactoryContainer& aParentContainer);
       
   103 	virtual ESock::CProtocolIntfBase* DoCreateProtocolIntfL(ESock::TFactoryQueryBase& aQuery);
       
   104 	CIPShimProtocolIntfFactory(TUid aFactoryId, ESock::CProtocolIntfFactoryContainer& aParentContainer);
       
   105 	};
       
   106 
       
   107 
       
   108 class CIPShimSubConnectionFlow : public ESock::CSubConnectionFlowBase,
       
   109                                  public ESock::MFlowBinderControl,
       
   110                                  public ESock::MLowerControl
       
   111 /**
       
   112 IP Shim flow.
       
   113 
       
   114 @internalComponent
       
   115 */
       
   116 	{
       
   117 	friend class CIPShimFlowFactory;
       
   118 	friend class CIPProtoBinder;
       
   119 
       
   120 //	struct TBinderPair;
       
   121 
       
   122 
       
   123 public:
       
   124 	// Unidirectional internal interface from Binder classes to Flow.
       
   125 	virtual void BinderReady();
       
   126 	virtual void SendMessageToSubConnProvider(const Messages::TSignatureBase& aCFMessage);
       
   127 	virtual const Messages::TNodeId& GetCommsId();
       
   128 	void OpenRoute();
       
   129 	void CloseRoute();
       
   130 
       
   131 	// MIpDataMonitoringNotifications
       
   132 	virtual void PostConnDataReceivedThresholdReached(TUint aVolume);
       
   133 	virtual void PostConnDataSentThresholdReached(TUint aVolume);
       
   134 	virtual void PostSubConnDataReceivedThresholdReached(TUint aVolume);
       
   135 	virtual void PostSubConnDataSentThresholdReached(TUint aVolume);
       
   136 
       
   137 
       
   138     void PostClientIdleIfIdle();
       
   139 	void BinderError(TInt aError, CIPProtoBinder* aIf);
       
   140 	void AsyncBinderClose();
       
   141 
       
   142 
       
   143     //MFlowBinderControl,
       
   144 	virtual MLowerControl* GetControlL(const TDesC8& aProtocol);
       
   145 	virtual ESock::MLowerDataSender* BindL(const TDesC8& aProtocol, ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl);
       
   146 	virtual void Unbind( ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl);
       
   147 	virtual CSubConnectionFlowBase* Flow();
       
   148 
       
   149     //MLowerControl
       
   150 	virtual TInt Control(TUint aLevel, TUint aName, TDes8& aOption);
       
   151 
       
   152 protected:
       
   153 	// from Messages::ANode
       
   154 	virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage);
       
   155 
       
   156 	CIPShimSubConnectionFlow(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf);
       
   157 	~CIPShimSubConnectionFlow();
       
   158 	ESock::MFlowBinderControl* DoGetBinderControlL();
       
   159 
       
   160 	// Functions for processing SCPR messages.
       
   161 	virtual void StartFlowL();
       
   162 	virtual void StopFlow(TInt aError);
       
   163 	virtual void ProcessProvisionConfigL();
       
   164 	virtual void Destroy();
       
   165 	virtual void BindToL(const Messages::TNodeId& aCommsBinder);
       
   166 #ifdef SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
       
   167 	virtual void UpdateIpAddressInfoL(ESock::TCFScpr::TSetParamsRequest& aParamReq);
       
   168 #else
       
   169 	virtual void UpdateIpAddressInfoL(ESock::TCFScpr::TParamsRequest& aParamReq);
       
   170 #endif // SYMBIAN_ADAPTIVE_TCP_RECEIVE_WINDOW
       
   171 	// Utility functions for sending messages to SCPR
       
   172 	void PostDataClientStartedIfReady();
       
   173 	void PostDataClientStoppedIfReady();
       
   174 	void Error(const TInt aError);
       
   175 
       
   176 
       
   177     TInt SetConnectionInfo(const TConnectionInfo& aInfo);
       
   178    	void InitialiseDataMonitoringL(CIPShimIfBase* intf);
       
   179 private:
       
   180 	static void CleanupBinderListAppend(TAny*);
       
   181 	static void CleanupSignalNewInterface(TAny*);
       
   182 	static void CleanupBindToLower(TAny*);
       
   183 	inline void SetCleanupError(TInt aError);
       
   184 	inline TInt CleanupError();
       
   185 
       
   186 	void CreateBinderL(const TDesC8& aProtocol, MFlowBinderControl* aBinderControl);
       
   187 	TInt SetProtocolList(const TDesC8& aProtocolList);
       
   188 
       
   189 	void MarkAllBindersForClosure();
       
   190 	inline void MarkBinderForClosure(CIPProtoBinder* aBinder);
       
   191 	void CloseMarkedBinders();
       
   192 	void SignalInterfaceDownOnAllBinders(TInt aError);
       
   193 
       
   194 	inline CIPShimProtocolIntf* ProtocolIntf();
       
   195 
       
   196 private:
       
   197 	RPointerArray<CIPProtoBinder> iBinderList;
       
   198     TInt iCleanupError;
       
   199     // iAsyncBinderClose is pre-allocated as KErrNoMemory recovery is complex in the situations it is needed
       
   200 	CAsyncBinderClose iAsyncBinderClose;
       
   201 	TInt  iStopCode;
       
   202 
       
   203 public:
       
   204 	RBuf8 iConnectionInfo;
       
   205     TPtrC8 iProtocolList;		// pointer to protocol list string in provisioning information
       
   206     TInt iBindCallCount;
       
   207 
       
   208 private:
       
   209     TBool iBinderReady:1;
       
   210     TBool iStarting:1;
       
   211     TBool iStarted:1;
       
   212 	TBool iDestroyPending:1;
       
   213 	};
       
   214 
       
   215 
       
   216 // =================================================================================
       
   217 //
       
   218 // Other inline methods
       
   219 //
       
   220 
       
   221 void CIPShimSubConnectionFlow::SetCleanupError(TInt aError)
       
   222 	{
       
   223 	iCleanupError = aError;
       
   224 	}
       
   225 
       
   226 TInt CIPShimSubConnectionFlow::CleanupError()
       
   227 	{
       
   228 	return iCleanupError;
       
   229 	}
       
   230 
       
   231 CIPShimProtocolIntf* CIPShimSubConnectionFlow::ProtocolIntf()
       
   232 	{
       
   233 	ASSERT(iProtocolIntf);
       
   234 	return static_cast<CIPShimProtocolIntf*>(iProtocolIntf);
       
   235 	}
       
   236 
       
   237 // ==========================================================================================
       
   238 //
       
   239 // Flow Factory
       
   240 //
       
   241 
       
   242 const TInt KIPShimFlowImplUid = 0x10281C36;
       
   243 
       
   244 class CIPShimFlowFactory : public ESock::CSubConnectionFlowFactoryBase
       
   245 /**
       
   246 IP Shim flow factory.
       
   247 
       
   248 @internalComponent
       
   249 */
       
   250 	{
       
   251 public:
       
   252 	static CIPShimFlowFactory* NewL(TAny* aConstructionParameters);
       
   253 	virtual ESock::CSubConnectionFlowBase* DoCreateFlowL(ESock::CProtocolIntfBase* aProtocolIntf, ESock::TFactoryQueryBase& aQuery);
       
   254 	virtual ESock::CProtocolIntfFactoryBase* CreateProtocolIntfFactoryL(ESock::CProtocolIntfFactoryContainer& aParentContainer);
       
   255     virtual ~CIPShimFlowFactory();
       
   256 
       
   257 protected:
       
   258 	CIPShimFlowFactory(TUid aFactoryId, ESock::CSubConnectionFlowFactoryContainer& aParentContainer);
       
   259 
       
   260 	};
       
   261 
       
   262 #endif