|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Name : CTransport.h |
|
16 * Part of : ConnectionMgr |
|
17 * Version : SIP/4.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef __CTRANSPORT_H__ |
|
29 #define __CTRANSPORT_H__ |
|
30 |
|
31 #include "CTransportBase.h" |
|
32 #include "SipStackServerDefs.h" |
|
33 #include "TResponseRoute.h" |
|
34 #include "CSipConnectionMgr.h" |
|
35 |
|
36 |
|
37 //SIP version |
|
38 _LIT8(KDefaultSipVersion, "SIP/2.0"); |
|
39 _LIT8(KDefaultProtocol, "SIP"); |
|
40 _LIT8(KDefaultVersion, "2.0"); |
|
41 |
|
42 class MTransactionFinder; |
|
43 class MServerTaFactory; |
|
44 class MTransportOwner; |
|
45 class CSIPServerResolver; |
|
46 class CNetworkInfo; |
|
47 class COwnerSettingsList; |
|
48 class CSIPMessage; |
|
49 class CSIPRequest; |
|
50 class CSIPResponse; |
|
51 class CSIPViaHeader; |
|
52 class CTransportErrorHandler; |
|
53 class CSIPHostPort; |
|
54 class CSIPNATTraversalController; |
|
55 class CSocketContainer; |
|
56 class MSIPNATBindingObserver; |
|
57 |
|
58 class CTransport : public CTransportBase |
|
59 { |
|
60 public: |
|
61 |
|
62 virtual ~CTransport(); |
|
63 |
|
64 public: // From CTransportBase |
|
65 |
|
66 void Send( const TSIPTransportParams& aParams, |
|
67 CSIPResponse& aResponse, |
|
68 TTransactionId aId, |
|
69 TRequestStatus &aStatus ); |
|
70 void Send( const TSIPTransportParams& aParams, |
|
71 CSIPResponse& aResponse, |
|
72 const TInetAddr& aAddr, |
|
73 TRequestStatus &aStatus ); |
|
74 void Send( const TSIPTransportParams& aParams, |
|
75 CSIPRequest& aRequest, |
|
76 TBool aForceUDP, |
|
77 const TInetAddr& aAddr, |
|
78 TUint aOrigTransport, |
|
79 TRequestStatus &aStatus, |
|
80 TBool aPublicAddrResolved ); |
|
81 |
|
82 TBool HandleL( const TSIPTransportParams& aParams, |
|
83 CSIPMessage* aMessage, |
|
84 TTransactionId aId, |
|
85 TBool aIsStrict ); |
|
86 TBool HandleL( const TSIPTransportParams& aParams, |
|
87 CSIPMessage* aMessage, |
|
88 const TInetAddr& aAddr, |
|
89 TUint aLocalPort, |
|
90 TBool aIsStrict ); |
|
91 |
|
92 virtual TBool HandleMessage( const TSIPTransportParams& aParams, |
|
93 RStringF aProtocol, |
|
94 const TInetAddr& aRemoteAddr, |
|
95 TUint aLocalPort, |
|
96 TBool aIsStrict ) = 0; |
|
97 |
|
98 virtual TBool Handle( TUint32 aTransportId ); |
|
99 |
|
100 TBool Match( const TSIPTransportParams& aParams ); |
|
101 |
|
102 void GetAddrFromResponseL( const TSIPTransportParams& aParams, |
|
103 CSIPMessage& aMessage, |
|
104 TInetAddr& aAddr ); |
|
105 TUint ProtocolType(); |
|
106 TBool HasRemoteHost( const TSIPTransportParams& aParams, |
|
107 const TInetAddr& aRemoteHost, |
|
108 RStringF aProtocol ); |
|
109 |
|
110 virtual void Disconnect( const TInetAddr& /*aRemoteHost*/ ) {} |
|
111 virtual void ICMPErrorL( CSipConnectionMgr::TICMPError /*aICMPError*/, |
|
112 const TInetAddr& /*aSourceAddr*/ ) {} |
|
113 |
|
114 virtual TBool Remove( const TSIPTransportParams& aParams ); |
|
115 virtual TBool Remove( TUint32 /*aTransportId*/ ) {return ETrue;} |
|
116 virtual TBool Remove( MSIPNATBindingObserver& aSIPNATBindingObserver ); |
|
117 |
|
118 virtual TBool Shutdown( TUint32 aTransportId, |
|
119 MSIPTransportRemovalObserver* aRemovalObserver ); |
|
120 |
|
121 virtual TBool AddUserL( const TSIPTransportParams& /*aParams*/, |
|
122 TUint /*aReceivePort*/ ) {return EFalse;} |
|
123 |
|
124 TBool IsReservedTransport() const; |
|
125 |
|
126 virtual RSocket* AcquireUdpSocket( |
|
127 MSocketUsagePermissionObserver* aObserver, |
|
128 const TInetAddr& aRemoteAddr, |
|
129 TBool& aPermissionToUse ); |
|
130 |
|
131 virtual void UdpSocketReleased( MSocketUsagePermissionObserver* aObserver, |
|
132 RSocket& aSocket ); |
|
133 |
|
134 virtual TInetAddr* PersistentRemoteAddr( |
|
135 MSIPNATBindingObserver* aBindingObserver ); |
|
136 |
|
137 |
|
138 public: |
|
139 |
|
140 static void ConvertToInetAddrL( const TDesC8& aAddrStr, TInetAddr& aAddr ); |
|
141 |
|
142 static HBufC8* ConvertInetAddrToTextL( const TInetAddr& aAddr ); |
|
143 |
|
144 static CSIPViaHeader* TopViaHeader( CSIPMessage* aMessage ); |
|
145 |
|
146 protected: |
|
147 |
|
148 // Uses cleanupstack for aData inside method, so caller should not |
|
149 // push aData to cleanupstack before calling this method |
|
150 void RecvL( HBufC8* aData, |
|
151 const TInetAddr& aRemoteAddr, |
|
152 TBool aCompressed ); |
|
153 void RecvL( CSIPMessage* aMessage, |
|
154 const TInetAddr& aRemoteAddr, |
|
155 TInt aParserError, |
|
156 TBool aCompressed ); |
|
157 CTransport( MTransactionFinder& aFinder, |
|
158 MServerTaFactory& aTaFactory, |
|
159 MTransportOwner& aTransportOwner, |
|
160 CSIPServerResolver& aServerResolver, |
|
161 MSigCompController& aSigCompHandler, |
|
162 const TSIPTransportParams& aTransportParams, |
|
163 CNetworkInfo& aNetworkInfo, |
|
164 COwnerSettingsList& aOwnerSettingsList, |
|
165 CSIPNATTraversalController& aNATTraversal ); |
|
166 virtual TBool CancelResponseSend( TTransactionId aId, TBool aCancelAlso2xxResponses ); |
|
167 virtual void SendToNetL( const TSIPTransportParams& aParams, |
|
168 const TInetAddr& aAddress, |
|
169 CSIPMessage& aMessage, |
|
170 TBool aForceUDP, |
|
171 TUint aOrigTransport, |
|
172 TRequestStatus &aStatus ); |
|
173 virtual void SendToNetL( const TSIPTransportParams& aParams, |
|
174 const TInetAddr& aAddress, |
|
175 TTransactionId aId, |
|
176 CSIPMessage& aMessage, |
|
177 TRequestStatus &aStatus ); |
|
178 virtual void SendToNetL( const TSIPTransportParams& aParams, |
|
179 const TInetAddr& aAddress, |
|
180 CSIPMessage& aMessage, |
|
181 TRequestStatus &aStatus ); |
|
182 virtual TUint SourcePort() = 0; |
|
183 virtual TUint Protocol() = 0; |
|
184 virtual CTransportErrorHandler& ErrorHandler() = 0; |
|
185 virtual CSocketContainer& GetSocketContainerL( const TInetAddr& aRemoteAddr ) = 0; |
|
186 virtual void InformSendingStatus( const TInetAddr& aRemoteAddr ) = 0; |
|
187 virtual void SetPersistencyL( const TInetAddr& aRemoteAddr, |
|
188 TBool aIsPersistent, |
|
189 MSIPNATBindingObserver* aBindingObserver ); |
|
190 TBool IsPersistent() const; |
|
191 TBool IsDefault() const; |
|
192 void RemoveResponseRoute( const TInetAddr& aRemoteAddr ); |
|
193 void RemoveResponseRoute( TTransactionId aId ); |
|
194 HBufC8* LocalAddressL(); |
|
195 void HandleMixedAddressFamilysL( CSIPMessage& aMessage, |
|
196 const TInetAddr& aRemoteAddr ); |
|
197 |
|
198 MSigCompController* SigCompressionHandler() {return iSigCompHandler;} |
|
199 |
|
200 TBool IsConnectedTransport(); |
|
201 |
|
202 TBool NotifyFlowFailure(); |
|
203 |
|
204 protected: // Data |
|
205 |
|
206 MTransportOwner* iTransportOwner; |
|
207 RArray<TResponseRoute> iIDArray; |
|
208 |
|
209 // Binding observers are not owned |
|
210 RPointerArray<MSIPNATBindingObserver> iBindingObservers; |
|
211 |
|
212 CSIPServerResolver* iServerResolver; |
|
213 |
|
214 TSIPTransportParams iTransportParams; |
|
215 COwnerSettingsList& iSettingsList; |
|
216 |
|
217 CSIPNATTraversalController& iNATTraversal; |
|
218 |
|
219 private: |
|
220 |
|
221 void HandleClientRequestL( const TSIPTransportParams& aParams, |
|
222 CSIPRequest& aRequest, |
|
223 TBool aPublicAddrResolved ); |
|
224 |
|
225 //Obtains address from the top Via-header of aMessage, and places it |
|
226 //into aAddr |
|
227 void HandleClientResponseL( const TSIPTransportParams& aParams, |
|
228 CSIPMessage* aMessage, |
|
229 TInetAddr& aAddr ); |
|
230 |
|
231 TBool HandleServerResponseL( CSIPMessage* aMessage, |
|
232 const TInetAddr& aAddr ); |
|
233 TInt HandleServerRequestL( CSIPMessage* aMessage, |
|
234 const TInetAddr& aAddr ); |
|
235 |
|
236 TBool MethodIsSameInCSecAndReqLine( CSIPRequest& aMessage ); |
|
237 TBool AllMandatoryHeaders( CSIPMessage& aMessage ); |
|
238 TBool SupportedSIPVersion( CSIPMessage& aMessage ); |
|
239 TBool ContentTypeOk( CSIPMessage& aMessage ); |
|
240 TBool OnlyOneViaHeader( CSIPMessage& aMessage ); |
|
241 TBool CorrectProtocolInVia( CSIPMessage& aMessage ); |
|
242 TInt CheckAndUpdateContentLengthL( CSIPMessage* aMessage, |
|
243 const TInetAddr& aAddr ); |
|
244 TBool IsAck( CSIPMessage& aMessage ); |
|
245 void HandleSigCompAllowDenyL( const TInetAddr& aRemoteAddr, |
|
246 TInt aParserError, |
|
247 TBool aCompressed ); |
|
248 void UpdateListenersL( const TSIPTransportParams& aParams, |
|
249 CSIPMessage* aMessage ); |
|
250 void SetReceivedIfNeededL( CSIPViaHeader* aViaHeader, TInetAddr aAddr ); |
|
251 |
|
252 void RouteL( CSIPMessage* aMessage, const TInetAddr& aRemoteAddr ); |
|
253 |
|
254 void SendErrorResponseL( TUint aResponseCode, |
|
255 TInt aStrIndex, |
|
256 CSIPMessage& aMessage, |
|
257 const TInetAddr& aAddr ); |
|
258 |
|
259 void UpdateContactHeadersL( const TSIPTransportParams& aParams, |
|
260 CSIPMessage* aMessage, |
|
261 TBool aUpdatePorts ); |
|
262 |
|
263 void ChangeHostAddressFamilyIfNeededL( CSIPHostPort& aHostPort, |
|
264 const TInetAddr& aRemoteAddr ); |
|
265 |
|
266 TBool HandleClientResponseRPortL( CSIPViaHeader& aViaHeader, TInetAddr& aAddr ); |
|
267 |
|
268 void HandleResponseNATTraversalL( CSIPResponse& aResponse, |
|
269 const TInetAddr& aRemoteAddr, |
|
270 MSIPNATBindingObserver* aBindingObserver ); |
|
271 |
|
272 TBool HasValue( CSIPViaHeader& aViaHeader, RStringF& aParam ); |
|
273 |
|
274 void AddBindingObserverL( MSIPNATBindingObserver& aBindingObserver ); |
|
275 |
|
276 TBool RemoveBindingObserver( MSIPNATBindingObserver& aBindingObserver ); |
|
277 |
|
278 private: // Data |
|
279 |
|
280 MTransactionFinder* iTaFinder; |
|
281 MServerTaFactory* iTaFactory; |
|
282 MSigCompController* iSigCompHandler; |
|
283 |
|
284 TTimerId iTimerId; |
|
285 TUint iTime; |
|
286 |
|
287 //For constructing P-Access-Network-Info header |
|
288 CNetworkInfo& iNetworkInfo; |
|
289 private: //For testing purposes |
|
290 #ifdef CPPUNIT_TEST |
|
291 friend class CValidTest; |
|
292 friend class CSipConnectionTest; |
|
293 friend class CTransportTlsTest; |
|
294 #endif |
|
295 }; |
|
296 #endif // end of __CTRANSPORT_H__ |
|
297 |
|
298 // End of File |