bluetooth/btstack/avdtp/avdtpSignallingMessages.cpp
changeset 0 29b1cd4cb562
child 51 20ac952a623c
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2003-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 // Implements the avdtp signalling messages
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <bluetooth/logger.h>
       
    24 #include "avdtpSignallingMessages.h"
       
    25 #include "avdtpSignallingChannel.h"
       
    26 #include "avdtputil.h"
       
    27 #include "avdtp.h"
       
    28 
       
    29 #ifdef __FLOG_ACTIVE
       
    30 _LIT8(KLogComponent, LOG_COMPONENT_AVDTP);
       
    31 #endif
       
    32 
       
    33 using namespace SymbianBluetoothAV;
       
    34 
       
    35 CAvdtpSignallingMessage::CAvdtpSignallingMessage()
       
    36 	{
       
    37 	LOG_FUNC
       
    38 	Data().Init();
       
    39 	}
       
    40 	
       
    41 CAvdtpInboundSignallingMessage::CAvdtpInboundSignallingMessage(CSignallingChannel& aSignallingChannel)
       
    42 : iSignallingChannel(aSignallingChannel)
       
    43 	{
       
    44 	LOG_FUNC
       
    45 	}
       
    46 
       
    47 /*static*/ void CAvdtpOutboundSignallingMessage::PrependSignallingHeaderL(
       
    48 									RMBufChain& aDest,
       
    49 									const TAvdtpPacketType& aPacketType,
       
    50 									const TAvdtpTransactionLabel& aTransLabel,
       
    51 									const TAvdtpMessageType& aMessageType,
       
    52 									TAvdtpMessage aSigId,
       
    53 									TInt aNumberSignalPackets)
       
    54 	{
       
    55 	LOG_STATIC_FUNC
       
    56 	RMBuf& header = *RMBuf::AllocL();
       
    57 	aDest.Prepend(&header);
       
    58 	
       
    59 	TUint8	firstByte = 
       
    60 		((aTransLabel<<KAvdtpTransactionLabelOffset) & KAvdtpTransactionLabelMask) |
       
    61 		((aPacketType<<KAvdtpPacketTypeOffset)		 & KAvdtpPacketTypeMask)       |
       
    62 		((aMessageType<<KAvdtpMessageTypeOffset)	 & KAvdtpMessageTypeMask);
       
    63 	
       
    64 	switch (aPacketType)
       
    65 		{
       
    66 		case ESingle:
       
    67 			{
       
    68 			header.SetLength(KAvdtpMinimumSignallingSinglePacketLength);
       
    69 			TUint8 lastByte = ((aSigId) & KAvdtpSignalIdentifierMask);
       
    70 			header.Put(firstByte,0);
       
    71 			header.Put(lastByte,1);
       
    72 			break;
       
    73 			}
       
    74 		case EStart:
       
    75 			{
       
    76 			header.SetLength(KAvdtpMinimumSignallingStartPacketLength);
       
    77 			TUint8 lastByte = ((aSigId) & KAvdtpSignalIdentifierMask);
       
    78 			header.Put(firstByte,0);
       
    79 			header.Put(static_cast<TUint8>(aNumberSignalPackets),1);
       
    80 			header.Put(lastByte,2);
       
    81 			break;
       
    82 			}
       
    83 		case EEnd:
       
    84 		case EContinue:
       
    85 			header.SetLength(KAvdtpMinimumSignallingContinuePacketLength);
       
    86 			header.Put(firstByte,0);
       
    87 			break;			
       
    88 		}	
       
    89 	
       
    90 	}
       
    91 
       
    92 
       
    93 /*
       
    94 Return True if more fragments in packet
       
    95 */
       
    96 TBool CAvdtpOutboundSignallingMessage::GetNextOutboundFragmentL(RMBufChain& aDest, TInt aMaxSize)
       
    97 	{
       
    98 	LOG_FUNC
       
    99 	TAvdtpPacketType pktType;
       
   100 	
       
   101 	if (!iFragInfo.iFragmented)
       
   102 		{
       
   103 		// no fragmentation already done - might be single or need fragmenting
       
   104 		__ASSERT_DEBUG(Data().Length()<=(0xff*aMaxSize), Panic(EAvdtpBadlyFormattedOutboundSignallingMessage));
       
   105 		
       
   106 		if ((Data().Length()+
       
   107 			KAvdtpMinimumSignallingSinglePacketLength) < aMaxSize)
       
   108 			{
       
   109 			//no fragmentation required
       
   110 			PrependSignallingHeaderL(Data(),ESingle,TransactionLabel(),iMessageType,Signal());
       
   111 			aDest.Assign(Data()); //transfer ownership of Data to aDest
       
   112 			Deque();	// remove this from the outbound queue
       
   113 			return EFalse; //no more frags - returned whole packet
       
   114 			}
       
   115 		else
       
   116 			{
       
   117 			// Start fragment(ing)
       
   118 			//we can get MTU-3 bytes in the first pkt, MTU-1 in the rest
       
   119 			//just pretend it's 2 bytes longer than it is and divide by
       
   120 			//MTU - 1 
       
   121 			iFragInfo.iTotalPackets = ((Data().Length()+2)/(aMaxSize-1));
       
   122 			//and add one if it wasn't an exact fit
       
   123 			if ((Data().Length()+2)%(aMaxSize-1))
       
   124 				{
       
   125 				iFragInfo.iTotalPackets++;
       
   126 				}
       
   127 			iFragInfo.iPacketNumber=0;
       
   128 			iFragInfo.iFragmented=ETrue;
       
   129 			
       
   130 			pktType = EStart;
       
   131 			}
       
   132 		}
       
   133 	else
       
   134 		{
       
   135 		// continue and end parts
       
   136 		pktType = (iFragInfo.iPacketNumber<(iFragInfo.iTotalPackets-1)) ? EContinue : EEnd;
       
   137 		}
       
   138 		
       
   139 	PrependSignallingHeaderL(Data(), pktType, TransactionLabel(), iMessageType,
       
   140 							 Signal(), iFragInfo.iTotalPackets);
       
   141 
       
   142 	// copy into "fragment" (whole packet if Single!) amount of message that will fit
       
   143 	// the message here doesn't have the header, but we do know we need to fragment
       
   144 	// (MTU-3) for Start, (MTU-1) for Continue,End
       
   145 	TInt size = 0;
       
   146 	
       
   147 	switch (pktType)
       
   148 		{
       
   149 		case EStart:
       
   150 		size = aMaxSize - KAvdtpMinimumSignallingStartPacketLength;
       
   151 		break; 
       
   152 		case EContinue:
       
   153 		size = aMaxSize - KAvdtpMinimumSignallingContinuePacketLength;
       
   154 		break;
       
   155 		case EEnd:
       
   156 		size = aMaxSize - KAvdtpMinimumSignallingEndPacketLength;
       
   157 		break;
       
   158 		case ESingle: // drop through
       
   159 		default:
       
   160 		__ASSERT_DEBUG(0, Panic(EAvdtpBadlyFormattedOutboundSignallingMessage));
       
   161 		}
       
   162 
       
   163 	Data().CopyL(aDest,0,size);
       
   164 	// and trim off the copied data from Data()
       
   165 	// esock workaround - panic if trim > size of chain
       
   166 	Data().TrimStart(Min(size, Data().Length()));
       
   167 	
       
   168 	if (iFragInfo.iPacketNumber++==iFragInfo.iTotalPackets)
       
   169 		{
       
   170 		// all fragments done
       
   171 		Deque();
       
   172 		return EFalse; // no more fragments from this packet
       
   173 		}
       
   174 		
       
   175 	return ETrue;
       
   176 	}
       
   177 
       
   178 /**
       
   179 Check that packet header is ok for the packet build state we're in
       
   180 @param aFragment the next incoming fragment to validate
       
   181 @return KErrNone if ok, KErrCorrupt if not. KErrAbort if fragment is an Abort packet
       
   182 */
       
   183 TInt CAvdtpInboundSignallingMessage::CheckPacketType(RMBufChain& aFragment, TAvdtpPacketType& aPacketType, TAvdtpMessageType& aMessageType, TAvdtpTransactionLabel& aTransactionLabel)
       
   184 	{
       
   185 	LOG_FUNC
       
   186 	 //NB could be an Abort packet interleaved in building up the previous packet
       
   187 	TInt ret = KErrCorrupt;
       
   188 
       
   189 	if (aFragment.First())
       
   190 		{
       
   191 		TAvdtpPacketType packetType = static_cast<TAvdtpPacketType>((aFragment.First()->Ptr()[0] & KAvdtpPacketTypeMask) >> KAvdtpPacketTypeOffset);
       
   192 		TAvdtpMessageType messageType = static_cast<TAvdtpMessageType>((aFragment.First()->Ptr()[0] & KAvdtpMessageTypeMask) >> KAvdtpMessageTypeOffset);
       
   193 		TAvdtpTransactionLabel transactionLabel = static_cast<TAvdtpTransactionLabel>((aFragment.First()->Ptr()[0] & KAvdtpTransactionLabelMask) >> KAvdtpTransactionLabelOffset);
       
   194 		
       
   195 		aMessageType = messageType;
       
   196 		aTransactionLabel = transactionLabel;
       
   197 		aPacketType = packetType;
       
   198 
       
   199 		/* check if an abort has come in
       
   200 			The abort will be a single packet type
       
   201 			The message type will be a command
       
   202 			The indication (second byte) will EAvdtpAbort
       
   203 		  if an abort has come in then return KErrAbort and
       
   204 		  the abort will be correctly processed. The packetbuildstate will 
       
   205 		  be reset to EAwaitingNew
       
   206 		  */
       
   207 		if ((ESingle == packetType) && (ECommand == messageType))
       
   208 			{
       
   209 			/* note that when checking for the signal identifier HERE
       
   210 			   we haven't yet removed the first byte from the message
       
   211 			 */
       
   212 			if (aFragment.First()->Size() > 1)
       
   213 				{
       
   214 				TAvdtpMessage id = static_cast<TAvdtpMessage>(aFragment.First()->Ptr()[1] & KAvdtpSignalIdentifierMask);
       
   215 				if (EAvdtpAbort == id)
       
   216 					{
       
   217 					return (KErrAbort);
       
   218 					}
       
   219 				}
       
   220 			}
       
   221 		
       
   222 		switch (iPacketBuildState)
       
   223 			{
       
   224 			case EAwaitingNew:
       
   225 				// if waiting for a new packet then packet type must be single or start
       
   226 				if ((packetType==ESingle)||(packetType==EStart))
       
   227 					{
       
   228 					ret=KErrNone;
       
   229 					}
       
   230 				break;
       
   231 			case EAwaitingContinue:
       
   232 				// if waiting for continue then type must be continue, and the transaction label
       
   233 				// of this fragment must match the packet we're building. Ditto for message type
       
   234 				if ((packetType==EContinue) && 
       
   235 				    (transactionLabel==iPacketBuildLabel) && 
       
   236 				    (messageType==iMessageType))
       
   237 					{
       
   238 					ret=KErrNone;
       
   239 					}
       
   240 				break;
       
   241 			case EAwaitingEnd:
       
   242 				// if waiting for end then type must be end, and the transaction label
       
   243 				// of this fragment must match the packet we're building. Ditto for message type			
       
   244 				if ((packetType==EEnd) && 
       
   245 				    (transactionLabel==iPacketBuildLabel) && 
       
   246 				    (messageType==iMessageType))
       
   247 				    {
       
   248 				    ret=KErrNone;
       
   249 				    }
       
   250 				break;
       
   251 			}
       
   252 		}
       
   253 	return ret;
       
   254 	}
       
   255 
       
   256 void CAvdtpSignallingMessage::SetType(TAvdtpMessageType aType,TAvdtpMessage aMessage)
       
   257 	{
       
   258 	LOG_FUNC
       
   259 	iSignal = aMessage;
       
   260 	iMessageType = aType;
       
   261 	}
       
   262 	
       
   263 
       
   264 CAvdtpOutboundSignallingMessage::~CAvdtpOutboundSignallingMessage()
       
   265 	{
       
   266 	LOG_FUNC
       
   267 	if (iMessageType==ECommand)
       
   268 		{
       
   269 		//OutBound Signalling message should never be EReserved
       
   270 		__ASSERT_DEBUG(Signal()!= EReserved,Panic(EAvdtpInvalidReservedValueInOutboundSignallingMessage));
       
   271 		iCommandLabel.Close();
       
   272 		}
       
   273 	Deque();
       
   274 	}
       
   275 
       
   276 void CAvdtpOutboundSignallingMessage::AddSEPInfoL(const TAvdtpSEPInfo& aSEPInfo)
       
   277 	{
       
   278 	LOG_FUNC
       
   279 	// append SEP info to packet
       
   280 	TBuf8<KAvdtpPacketSEPInfoSize> SEPInfoBuf;
       
   281 	SEPInfoBuf.SetMax();
       
   282 
       
   283 	SEPInfoBuf[0] = aSEPInfo.SEID().PacketValue();
       
   284 	if (aSEPInfo.InUse())
       
   285 		{
       
   286 		SEPInfoBuf[0]|=(1<<KAvdtpInUseFlagOffset);
       
   287 		}
       
   288 	SEPInfoBuf[1] = aSEPInfo.MediaType()<<KAvdtpMediaTypeOffset;
       
   289 	if (aSEPInfo.IsSink())
       
   290 		{
       
   291 		SEPInfoBuf[1]|=(1<<KAvdtpTSEPOffset);
       
   292 		}
       
   293 	AppendDataL(SEPInfoBuf);
       
   294 	}
       
   295 	
       
   296 	
       
   297 void CAvdtpOutboundSignallingMessage::AddSEPCapabilityL(const TAvdtpServiceCapability& aCapability)
       
   298 	{
       
   299 	LOG_FUNC
       
   300 	// append SEP capability to packet, this temp buffer *cannot* be placed on cleanupstack (it may get reallocated)
       
   301 	RBuf8 buf;
       
   302 	buf.CreateL(KAvdtpServiceCapabilitiesHeaderLen);
       
   303 	buf.CleanupClosePushL();
       
   304 	User::LeaveIfError(aCapability.AsProtocol(buf));	
       
   305 	AppendDataL(buf);
       
   306 	buf.Close();
       
   307 	CleanupStack::Pop();
       
   308 	}
       
   309 
       
   310 void CAvdtpOutboundSignallingMessage::Deque()
       
   311 	{
       
   312 	LOG_FUNC
       
   313 	iLink.Deque();
       
   314 	}
       
   315 		
       
   316 TInt CAvdtpOutboundSignallingMessage::AllocateTransactionLabel(TTransactionLabelManager& aManager)
       
   317 	{
       
   318 	LOG_FUNC
       
   319 	return aManager.GetLabel(iCommandLabel);
       
   320 	}
       
   321 
       
   322 void CAvdtpOutboundSignallingMessage::SetTransactionLabel(TAvdtpTransactionLabel aLabel)
       
   323 	{
       
   324 	LOG_FUNC
       
   325 	iResponseLabel = aLabel;
       
   326 	}
       
   327 
       
   328 TInt CAvdtpOutboundSignallingMessage::NewData(TUint /*aCount*/)	
       
   329 	{
       
   330 	Panic(EAvdtpOutboundMessageNewDataCalled);
       
   331 	return KErrNotSupported;
       
   332 	}
       
   333 	
       
   334 /**
       
   335 Upcall from signalling channel telling us of new inbound data
       
   336 The data is synchronously retrieved, checked and added to the building packet
       
   337 Once the packet is complete the packet begins parsing
       
   338 */	
       
   339 /*virtual*/ TInt CAvdtpInboundSignallingMessage::NewData(TUint aCount)
       
   340 	{
       
   341 	LOG_FUNC
       
   342 	RMBufChain fragment;
       
   343 	TInt result = KErrNone;
       
   344 	
       
   345 	while (aCount--)
       
   346 		{
       
   347 		result = iSignallingChannel.GetData(fragment,NULL);
       
   348 	
       
   349 		if (result<KErrNone)
       
   350 			{
       
   351 			break;
       
   352 			}
       
   353 		
       
   354 		TAvdtpPacketType packetType;
       
   355 		TAvdtpMessageType messageType;
       
   356 		TAvdtpTransactionLabel transactionLabel;
       
   357 		// check the AVDTP Packet type part of the header	
       
   358 		result = CheckPacketType(fragment, packetType, messageType, transactionLabel);
       
   359 
       
   360    		if (result == KErrAbort)
       
   361    			{
       
   362  			// if the packet build state is other than awaiting new then
       
   363  			// we have some existing data to throw out (the abort should discard)
       
   364  			if (iPacketBuildState != EAwaitingNew)
       
   365  				{
       
   366  				Data().Free(); 		//drop
       
   367  				}
       
   368  			// reset the packet build state so that we process the abort.
       
   369  			iPacketBuildState = EAwaitingNew;
       
   370    			// clear current message??
       
   371    			// at moment do nothing - mayneed to parse to see if it's the same SEID - yuk protocol
       
   372    			result = KErrNone; // will actually process the Abort message
       
   373    			}
       
   374 		
       
   375 		// if the packet type is ok then it can be added into the building up packet
       
   376 		if (result == KErrNone)
       
   377 			{
       
   378 			iFragmentationInfo.iPacketNumber++;
       
   379 			// see whether to start new packet
       
   380 			switch (iPacketBuildState)
       
   381 				{
       
   382 				case EAwaitingNew:
       
   383 					// can see what this message is going to be
       
   384 					iMessageType = messageType;
       
   385 					TRAP(result,Data() = MessageL(fragment,packetType));
       
   386 					
       
   387 					if (result==KErrNone)
       
   388 						{
       
   389 						iPacketBuildLabel = transactionLabel;
       
   390 						if (packetType==ESingle)
       
   391 							{
       
   392 							// and can now process - no more to wait for!
       
   393 							Process(iPacketBuildLabel);
       
   394 							// reset the packet number counter
       
   395 							iFragmentationInfo.iPacketNumber =0;
       
   396 							}
       
   397 						else
       
   398 							{
       
   399 							// a start, data remembered above, and hold off processing
       
   400 							iFragmentationInfo.iFragmented = ETrue;
       
   401 							iFragmentationInfo.iTotalPackets = NumberSignalPackets(fragment);
       
   402 							iPacketBuildState = EAwaitingContinue;
       
   403 							}
       
   404 						}
       
   405 					break;
       
   406 					
       
   407 				case EAwaitingContinue:
       
   408 					{
       
   409 					// check that the number of packets < NOSP
       
   410 					result = iFragmentationInfo.iFragmented &&
       
   411 								(iFragmentationInfo.iPacketNumber < iFragmentationInfo.iTotalPackets)
       
   412 								? KErrNone : KErrNotReady;
       
   413 
       
   414 					if (result==KErrNone)
       
   415 						{
       
   416 						RMBufChain message;
       
   417 						TRAP(result,message = MessageL(fragment,packetType));
       
   418 						
       
   419 						if (result==KErrNone)
       
   420 							{
       
   421 							// add into forming packet
       
   422 							Data().Append(message);
       
   423 
       
   424 							// see if we expect End next
       
   425 							if (iFragmentationInfo.iPacketNumber == iFragmentationInfo.iTotalPackets-1)
       
   426 								{
       
   427 								iPacketBuildState = EAwaitingEnd;
       
   428 								}
       
   429 							}
       
   430 						
       
   431 						}
       
   432 					}
       
   433 					break;
       
   434 				case EAwaitingEnd:
       
   435 					{
       
   436 					// check that the number of packets == NOSP
       
   437 					result = iFragmentationInfo.iFragmented &&
       
   438 								(iFragmentationInfo.iPacketNumber == iFragmentationInfo.iTotalPackets)
       
   439 								? KErrNone : KErrNotReady;
       
   440 					
       
   441 					if (result==KErrNone)
       
   442 						{
       
   443 						RMBufChain message;
       
   444 						TRAP(result,message = MessageL(fragment,packetType));
       
   445 						if (result==KErrNone)
       
   446 							{
       
   447 							// add into forming packet
       
   448 							Data().Append(message);
       
   449 							// and process cos no more to come
       
   450 							Process(iPacketBuildLabel);
       
   451 							iPacketBuildState = EAwaitingNew;
       
   452 							}
       
   453 						}
       
   454 					}
       
   455 					break;
       
   456 				}
       
   457 			}
       
   458 		else
       
   459 			{
       
   460 			//drop - free'd below
       
   461 			}
       
   462 		
       
   463 		// all done with the inbound fragment
       
   464 		fragment.Free();	
       
   465 		}
       
   466 		
       
   467 	return result;
       
   468 	}
       
   469 
       
   470 
       
   471 /**
       
   472 Begin processing the complete packet
       
   473 */
       
   474 void CAvdtpInboundSignallingMessage::Process(TAvdtpTransactionLabel aLabel)
       
   475 	{
       
   476 	LOG_FUNC
       
   477 	iSignal = SignalIdentifier(Data());
       
   478 	
       
   479 	// member function pointer
       
   480 	// the handlers have no policy - they just parse and generate indications to SAP
       
   481    	void (*handler)(CAvdtpInboundSignallingMessage&, TAvdtpTransactionLabel);
       
   482 	
       
   483 	switch (Signal())
       
   484 		{
       
   485 		case EAvdtpDiscover:
       
   486 			handler = HandleDiscoverL;
       
   487 			break;
       
   488 		case EAvdtpGetCapabilities:
       
   489 			handler = HandleGetCapsL;
       
   490 			break;
       
   491 		case EAvdtpSetConfiguration:
       
   492 			handler = HandleSetConfigL;
       
   493 			break;
       
   494 		case EAvdtpGetConfiguration:
       
   495 			handler = HandleGetConfigL;
       
   496 			break;
       
   497 		case EAvdtpReconfigure:
       
   498 			handler = HandleReconfigL;
       
   499 			break;
       
   500 		case EAvdtpOpen:
       
   501 			handler = HandleOpenL;
       
   502 			break;
       
   503 		case EAvdtpStart:
       
   504 			handler = HandleStartL;
       
   505 			break;
       
   506 		case EAvdtpRelease:
       
   507 			handler = HandleReleaseL;
       
   508 			break;
       
   509 		case EAvdtpSuspend:
       
   510 			handler = HandleSuspendL;
       
   511 			break;
       
   512 		case EAvdtpAbort:
       
   513 			handler = HandleAbortL;
       
   514 			break;
       
   515 		case EAvdtpSecurityControl:
       
   516 			handler = HandleSecurityControlL;
       
   517 			break;
       
   518 		case EReserved:
       
   519 			Data().Free(); 		//drop
       
   520 			iPacketBuildState = EAwaitingNew;
       
   521 			return;
       
   522 		default:
       
   523 			{
       
   524 			if(iMessageType==ECommand)
       
   525 				{
       
   526 				iSignallingChannel.SendReject(aLabel, Signal(), EAvdtpNotSupportedCommand/*ignored*/);
       
   527 				}
       
   528 			
       
   529 			Data().Free(); 		//drop
       
   530 			iPacketBuildState = EAwaitingNew;
       
   531 			return;
       
   532 			}
       
   533 		}
       
   534 	// trim off now-processed header stuff (that SigId)
       
   535 	Data().TrimStart(1);
       
   536 
       
   537 	// now invoke handler (via member function pointer)
       
   538 	
       
   539 	TRAPD(parseError, (*handler)(*this, aLabel));
       
   540 
       
   541 	if (parseError != KErrNone && iMessageType==ECommand)
       
   542 		{
       
   543 		// kick the signalling channel to send appropriate error, but only for commands (responses are discarded)
       
   544 		// further the handlers need to take care - if they are supposed to send extended error info
       
   545 		// they cannot use this service
       
   546 		__ASSERT_DEBUG(Signal()!=EAvdtpSetConfiguration && Signal()!=EAvdtpReconfigure, Panic(EAvdtpSignallingMessageHandlerLeft));
       
   547 		
       
   548 		switch(Signal())
       
   549 			{
       
   550 			case EAvdtpSetConfiguration:
       
   551 				{
       
   552 				iSignallingChannel.SendSetConfigurationReject(aLabel, AvdtpInternalUtils::SymbianErrorToAvdtpError(parseError), EServiceCategoryNull);
       
   553 				break;
       
   554 				}
       
   555 			case EAvdtpReconfigure:
       
   556 				{
       
   557 				iSignallingChannel.SendReconfigureReject(aLabel, AvdtpInternalUtils::SymbianErrorToAvdtpError(parseError), EServiceCategoryNull);
       
   558 				break;
       
   559 				}
       
   560 			default:
       
   561 				{
       
   562 				iSignallingChannel.SendReject(aLabel, Signal(), AvdtpInternalUtils::SymbianErrorToAvdtpError(parseError));
       
   563 				}
       
   564 			}
       
   565 		}
       
   566 	
       
   567 	Data().Free(); //done parsing
       
   568 	iPacketBuildState = EAwaitingNew;
       
   569 	}
       
   570 
       
   571 void CAvdtpInboundSignallingMessage::DoHandleDiscoverL(TAvdtpTransactionLabel aLabel)
       
   572 	{
       
   573 	LOG_FUNC
       
   574 	switch (iMessageType)
       
   575 		{
       
   576 		case ECommand:
       
   577 			{
       
   578 			CheckPacketLengthL(KAvdtpDiscoverCommandMinimumLength, KAvdtpDiscoverCommandMaximumLength);
       
   579 			iSignallingChannel.DiscoverIndication(aLabel);
       
   580 			break;
       
   581 			}
       
   582 		case EResponseAccept:
       
   583 			{
       
   584 			TAvdtpInternalDiscoverConfirm cfm;
       
   585 
       
   586 			TInt err = CheckPacketLength(KAvdtpDiscoverAcceptMinimumLength, KAvdtpDiscoverAcceptMaximumLength);
       
   587 			if (Data().Length()%2!=0)
       
   588 				{
       
   589 				err = KErrCorrupt;
       
   590 				}
       
   591 			TInt numSEPs;
       
   592 			if (err==KErrNone)
       
   593 				{				
       
   594 				const TInt KAvdtpDiscoverSEPLenOctets = 2;
       
   595 				numSEPs = (Data().Length())/KAvdtpDiscoverSEPLenOctets;
       
   596 				}
       
   597 			else
       
   598 				{
       
   599 				numSEPs = 0;
       
   600 				err = KErrNotFound;
       
   601 				}
       
   602 					
       
   603 			if (numSEPs)
       
   604 				{	
       
   605 				err = AvdtpSignallingMessageDiscover::Response::ParseL(Data(),
       
   606 																cfm.iDiscoveredSEPs,
       
   607 																iSignallingChannel.iProtocol.RemoteSEPCache(),
       
   608 																iSignallingChannel.RemoteAddress());
       
   609 				}
       
   610 
       
   611 			cfm.iResult = err;
       
   612 			cfm.iNumSEPs = numSEPs;			
       
   613 			iSignallingChannel.DiscoverConfirm(aLabel, err, &cfm);
       
   614 			break;
       
   615 			}
       
   616 		case EResponseReject:
       
   617 			{
       
   618 			TInt err = CheckPacketLength(KAvdtpDiscoverRejectMinimumLength, KAvdtpDiscoverRejectMaximumLength);
       
   619 			err = (err==KErrNone) ? SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(Data().First()->Ptr()[0]))
       
   620 								: KErrCorrupt;
       
   621 			// pass up NULL SEP data
       
   622 			// NOTE:	It is safe to set the third parameter below to NULL
       
   623 			// 			the ASSERT_DEBUG that might have been hit as a result won't be
       
   624 			// 			because 'err' cannot equal 'KErrNone'.
       
   625 			//			SymbianBluetoothAV::ConvertToSymbianError::AvdtpError
       
   626 			//			calls
       
   627 			// 			TInt SymbianBluetoothAV::ConvertToSymbianError::DoConvertError(TBluetoothAvDistributionError aAVError)
       
   628 			// 			which subtracts a TUint8 from -18045, and thus has to return a value 
       
   629 			//			between -18045 and -18045 - 255 = -18300
       
   630 			iSignallingChannel.DiscoverConfirm(aLabel, err, NULL);
       
   631 			break;
       
   632 			}
       
   633 		case EGeneralReject:
       
   634 			{
       
   635 			TInt err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
   636 			iSignallingChannel.DiscoverConfirm(aLabel,err, NULL);
       
   637 			break;
       
   638 			}
       
   639 		}
       
   640 	}
       
   641 	
       
   642 void CAvdtpInboundSignallingMessage::DoHandleGetCapsL(TAvdtpTransactionLabel aLabel)
       
   643 	{
       
   644 	LOG_FUNC
       
   645 	TInt err = KErrNone;
       
   646 	
       
   647 	switch (iMessageType)
       
   648 		{
       
   649 		case ECommand:
       
   650 			{
       
   651 			CheckPacketLengthL(KAvdtpGetCapsCommandMinimumLength, KAvdtpGetCapsCommandMaximumLength);
       
   652 			iSignallingChannel.GetCapsIndication(aLabel,LocalSEIDL());
       
   653 			break;
       
   654 			}
       
   655 		case EResponseAccept:
       
   656 			{
       
   657 			err = CheckPacketLength(KAvdtpGetCapsAcceptMinimumLength, KAvdtpGetCapsAcceptMaximumLength);
       
   658 			if (err==KErrNone)
       
   659 				{
       
   660 				// fish out the capabilities from mbufchain
       
   661 				// as this is immutable HBufC8 is chosen over RBuf8
       
   662 				HBufC8* capsBuf = NULL;
       
   663 				capsBuf = HBufC8::NewMaxLC(Data().Length());
       
   664 				TPtr8 des = capsBuf->Des();
       
   665 				Data().CopyOut(des);
       
   666 
       
   667 				// Remove unknown caps
       
   668 				CCapabilityRemoveUnknownVisitor* remover = new (ELeave) CCapabilityRemoveUnknownVisitor;
       
   669 				remover->Process(des);
       
   670 				delete remover;
       
   671 				
       
   672 				// parse caps for broken ones
       
   673 				CCapabilityValidateVisitor* validater = new (ELeave) CCapabilityValidateVisitor;
       
   674 				validater->Process(des);
       
   675 
       
   676 				if (validater->Result()!=KErrNone)
       
   677 					{
       
   678 					CleanupStack::PopAndDestroy(capsBuf);
       
   679 					// drop (can't response to response)
       
   680 					// pass up zero as capabilities "seen" with the result code (in symbian range)
       
   681 					iSignallingChannel.GetCapsConfirm(aLabel, validater->Result(), 0);
       
   682 					}
       
   683 				else
       
   684 					{
       
   685 					// packet now only left with config payload
       
   686 					// pass ownership of buf 
       
   687 					CleanupStack::Pop(capsBuf);
       
   688 					iSignallingChannel.GetCapsConfirm(aLabel, err, capsBuf);
       
   689 					}
       
   690 
       
   691 				delete validater;
       
   692 				}
       
   693 			else
       
   694  				{
       
   695  				iSignallingChannel.GetCapsConfirm(aLabel, err);
       
   696  				}				
       
   697 			break;
       
   698 			}
       
   699 		case EResponseReject:
       
   700 			{
       
   701 			err = CheckPacketLength(KAvdtpGetCapsRejectMinimumLength, KAvdtpGetCapsRejectMaximumLength);
       
   702 			err = (err==KErrNone) ? SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(Data().First()->Ptr()[0])) : 
       
   703 									KErrCorrupt;
       
   704 			// pass up zero as capabilities "seen"
       
   705 			iSignallingChannel.GetCapsConfirm(aLabel, err, 0);
       
   706 			break;
       
   707 			}	
       
   708 		case EGeneralReject:
       
   709 			{
       
   710 			err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
   711 			iSignallingChannel.GetCapsConfirm(aLabel, err, 0);
       
   712 			break;
       
   713 			}
       
   714 		}
       
   715 	}
       
   716 	
       
   717 /*
       
   718 Handle a fully reassembled SetConfig command or response
       
   719 */
       
   720 void CAvdtpInboundSignallingMessage::DoHandleSetConfigL(TAvdtpTransactionLabel aLabel)
       
   721 	{
       
   722 	LOG_FUNC
       
   723 	TInt err = KErrNone;
       
   724 	switch (iMessageType)
       
   725 		{
       
   726 		case ECommand:
       
   727 			{
       
   728 			CheckPacketLengthL(KAvdtpSetConfigCommandMinimumLength, KAvdtpSetConfigCommandMaximumLength);
       
   729 
       
   730 			TSEID intSEID;
       
   731 			TSEID acpSEID;
       
   732 			acpSEID = LocalSEIDL();
       
   733 			Data().TrimStart(1); // gulped ACP SEID
       
   734 			intSEID = RemoteSEIDL();
       
   735 			Data().TrimStart(1); // gulped INT SEID
       
   736 			
       
   737 			if (!Data().Length())
       
   738 				{
       
   739 				// empty configuration! not allowed?
       
   740 				AvdtpInternalUtils::PacketErrorLeaveL(EAvdtpBadPayloadFormat);
       
   741 				}
       
   742 				
       
   743 			RBuf8 caps;
       
   744 			CleanupClosePushL(caps);
       
   745 			caps.CreateMaxL(Data().Length());
       
   746 			Data().CopyOut(caps);
       
   747 			
       
   748 			// parse caps for broken ones
       
   749 			CCapabilityValidateVisitor* validater = new (ELeave) CCapabilityValidateVisitor;
       
   750 			validater->Process(caps);
       
   751 			
       
   752 			CleanupStack::Pop(1); //caps
       
   753 
       
   754 			if (validater->Result()!=KErrNone)
       
   755 				{
       
   756 				caps.Close();
       
   757 				iSignallingChannel.SendSetConfigurationReject(aLabel,
       
   758 													AvdtpInternalUtils::SymbianErrorToAvdtpError(validater->Result()),
       
   759 													validater->InvalidCategory());
       
   760 				}
       
   761 			else
       
   762 				{
       
   763 				// packet now only left with config payload, pass RBuf ownership
       
   764 				iSignallingChannel.SetConfigIndication(aLabel, acpSEID, intSEID, caps);
       
   765 				}
       
   766 
       
   767 			delete validater;			
       
   768 			break;
       
   769 			}
       
   770 		case EResponseAccept:
       
   771 			{
       
   772 			CheckPacketLength(KAvdtpSetConfigAcceptMinimumLength, KAvdtpSetConfigAcceptMaximumLength);
       
   773 			iSignallingChannel.SetConfigConfirm(aLabel, err, EServiceCategoryNull);
       
   774 			break;
       
   775 			}
       
   776 		case EResponseReject:
       
   777 			{
       
   778 			err = CheckPacketLength(KAvdtpSetConfigRejectMinimumLength, KAvdtpSetConfigRejectMaximumLength);
       
   779 			//Pull out the AVDTP error and convert to Symbian error
       
   780 			TAvdtpServiceCategory cat = EServiceCategoryNull;
       
   781 			if (err==KErrNone)
       
   782 				{
       
   783 				const TUint8* const rejData = Data().First()->Ptr();
       
   784 				cat = static_cast<TAvdtpServiceCategory>(rejData[0]);
       
   785 				err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(rejData[1]));
       
   786 				}
       
   787 			iSignallingChannel.SetConfigConfirm(aLabel, err, cat);
       
   788 			break;
       
   789 			}
       
   790 		case EGeneralReject:
       
   791 			{
       
   792 			err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
   793 			iSignallingChannel.SetConfigConfirm(aLabel, err, EServiceCategoryNull);
       
   794 			break;
       
   795 			}
       
   796 		}
       
   797 	}
       
   798 
       
   799 void CAvdtpInboundSignallingMessage::DoHandleGetConfigL(TAvdtpTransactionLabel aLabel)
       
   800 	{
       
   801 	LOG_FUNC
       
   802 	TInt err=KErrNone;
       
   803 	switch (iMessageType)
       
   804 		{
       
   805 		case ECommand:
       
   806 			{
       
   807 			CheckPacketLengthL(KAvdtpGetConfigCommandMinimumLength, KAvdtpGetConfigCommandMaximumLength);
       
   808 			iSignallingChannel.GetConfigIndication(aLabel, LocalSEIDL());
       
   809 			break;
       
   810 			}
       
   811 		case EResponseAccept:
       
   812 			{
       
   813 			err = CheckPacketLength(KAvdtpGetConfigAcceptMinimumLength, KAvdtpGetConfigAcceptMaximumLength);
       
   814 			iSignallingChannel.GetConfigConfirm(aLabel, err);
       
   815 			break;
       
   816 			}
       
   817 		case EResponseReject:
       
   818 			{
       
   819 			err = CheckPacketLength(KAvdtpGetConfigRejectMinimumLength, KAvdtpGetConfigRejectMaximumLength);
       
   820 			err = (err==KErrNone) ? SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(Data().First()->Ptr()[0])) : 
       
   821 									KErrCorrupt;
       
   822 			iSignallingChannel.GetConfigConfirm(aLabel,err);
       
   823 			break;
       
   824 			}
       
   825 		case EGeneralReject:
       
   826 			{
       
   827 			err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
   828 			iSignallingChannel.GetConfigConfirm(aLabel,err);
       
   829 			break;
       
   830 			}
       
   831 		default:
       
   832 			break;
       
   833 		}	
       
   834 	}
       
   835 
       
   836 void CAvdtpInboundSignallingMessage::DoHandleReconfigL(TAvdtpTransactionLabel aLabel)
       
   837 	{
       
   838 	LOG_FUNC
       
   839 	switch (iMessageType)
       
   840 		{
       
   841 		case ECommand:
       
   842 			{
       
   843 			CheckPacketLengthL(KAvdtpReConfigCommandMinimumLength, KAvdtpReConfigCommandMaximumLength);
       
   844 
       
   845 			TSEID intSEID;
       
   846 			TSEID acpSEID;
       
   847 			acpSEID = LocalSEIDL();
       
   848 			Data().TrimStart(1); // gulped ACP SEID
       
   849 			
       
   850 			if (!Data().Length())
       
   851 				{
       
   852 				// empty configuration! not allowed?
       
   853 				AvdtpInternalUtils::PacketErrorLeaveL(EAvdtpBadPayloadFormat);
       
   854 				}
       
   855 				
       
   856 			RBuf8 caps;
       
   857 			CleanupClosePushL(caps);
       
   858 			caps.CreateMaxL(Data().Length());
       
   859 			Data().CopyOut(caps);
       
   860 			
       
   861 			// parse caps for broken ones
       
   862 			CCapabilityValidateVisitor* validater = new (ELeave) CCapabilityValidateVisitor;
       
   863 			validater->Process(caps);
       
   864 			
       
   865 			CleanupStack::Pop(1); //caps
       
   866 			
       
   867 			if (validater->Result()!=KErrNone)
       
   868 				{
       
   869 				caps.Close();
       
   870 				iSignallingChannel.SendReconfigureReject(aLabel,
       
   871 													AvdtpInternalUtils::SymbianErrorToAvdtpError(validater->Result()),
       
   872 													validater->InvalidCategory());
       
   873 				}
       
   874 			else
       
   875 				{
       
   876 				// packet now only left with config payload
       
   877 				iSignallingChannel.ReconfigIndication(aLabel, acpSEID, caps);
       
   878 				}
       
   879 
       
   880 			delete validater;			
       
   881 			break;
       
   882 			}
       
   883 		case EResponseAccept:
       
   884 			{
       
   885 			CheckPacketLength(KAvdtpReConfigAcceptMinimumLength, KAvdtpReConfigAcceptMaximumLength);
       
   886 			iSignallingChannel.ReconfigConfirm(aLabel, KErrNone, EServiceCategoryNull);
       
   887 			break;
       
   888 			}
       
   889 		case EResponseReject:
       
   890 			{
       
   891 			TInt err = CheckPacketLength(KAvdtpReConfigRejectMinimumLength, KAvdtpReConfigRejectMaximumLength);
       
   892 			TAvdtpServiceCategory cat = EServiceCategoryNull;
       
   893 			if (err==KErrNone)
       
   894 				{
       
   895 				//Pull out the AVDTP error and convert to Symbian error
       
   896 				const TUint8* const rejData  = Data().First()->Ptr();
       
   897 				cat = static_cast<TAvdtpServiceCategory>(rejData[0]);
       
   898 				err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(rejData[1]));					
       
   899 				}
       
   900 			iSignallingChannel.ReconfigConfirm(aLabel, err, cat);
       
   901 			break;
       
   902 			}
       
   903 		case EGeneralReject:
       
   904 			{
       
   905 			TInt err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
   906 			iSignallingChannel.ReconfigConfirm(aLabel, err, EServiceCategoryNull);
       
   907 			break;
       
   908 			}
       
   909 		}
       
   910 	}
       
   911 
       
   912 void CAvdtpInboundSignallingMessage::DoHandleOpenL(TAvdtpTransactionLabel aLabel)
       
   913 	{
       
   914 	LOG_FUNC
       
   915 	switch (iMessageType)
       
   916 		{
       
   917 		case ECommand:
       
   918 			{
       
   919 			CheckPacketLengthL(KAvdtpOpenCommandMinimumLength, KAvdtpOpenCommandMaximumLength);
       
   920 			iSignallingChannel.OpenIndication(aLabel, LocalSEIDL());
       
   921 			break;
       
   922 			}
       
   923 		case EResponseAccept:
       
   924 			{
       
   925 			TInt err = CheckPacketLength(KAvdtpOpenAcceptMinimumLength, KAvdtpOpenAcceptMaximumLength);
       
   926 			iSignallingChannel.OpenConfirm(aLabel, err);
       
   927 			break;
       
   928 			}
       
   929 		case EResponseReject:
       
   930 			{
       
   931 			TInt err = CheckPacketLength(KAvdtpOpenRejectMinimumLength, KAvdtpOpenRejectMaximumLength);
       
   932 			err = (err==KErrNone) ? SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(Data().First()->Ptr()[0])) : 
       
   933 									KErrCorrupt;
       
   934 			iSignallingChannel.OpenConfirm(aLabel, err);
       
   935 			break;
       
   936 			}
       
   937 		case EGeneralReject:
       
   938 			{
       
   939 			TInt err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
   940 			iSignallingChannel.OpenConfirm(aLabel, err);
       
   941 			break;
       
   942 			}
       
   943 		default:
       
   944 			break;
       
   945 		}
       
   946 	}
       
   947 
       
   948 void CAvdtpInboundSignallingMessage::DoHandleStartL(TAvdtpTransactionLabel aLabel)
       
   949 	{
       
   950 	LOG_FUNC
       
   951 	TInt err=KErrNone;
       
   952 	switch (iMessageType)
       
   953 		{
       
   954 		case ECommand:
       
   955 			{
       
   956 			CheckPacketLengthL(KAvdtpStartCommandMinimumLength, KAvdtpStartCommandMaximumLength);
       
   957 			// get list of seids
       
   958 			// copy out - the data at this point is just the SEID list
       
   959 			TInt numSEIDs = Data().Length();
       
   960 			if (!numSEIDs)
       
   961 				{
       
   962 				AvdtpInternalUtils::PacketErrorLeaveL(EAvdtpBadPayloadFormat);
       
   963 				}
       
   964 			else
       
   965 				{
       
   966 				// we issue the starts individually
       
   967 				// as we cannot assume that the SEPs are within the same client process
       
   968 				// so even if we could send multiple SEIDs to each client process there is
       
   969 				// no synchronisation provided.
       
   970 				for (TInt i=0; i<numSEIDs; i++)
       
   971 					{
       
   972 					iSignallingChannel.StartIndication(aLabel, LocalSEIDL());
       
   973 					Data().TrimStart(1);
       
   974 					}
       
   975 				}
       
   976 			break;
       
   977 			}
       
   978 		case EResponseAccept:
       
   979 			{
       
   980 			err = CheckPacketLength(KAvdtpStartAcceptMinimumLength, KAvdtpStartAcceptMaximumLength);
       
   981 			iSignallingChannel.StartConfirm(aLabel, err);
       
   982 			break;
       
   983 			}
       
   984 		case EResponseReject:
       
   985 			{
       
   986 			err = CheckPacketLength(KAvdtpStartRejectMinimumLength, KAvdtpStartRejectMaximumLength);
       
   987 			err = (err==KErrNone) ? SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(Data().First()->Ptr()[1])) : 
       
   988 									KErrCorrupt;
       
   989 			// ignore the SEID - the channel will have stored the SEID (and the Accept doesnt have it!)
       
   990 			iSignallingChannel.StartConfirm(aLabel, err);
       
   991 			break;
       
   992 			}
       
   993 		case EGeneralReject:
       
   994 			{
       
   995 			err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
   996 			iSignallingChannel.StartConfirm(aLabel, err);
       
   997 			break;
       
   998 			}
       
   999 		default:
       
  1000 			break;
       
  1001 		} //end switch
       
  1002 	}
       
  1003 	
       
  1004 void CAvdtpInboundSignallingMessage::DoHandleReleaseL(TAvdtpTransactionLabel aLabel)
       
  1005 	{
       
  1006 	LOG_FUNC
       
  1007 	switch (iMessageType)
       
  1008 		{
       
  1009 		case ECommand:
       
  1010 			{
       
  1011 			CheckPacketLengthL(KAvdtpCloseCommandMinimumLength, KAvdtpCloseCommandMaximumLength);
       
  1012 			iSignallingChannel.ReleaseIndication(aLabel, LocalSEIDL());
       
  1013 			break;
       
  1014 			}
       
  1015 		case EResponseAccept:
       
  1016 			{
       
  1017 			TInt err = CheckPacketLength(KAvdtpCloseAcceptMinimumLength, KAvdtpCloseAcceptMaximumLength);
       
  1018 			iSignallingChannel.ReleaseConfirm(aLabel, err);
       
  1019 			break;
       
  1020 			}
       
  1021 		case EResponseReject:
       
  1022 			{
       
  1023 			TInt err = CheckPacketLength(KAvdtpCloseRejectMinimumLength, KAvdtpCloseRejectMaximumLength);
       
  1024 			err = (err==KErrNone) ? SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(Data().First()->Ptr()[0])) : 
       
  1025 									KErrCorrupt;
       
  1026 			iSignallingChannel.ReleaseConfirm(aLabel, err);
       
  1027 			break;
       
  1028 			}
       
  1029 		case EGeneralReject:
       
  1030 			{
       
  1031 			TInt err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
  1032 			iSignallingChannel.ReleaseConfirm(aLabel, err);
       
  1033 			break;
       
  1034 			}
       
  1035 		}
       
  1036 	}
       
  1037 
       
  1038 void CAvdtpInboundSignallingMessage::DoHandleSuspendL(TAvdtpTransactionLabel aLabel)
       
  1039 	{
       
  1040 	LOG_FUNC
       
  1041 	TInt err = KErrNone;
       
  1042 	switch (iMessageType)
       
  1043 		{
       
  1044 		case ECommand:
       
  1045 			{
       
  1046 			CheckPacketLengthL(KAvdtpSuspendCommandMinimumLength, KAvdtpSuspendCommandMaximumLength);
       
  1047 			// get list of seids
       
  1048 			// copy out - the data at this point is just the SEID list
       
  1049 			TInt numSEIDs = Data().Length();
       
  1050 			if (!numSEIDs)
       
  1051 				{
       
  1052 				AvdtpInternalUtils::PacketErrorLeaveL(EAvdtpBadPayloadFormat);
       
  1053 				}
       
  1054 			else
       
  1055 				{
       
  1056 				// we issue the suspends individually
       
  1057 				// as we cannot assume that the SEPs are within the same client process
       
  1058 				// so even if we could send multiple SEIDs to each client process there is
       
  1059 				// no synchronisation provided.
       
  1060 				for (TInt i=0; i<numSEIDs; i++)
       
  1061 					{
       
  1062 					iSignallingChannel.SuspendIndication(aLabel, LocalSEIDL());
       
  1063 					Data().TrimStart(1);
       
  1064 					}
       
  1065 				}
       
  1066 			break;
       
  1067 			}
       
  1068 		case EResponseAccept:
       
  1069 			{
       
  1070 			err = CheckPacketLength(KAvdtpSuspendAcceptMinimumLength, KAvdtpSuspendAcceptMaximumLength);
       
  1071 			iSignallingChannel.SuspendConfirm(aLabel, err);
       
  1072 			break;
       
  1073 			}
       
  1074 		case EResponseReject:
       
  1075 			{
       
  1076 			err = CheckPacketLength(KAvdtpSuspendRejectMinimumLength, KAvdtpSuspendRejectMaximumLength);
       
  1077 			err = (err==KErrNone) ? SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(Data().First()->Ptr()[1])) : 
       
  1078 									KErrCorrupt;
       
  1079 			// ignore the SEID as the Signalling Channel will have stored it
       
  1080 			iSignallingChannel.SuspendConfirm(aLabel,err);
       
  1081 			break;
       
  1082 			}
       
  1083 		case EGeneralReject:
       
  1084 			{
       
  1085 			err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
  1086 			iSignallingChannel.SuspendConfirm(aLabel,err);
       
  1087 			break;
       
  1088 			}
       
  1089 		default:
       
  1090 			break;
       
  1091 		}
       
  1092 	}
       
  1093 
       
  1094 void CAvdtpInboundSignallingMessage::DoHandleAbortL(TAvdtpTransactionLabel aLabel)
       
  1095 	{
       
  1096 	LOG_FUNC
       
  1097 	switch (iMessageType)
       
  1098 		{
       
  1099 		case ECommand:
       
  1100 			{
       
  1101 			TInt err = KErrNone;
       
  1102 
       
  1103 			err = CheckPacketLength(KAvdtpAbortCommandMinimumLength, KAvdtpAbortCommandMaximumLength);
       
  1104 			if (err==KErrNone)
       
  1105 				{
       
  1106 				iSignallingChannel.AbortIndication(aLabel, LocalSEIDL());
       
  1107 				}
       
  1108 			break;
       
  1109 			}
       
  1110 		case EResponseAccept:
       
  1111 			{
       
  1112 			iSignallingChannel.AbortConfirm(aLabel);
       
  1113 			break;
       
  1114 			}
       
  1115 		case EResponseReject:
       
  1116 		case EGeneralReject:	//General reject will be handled similar to Response Reject
       
  1117 			{
       
  1118 			//Don't expect this - spec a bit vague
       
  1119 			// just throw away
       
  1120 			break;
       
  1121 			}
       
  1122 		}
       
  1123 	}
       
  1124 
       
  1125 void CAvdtpInboundSignallingMessage::DoHandleSecurityControlL(TAvdtpTransactionLabel aLabel)
       
  1126 	{
       
  1127 	LOG_FUNC
       
  1128 	TInt err;
       
  1129 	switch (iMessageType)
       
  1130 		{
       
  1131 		case ECommand:
       
  1132 			{
       
  1133 			CheckPacketLengthL(KAvdtpSecurityControlCommandMinimumLength, KAvdtpSecurityControlCommandMaximumLength);
       
  1134 			// fish out the capabilities from mbufchain
       
  1135 			// as this is immutable HBufC8 is chosen over RBuf8
       
  1136 			TSEID localSEID;
       
  1137 			localSEID = LocalSEIDL();
       
  1138 			Data().TrimStart(1); // gulp SEID
       
  1139 			HBufC8* securityData = HBufC8::NewMaxL(Data().Length());
       
  1140 			TPtr8 des = securityData->Des();
       
  1141 			Data().CopyOut(des);
       
  1142 			//HBuf ownserhsip is transferred
       
  1143 			iSignallingChannel.SecurityControlIndication(aLabel, localSEID, securityData);
       
  1144 
       
  1145 			break;
       
  1146 			}
       
  1147 		case EResponseAccept:
       
  1148 			{
       
  1149 			err = CheckPacketLength(KAvdtpSecurityControlAcceptMinimumLength, KAvdtpSecurityControlAcceptMaximumLength);
       
  1150 			// fish out the capabilities from mbufchain
       
  1151 			HBufC8* securityData = HBufC8::NewMaxL(Data().Length());
       
  1152 			TPtr8 des = securityData->Des();
       
  1153 			Data().CopyOut(des);
       
  1154 			
       
  1155 			iSignallingChannel.SecurityControlConfirm(aLabel, err, *securityData);
       
  1156 			
       
  1157 			delete securityData;
       
  1158 			break;
       
  1159 			}
       
  1160 		case EResponseReject:
       
  1161 			{
       
  1162 			err = CheckPacketLength(KAvdtpSecurityControlRejectMinimumLength, KAvdtpSecurityControlRejectMaximumLength);
       
  1163 			err = (err==KErrNone) ? SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(Data().First()->Ptr()[0])) : 
       
  1164 									KErrCorrupt;
       
  1165 			iSignallingChannel.SecurityControlConfirm(aLabel, err, KNullDesC8);
       
  1166 			break;
       
  1167 			}
       
  1168 		case EGeneralReject:
       
  1169 			{
       
  1170 			err = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(static_cast<TAvdtpSignallingErrorCode>(EAvdtpNotSupportedCommand));
       
  1171 			iSignallingChannel.SecurityControlConfirm(aLabel, err, KNullDesC8);
       
  1172 			break;
       
  1173 			}
       
  1174 		}	
       
  1175 	}
       
  1176 
       
  1177 
       
  1178 /**
       
  1179 Splits the AVDTP message part from the packet
       
  1180 Returns a new mbufchain containing the message
       
  1181 The client has to free the input and output chains when convenient
       
  1182 */
       
  1183 /*static*/ RMBufChain CAvdtpInboundSignallingMessage::MessageL(RMBufChain& aPacket, const TAvdtpPacketType aPacketType)
       
  1184 	{
       
  1185 	LOG_STATIC_FUNC
       
  1186 	TInt offset = 0;
       
  1187 	
       
  1188 	switch (aPacketType)
       
  1189 		{
       
  1190 		case ESingle:
       
  1191 		case EEnd:
       
  1192 		case EContinue:
       
  1193 			__ASSERT_DEBUG(aPacket.Length() > 0, Panic(EAvdtpGotBadDataFromL2CAP));
       
  1194 			//if not in DEBUG mode, prevent MBuf panic by leaving here if 
       
  1195 			//we have received a corrupt frame.
       
  1196 			User::LeaveIfError(aPacket.Length() > 0 ? KErrNone : KErrUnderflow);
       
  1197 			offset = 1;
       
  1198 			break;
       
  1199 		case EStart:
       
  1200 			__ASSERT_DEBUG(aPacket.Length() > 1, Panic(EAvdtpGotBadDataFromL2CAP));
       
  1201 			//if not in DEBUG mode, prevent MBuf panic by leaving here if 
       
  1202 			//we have received a corrupt frame.
       
  1203 			User::LeaveIfError(aPacket.Length() > 1 ? KErrNone : KErrUnderflow);
       
  1204 			offset = 2;
       
  1205 			break;
       
  1206 		}
       
  1207 	RMBufChain message;
       
  1208 	aPacket.SplitL(offset, message);
       
  1209 	return message;
       
  1210 	}
       
  1211 
       
  1212 /**
       
  1213 Assumes NOSP is at offset 1
       
  1214 */
       
  1215 /*static*/ TUint8 CAvdtpInboundSignallingMessage::NumberSignalPackets(const RMBufChain& aChain)
       
  1216 	{
       
  1217 	LOG_STATIC_FUNC
       
  1218 	return aChain.First()->Ptr()[1]; // The length was checked in MessageL, so we don't need to check it here.
       
  1219 	}
       
  1220 
       
  1221 /**
       
  1222 Note for Start packets this assumes NOSP has been consumed, it takes the zeroth byte as the signal
       
  1223 Can only be used for Single and Start packets - no signal in Continue and End packets
       
  1224 */
       
  1225 /*static*/ TAvdtpMessage CAvdtpInboundSignallingMessage::SignalIdentifier(const RMBufChain& aChain)
       
  1226 	{
       
  1227 	LOG_STATIC_FUNC
       
  1228 	TAvdtpMessage message;
       
  1229 	if (aChain.First() == NULL) 
       
  1230 		{
       
  1231 		message = EAvdtpNull;
       
  1232 		}
       
  1233 	else 
       
  1234 		{
       
  1235 		message = static_cast<TAvdtpMessage>(aChain.First()->Ptr()[0] & KAvdtpSignalIdentifierMask);
       
  1236 		}
       
  1237 	return message;
       
  1238 	}
       
  1239 
       
  1240 /**
       
  1241 returns the (semantically local) SEID from the packet - leaves if bad seid
       
  1242 many commands received have SEID in the same place - this *assumes* that this is true
       
  1243 **/
       
  1244 TSEID CAvdtpInboundSignallingMessage::LocalSEIDL()
       
  1245 	{
       
  1246 	LOG_FUNC
       
  1247 	return TSEID::FromPacketL(Data().First()->Ptr()[0], ETrue); // The length of the packet is always checked by CheckPacketLengthL before this function is called
       
  1248 	}
       
  1249 	
       
  1250 /**
       
  1251 returns the (semantically remote) SEID from the packet - leaves if bad seid
       
  1252 many commands received have SEID in the same place - this *assumes* that this is true
       
  1253 **/
       
  1254 TSEID CAvdtpInboundSignallingMessage::RemoteSEIDL()
       
  1255 	{
       
  1256 	LOG_FUNC
       
  1257 	return TSEID::FromPacketL(Data().First()->Ptr()[0], EFalse); // The length of the packet is always checked by CheckPacketLengthL before this function is called
       
  1258 	}
       
  1259 	
       
  1260 /**
       
  1261 Returns what to do after packet sent:
       
  1262 e.g. setRTX, don't set RTX, or immediately scrub knowledge of sending
       
  1263 Whether or not the AVDTP Signalling RTX applies to this message
       
  1264 [calculated from the Message type based on GAVDTP 4.1.8]
       
  1265 
       
  1266 @return the action to use after sending
       
  1267 */
       
  1268 TPostSendAction CAvdtpOutboundSignallingMessage::PostSendAction() const
       
  1269 	{
       
  1270 	LOG_FUNC
       
  1271 	if (iMessageType == ECommand)
       
  1272 		{
       
  1273 		//OutBound Signalling message should never be EReserved
       
  1274 		__ASSERT_DEBUG(Signal()!=EReserved,Panic(EAvdtpInvalidReservedValueInOutboundSignallingMessage));
       
  1275 		switch(Signal())
       
  1276 			{
       
  1277 			case EAvdtpGetCapabilities:
       
  1278 			case EAvdtpDiscover:
       
  1279 			case EAvdtpSecurityControl:
       
  1280 				return EKeepDontSetRTX;
       
  1281 			default:
       
  1282 				return EKeepSetRTX;		
       
  1283 			}
       
  1284 		}
       
  1285 	else
       
  1286 		{
       
  1287 		return EDiscard;
       
  1288 		}	
       
  1289 	}
       
  1290 	
       
  1291 	
       
  1292 /**
       
  1293 Used for inbound command checking where the leave is trapped and a response sent
       
  1294 */
       
  1295 void  CAvdtpInboundSignallingMessage::CheckPacketLengthL(TUint aMin, TUint aMax)
       
  1296 	{
       
  1297 	LOG_FUNC
       
  1298 	User::LeaveIfError(CheckPacketLength(aMin, aMax));
       
  1299 	}
       
  1300 
       
  1301 /**
       
  1302 Used for inbound responses - doesn't leave as we don't send a response, but we do tell the client
       
  1303 that their command has completed with an AVDTP error
       
  1304 */	
       
  1305 TInt CAvdtpInboundSignallingMessage::CheckPacketLength(TUint aMin, TUint aMax)
       
  1306 	{
       
  1307 	LOG_FUNC
       
  1308 	TInt ret = KErrNone;
       
  1309 	
       
  1310 	TInt pktLen = Data().Length();
       
  1311 	
       
  1312 	if  (pktLen>aMax || pktLen<aMin)
       
  1313 		{
       
  1314 		ret = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadLength);
       
  1315 		}
       
  1316 	return ret;
       
  1317 	}
       
  1318 	
       
  1319 /*static*/	
       
  1320 TInt AvdtpSignallingMessageDiscover::Response::ParseL(const RMBufChain& aMessageData,
       
  1321 												 TDes8& aClientBuffer,
       
  1322 												 CRemoteSEPCache& aSEPCache,
       
  1323 												 const TBTDevAddr& aAddr)
       
  1324 	{
       
  1325 	LOG_STATIC_FUNC
       
  1326 	aClientBuffer.Zero();
       
  1327 	
       
  1328 	TInt numSEPs = (aMessageData.Length())/2;
       
  1329 	
       
  1330 	__ASSERT_DEBUG(numSEPs, Panic(EAvdtpBadSEPCount)); // this should have been policed earlier
       
  1331 	
       
  1332 	// initial checks
       
  1333 	if (numSEPs>KMaxAvdtpNumSEPs)
       
  1334 		{
       
  1335 		return KErrCorrupt;
       
  1336 		}
       
  1337 		
       
  1338 	if (aClientBuffer.MaxLength()<(numSEPs*sizeof(TAvdtpSEPInfo)))
       
  1339 		{
       
  1340 		return KErrNoMemory;
       
  1341 		}
       
  1342 	
       
  1343 	// ok - parse
       
  1344 	TInt err = KErrNone;
       
  1345 	
       
  1346 	for (TInt i=0;i<=numSEPs-1;i++)
       
  1347 		{
       
  1348 		TBuf8<KAvdtpPacketSEPInfoSize> dataBuf;
       
  1349 		dataBuf.SetLength(KAvdtpPacketSEPInfoSize);
       
  1350 		aMessageData.CopyOut(dataBuf,(i*KAvdtpPacketSEPInfoSize));
       
  1351 		
       
  1352 		TAvdtpSEPInfo sepInfo;
       
  1353 		sepInfo.SetSEID(TSEID::FromPacketL(dataBuf[0], EFalse));
       
  1354 		sepInfo.SetInUse(dataBuf[0] & 0x02 ? ETrue : EFalse);
       
  1355 		sepInfo.SetMediaType(static_cast<SymbianBluetoothAV::TBluetoothMediaType>
       
  1356 										(dataBuf[1]>>4));
       
  1357 		sepInfo.SetIsSink((dataBuf[1] & 0x08) ? ETrue : EFalse);
       
  1358 		
       
  1359 		err = aSEPCache.AddSEP(aAddr, sepInfo);
       
  1360 		
       
  1361 		if (err==KErrNone)
       
  1362 			{
       
  1363 			TPckg<TAvdtpSEPInfo> desc(sepInfo);
       
  1364 			aClientBuffer.Append(desc);	
       
  1365 			}
       
  1366 		}
       
  1367 	
       
  1368 	return err;
       
  1369 	}
       
  1370 
       
  1371 
       
  1372 /*static*/ void AvdtpSignallingMessageSetConfiguration::Command::FormatL(CAvdtpOutboundSignallingMessage& aSignallingMessage,
       
  1373 																	TSEID aACPSEID,
       
  1374 																	TSEID aINTSEID,
       
  1375 																	const RBuf8& aConfiguration)
       
  1376 	{
       
  1377 	LOG_STATIC_FUNC
       
  1378 	aSignallingMessage.AppendDataL(aACPSEID.PacketValue());
       
  1379 	aSignallingMessage.AppendDataL(aINTSEID.PacketValue());
       
  1380 	aSignallingMessage.AppendDataL(aConfiguration);
       
  1381 	}
       
  1382 
       
  1383 /*static*/ void AvdtpSignallingMessageReconfigure::Command::FormatL(CAvdtpOutboundSignallingMessage& aSignallingMessage,
       
  1384 																	TSEID aACPSEID,
       
  1385 																	const RBuf8& aConfiguration)
       
  1386 	{
       
  1387 	LOG_STATIC_FUNC
       
  1388 	aSignallingMessage.AppendDataL(aACPSEID.PacketValue());
       
  1389 	aSignallingMessage.AppendDataL(aConfiguration);
       
  1390 	}
       
  1391 
       
  1392 
       
  1393 /*static*/
       
  1394 void AvdtpSignallingMessage::Reject::FormatL(CAvdtpOutboundSignallingMessage& aSignallingMessage, 
       
  1395 					TBluetoothAvDistributionError aRejectionCode, const TDesC8* aRejectionData/*=NULL*/)
       
  1396 	{
       
  1397 	LOG_STATIC_FUNC
       
  1398 	if (aRejectionData)
       
  1399 		{
       
  1400 		aSignallingMessage.AppendDataL(*aRejectionData);
       
  1401 		}
       
  1402 	aSignallingMessage.AppendDataL(aRejectionCode);
       
  1403 	}
       
  1404 
       
  1405 
       
  1406 #ifdef _DEBUG
       
  1407 TBool CCapabilityFlogVisitor::Capability(TAvdtpServiceCategory /*aCat*/)
       
  1408 	{
       
  1409 //	FPrint(_L("Avdtp: Capability %d, payload %S"), aCat, &aCapPayload);
       
  1410 	return ETrue;
       
  1411 	}
       
  1412 #endif
       
  1413 
       
  1414 	
       
  1415 	
       
  1416 TPtrC8 CCapabilityExtractorVisitor::GetCapability() const
       
  1417 	{
       
  1418 	return iPtr;
       
  1419 	}
       
  1420 
       
  1421 	
       
  1422 
       
  1423 CCapabilityExtractorVisitor::CCapabilityExtractorVisitor(TAvdtpServiceCategory aRequiredCapability)
       
  1424 : iRequiredCapability(aRequiredCapability)
       
  1425 	{
       
  1426 	}
       
  1427 
       
  1428 TBool CCapabilityExtractorVisitor::Capability(TAvdtpServiceCategory aCat)
       
  1429 	{
       
  1430 	LOG_FUNC
       
  1431 	if (aCat == iRequiredCapability)
       
  1432 		{
       
  1433 		iPtr.Set(CapabilityPayload());
       
  1434 		return EFalse;
       
  1435 		}
       
  1436 	else
       
  1437 		{
       
  1438 		return ETrue;
       
  1439 		}
       
  1440 	}
       
  1441 
       
  1442 
       
  1443 TBool CCapabilityValidateVisitor::Capability(TAvdtpServiceCategory aCat)
       
  1444 	{
       
  1445 	LOG_FUNC
       
  1446 	// check lengths of payload of capability for known categories
       
  1447 	// unknown categories are marked invalid
       
  1448 	TBool valid = ETrue;
       
  1449 	
       
  1450 	switch (aCat)
       
  1451 		{
       
  1452 		case EServiceCategoryMediaTransport:
       
  1453  		valid = IsLOSCValid(CapabilityPayload().Length(), KAvdtpCapabilityMediaTransportMinimumLOSC, KAvdtpCapabilityMediaTransportMaximumLOSC);
       
  1454 		iResult = valid ? KErrNone : SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadMediaTransportFormat);
       
  1455  		break;
       
  1456 		case EServiceCategoryReporting:
       
  1457 		valid = IsLOSCValid(CapabilityPayload().Length(), KAvdtpCapabilityReportingMinimumLOSC, KAvdtpCapabilityReportingMaximumLOSC);
       
  1458 		// spec doesn't (yet?) have a specific error code for this! use bad-payload instead
       
  1459 		iResult = valid ? KErrNone : SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadPayloadFormat);
       
  1460 		break;
       
  1461 		case EServiceCategoryRecovery:
       
  1462 		valid = IsLOSCValid(CapabilityPayload().Length(), KAvdtpCapabilityRecoveryMinimumLOSC, KAvdtpCapabilityRecoveryMaximumLOSC);
       
  1463 		iResult = valid ? KErrNone : SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadRecoveryFormat);
       
  1464 		break;
       
  1465 		case EServiceCategoryContentProtection:
       
  1466 		valid = IsLOSCValid(CapabilityPayload().Length(), KAvdtpCapabilityContentProtectionMinimumLOSC, KAvdtpCapabilityContentProtectionMaximumLOSC);
       
  1467 		iResult = valid ? KErrNone : SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadCpFormat);
       
  1468 		break;
       
  1469 		case EServiceCategoryHeaderCompression:
       
  1470 		valid = IsLOSCValid(CapabilityPayload().Length(), KAvdtpCapabilityHeaderCompressionMinimumLOSC, KAvdtpCapabilityHeaderCompressionMaximumLOSC);
       
  1471 		iResult = valid ? KErrNone : SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadRohcFormat);
       
  1472 		break;
       
  1473 		case EServiceCategoryMultiplexing:
       
  1474 		valid = IsLOSCValid(CapabilityPayload().Length(), KAvdtpCapabilityMultiplexingMinimumLOSC, KAvdtpCapabilityMultiplexingMaximumLOSC);
       
  1475 		iResult = valid ? KErrNone : SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadMultiplexingFormat);
       
  1476 		break;
       
  1477 		case EServiceCategoryMediaCodec:
       
  1478 		valid = IsLOSCValid(CapabilityPayload().Length(), KAvdtpCapabilityMediaCodecMinimumLOSC, KAvdtpCapabilityMediaCodecMaximumLOSC);
       
  1479 		// daft spec doesn't have one for this! use bad-payload instead
       
  1480 		iResult = valid ? KErrNone : SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadPayloadFormat);
       
  1481 		break;
       
  1482 		
       
  1483 		default:
       
  1484 		// unknown capability
       
  1485 		iResult = SymbianBluetoothAV::ConvertToSymbianError::AvdtpError(EAvdtpBadServCategory);
       
  1486 		valid = EFalse;
       
  1487 		}
       
  1488 
       
  1489 	if (!valid)		
       
  1490 		{
       
  1491 		// store the invalid details
       
  1492 		iInvalidCategory = aCat;
       
  1493 		}
       
  1494 		
       
  1495 	return valid; // at present this visitor causes termination at first bad category
       
  1496 	}
       
  1497 
       
  1498 inline TInt CCapabilityValidateVisitor::Result() const
       
  1499 	{
       
  1500 	LOG_FUNC
       
  1501 	return iResult;
       
  1502 	}
       
  1503 
       
  1504 inline TAvdtpServiceCategory CCapabilityValidateVisitor::InvalidCategory() const
       
  1505 	{
       
  1506 	LOG_FUNC
       
  1507 	return iInvalidCategory;
       
  1508 	}
       
  1509 
       
  1510 TBool CCapabilityRemoveUnknownVisitor::Capability(TAvdtpServiceCategory aCat)
       
  1511 	{
       
  1512 	LOG_FUNC
       
  1513 
       
  1514 	switch (aCat)
       
  1515 		{
       
  1516 		case EServiceCategoryMediaTransport:
       
  1517  		case EServiceCategoryReporting:
       
  1518 		case EServiceCategoryRecovery:
       
  1519 		case EServiceCategoryContentProtection:
       
  1520 		case EServiceCategoryHeaderCompression:
       
  1521 		case EServiceCategoryMultiplexing:
       
  1522 		case EServiceCategoryMediaCodec:
       
  1523 			// Do nothing
       
  1524 			break;
       
  1525 		
       
  1526 		default:
       
  1527 		// unknown capability
       
  1528 			CapabilityDes().Zero();
       
  1529 		}
       
  1530 		
       
  1531 	return ETrue;
       
  1532 	}
       
  1533 
       
  1534 inline TBool CCapabilityValidateVisitor::IsLOSCValid(TUint aLOSC, TUint aMin, TUint aMax)
       
  1535 	{
       
  1536 	LOG_FUNC
       
  1537 	return (aLOSC<=aMax && aLOSC>=aMin);
       
  1538 	}
       
  1539 
       
  1540 // static forward functions to make more efficient than pointer-to-member-function
       
  1541 void CAvdtpInboundSignallingMessage::HandleDiscoverL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1542 	{
       
  1543 	LOG_STATIC_FUNC
       
  1544 	aThat.DoHandleDiscoverL(aLabel);
       
  1545 	}
       
  1546 	
       
  1547 void CAvdtpInboundSignallingMessage::HandleGetCapsL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1548 	{
       
  1549 	LOG_STATIC_FUNC
       
  1550 	aThat.DoHandleGetCapsL(aLabel);	
       
  1551 	}
       
  1552 	
       
  1553 void CAvdtpInboundSignallingMessage::HandleSetConfigL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1554 	{
       
  1555 	LOG_STATIC_FUNC
       
  1556 	aThat.DoHandleSetConfigL(aLabel);
       
  1557 	}
       
  1558 	
       
  1559 void CAvdtpInboundSignallingMessage::HandleGetConfigL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1560 	{
       
  1561 	LOG_STATIC_FUNC
       
  1562 	aThat.DoHandleGetConfigL(aLabel);
       
  1563 	}
       
  1564 	
       
  1565 void CAvdtpInboundSignallingMessage::HandleReconfigL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1566 	{
       
  1567 	LOG_STATIC_FUNC
       
  1568 	aThat.DoHandleReconfigL(aLabel);
       
  1569 	}
       
  1570 	
       
  1571 void CAvdtpInboundSignallingMessage::HandleOpenL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1572 	{
       
  1573 	LOG_STATIC_FUNC
       
  1574 	aThat.DoHandleOpenL(aLabel);
       
  1575 	}
       
  1576 	
       
  1577 void CAvdtpInboundSignallingMessage::HandleStartL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1578 	{
       
  1579 	LOG_STATIC_FUNC
       
  1580 	aThat.DoHandleStartL(aLabel);
       
  1581 	}
       
  1582 	
       
  1583 void CAvdtpInboundSignallingMessage::HandleReleaseL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1584 	{
       
  1585 	LOG_STATIC_FUNC
       
  1586 	aThat.DoHandleReleaseL(aLabel);
       
  1587 	}
       
  1588 	
       
  1589 void CAvdtpInboundSignallingMessage::HandleSuspendL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1590 	{
       
  1591 	LOG_STATIC_FUNC
       
  1592 	aThat.DoHandleSuspendL(aLabel);
       
  1593 	}
       
  1594 	
       
  1595 void CAvdtpInboundSignallingMessage::HandleAbortL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1596 	{
       
  1597 	LOG_STATIC_FUNC
       
  1598 	aThat.DoHandleAbortL(aLabel);
       
  1599 	}
       
  1600 	
       
  1601 void CAvdtpInboundSignallingMessage::HandleSecurityControlL(CAvdtpInboundSignallingMessage& aThat, TAvdtpTransactionLabel aLabel)
       
  1602 	{
       
  1603 	LOG_STATIC_FUNC
       
  1604 	aThat.DoHandleSecurityControlL(aLabel);
       
  1605 	}
       
  1606