telephonyprotocols/rawipnif/rawipnif2/src/BcaController.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     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".
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20 */
    20 */
    21 
    21 
       
    22 
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "BcaControllerTraces.h"
       
    26 #endif
       
    27 
    22 #include <e32uid.h>
    28 #include <e32uid.h>
    23 #include <nifmbuf.h>
    29 #include <nifmbuf.h>
    24 
    30 
    25 #include "Constants.h"
    31 #include "Constants.h"
    26 #include "BcaController.h"
    32 #include "BcaController.h"
    27 
    33 
    28 CBcaController::CBcaController(CRawIP2Flow& aRawIPFlow,CBttLogger* aTheLogger)
    34 CBcaController::CBcaController(CRawIP2Flow& aRawIPFlow)
    29 /**
    35 /**
    30  * Constructor. Performs standard active object initialisation.
    36  * Constructor. Performs standard active object initialisation.
    31  *
    37  *
    32  * @param aRawIPFlow Reference to the RawIp2Flow
    38  * @param aRawIPFlow Reference to the RawIp2Flow
    33  * @param aTheLogger The logging object
    39  *
    34  */
    40  */
    35 	: CActive(EPriorityStandard), 	  
    41 	: CActive(EPriorityStandard), 	  
    36 	  iTheLogger(aTheLogger),	 
       
    37 	  iMBca(NULL),	  
    42 	  iMBca(NULL),	  
    38 	  iState(EIdling),
    43 	  iState(EIdling),
    39 	  iRawIPFlow(aRawIPFlow),
    44 	  iRawIPFlow(aRawIPFlow),
    40 	  iUpperControl(NULL),
    45 	  iUpperControl(NULL),
    41 	  iUpperDataReceiver(NULL),	 
    46 	  iUpperDataReceiver(NULL),	 
    43 	  iBcaParams(NULL)
    48 	  iBcaParams(NULL)
    44 	{
    49 	{
    45 	CActiveScheduler::Add(this);
    50 	CActiveScheduler::Add(this);
    46 	}
    51 	}
    47 	 
    52 	 
    48 CBcaController* CBcaController::NewL(CRawIP2Flow& aRawIPFlow,CBttLogger* aTheLogger)
    53 CBcaController* CBcaController::NewL(CRawIP2Flow& aRawIPFlow)
    49 /**
    54 /**
    50  * Two-phase constructor. Creates a new CBcaController object, performs 
    55  * Two-phase constructor. Creates a new CBcaController object, performs 
    51  * second-phase construction, then returns it.
    56  * second-phase construction, then returns it.
    52  *
    57  *
    53  * @param aRawIPFlow Reference to the RawIp2Flow
    58  * @param aRawIPFlow Reference to the RawIp2Flow
    54  * @param aTheLogger The logging object
       
    55  * @return A newly constructed CBcaController object
    59  * @return A newly constructed CBcaController object
    56  */
    60  */
    57 	{
    61 	{
    58 	CBcaController* self = new (ELeave) CBcaController(aRawIPFlow,aTheLogger);
    62 	CBcaController* self = new (ELeave) CBcaController(aRawIPFlow);
    59 	CleanupStack::PushL(self);
    63 	CleanupStack::PushL(self);
    60 	self->ConstructL();
    64 	self->ConstructL();
    61 	CleanupStack::Pop(self);
    65 	CleanupStack::Pop(self);
    62 	return self;
    66 	return self;
    63 	}
    67 	}
    65 void CBcaController::ConstructL()
    69 void CBcaController::ConstructL()
    66 /**
    70 /**
    67  * Second-phase constructor. Creates all the state objects it owns.
    71  * Second-phase constructor. Creates all the state objects it owns.
    68  */
    72  */
    69 	{
    73 	{
    70 	_LOG_L1C1(_L8("CBcaController::ConstructL"));
    74 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_CONSTRUCTL_1, "CBcaController::ConstructL");
    71 	
    75 	
    72 	}
    76 	}
    73   
    77   
    74  
    78  
    75 CBcaController::~CBcaController()
    79 CBcaController::~CBcaController()
    90 /**
    94 /**
    91  *  AO async callback method. Called after request is completed. 
    95  *  AO async callback method. Called after request is completed. 
    92  *  
    96  *  
    93  */
    97  */
    94 	{
    98 	{
    95 	_LOG_L1C1(_L8("CBcaControl::RunL() called"));
    99 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_1, "CBcaControl::RunL() called");
    96 	switch (iState)
   100 	switch (iState)
    97 		{
   101 		{
    98 		//in this state, Ioctl is called to set IAP ID, check the result of
   102 		//in this state, Ioctl is called to set IAP ID, check the result of
    99 		// Ioctl, then either set the BCA stack with another Ioctl call, 
   103 		// Ioctl, then either set the BCA stack with another Ioctl call, 
   100 		// open the BCA (if there's no BCA stack to set), or stop the NIF.
   104 		// open the BCA (if there's no BCA stack to set), or stop the NIF.
   102 			{
   106 			{
   103 			if(iStatus == KErrNone || iStatus == KErrNotSupported)
   107 			if(iStatus == KErrNone || iStatus == KErrNotSupported)
   104 				{
   108 				{
   105 				if(iStatus == KErrNotSupported)
   109 				if(iStatus == KErrNotSupported)
   106 					{
   110 					{
   107 					_LOG_L1C1(_L8("This BCA does not support IAPID set"));
   111 					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_2, "This BCA does not support IAPID set");
   108 					}
   112 					}
   109 				else
   113 				else
   110 					{
   114 					{
   111 					_LOG_L2C1(_L8("This BCA supports IAPID set"));
   115 					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_3, "This BCA supports IAPID set");
   112 					}
   116 					}
   113 				
   117 				
   114 				TPtrC bcaStack = iBCAProvisionConfig->GetBCAStack();
   118 				TPtrC bcaStack = iBCAProvisionConfig->GetBCAStack();
   115 				if(bcaStack.Length())
   119 				if(bcaStack.Length())
   116 					{
   120 					{
   126 				iState = EIAPSet;
   130 				iState = EIAPSet;
   127 				SetActive();	
   131 				SetActive();	
   128 				}
   132 				}
   129 			else
   133 			else
   130 				{
   134 				{
   131 				_LOG_L1C2(_L8("ERROR in BCA IAPID set = %d"), iStatus.Int());
   135 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_4, "ERROR in BCA IAPID set = %d", iStatus.Int());
   132 				Stop(iStatus.Int());
   136 				Stop(iStatus.Int());
   133 				}
   137 				}
   134 			
   138 			
   135 			break;
   139 			break;
   136 			}			
   140 			}			
   140 			{
   144 			{
   141 			if(iStatus == KErrNotSupported || iStatus == KErrNone)
   145 			if(iStatus == KErrNotSupported || iStatus == KErrNone)
   142 				{
   146 				{
   143 				if(iStatus == KErrNotSupported)
   147 				if(iStatus == KErrNotSupported)
   144 					{
   148 					{
   145 					_LOG_L1C1(_L8("This BCA does not support BCA stacking"));
   149 					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_5, "This BCA does not support BCA stacking");
   146 					}
   150 					}
   147 				else
   151 				else
   148 					{
   152 					{
   149 					_LOG_L2C1(_L8("This BCA supports BCA stacking"));
   153 					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_6, "This BCA supports BCA stacking");
   150 					}
   154 					}
   151 				iBcaParams = new(ELeave) MBca2::TBcaParams(const_cast<CBCAProvision*>(iBCAProvisionConfig)->GetCommsPond(), iBCAProvisionConfig->GetPortName());
   155 				iBcaParams = new(ELeave) MBca2::TBcaParams(const_cast<CBCAProvision*>(iBCAProvisionConfig)->GetCommsPond(), iBCAProvisionConfig->GetPortName());
   152 			
   156 			
   153 				TInt aErr = iMBca->Open(*iUpperControl,*iUpperDataReceiver,*iBcaParams);
   157 				TInt aErr = iMBca->Open(*iUpperControl,*iUpperDataReceiver,*iBcaParams);
   154 				if ( aErr != KErrNone)
   158 				if ( aErr != KErrNone)
   155 					{					
   159 					{					
   156 					_LOG_L2C2(_L8("ERROR in BCA Open = %d"), aErr);
   160 					OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_7, "ERROR in BCA Open = %d", aErr);
   157 					Stop(iStatus.Int());
   161 					Stop(iStatus.Int());
   158 					iState = EIdling;
   162 					iState = EIdling;
   159 					}
   163 					}
   160 				else
   164 				else
   161 					{
   165 					{
   162 					iMBca->Start();					
   166 					iMBca->Start();					
   163 					}
   167 					}
   164 				}
   168 				}
   165 			else
   169 			else
   166 				{
   170 				{
   167 				_LOG_L2C2(_L8("ERROR in BCA stack set = %d"), iStatus.Int());
   171 				OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_8, "ERROR in BCA stack set = %d", iStatus.Int());
   168 				Stop(iStatus.Int());
   172 				Stop(iStatus.Int());
   169 				}
   173 				}
   170 			break;
   174 			break;
   171 			}
   175 			}
   172 		// Wrong state.
   176 		// Wrong state.
   173 		default:
   177 		default:
   174 			{
   178 			{
   175 			_LOG_L1C1(_L8("ERROR CBcaControl::RunL(): Unknown state"));
   179 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_9, "ERROR CBcaControl::RunL(): Unknown state");
   176 			_BTT_PANIC(KNifName, KBcaUnkownState);
   180 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_RUNL_10, "PANIC: %S %d", KNifName, KBcaUnkownState);
       
   181 			User::Panic(KNifName, KBcaUnkownState);
   177 			break;
   182 			break;
   178 			}
   183 			}
   179 		}
   184 		}
   180 
   185 
   181 	}
   186 	}
   183 void CBcaController::DoCancel()
   188 void CBcaController::DoCancel()
   184 /**
   189 /**
   185  *	cancel active request. 
   190  *	cancel active request. 
   186  */
   191  */
   187 	{
   192 	{
   188 	_LOG_L1C1(_L8("CBcaControl::DoCancel called."));
   193 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_DOCANCEL_1, "CBcaControl::DoCancel called.");
   189 	_LOG_L2C2(_L8("iState value is %d"), iState);
   194 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_DOCANCEL_2, "iState value is %d", iState);
   190 	switch (iState)
   195 	switch (iState)
   191 		{
   196 		{
   192 		case EIdling:
   197 		case EIdling:
   193 		case EIAPSet:
   198 		case EIAPSet:
   194 			if(iMBca)
   199 			if(iMBca)
   196 				iMBca->CancelControl();
   201 				iMBca->CancelControl();
   197 				}
   202 				}
   198 			iState = EIdling;
   203 			iState = EIdling;
   199 			break;
   204 			break;
   200 		default:
   205 		default:
   201 			_LOG_L2C1(_L8("ERROR CBcaControl::DoCancel(): Unknown state"));
   206 			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_DOCANCEL_3, "ERROR CBcaControl::DoCancel(): Unknown state");
   202 			_BTT_PANIC(KNifName, KBcaUnkownState);
   207 			OstTraceDefExt2(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_DOCANCEL_4, "PANIC: %S %d", KNifName, KBcaUnkownState);
       
   208 			User::Panic(KNifName, KBcaUnkownState);
   203 			break;
   209 			break;
   204 		}
   210 		}
   205 	}
   211 	}
   206 	
   212 	
   207 void CBcaController::StartLoadL(const CBCAProvision* aBCAProvisionConfig,MUpperControl* aControl, 
   213 void CBcaController::StartLoadL(const CBCAProvision* aBCAProvisionConfig,MUpperControl* aControl, 
   213  * @param aControl pointer to BasebandChannelAdaptation2::MUpperControl passed to the MBca2 to pass control information up the stack
   219  * @param aControl pointer to BasebandChannelAdaptation2::MUpperControl passed to the MBca2 to pass control information up the stack
   214  * * @param aData pointer to BasebandChannelAdaptation2::MUpperDataReceiver passed to the MBca2 to push packets up the stack
   220  * * @param aData pointer to BasebandChannelAdaptation2::MUpperDataReceiver passed to the MBca2 to push packets up the stack
   215  * @return none 
   221  * @return none 
   216  */
   222  */
   217 	{
   223 	{
   218 	_LOG_L1C1(_L8("CBcaControl::StartLoad"));
   224 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_STARTLOADL_1, "CBcaControl::StartLoad");
   219 
   225 
   220 	iBCAProvisionConfig = aBCAProvisionConfig;
   226 	iBCAProvisionConfig = aBCAProvisionConfig;
   221 	iUpperControl = aControl;
   227 	iUpperControl = aControl;
   222 	iUpperDataReceiver = aData;
   228 	iUpperDataReceiver = aData;
   223 	// Loads Bca Dll and creates a Bca instance;
   229 	// Loads Bca Dll and creates a Bca instance;
   224 	User::LeaveIfError(iBcaDll.iObj.Load(iBCAProvisionConfig->GetBCAName()));
   230 	User::LeaveIfError(iBcaDll.iObj.Load(iBCAProvisionConfig->GetBCAName()));
   225 	
   231 	
   226 	TNewBca2FactoryL newBca2FactoryProcL = (TNewBca2FactoryL)iBcaDll.iObj.Lookup(1);
   232 	TNewBca2FactoryL newBca2FactoryProcL = (TNewBca2FactoryL)iBcaDll.iObj.Lookup(1);
   227 	if (NULL == newBca2FactoryProcL)
   233 	if (NULL == newBca2FactoryProcL)
   228 		{
   234 		{
   229 		_LOG_L1C2(_L8("Library entry point found error %d"), KErrBadLibraryEntryPoint);
   235 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_STARTLOADL_2, "Library entry point found error %d", KErrBadLibraryEntryPoint);
   230 		User::Leave(KErrBadLibraryEntryPoint);	
   236 		User::Leave(KErrBadLibraryEntryPoint);	
   231 		}
   237 		}
   232 	
   238 	
   233 	MBca2Factory* bcaFactory = (*newBca2FactoryProcL)();
   239 	MBca2Factory* bcaFactory = (*newBca2FactoryProcL)();
   234 
   240 
   235 	if(!bcaFactory)
   241 	if(!bcaFactory)
   236 		{
   242 		{
   237 		_LOG_L1C2(_L8("BcaFactory creation error %d"), KErrCompletion);
   243 		OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_STARTLOADL_3, "BcaFactory creation error %d", KErrCompletion);
   238 		User::Leave(KErrCompletion);	
   244 		User::Leave(KErrCompletion);	
   239 		}
   245 		}
   240 	CleanupReleasePushL(*bcaFactory);
   246 	CleanupReleasePushL(*bcaFactory);
   241 	
   247 	
   242 	iMBca = bcaFactory->NewBcaL();
   248 	iMBca = bcaFactory->NewBcaL();
   253 /**
   259 /**
   254  *  Used to shutdown this module. This will cancel all the outstanding 
   260  *  Used to shutdown this module. This will cancel all the outstanding 
   255  *  requests on the active objects owned by this module and shutdown.
   261  *  requests on the active objects owned by this module and shutdown.
   256  */
   262  */
   257 	{
   263 	{
   258 	_LOG_L1C1(_L8("CBcaController::Stop is called."));
   264 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_STOP_1, "CBcaController::Stop is called.");
   259 
   265 
   260 	if(iMBca)
   266 	if(iMBca)
   261 		{
   267 		{
   262 		iMBca->Close();
   268 		iMBca->Close();
   263 		}
   269 		}
   264 	else 
   270 	else 
   265 		{
   271 		{
   266 		_LOG_L1C1(_L8("CBcaController::Stop Bca is not initialized. Bring the link layer down"));
   272 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_STOP_2, "CBcaController::Stop Bca is not initialized. Bring the link layer down");
   267 		iRawIPFlow.LinkLayerDown(aError);
   273 		iRawIPFlow.LinkLayerDown(aError);
   268 		}
   274 		}
   269   	}
   275   	}
   270 
   276 
   271 
   277 
   272 /** Panic function for RawIpNif 
   278 /** Panic function for RawIpNif 
   273 
   279 
   274 * @param aPanic panic code */
   280 * @param aPanic panic code */
   275 void Panic(TRawIP2NifPanic aPanic)
   281 void Panic(TRawIP2NifPanic aPanic)
   276 	{
   282 	{
   277 	_LOG_L2C2(_L8("Panic code for RawIpNif = %d"), aPanic);
   283 	OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CBCACONTROLLER_PANIC_1, "Panic code for RawIpNif = %d", aPanic);
   278 	User::Panic(KNifName,aPanic);
   284 	User::Panic(KNifName,aPanic);
   279 
   285 
   280 	}
   286 	}
   281 
   287