telephonyprotocols/rawipnif/inc/BcaIoController.h
branchRCL_3
changeset 7 fe8b59ab9fa0
parent 6 fc69e1e37771
child 8 3f227a47ad75
equal deleted inserted replaced
6:fc69e1e37771 7:fe8b59ab9fa0
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    24 
    24 
    25 #include <e32base.h>
    25 #include <e32base.h>
    26 #include <c32comm.h>
    26 #include <c32comm.h>
    27 #include <networking/bca.h>
    27 #include <networking/bca.h>
    28 #include <networking/bcafactory.h>
    28 #include <networking/bcafactory.h>
    29 
    29 // for the constants for sending/blocking
    30 #include "BcaController.h"
    30 #include <comms-infras/ss_flowbinders.h>
       
    31 #include "MControllerObserver.h"
       
    32 #include "Constants.h"
       
    33 
    31 using namespace BasebandChannelAdaptation;
    34 using namespace BasebandChannelAdaptation;
    32 
    35 
    33 class CBttLogger;
    36 class CBttLogger;
    34 class CSender;
    37 class CSender;
    35 class CReceiver;
    38 class CReceiver;
    49 
    52 
    50 
    53 
    51 /** 
    54 /** 
    52 @internalComponent 
    55 @internalComponent 
    53 */	
    56 */	
    54 class CBcaIoController : public CBcaController
    57 class CBcaIoController : public CBase
    55 	{
    58 	{
    56 public:
    59 public:
    57 	CBcaIoController(MControllerObserver& aObserver, CBttLogger* aTheLogger);
       
    58 	static CBcaIoController* NewL(MControllerObserver& aObserver, CBttLogger* aTheLogger);
    60 	static CBcaIoController* NewL(MControllerObserver& aObserver, CBttLogger* aTheLogger);
    59 	void ConstructL();
    61 	void ConstructL();
    60 	~CBcaIoController();
    62 	~CBcaIoController();
    61 
    63 
    62 public:
       
    63 	void StartL();
    64 	void StartL();
    64 	void Stop(TInt aError = KErrNone);
    65 	void Stop(TInt aError = KErrNone);
    65 
    66 	ESock::MLowerDataSender::TSendResult Send(RMBufChain& aPdu);
    66 public:  // Process Down/Up stack data packets 
    67 	void SendComplete();
    67 	void BcaProcess(TDesC8& aPdu);
    68 	
    68 	void BcaSend(RMBufChain& aPdu);
       
    69 	void BcaSendComplete();
       
    70 
       
    71 public:
       
    72 	inline CSender& Sender();
    69 	inline CSender& Sender();
    73 	inline CReceiver& Receiver();
    70 	inline CReceiver& Receiver();
    74 	inline TUint Nsapi();
    71 	inline TUint Nsapi();
    75 	void SetBcaStackAndName(const TDesC& aBcaStack, const TDesC& aBcaName);
    72 	void SetBcaStackAndName(const TDesC& aBcaStack, const TDesC& aBcaName);
    76 	inline TPtrC BcaStack()const;
    73 	inline TPtrC BcaStack()const;
    79 	inline void SetBca(MBca* aBca);
    76 	inline void SetBca(MBca* aBca);
    80 	inline void SetPort(const TDesC& aPortName);
    77 	inline void SetPort(const TDesC& aPortName);
    81 	inline TPtrC Port() const;
    78 	inline TPtrC Port() const;
    82 	inline void SetIapId(TUint32 aIapId);
    79 	inline void SetIapId(TUint32 aIapId);
    83 	inline TUint32 IapId();
    80 	inline TUint32 IapId();
    84 	TInt BcaSendBufferLength();
    81     inline void BlockSending(void) { iFlowBlocked = ETrue; }
    85 	
    82     void ResumeSending();
       
    83     
       
    84     // Get the NIF reference.
       
    85     inline MControllerObserver& GetObserver() { return iObserver; }
       
    86     
       
    87 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
       
    88     // tag headers
       
    89     void SetType(TUint16 aType);
       
    90     void AddHeader(TDes8& aDes);
       
    91     TUint16 RemoveHeader(RMBufChain& aPdu);
       
    92 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
       
    93     
       
    94 protected:
       
    95     CBttLogger* iTheLogger;
       
    96     TInt iMaxTxPacketSize;
       
    97     TInt iMaxRxPacketSize;
       
    98     
    86 private:
    99 private:
    87 	void InitialiseBcaL();
   100     
    88 
   101     CBcaIoController(MControllerObserver& aObserver, CBttLogger* aTheLogger);
    89 private: // Flow Control
   102     
    90 	void ResumeSending();
   103     enum TSendState
    91 
   104         {
    92 private: // Unowned data.
   105         EIdle,
    93 	/** Pointer to the BCA */
   106         ESending,
    94    	MBca* iMBca;
   107         EShuttingDown
    95 
   108         };
    96 	/** used to send data*/
   109        
    97 	CSender* iSender;
   110     enum TInitialisationState
    98 	/** used to receive data*/
   111         {
    99 	CReceiver* iReceiver;
   112         EStart,
   100 	/** used to load, open and close the BCA*/
   113         EBcaController,
   101 	CBcaControl* iLoader;
   114         EInitialised
   102 	/** IAP ID used to open CommDB*/
   115         };
   103 	TUint32 iIapId;
   116     
   104 	/** Bca name*/
   117     // Flow control flags
   105 	TPtrC iBcaName;
   118     TSendState iSendState;
   106 	/** Bca Stack*/
   119     
   107 	TPtrC iBcaStack;
   120     inline void SendState(TSendState aState) { iSendState = aState; }
   108 	/** CommPort Name*/
   121     
   109 	TPtrC iCommPort;
   122     
       
   123     // uplink flow control
       
   124     TBool iFlowBlocked;
       
   125 
       
   126     // Buffer control
       
   127     inline TBool IsSendQueueEmpty() { return iSendQueue.IsEmpty(); }
       
   128     inline TBool IsSendQueueFull() { return (iNumPacketsInSendQueue >= iMaxSendQueueLen) ? ETrue : EFalse; }
       
   129 
       
   130     inline void AppendToSendQueue(RMBufChain& aPdu) 
       
   131         {  
       
   132         iSendQueue.Append(aPdu);
       
   133         iNumPacketsInSendQueue++; 
       
   134         }
       
   135  
       
   136     inline TBool RemoveFromSendQueue(RMBufChain& aPdu) 
       
   137         {
       
   138         TBool ret = iSendQueue.Remove(aPdu);
       
   139          if(ret)
       
   140              {
       
   141              iNumPacketsInSendQueue--;
       
   142              }
       
   143          return ret;
       
   144         }
       
   145     
       
   146     /** The internal packet buffer */
       
   147     RMBufPktQ iSendQueue;
       
   148     /** The maximum number of packets that we want in an internal queue */
       
   149     TUint iMaxSendQueueLen;
       
   150     /** Current number of packets in the internal packet buffer */
       
   151     TInt iNumPacketsInSendQueue;
       
   152     
       
   153     MControllerObserver& iObserver;
       
   154     
       
   155     // Unowned data.
       
   156     /** Pointer to the BCA */
       
   157     MBca* iMBca;
       
   158     
       
   159     /** used to send data*/
       
   160     CSender* iSender;
       
   161     /** used to receive data*/
       
   162     CReceiver* iReceiver;
       
   163     /** used to load, open and close the BCA*/
       
   164     CBcaControl* iLoader;
       
   165     /** IAP ID used to open CommDB*/
       
   166     TUint32 iIapId;
       
   167     /** Bca name*/
       
   168     TPtrC iBcaName;
       
   169     /** Bca Stack*/
       
   170     TPtrC iBcaStack;
       
   171     /** CommPort Name*/
       
   172     TPtrC iCommPort;
       
   173 
       
   174 
   110 	};
   175 	};
   111 
   176 
   112 inline CSender& CBcaIoController::Sender()
   177 inline CSender& CBcaIoController::Sender()
   113 /**
   178 /**
   114  * Returns reference to CSender object
   179  * Returns reference to CSender object