telephonyprotocols/rawipnif/rawipnif2/src/BinderBase.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
child 42 3adadc800673
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 // This file implements the base class for the protocol interface classes.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include <nifmbuf.h>
       
    23 #include "BinderBase.h"
       
    24 #include "RawIP2Flow.h"
       
    25 #include "BcaController.h"
       
    26 
       
    27 CBinderBase::CBinderBase(CRawIP2Flow& aFlow, CBttLogger* aTheLogger)
       
    28 /**
       
    29  * Constructor
       
    30  *
       
    31  * @param aNifMain A pointer to CRawIPFlow
       
    32  */
       
    33 	:iFlow(&aFlow),
       
    34 	iTheLogger(aTheLogger),
       
    35 	iStarted(EFalse)
       
    36 	{	
       
    37 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
       
    38 	iIPTagHeader = new (ELeave) CIPTagHeader(iTheLogger);
       
    39 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
       
    40 	}
       
    41 
       
    42 CBinderBase::~CBinderBase()
       
    43 /**
       
    44  * Destructor
       
    45  */
       
    46 	{	
       
    47 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
       
    48 	delete iIPTagHeader;
       
    49 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
       
    50 	}
       
    51 
       
    52 #ifdef RAWIP_HEADER_APPENDED_TO_PACKETS
       
    53 void CBinderBase::SetType(TUint16 aType)
       
    54 {
       
    55 /**
       
    56  *	Used to specify the type of the IP header.
       
    57  */
       
    58 	_LOG_L1C1(_L8("CBinderBase::SetType"));
       
    59 	
       
    60 	iIPTagHeader->SetType(aType);	
       
    61 }
       
    62 #endif // RAWIP_HEADER_APPENDED_TO_PACKETS
       
    63 
       
    64 void CBinderBase::SetSender(BasebandChannelAdaptation2::MLowerDataSender* aLowerDataSender)
       
    65 	{
       
    66 	iLowerDataSender = aLowerDataSender;
       
    67 	}
       
    68 
       
    69 // from ESock::MLowerControl
       
    70 TInt CBinderBase::BlockFlow(MLowerControl::TBlockOption aOption)
       
    71 	{
       
    72 	
       
    73 	if(iFlow->GetBcaController())
       
    74 		{
       
    75 		if(iFlow->GetBcaController()->Bca())
       
    76 			{
       
    77 			if(aOption != MLowerControl::EEnableAllBinders)
       
    78 				{ // unblock flow
       
    79 				iFlow->GetBcaController()->Bca()->SetFlowControl(BasebandChannelAdaptation2::MBca2::EUnblockFlow);
       
    80 				}
       
    81 			else
       
    82 				{ //block flow
       
    83 				iFlow->GetBcaController()->Bca()->SetFlowControl(BasebandChannelAdaptation2::MBca2::EBlockFlow);
       
    84 				}
       
    85 			return KErrNone;
       
    86 			}
       
    87 		}
       
    88 	// MBca not ready
       
    89 	return KErrNotReady;
       
    90 	}
       
    91 	
       
    92 void CBinderBase::ChangeFlow(CRawIP2Flow& aNewFlow)
       
    93     {
       
    94     ASSERT(iFlow);
       
    95     iFlow = &aNewFlow;
       
    96     }
       
    97 
       
    98 ESock::MLowerDataSender* CBinderBase::Bind(ESock::MUpperDataReceiver* aUpperReceiver, ESock::MUpperControl* aUpperControl)
       
    99 /**
       
   100  * Binds TCP/IP protocol to Flow
       
   101  *
       
   102  * @param aUpperReceiver A pointer to Upper layer Receive class
       
   103  * @param aUpperControl A pointer to Upper layer control class
       
   104  */
       
   105 	{
       
   106     _LOG_L1C1(_L8("CBinderBase:\tBind()"));
       
   107 
       
   108 	iUpperReceiver = aUpperReceiver;
       
   109 	iUpperControl = aUpperControl;
       
   110 	return this;
       
   111 	}
       
   112 
       
   113 void CBinderBase::Unbind(ESock::MUpperDataReceiver* aUpperReceiver, ESock::MUpperControl* aUpperControl)
       
   114     {
       
   115 	_LOG_L1C1(_L8("CBinderBase:\tUnbind()"));
       
   116 	
       
   117 #ifndef _DEBUG
       
   118 	(void) aUpperReceiver;
       
   119 	(void) aUpperControl;
       
   120 #endif
       
   121 
       
   122 	ASSERT(aUpperReceiver == iUpperReceiver);
       
   123 	ASSERT(aUpperControl == iUpperControl);
       
   124 	iUpperReceiver = NULL;
       
   125 	iUpperControl = NULL;
       
   126 	}
       
   127 
       
   128 void CBinderBase::StartSending()
       
   129 /**
       
   130  * Indicates to the protocol layer that the NIF is ready to send packets.
       
   131  *
       
   132  * @param aProtocol A pointer to a protocol
       
   133  */
       
   134 	{
       
   135 	_LOG_L1C1(_L8("CBinderBase:\tStartSending()"));
       
   136 
       
   137 	if (!iStarted)
       
   138 		{
       
   139 		GetFlow().LinkLayerUp();
       
   140 		iStarted = ETrue;
       
   141 		}
       
   142 
       
   143 	// Default implementation.
       
   144 	// Uses iProtocol instead aProtocol.
       
   145 	iUpperControl->StartSending();
       
   146 	}
       
   147 
       
   148 void CBinderBase::Error(TInt aErr)
       
   149 /**
       
   150  * Indicates to the protocol layer that a fatal error has occured in the BCA.
       
   151  *
       
   152  * @param aProtocol A pointer to a protocol
       
   153  */
       
   154 	{
       
   155 	_LOG_L1C1(_L8("CBinderBase:\tError()"));
       
   156 
       
   157 	// Default implementation.
       
   158 	// Uses iProtocol instead aProtocol.
       
   159 	iUpperControl->Error(aErr);
       
   160 	}
       
   161 
       
   162 void CBinderBase::UpdateContextConfigL(const TPacketDataConfigBase& /*aConfig*/)
       
   163 /**
       
   164  * Method overidden by UpdateContextConfig on IPv4ProtocolIf class
       
   165  *
       
   166  * @param aConfig Not used
       
   167  */
       
   168 	{
       
   169 	// Default implementation does nothing.
       
   170 	}
       
   171 
       
   172 void CBinderBase::UpdateConnectionSpeed(TUint /*aConnectionSpeed*/)
       
   173 /**
       
   174  * Method overidden by UpdateConnectionSpeed on IPv4Binder class
       
   175  *
       
   176  * @param aConnectionSpeed Not used
       
   177  */
       
   178 	{
       
   179 	// Default implementation does nothing.
       
   180 	}