bluetooth/btstack/l2cap/l2cap.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 1999-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 // Defines the l2cap protocol class
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef L2CAP_H
       
    19 #define L2CAP_H
       
    20 
       
    21 #include <es_prot.h>
       
    22 #include <bt_sock.h>
       
    23 #include "secman.h"
       
    24 #include "notification.h"
       
    25 #include "bt.h"
       
    26 #include "l2capMuxController.h"
       
    27 #include <es_prot_internal.h>
       
    28 #include <bluetooth/lmoptions.h>
       
    29 
       
    30 // Stream and Datagram I/f's are mutually exclusive. You can't have some sockets one
       
    31 // time and some the other -- esock will always give precedence to stream.
       
    32 const TUint KL2CAPSeqPacketServiceInfo = 
       
    33   KSIReliable|KSIInOrder|KSIDatagram|KSIGracefulClose|KSIBroadcast|KSIQOS|KSICanReconnect;
       
    34 
       
    35 class CL2CAPSAPStateFactory;
       
    36 class CL2CAPSignalStateFactory;
       
    37 
       
    38 NONSHARABLE_CLASS(CL2CAPProtocol) : public CBluetoothProtocolBase
       
    39 	{
       
    40 public:
       
    41 	// Create ourselves
       
    42 	static CL2CAPProtocol* NewL(CBTSecMan& aSecMan, RBTControlPlane& aControlPlane, CBTCodServiceMan& aCodMan);
       
    43 	
       
    44 	// From CProtocolBase
       
    45 	// Factories
       
    46 	CServProviderBase* NewSAPL(TUint aSockType);
       
    47 	
       
    48 	void Close();
       
    49 	void Open();
       
    50 	void CloseNow();
       
    51 
       
    52     // From ProtocolManager before all binding.
       
    53 	void InitL(TDesC &aTag);
       
    54 	// From Protocol Manager - after all binding
       
    55 	void StartL();	
       
    56 	// From higher protocol
       
    57 	void BindL(CProtocolBase* aProtocol, TUint aId);
       
    58 	void BindToL(CProtocolBase* aProtocol);	// From Protocol Manager
       
    59 
       
    60 	// Query functions
       
    61 	void Identify(TServerProtocolDesc* aDesc)const;	
       
    62 	static void ProtocolIdentity(TServerProtocolDesc* aDesc);	
       
    63 
       
    64 	// L2CAP specific functions
       
    65 	CL2CAPSAPStateFactory& StateFactory() const;  
       
    66 	CL2CAPSignalStateFactory& SigStateFactory() const;  
       
    67 
       
    68 	// Get our local address
       
    69 	const TBTDevAddr& LocalBTAddr() const;
       
    70 
       
    71 	virtual TInt BearerConnectComplete(const TBTDevAddr& aAddr, CServProviderBase* aSAP);
       
    72 
       
    73 	// Interface for the L2CAP Mux
       
    74 	CL2CAPMuxController& MuxController() const;
       
    75 	
       
    76 	// A queue of resources has been reduced to zero so try to remove stack
       
    77 	void TryToClose();
       
    78 
       
    79 private:
       
    80     // Functions	
       
    81 	CL2CAPProtocol(CBTSecMan& aSecMan, RBTControlPlane& aControlPlane, CBTCodServiceMan& aCodMan);
       
    82 	~CL2CAPProtocol();
       
    83 	void ConstructL();
       
    84 
       
    85 	void QueIdleTimerEntry();
       
    86 	void RemoveIdleTimerEntry();
       
    87 
       
    88 	static TInt TryToClose(TAny* aProtocol);
       
    89 	// Start Listening
       
    90 	virtual TInt StartProtocolListening();
       
    91 	
       
    92 	// Data members
       
    93 	// Singleton objects
       
    94 	CL2CAPSAPStateFactory*		iStateFactory;
       
    95 	CL2CAPSignalStateFactory*	iSigStateFactory;
       
    96 	
       
    97 	TDeltaTimerEntry			iIdleTimerEntry;
       
    98 	TBool						iIdleEntryQueued;
       
    99 	
       
   100 	TBool                       iClosePending;
       
   101 	
       
   102 	CL2CAPMuxController* 		iMuxController;
       
   103 #ifdef _DEBUG
       
   104 public:
       
   105 	TUint	iDebugOptionMask;
       
   106 #endif
       
   107 	};
       
   108 
       
   109 inline CL2CAPMuxController& CL2CAPProtocol::MuxController() const
       
   110 	{
       
   111 	return *iMuxController;
       
   112 	}
       
   113 
       
   114 #endif