bluetooth/btstack/linkmgr/ACLSAP.cpp
branchRCL_3
changeset 22 9f17f914e828
parent 8 2b6718f05bdb
child 23 32ba20339036
equal deleted inserted replaced
18:f8503e232b0c 22:9f17f914e828
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-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".
  1331 	{
  1331 	{
  1332 	LOG_FUNC
  1332 	LOG_FUNC
  1333 	iState->Shutdown(*this, aOption);
  1333 	iState->Shutdown(*this, aOption);
  1334 	}
  1334 	}
  1335 
  1335 
  1336 
       
  1337 void CACLLink::NotifyDataToSocket(TUint8 aFlag, const TDesC8& aData)
  1336 void CACLLink::NotifyDataToSocket(TUint8 aFlag, const TDesC8& aData)
  1338 	{
  1337 	{
  1339 	LOG_FUNC
  1338 	LOG_FUNC
  1340 	const TUint8 KFlagHeaderSize =1;
       
  1341 /*
  1339 /*
  1342 	The design of the protocol specification for L2CAP
  1340 	The design of the protocol specification for L2CAP
  1343 	means that both we and L2CAP need to know the flag parameter
  1341 	means that both we and L2CAP need to know the flag parameter
  1344 	for now we just signal one datagram (*could* signal two - one for flag: but that's just as grubby)
  1342 	for now we just signal one datagram (*could* signal two - one for flag: but that's just as grubby)
  1345 */
  1343 */
  1346 
  1344 
  1347 
       
  1348 	// make a new chain consisting of Flag(1st octet) followed by Data.
       
  1349 	RMBufChain aclData;
  1345 	RMBufChain aclData;
  1350 	#ifdef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
  1346 
  1351 	THCIConnHandle connH=iHandle;
  1347 	CACLDataQController& aclQctrl = iProtocol.ACLController();
  1352 	aclData = const_cast<CHCIFacade&>(iLinksMan.HCIFacade()).TakeInboundACLDataBufferFromPool(connH);
  1348 	THCIConnHandle connH = iHandle;
  1353 	aclData.CopyIn(aData,KFlagHeaderSize);
  1349 	TRAPD(err, aclData = aclQctrl.PopulateInboundBufferL(connH, aFlag, aData));
  1354 	aclData.TrimEnd(aData.Length()+KFlagHeaderSize); //return the reserved MBufs we didn't need
       
  1355 													 //to the global pool
       
  1356 	#else
       
  1357 	TRAPD(err, aclData.CreateL(aData, KFlagHeaderSize));
       
  1358 
       
  1359 	if (err)
  1350 	if (err)
  1360 		{
  1351 		{
  1361 		//Since HC->H flow control is off, and we have run out of MBufs
  1352 		// We have run out of MBufs, there is nothing we can do here but 
  1362 		//there is nothing we can do here but drop or disconnect the link
  1353 		// 1) drop the received packet, or
  1363 		//due to limited resources. We drop.
  1354 		// 2) disconnect the link
       
  1355 		// We drop the packet to be multi-profile "friendly"
       
  1356 		LOG1(_L8("*** ERROR: Dropping ACL Data!!! (error = %d) ***"), err);
  1364 		return;
  1357 		return;
  1365 		}
  1358 		}
  1366 	#endif
  1359 	
  1367 
       
  1368 	aclData.First()->Ptr()[0] = aFlag;	// aData is already in the chain
       
  1369 
       
  1370 
       
  1371 	// slap onto the RMBufPacketQ
  1360 	// slap onto the RMBufPacketQ
  1372 	iInboundBuffer.Append(aclData); // transfers
  1361 	iInboundBuffer.Append(aclData); // transfers
  1373 	
  1362 	
  1374 
  1363 	iSocket->NewData(1);	// datagrams: could async notify - or get l2cap to drain async
  1375 	#ifndef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
  1376 	if (!err)
       
  1377 		{
       
  1378 	#endif
       
  1379 		iSocket->NewData(1);	// datagrams: could async notify - or get l2cap to drain async
       
  1380 	#ifndef HOSTCONTROLLER_TO_HOST_FLOW_CONTROL
       
  1381 		}
       
  1382 	#endif
       
  1383 	}
  1364 	}
  1384 
  1365 
  1385 
  1366 
  1386 void CACLLink::GetData(TDes8& aDesc,TUint aOptions,TSockAddr* aAddr)
  1367 void CACLLink::GetData(TDes8& aDesc,TUint aOptions,TSockAddr* aAddr)
  1387 	{
  1368 	{