telephonyprotocols/rawipnif/inc/BcaIoController.h
changeset 23 6b1d113cdff3
parent 20 244d7c5f118e
child 24 6638e7f4bd8f
child 42 3adadc800673
equal deleted inserted replaced
20:244d7c5f118e 23:6b1d113cdff3
     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);
    60 	static CBcaIoController* NewL(MControllerObserver& aObserver, CBttLogger* aTheLogger);	
    58 	static CBcaIoController* NewL(MControllerObserver& aObserver, CBttLogger* aTheLogger);
       
    59 	void ConstructL();
       
    60 	~CBcaIoController();
    61 	~CBcaIoController();
    61 
    62 
    62 public:
       
    63 	void StartL();
    63 	void StartL();
    64 	void Stop(TInt aError = KErrNone);
    64 	void Stop(TInt aError = KErrNone);
    65 
    65 	ESock::MLowerDataSender::TSendResult Send(RMBufChain& aPdu);
    66 public:  // Process Down/Up stack data packets 
    66 	void SendComplete();
    67 	void BcaProcess(TDesC8& aPdu);
    67 	
    68 	void BcaSend(RMBufChain& aPdu);
       
    69 	void BcaSendComplete();
       
    70 
       
    71 public:
       
    72 	inline CSender& Sender();
    68 	inline CSender& Sender();
    73 	inline CReceiver& Receiver();
    69 	inline CReceiver& Receiver();
    74 	inline TUint Nsapi();
    70 	inline TUint Nsapi();
    75 	void SetBcaStackAndName(const TDesC& aBcaStack, const TDesC& aBcaName);
    71 	void SetBcaStackAndName(const TDesC& aBcaStack, const TDesC& aBcaName);
    76 	inline TPtrC BcaStack()const;
    72 	inline TPtrC BcaStack()const;
    79 	inline void SetBca(MBca* aBca);
    75 	inline void SetBca(MBca* aBca);
    80 	inline void SetPort(const TDesC& aPortName);
    76 	inline void SetPort(const TDesC& aPortName);
    81 	inline TPtrC Port() const;
    77 	inline TPtrC Port() const;
    82 	inline void SetIapId(TUint32 aIapId);
    78 	inline void SetIapId(TUint32 aIapId);
    83 	inline TUint32 IapId();
    79 	inline TUint32 IapId();
    84 	TInt BcaSendBufferLength();
    80     inline void BlockSending(void) { iFlowBlocked = ETrue; }
    85 	
    81     void ResumeSending();
       
    82     
       
    83     // Get the NIF reference.
       
    84     inline MControllerObserver& GetObserver() { return iObserver; }
       
    85     
       
    86 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
       
    87     // tag headers
       
    88     void SetType(TUint16 aType);
       
    89     void AddHeader(TDes8& aDes);
       
    90     TUint16 RemoveHeader(RMBufChain& aPdu);
       
    91 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
       
    92     
       
    93 protected:
       
    94     CBttLogger* iTheLogger;
       
    95     TUint iMaxTxPacketSize;
       
    96     TUint iMaxRxPacketSize;
       
    97     
    86 private:
    98 private:
    87 	void InitialiseBcaL();
    99     
    88 
   100     CBcaIoController(MControllerObserver& aObserver, CBttLogger* aTheLogger);
    89 private: // Flow Control
   101     void ConstructL();
    90 	void ResumeSending();
   102     
    91 
   103     enum TSendState
    92 private: // Unowned data.
   104         {
    93 	/** Pointer to the BCA */
   105         EIdle,
    94    	MBca* iMBca;
   106         ESending,
    95 
   107         EShuttingDown
    96 	/** used to send data*/
   108         };
    97 	CSender* iSender;
   109        
    98 	/** used to receive data*/
   110     enum TInitialisationState
    99 	CReceiver* iReceiver;
   111         {
   100 	/** used to load, open and close the BCA*/
   112         EStart,
   101 	CBcaControl* iLoader;
   113         EBcaController,
   102 	/** IAP ID used to open CommDB*/
   114         EInitialised
   103 	TUint32 iIapId;
   115         };
   104 	/** Bca name*/
   116     
   105 	TPtrC iBcaName;
   117     // Flow control flags
   106 	/** Bca Stack*/
   118     TSendState iSendState;
   107 	TPtrC iBcaStack;
   119     
   108 	/** CommPort Name*/
   120     inline void SendState(TSendState aState) { iSendState = aState; }
   109 	TPtrC iCommPort;
   121     
       
   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