|
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 Channel Config class |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef L2CAPCHANNELCONFIG_H |
|
19 #define L2CAPCHANNELCONFIG_H |
|
20 |
|
21 #include <bt_sock.h> |
|
22 #include <bttypes.h> |
|
23 |
|
24 #include "L2types.h" |
|
25 #include "L2CapFecNegotiator.h" |
|
26 #include "l2capEntityConfig.h" |
|
27 #include "l2capSigPacketConfigure.h" |
|
28 |
|
29 // Forward declarations |
|
30 class TL2CAPEntityConfig; |
|
31 class HConfigureRequest; |
|
32 class HConfigureResponse; |
|
33 class RMBufChain; |
|
34 |
|
35 #ifndef __UNITTest__ |
|
36 class CL2CapSAPSignalHandler; |
|
37 #else |
|
38 class CL2CapConfigProxy; |
|
39 #endif |
|
40 |
|
41 NONSHARABLE_CLASS(CL2CapChannelConfig) : public CBase |
|
42 { |
|
43 public: |
|
44 enum TChannelConfigStatus |
|
45 { |
|
46 EChannelConfigOutstanding, |
|
47 EChannelConfigComplete, |
|
48 EChannelConfigFailed, |
|
49 }; |
|
50 |
|
51 // Configuration constants |
|
52 const static TUint16 KMinOutgoingFlushTimeout = TL2CapConfig::EMinDataObsolescenceTimeout; //min physically possible |
|
53 ~CL2CapChannelConfig(); |
|
54 |
|
55 static CL2CapChannelConfig* NewL(CL2CapSAPSignalHandler& aSAPSignalHandler); |
|
56 |
|
57 TInt HandleConfigRequest(HConfigureRequest& aConfigRequest, RMBufChain& aUnknownOptions); |
|
58 TInt HandleConfigResponse(HConfigureResponse& aConfigResponse, RMBufChain& aUnknownOptions); |
|
59 // This does the actual handling and sends a response to a whole Config Request "transaction", |
|
60 // so that segmented config requests are correctly handled. |
|
61 TInt ConfigRequestComplete(TBool aConfigRequestSent, TConfigResponseResult& aResult); |
|
62 |
|
63 void CloneChannelConfig(const CL2CapChannelConfig& aCL2CapChannelConfig); |
|
64 TInt UpdateLocalConfigWithEntityCapabilities(); |
|
65 |
|
66 TInt UpdateConfigAPIChange(const TL2CapConfig& aAPIConfig, TBool& aOnTheAirReconfigRequired); |
|
67 |
|
68 void RegisterL2CapEntityConfig(TL2CAPEntityConfig& aL2CapEntityConfig); |
|
69 void DetachChannelConfig(); |
|
70 inline TBool IsPeerInfoDefined(); |
|
71 |
|
72 TChannelConfigStatus LocalConfigurationStatus() const; |
|
73 |
|
74 TInt GetChannelMode(TL2CapChannelMode& aMode) const; |
|
75 |
|
76 // Accessors for configuration options. |
|
77 inline TL2CapConfigurationOptionGroup<TMTUOption>& IncomingMTU() const; |
|
78 inline TL2CapConfigurationOptionGroup<TMTUOption>& OutgoingMTU() const; |
|
79 inline TL2CapConfigurationOptionGroup<TFlushTimeoutDurationOption>& IncomingFlushTimeout() const; |
|
80 inline TL2CapConfigurationOptionGroup<TFlushTimeoutDurationOption>& OutgoingFlushTimeout() const; |
|
81 inline TL2CapConfigurationOptionGroup<TQualityOfServiceOption>& IncomingQOS() const; |
|
82 inline TL2CapConfigurationOptionGroup<TQualityOfServiceOption>& OutgoingQOS() const; |
|
83 inline TL2CapFecNegotiator& FecNegotiator(); |
|
84 inline const TL2CapFecNegotiator& FecNegotiator() const; |
|
85 |
|
86 private: |
|
87 #ifndef __UNITTest__ |
|
88 CL2CapChannelConfig(CL2CapSAPSignalHandler& aSAPSignalHandler); |
|
89 #else |
|
90 CL2CapChannelConfig(CL2CapConfigProxy& aSAPSignalHandler); |
|
91 #endif |
|
92 void ConstructL(); |
|
93 |
|
94 TBool GenerateFecOptions(const TL2CapEntityInfo& aPeerEntityConfig); |
|
95 TInt UpdateReliability(const TL2CapConfig& aApiConfig); |
|
96 TInt UpdateMtuMru(const TL2CapConfig& aApiConfig, TBool& aOnTheAirReconfigRequired); |
|
97 |
|
98 private: |
|
99 // Configuration members. |
|
100 // MTU / MRU |
|
101 TL2CapConfigurationOptionGroup<TMTUOption>* iIncomingMTU; |
|
102 TL2CapConfigurationOptionGroup<TMTUOption>* iOutgoingMTU; |
|
103 |
|
104 // Incoming and outgoing Flush timers. |
|
105 TL2CapConfigurationOptionGroup<TFlushTimeoutDurationOption>* iIncomingFlushTimeoutDuration; |
|
106 TL2CapConfigurationOptionGroup<TFlushTimeoutDurationOption>* iOutgoingFlushTimeoutDuration; |
|
107 |
|
108 // Incoming and outgoing QoS |
|
109 TL2CapConfigurationOptionGroup<TQualityOfServiceOption>* iIncomingQOS; |
|
110 TL2CapConfigurationOptionGroup<TQualityOfServiceOption>* iOutgoingQOS; |
|
111 |
|
112 // Incoming and outgoing FEC |
|
113 TL2CapFecNegotiator iFecNegotiator; |
|
114 |
|
115 #ifndef __UNITTest__ |
|
116 CL2CapSAPSignalHandler& iSAPSignalHandler; |
|
117 #else |
|
118 CL2CapConfigProxy& iSAPSignalHandler; |
|
119 #endif |
|
120 TL2CAPEntityConfig* iL2CapEntityConfig; // Non-owned. |
|
121 |
|
122 TL2CapConfig::TChannelReliability iRequestedChannelReliability; |
|
123 TBool iLegacyModesDisallowed; |
|
124 TUint16 iRequestedFlushTimeout; |
|
125 TUint16 iRequestedRetransmissionTimeout; |
|
126 |
|
127 // Thanks to the possibility of segmented ConfigRequests, we need |
|
128 // this to collect all the options as Config Request segments flow in. |
|
129 // Then once the whole ConfigRequest transaction is received, we process this. |
|
130 TL2CapConfigParamOptions iReceivedConfigRequestOptions; |
|
131 }; |
|
132 |
|
133 |
|
134 // Accessors for configuration options. |
|
135 inline TL2CapConfigurationOptionGroup<TMTUOption>& CL2CapChannelConfig::IncomingMTU() const |
|
136 { |
|
137 return *iIncomingMTU; |
|
138 } |
|
139 |
|
140 inline TL2CapConfigurationOptionGroup<TMTUOption>& CL2CapChannelConfig::OutgoingMTU() const |
|
141 { |
|
142 return *iOutgoingMTU; |
|
143 } |
|
144 |
|
145 inline TL2CapConfigurationOptionGroup<TFlushTimeoutDurationOption>& CL2CapChannelConfig::IncomingFlushTimeout() const |
|
146 { |
|
147 return *iIncomingFlushTimeoutDuration; |
|
148 } |
|
149 |
|
150 inline TL2CapConfigurationOptionGroup<TFlushTimeoutDurationOption>& CL2CapChannelConfig::OutgoingFlushTimeout() const |
|
151 { |
|
152 return *iOutgoingFlushTimeoutDuration; |
|
153 } |
|
154 |
|
155 inline TL2CapConfigurationOptionGroup<TQualityOfServiceOption>& CL2CapChannelConfig::IncomingQOS() const |
|
156 { |
|
157 return *iIncomingQOS; |
|
158 } |
|
159 |
|
160 inline TL2CapConfigurationOptionGroup<TQualityOfServiceOption>& CL2CapChannelConfig::OutgoingQOS() const |
|
161 { |
|
162 return *iOutgoingQOS; |
|
163 } |
|
164 |
|
165 inline TL2CapFecNegotiator& CL2CapChannelConfig::FecNegotiator() |
|
166 { |
|
167 return iFecNegotiator; |
|
168 } |
|
169 |
|
170 inline const TL2CapFecNegotiator& CL2CapChannelConfig::FecNegotiator() const |
|
171 { |
|
172 return iFecNegotiator; |
|
173 } |
|
174 |
|
175 inline TBool CL2CapChannelConfig::IsPeerInfoDefined() |
|
176 { |
|
177 return iL2CapEntityConfig && iL2CapEntityConfig->PeerInfoDefined(); |
|
178 } |
|
179 |
|
180 #endif |