bluetooth/btstack/l2cap/l2capSignalHandler.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This is the base class for handling L2CAP signalling.
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef L2CAPSIGNALHANDLER_H
       
    19 #define L2CAPSIGNALHANDLER_H
       
    20 
       
    21 #include <e32std.h>
       
    22 #include <e32base.h>
       
    23 #include <bt_sock.h>
       
    24 
       
    25 #include "l2constants.h"
       
    26 #include "L2types.h"
       
    27 
       
    28 #include "L2CapPDU.h"
       
    29 
       
    30 class HConnectionResponse;
       
    31 class HConnectionRequest;
       
    32 class HEchoRequest;
       
    33 class HEchoResponse;
       
    34 class HConfigureRequest;
       
    35 class HConfigureResponse;
       
    36 class HDisconnectRequest;
       
    37 class HDisconnectResponse;
       
    38 class HInformationRequest;
       
    39 class HInformationResponse;
       
    40 class HCommandReject;
       
    41 class HInvalidCommand;
       
    42 
       
    43 class CL2CAPConnectionSAP;
       
    44 
       
    45 
       
    46 NONSHARABLE_CLASS(CL2CapSignalHandler) : public CBase
       
    47 	{
       
    48 public:
       
    49 	virtual ~CL2CapSignalHandler();
       
    50 	virtual HL2CapPDU* GetPDU();
       
    51 
       
    52 	virtual TBool HandleIncomingCFrame(HCFramePDU* aCFrame);
       
    53 
       
    54 	// Process incoming commands
       
    55 	virtual TBool HandleConnectionResponse(HConnectionResponse* aConnectionResponse);
       
    56 	virtual TBool HandleConnectionRequest(HConnectionRequest* aConnectionRequest);
       
    57 	virtual TBool HandleEchoRequest(HEchoRequest* aEchoRequest);
       
    58 	virtual TBool HandleEchoResponse(HEchoResponse* aEchoResponse);
       
    59 	virtual TBool HandleConfigureRequest(HConfigureRequest* aConfigRequest);
       
    60 	virtual TBool HandleConfigureResponse(HConfigureResponse* aConfigResponse);
       
    61 	virtual TBool HandleDisconnectRequest(HDisconnectRequest* aDisconnectRequest);	
       
    62 	virtual TBool HandleDisconnectResponse(HDisconnectResponse* aDisconnectResponse);	
       
    63 	virtual TBool HandleInformationRequest(HInformationRequest* aInformationRequest);
       
    64 	virtual TBool HandleInformationResponse(HInformationResponse* aInformationResponse);
       
    65 	virtual TBool HandleCommandReject(HCommandReject* aCommandReject);
       
    66 	virtual TBool HandleInvalidCommand(HInvalidCommand* aInvalidCommand);
       
    67 
       
    68 	virtual void Error(TInt aErrorCode, MSocketNotify::TOperationBitmasks aErrorAction) = 0;
       
    69 
       
    70 	virtual void CommandResponseFailure(HL2CapCommand* aCommand) = 0;
       
    71 
       
    72 	void SendInvalidCIDCommandReject(TUint8 aId, TL2CAPPort aSourceCID, TL2CAPPort aDestinationCID);
       
    73 
       
    74 	void AddToOutgoingQueue(HL2CapCommand* aCommand);
       
    75 	TBool IsDuplicateCommandRequest(HL2CapCommand* aCommand);
       
    76 	
       
    77 	void ChannelConfigured();
       
    78 
       
    79 	void HandleLinkError();
       
    80 	void DrainPendingCommands();
       
    81 	void FlushPendingCommands();
       
    82 	void FlushAwaitingResponseCommands();
       
    83 	void FlushAllQueues();
       
    84 
       
    85 	TUint8 CurrentRTXTimerDuration(TUint8 aBaseRTXTimerDuration) const;
       
    86 
       
    87 	inline CL2CAPMux& Mux() const;
       
    88 	
       
    89 	
       
    90 protected:
       
    91 	CL2CapSignalHandler(CL2CAPMux* aMuxer = 0);
       
    92 	
       
    93 	void DeleteCommands(TDblQue<HL2CapCommand>& aCommandsToDelete );
       
    94 	
       
    95 	HL2CapCommand* FindMatchingOutstandingRequest(TUint8 aExpectedCommandCode, TUint8 aId);
       
    96 	
       
    97 	virtual void PendingCommandsDrained() = 0;
       
    98 
       
    99 private:
       
   100 
       
   101 // Class Members.
       
   102 protected:
       
   103 	enum
       
   104 		{
       
   105 		EMatchAnyL2CAPRequest = 0,
       
   106 		};
       
   107 		
       
   108 	CL2CAPMux* iMuxer;
       
   109 
       
   110 	TBool iDrainPendingCommands;
       
   111 
       
   112 	TDblQue<HL2CapCommand> iPendingCommands;
       
   113 	TDblQue<HL2CapCommand> iCommandsAwaitingResponse;
       
   114 	TDblQue<HL2CapCommand> iSentResponses;
       
   115 	};
       
   116 
       
   117 
       
   118 inline CL2CAPMux& CL2CapSignalHandler::Mux() const
       
   119 	{
       
   120 	return (*iMuxer);
       
   121 	}
       
   122 		
       
   123 
       
   124 #endif