DSMCC  17.9.0
 All Data Structures Files Functions Typedefs
getIopIor_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  *******************************************************************************/
27 /*
28 -- getIorInfo - Common Code
29 --
30 -- Get typeId, location and tap info from IOR data (compatible with
31 -- contiguous or managed/MemSeq memory)
32 --
33 -- Uses/assumes the following vars:
34 -- length_used, mpIorData, pIorTypeId, pLocation, pTap
35 --
36 -- mpIorData references ('points' to) first byte of IOP::IOR
37 -- length_used (U16BIT) indicates whether info was successfully recovered
38 --
39 -- mpIorData = pUInt8 OR MemSeqRef,
40 -- pIorTypeId = U32BIT *
41 -- pLocation = P_ObjectLocation
42 -- pTap = P_DeliveryParaTap
43 -- length_used = U16BIT
44 -- On entry - mpIorData -> first byte of IOR
45 -- On exit - mpIorData -> UNCHANGED
46 */
47 {
48  U32BIT profileIdTag;
49  MemPtr mpIor;
50  MemPtr mpIorStart;
51  MemPtr mpIopProfile;
52  BOOLEAN keyValid;
53  U8BIT ui8 = 0;
54  U16BIT ui16 = 0;
55  U32BIT ui32 = 0;
56  U32BIT profileIndex;
57  U32BIT taggedProfilesCount;
58  U32BIT profileDataLength;
59  /*U8BIT *pDump ;*/
60  /* -- stop compiler warnings when no checking */
61  ui8 += 0;
62 
63  dsmAssert((mpIorData != NULL));
64  dsmAssert((pIorTypeId != NULL));
65  dsmAssert((pLocation != NULL));
66  dsmAssert((pTap != NULL));
67 
68 
69  MEMPTR_OPEN( mpIorData, mpIor );
70 
71  mpIorStart = mpIor;
72 
73  /*pDump = mpIor;*/
74 
75  /* -- mpIor -> start of IOP::IOR */
76 
77  /* -- typeIdLength = 4 (DVB/UK DTT) */
78  ADV_UINT32_L2CHK( mpIor, ui32, ui32 == 4,
79  dsmDP2(("DATA ERROR: IOR typeIdLength (!= 4) = %u\n", ui32)),
80  goto _return_False );
81 
82  /* -- Read typeId */
83  READ_UINT32( mpIor, *pIorTypeId );
84 
85  /* -- taggedProfilesCount >= 1 (DVB/UK DTT) */
86  READ_UINT32_L2CHK( mpIor, taggedProfilesCount, taggedProfilesCount >= 1,
87  dsmDP2(("DATA ERROR: IOR taggedProfilesCount (< 1) = %u\n",
88  taggedProfilesCount)),
89  goto _return_False );
90 
91  /* -- Store location of first IOP::taggedProfile */
92  mpIopProfile = mpIor;
93 
94  /* -- Read profileIdTag */
95  READ_UINT32( mpIor, profileIdTag );
96 
97  pLocation->uiBindingTag = profileIdTag;
98 
99  /* -- mpIor -> start of (first) BIOPProfileBody */
100 
101  if (profileIdTag == TAG_BIOP)
102  {
103  /* -- profileDataLength */
104  ADV_UINT32_L2CHK( mpIor, ui32, ui32 >=
105  (2 + MIN_OBJ_LOCATION_LEN + MIN_CONN_BINDER_LEN),
106  dsmDP2(("DATA ERROR: IOR TAG_BIOP profileDataLength = %u\n", ui32)),
107  goto _return_False );
108 
109  /* -- byteOrder = big_endian (DVB) */
110  /* -- L1 check because if this is wrong, subsequent data will be garbaged */
111  ADV_UINT8_L1CHK( mpIor, ui8, ui8 == 0,
112  dsmDP2(("DATA ERROR: IOR TAG_BIOP byteOrder = %u\n", ui8)),
113  goto _return_False );
114 
115  /* -- liteComponentsCount >= 1 (UK DTT) */
116  /* -- L1 check because if this is wrong, subsequent data will be garbaged */
117  ADV_UINT8_L1CHK( mpIor, ui8, ui8 >= 1,
118  dsmDP2(("DATA ERROR: IOR TAG_BIOP liteComponentsCount (< 1) = %u\n", ui8)),
119  goto _return_False );
120 
121  /* -- mpIor -> start of BIOP::ObjectLocation */
122 
123  /* -- componentIdTag = BIOP::ObjectLocation (DVB/UK DTT) */
124  /* -- L0 check because this must be correct */
125  READ_UINT32_L0CHK( mpIor, ui32, ui32 == TAG_OBJECT_LOCATION,
126  dsmDP2(("DATA ERROR: IOR TAG_BIOP 1st componentIdTag (!= ObjectLocation) = %u\n", ui32)),
127  goto _return_False );
128 
129  /* -- componentDataLength */
130  ADV_UINT8_L2CHK( mpIor, ui8, ui8 >= MIN_OBJLOC_COMPONENT_DATA_LEN,
131  dsmDP2(("DATA ERROR: IOR ObjectLocation componentDataLength = %u\n", ui8)),
132  goto _return_False );
133 
134  /* -- Read carouselId */
135  READ_UINT32( mpIor, pLocation->carouselId );
136 
137  /* -- Read moduleId */
138  READ_UINT16( mpIor, pLocation->moduleId );
139 
140  /* -- BIOP protocol version - major = 0x01, minor = 0x00 (DVB) */
141  ADV_UINT16_L2CHK( mpIor, ui16, ui16 == 0x0100,
142  dsmDP2(("DATA ERROR: IOR ObjectLocation protocol version (!=0x0100) = %u\n", ui16)),
143  goto _return_False );
144 
145  /* -- mpIor -> start of objectKey info */
146  READ_OBJECT_KEY( mpIor, pLocation->objectKey, keyValid );
147  if (!keyValid)
148  {
149  dsmDP2(("DATA ERROR: IOR ObjectLocation objectKey invalid\n"));
150  goto _return_False;
151  }
152 
153  /* -- mpIor -> start of DSM::ConnBinder */
154 
155  /* -- componentIdTag = DSM::ConnBinder (DVB/UK DTT) */
156  /* -- L0 check because this must be correct */
157  READ_UINT32_L0CHK( mpIor, ui32, ui32 == TAG_CONN_BINDER,
158  dsmDP2(("DATA ERROR: IOR TAG_BIOP 2nd componentIdTag (!= ConnBinder) = %u\n", ui32)),
159  goto _return_False );
160 
161  /* -- componentDataLength */
162  ADV_UINT8_L2CHK( mpIor, ui8, ui8 >= MIN_CONBIND_COMPONENT_DATA_LEN,
163  dsmDP2(("DATA ERROR: IOR ConnBinder componentDataLength = %u\n", ui8)),
164  goto _return_False );
165 
166  /* -- tapsCount >= 1 (DVB) */
167  /* -- L1 check because if this is wrong, subsequent data will be garbaged */
168  ADV_UINT8_L1CHK( mpIor, ui8, ui8 >= 1,
169  dsmDP2(("DATA ERROR: IOR ConnBinder tapsCount (< 1) = %u\n", ui8)),
170  goto _return_False );
171 
172 
173  /* -- mpIor -> start of first BIOP::Tap */
174 
175  /* -- Read tapId - TODO: Not required ? */
176  READ_UINT16( mpIor, pTap->id );
177 
178  /* -- 1st tapUse = BIOP_DELIVERY_PARA_USE (in IORs - DVB UK DTT) */
179  /* -- L0 check because this must be correct */
180  READ_UINT16_L0CHK( mpIor, ui16, ui16 == BIOP_DELIVERY_PARA_USE,
181  dsmDP2(("DATA ERROR: IOR ConnBinder 1st tapUse (!= BIOP_DELIVERY_PARA_USE) = %u\n", ui16)),
182  goto _return_False );
183 
184  /* -- Read associationTag */
185  READ_UINT16( mpIor, pTap->associationTag );
186 
187  /* -- selectorLength = 10 (DVB/UK DTT) */
188  ADV_UINT8_L2CHK( mpIor, ui8, ui8 == 0x0A,
189  dsmDP2(("DATA ERROR: IOR ConnBinder tap selectorLength (!= 10) = %u\n", ui8)),
190  goto _return_False );
191 
192  /* -- selectorType = 1 (DVB/UK DTT) */
193  ADV_UINT16_L2CHK( mpIor, ui16, ui16 == 0x0001,
194  dsmDP2(("DATA ERROR: IOR ConnBinder tap selectorType (!= 1) = %u\n", ui16)),
195  goto _return_False );
196 
197  /* -- Read transactionId */
198  READ_UINT32( mpIor, pTap->transactionId );
199 
200  /* -- Read timeout */
201  READ_UINT32( mpIor, pTap->timeout );
202  }
203  else if (profileIdTag == TAG_LITE_OPTIONS)
204  {
205  U8BIT *pWriteNSAPaddr = NULL;
206  U32BIT i = 0;
207 
208  /* -- profileDataLength */
209  SET_POS_REL( mpIor, 4 ); /* changed from thing below as the check did nothing
210  ADV_UINT32_L2CHK( mpIor, ui32, ui32 >= 0,
211  dsmDP2(("DATA ERROR: IOR TAG_BIOP profileDataLength = %u\n", ui32)),
212  goto _return_False );*/
213 
214  /* -- byteOrder = big_endian (DVB) */
215  /* -- L1 check because if this is wrong, subsequent data will be garbaged */
216  ADV_UINT8_L1CHK( mpIor, ui8, ui8 == 0,
217  dsmDP2(("DATA ERROR: IOR TAG_BIOP byteOrder = %u\n", ui8)),
218  goto _return_False );
219 
220  /* -- liteComponentsCount >= 1 (UK DTT) */
221  /* -- L1 check because if this is wrong, subsequent data will be garbaged */
222  ADV_UINT8_L1CHK( mpIor, ui8, ui8 >= 1,
223  dsmDP2(("DATA ERROR: IOR TAG_BIOP liteComponentsCount (< 1) = %u\n", ui8)),
224  goto _return_False );
225 
226  /* -- mpIor -> start of BIOP::ObjectLocation */
227 
228  /* -- componentIdTag = BIOP::ObjectLocation (DVB/UK DTT) */
229  /* -- L0 check because this must be correct */
230  READ_UINT32_L0CHK( mpIor, ui32, ui32 == TAG_SERVICE_LOCATION,
231  dsmDP2(("DATA ERROR: IOR TAG_LITE_OPTIONS 1st componentIdTag (!= ServiceLocation) = %u\n", ui32)),
232  goto _return_False );
233 
234  /* -- componentDataLength */
235  READ_UINT8( mpIor, ui8 );
236 
237  /* -- Read service domain lg */
238  ADV_UINT8_L1CHK( mpIor, ui8, ui8 == 0x14,
239  dsmDP2(("DATA ERROR: IOR TAG_LITE_OPTIONS bad NSAP address length (!= 0x14) = %u\n", ui8)),
240  goto _return_False );
241 
242  pWriteNSAPaddr = &pLocation->dvbCarouselNSAPaddress[0];
243 
244  i = 0;
245  while (i++ < 0x14)
246  {
247  READ_UINT8( mpIor, *(pWriteNSAPaddr++));
248  }
249 
250  #ifdef READ_COSNAMING
251  {
252  U32BIT uiComponentCount;
253  S8BIT *pPathPtr;
254  /* read name component count */
255  READ_UINT32( mpIor, uiComponentCount);
256  pPathPtr = &pLocation->pathName[0];
257  for (i = 0; i < uiComponentCount; i++)
258  {
259  U32BIT uiNameId_lg = 0;
260  U32BIT uiKing_lg = 0;
261  U32BIT j = 0;
262 
263  /* read name_id lg */
264  READ_UINT32( mpIor, uiNameId_lg);
265  if (uiNameId_lg > MAX_PATH_NAME_SIZE)
266  {
267  uiNameId_lg = MAX_PATH_NAME_SIZE;
268  }
269  /* get path */
270  for (j = 0; j < uiNameId_lg; j++)
271  {
272  READ_UINT8( mpIor, ui8);
273  *pPathPtr++ = ui8;
274  }
275  *(pPathPtr++) = '/';
276  /* read path kind lg */
277  READ_UINT32( mpIor, uiKing_lg);
278  /* SKIP path kind data */
279  SET_POS_REL( mpIor, uiKing_lg);
280  }
281  }
282  #endif
283  }
284  else
285  {
286  dsmDP2(("DATA ERROR: IOR - Invalid profileIdTag for DVB object carousel: %x\n",
287  profileIdTag));
288  goto _return_False;
289  }
290 
291  /* -- SKIP ALL TAGGED PROFILES IN IOP::IOR */
292 
293  length_used = (U16BIT)(mpIopProfile - mpIorStart);
294  mpIor = mpIopProfile;
295  for (profileIndex = 0; profileIndex < taggedProfilesCount; profileIndex++)
296  {
297  /* -- Read profileIdTag */
298  READ_UINT32( mpIor, profileIdTag );
299 
300  /* -- profileDataLength */
301  READ_UINT32_L2CHK( mpIor, profileDataLength, profileDataLength >=
302  (2 + MIN_OBJ_LOCATION_LEN + MIN_CONN_BINDER_LEN),
303  dsmDP2(("DATA ERROR: IOR TAG_BIOP profileDataLength = %u\n", ui32)),
304  goto _return_False );
305 
306  /* -- Skip profile */
307  SET_POS_REL( mpIor, profileDataLength );
308 
309  /* -- profileIdTag, profileDataLength and the actual data */
310  length_used += 8 + profileDataLength;
311  }
312 
313  goto _return;
314 
315 _return_False:
316  length_used = 0;
317 
318 _return:
319  /* printf("DUMP -----\n"); */
320 
321 /* while(pDump < mpIor) */
322 /* printf(" 0x%2x",*(pDump++)); */
323 
324 /* printf("\nEND DUMP -----\n"); */
325 
326  MEMPTR_CLOSE( mpIor );
327  DEBUG_CHK( length_used != 0,
328  dsmDP1(("ERROR: getIorInfo failure (invalid)\n")));
329 }
330 
331 
332 /*----------------------------------------------------------------------------*/
333 
334 
335