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" ); |
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, |
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 |
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. |
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() ); |