DSMCC  15.3.1
source/dscore/src/getIopIor_include_src.h
Go to the documentation of this file.
00001 /*******************************************************************************
00002  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
00003  * Copyright © 2004 Ocean Blue Software Ltd
00004  * Copyright © 2001 Koninklijke Philips Electronics N.V
00005  *
00006  * This file is part of a DTVKit Software Component
00007  * You are permitted to copy, modify or distribute this file subject to the terms
00008  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
00009  * 
00010  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00011  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
00012  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00013  * 
00014  * If you or your organisation is not a member of DTVKit then you have access
00015  * to this source code outside of the terms of the licence agreement
00016  * and you are expected to delete this and any associated files immediately.
00017  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
00018  *******************************************************************************/
00027 /*
00028 -- getIorInfo - Common Code
00029 --
00030 -- Get typeId, location and tap info from IOR data (compatible with
00031 -- contiguous or managed/MemSeq memory)
00032 --
00033 -- Uses/assumes the following vars:
00034 --      length_used, mpIorData, pIorTypeId, pLocation, pTap
00035 --
00036 -- mpIorData references ('points' to) first byte of IOP::IOR
00037 -- length_used (U16BIT) indicates whether info was successfully recovered
00038 --
00039 -- mpIorData    = pUInt8 OR MemSeqRef,
00040 -- pIorTypeId   = U32BIT *
00041 -- pLocation    = ObjectLocation_t *
00042 -- pTap         = DeliveryParaTap_t *
00043 -- length_used  = U16BIT
00044 -- On entry - mpIorData -> first byte of IOR
00045 -- On exit  - mpIorData -> UNCHANGED
00046 */
00047 {
00048     U32BIT      profileIdTag;
00049     MemPtr      mpIor;
00050     MemPtr      mpIorStart;
00051     MemPtr      mpIopProfile;
00052     BOOLEAN        keyValid;
00053     U8BIT       ui8  = 0;
00054     U16BIT      ui16 = 0;
00055     U32BIT      ui32 = 0;
00056     U32BIT      profileIndex;
00057     U32BIT      taggedProfilesCount;
00058     U32BIT      profileDataLength;
00059     /*U8BIT *pDump  ;*/
00060     /* -- stop compiler warnings when no checking */
00061     ui8 += 0;
00062 
00063     dsmAssert(( mpIorData != NULL ));
00064     dsmAssert(( pIorTypeId != NULL ));
00065     dsmAssert(( pLocation != NULL ));
00066     dsmAssert(( pTap != NULL ));
00067 
00068 
00069     MEMPTR_OPEN( mpIorData, mpIor );
00070 
00071     mpIorStart = mpIor;
00072 
00073     /*pDump  = mpIor;*/
00074 
00075     /* -- mpIor -> start of IOP::IOR */
00076 
00077     /* -- typeIdLength = 4 (DVB/UK DTT) */
00078     ADV_UINT32_L2CHK( mpIor, ui32, ui32 == 4,
00079         dsmDP2(("DATA ERROR: IOR typeIdLength (!= 4) = %u\n", ui32)),
00080         goto _return_False );
00081 
00082     /* -- Read typeId */
00083     READ_UINT32( mpIor, *pIorTypeId );
00084 
00085     /* -- taggedProfilesCount >= 1 (DVB/UK DTT) */
00086     READ_UINT32_L2CHK( mpIor, taggedProfilesCount, taggedProfilesCount >= 1,
00087         dsmDP2(("DATA ERROR: IOR taggedProfilesCount (< 1) = %u\n",
00088                 taggedProfilesCount)),
00089         goto _return_False );
00090 
00091     /* -- Store location of first IOP::taggedProfile */
00092     mpIopProfile = mpIor;
00093 
00094     /* -- Read profileIdTag */
00095     READ_UINT32( mpIor, profileIdTag );
00096 
00097     pLocation->uiBindingTag = profileIdTag;
00098 
00099     /* -- mpIor -> start of (first) BIOPProfileBody */
00100 
00101     if ( profileIdTag == TAG_BIOP )
00102     {
00103         /* -- profileDataLength */
00104         ADV_UINT32_L2CHK( mpIor, ui32, ui32 >=
00105             (2 + MIN_OBJ_LOCATION_LEN + MIN_CONN_BINDER_LEN),
00106             dsmDP2(("DATA ERROR: IOR TAG_BIOP profileDataLength = %u\n", ui32)),
00107             goto _return_False );
00108 
00109         /* -- byteOrder = big_endian (DVB) */
00110         /* -- L1 check because if this is wrong, subsequent data will be garbaged */
00111         ADV_UINT8_L1CHK( mpIor, ui8, ui8 == 0,
00112             dsmDP2(("DATA ERROR: IOR TAG_BIOP byteOrder = %u\n", ui8)),
00113             goto _return_False );
00114 
00115         /* -- liteComponentsCount >= 1 (UK DTT) */
00116         /* -- L1 check because if this is wrong, subsequent data will be garbaged */
00117         ADV_UINT8_L1CHK( mpIor, ui8, ui8 >= 1,
00118             dsmDP2(("DATA ERROR: IOR TAG_BIOP liteComponentsCount (< 1) = %u\n", ui8)),
00119             goto _return_False );
00120 
00121         /* -- mpIor -> start of BIOP::ObjectLocation */
00122 
00123         /* -- componentIdTag = BIOP::ObjectLocation (DVB/UK DTT) */
00124         /* -- L0 check because this must be correct */
00125         READ_UINT32_L0CHK( mpIor, ui32, ui32 == TAG_OBJECT_LOCATION,
00126             dsmDP2(("DATA ERROR: IOR TAG_BIOP 1st componentIdTag (!= ObjectLocation) = %u\n", ui32)),
00127             goto _return_False );
00128 
00129         /* -- componentDataLength */
00130         ADV_UINT8_L2CHK( mpIor, ui8, ui8 >= MIN_OBJLOC_COMPONENT_DATA_LEN,
00131             dsmDP2(("DATA ERROR: IOR ObjectLocation componentDataLength = %u\n", ui8)),
00132             goto _return_False );
00133 
00134         /* -- Read carouselId */
00135         READ_UINT32( mpIor, pLocation->carouselId );
00136 
00137         /* -- Read moduleId */
00138         READ_UINT16( mpIor, pLocation->moduleId );
00139 
00140         /* -- BIOP protocol version - major = 0x01, minor = 0x00 (DVB) */
00141         ADV_UINT16_L2CHK( mpIor, ui16, ui16 == 0x0100,
00142             dsmDP2(("DATA ERROR: IOR ObjectLocation protocol version (!=0x0100) = %u\n", ui16)),
00143             goto _return_False );
00144 
00145         /* -- mpIor -> start of objectKey info */
00146         READ_OBJECT_KEY( mpIor, pLocation->objectKey, keyValid );
00147         if (!keyValid) {
00148             dsmDP2(("DATA ERROR: IOR ObjectLocation objectKey invalid\n"));
00149             goto _return_False;
00150         }
00151 
00152         /* -- mpIor -> start of DSM::ConnBinder */
00153 
00154         /* -- componentIdTag = DSM::ConnBinder (DVB/UK DTT) */
00155         /* -- L0 check because this must be correct */
00156         READ_UINT32_L0CHK( mpIor, ui32, ui32 == TAG_CONN_BINDER,
00157             dsmDP2(("DATA ERROR: IOR TAG_BIOP 2nd componentIdTag (!= ConnBinder) = %u\n", ui32)),
00158             goto _return_False );
00159 
00160         /* -- componentDataLength */
00161         ADV_UINT8_L2CHK( mpIor, ui8, ui8 >= MIN_CONBIND_COMPONENT_DATA_LEN,
00162             dsmDP2(("DATA ERROR: IOR ConnBinder componentDataLength = %u\n", ui8)),
00163             goto _return_False );
00164 
00165         /* -- tapsCount >= 1 (DVB) */
00166         /* -- L1 check because if this is wrong, subsequent data will be garbaged */
00167         ADV_UINT8_L1CHK( mpIor, ui8, ui8 >= 1,
00168             dsmDP2(("DATA ERROR: IOR ConnBinder tapsCount (< 1) = %u\n", ui8)),
00169             goto _return_False );
00170 
00171 
00172         /* -- mpIor -> start of first BIOP::Tap */
00173 
00174         /* -- Read tapId - TODO: Not required ? */
00175         READ_UINT16( mpIor, pTap->id );
00176 
00177         /* -- 1st tapUse = BIOP_DELIVERY_PARA_USE (in IORs - DVB UK DTT) */
00178         /* -- L0 check because this must be correct */
00179         READ_UINT16_L0CHK( mpIor, ui16, ui16 == BIOP_DELIVERY_PARA_USE,
00180             dsmDP2(("DATA ERROR: IOR ConnBinder 1st tapUse (!= BIOP_DELIVERY_PARA_USE) = %u\n", ui16)),
00181             goto _return_False );
00182 
00183         /* -- Read associationTag */
00184         READ_UINT16( mpIor, pTap->associationTag );
00185 
00186         /* -- selectorLength = 10 (DVB/UK DTT) */
00187         ADV_UINT8_L2CHK( mpIor, ui8, ui8 == 0x0A,
00188             dsmDP2(("DATA ERROR: IOR ConnBinder tap selectorLength (!= 10) = %u\n", ui8)),
00189             goto _return_False );
00190 
00191         /* -- selectorType = 1 (DVB/UK DTT) */
00192         ADV_UINT16_L2CHK( mpIor, ui16, ui16 == 0x0001,
00193             dsmDP2(("DATA ERROR: IOR ConnBinder tap selectorType (!= 1) = %u\n", ui16)),
00194             goto _return_False );
00195 
00196         /* -- Read transactionId */
00197         READ_UINT32( mpIor, pTap->transactionId );
00198 
00199         /* -- Read timeout */
00200         READ_UINT32( mpIor, pTap->timeout );
00201 
00202     }
00203     else if ( profileIdTag == TAG_LITE_OPTIONS )
00204     {
00205 
00206         U32BIT  uiComponentCount = 0;
00207         U8BIT  *pWriteNSAPaddr = NULL;
00208         U32BIT i = 0;
00209         S8BIT   *pPathPtr = NULL;
00210 
00211         /* -- profileDataLength */
00212         SET_POS_REL( mpIor, 4 );  /* changed from thing below as the check did nothing
00213         ADV_UINT32_L2CHK( mpIor, ui32, ui32 >= 0,
00214             dsmDP2(("DATA ERROR: IOR TAG_BIOP profileDataLength = %u\n", ui32)),
00215             goto _return_False );*/
00216 
00217         /* -- byteOrder = big_endian (DVB) */
00218         /* -- L1 check because if this is wrong, subsequent data will be garbaged */
00219         ADV_UINT8_L1CHK( mpIor, ui8, ui8 == 0,
00220             dsmDP2(("DATA ERROR: IOR TAG_BIOP byteOrder = %u\n", ui8)),
00221             goto _return_False );
00222 
00223         /* -- liteComponentsCount >= 1 (UK DTT) */
00224         /* -- L1 check because if this is wrong, subsequent data will be garbaged */
00225         ADV_UINT8_L1CHK( mpIor, ui8, ui8 >= 1,
00226             dsmDP2(("DATA ERROR: IOR TAG_BIOP liteComponentsCount (< 1) = %u\n", ui8)),
00227             goto _return_False );
00228 
00229         /* -- mpIor -> start of BIOP::ObjectLocation */
00230 
00231         /* -- componentIdTag = BIOP::ObjectLocation (DVB/UK DTT) */
00232         /* -- L0 check because this must be correct */
00233         READ_UINT32_L0CHK( mpIor, ui32, ui32 == TAG_SERVICE_LOCATION,
00234             dsmDP2(("DATA ERROR: IOR TAG_LITE_OPTIONS 1st componentIdTag (!= ServiceLocation) = %u\n", ui32)),
00235             goto _return_False );
00236 
00237         /* -- componentDataLength */
00238         READ_UINT8( mpIor, ui8 );
00239 
00240         /* -- Read service domain lg */
00241         ADV_UINT8_L1CHK( mpIor, ui8, ui8 == 0x14,
00242             dsmDP2(("DATA ERROR: IOR TAG_LITE_OPTIONS bad NSAP address length (!=  0x14) = %u\n", ui8)),
00243             goto _return_False );
00244 
00245         pWriteNSAPaddr = &pLocation->dvbCarouselNSAPaddress[0];
00246 
00247         i = 0;
00248         while(i++ < 0x14)
00249         {
00250             READ_UINT8( mpIor, *(pWriteNSAPaddr++));
00251         }
00252 
00253         /* read name component count */
00254         READ_UINT32( mpIor, uiComponentCount);
00255 
00256         pPathPtr = &pLocation->pathName[0];
00257 
00258         for(i=0; i < uiComponentCount; i++)
00259         {
00260             U32BIT  uiNameId_lg = 0;
00261             U32BIT  uiKing_lg = 0;
00262             U32BIT  j = 0;
00263 
00264 
00265             /* read name_id lg */
00266             READ_UINT32( mpIor, uiNameId_lg);
00267 
00268 
00269 
00270             if(uiNameId_lg > MAX_PATH_NAME_SIZE)
00271             {
00272                 uiNameId_lg = MAX_PATH_NAME_SIZE;
00273             }
00274 
00275             /* get path */
00276             for(j=0;j < uiNameId_lg; j++)
00277             {
00278                 READ_UINT8( mpIor,ui8);
00279                 *pPathPtr++=ui8;
00280             }
00281             *(pPathPtr++) = '/';
00282 
00283             /* read path kind lg */
00284             READ_UINT32( mpIor, uiKing_lg);
00285 
00286             /* SKIP path kind data */
00287             SET_POS_REL( mpIor, uiKing_lg);
00288 
00289         }
00290 
00291     }
00292     else
00293     {
00294         dsmDP2(( "DATA ERROR: IOR - Invalid profileIdTag for DVB object carousel: %x\n",
00295                  profileIdTag ));
00296         goto _return_False;
00297     }
00298 
00299     /* -- SKIP ALL TAGGED PROFILES IN IOP::IOR */
00300 
00301     length_used = (U16BIT)(mpIopProfile - mpIorStart);
00302     mpIor = mpIopProfile;
00303     for (profileIndex = 0; profileIndex < taggedProfilesCount; profileIndex++)
00304     {
00305         /* -- Read profileIdTag */
00306         READ_UINT32( mpIor, profileIdTag );
00307 
00308         /* -- profileDataLength */
00309         READ_UINT32_L2CHK( mpIor, profileDataLength, profileDataLength >=
00310             (2 + MIN_OBJ_LOCATION_LEN + MIN_CONN_BINDER_LEN),
00311             dsmDP2(("DATA ERROR: IOR TAG_BIOP profileDataLength = %u\n", ui32)),
00312             goto _return_False );
00313 
00314         /* -- Skip profile */
00315         SET_POS_REL( mpIor, profileDataLength );
00316 
00317         /* -- profileIdTag, profileDataLength and the actual data */
00318         length_used += 8 + profileDataLength;
00319     }
00320 
00321     goto _return;
00322 
00323 _return_False:
00324     length_used = 0;
00325 
00326 _return:
00327  /*  printf("DUMP -----\n"); */
00328 
00329 /*     while(pDump < mpIor) */
00330 /*       printf(" 0x%2x",*(pDump++)); */
00331 
00332 /*     printf("\nEND DUMP -----\n"); */
00333 
00334     MEMPTR_CLOSE( mpIor );
00335     DEBUG_CHK( length_used != 0,
00336         dsmDP1(("ERROR: getIorInfo failure (invalid)\n")) );
00337 }
00338 
00339 
00340 /*----------------------------------------------------------------------------*/
00341 
00342 
00343 
 All Data Structures Files Functions Typedefs