diff -r 942573423a60 -r fa67e03b87df connectivitylayer/isce/isaaccessextension_dll/src/router.cpp --- a/connectivitylayer/isce/isaaccessextension_dll/src/router.cpp Fri Jan 22 10:04:04 2010 +0200 +++ b/connectivitylayer/isce/isaaccessextension_dll/src/router.cpp Wed Feb 17 13:58:55 2010 +0200 @@ -23,7 +23,6 @@ #include "router.h" #include "iadtrace.h" // For C_TRACE.. #include "isaaccessextension.h" // For DIsaAccessExtension -#include "indicationhandler.h" // For DIndicationHandler #include "queue.h" // For DQueue #include "iadinternaldefinitions.h" // For EIADAsync... #include "iadhelpers.h" // For GET_RECEIVER @@ -41,6 +40,7 @@ // ISCE #include "memapi.h" // For MemApi #include "trxdefs.h" // For ETrx... +#include "ape_commgrisi.h" // For APE_COMMGR... // ISCE // CONSTS @@ -48,6 +48,17 @@ const TUint32 KCommunicationManagerUID( 0x2002B3D0 ); const TUint32 KNameServiceUID( 0x2002A5A1 ); +const TUint8 K8BitResourceId( 2 ); +const TUint8 K32BitResourceId( 5 ); +const TUint8 K32BitResourceOffsetByte1( 0 ); +const TUint8 K32BitResourceOffsetByte2( 1 ); +const TUint8 K32BitResourceOffsetByte3( 2 ); +const TUint8 K32BitResourceOffsetByte4( 3 ); +const TUint8 K8BitResourceOffset( 0 ); +const TUint8 KEventOffset32Bit( 4 ); +const TUint8 KEventOffset8Bit( 1 ); +const TUint8 KFiller( 0 ); +const TUint8 KNoResource( 0 ); // TODO: change this to use UnuqueID instead and to extension.. void DRouter::CheckDfc() { @@ -90,9 +101,7 @@ #ifdef NCP_COMMON_BRIDGE_FAMILY_PIPE_SUPPORT iPipeHandler = new DPipeHandler( *this ); #endif - iIndicationHandler = new DIndicationHandler( *this ); iCommonRxQueue = new DQueue( KIADExtensionRxQueueSize ); - ASSERT_RESET_ALWAYS( /*iPipeHandler &&*/ iIndicationHandler && iCommonRxQueue, EIADMemoryAllocationFailure | EIADFaultIdentifier17 << KFaultIdentifierShift ); // Initialize channels to NULL when channel is opened !NULL. for( TInt i( 0 ); i < EIADSizeOfChannels; ++i ) { @@ -156,11 +165,6 @@ iPipeHandler = NULL; } #endif - if( iIndicationHandler ) - { - delete iIndicationHandler; - iIndicationHandler = NULL; - } if( iCommonRxQueue ) { delete iCommonRxQueue; @@ -523,12 +527,72 @@ TRACE_ASSERT_INFO( msgOk == KErrNone, (TUint8)aCh<Subscribe( anOrder, aCh, a32Bit ); - TRACE_ASSERT_INFO( msgOk == KErrNone, (TUint8)aCh<( desPtr.Ptr() ) ); + ptr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_ROUTING_REQ; + SET_RECEIVER_DEV( ptr, PN_DEV_OWN ); + SET_SENDER_DEV( ptr, PN_DEV_OWN ); + ptr[ ISI_HEADER_OFFSET_RESOURCEID ] = PN_APE_COMMGR; + SET_LENGTH( ptr, ( desPtr.Length() - PN_HEADER_SIZE ) ); + SET_RECEIVER_OBJ( ptr, PN_OBJ_ROUTER ); + SET_SENDER_OBJ( ptr, aCh ); + ptr[ ISI_HEADER_SIZE + APE_COMMGR_SUBSCRIBE_REQ_OFFSET_TRANSID ] = 0x00; + ptr[ ISI_HEADER_SIZE + APE_COMMGR_SUBSCRIBE_REQ_OFFSET_MESSAGEID ] = APE_COMMGR_SUBSCRIBE_REQ; + ptr[ ISI_HEADER_SIZE + APE_COMMGR_SUBSCRIBE_REQ_OFFSET_FILLERBYTE1 ] = numOfOrders; + ptr[ ISI_HEADER_SIZE + APE_COMMGR_SUBSCRIBE_REQ_OFFSET_SUBBLOCKCOUNT ] = 0x00; + TInt orderIndex( 0 ); + //TODO automatically generated ape_commgrisi.h is totally wrong and not according to the specification + for( TInt subBlockOffset( ISI_HEADER_SIZE + SIZE_APE_COMMGR_SUBSCRIBE_REQ + APE_COMMGR_SUBSCRIBE_SB_OFFSET_SUBBLOCKID ); subBlockOffset < msgLength; subBlockOffset += SIZE_APE_COMMGR_SUBSCRIBE_SB ) + { + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_SUBBLOCKID ] = APE_COMMGR_SUBSCRIBE_SB; + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_SUBBLOCKLENGTH ] = SIZE_APE_COMMGR_SUBSCRIBE_SB; + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_DEVICEID ] = PN_DEV_HOST; + if( a32Bit == EFalse ) + { + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_RESOURCEID ] = ( anOrder.Ptr()[ orderIndex + KEventOffset8Bit ] ); + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_FILLERBYTE1 ] = KFiller; + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_FILLERBYTE2 ] = KFiller; + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_FILLERBYTE3 ] = KFiller; + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_MESSAGEID ] = ( anOrder.Ptr()[ orderIndex + K8BitResourceOffset ] ); + } + else + { + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_RESOURCEID ] = ( anOrder.Ptr()[ orderIndex + KEventOffset32Bit ] ); + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_FILLERBYTE1 ] = ( anOrder.Ptr()[ orderIndex + K32BitResourceOffsetByte1 ] ); + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_FILLERBYTE2 ] = ( anOrder.Ptr()[ orderIndex + K32BitResourceOffsetByte2 ] ); + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_FILLERBYTE3 ] = ( anOrder.Ptr()[ orderIndex + K32BitResourceOffsetByte3 ]) ; + ptr[ subBlockOffset + APE_COMMGR_SUBSCRIBE_SB_OFFSET_MESSAGEID ] = ( anOrder.Ptr()[ orderIndex + K32BitResourceOffsetByte4 ] ); + } + orderIndex = ( a32Bit == EFalse ) ? orderIndex + K8BitResourceId : orderIndex + K32BitResourceId; + } + iCommunicationManager->Receive( desPtr ); } - C_TRACE( ( _T( "DRouter::OrderIndication 0x%x 0x%x %d %d <-" ), &anOrder, aCh, a32Bit, msgOk ) ); - - OstTrace1( TRACE_NORMAL, DROUTER_ORDERINDICATION, "( tmpIndication.Ptr() ); - SET_RECEIVER_DEV( indicationPtr, THIS_DEVICE ); - SET_RECEIVER_OBJ( indicationPtr, KIADEventSubscriptionObjId ); - this->MessageReceived( tmpIndication ); - } // To communicationmanager if( ( msgBlockPtr[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] == PN_OBJ_EVENT_MULTICAST ) && ( msgBlockPtr[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) ) @@ -634,8 +682,20 @@ OstTraceExt2( TRACE_NORMAL, DROUTER_SENDINDICATION_ENTRY, ">DRouter::SendIndication;aMessage=%x;aCh=%hx", ( TUint )&( aMessage ), aCh ); C_TRACE( ( _T( "DRouter::SendIndication 0x%x 0x%x ->" ), &aMessage, aCh ) ); TUint8* msgPtr = const_cast( aMessage.Ptr() ); - SET_RECEIVER_DEV( msgPtr,OTHER_DEVICE_1 ); SET_RECEIVER_OBJ( msgPtr,PN_OBJ_EVENT_MULTICAST ); + if( GET_RECEIVER_DEV( aMessage ) != PN_DEV_OWN ) + { + SET_RECEIVER_DEV( msgPtr, OTHER_DEVICE_1 ); + // Copy for receivers in this device -> fake event from modem + TDes8& tmpIndication = MemApi::AllocBlock( aMessage.Length() ); + tmpIndication.SetLength( aMessage.Length() ); + tmpIndication.Copy( aMessage ); + TUint8* indicationPtr = const_cast( tmpIndication.Ptr() ); + SET_SENDER_DEV( indicationPtr, PN_DEV_HOST ); + SET_RECEIVER_DEV( indicationPtr, PN_DEV_OWN ); + indicationPtr[ ISI_HEADER_OFFSET_MEDIA ] = PN_MEDIA_SOS; + this->MessageReceived( tmpIndication ); + } TInt error( SendMessage( aMessage, aCh ) ); C_TRACE( ( _T( "DRouter::SendIndication 0x%x 0x%x %d <-" ), &aMessage, aCh, error ) ); OstTrace1( TRACE_NORMAL, DROUTER_SENDINDICATION_EXIT, "" ), &aMsg ) ); TUint8* msg = const_cast( aMsg.Ptr() ); // Message from MODEM to APE, or from APE to APE. If Media SOS -> come through link. If dev OWN -> from APE nameservice - if( msg[ ISI_HEADER_OFFSET_MEDIA ] == PN_MEDIA_SOS || ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) ) + if( ( msg[ ISI_HEADER_OFFSET_MEDIA ] == PN_MEDIA_SOS ) || ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) ) { const TUint16 rcvObjId( GET_RECEIVER_OBJ( aMsg ) ); C_TRACE( ( _T( "DRouter::HandleIsiMessage rcvObjId 0x%x" ), rcvObjId ) ); @@ -737,8 +797,16 @@ { if( iChannelTable[ rcvObjId ].iChannel ) { - iChannelTable[ rcvObjId ].iChannel->ReceiveMsg( aMsg ); - // DeAllocation done by the channel after writing to client's address space. + if( msg[ ISI_HEADER_OFFSET_RESOURCEID ] == PN_APE_COMMGR ) + { + C_TRACE( ( _T( "DRouter::HandleIsiMessage to channel from COMMUNICATIONMANAGER deallocate" ) ) ); + DeAllocateBlock( aMsg ); + } + else + { + iChannelTable[ rcvObjId ].iChannel->ReceiveMsg( aMsg ); + // DeAllocation done by the channel after writing to client's address space. + } } else { @@ -882,7 +950,7 @@ // Message to symbian side (media sos). if( msg[ ISI_HEADER_OFFSET_MEDIA ] == PN_MEDIA_SOS ) { - if( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == THIS_DEVICE ) + if( ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == THIS_DEVICE ) || ( msg[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) ) { switch( msg[ ISI_HEADER_OFFSET_RECEIVEROBJECT ] ) { @@ -978,7 +1046,6 @@ } case EIndicationMsg: { - aTmp.iIndicationHandler->Multicast( aMsg ); // De-allocate, message is multicasted to subsribers as new // message and the original is ready to be deallocated. aTmp.DeAllocateBlock( aMsg ); @@ -1077,10 +1144,9 @@ // Filler tempPtr.Append( 0x00 ); -// ASSERT_RESET_ALWAYS( iConnectionStatus == EIADConnectionOk, EIADCmtConnectionLost | EIADFaultIdentifier2 << KFaultIdentifierShift ); if( msgTmpPtr[ ISI_HEADER_OFFSET_RECEIVERDEVICE ] == PN_DEV_OWN ) { - MessageReceived( *reinterpret_cast( const_cast(&aMsg) ) ); + MessageReceived( tempPtr ); } else { @@ -1318,7 +1384,8 @@ //From objectapi EXPORT_C MISIObjectRouterIf* MISIObjectRouterIf::Connect( const TInt32 aUID, TUint8& aObjId, MISIRouterObjectIf* aCallback ) { - C_TRACE( ( _T( "MISIObjectRouterIf::Connect %d 0x%x 0x%x>" ), aUID, aObjId, aCallback ) ); + C_TRACE( ( _T( "MISIObjectRouterIf::Connect %d 0x%x 0x%x>" ), aUID, aObjId, aCallback ) ); + Kern::Printf( "IADRouter::Connect" ); //Connect( aUID, aObjId, aCallback ); if( aUID == KNameServiceUID ) { @@ -1344,6 +1411,7 @@ TInt DRouter::Send( TDes8& aMessage, const TUint8 aObjId ) { C_TRACE( ( _T( "DRouter::Send objectapi 0x%x 0x%x>" ), &aMessage, aObjId ) ); + Kern::Printf( "IADRouter::Send" ); if( aObjId == PN_OBJ_EVENT_MULTICAST ) //from communicationmanager { // Don't put to mainrxqueue @@ -1357,5 +1425,22 @@ return KErrNone; } +TDfcQue* DRouter::GetDfcThread( + const TISIDfcQThreadType // aType + ) + { + C_TRACE( ( _T( "DRouter::GetDfcThread<>" ) ) ); + Kern::Printf( "IADRouter::GetDfcThread" ); + return DIsaAccessExtension::GetDFCThread( EIADExtensionDfcQueue ); + //ASSERT_RESET_ALWAYS( 0, -1003 ); + //return NULL; + } + +void DRouter::FreeDfcThread( TDfcQue* aThread ) + { + C_TRACE( ( _T( "DRouter::FreeDfcThread 0x%x>" ), aThread ) ); + Kern::Printf( "IADRouter::FreeDfcThread" ); + ASSERT_RESET_ALWAYS( 0, -1002 ); + } // End of file.