connectivitylayer/isce/isaaccessextension_dll/src/router.cpp
changeset 5 8ccc39f9d787
parent 0 63b37f68c1ce
child 7 fa67e03b87df
equal deleted inserted replaced
4:510c70acdbf6 5:8ccc39f9d787
    17 
    17 
    18 
    18 
    19 #include <phonetisi.h>                  // For ISI_HEADER_SIZE
    19 #include <phonetisi.h>                  // For ISI_HEADER_SIZE
    20 #include <pn_const.h>                   // For PN_HEADER_SIZE
    20 #include <pn_const.h>                   // For PN_HEADER_SIZE
    21 #include <pipeisi.h>                    // For PNS_PIPE_DATA_OFFSET_DATA
    21 #include <pipeisi.h>                    // For PNS_PIPE_DATA_OFFSET_DATA
    22 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
    23 #include <mediaisi.h>                   // For PNS_MEDIA_SPECIFIC_REQ/RESP
       
    24 #include <nsisi.h>                      // For PNS_NAME...
       
    25 #endif // NCP_COMMON_BRIDGE_FAMILY
       
    26 #include <commisi.h>                    // For SIZE_COMMON_MESSAGE_COMM_ISA_ENTITY_NOT_REACHABLE_RESP
    22 #include <commisi.h>                    // For SIZE_COMMON_MESSAGE_COMM_ISA_ENTITY_NOT_REACHABLE_RESP
    27 #include "router.h"
    23 #include "router.h"
    28 #include "iadtrace.h"                   // For C_TRACE..
    24 #include "iadtrace.h"                   // For C_TRACE..
    29 #include "isaaccessextension.h"         // For DIsaAccessExtension
    25 #include "isaaccessextension.h"         // For DIsaAccessExtension
    30 #include "indicationhandler.h"          // For DIndicationHandler
    26 #include "indicationhandler.h"          // For DIndicationHandler
    31 #include "queue.h"                      // For DQueue
    27 #include "queue.h"                      // For DQueue
    32 #include "iadinternaldefinitions.h"     // For EIADAsync...
    28 #include "iadinternaldefinitions.h"     // For EIADAsync...
    33 #include "iadhelpers.h"                 // For GET_RECEIVER
    29 #include "iadhelpers.h"                 // For GET_RECEIVER
       
    30 #include <nsisi.h>                      // For PN_NAMESERVICE...
    34 
    31 
    35 #include "pipehandler.h"                // For PipeHandler
    32 #include "pipehandler.h"                // For PipeHandler
    36 #include "OstTraceDefinitions.h"
    33 #include "OstTraceDefinitions.h"
    37 #ifdef OST_TRACE_COMPILER_IN_USE
    34 #ifdef OST_TRACE_COMPILER_IN_USE
    38 #include "routerTraces.h"
    35 #include "routerTraces.h"
    39 #endif
    36 #endif
    40 
    37 
       
    38 
    41 //#define MODEM_MCE_DOES_NOT_WORK_AS_IT_SHOULD // TODO: to be removed when Bridge Modem SW is ok
    39 //#define MODEM_MCE_DOES_NOT_WORK_AS_IT_SHOULD // TODO: to be removed when Bridge Modem SW is ok
    42 
    40 
    43 // ISCE
    41 // ISCE
    44 #include "memapi.h"                     // For MemApi
    42 #include "memapi.h"                     // For MemApi
    45 #include "trxdefs.h"                    // For ETrx...
    43 #include "trxdefs.h"                    // For ETrx...
    46 // ISCE
    44 // ISCE
    47 // ISCE #include "miad2istapi.h" // For MIAD2ISTApi
       
    48 
       
    49 
       
    50 
    45 
    51 // CONSTS
    46 // CONSTS
    52 #ifndef NCP_COMMON_BRIDGE_FAMILY
    47 DRouter* DRouter::iThisPtr = NULL;
    53 
    48 const TUint32 KCommunicationManagerUID( 0x2002B3D0 );
    54 // TODO : spec this to some document
    49 const TUint32 KNameServiceUID( 0x2002A5A1 );
    55 /**** IAD<->SOS_MM ****/
       
    56 const TUint8 KIADObjId( 0xfe );
       
    57 /* CTRL CONF REQ START *
       
    58 [0]     media,          PN_MEDIA_SOS;
       
    59 [1]     recdev,         PN_MEDIA_ROUTING_REQ
       
    60 [2]     senderdev,      PN_DEV_SOS
       
    61 [3]     function,       PN_MEDIA_CONTROL
       
    62 [4,5]   length,         8
       
    63 [6]     recobj,         PN_OBJ_ROUTER
       
    64 [7]     senderobj,      KIADObjId
       
    65 [8]     transaction     0x00
       
    66 [9]     messageid       PNS_MEDIA_SPECIFIC_REQ
       
    67 [10]    media2control   PN_MEDIA_SOS
       
    68 [11]    ctrl msg id     KIADCtrlConfReq (0x05)
       
    69 [12]    filler          0x00
       
    70 [13]    filler          0x00
       
    71 *  CTRL CONF REQ END */
       
    72 const TUint8 KIADCtrlConfReq( 0x5 );
       
    73 /* CTRL CONF RESP START *
       
    74 [0]     media,          PN_MEDIA_SOS;
       
    75 [1]     recdev,         PN_DEV_SOS
       
    76 [2]     senderdev,      PN_MEDIA_ROUTING_REQ
       
    77 [3]     function,       PN_MEDIA_CONTROL
       
    78 [4,5]   length,         10
       
    79 [6]     recobj,         KIADObjId
       
    80 [7]     senderobj,      PN_OBJ_ROUTER
       
    81 [8]     transaction     0x00
       
    82 [9]     messageid       PNS_MEDIA_SPECIFIC_REQ
       
    83 [10]    media2control   PN_MEDIA_SOS
       
    84 [11]    media error     PN_MCTRL_NO_ERROR
       
    85 [12]    ctrl msg id     KIADCtrlConfResp (0x06)
       
    86 [13]    conf size       8 bytes
       
    87 [14]    conf size       8 bytes
       
    88 [15]    filler          0x00
       
    89 *  CTRL CONF RESP END */
       
    90 const TUint8 KIADCtrlConfResp( 0x6 );
       
    91 /* CTRL DRM REQ START *
       
    92 [0]     media,          PN_MEDIA_SOS;
       
    93 [1]     recdev,         PN_MEDIA_ROUTING_REQ
       
    94 [2]     senderdev,      PN_DEV_SOS
       
    95 [3]     function,       PN_MEDIA_CONTROL
       
    96 [4,5]   length,         8 ( + 6 = KIADCtrlDrmReqLength )
       
    97 [6]     recobj,         PN_OBJ_ROUTER
       
    98 [7]     senderobj,      KIADObjId
       
    99 [8]     channel number  IAD client's channel number
       
   100 [9]     messageid       PNS_MEDIA_SPECIFIC_REQ
       
   101 [10]    mediatocontrol  PN_MEDIA_SOS
       
   102 [11]    ctrl msg id     KIADCtrlDrmReq (0x07)
       
   103 [12]    ch is 2 be reg  IAD client's channel number
       
   104 [13]    filler          0x00
       
   105 *  CTRL DRM REQ END */
       
   106 const TUint8 KIADCtrlDrmReq( 0x7 );
       
   107 const TInt KIADCtrlDrmReqLength( 14 );
       
   108 /* CTRL DRM RESP START *
       
   109 [0]     media,          PN_MEDIA_SOS;
       
   110 [1]     recdev,         PN_DEV_SOS
       
   111 [2]     senderdev,      PN_MEDIA_ROUTING_REQ
       
   112 [3]     function,       PN_MEDIA_CONTROL
       
   113 [4,5]   length,         8
       
   114 [6]     recobj,         KIADObjId
       
   115 [7]     senderobj,      PN_OBJ_ROUTER
       
   116 [8]     channel number  IAD client's channel number
       
   117 [9]     messageid       PNS_MEDIA_SPECIFIC_RESP
       
   118 [10]    mediatocontrol  PN_MEDIA_SOS
       
   119 [11]    media error     PN_MCTRL_NO_ERROR
       
   120 [12]    ctrl msg id     KIADCtrlDrmResp (0x08)
       
   121 [13]    filler          0x00
       
   122 * CTRL DRM REQ END */
       
   123 const TUint8 KIADCtrlDrmResp( 0x8 );
       
   124 
       
   125 #define CTRL_REQ_OFFSET_MESSAGEID ( ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_REQ_OFFSET_DATA )
       
   126 #define CTRL_RESP_OFFSET_MESSAGEID ( ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_RESP_OFFSET_DATA )
       
   127 #define CTRL_CONF_RESP_OFFSET_SIZE_BYTE1 ( CTRL_RESP_OFFSET_MESSAGEID + 1 )
       
   128 #define CTRL_CONF_RESP_OFFSET_SIZE_BYTE2 ( CTRL_CONF_RESP_OFFSET_SIZE_BYTE1 + 1 )
       
   129 #define CTR_DRM_REQ_RESP_OFFSET_CHANNEL_ID ( ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_RESP_OFFSET_UTID )
       
   130 #define CTRL_DRM_REQ_OFFSET_REQUIRED_CHANNEL_ID ( CTRL_REQ_OFFSET_MESSAGEID + 1 )
       
   131 #endif // NCP_COMMON_BRIDGE_FAMILY
       
   132 
    50 
   133 // TODO: change this to use UnuqueID instead and to extension..
    51 // TODO: change this to use UnuqueID instead and to extension..
   134 void DRouter::CheckDfc()
    52 void DRouter::CheckDfc()
   135 {
    53 {
   136     OstTrace0( TRACE_NORMAL, DROUTER_CHECKDFC_ENTRY, ">DRouter::CheckDfc" );
    54     OstTrace0( TRACE_NORMAL, DROUTER_CHECKDFC_ENTRY, ">DRouter::CheckDfc" );
   167     {
    85     {
   168     OstTrace0( TRACE_NORMAL, DROUTER_DROUTER_ENTRY, "<DRouter::DRouter" );
    86     OstTrace0( TRACE_NORMAL, DROUTER_DROUTER_ENTRY, "<DRouter::DRouter" );
   169     
    87     
   170     C_TRACE( ( _T( "DRouter::DRouter ->" ) ) );
    88     C_TRACE( ( _T( "DRouter::DRouter ->" ) ) );
   171     // owned
    89     // owned
   172 #ifndef NCP_COMMON_BRIDGE_FAMILY
    90 #ifdef NCP_COMMON_BRIDGE_FAMILY_PIPE_SUPPORT
   173     iPipeHandler = new DPipeHandler( *this );
    91     iPipeHandler = new DPipeHandler( *this );
   174 #endif
    92 #endif
   175     iIndicationHandler = new DIndicationHandler( *this );
    93     iIndicationHandler = new DIndicationHandler( *this );
   176     iCommonRxQueue = new DQueue( KIADExtensionRxQueueSize );
    94     iCommonRxQueue = new DQueue( KIADExtensionRxQueueSize );
   177     ASSERT_RESET_ALWAYS( /*iPipeHandler &&*/ iIndicationHandler && iCommonRxQueue, EIADMemoryAllocationFailure | EIADFaultIdentifier17 << KFaultIdentifierShift );
    95     ASSERT_RESET_ALWAYS( /*iPipeHandler &&*/ iIndicationHandler && iCommonRxQueue, EIADMemoryAllocationFailure | EIADFaultIdentifier17 << KFaultIdentifierShift );
   199         {
   117         {
   200         iLinksArray[ i ] = NULL;
   118         iLinksArray[ i ] = NULL;
   201         C_TRACE( ( _T( "DRouter::DRouter %d" ), i ) );
   119         C_TRACE( ( _T( "DRouter::DRouter %d" ), i ) );
   202         }
   120         }
   203     // Configuration of ISI links. TODO: devices and link configurations for coming platforms are unknown and to be done later.
   121     // Configuration of ISI links. TODO: devices and link configurations for coming platforms are unknown and to be done later.
   204 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
   205     iLinksArray[ DRouter::EISIMediaSOS ] = MISIRouterLinkIf::CreateLinkF( this, PN_MEDIA_SOS, ETrxPartnerOS );
       
   206 #else
       
   207     // Bridge media = PN_MEDIA_MODEM_HOST_IF
       
   208     iLinksArray[ DRouter::EISIMediaHostSSI ] = MISIRouterLinkIf::CreateLinkF( this, PN_MEDIA_MODEM_HOST_IF, ETrxSharedMemory );
   122     iLinksArray[ DRouter::EISIMediaHostSSI ] = MISIRouterLinkIf::CreateLinkF( this, PN_MEDIA_MODEM_HOST_IF, ETrxSharedMemory );
   209 #endif // NCP_COMMON_BRIDGE_FAMILY
   123     DRouter::iThisPtr = this;
   210     // ISCE
       
   211     C_TRACE( ( _T( "DRouter::DRouter 0x%x <-" ), this ) );
   124     C_TRACE( ( _T( "DRouter::DRouter 0x%x <-" ), this ) );
   212     OstTrace1( TRACE_NORMAL, DROUTER_DROUTER_EXIT, "<DRouter::DRouter;this=%x", this );
   125     OstTrace1( TRACE_NORMAL, DROUTER_DROUTER_EXIT, "<DRouter::DRouter;this=%x", this );
   213     }
   126     }
   214     
   127 
   215 DRouter::~DRouter(
   128 DRouter::~DRouter(
   216         // None
   129         // None
   217        )
   130        )
   218     {
   131     {
       
   132 
   219     OstTrace0( TRACE_NORMAL, DUP1_DROUTER_DROUTER_ENTRY, "<DRouter::~DRouter" );
   133     OstTrace0( TRACE_NORMAL, DUP1_DROUTER_DROUTER_ENTRY, "<DRouter::~DRouter" );
   220 //ISCE
   134 //ISCE
   221     // owning so deleting
   135     // owning so deleting
   222     for( TInt i( 0 ); i < EISIAmountOfMedias; i++ )
   136     for( TInt i( 0 ); i < EISIAmountOfMedias; i++ )
   223         {
   137         {
   233         {
   147         {
   234         iChannelTable[ i ].iChannel = NULL;
   148         iChannelTable[ i ].iChannel = NULL;
   235         iChannelTable[ i ].iWaitingChannel = NULL;
   149         iChannelTable[ i ].iWaitingChannel = NULL;
   236         iChannelTable[ i ].iType = ENormalOpen;
   150         iChannelTable[ i ].iType = ENormalOpen;
   237         }
   151         }
   238 #ifndef NCP_COMMON_BRIDGE_FAMILY
   152 #ifdef NCP_COMMON_BRIDGE_FAMILY_PIPE_SUPPORT
   239     if( iPipeHandler )
   153     if( iPipeHandler )
   240         {
   154         {
   241         delete iPipeHandler;
   155         delete iPipeHandler;
   242         iPipeHandler = NULL;
   156         iPipeHandler = NULL;
   243         }
   157         }
   299     OstTraceExt1( TRACE_NORMAL, DROUTER_ALLOCATEDATABLOCK_ENTRY, ">DRouter::AllocateDataBlock;aSize=%hu", aSize );
   213     OstTraceExt1( TRACE_NORMAL, DROUTER_ALLOCATEDATABLOCK_ENTRY, ">DRouter::AllocateDataBlock;aSize=%hu", aSize );
   300 
   214 
   301     C_TRACE( ( _T( "DRouter::AllocateDataBlock %d <->" ), aSize ) );
   215     C_TRACE( ( _T( "DRouter::AllocateDataBlock %d <->" ), aSize ) );
   302     TUint32 neededLength( aSize + ISI_HEADER_SIZE + PNS_PIPE_DATA_OFFSET_DATA );
   216     TUint32 neededLength( aSize + ISI_HEADER_SIZE + PNS_PIPE_DATA_OFFSET_DATA );
   303     TDes8& tmp = this->AllocateBlock( neededLength );
   217     TDes8& tmp = this->AllocateBlock( neededLength );
   304 #ifndef NCP_COMMON_BRIDGE_FAMILY
   218 #ifdef NCP_COMMON_BRIDGE_FAMILY_PIPE_SUPPORT
   305     tmp.SetLength( neededLength );
   219     tmp.SetLength( neededLength );
   306     TUint8* msgPtr = const_cast<TUint8*>( tmp.Ptr() );
   220     TUint8* msgPtr = const_cast<TUint8*>( tmp.Ptr() );
   307     SET_RECEIVER_DEV( msgPtr, PN_DEV_DONT_CARE );    
   221     SET_RECEIVER_DEV( msgPtr, PN_DEV_DONT_CARE );    
   308     ASSERT_RESET_ALWAYS( neededLength > ISI_HEADER_OFFSET_MESSAGEID, EIADOverTheLimits | EIADFaultIdentifier1 << KFaultIdentifierShift  );
   222     ASSERT_RESET_ALWAYS( neededLength > ISI_HEADER_OFFSET_MESSAGEID, EIADOverTheLimits | EIADFaultIdentifier1 << KFaultIdentifierShift  );
   309     msgPtr[ ISI_HEADER_OFFSET_RESOURCEID ] = PN_PIPE;
   223     msgPtr[ ISI_HEADER_OFFSET_RESOURCEID ] = PN_PIPE;
   322     {
   236     {
   323 
   237 
   324     OstTraceExt1( TRACE_NORMAL, DROUTER_CLOSE_ENTRY, ">DRouter::Close;aChannelId=%hx", aChannelId );
   238     OstTraceExt1( TRACE_NORMAL, DROUTER_CLOSE_ENTRY, ">DRouter::Close;aChannelId=%hx", aChannelId );
   325     C_TRACE( ( _T( "DRouter::Close 0x%x ->" ), aChannelId ) );
   239     C_TRACE( ( _T( "DRouter::Close 0x%x ->" ), aChannelId ) );
   326     // Channel must be from appropiate length and although it is sixteenbit value it must contain only 8-bit values. If over 8-bit changes needed.
   240     // Channel must be from appropiate length and although it is sixteenbit value it must contain only 8-bit values. If over 8-bit changes needed.
   327     ASSERT_RESET_ALWAYS( aChannelId < EIADSizeOfChannels || aChannelId < 0xff, EIADWrongParameter | EIADFaultIdentifier10 << KFaultIdentifierShift );
   241     ASSERT_RESET_ALWAYS( aChannelId < EIADSizeOfChannels || aChannelId < 0xff, EIADWrongParameter | EIADFaultIdentifier10 << KFaultIdentifierShift | aChannelId << KChannelNumberShift );
   328     ASSERT_DFCTHREAD_INEXT();
   242     ASSERT_DFCTHREAD_INEXT();
   329     // If channel open (!NULL) set as closed (NULL) or if channel open is pending.
   243     // If channel open (!NULL) set as closed (NULL) or if channel open is pending.
   330     ASSERT_RESET_ALWAYS( aChannelId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)aChannelId << KChannelNumberShift | EIADFaultIdentifier21 << KFaultIdentifierShift );
   244     ASSERT_RESET_ALWAYS( aChannelId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)aChannelId << KChannelNumberShift | EIADFaultIdentifier21 << KFaultIdentifierShift );
   331     if( iChannelTable[ aChannelId ].iChannel || iChannelTable[ aChannelId ].iWaitingChannel )
   245     if( iChannelTable[ aChannelId ].iChannel || iChannelTable[ aChannelId ].iWaitingChannel )
   332         {
   246         {
   452             aCallback->CompleteChannelRequest( aRequest, ( iChannelTable[ aChannel ].iChannel == aCallback ? KErrInUse : KErrAlreadyExists ) );
   366             aCallback->CompleteChannelRequest( aRequest, ( iChannelTable[ aChannel ].iChannel == aCallback ? KErrInUse : KErrAlreadyExists ) );
   453             }
   367             }
   454         // Null so channel is not open, set !null to mark opened channel.
   368         // Null so channel is not open, set !null to mark opened channel.
   455         else
   369         else
   456             {
   370             {
   457 #ifndef NCP_COMMON_BRIDGE_FAMILY
   371             C_TRACE( ( _T( "DRouter::Open channel 0x%x normal 0x%x" ), aChannel, aCallback ) );
   458             const TBool drmChannel( ( aChannel == EIADNokiaDRM || aChannel == EIADNokiaSecurityDriver ) ? ETrue : EFalse );
   372             OstTraceExt1( TRACE_NORMAL, DUP1_DROUTER_OPEN, "DRouter::Open normal;aChannel=%hx", aChannel );
   459             if( drmChannel )
   373             iChannelTable[ aChannel ].iChannel = aCallback;
   460                 {
   374             aCallback->CompleteChannelRequest( aRequest, KErrNone );
   461                 C_TRACE( ( _T( "DRouter::Open channel 0x%x drm 0x%x" ), aChannel, aCallback ) );
       
   462                 OstTraceExt1( TRACE_NORMAL, DROUTER_OPEN, "DRouter::Open DRM;aChannel=%hx", aChannel );
       
   463                 iChannelTable[ aChannel ].iWaitingChannel = aCallback;
       
   464                 iChannelTable[ aChannel ].iType = EDrmOpen;
       
   465                 SendDrmReq( aChannel );
       
   466                 }
       
   467             else
       
   468                 {
       
   469 #endif // NCP_COMMON_BRIDGE_FAMILY
       
   470                 C_TRACE( ( _T( "DRouter::Open channel 0x%x normal 0x%x" ), aChannel, aCallback ) );
       
   471                 OstTraceExt1( TRACE_NORMAL, DUP1_DROUTER_OPEN, "DRouter::Open normal;aChannel=%hx", aChannel );
       
   472                 iChannelTable[ aChannel ].iChannel = aCallback;
       
   473                 aCallback->CompleteChannelRequest( aRequest, KErrNone );
       
   474 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
   475                 }
       
   476 #endif // NCP_COMMON_BRIDGE_FAMILY
       
   477             }
   375             }
   478         }
   376         }
   479     else
   377     else
   480         {
   378         {
   481         C_TRACE( ( _T( "DRouter::Open not ready" ) ) );
   379         C_TRACE( ( _T( "DRouter::Open not ready" ) ) );
   482         OstTrace0( TRACE_NORMAL, DUP2_DROUTER_OPEN, "DRouter::Open Not ready" );        
   380         OstTrace0( TRACE_NORMAL, DUP2_DROUTER_OPEN, "DRouter::Open Not ready" );        
   483         ASSERT_RESET_ALWAYS( !iChannelTable[ aChannel ].iWaitingChannel, EIADWrongRequest | EIADFaultIdentifier15 << KFaultIdentifierShift  );
   381         ASSERT_RESET_ALWAYS( !iChannelTable[ aChannel ].iWaitingChannel, EIADWrongRequest | EIADFaultIdentifier15 << KFaultIdentifierShift  );
   484         iChannelTable[ aChannel ].iWaitingChannel = aCallback;
   382         iChannelTable[ aChannel ].iWaitingChannel = aCallback;
   485         iChannelTable[ aChannel ].iType = ( ( aChannel == EIADNokiaDRM || aChannel == EIADNokiaSecurityDriver ) ?
   383         iChannelTable[ aChannel ].iType = ( ( aChannel == EIADNokiaDRM || aChannel == EIADNokiaSecurityDriver ) ? ENormalOpen : ENormalOpen );//??? TODO FIX THIS
   486 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
   487 EDrmOpen : ENormalOpen );
       
   488 #else
       
   489 ENormalOpen : ENormalOpen );
       
   490 #endif // NCP_COMMON_BRIDGE_FAMILY
       
   491         }
   384         }
   492     C_TRACE( ( _T( "DRouter::Open 0x%x <-" ), aChannel ) );
   385     C_TRACE( ( _T( "DRouter::Open 0x%x <-" ), aChannel ) );
   493 
       
   494     OstTraceExt1( TRACE_NORMAL, DROUTER_OPEN_EXIT, "<DRouter::Open;aChannel=%hx", aChannel );
   386     OstTraceExt1( TRACE_NORMAL, DROUTER_OPEN_EXIT, "<DRouter::Open;aChannel=%hx", aChannel );
   495     
   387 
   496     }
   388     }
   497 
   389 
   498 // With resource and media
   390 // With resource and media
   499 EXPORT_C void DRouter::Open(
   391 EXPORT_C void DRouter::Open(
   500         const TUint16 aChannel,
   392         const TUint16 aChannel,
   502         const TDesC8& aOpenInfo,
   394         const TDesC8& aOpenInfo,
   503         MIAD2ChannelApi* aCallback
   395         MIAD2ChannelApi* aCallback
   504         )
   396         )
   505     {
   397     {
   506     OstTraceExt4( TRACE_NORMAL, DUP1_DROUTER_OPEN_ENTRY, ">DRouter::Open;aChannel=%hx;aRequest=%hu;aOpenInfo=%x;aCallback=%x", aChannel, aRequest, ( TUint )&( aOpenInfo ), ( TUint )( aCallback ) );
   398     OstTraceExt4( TRACE_NORMAL, DUP1_DROUTER_OPEN_ENTRY, ">DRouter::Open;aChannel=%hx;aRequest=%hu;aOpenInfo=%x;aCallback=%x", aChannel, aRequest, ( TUint )&( aOpenInfo ), ( TUint )( aCallback ) );
   507 //TODO: open with resource: change not to be permit one and in closing pn_name_remove_req.
       
   508     C_TRACE( ( _T( "DRouter::Open 0x%x %d 0x%x 0x%x ->" ), aChannel, aRequest, &aOpenInfo, aCallback ) );
   399     C_TRACE( ( _T( "DRouter::Open 0x%x %d 0x%x 0x%x ->" ), aChannel, aRequest, &aOpenInfo, aCallback ) );
   509 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
   510     ASSERT_RESET_ALWAYS( aCallback, EIADNullParameter | EIADFaultIdentifier20 << KFaultIdentifierShift  );
       
   511     ASSERT_DFCTHREAD_INEXT();
       
   512     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, EIADWrongParameter | (TUint8)aChannel << KChannelNumberShift | EIADFaultIdentifier27 << KFaultIdentifierShift );
       
   513     if( iConnectionStatus == EIADConnectionOk )
       
   514         {
       
   515         // If not null channel is allready open.
       
   516         if( iChannelTable[ aChannel ].iChannel ||
       
   517             iChannelTable[ aChannel ].iWaitingChannel )
       
   518             {
       
   519             // If another channel tries to open already open channel.
       
   520             OstTrace0( TRACE_NORMAL, DUP4_DROUTER_OPEN, "DRouter::Open already open channel" );            
       
   521             TRACE_WARNING( iChannelTable[ aChannel ].iChannel == aCallback, (TUint8)aChannel << KChannelNumberShift );
       
   522             aCallback->CompleteChannelRequest( aRequest, ( iChannelTable[ aChannel ].iChannel == aCallback ? KErrInUse : KErrAlreadyExists ) );
       
   523             }
       
   524         // Null so channel is not open, set !null to mark opened channel.
       
   525         else
       
   526             {
       
   527             OstTrace0( TRACE_NORMAL, DUP3_DROUTER_OPEN, "DRouter::Open with resource" );            
       
   528             C_TRACE( ( _T( "DRouter::Open channel with resource 0x%x 0x%x" ), aChannel, aCallback ) );
       
   529             iChannelTable[ aChannel ].iWaitingChannel = aCallback;
       
   530             iChannelTable[ aChannel ].iType = ENameAddOpen;
       
   531             SendPnsNameAddReq( aChannel, aOpenInfo );
       
   532             }
       
   533         }
       
   534     else
       
   535         {
       
   536         C_TRACE( ( _T( "DRouter::Open with resource not ready" ) ) );
       
   537         // Opening with resource Id is not supported before IAD is initialized. 
       
   538         // If needed, client can open channel without resource Id and send PNS_NAME_ADD_REQ after 
       
   539         // channel open is actually completed
       
   540         TRACE_ASSERT_INFO( 0, (TUint8)aChannel<<KChannelNumberShift );
       
   541         ASSERT_RESET_ALWAYS( iBootDone, EIADNotSupported | EIADFaultIdentifier5 << KFaultIdentifierShift | (TUint8)aChannel<<KChannelNumberShift );        
       
   542         }
       
   543 #else // NCP_COMMON_BRIDGE_FAMILY
       
   544     // Some maniac from modem sw decided to remove name service in the last meters, hip-hip hurray inform which clients use resource from open to help debug!
   400     // Some maniac from modem sw decided to remove name service in the last meters, hip-hip hurray inform which clients use resource from open to help debug!
   545     TRACE_ASSERT_INFO( 0, (TUint8)aChannel<<KChannelNumberShift );
   401     TRACE_ASSERT_INFO( 0, (TUint8)aChannel<<KChannelNumberShift );
   546     // Treat as normal open to enable the sending NOTE! resource is not functioning!!
   402     // Treat as normal open to enable the sending.
       
   403     // NOTE! SUPPORT FOR RESOURCE OPEN DOES NOT EXISTS: CLIENT SHOULD NAME SERVICE BY ISI IF. SUPPORT FOR NAME SERVICE DOES NOT EXIST IN APE SW YET: NCP_COMMON_BRIDGE_FAMILY_NAME_SERVICE_SUPPORT
   547     Open( aChannel, aRequest, aCallback );
   404     Open( aChannel, aRequest, aCallback );
   548 #endif // NCP_COMMON_BRIDGE_FAMILY
       
   549 
       
   550     C_TRACE( ( _T( "DRouter::Open 0x%x <-" ), aChannel ) );
   405     C_TRACE( ( _T( "DRouter::Open 0x%x <-" ), aChannel ) );
   551 
       
   552     OstTraceExt1( TRACE_NORMAL, DUP1_DROUTER_OPEN_EXIT, "<DRouter::Open;aChannel=%hx", aChannel );
   406     OstTraceExt1( TRACE_NORMAL, DUP1_DROUTER_OPEN_EXIT, "<DRouter::Open;aChannel=%hx", aChannel );
       
   407 
   553     }
   408     }
   554 
   409 
   555 #if (NCP_COMMON_SOS_VERSION_SUPPORT >= SOS_VERSION_95)
   410 #if (NCP_COMMON_SOS_VERSION_SUPPORT >= SOS_VERSION_95)
   556 EXPORT_C TInt DRouter::Loan(
   411 EXPORT_C TInt DRouter::Loan(
   557         const TUint16 aChannel,
   412         const TUint16 aChannel,
   565     ASSERT_RESET_ALWAYS( aCallback, EIADNullParameter | EIADFaultIdentifier19 << KFaultIdentifierShift  );// TODO
   420     ASSERT_RESET_ALWAYS( aCallback, EIADNullParameter | EIADFaultIdentifier19 << KFaultIdentifierShift  );// TODO
   566     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, EIADWrongParameter | EIADFaultIdentifier11 << KFaultIdentifierShift );// TODO
   421     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, EIADWrongParameter | EIADFaultIdentifier11 << KFaultIdentifierShift );// TODO
   567     ASSERT_DFCTHREAD_INEXT();
   422     ASSERT_DFCTHREAD_INEXT();
   568     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, aChannel );
   423     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, aChannel );
   569     TInt error( KErrNone );
   424     TInt error( KErrNone );
   570 #ifndef NCP_COMMON_BRIDGE_FAMILY
   425 #ifdef NCP_COMMON_BRIDGE_FAMILY_PIPE_SUPPORT
   571     // Is connection lost.
   426     // Is connection lost.
   572     error = ( iConnectionStatus == EIADConnectionNotOk ) ? KErrNotSupported : error;
   427     error = ( iConnectionStatus == EIADConnectionNotOk ) ? KErrNotSupported : error;
   573     TRACE_ASSERT_INFO( KErrNone == error, error );
   428     TRACE_ASSERT_INFO( KErrNone == error, error );
   574     // Is loaning a resticted channel.
   429     // Is loaning a resticted channel.
   575     error = ( KErrNone == error && ( aChannel == EIADNokiaDRM || aChannel == EIADNokiaSecurityDriver ) ) ? KErrNotSupported : error;
   430     error = ( KErrNone == error && ( aChannel == EIADNokiaDRM || aChannel == EIADNokiaSecurityDriver ) ) ? KErrNotSupported : error;
   612     ASSERT_RESET_ALWAYS( aCallback, EIADNullParameter | EIADFaultIdentifier19 << KFaultIdentifierShift  );// TODO
   467     ASSERT_RESET_ALWAYS( aCallback, EIADNullParameter | EIADFaultIdentifier19 << KFaultIdentifierShift  );// TODO
   613     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, EIADWrongParameter | EIADFaultIdentifier11 << KFaultIdentifierShift );// TODO
   468     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, EIADWrongParameter | EIADFaultIdentifier11 << KFaultIdentifierShift );// TODO
   614     ASSERT_DFCTHREAD_INEXT();
   469     ASSERT_DFCTHREAD_INEXT();
   615     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, aChannel );
   470     ASSERT_RESET_ALWAYS( aChannel < EIADSizeOfChannels, aChannel );
   616     TInt error( KErrNone );
   471     TInt error( KErrNone );
   617 #ifndef NCP_COMMON_BRIDGE_FAMILY
   472 #ifdef NCP_COMMON_BRIDGE_FAMILY_PIPE_SUPPORT
   618     // Is connection lost.
   473     // Is connection lost.
   619     error = ( iConnectionStatus == EIADConnectionNotOk ) ? KErrNotSupported : error;
   474     error = ( iConnectionStatus == EIADConnectionNotOk ) ? KErrNotSupported : error;
   620     TRACE_ASSERT_INFO( KErrNone == error, error );
   475     TRACE_ASSERT_INFO( KErrNone == error, error );
   621     // Is loaning a resticted channel.
   476     // Is loaning a resticted channel.
   622     error = ( KErrNone == error && ( aChannel == EIADNokiaDRM || aChannel == EIADNokiaSecurityDriver ) ) ? KErrNotSupported : error;
   477     error = ( KErrNone == error && ( aChannel == EIADNokiaDRM || aChannel == EIADNokiaSecurityDriver ) ) ? KErrNotSupported : error;
   699         const TUint8* msgBlockPtr( aMessage.Ptr() );
   554         const TUint8* msgBlockPtr( aMessage.Ptr() );
   700         // TODO: Simplify this        
   555         // TODO: Simplify this        
   701         ASSERT_RESET_ALWAYS( aMessage.Length() > ISI_HEADER_OFFSET_RESOURCEID, EIADOverTheLimits | EIADFaultIdentifier2 << KFaultIdentifierShift  );
   556         ASSERT_RESET_ALWAYS( aMessage.Length() > ISI_HEADER_OFFSET_RESOURCEID, EIADOverTheLimits | EIADFaultIdentifier2 << KFaultIdentifierShift  );
   702         if( msgBlockPtr[ ISI_HEADER_OFFSET_RESOURCEID ] == PN_PIPE && msgBlockPtr[ ISI_HEADER_OFFSET_SENDERDEVICE ] == THIS_DEVICE )
   557         if( msgBlockPtr[ ISI_HEADER_OFFSET_RESOURCEID ] == PN_PIPE && msgBlockPtr[ ISI_HEADER_OFFSET_SENDERDEVICE ] == THIS_DEVICE )
   703             {
   558             {
   704 #ifndef NCP_COMMON_BRIDGE_FAMILY
   559 #ifdef NCP_COMMON_BRIDGE_FAMILY_PIPE_SUPPORT
   705             // This shall send the message and deallocate it too.
   560             // This shall send the message and deallocate it too.
   706             error = iPipeHandler->SendPipeMessage( aMessage, aCh );
   561             error = iPipeHandler->SendPipeMessage( aMessage, aCh );
       
   562 #else
       
   563 			error = KErrNotSupported;
   707 #endif
   564 #endif
   708             if( error != KErrNone )
   565             if( error != KErrNone )
   709                 {
   566                 {
   710                 // Deallocate the block.
   567                 // Deallocate the block.
   711                 this->DeAllocateBlock( aMessage );
   568                 this->DeAllocateBlock( aMessage );
   727                 TUint8* indicationPtr = const_cast<TUint8*>( tmpIndication.Ptr() );
   584                 TUint8* indicationPtr = const_cast<TUint8*>( tmpIndication.Ptr() );
   728                 SET_RECEIVER_DEV( indicationPtr, THIS_DEVICE );
   585                 SET_RECEIVER_DEV( indicationPtr, THIS_DEVICE );
   729                 SET_RECEIVER_OBJ( indicationPtr, KIADEventSubscriptionObjId );
   586                 SET_RECEIVER_OBJ( indicationPtr, KIADEventSubscriptionObjId );
   730                 this->MessageReceived( tmpIndication );
   587                 this->MessageReceived( tmpIndication );
   731                 }
   588                 }
   732             // The IST shall deallocate the block when it's approriate to do.
   589             // To communicationmanager
   733             C_TRACE( ( _T( "DRouter::SendMessage sending 0x%x" ), &aMessage ) );
   590             if( ( msgBlockPtr[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] == PN_OBJ_EVENT_MULTICAST  )
   734             OstTrace1( TRACE_NORMAL, DUP3_DROUTER_SENDMESSAGE, "DRouter::SendMessage;aMessage=%x", (TUint)&(aMessage ));
   591                && ( msgBlockPtr[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) )
   735             error = SendMsg( aMessage );
   592                 {
       
   593                 C_TRACE( ( _T( "DRouter::SendMessage sending to COMMUNICATIONMANAGER>" ) ) );
       
   594                 iCommunicationManager->Receive( aMessage );
       
   595                 C_TRACE( ( _T( "DRouter::SendMessage sending to COMMUNICATIONMANAGER<" ) ) );
       
   596                 }
       
   597             else if( ( msgBlockPtr[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] == PN_OBJ_ROUTING_REQ  )
       
   598                && ( msgBlockPtr[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) )
       
   599                 {
       
   600                 C_TRACE( ( _T( "DRouter::SendMessage sending to NAMESERVICE>" ) ) );
       
   601                 iNameService->Receive( aMessage );
       
   602                 C_TRACE( ( _T( "DRouter::SendMessage sending to NAMESERVICE<" ) ) );
       
   603                 }
       
   604             else // Normal way
       
   605                 {
       
   606                 // The IST shall deallocate the block when it's approriate to do.
       
   607                 C_TRACE( ( _T( "DRouter::SendMessage sending 0x%x" ), &aMessage ) );
       
   608                 OstTrace1( TRACE_NORMAL, DUP3_DROUTER_SENDMESSAGE, "DRouter::SendMessage;aMessage=%x", (TUint)&(aMessage ));
       
   609                 error = SendMsg( aMessage );
       
   610                 }
   736             }//PIPE
   611             }//PIPE
   737         }
   612         }
   738     else
   613     else
   739         {
   614         {
   740         C_TRACE( ( _T( "DRouter::SendMessage not sending due error 0x%x %d %d" ), &aMessage, aCh, error ) );
   615         C_TRACE( ( _T( "DRouter::SendMessage not sending due error 0x%x %d %d" ), &aMessage, aCh, error ) );
   837         )
   712         )
   838     {
   713     {
   839     OstTrace1( TRACE_NORMAL, DROUTER_HANDLEISIMESSAGE_ENTRY, ">DRouter::HandleIsiMessage;aMsg=%x", ( TUint )&( aMsg ) );
   714     OstTrace1( TRACE_NORMAL, DROUTER_HANDLEISIMESSAGE_ENTRY, ">DRouter::HandleIsiMessage;aMsg=%x", ( TUint )&( aMsg ) );
   840 
   715 
   841     C_TRACE( ( _T( "DRouter::HandleIsiMessage 0x%x ->" ), &aMsg ) );
   716     C_TRACE( ( _T( "DRouter::HandleIsiMessage 0x%x ->" ), &aMsg ) );
   842     const TUint16 rcvObjId( GET_RECEIVER_OBJ( aMsg ) );
   717     TUint8* msg = const_cast<TUint8*>( aMsg.Ptr() );
   843     C_TRACE( ( _T( "DRouter::HandleIsiMessage rcvObjId 0x%x" ), rcvObjId ) );
   718     // Message from MODEM to APE, or from APE to APE. If Media SOS -> come through link. If dev OWN -> from APE nameservice
   844     ASSERT_RESET_ALWAYS( rcvObjId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)rcvObjId << KChannelNumberShift | EIADFaultIdentifier22 << KFaultIdentifierShift );
   719     if( msg[ ISI_HEADER_OFFSET_MEDIA ] == PN_MEDIA_SOS || ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) )
   845     if( iChannelTable[ rcvObjId ].iChannel )
   720         {
   846         {
   721         const TUint16 rcvObjId( GET_RECEIVER_OBJ( aMsg ) );
   847         iChannelTable[ rcvObjId ].iChannel->ReceiveMsg( aMsg );
   722         C_TRACE( ( _T( "DRouter::HandleIsiMessage rcvObjId 0x%x" ), rcvObjId ) );
   848         // DeAllocation done by the channel after writing to client's address space.
   723         ASSERT_RESET_ALWAYS( rcvObjId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)rcvObjId << KChannelNumberShift | EIADFaultIdentifier22 << KFaultIdentifierShift );
   849         }
   724         if( rcvObjId == PN_OBJ_ROUTER ) //TODO to channel table
   850     else
   725             {
   851         {
   726             C_TRACE( ( _T( "DRouter::HandleIsiMessage to NAMESERVICE>" ) ) );
   852         SendCommIsaEntityNotReachableResp( aMsg );
   727             iNameService->Receive( aMsg );
   853         // Not going to anywhere deallocate.
   728             C_TRACE( ( _T( "DRouter::HandleIsiMessage to NAMESERVICE<" ) ) );
   854         DeAllocateBlock( aMsg );
   729             }
   855         }
   730         else if( rcvObjId == PN_OBJ_EVENT_MULTICAST )
       
   731             {
       
   732             C_TRACE( ( _T( "DRouter::HandleIsiMessage to COMMUNICATIONMANAGER>" ) ) );
       
   733             iCommunicationManager->Receive( aMsg );
       
   734             C_TRACE( ( _T( "DRouter::HandleIsiMessage to COMMUNICATIONMANAGER<" ) ) );
       
   735             }
       
   736         else
       
   737             {
       
   738             if( iChannelTable[ rcvObjId ].iChannel )
       
   739                 {
       
   740                 iChannelTable[ rcvObjId ].iChannel->ReceiveMsg( aMsg );
       
   741                 // DeAllocation done by the channel after writing to client's address space.
       
   742                 }
       
   743             else
       
   744                 {
       
   745                 SendCommIsaEntityNotReachableResp( aMsg );
       
   746                 // Not going to anywhere deallocate.
       
   747                 DeAllocateBlock( aMsg );
       
   748                 }
       
   749             }
       
   750         }
       
   751     else // PN_MEDIA_ROUTING_REQ, receivedevice != own, from nameservice, send to modem
       
   752         {
       
   753     	  C_TRACE( ( _T( "DRouter::CheckRouting going to MODEM" ) ) );
       
   754     	  msg[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_SOS; // link should set this
       
   755         TInt sendError = SendMsg( aMsg );
       
   756         C_TRACE( ( _T( "DRouter::CheckRouting sendError %d" ), sendError ) );
       
   757     	  }
       
   758     
   856     C_TRACE( ( _T( "DRouter::HandleIsiMessage 0x%x <-" ), &aMsg ) );
   759     C_TRACE( ( _T( "DRouter::HandleIsiMessage 0x%x <-" ), &aMsg ) );
   857 
   760 
   858     OstTrace0( TRACE_NORMAL, DROUTER_HANDLEISIMESSAGE_EXIT, "<DRouter::HandleIsiMessage" );    
   761     OstTrace0( TRACE_NORMAL, DROUTER_HANDLEISIMESSAGE_EXIT, "<DRouter::HandleIsiMessage" );    
   859     }
   762     }
   860 
   763 
   864         )
   767         )
   865     {
   768     {
   866     OstTrace1( TRACE_NORMAL, DROUTER_HANDLEPIPEMESSAGE_ENTRY, ">DRouter::HandlePipeMessage;aMsg=%x", ( TUint )&( aMsg ) );
   769     OstTrace1( TRACE_NORMAL, DROUTER_HANDLEPIPEMESSAGE_ENTRY, ">DRouter::HandlePipeMessage;aMsg=%x", ( TUint )&( aMsg ) );
   867 
   770 
   868     C_TRACE( ( _T( "DRouter::HandlePipeMessage 0x%x ->" ), &aMsg ) );
   771     C_TRACE( ( _T( "DRouter::HandlePipeMessage 0x%x ->" ), &aMsg ) );
   869 #ifndef NCP_COMMON_BRIDGE_FAMILY
   772 #ifdef NCP_COMMON_BRIDGE_FAMILY_PIPE_SUPPORT
   870     const TUint16 rcvObjId( GET_RECEIVER_OBJ( aMsg ) );
   773     const TUint16 rcvObjId( GET_RECEIVER_OBJ( aMsg ) );
   871     C_TRACE( ( _T( "DRouter::HandlePipeMessage rcvObjId 0x%x" ), rcvObjId ) );
   774     C_TRACE( ( _T( "DRouter::HandlePipeMessage rcvObjId 0x%x" ), rcvObjId ) );
   872     ASSERT_RESET_ALWAYS( rcvObjId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)rcvObjId << KChannelNumberShift| EIADFaultIdentifier25 << KFaultIdentifierShift );    
   775     ASSERT_RESET_ALWAYS( rcvObjId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)rcvObjId << KChannelNumberShift| EIADFaultIdentifier25 << KFaultIdentifierShift );    
   873     MIAD2ChannelApi* openChannel = iChannelTable[ rcvObjId ].iChannel;
   776     MIAD2ChannelApi* openChannel = iChannelTable[ rcvObjId ].iChannel;
   874     if( openChannel )
   777     if( openChannel )
   896 
   799 
   897 void DRouter::HandleMediaMessage(
   800 void DRouter::HandleMediaMessage(
   898         TDes8& aMsg
   801         TDes8& aMsg
   899         )
   802         )
   900     {
   803     {
       
   804 
   901     OstTrace1( TRACE_NORMAL, DROUTER_HANDLEMEDIAMESSAGE_ENTRY, ">DRouter::HandleMediaMessage;aMsg=%x", ( TUint )&( aMsg ) );
   805     OstTrace1( TRACE_NORMAL, DROUTER_HANDLEMEDIAMESSAGE_ENTRY, ">DRouter::HandleMediaMessage;aMsg=%x", ( TUint )&( aMsg ) );
   902 
       
   903     C_TRACE( ( _T( "DRouter::HandleMediaMessage 0x%x ->" ), &aMsg ) );
   806     C_TRACE( ( _T( "DRouter::HandleMediaMessage 0x%x ->" ), &aMsg ) );
   904     TUint8 rcvObjId( 0x00);
   807     TUint8 rcvObjId( 0x00);
   905     ASSERT_RESET_ALWAYS( aMsg.Length() > ISI_HEADER_OFFSET_MEDIA, EIADOverTheLimits | EIADFaultIdentifier3 << KFaultIdentifierShift  );
   808     ASSERT_RESET_ALWAYS( aMsg.Length() > ISI_HEADER_OFFSET_MEDIA, EIADOverTheLimits | EIADFaultIdentifier3 << KFaultIdentifierShift  );
   906     switch( aMsg[ ISI_HEADER_OFFSET_MEDIA ] )
   809     rcvObjId = GET_RECEIVER_OBJ( aMsg );
   907         {
   810     ASSERT_RESET_ALWAYS( 0, EIADUnkownMedia | ( rcvObjId << KChannelNumberShift ) );
   908 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
   909         case PN_MEDIA_USB:
       
   910             {
       
   911             C_TRACE( ( _T( "DRouter::HandleMediaMessage USB" ) ) );
       
   912             OstTrace0( TRACE_NORMAL, DROUTER_HANDLEMEDIAMESSAGE_USB, "DRouter::HandleMediaMessage USB" );            
       
   913             rcvObjId = EIADNokiaUsbPhonetLink;
       
   914             break;
       
   915             }
       
   916         case PN_MEDIA_BT:
       
   917             {
       
   918             C_TRACE( ( _T( "DRouter::HandleMediaMessage BT" ) ) );
       
   919             OstTrace0( TRACE_NORMAL, DROUTER_HANDLEMEDIAMESSAGE_BT, "DRouter::HandleMediaMessage BT" );            
       
   920             rcvObjId = EIADNokiaBtPhonetLink;
       
   921             break;
       
   922             }
       
   923         //TBR AFTER CMT ERROR CORRECTION : wk49 cellmo has correction, so remove this later on
       
   924         case PN_MEDIA_ROUTING_REQ:
       
   925             {
       
   926             // TODO: write an error! Someone is sending to APE with wrong media.
       
   927             // USB PDD
       
   928             TRACE_ASSERT_ALWAYS;
       
   929             rcvObjId = GET_RECEIVER_OBJ( aMsg );
       
   930             Kern::Printf("Unknown message 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", aMsg[ 0 ], aMsg[ 1 ], aMsg[ 2 ], aMsg[ 3 ], aMsg[ 4 ], aMsg[ 5 ], aMsg[ 6 ], aMsg[ 7 ], aMsg[ 8 ], aMsg[ 9 ] );
       
   931             break;
       
   932             }
       
   933 #endif
       
   934         //TBR AFTER CMT ERROR CORRECTION
       
   935         default:
       
   936             {
       
   937             rcvObjId = GET_RECEIVER_OBJ( aMsg );
       
   938             ASSERT_RESET_ALWAYS( 0, EIADUnkownMedia | ( rcvObjId << KChannelNumberShift ) );
       
   939             break;
       
   940             }
       
   941         }
       
   942     // TODO: UNIQUE
   811     // TODO: UNIQUE
   943     ASSERT_RESET_ALWAYS( rcvObjId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)rcvObjId << KChannelNumberShift | EIADFaultIdentifier3 << KFaultIdentifierShift  );
   812     ASSERT_RESET_ALWAYS( rcvObjId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)rcvObjId << KChannelNumberShift | EIADFaultIdentifier3 << KFaultIdentifierShift  );
   944     if( iChannelTable[ rcvObjId ].iChannel )
   813     if( iChannelTable[ rcvObjId ].iChannel )
   945         {
   814         {
   946         iChannelTable[ rcvObjId ].iChannel->ReceiveMsg( aMsg );
   815         iChannelTable[ rcvObjId ].iChannel->ReceiveMsg( aMsg );
   951         SendCommIsaEntityNotReachableResp( aMsg );
   820         SendCommIsaEntityNotReachableResp( aMsg );
   952         // Not going to anywhere deallocate.
   821         // Not going to anywhere deallocate.
   953         DeAllocateBlock( aMsg );
   822         DeAllocateBlock( aMsg );
   954         }
   823         }
   955     C_TRACE( ( _T( "DRouter::HandleMediaMessage 0x%x <-" ), &aMsg ) );
   824     C_TRACE( ( _T( "DRouter::HandleMediaMessage 0x%x <-" ), &aMsg ) );
   956 
       
   957     OstTrace0( TRACE_NORMAL, DROUTER_HANDLEMEDIAMESSAGE_EXIT, "<DRouter::HandleMediaMessage" );
   825     OstTrace0( TRACE_NORMAL, DROUTER_HANDLEMEDIAMESSAGE_EXIT, "<DRouter::HandleMediaMessage" );
   958     }
   826 
   959 
       
   960 void DRouter::HandleControlMessage(
       
   961         TDes8& aMsg
       
   962         )
       
   963     {
       
   964     OstTrace1( TRACE_NORMAL, DROUTER_HANDLECONTROLMESSAGE_ENTRY, ">DRouter::HandleControlMessage;aMsg=%x", ( TUint )&( aMsg ) );
       
   965 
       
   966     C_TRACE( ( _T( "DRouter::HandleControlMessage 0x%x ->" ), &aMsg ) );
       
   967 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
   968     const TUint8* msgPtr( aMsg.Ptr() );
       
   969     // Check legal msgs
       
   970     ASSERT_RESET_ALWAYS( msgPtr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_RESP_OFFSET_SUBFUNCTION ] == PNS_MEDIA_SPECIFIC_RESP, EIADInvalidCtrlMessage | EIADFaultIdentifier1 << KFaultIdentifierShift  );
       
   971     ASSERT_RESET_ALWAYS( msgPtr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_RESP_OFFSET_MEDIATOCTRL ] == PN_MEDIA_SOS, EIADInvalidCtrlMessage | EIADFaultIdentifier2 << KFaultIdentifierShift  );
       
   972     ASSERT_RESET_ALWAYS( msgPtr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_RESP_OFFSET_ERRORCODE ] == PN_MCTRL_NO_ERROR, EIADInvalidCtrlMessage | EIADFaultIdentifier3 << KFaultIdentifierShift  );
       
   973     ASSERT_RESET_ALWAYS( aMsg.Length() > CTRL_RESP_OFFSET_MESSAGEID,  EIADOverTheLimits | EIADFaultIdentifier4 << KFaultIdentifierShift );
       
   974     switch( msgPtr[ CTRL_RESP_OFFSET_MESSAGEID ] )
       
   975         {
       
   976         case KIADCtrlConfResp:
       
   977             {
       
   978             // In MINI_OS case take the maximumdatasize amount from configuration message if bigger than "hat" constant.
       
   979             iMaxFrameSize = KIADMaxIsiMsgSize;
       
   980 #ifdef NCP_COMMON_MINIOS
       
   981             TUint16 confMsgSize = ( ( ( ( TUint16 )( msgPtr[ CTRL_CONF_RESP_OFFSET_SIZE_BYTE1 ] ) ) << 8 ) | ( ( TUint16 )( msgPtr[ CTRL_CONF_RESP_OFFSET_SIZE_BYTE2 ] ) ) );
       
   982             // NOTE! This hat constant has relation to cmt side (sos_mm) if the const is changed in either place harmonize!!
       
   983             const TUint16 KSosProxyHatConst( 2140 );
       
   984             iMaxFrameSize = ( confMsgSize > KSosProxyHatConst ? confMsgSize : KIADMaxIsiMsgSize );
       
   985             ASSERT_RESET_ALWAYS( iMaxFrameSize <= confMsgSize, EIADConfigurationInvalid );
       
   986 #endif
       
   987             // Datalink layer initialized, router layer is this and knows it, now inform obj layer clients.
       
   988             iConnectionStatus = EIADConnectionOk;
       
   989             iBootDone = ETrue;
       
   990             // Could call straight cause the context is the same thread (extension dfc)
       
   991             NotifyObjLayerConnStat( EIADConnectionOk );
       
   992             // TODO: pns_name_add_req
       
   993             // Initialize channels to NULL when channel is opened !NULL.
       
   994             for( TInt i( 0 ); i < EIADSizeOfChannels; ++i )
       
   995                 {
       
   996                 ASSERT_RESET_ALWAYS( !iChannelTable[ i ].iChannel, EIADChannelOpenedBeforePhysicalLayerInit );
       
   997                 C_TRACE( ( _T( "DRouter::HandleControlMessage loop TBR 0x%x" ), i ) );
       
   998                 if( iChannelTable[ i ].iWaitingChannel )
       
   999                     {
       
  1000                     switch( iChannelTable[ i ].iType )
       
  1001                         {
       
  1002                         case ENormalOpen:
       
  1003                             {
       
  1004                             C_TRACE( ( _T( "DRouter::HandleControlMessage booting ENormalOpen 0x%x" ), i ) );
       
  1005                             OstTrace1( TRACE_NORMAL, DROUTER_HANDLECONTROLMESSAGE_NORMAL_OPEN, "DRouter::HandleControlMessage;i=%x", i );
       
  1006                             
       
  1007                             MIAD2ChannelApi* tmpChannel = iChannelTable[ i ].iWaitingChannel;
       
  1008                             iChannelTable[ i ].iChannel = tmpChannel;
       
  1009                             iChannelTable[ i ].iWaitingChannel = NULL;
       
  1010                             iChannelTable[ i ].iChannel->CompleteChannelRequest( EIADAsyncOpen, KErrNone );
       
  1011                             break;
       
  1012                             }
       
  1013                         case EDrmOpen:
       
  1014                             {
       
  1015                             C_TRACE( ( _T( "DRouter::HandleControlMessage booting EDrmOpen 0x%x" ), i ) );
       
  1016                             OstTrace1( TRACE_NORMAL, DROUTER_HANDLECONTROLMESSAGE_DRM_OPEN, "DRouter::HandleControlMessage EDrmOpen;i=%x", i );
       
  1017                             
       
  1018                             SendDrmReq( i );
       
  1019                             break;
       
  1020                             }
       
  1021                         case ENameAddOpen:
       
  1022                             {
       
  1023                             C_TRACE( ( _T( "DRouter::HandleControlMessage booting ENameAddOpen 0x%x" ), i ) );
       
  1024                             OstTrace1( TRACE_NORMAL, DROUTER_HANDLECONTROLMESSAGE_NAMEADD_OPEN, "DRouter::HandleControlMessage ENameAddOpen;i=%x", i );
       
  1025                             
       
  1026                             // TODO: Not done yet, problem info get as param, channel to allocate deallocate after open complete?
       
  1027                             ASSERT_RESET_ALWAYS( 0, EIADWrongParameter | EIADFaultIdentifier13 << KFaultIdentifierShift );
       
  1028                             break;
       
  1029                             }
       
  1030                         default:
       
  1031                             {
       
  1032                             ASSERT_RESET_ALWAYS( 0, EIADWrongParameter | EIADFaultIdentifier14 << KFaultIdentifierShift  );
       
  1033                             break;
       
  1034                             }
       
  1035                         }
       
  1036                     }
       
  1037                 }
       
  1038             C_TRACE( ( _T( "DRouter::HandleControlMessage conf %d" ), iMaxFrameSize ) );
       
  1039             break;
       
  1040             }
       
  1041         case KIADCtrlDrmResp:
       
  1042             {
       
  1043             const TUint16 channelId( msgPtr[ CTR_DRM_REQ_RESP_OFFSET_CHANNEL_ID ] );
       
  1044             C_TRACE( ( _T( "DRouter::HandleControlMessage drm resp 0x%x" ), channelId ) );
       
  1045             OstTrace0( TRACE_NORMAL, DROUTER_HANDLECONTROLMESSAGE_DRM_RESP, "DRouter::HandleControlMessage drm resp");
       
  1046             
       
  1047             // Check is this waiting
       
  1048             ASSERT_RESET_ALWAYS( channelId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)channelId << KChannelNumberShift | EIADFaultIdentifier28 << KFaultIdentifierShift );
       
  1049             TRACE_ASSERT_INFO( iChannelTable[ channelId ].iWaitingChannel, (TUint8)channelId<<KChannelNumberShift );
       
  1050             TRACE_ASSERT_INFO( !iChannelTable[ channelId ].iChannel, (TUint8)channelId<<KChannelNumberShift );
       
  1051             ASSERT_RESET_ALWAYS( iChannelTable[ channelId ].iType == EDrmOpen, EIADWrongTypeOfOpenPending | EIADFaultIdentifier1 << KFaultIdentifierShift );
       
  1052             MIAD2ChannelApi* tmpChannel = iChannelTable[ channelId ].iWaitingChannel;
       
  1053             iChannelTable[ channelId ].iChannel = tmpChannel;
       
  1054             iChannelTable[ channelId ].iWaitingChannel = NULL;
       
  1055             C_TRACE( ( _T( "DRouter::HandleControlMessage drm resp 0x%x 0x%x 0x%x 0x%x" ), channelId, tmpChannel, iChannelTable[ channelId ].iChannel, &aMsg ) );
       
  1056             iChannelTable[ channelId ].iChannel->CompleteChannelRequest( EIADAsyncOpen, KErrNone );
       
  1057             break;
       
  1058             }
       
  1059         default:
       
  1060             {
       
  1061             // If wrong message reset! IF changed take care of completion of requests.
       
  1062             ASSERT_RESET_ALWAYS( 0, EIADInvalidCtrlMessage | EIADFaultIdentifier5 << KFaultIdentifierShift  );
       
  1063             break;
       
  1064             }
       
  1065         } // switch
       
  1066 #endif
       
  1067     // De-allocate cause not going anywhere else.
       
  1068     DeAllocateBlock( aMsg );
       
  1069     C_TRACE( ( _T( "DRouter::HandleControlMessage 0x%x <-" ), &aMsg ) );
       
  1070 
       
  1071     OstTrace0( TRACE_NORMAL, DROUTER_HANDLECONTROLMESSAGE_EXIT, "<DRouter::HandleControlMessage" );
       
  1072     }
   827     }
  1073 
   828 
  1074 // KErrBadDescriptor, if message length too small
   829 // KErrBadDescriptor, if message length too small
  1075 // KErrUnderFlow, if message length too big.
   830 // KErrUnderFlow, if message length too big.
  1076 // KErrCouldNotConnect, if receiver object is out of scope.
   831 // KErrCouldNotConnect, if receiver object is out of scope.
  1129         {
   884         {
  1130         if( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == THIS_DEVICE )
   885         if( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == THIS_DEVICE )
  1131             {
   886             {
  1132             switch( msg[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] )
   887             switch( msg[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] )
  1133                 {
   888                 {
  1134 #ifndef NCP_COMMON_BRIDGE_FAMILY
   889                 // Indication NOTE! INDICATION HANDLING IS STILL LEGACY
  1135                 // Router <-> SOSMM
       
  1136                 case KIADObjId:
       
  1137                     {
       
  1138                     // Name add resp, drm or conf
       
  1139                     ASSERT_RESET_ALWAYS( msg[  ISI_HEADER_OFFSET_RESOURCEID ] == PN_NAMESERVICE || msg[  ISI_HEADER_OFFSET_RESOURCEID ] == PN_MEDIA_CONTROL, EIADWrongParameter | msg[  ISI_HEADER_OFFSET_RESOURCEID ] );
       
  1140                     route = ( msg[ ISI_HEADER_OFFSET_RESOURCEID ] == PN_NAMESERVICE ) ? EPnNameAddRespMsg : EControlMsg;
       
  1141                     break;
       
  1142                     }
       
  1143 #endif
       
  1144                 // Indication
       
  1145                 case KIADEventSubscriptionObjId:
   890                 case KIADEventSubscriptionObjId:
  1146                     {
   891                     {
  1147                     ASSERT_RESET_ALWAYS( msg[  ISI_HEADER_OFFSET_RESOURCEID ] != PN_PIPE, EIADWrongParameter | msg[  ISI_HEADER_OFFSET_RESOURCEID ] );
   892                     ASSERT_RESET_ALWAYS( msg[  ISI_HEADER_OFFSET_RESOURCEID ] != PN_PIPE, EIADWrongParameter | msg[  ISI_HEADER_OFFSET_RESOURCEID ] );
  1148                     route = EIndicationMsg;
   893                     route = EIndicationMsg;
  1149                     break;
   894                     break;
  1166             C_TRACE( ( _T( "DRouter::CheckRouting message to PN_DEV_GLOBAL -> EIndicationMsg" ) ) );
   911             C_TRACE( ( _T( "DRouter::CheckRouting message to PN_DEV_GLOBAL -> EIndicationMsg" ) ) );
  1167             OstTrace0( TRACE_NORMAL, DROUTER_CHECKROUTING_PN_DEV_GLOBAL, "DRouter::CheckRouting PN_DEV_GLOBAL -> EIndicationMsg");
   912             OstTrace0( TRACE_NORMAL, DROUTER_CHECKROUTING_PN_DEV_GLOBAL, "DRouter::CheckRouting PN_DEV_GLOBAL -> EIndicationMsg");
  1168             TUint8* ptr = const_cast<TUint8*>( msg );    
   913             TUint8* ptr = const_cast<TUint8*>( msg );    
  1169             SET_RECEIVER_DEV( ptr, THIS_DEVICE );
   914             SET_RECEIVER_DEV( ptr, THIS_DEVICE );
  1170             route = EIndicationMsg;
   915             route = EIndicationMsg;
       
   916             }
       
   917        else if ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_PC )// TODO: This (PN_DEV_GLOBAL) should be removed from Bridge when modem SW MCE Server is ok
       
   918             {
       
   919             C_TRACE( ( _T( "DRouter::CheckRouting message to PN_DEV_PC ") ) );
       
   920             route=EUsbPhonetMsg;
  1171             }
   921             }
  1172 #ifdef MODEM_MCE_DOES_NOT_WORK_AS_IT_SHOULD
   922 #ifdef MODEM_MCE_DOES_NOT_WORK_AS_IT_SHOULD
  1173 #include <mceisi.h>
   923 #include <mceisi.h>
  1174             else
   924             else
  1175                 {
   925                 {
  1194             C_TRACE( ( _T( "DRouter::CheckRouting Unknown message" ) ) );
   944             C_TRACE( ( _T( "DRouter::CheckRouting Unknown message" ) ) );
  1195             TRACE_ASSERT_ALWAYS;
   945             TRACE_ASSERT_ALWAYS;
  1196             Kern::Printf("Unknown message 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", msg[ 0 ], msg[ 1 ], msg[ 2 ], msg[ 3 ], msg[ 4 ], msg[ 5 ], msg[ 6 ], msg[ 7 ], msg[ 8 ], msg[ 9 ] );
   946             Kern::Printf("Unknown message 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", msg[ 0 ], msg[ 1 ], msg[ 2 ], msg[ 3 ], msg[ 4 ], msg[ 5 ], msg[ 6 ], msg[ 7 ], msg[ 8 ], msg[ 9 ] );
  1197             }
   947             }
  1198         }
   948         }
       
   949     // APE to APE routing
       
   950     else if( ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) && ( msg[ ISI_HEADER_OFFSET_SENDERDEVICE ] == PN_DEV_OWN ) )
       
   951         {
       
   952         C_TRACE( ( _T( "DRouter::CheckRouting APE to APE routing" ) ) );
       
   953         route = EIsiMsg;
       
   954         }
  1199     // Message to other media than sos in symbian side.
   955     // Message to other media than sos in symbian side.
  1200     else
   956     else
  1201         {
   957         {
  1202         route = EMediaMsg;
   958         route = EMediaMsg;
  1203         }
   959         }
  1226             // De-allocate, message is multicasted to subsribers as new
   982             // De-allocate, message is multicasted to subsribers as new
  1227             // message and the original is ready to be deallocated.
   983             // message and the original is ready to be deallocated.
  1228             aTmp.DeAllocateBlock( aMsg );
   984             aTmp.DeAllocateBlock( aMsg );
  1229             break;
   985             break;
  1230             }
   986             }
  1231 #ifndef NCP_COMMON_BRIDGE_FAMILY
   987         case EUsbPhonetMsg:
  1232         case EControlMsg:
   988             {
  1233             {
   989             aTmp.iChannelTable[ EIscNokiaUsbPhonetLink ].iChannel->ReceiveMsg( aMsg );
  1234             aTmp.HandleControlMessage( aMsg );
       
  1235             break;
   990             break;
  1236             }
   991             }
  1237         case EPnNameAddRespMsg:
       
  1238             {
       
  1239             aTmp.HandlePnsNameAddResp( aMsg );
       
  1240             break;
       
  1241             }
       
  1242 #endif // NCP_COMMON_BRIDGE_FAMILY
       
  1243         case ENotKnownMsg:
   992         case ENotKnownMsg:
  1244             {
   993             {
  1245             // Not going to anywhere deallocate.
   994             // Not going to anywhere deallocate.
  1246             aTmp.DeAllocateBlock( aMsg );
   995             aTmp.DeAllocateBlock( aMsg );
  1247             break;
   996             break;
  1264     
  1013     
  1265     OstTrace1( TRACE_NORMAL, DROUTER_COMMONRXDFC_ENTRY, ">DRouter::CommonRxDfc;aPtr=%x", ( TUint )( aPtr ) );
  1014     OstTrace1( TRACE_NORMAL, DROUTER_COMMONRXDFC_ENTRY, ">DRouter::CommonRxDfc;aPtr=%x", ( TUint )( aPtr ) );
  1266     C_TRACE( ( _T( "DRouter::CommonRxDfc ->" ) ) );
  1015     C_TRACE( ( _T( "DRouter::CommonRxDfc ->" ) ) );
  1267     DRouter& tmp = *reinterpret_cast<DRouter*>( aPtr );
  1016     DRouter& tmp = *reinterpret_cast<DRouter*>( aPtr );
  1268     ASSERT_DFCTHREAD_INEXT();
  1017     ASSERT_DFCTHREAD_INEXT();
       
  1018 		
  1269     if( tmp.iCommonRxQueue->Count() > KErrNone )
  1019     if( tmp.iCommonRxQueue->Count() > KErrNone )
  1270         {
  1020         {
  1271         TDes8& msg( tmp.iCommonRxQueue->Get() );
  1021         TDes8& msg( tmp.iCommonRxQueue->Get() );
  1272         DATA_DUMP_TRACE( msg, EFalse );// TODO: this causes problems in legacy flowcontrol causing main rx to overflow!!
  1022         DATA_DUMP_TRACE( msg, EFalse );// TODO: this causes problems in legacy flowcontrol causing main rx to overflow!!
  1273         OstTraceData( TRACE_ISIMSG, DROUTER_COMMONRXDFC_DATA, "DRouter::CommonRxDfc RX: 0x%hx", msg.Ptr(), msg.Length() );
  1023         OstTraceData( TRACE_ISIMSG, DROUTER_COMMONRXDFC_DATA, "DRouter::CommonRxDfc RX: 0x%hx", msg.Ptr(), msg.Length() );
  1326     tempPtr.Append( 0x00 );
  1076     tempPtr.Append( 0x00 );
  1327     // Filler
  1077     // Filler
  1328     tempPtr.Append( 0x00 );
  1078     tempPtr.Append( 0x00 );
  1329 
  1079 
  1330 //    ASSERT_RESET_ALWAYS( iConnectionStatus == EIADConnectionOk, EIADCmtConnectionLost | EIADFaultIdentifier2 << KFaultIdentifierShift );
  1080 //    ASSERT_RESET_ALWAYS( iConnectionStatus == EIADConnectionOk, EIADCmtConnectionLost | EIADFaultIdentifier2 << KFaultIdentifierShift );
  1331     SendMsg( tempPtr );
  1081     if( msgTmpPtr[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN )
       
  1082         {
       
  1083         MessageReceived( *reinterpret_cast<TDes8*>( const_cast<TDesC8*>(&aMsg) ) );
       
  1084         }
       
  1085     else
       
  1086         {
       
  1087         SendMsg( tempPtr );
       
  1088         }
  1332     C_TRACE( ( _T( "DRouter::SendCommIsaEntityNotReachableResp 0x%x <-" ), &aMsg ) );
  1089     C_TRACE( ( _T( "DRouter::SendCommIsaEntityNotReachableResp 0x%x <-" ), &aMsg ) );
  1333 
       
  1334     OstTrace0( TRACE_NORMAL, DROUTER_SENDCOMMISAENTITYNOTREACHABLERESP_EXIT, "<DRouter::SendCommIsaEntityNotReachableResp" );
  1090     OstTrace0( TRACE_NORMAL, DROUTER_SENDCOMMISAENTITYNOTREACHABLERESP_EXIT, "<DRouter::SendCommIsaEntityNotReachableResp" );
  1335     }
  1091     }
  1336 
  1092 
  1337 void DRouter::InitCmtDfc(
  1093 void DRouter::InitCmtDfc(
  1338         TAny* aPtr
  1094         TAny* aPtr
  1342 
  1098 
  1343     C_TRACE( ( _T( "DRouter::InitCmtDfc ->" ) ) );
  1099     C_TRACE( ( _T( "DRouter::InitCmtDfc ->" ) ) );
  1344     DRouter& tmp = *reinterpret_cast<DRouter*>( aPtr );
  1100     DRouter& tmp = *reinterpret_cast<DRouter*>( aPtr );
  1345     if( !tmp.iBootDone )
  1101     if( !tmp.iBootDone )
  1346         {
  1102         {
  1347 #ifdef NCP_COMMON_BRIDGE_FAMILY
       
  1348 #ifndef MODEM_MCE_DOES_NOT_WORK_AS_IT_SHOULD
  1103 #ifndef MODEM_MCE_DOES_NOT_WORK_AS_IT_SHOULD
  1349         tmp.InitConnectionOk();
  1104         tmp.InitConnectionOk();
  1350 #endif // MODEM_MCE_DOES_NOT_WORK_AS_IT_SHOULD
  1105 #endif // MODEM_MCE_DOES_NOT_WORK_AS_IT_SHOULD
  1351 #else
  1106         }
  1352         tmp.InitCmtConnection();
       
  1353 #endif
       
  1354         }
       
  1355 
       
  1356 // ISCE    tmp.InitCmtConnection();
       
  1357     C_TRACE( ( _T( "DRouter::InitCmtDfc <-" ) ) );
  1107     C_TRACE( ( _T( "DRouter::InitCmtDfc <-" ) ) );
  1358 
       
  1359     OstTrace0( TRACE_NORMAL, DROUTER_INITCMTDFC_EXIT, "<DRouter::InitCmtDfc" );
  1108     OstTrace0( TRACE_NORMAL, DROUTER_INITCMTDFC_EXIT, "<DRouter::InitCmtDfc" );
  1360     }
  1109 
  1361 
  1110     }
  1362 #ifdef NCP_COMMON_BRIDGE_FAMILY
  1111 
  1363 void DRouter::InitConnectionOk()
  1112 void DRouter::InitConnectionOk()
  1364     {
  1113     {
  1365 
  1114 
  1366     C_TRACE( ( _T( "DRouter::InitConnectionOk ->" ) ) );
  1115     C_TRACE( ( _T( "DRouter::InitConnectionOk ->" ) ) );
  1367     iMaxFrameSize = KIADMaxIsiMsgSize;
  1116     iMaxFrameSize = KIADMaxIsiMsgSize;
  1394                 }
  1143                 }
  1395             }
  1144             }
  1396         }
  1145         }
  1397     C_TRACE( ( _T( "DRouter::InitConnectionOk <-" ) ) );
  1146     C_TRACE( ( _T( "DRouter::InitConnectionOk <-" ) ) );
  1398     }
  1147     }
  1399 #endif // NCP_COMMON_BRIDGE_FAMILY
       
  1400 
       
  1401 void DRouter::InitCmtConnection(
       
  1402         // None
       
  1403         )
       
  1404     {
       
  1405     OstTrace0( TRACE_NORMAL, DROUTER_INITCMTCONNECTION_ENTRY, ">DRouter::InitCmtConnection" );
       
  1406 
       
  1407     C_TRACE( ( _T( "DRouter::InitCmtConnection ->" ) ) );
       
  1408 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
  1409 
       
  1410     // send configuration request to proxy
       
  1411     const TInt KCtrlConfReqLength( 14 );
       
  1412     //ASSERT_RESET_ALWAYS( iIST, EIADNullParameter | EIADFaultIdentifier16 << KFaultIdentifierShift  );
       
  1413     TDes8& temp = AllocateBlock( KCtrlConfReqLength );
       
  1414     ASSERT_RESET_ALWAYS( ( KCtrlConfReqLength > CTRL_REQ_OFFSET_MESSAGEID + 2 ), EIADOverTheLimits | EIADFaultIdentifier6 << KFaultIdentifierShift  );
       
  1415     temp.SetLength( KCtrlConfReqLength );
       
  1416     TUint8* tmpPtr( const_cast<TUint8*>( temp.Ptr() ) );
       
  1417     tmpPtr[ ISI_HEADER_OFFSET_MEDIA ]                                       = PN_MEDIA_SOS;
       
  1418     SET_RECEIVER_DEV( tmpPtr, PN_MEDIA_ROUTING_REQ );
       
  1419     SET_SENDER_DEV( tmpPtr, THIS_DEVICE );
       
  1420     tmpPtr[ ISI_HEADER_OFFSET_RESOURCEID ]                                  = PN_MEDIA_CONTROL;
       
  1421     SET_LENGTH( tmpPtr, ( KCtrlConfReqLength - PN_HEADER_SIZE ) );
       
  1422     SET_RECEIVER_OBJ( tmpPtr, PN_OBJ_ROUTER );
       
  1423     SET_SENDER_OBJ( tmpPtr, KIADObjId );
       
  1424     tmpPtr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_REQ_OFFSET_UTID ]          = 0x00;
       
  1425     tmpPtr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_REQ_OFFSET_SUBFUNCTION ]   = PNS_MEDIA_SPECIFIC_REQ;
       
  1426     tmpPtr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_REQ_OFFSET_MEDIATOCTRL ]   = PN_MEDIA_SOS;
       
  1427     tmpPtr[ CTRL_REQ_OFFSET_MESSAGEID ]                                     = KIADCtrlConfReq;
       
  1428     tmpPtr[ CTRL_REQ_OFFSET_MESSAGEID + 1 ]                                 = 0x00; // Filler
       
  1429     tmpPtr[ CTRL_REQ_OFFSET_MESSAGEID +2 ]                                  = 0x00; // Filler
       
  1430     temp.SetLength( KCtrlConfReqLength );
       
  1431     SendMsg( temp );
       
  1432 #endif // NCP_COMMON_BRIDGE_FAMILY
       
  1433 
       
  1434     C_TRACE( ( _T( "DRouter::InitCmtConnection <-" ) ) );
       
  1435 
       
  1436     OstTrace0( TRACE_NORMAL, DROUTER_INITCMTCONNECTION_EXIT, "<DRouter::InitCmtConnection" );
       
  1437     }
       
  1438 
       
  1439 void DRouter::SendDrmReq(
       
  1440         const TUint16 aChannelId
       
  1441         )
       
  1442     {
       
  1443     OstTraceExt1( TRACE_NORMAL, DROUTER_SENDDRMREQ_ENTRY, ">DRouter::SendDrmReq;aChannelId=%hx", aChannelId );
       
  1444 
       
  1445     C_TRACE( ( _T( "DRouter::SendDrmReq 0x%x ->" ), aChannelId) );
       
  1446 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
  1447     // DRM REQ/RESP messages are spec so that only 8-bit values for channelid are possible.
       
  1448     ASSERT_RESET_ALWAYS( aChannelId <= 0xff, EIADTooManyBytesToPresent );
       
  1449     TDes8& block = AllocateBlock( KIADCtrlDrmReqLength );
       
  1450     ASSERT_RESET_ALWAYS( ( KIADCtrlDrmReqLength > CTRL_DRM_REQ_OFFSET_REQUIRED_CHANNEL_ID ), EIADOverTheLimits | EIADFaultIdentifier7 << KFaultIdentifierShift  );;
       
  1451     block.SetLength( KIADCtrlDrmReqLength );
       
  1452     TUint8* ptr( const_cast<TUint8*>( block.Ptr() ) );
       
  1453     ptr[ ISI_HEADER_OFFSET_MEDIA ]                                      = PN_MEDIA_SOS;
       
  1454     SET_RECEIVER_DEV( ptr, PN_MEDIA_ROUTING_REQ );
       
  1455     SET_SENDER_DEV( ptr, THIS_DEVICE );
       
  1456     ptr[ ISI_HEADER_OFFSET_RESOURCEID ]                                 = PN_MEDIA_CONTROL;
       
  1457     SET_LENGTH( ptr, ( KIADCtrlDrmReqLength - PN_HEADER_SIZE ) );
       
  1458     SET_RECEIVER_OBJ( ptr, PN_OBJ_ROUTER );
       
  1459     SET_SENDER_OBJ( ptr, KIADObjId );
       
  1460     ptr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_REQ_OFFSET_UTID ]         = aChannelId;
       
  1461     ptr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_REQ_OFFSET_SUBFUNCTION ]  = PNS_MEDIA_SPECIFIC_REQ;
       
  1462     ptr[ ISI_HEADER_SIZE + PNS_MEDIA_SPECIFIC_REQ_OFFSET_MEDIATOCTRL ]  = PN_MEDIA_SOS;
       
  1463     ptr[ CTRL_REQ_OFFSET_MESSAGEID ]                                    = KIADCtrlDrmReq;
       
  1464     ptr[ CTRL_DRM_REQ_OFFSET_REQUIRED_CHANNEL_ID ]                      = aChannelId;
       
  1465     ASSERT_RESET_ALWAYS( iConnectionStatus == EIADConnectionOk, EIADCmtConnectionLost | EIADFaultIdentifier3 << KFaultIdentifierShift );
       
  1466     SendMsg( block );
       
  1467 #endif // NCP_COMMON_BRIDGE_FAMILY
       
  1468     C_TRACE( ( _T( "DRouter::SendDrmReq 0x%x <-" ), aChannelId) );
       
  1469 
       
  1470     OstTrace0( TRACE_NORMAL, DROUTER_SENDDRMREQ_EXIT, "<DRouter::SendDrmReq" );
       
  1471     }
       
  1472 
       
  1473 void DRouter::SendPnsNameAddReq( 
       
  1474         const TUint16 aChannel, 
       
  1475         const TDesC8& aOpenInfo
       
  1476         )
       
  1477     {
       
  1478     OstTraceExt2( TRACE_NORMAL, DROUTER_SENDPNSNAMEADDREQ_ENTRY, ">DRouter::SendPnsNameAddReq;aChannel=%hx;aOpenInfo=%x", aChannel, ( TUint )&( aOpenInfo ) );
       
  1479 
       
  1480     C_TRACE( ( _T( "DRouter::SendPnsNameAddReq 0x%x 0x%x ->" ), aChannel, &aOpenInfo ) );
       
  1481 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
  1482 
       
  1483     TUint16 msgLength( ISI_HEADER_SIZE + SIZE_PNS_NAME_ADD_REQ );
       
  1484     TDes8& block = AllocateBlock( msgLength );
       
  1485     ASSERT_RESET_ALWAYS( ( msgLength > ( ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 7 ) ), EIADOverTheLimits | EIADFaultIdentifier8 << KFaultIdentifierShift );
       
  1486     block.SetLength( msgLength );
       
  1487     TUint8* ptr = const_cast<TUint8*>( block.Ptr() );
       
  1488 
       
  1489     ptr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_SOS;
       
  1490     SET_RECEIVER_DEV( ptr, OTHER_DEVICE_1 );
       
  1491     SET_SENDER_DEV( ptr, THIS_DEVICE );
       
  1492     ptr[ ISI_HEADER_OFFSET_RESOURCEID ] = PN_NAMESERVICE;
       
  1493     SET_LENGTH( ptr, ( msgLength - PN_HEADER_SIZE ) );
       
  1494     SET_RECEIVER_OBJ( ptr, PN_OBJ_ROUTER);
       
  1495     SET_SENDER_OBJ( ptr, KIADObjId );
       
  1496     ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_UTID ] = aChannel; 
       
  1497     ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_SUBFUNCTION ] = PNS_NAME_ADD_REQ;
       
  1498     ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_RESERVED1 ] = 0x00;
       
  1499     ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_RESERVED2 ] = 0x00;
       
  1500 
       
  1501     TUint8* resourcePtr = const_cast<TUint8*>( aOpenInfo.Ptr() );
       
  1502     /*
       
  1503     //TBR
       
  1504     for( TInt i( 0 ); i < aOpenInfo.Length(); i++ )
       
  1505         {
       
  1506         Kern::Printf( "resource[%d]0x%x", i, resourcePtr[i] );
       
  1507         }
       
  1508     //TBR
       
  1509     */
       
  1510     switch( aOpenInfo.Length() )
       
  1511         {
       
  1512         // Resource bigendian 32-bit, TODO : how about winscw?
       
  1513         case 4:
       
  1514             {
       
  1515             C_TRACE( ( _T( "DRouter::SendPnsNameAddReq 32-bit resourceid used 0x%x 0x%x" ), aChannel, &aOpenInfo ) );
       
  1516             OstTraceExt5( TRACE_NORMAL, DROUTER_SENDPNSNAMEADDREQ_32BIT, "DRouter::SendPnsNameAddReq;aChannel=%hx;resourcePtr[0]=%hhx;resourcePtr[1]=%hhx;resourcePtr[2]=%hhx;resourcePtr[3]=%hhx", aChannel, resourcePtr[0], resourcePtr[1], resourcePtr[2], resourcePtr[3] );
       
  1517             
       
  1518             ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY ] = resourcePtr[ 0 ];
       
  1519             ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 1 ] = resourcePtr[ 1 ];
       
  1520             ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 2 ] = resourcePtr[ 2 ];
       
  1521             ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 3 ] = resourcePtr[ 3 ];
       
  1522             break;
       
  1523             }
       
  1524         case 1:
       
  1525             {
       
  1526             ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY ] = 0x00;
       
  1527             ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 1 ] = 0x00;
       
  1528             ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 2 ] = 0x00;
       
  1529             ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 3 ] = resourcePtr[ 0 ];
       
  1530             OstTraceExt2( TRACE_NORMAL, DROUTER_SENDPNSNAMEADDREQ_8BIT, "DRouter::SendPnsNameAddReq;aChannel=%hx;resourcePtr[0]=%hhx", aChannel, resourcePtr[0] );
       
  1531             C_TRACE( ( _T( "DRouter::SendPnsNameAddReq 8-bit resourceid used 0x%x 0x%x" ), aChannel, &aOpenInfo ) );
       
  1532             break;
       
  1533             }
       
  1534         default:
       
  1535             {
       
  1536             ASSERT_RESET_ALWAYS( 0, EIADWrongParameter | EIADFaultIdentifier17 << KFaultIdentifierShift  );
       
  1537             break;
       
  1538             }
       
  1539         }
       
  1540     // Phonet device id associated with name.
       
  1541     ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 4 ] = THIS_DEVICE;
       
  1542     // Phonet object id associated with name.
       
  1543     ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 5 ] = aChannel;
       
  1544     // Record flags. This entry cannot be changed.
       
  1545     ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 6 ] = PN_NAME_NOCHG;
       
  1546     ptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_NAMEENTRY + 7 ] = 0x00;
       
  1547     ASSERT_RESET_ALWAYS( iConnectionStatus == EIADConnectionOk, EIADCmtConnectionLost | EIADFaultIdentifier4 << KFaultIdentifierShift );
       
  1548     SendMsg( block );
       
  1549 #endif // NCP_COMMON_BRIDGE_FAMILY
       
  1550     C_TRACE( ( _T( "DRouter::SendPnsNameAddReq 0x%x 0x%x <-" ), aChannel, &aOpenInfo ) );
       
  1551 
       
  1552     OstTrace0( TRACE_NORMAL, DROUTER_SENDPNSNAMEADDREQ_EXIT, "<DRouter::SendPnsNameAddReq" );
       
  1553     }
       
  1554 
       
  1555 void DRouter::HandlePnsNameAddResp(
       
  1556         TDes8& aMsg
       
  1557         )
       
  1558     {
       
  1559     OstTrace1( TRACE_NORMAL, DROUTER_HANDLEPNSNAMEADDRESP_ENTRY, ">DRouter::HandlePnsNameAddResp;aMsg=%x", ( TUint )&( aMsg ) );
       
  1560 
       
  1561     C_TRACE( ( _T( "DRouter::HandlePnsNameAddResp 0x%x ->" ), &aMsg ) );
       
  1562 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
  1563 
       
  1564     // Channel id from Transaction ID.
       
  1565     const TUint8* cptr( aMsg.Ptr() );
       
  1566     ASSERT_RESET_ALWAYS( ( ISI_HEADER_SIZE + PNS_NAME_ADD_RESP_OFFSET_REASON ) < aMsg.Length(), EIADOverTheLimits | EIADFaultIdentifier9 << KFaultIdentifierShift  );
       
  1567     TUint8 channelId( cptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_REQ_OFFSET_UTID ] );
       
  1568     ASSERT_RESET_ALWAYS( channelId < EIADSizeOfChannels, EIADWrongParameter | (TUint8)channelId << KChannelNumberShift | EIADFaultIdentifier23 << KFaultIdentifierShift );
       
  1569     if( iChannelTable[ channelId ].iWaitingChannel )
       
  1570         {
       
  1571         ASSERT_RESET_ALWAYS( iChannelTable[ channelId ].iType == ENameAddOpen, EIADWrongTypeOfOpenPending | EIADFaultIdentifier2 << KFaultIdentifierShift );
       
  1572         if( cptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_RESP_OFFSET_REASON ] == PN_NAME_OK )
       
  1573             {
       
  1574             MIAD2ChannelApi* tmpChannel = iChannelTable[ channelId ].iWaitingChannel;
       
  1575             iChannelTable[ channelId ].iChannel = tmpChannel;
       
  1576             iChannelTable[ channelId ].iWaitingChannel = NULL;
       
  1577             C_TRACE( ( _T( "DRouter::HandlePnsNameAddResp name add resp ok 0x%x 0x%x 0x%x 0x%x" ), channelId, tmpChannel, iChannelTable[ channelId ].iChannel, &aMsg ) );
       
  1578 
       
  1579             OstTraceExt2( TRACE_NORMAL, DROUTER_HANDLEPNSNAMEADDRESP_OK, "DRouter::HandlePnsNameAddResp OK;channelId=%hhx;tmpChannel=%x", channelId, (TUint) ( tmpChannel ) );
       
  1580             
       
  1581             iChannelTable[ channelId ].iChannel->CompleteChannelRequest( EIADAsyncOpen, KErrNone );
       
  1582             }
       
  1583         else
       
  1584             {
       
  1585             C_TRACE( ( _T( "DRouter::HandlePnsNameAddResp name add resp NOK 0x%x 0x%x" ), channelId, &aMsg ) );
       
  1586             OstTraceExt1( TRACE_NORMAL, DROUTER_HANDLEPNSNAMEADDRESP_NOK, "DRouter::HandlePnsNameAddResp;channelId=%hhx", channelId );
       
  1587             
       
  1588             TRACE_ASSERT( cptr[ ISI_HEADER_SIZE + PNS_NAME_ADD_RESP_OFFSET_REASON ] == PN_NAME_OK );
       
  1589             iChannelTable[ channelId ].iWaitingChannel->CompleteChannelRequest( EIADAsyncOpen, KErrNotSupported );
       
  1590             // Set channel open waiting to null, open was failed.
       
  1591             iChannelTable[ channelId ].iWaitingChannel = NULL;
       
  1592             }
       
  1593         }
       
  1594     else
       
  1595         {
       
  1596         // Check is this waiting
       
  1597         // TODO: Does pns_name_add_resp need to be informed with comm_isa_entity_not_reachable_resp if channel is closed?
       
  1598         TRACE_ASSERT_INFO( !iChannelTable[ channelId ].iChannel, channelId<<KChannelNumberShift );
       
  1599         TRACE_ASSERT_INFO( iChannelTable[ channelId ].iWaitingChannel, channelId<<KChannelNumberShift ); // TODO: This will come when open cancel called with resource.
       
  1600         }
       
  1601     // De-allocate cause not going anywhere else.
       
  1602     DeAllocateBlock( aMsg );
       
  1603 #endif // NCP_COMMON_BRIDGE_FAMILY
       
  1604 
       
  1605     C_TRACE( ( _T( "DRouter::HandlePnsNameAddResp 0x%x <-" ), &aMsg ) );
       
  1606 
       
  1607     OstTrace0( TRACE_NORMAL, DROUTER_HANDLEPNSNAMEADDRESP_EXIT, "<DRouter::HandlePnsNameAddResp" );
       
  1608     }
       
  1609 
  1148 
  1610 // router and handler (pipe and indication)
  1149 // router and handler (pipe and indication)
  1611 TInt DRouter::SendMsg(
  1150 TInt DRouter::SendMsg(
  1612          TDes8& aMsg
  1151          TDes8& aMsg
  1613          )
  1152          )
  1663          TDes8& aMessage,
  1202          TDes8& aMessage,
  1664          const TUint16 aCh
  1203          const TUint16 aCh
  1665          )
  1204          )
  1666     {
  1205     {
  1667     OstTraceExt2( TRACE_NORMAL, DROUTER_SETSENDERINFO_ENTRY, ">DRouter::SetSenderInfo;aMessage=%x;aCh=%hx", ( TUint )&( aMessage ), aCh );
  1206     OstTraceExt2( TRACE_NORMAL, DROUTER_SETSENDERINFO_ENTRY, ">DRouter::SetSenderInfo;aMessage=%x;aCh=%hx", ( TUint )&( aMessage ), aCh );
  1668 
  1207     C_TRACE( ( _T( "DRouter::SetSenderInfo 0x%x ->" ), &aMessage ) );
  1669     C_TRACE( ( _T( "DRouter::SetSenderInfo 0x%x ->" ), &aMessage ) );    
       
  1670     TUint8* msgBlockPtr = const_cast<TUint8*>( aMessage.Ptr() );
  1208     TUint8* msgBlockPtr = const_cast<TUint8*>( aMessage.Ptr() );
  1671     ASSERT_RESET_ALWAYS( aMessage.Length() > ISI_HEADER_OFFSET_MEDIA, EIADOverTheLimits | EIADFaultIdentifier10 << KFaultIdentifierShift  );
  1209     ASSERT_RESET_ALWAYS( aMessage.Length() > ISI_HEADER_OFFSET_MEDIA, EIADOverTheLimits | EIADFaultIdentifier10 << KFaultIdentifierShift  );
  1672     switch( aCh )
  1210     if ( aCh == EIADNokiaUsbPhonetLink )
  1673         {
  1211  	      {
  1674 #ifndef NCP_COMMON_BRIDGE_FAMILY
  1212         msgBlockPtr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_SOS;
  1675         case EIADNokiaBtPhonetLink:
  1213         SET_RECEIVER_DEV( msgBlockPtr, OTHER_DEVICE_1 );
  1676             {
  1214         }
  1677             OstTrace0( TRACE_NORMAL, DROUTER_SETSENDERINFO_BT, "DRouter::SetSenderInfo BT" );            
  1215     else{
  1678             msgBlockPtr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_BT;
  1216         SET_SENDER_OBJ( msgBlockPtr, aCh );    
  1679             break;
  1217         C_TRACE( ( _T( "DRouter::SetSenderInfo receiver device %d" ), msgBlockPtr[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] ) );
  1680             }
  1218         if( msgBlockPtr[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN )
  1681         case EIADNokiaUsbPhonetLink:
  1219             {
  1682             {
  1220             C_TRACE( ( _T( "DRouter::SetSenderInfo message to APE from APE" ) ) );
  1683             OstTrace0( TRACE_NORMAL, DROUTER_SETSENDERINFO_USB, "DRouter::SetSenderInfo USB" );            
  1221             SET_SENDER_DEV( msgBlockPtr, PN_DEV_OWN );
  1684             msgBlockPtr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_USB;
  1222             }
  1685             break;
  1223         else
  1686             }
  1224             {
  1687 #endif
  1225             C_TRACE( ( _T( "DRouter::SetSenderInfo message to MODEM from APE" ) ) );
  1688         default:
       
  1689             {
       
  1690             msgBlockPtr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_SOS;
  1226             msgBlockPtr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_SOS;
       
  1227             SET_RECEIVER_DEV( msgBlockPtr, OTHER_DEVICE_1 );
  1691             SET_SENDER_DEV( msgBlockPtr, THIS_DEVICE );
  1228             SET_SENDER_DEV( msgBlockPtr, THIS_DEVICE );
  1692             SET_RECEIVER_DEV( msgBlockPtr, OTHER_DEVICE_1 );
  1229             }
  1693             SET_SENDER_OBJ( msgBlockPtr, aCh );
  1230         }
  1694             break;
  1231     C_TRACE( ( _T( "DRouter::SetSenderInfo 0x%x <-" ), &aMessage ) );
  1695             }
       
  1696         }
       
  1697     C_TRACE( ( _T( "DRouter::SetSenderInfo 0x%x <-" ), &aMessage ) );        
       
  1698     
       
  1699     OstTrace0( TRACE_NORMAL, DROUTER_SETSENDERINFO_EXIT, "<DRouter::SetSenderInfo" );
  1232     OstTrace0( TRACE_NORMAL, DROUTER_SETSENDERINFO_EXIT, "<DRouter::SetSenderInfo" );
  1700     }
  1233     }
  1701     
  1234 
  1702 void DRouter::CheckSameThreadContext()
  1235 void DRouter::CheckSameThreadContext()
  1703     {
  1236     {
  1704     OstTrace0( TRACE_NORMAL, DROUTER_CHECKSAMETHREADCONTEXT_ENTRY, ">DRouter::CheckSameThreadContext" );
  1237     OstTrace0( TRACE_NORMAL, DROUTER_CHECKSAMETHREADCONTEXT_ENTRY, ">DRouter::CheckSameThreadContext" );
  1705 
  1238 
  1706     DObject* tempObj = reinterpret_cast<DObject*>( &Kern::CurrentThread() ); 
  1239     DObject* tempObj = reinterpret_cast<DObject*>( &Kern::CurrentThread() ); 
  1766     TUint8 linkdId( DRouter::EISIAmountOfMedias );
  1299     TUint8 linkdId( DRouter::EISIAmountOfMedias );
  1767     switch( aMedia )
  1300     switch( aMedia )
  1768         {
  1301         {
  1769         case PN_MEDIA_SOS:
  1302         case PN_MEDIA_SOS:
  1770             {
  1303             {
  1771 #ifndef NCP_COMMON_BRIDGE_FAMILY
       
  1772             linkdId = EISIMediaSOS;
       
  1773 #else
       
  1774             linkdId = EISIMediaHostSSI;
  1304             linkdId = EISIMediaHostSSI;
  1775 #endif
       
  1776             break;
  1305             break;
  1777             }
  1306             }
  1778         // Not supported media
  1307         // Not supported media
  1779         default:
  1308         default:
  1780             {
  1309             {
  1784         }
  1313         }
  1785     return linkdId;
  1314     return linkdId;
  1786 
  1315 
  1787     }
  1316     }
  1788 
  1317 
       
  1318 //From objectapi
       
  1319 EXPORT_C MISIObjectRouterIf* MISIObjectRouterIf::Connect( const TInt32 aUID, TUint8& aObjId, MISIRouterObjectIf* aCallback )
       
  1320     {
       
  1321     C_TRACE( ( _T( "MISIObjectRouterIf::Connect %d 0x%x 0x%x>" ), aUID, aObjId, aCallback ) );
       
  1322     //Connect( aUID, aObjId, aCallback );
       
  1323     if( aUID == KNameServiceUID )
       
  1324         {
       
  1325         C_TRACE( ( _T( "MISIObjectRouterIf was nameservice" ) ) );
       
  1326         DRouter::iThisPtr->iNameService = aCallback;
       
  1327         aObjId = PN_OBJ_ROUTING_REQ; // 0x00
       
  1328         }
       
  1329     else if( aUID == KCommunicationManagerUID )
       
  1330         {
       
  1331         C_TRACE( ( _T( "MISIObjectRouterIf was communicationmanager" ) ) );
       
  1332         DRouter::iThisPtr->iCommunicationManager = aCallback;
       
  1333         aObjId = PN_OBJ_EVENT_MULTICAST; // 0x20
       
  1334         }
       
  1335     else
       
  1336         {
       
  1337         C_TRACE( ( _T( "MISIObjectRouterIf unknown object api client" ) ) );
       
  1338         }
       
  1339     MISIObjectRouterIf* tmp = DRouter::iThisPtr;
       
  1340     C_TRACE( ( _T( "MISIObjectRouterIf::Connect %d 0x%x 0x%x<" ), aUID, aObjId, aCallback ) );
       
  1341     return tmp;
       
  1342     }
       
  1343 
       
  1344 TInt DRouter::Send( TDes8& aMessage, const TUint8 aObjId )
       
  1345     {
       
  1346   	C_TRACE( ( _T( "DRouter::Send objectapi 0x%x 0x%x>" ), &aMessage, aObjId ) );
       
  1347     if( aObjId == PN_OBJ_EVENT_MULTICAST ) //from communicationmanager
       
  1348         {
       
  1349         // Don't put to mainrxqueue
       
  1350         HandleIsiMessage( aMessage );
       
  1351         }
       
  1352     else
       
  1353         {
       
  1354         Receive( aMessage );
       
  1355         }
       
  1356     C_TRACE( ( _T( "DRouter::Send objectapi 0x%x 0x%x<" ), &aMessage, aObjId ) );
       
  1357   	return KErrNone;
       
  1358     }
       
  1359 
  1789 // End of file.
  1360 // End of file.
  1790 
  1361