DSMCC  17.9.0
 All Data Structures Files Functions Typedefs
findModuleInDii_include_src.h
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  *******************************************************************************/
28 /*
29 -- findModuleInDiiMsg - Common Code
30 --
31 -- Find start of requested module in DII message (compatible with
32 -- contiguous or managed/MemSeq memory)
33 --
34 -- Uses/assumes the following vars:
35 -- found, mpDiiMsg, dataLength, *mpModuleInfoDescStart
36 --
37 -- mpDiiMsg references ('points' to) first byte of DIIMessageBody,
38 -- found (BOOLEAN) indicates whether module descriptor was found
39 --
40 -- mpDiiMsg = const U8BIT* or MemSeqRef,
41 -- dataLength = U32BIT
42 -- mpModuleInfoDescStart = *U8BIT* or *MemSeqRef
43 -- found = BOOLEAN
44 */
45 
46 {
47  MemPtr mpModuleInfoDesc;
48  U16BIT numModules;
49  U16BIT currModuleId;
50  MemPos moduleDataEnd = 0;
51  MemPos currStartPos = 0;
52  U8BIT moduleInfoLength;
53 
54  dsmAssert((mpDiiMsg != NULL));
55  dsmAssert((dataLength > 0));
56  dsmAssert((mpModuleInfoDescStart != NULL));
57 
58 
59  found = FALSE;
60 
61  /* -- Open MemPtr for accessing module info in DII message */
62  MEMPTR_OPEN( mpDiiMsg, mpModuleInfoDesc );
63 
64  /* -- mpModuleInfo -> DIIMessageBody */
65 
66  /* -- Skip downloadId, blockSize - not used here */
67  SET_POS_REL( mpModuleInfoDesc, 6 );
68 
69  /* -- Skip windowSize, ackPeriod, tCDownloadWindow, tCDownloadScenario,
70  -- compatibilityDescriptor - unused in DVB OC */
71  SET_POS_REL( mpModuleInfoDesc, 12 );
72 
73  /* -- Read numberOfModules */
74  READ_UINT16( mpModuleInfoDesc, numModules );
75 
76  /* -- Calculate end position of module data */
77  GET_POS( mpModuleInfoDesc, moduleDataEnd );
78  moduleDataEnd += dataLength;
79 
80  /* -- Loop through module descriptors until we find the right one */
81  while (numModules--)
82  {
83  /* -- mpModuleInfo -> start of module descriptor */
84 
85  /* -- Remember start position of this module descriptor */
86  GET_POS( mpModuleInfoDesc, currStartPos );
87 
88  /* -- Check for end of module data */
89  if (currStartPos >= moduleDataEnd)
90  {
91  break;
92  }
93 
94  /* -- Read moduleId */
95  READ_UINT16( mpModuleInfoDesc, currModuleId );
96 
97  if (currModuleId == moduleId)
98  {
99  found = TRUE;
100  break;
101  }
102 
103  /* -- Skip moduleSize, moduleVersion */
104  SET_POS_REL( mpModuleInfoDesc, 5 );
105 
106  /* -- Read moduleInfoLength */
107  READ_UINT8( mpModuleInfoDesc, moduleInfoLength );
108 
109  /* -- Skip objectInfo */
110  SET_POS_REL( mpModuleInfoDesc, (S32BIT)moduleInfoLength );
111  }
112 
113  if (found)
114  {
115  SET_POS_ABS( *mpModuleInfoDescStart, currStartPos );
116  }
117 
118  MEMPTR_CLOSE( mpModuleInfoDesc );
119 }
120 
121 
122 /*----------------------------------------------------------------------------*/
123 
124 
125