adaptationlayer/modematadaptation/modematcontroller_exe/src/cmodematpipecontroller.cpp
changeset 5 8ccc39f9d787
parent 0 63b37f68c1ce
child 8 6295dc2169f3
equal deleted inserted replaced
4:510c70acdbf6 5:8ccc39f9d787
    36 #ifndef NCP_COMMON_BRIDGE_FAMILY
    36 #ifndef NCP_COMMON_BRIDGE_FAMILY
    37 const TUint8 PEP_COMM_IND_ID_ESCAPE(0x07);
    37 const TUint8 PEP_COMM_IND_ID_ESCAPE(0x07);
    38 const TInt KInvalidDteId = -1;
    38 const TInt KInvalidDteId = -1;
    39 const TUint8 KFiller = 0;
    39 const TUint8 KFiller = 0;
    40 const TUint8 KDefaultTrId(0);
    40 const TUint8 KDefaultTrId(0);
    41 const TUint8 KTaskIdQuerySize(20);
       
    42 #endif
    41 #endif
       
    42 const TInt KLastByteIndex = 3;
    43 
    43 
    44 CModemAtPipeController* CModemAtPipeController::NewL( RIscApi& aIscApi,
    44 CModemAtPipeController* CModemAtPipeController::NewL( RIscApi& aIscApi,
    45     TUint& aObjId,
    45     TUint& aObjId,
    46     CModemAtHandler& aHandler )
    46     CModemAtHandler& aHandler )
    47     {
    47     {
    77     iModemAtObjId( aObjId ),
    77     iModemAtObjId( aObjId ),
    78     iModemAtDevId( THIS_DEVICE ),
    78     iModemAtDevId( THIS_DEVICE ),
    79     iPipeHandle( KInvalidPipeHandle ),
    79     iPipeHandle( KInvalidPipeHandle ),
    80     iDataportDevId( 0 ),
    80     iDataportDevId( 0 ),
    81     iDataportObjId( 0 ),
    81     iDataportObjId( 0 ),
    82     iCellmoDevId( 0 ),
       
    83     iCellmoObjId( 0 ),
       
    84     iAtHandler( aHandler ),
    82     iAtHandler( aHandler ),
    85     iSchedulerWait( NULL ),
    83     iSchedulerWait( NULL ),
    86     iDteId( KInitialDteId )
    84     iDteId( KInitialDteId )
    87     {
    85     {
    88     C_TRACE (( _T("CModemAtPipeController::CModemAtPipeController()") ));
    86     C_TRACE (( _T("CModemAtPipeController::CModemAtPipeController()") ));
   109             C_TRACE(_L("PNS_NAME_REMOVE_IND")); 
   107             C_TRACE(_L("PNS_NAME_REMOVE_IND")); 
   110             HandleNameRemoveInd( aReceivedMessage );
   108             HandleNameRemoveInd( aReceivedMessage );
   111             break;
   109             break;
   112 
   110 
   113         default:
   111         default:
   114             ASSERT_PANIC_ALWAYS( EFalse ) ;
   112             TRACE_ASSERT_ALWAYS;
   115             break;
   113             break;
   116         }
   114         }
   117      }
   115      }
   118 
   116 
   119  void CModemAtPipeController::HandlePipeServiceMessage( const TIsiReceiveC& aReceivedMessage)
   117  void CModemAtPipeController::HandlePipeServiceMessage( const TIsiReceiveC& aReceivedMessage)
   120      {
   118      {
   121      C_TRACE (( _T("CModemAtPipeController::HandlePipeServiceMessage()") ));
   119      C_TRACE (( _T("CModemAtPipeController::HandlePipeServiceMessage()") ));
       
   120      C_TRACE((_L("message id: %d") , aReceivedMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) ));
   122      switch( aReceivedMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) )
   121      switch( aReceivedMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) )
   123         {
   122         {
   124         case PNS_PIPE_CREATE_RESP:
   123         case PNS_PIPE_CREATE_RESP:
   125             C_TRACE(_L("PIPE CREATE RESP"));
   124             C_TRACE(_L("PIPE CREATE RESP"));
   126             HandlePipeCreateResp( aReceivedMessage );
   125             HandlePipeCreateResp( aReceivedMessage );
   145             C_TRACE(_L("PNS_PEP_STATUS_IND "));
   144             C_TRACE(_L("PNS_PEP_STATUS_IND "));
   146             HandlePepStatusInd( aReceivedMessage );
   145             HandlePepStatusInd( aReceivedMessage );
   147             break;
   146             break;
   148 
   147 
   149         default:
   148         default:
   150             ASSERT_PANIC_ALWAYS( EFalse );
   149             TRACE_ASSERT_ALWAYS;
   151             break;
   150             break;
   152         }                            
   151         }                            
   153      }
   152      }
   154 
   153 
   155 
   154 
   190     }
   189     }
   191 
   190 
   192 void CModemAtPipeController::HandleNameAddInd( const TIsiReceiveC& aReceivedMessage )     
   191 void CModemAtPipeController::HandleNameAddInd( const TIsiReceiveC& aReceivedMessage )     
   193      {
   192      {
   194      C_TRACE (( _T("CModemAtPipeController::HandleNameAddInd()") ));
   193      C_TRACE (( _T("CModemAtPipeController::HandleNameAddInd()") ));
   195      TInt count = aReceivedMessage.Get16bit( ISI_HEADER_SIZE + PNS_NAME_ADD_IND_OFFSET_MATCHESINMSG );
   194      TInt matchesInThisMsg = aReceivedMessage.Get16bit( ISI_HEADER_SIZE +
       
   195        PNS_NAME_ADD_IND_OFFSET_MATCHESINMSG );
   196      
   196      
   197      C_TRACE((_L("Count %d") ,count ));
   197      C_TRACE((_L("matchesInThisMsg: %d") ,matchesInThisMsg ));
   198      TUint name = 0;
   198      TUint name = 0;
   199     
   199     
   200      for( TInt i = 1; i <= count ; i++ ) 
   200      for( TInt i = 1; i <= matchesInThisMsg; i++ ) 
   201          {
   201          {
   202          name = aReceivedMessage.Get32bit(ISI_HEADER_SIZE+PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i);
   202          name = aReceivedMessage.Get32bit(ISI_HEADER_SIZE +
       
   203            PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i);
   203          C_TRACE((_L("name [%d] 0x%x"), i ,name));
   204          C_TRACE((_L("name [%d] 0x%x"), i ,name));
   204 
   205 
   205          if( MatchDataportName(name) )   
   206          if( MatchDataportName(name) )
   206              {
   207              {
   207              iDataportDevId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   208              iDataportDevId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   208                PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i +  PN_NAME_SRV_ITEM_STR_OFFSET_DEV );
   209                PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i +
       
   210                PN_NAME_SRV_ITEM_STR_OFFSET_DEV );
   209              iDataportObjId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   211              iDataportObjId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   210                PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i +  PN_NAME_SRV_ITEM_STR_OFFSET_OBJ);
   212                PNS_NAME_ADD_IND_OFFSET_NAMEENTRYTBL * i +
   211              
   213                PN_NAME_SRV_ITEM_STR_OFFSET_OBJ);
       
   214 
   212              if( iDataportDevId == THIS_DEVICE )
   215              if( iDataportDevId == THIS_DEVICE )
   213                 {
   216                 {
   214                 C_TRACE((_L("CREATE PIPE FROM DATAPORT when ATEXT plugins connect (devid %x  o-bjid %x) "),iDataportDevId,iDataportObjId));
   217                 C_TRACE((_L("CREATE PIPE FROM DATAPORT when ATEXT plugins connect (devid %x  o-bjid %x) "),iDataportDevId,iDataportObjId));
   215                 }
   218                 }
   216              else
   219              else
   221              }
   224              }
   222          }
   225          }
   223      }
   226      }
   224 
   227 
   225 void CModemAtPipeController::HandleNameRemoveInd( const TIsiReceiveC& aReceivedMessage )     
   228 void CModemAtPipeController::HandleNameRemoveInd( const TIsiReceiveC& aReceivedMessage )     
   226      {
   229     {
   227      C_TRACE (( _T("CModemAtPipeController::HandleNameRemoveInd()") ));
   230     C_TRACE (( _T("CModemAtPipeController::HandleNameRemoveInd()") ));
   228      TInt count = aReceivedMessage.Get16bit( ISI_HEADER_SIZE + PNS_NAME_REMOVE_IND_OFFSET_MATCHESINMSG );
   231     TInt matchesInThisMsg = aReceivedMessage.Get16bit( ISI_HEADER_SIZE +
   229      
   232       PNS_NAME_REMOVE_IND_OFFSET_MATCHESINMSG );
   230      C_TRACE((_L("Count %d") ,count ));
       
   231      TUint name = 0;
       
   232     
   233     
   233      for( TInt i = 1; i <= count ; i++ ) 
   234     C_TRACE((_L("matchesInThisMsg: %d"), matchesInThisMsg ));
   234          {
   235     TUint name = 0;
   235          name = aReceivedMessage.Get32bit(ISI_HEADER_SIZE + PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i);
   236 
   236          C_TRACE((_L("name [%d] 0x%x"), i ,name));
   237     for( TInt i = 1; i <= matchesInThisMsg; i++ ) 
   237 
   238         {
   238          if( MatchDataportName(name) )   
   239         name = aReceivedMessage.Get32bit(ISI_HEADER_SIZE +
   239              {
   240           PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i);
   240              TUint devId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   241         C_TRACE((_L("name [%d] 0x%x"), i ,name));
   241                PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i +  PN_NAME_SRV_ITEM_STR_OFFSET_DEV );
   242 
   242              TUint objId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   243         if( MatchDataportName(name) )
   243                PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i +  PN_NAME_SRV_ITEM_STR_OFFSET_OBJ);
   244             {
   244 
   245             TUint devId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   245              if( iDataportDevId == devId && iDataportObjId == objId )
   246               PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i +
       
   247               PN_NAME_SRV_ITEM_STR_OFFSET_DEV );
       
   248             TUint objId = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
       
   249               PNS_NAME_REMOVE_IND_OFFSET_NAMEENTRYTBL * i +
       
   250               PN_NAME_SRV_ITEM_STR_OFFSET_OBJ);
       
   251 
       
   252             if( iDataportDevId == devId && iDataportObjId == objId )
       
   253                {
       
   254                C_TRACE((_L("Dataport removed from name service (devid %x  o-bjid %x) "), iDataportDevId, iDataportObjId));
       
   255                iDataportDevId = 0;
       
   256                iDataportObjId = 0;
       
   257                }
       
   258             else
       
   259                {
       
   260                C_TRACE((_L("Unused dataport removed from name service. DevId: 0x%x or ObjId 0x%x"), iDataportDevId, iDataportObjId ));
       
   261                TRACE_ASSERT_ALWAYS;
       
   262                }
       
   263             }
       
   264         }
       
   265     }
       
   266 
       
   267 void CModemAtPipeController::HandleNameQueryResp( const TIsiReceiveC& aReceivedMessage )
       
   268     {
       
   269     C_TRACE((_L("CModemAtPipeHandler::HandleNameQueryResp")));
       
   270     TUint16 matchesInThisMsg( aReceivedMessage.Get16bit(
       
   271         ISI_HEADER_SIZE + PNS_NAME_QUERY_RESP_OFFSET_MATCHESINMSG ) );
       
   272     C_TRACE((_L("matchesInThisMsg: %d"), matchesInThisMsg ));
       
   273 
       
   274     TBool found = EFalse;
       
   275     if( 0 < matchesInThisMsg )
       
   276         {
       
   277         for( TInt i = 0; i < matchesInThisMsg; i++ )
       
   278             {
       
   279             TInt recordIndex( i * SIZE_PN_NAME_SRV_ITEM_STR );
       
   280             TUint8 name( aReceivedMessage.Get8bit(
       
   281                 ISI_HEADER_SIZE + PNS_NAME_QUERY_RESP_OFFSET_NAMEENTRYTBL +
       
   282                 recordIndex + ( PN_NAME_SRV_ITEM_STR_OFFSET_NAME + KLastByteIndex ) ) );
       
   283             C_TRACE((_L("name [%d] 0x%x"), i, name ));
       
   284             if( PN_AT_MODEM == name )
   246                 {
   285                 {
   247                 C_TRACE((_L("Dataport removed from name service (devid %x  o-bjid %x) "),iDataportDevId,iDataportObjId));
   286                 C_TRACE((_L("PN_AT_MODEM found.")));
   248                 iDataportDevId = 0;
   287                 i = matchesInThisMsg;
   249                 iDataportObjId = 0;
   288                 found = ETrue;
   250                 }
   289                 }
   251              else
       
   252                 {
       
   253                 C_TRACE((_L("Unused dataport removed from name service. DevId: 0x%x or ObjId 0x%x"), iDataportDevId, iDataportObjId ));
       
   254                 TRACE_ASSERT_ALWAYS;
       
   255                 }
       
   256              }
       
   257          }
       
   258      }
       
   259 
       
   260 
       
   261 void CModemAtPipeController::HandleNameQueryResp( const TIsiReceiveC& aReceivedMessage ) 
       
   262     {
       
   263     C_TRACE((_L("CModemAtPipeHandler::HandleNameQueryResp")));
       
   264      
       
   265     TInt count = aReceivedMessage.Get16bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_RESP_OFFSET_MATCHESINMSG );
       
   266     C_TRACE((_L("Count d%d"), count ));
       
   267     TInt name = 0;
       
   268     TBool found = EFalse;
       
   269      
       
   270     for( TInt i = 0; i < count ; i++ ) 
       
   271         {
       
   272         name = aReceivedMessage.Get32bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_RESP_OFFSET_NAMEENTRYTBL * i );
       
   273         C_TRACE((_L("name [%d]%x"),i ,name ));
       
   274         if(name == PN_AT_MODEM) 
       
   275             {
       
   276             iCellmoDevId =  aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
       
   277               PNS_NAME_QUERY_RESP_OFFSET_NAMEENTRYTBL * i +  PN_NAME_SRV_ITEM_STR_OFFSET_DEV );
       
   278             iCellmoObjId =  aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
       
   279               PNS_NAME_QUERY_RESP_OFFSET_NAMEENTRYTBL * i +  PN_NAME_SRV_ITEM_STR_OFFSET_OBJ );
       
   280             found = ETrue;
       
   281             C_TRACE((_L("devid %x  objid %x"),iCellmoDevId,iCellmoObjId));
       
   282             }
   290             }
   283         }
   291         }
   284      
   292     iAtHandler.SetModemAtExistsInCmt( found );
   285     if( !found )
       
   286         {
       
   287         TRACE_ASSERT_ALWAYS;
       
   288         User::Panic( _L("NO AT-MODEM"), KErrNotFound );
       
   289         }
       
   290     }
   293     }
   291 
   294 
   292 
   295 
   293 
   296 
   294 void CModemAtPipeController::SendCreatePipeMessage( const TUint8 aDevId, const TUint8 aObjId ) 
   297 void CModemAtPipeController::SendCreatePipeMessage( const TUint8 aDevId, const TUint8 aObjId ) 
   317      isimessage.Complete();
   320      isimessage.Complete();
   318     
   321     
   319      C_TRACE(_L("Created ISI-message"));
   322      C_TRACE(_L("Created ISI-message"));
   320      DUMP_MESSAGE( messageptr );
   323      DUMP_MESSAGE( messageptr );
   321      TInt retVal = iIscApi.Send( messageptr );
   324      TInt retVal = iIscApi.Send( messageptr );
   322      ASSERT_PANIC_ALWAYS( retVal == KErrNone );
   325      TRACE_ASSERT( retVal == KErrNone );
   323      delete message;
   326      delete message;
   324      }
   327      }
   325 
   328 
   326 
   329 
   327  void CModemAtPipeController::HandlePipeCreateResp( const TIsiReceiveC& aReceivedMessage )
   330  void CModemAtPipeController::HandlePipeCreateResp( const TIsiReceiveC& aReceivedMessage )
   360 
   363 
   361  void CModemAtPipeController::LinkDteIdToPipe( const TUint8 aDteId )
   364  void CModemAtPipeController::LinkDteIdToPipe( const TUint8 aDteId )
   362     {
   365     {
   363     C_TRACE (( _T("CModemAtPipeController::LinkDteIdToPipe(0x%x)"), aDteId ));
   366     C_TRACE (( _T("CModemAtPipeController::LinkDteIdToPipe(0x%x)"), aDteId ));
   364     TRACE_ASSERT( aDteId < KMaxDteIdCount );
   367     TRACE_ASSERT( aDteId < KMaxDteIdCount );
       
   368     if( !(aDteId < KMaxDteIdCount) )
       
   369         {
       
   370         C_TRACE(( _T("CModemAtPipeController::LinkDteIdToPipe() illegal dteid %d"), aDteId ));
       
   371         return;
       
   372         }
       
   373 
   365     iDteId = aDteId;
   374     iDteId = aDteId;
   366     if( iDataportDevId == THIS_DEVICE )
   375     if( iDataportDevId == THIS_DEVICE )
   367         {
   376         {
   368         C_TRACE((_L("CREATE PIPE FROM DATAPORT (plugins are connecting) (devid %x  o-bjid %x) "),iDataportDevId,iDataportObjId));
   377         C_TRACE((_L("CREATE PIPE FROM DATAPORT (plugins are connecting) (devid %x  o-bjid %x) "),iDataportDevId,iDataportObjId));
   369         SendCreatePipeMessage( iDataportDevId, iDataportObjId );
   378         SendCreatePipeMessage( iDataportDevId, iDataportObjId );
   389       PNS_PIPE_REMOVE_RESP_OFFSET_ERRORCODE );
   398       PNS_PIPE_REMOVE_RESP_OFFSET_ERRORCODE );
   390     TInt pipehandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   399     TInt pipehandle = aReceivedMessage.Get8bit( ISI_HEADER_SIZE + 
   391       PNS_PIPE_REMOVE_RESP_OFFSET_PIPEHANDLE );
   400       PNS_PIPE_REMOVE_RESP_OFFSET_PIPEHANDLE );
   392 
   401 
   393     TInt dteId = FindDteId( pipehandle );
   402     TInt dteId = FindDteId( pipehandle );
   394     ASSERT_PANIC_ALWAYS( dteId < KMaxDteIdCount )
   403     
   395     ASSERT_PANIC_ALWAYS( error == PN_PIPE_NO_ERROR )
   404     TRACE_ASSERT( dteId < KMaxDteIdCount )
       
   405     if( !(dteId < KMaxDteIdCount) )
       
   406         {
       
   407         C_TRACE(( _T("CModemAtPipeController::HandlePipeRemoveResp() illegal dteid %d"), dteId ));
       
   408         return;
       
   409         }
       
   410     
       
   411     TRACE_ASSERT( error == PN_PIPE_NO_ERROR )
       
   412     if( error != PN_PIPE_NO_ERROR )
       
   413         {
       
   414         C_TRACE(( _T("CModemAtPipeController::HandlePipeRemoveResp() error %d"), error ));
       
   415         return;
       
   416         }
       
   417 
   396     ChangePipeState( dteId, TPipeInfo::EPipeNoPipe );
   418     ChangePipeState( dteId, TPipeInfo::EPipeNoPipe );
   397 
   419 
   398     iPipeTable[ dteId ].iHandle = KInvalidPipeHandle; 
   420     iPipeTable[ dteId ].iHandle = KInvalidPipeHandle; 
   399 
   421 
   400     if( iSchedulerWait )
   422     if( iSchedulerWait )
   409 
   431 
   410  
   432  
   411 void CModemAtPipeController::RemovePipe( const TUint8 aDteId )
   433 void CModemAtPipeController::RemovePipe( const TUint8 aDteId )
   412     {
   434     {
   413     C_TRACE (( _T("CModemAtPipeController::RemovePipe(%d, 0x%x)"), aDteId, this ));
   435     C_TRACE (( _T("CModemAtPipeController::RemovePipe(%d, 0x%x)"), aDteId, this ));
   414     ASSERT_PANIC_ALWAYS( aDteId < KMaxDteIdCount );
   436 
       
   437     TRACE_ASSERT( aDteId < KMaxDteIdCount );
       
   438     if( !(aDteId < KMaxDteIdCount) )
       
   439         {
       
   440         C_TRACE(( _T("CModemAtPipeController::RemovePipe() illegal dteid %d"), aDteId ));
       
   441         return;
       
   442         }
       
   443 
   415     C_TRACE (( _T("iPipeTable[aDteId]:0x%x"), &iPipeTable[aDteId] ));
   444     C_TRACE (( _T("iPipeTable[aDteId]:0x%x"), &iPipeTable[aDteId] ));
   416     C_TRACE (( _T("iHandle: %d"), iPipeTable[aDteId].iHandle ));
   445     C_TRACE (( _T("iHandle: %d"), iPipeTable[aDteId].iHandle ));
   417     C_TRACE (( _T("i1stDevId: %d"), iPipeTable[aDteId].iFirstDevId ));
   446     C_TRACE (( _T("i1stDevId: %d"), iPipeTable[aDteId].iFirstDevId ));
   418     C_TRACE (( _T("i1stObjId: %d"), iPipeTable[aDteId].iFirstObjId )); 
   447     C_TRACE (( _T("i1stObjId: %d"), iPipeTable[aDteId].iFirstObjId )); 
   419     C_TRACE (( _T("i2ndDevId: %d"), iPipeTable[aDteId].iSecondDevId ));
   448     C_TRACE (( _T("i2ndDevId: %d"), iPipeTable[aDteId].iSecondDevId ));
   442     {
   471     {
   443     C_TRACE (( _T(">>CModemAtPipeController::SendRemovePipeReq()") ));
   472     C_TRACE (( _T(">>CModemAtPipeController::SendRemovePipeReq()") ));
   444     C_TRACE((_L("Remove pipe handle %d"), aPipeHandle));
   473     C_TRACE((_L("Remove pipe handle %d"), aPipeHandle));
   445     TInt size = ISI_HEADER_SIZE + SIZE_PNS_PIPE_REMOVE_REQ;
   474     TInt size = ISI_HEADER_SIZE + SIZE_PNS_PIPE_REMOVE_REQ;
   446     HBufC8* message = HBufC8::New( size );
   475     HBufC8* message = HBufC8::New( size );
   447     ASSERT_PANIC_ALWAYS( message );
   476     TRACE_ASSERT( message );
   448 
   477 
   449     TPtr8 messageptr = message->Des();
   478     TPtr8 messageptr = message->Des();
   450     TIsiSend isimessage( messageptr, size );
   479     TIsiSend isimessage( messageptr, size );
   451     isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_PIPE );
   480     isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_PIPE );
   452     isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REMOVE_REQ_OFFSET_UTID, 0 );
   481     isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REMOVE_REQ_OFFSET_UTID, 0 );
   457     isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REMOVE_REQ_OFFSET_FILLERBYTE1 ,0 );
   486     isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REMOVE_REQ_OFFSET_FILLERBYTE1 ,0 );
   458     isimessage.Complete();
   487     isimessage.Complete();
   459     C_TRACE(_L("Created ISI-message"));
   488     C_TRACE(_L("Created ISI-message"));
   460 
   489 
   461     TInt retVal = iIscApi.Send( messageptr );
   490     TInt retVal = iIscApi.Send( messageptr );
   462     ASSERT_PANIC_ALWAYS( retVal == KErrNone );
   491     TRACE_ASSERT( retVal == KErrNone );
   463     delete message;
   492     delete message;
   464     if( !iSchedulerWait )
   493     if( !iSchedulerWait )
   465         {
   494         {
   466         C_TRACE(_L("CModemAtPipeController::SendRemovePipeReq() iSchedulerWait->Start()"));
   495         C_TRACE(_L("CModemAtPipeController::SendRemovePipeReq() iSchedulerWait->Start()"));
   467         TRAPD(err, iSchedulerWait = new (ELeave) CActiveSchedulerWait);
   496         TRAPD(err, iSchedulerWait = new (ELeave) CActiveSchedulerWait);
   475     const TUint8 aNewDevId,
   504     const TUint8 aNewDevId,
   476     const TUint8 aNewObjId ) 
   505     const TUint8 aNewObjId ) 
   477     {
   506     {
   478     C_TRACE (( _T("CModemAtPipeController::RedirectPipe() dteid %d"), aDteId ));
   507     C_TRACE (( _T("CModemAtPipeController::RedirectPipe() dteid %d"), aDteId ));
   479     C_TRACE((_L("CModemAtPipeController::RedirectPipe() New pep, deviceId: 0x%x objId: 0x%x "), aNewDevId, aNewObjId));
   508     C_TRACE((_L("CModemAtPipeController::RedirectPipe() New pep, deviceId: 0x%x objId: 0x%x "), aNewDevId, aNewObjId));
   480     ASSERT_PANIC_ALWAYS( aDteId < KMaxDteIdCount ) 
   509     TRACE_ASSERT( aDteId < KMaxDteIdCount );
   481     ASSERT_PANIC_ALWAYS( iPipeTable[aDteId].iHandle != KInvalidPipeHandle )
   510     if( !(aDteId < KMaxDteIdCount) )
       
   511         {
       
   512         C_TRACE(( _T("CModemAtPipeController::RedirectPipe() illegal dteid %d"), aDteId ));
       
   513         return;
       
   514         }
       
   515     TRACE_ASSERT( iPipeTable[aDteId].iHandle != KInvalidPipeHandle );
       
   516     if( iPipeTable[aDteId].iHandle == KInvalidPipeHandle )
       
   517         {
       
   518         C_TRACE(( _T("CModemAtPipeController::RedirectPipe() invalid pipe handle %d"), iPipeTable[aDteId].iHandle ));
       
   519         return;
       
   520         }
   482 
   521 
   483     if( iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeRemoving || 
   522     if( iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeRemoving || 
   484         iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeNoPipe ) 
   523         iPipeTable[aDteId].iPipeState == TPipeInfo::EPipeNoPipe ) 
   485         {
   524         {
   486         C_TRACE(_L("CModemAtPipeController::RedirectPipe() Pipe is already removed -> cant redirect"));
   525         C_TRACE(_L("CModemAtPipeController::RedirectPipe() Pipe is already removed -> cant redirect"));
   499         }
   538         }
   500 
   539 
   501     C_TRACE(_L("CModemAtPipeController::RedirectPipe() Redirecting pipe"));
   540     C_TRACE(_L("CModemAtPipeController::RedirectPipe() Redirecting pipe"));
   502 
   541 
   503     HBufC8* message = HBufC8::New( ISI_HEADER_SIZE + SIZE_PNS_PIPE_REDIRECT_REQ );
   542     HBufC8* message = HBufC8::New( ISI_HEADER_SIZE + SIZE_PNS_PIPE_REDIRECT_REQ );
   504     ASSERT_PANIC_ALWAYS( message ) 
   543     ASSERT_PANIC_ALWAYS( message );
   505     TPtr8 messageptr = message->Des();
   544     TPtr8 messageptr = message->Des();
   506     TIsiSend isimessage( messageptr, ISI_HEADER_SIZE + SIZE_PNS_PIPE_REDIRECT_REQ );
   545     TIsiSend isimessage( messageptr, ISI_HEADER_SIZE + SIZE_PNS_PIPE_REDIRECT_REQ );
   507     isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID,PN_PIPE);
   546     isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID,PN_PIPE);
   508     isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_UTID, 0); 
   547     isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_UTID, 0); 
   509 
   548 
   532     isimessage.Set8bit(ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_NSB, KFiller );
   571     isimessage.Set8bit(ISI_HEADER_SIZE + PNS_PIPE_REDIRECT_REQ_OFFSET_NSB, KFiller );
   533     isimessage.Complete();
   572     isimessage.Complete();
   534 
   573 
   535     C_TRACE(_L("Created ISI-message"));
   574     C_TRACE(_L("Created ISI-message"));
   536     TInt retVal = iIscApi.Send( messageptr );
   575     TInt retVal = iIscApi.Send( messageptr );
   537     ASSERT_PANIC_ALWAYS( retVal == KErrNone );
   576     TRACE_ASSERT( retVal == KErrNone );
   538     delete message;
   577     delete message;
   539     }
   578     }
   540  
   579  
   541 void CModemAtPipeController::HandlePipeRedirectResp( const TIsiReceiveC& aReceivedMessage )
   580 void CModemAtPipeController::HandlePipeRedirectResp( const TIsiReceiveC& aReceivedMessage )
   542     {
   581     {
   572         SendEnablePipeReq( pipeHandle );
   611         SendEnablePipeReq( pipeHandle );
   573         }
   612         }
   574 
   613 
   575     }
   614     }
   576 
   615 
   577 void CModemAtPipeController::SendTaskIdQuery() 
   616 void CModemAtPipeController::QueryModemAtFromNameService() 
   578     {
   617     {
   579     C_TRACE (( _T("CModemAtPipeController::SendTaskIdQuery()") ));
   618     C_TRACE (( _T("CModemAtPipeController::QueryModemAtFromNameService()") ));
   580     HBufC8* message = HBufC8::New( KTaskIdQuerySize );
   619     HBufC8* message = HBufC8::New( ISI_HEADER_SIZE + SIZE_PNS_NAME_QUERY_REQ );
   581     TRACE_ASSERT( message );
   620     TRACE_ASSERT( message );
   582     if( message )
   621     if( message )
   583         {
   622         {
   584         TPtr8 messageptr = message->Des();
   623         TPtr8 messageptr = message->Des();
   585         TIsiSend isimessage( messageptr, KTaskIdQuerySize );
   624         TIsiSend isimessage( messageptr, ISI_HEADER_SIZE + SIZE_PNS_NAME_QUERY_REQ );
   586         isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_NAMESERVICE );       
   625         isimessage.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_NAMESERVICE );       
   587         isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_UTID, KDefaultTrId );
   626         isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_UTID, KDefaultTrId );
   588         isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_SUBFUNCTION, PNS_NAME_QUERY_REQ );
   627         isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_SUBFUNCTION, PNS_NAME_QUERY_REQ );
   589         isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_RESERVED1, 0 );
   628         isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_RESERVED1, 0 );
   590         isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_RESERVED2, 0);
   629         isimessage.Set8bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_RESERVED2, 0);
   592         isimessage.Set32bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_BITMASK, PN_AT_MODEM );
   631         isimessage.Set32bit( ISI_HEADER_SIZE + PNS_NAME_QUERY_REQ_OFFSET_BITMASK, PN_AT_MODEM );
   593         isimessage.Complete();
   632         isimessage.Complete();
   594 
   633 
   595         DUMP_MESSAGE( messageptr );
   634         DUMP_MESSAGE( messageptr );
   596         TInt retVal = iIscApi.Send( messageptr );
   635         TInt retVal = iIscApi.Send( messageptr );
   597         ASSERT_PANIC_ALWAYS( retVal == KErrNone );
   636         TRACE_ASSERT( retVal == KErrNone );
   598         delete message;
   637         delete message;
   599         }
   638         }
   600     }
   639     }
   601 
   640 
   602 void CModemAtPipeController::SendEnablePipeReq( const TUint8 aPipeHandle )
   641 void CModemAtPipeController::SendEnablePipeReq( const TUint8 aPipeHandle )
   613     isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_ENABLE_REQ_OFFSET_FILLERBYTE1 , 0 );
   652     isimessage.Set8bit( ISI_HEADER_SIZE + PNS_PIPE_ENABLE_REQ_OFFSET_FILLERBYTE1 , 0 );
   614     isimessage.Complete();
   653     isimessage.Complete();
   615 
   654 
   616     DUMP_MESSAGE( messageptr );
   655     DUMP_MESSAGE( messageptr );
   617     TInt retVal = iIscApi.Send( messageptr );
   656     TInt retVal = iIscApi.Send( messageptr );
   618     ASSERT_PANIC_ALWAYS( retVal == KErrNone );
   657     TRACE_ASSERT( retVal == KErrNone );
   619     delete message;
   658     delete message;
   620     }
   659     }
   621 
   660 
   622  TInt CModemAtPipeController::FindDteId( const TInt aHandle )
   661  TInt CModemAtPipeController::FindDteId( const TInt aHandle )
   623     {
   662     {