|
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 Mux |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef L2SIGNALMGR_H |
|
19 #define L2SIGNALMGR_H |
|
20 |
|
21 #include <e32base.h> // CBase |
|
22 #include <es_prot.h> // MSocketNotify |
|
23 #include <bt_sock.h> |
|
24 |
|
25 #include "notification.h" |
|
26 #include "L2CapPDU.h" |
|
27 |
|
28 class CL2CAPMuxController; |
|
29 class CL2CapSAPSignalHandler; |
|
30 class CL2CapLinkSignalHandler; |
|
31 |
|
32 class CL2CapBasicDataController; |
|
33 class MEchoResponseHandler; |
|
34 |
|
35 class TBTDevAddr; |
|
36 |
|
37 static const TUint KRemoteDeviceProcessRequestDuration = 1; // Time in seconds |
|
38 NONSHARABLE_CLASS(CL2CAPMux) : public CBase, |
|
39 private MSocketNotify, |
|
40 public MPhysicalLinkObserver, |
|
41 public MPduOwner |
|
42 { |
|
43 public: |
|
44 static CL2CAPMux* NewL(CL2CAPMuxController& aMuxController, const TBTDevAddr& aAddr); |
|
45 ~CL2CAPMux(); |
|
46 |
|
47 // Some notifications passed up from the linkmgr |
|
48 void IoctlComplete(TInt aErr, TUint level,TUint name,TDesC8* aBuf); |
|
49 void L2CapEntityConfigUpdated(); |
|
50 |
|
51 // From MSocketNotify |
|
52 void NewData(TUint aCount); |
|
53 void CanSend(); |
|
54 void ConnectComplete(); |
|
55 void ConnectComplete(const TDesC8& aConnectData); |
|
56 void ConnectComplete(CServProviderBase& aSSP); |
|
57 void ConnectComplete(CServProviderBase& aSSP,const TDesC8& aConnectData); |
|
58 void CanClose(TDelete aDelete = EDelete); |
|
59 void CanClose(const TDesC8& aDisconnectData, TDelete aDelete = EDelete); |
|
60 void Error(TInt aError,TUint aOperationMask = EErrorAllOperations); |
|
61 void Disconnect(); |
|
62 void Disconnect(TDesC8& aDisconnectData); |
|
63 |
|
64 void IoctlComplete(TDesC8 *aBuf); |
|
65 void NoBearer(const TDesC8& aConnectionInfo); |
|
66 void Bearer(const TDesC8& aConnectionInfo); |
|
67 |
|
68 // MPduOwner |
|
69 virtual void HandlePduSendComplete(HL2CapPDU& aPdu); |
|
70 virtual void HandlePduSendError(HL2CapPDU& aPdu); |
|
71 |
|
72 // Signal packet timer interface |
|
73 |
|
74 // Getters & Setters |
|
75 const TBTDevAddr& RemoteBTAddr() const; |
|
76 TUint8 NextSigId(); |
|
77 CL2CAPMuxController& MuxController() const; |
|
78 |
|
79 TInt SetOption(TUint level,TUint name,const TDesC8 &aOption); |
|
80 TInt GetOption(TUint level,TUint name,TDes8& aOption) const; |
|
81 |
|
82 void RegisterSAPSignalHandler(CL2CapSAPSignalHandler& aSAPSigHandler); |
|
83 void DetachFromMux(CL2CapSAPSignalHandler& aSAPSigHandler); |
|
84 |
|
85 void CompleteACLConnect(CServProviderBase* aSAP); |
|
86 |
|
87 void RegisterDataPDUHandler(CL2CapBasicDataController& aPDUDataHandler); |
|
88 void DataChannelRemoved(CL2CapBasicDataController* aDataController); |
|
89 void MuxerPriorityUpdate(TInt aPriority); |
|
90 TInt GetSumMuxerChannelPriorities(); |
|
91 void ChannelPriorityUpdated(CL2CapBasicDataController& aDataController); |
|
92 |
|
93 void PDUAvailable(); |
|
94 |
|
95 void ProcessFlushTimerExpiry(); |
|
96 TUint16 SigMTU() const; |
|
97 |
|
98 void ErrorAllSignalHandlers(TInt aError); |
|
99 |
|
100 TInt SendEchoRequest(const TDes8* aData, CL2CapSAPSignalHandler& aEchoResponseHandler); |
|
101 void EchoResponseReceived(const TDesC8* aData, MEchoResponseHandler& aEchoResponseHandler); |
|
102 |
|
103 TInt GetFreeCID(TL2CAPPort& aReturnPort); |
|
104 TInt GetACLMTU() const; |
|
105 |
|
106 CL2CapSAPSignalHandler* GetSignalHandlerWithRemoteCID(TL2CAPPort aRemoteCID); |
|
107 |
|
108 //From MPhysicalLinkObserver |
|
109 void PhysicalLinkChange(const TBTBasebandEventNotification& aEvent, CPhysicalLink& aPhysicalLink); |
|
110 TPhysicalLinkObserverQLink& ObserverQLink() {return iQlink;}; |
|
111 |
|
112 TUint8 AdjustRTXTimerForSniffMode(TUint8 aBaseRTXTimerDuration) const; |
|
113 |
|
114 private: |
|
115 CL2CAPMux(CL2CAPMuxController&, const TBTDevAddr& aAddr); |
|
116 void ConstructL(); |
|
117 |
|
118 void PacketComplete(); |
|
119 TBool HardwareFlushAllowed(); |
|
120 |
|
121 TBool Idle(); |
|
122 TInt MuxIdled(); |
|
123 void CancelIdle(); |
|
124 void StartIdleTimer(); |
|
125 static TInt IdleTimerExpired(TAny *aMuxer); |
|
126 static TInt AsyncCallBackForIdleMux(TAny *aMuxer); |
|
127 static TInt AsyncCallBackForTryToSend(TAny *aMuxer); |
|
128 void NewL2CAPData(RMBufChain& aData, TUint8 aFlag); |
|
129 |
|
130 void PriorityAddDataController(CL2CapBasicDataController& aDataController); |
|
131 void TryToSend(); |
|
132 |
|
133 public: |
|
134 TDblQueLink iMuxControllerLink; |
|
135 |
|
136 private: |
|
137 // Link info |
|
138 enum TLinkState |
|
139 { |
|
140 ELinkNone = 0, |
|
141 ELinkPending, |
|
142 EConnected, |
|
143 ELinkInbound, |
|
144 }; |
|
145 |
|
146 |
|
147 CL2CAPMuxController& iMuxController; //< Our Mux Controller |
|
148 TLinkState iLinkState; //< The state of the baseband link |
|
149 TBTDevAddr iRemote; //< The device we're talking to |
|
150 |
|
151 TDeltaTimerEntry iIdleTimerEntry; //< Disconnection idle timer |
|
152 TBool iIdleTimerActive; //< Is Idle timer running. |
|
153 |
|
154 CAsyncCallBack* iAsyncCallBackForTryToSend;//< Async. stuff: callback SendCallBack to send (medium priority) or, finally, TerminateCallBack to kill (high priority). |
|
155 CAsyncCallBack* iAsyncCallBackForIdleMux;//< For deleting idle muxers without a delay |
|
156 |
|
157 // the bound SAP |
|
158 CServProviderBase* iBoundSAP; |
|
159 |
|
160 //link level stuff |
|
161 TInt iACLMTU; |
|
162 TInt iACLMRU; |
|
163 TUint8 iSigId; |
|
164 |
|
165 TDblQue<CL2CapBasicDataController> iDataHandlers; |
|
166 TDblQue<CL2CapSAPSignalHandler> iSapSignalHandlers; |
|
167 CL2CapLinkSignalHandler* iBoundLinkSignalHandler; |
|
168 |
|
169 TDblQue<HL2CapPDU> iPDUsWaitingResendQ; |
|
170 TDblQue<HL2CapPDU> iPDUsWaitingSend; |
|
171 |
|
172 HFragmentedPDUSender* iFragmentSender; |
|
173 RMBufChain iIncomingPDU; |
|
174 |
|
175 TInt iTryToSendPriority; |
|
176 TBool iUpdateTryToSendPriority; |
|
177 |
|
178 TL2CAPPort iNextCID; |
|
179 TUint16 iNumberOfDataChannels; |
|
180 TBasebandTime iSniffInterval; |
|
181 |
|
182 TPhysicalLinkObserverQLink iQlink; |
|
183 }; |
|
184 |
|
185 inline const TBTDevAddr& CL2CAPMux::RemoteBTAddr() const |
|
186 { |
|
187 return iRemote; |
|
188 } |
|
189 |
|
190 inline CL2CAPMuxController& CL2CAPMux::MuxController() const |
|
191 { |
|
192 return iMuxController; |
|
193 } |
|
194 |
|
195 #endif |