DSMCC  17.9.0
 All Data Structures Files Functions Typedefs
object.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2001 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
26 /*---includes for this file--------------------------------------------------*/
27 #include "clDsmSystem.h"
28 #include <string.h>
29 
30 #include "object.h"
31 
32 #include "linkList.h"
33 #include "cacheMgr.h"
34 #include "clDsmUtils.h"
35 #include "defMemUtilsMgd.h" /* -- Default mem type for module */
36 
37 
38 /*---constant definitions for this file--------------------------------------*/
39 
40 
41 /*---local typedef structs for this file-------------------------------------*/
42 
43 /*---local (static) variable declarations for this file----------------------*/
44 
45 /*---local function definitions----------------------------------------------*/
46 
47 /*---global function definitions---------------------------------------------*/
48 
49 /* /////////////////////////////////////////////////////////////////////////////
50 // objectDataGetKeyAndLen
51 // Gets the objectKey value and object length for an object.
52 // Returns TRUE if successful.
54 BOOLEAN objectDataGetKeyAndLen( const MemPtr mpObjectData,
55  P_ObjectKey pObjectKey, U32BIT *pObjectLength )
56 {
57  MemPtr mpObjectHdr;
58  U32BIT messageSize;
59  BOOLEAN keyValid;
60  BOOLEAN valid = TRUE;
61  U8BIT ui8 = 0;
62  U16BIT ui16 = 0;
63  U32BIT ui32 = 0;
64 
65  S_ObjectKey LocalObjectKey;
66 
67  /* -- stop compiler warnings when no checking */
68  ui8 += 0; ui16 += 0; ui32 += 0;
69 
70  /* -- DP level 4 since called in a loop whenever a module is searched
71  -- for an object */
72  dsmDP4(("objectDataGetKeyAndLen()\n"));
73  dsmAssert((mpObjectData != NULL));
74  dsmAssert((pObjectKey != NULL));
75  dsmAssert((pObjectLength != NULL));
76 
77 
78  /* -- Open MemPtr for accessing object data */
79  MEMPTR_OPEN( mpObjectData, mpObjectHdr );
80 
81  /* -- Skip magic, BIOP protocol version, byteOrder, messageType */
82  SET_POS_REL( mpObjectHdr, 8 );
83 
84  /* -- Read messageSize */
85  READ_UINT32( mpObjectHdr, messageSize );
86 
87  /* -- Calculate objectLength */
88  *pObjectLength = messageSize + OBJECT_NUMBYTES_TO_MESSAGE_START;
89 
90  /* -- mpObjectHdr -> start of objectKey info */
91  READ_OBJECT_KEY( mpObjectHdr, LocalObjectKey, keyValid );
92 
93  memcpy(pObjectKey, &LocalObjectKey, sizeof(S_ObjectKey));
94 
95  if (!keyValid)
96  {
97  dsmDP2(("DATA ERROR: Object data objectKey invalid\n"));
98  valid = FALSE;
99  }
100 
101  MEMPTR_CLOSE( mpObjectHdr );
102  DEBUG_CHK( valid == TRUE,
103  dsmDP1(("ERROR: objectDataGetKeyAndLen failure (invalid)\n")));
104  dsmDP4(("exit objectDataGetKeyAndLen -> rtn: %u\n", valid));
105  return valid;
106 }
107 
121  /*I*/ const MemPtr mpObjectData,
122  /*O*/ ObjectDataInfo_t *pObjInf)
123 {
124  MemPtr mpObjectHdr;
125  U32BIT messageSize;
126  BOOLEAN valid = FALSE; /* Set true when all data read and stored OK */
127  U8BIT ui8 = 0;
128  U16BIT ui16 = 0;
129  U32BIT ui32 = 0;
130  U8BIT serviceContextList_count;
131  U16BIT context_data_length;
132  BOOLEAN keyValid; /* Temporary variable stating when object key valid */
133  U8BIT i; /* General purpose 8-bit counter */
134 
135  /* -- stop compiler warnings when no checking */
136  ui8 += 0; ui16 += 0; ui32 += 0;
137 
138  dsmDP3(("objectDataGetInfo()\n"));
139  dsmAssert((mpObjectData != NULL));
140  dsmAssert((pObjInf != NULL));
141 
142  /* -- Open MemPtr for accessing object data */
143  MEMPTR_OPEN( mpObjectData, mpObjectHdr );
144 
145  /* -- magic = BIOP (DSM-CC) */
146  ADV_UINT32_L2CHK( mpObjectHdr, ui32, ui32 == BIOP_MAGIC,
147  dsmDP2(("DATA ERROR: Object data BIOP magic = %u\n", ui32)),
148  goto _return );
149 
150  /* -- BIOP protocol version - major = 0x01, minor = 0x00 (DVB) */
151  ADV_UINT16_L2CHK( mpObjectHdr, ui16, ui16 == 0x0100,
152  dsmDP2(("DATA ERROR: Object data protocol version (!=0x0100) = %u\n", ui16)),
153  goto _return );
154 
155  /* -- byteOrder = big endian (0x00) (DVB) */
156  /* -- L1 check because if this is wrong, subsequent data will be garbaged */
157  ADV_UINT8_L1CHK( mpObjectHdr, ui8, ui8 == 0x00,
158  dsmDP2(("DATA ERROR: Object data byteOrder = %u\n", ui8)),
159  goto _return );
160 
161  /* -- Skip messageType */
162  SET_POS_REL( mpObjectHdr, 1 );
163 
164  /* -- Read messageSize */
165  READ_UINT32( mpObjectHdr, messageSize );
166 
167  /* -- Calculate total objectLength */
168  pObjInf->objectLen = messageSize + OBJECT_NUMBYTES_TO_MESSAGE_START;
169 
170  /* mpObjectHdr -> start of objectKey info */
171  READ_OBJECT_KEY(mpObjectHdr, pObjInf->objectKey, keyValid);
172  if (!keyValid)
173  {
174  dsmDP2(("DATA ERROR: Object data objectKey invalid\n"));
175  goto _return;
176  }
177 
178  /* -- objectKindLength = 4 (DVB/UK DTT) */
179  /* -- L1 check because if this is wrong, subsequent data will be garbaged */
180  ADV_UINT32_L1CHK( mpObjectHdr, ui32, ui32 == 4,
181  dsmDP2(("DATA ERROR: Object data objectKindLength (!= 4) = %u\n", ui32)),
182  goto _return );
183 
184  /* -- Read objectKindData */
185  READ_UINT32( mpObjectHdr, pObjInf->objectKind );
186 
187  /* Read how many bytes of object information is in BIOP message */
188  READ_UINT16(mpObjectHdr, pObjInf->objectInfoLength);
189 
190  /* Calculate offset of object information from start of message.
191  The data pointed to is dependant on the object kind */
192  MEMPTR_GET_DIFF(mpObjectData, mpObjectHdr, pObjInf->objectInfoOffset);
193 
194  /* Skip the object information because it is specific to object type.
195  This will move us to the serviceContextList_count */
196  SET_POS_REL(mpObjectHdr, (U32BIT)pObjInf->objectInfoLength);
197 
198  /* Read how many service contexts are in the message */
199  READ_UINT8(mpObjectHdr, serviceContextList_count);
200 
201  /* Skip the service contexts */
202  for (i = 0; i < serviceContextList_count; i++)
203  {
204  /* Skip context_id */
205  SET_POS_REL(mpObjectHdr, 4);
206 
207  /* Read context_data_length */
208  READ_UINT16(mpObjectHdr, context_data_length);
209 
210  /* Skip context (8-bit) data */
211  SET_POS_REL(mpObjectHdr, context_data_length);
212  }
213 
214  /* Read and store messageBodyLength */
215  READ_UINT32(mpObjectHdr, pObjInf->messageBodyLength);
216 
217  /* Calculate and store messageBodyOffset */
218  MEMPTR_GET_DIFF(mpObjectData, mpObjectHdr, pObjInf->messageBodyOffset);
219 
220  /* -- Check lengths consistent */
221  L2_DATA_CHK( messageSize + OBJECT_NUMBYTES_TO_MESSAGE_START ==
222  pObjInf->messageBodyOffset + pObjInf->messageBodyLength,
223  dsmDP2(("DATA ERROR: Object data message lengths inconsistent\n")),
224  goto _return );
225 
226  /* -- If we get here, assume we have recovered the required data */
227  valid = TRUE;
228 
229 _return:
230  MEMPTR_CLOSE( mpObjectHdr );
231  DEBUG_CHK( valid == TRUE,
232  dsmDP1(("ERROR: objectDataGetInfo failure (invalid)\n")));
233  dsmDP3(("exit objectDataGetInfo -> rtn: %u\n", valid));
234  return valid;
235 }
236 
237 /* /////////////////////////////////////////////////////////////////////////////
238 // odDirFindBinding
239 // If found: pBinding set to required binding start & BindingLength valid
240 // Else: pBinding set to end of data (or binding causing error) &
241 // BindingLength invalid
242 //
244 BOOLEAN odDirFindBinding(
245  /*I*/ const MemPtr mpObject, pObjectDataInfo_t pObjInf, U8BIT *name,
246  /*O*/ MemPtr *mpBinding )
247 {
248  MemPtr mpBindingData;
249  MemPos currStartPos;
250  BOOLEAN found = FALSE;
251  U16BIT bindingsCount;
252  U8BIT idLength;
253  U8BIT nameLength;
254  U32BIT profilesCount;
255  U8BIT ui8 = 0;
256  U16BIT ui16 = 0;
257  U32BIT ui32 = 0;
258  /* -- stop compiler warnings when no checking */
259  ui8 += 0; ui16 += 0; ui32 += 0;
260 
261  dsmDP3(("odDirFindBinding( %s )\n", name));
262  dsmAssert((mpObject != NULL));
263  dsmAssert((pObjInf != NULL));
264  dsmAssert((name != NULL));
265  dsmAssert(((pObjInf->objectKind == DIR_STR) ||
266  (pObjInf->objectKind == SRG_STR)));
267  dsmAssert((mpBinding != NULL));
268 
269 
270  nameLength = (U8BIT)(strlen((char *)name ) + 1); /* -- Add 1 for null terminator */
271  dsmAssert((nameLength <= MAX_OBJ_NAME_SIZE));
272 
273  /* -- Open MemPtr for accessing binding data in object */
274  MEMPTR_OPEN( mpObject, mpBindingData );
275 
276  /* -- mpBindingData -> BIOP::DirectoryMessage */
277 
278  /* -- Skip header info and go to first message body */
279  SET_POS_REL( mpBindingData, (S32BIT)pObjInf->messageBodyOffset );
280 
281  /* -- Read bindingsCount */
282  READ_UINT16( mpBindingData, bindingsCount );
283 
284  /* -- Loop through bindings until we find the right one */
285  /* TODO: also check for hitting end of data? */
286  while (bindingsCount--)
287  {
288  /* -- mpBindingData -> BIOP::Name */
289 
290  /* -- Remember start position of this binding */
291  GET_POS( mpBindingData, currStartPos );
292 
293  /* -- nameComponentsCount = 1 (DVB/UK DTT) */
294  ADV_UINT8_L2CHK( mpBindingData, ui8, ui8 == 1,
295  dsmDP2(("DATA ERROR: DIR Binding nameComponentsCount (!= 1) = %u\n", ui8)),
296  break );
297 
298  /* -- Read id (name) */
299  /* TODO: L2 check idLength is legal? */
300  READ_UINT8( mpBindingData, idLength );
301 
302  if (nameLength == idLength)
303  {
304  MEMPTR_DATA_COMPARE(
305  (U8BIT *)name, mpBindingData, nameLength, found );
306 
307  if (found)
308  {
309  SET_POS_ABS( *mpBinding, currStartPos );
310  break;
311  }
312  }
313 
314  /* -- Skip id (name) */
315  SET_POS_REL( mpBindingData, (S32BIT)idLength );
316 
317  /* -- kindLength = 4 (DVB/UK DTT) */
318  /* -- L1 check because this should be correct */
319  ADV_UINT8_L1CHK( mpBindingData, ui8, ui8 == 4,
320  dsmDP2(("DATA ERROR: DIR Binding kindLength (!= 4) = %u\n", ui8)),
321  break );
322 
323  /* -- Skip kind */
324  SET_POS_REL( mpBindingData, 4 );
325 
326  /* -- Skip binding type */
327  SET_POS_REL( mpBindingData, 1 );
328 
329 
330  /* -- mpBindingData -> IOP::IOR */
331 
332  /* -- typeIdLength = 4 (DVB/UK DTT) */
333  /* -- L1 check because this should be correct */
334  ADV_UINT32_L1CHK( mpBindingData, ui32, ui32 == 4,
335  dsmDP2(("DATA ERROR: DIR Binding typeIdLength (!= 4) = %u\n", ui32)),
336  break );
337 
338  /* -- Skip typeId */
339  SET_POS_REL( mpBindingData, 4 );
340 
341  /* -- Read taggedProfilesCount >= 1 (DVB/UK DTT) */
342  READ_UINT32_L2CHK( mpBindingData, profilesCount, profilesCount >= 1,
343  dsmDP2(("DATA ERROR: DIR Binding taggedProfilesCount (< 1) = %u\n", ui32)),
344  break );
345 
346  while (profilesCount--)
347  {
348  /* -- Skip profileIdTag */
349  SET_POS_REL( mpBindingData, 4 );
350 
351  /* -- Read profileDataLength */
352  READ_UINT32( mpBindingData, ui32 );
353 
354  /* -- Skip profile data */
355  SET_POS_REL( mpBindingData, (S32BIT)ui32 );
356  }
357 
358  /* -- Read objectInfoLength */
359  READ_UINT16( mpBindingData, ui16 );
360 
361  /* -- Skip objectInfo */
362  SET_POS_REL( mpBindingData, (S32BIT)ui16 );
363  }
364 
365  MEMPTR_CLOSE( mpBindingData );
366 
367  dsmDP3(("exit odDirFindBinding -> rtn: %u\n", found));
368  return found;
369 }
370 
371 /* /////////////////////////////////////////////////////////////////////////////
372 // odDirGetBindingInfo
373 // Returns TRUE if successful.
375 BOOLEAN odDirGetBindingInfo(
376  /*I*/ const MemPtr mpBinding,
377  /*O*/ P_ObjectLocation pLocation, P_DeliveryParaTap pTap )
378 {
379  MemPtr mpBindingData;
380  U8BIT ui8 = 0;
381  U32BIT iorTypeId;
382  U16BIT length = 0;
383 
384  dsmDP3(("odDirGetBindingInfo()\n"));
385  dsmAssert((mpBinding != NULL));
386  dsmAssert((pLocation != NULL));
387  dsmAssert((pTap != NULL));
388 
389 
390  /* -- Open MemPtr for accessing binding data */
391  MEMPTR_OPEN( mpBinding, mpBindingData );
392 
393  /* -- mpBindingData -> BIOP::Name */
394 
395  /* -- nameComponentsCount = 1 (DVB/UK DTT) */
396  ADV_UINT8_L2CHK( mpBindingData, ui8, ui8 == 1,
397  dsmDP2(("DATA ERROR: DIR Binding nameComponentsCount (!= 1) = %u\n", ui8)),
398  goto _return );
399 
400  /* -- Skip id (name) */
401  /* TODO: L2 check idLength is legal? */
402  READ_UINT8( mpBindingData, ui8 );
403  SET_POS_REL( mpBindingData, (S32BIT)ui8 );
404 
405  /* -- kindLength = 4 (DVB/UK DTT) */
406  /* -- L1 check because this should be correct */
407  ADV_UINT8_L1CHK( mpBindingData, ui8, ui8 == 4,
408  dsmDP2(("DATA ERROR: DIR Binding kindLength (!= 4) = %u\n", ui8)),
409  goto _return );
410 
411  /* -- Skip kind */
412  SET_POS_REL( mpBindingData, 4 );
413 
414  /* -- bindingType = 0x01 or 0x02 (DVB) */
415  /* -- L1 check because this should be correct */
416  ADV_UINT8_L1CHK( mpBindingData, ui8, ((ui8 == 0x01) || (ui8 == 0x02)),
417  dsmDP2(("DATA ERROR: DIR Binding bindingType = %u\n", ui8)),
418  goto _return );
419 
420  /* -- pBindingData -> start of IOP::IOR */
421  length = getIorInfoSeq( mpBindingData, &iorTypeId, pLocation, pTap );
422  /*TODO: check returned IOR type against binding and/or object kind? */
423  /*TODO: handle LiteOptionsProfile */
424 
425  goto _return; /* -- stop compiler warnings when no checking */
426 _return:
427  MEMPTR_CLOSE( mpBindingData );
428  DEBUG_CHK( length != 0,
429  dsmDP1(("ERROR: odDirGetBindingInfo failure (invalid)\n")));
430  dsmDP3(("exit odDirGetBindingInfo -> rtn: %u\n", length));
431  return (length != 0) ? TRUE : FALSE;
432 }
433 
434 /* /////////////////////////////////////////////////////////////////////////////
435 // odDirBindingNameLength
436 // Returns name length
438 extern U8BIT odDirBindingNameLength(
439  /*I*/ const MemPtr mpBinding )
440 {
441  MemPtr mpBindingData;
442  U8BIT ui8 = 0;
443 
444  dsmDP3(("odDirGetBindingName()\n"));
445  dsmAssert((mpBinding != NULL));
446 
447  /* -- Open MemPtr for accessing binding data */
448  MEMPTR_OPEN( mpBinding, mpBindingData );
449 
450  /* -- mpBindingData -> BIOP::Name */
451 
452  /* -- nameComponentsCount = 1 (DVB/UK DTT) */
453  ADV_UINT8_L2CHK( mpBindingData, ui8, ui8 == 1,
454  dsmDP2(("DATA ERROR: DIR Binding nameComponentsCount (!= 1) = %u\n", ui8)), );
455 
456  /* -- Get name (id) length */
457  READ_UINT8( mpBindingData, ui8 );
458 
459  MEMPTR_CLOSE( mpBindingData );
460  return ui8;
461 }
462 
463 /* /////////////////////////////////////////////////////////////////////////////
464 // odDirBindingNameCopy
465 // copies name data to 'name'
466 // Returns name length
468 extern U8BIT odDirBindingNameCopy(
469  /*I*/ const MemPtr mpBinding,
470  /*O*/ U8BIT *name )
471 {
472  MemPtr mpBindingData;
473  U8BIT ui8 = 0;
474 
475  dsmDP3(("odDirGetBindingName()\n"));
476  dsmAssert((mpBinding != NULL));
477 
478  /* -- Open MemPtr for accessing binding data */
479  MEMPTR_OPEN( mpBinding, mpBindingData );
480 
481  /* -- mpBindingData -> BIOP::Name */
482 
483  /* -- nameComponentsCount = 1 (DVB/UK DTT) */
484  ADV_UINT8_L2CHK( mpBindingData, ui8, ui8 == 1,
485  dsmDP2(("DATA ERROR: DIR Binding nameComponentsCount (!= 1) = %u\n", ui8)), );
486 
487  /* -- Get name (id) length */
488  READ_UINT8( mpBindingData, ui8 );
489 
490  /* -- Read name */
491  MEMPTR_READ( mpBindingData, name, ui8 );
492 
493  MEMPTR_CLOSE( mpBindingData );
494  return ui8;
495 }
496 
497 /* /////////////////////////////////////////////////////////////////////////////
498 // odDirGetBindingKind
499 // Returns TRUE if valid.
501 BOOLEAN odDirGetBindingKind(
502  /*I*/ const MemPtr mpBinding,
503  /*O*/ U32BIT *pKind )
504 {
505  MemPtr mpBindingData;
506  U8BIT ui8 = 0;
507  BOOLEAN valid = FALSE;
508 
509  dsmDP3(("odDirGetBindingKind()\n"));
510  dsmAssert((mpBinding != NULL));
511  dsmAssert((pKind != NULL));
512 
513 
514  /* -- Open MemPtr for accessing binding data */
515  MEMPTR_OPEN( mpBinding, mpBindingData );
516 
517  /* -- mpBindingData -> BIOP::Name */
518 
519  /* -- nameComponentsCount = 1 (DVB/UK DTT) */
520  ADV_UINT8_L2CHK( mpBindingData, ui8, ui8 == 1,
521  dsmDP2(("DATA ERROR: DIR Binding nameComponentsCount (!= 1) = %u\n", ui8)),
522  goto _return );
523 
524  /* -- Skip id (name) */
525  /* TODO: L2 check idLength is legal? */
526  READ_UINT8( mpBindingData, ui8 );
527  SET_POS_REL( mpBindingData, (S32BIT)ui8 );
528 
529  /* -- kindLength = 4 (DVB/UK DTT) */
530  /* -- L1 check because this should be correct */
531  ADV_UINT8_L1CHK( mpBindingData, ui8, ui8 == 4,
532  dsmDP2(("DATA ERROR: DIR Binding kindLength (!= 4) = %u\n", ui8)),
533  goto _return );
534 
535  /* -- Read kind */
536  READ_UINT32( mpBindingData, *pKind );
537 
538  /* -- bindingType = 0x01 or 0x02 (DVB) */
539  /* -- L1 check because this should be correct */
540  ADV_UINT8_L1CHK( mpBindingData, ui8, ((ui8 == 0x01) || (ui8 == 0x02)),
541  dsmDP2(("DATA ERROR: DIR Binding bindingType = %u\n", ui8)),
542  goto _return );
543 
544  /* -- If we get here, assume we have recovered the required data */
545  valid = TRUE;
546 
547  goto _return; /* -- stop compiler warnings when no checking */
548 _return:
549  MEMPTR_CLOSE( mpBindingData );
550  DEBUG_CHK( valid == TRUE,
551  dsmDP1(("ERROR: odDirGetBindingKind failure (invalid)\n")));
552  dsmDP3(("exit odDirGetBindingKind -> kind: %08x, rtn: %u\n", *pKind, valid));
553  return valid;
554 }
555 
556 void odDirGetBindingsCount(
557  /*I*/ const MemPtr mpObject, pObjectDataInfo_t pObjInf,
558  /*O*/ U16BIT *pBindingsCount )
559 {
560  MemPtr mpDirObjData;
561 
562  dsmDP3(("odDirGetBindingsCount()\n"));
563  dsmAssert((mpObject != NULL));
564  dsmAssert((pObjInf != NULL));
565  dsmAssert(((pObjInf->objectKind == DIR_STR) ||
566  (pObjInf->objectKind == SRG_STR)));
567 
568 
569  /* -- Open MemPtr for accessing binding data in object */
570  MEMPTR_OPEN( mpObject, mpDirObjData );
571 
572  /* -- mpDirObjData -> BIOP::DirectoryMessage */
573 
574  /* -- Skip header info and go to first message body */
575  SET_POS_REL( mpDirObjData, (S32BIT)pObjInf->messageBodyOffset );
576 
577  /* -- Read bindingsCount */
578  READ_UINT16( mpDirObjData, *pBindingsCount );
579 
580  MEMPTR_CLOSE( mpDirObjData );
581 
582  dsmDP3(("exit odDirGetBindingsCount\n"));
583 }
584 
585 U16BIT odDirCountAndFirstBinding(
586  /*I*/ const MemPtr mpObject, pObjectDataInfo_t pObjInf,
587  /*O*/ MemPtr *mpFirstBinding )
588 {
589  MemPtr mpBindingData;
590  MemPos bindingPos;
591  U16BIT bindingsCount;
592 
593  dsmDP3(("odDirGetFirstBinding()\n"));
594  dsmAssert((mpObject != NULL));
595  dsmAssert((pObjInf != NULL));
596  dsmAssert(((pObjInf->objectKind == DIR_STR) ||
597  (pObjInf->objectKind == SRG_STR)));
598  dsmAssert((mpFirstBinding != NULL));
599 
600 
601  /* -- Open MemPtr for accessing binding data in object */
602  MEMPTR_OPEN( mpObject, mpBindingData );
603 
604  /* -- mpBindingData -> BIOP::DirectoryMessage */
605 
606  /* -- Skip header info and go to first message body */
607  SET_POS_REL( mpBindingData, (S32BIT)pObjInf->messageBodyOffset );
608 
609  /* -- Read bindingsCount */
610  READ_UINT16( mpBindingData, bindingsCount );
611 
612  if (bindingsCount > 0)
613  {
614  /* -- mpBindingData -> BIOP::Name */
615 
616  /* -- Read current MemPtr position and assign to output MemPtr */
617  GET_POS( mpBindingData, bindingPos );
618  SET_POS_ABS( *mpFirstBinding, bindingPos );
619  }
620 
621  MEMPTR_CLOSE( mpBindingData );
622 
623  dsmDP3(("exit odDirGetFirstBinding -> rtn: %u\n", bindingsCount));
624  return bindingsCount;
625 }
626 
627 /*
628 -- NB. This function does not determine if the next binding is actually a
629 -- valid binding (eg. it may be the end of the dir bindings list).
630 */
631 BOOLEAN odDirGetNextBinding(
632  /*I*/ const MemPtr mpCurrBinding,
633  /*O*/ MemPtr *mpNextBinding )
634 {
635  MemPtr mpBindingData;
636  MemPos bindingPos;
637  BOOLEAN valid = FALSE;
638  U8BIT idLength;
639  U32BIT profilesCount;
640  U8BIT ui8 = 0;
641  U16BIT ui16 = 0;
642  U32BIT ui32 = 0;
643  /* -- stop compiler warnings when no checking */
644  ui8 += 0; ui16 += 0; ui32 += 0;
645 
646  dsmDP3(("odDirGetNextBinding()\n"));
647  dsmAssert((mpCurrBinding != NULL));
648  dsmAssert((mpNextBinding != NULL));
649 
650 
651  /* -- Open MemPtr for accessing binding data in object */
652  MEMPTR_OPEN( mpCurrBinding, mpBindingData );
653 
654  /* -- mpBindingData -> BIOP::Name */
655 
656  /* -- nameComponentsCount = 1 (DVB/UK DTT) */
657  ADV_UINT8_L2CHK( mpBindingData, ui8, ui8 == 1,
658  dsmDP2(("DATA ERROR: DIR Binding nameComponentsCount (!= 1) = %u\n", ui8)),
659  goto _return );
660 
661  /* -- Read id (name) */
662  /* TODO: L2 check idLength is legal? */
663  READ_UINT8( mpBindingData, idLength );
664 
665  /* -- Skip id (name) */
666  SET_POS_REL( mpBindingData, (S32BIT)idLength );
667 
668  /* -- kindLength = 4 (DVB/UK DTT) */
669  /* -- L1 check because this should be correct */
670  ADV_UINT8_L1CHK( mpBindingData, ui8, ui8 == 4,
671  dsmDP2(("DATA ERROR: DIR Binding kindLength (!= 4) = %u\n", ui8)),
672  goto _return );
673 
674  /* -- Skip kind */
675  SET_POS_REL( mpBindingData, 4 );
676 
677  /* -- Skip binding type */
678  SET_POS_REL( mpBindingData, 1 );
679 
680 
681  /* -- mpBindingData -> IOP::IOR */
682 
683  /* -- typeIdLength = 4 (DVB/UK DTT) */
684  /* -- L1 check because this should be correct */
685  ADV_UINT32_L1CHK( mpBindingData, ui32, ui32 == 4,
686  dsmDP2(("DATA ERROR: DIR Binding typeIdLength (!= 4) = %u\n", ui32)),
687  goto _return );
688 
689  /* -- Skip typeId */
690  SET_POS_REL( mpBindingData, 4 );
691 
692  /* -- Read taggedProfilesCount >= 1 (DVB/UK DTT) */
693  READ_UINT32_L2CHK( mpBindingData, profilesCount, profilesCount >= 1,
694  dsmDP2(("DATA ERROR: DIR Binding taggedProfilesCount (< 1) = %u\n", ui32)),
695  goto _return );
696 
697  while (profilesCount--)
698  {
699  /* -- Skip profileIdTag */
700  SET_POS_REL( mpBindingData, 4 );
701 
702  /* -- Read profileDataLength */
703  READ_UINT32( mpBindingData, ui32 );
704 
705  /* -- Skip profile data */
706  SET_POS_REL( mpBindingData, (S32BIT)ui32 );
707  }
708 
709  /* -- Read objectInfoLength */
710  READ_UINT16( mpBindingData, ui16 );
711 
712  /* -- Skip objectInfo */
713  SET_POS_REL( mpBindingData, (S32BIT)ui16 );
714 
715  /* -- Read current MemPtr position and assign to output MemPtr */
716  GET_POS( mpBindingData, bindingPos );
717  SET_POS_ABS( *mpNextBinding, bindingPos );
718 
719  /* -- If we get here, assume we have recovered the required data */
720  valid = TRUE;
721 
722  goto _return; /* -- stop compiler warnings when no checking */
723 _return:
724  MEMPTR_CLOSE( mpBindingData );
725  dsmDP3(("exit odDirGetNextBinding -> rtn: %u\n", valid));
726  return valid;
727 }
728 
729 /*------------------------------ Local Functions -----------------------------*/
730 
731 
732 /*----------------------------------------------------------------------------*/
General include file for clDsm library internal definitions.
BOOLEAN objectDataGetInfo(const MemPtr mpObjectData, ObjectDataInfo_t *pObjInf)
Parse the supplied object data. Verify selected fields. Extract generic information from selected fie...
Definition: object.c:120
Header to the cacheMgr module.
Header to the object module - functions/methods accessing data of object messages inside modules...
Defines memory access utils to work with managed (MemMgr) memory.
eader to the clDsmUtils module.