|
1 /* |
|
2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <c32comm.h> |
|
22 |
|
23 #if defined (__WINS__) |
|
24 #define PDD_NAME _L("ECDRV") |
|
25 #else |
|
26 #define PDD_NAME _L("EUART1") |
|
27 #define PDD2_NAME _L("EUART2") |
|
28 #define PDD3_NAME _L("EUART3") |
|
29 #define PDD4_NAME _L("EUART4") |
|
30 #endif |
|
31 |
|
32 #define LDD_NAME _L("ECOMM") |
|
33 |
|
34 /** |
|
35 * @file |
|
36 * |
|
37 * Pipe test server implementation |
|
38 */ |
|
39 #include "tsocketserver.h" |
|
40 #include "tsocket.h" |
|
41 |
|
42 |
|
43 _LIT(KServerName, "tsocket"); |
|
44 |
|
45 CSocketTestServer* CSocketTestServer::NewL() |
|
46 { |
|
47 CSocketTestServer *server = new(ELeave) CSocketTestServer(); |
|
48 CleanupStack::PushL(server); |
|
49 server->ConstructL(KServerName); |
|
50 CleanupStack::Pop(server); |
|
51 return server; |
|
52 } |
|
53 |
|
54 static void InitCommsL() |
|
55 { |
|
56 TInt ret = User::LoadPhysicalDevice(PDD_NAME); |
|
57 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
58 |
|
59 #ifndef __WINS__ |
|
60 ret = User::LoadPhysicalDevice(PDD2_NAME); |
|
61 ret = User::LoadPhysicalDevice(PDD3_NAME); |
|
62 ret = User::LoadPhysicalDevice(PDD4_NAME); |
|
63 #endif |
|
64 |
|
65 ret = User::LoadLogicalDevice(LDD_NAME); |
|
66 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
67 ret = StartC32(); |
|
68 User::LeaveIfError(ret == KErrAlreadyExists?KErrNone:ret); |
|
69 } |
|
70 |
|
71 LOCAL_C void MainL() |
|
72 { |
|
73 // Leave the hooks in for platform security |
|
74 #if (defined __DATA_CAGING__) |
|
75 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
76 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
77 #endif |
|
78 InitCommsL(); |
|
79 |
|
80 CActiveScheduler* sched=NULL; |
|
81 sched=new(ELeave) CActiveScheduler; |
|
82 CActiveScheduler::Install(sched); |
|
83 CSocketTestServer* server = NULL; |
|
84 // Create the CTestServer derived server |
|
85 TRAPD(err, server = CSocketTestServer::NewL()); |
|
86 if(!err) |
|
87 { |
|
88 // Sync with the client and enter the active scheduler |
|
89 RProcess::Rendezvous(KErrNone); |
|
90 sched->Start(); |
|
91 } |
|
92 delete server; |
|
93 delete sched; |
|
94 } |
|
95 |
|
96 /** |
|
97 * Server entry point |
|
98 * @return Standard Epoc error code on exit |
|
99 */ |
|
100 TInt main() |
|
101 { |
|
102 __UHEAP_MARK; |
|
103 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
104 if(cleanup == NULL) |
|
105 { |
|
106 return KErrNoMemory; |
|
107 } |
|
108 TRAP_IGNORE(MainL()); |
|
109 delete cleanup; |
|
110 __UHEAP_MARKEND; |
|
111 |
|
112 return KErrNone; |
|
113 } |
|
114 |
|
115 CTestStep* CSocketTestServer::CreateTestStep(const TDesC& aStepName) |
|
116 { |
|
117 CTestStep* testStep = NULL; |
|
118 |
|
119 // This server creates just one step but create as many as you want |
|
120 // They are created "just in time" when the worker thread is created |
|
121 // install steps |
|
122 if(aStepName == KExampleL) |
|
123 { |
|
124 testStep = new CTestSocket(aStepName); |
|
125 } |
|
126 if(aStepName == KUDP) |
|
127 { |
|
128 testStep = new CTestSocket(aStepName); |
|
129 } |
|
130 if(aStepName == KTCP) |
|
131 { |
|
132 testStep = new CTestSocket(aStepName); |
|
133 } |
|
134 if(aStepName == KGetSocketName) |
|
135 { |
|
136 testStep = new CTestSocket(aStepName); |
|
137 } |
|
138 if(aStepName == KGetSocketNameUsingFileDescriptor) |
|
139 { |
|
140 testStep = new CTestSocket(aStepName); |
|
141 } |
|
142 if(aStepName == KGetSocketNameUsingInvalidSocketDescriptor) |
|
143 { |
|
144 testStep = new CTestSocket(aStepName); |
|
145 } |
|
146 if(aStepName == KGetSocketNameInvalidLength) |
|
147 { |
|
148 testStep = new CTestSocket(aStepName); |
|
149 } |
|
150 if(aStepName == KGetSocketNameInvalidSocketBuffer) |
|
151 { |
|
152 testStep = new CTestSocket(aStepName); |
|
153 } |
|
154 if(aStepName == KGetPeerSocketName) |
|
155 { |
|
156 testStep = new CTestSocket(aStepName); |
|
157 } |
|
158 if(aStepName == KGetPeerSocketNameUsingFileDescriptor) |
|
159 { |
|
160 testStep = new CTestSocket(aStepName); |
|
161 } |
|
162 if(aStepName == KGetPeerSocketNameUsingInvalidSocketDescriptor) |
|
163 { |
|
164 testStep = new CTestSocket(aStepName); |
|
165 } |
|
166 if(aStepName == KGetPeerSocketNameforUnconnectedSocket) |
|
167 { |
|
168 testStep = new CTestSocket(aStepName); |
|
169 } |
|
170 if(aStepName == KGetPeerSocketNameInvalidLengthSockAddr) |
|
171 { |
|
172 testStep = new CTestSocket(aStepName); |
|
173 } |
|
174 if(aStepName == KBindTest) |
|
175 { |
|
176 testStep = new CTestSocket(aStepName); |
|
177 } |
|
178 if(aStepName == KMultipleBindOnSameSocket) |
|
179 { |
|
180 testStep = new CTestSocket(aStepName); |
|
181 } |
|
182 if(aStepName == KBindInvalidAddress) |
|
183 { |
|
184 testStep = new CTestSocket(aStepName); |
|
185 } |
|
186 if(aStepName == KBindUsingInvalidSocketDescriptor) |
|
187 { |
|
188 testStep = new CTestSocket(aStepName); |
|
189 } |
|
190 if(aStepName == KBindUsingFileDescriptor) |
|
191 { |
|
192 testStep = new CTestSocket(aStepName); |
|
193 } |
|
194 if(aStepName == KShutdownTest) |
|
195 { |
|
196 testStep = new CTestSocket(aStepName); |
|
197 } |
|
198 if(aStepName == KShutDownTestWithInvalidShutdownOption) |
|
199 { |
|
200 testStep = new CTestSocket(aStepName); |
|
201 } |
|
202 if(aStepName == KShutdownUsingFileDescriptor) |
|
203 { |
|
204 testStep = new CTestSocket(aStepName); |
|
205 } |
|
206 if(aStepName == KShutdownUsingInvalidSocketDescriptor) |
|
207 { |
|
208 testStep = new CTestSocket(aStepName); |
|
209 } |
|
210 if(aStepName == KShutdownDisconnectedSocket) |
|
211 { |
|
212 testStep = new CTestSocket(aStepName); |
|
213 } |
|
214 if(aStepName == KSocketTest) |
|
215 { |
|
216 testStep = new CTestSocket(aStepName); |
|
217 } |
|
218 if(aStepName == KListenTest) |
|
219 { |
|
220 testStep = new CTestSocket(aStepName); |
|
221 } |
|
222 if(aStepName == KListenUsingFileDescriptor) |
|
223 { |
|
224 testStep = new CTestSocket(aStepName); |
|
225 } |
|
226 if(aStepName == KListenUsingInvalidSocketDescriptor) |
|
227 { |
|
228 testStep = new CTestSocket(aStepName); |
|
229 } |
|
230 if(aStepName == KAcceptTest) |
|
231 { |
|
232 testStep = new CTestSocket(aStepName); |
|
233 } |
|
234 if(aStepName == KUDPAccept) |
|
235 { |
|
236 testStep = new CTestSocket(aStepName); |
|
237 } |
|
238 if(aStepName == KAcceptUsingFileDescriptor) |
|
239 { |
|
240 testStep = new CTestSocket(aStepName); |
|
241 } |
|
242 if(aStepName == KAcceptUsingInvalidSocketDescriptor) |
|
243 { |
|
244 testStep = new CTestSocket(aStepName); |
|
245 } |
|
246 if(aStepName == KConnectTestFailCases) |
|
247 { |
|
248 testStep = new CTestSocket(aStepName); |
|
249 } |
|
250 if(aStepName == KConnectUsingFileDescriptor) |
|
251 { |
|
252 testStep = new CTestSocket(aStepName); |
|
253 } |
|
254 if(aStepName == KConnectUsingInvalidSocketDescriptor) |
|
255 { |
|
256 testStep = new CTestSocket(aStepName); |
|
257 } |
|
258 if(aStepName == KRecvTestFailCases) |
|
259 { |
|
260 testStep = new CTestSocket(aStepName); |
|
261 } |
|
262 if(aStepName == KRecvUsingInvalidSocketDescriptor) |
|
263 { |
|
264 testStep = new CTestSocket(aStepName); |
|
265 } |
|
266 if(aStepName == KRecvUsingFileDescriptor) |
|
267 { |
|
268 testStep = new CTestSocket(aStepName); |
|
269 } |
|
270 if(aStepName == KSendTestFailCases) |
|
271 { |
|
272 testStep = new CTestSocket(aStepName); |
|
273 } |
|
274 if(aStepName == KSendUsingFileDescriptor) |
|
275 { |
|
276 testStep = new CTestSocket(aStepName); |
|
277 } |
|
278 if(aStepName == KSendUsingInvalidSocketDescriptor) |
|
279 { |
|
280 testStep = new CTestSocket(aStepName); |
|
281 } |
|
282 if(aStepName == KSocketOptions) |
|
283 { |
|
284 testStep = new CTestSocket(aStepName); |
|
285 } |
|
286 if(aStepName == KGetSockOptFailCases) |
|
287 { |
|
288 testStep = new CTestSocket(aStepName); |
|
289 } |
|
290 if(aStepName == KSetSockOptFailCases) |
|
291 { |
|
292 testStep = new CTestSocket(aStepName); |
|
293 } |
|
294 if(aStepName == KSendToTestFailCases) |
|
295 { |
|
296 testStep = new CTestSocket(aStepName); |
|
297 } |
|
298 if(aStepName == KSendToUsingFileDescriptor) |
|
299 { |
|
300 testStep = new CTestSocket(aStepName); |
|
301 } |
|
302 if(aStepName == KSendToUsingInvalidSocketDescriptor) |
|
303 { |
|
304 testStep = new CTestSocket(aStepName); |
|
305 } |
|
306 if(aStepName == KTestSendReturnValue) |
|
307 { |
|
308 testStep = new CTestSocket(aStepName); |
|
309 } |
|
310 if(aStepName == KRecvFromTestFailCases) |
|
311 { |
|
312 testStep = new CTestSocket(aStepName); |
|
313 } |
|
314 if(aStepName == KSockAtMark) |
|
315 { |
|
316 testStep = new CTestSocket(aStepName); |
|
317 } |
|
318 if(aStepName == KBindResvPort) |
|
319 { |
|
320 testStep = new CTestSocket(aStepName); |
|
321 } |
|
322 if(aStepName == KBindResvPortFailCases) |
|
323 { |
|
324 testStep = new CTestSocket(aStepName); |
|
325 } |
|
326 if(aStepName == KHErrNoLocation) |
|
327 { |
|
328 testStep = new CTestSocket(aStepName); |
|
329 } |
|
330 if(aStepName == KSendMsgRecvMsg) |
|
331 { |
|
332 testStep = new CTestSocket(aStepName); |
|
333 } |
|
334 if(aStepName == KTestRecv) |
|
335 { |
|
336 testStep = new CTestSocket(aStepName); |
|
337 } |
|
338 if(aStepName == KTestReadStream) |
|
339 { |
|
340 testStep = new CTestSocket(aStepName); |
|
341 } |
|
342 if(aStepName == KTestReadDatagram) |
|
343 { |
|
344 testStep = new CTestSocket(aStepName); |
|
345 } |
|
346 if(aStepName == KBindFailCases) |
|
347 { |
|
348 testStep = new CTestSocket(aStepName); |
|
349 } |
|
350 if(aStepName == KAcceptFailCases) |
|
351 { |
|
352 testStep = new CTestSocket(aStepName); |
|
353 } |
|
354 if(aStepName == KAcceptTestZeroAddrLen) |
|
355 { |
|
356 testStep = new CTestSocket(aStepName); |
|
357 } |
|
358 if(aStepName == KAcceptTestNullAddr) |
|
359 { |
|
360 testStep = new CTestSocket(aStepName); |
|
361 } |
|
362 if(aStepName == KListenUdp) |
|
363 { |
|
364 testStep = new CTestSocket(aStepName); |
|
365 } |
|
366 if(aStepName == KGetHostName) |
|
367 { |
|
368 testStep = new CTestSocket(aStepName); |
|
369 } |
|
370 if(aStepName == KGetHostNameNull) |
|
371 { |
|
372 testStep = new CTestSocket(aStepName); |
|
373 } |
|
374 if(aStepName == KGetHostNameZero) |
|
375 { |
|
376 testStep = new CTestSocket(aStepName); |
|
377 } |
|
378 if(aStepName == KTestSktlseek) |
|
379 { |
|
380 testStep = new CTestSocket(aStepName); |
|
381 } |
|
382 if(aStepName == KTestSockAfLocal) |
|
383 { |
|
384 testStep = new CTestSocket(aStepName); |
|
385 } |
|
386 if(aStepName == KTestSktfstat) |
|
387 { |
|
388 testStep = new CTestSocket(aStepName); |
|
389 } |
|
390 if(aStepName == KTestSktfsync) |
|
391 { |
|
392 testStep = new CTestSocket(aStepName); |
|
393 } |
|
394 if(aStepName == KTestGreaterThan16kReadWrite) |
|
395 { |
|
396 testStep = new CTestSocket(aStepName); |
|
397 } |
|
398 if(aStepName == KTestNotify) |
|
399 { |
|
400 testStep = new CTestSocket(aStepName); |
|
401 } |
|
402 if(aStepName == KTestRecvMsgPeekTCP) |
|
403 { |
|
404 testStep = new CTestSocket(aStepName); |
|
405 } |
|
406 if(aStepName == KTestRecvMsgPeekUDP) |
|
407 { |
|
408 testStep = new CTestSocket(aStepName); |
|
409 } |
|
410 if(aStepName == KTestLargeUDP) |
|
411 { |
|
412 testStep = new CTestSocket(aStepName); |
|
413 } |
|
414 if(aStepName == KTestFionread) |
|
415 { |
|
416 testStep = new CTestSocket(aStepName); |
|
417 } |
|
418 if(aStepName == KTestBind1) |
|
419 { |
|
420 testStep = new CTestSocket(aStepName); |
|
421 } |
|
422 if(aStepName == KTestConnectNonBlocking) |
|
423 { |
|
424 testStep = new CTestSocket(aStepName); |
|
425 } |
|
426 if(aStepName == KTCP1) |
|
427 { |
|
428 testStep = new CTestSocket(aStepName); |
|
429 } |
|
430 if(aStepName == KTestV4MappedAddress) |
|
431 { |
|
432 testStep = new CTestSocket(aStepName); |
|
433 } |
|
434 if(aStepName == KReadTestFailCase) |
|
435 { |
|
436 testStep = new CTestSocket(aStepName); |
|
437 } |
|
438 if(aStepName == KTestNotify1) |
|
439 { |
|
440 testStep = new CTestSocket(aStepName); |
|
441 } |
|
442 if(aStepName == KTestSockFcntl) |
|
443 { |
|
444 testStep = new CTestSocket(aStepName); |
|
445 } |
|
446 if(aStepName == KTestSockIoctl) |
|
447 { |
|
448 testStep = new CTestSocket(aStepName); |
|
449 } |
|
450 if(aStepName == KSockErrnoTest) |
|
451 { |
|
452 testStep = new CTestSocket(aStepName); |
|
453 } |
|
454 if(aStepName == KSockSendOnClosedConn ) |
|
455 { |
|
456 testStep = new CTestSocket(aStepName); |
|
457 } |
|
458 |
|
459 return testStep; |
|
460 } |