34 #include "epos_csuplpacketinfo.h" |
32 #include "epos_csuplpacketinfo.h" |
35 #include "epos_psktlsusageprivatecrkeys.h" |
33 #include "epos_psktlsusageprivatecrkeys.h" |
36 #include "epos_suplpskloger.h" |
34 #include "epos_suplpskloger.h" |
37 |
35 |
38 #include <extendedconnpref.h> //For OCC |
36 #include <extendedconnpref.h> //For OCC |
39 |
37 const TInt KMaxGBAUsageLength = 4; |
40 const TInt KMaxGBAUsageLength = 4; |
38 const TInt KMaxVerLength = 4; |
41 const TInt KMaxVerLength = 4; |
|
42 //const TInt KMaxNewPasswordLength = 8; |
39 //const TInt KMaxNewPasswordLength = 8; |
43 const TInt KMaxNewPasswordLength = 16; |
40 const TInt KMaxNewPasswordLength = 16; |
44 const TInt KMaxPskKeyLength = 256; |
41 const TInt KMaxPskKeyLength = 256; |
45 |
42 |
46 const TInt KMaxRootKeyLength = 32; |
43 const TInt KMaxRootKeyLength = 32; |
47 const TInt KMaxRootKeyXORLength = 16; |
44 const TInt KMaxRootKeyXORLength = 16; |
48 //const TInt KMaxRootKeyLength = 16; |
45 //const TInt KMaxRootKeyLength = 16; |
49 const TInt KMaxPassKeyLength = 8; |
46 const TInt KMaxPassKeyLength = 8; |
50 //const TInt KMaxPassKeyLength = 8; |
47 //const TInt KMaxPassKeyLength = 8; |
51 const TInt KMaxSaltLength = 128; |
48 const TInt KMaxSaltLength = 128; |
52 //const TInt KMaxSaltLength = 64; |
49 //const TInt KMaxSaltLength = 64; |
53 |
50 |
54 const TInt KMaxPskIdentityHintLength = KMaxGBAUsageLength + KMaxVerLength + KMaxPassKeyLength ; |
51 const TInt KMaxPskIdentityHintLength = KMaxGBAUsageLength + KMaxVerLength |
|
52 + KMaxPassKeyLength; |
55 |
53 |
56 // Constant definition |
54 // Constant definition |
57 |
55 |
58 _LIT8(KWGBA,"WGBA"); |
56 _LIT8(KWGBA,"WGBA"); |
59 |
57 |
60 _LIT(KTraceFileName,"SUPL_PH_API::epos_csuplconnection.cpp"); |
58 _LIT(KTraceFileName,"SUPL_PH_API::epos_csuplconnection.cpp"); |
61 |
59 |
62 _LIT8(KSaltValue,"0x19,0x31,0x45,0x69,0x69,0x45,0x31,0x19"); |
60 _LIT8(KSaltValue,"0x19,0x31,0x45,0x69,0x69,0x45,0x31,0x19"); |
63 |
61 |
64 void DoSelfXOR(TDes8& aDestination,const TDesC8& aSource) |
62 void DoSelfXOR(TDes8& aDestination, const TDesC8& aSource) |
65 { |
63 { |
66 aDestination.Zero(); |
64 aDestination.Zero(); |
67 TInt half = aSource.Length() / 2; |
65 TInt half = aSource.Length() / 2; |
68 for(TInt i = 0; i < half; i++) |
66 for (TInt i = 0; i < half; i++) |
69 { |
67 { |
70 aDestination.Append(aSource[i] ^ aSource[half + i]); |
68 aDestination.Append(aSource[i] ^ aSource[half + i]); |
71 } |
69 } |
72 } |
70 } |
73 |
71 |
74 |
72 void DoXOR(TDes8& aDestination, const TDesC8& aSource1, |
75 void DoXOR(TDes8& aDestination,const TDesC8& aSource1,const TDesC8& aSource2) |
73 const TDesC8& aSource2) |
76 { |
74 { |
77 aDestination.Zero(); |
75 aDestination.Zero(); |
78 TInt srcLen1 = aSource1.Length(); |
76 TInt srcLen1 = aSource1.Length(); |
79 TInt srcLen2 = aSource2.Length(); |
77 TInt srcLen2 = aSource2.Length(); |
80 TInt j = 0; |
78 TInt j = 0; |
81 for(TInt i = 0; i < srcLen1; i++ ) |
79 for (TInt i = 0; i < srcLen1; i++) |
82 { |
80 { |
83 if(j >= srcLen2 ) |
81 if (j >= srcLen2) |
84 { |
82 { |
85 j = 0; |
83 j = 0; |
86 } |
84 } |
87 |
85 |
88 aDestination.Append(aSource1[i] ^ aSource2[j++]); |
86 aDestination.Append(aSource1[i] ^ aSource2[j++]); |
89 } |
87 } |
90 } |
88 } |
91 |
89 |
92 |
|
93 //0x18,0x32,0x34,0x55,0x55,0x34,0x32,0x18 |
90 //0x18,0x32,0x34,0x55,0x55,0x34,0x32,0x18 |
94 void FormSaltKey(TDes8& aDestination,const TDesC8& aSource) |
91 void FormSaltKey(TDes8& aDestination, const TDesC8& aSource) |
95 { |
92 { |
96 TBuf8<2> seachText(_L8("0x")); |
93 TBuf8<2> seachText(_L8("0x")); |
97 aDestination.Zero(); |
94 aDestination.Zero(); |
98 TBuf8<KMaxSaltLength> tempSaltBuffer(aSource); |
95 TBuf8<KMaxSaltLength> tempSaltBuffer(aSource); |
99 TUint32 hexNumber; |
96 TUint32 hexNumber; |
100 TBuf<2> decNumber; |
97 TBuf<2> decNumber; |
101 TInt offSet = tempSaltBuffer.Find(seachText); |
98 TInt offSet = tempSaltBuffer.Find(seachText); |
102 |
99 |
103 while(offSet != KErrNotFound) |
100 while (offSet != KErrNotFound) |
104 { |
101 { |
105 offSet+=2; |
102 offSet += 2; |
106 decNumber.Copy(tempSaltBuffer.Mid(offSet,2)); |
103 decNumber.Copy(tempSaltBuffer.Mid(offSet, 2)); |
107 tempSaltBuffer.Copy(tempSaltBuffer.Mid(offSet+2)); |
104 tempSaltBuffer.Copy(tempSaltBuffer.Mid(offSet + 2)); |
108 TLex lex(decNumber); |
105 TLex lex(decNumber); |
109 lex.Val(hexNumber,EHex); |
106 lex.Val(hexNumber, EHex); |
110 aDestination.Append(hexNumber); |
107 aDestination.Append(hexNumber); |
111 offSet = tempSaltBuffer.Find(seachText); |
108 offSet = tempSaltBuffer.Find(seachText); |
112 } |
109 } |
113 } |
110 } |
114 |
111 |
115 //void get_key(unsigned char key[],unsigned int keylength); |
112 //void get_key(unsigned char key[],unsigned int keylength); |
116 |
113 |
117 void derive_key(const unsigned char pwd[], /* the PASSWORD */ |
114 void derive_key(const unsigned char pwd[], /* the PASSWORD */ |
118 unsigned int pwd_len, /* and its length */ |
115 unsigned int pwd_len, /* and its length */ |
119 const unsigned char salt[], /* the SALT and its */ |
116 const unsigned char salt[], /* the SALT and its */ |
120 unsigned int salt_len, /* length */ |
117 unsigned int salt_len, /* length */ |
121 unsigned int iter, /* the number of iterations */ |
118 unsigned int iter, /* the number of iterations */ |
122 unsigned char key[], /* space for the output key */ |
119 unsigned char key[], /* space for the output key */ |
123 unsigned int key_len);/* and its required length */ |
120 unsigned int key_len);/* and its required length */ |
124 |
|
125 |
|
126 |
|
127 |
121 |
128 // ============================ MEMBER FUNCTIONS =============================== |
122 // ============================ MEMBER FUNCTIONS =============================== |
129 |
123 |
130 CSuplConnection::CSuplConnection(RSocketServ &aSocketServ): |
124 CSuplConnection::CSuplConnection(RSocketServ &aSocketServ) : |
131 CActive(EPriorityStandard), |
125 CActive(EPriorityStandard), iSocketServ(aSocketServ), iRefCount(0), |
132 iSocketServ(aSocketServ), |
126 iState(ENotConnected), iPacket(0, 0), iVariantEnabled(ETrue), |
133 iRefCount(0), |
127 iPskTLSUsage(EFalse), iStartedListen(EFalse), iConnectStarted( |
134 iState(ENotConnected), |
128 EFalse), iSendInProgress(EFalse), iFirstPkt(EFalse), |
135 iPacket(0,0), |
129 iListenCount(0), iPrompt(EFalse), iWlanOnly(EFalse) |
136 iVariantEnabled(ETrue), |
|
137 iPskTLSUsage(EFalse), |
|
138 iStartedListen(EFalse), |
|
139 iConnectStarted(EFalse), |
|
140 iSendInProgress(EFalse), |
|
141 iFirstPkt(EFalse), |
|
142 iListenCount(0), |
|
143 iPrompt(EFalse), |
|
144 iWlanOnly(EFalse) |
|
145 { |
130 { |
146 iHostAddress.Zero(); |
131 iHostAddress.Zero(); |
147 CActiveScheduler::Add(this); |
132 CActiveScheduler::Add(this); |
148 } |
133 } |
149 |
134 |
150 void CSuplConnection::ConstructL(const TDesC &aHostAddress, const TUint aPort, |
135 void CSuplConnection::ConstructL(const TDesC &aHostAddress, |
151 const TInt aIAPId, |
136 const TUint aPort, const TInt aIAPId, MSuplPacketNotifier *aNotifier) |
152 MSuplPacketNotifier *aNotifier) |
137 { |
153 { |
138 |
154 |
|
155 iTrace = CSuplConnTrace::NewL(); |
139 iTrace = CSuplConnTrace::NewL(); |
156 |
140 |
157 iTrace->Trace(_L("CSuplConnection::ConstructL"), KTraceFileName, __LINE__); |
141 iTrace->Trace(_L("CSuplConnection::ConstructL"), KTraceFileName, __LINE__); |
158 SetVariation(); |
142 SetVariation(); |
159 iHostAddress.Append(aHostAddress); |
143 iHostAddress.Append(aHostAddress); |
160 iPort = aPort; |
144 iPort = aPort; |
161 iIAPId = aIAPId; |
145 iIAPId = aIAPId; |
162 |
146 |
163 // Create the Secure Socket |
147 // Create the Secure Socket |
164 if(iVariantEnabled) |
148 if (iVariantEnabled) |
165 { |
149 { |
166 iTrace->Trace(_L("Using CSuplConnection::Secure Construction"), KTraceFileName, __LINE__); |
150 iTrace->Trace(_L("Using CSuplConnection::Secure Construction"), |
167 _LIT(KTLS1,"TLS1.0"); |
151 KTraceFileName, __LINE__); |
168 iTlsSocket = CSecureSocket::NewL( iSocket, KTLS1 ); |
152 _LIT(KTLS1, "TLS1.0"); |
169 |
153 iTlsSocket = CSecureSocket::NewL(iSocket, KTLS1); |
170 TBuf8<KMaxHostAddressLen> dNSName; |
154 |
171 dNSName.Copy(aHostAddress); |
155 TBuf8<KMaxHostAddressLen> dNSName; |
172 iTlsSocket->SetOpt(KSoSSLDomainName,KSolInetSSL,dNSName); |
156 dNSName.Copy(aHostAddress); |
173 |
157 iTlsSocket->SetOpt(KSoSSLDomainName, KSolInetSSL, dNSName); |
174 if(iPskTLSUsage) |
158 |
175 { |
159 if (iPskTLSUsage) |
176 iTrace->Trace(_L("Considering PSK Ciphersuites for Usage..."), KTraceFileName, __LINE__); |
160 { |
177 |
161 iTrace->Trace(_L("Considering PSK Ciphersuites for Usage..."), |
178 // PSK TLS Start |
162 KTraceFileName, __LINE__); |
179 TPckgBuf<MSoPskKeyHandler *> pskConfigPkg; |
163 |
180 pskConfigPkg() = this; |
164 // PSK TLS Start |
181 User::LeaveIfError(iTlsSocket->SetOpt(KSoPskConfig, KSolInetSSL, pskConfigPkg)); |
165 TPckgBuf<MSoPskKeyHandler *> pskConfigPkg; |
182 // PSK TLS End |
166 pskConfigPkg() = this; |
183 } |
167 User::LeaveIfError(iTlsSocket->SetOpt(KSoPskConfig, KSolInetSSL, |
184 |
168 pskConfigPkg)); |
185 iTlsSocket->SetDialogMode(EDialogModeUnattended); |
169 // PSK TLS End |
186 |
170 } |
187 iSocketReader = CSuplSocketReader::NewL(iTlsSocket, aNotifier, iVariantEnabled); |
171 |
188 } |
172 iTlsSocket->SetDialogMode(EDialogModeUnattended); |
189 else |
173 |
190 { |
174 iSocketReader = CSuplSocketReader::NewL(iTlsSocket, aNotifier, |
191 iTrace->Trace(_L("Using CSuplConnection::NonSecure Construction"), KTraceFileName, __LINE__); |
175 iVariantEnabled); |
192 iSocketReader = CSuplSocketReader::NewL(iSocket, aNotifier, iVariantEnabled); |
176 } |
193 } |
177 else |
|
178 { |
|
179 iTrace->Trace(_L("Using CSuplConnection::NonSecure Construction"), |
|
180 KTraceFileName, __LINE__); |
|
181 iSocketReader = CSuplSocketReader::NewL(iSocket, aNotifier, |
|
182 iVariantEnabled); |
|
183 } |
194 iTimer = CSuplSocketTimer::NewL(this); |
184 iTimer = CSuplSocketTimer::NewL(this); |
195 |
185 |
196 |
186 if (iPskTLSUsage) |
197 if(iPskTLSUsage) |
187 { |
198 { |
188 // PSK TLS Start |
199 // PSK TLS Start |
189 #if WITH_GBA_OFFF |
200 #if WITH_GBA_OFFF |
190 iGbaClient = CGbaClientRequestHandler::NewL(); |
201 iGbaClient = CGbaClientRequestHandler::NewL(); |
191 #endif /* WITH_GBA */ |
202 #endif /* WITH_GBA */ |
192 // PSK TLS End |
203 // PSK TLS End |
193 } |
204 } |
194 |
205 |
|
206 iConnArray.Reset(); |
195 iConnArray.Reset(); |
207 |
196 |
208 iPktArray.Reset(); |
197 iPktArray.Reset(); |
209 |
198 |
210 } |
199 } |
211 // ----------------------------------------------------------------------------- |
200 // ----------------------------------------------------------------------------- |
212 // CSuplConnection::ConstructL |
201 // CSuplConnection::ConstructL |
213 // |
202 // |
214 // (other items were commented in a header). |
203 // (other items were commented in a header). |
215 // ----------------------------------------------------------------------------- |
204 // ----------------------------------------------------------------------------- |
216 // |
205 // |
217 //------------------------------------------------------------------------------------------------------------- |
206 //------------------------------------------------------------------------------------------------------------- |
218 void CSuplConnection::ConstructL(const TDesC &aHostAddress, const TUint aPort, |
207 void CSuplConnection::ConstructL(const TDesC &aHostAddress, |
219 const TInt aIAPId, |
208 const TUint aPort, const TInt aIAPId, TBool aTls, TBool aPskTls, |
220 TBool aTls, TBool aPskTls, |
209 MSuplPacketNotifier *aNotifier) |
221 MSuplPacketNotifier *aNotifier) |
210 { |
222 { |
211 |
223 |
|
224 iTrace = CSuplConnTrace::NewL(); |
212 iTrace = CSuplConnTrace::NewL(); |
225 |
213 |
226 iTrace->Trace(_L("CSuplConnection::ConstructL"), KTraceFileName, __LINE__); |
214 iTrace->Trace(_L("CSuplConnection::ConstructL"), KTraceFileName, __LINE__); |
227 //SetVariation(); |
215 //SetVariation(); |
228 iVariantEnabled = aTls; |
216 iVariantEnabled = aTls; |
229 iPskTLSUsage = aPskTls; |
217 iPskTLSUsage = aPskTls; |
230 iHostAddress.Append(aHostAddress); |
218 iHostAddress.Append(aHostAddress); |
231 iPort = aPort; |
219 iPort = aPort; |
232 iIAPId = aIAPId; |
220 iIAPId = aIAPId; |
233 |
221 |
234 // Create the Secure Socket |
222 // Create the Secure Socket |
235 if(iVariantEnabled) |
223 if (iVariantEnabled) |
236 { |
224 { |
237 iTrace->Trace(_L("Using CSuplConnection::Secure Construction"), KTraceFileName, __LINE__); |
225 iTrace->Trace(_L("Using CSuplConnection::Secure Construction"), |
238 _LIT(KTLS1,"TLS1.0"); |
226 KTraceFileName, __LINE__); |
239 iTlsSocket = CSecureSocket::NewL( iSocket, KTLS1 ); |
227 _LIT(KTLS1, "TLS1.0"); |
240 |
228 iTlsSocket = CSecureSocket::NewL(iSocket, KTLS1); |
|
229 |
241 TBuf8<KMaxHostAddressLen> dNSName; |
230 TBuf8<KMaxHostAddressLen> dNSName; |
242 dNSName.Copy(aHostAddress); |
231 dNSName.Copy(aHostAddress); |
243 iTlsSocket->SetOpt(KSoSSLDomainName,KSolInetSSL,dNSName); |
232 iTlsSocket->SetOpt(KSoSSLDomainName, KSolInetSSL, dNSName); |
244 |
233 |
245 if(iPskTLSUsage) |
234 if (iPskTLSUsage) |
246 { |
235 { |
247 iTrace->Trace(_L("Considering PSK Ciphersuites for Usage..."), KTraceFileName, __LINE__); |
236 iTrace->Trace(_L("Considering PSK Ciphersuites for Usage..."), |
248 // PSK TLS Start |
237 KTraceFileName, __LINE__); |
249 TPckgBuf<MSoPskKeyHandler *> pskConfigPkg; |
238 // PSK TLS Start |
250 pskConfigPkg() = this; |
239 TPckgBuf<MSoPskKeyHandler *> pskConfigPkg; |
251 User::LeaveIfError(iTlsSocket->SetOpt(KSoPskConfig, KSolInetSSL, pskConfigPkg)); |
240 pskConfigPkg() = this; |
252 // PSK TLS End |
241 User::LeaveIfError(iTlsSocket->SetOpt(KSoPskConfig, KSolInetSSL, |
253 } |
242 pskConfigPkg)); |
254 |
243 // PSK TLS End |
|
244 } |
|
245 |
255 iTlsSocket->SetDialogMode(EDialogModeUnattended); |
246 iTlsSocket->SetDialogMode(EDialogModeUnattended); |
256 |
247 |
257 iSocketReader = CSuplSocketReader::NewL(iTlsSocket, aNotifier, iVariantEnabled); |
248 iSocketReader = CSuplSocketReader::NewL(iTlsSocket, aNotifier, |
|
249 iVariantEnabled); |
258 } |
250 } |
259 else |
251 else |
260 { |
252 { |
261 iTrace->Trace(_L("Using CSuplConnection::NonSecure Construction"), KTraceFileName, __LINE__); |
253 iTrace->Trace(_L("Using CSuplConnection::NonSecure Construction"), |
262 iSocketReader = CSuplSocketReader::NewL(iSocket, aNotifier, iVariantEnabled); |
254 KTraceFileName, __LINE__); |
|
255 iSocketReader = CSuplSocketReader::NewL(iSocket, aNotifier, |
|
256 iVariantEnabled); |
263 } |
257 } |
264 iTimer = CSuplSocketTimer::NewL(this); |
258 iTimer = CSuplSocketTimer::NewL(this); |
265 |
259 |
266 if(iPskTLSUsage) |
260 if (iPskTLSUsage) |
267 { |
261 { |
268 // PSK TLS Start |
262 // PSK TLS Start |
269 #if WITH_GBA_OFFF |
263 #if WITH_GBA_OFFF |
270 iGbaClient = CGbaClientRequestHandler::NewL(); |
264 iGbaClient = CGbaClientRequestHandler::NewL(); |
271 #endif /* WITH_GBA */ |
265 #endif /* WITH_GBA */ |
272 // PSK TLS End |
266 // PSK TLS End |
273 } |
267 } |
274 |
268 |
275 iConnArray.Reset(); |
269 iConnArray.Reset(); |
276 |
270 |
277 iPktArray.Reset(); |
271 iPktArray.Reset(); |
278 |
272 |
279 } |
273 } |
280 |
274 |
281 CSuplConnection* CSuplConnection::NewL(RSocketServ &aSocketServ, const TDesC &aHostAddress, |
275 CSuplConnection* CSuplConnection::NewL(RSocketServ &aSocketServ, |
282 const TUint aPort,const TInt aIAPId, |
276 const TDesC &aHostAddress, const TUint aPort, const TInt aIAPId, |
283 MSuplPacketNotifier *aNotifier) |
277 MSuplPacketNotifier *aNotifier) |
284 { |
278 { |
285 CSuplConnection* self = new( ELeave ) CSuplConnection(aSocketServ); |
279 CSuplConnection* self = new (ELeave) CSuplConnection(aSocketServ); |
286 |
280 |
287 CleanupStack::PushL( self ); |
281 CleanupStack::PushL(self); |
288 self->ConstructL(aHostAddress, aPort,aIAPId, aNotifier); |
282 self->ConstructL(aHostAddress, aPort, aIAPId, aNotifier); |
289 CleanupStack::Pop(); |
283 CleanupStack::Pop(); |
290 |
284 |
291 return self; |
285 return self; |
292 } |
286 } |
293 |
287 |
294 // --------------------------------------------ADDED NEWL TAKING TLS ALSO------------------------------------- |
288 // --------------------------------------------ADDED NEWL TAKING TLS ALSO------------------------------------- |
295 // ----------------------------------------------------------------------------- |
289 // ----------------------------------------------------------------------------- |
296 // CSuplConnection::NewL |
290 // CSuplConnection::NewL |
297 // |
291 // |
298 // (other items were commented in a header). |
292 // (other items were commented in a header). |
299 // ----------------------------------------------------------------------------- |
293 // ----------------------------------------------------------------------------- |
300 // |
294 // |
301 CSuplConnection* CSuplConnection::NewL(RSocketServ &aSocketServ, const TDesC &aHostAddress, |
295 CSuplConnection* CSuplConnection::NewL(RSocketServ &aSocketServ, |
302 const TUint aPort,const TInt aIAPId, |
296 const TDesC &aHostAddress, const TUint aPort, const TInt aIAPId, |
303 TBool aTls, TBool aPskTls, |
297 TBool aTls, TBool aPskTls, MSuplPacketNotifier *aNotifier) |
304 MSuplPacketNotifier *aNotifier) |
298 { |
305 { |
299 CSuplConnection* self = new (ELeave) CSuplConnection(aSocketServ); |
306 CSuplConnection* self = new( ELeave ) CSuplConnection(aSocketServ); |
300 |
307 |
301 CleanupStack::PushL(self); |
308 CleanupStack::PushL( self ); |
302 self->ConstructL(aHostAddress, aPort, aIAPId, aTls, aPskTls, aNotifier); |
309 self->ConstructL(aHostAddress, aPort,aIAPId, aTls, aPskTls, aNotifier); |
|
310 CleanupStack::Pop(); |
303 CleanupStack::Pop(); |
311 |
304 |
312 return self; |
305 return self; |
313 } |
306 } |
314 //------------------------------------------------------------------------------------------------------------ |
307 //------------------------------------------------------------------------------------------------------------ |
315 CSuplConnection::~CSuplConnection() |
308 CSuplConnection::~CSuplConnection() |
316 { |
309 { |
317 |
310 |
318 // Log |
311 // Log |
319 if(iTrace) |
312 if (iTrace) |
320 { |
313 { |
321 iTrace->Trace(_L("CSuplConnection::Destructor"), KTraceFileName, __LINE__); |
314 iTrace->Trace(_L("CSuplConnection::Destructor"), KTraceFileName, |
322 |
315 __LINE__); |
323 iTrace->Trace(_L("CSuplConnection::Destructor...Cancelling "), KTraceFileName, __LINE__); |
316 |
324 } |
317 iTrace->Trace(_L("CSuplConnection::Destructor...Cancelling "), |
|
318 KTraceFileName, __LINE__); |
|
319 } |
325 // Cancel Any outstanding request |
320 // Cancel Any outstanding request |
326 Cancel(); |
321 Cancel(); |
327 |
322 |
328 if(iTrace) |
323 if (iTrace) |
329 iTrace->Trace(_L("CSuplConnection::Destructor...Deleting Socket Reader"), KTraceFileName, __LINE__); |
324 iTrace->Trace(_L( |
|
325 "CSuplConnection::Destructor...Deleting Socket Reader"), |
|
326 KTraceFileName, __LINE__); |
330 //Delete the Socket Reader |
327 //Delete the Socket Reader |
331 delete iSocketReader; |
328 delete iSocketReader; |
332 |
329 |
333 // Close the resolver if required |
330 // Close the resolver if required |
334 if(iState == ELookingUp) |
331 if (iState == ELookingUp) |
335 { |
332 { |
336 if(iTrace) |
333 if (iTrace) |
337 iTrace->Trace(_L("CSuplConnection::Destructor...Closing Resolver"), KTraceFileName, __LINE__); |
334 iTrace->Trace( |
338 iResolver.Close(); |
335 _L("CSuplConnection::Destructor...Closing Resolver"), |
339 } |
336 KTraceFileName, __LINE__); |
340 if(iTrace) |
337 iResolver.Close(); |
341 iTrace->Trace(_L("CSuplConnection::Destructor...Deleting Secure Socket"), KTraceFileName, __LINE__); |
338 } |
|
339 if (iTrace) |
|
340 iTrace->Trace(_L( |
|
341 "CSuplConnection::Destructor...Deleting Secure Socket"), |
|
342 KTraceFileName, __LINE__); |
342 // Delete the TLS Socket |
343 // Delete the TLS Socket |
343 delete iTlsSocket; |
344 delete iTlsSocket; |
344 |
345 |
345 // Close the Socket if required |
346 // Close the Socket if required |
346 if(iState == EConnected || iState == EConnecting) |
347 if (iState == EConnected || iState == EConnecting) |
347 { |
348 { |
348 iTrace->Trace(_L("CSuplConnection::Destructor...Closing Socket"), KTraceFileName, __LINE__); |
349 iTrace->Trace(_L("CSuplConnection::Destructor...Closing Socket"), |
349 iSocket.Close(); |
350 KTraceFileName, __LINE__); |
350 } |
351 iSocket.Close(); |
351 |
352 } |
|
353 |
352 #ifndef __WINS__ |
354 #ifndef __WINS__ |
353 // Close the RConnection |
355 // Close the RConnection |
354 if(iTrace) |
356 if(iTrace) |
355 iTrace->Trace(_L("CSuplConnection::Destructor...Closing RConnection"), KTraceFileName, __LINE__); |
357 iTrace->Trace(_L("CSuplConnection::Destructor...Closing RConnection"), KTraceFileName, __LINE__); |
356 iConnection.Close(); |
358 iConnection.Close(); |
357 #endif |
359 #endif |
358 if(iTrace) |
360 if (iTrace) |
359 iTrace->Trace(_L("CSuplConnection::Destructor...Deleting Timer"), KTraceFileName, __LINE__); |
361 iTrace->Trace(_L("CSuplConnection::Destructor...Deleting Timer"), |
|
362 KTraceFileName, __LINE__); |
360 // Delete timer |
363 // Delete timer |
361 delete iTimer; |
364 delete iTimer; |
362 |
365 |
363 // PSK TLS Start |
366 // PSK TLS Start |
364 #if WITH_GBA_OFFF |
367 #if WITH_GBA_OFFF |
365 delete iGbaClient; |
368 delete iGbaClient; |
366 #endif /* WITH_GBA */ |
369 #endif /* WITH_GBA */ |
367 // PSK TLS End |
370 // PSK TLS End |
368 |
371 |
369 iConnArray.Close(); |
372 iConnArray.Close(); |
370 // Delete Trace |
373 // Delete Trace |
371 delete iTrace; |
374 delete iTrace; |
372 |
375 |
373 iPktArray.Close(); |
376 iPktArray.Close(); |
374 } |
377 } |
375 |
378 |
380 // (other items were commented in a header). |
383 // (other items were commented in a header). |
381 // ----------------------------------------------------------------------------- |
384 // ----------------------------------------------------------------------------- |
382 // |
385 // |
383 void CSuplConnection::RunL() |
386 void CSuplConnection::RunL() |
384 { |
387 { |
385 |
388 |
386 // Log |
389 // Log |
387 TBuf<64> msg(_L("CSuplConnection::RunL: State is ")); |
390 TBuf<64> msg(_L("CSuplConnection::RunL: State is ")); |
388 msg.AppendNum(iState); |
391 msg.AppendNum(iState); |
389 msg.Append(_L(" iStatus is ")); |
392 msg.Append(_L(" iStatus is ")); |
390 msg.AppendNum(iStatus.Int()); |
393 msg.AppendNum(iStatus.Int()); |
391 iTrace->Trace(msg, KTraceFileName, __LINE__); |
394 iTrace->Trace(msg, KTraceFileName, __LINE__); |
392 |
395 |
393 switch(iState) |
396 switch (iState) |
394 { |
397 { |
395 case ERetriveIAP: |
398 case ERetriveIAP: |
396 { |
399 { |
397 iTrace->Trace(_L("CSuplConnection::ERetriveIAP"), KTraceFileName, __LINE__); |
400 iTrace->Trace(_L("CSuplConnection::ERetriveIAP"), KTraceFileName, |
398 if(iStatus.Int() == KErrNone) |
401 __LINE__); |
399 { |
402 if (iStatus.Int() == KErrNone) |
400 ConnectIAP(); |
403 { |
401 } |
404 ConnectIAP(); |
402 else |
405 } |
403 { |
406 else |
404 iTrace->Trace(_L("Error in Retriving IAP Id... "), KTraceFileName, __LINE__); |
407 { |
405 iConnection.Close(); |
408 iTrace->Trace(_L("Error in Retriving IAP Id... "), |
406 iTrace->Trace(_L("iConnection.Close();... "), KTraceFileName, __LINE__); |
409 KTraceFileName, __LINE__); |
407 //User::RequestComplete(iReqStatus, iStatus.Int()); |
410 iConnection.Close(); |
|
411 iTrace->Trace(_L("iConnection.Close();... "), KTraceFileName, |
|
412 __LINE__); |
|
413 //User::RequestComplete(iReqStatus, iStatus.Int()); |
|
414 CompleteConnectRequests(iStatus.Int()); |
|
415 } |
|
416 break; |
|
417 } |
|
418 // Socket Connect has completed |
|
419 case EConnecting: |
|
420 iTimer->Cancel(); // Valid SUPL server, Cancel timer started for this purpose |
|
421 if (iStatus == KErrNone) |
|
422 { |
|
423 if (iVariantEnabled) |
|
424 { |
|
425 iTrace->Trace( |
|
426 _L( |
|
427 "CSuplConnection::RunL Making Secure Connection"), |
|
428 KTraceFileName, __LINE__); |
|
429 iState = EMakingSecureConn; |
|
430 |
|
431 MakeSecureConnection(); |
|
432 } |
|
433 else |
|
434 { |
|
435 // Log |
|
436 iTrace->Trace( |
|
437 _L( |
|
438 "CSuplConnection::RunL Non Secure Socket Connection Established"), |
|
439 KTraceFileName, __LINE__); |
|
440 // Change State |
|
441 iState = EConnected; |
|
442 //User::RequestComplete(iReqStatus, iStatus.Int()); |
408 CompleteConnectRequests(iStatus.Int()); |
443 CompleteConnectRequests(iStatus.Int()); |
409 } |
444 } |
410 break; |
445 } |
411 } |
446 else |
412 // Socket Connect has completed |
447 { |
413 case EConnecting: |
448 // Log |
414 iTimer->Cancel(); // Valid SUPL server, Cancel timer started for this purpose |
449 iTrace->Trace(_L( |
415 if(iStatus == KErrNone) |
450 "CSuplConnection::RunL Socket Connection Failed"), |
416 { |
451 KTraceFileName, __LINE__); |
417 if(iVariantEnabled) |
452 |
418 { |
453 iState = EFailure; |
419 iTrace->Trace(_L("CSuplConnection::RunL Making Secure Connection"), KTraceFileName, __LINE__); |
454 iSocket.Close(); |
420 iState = EMakingSecureConn; |
455 #ifndef __WINS__ // Bug Fix for close connection |
421 |
456 // Close the RConnection |
422 MakeSecureConnection(); |
457 iConnection.Close(); |
423 } |
458 #endif |
424 else |
459 //User::RequestComplete(iReqStatus, iStatus.Int()); |
425 { |
|
426 // Log |
|
427 iTrace->Trace(_L("CSuplConnection::RunL Non Secure Socket Connection Established"), KTraceFileName, __LINE__); |
|
428 // Change State |
|
429 iState = EConnected; |
|
430 //User::RequestComplete(iReqStatus, iStatus.Int()); |
|
431 CompleteConnectRequests(iStatus.Int()); |
|
432 } |
|
433 } |
|
434 else |
|
435 { |
|
436 // Log |
|
437 iTrace->Trace(_L("CSuplConnection::RunL Socket Connection Failed"), KTraceFileName, __LINE__); |
|
438 |
|
439 iState = EFailure; |
|
440 iSocket.Close(); |
|
441 #ifndef __WINS__ // Bug Fix for close connection |
|
442 // Close the RConnection |
|
443 iConnection.Close(); |
|
444 #endif |
|
445 //User::RequestComplete(iReqStatus, iStatus.Int()); |
|
446 CompleteConnectRequests(iStatus.Int()); |
460 CompleteConnectRequests(iStatus.Int()); |
447 iTrace->Trace(_L("CSuplConnection::SocketConn Failed Exit"), KTraceFileName, __LINE__); |
461 iTrace->Trace(_L("CSuplConnection::SocketConn Failed Exit"), |
448 } |
462 KTraceFileName, __LINE__); |
449 break; |
463 } |
450 |
464 break; |
451 // Secure Connection |
465 |
452 case ESecureHandShake: |
466 // Secure Connection |
|
467 case ESecureHandShake: |
453 // Stop timer |
468 // Stop timer |
454 iTimer->Cancel(); |
469 iTimer->Cancel(); |
455 if(iStatus != KErrNone) |
470 if (iStatus != KErrNone) |
456 { |
471 { |
457 // Log |
472 // Log |
458 iTrace->Trace(_L("CSuplConnection::RunL Secure Connection Failed"), KTraceFileName, __LINE__); |
473 iTrace->Trace(_L( |
459 |
474 "CSuplConnection::RunL Secure Connection Failed"), |
460 // Connection was not successful |
475 KTraceFileName, __LINE__); |
461 iState = EFailure; |
476 |
462 iSocket.Close(); |
477 // Connection was not successful |
463 #ifndef __WINS__ // Bug Fix for close connection |
478 iState = EFailure; |
464 // Close the RConnection |
479 iSocket.Close(); |
465 iConnection.Close(); |
480 #ifndef __WINS__ // Bug Fix for close connection |
466 #endif |
481 // Close the RConnection |
467 } |
482 iConnection.Close(); |
468 else |
483 #endif |
469 { |
484 } |
470 // Log |
485 else |
471 iTrace->Trace(_L("CSuplConnection::RunL Secure Connection Established"), KTraceFileName, __LINE__); |
486 { |
472 // Change State |
487 // Log |
473 iState = EConnected; |
488 iTrace->Trace( |
474 } |
489 _L( |
475 |
490 "CSuplConnection::RunL Secure Connection Established"), |
476 //User::RequestComplete(iReqStatus, iStatus.Int()); |
491 KTraceFileName, __LINE__); |
|
492 // Change State |
|
493 iState = EConnected; |
|
494 } |
|
495 |
|
496 //User::RequestComplete(iReqStatus, iStatus.Int()); |
477 CompleteConnectRequests(iStatus.Int()); |
497 CompleteConnectRequests(iStatus.Int()); |
478 break; |
498 break; |
479 |
499 |
480 // DNS Lookup has completed |
500 // DNS Lookup has completed |
481 case ELookingUp: |
501 case ELookingUp: |
482 { |
502 { |
483 // Log |
503 // Log |
484 iTrace->Trace(_L("CSuplConnection::RunL DNS Lookup Complete"), KTraceFileName, __LINE__); |
504 iTrace->Trace(_L("CSuplConnection::RunL DNS Lookup Complete"), |
|
505 KTraceFileName, __LINE__); |
485 iTimer->Cancel(); |
506 iTimer->Cancel(); |
486 |
507 |
487 // Close the Resolver |
508 // Close the Resolver |
488 iResolver.Close(); |
509 iResolver.Close(); |
489 |
510 |
490 if(iStatus != KErrNone) |
511 if (iStatus != KErrNone) |
491 { |
512 { |
492 // Log |
513 // Log |
493 iTrace->Trace(_L("CSuplConnection::RunL DNS Lookup Failed"), KTraceFileName, __LINE__); |
514 iTrace->Trace(_L("CSuplConnection::RunL DNS Lookup Failed"), |
494 |
515 KTraceFileName, __LINE__); |
495 iState = EFailure; |
516 |
496 iSocket.Close(); |
517 iState = EFailure; |
497 #ifndef __WINS__ // Bug Fix for close connection |
518 iSocket.Close(); |
498 // Close the RConnection |
519 #ifndef __WINS__ // Bug Fix for close connection |
499 iConnection.Close(); |
520 // Close the RConnection |
500 #endif |
521 iConnection.Close(); |
501 |
522 #endif |
502 //User::RequestComplete(iReqStatus, iStatus.Int()); |
523 |
|
524 //User::RequestComplete(iReqStatus, iStatus.Int()); |
503 CompleteConnectRequests(iStatus.Int()); |
525 CompleteConnectRequests(iStatus.Int()); |
504 break; |
526 break; |
505 } |
527 } |
506 |
528 |
507 // Log |
529 // Log |
508 iTrace->Trace(_L("CSuplConnection::RunL DNS Lookup Successful"), KTraceFileName, __LINE__); |
530 iTrace->Trace(_L("CSuplConnection::RunL DNS Lookup Successful"), |
509 |
531 KTraceFileName, __LINE__); |
510 // Retrieve Address |
532 |
511 TInt addrFamily = iNameEntry().iAddr.Family(); |
533 // Retrieve Address |
512 if(addrFamily == KAfInet) |
534 TInt addrFamily = iNameEntry().iAddr.Family(); |
513 { |
535 if (addrFamily == KAfInet) |
514 //IPv4 Address |
536 { |
515 iAddress.SetAddress(TInetAddr::Cast(iNameEntry().iAddr).Address()); |
537 //IPv4 Address |
516 |
538 iAddress.SetAddress( |
517 } |
539 TInetAddr::Cast(iNameEntry().iAddr).Address()); |
518 if(addrFamily == KAfInet6) |
540 |
519 { |
541 } |
520 //IPv6 Address |
542 if (addrFamily == KAfInet6) |
521 iAddress.SetAddress(TInetAddr::Cast(iNameEntry().iAddr).Ip6Address()); |
543 { |
522 } |
544 //IPv6 Address |
523 |
545 iAddress.SetAddress( |
524 // Set Port |
546 TInetAddr::Cast(iNameEntry().iAddr).Ip6Address()); |
525 iAddress.SetPort(Port()); |
547 } |
526 |
548 |
527 // Connect to Remote Host |
549 // Set Port |
528 Connect(); |
550 iAddress.SetPort(Port()); |
529 |
551 |
530 break; |
552 // Connect to Remote Host |
531 } |
553 Connect(); |
532 default: |
554 |
533 { |
555 break; |
534 if (iSendInProgress) |
556 } |
535 { |
557 default: |
536 if (iPkt) |
558 { |
537 iPkt->CompleteRequest(iStatus.Int()); |
559 if (iSendInProgress) |
538 CheckForOutstandingPackets(); |
560 { |
539 } |
561 if (iPkt) |
540 else |
562 iPkt->CompleteRequest(iStatus.Int()); |
541 { |
563 CheckForOutstandingPackets(); |
542 iState = EFailure; |
564 } |
543 //User::RequestComplete(iReqStatus, KErrGeneral); |
565 else |
544 CompleteConnectRequests(KErrGeneral); |
566 { |
545 } |
567 iState = EFailure; |
546 break; |
568 //User::RequestComplete(iReqStatus, KErrGeneral); |
547 } |
569 CompleteConnectRequests( KErrGeneral); |
548 |
570 } |
549 } |
571 break; |
550 } |
572 } |
551 |
573 |
|
574 } |
|
575 } |
|
576 |
552 // ----------------------------------------------------------------------------- |
577 // ----------------------------------------------------------------------------- |
553 // CSuplConnection::CheckForOutstandingPackets |
578 // CSuplConnection::CheckForOutstandingPackets |
554 // Checks for outstanding packets in the send queue |
579 // Checks for outstanding packets in the send queue |
555 // and sends packets based on FIFO |
580 // and sends packets based on FIFO |
556 // (other items were commented in a header). |
581 // (other items were commented in a header). |
557 // ----------------------------------------------------------------------------- |
582 // ----------------------------------------------------------------------------- |
558 // |
583 // |
559 void CSuplConnection::CheckForOutstandingPackets() |
584 void CSuplConnection::CheckForOutstandingPackets() |
560 { |
585 { |
561 if (iFirstPkt) |
586 if (iFirstPkt) |
562 { |
587 { |
563 iFirstPkt = EFalse; |
588 iFirstPkt = EFalse; |
564 } |
589 } |
565 TInt index = iPktArray.Find(iPkt); |
590 TInt index = iPktArray.Find(iPkt); |
566 if (index != KErrNotFound) |
591 if (index != KErrNotFound) |
567 iPktArray.Remove(index); |
592 iPktArray.Remove(index); |
568 delete iPkt; |
593 delete iPkt; |
569 |
594 |
570 TInt count = iPktArray.Count(); |
595 TInt count = iPktArray.Count(); |
571 if (count == 0) |
596 if (count == 0) |
572 { |
597 { |
573 iSendInProgress = EFalse; |
598 iSendInProgress = EFalse; |
574 } |
599 } |
575 else |
600 else |
576 { |
601 { |
577 iPkt = REINTERPRET_CAST(CSuplPacketInfo*, iPktArray[0]); |
602 iPkt = REINTERPRET_CAST(CSuplPacketInfo*, iPktArray[0]); |
578 iPkt->GetPacketData(iPacket); |
603 iPkt->GetPacketData(iPacket); |
579 |
604 |
580 TBuf<64> msg(_L("Sending data on port ")); |
605 TBuf<64> msg(_L("Sending data on port ")); |
581 msg.AppendNum(iSocket.LocalPort()); |
606 msg.AppendNum(iSocket.LocalPort()); |
582 iTrace->Trace(msg, KTraceFileName, __LINE__); |
607 iTrace->Trace(msg, KTraceFileName, __LINE__); |
583 |
608 |
584 // Log |
609 // Log |
585 if(iVariantEnabled) |
610 if (iVariantEnabled) |
586 { |
611 { |
587 iTrace->Trace(_L("CSuplConnection::CheckForOutstandingPackets sending packet over Secure Connection"), KTraceFileName, __LINE__); |
612 iTrace->Trace( |
588 iTlsSocket->Send(iPacket, iStatus); |
613 _L( |
589 iSendInProgress = ETrue; |
614 "CSuplConnection::CheckForOutstandingPackets sending packet over Secure Connection"), |
590 SetActive(); |
615 KTraceFileName, __LINE__); |
591 } |
616 iTlsSocket->Send(iPacket, iStatus); |
592 else |
617 iSendInProgress = ETrue; |
593 { |
618 SetActive(); |
594 iTrace->Trace(_L("CSuplConnection::CheckForOutstandingPackets sending packet over NonSecure Connection"), KTraceFileName, __LINE__); |
619 } |
595 iSocket.Send(iPacket, 0, iStatus); |
620 else |
596 iSendInProgress = ETrue; |
621 { |
597 SetActive(); |
622 iTrace->Trace( |
598 } |
623 _L( |
599 } |
624 "CSuplConnection::CheckForOutstandingPackets sending packet over NonSecure Connection"), |
|
625 KTraceFileName, __LINE__); |
|
626 iSocket.Send(iPacket, 0, iStatus); |
|
627 iSendInProgress = ETrue; |
|
628 SetActive(); |
|
629 } |
|
630 } |
600 } |
631 } |
601 |
632 |
602 // ----------------------------------------------------------------------------- |
633 // ----------------------------------------------------------------------------- |
603 // CSuplConnection::CancelConnect |
634 // CSuplConnection::CancelConnect |
604 // Cancels connect request. |
635 // Cancels connect request. |
903 TUint CSuplConnection::Port() |
942 TUint CSuplConnection::Port() |
904 { |
943 { |
905 return iPort; |
944 return iPort; |
906 } |
945 } |
907 |
946 |
908 |
|
909 // ----------------------------------------------------------------------------- |
947 // ----------------------------------------------------------------------------- |
910 // CSuplConnection::Connect |
948 // CSuplConnection::Connect |
911 // Makes a secure connection to Network |
949 // Makes a secure connection to Network |
912 // (other items were commented in a header). |
950 // (other items were commented in a header). |
913 // ----------------------------------------------------------------------------- |
951 // ----------------------------------------------------------------------------- |
914 // |
952 // |
915 EXPORT_C void CSuplConnection::Connect(TRequestStatus &aStatus) |
953 EXPORT_C void CSuplConnection::Connect(TRequestStatus &aStatus) |
916 { |
954 { |
917 |
955 |
918 // Log |
956 // Log |
919 iTrace->Trace(_L("CSuplConnection::Connect"), KTraceFileName, __LINE__); |
957 iTrace->Trace(_L("CSuplConnection::Connect"), KTraceFileName, __LINE__); |
920 |
958 |
921 if (iState == EConnected) |
959 if (iState == EConnected) |
922 { |
960 { |
923 aStatus = KRequestPending; |
961 aStatus = KRequestPending; |
924 TRequestStatus *reqStatus = &aStatus; |
962 TRequestStatus *reqStatus = &aStatus; |
925 User::RequestComplete(reqStatus, KErrNone); |
963 User::RequestComplete(reqStatus, KErrNone); |
926 iConnectClients++; |
964 iConnectClients++; |
|
965 return; |
|
966 } |
|
967 |
|
968 // Check if Connect() is started. If started, add status to Q |
|
969 //if (iConnectStarted) |
|
970 { |
|
971 aStatus = KRequestPending; |
|
972 TRequestStatus *reqStatus = &aStatus; |
|
973 TInt error = iConnArray.Append(reqStatus); |
|
974 if (error != KErrNone) |
|
975 { |
|
976 User::RequestComplete(reqStatus, error); |
927 return; |
977 return; |
928 } |
978 } |
929 |
979 } |
930 // Check if Connect() is started. If started, add status to Q |
980 |
931 //if (iConnectStarted) |
981 if (!iConnectStarted) |
932 { |
982 { |
933 aStatus = KRequestPending; |
983 iTrace->Trace( |
934 TRequestStatus *reqStatus = &aStatus; |
984 _L("CSuplConnection::Connect : Connection not started"), |
935 iConnArray.Append(reqStatus); |
985 KTraceFileName, __LINE__); |
936 } |
986 // Connect only if not already connected |
937 |
987 if (iState == ENotConnected || iState == EFailure) |
938 if (!iConnectStarted) |
988 { |
939 { |
989 iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"), |
940 iTrace->Trace(_L("CSuplConnection::Connect : Connection not started"), KTraceFileName, __LINE__); |
990 KTraceFileName, __LINE__); |
941 // Connect only if not already connected |
|
942 if(iState == ENotConnected || iState == EFailure) |
|
943 { |
|
944 iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"), KTraceFileName, __LINE__); |
|
945 iConnectStarted = ETrue; |
991 iConnectStarted = ETrue; |
946 |
992 |
947 #ifndef __WINS__ |
993 #ifndef __WINS__ |
948 TExtendedConnPref OCCPrefs; |
994 TExtendedConnPref OCCPrefs; |
949 TConnPrefList prefList; |
995 TConnPrefList prefList; |
950 |
996 |
951 OCCPrefs.SetForcedRoaming(EFalse); //do not switch networks during an ongoing connection |
997 OCCPrefs.SetForcedRoaming(EFalse); //do not switch networks during an ongoing connection |
952 OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault); |
998 OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault); |
953 |
999 |
954 |
|
955 if(iIAPId != -1) //if a IAP was configured |
1000 if(iIAPId != -1) //if a IAP was configured |
956 { |
1001 |
957 iTrace->Trace(_L("CSuplConnection::Connect : IAP configured"), KTraceFileName, __LINE__); |
1002 { |
|
1003 iTrace->Trace(_L("CSuplConnection::Connect : IAP configured"), KTraceFileName, __LINE__); |
958 OCCPrefs.SetIapId(iIAPId); |
1004 OCCPrefs.SetIapId(iIAPId); |
959 // since IAP Id is set SNAP purpose should not be set - set to unknown |
1005 // since IAP Id is set SNAP purpose should not be set - set to unknown |
960 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown); |
1006 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeUnknown); |
961 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerUnknown); |
1007 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerUnknown); |
962 } |
1008 } |
963 else |
1009 else |
964 { |
1010 { |
965 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet); |
1011 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet); |
966 //WLAN and Cellular Networks allowed for connection |
1012 //WLAN and Cellular Networks allowed for connection |
967 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN | TExtendedConnPref::EExtendedConnBearerCellular); |
1013 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN | TExtendedConnPref::EExtendedConnBearerCellular); |
968 |
1014 |
969 //if SNAP purpose is set IAP Id should be zero - zero by default not explicitly set |
1015 //if SNAP purpose is set IAP Id should be zero - zero by default not explicitly set |
970 iTrace->Trace(_L("CSuplConnection::Connect : IAP not configured"), KTraceFileName, __LINE__); |
1016 iTrace->Trace(_L("CSuplConnection::Connect : IAP not configured"), KTraceFileName, __LINE__); |
971 } |
1017 } |
972 |
1018 |
973 |
|
974 TRAP_IGNORE(prefList.AppendL(&OCCPrefs)); |
1019 TRAP_IGNORE(prefList.AppendL(&OCCPrefs)); |
975 |
1020 |
976 TInt ret = iConnection.Open(iSocketServ); |
1021 TInt ret = iConnection.Open(iSocketServ); |
977 if(ret != KErrNone) |
1022 if(ret != KErrNone) |
978 iTrace->Trace(_L("RConnection Open returned error"), KTraceFileName, __LINE__); |
1023 iTrace->Trace(_L("RConnection Open returned error"), KTraceFileName, __LINE__); |
979 |
1024 |
980 iTrace->Trace(_L("RConnection Start Called, State is ERetriveIAP"), KTraceFileName, __LINE__); |
1025 iTrace->Trace(_L("RConnection Start Called, State is ERetriveIAP"), KTraceFileName, __LINE__); |
981 // Start an Outgoing Connection with overrides |
|
982 iConnection.Start(prefList,iStatus); |
|
983 // Set state to ERetriveIAP |
|
984 iState = ERetriveIAP; |
|
985 SetActive(); |
|
986 #else |
|
987 ConnectIAP(); |
|
988 #endif |
|
989 } |
|
990 } |
|
991 else |
|
992 iTrace->Trace(_L("CSuplConnection::Connect : Conn in progress, request queued"), KTraceFileName, __LINE__); |
|
993 // Log |
|
994 iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName, __LINE__); |
|
995 } |
|
996 |
|
997 |
|
998 // ----------------------------------------------------------------------------- |
|
999 // CSuplConnection::Connect |
|
1000 // Makes a secure connection to Network |
|
1001 // (other items were commented in a header). |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // |
|
1004 |
|
1005 EXPORT_C void CSuplConnection::Connect(TRequestStatus &aStatus,TBool aPrompt,TBool aWlanOnly) |
|
1006 { |
|
1007 |
|
1008 // Log |
|
1009 iTrace->Trace(_L("CSuplConnection::Connect"), KTraceFileName, __LINE__); |
|
1010 iPrompt = aPrompt; |
|
1011 iWlanOnly = aWlanOnly; |
|
1012 |
|
1013 if (iState == EConnected) |
|
1014 { |
|
1015 aStatus = KRequestPending; |
|
1016 TRequestStatus *reqStatus = &aStatus; |
|
1017 User::RequestComplete(reqStatus, KErrNone); |
|
1018 iConnectClients++; |
|
1019 return; |
|
1020 } |
|
1021 |
|
1022 // Check if Connect() is started. If started, add status to Q |
|
1023 //if (iConnectStarted) |
|
1024 // { |
|
1025 aStatus = KRequestPending; |
|
1026 TRequestStatus *reqStatus = &aStatus; |
|
1027 iConnArray.Append(reqStatus); |
|
1028 // } |
|
1029 |
|
1030 if (!iConnectStarted) |
|
1031 { |
|
1032 iTrace->Trace(_L("CSuplConnection::Connect : Connection not started"), KTraceFileName, __LINE__); |
|
1033 // Connect only if not already connected |
|
1034 if(iState == ENotConnected || iState == EFailure) |
|
1035 { |
|
1036 iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"), KTraceFileName, __LINE__); |
|
1037 iConnectStarted = ETrue; |
|
1038 |
|
1039 #ifndef __WINS__ |
|
1040 |
|
1041 iTrace->Trace(_L("CSuplConnection::Connect ExtendedConnPref"), KTraceFileName, __LINE__); |
|
1042 |
|
1043 TExtendedConnPref OCCPrefs; |
|
1044 TConnPrefList prefList; |
|
1045 |
|
1046 if(iWlanOnly) |
|
1047 { |
|
1048 iTrace->Trace(_L("CSuplConnection::Connect : iWLANOnly used"), KTraceFileName, __LINE__); |
|
1049 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN); |
|
1050 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet); |
|
1051 } |
|
1052 else |
|
1053 { |
|
1054 iTrace->Trace(_L("CSuplConnection::Connect using OCC"), KTraceFileName, __LINE__); |
|
1055 iTrace->Trace(_L("CSuplConnection::Connect OCC GPRS Connection.."), KTraceFileName, __LINE__); |
|
1056 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerCellular); |
|
1057 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet); |
|
1058 } |
|
1059 |
|
1060 if(!iPrompt) |
|
1061 { |
|
1062 iTrace->Trace(_L("CSuplConnection::Connect : silent connection"), KTraceFileName, __LINE__); |
|
1063 OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent); |
|
1064 } |
|
1065 else |
|
1066 { |
|
1067 iTrace->Trace(_L("CSuplConnection::Connect : Dialog prompt"), KTraceFileName, __LINE__); |
|
1068 OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault); |
|
1069 } |
|
1070 |
|
1071 |
|
1072 |
|
1073 TRAP_IGNORE(prefList.AppendL(&OCCPrefs)); |
|
1074 |
|
1075 |
|
1076 TInt ret = iConnection.Open(iSocketServ); |
|
1077 // Start an Outgoing Connection with overrides |
1026 // Start an Outgoing Connection with overrides |
1078 iConnection.Start(prefList,iStatus); |
1027 iConnection.Start(prefList,iStatus); |
1079 // Set state to ERetriveIAP |
1028 // Set state to ERetriveIAP |
1080 iState = ERetriveIAP; |
1029 iState = ERetriveIAP; |
1081 SetActive(); |
1030 SetActive(); |
1082 |
|
1083 |
|
1084 |
|
1085 #else |
1031 #else |
1086 ConnectIAP(); |
1032 ConnectIAP(); |
1087 #endif |
1033 #endif |
1088 } |
1034 } |
1089 } |
1035 } |
1090 else |
1036 else |
1091 iTrace->Trace(_L("CSuplConnection::Connect : Conn in progress, request queued"), KTraceFileName, __LINE__); |
1037 iTrace->Trace( |
|
1038 _L( |
|
1039 "CSuplConnection::Connect : Conn in progress, request queued"), |
|
1040 KTraceFileName, __LINE__); |
1092 // Log |
1041 // Log |
1093 iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName, __LINE__); |
1042 iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName, |
1094 } |
1043 __LINE__); |
1095 |
1044 } |
|
1045 |
|
1046 // ----------------------------------------------------------------------------- |
|
1047 // CSuplConnection::Connect |
|
1048 // Makes a secure connection to Network |
|
1049 // (other items were commented in a header). |
|
1050 // ----------------------------------------------------------------------------- |
|
1051 // |
|
1052 |
|
1053 EXPORT_C void CSuplConnection::Connect(TRequestStatus &aStatus, |
|
1054 TBool aPrompt, TBool aWlanOnly) |
|
1055 { |
|
1056 |
|
1057 // Log |
|
1058 iTrace->Trace(_L("CSuplConnection::Connect"), KTraceFileName, __LINE__); |
|
1059 iPrompt = aPrompt; |
|
1060 iWlanOnly = aWlanOnly; |
|
1061 |
|
1062 aStatus = KRequestPending; |
|
1063 TRequestStatus *reqStatus = &aStatus; |
|
1064 |
|
1065 if (iState == EConnected) |
|
1066 { |
|
1067 User::RequestComplete(reqStatus, KErrNone); |
|
1068 iConnectClients++; |
|
1069 return; |
|
1070 } |
|
1071 |
|
1072 TInt error = iConnArray.Append(reqStatus); |
|
1073 if (error != KErrNone) |
|
1074 { |
|
1075 User::RequestComplete(reqStatus, error); |
|
1076 return; |
|
1077 } |
|
1078 |
|
1079 if (!iConnectStarted) |
|
1080 { |
|
1081 iTrace->Trace( |
|
1082 _L("CSuplConnection::Connect : Connection not started"), |
|
1083 KTraceFileName, __LINE__); |
|
1084 // Connect only if not already connected |
|
1085 if (iState == ENotConnected || iState == EFailure) |
|
1086 { |
|
1087 iTrace->Trace(_L("CSuplConnection::Connect : ENotConnected"), |
|
1088 KTraceFileName, __LINE__); |
|
1089 iConnectStarted = ETrue; |
|
1090 |
|
1091 #ifndef __WINS__ |
|
1092 |
|
1093 iTrace->Trace(_L("CSuplConnection::Connect ExtendedConnPref"), KTraceFileName, __LINE__); |
|
1094 |
|
1095 TExtendedConnPref OCCPrefs; |
|
1096 TConnPrefList prefList; |
|
1097 |
|
1098 if(iWlanOnly) |
|
1099 { |
|
1100 iTrace->Trace(_L("CSuplConnection::Connect : iWLANOnly used"), KTraceFileName, __LINE__); |
|
1101 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerWLAN); |
|
1102 } |
|
1103 else |
|
1104 { |
|
1105 iTrace->Trace(_L("CSuplConnection::Connect OCC GPRS Connection.."), KTraceFileName, __LINE__); |
|
1106 OCCPrefs.SetBearerSet(TExtendedConnPref::EExtendedConnBearerCellular); |
|
1107 } |
|
1108 OCCPrefs.SetSnapPurpose(CMManager::ESnapPurposeInternet); |
|
1109 |
|
1110 if(!iPrompt) |
|
1111 { |
|
1112 iTrace->Trace(_L("CSuplConnection::Connect : silent connection"), KTraceFileName, __LINE__); |
|
1113 OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourConnSilent); |
|
1114 } |
|
1115 else |
|
1116 { |
|
1117 iTrace->Trace(_L("CSuplConnection::Connect : Dialog prompt"), KTraceFileName, __LINE__); |
|
1118 OCCPrefs.SetNoteBehaviour(TExtendedConnPref::ENoteBehaviourDefault); |
|
1119 } |
|
1120 |
|
1121 TRAP_IGNORE(prefList.AppendL(&OCCPrefs)); |
|
1122 |
|
1123 TInt ret = iConnection.Open(iSocketServ); |
|
1124 if( ret != KErrNone ) |
|
1125 { |
|
1126 TRequestStatus* statusPtr = &aStatus; |
|
1127 User::RequestComplete( statusPtr,ret ); |
|
1128 return; |
|
1129 } |
|
1130 // Start an Outgoing Connection with overrides |
|
1131 iConnection.Start(prefList,iStatus); |
|
1132 // Set state to ERetriveIAP |
|
1133 iState = ERetriveIAP; |
|
1134 SetActive(); |
|
1135 |
|
1136 #else |
|
1137 ConnectIAP(); |
|
1138 #endif |
|
1139 } |
|
1140 } |
|
1141 else |
|
1142 iTrace->Trace( |
|
1143 _L( |
|
1144 "CSuplConnection::Connect : Conn in progress, request queued"), |
|
1145 KTraceFileName, __LINE__); |
|
1146 // Log |
|
1147 iTrace->Trace(_L("CSuplConnection::Connect:Exit"), KTraceFileName, |
|
1148 __LINE__); |
|
1149 } |
1096 |
1150 |
1097 // ----------------------------------------------------------------------------- |
1151 // ----------------------------------------------------------------------------- |
1098 // CSuplConnection::CompleteConnectStatus |
1152 // CSuplConnection::CompleteConnectStatus |
1099 // Completes the request to cancel connection |
1153 // Completes the request to cancel connection |
1100 // (other items were commented in a header). |
1154 // (other items were commented in a header). |
1101 // ----------------------------------------------------------------------------- |
1155 // ----------------------------------------------------------------------------- |
1102 void CSuplConnection::CompleteConnectRequests(TInt aErr) |
1156 void CSuplConnection::CompleteConnectRequests(TInt aErr) |
1103 { |
1157 { |
1104 iTrace->Trace(_L("CSuplConnection::CompleteConnectRequests"), KTraceFileName, __LINE__); |
1158 iTrace->Trace(_L("CSuplConnection::CompleteConnectRequests"), |
|
1159 KTraceFileName, __LINE__); |
1105 |
1160 |
1106 TInt statusCount = iConnArray.Count(); |
1161 TInt statusCount = iConnArray.Count(); |
1107 |
1162 |
1108 TBuf<32> msg(_L("Number of conns :")); |
1163 TBuf<32> msg(_L("Number of conns :")); |
1109 msg.AppendNum(statusCount); |
1164 msg.AppendNum(statusCount); |
1110 iTrace->Trace(msg, KTraceFileName, __LINE__); |
1165 iTrace->Trace(msg, KTraceFileName, __LINE__); |
1111 |
1166 |
1112 for(TInt loop = 0; loop < statusCount;loop++) |
1167 for (TInt loop = 0; loop < statusCount; loop++) |
1113 { |
1168 { |
1114 TRequestStatus* newStatus = REINTERPRET_CAST(TRequestStatus*, iConnArray[loop]); |
1169 TRequestStatus* newStatus = REINTERPRET_CAST(TRequestStatus*, iConnArray[loop]); |
1115 User::RequestComplete(newStatus, aErr); |
1170 User::RequestComplete(newStatus, aErr); |
1116 if (aErr == KErrNone) |
1171 if (aErr == KErrNone) |
1117 iConnectClients++; |
1172 iConnectClients++; |
1118 iTrace->Trace(_L("CSuplConnection::CompleteConnectRequests, request completed"), KTraceFileName, __LINE__); |
1173 iTrace->Trace( |
1119 } |
1174 _L( |
|
1175 "CSuplConnection::CompleteConnectRequests, request completed"), |
|
1176 KTraceFileName, __LINE__); |
|
1177 } |
1120 iConnArray.Reset(); |
1178 iConnArray.Reset(); |
1121 iConnectStarted = EFalse; |
1179 iConnectStarted = EFalse; |
1122 } |
1180 } |
1123 |
1181 |
1124 // ----------------------------------------------------------------------------- |
1182 // ----------------------------------------------------------------------------- |
1125 // CSuplConnection::CompleteConnectStatus |
1183 // CSuplConnection::CompleteConnectStatus |
1126 // Completes the request to cancel connection |
1184 // Completes the request to cancel connection |
1127 // (other items were commented in a header). |
1185 // (other items were commented in a header). |
1131 { |
1189 { |
1132 TInt index = iConnArray.Find(&aStatus); |
1190 TInt index = iConnArray.Find(&aStatus); |
1133 |
1191 |
1134 if (index != KErrNotFound) |
1192 if (index != KErrNotFound) |
1135 { |
1193 { |
1136 TRequestStatus *reqStatus = &aStatus; |
1194 TRequestStatus *reqStatus = &aStatus; |
1137 User::RequestComplete(reqStatus, KErrCancel); |
1195 User::RequestComplete(reqStatus, KErrCancel); |
1138 iConnArray.Remove(index); |
1196 iConnArray.Remove(index); |
1139 } |
1197 } |
1140 } |
1198 } |
1141 |
1199 |
1142 // ----------------------------------------------------------------------------- |
1200 // ----------------------------------------------------------------------------- |
1143 // CSuplConnection::Send |
1201 // CSuplConnection::Send |
1144 // Sends a Packet out of the Secure Connection |
1202 // Sends a Packet out of the Secure Connection |
1145 // (other items were commented in a header). |
1203 // (other items were commented in a header). |
1146 // ----------------------------------------------------------------------------- |
1204 // ----------------------------------------------------------------------------- |
1147 // |
1205 // |
1148 EXPORT_C void CSuplConnection::Send(const TDesC8 &aPacket, TRequestStatus &aStatus) |
1206 EXPORT_C void CSuplConnection::Send(const TDesC8 &aPacket, |
1149 { |
1207 TRequestStatus &aStatus) |
1150 // Log |
1208 { |
1151 iTrace->Trace(_L("CSuplConnection::Send"), KTraceFileName, __LINE__); |
1209 // Log |
1152 |
1210 iTrace->Trace(_L("CSuplConnection::Send"), KTraceFileName, __LINE__); |
1153 if(iState != EConnected || iState == EFailure) |
1211 |
1154 { |
1212 if (iState != EConnected || iState == EFailure) |
1155 // Log |
1213 { |
1156 iTrace->Trace(_L("CSuplConnection::Send...Disconnected"), KTraceFileName, __LINE__); |
1214 // Log |
1157 aStatus = KRequestPending; |
1215 iTrace->Trace(_L("CSuplConnection::Send...Disconnected"), |
1158 TRequestStatus *reqStatus = &aStatus; |
1216 KTraceFileName, __LINE__); |
1159 User::RequestComplete(reqStatus, KErrDisconnected); |
1217 aStatus = KRequestPending; |
1160 return; |
1218 TRequestStatus *reqStatus = &aStatus; |
1161 } |
1219 User::RequestComplete(reqStatus, KErrDisconnected); |
1162 |
1220 return; |
1163 // if send in progress Q it |
1221 } |
1164 if (iSendInProgress) |
1222 |
1165 { |
1223 // if send in progress Q it |
1166 TInt err=KErrNone; |
1224 if (iSendInProgress) |
1167 aStatus = KRequestPending; |
1225 { |
1168 CSuplPacketInfo *packetInfo = NULL; |
1226 TInt err = KErrNone; |
1169 |
1227 aStatus = KRequestPending; |
1170 TRAP(err, packetInfo = CSuplPacketInfo::NewL(aPacket, aStatus)); |
1228 CSuplPacketInfo *packetInfo = NULL; |
1171 if (err != KErrNone) |
1229 |
1172 { |
1230 TRAP(err, packetInfo = CSuplPacketInfo::NewL(aPacket, aStatus); |
1173 TRequestStatus *reqStatus = &aStatus; |
1231 iPktArray.AppendL(packetInfo)); |
1174 User::RequestComplete(reqStatus, err); |
1232 if (err != KErrNone) |
1175 return; |
1233 { |
1176 } |
1234 TRequestStatus *reqStatus = &aStatus; |
1177 iPktArray.Append(packetInfo); |
1235 User::RequestComplete(reqStatus, err); |
1178 } |
1236 return; |
1179 |
1237 } |
1180 else |
1238 } |
1181 { |
1239 |
1182 TInt err=KErrNone; |
1240 else |
1183 aStatus = KRequestPending; |
1241 { |
1184 TRAP(err, iPkt = CSuplPacketInfo::NewL(aPacket, aStatus)); |
1242 TInt err = KErrNone; |
1185 //iPkt->GetPacketData(iPacket, status); |
1243 aStatus = KRequestPending; |
1186 if (err != KErrNone) |
1244 TRAP(err, iPkt = CSuplPacketInfo::NewL(aPacket, aStatus)); |
1187 { |
1245 //iPkt->GetPacketData(iPacket, status); |
1188 TRequestStatus *reqStatus = &aStatus; |
1246 if (err != KErrNone) |
1189 User::RequestComplete(reqStatus, err); |
1247 { |
1190 return; |
1248 TRequestStatus *reqStatus = &aStatus; |
1191 } |
1249 User::RequestComplete(reqStatus, err); |
1192 iFirstPkt = ETrue; |
1250 return; |
1193 TBuf<64> msg(_L("Sending data on port ")); |
1251 } |
1194 msg.AppendNum(iSocket.LocalPort()); |
1252 iFirstPkt = ETrue; |
1195 iTrace->Trace(msg, KTraceFileName, __LINE__); |
1253 TBuf<64> msg(_L("Sending data on port ")); |
1196 // Log |
1254 msg.AppendNum(iSocket.LocalPort()); |
1197 if(iVariantEnabled) |
1255 iTrace->Trace(msg, KTraceFileName, __LINE__); |
1198 { |
1256 // Log |
1199 iTrace->Trace(_L("CSuplConnection::Send sending packet over Secure Connection"), KTraceFileName, __LINE__); |
1257 if (iVariantEnabled) |
1200 iTlsSocket->Send(aPacket, iStatus); |
1258 { |
1201 iSendInProgress = ETrue; |
1259 iTrace->Trace( |
1202 SetActive(); |
1260 _L( |
1203 } |
1261 "CSuplConnection::Send sending packet over Secure Connection"), |
1204 else |
1262 KTraceFileName, __LINE__); |
1205 { |
1263 iTlsSocket->Send(aPacket, iStatus); |
1206 iTrace->Trace(_L("CSuplConnection::Send sending packet over NonSecure Connection"), KTraceFileName, __LINE__); |
1264 iSendInProgress = ETrue; |
1207 iSocket.Send(aPacket, 0, iStatus); |
1265 SetActive(); |
1208 iSendInProgress = ETrue; |
1266 } |
1209 SetActive(); |
1267 else |
1210 } |
1268 { |
1211 } |
1269 iTrace->Trace( |
1212 } |
1270 _L( |
|
1271 "CSuplConnection::Send sending packet over NonSecure Connection"), |
|
1272 KTraceFileName, __LINE__); |
|
1273 iSocket.Send(aPacket, 0, iStatus); |
|
1274 iSendInProgress = ETrue; |
|
1275 SetActive(); |
|
1276 } |
|
1277 } |
|
1278 } |
1213 |
1279 |
1214 // ----------------------------------------------------------------------------- |
1280 // ----------------------------------------------------------------------------- |
1215 // CSuplConnection::CancelSend |
1281 // CSuplConnection::CancelSend |
1216 // Method to cancel the Socket Send operation |
1282 // Method to cancel the Socket Send operation |
1217 // (other items were commented in a header). |
1283 // (other items were commented in a header). |
1218 // ----------------------------------------------------------------------------- |
1284 // ----------------------------------------------------------------------------- |
1219 // |
1285 // |
1220 EXPORT_C void CSuplConnection::CancelSend(TRequestStatus &aStatus) |
1286 EXPORT_C void CSuplConnection::CancelSend(TRequestStatus &aStatus) |
1221 { |
1287 { |
1222 if (iFirstPkt) |
1288 if (iFirstPkt) |
1223 { |
1289 { |
1224 if(iVariantEnabled) |
1290 if (iVariantEnabled) |
1225 { |
1291 { |
1226 iTrace->Trace(_L("CSuplConnection::Secure Send Cancel"), KTraceFileName, __LINE__); |
1292 iTrace->Trace(_L("CSuplConnection::Secure Send Cancel"), |
1227 iTlsSocket->CancelSend(); |
1293 KTraceFileName, __LINE__); |
1228 } |
1294 iTlsSocket->CancelSend(); |
1229 else |
|
1230 { |
|
1231 iTrace->Trace(_L("CSuplConnection::Non Secure Send Cancel"), KTraceFileName, __LINE__); |
|
1232 iSocket.CancelSend(); |
|
1233 } |
|
1234 delete iPkt; |
|
1235 iPkt = NULL; |
|
1236 TRequestStatus *reqStatus = &aStatus; |
|
1237 User::RequestComplete(reqStatus, KErrCancel); |
|
1238 } |
1295 } |
1239 else |
1296 else |
1240 { |
1297 { |
1241 TInt count = iPktArray.Count(); |
1298 iTrace->Trace(_L("CSuplConnection::Non Secure Send Cancel"), |
1242 if (count == 1) |
1299 KTraceFileName, __LINE__); |
1243 { |
1300 iSocket.CancelSend(); |
1244 TInt index = iPktArray.Find(iPkt); |
1301 } |
1245 if (index != KErrNotFound) |
1302 delete iPkt; |
1246 iPktArray.Remove(index); |
1303 iPkt = NULL; |
1247 delete iPkt; |
1304 TRequestStatus *reqStatus = &aStatus; |
1248 iPkt = NULL; |
1305 User::RequestComplete(reqStatus, KErrCancel); |
1249 TRequestStatus *reqStatus = &aStatus; |
1306 } |
1250 User::RequestComplete(reqStatus, KErrCancel); |
1307 else |
1251 } |
1308 { |
1252 else |
1309 TInt count = iPktArray.Count(); |
1253 { |
1310 if (count == 1) |
1254 for(TInt loop=0;loop<count;loop++) |
1311 { |
|
1312 TInt index = iPktArray.Find(iPkt); |
|
1313 if (index != KErrNotFound) |
|
1314 iPktArray.Remove(index); |
|
1315 delete iPkt; |
|
1316 iPkt = NULL; |
|
1317 TRequestStatus *reqStatus = &aStatus; |
|
1318 User::RequestComplete(reqStatus, KErrCancel); |
|
1319 } |
|
1320 else |
|
1321 { |
|
1322 for (TInt loop = 0; loop < count; loop++) |
|
1323 { |
|
1324 iPkt = REINTERPRET_CAST(CSuplPacketInfo*, iPktArray[0]); |
|
1325 if (iPkt->IsStatusMatches(aStatus)) |
1255 { |
1326 { |
1256 iPkt = REINTERPRET_CAST(CSuplPacketInfo*, iPktArray[0]); |
1327 iTrace->Trace(_L("Found packet, deleting"), |
1257 if (iPkt->IsStatusMatches(aStatus)) |
1328 KTraceFileName, __LINE__); |
|
1329 TInt index = iPktArray.Find(iPkt); |
|
1330 if (index != KErrNotFound) |
1258 { |
1331 { |
1259 iTrace->Trace(_L("Found packet, deleting"), KTraceFileName, __LINE__); |
1332 iTrace->Trace(_L("Found packet, deleted"), |
1260 TInt index = iPktArray.Find(iPkt); |
1333 KTraceFileName, __LINE__); |
1261 if (index != KErrNotFound) |
1334 iPktArray.Remove(index); |
1262 { |
1335 TRequestStatus *reqStatus = &aStatus; |
1263 iTrace->Trace(_L("Found packet, deleted"), KTraceFileName, __LINE__); |
1336 User::RequestComplete(reqStatus, KErrCancel); |
1264 iPktArray.Remove(index); |
1337 } |
1265 TRequestStatus *reqStatus = &aStatus; |
1338 delete iPkt; |
1266 User::RequestComplete(reqStatus, KErrCancel); |
1339 iPkt = NULL; |
1267 } |
1340 break; |
1268 delete iPkt; |
1341 } |
1269 iPkt = NULL; |
1342 } |
1270 break; |
1343 } |
1271 } |
1344 } |
1272 } |
1345 |
1273 } |
1346 } |
1274 } |
|
1275 |
|
1276 } |
|
1277 |
1347 |
1278 // ----------------------------------------------------------------------------- |
1348 // ----------------------------------------------------------------------------- |
1279 // CSuplConnection::Connect |
1349 // CSuplConnection::Connect |
1280 // Makes a socket connection to Network |
1350 // Makes a socket connection to Network |
1281 // (other items were commented in a header). |
1351 // (other items were commented in a header). |
1282 // ----------------------------------------------------------------------------- |
1352 // ----------------------------------------------------------------------------- |
1283 // |
1353 // |
1284 void CSuplConnection::Connect() |
1354 void CSuplConnection::Connect() |
1285 { |
1355 { |
1286 // Log |
1356 // Log |
1287 iTrace->Trace(_L("CSuplConnection::Connect(void)"), KTraceFileName, __LINE__); |
1357 iTrace->Trace(_L("CSuplConnection::Connect(void)"), KTraceFileName, |
1288 |
1358 __LINE__); |
1289 iState = EConnecting; |
1359 |
1290 iTimer->Start(4000000); // For DNS pass case , but not a valid SUPL server |
1360 iState = EConnecting; |
1291 iSocket.Connect(iAddress, iStatus); |
1361 iTimer->Start(4000000); // For DNS pass case , but not a valid SUPL server |
1292 SetActive(); |
1362 iSocket.Connect(iAddress, iStatus); |
1293 } |
1363 if (!IsActive()) |
1294 |
1364 { |
|
1365 SetActive(); |
|
1366 } |
|
1367 } |
|
1368 |
1295 // ----------------------------------------------------------------------------- |
1369 // ----------------------------------------------------------------------------- |
1296 // CSuplConnection::ConnectIAP |
1370 // CSuplConnection::ConnectIAP |
1297 // Makes a socket connection to Network |
1371 // Makes a socket connection to Network |
1298 // (other items were commented in a header). |
1372 // (other items were commented in a header). |
1299 // ----------------------------------------------------------------------------- |
1373 // ----------------------------------------------------------------------------- |
1300 // |
1374 // |
1301 |
1375 |
1302 void CSuplConnection::ConnectIAP() |
1376 void CSuplConnection::ConnectIAP() |
1303 { |
1377 { |
1304 iTrace->Trace(_L("CSuplConnection::ConnectIAP(void)"), KTraceFileName, __LINE__); |
1378 iTrace->Trace(_L("CSuplConnection::ConnectIAP(void)"), KTraceFileName, |
1305 // Connect only if not already connected |
1379 __LINE__); |
1306 if(iState == ENotConnected || iState == EFailure || iState == ERetriveIAP) |
1380 // Connect only if not already connected |
1307 { |
1381 if (iState == ENotConnected || iState == EFailure || iState |
1308 // Open the Socket |
1382 == ERetriveIAP) |
|
1383 { |
|
1384 // Open the Socket |
1309 #ifndef __WINS__ |
1385 #ifndef __WINS__ |
1310 // Emulator can't handle RConnections |
1386 // Emulator can't handle RConnections |
1311 TInt err = iSocket.Open( iSocketServ, |
1387 TInt err = iSocket.Open( iSocketServ, |
1312 KAfInet, |
1388 KAfInet, |
1313 KSockStream, |
1389 KSockStream, |
1314 KProtocolInetTcp, |
1390 KProtocolInetTcp, |
1315 iConnection ); |
1391 iConnection ); |
1316 #else |
1392 #else |
1317 TInt err = iSocket.Open( iSocketServ, |
1393 TInt err = iSocket.Open(iSocketServ, KAfInet, KSockStream, |
1318 KAfInet, |
1394 KProtocolInetTcp); |
1319 KSockStream, |
1395 #endif |
1320 KProtocolInetTcp) ; |
1396 |
1321 #endif |
1397 if (KErrNone != err) |
1322 |
1398 { |
1323 if(KErrNone != err) |
1399 // Log |
1324 { |
1400 iTrace->Trace(_L("CSuplConnection::Socket Open Failure"), |
1325 // Log |
1401 KTraceFileName, __LINE__); |
1326 iTrace->Trace(_L("CSuplConnection::Socket Open Failure"), KTraceFileName, __LINE__); |
1402 |
1327 |
1403 //User::RequestComplete(iReqStatus, err); |
1328 //User::RequestComplete(iReqStatus, err); |
1404 CompleteConnectRequests(err); |
|
1405 return; |
|
1406 } |
|
1407 |
|
1408 // Set IP Address and Port |
|
1409 if (iAddress.Input(iHostAddress) == KErrNone) |
|
1410 { |
|
1411 // Log |
|
1412 iTrace->Trace( |
|
1413 _L( |
|
1414 "CSuplConnection::Connect Host Address is an IP Address"), |
|
1415 KTraceFileName, __LINE__); |
|
1416 |
|
1417 iAddress.SetPort(Port()); |
|
1418 Connect(); |
|
1419 } |
|
1420 |
|
1421 else |
|
1422 { |
|
1423 // DNS Lookup |
|
1424 // Log |
|
1425 iTrace->Trace(_L("CSuplConnection::Connect Perform DNS lookup"), |
|
1426 KTraceFileName, __LINE__); |
|
1427 #ifndef __WINS__ |
|
1428 err = iResolver.Open(iSocketServ, KAfInet, KProtocolInetUdp, iConnection); |
|
1429 #else |
|
1430 err = iResolver.Open(iSocketServ, KAfInet, KProtocolInetUdp); |
|
1431 #endif |
|
1432 if (KErrNone != err) |
|
1433 { |
|
1434 //User::RequestComplete(iReqStatus, err); |
1329 CompleteConnectRequests(err); |
1435 CompleteConnectRequests(err); |
1330 return; |
1436 return; |
1331 } |
1437 } |
1332 |
1438 |
1333 // Set IP Address and Port |
1439 iState = ELookingUp; |
1334 if(iAddress.Input(iHostAddress) == KErrNone) |
1440 iResolver.GetByName(iHostAddress, iNameEntry, iStatus); |
1335 { |
1441 iTimer->Start(10000000); |
1336 // Log |
1442 if (!IsActive()) |
1337 iTrace->Trace(_L("CSuplConnection::Connect Host Address is an IP Address"), KTraceFileName, __LINE__); |
1443 { |
1338 |
1444 SetActive(); |
1339 iAddress.SetPort(Port()); |
1445 } |
1340 Connect(); |
1446 } |
1341 } |
1447 |
1342 |
1448 } |
1343 else |
1449 |
1344 { |
1450 else |
1345 // DNS Lookup |
1451 { |
1346 // Log |
1452 // Already Connected. Just return KErrNone |
1347 iTrace->Trace(_L("CSuplConnection::Connect Perform DNS lookup"), KTraceFileName, __LINE__); |
1453 //User::RequestComplete(iReqStatus, KErrNone); |
1348 #ifndef __WINS__ |
1454 CompleteConnectRequests( KErrNone); |
1349 err = iResolver.Open(iSocketServ, KAfInet, KProtocolInetUdp, iConnection); |
1455 } |
1350 #else |
1456 |
1351 err = iResolver.Open(iSocketServ, KAfInet, KProtocolInetUdp); |
1457 } |
1352 #endif |
|
1353 if(KErrNone != err) |
|
1354 { |
|
1355 //User::RequestComplete(iReqStatus, err); |
|
1356 CompleteConnectRequests(err); |
|
1357 return; |
|
1358 } |
|
1359 |
|
1360 iState = ELookingUp; |
|
1361 iResolver.GetByName(iHostAddress, iNameEntry, iStatus); |
|
1362 iTimer->Start(10000000); |
|
1363 SetActive(); |
|
1364 } |
|
1365 |
|
1366 } |
|
1367 |
|
1368 else |
|
1369 { |
|
1370 // Already Connected. Just return KErrNone |
|
1371 //User::RequestComplete(iReqStatus, KErrNone); |
|
1372 CompleteConnectRequests(KErrNone); |
|
1373 } |
|
1374 |
|
1375 } |
|
1376 // ----------------------------------------------------------------------------- |
1458 // ----------------------------------------------------------------------------- |
1377 // CSuplConnection::MakeSecureConnection |
1459 // CSuplConnection::MakeSecureConnection |
1378 // Makes a secure connection to Network |
1460 // Makes a secure connection to Network |
1379 // (other items were commented in a header). |
1461 // (other items were commented in a header). |
1380 // ----------------------------------------------------------------------------- |
1462 // ----------------------------------------------------------------------------- |
1381 // |
1463 // |
1382 void CSuplConnection::MakeSecureConnection() |
1464 void CSuplConnection::MakeSecureConnection() |
1383 { |
1465 { |
1384 // Log |
1466 // Log |
1385 iTrace->Trace(_L("CSuplConnection::MakeSecureConnection"), KTraceFileName, __LINE__); |
1467 iTrace->Trace(_L("CSuplConnection::MakeSecureConnection"), |
1386 |
1468 KTraceFileName, __LINE__); |
1387 // Clear any pervious options |
1469 |
1388 //iTlsSocket->FlushSessionCache(); |
1470 // Clear any pervious options |
1389 |
1471 //iTlsSocket->FlushSessionCache(); |
1390 iTlsSocket->StartClientHandshake( iStatus ); |
1472 |
1391 iTimer->Start(10000000); |
1473 iTlsSocket->StartClientHandshake(iStatus); |
1392 iState = ESecureHandShake; |
1474 iTimer->Start(10000000); |
1393 SetActive(); |
1475 iState = ESecureHandShake; |
1394 |
1476 if (!IsActive()) |
1395 } |
1477 { |
1396 |
1478 SetActive(); |
|
1479 } |
|
1480 } |
1397 |
1481 |
1398 // ----------------------------------------------------------------------------- |
1482 // ----------------------------------------------------------------------------- |
1399 // CSuplConnection::ListenToMessages |
1483 // CSuplConnection::ListenToMessages |
1400 // Start reading from the socket for packets from the network |
1484 // Start reading from the socket for packets from the network |
1401 // (other items were commented in a header). |
1485 // (other items were commented in a header). |
1402 // ----------------------------------------------------------------------------- |
1486 // ----------------------------------------------------------------------------- |
1403 // |
1487 // |
1404 EXPORT_C TInt CSuplConnection::ListenToMessages() |
1488 EXPORT_C TInt CSuplConnection::ListenToMessages() |
1405 { |
1489 { |
1406 // Log |
1490 // Log |
1407 iTrace->Trace(_L("CSuplConnection::ListenToMessages"), KTraceFileName, __LINE__); |
1491 iTrace->Trace(_L("CSuplConnection::ListenToMessages"), KTraceFileName, |
1408 |
1492 __LINE__); |
1409 iListenCount++; |
1493 |
1410 |
1494 iListenCount++; |
1411 if (iStartedListen) |
1495 |
1412 return KErrNone; |
1496 if (iStartedListen) |
1413 |
1497 return KErrNone; |
1414 if(iState != EConnected) |
1498 |
1415 { |
1499 if (iState != EConnected) |
1416 return KErrDisconnected; |
1500 { |
1417 } |
1501 return KErrDisconnected; |
1418 |
1502 } |
1419 if(iSocketReader && (!IsActive())) |
1503 |
1420 { |
1504 if (iSocketReader && (!IsActive())) |
1421 iSocketReader->SetPortNum(GetPortNumberUsed()); |
1505 { |
1422 iSocketReader->IssueRead(); |
1506 iSocketReader->SetPortNum(GetPortNumberUsed()); |
1423 iStartedListen = ETrue; |
1507 iSocketReader->IssueRead(); |
1424 return KErrNone; |
1508 iStartedListen = ETrue; |
1425 } |
1509 return KErrNone; |
1426 |
1510 } |
1427 return KErrGeneral; |
1511 |
1428 } |
1512 return KErrGeneral; |
|
1513 } |
1429 |
1514 |
1430 // ----------------------------------------------------------------------------- |
1515 // ----------------------------------------------------------------------------- |
1431 // CSuplConnection::GetLocalIPAddress |
1516 // CSuplConnection::GetLocalIPAddress |
1432 // Start reading from the socket for packets from the network |
1517 // Start reading from the socket for packets from the network |
1433 // (other items were commented in a header). |
1518 // (other items were commented in a header). |
1434 // ----------------------------------------------------------------------------- |
1519 // ----------------------------------------------------------------------------- |
1435 // |
1520 // |
1436 |
1521 |
1437 EXPORT_C TInt CSuplConnection::GetLocalIPAddress(TInetAddr & aTInetAddress ) |
1522 EXPORT_C TInt CSuplConnection::GetLocalIPAddress(TInetAddr & aTInetAddress) |
1438 { |
1523 { |
1439 if(iState != EConnected) |
1524 if (iState != EConnected) |
1440 return KErrDisconnected; |
1525 return KErrDisconnected; |
1441 |
1526 |
1442 TSockAddr sockAddr; |
1527 TSockAddr sockAddr; |
1443 iSocket.LocalName(sockAddr); |
1528 iSocket.LocalName(sockAddr); |
1444 |
1529 |
1445 TInetAddr inetAddress(sockAddr); |
1530 TInetAddr inetAddress(sockAddr); |
1446 |
1531 |
1447 aTInetAddress = inetAddress; |
1532 aTInetAddress = inetAddress; |
1448 return KErrNone; |
1533 return KErrNone; |
1449 } |
1534 } |
1450 |
1535 |
1451 // ----------------------------------------------------------------------------- |
1536 // ----------------------------------------------------------------------------- |
1452 // CSuplConnection::CancelListenToMessages |
1537 // CSuplConnection::CancelListenToMessages |
1453 // Start reading from the socket for packets from the network |
1538 // Start reading from the socket for packets from the network |
1454 // (other items were commented in a header). |
1539 // (other items were commented in a header). |
1455 // ----------------------------------------------------------------------------- |
1540 // ----------------------------------------------------------------------------- |
1456 // |
1541 // |
1457 EXPORT_C void CSuplConnection::CancelListenToMessages() |
1542 EXPORT_C void CSuplConnection::CancelListenToMessages() |
1458 { |
1543 { |
1459 if (iListenCount > 1) |
1544 if (iListenCount > 1) |
1460 { |
1545 { |
1461 iListenCount--; |
1546 iListenCount--; |
1462 return; |
1547 return; |
1463 } |
1548 } |
1464 if(iSocketReader) |
1549 if (iSocketReader) |
1465 { |
1550 { |
1466 iSocketReader->Cancel(); |
1551 iSocketReader->Cancel(); |
1467 } |
1552 } |
1468 } |
1553 } |
1469 |
1554 |
1470 // ----------------------------------------------------------------------------- |
1555 // ----------------------------------------------------------------------------- |
1471 // COMASuplProvHandler::SetVariation |
1556 // COMASuplProvHandler::SetVariation |
1472 // Initializes the local variation flag |
1557 // Initializes the local variation flag |
1473 // ----------------------------------------------------------------------------- |
1558 // ----------------------------------------------------------------------------- |
1474 // |
1559 // |
1475 void CSuplConnection::SetVariation() |
1560 void CSuplConnection::SetVariation() |
1476 { |
1561 { |
1477 #if 0 |
1562 #if 0 |
1478 CRepository *repository = NULL; |
1563 CRepository *repository = NULL; |
1479 TRAPD( err, repository = CRepository::NewL( KCRUidSuplConfiguration)); |
1564 TRAPD( err, repository = CRepository::NewL( KCRUidSuplConfiguration)); |
1480 if ( KErrNone != err ) |
1565 if ( KErrNone != err ) |
1481 { |
1566 { |
1482 return; |
1567 return; |
1483 } |
1568 } |
1484 |
1569 |
1485 TInt val; |
1570 TInt val; |
1486 TInt rc = repository->Get( KSuplTLSAuthenticationVariant,val ); |
1571 TInt rc = repository->Get( KSuplTLSAuthenticationVariant,val ); |
1487 if ( KErrNone == rc && val == 0 ) |
1572 if ( KErrNone == rc && val == 0 ) |
1488 { |
1573 { |
1489 iVariantEnabled = EFalse; |
1574 iVariantEnabled = EFalse; |
1490 } |
1575 } |
1491 |
1576 |
1492 if ( KErrNone == rc && (val == 1 || val == 2 )) |
1577 if ( KErrNone == rc && (val == 1 || val == 2 )) |
1493 { |
1578 { |
1494 iVariantEnabled = ETrue; |
1579 iVariantEnabled = ETrue; |
1495 if(val == 2 ) |
1580 if(val == 2 ) |
1496 { |
1581 { |
1497 iPskTLSUsage = ETrue; |
1582 iPskTLSUsage = ETrue; |
1498 } |
1583 } |
1499 } |
1584 } |
1500 |
1585 |
1501 delete repository; |
1586 delete repository; |
1502 #endif |
1587 #endif |
1503 } |
1588 } |
1504 |
1589 |
1505 EXPORT_C void CSuplConnection::CloseConnection() |
1590 EXPORT_C void CSuplConnection::CloseConnection() |
1506 { |
1591 { |
1507 if(iTrace) |
1592 if (iTrace) |
1508 iTrace->Trace(_L("CSuplConnection::CloseConnection"), KTraceFileName, __LINE__); |
1593 iTrace->Trace(_L("CSuplConnection::CloseConnection"), KTraceFileName, |
|
1594 __LINE__); |
1509 |
1595 |
1510 // if connection request is from multiple clients and it is not yet |
1596 // if connection request is from multiple clients and it is not yet |
1511 // completed, just return. |
1597 // completed, just return. |
1512 if (iConnArray.Count() > 1) |
1598 if (iConnArray.Count() > 1) |
1513 return; |
1599 return; |
1514 #if 0 |
1600 #if 0 |
1515 TBuf<128> buf; |
1601 TBuf<128> buf; |
1516 buf.Copy(_L("CSuplConnection::CloseConnection, iConnectClients = ")); |
1602 buf.Copy(_L("CSuplConnection::CloseConnection, iConnectClients = ")); |
1517 buf.AppendNum(iConnectClients); |
1603 buf.AppendNum(iConnectClients); |
1518 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1604 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1519 |
1605 |
1520 buf.Copy(_L("CSuplConnection::CloseConnection, iState = ")); |
1606 buf.Copy(_L("CSuplConnection::CloseConnection, iState = ")); |
1521 buf.AppendNum(iState); |
1607 buf.AppendNum(iState); |
1522 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1608 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1523 #endif |
1609 #endif |
1524 |
1610 |
1525 if (iConnArray.Count() == 1) |
1611 if (iConnArray.Count() == 1) |
1526 iConnArray.Reset(); |
1612 iConnArray.Reset(); |
1527 |
1613 |
1528 iConnectClients--; |
1614 iConnectClients--; |
1529 |
1615 |
1530 if (iConnectClients > 0) //earlier > 1 |
1616 if (iConnectClients > 0) //earlier > 1 |
1531 return; |
1617 return; |
1532 |
1618 |
1533 iResolver.Close(); |
1619 iResolver.Close(); |
1534 CancelListenToMessages(); |
1620 CancelListenToMessages(); |
1535 // Close the Socket if required |
1621 // Close the Socket if required |
1536 if(iState == EConnected || iState == EConnecting || iState == ESecureHandShake) |
1622 if (iState == EConnected || iState == EConnecting || iState |
1537 { |
1623 == ESecureHandShake) |
1538 if(iTrace) |
1624 { |
1539 iTrace->Trace(_L("CSuplConnection::...Closing Socket"), KTraceFileName, __LINE__); |
1625 if (iTrace) |
1540 if(iVariantEnabled) |
1626 iTrace->Trace(_L("CSuplConnection::...Closing Socket"), |
1541 iTlsSocket->Close(); |
1627 KTraceFileName, __LINE__); |
1542 iSocket.Close(); |
1628 if (iVariantEnabled) |
1543 } |
1629 iTlsSocket->Close(); |
1544 |
1630 iSocket.Close(); |
|
1631 } |
|
1632 |
1545 #ifndef __WINS__ |
1633 #ifndef __WINS__ |
1546 // Close the RConnection |
1634 // Close the RConnection |
1547 if(iTrace) |
1635 if(iTrace) |
1548 iTrace->Trace(_L("CSuplConnection::...Closing RConnection"), KTraceFileName, __LINE__); |
1636 iTrace->Trace(_L("CSuplConnection::...Closing RConnection"), KTraceFileName, __LINE__); |
1549 iConnection.Close(); |
1637 iConnection.Close(); |
1550 #endif |
1638 #endif |
1551 iState = ENotConnected; |
1639 iState = ENotConnected; |
1552 } |
1640 } |
1553 |
1641 |
1554 // ----------------------------------------------------------------------------- |
1642 // ----------------------------------------------------------------------------- |
1555 // CSuplConnection::GetPskL |
1643 // CSuplConnection::GetPskL |
1556 // |
1644 // |
1557 // (other items were commented in a header). |
1645 // (other items were commented in a header). |
1558 // ----------------------------------------------------------------------------- |
1646 // ----------------------------------------------------------------------------- |
1559 // |
1647 // |
1560 |
1648 |
1561 // PSK TLS Start |
1649 // PSK TLS Start |
1562 void CSuplConnection::GetPskL(const HBufC8 * aPskIdentityHint, HBufC8 *& aPskIdentity, HBufC8 *& aPskKey) |
1650 void CSuplConnection::GetPskL(const HBufC8 * aPskIdentityHint, |
1563 { |
1651 HBufC8 *& aPskIdentity, HBufC8 *& aPskKey) |
1564 |
1652 { |
1565 iTrace->Trace(_L("CSuplConnection::GetPskL Start"), KTraceFileName, __LINE__); |
1653 |
1566 if (aPskIdentityHint != NULL && aPskIdentityHint->Length() >= KMaxPskIdentityHintLength ) |
1654 iTrace->Trace(_L("CSuplConnection::GetPskL Start"), KTraceFileName, |
1567 { |
1655 __LINE__); |
1568 iTrace->Trace(_L("aPskIdentityHint is not null..."), KTraceFileName, __LINE__); |
1656 if (aPskIdentityHint != NULL && aPskIdentityHint->Length() |
1569 TBuf8<KMaxGBAUsageLength> gbaUsage; |
1657 >= KMaxPskIdentityHintLength) |
1570 TBuf8<KMaxVerLength> ver; |
1658 { |
1571 TBuf8<KMaxNewPasswordLength> newPassword; |
1659 iTrace->Trace(_L("aPskIdentityHint is not null..."), KTraceFileName, |
1572 |
1660 __LINE__); |
1573 gbaUsage.Copy(aPskIdentityHint->Left(KMaxGBAUsageLength)); |
1661 TBuf8<KMaxGBAUsageLength> gbaUsage; |
1574 ver.Copy(aPskIdentityHint->Mid(KMaxGBAUsageLength,KMaxVerLength)); |
1662 TBuf8<KMaxVerLength> ver; |
1575 newPassword.Copy(aPskIdentityHint->Mid(KMaxGBAUsageLength + KMaxVerLength)); |
1663 TBuf8<KMaxNewPasswordLength> newPassword; |
1576 |
1664 |
1577 gbaUsage.UpperCase(); |
1665 gbaUsage.Copy(aPskIdentityHint->Left(KMaxGBAUsageLength)); |
1578 ver.UpperCase(); |
1666 ver.Copy(aPskIdentityHint->Mid(KMaxGBAUsageLength, KMaxVerLength)); |
1579 |
1667 newPassword.Copy(aPskIdentityHint->Mid(KMaxGBAUsageLength |
1580 if(gbaUsage.Compare(KWGBA) == 0) //We will proceed with key generation if its WGBA |
1668 + KMaxVerLength)); |
1581 { |
1669 |
1582 iTrace->Trace(_L("Its WGBA..."), KTraceFileName, __LINE__); |
1670 gbaUsage.UpperCase(); |
1583 GeneratePsk_Identity_KeyL(ver,newPassword,aPskIdentity,aPskKey); |
1671 ver.UpperCase(); |
1584 } |
1672 |
1585 else |
1673 if (gbaUsage.Compare(KWGBA) == 0) //We will proceed with key generation if its WGBA |
1586 { |
1674 { |
1587 TBuf<32> buf; |
1675 iTrace->Trace(_L("Its WGBA..."), KTraceFileName, __LINE__); |
1588 buf.Copy(gbaUsage); |
1676 GeneratePsk_Identity_KeyL(ver, newPassword, aPskIdentity, aPskKey); |
1589 iTrace->Trace(_L("Received GBA field is ..."), KTraceFileName, __LINE__); |
1677 } |
1590 iTrace->Trace(buf,KTraceFileName, __LINE__); |
1678 else |
1591 iTrace->Trace(_L("Leaving as of now,till GBA supports comes..."), KTraceFileName, __LINE__); |
1679 { |
1592 User::LeaveIfError(KErrNotSupported); |
1680 TBuf<32> buf; |
1593 } |
1681 buf.Copy(gbaUsage); |
1594 } |
1682 iTrace->Trace(_L("Received GBA field is ..."), KTraceFileName, |
|
1683 __LINE__); |
|
1684 iTrace->Trace(buf, KTraceFileName, __LINE__); |
|
1685 iTrace->Trace(_L("Leaving as of now,till GBA supports comes..."), |
|
1686 KTraceFileName, __LINE__); |
|
1687 User::LeaveIfError( KErrNotSupported); |
|
1688 } |
|
1689 } |
1595 else |
1690 else |
1596 { |
1691 { |
1597 iTrace->Trace(_L("Either Hint is Null OR Hint Length is exceeded."), KTraceFileName, __LINE__); |
1692 iTrace->Trace(_L("Either Hint is Null OR Hint Length is exceeded."), |
1598 User::LeaveIfError(KErrArgument); |
1693 KTraceFileName, __LINE__); |
1599 } |
1694 User::LeaveIfError( KErrArgument); |
1600 |
1695 } |
1601 #ifdef _DEBUG |
1696 |
1602 LogPskKeyInfoL(aPskIdentityHint,aPskIdentity,aPskKey); |
1697 #ifdef _DEBUG |
1603 #endif |
1698 LogPskKeyInfoL(aPskIdentityHint, aPskIdentity, aPskKey); |
1604 iTrace->Trace(_L("CSuplConnection::GetPskL End"), KTraceFileName, __LINE__); |
1699 #endif |
1605 |
1700 iTrace->Trace(_L("CSuplConnection::GetPskL End"), KTraceFileName, |
1606 } |
1701 __LINE__); |
1607 |
1702 |
|
1703 } |
|
1704 |
1608 // ----------------------------------------------------------------------------- |
1705 // ----------------------------------------------------------------------------- |
1609 // CSuplConnection::GeneratePsk_Identity_KeyL |
1706 // CSuplConnection::GeneratePsk_Identity_KeyL |
1610 // |
1707 // |
1611 // (other items were commented in a header). |
1708 // (other items were commented in a header). |
1612 // ----------------------------------------------------------------------------- |
1709 // ----------------------------------------------------------------------------- |
1613 // |
1710 // |
1614 void CSuplConnection::GeneratePsk_Identity_KeyL(const TDesC8& aSLPKeyVer,const TDesC8& aPassKey, |
1711 void CSuplConnection::GeneratePsk_Identity_KeyL(const TDesC8& aSLPKeyVer, |
1615 HBufC8 *& aPskIdentity, HBufC8 *& aPskKey) |
1712 const TDesC8& aPassKey, HBufC8 *& aPskIdentity, HBufC8 *& aPskKey) |
1616 { |
1713 { |
1617 |
1714 |
1618 iTrace->Trace(_L("Before CR..."), KTraceFileName, __LINE__); |
1715 iTrace->Trace(_L("Before CR..."), KTraceFileName, __LINE__); |
1619 CRepository* repository = CRepository::NewL( KCRUidPskTLSUsageConfiguration); |
1716 CRepository* repository = CRepository::NewL( |
1620 iTrace->Trace(_L("After CR..."), KTraceFileName, __LINE__); |
1717 KCRUidPskTLSUsageConfiguration); |
1621 CleanupStack::PushL(repository); |
1718 iTrace->Trace(_L("After CR..."), KTraceFileName, __LINE__); |
1622 |
1719 CleanupStack::PushL(repository); |
1623 TInt keyVersion; |
1720 |
1624 |
1721 TInt keyVersion; |
1625 TLex8 verStr(aSLPKeyVer); |
1722 |
1626 TInt SLPKeyVer; |
1723 TLex8 verStr(aSLPKeyVer); |
1627 verStr.Val(SLPKeyVer); |
1724 TInt SLPKeyVer; |
1628 |
1725 verStr.Val(SLPKeyVer); |
1629 TBuf8<KMaxPskKeyLength> pskKey; |
1726 |
1630 |
1727 TBuf8<KMaxPskKeyLength> pskKey; |
1631 TInt rc = repository->Get(KSuplPskTLSKeyVersion,keyVersion); |
1728 |
1632 if(rc == KErrNone && keyVersion == SLPKeyVer) |
1729 TInt rc = repository->Get(KSuplPskTLSKeyVersion, keyVersion); |
1633 { |
1730 if (rc == KErrNone && keyVersion == SLPKeyVer) |
1634 iTrace->Trace(_L("Version is matching with stored one..."), KTraceFileName, __LINE__); |
1731 { |
1635 rc = repository->Get(KSuplPskTLSNewPassword,pskKey); |
1732 iTrace->Trace(_L("Version is matching with stored one..."), |
1636 if(rc == KErrNone) |
1733 KTraceFileName, __LINE__); |
1637 { |
1734 rc = repository->Get(KSuplPskTLSNewPassword, pskKey); |
1638 aPskKey = HBufC8::NewL(KMaxPskKeyLength); |
1735 if (rc == KErrNone) |
1639 aPskKey->Des().Copy(pskKey); |
1736 { |
1640 iTrace->Trace(_L("Copied Psk Key"), KTraceFileName, __LINE__); |
1737 aPskKey = HBufC8::NewL(KMaxPskKeyLength); |
1641 PrintHex(pskKey,__LINE__); |
1738 aPskKey->Des().Copy(pskKey); |
1642 } |
1739 iTrace->Trace(_L("Copied Psk Key"), KTraceFileName, __LINE__); |
1643 else |
1740 PrintHex(pskKey, __LINE__); |
1644 { |
1741 } |
1645 iTrace->Trace(_L("KSuplPskTLSNewPassword Not Found"), KTraceFileName, __LINE__); |
1742 else |
1646 User::LeaveIfError(rc); |
1743 { |
1647 } |
1744 iTrace->Trace(_L("KSuplPskTLSNewPassword Not Found"), |
1648 } |
1745 KTraceFileName, __LINE__); |
1649 else |
1746 User::LeaveIfError(rc); |
1650 { |
1747 } |
1651 iTrace->Trace(_L("Version is NOT matching with stored one..."), KTraceFileName, __LINE__); |
1748 } |
1652 iTrace->Trace(_L("Generating new Key..."), KTraceFileName, __LINE__); |
1749 else |
1653 GeneratePskKeyL(repository,aPassKey,aPskKey,SLPKeyVer); |
1750 { |
1654 PrintHex(*aPskKey,__LINE__); |
1751 iTrace->Trace(_L("Version is NOT matching with stored one..."), |
1655 } |
1752 KTraceFileName, __LINE__); |
1656 |
1753 iTrace->Trace(_L("Generating new Key..."), KTraceFileName, __LINE__); |
1657 GeneratePskIdentityL(repository,SLPKeyVer,aPskIdentity); |
1754 GeneratePskKeyL(repository, aPassKey, aPskKey, SLPKeyVer); |
1658 CleanupStack::PopAndDestroy(repository); |
1755 PrintHex(*aPskKey, __LINE__); |
1659 |
1756 } |
1660 } |
1757 |
|
1758 GeneratePskIdentityL(repository, SLPKeyVer, aPskIdentity); |
|
1759 CleanupStack::PopAndDestroy(repository); |
|
1760 |
|
1761 } |
1661 |
1762 |
1662 // ----------------------------------------------------------------------------- |
1763 // ----------------------------------------------------------------------------- |
1663 // CSuplConnection::GeneratePskIdentity |
1764 // CSuplConnection::GeneratePskIdentity |
1664 // |
1765 // |
1665 // (other items were commented in a header). |
1766 // (other items were commented in a header). |
1666 // ----------------------------------------------------------------------------- |
1767 // ----------------------------------------------------------------------------- |
1667 // |
1768 // |
1668 void CSuplConnection::GeneratePskIdentityL(CRepository* aRepository,TInt /*aKeyVer*/,HBufC8 *& aPskIdentity) |
1769 void CSuplConnection::GeneratePskIdentityL(CRepository* aRepository, |
1669 { |
1770 TInt /*aKeyVer*/, HBufC8 *& aPskIdentity) |
1670 iTrace->Trace(_L("Start of GeneratePskIdentityL"), KTraceFileName, __LINE__); |
1771 { |
1671 |
1772 iTrace->Trace(_L("Start of GeneratePskIdentityL"), KTraceFileName, |
1672 TInt crKeyId; |
1773 __LINE__); |
1673 TInt rc = aRepository->Get(KSuplPskTLSKeyId,crKeyId); |
1774 |
1674 |
1775 TInt crKeyId; |
1675 if(rc == KErrNone) |
1776 TInt rc = aRepository->Get(KSuplPskTLSKeyId, crKeyId); |
1676 { |
1777 |
1677 aPskIdentity = HBufC8::NewL(KMaxPskKeyLength); |
1778 if (rc == KErrNone) |
1678 aPskIdentity->Des().Append(crKeyId); |
1779 { |
1679 aPskIdentity->Des().Append(13);//newline |
1780 aPskIdentity = HBufC8::NewL(KMaxPskKeyLength); |
1680 iTrace->Trace(_L("Copied PskIdentityL"), KTraceFileName, __LINE__); |
1781 aPskIdentity->Des().Append(crKeyId); |
1681 TRACESTRING("PskIdentity : ") |
1782 aPskIdentity->Des().Append(13);//newline |
1682 PrintHex(aPskIdentity->Des(),__LINE__); |
1783 iTrace->Trace(_L("Copied PskIdentityL"), KTraceFileName, __LINE__); |
1683 } |
1784 TRACESTRING ("PskIdentity : ") |
1684 else |
1785 PrintHex(aPskIdentity->Des(),__LINE__); |
1685 { |
1786 } |
1686 iTrace->Trace(_L("KSuplPskTLSKeyId Not Found"), KTraceFileName, __LINE__); |
1787 else |
1687 User::LeaveIfError(rc); |
1788 { |
1688 } |
1789 iTrace->Trace(_L("KSuplPskTLSKeyId Not Found"), KTraceFileName, __LINE__); |
1689 iTrace->Trace(_L("End of GeneratePskIdentityL"), KTraceFileName, __LINE__); |
1790 User::LeaveIfError(rc); |
1690 } |
1791 } |
1691 |
1792 iTrace->Trace(_L("End of GeneratePskIdentityL"), KTraceFileName, __LINE__); |
|
1793 } |
1692 |
1794 |
1693 // ----------------------------------------------------------------------------- |
1795 // ----------------------------------------------------------------------------- |
1694 // CSuplConnection::GeneratePskKeyL |
1796 // CSuplConnection::GeneratePskKeyL |
1695 // |
1797 // |
1696 // (other items were commented in a header). |
1798 // (other items were commented in a header). |
1697 // ----------------------------------------------------------------------------- |
1799 // ----------------------------------------------------------------------------- |
1698 // |
1800 // |
1699 void CSuplConnection::GeneratePskKeyL(CRepository* aRepository,const TDesC8& aPassKey,HBufC8 *& aPskKey,TInt aSLPKeyVersion) |
1801 void CSuplConnection::GeneratePskKeyL(CRepository* aRepository, |
1700 { |
1802 const TDesC8& aPassKey, HBufC8 *& aPskKey, TInt aSLPKeyVersion) |
1701 unsigned char newpassword[32]; |
1803 { |
1702 TBuf8<KMaxRootKeyLength> rootKey; |
1804 unsigned char newpassword[32]; |
1703 TBuf8<KMaxRootKeyXORLength> rootXORedPassKey; |
1805 TBuf8<KMaxRootKeyLength> rootKey; |
1704 TBuf8<KMaxSaltLength> finalSalt; |
1806 TBuf8<KMaxRootKeyXORLength> rootXORedPassKey; |
1705 |
1807 TBuf8<KMaxSaltLength> finalSalt; |
1706 iTrace->Trace(_L("Get rootKey from CR"), KTraceFileName, __LINE__); |
1808 |
1707 |
1809 iTrace->Trace(_L("Get rootKey from CR"), KTraceFileName, __LINE__); |
1708 TBuf<KMaxRootKeyLength> rootKey16; |
1810 |
1709 TInt rc = aRepository->Get(KSuplPskTLSRootPassword,rootKey16); |
1811 TBuf<KMaxRootKeyLength> rootKey16; |
1710 rootKey.Copy(rootKey16); |
1812 TInt rc = aRepository->Get(KSuplPskTLSRootPassword, rootKey16); |
1711 |
1813 rootKey.Copy(rootKey16); |
1712 TBuf<64> buf; |
1814 |
1713 TRACESTRING("Root Key from CenRep") |
1815 TBuf<64> buf; |
1714 TRACETEXT(rootKey) |
1816 TRACESTRING("Root Key from CenRep") |
1715 |
1817 TRACETEXT(rootKey) |
1716 buf.Copy(_L("Get(KSuplPskTLSRootPassword,rootKey16) ")); |
1818 |
1717 buf.AppendNum(rc); |
1819 buf.Copy(_L("Get(KSuplPskTLSRootPassword,rootKey16) ")); |
1718 buf.Append(_L(" Len of rootkey ")); |
1820 buf.AppendNum(rc); |
1719 buf.AppendNum(rootKey.Length()); |
1821 buf.Append(_L(" Len of rootkey ")); |
1720 iTrace->Trace(buf,KTraceFileName, __LINE__); |
1822 buf.AppendNum(rootKey.Length()); |
1721 User::LeaveIfError(rc); |
1823 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1722 |
1824 User::LeaveIfError(rc); |
1723 TRACESTRING("Pass Key from SLP") |
1825 |
1724 TRACETEXT(aPassKey) |
1826 TRACESTRING("Pass Key from SLP") |
1725 |
1827 TRACETEXT(aPassKey) |
1726 if(rc == KErrNone && rootKey.Length() != 0) |
1828 |
1727 { |
1829 if(rc == KErrNone && rootKey.Length() != 0) |
1728 TBuf8<KMaxRootKeyLength> rootXORedKey; |
1830 { |
1729 |
1831 TBuf8<KMaxRootKeyLength> rootXORedKey; |
1730 iTrace->Trace(_L("DoSelfXOR"), KTraceFileName, __LINE__); |
1832 |
1731 DoSelfXOR(rootXORedKey,rootKey); |
1833 iTrace->Trace(_L("DoSelfXOR"), KTraceFileName, __LINE__); |
1732 TRACESTRING("Self XOR") |
1834 DoSelfXOR(rootXORedKey,rootKey); |
1733 PrintHex(rootXORedKey,__LINE__); |
1835 TRACESTRING("Self XOR") |
1734 |
1836 PrintHex(rootXORedKey,__LINE__); |
1735 iTrace->Trace(_L("DoXOR"), KTraceFileName, __LINE__); |
1837 |
1736 DoXOR(rootXORedPassKey,aPassKey,rootXORedKey); |
1838 iTrace->Trace(_L("DoXOR"), KTraceFileName, __LINE__); |
1737 TRACESTRING("DoXOR") |
1839 DoXOR(rootXORedPassKey,aPassKey,rootXORedKey); |
1738 PrintHex(rootXORedPassKey,__LINE__); |
1840 TRACESTRING("DoXOR") |
1739 |
1841 PrintHex(rootXORedPassKey,__LINE__); |
1740 iTrace->Trace(_L("FormSalt"), KTraceFileName, __LINE__); |
1842 |
1741 TRACETEXT(KSaltValue) |
1843 iTrace->Trace(_L("FormSalt"), KTraceFileName, __LINE__); |
1742 FormSaltKey(finalSalt,KSaltValue); |
1844 TRACETEXT(KSaltValue) |
1743 TRACESTRING("Salt Value in hex...") |
1845 FormSaltKey(finalSalt,KSaltValue); |
1744 PrintHex(finalSalt,__LINE__); |
1846 TRACESTRING("Salt Value in hex...") |
1745 |
1847 PrintHex(finalSalt,__LINE__); |
1746 iTrace->Trace(_L("Call derive key"), KTraceFileName, __LINE__); |
1848 |
1747 |
1849 iTrace->Trace(_L("Call derive key"), KTraceFileName, __LINE__); |
1748 buf.Copy(_L("Length of RootXORedPassKey ")); |
1850 |
1749 buf.AppendNum(rootXORedPassKey.Length()); |
1851 buf.Copy(_L("Length of RootXORedPassKey ")); |
1750 TRACETEXT(buf) |
1852 buf.AppendNum(rootXORedPassKey.Length()); |
1751 |
1853 TRACETEXT(buf) |
1752 buf.Copy(_L("Length of Salt Key ")); |
1854 |
1753 buf.AppendNum(finalSalt.Length()); |
1855 buf.Copy(_L("Length of Salt Key ")); |
1754 TRACETEXT(buf) |
1856 buf.AppendNum(finalSalt.Length()); |
1755 |
1857 TRACETEXT(buf) |
1756 derive_key(rootXORedPassKey.Ptr(),rootXORedPassKey.Length(),finalSalt.Ptr(), |
1858 |
1757 finalSalt.Length(),8,newpassword,32); |
1859 derive_key(rootXORedPassKey.Ptr(),rootXORedPassKey.Length(),finalSalt.Ptr(), |
1758 |
1860 finalSalt.Length(),8,newpassword,32); |
1759 iTrace->Trace(_L("Copy key into PskKey"), KTraceFileName, __LINE__); |
1861 |
1760 |
1862 iTrace->Trace(_L("Copy key into PskKey"), KTraceFileName, __LINE__); |
1761 aPskKey = HBufC8::NewL(32); |
1863 |
1762 aPskKey->Des().Copy(newpassword,32); |
1864 aPskKey = HBufC8::NewL(32); |
1763 |
1865 aPskKey->Des().Copy(newpassword,32); |
1764 buf.Copy(_L("Length of Key ")); |
1866 |
1765 buf.AppendNum(aPskKey->Des().Length()); |
1867 buf.Copy(_L("Length of Key ")); |
1766 TRACETEXT(buf) |
1868 buf.AppendNum(aPskKey->Des().Length()); |
1767 |
1869 TRACETEXT(buf) |
1768 TRACESTRING("Key...") |
1870 |
1769 PrintHex(aPskKey->Des(),__LINE__); |
1871 TRACESTRING("Key...") |
1770 |
1872 PrintHex(aPskKey->Des(),__LINE__); |
1771 aRepository->Set(KSuplPskTLSNewPassword,aPskKey->Des()); |
1873 |
1772 aRepository->Set(KSuplPskTLSKeyVersion,aSLPKeyVersion); |
1874 aRepository->Set(KSuplPskTLSNewPassword,aPskKey->Des()); |
1773 iTrace->Trace(_L("Copied PskKey"), KTraceFileName, __LINE__); |
1875 aRepository->Set(KSuplPskTLSKeyVersion,aSLPKeyVersion); |
1774 } |
1876 iTrace->Trace(_L("Copied PskKey"), KTraceFileName, __LINE__); |
1775 |
1877 } |
1776 else |
1878 |
1777 { |
1879 else |
1778 iTrace->Trace(_L("KSuplPskTLSRootPassword Not Found"), KTraceFileName, __LINE__); |
1880 { |
1779 User::LeaveIfError(rc); |
1881 iTrace->Trace(_L("KSuplPskTLSRootPassword Not Found"), KTraceFileName, __LINE__); |
1780 } |
1882 User::LeaveIfError(rc); |
1781 |
1883 } |
1782 iTrace->Trace(_L("End GeneratePskKeyL"), KTraceFileName, __LINE__); |
1884 |
1783 } |
1885 iTrace->Trace(_L("End GeneratePskKeyL"), KTraceFileName, __LINE__); |
|
1886 } |
1784 // ----------------------------------------------------------------------------- |
1887 // ----------------------------------------------------------------------------- |
1785 // CSuplConnection::LogPskKeyInfoL |
1888 // CSuplConnection::LogPskKeyInfoL |
1786 // |
1889 // |
1787 // (other items were commented in a header). |
1890 // (other items were commented in a header). |
1788 // ----------------------------------------------------------------------------- |
1891 // ----------------------------------------------------------------------------- |
1789 // |
1892 // |
1790 void CSuplConnection::LogPskKeyInfoL(const HBufC8* /*aPskIdentityHint*/,HBufC8* /*aPskIdentity*/,HBufC8* /*aPskKey*/) |
1893 void CSuplConnection::LogPskKeyInfoL(const HBufC8* /*aPskIdentityHint*/, |
1791 { |
1894 HBufC8* /*aPskIdentity*/, HBufC8* /*aPskKey*/) |
1792 #if 0 |
1895 { |
1793 TBuf<128> buf; |
1896 #if 0 |
1794 buf.Copy(_L("PSK Key :")); |
1897 TBuf<128> buf; |
|
1898 buf.Copy(_L("PSK Key :")); |
1795 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1899 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1796 HBufC* hintbuf = NULL; |
1900 HBufC* hintbuf = NULL; |
1797 TInt err; |
1901 TInt err; |
1798 TRAP(err, hintbuf = HBufC::NewL(aPskKey->Length())); |
1902 TRAP(err, hintbuf = HBufC::NewL(aPskKey->Length())); |
1799 err = 0; |
1903 err = 0; |
1800 hintbuf->Des().Copy(aPskKey->Des()); |
1904 hintbuf->Des().Copy(aPskKey->Des()); |
1801 iTrace->Trace( hintbuf->Des(),KTraceFileName, __LINE__); |
1905 iTrace->Trace( hintbuf->Des(),KTraceFileName, __LINE__); |
1802 delete hintbuf; |
1906 delete hintbuf; |
1803 hintbuf = NULL; |
1907 hintbuf = NULL; |
1804 |
1908 |
1805 buf.Copy(_L("PSK Identity :")); |
1909 buf.Copy(_L("PSK Identity :")); |
1806 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1910 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1807 TRAP(err, hintbuf = HBufC::NewL(aPskIdentity->Length())); |
1911 TRAP(err, hintbuf = HBufC::NewL(aPskIdentity->Length())); |
1808 err = 0; |
1912 err = 0; |
1809 hintbuf->Des().Copy(aPskIdentity->Des()); |
1913 hintbuf->Des().Copy(aPskIdentity->Des()); |
1810 iTrace->Trace( hintbuf->Des(),KTraceFileName, __LINE__); |
1914 iTrace->Trace( hintbuf->Des(),KTraceFileName, __LINE__); |
1811 delete hintbuf; |
1915 delete hintbuf; |
1812 hintbuf = NULL; |
1916 hintbuf = NULL; |
1813 |
1917 |
1814 if (aPskIdentityHint != NULL) |
1918 if (aPskIdentityHint != NULL) |
1815 { |
1919 { |
1816 buf.Copy(_L("Rcvd Identity Hint :")); |
1920 buf.Copy(_L("Rcvd Identity Hint :")); |
1817 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1921 iTrace->Trace(buf, KTraceFileName, __LINE__); |
1818 TRAP(err, hintbuf = HBufC::NewL(aPskIdentityHint->Length())); |
1922 TRAP(err, hintbuf = HBufC::NewL(aPskIdentityHint->Length())); |
1819 err = 0; |
1923 err = 0; |
1820 hintbuf->Des().Copy(*aPskIdentityHint); |
1924 hintbuf->Des().Copy(*aPskIdentityHint); |
1821 iTrace->Trace( hintbuf->Des(),KTraceFileName, __LINE__); |
1925 iTrace->Trace( hintbuf->Des(),KTraceFileName, __LINE__); |
1822 delete hintbuf; |
1926 delete hintbuf; |
1823 hintbuf = NULL; |
1927 hintbuf = NULL; |
1824 } |
1928 } |
1825 else |
1929 else |
1826 { |
1930 { |
1827 iTrace->Trace(_L("Rcvd Null Identity Hint"), KTraceFileName, __LINE__); |
1931 iTrace->Trace(_L("Rcvd Null Identity Hint"), KTraceFileName, __LINE__); |
1828 } |
1932 } |
1829 #endif |
1933 #endif |
1830 } |
1934 } |
1831 |
1935 |
1832 |
1936 void CSuplConnection::PrintHex(const TDesC8& |
1833 void CSuplConnection::PrintHex(const TDesC8& |
|
1834 #ifdef _DEBUG |
1937 #ifdef _DEBUG |
1835 aBuffer |
1938 aBuffer |
1836 #endif |
1939 #endif |
1837 , |
1940 , TInt |
1838 TInt |
|
1839 #ifdef _DEBUG |
1941 #ifdef _DEBUG |
1840 aLine |
1942 aLine |
1841 #endif |
1943 #endif |
1842 |
1944 |
1843 ) |
1945 ) |
1844 { |
1946 { |
1845 #ifdef _DEBUG |
1947 #ifdef _DEBUG |
1846 TBuf<128> buffer; |
1948 TBuf<128> buffer; |
1847 TBuf<8> buff; |
1949 TBuf<8> buff; |
1848 _LIT16(KFormat1,"%02x"); |
1950 _LIT16(KFormat1, "%02x"); |
1849 TInt len = aBuffer.Length(); |
1951 TInt len = aBuffer.Length(); |
1850 for(TInt i = 0 ; i <len; i++) |
1952 for (TInt i = 0; i < len; i++) |
1851 { |
1953 { |
1852 buff.Zero(); |
1954 buff.Zero(); |
1853 buff.Format(KFormat1,aBuffer[i]); |
1955 buff.Format(KFormat1, aBuffer[i]); |
1854 TRACETEXT(buff) |
1956 TRACETEXT (buff) |
1855 iTrace->Trace(buff, KTraceFileName, aLine); |
1957 iTrace->Trace(buff, KTraceFileName, aLine); |
1856 } |
1958 } |
1857 #endif |
1959 #endif |
1858 } |
1960 } |
1859 |
1961 |
1860 EXPORT_C TInt CSuplConnection::GetPortNumberUsed() |
1962 EXPORT_C TInt CSuplConnection::GetPortNumberUsed() |
1861 { |
1963 { |
1862 iTrace->Trace(_L("CSuplConnection::GetPortNumberUsed"), KTraceFileName, __LINE__); |
1964 iTrace->Trace(_L("CSuplConnection::GetPortNumberUsed"), KTraceFileName, |
|
1965 __LINE__); |
1863 if (iState == EConnected) |
1966 if (iState == EConnected) |
1864 { |
1967 { |
1865 TBuf<64> msg(_L("Port Number used is ")); |
1968 TBuf<64> msg(_L("Port Number used is ")); |
1866 msg.AppendNum(iSocket.LocalPort()); |
1969 msg.AppendNum(iSocket.LocalPort()); |
1867 iTrace->Trace(msg, KTraceFileName, __LINE__); |
1970 iTrace->Trace(msg, KTraceFileName, __LINE__); |
1868 return iSocket.LocalPort(); |
1971 return iSocket.LocalPort(); |
1869 } |
1972 } |
1870 else |
1973 else |
1871 return KErrGeneral; |
1974 return KErrGeneral; |
1872 } |
1975 } |
1873 |
1976 |
1874 // PSK TLS End |
1977 // PSK TLS End |
1875 // End of File |
1978 // End of File |