|
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 // Name : CState.cpp |
|
15 // Part of : SIPSec, IpSec Plugin |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "sipsecurityheaderbase.h" |
|
22 #include "sipresponse.h" |
|
23 #include "CSipSecAgreeRecord.h" |
|
24 #include "SipSecIpsecParams.h" |
|
25 #include "MIpSecAgreeContextParams.h" |
|
26 #include "CIpSecSadbHandler.h" |
|
27 #include "MIpSecMechanismParams.h" |
|
28 #include "CState.h" |
|
29 |
|
30 #ifdef CPPUNIT_TEST |
|
31 #include "CActiveObjController1.h" |
|
32 #endif |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // CState::~CState |
|
36 // ---------------------------------------------------------------------------- |
|
37 // |
|
38 CState::~CState() |
|
39 { |
|
40 } |
|
41 |
|
42 // ---------------------------------------------------------------------------- |
|
43 // CState::SaAddedL |
|
44 // ---------------------------------------------------------------------------- |
|
45 // |
|
46 void CState::SaAddedL( CSipSecAgreeRecord& /* aRec */ ) |
|
47 { |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CState::SaDeleted |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 void CState::SaDeleted( CSipSecAgreeRecord& /* aRec */ ) |
|
55 { |
|
56 } |
|
57 |
|
58 // ---------------------------------------------------------------------------- |
|
59 // CState::PolicyActivatedL |
|
60 // ---------------------------------------------------------------------------- |
|
61 // |
|
62 void CState::PolicyActivatedL( CSipSecAgreeRecord& /* aRec */ ) |
|
63 { |
|
64 } |
|
65 |
|
66 // ---------------------------------------------------------------------------- |
|
67 // CState::PolicyUnloaded |
|
68 // ---------------------------------------------------------------------------- |
|
69 // |
|
70 void CState::PolicyUnloaded( CSipSecAgreeRecord& /* aRec */ ) |
|
71 { |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // CState::TimerExpiredL |
|
76 // ---------------------------------------------------------------------------- |
|
77 // |
|
78 void CState::TimerExpiredL( |
|
79 CSipSecAgreeRecord& /* aRec */, |
|
80 TTimerId /* aTimerId */, |
|
81 TAny* /* aTimerParam */ ) |
|
82 { |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // CState::Resp4xxL |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 void CState::Resp4xxL( |
|
90 CSipSecAgreeRecord& /* aRec */, |
|
91 CSIPResponse& /* aResponse */, |
|
92 CSIPRequest& /* aRequest */ ) |
|
93 { |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // CState::AuthKeyL |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 TBool CState::AuthKeyL( |
|
101 CSipSecAgreeRecord& /* aRec */, |
|
102 const TDesC8& /* aAuthKey */ ) |
|
103 { |
|
104 return EFalse; |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CState::AuthKeyFailedL |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 void CState::AuthKeyFailedL( CSipSecAgreeRecord& /* aRec */ ) |
|
112 { |
|
113 } |
|
114 |
|
115 // ---------------------------------------------------------------------------- |
|
116 // CState::RegisterL |
|
117 // ---------------------------------------------------------------------------- |
|
118 // |
|
119 void CState::RegisterL( |
|
120 CSipSecAgreeRecord& /* aRec */, |
|
121 CSIPRequest& /* aRequest */, |
|
122 TSIPTransportParams& /* aTransportParams */, |
|
123 const TDesC8& /* aOutboundProxy */ ) |
|
124 { |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CState::ReguestL |
|
129 // ---------------------------------------------------------------------------- |
|
130 // |
|
131 void CState::ReguestL( |
|
132 CSipSecAgreeRecord& /* aRec */, |
|
133 CSIPRequest& /* aRequest */, |
|
134 TSIPTransportParams& /* aTransportParams */, |
|
135 const TDesC8& /* aOutboundProxy */ ) |
|
136 { |
|
137 } |
|
138 |
|
139 // ---------------------------------------------------------------------------- |
|
140 // CState::Resp2xxL |
|
141 // ---------------------------------------------------------------------------- |
|
142 // |
|
143 void CState::Resp2xxL( |
|
144 CSipSecAgreeRecord& /* aRec */, |
|
145 CSIPResponse& /* aResponse */ ) |
|
146 { |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------------------------------- |
|
150 // CState::ProcessSecVerifyL |
|
151 // ---------------------------------------------------------------------------- |
|
152 // |
|
153 void CState::ProcessSecVerifyL( |
|
154 CSipSecAgreeRecord& /* aRec */, |
|
155 RPointerArray<CSIPSecurityVerifyHeader>& /* aSecurityVerify */ ) |
|
156 { |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------------------------------- |
|
160 // CState::ClearSaL |
|
161 // ---------------------------------------------------------------------------- |
|
162 // |
|
163 void CState::ClearSaL( CSipSecAgreeRecord& aRec ) |
|
164 { |
|
165 DoClearSaL( aRec ); |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------------------------- |
|
169 // CState::ReInitializeL |
|
170 // ---------------------------------------------------------------------------- |
|
171 // |
|
172 void CState::ReInitializeL( |
|
173 CSipSecAgreeRecord& aRec, |
|
174 CSIPResponse& aResponse, |
|
175 TBool aFullReInitialize ) |
|
176 { |
|
177 if ( aFullReInitialize ) |
|
178 { |
|
179 DeleteSasAndPolicyL( aRec ); |
|
180 } |
|
181 else |
|
182 { |
|
183 aRec.DeleteSasL(); |
|
184 } |
|
185 |
|
186 aRec.iSecVerifyHeaders.ResetAndDestroy(); |
|
187 aRec.CopyHeadersFromMessageL( aResponse, EFalse ); |
|
188 // Wait for Digest plugin generate a key |
|
189 // Set timer to 4 min while SA is temporal |
|
190 aRec.StartTimerL( KTempTime ); |
|
191 aRec.NextState( EPendingKey ); |
|
192 } |
|
193 |
|
194 // ---------------------------------------------------------------------------- |
|
195 // CState::DeleteSasL |
|
196 // ---------------------------------------------------------------------------- |
|
197 // |
|
198 void CState::DeleteSasL( CSipSecAgreeRecord& aRec ) |
|
199 { |
|
200 DeleteSasAndPolicyL( aRec ); |
|
201 aRec.NextState( EDeleting ); |
|
202 } |
|
203 |
|
204 // ---------------------------------------------------------------------------- |
|
205 // CState::DoClearSaL |
|
206 // ---------------------------------------------------------------------------- |
|
207 // |
|
208 void CState::DoClearSaL( CSipSecAgreeRecord& aRec ) |
|
209 { |
|
210 DeleteSasAndPolicyL( aRec ); |
|
211 aRec.NextState( EClearing ); |
|
212 } |
|
213 |
|
214 // ---------------------------------------------------------------------------- |
|
215 // CState::DeleteSasAndPolicyL |
|
216 // ---------------------------------------------------------------------------- |
|
217 // |
|
218 void CState::DeleteSasAndPolicyL( CSipSecAgreeRecord& aRec ) |
|
219 { |
|
220 aRec.RemoveTransportL(); |
|
221 } |
|
222 |
|
223 // ---------------------------------------------------------------------------- |
|
224 // CState::UpdateExpirationTimeL |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CState::UpdateExpirationTimeL( |
|
228 CSipSecAgreeRecord& aRec, |
|
229 CSIPResponse& aResponse ) |
|
230 { |
|
231 TUint t = CSipSecAgreeRecord::ExpiresFromContactL( aResponse ); |
|
232 |
|
233 // Set lifetime to expiration time of just completed registration + |
|
234 // 2 x transaction timeout (since timeouted ta is retried without sigcomp) |
|
235 const TUint KTATimeoutMultiplier = 128; |
|
236 const TUint KSecondAsMillisecs = 1000; |
|
237 |
|
238 __ASSERT_ALWAYS( |
|
239 t <= ( KMaxTUint / KSecondAsMillisecs - |
|
240 KTATimeoutMultiplier * aRec.iParams.MechParams().T1() ), |
|
241 User::Leave( KErrOverflow ) ); |
|
242 |
|
243 t = t * KSecondAsMillisecs + |
|
244 KTATimeoutMultiplier * aRec.iParams.MechParams().T1(); |
|
245 |
|
246 TUint t2; |
|
247 if ( aRec.iParams.HasLongerLifetimeSA( t, t2 ) ) |
|
248 { |
|
249 // t2 is filled with longer lifetime, use it instead |
|
250 t = t2; |
|
251 } |
|
252 |
|
253 aRec.StartTimerL( t ); |
|
254 } |
|
255 |
|
256 // End of File |