|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Bluetooth SDP verification tests |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32test.h> |
|
19 #include <bluetooth/logger.h> |
|
20 #include "TSDPSAS.h" |
|
21 #include "MAttributeVisitor.h" |
|
22 |
|
23 #ifdef __FLOG_ACTIVE |
|
24 _LIT8(KLogComponent, LOG_COMPONENT_TSDPSAS); |
|
25 #endif |
|
26 |
|
27 #ifdef _DEBUG |
|
28 PANICCATEGORY("tsdpsas"); |
|
29 #endif |
|
30 |
|
31 #undef STOPPING_MODE |
|
32 #ifndef STOPPING_MODE |
|
33 //#define STOPPING_MODE |
|
34 #endif |
|
35 |
|
36 #undef SEVEN_LAYERS_BUG |
|
37 #ifndef SEVEN_LAYERS_BUG |
|
38 //#define SEVEN_LAYERS_BUG |
|
39 #endif |
|
40 |
|
41 #define ONLY_CONTINUATION_AND_BROWSE |
|
42 |
|
43 //If you want to see what actual attributes are coming back from an SAS query. |
|
44 //#define PRINT_BUILDER |
|
45 // constants |
|
46 const TUint KUselessRecordHandle=0xffffffff; |
|
47 const TUint KNonExistantUUID=0xffff; |
|
48 const TUint KAttributeTestsServiceUUID=0x0011; |
|
49 //const TInt KNumSdpVerificationTests=55; |
|
50 const TInt KServiceRequestTest = 0; // Number of the first test |
|
51 const TInt KServiceAttributeRequestTest = 6; // Number of the first test |
|
52 const TInt KServiceSearchAttributeRequestTest = 29; // Number of the first test |
|
53 const TInt KSdpBrowseTest = 53; |
|
54 const TInt KSdpLastTest = KSdpBrowseTest + 1; |
|
55 const TInt KServiceRequestBITest = KServiceAttributeRequestTest - 2; |
|
56 const TInt KServiceAttributeRequestBITest = KServiceSearchAttributeRequestTest - 3; |
|
57 const TInt KServiceSearchAttributeRequestBITest = KSdpBrowseTest - 2; |
|
58 const TInt KMinResponseSize = 8; // This is the 5 byte header + 2 byte size (zero) + cont bytes(zero) |
|
59 const TInt KAttributeParamsSize = 11; |
|
60 const TInt KServiceParamsSize16 = 7; |
|
61 const TInt KServiceParamsSize32 = 9; |
|
62 const TInt KServiceParamsSize128 = 21; |
|
63 //const TInt KMaxCountSize = 2; |
|
64 //const TInt KUuidListHeaderSize = 2; |
|
65 const TInt KUuid16ParamSize = 3; |
|
66 const TInt KUuid32ParamSize = 5; |
|
67 const TInt KUuid128ParamSize = 17; |
|
68 const TInt KServiceAttributeParamsSize16 = 12; |
|
69 const TInt KServiceAttributeParamsSize32 = 14; |
|
70 const TInt KServiceAttributeParamsSize128 = 26; |
|
71 //const TInt KSdpSyncPointBase = 0x1000; |
|
72 |
|
73 const TInt KSdpAttributeBigRange = 0x00000202; |
|
74 // UUIDS (add to these as necessary) - see builddb.cpp |
|
75 // UUIDS (add to these as necessary) |
|
76 //const TUint32 KSdpContTestUUID = 0x100; |
|
77 |
|
78 |
|
79 // Offsets and constants |
|
80 const TInt KRecordHandleOffset = 9; |
|
81 const TInt KTotalCountOffset = 5; |
|
82 const TInt KCurrentCountOffset = 7; |
|
83 const TInt KErrorCodeOffset = 5; |
|
84 const TInt KAttributeByteCountOffset = 5; |
|
85 const TInt KAttributeListOffset = 7; |
|
86 |
|
87 |
|
88 GLREF_D TBTDevAddr devAddr; |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 // |
|
102 // CSdpTestBase |
|
103 // |
|
104 CSdpTestBase::CSdpTestBase(CConsoleBase& aConsole) |
|
105 :iConsole(aConsole),iRawTransactionId(0x0000) |
|
106 { |
|
107 } |
|
108 |
|
109 CSdpTestBase::~CSdpTestBase() |
|
110 { |
|
111 iRawSock.Close(); |
|
112 } |
|
113 |
|
114 void CSdpTestBase::StartSDPServerL() |
|
115 /** |
|
116 Builds up a static DB, and copies it into the RSdpDatabase |
|
117 **/ |
|
118 { |
|
119 |
|
120 } |
|
121 |
|
122 void CSdpTestBase::RegisterDatabaseInServerL (CSdpDatabase&) |
|
123 { |
|
124 } |
|
125 |
|
126 |
|
127 void CSdpTestBase::SendCloseL() |
|
128 /** |
|
129 Send info to remote device to indicate the tests have finished |
|
130 **/ |
|
131 { |
|
132 } |
|
133 |
|
134 void CSdpTestBase::WaitForCloseL() |
|
135 /** |
|
136 Wait for input from the other side to show the tests have finished |
|
137 (We only need to read one byte). |
|
138 **/ |
|
139 { |
|
140 } |
|
141 |
|
142 void CSdpTestBase::SdpConnectL() |
|
143 /** |
|
144 Connect to remote SDP server |
|
145 **/ |
|
146 { |
|
147 TRequestStatus stat; |
|
148 TL2CAPSockAddr addr; |
|
149 addr.SetBTAddr(devAddr); |
|
150 addr.SetPort(1); |
|
151 iRawSock.Connect(addr, stat); |
|
152 User::WaitForRequest(stat); |
|
153 if(stat.Int()) |
|
154 { |
|
155 iConsole.Printf(_L("Connection failed with error %d. Press any key.\r\n"), stat.Int()); |
|
156 iConsole.Getch(); |
|
157 } |
|
158 |
|
159 User::LeaveIfError(stat.Int()); |
|
160 } |
|
161 |
|
162 |
|
163 // |
|
164 // TSDPHeader class |
|
165 // |
|
166 TSDPHeader::TSDPHeader() |
|
167 :iPduId(0), iTransactionId(0), iParamLen(0) |
|
168 { |
|
169 } |
|
170 |
|
171 TSDPHeader::TSDPHeader(TUint8 aPduId, TUint16 aTranId, TUint16 aLen) |
|
172 :iPduId(aPduId), iTransactionId(aTranId), iParamLen(aLen) |
|
173 { |
|
174 } |
|
175 |
|
176 void TSDPHeader::AppendHeader(TDes8& aBuf) |
|
177 { |
|
178 // Need to make sure endina-ness is OK (is this right) |
|
179 // |
|
180 TUint16 bigTranId = BigEndian::Get16((TUint8*)&iTransactionId); |
|
181 TUint16 bigLen = BigEndian::Get16((TUint8*)&iParamLen); |
|
182 aBuf.Append(&iPduId, 1); |
|
183 aBuf.Append((TUint8*)&bigTranId, 2); |
|
184 aBuf.Append((TUint8*)&bigLen, 2); |
|
185 } |
|
186 |
|
187 |
|
188 // |
|
189 // TServiceRequest class |
|
190 // |
|
191 |
|
192 TServiceRequest::TServiceRequest() |
|
193 :iUuid(0), iSP(0), iMaxRecordCount(0), iUuidType(CSdpTestBase::EUuid16), iAutoDes(ETrue) |
|
194 { |
|
195 SetupDES(); |
|
196 } |
|
197 |
|
198 TServiceRequest::TServiceRequest(TUint8* aDes, |
|
199 TUUID aUuid, |
|
200 CSdpTestBase::TUuidType aUuidType, |
|
201 TUint16 aMaxRecordCount) |
|
202 :iUuid(0), iSP(0), iMaxRecordCount(0), iUuidType(CSdpTestBase::EUuid16), iAutoDes(EFalse) |
|
203 { |
|
204 Mem::Copy(iDes, aDes, 3); |
|
205 iUuid = aUuid; |
|
206 iUuidType = aUuidType; |
|
207 iMaxRecordCount = aMaxRecordCount; |
|
208 } |
|
209 |
|
210 TServiceRequest::TServiceRequest(TUint8* aDes, |
|
211 CSdpSearchPattern& aSP, |
|
212 CSdpTestBase::TUuidType aUuidType, |
|
213 TUint16 aMaxRecordCount) |
|
214 :iUuid(0), iSP(0), iMaxRecordCount(0), iUuidType(CSdpTestBase::EUuid16), iAutoDes(EFalse) |
|
215 { |
|
216 Mem::Copy(iDes, aDes, 3); |
|
217 iSP = &aSP; |
|
218 iUuidType = aUuidType; |
|
219 iMaxRecordCount = aMaxRecordCount; |
|
220 } |
|
221 |
|
222 TServiceRequest::TServiceRequest(TUUID aUuid, |
|
223 CSdpTestBase::TUuidType aUuidType, |
|
224 TUint16 aMaxRecordCount) |
|
225 :iUuid(aUuid), iSP(0), iMaxRecordCount(aMaxRecordCount), iUuidType(aUuidType), iAutoDes(ETrue) |
|
226 { |
|
227 SetupDES(); |
|
228 } |
|
229 |
|
230 TServiceRequest::TServiceRequest(CSdpSearchPattern& aSP, |
|
231 CSdpTestBase::TUuidType aUuidType, |
|
232 TUint16 aMaxRecordCount) |
|
233 :iUuid(0), iSP(0), iMaxRecordCount(aMaxRecordCount), iUuidType(aUuidType), iAutoDes(ETrue) |
|
234 { |
|
235 iSP = &aSP; |
|
236 SetupDES(); |
|
237 } |
|
238 |
|
239 void TServiceRequest::SetupDES() |
|
240 { |
|
241 if(iSP) |
|
242 //just set up first two bytes |
|
243 { |
|
244 iDes[0] = 0x35; |
|
245 switch(iUuidType) |
|
246 { |
|
247 case CSdpTestBase::EUuid128: |
|
248 iDes[1] = (TUint8)(KUuid128ParamSize*iSP->Count()); //take the length |
|
249 break; |
|
250 case CSdpTestBase::EUuid32: |
|
251 iDes[1] = (TUint8)(KUuid32ParamSize*iSP->Count()); //take the length |
|
252 break; |
|
253 default: |
|
254 iDes[1] = (TUint8)(KUuid16ParamSize*iSP->Count()); //take the length |
|
255 } |
|
256 } |
|
257 else |
|
258 { |
|
259 TUint8 validDes16[] = {0x35, 0x03, 0x19}; |
|
260 TUint8 validDes32[] = {0x35, 0x05, 0x1a}; |
|
261 TUint8 validDes128[] = {0x35, 0x11, 0x1c}; |
|
262 switch(iUuidType) |
|
263 { |
|
264 case CSdpTestBase::EUuid16: |
|
265 Mem::Copy(iDes, validDes16, 3); |
|
266 break; |
|
267 case CSdpTestBase::EUuid32: |
|
268 Mem::Copy(iDes, validDes32, 3); |
|
269 break; |
|
270 default: |
|
271 Mem::Copy(iDes, validDes128, 3); |
|
272 } |
|
273 } |
|
274 |
|
275 } |
|
276 |
|
277 void TServiceRequest::SetUuidType(CSdpTestBase::TUuidType aUuidType) |
|
278 { |
|
279 iUuidType = aUuidType; |
|
280 if(iAutoDes) |
|
281 { |
|
282 SetupDES(); |
|
283 } |
|
284 } |
|
285 |
|
286 void TServiceRequest::AppendRequest(TDes8& aBuf) |
|
287 { |
|
288 if(iSP) |
|
289 { |
|
290 aBuf.Append(iDes, 2); //just take the list header bytes ..then... |
|
291 for(TInt i = 0; i<iSP->Count(); i++) |
|
292 { |
|
293 TUUID uuid = iSP->At(i); |
|
294 TPtrC8 ptr16 = uuid.ShortestForm(); |
|
295 TPtrC8 ptr32 = uuid.LongForm().Mid(0,4); |
|
296 TPtrC8 ptr128 = uuid.LongForm(); |
|
297 switch(iUuidType) |
|
298 { |
|
299 case CSdpTestBase::EUuid128: |
|
300 aBuf.Append(0x1c); |
|
301 aBuf.Append(ptr128); |
|
302 break; |
|
303 case CSdpTestBase::EUuid32: |
|
304 aBuf.Append(0x1a); |
|
305 aBuf.Append(ptr32); |
|
306 break; |
|
307 default: |
|
308 aBuf.Append(0x19); |
|
309 aBuf.Append(ptr16); |
|
310 } |
|
311 } |
|
312 TUint16 bigCount = BigEndian::Get16((TUint8*)&iMaxRecordCount); |
|
313 aBuf.Append((TUint8*)&bigCount, 2); |
|
314 } |
|
315 else |
|
316 { |
|
317 TPtrC8 ptr16 = iUuid.ShortestForm(); |
|
318 TPtrC8 ptr32 = iUuid.LongForm().Mid(0,4); |
|
319 TPtrC8 ptr128 = iUuid.LongForm(); |
|
320 TUint16 bigCount = BigEndian::Get16((TUint8*)&iMaxRecordCount); |
|
321 aBuf.Append(iDes, 3); //....CHANGED |
|
322 switch(iUuidType) |
|
323 { |
|
324 case CSdpTestBase::EUuid128: |
|
325 aBuf.Append(ptr128); |
|
326 break; |
|
327 case CSdpTestBase::EUuid32: |
|
328 aBuf.Append(ptr32); |
|
329 break; |
|
330 default: |
|
331 aBuf.Append(ptr16); |
|
332 } |
|
333 |
|
334 aBuf.Append((TUint8*)&bigCount, 2); |
|
335 } |
|
336 } |
|
337 |
|
338 // |
|
339 // TAttributeRequest class |
|
340 // |
|
341 TAttributeRequest::TAttributeRequest() |
|
342 :iRecordHandle(0), iMaxByteCount(0), iAttributeId(0), iAttributeIdRange(0), iAutoDes(ETrue) |
|
343 { |
|
344 Mem::FillZ(iDes, 0); |
|
345 } |
|
346 TAttributeRequest::TAttributeRequest(TUint32 aRecordHandle, TUint16 aMaxByteCount, TUint8* aDes, TUint16 aAttributeId) |
|
347 :iRecordHandle(aRecordHandle), iMaxByteCount(aMaxByteCount), iAttributeId(aAttributeId), iAttributeIdRange(0), iAutoDes(EFalse) |
|
348 { |
|
349 Mem::Copy(iDes, aDes, 3); |
|
350 } |
|
351 |
|
352 TAttributeRequest::TAttributeRequest(TUint32 aRecordHandle, TUint16 aMaxByteCount, TUint8* aDes, TUint32 aAttributeIdRange) |
|
353 :iRecordHandle(aRecordHandle), iMaxByteCount(aMaxByteCount), iAttributeId(0), iAttributeIdRange(aAttributeIdRange), iAutoDes(EFalse) |
|
354 { |
|
355 Mem::Copy(iDes, aDes, 3); |
|
356 } |
|
357 |
|
358 TAttributeRequest::TAttributeRequest(TUint32 aRecordHandle, TUint16 aMaxByteCount, TUint16 aAttributeId) |
|
359 :iRecordHandle(aRecordHandle), iMaxByteCount(aMaxByteCount), iAttributeId(aAttributeId), iAttributeIdRange(0), iAutoDes(ETrue) |
|
360 { |
|
361 SetupDES(); |
|
362 } |
|
363 |
|
364 TAttributeRequest::TAttributeRequest(TUint32 aRecordHandle, TUint16 aMaxByteCount, TUint32 aAttributeIdRange) |
|
365 :iRecordHandle(aRecordHandle), iMaxByteCount(aMaxByteCount), iAttributeId(0), iAttributeIdRange(aAttributeIdRange), iAutoDes(ETrue) |
|
366 { |
|
367 SetupDES(); |
|
368 } |
|
369 |
|
370 void TAttributeRequest::SetupDES() |
|
371 { |
|
372 TUint8 validDesId[] = {0x35, 0x03, 0x09}; |
|
373 TUint8 validDesIdRange[] = {0x35, 0x05, 0x0a}; |
|
374 if(iAttributeIdRange) |
|
375 { |
|
376 Mem::Copy(iDes, validDesIdRange, 3); |
|
377 } |
|
378 else |
|
379 { |
|
380 Mem::Copy(iDes, validDesId, 3); |
|
381 } |
|
382 } |
|
383 |
|
384 void TAttributeRequest ::AppendRequest(TDes8& aBuf) |
|
385 { |
|
386 TUint32 bigHandle = BigEndian::Get32((TUint8*)&iRecordHandle); |
|
387 TUint16 bigCount = BigEndian::Get16((TUint8*)&iMaxByteCount); |
|
388 TUint16 bigId = BigEndian::Get16((TUint8*)&iAttributeId);; |
|
389 TUint32 bigId32 = BigEndian::Get32((TUint8*)&iAttributeIdRange);; |
|
390 |
|
391 |
|
392 aBuf.Append((TUint8*)&bigHandle, 4); |
|
393 aBuf.Append((TUint8*)&bigCount, 2); |
|
394 aBuf.Append(iDes, 3); |
|
395 if(iAttributeIdRange) |
|
396 aBuf.Append((TUint8*)&bigId32, 4); |
|
397 else |
|
398 aBuf.Append((TUint8*)&bigId, 2); |
|
399 } |
|
400 |
|
401 // |
|
402 // TServiceAttributeRequest class |
|
403 // |
|
404 TServiceAttributeRequest::TServiceAttributeRequest() |
|
405 { |
|
406 } |
|
407 |
|
408 |
|
409 TServiceAttributeRequest::TServiceAttributeRequest(TUint8* aServiceDes, TUUID aServiceUuid, CSdpTestBase::TUuidType aUuidType, TUint16 aMaxByteCount, TUint8* aAttribDes, TUint16 aAttributeId) |
|
410 { |
|
411 iServiceRequest=TServiceRequest(aServiceDes, aServiceUuid, aUuidType, 0); |
|
412 iAttributeRequest=TAttributeRequest(0, aMaxByteCount, aAttribDes, aAttributeId); |
|
413 } |
|
414 |
|
415 TServiceAttributeRequest::TServiceAttributeRequest(TUUID aServiceUuid, CSdpTestBase::TUuidType aUuidType, TUint16 aMaxByteCount, TUint16 aAttributeId) |
|
416 { |
|
417 iServiceRequest=TServiceRequest(aServiceUuid, aUuidType, 0); |
|
418 iAttributeRequest=TAttributeRequest(0, aMaxByteCount, aAttributeId); |
|
419 } |
|
420 |
|
421 TServiceAttributeRequest::TServiceAttributeRequest(TUint8* aServiceDes, TUUID aServiceUuid, CSdpTestBase::TUuidType aUuidType, TUint16 aMaxByteCount, TUint8* aAttribDes, TUint32 aAttributeIdRange) |
|
422 { |
|
423 iServiceRequest=TServiceRequest(aServiceDes, aServiceUuid, aUuidType, 0); |
|
424 iAttributeRequest=TAttributeRequest(0, aMaxByteCount, aAttribDes, aAttributeIdRange); |
|
425 } |
|
426 |
|
427 TServiceAttributeRequest::TServiceAttributeRequest(TUUID aServiceUuid, CSdpTestBase::TUuidType aUuidType, TUint16 aMaxByteCount, TUint32 aAttributeIdRange) |
|
428 { |
|
429 iServiceRequest=TServiceRequest(aServiceUuid, aUuidType, 0); |
|
430 iAttributeRequest=TAttributeRequest(0, aMaxByteCount, aAttributeIdRange); |
|
431 } |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 void TServiceAttributeRequest::SetUuidType(CSdpTestBase::TUuidType aUuidType) |
|
437 { |
|
438 iServiceRequest.SetUuidType(aUuidType); |
|
439 } |
|
440 |
|
441 void TServiceAttributeRequest::AppendRequest(TDes8& aBuf) |
|
442 { |
|
443 TUint16 byteCount = iAttributeRequest.MaxByteCount(); |
|
444 TUint16 bigCount = BigEndian::Get16((TUint8*)&byteCount); |
|
445 TUint attribId = 0; |
|
446 TUint16 bigAttributeId = 0; |
|
447 TUint32 bigAttributeIdRange = 0; |
|
448 |
|
449 if((attribId = iAttributeRequest.AttributeIdRange())!=0) |
|
450 { |
|
451 bigAttributeIdRange = BigEndian::Get32((TUint8*)&attribId); |
|
452 } |
|
453 else |
|
454 { |
|
455 attribId = iAttributeRequest.AttributeId(); |
|
456 bigAttributeId = BigEndian::Get16((TUint8*)&attribId); |
|
457 } |
|
458 |
|
459 if(iServiceRequest.SP()) |
|
460 //WARNING-> THIS 'IF' HAS NOT BEEN TESTED! |
|
461 { |
|
462 aBuf.Append(iServiceRequest.Des(), 2); //just take the list header bytes..then... |
|
463 for(TInt i = 0; i<iServiceRequest.SP()->Count(); i++) |
|
464 { |
|
465 TUUID uuid = iServiceRequest.SP()->At(i); |
|
466 TPtrC8 ptr16 = uuid.ShortestForm(); |
|
467 TPtrC8 ptr32 = uuid.LongForm().Mid(0,4); |
|
468 TPtrC8 ptr128 = uuid.LongForm(); |
|
469 switch(iServiceRequest.UuidType()) |
|
470 { |
|
471 case CSdpTestBase::EUuid128: |
|
472 aBuf.Append(0x1c); |
|
473 aBuf.Append(ptr128); |
|
474 break; |
|
475 case CSdpTestBase::EUuid32: |
|
476 aBuf.Append(0x1a); |
|
477 aBuf.Append(ptr32); |
|
478 break; |
|
479 default: |
|
480 aBuf.Append(0x19); |
|
481 aBuf.Append(ptr16); |
|
482 } |
|
483 } |
|
484 } |
|
485 else |
|
486 { |
|
487 TUUID uuid = iServiceRequest.Uuid(); |
|
488 TPtrC8 ptr16 = uuid.ShortestForm(); |
|
489 TPtrC8 ptr32 = uuid.LongForm().Mid(0,4); |
|
490 TPtrC8 ptr128 = uuid.LongForm(); |
|
491 aBuf.Append(iServiceRequest.Des(), 3); |
|
492 switch(iServiceRequest.UuidType()) |
|
493 { |
|
494 case CSdpTestBase::EUuid128: |
|
495 aBuf.Append(ptr128); |
|
496 break; |
|
497 case CSdpTestBase::EUuid32: |
|
498 aBuf.Append(ptr32); |
|
499 break; |
|
500 default: |
|
501 aBuf.Append(ptr16); |
|
502 } |
|
503 } |
|
504 |
|
505 aBuf.Append((TUint8*)&bigCount, 2); |
|
506 aBuf.Append(iAttributeRequest.Des(), 3); |
|
507 |
|
508 if(bigAttributeIdRange) |
|
509 { |
|
510 aBuf.Append((TUint8*)&bigAttributeIdRange, 4); |
|
511 } |
|
512 else |
|
513 { |
|
514 aBuf.Append((TUint8*)&bigAttributeId, 2); |
|
515 } |
|
516 |
|
517 } |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 class CAttrPrintVisitor : public CBase, public MAttributeVisitor |
|
523 { |
|
524 public: |
|
525 CAttrPrintVisitor(CConsoleBase& aConsole) : iConsole(aConsole) {iIndent=0;} |
|
526 ~CAttrPrintVisitor() {/*iConsole.Getch();*/} |
|
527 void VisitAttributeL(CSdpAttr &aAttribute) |
|
528 { |
|
529 Indent(); |
|
530 iConsole.Printf(_L("\nID:0x%x:"), aAttribute.AttributeID()); |
|
531 } |
|
532 void HexDes(const TDesC8& aDes) |
|
533 { |
|
534 for (TInt i = 0; i < aDes.Length(); ++i) |
|
535 iConsole.Printf(_L("%02x"), aDes[i]); |
|
536 //iConsole.Printf(_L("\n")); |
|
537 } |
|
538 void VisitAttributeValueL(CSdpAttrValue & aValue, TSdpElementType aType) |
|
539 { |
|
540 // FIXME need a new object like the match list that will just store the object in |
|
541 // FIXME an array, or perhaps just print it ? Is it a visitor ? |
|
542 // CSdpSearchPattern* encAttrList = new (ELeave) CSdpSearchPattern; |
|
543 // CleanupStack::PushL(encAttrList); |
|
544 |
|
545 // CElementParser* parser = CElementParser::NewL(encAttrList); |
|
546 // CleanupStack::PushL(parser); |
|
547 |
|
548 // TInt rem; |
|
549 |
|
550 TBuf16<0x64> iString; |
|
551 // TInt iFound; |
|
552 switch (aType) |
|
553 { |
|
554 case ETypeString: |
|
555 { |
|
556 TInt len = aValue.Des().Length(); |
|
557 if(len<0x60) |
|
558 //cannot cope with strings longer than 100 bytes! |
|
559 { |
|
560 iString.Copy(aValue.Des()); |
|
561 iConsole.Printf(_L("\"%S\""),&iString); |
|
562 } |
|
563 else |
|
564 { |
|
565 iConsole.Printf(_L("String attribute too long for CONSOLE: Length %d\n"),len); |
|
566 } |
|
567 break; |
|
568 } |
|
569 case ETypeDES: |
|
570 iConsole.Printf(_L(" DES")); |
|
571 break; |
|
572 case ETypeUint: |
|
573 iConsole.Printf(_L(" UInt:0x%x"), aValue.Uint()); |
|
574 break; |
|
575 case ETypeUUID: |
|
576 iConsole.Printf(_L(" UUID:0x")); |
|
577 HexDes(aValue.UUID().ShortestForm()); |
|
578 break; |
|
579 case ETypeEncoded: |
|
580 HexDes(aValue.Des()); // simplest |
|
581 //parse out the elements in this encoded attribute |
|
582 // rem = parser->ParseElementsL(aValue.Des()); |
|
583 // CleanupStack::PopAndDestroy(/*parser*/); |
|
584 // for (iFound=0 ; iFound++ ; (iFound < (encAttrList->Length()))) |
|
585 // { |
|
586 // VisitAttributeValueL(encAttrList->At(iFound).Value, encAttrList->At(iFound).Type); |
|
587 // } |
|
588 // CleanupStack::PopAndDestroy(/*encAttrList*/); |
|
589 break; |
|
590 default: |
|
591 iConsole.Printf(_L("type %d"), aType); |
|
592 } |
|
593 } |
|
594 void StartListL(CSdpAttrValueList &/*aList*/) |
|
595 { |
|
596 ++iIndent; |
|
597 iConsole.Printf(_L("{")); |
|
598 } |
|
599 void EndListL() |
|
600 { |
|
601 if(iIndent<=0) |
|
602 { |
|
603 iConsole.Printf(_L("\nERROR! Unmatched EndList!\n")); |
|
604 __DEBUGGER(); |
|
605 } |
|
606 iConsole.Printf(_L("}")); |
|
607 --iIndent; |
|
608 } |
|
609 private: |
|
610 void Indent() {/*test.SetPos(iIndent)*/;} |
|
611 CConsoleBase &iConsole; |
|
612 TInt iIndent; |
|
613 }; |
|
614 |
|
615 // |
|
616 // CSdpVerificationTests |
|
617 // |
|
618 |
|
619 void CSdpVerificationTests::RunTestL(CConsoleBase& aConsole) |
|
620 { |
|
621 CSdpVerificationTests* test=new(ELeave) CSdpVerificationTests(aConsole); |
|
622 TRAPD(err,test->DoTestsL()); |
|
623 aConsole.Printf(_L("SAS tests completed with error code: %d\r\nPRESS ANY KEY.\r\n"), err); |
|
624 aConsole.Getch(); |
|
625 delete test; |
|
626 } |
|
627 |
|
628 CSdpVerificationTests::CSdpVerificationTests(CConsoleBase& aConsole) |
|
629 :CSdpTestBase(aConsole), iIndent(0), iUuidType(CSdpTestBase::EUuid16) |
|
630 { |
|
631 iSP = CSdpSearchPattern::NewL(); //naughty but time is short! |
|
632 |
|
633 |
|
634 SetUpServiceTestParams(); |
|
635 SetUpAttributeTestParams(); |
|
636 SetUpServiceAttributeTestParams(); |
|
637 |
|
638 Mem::FillZ( iContinuationBuffer,KSdpContinuationStateMaxLength); |
|
639 |
|
640 iType = EServiceRequest; |
|
641 iQueryIndex = 0; |
|
642 iQueryState = EServiceRequest; |
|
643 iTestNum = 0; |
|
644 iContinuationStore.SetLength(0); |
|
645 iNeedAttributeId = ETrue; |
|
646 iBuildingList = 0; |
|
647 iBrowseIter = 0; |
|
648 iRequestMaxCount = 0; |
|
649 iRequestMaxCount1 = 0; |
|
650 iRequestMaxCount2 = 0; |
|
651 iRequestTransId = 0; |
|
652 iRequestTransId1 = 0; |
|
653 iRequestTransId2 = 0; |
|
654 iNeedMoreRecordHandles = EFalse; |
|
655 iBrowseTestNumRecordHandlesStored = 0; |
|
656 for (TUint i = 0; i < KMaxNumRecordHandles; i ++) |
|
657 { |
|
658 iBrowseTestServiceRecordHandle[i] = KUselessRecordHandle; //we want test database NOT to need this handle! |
|
659 } |
|
660 } |
|
661 |
|
662 CSdpVerificationTests::~CSdpVerificationTests() |
|
663 { |
|
664 delete iSP; |
|
665 } |
|
666 |
|
667 |
|
668 void CSdpVerificationTests::RunMasterTestL() |
|
669 { |
|
670 // Set the type |
|
671 // |
|
672 if(iTestNum<KServiceAttributeRequestTest) |
|
673 { |
|
674 iType=EServiceRequest; |
|
675 } |
|
676 if(iTestNum>=KServiceAttributeRequestTest) |
|
677 { |
|
678 iType=EServiceAttributeRequest; |
|
679 } |
|
680 if(iTestNum>=KServiceSearchAttributeRequestTest) |
|
681 { |
|
682 iType=EServiceSearchAttributeRequest; |
|
683 iQueryState=EServiceSearchAttributeRequest; |
|
684 } |
|
685 SDPQueryL(); |
|
686 } |
|
687 |
|
688 void CSdpVerificationTests::DoTestsL() |
|
689 { |
|
690 |
|
691 // Initialisation stuff |
|
692 // |
|
693 RSocketServ ss; |
|
694 TInt ret=ss.Connect(); |
|
695 if(ret!=KErrNone) |
|
696 { |
|
697 iConsole.Printf(_L("l2cap: no connection")); |
|
698 return; |
|
699 } |
|
700 |
|
701 TUint numProtocols; |
|
702 if(ss.NumProtocols(numProtocols)!=KErrNone) |
|
703 { |
|
704 iConsole.Printf(_L("l2cap: no protocols")); |
|
705 return; |
|
706 } |
|
707 TProtocolDesc pInfo; |
|
708 |
|
709 ret=ss.FindProtocol(_L("L2CAP"),pInfo); |
|
710 if (ret!=KErrNone) |
|
711 { |
|
712 iConsole.Printf(_L("l2cap datagram protocol not loaded")); |
|
713 return; |
|
714 } |
|
715 |
|
716 |
|
717 User::LeaveIfError(iRawSock.Open(ss,pInfo.iAddrFamily,pInfo.iSockType,pInfo.iProtocol)); |
|
718 |
|
719 WaitForStartSignalL(); |
|
720 SdpConnectL(); |
|
721 |
|
722 for(iTestNum=KServiceRequestTest;iTestNum<=KSdpLastTest;iTestNum++) |
|
723 { |
|
724 // Do any synching required here |
|
725 // |
|
726 // Reset the continuation buffer |
|
727 iContinuationStore.SetLength(0); |
|
728 if(AnotherQuery()) |
|
729 //These two query tests not reomoved from current spec |
|
730 { |
|
731 continue; |
|
732 } |
|
733 /* |
|
734 //MASK UNWANTED TEST or SPECIFY WANTED TESTS HERE! |
|
735 if(iTestNum!=1&& |
|
736 iTestNum!=8&& |
|
737 iTestNum!=34&& |
|
738 iTestNum!=53&& |
|
739 iTestNum!=54) |
|
740 { |
|
741 continue; |
|
742 } |
|
743 */ |
|
744 if(iTestNum!=34) continue; |
|
745 |
|
746 iConsole.Printf(_L("\r\n\r\n")); |
|
747 FLOG(_L("")); |
|
748 FLOG(_L("")); |
|
749 if(/*iTestNum<KServiceRequestTest*/EFalse) |
|
750 ; //do nothing |
|
751 else if(/*iTestNum>=KServiceRequestTest&&*/iTestNum<KServiceAttributeRequestTest) |
|
752 { |
|
753 iType = EServiceRequest; //allows skip of first SS test |
|
754 iQueryState=EServiceRequest; |
|
755 for(TUint j = 0;j < 3;j++) |
|
756 { |
|
757 switch(j) |
|
758 { |
|
759 case 0: |
|
760 iUuidType = CSdpTestBase::EUuid16; |
|
761 break; |
|
762 case 1: |
|
763 iUuidType = CSdpTestBase::EUuid32; |
|
764 break; |
|
765 default: |
|
766 iUuidType = CSdpTestBase::EUuid128; |
|
767 break; |
|
768 } |
|
769 UpdateTestString(); |
|
770 FTRACE(FPrint(_L("Starting %S..."), &iTestName)); |
|
771 FLOG(_L("")); |
|
772 iConsole.Printf(_L("Starting %S...\r\n"), &iTestName); |
|
773 |
|
774 TRAPD(err, RunMasterTestL()); |
|
775 FTRACE(FPrint(_L("%S returned with error %d. (0 => success!)"), &iTestName, err)); |
|
776 FTRACE(FPrint(_L(""))); |
|
777 FTRACE(FPrint(_L(""))); |
|
778 FTRACE(FPrint(_L(""))); |
|
779 iConsole.Printf(_L("%S returned with error %d. (0 => success!)\r\n"), &iTestName, err); |
|
780 PromptedGetch(); |
|
781 } |
|
782 } |
|
783 else if(iTestNum>=KServiceAttributeRequestTest&&iTestNum<KServiceSearchAttributeRequestTest) |
|
784 { |
|
785 iType = EServiceAttributeRequest; //allows skip of first SA test |
|
786 iQueryState=EServiceAttributeRequest; |
|
787 iUuidType = CSdpTestBase::EUuid16; |
|
788 UpdateTestString(); |
|
789 FTRACE(FPrint(_L("Starting %S..."), &iTestName)); |
|
790 FLOG(_L("")); |
|
791 iConsole.Printf(_L("Starting %S...\r\n"), &iTestName); |
|
792 |
|
793 TRAPD(err, RunMasterTestL()); |
|
794 FTRACE(FPrint(_L("%S returned with error %d. (0 => success!)"), &iTestName, err)); |
|
795 FTRACE(FPrint(_L(""))); |
|
796 FTRACE(FPrint(_L(""))); |
|
797 FTRACE(FPrint(_L(""))); |
|
798 iConsole.Printf(_L("%S returned with error %d. (0 => success!)\r\n"), &iTestName, err); |
|
799 PromptedGetch(); |
|
800 } |
|
801 else if(iTestNum>=KServiceSearchAttributeRequestTest && iTestNum<KSdpBrowseTest) |
|
802 { |
|
803 iType = EServiceSearchAttributeRequest; //allows skip of first SSA test |
|
804 iQueryState=EServiceSearchAttributeRequest; |
|
805 #ifdef SEVEN_LAYERS_BUG |
|
806 for(TUint j = 0;j < 1;j++) |
|
807 #else |
|
808 for(TUint j = 0;j < 3;j++) |
|
809 #endif |
|
810 { |
|
811 switch(j) |
|
812 { |
|
813 case 0: |
|
814 iUuidType = CSdpTestBase::EUuid16; |
|
815 break; |
|
816 case 1: |
|
817 iUuidType = CSdpTestBase::EUuid32; |
|
818 break; |
|
819 default: |
|
820 iUuidType = CSdpTestBase::EUuid128; |
|
821 break; |
|
822 } |
|
823 UpdateTestString(); |
|
824 FTRACE(FPrint(_L("Starting %S..."), &iTestName)); |
|
825 FLOG(_L("")); |
|
826 iConsole.Printf(_L("Starting %S...\r\n"), &iTestName); |
|
827 |
|
828 TRAPD(err, RunMasterTestL()); |
|
829 FTRACE(FPrint(_L("%S returned with error %d. (0 => success!)"), &iTestName, err)); |
|
830 FTRACE(FPrint(_L(""))); |
|
831 FTRACE(FPrint(_L(""))); |
|
832 FTRACE(FPrint(_L(""))); |
|
833 iConsole.Printf(_L("%S returned with error %d. (0 => success!)\r\n"), &iTestName, err); |
|
834 PromptedGetch(); |
|
835 } |
|
836 } |
|
837 else |
|
838 { |
|
839 TInt browseRet = KErrNone; |
|
840 for(TUint j = 0;j < 3;j++) |
|
841 { |
|
842 switch(j) |
|
843 { |
|
844 case 0: |
|
845 iUuidType = CSdpTestBase::EUuid16; |
|
846 break; |
|
847 case 1: |
|
848 iUuidType = CSdpTestBase::EUuid32; |
|
849 break; |
|
850 default: |
|
851 iUuidType = CSdpTestBase::EUuid128; |
|
852 break; |
|
853 } |
|
854 |
|
855 UpdateTestString(); |
|
856 FTRACE(FPrint(_L("Starting %S..."), &iTestName)); |
|
857 FLOG(_L("")); |
|
858 iConsole.Printf(_L("Starting %S...\r\n"), &iTestName); |
|
859 while(iBrowseIter<3) |
|
860 { |
|
861 TRAPD(err, SDPBrowseTestL(iUuidType)); |
|
862 if(err) |
|
863 { |
|
864 iBrowseIter++; //for messages/logging - this would have been jumped! |
|
865 } |
|
866 |
|
867 FTRACE(FPrint(_L("%S: Stage %d - returned with error %d (0 => success!)"), &iTestName, iBrowseIter, err)); |
|
868 FTRACE(FPrint(_L(""))); |
|
869 FTRACE(FPrint(_L(""))); |
|
870 FTRACE(FPrint(_L(""))); |
|
871 iConsole.Printf(_L("%S: Stage %d: returned with error %d (0 => success!)\r\n"), &iTestName, iBrowseIter, err); |
|
872 browseRet = err; |
|
873 if(browseRet!=KErrNone) |
|
874 { |
|
875 break; |
|
876 } |
|
877 } |
|
878 iBrowseIter = 0; |
|
879 PromptedGetch(); |
|
880 } |
|
881 } |
|
882 |
|
883 }//end of for loop |
|
884 SendCloseL(); |
|
885 } |
|
886 |
|
887 void CSdpVerificationTests::SDPQueryL() |
|
888 { |
|
889 TRequestStatus stat1; |
|
890 TRequestStatus stat2; |
|
891 |
|
892 // Buffers for sending/receiving requests |
|
893 // (use 700 so it 3ill definitely be big enough). |
|
894 TBuf8<700> queryResult1; |
|
895 TBuf8<700> queryResult2; |
|
896 |
|
897 iQueryIndex = 0; |
|
898 |
|
899 // Continue round this loop until finished |
|
900 // |
|
901 TBool bContinue = ETrue; |
|
902 while(bContinue) |
|
903 { |
|
904 // Run the first query |
|
905 // |
|
906 RunSDPSearchL(); |
|
907 // Do we have to do another query as well?? |
|
908 // |
|
909 TBool anotherQuery = AnotherQuery(); |
|
910 if(anotherQuery) |
|
911 { |
|
912 iQueryIndex++; |
|
913 RunSDPSearchL(); |
|
914 } |
|
915 // Wait for reply(s) |
|
916 // |
|
917 iRawSock.Read(queryResult1, stat1); |
|
918 User::WaitForRequest(stat1); |
|
919 if (stat1!=KErrNone) |
|
920 { |
|
921 iConsole.Printf(_L("First query failed\n")); |
|
922 User::Leave(stat1.Int()); |
|
923 } |
|
924 FlogReadString(queryResult1); |
|
925 |
|
926 if(anotherQuery) |
|
927 { |
|
928 iRawSock.Read(queryResult2, stat2); |
|
929 User::WaitForRequest(stat2); |
|
930 if (stat2!=KErrNone) |
|
931 { |
|
932 iConsole.Printf(_L("Second query failed\n")); |
|
933 User::Leave(stat1.Int()); |
|
934 } |
|
935 FlogReadString(queryResult2); |
|
936 } |
|
937 |
|
938 // Now process the results |
|
939 // |
|
940 User::LeaveIfError(ProcessSearchResults(queryResult1, queryResult2)); |
|
941 // Reset stuff |
|
942 iQueryIndex = 0; |
|
943 |
|
944 bContinue=Continue(); |
|
945 } |
|
946 } |
|
947 |
|
948 |
|
949 void CSdpVerificationTests::RunSDPSearchL() |
|
950 { |
|
951 // Run the appropiate query |
|
952 // |
|
953 if(iQueryState==EServiceRequest) |
|
954 { |
|
955 SDPServiceSearchL(); |
|
956 } |
|
957 else if(iQueryState==EServiceAttributeRequest) |
|
958 { |
|
959 SDPAttributeSearchL(); |
|
960 } |
|
961 else |
|
962 { |
|
963 SDPServiceAttributeSearch(); |
|
964 } |
|
965 |
|
966 } |
|
967 |
|
968 |
|
969 void CSdpVerificationTests::SDPServiceSearchL() |
|
970 { |
|
971 |
|
972 // If aLoop == 1, the first and second tests need to be run concurrently |
|
973 // |
|
974 TInt paramsIndex = iTestNum; |
|
975 if((iTestNum==1)&&(iQueryIndex==0)) |
|
976 { |
|
977 paramsIndex = 0; |
|
978 } |
|
979 // Set up the raw buffer. |
|
980 // First create the SDP header |
|
981 // |
|
982 TUint16 paramsSize = TUint16(KServiceParamsSize16); |
|
983 switch(iUuidType) |
|
984 { |
|
985 case CSdpTestBase::EUuid16: |
|
986 paramsSize = KServiceParamsSize16; |
|
987 break; |
|
988 case CSdpTestBase::EUuid32: |
|
989 paramsSize = KServiceParamsSize32; |
|
990 break; |
|
991 case CSdpTestBase::EUuid128: |
|
992 paramsSize = KServiceParamsSize128; |
|
993 break; |
|
994 default: |
|
995 break; |
|
996 } |
|
997 if(iTestNum==4) |
|
998 { |
|
999 // This is the invalid PDU length test |
|
1000 // |
|
1001 paramsSize+=1; |
|
1002 } |
|
1003 TSDPHeader header(0x02, iRawTransactionId++, TUint16(paramsSize + iContLength + 1)); |
|
1004 |
|
1005 //Now add these to the query |
|
1006 // |
|
1007 TRequestStatus writeStat; |
|
1008 TBuf8<100> request; |
|
1009 request.Zero(); |
|
1010 header.AppendHeader(request); |
|
1011 iServiceTests[paramsIndex].SetUuidType(iUuidType); //update with current uuid type |
|
1012 iServiceTests[paramsIndex].AppendRequest(request); |
|
1013 request.Append(&iContLength, 1); |
|
1014 request.Append(iContinuationBuffer, iContLength); |
|
1015 FlogWriteString(request); |
|
1016 iRawSock.Write(request, writeStat); |
|
1017 User::WaitForRequest(writeStat); |
|
1018 } |
|
1019 |
|
1020 void CSdpVerificationTests::SDPAttributeSearchL() |
|
1021 { |
|
1022 TRequestStatus writeStat; |
|
1023 TBuf8<100> request; |
|
1024 TRequestStatus readStat; |
|
1025 TBuf8<700> queryResult1; |
|
1026 TBuf8<700> queryResult2; |
|
1027 request.Zero(); |
|
1028 TUint8 loop = 1; |
|
1029 iNeedMoreRecordHandles = EFalse; |
|
1030 iAttributeTestServiceRecordHandle = KUselessRecordHandle; |
|
1031 TBool doSS = ETrue; |
|
1032 if(iTestNum==26||(iTestNum==7&&iQueryIndex!=0)) |
|
1033 { |
|
1034 doSS = EFalse; |
|
1035 } |
|
1036 if(doSS) |
|
1037 { |
|
1038 while(loop) |
|
1039 { |
|
1040 TServiceRequest serviceRequest; |
|
1041 TSDPHeader header = TSDPHeader(0x02, iRawTransactionId++, TUint16(KServiceParamsSize16 + iContLength + 1));//cont length byte); |
|
1042 serviceRequest = TServiceRequest(KAttributeTestsServiceUUID, EUuid16, 1); |
|
1043 request.Zero(); |
|
1044 header.AppendHeader(request); |
|
1045 serviceRequest.AppendRequest(request); |
|
1046 request.Append(&iContLength, 1); |
|
1047 request.Append(iContinuationBuffer, iContLength); |
|
1048 FlogWriteString(request); |
|
1049 iRawSock.Write(request, writeStat); |
|
1050 User::WaitForRequest(writeStat); |
|
1051 // Wait for reply |
|
1052 // |
|
1053 iRawSock.Read(queryResult1, readStat); |
|
1054 User::WaitForRequest(readStat); |
|
1055 User::LeaveIfError(readStat.Int()); |
|
1056 // Process results (fills up browse record handle array) |
|
1057 // |
|
1058 FlogReadString(queryResult1); |
|
1059 User::LeaveIfError(ProcessServiceSearchResults(queryResult1, queryResult2)); |
|
1060 loop = iContLength; |
|
1061 } |
|
1062 } |
|
1063 |
|
1064 |
|
1065 // If aLoop ==7 the first and second tests need to be run concurrently |
|
1066 // |
|
1067 iNeedAttributeId = ETrue; |
|
1068 TInt paramsIndex = iTestNum; |
|
1069 if((iTestNum==7)&&(iQueryIndex==0)) |
|
1070 { |
|
1071 paramsIndex = 6; |
|
1072 } |
|
1073 // Now take off the index of the service tests |
|
1074 // |
|
1075 paramsIndex -= KNumSDPServiceTests; |
|
1076 |
|
1077 // Set up the raw buffer. |
|
1078 // First create the SDP header |
|
1079 // |
|
1080 TUint16 paramLen = TUint16(KAttributeParamsSize + iContLength + 1);//cont length byte |
|
1081 if(iTestNum==28) |
|
1082 { |
|
1083 // This is the invalid PDU length test |
|
1084 // |
|
1085 paramLen+=1; |
|
1086 } |
|
1087 TSDPHeader header(0x04, iRawTransactionId++, paramLen); |
|
1088 |
|
1089 //Now add these to the query |
|
1090 // |
|
1091 request.Zero(); |
|
1092 header.AppendHeader(request); |
|
1093 if(doSS) |
|
1094 { |
|
1095 if(iAttributeTestServiceRecordHandle==KUselessRecordHandle) |
|
1096 User::Leave(KErrGeneral); |
|
1097 //***********// |
|
1098 //overwrite requested record handle with result of |
|
1099 //initial service search (required by spec) |
|
1100 iAttributeTests[paramsIndex].SetRecordHandle((TUint16)iAttributeTestServiceRecordHandle); |
|
1101 } |
|
1102 //***********// |
|
1103 iAttributeTests[paramsIndex].AppendRequest(request); |
|
1104 request.Append(&iContLength, 1); |
|
1105 request.Append(iContinuationBuffer, iContLength); |
|
1106 FlogWriteString(request); |
|
1107 iRawSock.Write(request, writeStat); |
|
1108 User::WaitForRequest(writeStat); |
|
1109 } |
|
1110 |
|
1111 void CSdpVerificationTests::SDPServiceAttributeSearch() |
|
1112 { |
|
1113 iNeedAttributeId = ETrue; |
|
1114 // If aLoop == 33 the first and second tests need to be run concurrently |
|
1115 // |
|
1116 TInt paramsIndex = iTestNum; |
|
1117 if((iTestNum==33)&&(iQueryIndex==0)) |
|
1118 { |
|
1119 paramsIndex = 32; |
|
1120 } |
|
1121 // Now take off the index of the Service and Attribute tests |
|
1122 // |
|
1123 paramsIndex -= (KNumSDPServiceTests + KNumSDPAttributeTests); |
|
1124 |
|
1125 // Set up the raw buffer. |
|
1126 // First create the SDP header |
|
1127 // |
|
1128 TUint16 paramsSize = TUint16(KServiceAttributeParamsSize16); |
|
1129 |
|
1130 switch(iUuidType) |
|
1131 { |
|
1132 case CSdpTestBase::EUuid16: |
|
1133 paramsSize = KServiceAttributeParamsSize16; |
|
1134 break; |
|
1135 case CSdpTestBase::EUuid32: |
|
1136 paramsSize = KServiceAttributeParamsSize32; |
|
1137 break; |
|
1138 case CSdpTestBase::EUuid128: |
|
1139 paramsSize = KServiceAttributeParamsSize128; |
|
1140 break; |
|
1141 default: |
|
1142 break; |
|
1143 } |
|
1144 #ifdef SEVEN_LAYERS_BUG |
|
1145 #else |
|
1146 if(iTestNum==34) |
|
1147 { |
|
1148 paramsSize += 2; // This is the one test that uses an attr range parameter |
|
1149 } |
|
1150 #endif |
|
1151 |
|
1152 if(iTestNum==52) |
|
1153 { |
|
1154 paramsSize += 1; // This is the invalid PDU length test |
|
1155 } |
|
1156 |
|
1157 TSDPHeader header(0x06, iRawTransactionId++, TUint16(paramsSize + iContLength + 1)); |
|
1158 |
|
1159 //Now add these to the query |
|
1160 // |
|
1161 TRequestStatus writeStat; |
|
1162 TBuf8<100> request; |
|
1163 request.Zero(); |
|
1164 header.AppendHeader(request); |
|
1165 iServiceAttributeTests[paramsIndex].SetUuidType(iUuidType); //update with current uuid type |
|
1166 iServiceAttributeTests[paramsIndex].AppendRequest(request); |
|
1167 request.Append(&iContLength, 1); |
|
1168 request.Append(iContinuationBuffer, iContLength); |
|
1169 FlogWriteString(request); |
|
1170 iRawSock.Write(request, writeStat); |
|
1171 User::WaitForRequest(writeStat); |
|
1172 } |
|
1173 /* |
|
1174 header = TSDPHeader(0x06, iRawTransactionId++, TUint16(ssaParamsSize + iContLength + 1));//cont length byte); |
|
1175 servAttrRequest = TServiceAttributeRequest(iSP->At(j), aUuidType, 200, attrUUID); |
|
1176 request.Zero(); |
|
1177 header.AppendHeader(request); |
|
1178 servAttrRequest.AppendRequest(request); |
|
1179 request.Append(&iContLength, 1); |
|
1180 request.Append(iContinuationBuffer, iContLength); |
|
1181 */ |
|
1182 |
|
1183 void CSdpVerificationTests::SDPBrowseTestL(CSdpTestBase::TUuidType aUuidType) |
|
1184 { |
|
1185 TSDPHeader header; |
|
1186 TUint16 serviceUUID = 0; |
|
1187 TUint16 attrUUID = 0; |
|
1188 TInt ssParamsSize = KServiceParamsSize16; |
|
1189 TInt ssaParamsSize = KServiceAttributeParamsSize16; |
|
1190 |
|
1191 switch(aUuidType) |
|
1192 { |
|
1193 case CSdpTestBase::EUuid16: |
|
1194 ssParamsSize = KServiceParamsSize16; |
|
1195 ssaParamsSize = KServiceAttributeParamsSize16; |
|
1196 break; |
|
1197 case CSdpTestBase::EUuid32: |
|
1198 ssParamsSize = KServiceParamsSize32; |
|
1199 ssaParamsSize = KServiceAttributeParamsSize32; |
|
1200 break; |
|
1201 case CSdpTestBase::EUuid128: |
|
1202 ssParamsSize = KServiceParamsSize128; |
|
1203 ssaParamsSize = KServiceAttributeParamsSize128; |
|
1204 break; |
|
1205 default: |
|
1206 break; |
|
1207 } |
|
1208 |
|
1209 |
|
1210 //Reset for next level browse query |
|
1211 iContLength = 0; |
|
1212 iContinuationStore.SetLength(0); |
|
1213 iBrowseTestNumRecordHandlesStored = 0; |
|
1214 for (TUint i = 0; i < KMaxNumRecordHandles; i ++) |
|
1215 { |
|
1216 iBrowseTestServiceRecordHandle[i] = KUselessRecordHandle; //we want test database NOT to need this handle! |
|
1217 } |
|
1218 |
|
1219 |
|
1220 TRequestStatus writeStat; |
|
1221 TBuf8<100> request; |
|
1222 TRequestStatus readStat; |
|
1223 TBuf8<700> queryResult1; |
|
1224 TBuf8<700> queryResult2; |
|
1225 if(iTestNum == KSdpBrowseTest) |
|
1226 { |
|
1227 // This pattern repeats the search/atrribute request pattern |
|
1228 // |
|
1229 switch(iBrowseIter) |
|
1230 { |
|
1231 case 0: |
|
1232 serviceUUID = 0x1002; // Public browse group |
|
1233 FLOG(_L("***********FIRST PHASE SERVICE SEARCH TRANSACTION(S)**************")); |
|
1234 FTRACE(FPrint(_L("***********uses single UUID 0x%04x***********"), serviceUUID)); |
|
1235 break; |
|
1236 case 1: |
|
1237 iSP->Reset(); |
|
1238 serviceUUID = 0x1001; // Browse group descriptor class ID |
|
1239 FLOG(_L("***********SECOND PHASE SERVICE SEARCH TRANSACTION(S)**************")); |
|
1240 FTRACE(FPrint(_L("***********uses single UUID 0x%04x***********"), serviceUUID)); |
|
1241 break; |
|
1242 case 2: |
|
1243 { |
|
1244 if(iSP->Count()<=0) |
|
1245 { |
|
1246 User::Leave(KErrGeneral); |
|
1247 } |
|
1248 TPtrC8 uuid = iBrowseUUID[0].ShortestForm(); |
|
1249 serviceUUID = BigEndian::Get16(uuid.Ptr()); |
|
1250 FLOG(_L("***********THIRD PHASE SERVICE SEARCH TRANSACTION(S)**************")); |
|
1251 FTRACE(FPrint(_L("***********uses single UUID 0x%04x***********"), serviceUUID)); |
|
1252 } |
|
1253 break; |
|
1254 default: |
|
1255 User::Leave(KErrGeneral); |
|
1256 break; |
|
1257 } |
|
1258 TUint8 loop = 1; |
|
1259 iNeedMoreRecordHandles = EFalse; |
|
1260 while(loop) |
|
1261 { |
|
1262 TServiceRequest serviceRequest; |
|
1263 if(iBrowseIter==2) |
|
1264 { |
|
1265 iNeedMoreRecordHandles = ETrue; |
|
1266 TInt j = 0; |
|
1267 while(j<iSP->Count()) |
|
1268 { |
|
1269 header = TSDPHeader(0x02, iRawTransactionId++, TUint16(ssParamsSize + iContLength + 1));//cont length byte); |
|
1270 serviceRequest = TServiceRequest(iSP->At(j), aUuidType, KMaxNumRecordHandles); |
|
1271 request.Zero(); |
|
1272 header.AppendHeader(request); |
|
1273 serviceRequest.AppendRequest(request); |
|
1274 request.Append(&iContLength, 1); |
|
1275 request.Append(iContinuationBuffer, iContLength); |
|
1276 FlogWriteString(request); |
|
1277 iRawSock.Write(request, writeStat); |
|
1278 User::WaitForRequest(writeStat); |
|
1279 // Wait for reply |
|
1280 // |
|
1281 iRawSock.Read(queryResult1, readStat); |
|
1282 User::WaitForRequest(readStat); |
|
1283 User::LeaveIfError(readStat.Int()); |
|
1284 // Process results (fills up browse record handle array) |
|
1285 // |
|
1286 FlogReadString(queryResult1); |
|
1287 User::LeaveIfError(ProcessServiceSearchResults(queryResult1, queryResult2)); |
|
1288 if(!iContLength) |
|
1289 j++; |
|
1290 } |
|
1291 iNeedMoreRecordHandles = EFalse; |
|
1292 } |
|
1293 else |
|
1294 { |
|
1295 header = TSDPHeader(0x02, iRawTransactionId++, TUint16(ssParamsSize + iContLength + 1));//cont length byte); |
|
1296 serviceRequest = TServiceRequest(/*UuidDes, */serviceUUID, aUuidType, KMaxNumRecordHandles); |
|
1297 request.Zero(); |
|
1298 header.AppendHeader(request); |
|
1299 serviceRequest.AppendRequest(request); |
|
1300 request.Append(&iContLength, 1); |
|
1301 request.Append(iContinuationBuffer, iContLength); |
|
1302 FlogWriteString(request); |
|
1303 iRawSock.Write(request, writeStat); |
|
1304 User::WaitForRequest(writeStat); |
|
1305 // Wait for reply |
|
1306 // |
|
1307 iRawSock.Read(queryResult1, readStat); |
|
1308 User::WaitForRequest(readStat); |
|
1309 User::LeaveIfError(readStat.Int()); |
|
1310 // Process results (fills up browse record handle array) |
|
1311 // |
|
1312 FlogReadString(queryResult1); |
|
1313 User::LeaveIfError(ProcessServiceSearchResults(queryResult1, queryResult2)); |
|
1314 } |
|
1315 loop = iContLength; |
|
1316 } |
|
1317 // the and attribute query on the first record handle for service class id list... |
|
1318 // |
|
1319 switch(iBrowseIter) |
|
1320 { |
|
1321 case 0: |
|
1322 attrUUID = KSdpAttrIdServiceClassIDList; |
|
1323 FLOG(_L("***********FIRST PHASE ATTRIBUTE SEARCH TRANSACTION(S)**************")); |
|
1324 FTRACE(FPrint(_L("***********uses single attr id 0x%04x***********"), attrUUID)); |
|
1325 break; |
|
1326 case 1: |
|
1327 attrUUID = KSdpAttrIdSdpServerGroupID; |
|
1328 FLOG(_L("***********SECOND PHASE ATTRIBUTE SEARCH TRANSACTION(S)**************")); |
|
1329 FTRACE(FPrint(_L("***********uses single attr id 0x%04x***********"), attrUUID)); |
|
1330 break; |
|
1331 case 2: |
|
1332 attrUUID = KSdpAttrIdServiceClassIDList; |
|
1333 FLOG(_L("***********THIRD PHASE ATTRIBUTE SEARCH TRANSACTION(S)**************")); |
|
1334 FTRACE(FPrint(_L("***********uses single attr id 0x%04x***********"), attrUUID)); |
|
1335 break; |
|
1336 default: |
|
1337 User::Leave(KErrGeneral); |
|
1338 break; |
|
1339 } |
|
1340 TUint i = 0; |
|
1341 iContLength = 0; //make sure: new attribute request |
|
1342 iContinuationStore.SetLength(0); |
|
1343 for (TUint j = 0; j < KMaxNumBrowseUUIDs; j ++) |
|
1344 { |
|
1345 iBrowseUUID[i] = KUselessRecordHandle; //we want test database NOT to need this UUID! |
|
1346 } |
|
1347 iNumBrowseUUIDs = 0; |
|
1348 while(i < iBrowseTestNumRecordHandlesStored) |
|
1349 { |
|
1350 TAttributeRequest attrRequest; |
|
1351 if(iBrowseTestServiceRecordHandle[i]==KUselessRecordHandle) |
|
1352 { |
|
1353 i++; |
|
1354 continue; |
|
1355 } |
|
1356 header = TSDPHeader(0x04, iRawTransactionId++, TUint16(KAttributeParamsSize + iContLength + 1));//cont length byte); |
|
1357 attrRequest = TAttributeRequest(iBrowseTestServiceRecordHandle[i], 200, attrUUID); |
|
1358 writeStat = KRequestPending; |
|
1359 request.Zero(); |
|
1360 header.AppendHeader(request); |
|
1361 attrRequest.AppendRequest(request); |
|
1362 request.Append(&iContLength, 1); |
|
1363 request.Append(iContinuationBuffer, iContLength); |
|
1364 FlogWriteString(request); |
|
1365 iRawSock.Write(request, writeStat); |
|
1366 User::WaitForRequest(writeStat); |
|
1367 |
|
1368 // Wait for reply |
|
1369 // |
|
1370 readStat = KRequestPending; |
|
1371 iRawSock.Read(queryResult1, readStat); |
|
1372 User::WaitForRequest(readStat); |
|
1373 User::LeaveIfError(readStat.Int()); |
|
1374 // Process results |
|
1375 // |
|
1376 FlogReadString(queryResult1); |
|
1377 User::LeaveIfError(ProcessAttributeSearchResults(queryResult1, queryResult2)); |
|
1378 if(!iContLength) |
|
1379 i++; //augment ready for next record handle only if no continuation. |
|
1380 } |
|
1381 // Increment tree level counter |
|
1382 // |
|
1383 iBrowseIter++; |
|
1384 |
|
1385 } |
|
1386 else |
|
1387 { |
|
1388 header = TSDPHeader(0x06, iRawTransactionId++, TUint16(ssaParamsSize + iContLength + 1)); |
|
1389 switch(iBrowseIter) |
|
1390 { |
|
1391 case 0: |
|
1392 serviceUUID = 0x1002; // Public browse group |
|
1393 attrUUID = KSdpAttrIdServiceClassIDList; |
|
1394 FLOG(_L("***********FIRST PHASE SERVICE SEARCH ATTRIBUTE TRANSACTION(S)**************")); |
|
1395 FTRACE(FPrint(_L("***********uses single UUID 0x%04x, and single attr id 0x%04x***********"), serviceUUID, attrUUID)); |
|
1396 break; |
|
1397 case 1: |
|
1398 serviceUUID = 0x1001; // Browse group descriptor class ID |
|
1399 attrUUID = KSdpAttrIdSdpServerGroupID; |
|
1400 FLOG(_L("***********SECOND PHASE SERVICE SEARCH ATTRIBUTE TRANSACTION(S)**************")); |
|
1401 FTRACE(FPrint(_L("***********uses single UUID 0x%04x, and single attr id 0x%04x***********"), serviceUUID, attrUUID)); |
|
1402 break; |
|
1403 case 2: |
|
1404 serviceUUID = (TUint16)KGenericNetworkingUUID; // Generic networking |
|
1405 attrUUID = KSdpAttrIdServiceClassIDList; |
|
1406 FLOG(_L("***********THIRD PHASE SERVICE SEARCH ATTRIBUTE TRANSACTION(S)**************")); |
|
1407 FTRACE(FPrint(_L("***********uses single UUID 0x%04x, and single attr id 0x%04x***********"), serviceUUID, attrUUID)); |
|
1408 break; |
|
1409 default: |
|
1410 User::Leave(KErrGeneral); |
|
1411 break; |
|
1412 } |
|
1413 |
|
1414 TUint8 loop = 1; |
|
1415 iNeedMoreRecordHandles = EFalse; |
|
1416 while(loop) |
|
1417 { |
|
1418 TServiceAttributeRequest servAttrRequest; |
|
1419 if(iBrowseIter==2) |
|
1420 { |
|
1421 iNeedMoreRecordHandles = ETrue; |
|
1422 TInt j = 0; |
|
1423 while(j<iSP->Count()) |
|
1424 { |
|
1425 header = TSDPHeader(0x06, iRawTransactionId++, TUint16(ssaParamsSize + iContLength + 1));//cont length byte); |
|
1426 servAttrRequest = TServiceAttributeRequest(iSP->At(j), aUuidType, 200, attrUUID); |
|
1427 request.Zero(); |
|
1428 header.AppendHeader(request); |
|
1429 servAttrRequest.AppendRequest(request); |
|
1430 request.Append(&iContLength, 1); |
|
1431 request.Append(iContinuationBuffer, iContLength); |
|
1432 FlogWriteString(request); |
|
1433 iRawSock.Write(request, writeStat); |
|
1434 User::WaitForRequest(writeStat); |
|
1435 // Wait for reply |
|
1436 // |
|
1437 readStat = KRequestPending; |
|
1438 iRawSock.Read(queryResult1, readStat); |
|
1439 User::WaitForRequest(readStat); |
|
1440 User::LeaveIfError(readStat.Int()); |
|
1441 // Process results |
|
1442 // |
|
1443 FlogReadString(queryResult1); |
|
1444 User::LeaveIfError(ProcessServiceAttributeSearchResults(queryResult1, queryResult2)); |
|
1445 if(!iContLength) |
|
1446 j++; |
|
1447 } |
|
1448 iNeedMoreRecordHandles = EFalse; |
|
1449 } |
|
1450 else |
|
1451 { |
|
1452 header = TSDPHeader(0x06, iRawTransactionId++, TUint16(ssaParamsSize + iContLength + 1));//cont length byte); |
|
1453 servAttrRequest = TServiceAttributeRequest(serviceUUID, aUuidType, 200, attrUUID); |
|
1454 //Now add these to the query |
|
1455 // |
|
1456 TRequestStatus writeStat; |
|
1457 TRequestStatus readStat; |
|
1458 TBuf8<700> queryResult1; |
|
1459 TBuf8<700> queryResult2; |
|
1460 TBuf8<100> request; |
|
1461 request.Zero(); |
|
1462 header.AppendHeader(request); |
|
1463 servAttrRequest.AppendRequest(request); |
|
1464 request.Append(&iContLength, 1); |
|
1465 request.Append(iContinuationBuffer, iContLength); |
|
1466 FlogWriteString(request); |
|
1467 iRawSock.Write(request, writeStat); |
|
1468 User::WaitForRequest(writeStat); |
|
1469 // Wait for reply |
|
1470 // |
|
1471 readStat = KRequestPending; |
|
1472 iRawSock.Read(queryResult1, readStat); |
|
1473 User::WaitForRequest(readStat); |
|
1474 User::LeaveIfError(readStat.Int()); |
|
1475 // Process results |
|
1476 // |
|
1477 FlogReadString(queryResult1); |
|
1478 User::LeaveIfError(ProcessServiceAttributeSearchResults(queryResult1, queryResult2)); |
|
1479 |
|
1480 } |
|
1481 loop = iContLength; |
|
1482 } |
|
1483 // Increment tree level counter |
|
1484 // |
|
1485 iBrowseIter++; |
|
1486 } |
|
1487 } |
|
1488 |
|
1489 //-- |
|
1490 //-- |
|
1491 //-- |
|
1492 //-- |
|
1493 //-- |
|
1494 //-- |
|
1495 //-- |
|
1496 //-- |
|
1497 //-- |
|
1498 //-- |
|
1499 //-- |
|
1500 //-- |
|
1501 //-- |
|
1502 //-- |
|
1503 //-- |
|
1504 //-- |
|
1505 //-- |
|
1506 //-- |
|
1507 //-- |
|
1508 //-- |
|
1509 //-- |
|
1510 //-- |
|
1511 //-- |
|
1512 //-- |
|
1513 //-- |
|
1514 //-- |
|
1515 //-- |
|
1516 //-- |
|
1517 //-- |
|
1518 //-- |
|
1519 //-- |
|
1520 //-- |
|
1521 //-- |
|
1522 //-- |
|
1523 //-- |
|
1524 //-- |
|
1525 //-- |
|
1526 //-- |
|
1527 //-- |
|
1528 //-- |
|
1529 //-- |
|
1530 //-- |
|
1531 //-- |
|
1532 //-- |
|
1533 |
|
1534 |
|
1535 |
|
1536 TInt CSdpVerificationTests::ProcessSearchResults(TDesC8& aResult1, TDesC8& aResult2) |
|
1537 { |
|
1538 // Process accordingly |
|
1539 // |
|
1540 TInt ret = KErrNone; |
|
1541 if(iQueryState==EServiceRequest) |
|
1542 { |
|
1543 ret = ProcessServiceSearchResults(aResult1, aResult2); |
|
1544 } |
|
1545 else if(iQueryState==EServiceAttributeRequest) |
|
1546 { |
|
1547 ret = ProcessAttributeSearchResults(aResult1, aResult2); |
|
1548 } |
|
1549 else |
|
1550 { |
|
1551 ASSERT_DEBUG(iQueryState==EServiceSearchAttributeRequest); |
|
1552 ret = ProcessServiceAttributeSearchResults(aResult1, aResult2); |
|
1553 } |
|
1554 return ret; |
|
1555 } |
|
1556 |
|
1557 TInt CSdpVerificationTests::ProcessServiceSearchResults(TDesC8& aResult1, TDesC8& aResult2) |
|
1558 { |
|
1559 |
|
1560 TInt ret = KErrGeneral; |
|
1561 |
|
1562 // Have we found any records? |
|
1563 // |
|
1564 TBool haveRecords = ETrue; |
|
1565 if (aResult1.Length() < KMinResponseSize) |
|
1566 { |
|
1567 haveRecords = EFalse; |
|
1568 } |
|
1569 if(iTestNum == 1) |
|
1570 { |
|
1571 // Check the second result completed with records too |
|
1572 if((haveRecords) && (aResult2.Length() < 8)) |
|
1573 { |
|
1574 haveRecords = EFalse; |
|
1575 } |
|
1576 } |
|
1577 |
|
1578 // The test document dictates that size comparisons must be carried out. |
|
1579 // |
|
1580 |
|
1581 TUint16 totalRecordCount = 0; |
|
1582 TUint16 currentRecordCount = 0; |
|
1583 TUint16 totalRecordCount2 = 0; |
|
1584 TUint16 currentRecordCount2 = 0; |
|
1585 if(haveRecords) |
|
1586 { |
|
1587 totalRecordCount = BigEndian::Get16(&aResult1[KTotalCountOffset]); |
|
1588 currentRecordCount = BigEndian::Get16(&aResult1[KCurrentCountOffset]); |
|
1589 /* |
|
1590 ...now done in FlogParsedPDUHeader(..) |
|
1591 |
|
1592 if(currentRecordCount > totalRecordCount) |
|
1593 { |
|
1594 return KErrGeneral; |
|
1595 } |
|
1596 TUint maxRecordCount = KMaxNumRecordHandles; |
|
1597 if(iTestNum<KSdpBrowseTest) |
|
1598 { |
|
1599 maxRecordCount = iServiceTests[iTestNum].MaxRecordCount(); |
|
1600 } |
|
1601 if(totalRecordCount > maxRecordCount) |
|
1602 { |
|
1603 return KErrGeneral; |
|
1604 } |
|
1605 */ |
|
1606 // Check the second buffer as well if necessary |
|
1607 // |
|
1608 if(iTestNum==1) |
|
1609 { |
|
1610 totalRecordCount2 = BigEndian::Get16(&aResult2[KTotalCountOffset]); |
|
1611 currentRecordCount2 = BigEndian::Get16(&aResult2[KCurrentCountOffset]); |
|
1612 if(currentRecordCount2 > totalRecordCount2) |
|
1613 { |
|
1614 return KErrGeneral; |
|
1615 } |
|
1616 if(totalRecordCount2 > iServiceTests[iTestNum].MaxRecordCount()) |
|
1617 { |
|
1618 return KErrGeneral; |
|
1619 } |
|
1620 } |
|
1621 } |
|
1622 |
|
1623 |
|
1624 // The rest depends on which tests is being run... |
|
1625 // |
|
1626 TInt recordHandleOffset = KRecordHandleOffset; |
|
1627 if(iType==EServiceAttributeRequest) |
|
1628 { |
|
1629 if(haveRecords) |
|
1630 { |
|
1631 iAttributeTestServiceRecordHandle = BigEndian::Get32(&aResult1[recordHandleOffset]); |
|
1632 } |
|
1633 } |
|
1634 switch(iTestNum) |
|
1635 { |
|
1636 case 1: |
|
1637 case 0: |
|
1638 case 6: |
|
1639 case 7: |
|
1640 case 8: |
|
1641 case 9: |
|
1642 case 10: |
|
1643 case 11: |
|
1644 case 12: |
|
1645 case 13: |
|
1646 case 14: |
|
1647 case 15: |
|
1648 case 16: |
|
1649 case 17: |
|
1650 case 18: |
|
1651 case 19: |
|
1652 case 20: |
|
1653 case 21: |
|
1654 case 22: |
|
1655 case 23: |
|
1656 case 24: |
|
1657 case 25: |
|
1658 case 26: |
|
1659 case 27: |
|
1660 case 28: |
|
1661 if(haveRecords) |
|
1662 { |
|
1663 // Check the returned record is correct |
|
1664 // Should only return the 1st record |
|
1665 // |
|
1666 if(currentRecordCount==1) |
|
1667 { |
|
1668 TUint32 serviceRecordHandle = BigEndian::Get32(&aResult1[recordHandleOffset]); |
|
1669 if(serviceRecordHandle==KSdpMinServRecordHandle) |
|
1670 { |
|
1671 ret = KErrNone; |
|
1672 } |
|
1673 |
|
1674 // Now check the second result |
|
1675 if((iTestNum==1)&& (ret==KErrNone)) |
|
1676 { |
|
1677 serviceRecordHandle = BigEndian::Get32(&aResult2[recordHandleOffset]); |
|
1678 if(serviceRecordHandle!=KSdpMinServRecordHandle+1) |
|
1679 { |
|
1680 ret = KErrGeneral; |
|
1681 } |
|
1682 } |
|
1683 } |
|
1684 } |
|
1685 break; |
|
1686 case 2: |
|
1687 if(haveRecords) |
|
1688 { |
|
1689 // This one should have the continuation state set |
|
1690 // Offset of continuation byte = |
|
1691 // (CurrentServiceRecordCount * 4) + 4 + HeaderSize |
|
1692 TUint16 partial = TUint16((currentRecordCount * 4) + 4 + KSdpPduHeaderSize); |
|
1693 iContLength = aResult1[partial]; |
|
1694 TBuf8<20> cont; |
|
1695 cont.SetLength(0); |
|
1696 cont.Append(aResult1.Mid(partial)); |
|
1697 FlogContinuationString(cont); |
|
1698 if (iContLength == 0) |
|
1699 { |
|
1700 // No continuation set. Is this the end or is there an error? |
|
1701 // Are these handles correct? |
|
1702 ret=KErrNone; |
|
1703 for(TInt i=0; i<currentRecordCount; i++) |
|
1704 { |
|
1705 TUint32 serviceRecordHandle = BigEndian::Get32(&aResult1[recordHandleOffset]); |
|
1706 recordHandleOffset += 4; //Move to next handle; |
|
1707 if(serviceRecordHandle<KSdpMinServRecordHandle+3) |
|
1708 { |
|
1709 ret = KErrGeneral; |
|
1710 } |
|
1711 } |
|
1712 } |
|
1713 else |
|
1714 { |
|
1715 // Check these UUIDs first |
|
1716 // |
|
1717 ret = KErrNone; |
|
1718 for(TInt i=0; i<currentRecordCount; i++) |
|
1719 { |
|
1720 TUint32 serviceRecordHandle = BigEndian::Get32(&aResult1[recordHandleOffset]); |
|
1721 recordHandleOffset += 4; //Move to next handle; |
|
1722 if(serviceRecordHandle<KSdpMinServRecordHandle+3) |
|
1723 { |
|
1724 ret = KErrGeneral; |
|
1725 } |
|
1726 } |
|
1727 if(ret==KErrNone) |
|
1728 { |
|
1729 Mem::Copy(iContinuationBuffer, &aResult1[partial+1], KSdpContinuationStateMaxLength); |
|
1730 TRAP(ret, SDPQueryL()); |
|
1731 // Clear out the continuation state buffer ready for next query |
|
1732 // |
|
1733 Mem::FillZ( iContinuationBuffer,KSdpContinuationStateMaxLength); |
|
1734 iContLength = 0; |
|
1735 } |
|
1736 } |
|
1737 } |
|
1738 break; |
|
1739 case 3: |
|
1740 // Should get no records back here |
|
1741 if(haveRecords) |
|
1742 { |
|
1743 if((totalRecordCount==currentRecordCount) && (totalRecordCount==0)) |
|
1744 { |
|
1745 ret=KErrNone; |
|
1746 } |
|
1747 } |
|
1748 break; |
|
1749 case 4: |
|
1750 case 5: |
|
1751 // This should be the SDP_ErrorResponse PDU |
|
1752 // |
|
1753 if(!haveRecords) // Should be no records here |
|
1754 { |
|
1755 if(aResult1[0] == 0x01) |
|
1756 { |
|
1757 // This is an error response. |
|
1758 // Check the error code. It must either be |
|
1759 // an invalid size or invalid syntax. |
|
1760 // |
|
1761 TInt16 errorCode = BigEndian::Get16(&aResult1[KErrorCodeOffset]); |
|
1762 if(((errorCode==EInvalidPduSize) && (iTestNum==4)) |
|
1763 ||((errorCode==EInvalidRequestSyntax) && (iTestNum==5))) |
|
1764 { |
|
1765 ret = KErrNone; |
|
1766 } |
|
1767 // Otherwise, wrong response. |
|
1768 } |
|
1769 } |
|
1770 break; |
|
1771 case 53: |
|
1772 if(haveRecords) |
|
1773 { |
|
1774 // Check the returned record is correct. |
|
1775 // |
|
1776 TUint16 partial = TUint16((currentRecordCount * 4) + 4 + KSdpPduHeaderSize); |
|
1777 |
|
1778 if(iBrowseIter/*=*/<=2) |
|
1779 { |
|
1780 ret = KErrNone; |
|
1781 } |
|
1782 |
|
1783 for (TUint i = iBrowseTestNumRecordHandlesStored; |
|
1784 i < iBrowseTestNumRecordHandlesStored + currentRecordCount; |
|
1785 i ++) |
|
1786 { |
|
1787 iBrowseTestServiceRecordHandle[i] = BigEndian::Get32(&aResult1[recordHandleOffset]); |
|
1788 recordHandleOffset += 4; |
|
1789 for(TUint j = 0; j<i; j++) |
|
1790 { |
|
1791 if(iBrowseTestServiceRecordHandle[i]==iBrowseTestServiceRecordHandle[j]) |
|
1792 //Check we are not repeating a handle |
|
1793 //and if so set that handle to 'KUselessRecordHandle' |
|
1794 //so that we ignore it! |
|
1795 { |
|
1796 iBrowseTestServiceRecordHandle[i] = KUselessRecordHandle; //indicates useless handle |
|
1797 break; |
|
1798 } |
|
1799 } |
|
1800 } |
|
1801 |
|
1802 if(iContLength) |
|
1803 { |
|
1804 Mem::Copy(iContinuationBuffer, &aResult1[partial+1], KSdpContinuationStateMaxLength); |
|
1805 } |
|
1806 iBrowseTestNumRecordHandlesStored += currentRecordCount; |
|
1807 } |
|
1808 break; |
|
1809 default: |
|
1810 break; |
|
1811 } |
|
1812 |
|
1813 return ret; |
|
1814 } |
|
1815 |
|
1816 |
|
1817 TInt CSdpVerificationTests::ProcessServiceAttributeSearchResults(TDesC8& aResult1, TDesC8& aResult2) |
|
1818 { |
|
1819 TInt ret = KErrGeneral; |
|
1820 // Have got a response? |
|
1821 // |
|
1822 TBool haveResult = ETrue; |
|
1823 if (aResult1.Length() < KMinResponseSize) |
|
1824 { |
|
1825 haveResult = EFalse; |
|
1826 } |
|
1827 if(iTestNum == 33) |
|
1828 { |
|
1829 // Check the second result completed with records too |
|
1830 if((haveResult) && (aResult2.Length() < KMinResponseSize)) |
|
1831 { |
|
1832 haveResult = EFalse; |
|
1833 } |
|
1834 } |
|
1835 // The test document dictates that size comparisons must be carried out. |
|
1836 // |
|
1837 TUint16 byteCount1 = 0; |
|
1838 TUint16 byteCount2 = 0; |
|
1839 if(haveResult) |
|
1840 { |
|
1841 TUint16 intendedByteCount = 200; |
|
1842 if(iTestNum<KSdpBrowseTest) |
|
1843 { |
|
1844 intendedByteCount = iServiceAttributeTests[iTestNum - KNumSDPServiceTests - KNumSDPServiceAttributeTests].MaxByteCount(); |
|
1845 } |
|
1846 byteCount1 = BigEndian::Get16(&aResult1[KAttributeByteCountOffset]); |
|
1847 if(byteCount1 > intendedByteCount) |
|
1848 { |
|
1849 return KErrGeneral; |
|
1850 } |
|
1851 //Now check the second buffer if necessary |
|
1852 // |
|
1853 if(iTestNum==33) |
|
1854 { |
|
1855 byteCount2 = BigEndian::Get16(&aResult2[KAttributeByteCountOffset]); |
|
1856 if(byteCount2 > iServiceAttributeTests[iTestNum - KNumSDPServiceTests - KNumSDPServiceAttributeTests].MaxByteCount()) |
|
1857 { |
|
1858 return KErrGeneral; |
|
1859 } |
|
1860 } |
|
1861 } |
|
1862 |
|
1863 // Now parse what we've got back |
|
1864 // |
|
1865 if(haveResult) |
|
1866 { |
|
1867 if(byteCount1==0) |
|
1868 { |
|
1869 if((iTestNum==29) || (iTestNum==30) || (iTestNum==31)) |
|
1870 { |
|
1871 // the non-existing attribute/service test |
|
1872 ret = KErrNone; |
|
1873 } |
|
1874 } |
|
1875 else |
|
1876 { |
|
1877 #ifdef PRINT_BUILDER |
|
1878 TRAP(ret,MSdpElementBuilder* builder = (MSdpElementBuilder*)new(ELeave)CPrintBuilder(iConsole)); |
|
1879 if (ret != KErrNone) |
|
1880 { |
|
1881 return ret; |
|
1882 } |
|
1883 #else |
|
1884 MSdpElementBuilder* builder = this; |
|
1885 #endif |
|
1886 |
|
1887 if(iTestNum>=KSdpBrowseTest) |
|
1888 { |
|
1889 TRAP(ret,builder = (MSdpElementBuilder*)new(ELeave)CBrowseResponseBuilder(iTestName,iBrowseIter/*,iTestNum - KSdpBrowseTest + 1, GetUuidSize()*/, *iSP)); |
|
1890 if (ret != KErrNone) |
|
1891 { |
|
1892 return ret; |
|
1893 } |
|
1894 } |
|
1895 |
|
1896 CElementParser* parser = NULL; |
|
1897 TRAP(ret,parser = CElementParser::NewL(builder)); |
|
1898 if (ret != KErrNone) |
|
1899 { |
|
1900 return ret; |
|
1901 } |
|
1902 TRAP(ret,CleanupStack::PushL(parser)); |
|
1903 if (ret != KErrNone) |
|
1904 { |
|
1905 return ret; |
|
1906 } |
|
1907 |
|
1908 // Get the offset of the continuation state |
|
1909 TUint16 attributeListLength = BigEndian::Get16(&aResult1[KSdpPduHeaderSize]); |
|
1910 TUint16 partial = TUint16(attributeListLength + KSdpPduHeaderSize + 2); |
|
1911 iContLength = aResult1[partial]; |
|
1912 TBuf8<20> cont; |
|
1913 cont.SetLength(0); |
|
1914 cont.Append(aResult1.Mid(partial)); |
|
1915 FlogContinuationString(cont); |
|
1916 |
|
1917 if (iTestNum == 34) |
|
1918 { |
|
1919 // This one should have the continuation state set so do another query. |
|
1920 iContinuationStore.Append(aResult1.Mid(KAttributeListOffset, attributeListLength)); |
|
1921 if (iContLength != 0) |
|
1922 { |
|
1923 Mem::Copy(iContinuationBuffer, &aResult1[partial+1], KSdpContinuationStateMaxLength); |
|
1924 TRAPD(err, SDPQueryL()); |
|
1925 ret = err; |
|
1926 // Clear out the continuation state buffer ready for next query |
|
1927 // |
|
1928 Mem::FillZ( iContinuationBuffer,KSdpContinuationStateMaxLength); |
|
1929 iContLength = 0; |
|
1930 } |
|
1931 else |
|
1932 { |
|
1933 TRAPD(err, parser->ParseElementsL(iContinuationStore)); |
|
1934 ret = err; |
|
1935 iContinuationStore.SetLength(0); |
|
1936 } |
|
1937 } |
|
1938 else if(iTestNum>=KSdpBrowseTest) |
|
1939 { |
|
1940 // This one might have the continuation state set so prepare, |
|
1941 // if necessary, for another query. |
|
1942 iContinuationStore.Append(aResult1.Mid(KAttributeListOffset, attributeListLength)); |
|
1943 if (iContLength != 0) |
|
1944 { |
|
1945 Mem::Copy(iContinuationBuffer, &aResult1[partial+1], KSdpContinuationStateMaxLength); |
|
1946 ret = KErrNone; |
|
1947 } |
|
1948 else |
|
1949 { |
|
1950 TRAPD(err, parser->ParseElementsL(iContinuationStore)); |
|
1951 ret = err; |
|
1952 iContinuationStore.SetLength(0); |
|
1953 } |
|
1954 } |
|
1955 else |
|
1956 { |
|
1957 TRAPD(err,parser->ParseElementsL(aResult1.Mid(KAttributeListOffset, attributeListLength))); |
|
1958 ret = err; |
|
1959 } |
|
1960 |
|
1961 if((ret==KErrNone)&&(iTestNum == 33)) |
|
1962 { |
|
1963 // We need to parse the second buffer as well. |
|
1964 // |
|
1965 if((byteCount2!=0)) |
|
1966 { |
|
1967 iNeedAttributeId = ETrue; |
|
1968 TUint16 attributeListLength2 = BigEndian::Get16(&aResult2[KSdpPduHeaderSize]); |
|
1969 TRAPD(err,ret=parser->ParseElementsL(aResult2.Mid(KAttributeListOffset, attributeListLength2))); |
|
1970 if (err) |
|
1971 { |
|
1972 ret = err; |
|
1973 } |
|
1974 } |
|
1975 } |
|
1976 if(iTestNum>=KSdpBrowseTest) |
|
1977 { |
|
1978 delete (CBrowseResponseBuilder*)builder; |
|
1979 builder = 0; |
|
1980 } |
|
1981 #ifdef PRINT_BUILDER |
|
1982 delete (CPrintBuilder*)builder; |
|
1983 iConsole.Printf(_L("Press any key.\r\n")); |
|
1984 iConsole.Getch(); |
|
1985 #endif |
|
1986 |
|
1987 CleanupStack::PopAndDestroy(parser); |
|
1988 } |
|
1989 } |
|
1990 else |
|
1991 { |
|
1992 // What's left should be invalid behaviour tests |
|
1993 // ie. the SDP_ErrorResponse PDU |
|
1994 if(aResult1[0] == 0x01) |
|
1995 { |
|
1996 // This is an error response. |
|
1997 // Check the error code. It must either be |
|
1998 // an invalid size, invalid syntax or invalid record handle. |
|
1999 // |
|
2000 TInt16 errorCode = BigEndian::Get16(&aResult1[KErrorCodeOffset]); |
|
2001 if(((errorCode==EInvalidPduSize) && (iTestNum==52)) |
|
2002 ||((errorCode==EInvalidRequestSyntax) && (iTestNum==51))) |
|
2003 { |
|
2004 ret = KErrNone; |
|
2005 } |
|
2006 // Otherwise, wrong response. |
|
2007 } |
|
2008 } |
|
2009 iContLength = 0; //reset |
|
2010 return ret; |
|
2011 } |
|
2012 |
|
2013 |
|
2014 TInt CSdpVerificationTests::ProcessAttributeSearchResults(TDesC8& aResult1, TDesC8& aResult2) |
|
2015 { |
|
2016 TInt ret = KErrGeneral; |
|
2017 // Have got a response? |
|
2018 // |
|
2019 TBool haveResult = ETrue; |
|
2020 if (aResult1.Length() < KMinResponseSize) |
|
2021 { |
|
2022 haveResult = EFalse; |
|
2023 } |
|
2024 if(iTestNum == 7) |
|
2025 { |
|
2026 // Check the second result completed with records too |
|
2027 if((haveResult) && (aResult2.Length() < KMinResponseSize)) |
|
2028 { |
|
2029 haveResult = EFalse; |
|
2030 } |
|
2031 } |
|
2032 // The test document dictates that size comparisons must be carried out. |
|
2033 // |
|
2034 TUint16 byteCount1 = 0; |
|
2035 TUint16 byteCount2 = 0; |
|
2036 if(haveResult) |
|
2037 { |
|
2038 TUint16 intendedByteCount = 200; |
|
2039 if(iTestNum<KSdpBrowseTest) |
|
2040 { |
|
2041 intendedByteCount = iAttributeTests[iTestNum - KNumSDPServiceTests].MaxByteCount(); |
|
2042 } |
|
2043 byteCount1 = BigEndian::Get16(&aResult1[KAttributeByteCountOffset]); |
|
2044 if(byteCount1 > intendedByteCount) |
|
2045 { |
|
2046 return KErrGeneral; |
|
2047 } |
|
2048 // Check the second buffer as well if necessary |
|
2049 // |
|
2050 if(iTestNum==7) |
|
2051 { |
|
2052 byteCount2 = BigEndian::Get16(&aResult2[KAttributeByteCountOffset]); |
|
2053 if(byteCount2 > iAttributeTests[iTestNum - KNumSDPServiceTests].MaxByteCount()) |
|
2054 { |
|
2055 return KErrGeneral; |
|
2056 } |
|
2057 } |
|
2058 } |
|
2059 |
|
2060 // Now Parse what we've got back |
|
2061 // |
|
2062 if(haveResult) |
|
2063 { |
|
2064 if(byteCount1!=0) |
|
2065 { |
|
2066 MSdpElementBuilder* builder = this; |
|
2067 if(iTestNum>=KSdpBrowseTest) |
|
2068 { |
|
2069 TRAP(ret,builder = (MSdpElementBuilder*)new(ELeave)CBrowseResponseBuilder(iTestName,iBrowseIter/*,iTestNum - KSdpBrowseTest + 1, GetUuidSize()*/, *iSP)); |
|
2070 if (ret != KErrNone) |
|
2071 { |
|
2072 return ret; |
|
2073 } |
|
2074 } |
|
2075 |
|
2076 CElementParser* parser = NULL; |
|
2077 TRAP(ret,parser = CElementParser::NewL(builder)); |
|
2078 if (ret != KErrNone) |
|
2079 { |
|
2080 return ret; |
|
2081 } |
|
2082 |
|
2083 TRAP(ret,CleanupStack::PushL(parser)); |
|
2084 if (ret != KErrNone) |
|
2085 { |
|
2086 return ret; |
|
2087 } |
|
2088 |
|
2089 // Get the offset of the continuation state |
|
2090 TUint16 attributeListLength = BigEndian::Get16(&aResult1[KSdpPduHeaderSize]); |
|
2091 TUint16 partial = TUint16(attributeListLength + KSdpPduHeaderSize + 2); |
|
2092 iContLength = aResult1[partial]; |
|
2093 TBuf8<20> cont; |
|
2094 cont.SetLength(0); |
|
2095 cont.Append(aResult1.Mid(partial)); |
|
2096 FlogContinuationString(cont); |
|
2097 if (iTestNum == 8) |
|
2098 { |
|
2099 // This one should have the continuation state set so do another query. |
|
2100 iContinuationStore.Append(aResult1.Mid(KAttributeListOffset, attributeListLength)); |
|
2101 if (iContLength != 0) |
|
2102 { |
|
2103 Mem::Copy(iContinuationBuffer, &aResult1[partial+1], KSdpContinuationStateMaxLength); |
|
2104 TRAPD(err, SDPQueryL()); |
|
2105 ret = err; |
|
2106 // Clear out the continuation state buffer ready for next query |
|
2107 // |
|
2108 Mem::FillZ( iContinuationBuffer,KSdpContinuationStateMaxLength); |
|
2109 iContLength = 0; |
|
2110 } |
|
2111 else |
|
2112 { |
|
2113 TRAPD(err, parser->ParseElementsL(iContinuationStore)); |
|
2114 ret = err; |
|
2115 iContinuationStore.SetLength(0); |
|
2116 } |
|
2117 } |
|
2118 else if(iTestNum>=KSdpBrowseTest) |
|
2119 { |
|
2120 // This one might have the continuation state set so prepare, |
|
2121 // if necessary, for another query. |
|
2122 iContinuationStore.Append(aResult1.Mid(KAttributeListOffset, attributeListLength)); |
|
2123 if (iContLength != 0) |
|
2124 { |
|
2125 Mem::Copy(iContinuationBuffer, &aResult1[partial+1], KSdpContinuationStateMaxLength); |
|
2126 ret = KErrNone; //only error when (?) iContLength is zero |
|
2127 } |
|
2128 else |
|
2129 { |
|
2130 TRAPD(err, parser->ParseElementsL(iContinuationStore)); |
|
2131 ret = err; |
|
2132 iContinuationStore.SetLength(0); |
|
2133 } |
|
2134 } |
|
2135 else |
|
2136 { |
|
2137 TRAPD(err, parser->ParseElementsL(aResult1.Mid(KAttributeListOffset, attributeListLength))); |
|
2138 ret = err; |
|
2139 } |
|
2140 |
|
2141 if((ret==KErrNone)&&(iTestNum == 7)) |
|
2142 { |
|
2143 // We need to parse the second buffer as well. |
|
2144 // |
|
2145 if(byteCount2!= 0) |
|
2146 { |
|
2147 iNeedAttributeId = ETrue; |
|
2148 TRAPD(err,ret=parser->ParseElementsL(aResult2.Mid(KAttributeListOffset))); |
|
2149 if (err) |
|
2150 { |
|
2151 ret = err; |
|
2152 } |
|
2153 } |
|
2154 } |
|
2155 if(iTestNum>=KSdpBrowseTest) |
|
2156 { |
|
2157 delete (CBrowseResponseBuilder*)builder; |
|
2158 builder = 0; |
|
2159 } |
|
2160 CleanupStack::PopAndDestroy(parser); |
|
2161 parser = 0; |
|
2162 } |
|
2163 } |
|
2164 else |
|
2165 { |
|
2166 // What's left should be invalid behaviour tests |
|
2167 // ie. the SDP_ErrorResponse PDU |
|
2168 if(aResult1[0] == 0x01) |
|
2169 { |
|
2170 // This is an error response. |
|
2171 // Check the error code. It must either be |
|
2172 // an invalid size, invalid syntax or invalid record handle. |
|
2173 // |
|
2174 TInt16 errorCode = BigEndian::Get16(&aResult1[KErrorCodeOffset]); |
|
2175 if(((errorCode==EInvalidServiceRecordHandle) && (iTestNum==26)) |
|
2176 ||((errorCode==EInvalidPduSize) && (iTestNum==28)) |
|
2177 ||((errorCode==EInvalidRequestSyntax) && (iTestNum==27))) |
|
2178 { |
|
2179 ret = KErrNone; |
|
2180 } |
|
2181 // Otherwise, wrong response. |
|
2182 } |
|
2183 } |
|
2184 return ret; |
|
2185 } |
|
2186 |
|
2187 |
|
2188 void CSdpVerificationTests::SetUpServiceTestParams() |
|
2189 /* |
|
2190 THE BIG SETUP..... |
|
2191 */ |
|
2192 { |
|
2193 // Fill up the service test structure (see SetUpAttributeParams() for desription) |
|
2194 /* TUint8 validDes[3]; |
|
2195 validDes[0] = 0x35; |
|
2196 validDes[1] = 0x03; |
|
2197 validDes[2] = 0x19; |
|
2198 */ |
|
2199 TUint8 invalidDes[3]; |
|
2200 invalidDes[0] = 0x35; |
|
2201 invalidDes[1] = 0x03; |
|
2202 invalidDes[2] = 0x09; |
|
2203 |
|
2204 // TEST 0 - Dial up networking should return the first handle |
|
2205 iServiceTests[0] = TServiceRequest((TUint16)KDialUpNetworkingUUID, EUuid16, (TUint16)3); |
|
2206 |
|
2207 // TEST 1 - Search for 2 services (use test1 as well), should return the first 2 handles |
|
2208 iServiceTests[1] = TServiceRequest((TUint16)KFaxUUID, EUuid16, (TUint16)3); |
|
2209 |
|
2210 // TEST 2 - Search for Headset UUID can return any of the registered records. The max record |
|
2211 // handles param is large so that continuation occurs |
|
2212 iServiceTests[2] = TServiceRequest((TUint16)0x1108, EUuid16, (TUint16)200); |
|
2213 |
|
2214 // TEST 3 - SPP profile UUID has not been registered so should return with no records |
|
2215 iServiceTests[3] = TServiceRequest((TUint16)KNonExistantUUID, EUuid16, (TUint16)1); |
|
2216 |
|
2217 // TEST 4 - UUID doesn't matter as size will be invalid. |
|
2218 iServiceTests[4] = TServiceRequest((TUint16)0x1101, EUuid16, (TUint16)1); |
|
2219 |
|
2220 // TEST 5 - UUID doesn't matter as des will be invalid. |
|
2221 iServiceTests[5] = TServiceRequest(invalidDes, (TUint16)0x1101, EUuid16, (TUint16)1); |
|
2222 |
|
2223 for(TInt i=KNumSDPServiceTests; i<25; i++) |
|
2224 { |
|
2225 iServiceTests[i] = TServiceRequest((TUint16)KDialUpNetworkingUUID, EUuid16, (TUint16)2); |
|
2226 } |
|
2227 |
|
2228 // This one needs to return the second record handle |
|
2229 iServiceTests[25] = TServiceRequest((TUint16)KFaxUUID, EUuid16, (TUint16)2); |
|
2230 iServiceTests[26] = TServiceRequest((TUint16)KDialUpNetworkingUUID, EUuid16, (TUint16)2); |
|
2231 iServiceTests[27] = TServiceRequest((TUint16)KDialUpNetworkingUUID, EUuid16, (TUint16)2); |
|
2232 } |
|
2233 |
|
2234 void CSdpVerificationTests::SetUpAttributeTestParams() |
|
2235 { |
|
2236 // Fill in the attribute request params. |
|
2237 TUint8 validDes[3]; |
|
2238 validDes[0] = 0x35; // Type = 6(DES), Size = 5(size is contained in next 8 bits). |
|
2239 validDes[1] = 0x03; // This is the next 8 bits: size = 3 |
|
2240 validDes[2] = 0x09; // Type = 1 (Unsigned int), size = 1 (2Bytes). |
|
2241 |
|
2242 TUint8 invalidDes[3]; |
|
2243 invalidDes[0] = 0x35;// Type = 6(DES), Size = 5(size is ontained in next 8 bits). |
|
2244 invalidDes[1] = 0x03;// This is the next 8 bits: size = 3 |
|
2245 invalidDes[2] = 0x19;// Type = 3 (UUID), size = 1 (2Bytes). |
|
2246 |
|
2247 // TEST 6 - Service for an existing attribute (0x0005) in the first record. |
|
2248 // |
|
2249 iAttributeTests[0]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdBrowseGroupList); |
|
2250 |
|
2251 // TEST 7 - Search for 2 attributes, see test 7 and also 0x0003 Service Id |
|
2252 iAttributeTests[1]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdServiceID); |
|
2253 |
|
2254 // TEST 8 - Like test 1 but using continuation state (search for a very long URL). |
|
2255 iAttributeTests[2]=TAttributeRequest(KSdpMinServRecordHandle + 1, 200, validDes, KSdpAttrIdDocumentationURL); |
|
2256 |
|
2257 // TEST 9 - Service ID |
|
2258 iAttributeTests[3]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdServiceID); |
|
2259 |
|
2260 // TEST 10 - Protocol descriptor list |
|
2261 iAttributeTests[4]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdProtocolDescriptorList); |
|
2262 |
|
2263 // TEST 11 - Service record state |
|
2264 iAttributeTests[5]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdServiceRecordState); |
|
2265 |
|
2266 // TEST 12 - ServiceInfoTimetoLive |
|
2267 iAttributeTests[6]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdServiceInfoTimeToLive); |
|
2268 |
|
2269 // TEST 13 - BrowseGroupList |
|
2270 iAttributeTests[7]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdBrowseGroupList); |
|
2271 |
|
2272 // TEST 14 - LanguageBaseAttributeId |
|
2273 iAttributeTests[8]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdLanguageBaseAttributeIDList); |
|
2274 |
|
2275 // TEST 15 - ServiceAvailability |
|
2276 iAttributeTests[9]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdServiceAvailability); |
|
2277 |
|
2278 // TEST 16 - IconURL |
|
2279 iAttributeTests[10]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdIconURL); |
|
2280 |
|
2281 // TEST 17 - ServiceName (offset from LanguageBaseAttributeIDList). |
|
2282 iAttributeTests[11]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, (TUint16)(KSdpAttrIdBasePrimaryLanguage+KSdpAttrIdOffsetServiceName)); |
|
2283 |
|
2284 // TEST 18 - Service Description |
|
2285 iAttributeTests[12]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, (TUint16)(KSdpAttrIdBasePrimaryLanguage+KSdpAttrIdOffsetServiceDescription)); |
|
2286 |
|
2287 // TEST 19 - ProviderName |
|
2288 iAttributeTests[13]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, (TUint16)(KSdpAttrIdBasePrimaryLanguage+KSdpAttrIdOffsetProviderName)); |
|
2289 |
|
2290 // TEST 20 - Version number list |
|
2291 iAttributeTests[14]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdSdpServerVersionNumberList); |
|
2292 |
|
2293 // TEST 21 - Service Database State |
|
2294 iAttributeTests[15]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdSdpServerServiceDatabaseState); |
|
2295 |
|
2296 // TEST 22 - Bluetooth Profile DescriptorList |
|
2297 iAttributeTests[16]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdBluetoothProfileDescriptorList); |
|
2298 |
|
2299 // TEST 23 - Documentation URL |
|
2300 iAttributeTests[17]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdDocumentationURL); |
|
2301 |
|
2302 // TEST 24 - Client Executable URL |
|
2303 iAttributeTests[18]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdClientExecutableURL); |
|
2304 |
|
2305 // TEST 25 - Non-existing attribute |
|
2306 iAttributeTests[19]=TAttributeRequest(KSdpMinServRecordHandle+1, 200, validDes, KSdpAttrIdServiceRecordState); |
|
2307 |
|
2308 //TEST 26 - Invalid service record handle |
|
2309 iAttributeTests[20]=TAttributeRequest(KSdpMinServRecordHandle-1, 200, validDes, KSdpAttrIdServiceRecordState); |
|
2310 |
|
2311 // TEST 27 - invalid syntax |
|
2312 iAttributeTests[21]=TAttributeRequest(KSdpMinServRecordHandle, 200, invalidDes, KSdpAttrIdServiceClassIDList); |
|
2313 |
|
2314 // TEST 28 - invalid PDU size |
|
2315 iAttributeTests[22]=TAttributeRequest(KSdpMinServRecordHandle, 200, validDes, KSdpAttrIdServiceClassIDList); |
|
2316 |
|
2317 } |
|
2318 |
|
2319 |
|
2320 void CSdpVerificationTests::SetUpServiceAttributeTestParams() |
|
2321 { |
|
2322 // see SetUpAttributeParams() for desription |
|
2323 TUint8 validServiceDes[] = {0x35, 0x03, 0x19}; |
|
2324 TUint8 validAttributeDes[3]; |
|
2325 |
|
2326 /* |
|
2327 TUint8 validUUID128[16]; |
|
2328 validUUID128[0] = 0x0; |
|
2329 validUUID128[1] = 0x0; |
|
2330 validUUID128[2] = 0x0; |
|
2331 validUUID128[3] = 0x0; |
|
2332 //Bluetooth_Base_UUID |
|
2333 validUUID128[4] = 0x00; |
|
2334 validUUID128[5] = 0x00; |
|
2335 validUUID128[6] = 0x10; |
|
2336 validUUID128[7] = 0x00; |
|
2337 validUUID128[8] = 0x80; |
|
2338 validUUID128[9] = 0x00; |
|
2339 validUUID128[10] = 0x00; |
|
2340 validUUID128[11] = 0x80; |
|
2341 validUUID128[12] = 0x5f; |
|
2342 validUUID128[13] = 0x9b; |
|
2343 validUUID128[14] = 0x34; |
|
2344 validUUID128[15] = 0xfb; |
|
2345 */ |
|
2346 |
|
2347 validAttributeDes[0] = 0x35; |
|
2348 validAttributeDes[1] = 0x03; |
|
2349 validAttributeDes[2] = 0x09; |
|
2350 |
|
2351 // TEST 29 - non-existing service (SPP), existing attribute. |
|
2352 iServiceAttributeTests[0]=TServiceAttributeRequest((TUint16)0x1101, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceClassIDList ); |
|
2353 |
|
2354 // TEST 30 - existing service, non-existing attribute |
|
2355 iServiceAttributeTests[1]=TServiceAttributeRequest((TUint16)KFaxUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceRecordState); |
|
2356 |
|
2357 // TEST 31 - non-existing service, non-existing attribute |
|
2358 iServiceAttributeTests[2]=TServiceAttributeRequest((TUint16)0x1101, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceRecordState) ; |
|
2359 |
|
2360 // TEST 32 - existing service and attribute |
|
2361 iServiceAttributeTests[3]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdBrowseGroupList ); |
|
2362 |
|
2363 // TEST 33 - two searches for existing services and attibutes (see test 33 as well). |
|
2364 iServiceAttributeTests[4]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceID ); |
|
2365 |
|
2366 // TEST 34 - continuation UUID16 |
|
2367 #ifdef SEVEN_LAYERS_BUG |
|
2368 iServiceAttributeTests[5]=TServiceAttributeRequest( |
|
2369 (TUint16)KPublicBrowseGroupUUID, |
|
2370 EUuid16, |
|
2371 0xffff,//0x1e,//0x30,//KMaxAttributeListByteCount, |
|
2372 KSdpAttrIdServiceClassIDList);//(TUint32)0x0001); |
|
2373 #else |
|
2374 iServiceAttributeTests[5]=TServiceAttributeRequest( |
|
2375 //(TUint16)KPublicBrowseGroupUUID, |
|
2376 0x1101, |
|
2377 EUuid16, |
|
2378 0x30,//KMaxAttributeListByteCount, |
|
2379 (TUint32)KSdpAttributeBigRange); |
|
2380 #endif |
|
2381 // TEST 35 - service record state |
|
2382 iServiceAttributeTests[6]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceRecordState); |
|
2383 |
|
2384 // Test 36 - Service database state |
|
2385 iServiceAttributeTests[7]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdSdpServerServiceDatabaseState); |
|
2386 |
|
2387 // TEST 37 - service info time to live |
|
2388 iServiceAttributeTests[8]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceInfoTimeToLive); |
|
2389 |
|
2390 // TEST 38 - Service Id |
|
2391 iServiceAttributeTests[9]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceID); |
|
2392 |
|
2393 // TEST 39 - Protocol descriptor list |
|
2394 iServiceAttributeTests[10]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdProtocolDescriptorList); |
|
2395 |
|
2396 // TEST 40 - Browse group list |
|
2397 iServiceAttributeTests[11]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdBrowseGroupList); |
|
2398 |
|
2399 // TEST 41 - Language base attribute id |
|
2400 iServiceAttributeTests[12]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdLanguageBaseAttributeIDList); |
|
2401 |
|
2402 // TEST 42 - Service availability - |
|
2403 iServiceAttributeTests[13]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceAvailability); |
|
2404 |
|
2405 // TEST 43 - Icon URL |
|
2406 iServiceAttributeTests[14]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdIconURL); |
|
2407 |
|
2408 // TEST 44 - Service Name |
|
2409 iServiceAttributeTests[15]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, (TUint16)(KSdpAttrIdBasePrimaryLanguage+KSdpAttrIdOffsetServiceName)); |
|
2410 |
|
2411 // TEST 45 - Service description |
|
2412 iServiceAttributeTests[16]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, (TUint16)(KSdpAttrIdBasePrimaryLanguage+KSdpAttrIdOffsetServiceDescription)); |
|
2413 |
|
2414 // TEST 46 - Provider name |
|
2415 iServiceAttributeTests[17]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, (TUint16)(KSdpAttrIdBasePrimaryLanguage+KSdpAttrIdOffsetProviderName)); |
|
2416 |
|
2417 // TEST 47 - version number list |
|
2418 iServiceAttributeTests[18]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdSdpServerVersionNumberList); |
|
2419 |
|
2420 // TEST 48 - Bluetooth profile descriptor list |
|
2421 iServiceAttributeTests[19]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdBluetoothProfileDescriptorList); |
|
2422 |
|
2423 // TEST 49 - Documentation URL |
|
2424 iServiceAttributeTests[20]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdDocumentationURL); |
|
2425 |
|
2426 // TEST 50 - Client executable URL |
|
2427 iServiceAttributeTests[21]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdClientExecutableURL); |
|
2428 |
|
2429 // TEST 51 - invalid request syntax (swap round the des values). |
|
2430 iServiceAttributeTests[22]=TServiceAttributeRequest(validAttributeDes, (TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, validServiceDes, KSdpAttrIdClientExecutableURL); |
|
2431 |
|
2432 // TEST 52 - invalid PDU size |
|
2433 iServiceAttributeTests[23]=TServiceAttributeRequest((TUint16)KDialUpNetworkingUUID, EUuid16, KMaxAttributeListByteCount, KSdpAttrIdServiceClassIDList); |
|
2434 |
|
2435 } |
|
2436 |
|
2437 TBool CSdpVerificationTests::AnotherQuery() |
|
2438 { |
|
2439 if((iTestNum==1)||(iTestNum==7)||(iTestNum==33)) |
|
2440 { |
|
2441 return ETrue; |
|
2442 } |
|
2443 return EFalse; |
|
2444 } |
|
2445 |
|
2446 TBool CSdpVerificationTests::Continue() |
|
2447 { |
|
2448 TBool ret = EFalse; |
|
2449 if(iType==EServiceRequest) |
|
2450 { |
|
2451 ret = EFalse; |
|
2452 } |
|
2453 else if((iType==EServiceAttributeRequest)&&(iQueryState!=EServiceAttributeRequest)) |
|
2454 { |
|
2455 iQueryState = EServiceAttributeRequest; |
|
2456 ret = ETrue; |
|
2457 } |
|
2458 return ret; |
|
2459 } |
|
2460 |
|
2461 TInt CSdpVerificationTests::GetUuidSize() |
|
2462 { |
|
2463 switch(iUuidType) |
|
2464 { |
|
2465 case CSdpTestBase::EUuid16: |
|
2466 return 16; |
|
2467 case CSdpTestBase::EUuid32: |
|
2468 return 32; |
|
2469 case CSdpTestBase::EUuid128: |
|
2470 return 128; |
|
2471 default: |
|
2472 return 0; |
|
2473 } |
|
2474 } |
|
2475 |
|
2476 void CSdpVerificationTests::UpdateTestString() |
|
2477 { |
|
2478 TInt uuidsize = GetUuidSize(); |
|
2479 TBuf<4> uuidBuf; |
|
2480 uuidBuf.SetLength(0); |
|
2481 switch(uuidsize) |
|
2482 { |
|
2483 case 16: |
|
2484 uuidBuf.Append('1'); |
|
2485 uuidBuf.Append('6'); |
|
2486 break; |
|
2487 case 32: |
|
2488 uuidBuf.Append('3'); |
|
2489 uuidBuf.Append('2'); |
|
2490 break; |
|
2491 case 128: |
|
2492 uuidBuf.Append('1'); |
|
2493 uuidBuf.Append('2'); |
|
2494 uuidBuf.Append('8'); |
|
2495 break; |
|
2496 default: |
|
2497 break; |
|
2498 } |
|
2499 TChar ch = 'V'; |
|
2500 TInt num = 0; |
|
2501 iTestName.SetLength(0); |
|
2502 if(/*iTestNum>=KServiceRequestTest&&*/iTestNum<KServiceAttributeRequestTest) |
|
2503 { |
|
2504 num = iTestNum - KServiceRequestTest + 1; |
|
2505 if(iTestNum>=KServiceRequestBITest) |
|
2506 { |
|
2507 ch = 'I'; |
|
2508 num = iTestNum - KServiceRequestBITest + 1; |
|
2509 } |
|
2510 iTestName.Append(_L("TC_SERVER_SS_UUID")); |
|
2511 iTestName.AppendNum(uuidsize); |
|
2512 iTestName.Append(_L("_B")); |
|
2513 } |
|
2514 else if(iTestNum>=KServiceAttributeRequestTest&&iTestNum<KServiceSearchAttributeRequestTest) |
|
2515 { |
|
2516 num = iTestNum - KServiceAttributeRequestTest + 1; |
|
2517 if(iTestNum>=KServiceAttributeRequestBITest) |
|
2518 { |
|
2519 ch = 'I'; |
|
2520 num = iTestNum - KServiceAttributeRequestBITest + 1; |
|
2521 } |
|
2522 iTestName.Append(_L("TC_SERVER_SA_B")); |
|
2523 } |
|
2524 else if(iTestNum>=KServiceSearchAttributeRequestTest && iTestNum<KSdpBrowseTest) |
|
2525 { |
|
2526 num = iTestNum - KServiceSearchAttributeRequestTest + 1; |
|
2527 if(iTestNum>=KServiceSearchAttributeRequestBITest) |
|
2528 { |
|
2529 ch = 'I'; |
|
2530 num = iTestNum - KServiceSearchAttributeRequestBITest + 1; |
|
2531 } |
|
2532 iTestName.Append(_L("TC_SERVER_SSA_UUID")); |
|
2533 iTestName.AppendNum(uuidsize); |
|
2534 iTestName.Append(_L("_B")); |
|
2535 } |
|
2536 else if(iTestNum>=KSdpBrowseTest && iTestNum<=KSdpLastTest) |
|
2537 { |
|
2538 num = iTestNum - KSdpBrowseTest + 1; |
|
2539 iTestName.Append(_L("TC_SERVER_BRW_UUID")); |
|
2540 iTestName.AppendNum(uuidsize); |
|
2541 iTestName.Append(_L("_B")); |
|
2542 } |
|
2543 else |
|
2544 { |
|
2545 ; //print nothing |
|
2546 } |
|
2547 iTestName.Append(ch); |
|
2548 iTestName.Append('_'); |
|
2549 if(num<10) |
|
2550 iTestName.Append('0'); |
|
2551 iTestName.AppendNum(num); |
|
2552 iTestName.Append(_L("_C")); |
|
2553 } |
|
2554 |
|
2555 void CSdpVerificationTests::FlogTestId() |
|
2556 { |
|
2557 UpdateTestString(); |
|
2558 FTRACE(FPrint(_L(""))); |
|
2559 FTRACE(FPrint(_L("%S: "), &iTestName)); |
|
2560 } |
|
2561 |
|
2562 #ifdef __FLOGGING__ |
|
2563 void CSdpVerificationTests::FlogString(const TText* aLineStart, TDesC8& aString) |
|
2564 { |
|
2565 TInt len = aString.Length(); |
|
2566 TInt i = 0; |
|
2567 while(len-i>=6) |
|
2568 { |
|
2569 RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, aLineStart, 0, aString.Mid(i, 6).Ptr(), 6); |
|
2570 i+=6; |
|
2571 } |
|
2572 if(len-i>=0) |
|
2573 { |
|
2574 RFileLogger::HexDump(KLogDir, KLogFile, EFileLoggingModeAppend, aLineStart, 0, aString.Mid(i, len-i).Ptr(), len-i); |
|
2575 } |
|
2576 } |
|
2577 #else |
|
2578 void CSdpVerificationTests::FlogString(const TText* /*aLineStart*/, TDesC8& /*aString*/) |
|
2579 { |
|
2580 } |
|
2581 #endif |
|
2582 |
|
2583 |
|
2584 TInt CSdpVerificationTests::MaxCountFoundAfterServiceSearchPatternOrWhatYouWill(TDesC8& aString) |
|
2585 { |
|
2586 TInt ret = -1; |
|
2587 TUint32 pos = 0; |
|
2588 if(aString.Length()<7) |
|
2589 return ret; |
|
2590 TInt listType = aString[5]; |
|
2591 switch(listType) |
|
2592 { |
|
2593 case 0x35: |
|
2594 if(aString.Length()<7) |
|
2595 return ret; |
|
2596 pos += 7+aString[6]; |
|
2597 break; |
|
2598 case 0x36: |
|
2599 if(aString.Length()<8) |
|
2600 return ret; |
|
2601 pos += 8+aString[7]+256*aString[6]; |
|
2602 break; |
|
2603 case 0x37: |
|
2604 if(aString.Length()<10) |
|
2605 return ret; |
|
2606 pos += 10+aString[9]+256*aString[8]+256*256*aString[7]+256*256*256*aString[6]; |
|
2607 break; |
|
2608 default: |
|
2609 return ret; |
|
2610 } |
|
2611 ret = aString[pos+1]+256*aString[pos]; |
|
2612 return ret; |
|
2613 } |
|
2614 |
|
2615 void CSdpVerificationTests::FlogParsedPDUHeader(TDesC8& aString) |
|
2616 { |
|
2617 TInt id = aString[2]+256*aString[1]; |
|
2618 FTRACE(FPrint(_L("SDP_Transaction Id: 0x%02x"), id)); |
|
2619 switch(aString[0]) |
|
2620 { |
|
2621 case 1: |
|
2622 if(iRequestTransId != id) |
|
2623 { |
|
2624 FTRACE(FPrint(_L("Request and Error Response Transaction Ids DO NOT MATCH: 0x%02x != 0x%02x ... Error code still printed below"), id, iRequestTransId)); |
|
2625 } |
|
2626 if(aString.Length()>=7) |
|
2627 { |
|
2628 TInt errorCode = aString[6]+256*aString[5]; |
|
2629 switch(errorCode) |
|
2630 { |
|
2631 case 1: |
|
2632 FTRACE(FPrint(_L("SDP_ErrorResponse - Invalid/Unsupported SDP version"))); |
|
2633 break; |
|
2634 case 2: |
|
2635 FTRACE(FPrint(_L("SDP_ErrorResponse - Invalid Srvice Record Handle"))); |
|
2636 break; |
|
2637 case 3: |
|
2638 FTRACE(FPrint(_L("SDP_ErrorResponse - Invalid request syntax"))); |
|
2639 break; |
|
2640 case 4: |
|
2641 FTRACE(FPrint(_L("SDP_ErrorResponse - Invalid PDU Size"))); |
|
2642 break; |
|
2643 case 5: |
|
2644 FTRACE(FPrint(_L("SDP_ErrorResponse - Invalid Continuation State"))); |
|
2645 break; |
|
2646 case 6: |
|
2647 FTRACE(FPrint(_L("SDP_ErrorResponse - Insufficient Resources to satisfy Request"))); |
|
2648 break; |
|
2649 default: |
|
2650 FTRACE(FPrint(_L("SDP_ErrorResponse - Reserved Value 0x%04x"), errorCode)); |
|
2651 break; |
|
2652 } |
|
2653 } |
|
2654 else |
|
2655 { |
|
2656 FTRACE(FPrint(_L("SDP_ErrorResponse sent without parameters!"))); |
|
2657 User::Leave(KErrGeneral); //Qualified |
|
2658 } |
|
2659 if(iRequestTransId != id) |
|
2660 { |
|
2661 User::Leave(KErrGeneral); //Qualified |
|
2662 } |
|
2663 break; |
|
2664 case 2: |
|
2665 { |
|
2666 FTRACE(FPrint(_L("SDP_ServiceSearchRequest"))); |
|
2667 iRequestTransId2 = iRequestTransId1; |
|
2668 iRequestMaxCount2 = iRequestMaxCount1; |
|
2669 iRequestTransId1 = id; |
|
2670 iRequestMaxCount1 = MaxCountFoundAfterServiceSearchPatternOrWhatYouWill(aString); |
|
2671 if(iTestNum==1) |
|
2672 { |
|
2673 iRequestTransId = iRequestTransId2; |
|
2674 iRequestMaxCount = iRequestMaxCount2; |
|
2675 } |
|
2676 else |
|
2677 { |
|
2678 iRequestTransId = iRequestTransId1; |
|
2679 iRequestMaxCount = iRequestMaxCount1; |
|
2680 } |
|
2681 if(iRequestMaxCount1>=0) |
|
2682 { |
|
2683 FTRACE(FPrint(_L(" MaximumServiceRecordCount = 0x%04x"), iRequestMaxCount1)); |
|
2684 } |
|
2685 else |
|
2686 { |
|
2687 FTRACE(FPrint(_L(" .....sent without parameters!"))); |
|
2688 User::Leave(KErrGeneral); |
|
2689 } |
|
2690 } |
|
2691 break; |
|
2692 case 3: |
|
2693 { |
|
2694 FTRACE(FPrint(_L("SDP_ServiceSearchResponse"))); |
|
2695 if(iRequestTransId != id) |
|
2696 { |
|
2697 FTRACE(FPrint(_L("Request and Response Transaction Ids DO NOT MATCH: 0x%02x != 0x%02x ... ERROR!!!!!!!!"), id, iRequestTransId)); |
|
2698 //break; |
|
2699 } |
|
2700 if(aString.Length()>=9) |
|
2701 { |
|
2702 TInt total = aString[6]+256*aString[5]; |
|
2703 TInt current = aString[8]+256*aString[7]; |
|
2704 FTRACE(FPrint(_L(" TotalServiceRecordCount = 0x%04x, CurrentRecordCount = 0x%04x "), total, current)); |
|
2705 if(iRequestTransId == id) |
|
2706 { |
|
2707 if(iRequestMaxCount>=total&&total>=current) |
|
2708 { |
|
2709 FTRACE(FPrint(_L(" So: requested MaximumServiceRecordCount 0x%04x >= TotalServiceRecordCount, 0x%04x >= CurrentRecordCount, 0x%04x "), iRequestMaxCount, total, current)); |
|
2710 } |
|
2711 else |
|
2712 { |
|
2713 FTRACE(FPrint(_L(" ERROR!!!! the following is NOT true: requested MaximumServiceRecordCount 0x%04x >= TotalServiceRecordCount, 0x%04x >= CurrentRecordCount, 0x%04x "), iRequestMaxCount, total, current)); |
|
2714 User::Leave(KErrGeneral); //Qualified |
|
2715 } |
|
2716 } |
|
2717 } |
|
2718 else |
|
2719 { |
|
2720 FTRACE(FPrint(_L(" .....sent without parameters!"))); |
|
2721 User::Leave(KErrGeneral); //Qualified |
|
2722 } |
|
2723 } |
|
2724 if(iRequestTransId != id) |
|
2725 { |
|
2726 User::Leave(KErrGeneral); //Qualified |
|
2727 } |
|
2728 if(iTestNum==1) |
|
2729 //Prepare for next response when we'll be looking |
|
2730 //at the LAST request's values. |
|
2731 { |
|
2732 iRequestTransId = iRequestTransId1; |
|
2733 iRequestMaxCount = iRequestMaxCount1; |
|
2734 } |
|
2735 break; |
|
2736 case 4: |
|
2737 { |
|
2738 iRequestTransId2 = iRequestTransId1; |
|
2739 iRequestMaxCount2 = iRequestMaxCount1; |
|
2740 iRequestTransId1 = id; |
|
2741 FTRACE(FPrint(_L("SDP_ServiceAttributeRequest"))); |
|
2742 if(aString.Length()>=11) |
|
2743 { |
|
2744 TInt handle = aString[8]+256*aString[7]+256*256*aString[6]+256*256*256*aString[5]; |
|
2745 iRequestMaxCount1 = aString[10]+256*aString[9]; |
|
2746 FTRACE(FPrint(_L(" Record Handle = 0x%08x, MaximumAttributByteCount = 0x%04x"), handle, iRequestMaxCount1)); |
|
2747 if(iTestNum==7) |
|
2748 { |
|
2749 iRequestTransId = iRequestTransId2; |
|
2750 iRequestMaxCount = iRequestMaxCount2; |
|
2751 } |
|
2752 else |
|
2753 { |
|
2754 iRequestTransId = iRequestTransId1; |
|
2755 iRequestMaxCount = iRequestMaxCount1; |
|
2756 } |
|
2757 } |
|
2758 else |
|
2759 { |
|
2760 FTRACE(FPrint(_L(" ....sent without parameters!"))); |
|
2761 User::Leave(KErrGeneral); //Qualified |
|
2762 } |
|
2763 } |
|
2764 break; |
|
2765 case 5: |
|
2766 { |
|
2767 FTRACE(FPrint(_L("SDP_ServiceAttributeResponse"))); |
|
2768 if(iRequestTransId != id) |
|
2769 { |
|
2770 FTRACE(FPrint(_L("Request and Response Transaction Ids DO NOT MATCH: 0x%02x != 0x%02x ... ERROR!!!!!!!!"), id, iRequestTransId)); |
|
2771 //break; |
|
2772 } |
|
2773 if(aString.Length()>=7) |
|
2774 { |
|
2775 TInt count = aString[6]+256*aString[5]; |
|
2776 if(iRequestTransId != id) |
|
2777 { |
|
2778 FTRACE(FPrint(_L(" AttributeListByteCount = 0x%04x"), count)); |
|
2779 } |
|
2780 else |
|
2781 { |
|
2782 if(count <= iRequestMaxCount) |
|
2783 { |
|
2784 FTRACE(FPrint(_L(" AttributeListsByteCount = 0x%04x (<= requested MaxiumumAttributeByteCount, 0x%04x"), count, iRequestMaxCount)); |
|
2785 } |
|
2786 else |
|
2787 { |
|
2788 FTRACE(FPrint(_L(" ERROR!!!!! AttributeListsByteCount = 0x%04x > requested MaxiumumAttributeByteCount, 0x%04x"), count, iRequestMaxCount)); |
|
2789 User::Leave(KErrGeneral); //Qualified |
|
2790 } |
|
2791 } |
|
2792 } |
|
2793 else |
|
2794 { |
|
2795 FTRACE(FPrint(_L(" ....sent without parameters!"))); |
|
2796 User::Leave(KErrGeneral); //Qualified |
|
2797 } |
|
2798 } |
|
2799 if(iRequestTransId != id) |
|
2800 { |
|
2801 User::Leave(KErrGeneral); //Qualified |
|
2802 } |
|
2803 if(iTestNum==7) |
|
2804 //Prepare for next response when we'll be looking |
|
2805 //at the LAST request's values. |
|
2806 { |
|
2807 iRequestTransId = iRequestTransId1; |
|
2808 iRequestMaxCount = iRequestMaxCount1; |
|
2809 } |
|
2810 break; |
|
2811 case 6: |
|
2812 { |
|
2813 FTRACE(FPrint(_L("SDP_ServiceSearchAttributeRequest"))); |
|
2814 FTRACE(FPrint(_L("SDP_ServiceSearchRequest"))); |
|
2815 iRequestTransId2 = iRequestTransId1; |
|
2816 iRequestMaxCount2 = iRequestMaxCount1; |
|
2817 iRequestTransId1 = id; |
|
2818 iRequestMaxCount1 = MaxCountFoundAfterServiceSearchPatternOrWhatYouWill(aString); |
|
2819 if(iTestNum==33) |
|
2820 { |
|
2821 iRequestTransId = iRequestTransId2; |
|
2822 iRequestMaxCount = iRequestMaxCount2; |
|
2823 } |
|
2824 else |
|
2825 { |
|
2826 iRequestTransId = iRequestTransId1; |
|
2827 iRequestMaxCount = iRequestMaxCount1; |
|
2828 } |
|
2829 if(iRequestMaxCount1>=0) |
|
2830 { |
|
2831 FTRACE(FPrint(_L(" MaximumAttributeByteCount = 0x%04x"), iRequestMaxCount1)); |
|
2832 } |
|
2833 else |
|
2834 { |
|
2835 FTRACE(FPrint(_L(" .....sent without parameters!"))); |
|
2836 User::Leave(KErrGeneral); //Qualified |
|
2837 } |
|
2838 } |
|
2839 break; |
|
2840 case 7: |
|
2841 { |
|
2842 FTRACE(FPrint(_L("SDP_ServiceSearchAttributeResponse"))); |
|
2843 if(iRequestTransId != id) |
|
2844 { |
|
2845 FTRACE(FPrint(_L("Request and Response Transaction Ids DO NOT MATCH: 0x%02x != 0x%02x ... ERROR!!!!!!!!"), id, iRequestTransId)); |
|
2846 //break; |
|
2847 } |
|
2848 if(aString.Length()>=7) |
|
2849 { |
|
2850 TInt count = aString[6]+256*aString[5]; |
|
2851 if(iRequestTransId != id) |
|
2852 { |
|
2853 FTRACE(FPrint(_L(" AttributeListByteCount = 0x%04x"), count)); |
|
2854 } |
|
2855 else |
|
2856 { |
|
2857 if(count <= iRequestMaxCount) |
|
2858 { |
|
2859 FTRACE(FPrint(_L(" AttributeListsByteCount = 0x%04x (<= requested MaxiumumAttributeByteCount, 0x%04x"), count, iRequestMaxCount)); |
|
2860 } |
|
2861 else |
|
2862 { |
|
2863 FTRACE(FPrint(_L(" ERROR!!!!! AttributeListsByteCount = 0x%04x > requested MaxiumumAttributeByteCount, 0x%04x"), count, iRequestMaxCount)); |
|
2864 User::Leave(KErrGeneral); //Qualified |
|
2865 } |
|
2866 } |
|
2867 } |
|
2868 else |
|
2869 { |
|
2870 FTRACE(FPrint(_L(" ....sent without parameters!"))); |
|
2871 User::Leave(KErrGeneral); //Qualified |
|
2872 } |
|
2873 } |
|
2874 if(iRequestTransId != id) |
|
2875 { |
|
2876 User::Leave(KErrGeneral); //Qualified |
|
2877 } |
|
2878 if(iTestNum==33) |
|
2879 //Prepare for next response when we'll be looking |
|
2880 //at the LAST request's values. |
|
2881 { |
|
2882 iRequestTransId = iRequestTransId1; |
|
2883 iRequestMaxCount = iRequestMaxCount1; |
|
2884 } |
|
2885 break; |
|
2886 default: |
|
2887 FTRACE(FPrint(_L("Reserved PDU Id: %02x"), aString[0])); |
|
2888 User::Leave(KErrGeneral); //Qualified |
|
2889 break; |
|
2890 } |
|
2891 } |
|
2892 |
|
2893 void CSdpVerificationTests::FlogReadString(TDesC8& aString) |
|
2894 { |
|
2895 if(!aString.Length()) |
|
2896 return; |
|
2897 FLOG(_L("")); |
|
2898 ; |
|
2899 FlogTestId(); |
|
2900 FlogParsedPDUHeader(aString); |
|
2901 FLOG(_L("Raw data RECEIVED.........")); |
|
2902 TPtrC start(_L(" Bytes READ - ")); |
|
2903 FlogString(&start[0], aString); |
|
2904 FLOG(_L("")); |
|
2905 } |
|
2906 |
|
2907 void CSdpVerificationTests::FlogContinuationString(TDesC8& aString) |
|
2908 { |
|
2909 FLOG(_L("NB....")); |
|
2910 TPtrC start(_L(" Continuation Bytes - ")); |
|
2911 FlogString(&start[0], aString); |
|
2912 } |
|
2913 |
|
2914 void CSdpVerificationTests::FlogWriteString(TDesC8& aString) |
|
2915 { |
|
2916 if(!aString.Length()) |
|
2917 return; |
|
2918 FLOG(_L("")); |
|
2919 FlogTestId(); |
|
2920 FlogParsedPDUHeader(aString); |
|
2921 FLOG(_L("Raw data SENT.........")); |
|
2922 TPtrC start(_L(" Bytes WRITTEN - ")); |
|
2923 FlogString(&start[0], aString); |
|
2924 TBuf8<20> contStr; |
|
2925 contStr.SetLength(0); |
|
2926 contStr.Append(&iContLength, 1); |
|
2927 contStr.Append(iContinuationBuffer, iContLength); |
|
2928 FlogContinuationString(contStr); |
|
2929 FLOG(_L("")); |
|
2930 } |
|
2931 |
|
2932 |
|
2933 |
|
2934 void CSdpVerificationTests::WaitForStartSignalL() |
|
2935 { |
|
2936 // Wait for sync info to be sent |
|
2937 // |
|
2938 } |
|
2939 |
|
2940 void CSdpVerificationTests::SendStartSignalL() |
|
2941 { |
|
2942 // Send sync info |
|
2943 // |
|
2944 } |
|
2945 |
|
2946 void CSdpVerificationTests::PromptedGetch() |
|
2947 { |
|
2948 // For putting stops between tests so user can check results as he goes |
|
2949 // |
|
2950 #ifdef STOPPING_MODE |
|
2951 iConsole.Printf(_L("Press any key.\r\n")); |
|
2952 iConsole.Getch(); |
|
2953 #endif |
|
2954 } |
|
2955 |
|
2956 |
|
2957 |
|
2958 // this is the nearest thing to a real database. |
|
2959 // originally for UPF4, but record 0 removed above. |
|
2960 |
|
2961 CSdpDatabase* CSdpVerificationTests::BuildDbL() |
|
2962 { |
|
2963 //see builddb.cpp for copy of this |
|
2964 return 0; |
|
2965 } |
|
2966 |
|
2967 |
|
2968 void CSdpVerificationTests::PrintDb(CSdpDatabase& aDb, CConsoleBase& aConsole) |
|
2969 { |
|
2970 aConsole.Printf(_L("Printing Database...\n")); |
|
2971 |
|
2972 for(TServRecordIter recIter(aDb.RecordIter()); recIter; recIter++) |
|
2973 {// Iterate thru records in Db |
|
2974 aConsole.Printf(_L("\n...Printing Record 0x%x\n"), (*recIter).Handle()); |
|
2975 for(TServAttrIter attrIter((*recIter).AttributeIter()); attrIter; attrIter++) |
|
2976 {// Iterate thru attributes in record |
|
2977 CAttrPrintVisitor* theVisitor = new CAttrPrintVisitor(aConsole); |
|
2978 (*attrIter).AcceptVisitorL(*theVisitor); //Qualified |
|
2979 delete theVisitor; |
|
2980 } |
|
2981 } |
|
2982 } |
|
2983 |
|
2984 |
|
2985 MSdpElementBuilder* CSdpVerificationTests::BuildUintL(const TDesC8& aUint) |
|
2986 { |
|
2987 if(aUint.Length() != 2) |
|
2988 { |
|
2989 iNeedAttributeId = EFalse; |
|
2990 } |
|
2991 if (iNeedAttributeId) |
|
2992 { |
|
2993 iBuildingList = 0; //reset so only sublists are counted |
|
2994 iNeedAttributeId = EFalse; |
|
2995 // This is the Attribute ID level (the same for SA or SAS request) |
|
2996 // First check the length |
|
2997 // |
|
2998 if(aUint.Length() != 2) |
|
2999 { |
|
3000 User::Leave(KErrGeneral); |
|
3001 } |
|
3002 // Now check the value; |
|
3003 // |
|
3004 TUint16 id = BigEndian::Get16(aUint.Ptr()); |
|
3005 FlogTestId(); |
|
3006 FTRACE(FPrint(_L(" Attribute ID - %d"), id)); |
|
3007 } |
|
3008 else |
|
3009 { |
|
3010 // First, get the correct size integer |
|
3011 // TUint32 uint32 = 0; |
|
3012 TUint16 uint16a = 0; |
|
3013 TUint16 uint16b = 0; |
|
3014 TUint8 uint8 = 0; |
|
3015 if(iBuildingList<=0) |
|
3016 { |
|
3017 iNeedAttributeId = ETrue; |
|
3018 } |
|
3019 if(aUint.Length() == 4) |
|
3020 { |
|
3021 // uint32 = BigEndian::Get32(aUint.Ptr()); |
|
3022 uint16a = BigEndian::Get16(aUint.Ptr()); |
|
3023 TUint8* ptr = CONST_CAST(TUint8 *, aUint.Ptr()); |
|
3024 ptr+=2; |
|
3025 uint16b = BigEndian::Get16(ptr); |
|
3026 FlogTestId(); |
|
3027 FTRACE(FPrint(_L(" Attribute Uint32 Value - 0x%04x%04x"), uint16a, uint16b)); |
|
3028 } |
|
3029 else if(aUint.Length() == 2) |
|
3030 { |
|
3031 uint16a = BigEndian::Get16(aUint.Ptr()); |
|
3032 FlogTestId(); |
|
3033 FTRACE(FPrint(_L(" Attribute Uint16 Value - 0x%x"), uint16a)); |
|
3034 } |
|
3035 else if(aUint.Length() == 1) |
|
3036 { |
|
3037 uint8 = aUint[0]; |
|
3038 FlogTestId(); |
|
3039 FTRACE(FPrint(_L(" Attribute Uint8 Value - 0x%x"), uint8)); |
|
3040 } |
|
3041 else |
|
3042 { |
|
3043 // We don't have 32, 16 or 8 bit Uint |
|
3044 User::Leave(KErrGeneral); |
|
3045 } |
|
3046 |
|
3047 (void)(uint16a != 0); // keep compiler happy by referencing uint16a as an r-value in urel |
|
3048 (void)(uint16b != 0); // keep compiler happy by referencing uint16b as an r-value in urel |
|
3049 (void)(uint8 != 0); // keep compiler happy by referencing uint8 as an r-value in urel |
|
3050 } |
|
3051 return this; |
|
3052 } |
|
3053 |
|
3054 |
|
3055 MSdpElementBuilder* CSdpVerificationTests::BuildUUIDL(const TUUID& aUUID) |
|
3056 { |
|
3057 |
|
3058 TPtrC8 uuid = aUUID.ShortestForm(); |
|
3059 TUint16 bigUuid = BigEndian::Get16(uuid.Ptr()); |
|
3060 FlogTestId(); |
|
3061 FTRACE(FPrint(_L(" Attribute UUID Value - 0x%x"), bigUuid)); |
|
3062 if(iBuildingList<=0) |
|
3063 { |
|
3064 iNeedAttributeId = ETrue; |
|
3065 } |
|
3066 return this; |
|
3067 } |
|
3068 |
|
3069 |
|
3070 MSdpElementBuilder* CSdpVerificationTests::BuildStringL(const TDesC8& aString) |
|
3071 { |
|
3072 if(iBuildingList<=0) |
|
3073 { |
|
3074 iNeedAttributeId = ETrue; |
|
3075 } |
|
3076 FlogTestId(); |
|
3077 FTRACE(FPrint(_L(" Attribute Value String - "))); |
|
3078 for(TInt i = 0; i < aString.Length(); i ++) |
|
3079 { |
|
3080 FTRACE(FPrint(_L(" %c"), aString[i])); |
|
3081 } |
|
3082 return this; |
|
3083 } |
|
3084 |
|
3085 MSdpElementBuilder* CSdpVerificationTests::BuildDESL() |
|
3086 { |
|
3087 return this; |
|
3088 } |
|
3089 |
|
3090 MSdpElementBuilder* CSdpVerificationTests::BuildURLL(const TDesC8& aURL) |
|
3091 { |
|
3092 // TInt ret = KErrNone; |
|
3093 TInt i = 0; |
|
3094 TBuf8<654> urlBuf; |
|
3095 if(iBuildingList<=0) |
|
3096 { |
|
3097 iNeedAttributeId = ETrue; |
|
3098 } |
|
3099 FlogTestId(); |
|
3100 FTRACE(FPrint(_L(" Attribute Value URL - "))); |
|
3101 for(i = 0; i < aURL.Length(); i ++) |
|
3102 { |
|
3103 FTRACE(FPrint(_L(" %c"), aURL[i])); |
|
3104 } |
|
3105 |
|
3106 switch(iTestNum) |
|
3107 { |
|
3108 case 8: |
|
3109 case 34: |
|
3110 case 35: |
|
3111 case 36: |
|
3112 // This should be part of a very long URL. Append it to the buffer until continuation has finished |
|
3113 // Set up a string to compare it to. |
|
3114 // |
|
3115 urlBuf.Append(_L8("http://")); |
|
3116 for(i = 0; i < 160; i ++) |
|
3117 { |
|
3118 urlBuf.Append(_L8("url/")); |
|
3119 } |
|
3120 urlBuf.Append(_L8("url.doc")); |
|
3121 (void) aURL.Compare(urlBuf); |
|
3122 |
|
3123 // Reset the continuation buffer |
|
3124 //??iContinuationStore.SetLength(0); |
|
3125 break; |
|
3126 default: |
|
3127 break; |
|
3128 } |
|
3129 return this; |
|
3130 } |
|
3131 |
|
3132 MSdpElementBuilder* CSdpVerificationTests::StartListL() |
|
3133 { |
|
3134 FlogTestId(); |
|
3135 FTRACE(FPrint(_L(" New List (DES)"))); |
|
3136 iBuildingList++; |
|
3137 return this; |
|
3138 } |
|
3139 |
|
3140 MSdpElementBuilder* CSdpVerificationTests::EndListL() |
|
3141 { |
|
3142 FlogTestId(); |
|
3143 FTRACE(FPrint(_L(" End Current List"))); |
|
3144 iBuildingList--; |
|
3145 if(iBuildingList<=0) |
|
3146 iNeedAttributeId=ETrue; |
|
3147 return this; |
|
3148 } |
|
3149 |
|
3150 |
|
3151 MSdpElementBuilder* CSdpVerificationTests::BuildNilL() |
|
3152 { |
|
3153 User::Leave(KErrGeneral); |
|
3154 return this; |
|
3155 } |
|
3156 |
|
3157 |
|
3158 |
|
3159 |
|
3160 |
|
3161 |
|
3162 |
|
3163 |
|
3164 |
|
3165 |
|
3166 |
|
3167 void CSdpVerificationTests::BuildBrowseDbL(CConsoleBase& aConsole) |
|
3168 { |
|
3169 // First thing is to get rid of the old one |
|
3170 // |
|
3171 iTheDb = CSdpDatabase::NewL(); |
|
3172 |
|
3173 TBuf8<2> attrId; |
|
3174 TBuf8<4> val; |
|
3175 TBuf8<2> val1; |
|
3176 CSdpServRecord *theRec = CSdpServRecord::NewL(); |
|
3177 // all attribute IDs are BIG ENDian |
|
3178 |
|
3179 // First Record is the Public browse group service. |
|
3180 attrId.FillZ(2); |
|
3181 val.FillZ(4); |
|
3182 val1.FillZ(2); |
|
3183 // Set Attr 0 (Record handle) to 0x00010000 |
|
3184 val[0] = 0x00; |
|
3185 val[1] = 0x01; |
|
3186 val[2] = 0x00; |
|
3187 val[3] = 0x00; |
|
3188 theRec->BuildUintL(attrId)->BuildUintL(val); |
|
3189 |
|
3190 // Set Attr 1 (service class list) to BrowseGroupDescriptor |
|
3191 attrId[0] = 0x00; |
|
3192 attrId[1] = 0x01; |
|
3193 theRec->BuildUintL(attrId)->BuildDESL() |
|
3194 ->StartListL() |
|
3195 ->BuildUUIDL(TUUID(0x1001)) |
|
3196 ->EndListL(); |
|
3197 |
|
3198 // Set Attr 0x005 (browse group list) to public root |
|
3199 attrId[0] = 0x00; |
|
3200 attrId[1] = 0x05; |
|
3201 theRec->BuildUintL(attrId)->BuildDESL() |
|
3202 ->StartListL() |
|
3203 ->BuildUUIDL(TUUID(TUint16(0x1002))) // publicBrowseRoot |
|
3204 ->EndListL(); |
|
3205 |
|
3206 // Set Attr 0x200 (group ID) to 0x1201 (Generic networking). |
|
3207 attrId[0] = 0x02; |
|
3208 attrId[1] = 0x00; |
|
3209 theRec->BuildUintL(attrId)->BuildDESL() |
|
3210 ->StartListL() |
|
3211 ->BuildUUIDL(TUUID(TUint16((TUint16)KGenericNetworkingUUID))) |
|
3212 ->EndListL(); |
|
3213 |
|
3214 |
|
3215 // Add the record into the database |
|
3216 iTheDb->AddRecord(theRec); |
|
3217 |
|
3218 // Record 2 - a member of the Browse group 0x1201 (Generic networking) |
|
3219 theRec = CSdpServRecord::NewL(); |
|
3220 |
|
3221 attrId.FillZ(2); |
|
3222 // Set Attr 0 (Record handle) to 0x0001001 |
|
3223 val[0] = 0x00; |
|
3224 val[1] = 0x01; |
|
3225 val[2] = 0x00; |
|
3226 val[3] = 0x01; |
|
3227 theRec->BuildUintL(attrId)->BuildUintL(val); |
|
3228 |
|
3229 |
|
3230 // Set Attr 1 (service class list) to 0x1201 |
|
3231 attrId[0] = 0x00; |
|
3232 attrId[1] = 0x01; |
|
3233 theRec->BuildUintL(attrId)->BuildDESL() |
|
3234 ->StartListL() |
|
3235 ->BuildUUIDL(TUUID((TUint16)KDialUpNetworkingUUID)) |
|
3236 ->EndListL(); |
|
3237 |
|
3238 // Set Attr 0x005 (browse group list) to the generic networking browse group |
|
3239 attrId[0] = 0x00; |
|
3240 attrId[1] = 0x05; |
|
3241 theRec->BuildUintL(attrId)->BuildDESL() |
|
3242 ->StartListL() |
|
3243 ->BuildUUIDL(TUUID(TUint16((TUint16)KGenericNetworkingUUID))) |
|
3244 ->EndListL(); |
|
3245 |
|
3246 |
|
3247 // Add the record into the database |
|
3248 iTheDb->AddRecord(theRec); |
|
3249 |
|
3250 // Record 3 - a member of the Browse group 0x1201 (Generic networking) |
|
3251 theRec = CSdpServRecord::NewL(); |
|
3252 |
|
3253 attrId.FillZ(2); |
|
3254 // Set Attr 0 (Record handle) to 0x0001002 |
|
3255 val[0] = 0x00; |
|
3256 val[1] = 0x01; |
|
3257 val[2] = 0x00; |
|
3258 val[3] = 0x02; |
|
3259 theRec->BuildUintL(attrId)->BuildUintL(val); |
|
3260 |
|
3261 // Set Attr 1 (service class list) to LanAccessUsingPPP UUID (0x1102) |
|
3262 attrId[0] = 0x00; |
|
3263 attrId[1] = 0x01; |
|
3264 theRec->BuildUintL(attrId)->BuildDESL() |
|
3265 ->StartListL() |
|
3266 ->BuildUUIDL(TUUID(0x1102)) |
|
3267 ->EndListL(); |
|
3268 |
|
3269 // Set Attr 0x005 (browse group list) to the generic networking browse group |
|
3270 attrId[0] = 0x00; |
|
3271 attrId[1] = 0x05; |
|
3272 theRec->BuildUintL(attrId)->BuildDESL() |
|
3273 ->StartListL() |
|
3274 ->BuildUUIDL(TUUID(TUint16((TUint16)KGenericNetworkingUUID))) |
|
3275 ->EndListL(); |
|
3276 |
|
3277 |
|
3278 // Add the record into the database |
|
3279 iTheDb->AddRecord(theRec); |
|
3280 |
|
3281 CSdpDatabase& db = *iTheDb; |
|
3282 PrintDb(db, aConsole); |
|
3283 } |
|
3284 |
|
3285 |
|
3286 |
|
3287 // |
|
3288 // Browse builder implementation |
|
3289 // |
|
3290 CBrowseResponseBuilder::CBrowseResponseBuilder(TDes& aTestName, TInt aBrowseIter/*, TInt aBrowseTest, TInt aUuidSize*/, CSdpSearchPattern& aBrowseSP) |
|
3291 |
|
3292 :iTestName(aTestName),iBrowseIter(aBrowseIter),/*iBrowseTest(aBrowseTest),iUuidSize(aUuidSize),*/iNeedAttributeId(ETrue),iBuildingList(0),iBrowseSP(aBrowseSP) |
|
3293 { |
|
3294 |
|
3295 } |
|
3296 |
|
3297 CBrowseResponseBuilder::~CBrowseResponseBuilder() |
|
3298 { |
|
3299 } |
|
3300 |
|
3301 MSdpElementBuilder* CBrowseResponseBuilder::BuildUintL(const TDesC8& aUint) |
|
3302 { |
|
3303 |
|
3304 if(iNeedAttributeId) |
|
3305 { |
|
3306 iNeedAttributeId = EFalse; |
|
3307 if(aUint.Length() != 2) |
|
3308 { |
|
3309 User::Leave(KErrGeneral); |
|
3310 } |
|
3311 // Now check the value; |
|
3312 // |
|
3313 TUint16 id = BigEndian::Get16(aUint.Ptr()); |
|
3314 FTRACE(FPrint(_L(""))); |
|
3315 FTRACE(FPrint(_L("%S:"), &iTestName)); |
|
3316 FTRACE(FPrint(_L(" Browse Iter %d: Attribute ID - %d"),iBrowseIter + 1, id)); |
|
3317 |
|
3318 switch(iBrowseIter) |
|
3319 { |
|
3320 case 0: |
|
3321 case 2: |
|
3322 if(id!=KSdpAttrIdServiceClassIDList) |
|
3323 { |
|
3324 User::Leave(KErrGeneral); |
|
3325 } |
|
3326 break; |
|
3327 case 1: |
|
3328 if(id!=KSdpAttrIdSdpServerGroupID) |
|
3329 { |
|
3330 User::Leave(KErrGeneral); |
|
3331 } |
|
3332 |
|
3333 break; |
|
3334 default: |
|
3335 User::Leave(KErrGeneral); |
|
3336 break; |
|
3337 } |
|
3338 |
|
3339 } |
|
3340 else |
|
3341 { |
|
3342 // Get the appropriate size uint |
|
3343 // |
|
3344 // First, get the correct size integer |
|
3345 // TUint32 uint32 = 0; |
|
3346 TUint16 uint16a = 0; |
|
3347 TUint16 uint16b = 0; |
|
3348 TUint8 uint8 = 0; |
|
3349 if(iBuildingList<=0) |
|
3350 { |
|
3351 iNeedAttributeId = ETrue; |
|
3352 } |
|
3353 if(aUint.Length() == 4) |
|
3354 { |
|
3355 // uint32 = BigEndian::Get32(aUint.Ptr()); |
|
3356 uint16a = BigEndian::Get16(aUint.Ptr()); |
|
3357 TUint8* ptr = CONST_CAST(TUint8 *, aUint.Ptr()); |
|
3358 ptr+=2; |
|
3359 uint16b = BigEndian::Get16(ptr); |
|
3360 FTRACE(FPrint(_L(""))); |
|
3361 FTRACE(FPrint(_L("%S:"), &iTestName)); |
|
3362 FTRACE(FPrint(_L(" Browse Iter %d: Attribute Uint32 Value - 0x%04x%04x"), iBrowseIter + 1, uint16a, uint16b)); |
|
3363 } |
|
3364 else if(aUint.Length() == 2) |
|
3365 { |
|
3366 uint16a = BigEndian::Get16(aUint.Ptr()); |
|
3367 FTRACE(FPrint(_L(""))); |
|
3368 FTRACE(FPrint(_L("%S:"), &iTestName)); |
|
3369 FTRACE(FPrint(_L(" Browse Iter %d: Attribute Uint32 Value - 0x%x"), iBrowseIter + 1, uint16a)); |
|
3370 } |
|
3371 else if(aUint.Length() == 1) |
|
3372 { |
|
3373 uint8 = aUint[0]; |
|
3374 FTRACE(FPrint(_L(""))); |
|
3375 FTRACE(FPrint(_L("%S:"), &iTestName)); |
|
3376 FTRACE(FPrint(_L(" Browse Iter %d: Attribute Uint32 Value - 0x%x"), iBrowseIter + 1, uint8)); |
|
3377 } |
|
3378 else |
|
3379 { |
|
3380 // We don't have 32, 16 or 8 bit Uint |
|
3381 User::Leave(KErrGeneral); |
|
3382 } |
|
3383 |
|
3384 (void)(uint16a != 0); // keep compiler happy by referencing uint16a as an r-value in urel |
|
3385 (void)(uint16b != 0); // keep compiler happy by referencing uint16b as an r-value in urel |
|
3386 (void)(uint8 != 0); // keep compiler happy by referencing uint8 as an r-value in urel |
|
3387 } |
|
3388 return this; |
|
3389 } |
|
3390 |
|
3391 MSdpElementBuilder* CBrowseResponseBuilder::BuildUUIDL(const TUUID& aUUID) |
|
3392 { |
|
3393 // Extract the underlying integer |
|
3394 // |
|
3395 TPtrC8 uuid = aUUID.ShortestForm(); |
|
3396 TUint16 bigUuid = BigEndian::Get16(uuid.Ptr()); |
|
3397 FTRACE(FPrint(_L(""))); |
|
3398 FTRACE(FPrint(_L("%S:"), &iTestName)); |
|
3399 FTRACE(FPrint(_L(" Browse Iter %d: Attribute UUID Value - 0x%x"), iBrowseIter + 1, bigUuid)); |
|
3400 if(iBuildingList<=0) |
|
3401 { |
|
3402 iNeedAttributeId = ETrue; |
|
3403 } |
|
3404 |
|
3405 |
|
3406 switch(iBrowseIter) |
|
3407 { |
|
3408 case 0: |
|
3409 // Browse group list |
|
3410 if(bigUuid==0x1001) |
|
3411 { |
|
3412 FTRACE(FPrint(_L(""))); |
|
3413 FTRACE(FPrint(_L("%S:"), &iTestName)); |
|
3414 FTRACE(FPrint(_L(" Browse Iter %d.... Browse Group Record Found!"), iBrowseIter + 1)); |
|
3415 } |
|
3416 break; |
|
3417 case 1: |
|
3418 iBrowseSP.AddL(aUUID); |
|
3419 FTRACE(FPrint(_L(""))); |
|
3420 FTRACE(FPrint(_L("%S:"), &iTestName)); |
|
3421 FTRACE(FPrint(_L(" Browse Iter %d.... Browse Group ID (0x%x) found!"), iBrowseIter + 1, bigUuid)); |
|
3422 break; |
|
3423 default: |
|
3424 break; |
|
3425 } |
|
3426 return this; |
|
3427 } |
|
3428 |
|
3429 MSdpElementBuilder* CBrowseResponseBuilder::BuildDESL() |
|
3430 { |
|
3431 return this; |
|
3432 } |
|
3433 |
|
3434 MSdpElementBuilder* CBrowseResponseBuilder::StartListL() |
|
3435 { |
|
3436 FTRACE(FPrint(_L(""))); |
|
3437 FTRACE(FPrint(_L("%S: New List (DES)...."), &iTestName)); |
|
3438 iBuildingList++; |
|
3439 return this; |
|
3440 } |
|
3441 |
|
3442 MSdpElementBuilder* CBrowseResponseBuilder::EndListL() |
|
3443 { |
|
3444 FTRACE(FPrint(_L("%S: End Current List"), &iTestName)); |
|
3445 iBuildingList--; |
|
3446 if(iBuildingList<=0) |
|
3447 iNeedAttributeId=ETrue; |
|
3448 return this; |
|
3449 } |
|
3450 |
|
3451 // |
|
3452 // Print out builder implementation |
|
3453 // |
|
3454 CPrintBuilder::CPrintBuilder(CConsoleBase& aConsole) |
|
3455 : iIndent(0), iConsole(aConsole) |
|
3456 { |
|
3457 |
|
3458 } |
|
3459 |
|
3460 CPrintBuilder::~CPrintBuilder() |
|
3461 { |
|
3462 } |
|
3463 |
|
3464 |
|
3465 void CPrintBuilder::HexDumpVT(const TDesC8& aDes) |
|
3466 { |
|
3467 for (TInt i = 0; i < aDes.Length(); ++i) |
|
3468 { |
|
3469 if (i%8 == 0) |
|
3470 iConsole.Printf(_L("0x%04x: "), i); |
|
3471 iConsole.Printf(_L("0x%02x "), aDes[i]); |
|
3472 if (i%8 == 7 || i == aDes.Length() - 1) |
|
3473 iConsole.Printf(_L("\n")); |
|
3474 } |
|
3475 } |
|
3476 |
|
3477 |
|
3478 |
|
3479 MSdpElementBuilder* CPrintBuilder::BuildUnknown(TUint8 aType, TUint8 aSizeDesc, const TDesC8& aData) |
|
3480 { |
|
3481 iConsole.SetPos(iIndent); |
|
3482 iConsole.Printf(_L("Got Unknown: <type %d, sizedesc %d, length %d>\n"), aType, aSizeDesc, aData.Length()); |
|
3483 HexDumpVT(aData); |
|
3484 return this; |
|
3485 }; |
|
3486 MSdpElementBuilder* CPrintBuilder::BuildNilL() |
|
3487 { |
|
3488 iConsole.SetPos(iIndent); |
|
3489 iConsole.Printf(_L("Got Nil: <>\n")); |
|
3490 return this; |
|
3491 }; |
|
3492 |
|
3493 MSdpElementBuilder* CPrintBuilder::BuildUintL(const TDesC8& aLongUint) |
|
3494 { |
|
3495 iConsole.SetPos(iIndent); |
|
3496 iConsole.Printf(_L("Got Long Uint: <Length %d>\n"), aLongUint.Length()); |
|
3497 HexDumpVT(aLongUint); |
|
3498 return this; |
|
3499 }; |
|
3500 MSdpElementBuilder* CPrintBuilder::BuildIntL(const TDesC8& aLongInt) |
|
3501 { |
|
3502 iConsole.SetPos(iIndent); |
|
3503 iConsole.Printf(_L("Got Long Int: <Length %d>\n"), aLongInt.Length()); |
|
3504 HexDumpVT(aLongInt); |
|
3505 return this; |
|
3506 }; |
|
3507 MSdpElementBuilder* CPrintBuilder::BuildUUIDL(const TUUID& aUUID) |
|
3508 { |
|
3509 iConsole.SetPos(iIndent); |
|
3510 iConsole.Printf(_L("Got UUID: <length %d>\n"), aUUID.ShortestForm().Length()); |
|
3511 HexDumpVT(aUUID.ShortestForm()); |
|
3512 return this; |
|
3513 }; |
|
3514 MSdpElementBuilder* CPrintBuilder::BuildBooleanL(TBool aBool) |
|
3515 { |
|
3516 iConsole.SetPos(iIndent); |
|
3517 iConsole.Printf(_L("Got Boolean: <%d>\n"), aBool); |
|
3518 return this; |
|
3519 }; |
|
3520 MSdpElementBuilder* CPrintBuilder::BuildStringL(const TDesC8& aString) |
|
3521 { |
|
3522 TBuf<512> ustr; |
|
3523 ustr.Copy(aString.Left(Min(aString.Length(), ustr.MaxLength()))); |
|
3524 iConsole.SetPos(iIndent); |
|
3525 iConsole.Printf(_L("Got String: <length %d, Contents %S>\n"), ustr.Length(), &ustr); |
|
3526 return this; |
|
3527 }; |
|
3528 MSdpElementBuilder* CPrintBuilder::BuildDESL() |
|
3529 { |
|
3530 return StartListL(); |
|
3531 }; |
|
3532 |
|
3533 MSdpElementBuilder* CPrintBuilder::BuildDEAL() |
|
3534 { |
|
3535 return StartListL(); |
|
3536 }; |
|
3537 |
|
3538 MSdpElementBuilder* CPrintBuilder::StartListL(/*prob want list type here*/) |
|
3539 { |
|
3540 iConsole.SetPos(iIndent); |
|
3541 iConsole.Printf(_L("<START LIST>\n")); |
|
3542 iIndent += 2; |
|
3543 return this; |
|
3544 }; |
|
3545 MSdpElementBuilder* CPrintBuilder::EndListL() |
|
3546 { |
|
3547 if (iIndent > 0) |
|
3548 { |
|
3549 iIndent-=2; |
|
3550 iConsole.SetPos(iIndent); |
|
3551 iConsole.Printf(_L("<END LIST>\n")); |
|
3552 } |
|
3553 else |
|
3554 { |
|
3555 iConsole.Printf(_L("WARNING: UNMATCHED END LIST!")); |
|
3556 } |
|
3557 return this; |
|
3558 }; |
|
3559 MSdpElementBuilder* CPrintBuilder::BuildURLL(const TDesC8& aString) |
|
3560 { |
|
3561 iConsole.SetPos(iIndent); |
|
3562 iConsole.Printf(_L("Got URL: \n")); |
|
3563 HexDumpVT(aString); |
|
3564 return this; |
|
3565 }; |
|
3566 |
|
3567 |
|
3568 |
|
3569 |