telephonyprotocols/rawipnif/inc/RawIPFlow.h
changeset 0 3553901f7fa8
child 7 fe8b59ab9fa0
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Defines the CRawIPFlow class, which provides a central point for the Flow
       
    15 // to communicate with NifMan and the BCA controller. This class creates an
       
    16 // interface to the IPv4 binder when it is required.
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22 */
       
    23 
       
    24 #ifndef RAWIPFLOW_H
       
    25 #define RAWIPFLOW_H
       
    26 
       
    27 #include <comms-infras/nifif.h>
       
    28 #include <networking/packetlogger.h>
       
    29 #include <in_sock.h>
       
    30 #include <comms-infras/ss_flowbinders.h>
       
    31 #include <comms-infras/ss_subconnflow.h>
       
    32 #include "BinderBase.h"
       
    33 #include "BcaIoController.h"
       
    34 #include "MControllerObserver.h"
       
    35 #include "bttlog.h"
       
    36 #include <comms-infras/linkmessages.h>		// for TLinkMessageId
       
    37 
       
    38 class CBttLogger;
       
    39 class CPacketLogger;
       
    40 class TRawIpAgentProvision;
       
    41 class CBCAProvision;
       
    42 
       
    43 class CRawIPFlow : public ESock::CSubConnectionFlowBase, public ESock::MFlowBinderControl,
       
    44 				   public MControllerObserver
       
    45 	{
       
    46 	friend class CRawIPFlowFactory;
       
    47 
       
    48 public:
       
    49 
       
    50     //-=========================================================
       
    51     // Methods for handling incoming SCPR messages
       
    52     //-=========================================================
       
    53     void StartFlowL();
       
    54 	void StopFlow(TInt aError);
       
    55 	void SubConnectionGoingDown();
       
    56 	void SubConnectionError(TInt aError);
       
    57 	void Destroy();
       
    58 	void Notification(TInt aNotificationId);
       
    59 
       
    60 	//-=========================================================
       
    61 	// CSubConnectionProviderBase methods
       
    62 	//-=========================================================
       
    63 	MFlowBinderControl* DoGetBinderControlL();
       
    64 
       
    65 	//-=========================================================
       
    66 	// Messages::ANode methods
       
    67 	//-=========================================================
       
    68 	virtual void ReceivedL(const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage);
       
    69 
       
    70 	//-=========================================================
       
    71 	// MFlowBinderControl methods
       
    72 	//-=========================================================
       
    73 	virtual ESock::MLowerControl* GetControlL(const TDesC8& aProtocol);
       
    74 	virtual ESock::MLowerDataSender* BindL(const TDesC8& aProtocol, ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl);
       
    75 	virtual void Unbind(ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl);
       
    76 	virtual CSubConnectionFlowBase* Flow(); //returns its own flow
       
    77 
       
    78     //-=========================================================
       
    79     // Custom methods
       
    80     //-=========================================================
       
    81     // provide compatability for classes using old CNifIfLink style API and PPP Internal Stop() calls
       
    82     void Stop(TInt aReason, MNifIfNotify::TAction aAction);
       
    83     // call from Binder - MLowerDataSender
       
    84 	ESock::MLowerDataSender::TSendResult Send(RMBufChain& aPdu, TUint aProtocol);
       
    85 
       
    86 	// Used to be :Pure virtuals inherited from MContextSmObserver
       
    87 	CBcaIoController* GetBcaController();
       
    88 	void UpdateContextState(RPacketContext::TContextStatus aState,	TInt aError);
       
    89 
       
    90 public: // Pure virtuals inherited from MRawIPNifObserverBase
       
    91 	virtual void InitialiseL(TInitialisationState aState, TInt aError);
       
    92 	virtual void ShutDown(TInitialisationState aState, TInt aError);
       
    93 
       
    94 	virtual CBinderBase* GetBinder();
       
    95 
       
    96 public: // Pure virtuals inherited from MControllerObserver
       
    97 	// Data going upstack
       
    98 	virtual void Process(RMBufChain& aPdu, TUint16 aProtocolCode);
       
    99 	// Flow Control unblocked
       
   100 	virtual void ResumeSending();
       
   101 
       
   102 public:
       
   103 	// Notify that link is Up/Down
       
   104 	void LinkLayerUp();
       
   105 	void LinkLayerDown(TInt aError);
       
   106 
       
   107 public:	// Send data to CBcaIoController
       
   108 	TInt SendPacket(RMBufChain& aPdu, TAny* /*aSource=0*/,
       
   109 		TUint16 /*aType=KIp4FrameType*/);
       
   110 
       
   111 public:	// Context status retrieval.
       
   112 	inline RPacketContext::TContextStatus GetContextStatus();
       
   113 
       
   114 protected:
       
   115 	CRawIPFlow(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf, CBttLogger* aTheLogger);
       
   116 	void ConstructL();
       
   117 	virtual ~CRawIPFlow();
       
   118 
       
   119 protected:
       
   120     class TBinderControlProxy : public ESock::MFlowBinderControl
       
   121         {
       
   122         public:
       
   123     	virtual ESock::MLowerControl* GetControlL(const TDesC8& aProtocol);
       
   124     	virtual ESock::MLowerDataSender* BindL(const TDesC8& aProtocol, ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl);
       
   125     	virtual void Unbind(ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl);
       
   126     	virtual CSubConnectionFlowBase* Flow(); //returns its own flow
       
   127     	CRawIPFlow& RawIPFlow()
       
   128         	{
       
   129         	ASSERT(iFlow);
       
   130         	return *iFlow;
       
   131         	}
       
   132 
       
   133         TBinderControlProxy(CRawIPFlow& aFlow)
       
   134         :iFlow(&aFlow)
       
   135             {
       
   136             }
       
   137 
       
   138         CRawIPFlow* iFlow;
       
   139         };
       
   140     TBinderControlProxy* iBinderControl;
       
   141 
       
   142 private:
       
   143 	void ProvisionConfig(const ESock::RMetaExtensionContainerC& aConfigData);
       
   144 	void DynamicProvisionConfigL();
       
   145 
       
   146 	// Utility functions
       
   147 	void PostProgressMessage(TInt aStage, TInt aError);
       
   148     void SendDataClientIdleIfNoClients();
       
   149 
       
   150 private:// Unowned
       
   151 	/** networking packet logger for debugging packets */
       
   152 	__PACKETLOG_DECLARATION_MEMBER;
       
   153 	CBttLogger* iTheLogger;
       
   154 
       
   155 	// Upstack bound protocol reference
       
   156 	CProtocolBase* iProtocol;
       
   157 
       
   158 	// The protocol to use (IPv4).Note: This is not owned by this class.
       
   159 	CBinderBase* iBinder;
       
   160 
       
   161 	const CBCAProvision* iProvision;						// pointer to BCA provisioning structure in AccessPointConfig
       
   162 	const CRawIpAgentConfig* iAgentProvision;				// pointer to Agent provisioning structure in AccessPointConfig
       
   163 	TInt iProvisionError;						// error code saved during processing of ProvisionConfig message
       
   164 
       
   165 private:// Owned
       
   166 	TInt iInitError;
       
   167 
       
   168 	RPacketContext::TContextStatus iContextStatus;
       
   169 
       
   170 	CBcaIoController* iBcaController;
       
   171 	TBool iStarting:1;
       
   172 	TBool iStarted:1;
       
   173 	TBool iStopping:1;
       
   174 	TBool iBlocked:1;
       
   175 	};
       
   176 
       
   177 inline RPacketContext::TContextStatus CRawIPFlow::GetContextStatus()
       
   178 /**
       
   179  * Returns Context status
       
   180  *
       
   181  * @return iContextStatus The context status
       
   182  */
       
   183 	{
       
   184 	return iContextStatus;
       
   185 	}
       
   186 
       
   187 #endif // RAWIPFlow_H