adaptationlayer/tsy/nokiatsy_dll/src/cmmpacketcontextmesshandler.cpp
changeset 0 63b37f68c1ce
child 5 8ccc39f9d787
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDES
       
    21 #include <in_sock.h>
       
    22 #include <etelutils.h>
       
    23 #include <etelmmerr.h>
       
    24 #include "cmmmessagerouter.h"
       
    25 #include "cmmpacketmesshandlercontextlist.h"
       
    26 #include "cmmpacketservicemesshandler.h"
       
    27 #include "cmmpacketcontextmesshandler.h"
       
    28 #include "cmmpacketqosmesshandler.h"
       
    29 #include "cmmphonetsender.h"
       
    30 #include <ctsy/serviceapi/mmtsy_defaults.h>
       
    31 #include "cmmstaticutility.h"
       
    32 #include <ctsy/serviceapi/cmmutility.h>
       
    33 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    34 #include <pcktcs.h>
       
    35 #include <ctsy/serviceapi/gsmerror.h>
       
    36 #include <tisi.h>
       
    37 #include <gpdsisi.h>
       
    38 #include "tsylogger.h"
       
    39 #include <gpds_sharedisi.h>
       
    40 #include <ctsy/pluginapi/cmmdatapackage.h>
       
    41 #include <call_modemisi.h>
       
    42 
       
    43 #if (NCP_COMMON_S60_VERSION_SUPPORT==S60_VERSION_32)
       
    44 #include <cmmcommonstaticutility.h>
       
    45 #endif // (NCP_COMMON_S60_VERSION_SUPPORT==S60_VERSION_32)
       
    46 #include "osttracedefinitions.h"
       
    47 #ifdef OST_TRACE_COMPILER_IN_USE
       
    48 #include "cmmpacketcontextmesshandlertraces.h"
       
    49 #endif
       
    50 
       
    51 // EXTERNAL DATA STRUCTURES
       
    52     //None
       
    53 
       
    54 // EXTERNAL FUNCTION PROTOTYPES
       
    55     //None
       
    56 
       
    57 // CONSTANTS
       
    58 
       
    59 // MACROS
       
    60     //None
       
    61 
       
    62 // LOCAL CONSTANTS AND MACROS
       
    63     //None
       
    64 
       
    65 // MODULE DATA STRUCTURES
       
    66     //None
       
    67 
       
    68 // LOCAL FUNCTION PROTOTYPES
       
    69     //None
       
    70 
       
    71 // FORWARD DECLARATIONS
       
    72     //None
       
    73 
       
    74 // ============================= LOCAL FUNCTIONS ===============================
       
    75 
       
    76     //None
       
    77 
       
    78 // ============================ MEMBER FUNCTIONS ===============================
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CMmPacketContextMessHandler::NewL
       
    82 // Two-phased constructor.
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 CMmPacketContextMessHandler* CMmPacketContextMessHandler::NewL(
       
    86     CMmPhoNetSender* const aPhoNetSender,
       
    87     CMmPhoNetReceiver* aPhoNetReceiver,
       
    88     CMmPacketContextMesshandlerList* aMmPacketContextMesshandlerList,
       
    89     CMmPacketQoSMessHandler* aMmPacketQoSMessHandler,
       
    90     CMmMessageRouter* aMessageRouter )
       
    91     {
       
    92 
       
    93     TFLOGSTRING("TSY: CMmPacketContextMessHandler::NewL." );
       
    94 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_NEWL, "CMmPacketContextMessHandler::NewL" );
       
    95 
       
    96     CMmPacketContextMessHandler* packetContextMessHandler =
       
    97         new ( ELeave ) CMmPacketContextMessHandler();
       
    98 
       
    99     CleanupStack::PushL( packetContextMessHandler );
       
   100 
       
   101     packetContextMessHandler->iPhoNetSender = aPhoNetSender;
       
   102     packetContextMessHandler->iPhoNetReceiver = aPhoNetReceiver;
       
   103     packetContextMessHandler->iContextList = aMmPacketContextMesshandlerList;
       
   104     packetContextMessHandler->iMmPacketQoSMessHandler = aMmPacketQoSMessHandler;
       
   105     packetContextMessHandler->iMessageRouter = aMessageRouter;
       
   106 
       
   107     packetContextMessHandler->ConstructL();
       
   108 
       
   109     aPhoNetReceiver->RegisterL(
       
   110         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_ID_CREATE_RESP );
       
   111     aPhoNetReceiver->RegisterL(
       
   112         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_ID_CREATE_IND );
       
   113     aPhoNetReceiver->RegisterL(
       
   114         packetContextMessHandler, PN_GPDS, GPDS_LL_CONFIGURE_RESP );
       
   115     aPhoNetReceiver->RegisterL(
       
   116         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_CONFIGURE_RESP );
       
   117     aPhoNetReceiver->RegisterL(
       
   118         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_AUTH_RESP );
       
   119     aPhoNetReceiver->RegisterL(
       
   120         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_ACTIVATING_IND );
       
   121     aPhoNetReceiver->RegisterL(
       
   122         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_ACTIVATE_IND );
       
   123     aPhoNetReceiver->RegisterL(
       
   124         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_ACTIVATE_FAIL_IND );
       
   125     aPhoNetReceiver->RegisterL(
       
   126         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_MODIFY_IND );
       
   127     aPhoNetReceiver->RegisterL(
       
   128         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_DEACTIVATING_IND );
       
   129     aPhoNetReceiver->RegisterL(
       
   130         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_DEACTIVATE_RESP );
       
   131     aPhoNetReceiver->RegisterL(
       
   132         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_DEACTIVATE_IND );
       
   133     aPhoNetReceiver->RegisterL(
       
   134         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_STATUS_RESP );
       
   135     aPhoNetReceiver->RegisterL(
       
   136         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_STATUS_IND );
       
   137     aPhoNetReceiver->RegisterL(
       
   138         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_ID_DELETE_IND );
       
   139     aPhoNetReceiver->RegisterL(
       
   140         packetContextMessHandler, PN_GPDS, GPDS_CONTEXT_MODIFY_RESP);
       
   141 
       
   142     // for allow incoming call feature
       
   143     aPhoNetReceiver->RegisterL(
       
   144         packetContextMessHandler, PN_MODEM_CALL, CALL_MODEM_RESOURCE_IND );
       
   145     aPhoNetReceiver->RegisterL(
       
   146         packetContextMessHandler, PN_MODEM_CALL, CALL_MODEM_RESOURCE_RESP );
       
   147 
       
   148     CleanupStack::Pop( packetContextMessHandler );
       
   149 
       
   150     return packetContextMessHandler;
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CMmPacketContextMessHandler::CMmPacketContextMessHandler
       
   155 // C++ default constructor can NOT contain any code, that might leave.
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 CMmPacketContextMessHandler::CMmPacketContextMessHandler()
       
   159     {
       
   160     //None
       
   161     TFLOGSTRING("TSY: CMmPacketContextMessHandler::CMmPacketContextMessHandler" );
       
   162 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_CMMPACKETCONTEXTMESSHANDLER, "CMmPacketContextMessHandler::CMmPacketContextMessHandler" );
       
   163 
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CMmPacketContextMessHandler::ConstructL
       
   168 // Symbian 2nd phase constructor can leave.
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CMmPacketContextMessHandler::ConstructL()
       
   172     {
       
   173 
       
   174     TFLOGSTRING("TSY: CMmPacketContextMessHandler::ConstructL.");
       
   175 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_CONSTRUCTL, "CMmPacketContextMessHandler::ConstructL" );
       
   176 
       
   177 #ifdef DUMMY_NIF_PEP_FOR_PACKET_DATA_TESTING_DOS
       
   178      iTransIdForProxies = 0;
       
   179 #endif // DUMMY_NIF_PEP_FOR_PACKET_DATA_TESTING_DOS
       
   180 
       
   181     // for allow incoming call feature
       
   182     iCallModemResourceCallId = CALL_MODEM_ID_NONE;
       
   183     iDeactivateContextList = NULL;
       
   184 
       
   185     // initialize DCM drive mode flag. Default value is EFalse.
       
   186     iDriveModeFlag = EFalse;
       
   187 
       
   188     // create pipe controller
       
   189     iMmPipeController = CMmPipeControl::NewL(
       
   190         iPhoNetSender, iPhoNetReceiver, this, iContextList );
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CMmPacketContextMessHandler::~CMmPacketContextMessHandler
       
   195 // Destructor, deletes all allocated resources.
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 CMmPacketContextMessHandler::~CMmPacketContextMessHandler()
       
   199     {
       
   200 
       
   201     TFLOGSTRING("TSY: CMmPacketContextMessHandler::~CMmPacketContextMessHandler." );
       
   202 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_CMMPACKETCONTEXTMESSHANDLER, "CMmPacketContextMessHandler::~CMmPacketContextMessHandler" );
       
   203 
       
   204     // Delete owned iMmPipeControl object
       
   205     if ( iMmPipeController )
       
   206         {
       
   207         delete iMmPipeController;
       
   208         }
       
   209 
       
   210     // for allow incoming call feature
       
   211     if ( iDeactivateContextList )
       
   212         {
       
   213         iDeactivateContextList->Reset();
       
   214         delete iDeactivateContextList;
       
   215         }
       
   216 
       
   217     // delete iResourceControlMsg if allocated
       
   218     if ( iResourceControlMsg  )
       
   219         {
       
   220         delete iResourceControlMsg;
       
   221         }
       
   222 
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CMmPacketContextMessHandler::ReceiveMessageL
       
   227 // Entry point for messages received from Domestic OS.
       
   228 // Switches the message to the correct method.
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 void CMmPacketContextMessHandler::ReceiveMessageL(
       
   232     const TIsiReceiveC& aIsiMessage )
       
   233     {
       
   234 
       
   235     TFLOGSTRING("TSY: CMmPacketContextMessHandler::ReceiveMessageL" );
       
   236 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_RECEIVEMESSAGEL, "CMmPacketContextMessHandler::ReceiveMessageL" );
       
   237 
       
   238     TInt resource( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_RESOURCEID ) );
       
   239     TInt messageId( aIsiMessage.Get8bit( ISI_HEADER_OFFSET_MESSAGEID ) );
       
   240 
       
   241     switch ( resource )
       
   242         {
       
   243         case PN_GPDS:
       
   244             {
       
   245             switch ( messageId )
       
   246                 {
       
   247                 // Context creation
       
   248                 case GPDS_CONTEXT_ID_CREATE_RESP:
       
   249                     {
       
   250                     GpdsContextIdCreateResp( aIsiMessage );
       
   251                     break;
       
   252                     }
       
   253                 case GPDS_CONTEXT_ID_CREATE_IND:
       
   254                     {
       
   255                     GpdsContextIdCreateInd( aIsiMessage );
       
   256                     break;
       
   257                     }
       
   258                 case GPDS_LL_CONFIGURE_RESP:
       
   259                     {
       
   260                     GpdsLlConfigureResp( aIsiMessage );
       
   261                     break;
       
   262                     }
       
   263                 // Context configuration
       
   264                 case GPDS_CONTEXT_CONFIGURE_RESP:
       
   265                     {
       
   266                     GpdsContextConfigureResp( aIsiMessage );
       
   267                     break;
       
   268                     }
       
   269                 // Context authentication
       
   270                 case GPDS_CONTEXT_AUTH_RESP:
       
   271                     {
       
   272                     GpdsContextAuthResp( aIsiMessage );
       
   273                     break;
       
   274                     }
       
   275                 case GPDS_CONTEXT_ACTIVATING_IND:
       
   276                     {
       
   277                     GpdsContextActivatingInd( aIsiMessage );
       
   278                     break;
       
   279                     }
       
   280                 case GPDS_CONTEXT_ACTIVATE_IND:
       
   281                     {
       
   282                     GpdsContextActivateIndL( aIsiMessage );
       
   283                     break;
       
   284                     }
       
   285                 case GPDS_CONTEXT_ACTIVATE_FAIL_IND:
       
   286                     {
       
   287                     GpdsContextActivateFailInd( aIsiMessage );
       
   288                     break;
       
   289                     }
       
   290                 // Context modifying
       
   291                 case GPDS_CONTEXT_MODIFY_IND:
       
   292                     {
       
   293                     GpdsContextModifyInd( aIsiMessage );
       
   294                     break;
       
   295                     }
       
   296                 // Context deactivation
       
   297                 case GPDS_CONTEXT_DEACTIVATING_IND:
       
   298                     {
       
   299                     GpdsContextDeactivatingInd( aIsiMessage );
       
   300                     break;
       
   301                     }
       
   302                 case GPDS_CONTEXT_DEACTIVATE_RESP:
       
   303                     {
       
   304                     GpdsContextDeactivateRespL( aIsiMessage );
       
   305                     break;
       
   306                     }
       
   307                 case GPDS_CONTEXT_DEACTIVATE_IND:
       
   308                     {
       
   309                     GpdsContextDeactivateInd( aIsiMessage );
       
   310                     break;
       
   311                     }
       
   312                 // Context status
       
   313                 case GPDS_CONTEXT_STATUS_RESP:
       
   314                     {
       
   315                     GpdsContextStatusResp( aIsiMessage );
       
   316                     break;
       
   317                     }
       
   318                 // Context deletion
       
   319                 case GPDS_CONTEXT_STATUS_IND:
       
   320                     {
       
   321                     GpdsContextStatusInd( aIsiMessage );
       
   322                     break;
       
   323                     }
       
   324                 case GPDS_CONTEXT_ID_DELETE_IND:
       
   325                     {
       
   326                     GpdsContextIdDeleteInd( aIsiMessage );
       
   327                     break;
       
   328                     }
       
   329                 case GPDS_CONTEXT_MODIFY_RESP:
       
   330                     {
       
   331                     GpdsContextModifyResp( aIsiMessage );
       
   332                     }
       
   333                 default:
       
   334                     {
       
   335 
       
   336                     TFLOGSTRING("TSY: CMmPacketContextMessHandler::ReceiveMessageL. Switch messageId case default");
       
   337 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_RECEIVEMESSAGEL, "CMmPacketContextMessHandler::ReceiveMessageL" );
       
   338 
       
   339                     //None
       
   340                     break;
       
   341                     }
       
   342                 }
       
   343             break;
       
   344             }
       
   345 
       
   346         // for allow incoming call feature
       
   347         case PN_MODEM_CALL:
       
   348             {
       
   349             if ( CALL_MODEM_RESOURCE_IND == messageId )
       
   350                 {
       
   351                 CallModemResourceIndL( aIsiMessage );
       
   352                 }
       
   353             else if ( CALL_MODEM_RESOURCE_RESP == messageId )
       
   354                 {
       
   355                 CallModemResourceResp( aIsiMessage );
       
   356                 }
       
   357             //no else
       
   358             break;
       
   359             }
       
   360 
       
   361         default:
       
   362             {
       
   363 
       
   364             TFLOGSTRING("TSY: CMmPacketContextMessHandler::ReceiveMessageL. Switch resource case default");
       
   365 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_RECEIVEMESSAGEL, "CMmPacketContextMessHandler::ReceiveMessageL" );
       
   366 
       
   367             //None
       
   368             break;
       
   369             }
       
   370         } // switch
       
   371     }
       
   372 
       
   373 // -----------------------------------------------------------------------------
       
   374 // CMmPacketContextMessHandler::GpdsContextIdCreateReq
       
   375 // Create an Isi-message for creating a context id.
       
   376 // -----------------------------------------------------------------------------
       
   377 //
       
   378 TInt CMmPacketContextMessHandler::GpdsContextIdCreateReq(
       
   379     const TUint8 aCreateContextIdTransId ) const
       
   380     {
       
   381 
       
   382     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextIdCreateReq. TransId: %d", aCreateContextIdTransId );
       
   383 OstTraceExt1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTIDCREATEREQ, "CMmPacketContextMessHandler::GpdsContextIdCreateReq;aCreateContextIdTransId=%hhu", aCreateContextIdTransId );
       
   384 
       
   385     //Append data for ISI message
       
   386     TBuf8<1> data;
       
   387     // Send Isi message via Phonet
       
   388     return iPhoNetSender->Send(
       
   389         PN_GPDS,
       
   390         aCreateContextIdTransId,
       
   391         GPDS_CONTEXT_ID_CREATE_REQ,
       
   392         data );
       
   393     }
       
   394 
       
   395 // -----------------------------------------------------------------------------
       
   396 // CMmPacketContextMessHandler::GpdsContextIdCreateResp
       
   397 // This method breaks the response to the Gpds Context Id Create request.
       
   398 // -----------------------------------------------------------------------------
       
   399 //
       
   400 void CMmPacketContextMessHandler::GpdsContextIdCreateResp(
       
   401     const TIsiReceiveC& aIsiMessage )
       
   402     {
       
   403 
       
   404     // Get transaction id
       
   405     TUint8 createContextIdTraId( aIsiMessage.Get8bit(
       
   406         ISI_HEADER_SIZE + GPDS_CONTEXT_ID_CREATE_RESP_OFFSET_UTID ) );
       
   407 
       
   408     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextIdCreateResp.CreateTraId: %d", createContextIdTraId );
       
   409 OstTraceExt1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTIDCREATERESP, "CMmPacketContextMessHandler::GpdsContextIdCreateResp;createContextIdTraId=%hhu", createContextIdTraId );
       
   410 
       
   411     // context stuff exists
       
   412     TInt ret = iContextList->CreateContextIdTraIdOK( createContextIdTraId );
       
   413 
       
   414     if ( KErrNone == ret )
       
   415         {
       
   416         // Get context id
       
   417         TUint8 contextId( aIsiMessage.Get8bit(
       
   418             ISI_HEADER_SIZE + GPDS_CONTEXT_ID_CREATE_RESP_OFFSET_CID ) );
       
   419         // Get status
       
   420         TUint8 status( aIsiMessage.Get8bit(
       
   421             ISI_HEADER_SIZE + GPDS_CONTEXT_ID_CREATE_RESP_OFFSET_STATUS ) );
       
   422 
       
   423         if ( GPDS_OK == status )
       
   424             {
       
   425             // Store the context id to contextList
       
   426             iContextList->SetContextId( contextId, createContextIdTraId );
       
   427             }
       
   428         else
       
   429             {
       
   430             InitialiseContextPhase3( status, contextId );
       
   431             }
       
   432         }
       
   433     //no else
       
   434     }
       
   435 
       
   436 // -----------------------------------------------------------------------------
       
   437 // CMmPacketContextMessHandler::GpdsContextIdCreateInd
       
   438 // Breaks gpds context id create indication message.
       
   439 // -----------------------------------------------------------------------------
       
   440 //
       
   441 void CMmPacketContextMessHandler::GpdsContextIdCreateInd(
       
   442     const TIsiReceiveC& aIsiMessage )
       
   443     {
       
   444 
       
   445     TFLOGSTRING( "TSY: CMmPacketContextMessHandler::GpdsContextIdCreateInd." );
       
   446 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTIDCREATEIND, "CMmPacketContextMessHandler::GpdsContextIdCreateInd" );
       
   447 
       
   448     // Get context id
       
   449     TUint8 contextId(  aIsiMessage.Get8bit(
       
   450         ISI_HEADER_SIZE + GPDS_CONTEXT_ID_CREATE_IND_OFFSET_CID ) );
       
   451 
       
   452     TInfoName mmContextName;
       
   453 
       
   454     TInt ret( iContextList->
       
   455         GetContextNameByContextId(contextId, mmContextName) );
       
   456     TInfoName hostCID( iContextList->GetHostCidName( &mmContextName ) );
       
   457 
       
   458     if( 0 != hostCID.Length() )
       
   459         {
       
   460         TInt hostId( iContextList->GetContextIdByContextName( &hostCID ) );
       
   461         if( GPDS_CID_VOID != hostId )
       
   462             {
       
   463             iContextList->SetInitialiseMember( contextId, ETrue );
       
   464             }
       
   465         //no else
       
   466         }
       
   467     //no else
       
   468 
       
   469     // Context stuff exists in list
       
   470     if ( KErrNone == ret )
       
   471         {
       
   472          // Creation of context id succeeded -> Call
       
   473          // InitialiseContextPhase3L with GPDS_OK
       
   474         InitialiseContextPhase3( GPDS_OK, contextId );
       
   475         }
       
   476     // no else
       
   477     }
       
   478 
       
   479 // -----------------------------------------------------------------------------
       
   480 // CMmPacketContextMessHandler::GpdsLlConfigureReq
       
   481 // Create an Isi-message for configuring the local link.
       
   482 // This function configures a local link between the context and the pipe.
       
   483 // -----------------------------------------------------------------------------
       
   484 //
       
   485 TInt CMmPacketContextMessHandler::GpdsLlConfigureReq(
       
   486     const TUint8 aTransactionId,
       
   487     const TUint8 aContextId,
       
   488     const TUint8 aPipeHandle ) const
       
   489     {
       
   490 
       
   491     TFLOGSTRING3( "TSY: CMmPacketContextMessHandler::GpdsLlConfigureReq. TransId: %d, ContextId: %d", aTransactionId, aContextId );
       
   492 OstTraceExt2( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSLLCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsLlConfigureReq;aTransactionId=%hhu;aContextId=%hhu", aTransactionId, aContextId );
       
   493     TFLOGSTRING2( "TSY: CMmPacketContextMessHandler::GpdsLlConfigureReq. PipeHandle: %d", aPipeHandle );
       
   494 OstTraceExt1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSLLCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsLlConfigureReq;aPipeHandle=%hhu", aPipeHandle );
       
   495 
       
   496     // Set the message data that consists of three parameters
       
   497     TBuf8<SIZE_GPDS_LL_CONFIGURE_REQ> messageData;
       
   498     messageData.Append( aContextId );
       
   499     messageData.Append( aPipeHandle );
       
   500     // Packet tsy uses always Plain mode
       
   501     messageData.Append( GPDS_LL_PLAIN );
       
   502 
       
   503     // Send Isi message via Phonet
       
   504     return iPhoNetSender->Send(
       
   505         PN_GPDS,
       
   506         aTransactionId,
       
   507         GPDS_LL_CONFIGURE_REQ,
       
   508         messageData );
       
   509     }
       
   510 
       
   511 // -----------------------------------------------------------------------------
       
   512 // CMmPacketContextMessHandler::GpdsLlConfigureResp
       
   513 // This method breaks the response to the local link configuration request.
       
   514 // -----------------------------------------------------------------------------
       
   515 //
       
   516 void CMmPacketContextMessHandler::GpdsLlConfigureResp(
       
   517     const TIsiReceiveC& aIsiMessage )
       
   518     {
       
   519 
       
   520     TFLOGSTRING( "TSY: CMmPacketContextMessHandler::GpdsLlConfigureResp.");
       
   521 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSLLCONFIGURERESP, "CMmPacketContextMessHandler::GpdsLlConfigureResp" );
       
   522 
       
   523     // Get transaction id
       
   524     TUint8 transActionId( aIsiMessage.Get8bit(
       
   525         ISI_HEADER_SIZE + GPDS_LL_CONFIGURE_RESP_OFFSET_UTID ) );
       
   526 
       
   527     if ( KErrNone == iContextList->GpdsLlConfigureTraIdOK( transActionId ) )
       
   528         {
       
   529         TUint8 contextId( aIsiMessage.Get8bit(
       
   530             ISI_HEADER_SIZE + GPDS_LL_CONFIGURE_RESP_OFFSET_CID ) );
       
   531 
       
   532         transActionId = iContextList->
       
   533             CreateContextIdTraIdByContextId( contextId );
       
   534 
       
   535         if( KTUint8NotDefined != transActionId )
       
   536             {
       
   537             // Get status
       
   538             TUint8 status( aIsiMessage.Get8bit(
       
   539                 ISI_HEADER_SIZE + GPDS_LL_CONFIGURE_RESP_OFFSET_STATUS ) );
       
   540 
       
   541             if( GPDS_OK == status )
       
   542                 {
       
   543                 // Get context name by context id
       
   544                 TInfoName contextName; // just to check if context stuff exists
       
   545                 TInt ret( iContextList->
       
   546                     GetContextNameByContextId( contextId, contextName ) );
       
   547 
       
   548                 if( KErrNone == ret )
       
   549                     {
       
   550                     // If all is OK this far, complete Initialisation
       
   551                     CMmDataPackage data;
       
   552                     data.PackData( &contextName );
       
   553                     iMessageRouter->Complete(
       
   554                         EPacketContextInitialiseContext,
       
   555                         &data,
       
   556                         KErrNone );
       
   557                     }
       
   558                 else if( KErrArgument == ret )
       
   559                     {
       
   560 
       
   561                     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsLlConfigureResp. Initialisation Complete failed" );
       
   562 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSLLCONFIGURERESP, "CMmPacketContextMessHandler::GpdsLlConfigureResp, Initialisation Complete failed" );
       
   563                     }
       
   564                 //no else
       
   565                 }
       
   566             else
       
   567                 {
       
   568 
       
   569                 // create transaction Id for pipe removal
       
   570                 // one TraId is used for one context
       
   571                 TUint8 pipeRemoveTraId( transActionId );
       
   572                 TUint8 pipeHandle = iContextList->
       
   573                     PipeHandleByContextId( contextId );
       
   574                 // Remove the pipe
       
   575                 TInt ret( iMmPipeController->
       
   576                     PnsPipeRemoveReq( pipeRemoveTraId, pipeHandle ) );
       
   577 
       
   578                 if ( KErrNone == ret )
       
   579                     {
       
   580                     // Store the trans id
       
   581                     ret = iContextList->
       
   582                         SetRemovePipeTraId( pipeRemoveTraId, pipeHandle );
       
   583                     }
       
   584                 else
       
   585                     {
       
   586                     // check if context stuff exists
       
   587                     TInfoName contextName;
       
   588                     ret = iContextList->
       
   589                         GetContextNameByContextId( contextId, contextName );
       
   590 
       
   591                     if( KErrNone == ret )
       
   592                         {
       
   593                         // Complete initialisation; some error in gprs server
       
   594                         CMmDataPackage data;
       
   595                         data.PackData( &contextName );
       
   596                         iMessageRouter->Complete(
       
   597                             EPacketContextInitialiseContext,
       
   598                             &data,
       
   599                             KErrGeneral );
       
   600                         }
       
   601                     }
       
   602                 }
       
   603             }
       
   604         // no else
       
   605         }
       
   606     // no else
       
   607     }
       
   608 
       
   609 // -----------------------------------------------------------------------------
       
   610 // CMmPacketContextMessHandler::GpdsContextConfigureReq
       
   611 // Create an Isi-message for context configuration.
       
   612 // -----------------------------------------------------------------------------
       
   613 //
       
   614 TInt CMmPacketContextMessHandler::GpdsContextConfigureReq(
       
   615     const TUint8 aTransactionId,
       
   616     const TUint8 aContextId,
       
   617     const TUint8 aPdpType,
       
   618     const TUint8 aContextType,
       
   619     const TUint8 aPrimaryContextId,
       
   620     const TUint8 aDataCompression,
       
   621     const TUint8 aHeaderCompression,
       
   622     const TBuf8<KAccessPointBuffer252>& aAccessPointName,
       
   623     CArrayFixFlat<RPacketContext::TPacketFilterV2>* aPacketFilterPtr,
       
   624     RPacketContext::CTFTMediaAuthorizationV3* aMediaAuthorization,
       
   625     TBool aSignallingIndication,
       
   626     TBool aPCFCSAddressIndication,
       
   627     TBool aDNSAddressRequestIndication )
       
   628     {
       
   629 
       
   630     TFLOGSTRING3("TSY: CMmPacketContextMessHandler::GpdsContextConfigureReq. TransId: %d ContextId: %d", aTransactionId, aContextId );
       
   631 OstTraceExt2( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsContextConfigureReq;aTransactionId=%hhu;aContextId=%hhu", aTransactionId, aContextId );
       
   632 
       
   633     // Initializing ret value to KErrNone
       
   634     TInt ret( KErrNone );
       
   635 
       
   636     // Create isi message
       
   637     TIsiSend gpdsContextConfigureReq( iPhoNetSender->SendBufferDes() );
       
   638     gpdsContextConfigureReq.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_GPDS );
       
   639 
       
   640     // Set the Gpds Context Configure Req data
       
   641     gpdsContextConfigureReq.Set8bit(
       
   642         ISI_HEADER_OFFSET_TRANSID, aTransactionId );
       
   643     gpdsContextConfigureReq.Set8bit(
       
   644         ISI_HEADER_OFFSET_MESSAGEID, GPDS_CONTEXT_CONFIGURE_REQ );
       
   645     gpdsContextConfigureReq.Set8bit(
       
   646         ISI_HEADER_SIZE + GPDS_CONTEXT_CONFIGURE_REQ_OFFSET_CID,
       
   647         aContextId );
       
   648     gpdsContextConfigureReq.Set8bit(
       
   649         ISI_HEADER_SIZE + GPDS_CONTEXT_CONFIGURE_REQ_OFFSET_PDPTYPE,
       
   650         aPdpType );
       
   651     gpdsContextConfigureReq.Set8bit(
       
   652         ISI_HEADER_SIZE + GPDS_CONTEXT_CONFIGURE_REQ_OFFSET_CONTEXTTYPE,
       
   653         aContextType );
       
   654     gpdsContextConfigureReq.Set8bit(
       
   655         ISI_HEADER_SIZE + GPDS_CONTEXT_CONFIGURE_REQ_OFFSET_PRIMARYCID,
       
   656         aPrimaryContextId );
       
   657     gpdsContextConfigureReq.Set8bit(
       
   658         ISI_HEADER_SIZE + GPDS_CONTEXT_CONFIGURE_REQ_OFFSET_FILLERBYTE1,
       
   659         KGpdsPadding );
       
   660 
       
   661     // Initialize message offset and subblock count
       
   662     TInt currentMsgOffset(
       
   663         ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_CONFIGURE_REQ );
       
   664     TUint8 numOfSbInMessage( 0 );
       
   665 
       
   666     // GPDS_SHARED_IM_CN_SIGNALING_FLAG_INFO (= 0xF7)
       
   667     // An OPTIONAL sub block of Configure Req.
       
   668     // Context for dedicated signaling purpose can be configured either using
       
   669     // REL5
       
   670     // QoS sub-block or IM CN Subsystem Signaling Flag sub-block.
       
   671     if( aSignallingIndication )
       
   672         {
       
   673 
       
   674         TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextConfigureReq. signalling indication ON");
       
   675 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsContextConfigureReq, signalling indication ON" );
       
   676 
       
   677         TBuf8<SIZE_GPDS_SHARED_IM_CN_SIGNALING_FLAG_INFO> tempSbBuffer;
       
   678         TIsiSubBlock flagInfoSubBlock(
       
   679             tempSbBuffer,
       
   680             GPDS_SHARED_IM_CN_SIGNALING_FLAG_INFO,
       
   681             EIsiSubBlockTypeId8Len8 );
       
   682 
       
   683         tempSbBuffer.Append( GPDS_CTX_FOR_DEDICATED_SIGN );
       
   684         tempSbBuffer.Append( KGpdsPadding );
       
   685         gpdsContextConfigureReq.CopyData(
       
   686             currentMsgOffset, flagInfoSubBlock.CompleteSubBlock() );
       
   687         // Set new offset and increase subblock count
       
   688         currentMsgOffset =
       
   689             currentMsgOffset + SIZE_GPDS_SHARED_IM_CN_SIGNALING_FLAG_INFO;
       
   690         numOfSbInMessage++;
       
   691         }
       
   692     //no else
       
   693 
       
   694     // GPDS_DNS_ADDRESS_REQ_INFO (= 0x90)
       
   695     // An OPTIONAL sub block of Configure Req
       
   696     if( aDNSAddressRequestIndication )
       
   697         {
       
   698 
       
   699         TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextConfigureReq. DNS address request indication indication ON");
       
   700 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsContextConfigureReq, DNS address request indication indication ON" );
       
   701 
       
   702         TInt ret( iContextList->SetDNSAddressInfoToContextInfo( aContextId ) );
       
   703 
       
   704         if ( KErrNone == ret )
       
   705             {
       
   706 
       
   707             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextConfigureReq. DNS Requested");
       
   708 OstTrace0( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsContextConfigureReq, DNS Requested" );
       
   709 
       
   710             TBuf8<SIZE_GPDS_DNS_ADDRESS_REQ_INFO> tempDnsAddrInfo;
       
   711             TIsiSubBlock reqInfoSubBlock(
       
   712                 tempDnsAddrInfo,
       
   713                 GPDS_DNS_ADDRESS_REQ_INFO,
       
   714                 EIsiSubBlockTypeId8Len8 );
       
   715 
       
   716             tempDnsAddrInfo.Append( KGpdsPadding );
       
   717             tempDnsAddrInfo.Append( KGpdsPadding );
       
   718             gpdsContextConfigureReq.CopyData(
       
   719                 currentMsgOffset, reqInfoSubBlock.CompleteSubBlock() );
       
   720             // Set new offset and increase subblock count
       
   721             currentMsgOffset =
       
   722                 currentMsgOffset + SIZE_GPDS_DNS_ADDRESS_REQ_INFO;
       
   723             numOfSbInMessage++;
       
   724             }
       
   725         // no else
       
   726         }
       
   727     // no else
       
   728 
       
   729     // GPDS_SHARED_PCSCF_ADDRESS_REQ_INFO (= 0xF3)
       
   730     // An OPTIONAL sub block of Configure Req
       
   731     if( aPCFCSAddressIndication )
       
   732         {
       
   733         TInt ret( iContextList->
       
   734             SetPCSCFAddressInfoToContextInfo( aContextId ) );
       
   735 
       
   736         if ( KErrNone == ret )
       
   737             {
       
   738 
       
   739             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextConfigureReq. PCSCF Requested");
       
   740 OstTrace0( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsContextConfigureReq, PCSCF Requested" );
       
   741 
       
   742             TBuf8<SIZE_GPDS_SHARED_PCSCF_ADDRESS_REQ_INFO> tempPscfAddrInfo;
       
   743             TIsiSubBlock reqInfoSubBlock(
       
   744                 tempPscfAddrInfo,
       
   745                 GPDS_SHARED_PCSCF_ADDRESS_REQ_INFO,
       
   746                 EIsiSubBlockTypeId8Len8 );
       
   747 
       
   748             tempPscfAddrInfo.Append( KGpdsPadding );
       
   749             tempPscfAddrInfo.Append( KGpdsPadding );
       
   750             gpdsContextConfigureReq.CopyData(
       
   751                 currentMsgOffset, reqInfoSubBlock.CompleteSubBlock() );
       
   752             // Set new offset and increase subblock count
       
   753             currentMsgOffset =
       
   754                 currentMsgOffset + SIZE_GPDS_SHARED_PCSCF_ADDRESS_REQ_INFO;
       
   755             numOfSbInMessage++;
       
   756             }
       
   757         // no else
       
   758         }
       
   759     //no else
       
   760 
       
   761     // GPDS_TFT_INFO
       
   762     // An OPTIONAL sub block of Configure Req.
       
   763     if ( aMediaAuthorization || aPacketFilterPtr )
       
   764         {
       
   765         TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextConfigureReq. MediaAuthorization || PacketFilterPtr");
       
   766 OstTrace0( TRACE_NORMAL, DUP5_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsContextConfigureReq, MediaAuthorization || PacketFilterPtr" );
       
   767 
       
   768         TBuf8<KMaximumLengthOfGpdsTftInfo> gpdsTftInfoSbBuffer;
       
   769         TIsiSubBlock gpdsTftInfoSubBlock(
       
   770             gpdsTftInfoSbBuffer,
       
   771             GPDS_TFT_INFO,
       
   772             EIsiSubBlockTypeId8Len8 );
       
   773 
       
   774         ret = FillGpdsTFTInfo( GPDS_TFT_CREATE_NEW, aMediaAuthorization,
       
   775                                aPacketFilterPtr, aPdpType, gpdsTftInfoSbBuffer );
       
   776 
       
   777         if ( KErrNone == ret )
       
   778             {
       
   779             gpdsContextConfigureReq.CopyData(
       
   780                 currentMsgOffset, gpdsTftInfoSubBlock.CompleteSubBlock() );
       
   781             // Set new message offset and increase messages subblock count
       
   782             currentMsgOffset = currentMsgOffset + gpdsTftInfoSbBuffer.Length();
       
   783             numOfSbInMessage++;
       
   784             }
       
   785         }
       
   786     // no else
       
   787 
       
   788     // If there were no errors
       
   789     if ( KErrNone == ret )
       
   790         {
       
   791         TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextConfigureReq. there were no errors");
       
   792 OstTrace0( TRACE_NORMAL, DUP7_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGUREREQ, "CMmPacketContextMessHandler::GpdsContextConfigureReq, there were no errors" );
       
   793 
       
   794         // Add GPDS_COMP_INFO subblock
       
   795         // sub block of Configure Req
       
   796         TBuf8<SIZE_GPDS_COMP_INFO> compInfo;
       
   797         TIsiSubBlock compInfoSubBlock(
       
   798             compInfo,
       
   799             GPDS_COMP_INFO,
       
   800             EIsiSubBlockTypeId8Len8 );
       
   801 
       
   802         compInfo.Append( aDataCompression );
       
   803         compInfo.Append( aHeaderCompression );
       
   804         gpdsContextConfigureReq.CopyData(
       
   805             currentMsgOffset, compInfoSubBlock.CompleteSubBlock() );
       
   806         // Set new offset and increase subblock count
       
   807         currentMsgOffset = currentMsgOffset + SIZE_GPDS_COMP_INFO;
       
   808         numOfSbInMessage++;
       
   809 
       
   810         // Add GPDS_APN_INFO subblock
       
   811         // sub block of Configure Req
       
   812         TBuf8<SIZE_GPDS_APN_INFO + RPacketContext::KGSNNameLength>
       
   813             accessPointNameInfo;
       
   814         TIsiSubBlock apnInfoSubBlock(
       
   815             accessPointNameInfo,
       
   816             GPDS_APN_INFO,
       
   817             EIsiSubBlockTypeId8Len8 );
       
   818 
       
   819         accessPointNameInfo.Append(
       
   820             static_cast<TUint8>( aAccessPointName.Length() ) );
       
   821         accessPointNameInfo.Append( aAccessPointName );
       
   822         gpdsContextConfigureReq.CopyData(
       
   823             currentMsgOffset, apnInfoSubBlock.CompleteSubBlock() );
       
   824         // Set new offset and increase subblock count
       
   825         currentMsgOffset = currentMsgOffset + accessPointNameInfo.Length();
       
   826         numOfSbInMessage++;
       
   827 
       
   828         // Add GPDS_SHARED_RADIO_ACTIVITY_REQ_INFO sub block
       
   829         TBuf8< SIZE_GPDS_SHARED_RADIO_ACTIVITY_REQ_INFO > radioActivity;
       
   830         TIsiSubBlock radioActivitySubBlock(
       
   831             radioActivity,
       
   832             GPDS_SHARED_RADIO_ACTIVITY_REQ_INFO,
       
   833             EIsiSubBlockTypeId8Len8 );
       
   834 
       
   835         // contains no parameters
       
   836         radioActivity.Append( KGpdsPadding );
       
   837         radioActivity.Append( KGpdsPadding );
       
   838         gpdsContextConfigureReq.CopyData(
       
   839             currentMsgOffset, radioActivitySubBlock.CompleteSubBlock() );
       
   840         // Set new offset and increase subblock count
       
   841         currentMsgOffset = currentMsgOffset +
       
   842             SIZE_GPDS_SHARED_RADIO_ACTIVITY_REQ_INFO;
       
   843         numOfSbInMessage++;
       
   844 
       
   845         // Set number of subblocks in GPDS_CONTEXT_CONFIGURE_REQ message
       
   846         gpdsContextConfigureReq.Set8bit(
       
   847             ISI_HEADER_SIZE +
       
   848             GPDS_CONTEXT_CONFIGURE_REQ_OFFSET_NUMBEROFSUBBLOCKS,
       
   849             numOfSbInMessage );
       
   850         // Send GPDS_CONTEXT_CONFIGURE_REQ message
       
   851         ret = iPhoNetSender->Send( gpdsContextConfigureReq.Complete() );
       
   852         }
       
   853     // no else
       
   854 
       
   855     return ret;
       
   856     }
       
   857 
       
   858 // -----------------------------------------------------------------------------
       
   859 // CMmPacketContextMessHandler::GpdsContextConfigureResp
       
   860 // This method breaks the response to the context configuration request.
       
   861 // -----------------------------------------------------------------------------
       
   862 //
       
   863 void CMmPacketContextMessHandler::GpdsContextConfigureResp(
       
   864     const TIsiReceiveC& aIsiMessage )
       
   865     {
       
   866     TInt ret( KErrNone );
       
   867     // Get transaction id
       
   868     TUint8 transactionId( aIsiMessage.Get8bit(
       
   869         ISI_HEADER_SIZE + GPDS_CONTEXT_CONFIGURE_RESP_OFFSET_UTID ) );
       
   870 
       
   871     TUint8 contextId( aIsiMessage.Get8bit(
       
   872         ISI_HEADER_SIZE + GPDS_CONTEXT_CONFIGURE_RESP_OFFSET_CID ) );
       
   873 
       
   874     TUint8 proxyId( GenerateTraId( contextId ) );
       
   875 
       
   876     TInfoName contextName;
       
   877     ret = iContextList->GetContextNameByContextId( contextId, contextName );
       
   878 
       
   879     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextConfigureResp. GetContextNameByContextId returns:%d", ret);
       
   880 OstTrace1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGURERESP, "CMmPacketContextMessHandler::GpdsContextConfigureResp;returns=%d", ret );
       
   881 
       
   882     // Check that transactionId and context exists
       
   883     if ( transactionId == proxyId && KErrNone == ret )
       
   884         {
       
   885         CMmDataPackage dataPackage;
       
   886         dataPackage.PackData( &contextName );
       
   887         TUint8 status( aIsiMessage.Get8bit(
       
   888             ISI_HEADER_SIZE + GPDS_CONTEXT_CONFIGURE_RESP_OFFSET_STATUS ) );
       
   889 
       
   890         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextConfigureResp. status: %d", status);
       
   891 OstTraceExt1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGURERESP, "CMmPacketContextMessHandler::GpdsContextConfigureResp;status=%hhu", status );
       
   892 
       
   893         if ( GPDS_OK == status )
       
   894             {
       
   895             TInt configurationType( iContextList->
       
   896                 GetContextConfigurationType( contextId ) );
       
   897 
       
   898             if( KTIntNotDefined != configurationType )
       
   899                 {
       
   900 
       
   901                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextConfigureResp. KTIntNotDefined != configurationType");
       
   902 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGURERESP, "CMmPacketContextMessHandler::GpdsContextConfigureResp, KTIntNotDefined != configurationType" );
       
   903 
       
   904                 if( TPacketDataConfigBase::KConfigGPRS == configurationType )
       
   905                     {
       
   906 
       
   907                     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextConfigureResp. configurationType == KConfigGPRS");
       
   908 OstTrace0( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTCONFIGURERESP, "CMmPacketContextMessHandler::GpdsContextConfigureResp, configurationType == KConfigGPRS" );
       
   909 
       
   910                      // authentication info included in setconfig. Send auth reg
       
   911                     RPacketContext::TContextConfigGPRS* config =
       
   912                         reinterpret_cast<RPacketContext::TContextConfigGPRS*>(
       
   913                             iContextList->GetConfig( contextId,
       
   914                                                      configurationType ) );
       
   915 
       
   916                     if ( RPacketContext::EProtocolPAP ==
       
   917                         config->iProtocolConfigOption.iAuthInfo.iProtocol ||
       
   918                         RPacketContext::EProtocolCHAP ==
       
   919                         config->iProtocolConfigOption.iAuthInfo.iProtocol )
       
   920                         {
       
   921                         ret = SetAuthenticationConfigReq(
       
   922                             transactionId, contextId,
       
   923                             config->iProtocolConfigOption.iAuthInfo,
       
   924                             config->iProtocolConfigOption.iResponse,
       
   925                             config->iProtocolConfigOption.iChallenge,
       
   926                             config->iProtocolConfigOption.iId );
       
   927 
       
   928                         if( KErrNone != ret )
       
   929                             {
       
   930                             // Error in sending authentication reg.
       
   931                             iMessageRouter->Complete(
       
   932                                 EPacketContextSetConfig,
       
   933                                 &dataPackage,
       
   934                                 ret );
       
   935                             }
       
   936                         //no else
       
   937                         }
       
   938                     else
       
   939                         {
       
   940                         // Authentication not included, Complete with KErrNone
       
   941                         iMessageRouter->Complete(
       
   942                             EPacketContextSetConfig,
       
   943                             &dataPackage,
       
   944                             ret );
       
   945                         }
       
   946                     }
       
   947                 else
       
   948                     {
       
   949                     RPacketContext::TContextConfigR99_R4* config =
       
   950                         reinterpret_cast<RPacketContext::TContextConfigR99_R4*>(
       
   951                             iContextList->GetConfig( contextId,
       
   952                                 TPacketDataConfigBase::KConfigRel99Rel4 ) );
       
   953 
       
   954                     // authentication info included in setconfig. Send auth reg
       
   955                     if ( RPacketContext::EProtocolPAP ==
       
   956                         config->iProtocolConfigOption.iAuthInfo.iProtocol ||
       
   957                         RPacketContext::EProtocolCHAP ==
       
   958                         config->iProtocolConfigOption.iAuthInfo.iProtocol )
       
   959                         {
       
   960                         ret = SetAuthenticationConfigReq(
       
   961                             transactionId, contextId,
       
   962                             config->iProtocolConfigOption.iAuthInfo,
       
   963                             config->iProtocolConfigOption.iResponse,
       
   964                             config->iProtocolConfigOption.iChallenge,
       
   965                             config->iProtocolConfigOption.iId );
       
   966 
       
   967                         if( KErrNone != ret )
       
   968                             {
       
   969                             // Error in sending authentication reg.
       
   970                             iMessageRouter->Complete(
       
   971                                 EPacketContextSetConfig,
       
   972                                 &dataPackage,
       
   973                                 ret );
       
   974                             }
       
   975                         // no else
       
   976                         }
       
   977                       else
       
   978                         {
       
   979                         // Authentication not included, Complete with KErrNone
       
   980                         iMessageRouter->Complete(
       
   981                             EPacketContextSetConfig,
       
   982                             &dataPackage,
       
   983                             ret );
       
   984                         }
       
   985                     }
       
   986                 }
       
   987             else
       
   988                 {
       
   989                 // Configuration type not found
       
   990                 iMessageRouter->Complete(
       
   991                     EPacketContextSetConfig,
       
   992                     &dataPackage,
       
   993                     KErrGeneral );
       
   994                 }
       
   995             }
       
   996         else
       
   997             {
       
   998             // Some error in Gpds server, Complete with KErrGeneral
       
   999             iMessageRouter->Complete(
       
  1000                 EPacketContextSetConfig,
       
  1001                 &dataPackage,
       
  1002                 KErrGeneral );
       
  1003             }
       
  1004         }
       
  1005     // no else
       
  1006     }
       
  1007 
       
  1008 // -----------------------------------------------------------------------------
       
  1009 // CMmPacketContextMessHandler::GpdsContextAuthResp
       
  1010 // This method breaks the response for setting the context authentication info.
       
  1011 // -----------------------------------------------------------------------------
       
  1012 //
       
  1013 void CMmPacketContextMessHandler::GpdsContextAuthResp(
       
  1014     const TIsiReceiveC& aIsiMessage )
       
  1015     {
       
  1016 
       
  1017     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextAuthResp." );
       
  1018 
       
  1019     TInt errorCause( KErrNone );
       
  1020 
       
  1021     TUint8 contextId( aIsiMessage.Get8bit(
       
  1022         ISI_HEADER_SIZE + GPDS_CONTEXT_AUTH_RESP_OFFSET_CID ) );
       
  1023 
       
  1024     TInfoName contextName;
       
  1025 
       
  1026     if ( KErrNone == iContextList->
       
  1027         GetContextNameByContextId( contextId, contextName ) )
       
  1028         {
       
  1029         TUint8 status( aIsiMessage.Get8bit(
       
  1030             ISI_HEADER_SIZE + GPDS_CONTEXT_AUTH_RESP_OFFSET_STATUS ) );
       
  1031 
       
  1032         if ( GPDS_OK != status )
       
  1033             {
       
  1034             errorCause = KErrGeneral;
       
  1035             }
       
  1036         // no else
       
  1037 
       
  1038         CMmDataPackage dataPackage;
       
  1039         dataPackage.PackData( &contextName );
       
  1040         // Complete Set Config Info
       
  1041         iMessageRouter->Complete(
       
  1042             EPacketContextSetConfig,
       
  1043             &dataPackage,
       
  1044             errorCause );
       
  1045         }
       
  1046     // no else
       
  1047     }
       
  1048 
       
  1049 // -----------------------------------------------------------------------------
       
  1050 // CMmPacketContextMessHandler::GpdsContextActivateReq
       
  1051 // Create an Isi-message for context activation.
       
  1052 // -----------------------------------------------------------------------------
       
  1053 //
       
  1054 TInt CMmPacketContextMessHandler::GpdsContextActivateReq(
       
  1055     const TUint8 aTransactionId,
       
  1056     const TUint8 aContextId,
       
  1057     const TDesC8& aPdpAddress,
       
  1058     const TUint8 aPdpType ) const
       
  1059     {
       
  1060 
       
  1061     TFLOGSTRING3("TSY: CMmPacketContextMessHandler::GpdsContextActivateReq. TransId: %d ContextId: %d", aTransactionId, aContextId );
       
  1062 OstTraceExt2( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEREQ, "CMmPacketContextMessHandler::GpdsContextActivateReq;aTransactionId=%hhu;aContextId=%hhu", aTransactionId, aContextId );
       
  1063 
       
  1064     TInt ret(iContextList->SetActivationTraId( aContextId, aTransactionId ));
       
  1065 
       
  1066     if( KErrNone == ret )
       
  1067         {
       
  1068         // Create and set gpds isi message
       
  1069         TBuf8<SIZE_GPDS_CONTEXT_ACTIVATE_REQ + KMaxLengthOfGdpsActivateReqSB>
       
  1070             gpdsActivateReq;
       
  1071         gpdsActivateReq.Append( aContextId );
       
  1072 
       
  1073         // Create GPDS_PDP_ADDRESS_INFO subblock
       
  1074         // Max length of pdpAddressInfo is 20
       
  1075         // If aPdpAddress length is more than zero, and the type of aPdpAddress
       
  1076         // is IPv4 or IPv6, create GPDS_PDP_ADDRESS_INFO
       
  1077         if ( 0 < aPdpAddress.Length() &&
       
  1078             ( GPDS_PDP_TYPE_IPV4 == aPdpType ||
       
  1079                 GPDS_PDP_TYPE_IPV6 == aPdpType ) )
       
  1080             {
       
  1081             // Set the pdp address info
       
  1082             TBuf8<KMaxLengthOfGdpsActivateReqSB> pdpAddressInfo;
       
  1083             pdpAddressInfo.Zero();
       
  1084             TIsiSubBlock gpdsPdpAddressInfoSb (
       
  1085                 pdpAddressInfo,
       
  1086                 GPDS_PDP_ADDRESS_INFO,
       
  1087                 EIsiSubBlockTypeId8Len8 );
       
  1088 
       
  1089             pdpAddressInfo.Append( KGpdsPadding );
       
  1090             pdpAddressInfo.Append( aPdpAddress.Length() ); //lenght should always
       
  1091                                                            //be 4 or 16
       
  1092             pdpAddressInfo.Append( aPdpAddress );
       
  1093 
       
  1094             TUint8 subBlockCount( 1 );
       
  1095             gpdsActivateReq.Append( subBlockCount );
       
  1096             gpdsActivateReq.Append( gpdsPdpAddressInfoSb.CompleteSubBlock() );
       
  1097             }
       
  1098         else
       
  1099             {
       
  1100             gpdsActivateReq.Append( 0 ); //sub block count
       
  1101             }
       
  1102 
       
  1103         // Send Isi message via Phonet
       
  1104         ret = iPhoNetSender->Send( PN_GPDS,
       
  1105             aTransactionId, GPDS_CONTEXT_ACTIVATE_REQ, gpdsActivateReq );
       
  1106         }
       
  1107     // no else
       
  1108 
       
  1109     return ret;
       
  1110     }
       
  1111 
       
  1112 // -----------------------------------------------------------------------------
       
  1113 // CMmPacketContextMessHandler::GpdsContextActivatingInd
       
  1114 // Breaks gpds context activating indication message.
       
  1115 // Indicate that context activation has started.
       
  1116 // -----------------------------------------------------------------------------
       
  1117 //
       
  1118 void CMmPacketContextMessHandler::GpdsContextActivatingInd(
       
  1119     const TIsiReceiveC& aIsiMessage )
       
  1120     {
       
  1121 
       
  1122     TUint8 contextId( aIsiMessage.Get8bit(
       
  1123         ISI_HEADER_SIZE + GPDS_CONTEXT_ACTIVATING_IND_OFFSET_CID ) );
       
  1124 
       
  1125     // Get transaction id for completion
       
  1126     iContextList->GetAndResetActivationTraId( contextId );
       
  1127 
       
  1128     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivatingInd. ContextId: %d", contextId );
       
  1129 OstTraceExt1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATINGIND, "CMmPacketContextMessHandler::GpdsContextActivatingInd;contextId=%hhu", contextId );
       
  1130 
       
  1131     CMmDataPackage data;
       
  1132     TInt dialUpContext( KTIntNotDefined );
       
  1133     TInfoName contextName;
       
  1134     TInt ret( KErrNone );
       
  1135     TUint sbStartOffSet( 0 );
       
  1136 
       
  1137     ret = iContextList->GetContextNameByContextId( contextId, contextName );
       
  1138 
       
  1139     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivatingInd. GetContextNameByContextId returns: %d", ret );
       
  1140 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATINGIND, "CMmPacketContextMessHandler::GpdsContextActivatingInd;ret=%d", ret );
       
  1141 
       
  1142     // context not found, check dial-up context
       
  1143     if ( KErrArgument == ret  )
       
  1144         {
       
  1145         dialUpContext = iContextList->DialUpContextName( contextId, contextName );
       
  1146         }
       
  1147     // no else
       
  1148 
       
  1149     if ( ret == KErrNone )
       
  1150         {
       
  1151         TInt configurationType( iContextList->
       
  1152             GetContextConfigurationType( contextId ) );
       
  1153         TPacketDataConfigBase* configBase = iContextList->
       
  1154             GetConfig( contextId, configurationType );
       
  1155 
       
  1156         if( TPacketDataConfigBase::KConfigGPRS == configurationType )
       
  1157             {
       
  1158 
       
  1159             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivatingInd. KConfigGPRS");
       
  1160 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATINGIND, "CMmPacketContextMessHandler::GpdsContextActivatingInd, KConfigGPRS" );
       
  1161 
       
  1162             RPacketContext::TContextConfigGPRS* config =
       
  1163                 reinterpret_cast<RPacketContext::TContextConfigGPRS*>(
       
  1164                     configBase );
       
  1165 
       
  1166             sbStartOffSet = 0;
       
  1167             TPtrC8 apn;
       
  1168 
       
  1169             // Get pdp type
       
  1170             TUint8 pdpType( aIsiMessage.Get8bit(
       
  1171                 ISI_HEADER_SIZE + GPDS_CONTEXT_ACTIVATING_IND_OFFSET_PDPTYPE ) );
       
  1172 
       
  1173             CMmStaticUtility::MapPdpTypeToClient( config->iPdpType, pdpType );
       
  1174 
       
  1175             // Get APN info sub block
       
  1176             TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
  1177                 ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATING_IND,
       
  1178                 GPDS_APN_INFO,
       
  1179                 EIsiSubBlockTypeId8Len8,
       
  1180                 sbStartOffSet ) );
       
  1181 
       
  1182             if ( KErrNone == retValue )
       
  1183                 {
       
  1184                 TUint8 nameLen ( aIsiMessage.Get8bit( sbStartOffSet +
       
  1185                     GPDS_APN_INFO_OFFSET_ADDRLENGTH ) );
       
  1186 
       
  1187                 // Get APN info
       
  1188                 apn.Set( aIsiMessage.GetData( sbStartOffSet +
       
  1189                     GPDS_APN_INFO_OFFSET_APNNAME, nameLen ) );
       
  1190                 }
       
  1191             // no else
       
  1192 
       
  1193             if ( NULL != apn.Ptr() )
       
  1194                 {
       
  1195 
       
  1196                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivatingInd. apn is not null");
       
  1197 OstTrace0( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATINGIND, "CMmPacketContextMessHandler::GpdsContextActivatingInd, apn is not null" );
       
  1198 
       
  1199                 config->iAccessPointName.Copy( apn );
       
  1200                 }
       
  1201             else
       
  1202                 {
       
  1203                 config->iAccessPointName.Zero();
       
  1204                 }
       
  1205             // no else
       
  1206 
       
  1207             data.PackData( &contextName, &config );
       
  1208             iMessageRouter->Complete(
       
  1209                 EPacketContextActivate,
       
  1210                 &data,
       
  1211                 KErrNone );
       
  1212             }
       
  1213         else if( TPacketDataConfigBase::KConfigRel99Rel4 == configurationType )
       
  1214             {
       
  1215 
       
  1216             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivatingInd. KConfigRel99Rel4");
       
  1217 OstTrace0( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATINGIND, "CMmPacketContextMessHandler::GpdsContextActivatingInd, KConfigRel99Rel4" );
       
  1218 
       
  1219             RPacketContext::TContextConfigR99_R4* config =
       
  1220                 reinterpret_cast<RPacketContext::TContextConfigR99_R4*>(
       
  1221                     configBase );
       
  1222 
       
  1223             sbStartOffSet = 0;
       
  1224             TPtrC8 apn;
       
  1225 
       
  1226             // Get pdp type
       
  1227             TUint8 pdpType( aIsiMessage.Get8bit(
       
  1228                 ISI_HEADER_SIZE + GPDS_CONTEXT_ACTIVATING_IND_OFFSET_PDPTYPE ) );
       
  1229 
       
  1230             CMmStaticUtility::MapPdpTypeToClient( config->iPdpType, pdpType );
       
  1231 
       
  1232             // Get APN info sub block
       
  1233             TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
  1234                 ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATING_IND,
       
  1235                 GPDS_APN_INFO,
       
  1236                 EIsiSubBlockTypeId8Len8,
       
  1237                 sbStartOffSet ) );
       
  1238 
       
  1239             if ( KErrNone == retValue )
       
  1240                 {
       
  1241                 TUint8 nameLen ( aIsiMessage.Get8bit( sbStartOffSet +
       
  1242                     GPDS_APN_INFO_OFFSET_ADDRLENGTH ) );
       
  1243 
       
  1244                 // Get APN info
       
  1245                 apn.Set( aIsiMessage.GetData( sbStartOffSet +
       
  1246                     GPDS_APN_INFO_OFFSET_APNNAME, nameLen ) );
       
  1247                 }
       
  1248             // no else
       
  1249 
       
  1250             if ( NULL != apn.Ptr() )
       
  1251                 {
       
  1252 
       
  1253                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivatingInd. accesspointname is not null");
       
  1254 OstTrace0( TRACE_NORMAL, DUP5_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATINGIND, "CMmPacketContextMessHandler::GpdsContextActivatingInd, accesspointname is not null" );
       
  1255 
       
  1256                 config->iAccessPointName.Copy( apn );
       
  1257                 }
       
  1258             else if ( NULL == apn.Ptr() )
       
  1259                 {
       
  1260                 config->iAccessPointName.Zero();
       
  1261                 }
       
  1262             // no else
       
  1263 
       
  1264             data.PackData( &contextName, &config );
       
  1265             iMessageRouter->Complete(
       
  1266                 EPacketContextActivate,
       
  1267                 &data,
       
  1268                 KErrNone );
       
  1269             }
       
  1270         // no else
       
  1271         }
       
  1272     else if( KErrNone == dialUpContext
       
  1273         && contextId == iContextList->GetDialUpContextId() )
       
  1274         {
       
  1275         RPacketContext::TContextConfigR99_R4 config;
       
  1276         sbStartOffSet = 0;
       
  1277         TPtrC8 apn;
       
  1278 
       
  1279         // Get pdp type
       
  1280         TUint8 pdpType( aIsiMessage.Get8bit(
       
  1281             ISI_HEADER_SIZE + GPDS_CONTEXT_ACTIVATING_IND_OFFSET_PDPTYPE ) );
       
  1282 
       
  1283         CMmStaticUtility::MapPdpTypeToClient( config.iPdpType, pdpType );
       
  1284 
       
  1285         // Get APN info sub block
       
  1286         TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
  1287             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATING_IND,
       
  1288             GPDS_APN_INFO,
       
  1289             EIsiSubBlockTypeId8Len8,
       
  1290             sbStartOffSet ) );
       
  1291 
       
  1292         if ( KErrNone == retValue )
       
  1293             {
       
  1294             TUint8 nameLen ( aIsiMessage.Get8bit( sbStartOffSet +
       
  1295                 GPDS_APN_INFO_OFFSET_ADDRLENGTH ) );
       
  1296 
       
  1297             // Get APN info
       
  1298             apn.Set( aIsiMessage.GetData( sbStartOffSet +
       
  1299                 GPDS_APN_INFO_OFFSET_APNNAME, nameLen ) );
       
  1300             }
       
  1301         // no else
       
  1302 
       
  1303         if ( NULL != apn.Ptr() )
       
  1304             {
       
  1305             config.iAccessPointName.Copy( apn );
       
  1306             }
       
  1307          else if ( NULL == apn.Ptr() )
       
  1308             {
       
  1309             config.iAccessPointName.Zero();
       
  1310             }
       
  1311         // no else
       
  1312 
       
  1313         RPacketContext::TContextConfigR99_R4* config1 = &config;
       
  1314         data.PackData( &contextName, &config1 );
       
  1315         iMessageRouter->Complete(
       
  1316             EPacketContextActivate,
       
  1317             &data,
       
  1318             KErrNone );
       
  1319         }
       
  1320     // no else
       
  1321     }
       
  1322 
       
  1323 // -----------------------------------------------------------------------------
       
  1324 // CMmPacketContextMessHandler::GpdsContextActivateIndL
       
  1325 // Breaks gpds context activate indication message.
       
  1326 // Indicate that context activation has succeeded.
       
  1327 // -----------------------------------------------------------------------------
       
  1328 //
       
  1329 void CMmPacketContextMessHandler::GpdsContextActivateIndL(
       
  1330     const TIsiReceiveC& aIsiMessage )
       
  1331     {
       
  1332 
       
  1333     // Buffer for DNS data
       
  1334     TBuf8<RPacketContext::KMiscProtocolBufferLength - KRemoveOtherThanDNSBytes>
       
  1335         tempDNSBuffer;
       
  1336     // make sure that buffer is empty
       
  1337     tempDNSBuffer.Zero();
       
  1338 
       
  1339     TUint8 contextId( aIsiMessage.Get8bit(
       
  1340         ISI_HEADER_SIZE + GPDS_CONTEXT_ACTIVATE_IND_OFFSET_CID ) );
       
  1341 
       
  1342     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. ContextId: %d", contextId);
       
  1343 OstTraceExt1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;contextId=%hhu", contextId );
       
  1344 
       
  1345     TUint sbStartOffSet( 0 );
       
  1346 
       
  1347     TInfoName contextName;
       
  1348     TInt ret( iContextList->
       
  1349         GetContextNameByContextId( contextId, contextName ) );
       
  1350 
       
  1351     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. GetContextNameByContextId returns:%d", ret );
       
  1352 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;ret=%d", ret );
       
  1353 
       
  1354     if( KErrArgument == ret )
       
  1355         {
       
  1356         ret = iContextList->DialUpContextName( contextId, contextName );
       
  1357         }
       
  1358     // no else
       
  1359 
       
  1360     if( KErrNone == ret )
       
  1361         {
       
  1362         RPacketContext::TContextConfigGPRS config;
       
  1363 
       
  1364         TPtrC8 pdpAddress;
       
  1365         TPtrC8 apn;
       
  1366         TPtrC8 pDnsAddress;
       
  1367         TPtrC8 sDnsAddress;
       
  1368         TUint8 dataCompression( GPDS_PDP_DCOMP_DEFAULT );
       
  1369         TUint8 headerCompression( GPDS_PDP_DCOMP_DEFAULT );
       
  1370         TUint8 connectionSpeed( 0 );
       
  1371         TInt connectionSpeedClient( 0 );
       
  1372         TPtrC8 pcScfAddress;
       
  1373 
       
  1374         // Gpds sub blocks
       
  1375         sbStartOffSet = 0;
       
  1376 
       
  1377         TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
  1378             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_IND,
       
  1379             GPDS_PDP_ADDRESS_INFO,
       
  1380             EIsiSubBlockTypeId8Len8,
       
  1381             sbStartOffSet ) );
       
  1382 
       
  1383         if ( KErrNone == retValue )
       
  1384             {
       
  1385             TUint8 addrLen ( aIsiMessage.Get8bit(
       
  1386                 sbStartOffSet + GPDS_PDP_ADDRESS_INFO_OFFSET_ADDRLENGTH ) );
       
  1387 
       
  1388             // Get PDP address
       
  1389             pdpAddress.Set( aIsiMessage.GetData(
       
  1390                 sbStartOffSet + GPDS_PDP_ADDRESS_INFO_OFFSET_ADDRESS,
       
  1391                 addrLen ) );
       
  1392             }
       
  1393             // no else
       
  1394 
       
  1395         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. pdpAddress length:%d", pdpAddress.Length() );
       
  1396 OstTrace1( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL; pdpAddress length=%d", pdpAddress.Length() );
       
  1397 
       
  1398         // Get PDP address
       
  1399         if ( 0 < pdpAddress.Length() )
       
  1400             {
       
  1401             CMmStaticUtility::ConvertIPAddressToClient(
       
  1402                 pdpAddress,
       
  1403                 config.iPdpAddress );
       
  1404             }
       
  1405         // no else
       
  1406 
       
  1407         retValue =  aIsiMessage.FindSubBlockOffsetById(
       
  1408             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_IND,
       
  1409             GPDS_APN_INFO,
       
  1410             EIsiSubBlockTypeId8Len8,
       
  1411             sbStartOffSet );
       
  1412 
       
  1413         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. find sub block. retValue:%d", retValue );
       
  1414 OstTrace1( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;retValue=%d", retValue );
       
  1415 
       
  1416         if ( KErrNone == retValue )
       
  1417             {
       
  1418             TUint8 nameLen ( aIsiMessage.Get8bit(
       
  1419                 sbStartOffSet + GPDS_APN_INFO_OFFSET_ADDRLENGTH ) );
       
  1420 
       
  1421             // Get APN info
       
  1422             apn.Set( aIsiMessage.GetData(
       
  1423                 sbStartOffSet + GPDS_APN_INFO_OFFSET_APNNAME, nameLen ) );
       
  1424             }
       
  1425         // no else
       
  1426 
       
  1427         // Get Access point name.
       
  1428         if ( NULL != apn.Ptr() )
       
  1429             {
       
  1430 
       
  1431             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. apn.Ptr is not null");
       
  1432 OstTrace0( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL, apn.Ptr is not null" );
       
  1433 
       
  1434             config.iAccessPointName.Copy( apn );
       
  1435             }
       
  1436         // no else
       
  1437 
       
  1438         retValue = aIsiMessage.FindSubBlockOffsetById(
       
  1439             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_IND,
       
  1440             GPDS_QOS_NEG_INFO,
       
  1441             EIsiSubBlockTypeId8Len8,
       
  1442             sbStartOffSet );
       
  1443 
       
  1444         if ( KErrNone == retValue )
       
  1445             {
       
  1446             // Get connection speed
       
  1447             connectionSpeed = aIsiMessage.Get8bit(
       
  1448                 sbStartOffSet + GPDS_QOS_NEG_INFO_OFFSET_PEAKTHROUGHPUT );
       
  1449             }
       
  1450         // no else
       
  1451 
       
  1452         MapConnectionSpeed( connectionSpeed, connectionSpeedClient );
       
  1453 
       
  1454         retValue = aIsiMessage.FindSubBlockOffsetById(
       
  1455             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_IND,
       
  1456             GPDS_PDNS_ADDRESS_INFO,
       
  1457             EIsiSubBlockTypeId8Len8,
       
  1458             sbStartOffSet );
       
  1459 
       
  1460         if ( KErrNone == retValue )
       
  1461             {
       
  1462             TUint8 addrLen ( aIsiMessage.Get8bit(
       
  1463                 sbStartOffSet + GPDS_PDNS_ADDRESS_INFO_OFFSET_ADDRLENGTH ) );
       
  1464 
       
  1465             // Get Primary DNS address
       
  1466             pDnsAddress.Set( aIsiMessage.GetData(
       
  1467                 sbStartOffSet + GPDS_PDNS_ADDRESS_INFO_OFFSET_ADDRESS,
       
  1468                 addrLen ) );
       
  1469             }
       
  1470         // no else
       
  1471 
       
  1472         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. primary DNS address length:%d", pDnsAddress.Length() );
       
  1473 OstTrace1( TRACE_NORMAL, DUP5_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;primary DNS address length=%d", pDnsAddress.Length() );
       
  1474 
       
  1475         // Get Primary DNS address.
       
  1476         if ( 0 < pDnsAddress.Length() )
       
  1477             {
       
  1478             CMmStaticUtility::ConvertIPAddressToClient(
       
  1479                 pDnsAddress,
       
  1480                 config.iProtocolConfigOption.iDnsAddresses.iPrimaryDns );
       
  1481             }
       
  1482         // no else
       
  1483 
       
  1484         retValue = aIsiMessage.FindSubBlockOffsetById(
       
  1485             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_IND,
       
  1486             GPDS_SDNS_ADDRESS_INFO,
       
  1487             EIsiSubBlockTypeId8Len8,
       
  1488             sbStartOffSet );
       
  1489 
       
  1490         if ( KErrNone == retValue )
       
  1491             {
       
  1492             TUint8 addrLen ( aIsiMessage.Get8bit(
       
  1493                 sbStartOffSet + GPDS_SDNS_ADDRESS_INFO_OFFSET_ADDRLENGTH ) );
       
  1494 
       
  1495             // Get Secondary DNS address
       
  1496             sDnsAddress.Set( aIsiMessage.GetData(
       
  1497                 sbStartOffSet + GPDS_SDNS_ADDRESS_INFO_OFFSET_ADDRESS,
       
  1498                 addrLen ) );
       
  1499             }
       
  1500         // no else
       
  1501 
       
  1502         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. secondary DNS address length:%d", sDnsAddress.Length());
       
  1503 OstTrace1( TRACE_NORMAL, DUP6_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;secondary DNS address length=%d", sDnsAddress.Length() );
       
  1504 
       
  1505         // Get Secondary DNS address.
       
  1506         if ( 0 < sDnsAddress.Length() )
       
  1507             {
       
  1508             CMmStaticUtility::ConvertIPAddressToClient(
       
  1509                 sDnsAddress,
       
  1510                 config.iProtocolConfigOption.iDnsAddresses.iSecondaryDns );
       
  1511             }
       
  1512         // no else
       
  1513 
       
  1514         retValue = aIsiMessage.FindSubBlockOffsetById(
       
  1515             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_IND,
       
  1516             GPDS_COMP_INFO,
       
  1517             EIsiSubBlockTypeId8Len8,
       
  1518             sbStartOffSet );
       
  1519 
       
  1520         if ( KErrNone == retValue )
       
  1521             {
       
  1522             dataCompression = aIsiMessage.Get8bit(
       
  1523                 sbStartOffSet + GPDS_COMP_INFO_OFFSET_DATACOMPRESSION );
       
  1524 
       
  1525             headerCompression = aIsiMessage.Get8bit(
       
  1526                 sbStartOffSet + GPDS_COMP_INFO_OFFSET_HEADERCOMPRESSION );
       
  1527             }
       
  1528         // no else
       
  1529 
       
  1530         if ( GPDS_PDP_DCOMP_DEFAULT != dataCompression )
       
  1531             {
       
  1532 
       
  1533             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. GPDS_PDP_DCOMP_DEFAULT != dataCompression");
       
  1534 OstTrace0( TRACE_NORMAL, DUP7_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL, GPDS_PDP_DCOMP_DEFAULT != dataCompression" );
       
  1535 
       
  1536             if ( GPDS_PDP_DCOMP_ON == dataCompression )
       
  1537                 {
       
  1538 
       
  1539                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. GPDS_PDP_DCOMP_ON == dataCompression");
       
  1540 OstTrace0( TRACE_NORMAL, DUP8_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL,  GPDS_PDP_DCOMP_ON == dataCompression" );
       
  1541 
       
  1542                 if ( !( config.iPdpCompression &
       
  1543                     RPacketContext::KPdpDataCompression ) )
       
  1544                     {
       
  1545                     config.iPdpCompression ^=
       
  1546                         RPacketContext::KPdpDataCompression;
       
  1547                     }
       
  1548                 // no else
       
  1549                 }
       
  1550             else
       
  1551                 {
       
  1552                 if ( ( config.iPdpCompression &
       
  1553                     RPacketContext::KPdpDataCompression ) )
       
  1554                     {
       
  1555                     config.iPdpCompression ^=
       
  1556                         RPacketContext::KPdpDataCompression;
       
  1557                     }
       
  1558                 // no else
       
  1559                 }
       
  1560             }
       
  1561         // no else
       
  1562 
       
  1563         if ( GPDS_PDP_DCOMP_DEFAULT != headerCompression )
       
  1564             {
       
  1565 
       
  1566             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. GPDS_PDP_DCOMP_DEFAULT != headerCompression");
       
  1567 OstTrace0( TRACE_NORMAL, DUP9_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateInd, GPDS_PDP_DCOMP_DEFAULT != headerCompressionL" );
       
  1568 
       
  1569             if ( GPDS_PDP_DCOMP_ON == headerCompression )
       
  1570                 {
       
  1571 
       
  1572                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. GPDS_PDP_DCOMP_ON == headerCompression");
       
  1573 OstTrace0( TRACE_NORMAL, DUP10_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL, GPDS_PDP_DCOMP_ON == headerCompression" );
       
  1574 
       
  1575                 if ( !( config.iPdpCompression &
       
  1576                     RPacketContext::KPdpHeaderCompression ) )
       
  1577                     {
       
  1578                     config.iPdpCompression ^=
       
  1579                         RPacketContext::KPdpHeaderCompression;
       
  1580                     }
       
  1581                 // no else
       
  1582             }
       
  1583             else
       
  1584                 {
       
  1585                 if ( ( config.iPdpCompression &
       
  1586                     RPacketContext::KPdpHeaderCompression ) )
       
  1587                     {
       
  1588                     config.iPdpCompression ^=
       
  1589                         RPacketContext::KPdpHeaderCompression;
       
  1590                     }
       
  1591                 // no else
       
  1592                 }
       
  1593             }
       
  1594         // no else
       
  1595 
       
  1596         // TLV  buffer  construction
       
  1597         TInt tlvLen( 0 );
       
  1598         RPacketContext::TPcoId pcoId( RPacketContext::EEtelPcktNotSupported );
       
  1599         TBuf8<KDNSBufferLength>pDnsBuffer;
       
  1600         pDnsBuffer.Zero();
       
  1601         TBuf8<KDNSBufferLength>sDnsBuffer;
       
  1602         sDnsBuffer.Zero();
       
  1603         TBuf8<KCSCFBufferLength>pCSCFBuffer;
       
  1604         pCSCFBuffer.Zero();
       
  1605         TBuf8<KSignallingFlagBuffer>signallingFlagBuffer;
       
  1606         signallingFlagBuffer.Zero();
       
  1607 
       
  1608         // If asked add to TLV struct
       
  1609         if ( iContextList->GetDNSAddressInfoToContextInfo( contextId ) )
       
  1610             {
       
  1611 
       
  1612             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. add to TLV struct");
       
  1613 OstTrace0( TRACE_NORMAL, DUP11_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL, add to TLV struct" );
       
  1614 
       
  1615             // Type is always ipv6
       
  1616             if ( KIpv6AddressLen == pDnsAddress.Length() )
       
  1617                 {
       
  1618                 for ( TInt i = 0; i < KIpv6AddressLen; i++ )
       
  1619                     {
       
  1620                     pDnsBuffer.Append( static_cast<TUint8>( pDnsAddress[i] ) );
       
  1621                     }
       
  1622                 pDnsBuffer.SetLength( KIpv6AddressLen );
       
  1623                 // 2+1+16
       
  1624                 tlvLen = tlvLen + KTLVDataLen + KPCOIdLen + KIpv6AddressLen;
       
  1625                 }
       
  1626             // no else
       
  1627             }
       
  1628         // no else
       
  1629 
       
  1630         // add secondary DNS
       
  1631         if ( iContextList->GetDNSAddressInfoToContextInfo( contextId ) )
       
  1632             {
       
  1633 
       
  1634             TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. add secondary DNS");
       
  1635 OstTrace0( TRACE_NORMAL, DUP12_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL, add secondary DNS" );
       
  1636 
       
  1637             // Type is allways ipv6
       
  1638             if ( KIpv6AddressLen == sDnsAddress.Length() )
       
  1639                 {
       
  1640                 for ( TInt i = 0; i < KIpv6AddressLen; i++ )
       
  1641                     {
       
  1642                     sDnsBuffer.Append( static_cast<TUint8>( sDnsAddress[i] ) );
       
  1643                     }
       
  1644                 sDnsBuffer.SetLength( KIpv6AddressLen );
       
  1645                 tlvLen = tlvLen + KTLVDataLen + KPCOIdLen + KIpv6AddressLen;
       
  1646                 }
       
  1647             // no else
       
  1648             }
       
  1649         // no else
       
  1650 
       
  1651         // get P-CSCF Address sub-block: P-CSCF IP address. This sub-block is
       
  1652         // ONLY present if P-CSCF address was requested in
       
  1653         // GPDS_CONTEXT_CONFIGURE_REQ.
       
  1654         // Although might still miss if network does not send it.
       
  1655         retValue = aIsiMessage.FindSubBlockOffsetById(
       
  1656             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_IND,
       
  1657             GPDS_SHARED_PCSCF_ADDRESS_INFO,
       
  1658             EIsiSubBlockTypeId8Len8,
       
  1659             sbStartOffSet );
       
  1660 
       
  1661         TFLOGSTRING2("TSY: GPDS_SHARED_PCSCF_ADDRESS_INFO sub-block, retValue %d.", retValue );
       
  1662 OstTrace1( TRACE_NORMAL, DUP13_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;GPDS_SHARED_PCSCF_ADDRESS_INFO sub-block retValue=%d", retValue );
       
  1663 
       
  1664         if( KErrNone == retValue )
       
  1665             {
       
  1666             TUint8 addrLen ( aIsiMessage.Get8bit(
       
  1667                 sbStartOffSet +
       
  1668                 GPDS_SHARED_PCSCF_ADDRESS_INFO_OFFSET_ADDRLENGTH ) );
       
  1669 
       
  1670             pcScfAddress.Set( aIsiMessage.GetData(
       
  1671                 ( sbStartOffSet +
       
  1672                 GPDS_SHARED_PCSCF_ADDRESS_INFO_OFFSET_PCSCFADDRESS ),
       
  1673                 addrLen ) );
       
  1674             }
       
  1675         // no else
       
  1676 
       
  1677         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. PCSCF address length:%d", pcScfAddress.Length() );
       
  1678 OstTrace1( TRACE_NORMAL, DUP14_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;PCSCF address length=%d", pcScfAddress.Length() );
       
  1679 
       
  1680         // PCSCF address types IPv6 and IPv4 are valid
       
  1681         // The length of IPv4 address is 4
       
  1682         if( KIpv4AddressLen == pcScfAddress.Length() )
       
  1683             {
       
  1684             // get data to temp buffer
       
  1685             for ( TInt index = 0; index < pcScfAddress.Length(); index++ )
       
  1686                 {
       
  1687                 TUint8 entry( static_cast<TUint8>( pcScfAddress[index] ));
       
  1688                 pCSCFBuffer.Append( entry );
       
  1689                 }
       
  1690             pCSCFBuffer.SetLength( KIpv4AddressLen );
       
  1691             // 2+1+4 (data length + PCO Id + data)
       
  1692             tlvLen = tlvLen + KTLVDataLen + KPCOIdLen + KIpv4AddressLen;
       
  1693             }
       
  1694         // The length of IPv6 address is 16
       
  1695         else if( KIpv6AddressLen == pcScfAddress.Length() )
       
  1696             {
       
  1697             //get data to temp buffer
       
  1698             for ( TInt index = 0; index < pcScfAddress.Length(); index++ )
       
  1699                 {
       
  1700                 TUint8 entry( static_cast<TUint8>( pcScfAddress[index] ));
       
  1701                 pCSCFBuffer.Append( entry );
       
  1702                 }
       
  1703             pCSCFBuffer.SetLength( KIpv6AddressLen );
       
  1704             // 2+1+16 (data length + PCO Id + data)
       
  1705             tlvLen = tlvLen + KTLVDataLen + KPCOIdLen + KIpv6AddressLen;
       
  1706             }
       
  1707         // no else
       
  1708 
       
  1709         retValue = aIsiMessage.FindSubBlockOffsetById(
       
  1710             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_IND,
       
  1711             GPDS_SHARED_IM_CN_SIGNALING_FLAG_INFO,
       
  1712             EIsiSubBlockTypeId8Len8,
       
  1713             sbStartOffSet );
       
  1714 
       
  1715         if ( KErrNone == retValue )
       
  1716             {
       
  1717             signallingFlagBuffer.Append( aIsiMessage.Get8bit(
       
  1718                 sbStartOffSet +
       
  1719                 GPDS_SHARED_IM_CN_SIGNALING_FLAG_INFO_OFFSET_IMCNSIGFLAG ) );
       
  1720             signallingFlagBuffer.SetLength( KSignallingFlagBuffer );
       
  1721             tlvLen += KIpv4AddressLen;
       
  1722             }
       
  1723         // no else
       
  1724 
       
  1725         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. tlv length:%d", tlvLen );
       
  1726 OstTrace1( TRACE_NORMAL, DUP15_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;tlvLen=%d", tlvLen );
       
  1727 
       
  1728         // Initialise buffer
       
  1729         if( 0 < tlvLen )
       
  1730             {
       
  1731             config.iProtocolConfigOption.iMiscBuffer.SetLength( tlvLen );
       
  1732             config.iProtocolConfigOption.iMiscBuffer.FillZ();
       
  1733 
       
  1734             // Create pointer to it
       
  1735             TPtr8 smallPtr( config.iProtocolConfigOption.iMiscBuffer.LeftTPtr(
       
  1736                 config.iProtocolConfigOption.iMiscBuffer.MaxLength() ) );
       
  1737             smallPtr.SetLength( 0 );
       
  1738 
       
  1739             // Create TLV struct
       
  1740             TTlvStruct<RPacketContext::TPcoId,
       
  1741                        RPacketContext::TPcoItemDataLength>
       
  1742                        smallTLV( smallPtr, 0 );
       
  1743 
       
  1744             // Append primary DNS
       
  1745             if ( KDNSBufferLength == pDnsBuffer.Length() )
       
  1746                 {
       
  1747                 TPtr8 pDnsBufferPtr(
       
  1748                     const_cast<TUint8*>( pDnsBuffer.Ptr() ),
       
  1749                     pDnsBuffer.Length(),
       
  1750                     pDnsBuffer.Length() );
       
  1751                 pcoId = RPacketContext::EEtelPcktDNSServerAddressRequest;
       
  1752                 ret = smallTLV.AppendItemL( pcoId, pDnsBufferPtr );
       
  1753 
       
  1754                 TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd.EEtelPcktDNSServerAddressRequest, Prim. DNS, AppendItemL ret=%d ",ret );
       
  1755 OstTrace1( TRACE_NORMAL, DUP16_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;Prim. DNS, AppendItemL ret=%d", ret );
       
  1756                 }
       
  1757             // no else
       
  1758 
       
  1759             // Append secondary DNS
       
  1760             if( KDNSBufferLength == sDnsBuffer.Length() )
       
  1761                 {
       
  1762                 TPtr8 sDnsBufferPtr(
       
  1763                     const_cast<TUint8*>( sDnsBuffer.Ptr() ),
       
  1764                     sDnsBuffer.Length(),
       
  1765                     sDnsBuffer.Length() );
       
  1766                 pcoId = RPacketContext::EEtelPcktDNSServerAddressRequest;
       
  1767                 ret = smallTLV.AppendItemL( pcoId, sDnsBufferPtr );
       
  1768 
       
  1769                 TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd.EEtelPcktDNSServerAddressRequest, Sec. DNS, AppendItemL ret=%d ",ret );
       
  1770 OstTrace1( TRACE_NORMAL, DUP17_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL; Sec. DNS, AppendItemL ret=%d", ret );
       
  1771                 }
       
  1772             // no else
       
  1773 
       
  1774             // Append PCSCFBuffer address
       
  1775             // (IPv6 (length 16) and IPv4 (length 4) address supported)
       
  1776             if( KIpv6AddressLen == pCSCFBuffer.Length() ||
       
  1777                 KIpv4AddressLen == pCSCFBuffer.Length() )
       
  1778                 {
       
  1779                 TPtr8 pCSCFBufferPtr(
       
  1780                     const_cast<TUint8*>( pCSCFBuffer.Ptr() ),
       
  1781                     pCSCFBuffer.Length(),
       
  1782                     pCSCFBuffer.Length() );
       
  1783                 pcoId = RPacketContext::EEtelPcktPCSCFAddressRequest;
       
  1784                 ret = smallTLV.AppendItemL( pcoId, pCSCFBufferPtr );
       
  1785 
       
  1786                 TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd.EEtelPcktPCSCFAddressRequest AppendItemL ret=%d ",ret );
       
  1787 OstTrace1( TRACE_NORMAL, DUP18_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;EEtelPcktPCSCFAddressRequest AppendItemL ret=%d", ret );
       
  1788                 }
       
  1789             // no else
       
  1790 
       
  1791             // Append IM CNMS sub system Signalling Flag
       
  1792             if( KSignallingFlagBuffer == signallingFlagBuffer.Length() )
       
  1793                 {
       
  1794                 TPtr8 signallingFlagBufferPtr(
       
  1795                     const_cast<TUint8*>( signallingFlagBuffer.Ptr() ),
       
  1796                     signallingFlagBuffer.Length(),
       
  1797                     signallingFlagBuffer.Length() );
       
  1798                 pcoId = RPacketContext::EEtelPcktIMCNMSSubsystemSignallingFlag;
       
  1799                 ret = smallTLV.AppendItemL( pcoId, signallingFlagBufferPtr );
       
  1800 
       
  1801                 TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd.EEtelPcktIMCNMSSubsystemSignallingFlag AppendItemL ret=%d ",ret );
       
  1802 OstTrace1( TRACE_NORMAL, DUP19_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL;EEtelPcktIMCNMSSubsystemSignallingFlag AppendItemL ret=%d", ret );
       
  1803                 }
       
  1804             // no else
       
  1805             }
       
  1806         // no else
       
  1807 
       
  1808         CMmDataPackage data;
       
  1809         data.PackData( &contextName, &config );
       
  1810         iMessageRouter->Complete(
       
  1811             EPacketContextNotifyConfigChanged,
       
  1812             &data,
       
  1813             KErrNone );
       
  1814         // CompleteNotifyConnectionSpeedChange
       
  1815         data.PackData( &contextName, &connectionSpeedClient );
       
  1816         iMessageRouter->Complete(
       
  1817             EPacketContextNotifyConnectionSpeedChange,
       
  1818             &data,
       
  1819             KErrNone );
       
  1820         }
       
  1821     // no else
       
  1822 
       
  1823     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateInd. End point.");
       
  1824 OstTrace0( TRACE_NORMAL, DUP20_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEINDL, "CMmPacketContextMessHandler::GpdsContextActivateIndL, End point" );
       
  1825     }
       
  1826 
       
  1827 // -----------------------------------------------------------------------------
       
  1828 // CMmPacketContextMessHandler::GpdsContextActivateFailIndL
       
  1829 // Breaks gpds context activate fail indication message.
       
  1830 // Indicate that context activation has failed.
       
  1831 // -----------------------------------------------------------------------------
       
  1832 //
       
  1833 void CMmPacketContextMessHandler::GpdsContextActivateFailInd(
       
  1834     const TIsiReceiveC& aIsiMessage )
       
  1835     {
       
  1836 
       
  1837     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextActivateFailInd.");
       
  1838 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTACTIVATEFAILIND, "CMmPacketContextMessHandler::GpdsContextActivateFailInd" );
       
  1839 
       
  1840     // initialise struct for completion
       
  1841     #if (NCP_COMMON_S60_VERSION_SUPPORT==S60_VERSION_32)
       
  1842     CMmCommonStaticUtility::TContextMisc misc;
       
  1843     #else
       
  1844     TContextMisc misc;
       
  1845     #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  1846 
       
  1847     misc.iStatus = RPacketContext::EStatusInactive;
       
  1848     misc.iRejectionCause.Zero();
       
  1849 
       
  1850     TUint8 contextId( aIsiMessage.Get8bit(
       
  1851         ISI_HEADER_SIZE + GPDS_CONTEXT_ACTIVATE_FAIL_IND_OFFSET_CID ) );
       
  1852 
       
  1853     TInfoName contextName;
       
  1854     TInt ret( iContextList->
       
  1855         GetContextNameByContextId( contextId, contextName ) );
       
  1856 
       
  1857     if ( KErrNone == ret )
       
  1858         {
       
  1859         TUint8 cause( aIsiMessage.Get8bit(  ISI_HEADER_SIZE +
       
  1860             GPDS_CONTEXT_ACTIVATE_FAIL_IND_OFFSET_CAUSE ) );
       
  1861 
       
  1862         TInt errorValue( KErrNone );
       
  1863         TUint8 rejectionCause( KErrNone );
       
  1864 
       
  1865         if ( GPDS_CAUSE_NO_CONNECTION == cause )
       
  1866             {
       
  1867             errorValue = CMmStaticUtility::EpocErrorCode(
       
  1868                 KErrCouldNotConnect, KErrGprsActivationRejected );
       
  1869             }
       
  1870         else if ( GPDS_CAUSE_AUTHENTICATION == cause )
       
  1871             {
       
  1872             errorValue = CMmStaticUtility::PacketDataCSCauseToEpocError(
       
  1873                 cause );
       
  1874 
       
  1875             TUint sbStartOffSet( 0 );
       
  1876 
       
  1877             TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
  1878                 ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_ACTIVATE_FAIL_IND,
       
  1879                 GPDS_SHARED_POLICY_CONTROL_REJ_CODE_INFO,
       
  1880                 EIsiSubBlockTypeId8Len8,
       
  1881                 sbStartOffSet ) );
       
  1882 
       
  1883             if( KErrNone == retValue)
       
  1884                 {
       
  1885                 rejectionCause = aIsiMessage.Get8bit( sbStartOffSet +
       
  1886                   GPDS_SHARED_POLICY_CONTROL_REJ_CODE_INFO_OFFSET_REJECTIONCAUSE
       
  1887                   );
       
  1888 
       
  1889                 misc.iRejectionCause.Append( rejectionCause );
       
  1890                 }
       
  1891             // no else
       
  1892             }
       
  1893         else if ( GPDS_CAUSE_CALL_CONTROL == cause )
       
  1894             {
       
  1895             errorValue = CMmStaticUtility::EpocErrorCode(
       
  1896                 KErrGeneral,
       
  1897                 KErrMMEtelActivationBlockedByCallControlNoText );
       
  1898             }
       
  1899         else
       
  1900             {
       
  1901             // Map the error cause to Epoc error
       
  1902             errorValue = CMmStaticUtility::PacketDataCSCauseToEpocError(
       
  1903                 cause );
       
  1904             }
       
  1905 
       
  1906         // Pack data
       
  1907         CMmDataPackage data;
       
  1908         data.PackData( &contextName, &misc);
       
  1909         iMessageRouter->Complete(
       
  1910             EPacketContextNotifyStatusChange,
       
  1911             &data,
       
  1912             errorValue );
       
  1913 
       
  1914         data.PackData( &contextName );
       
  1915         iMessageRouter->Complete(
       
  1916             EPacketContextNotifyConfigChanged,
       
  1917             &data,
       
  1918             errorValue );
       
  1919         }
       
  1920     // no else
       
  1921     }
       
  1922 
       
  1923 // -----------------------------------------------------------------------------
       
  1924 // CMmPacketContextMessHandler::GpdsContextModifyInd
       
  1925 // Breaks gpds context modify indication message.
       
  1926 // Indicate the context modification.
       
  1927 // -----------------------------------------------------------------------------
       
  1928 //
       
  1929 void CMmPacketContextMessHandler::GpdsContextModifyInd(
       
  1930     const TIsiReceiveC& aIsiMessage )
       
  1931     {
       
  1932     TUint sbStartOffSet( 0 );
       
  1933 
       
  1934     // Get context id
       
  1935     TUint8 contextId( aIsiMessage.Get8bit(
       
  1936        ISI_HEADER_SIZE + GPDS_CONTEXT_MODIFY_IND_OFFSET_CID ) );
       
  1937     // Get context name by context id
       
  1938     TInfoName contextName;
       
  1939     TInt ret( iContextList->
       
  1940         GetContextNameByContextId( contextId, contextName ) );
       
  1941 
       
  1942     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextModifyInd. ContextId:%d", contextId);
       
  1943 OstTraceExt1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTMODIFYIND, "CMmPacketContextMessHandler::GpdsContextModifyInd;contextId=%hhu", contextId );
       
  1944 
       
  1945     if( KErrArgument == ret )
       
  1946         {
       
  1947         ret = iContextList->DialUpContextName( contextId, contextName );
       
  1948         }
       
  1949     // no else
       
  1950 
       
  1951     if ( KErrNone == ret )
       
  1952         {
       
  1953         // Gpds sub block
       
  1954         sbStartOffSet = 0;
       
  1955 
       
  1956         TUint8 connectionSpeed( 0 );
       
  1957 
       
  1958         TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
  1959             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_MODIFY_IND,
       
  1960             GPDS_QOS_NEG_INFO,
       
  1961             EIsiSubBlockTypeId8Len8,
       
  1962             sbStartOffSet ) );
       
  1963 
       
  1964         if ( KErrNone == retValue )
       
  1965             {
       
  1966             // Get connection speed
       
  1967             connectionSpeed = aIsiMessage.Get8bit( sbStartOffSet +
       
  1968                 GPDS_QOS_NEG_INFO_OFFSET_PEAKTHROUGHPUT );
       
  1969 
       
  1970             TInt connectionSpeedClient( 0 );
       
  1971             MapConnectionSpeed( connectionSpeed, connectionSpeedClient );
       
  1972 
       
  1973             CMmDataPackage data;
       
  1974             // CompleteNotifyConnectionSpeedChange
       
  1975             data.PackData( &contextName, &connectionSpeedClient );
       
  1976             iMessageRouter->Complete(
       
  1977                 EPacketContextNotifyConnectionSpeedChange,
       
  1978                 &data,
       
  1979                 KErrNone );
       
  1980             }
       
  1981         // no else
       
  1982         }
       
  1983     // no else
       
  1984     }
       
  1985 
       
  1986 // -----------------------------------------------------------------------------
       
  1987 // CMmPacketContextMessHandler::GpdsContextDeactivateReq
       
  1988 // Create an Isi-message for context deactivation.
       
  1989 // -----------------------------------------------------------------------------
       
  1990 //
       
  1991 TInt CMmPacketContextMessHandler::GpdsContextDeactivateReq(
       
  1992     const CMmDataPackage& aDataPackage )
       
  1993     {
       
  1994     TInfoName* contextName = NULL;
       
  1995     aDataPackage.UnPackData( &contextName );
       
  1996     TUint8 contextId( iContextList->GetContextIdByContextName( contextName ) );
       
  1997 
       
  1998     if( GPDS_CID_VOID == contextId )
       
  1999         {
       
  2000         contextId = iContextList->GetDialUpContextIdByName( contextName );
       
  2001         }
       
  2002     // no else
       
  2003 
       
  2004     TUint8 transactionId( GenerateTraId( contextId ) );
       
  2005 
       
  2006     TFLOGSTRING3("TSY: CMmPacketContextMessHandler::GpdsContextDeactivateReq. TransId: %d ContextId: %d", transactionId, contextId );
       
  2007 OstTraceExt2( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTDEACTIVATEREQ, "CMmPacketContextMessHandler::GpdsContextDeactivateReq;transactionId=%hhu;contextId=%hhu", transactionId, contextId );
       
  2008 
       
  2009     // Set the message data that consists of one parameter
       
  2010     TBuf8<KMessageDataBufSize1> messageData;
       
  2011     messageData.Append( contextId );
       
  2012 
       
  2013     // Send Isi message via Phonet
       
  2014     return iPhoNetSender->Send( PN_GPDS,
       
  2015         transactionId, GPDS_CONTEXT_DEACTIVATE_REQ, messageData );
       
  2016     }
       
  2017 
       
  2018 // -----------------------------------------------------------------------------
       
  2019 // CMmPacketContextMessHandler::GpdsContextDeactivateRespL
       
  2020 // This method breaks the response to the context deactivation request.
       
  2021 // -----------------------------------------------------------------------------
       
  2022 //
       
  2023 void CMmPacketContextMessHandler::GpdsContextDeactivateRespL(
       
  2024     const TIsiReceiveC& aIsiMessage )
       
  2025     {
       
  2026 
       
  2027     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextDeactivateRespL.");
       
  2028 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTDEACTIVATERESPL, "CMmPacketContextMessHandler::GpdsContextDeactivateRespL" );
       
  2029 
       
  2030     // Get transaction id
       
  2031     TUint8 transactionId( aIsiMessage.Get8bit(
       
  2032        ISI_HEADER_SIZE + GPDS_CONTEXT_DEACTIVATE_RESP_OFFSET_UTID ) );
       
  2033     TUint8 status( aIsiMessage.Get8bit(
       
  2034        ISI_HEADER_SIZE + GPDS_CONTEXT_DEACTIVATE_RESP_OFFSET_STATUS ) );
       
  2035     TUint8 contextId( aIsiMessage.Get8bit(
       
  2036        ISI_HEADER_SIZE + GPDS_CONTEXT_DEACTIVATE_RESP_OFFSET_CID ) );
       
  2037     TInt result( KErrGeneral );
       
  2038     TInfoName contextName;
       
  2039 
       
  2040     if ( transactionId == GenerateTraId( contextId ) )
       
  2041         {
       
  2042         if ( GPDS_OK == status )
       
  2043             {
       
  2044             result = KErrNone;
       
  2045             if ( PN_PIPE_DISABLE != iContextList->GetPipeStatus( contextId ) &&
       
  2046                 KErrNotFound == iContextList->
       
  2047                     DialUpContextName( contextId, contextName ) )
       
  2048                 {
       
  2049                 TUint8 pipeHandle( iContextList->
       
  2050                     PipeHandleByContextId( contextId ) );
       
  2051 
       
  2052                 // Reset the pipe
       
  2053                 TInt ret( iMmPipeController->PnsPipeResetReq(
       
  2054                     transactionId, pipeHandle, PN_PIPE_DISABLE ) );
       
  2055 
       
  2056                 if ( KErrNone == ret )
       
  2057                     {
       
  2058                     // Store the trans id
       
  2059                     ret = iContextList->
       
  2060                         SetPipeResetTraId( contextId, transactionId );
       
  2061 
       
  2062                     if( KErrNone != ret )
       
  2063                         {
       
  2064 
       
  2065                         TFLOGSTRING( "TSY: CMmPacketContextMessHandler::GpdsContextDeactivateRespL. SetPipeResetTraId failed " );
       
  2066 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTDEACTIVATERESPL, "CMmPacketContextMessHandler::GpdsContextDeactivateRespL, SetPipeResetTraId failed" );
       
  2067                         }
       
  2068                     // no else
       
  2069                     }
       
  2070                 // no else
       
  2071                 }
       
  2072             // no else
       
  2073             }
       
  2074         // no else
       
  2075 
       
  2076         TInt found( iContextList->
       
  2077             GetContextNameByContextId( contextId, contextName ) );
       
  2078 
       
  2079         if( KErrArgument == found )
       
  2080             {
       
  2081             found = iContextList->DialUpContextName( contextId, contextName );
       
  2082             }
       
  2083         // no else
       
  2084 
       
  2085         if( found == KErrNone &&
       
  2086             CALL_MODEM_ID_NONE == iCallModemResourceCallId )
       
  2087             {
       
  2088             // don't complete if allow incoming call feature is initiated
       
  2089             CMmDataPackage data;
       
  2090             data.PackData( &contextName );
       
  2091             iMessageRouter->Complete(
       
  2092                 EPacketContextDeactivate,
       
  2093                 &data,
       
  2094                 result );
       
  2095             }
       
  2096         // no else
       
  2097 
       
  2098         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextDeactivateRespL. Error(0=OK): %d ", found );
       
  2099 OstTrace1( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTDEACTIVATERESPL, "CMmPacketContextMessHandler::GpdsContextDeactivateRespL;Error(0=OK)=%d", found );
       
  2100 
       
  2101         // check if incoming call allowation is requested
       
  2102         // (for allow incoming call feature)
       
  2103         if ( GPDS_OK == status &&
       
  2104             CALL_MODEM_ID_NONE != iCallModemResourceCallId )
       
  2105             {
       
  2106             if ( iDeactivateContextList &&
       
  2107                 0 < iDeactivateContextList->Count() )
       
  2108                 {
       
  2109                 // remove deactivated context from the list
       
  2110                 iDeactivateContextList->Delete( 0 );
       
  2111                 }
       
  2112             //no else
       
  2113             AllowIncomingCallActivationL();
       
  2114             }
       
  2115 
       
  2116         else if ( CALL_MODEM_ID_NONE != iCallModemResourceCallId )
       
  2117             {
       
  2118             // deactivation failed, can't allow call activation
       
  2119             iCallModemResourceCallId = CALL_MODEM_ID_NONE;
       
  2120 
       
  2121             if ( iDeactivateContextList )
       
  2122                 {
       
  2123                 iDeactivateContextList->Reset();
       
  2124                 delete iDeactivateContextList;
       
  2125                 }
       
  2126             //no else
       
  2127             iDeactivateContextList = NULL;
       
  2128             }
       
  2129         //no else
       
  2130         }
       
  2131     // no else
       
  2132     }
       
  2133 
       
  2134 // -----------------------------------------------------------------------------
       
  2135 // CMmPacketContextMessHandler::GpdsContextDeactivatingInd
       
  2136 // Breaks gpds context deactivating indication message.
       
  2137 // Indicate that context deactivation has been started.
       
  2138 // -----------------------------------------------------------------------------
       
  2139 //
       
  2140 void CMmPacketContextMessHandler::GpdsContextDeactivatingInd(
       
  2141     const TIsiReceiveC& aIsiMessage )
       
  2142     {
       
  2143 
       
  2144     TUint8 contextId( aIsiMessage.Get8bit(
       
  2145         ISI_HEADER_SIZE + GPDS_CONTEXT_DEACTIVATING_IND_OFFSET_CID ) );
       
  2146 
       
  2147     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextDeactivatingInd. Context id: %d", contextId );
       
  2148 OstTraceExt1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTDEACTIVATINGIND, "CMmPacketContextMessHandler::GpdsContextDeactivatingInd;contextId=%hhu", contextId );
       
  2149 
       
  2150     TInfoName contextName;
       
  2151     TInt ret( iContextList->
       
  2152         GetContextNameByContextId( contextId, contextName ) );
       
  2153 
       
  2154     if( KErrArgument == ret )
       
  2155         {
       
  2156         ret = iContextList->DialUpContextName( contextId, contextName );
       
  2157         }
       
  2158     // no else
       
  2159 
       
  2160     if ( KErrNone == ret )
       
  2161         {
       
  2162         // initialise struct for completion
       
  2163         #if (NCP_COMMON_S60_VERSION_SUPPORT==S60_VERSION_32)
       
  2164         CMmCommonStaticUtility::TContextMisc misc;
       
  2165         #else
       
  2166         TContextMisc misc;
       
  2167         #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  2168 
       
  2169         misc.iStatus = RPacketContext::EStatusDeactivating;
       
  2170         misc.iRejectionCause.Zero();
       
  2171 
       
  2172         CMmDataPackage data;
       
  2173         data.PackData( &contextName, &misc );
       
  2174 
       
  2175         iMessageRouter->Complete(
       
  2176             EPacketContextNotifyStatusChange,
       
  2177             &data,
       
  2178             KErrNone );
       
  2179         }
       
  2180     // no else
       
  2181 
       
  2182     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextDeactivatingInd. Error(0=OK): %d ", ret );
       
  2183 
       
  2184 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTDEACTIVATINGIND, "CMmPacketContextMessHandler::GpdsContextDeactivatingInd;Error(0=OK)=%d", ret );
       
  2185     }
       
  2186 
       
  2187 // -----------------------------------------------------------------------------
       
  2188 // CMmPacketContextMessHandler::GpdsContextDeactivateInd
       
  2189 // Breaks gpds context deactivate indication message.
       
  2190 // Indicate that context deactivation has been succeeded.
       
  2191 // -----------------------------------------------------------------------------
       
  2192 //
       
  2193 void CMmPacketContextMessHandler::GpdsContextDeactivateInd(
       
  2194    const TIsiReceiveC& aIsiMessage )
       
  2195     {
       
  2196 
       
  2197     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextDeactivateInd.");
       
  2198 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTDEACTIVATEIND, "CMmPacketContextMessHandler::GpdsContextDeactivateInd" );
       
  2199 
       
  2200     TUint8 contextId( aIsiMessage.Get8bit(
       
  2201         ISI_HEADER_SIZE + GPDS_CONTEXT_DEACTIVATE_IND_OFFSET_CID ) );
       
  2202 
       
  2203     TInfoName contextName;
       
  2204     TInt ret( iContextList->
       
  2205         GetContextNameByContextId( contextId, contextName ) );
       
  2206 
       
  2207     if( KErrArgument == ret )
       
  2208         {
       
  2209         ret = iContextList->DialUpContextName( contextId, contextName );
       
  2210         }
       
  2211     // no else
       
  2212 
       
  2213     if ( KErrNone == ret )
       
  2214         {
       
  2215         TUint8 cause( aIsiMessage.Get8bit(
       
  2216            ISI_HEADER_SIZE + GPDS_CONTEXT_DEACTIVATE_IND_OFFSET_CAUSE ) );
       
  2217 
       
  2218         TInt result( KErrNone );
       
  2219 
       
  2220         if ( GPDS_CAUSE_DEACT_REGULAR != cause )
       
  2221             {
       
  2222             result = CMmStaticUtility::PacketDataCSCauseToEpocError( cause );
       
  2223             }
       
  2224         // no else
       
  2225 
       
  2226         //initialise struct for completion
       
  2227         #if (NCP_COMMON_S60_VERSION_SUPPORT==S60_VERSION_32)
       
  2228         CMmCommonStaticUtility::TContextMisc misc;
       
  2229         #else
       
  2230         TContextMisc misc;
       
  2231         #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  2232 
       
  2233         misc.iStatus = RPacketContext::EStatusInactive;
       
  2234         misc.iRejectionCause.Zero();
       
  2235 
       
  2236         CMmDataPackage data;
       
  2237         data.PackData( &contextName, &misc );
       
  2238         iMessageRouter->Complete(
       
  2239             EPacketContextNotifyStatusChange,
       
  2240             &data,
       
  2241             result );
       
  2242         }
       
  2243     // no else
       
  2244     }
       
  2245 
       
  2246 // -----------------------------------------------------------------------------
       
  2247 // CMmPacketContextMessHandler::GpdsContextStatusReq
       
  2248 // Create an Isi-message for context status info request.
       
  2249 // -----------------------------------------------------------------------------
       
  2250 //
       
  2251 TInt CMmPacketContextMessHandler::GpdsContextStatusReq(
       
  2252     const CMmDataPackage& aDataPackage )
       
  2253     {
       
  2254     TInfoName* contextName=NULL;
       
  2255     aDataPackage.UnPackData( &contextName );
       
  2256 
       
  2257     TUint8 contextId( iContextList->
       
  2258         GetContextIdByContextName( contextName ) );
       
  2259 
       
  2260     if( GPDS_CID_VOID == contextId )
       
  2261         {
       
  2262         contextId = iContextList->
       
  2263             GetDialUpContextIdByName( contextName );
       
  2264         }
       
  2265     // no else
       
  2266 
       
  2267     TInt ret( KErrNotReady );
       
  2268     TUint8 transactionId( GenerateTraId( contextId ) );
       
  2269 
       
  2270     TFLOGSTRING3("TSY: CMmPacketContextMessHandler::GpdsContextStatusReq. TransId: %d ContextId: %d", transactionId, contextId );
       
  2271 OstTraceExt2( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTSTATUSREQ, "CMmPacketContextMessHandler::GpdsContextStatusReq;transactionId=%hhu;contextId=%hhu", transactionId, contextId );
       
  2272 
       
  2273     if(  GPDS_CID_VOID != contextId  )
       
  2274         {
       
  2275         // Set the message data that consists of one parameter
       
  2276         TBuf8<KMessageDataBufSize1> messageData;
       
  2277         messageData.Append( contextId );
       
  2278 
       
  2279         // Send Isi message via Phonet
       
  2280         ret = iPhoNetSender->Send( PN_GPDS,
       
  2281             transactionId, GPDS_CONTEXT_STATUS_REQ, messageData );
       
  2282         }
       
  2283     // no else
       
  2284 
       
  2285     return ret;
       
  2286     }
       
  2287 
       
  2288 // -----------------------------------------------------------------------------
       
  2289 // CMmPacketContextMessHandler::GpdsContextStatusResp
       
  2290 // This method breaks the response to the context status request.
       
  2291 // -----------------------------------------------------------------------------
       
  2292 //
       
  2293 void CMmPacketContextMessHandler::GpdsContextStatusResp(
       
  2294     const TIsiReceiveC& aIsiMessage )
       
  2295     {
       
  2296 
       
  2297     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextStatusResp.");
       
  2298 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTSTATUSRESP, "CMmPacketContextMessHandler::GpdsContextStatusResp" );
       
  2299 
       
  2300     // Get context id
       
  2301     TUint8 contextId( aIsiMessage.Get8bit(
       
  2302        ISI_HEADER_SIZE + GPDS_CONTEXT_STATUS_RESP_OFFSET_CID ) );
       
  2303     TInfoName contextName;
       
  2304     TInt ret( iContextList->
       
  2305         GetContextNameByContextId( contextId, contextName ) );
       
  2306 
       
  2307     if( KErrArgument == ret )
       
  2308         {
       
  2309         ret =  iContextList->DialUpContextName( contextId, contextName );
       
  2310         }
       
  2311     // no else
       
  2312 
       
  2313     if ( KErrNone == ret )
       
  2314         {
       
  2315         RPacketContext::TDataVolume dataVolume;
       
  2316 
       
  2317         TUint8 status( aIsiMessage.Get8bit(
       
  2318            ISI_HEADER_SIZE + GPDS_CONTEXT_STATUS_RESP_OFFSET_STATUS ) );
       
  2319         TInt result( KErrGeneral );
       
  2320 
       
  2321         if ( GPDS_OK == status )
       
  2322             {
       
  2323             // Get the amount of Tx data
       
  2324             dataVolume.iBytesSent = aIsiMessage.Get32bit(
       
  2325                 ISI_HEADER_SIZE + GPDS_CONTEXT_STATUS_RESP_OFFSET_TXBYTECOUNT );
       
  2326 
       
  2327             // Get the amount of Rx data
       
  2328             dataVolume.iBytesReceived = aIsiMessage.Get32bit(
       
  2329                 ISI_HEADER_SIZE + GPDS_CONTEXT_STATUS_RESP_OFFSET_RXBYTECOUNT );
       
  2330 
       
  2331             result = KErrNone;
       
  2332             }
       
  2333         // no else
       
  2334 
       
  2335         CMmDataPackage data;
       
  2336         data.PackData( &contextName, &dataVolume );
       
  2337 
       
  2338         iMessageRouter->Complete(
       
  2339             EPacketContextGetDataVolumeTransferred,
       
  2340             &data,
       
  2341             result);
       
  2342         }
       
  2343     // no else
       
  2344     }
       
  2345 
       
  2346 // -----------------------------------------------------------------------------
       
  2347 // CMmPacketContextMessHandler::GpdsContextStatusInd
       
  2348 // Breaks gpds context status indication message.
       
  2349 // This indication includes the final amount of data transferred over airlink.
       
  2350 // -----------------------------------------------------------------------------
       
  2351 //
       
  2352 void CMmPacketContextMessHandler::GpdsContextStatusInd(
       
  2353     const TIsiReceiveC& aIsiMessage )
       
  2354     {
       
  2355 
       
  2356     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextStatusInd.");
       
  2357 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTSTATUSIND, "CMmPacketContextMessHandler::GpdsContextStatusInd" );
       
  2358 
       
  2359     // Get context id
       
  2360     TUint8 contextId( aIsiMessage.Get8bit(
       
  2361        ISI_HEADER_SIZE + GPDS_CONTEXT_STATUS_IND_OFFSET_CID  ) );
       
  2362     TInfoName contextName;
       
  2363     TInt ret( iContextList->
       
  2364         GetContextNameByContextId( contextId, contextName ) );
       
  2365 
       
  2366     // context not found, check dial-up context
       
  2367     if ( KErrArgument == ret  )
       
  2368         {
       
  2369         ret = iContextList->DialUpContextName( contextId, contextName );
       
  2370         }
       
  2371     // no else
       
  2372 
       
  2373     if ( KErrNone == ret )
       
  2374         {
       
  2375         RPacketContext::TDataVolume dataVolume;
       
  2376 
       
  2377         // Get the amount of Tx data
       
  2378         dataVolume.iBytesSent = aIsiMessage.Get32bit(
       
  2379             ISI_HEADER_SIZE + GPDS_CONTEXT_STATUS_IND_OFFSET_TXBYTECOUNT );
       
  2380 
       
  2381         // Get the amount of Rx data
       
  2382         dataVolume.iBytesReceived = aIsiMessage.Get32bit(
       
  2383             ISI_HEADER_SIZE + GPDS_CONTEXT_STATUS_IND_OFFSET_RXBYTECOUNT );
       
  2384 
       
  2385         CMmDataPackage data;
       
  2386         data.PackData( &contextName, &dataVolume );
       
  2387 
       
  2388         iMessageRouter->Complete(
       
  2389             EPacketContextNotifyDataTransferred,
       
  2390             &data,
       
  2391             KErrNone );
       
  2392         }
       
  2393     // no else
       
  2394     }
       
  2395 
       
  2396 // -----------------------------------------------------------------------------
       
  2397 // CMmPacketContextMessHandler::GpdsContextIdDeleteInd
       
  2398 // Breaks gpds context id delete indication message.
       
  2399 // Indicate that context id has been deleted.
       
  2400 // -----------------------------------------------------------------------------
       
  2401 //
       
  2402 void CMmPacketContextMessHandler::GpdsContextIdDeleteInd(
       
  2403     const TIsiReceiveC& aIsiMessage )
       
  2404     {
       
  2405 
       
  2406     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextIdDeleteInd.");
       
  2407 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTIDDELETEIND, "CMmPacketContextMessHandler::GpdsContextIdDeleteInd" );
       
  2408 
       
  2409     TUint8 contextId( aIsiMessage.Get8bit(
       
  2410        ISI_HEADER_SIZE + GPDS_CONTEXT_ID_DELETE_IND_OFFSET_CID  ) );
       
  2411     // Get transaction id
       
  2412     TUint8 transactionId( iContextList->
       
  2413         GetAndResetDeletionTraId( contextId ) );
       
  2414     TInfoName contextName;
       
  2415     TInt ret( iContextList->
       
  2416         GetContextNameByContextId( contextId, contextName ) );
       
  2417 
       
  2418     // context not found, check dial-up context
       
  2419     if ( KErrArgument == ret  )
       
  2420         {
       
  2421         ret = iContextList->DialUpContextName( contextId, contextName );
       
  2422         }
       
  2423     // no else
       
  2424 
       
  2425     if( KErrNone == ret )
       
  2426         {
       
  2427 
       
  2428         TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextIdDeleteInd. Context name found.");
       
  2429 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTIDDELETEIND, "CMmPacketContextMessHandler::GpdsContextIdDeleteInd, Context name found" );
       
  2430 
       
  2431         // initialise struct for completion
       
  2432         #if (NCP_COMMON_S60_VERSION_SUPPORT==S60_VERSION_32)
       
  2433         CMmCommonStaticUtility::TContextMisc misc;
       
  2434         #else
       
  2435         TContextMisc misc;
       
  2436         #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  2437 
       
  2438         misc.iStatus = RPacketContext::EStatusDeleted;
       
  2439         misc.iRejectionCause.Zero();
       
  2440 
       
  2441         CMmDataPackage data;
       
  2442         data.PackData( &contextName, &misc );
       
  2443 
       
  2444         iMessageRouter->Complete(
       
  2445             EPacketContextNotifyStatusChange,
       
  2446             &data,
       
  2447             KErrNone );
       
  2448 
       
  2449         TUint8 proxyId = GenerateTraId( contextId );
       
  2450 
       
  2451         // check that delete is requested for this context
       
  2452         if ( transactionId == proxyId )
       
  2453             {
       
  2454             RPacketContext::TContextStatus status(
       
  2455                 RPacketContext::EStatusDeleted );
       
  2456             data.PackData( &contextName, &status );
       
  2457             iMessageRouter->Complete(
       
  2458                 EPacketContextDelete,
       
  2459                 &data,
       
  2460                 KErrNone );
       
  2461             }
       
  2462         // no else
       
  2463         }
       
  2464     // no else
       
  2465 
       
  2466     // Reset context id and Host context id from contextmessagehandler list.
       
  2467     iContextList->RemoveContextId( contextId );
       
  2468     }
       
  2469 
       
  2470 // -----------------------------------------------------------------------------
       
  2471 // CMmPacketContextMessHandler::GpdsContextModifyReq
       
  2472 // Create an Isi-message for context modify request.
       
  2473 // Modifies parameters of an active PDP context.
       
  2474 // -----------------------------------------------------------------------------
       
  2475 //
       
  2476 TInt CMmPacketContextMessHandler::GpdsContextModifyReq(
       
  2477     const CMmDataPackage* aDataPackage )
       
  2478     {
       
  2479     TInfoName contextName;
       
  2480     TContextConfiguration configuration;
       
  2481     CArrayFixFlat<RPacketContext::CTFTMediaAuthorizationV3>*
       
  2482         mediaAuthorizationArray;
       
  2483 
       
  2484     aDataPackage->UnPackData( configuration, mediaAuthorizationArray );
       
  2485 
       
  2486     contextName = configuration.iContextName;
       
  2487 
       
  2488     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextModifyReq. Context:%s", &contextName );
       
  2489 OstTraceExt1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTMODIFYREQ, "CMmPacketContextMessHandler::GpdsContextModifyReq;contextName=%S", contextName );
       
  2490 
       
  2491     TUint8 contextId(iContextList->GetContextIdByContextName( &contextName ));
       
  2492 
       
  2493     // Initializing ret value to KErrNone
       
  2494     TInt ret( KErrNone );
       
  2495 
       
  2496     if( GPDS_CID_VOID != contextId )
       
  2497         {
       
  2498         TUint8 modifyTraId( GenerateTraId( contextId ) );
       
  2499 
       
  2500         TFLOGSTRING3("TSY: CMmPacketContextMessHandler::GpdsContextModifyReq. TransId: %d ContextId: %d", modifyTraId, contextId );
       
  2501 OstTraceExt2( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTMODIFYREQ, "CMmPacketContextMessHandler::GpdsContextModifyReq;modifyTraId=%hhu;contextId=%hhu", modifyTraId, contextId );
       
  2502 
       
  2503         TUint8 tftOperation( 0 );
       
  2504 
       
  2505         MapTftOperation( configuration.iTftOperation, tftOperation );
       
  2506 
       
  2507         TUint8 pdpType( 0 );
       
  2508 
       
  2509         MapPdpType( pdpType, configuration.iConfiguration );
       
  2510 
       
  2511         // Temporary container to context packet filter(s)
       
  2512         CArrayFixFlat<RPacketContext::TPacketFilterV2>* aPacketFilterPtr =
       
  2513             configuration.iTftFilterArray;
       
  2514 
       
  2515         // Create isi message
       
  2516         TIsiSend gpdsContextModifyReq( iPhoNetSender->SendBufferDes() );
       
  2517         gpdsContextModifyReq.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_GPDS );
       
  2518         // Set the Gpds Context Modify Req data
       
  2519         gpdsContextModifyReq.Set8bit(
       
  2520             ISI_HEADER_OFFSET_TRANSID, modifyTraId );
       
  2521         gpdsContextModifyReq.Set8bit(
       
  2522             ISI_HEADER_OFFSET_MESSAGEID, GPDS_CONTEXT_MODIFY_REQ );
       
  2523         gpdsContextModifyReq.Set8bit(
       
  2524             ISI_HEADER_SIZE + GPDS_CONTEXT_MODIFY_REQ_OFFSET_CID,
       
  2525             contextId );
       
  2526 
       
  2527         // Initialize message offset and subblock count
       
  2528         TInt currentMsgOffset(
       
  2529             ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_MODIFY_REQ );
       
  2530         TUint8 numOfSbInMessage( 0 );
       
  2531 
       
  2532         // If Rel99 QoS parameters are included
       
  2533         if( NULL != configuration.iQosParams99 )
       
  2534             {
       
  2535             // Add GPDS_QOS99_REQ_INFO subblock
       
  2536             TBuf8<SIZE_GPDS_QOS99_REQ_INFO> qos99ReqInfo;
       
  2537             TIsiSubBlock reqInfo99SubBlock(
       
  2538                 qos99ReqInfo,
       
  2539                 GPDS_QOS99_REQ_INFO,
       
  2540                 EIsiSubBlockTypeId8Len8 );
       
  2541 
       
  2542             ret = FillGpdsQos99ReqInfo( *configuration.iQosParams99,
       
  2543                                         qos99ReqInfo );
       
  2544 
       
  2545             if ( KErrNone == ret )
       
  2546                 {
       
  2547                 gpdsContextModifyReq.CopyData(
       
  2548                     currentMsgOffset, reqInfo99SubBlock.CompleteSubBlock() );
       
  2549                 // Set new offset and increase subblock count
       
  2550                 currentMsgOffset =
       
  2551                     currentMsgOffset + SIZE_GPDS_QOS99_REQ_INFO;
       
  2552                 numOfSbInMessage++;
       
  2553                 }
       
  2554             }
       
  2555         // no else
       
  2556 
       
  2557         // If Rel97/98 QoS parameters are included
       
  2558         if( NULL != configuration.iQosParams97 )
       
  2559             {
       
  2560             // Add GPDS_QOS_REQ_INFO subblock
       
  2561             TBuf8<SIZE_GPDS_QOS_REQ_INFO> qos97ReqInfo;
       
  2562             TIsiSubBlock reqInfo97SubBlock(
       
  2563                 qos97ReqInfo,
       
  2564                 GPDS_QOS_REQ_INFO,
       
  2565                 EIsiSubBlockTypeId8Len8 );
       
  2566 
       
  2567             ret = FillGpdsQosReqInfo( *configuration.iQosParams97,
       
  2568                                       qos97ReqInfo );
       
  2569 
       
  2570             if ( KErrNone == ret )
       
  2571                 {
       
  2572                 gpdsContextModifyReq.CopyData(
       
  2573                     currentMsgOffset, reqInfo97SubBlock.CompleteSubBlock() );
       
  2574                 // Set new offset and increase subblock count
       
  2575                 currentMsgOffset =
       
  2576                     currentMsgOffset + SIZE_GPDS_QOS_REQ_INFO;
       
  2577                 numOfSbInMessage++;
       
  2578                 }
       
  2579             }
       
  2580         // no else
       
  2581 
       
  2582         // If given aTftOperation indicates "DeletePacketFilter" and
       
  2583         // DeleteID-array includes PacketFilterID's to be removed.
       
  2584         // DeleteID -array may include 1 to 8 items and ID's can have values
       
  2585         // from 1 to 8. Value 0xFF indicates there is no valid ID.
       
  2586         if ( KTIntNotDefined == configuration.iFilterIdArray[0] &&
       
  2587                 GPDS_TFT_DELETE_PACKET_FILTERS == tftOperation )
       
  2588             {
       
  2589             // do nothing - this is the only case when no
       
  2590             // GPDS_TFT_INFO is added to the message
       
  2591             }
       
  2592         else
       
  2593             {
       
  2594             // preamble
       
  2595             // Add GPDS_TFT_INFO sub block
       
  2596             TUint8 numOfSbsInsideSb( 0 );
       
  2597             TBuf8<KMaximumLengthOfGpdsTftInfo> gpdsTftInfoSbBuffer;
       
  2598             TIsiSubBlock gpdsTftInfoSubBlock(
       
  2599                 gpdsTftInfoSbBuffer,
       
  2600                 GPDS_TFT_INFO,
       
  2601                 EIsiSubBlockTypeId8Len8 );
       
  2602 
       
  2603             gpdsTftInfoSbBuffer.Append( tftOperation );
       
  2604 
       
  2605             if( NULL != mediaAuthorizationArray &&
       
  2606                 ( 0 <= mediaAuthorizationArray->Count() ) )
       
  2607                 {
       
  2608                 // Add sub blocks to GPDS_TFT_INFO sub block
       
  2609                 AddMediaAuthorizationInfo( mediaAuthorizationArray,
       
  2610                     gpdsTftInfoSbBuffer, numOfSbsInsideSb );
       
  2611                 }
       
  2612             // no else
       
  2613 
       
  2614             if ( NULL == aPacketFilterPtr &&  NULL != mediaAuthorizationArray )
       
  2615                 {
       
  2616                 // Complete GPDS_TFT_INFO sub block and set sub block count
       
  2617                 TBuf8<KSubBlockCount1> sbCountbuf;
       
  2618                 sbCountbuf.Append( numOfSbsInsideSb );
       
  2619                 gpdsTftInfoSbBuffer.Insert(
       
  2620                     GPDS_TFT_INFO_OFFSET_NUMBEROFSUBBLOCKS, sbCountbuf );
       
  2621                 gpdsContextModifyReq.CopyData(
       
  2622                     currentMsgOffset, gpdsTftInfoSubBlock.CompleteSubBlock() );
       
  2623                 // Set new message offset and increase messages subblock count
       
  2624                 currentMsgOffset =
       
  2625                     currentMsgOffset + gpdsTftInfoSbBuffer.Length();
       
  2626                 numOfSbInMessage++;
       
  2627 
       
  2628                 // Initialise message buffer again for future use
       
  2629                 numOfSbsInsideSb = 0;
       
  2630                 gpdsTftInfoSbBuffer.Delete(
       
  2631                     GPDS_TFT_INFO_OFFSET_NUMBEROFSUBBLOCKS,
       
  2632                     ( gpdsTftInfoSbBuffer.Length() -
       
  2633                       GPDS_TFT_INFO_OFFSET_NUMBEROFSUBBLOCKS ) );
       
  2634                 }
       
  2635             // no else
       
  2636 
       
  2637             if ( GPDS_TFT_DELETE_PACKET_FILTERS == tftOperation )
       
  2638                 {
       
  2639 
       
  2640                 // Add GPDS_TFT_FILTER_INFO sub blocks to GPDS_TFT_INFO sub block
       
  2641                 // Count number of valid ID's from DeleteID array and
       
  2642                 // adding ID's to buffer
       
  2643                 for ( TUint8 i = 0; ( i < KMaxNumberOfTftFilters ) &&
       
  2644                     ( KTIntNotDefined != configuration.iFilterIdArray[i] ); i++ )
       
  2645                     {
       
  2646                     AppendGpdsTftFilterInfo( configuration.iFilterIdArray[i],
       
  2647                             gpdsTftInfoSbBuffer, numOfSbsInsideSb );
       
  2648                     }
       
  2649 
       
  2650                 // Add GPDS_TFT_INFO subblock, which includes tftInfo buffer and
       
  2651                 // number of removed filters
       
  2652                 // Complete GPDS_TFT_INFO sub block and set sub block count
       
  2653                 TBuf8<KSubBlockCount1> sbCountBuff;
       
  2654                 sbCountBuff.Append( numOfSbsInsideSb );
       
  2655                 gpdsTftInfoSbBuffer.Insert(
       
  2656                     GPDS_TFT_INFO_OFFSET_NUMBEROFSUBBLOCKS, sbCountBuff );
       
  2657                 gpdsContextModifyReq.CopyData(
       
  2658                     currentMsgOffset, gpdsTftInfoSubBlock.CompleteSubBlock() );
       
  2659                 // Set new message offset and increase messages subblock count
       
  2660                 currentMsgOffset =
       
  2661                     currentMsgOffset + gpdsTftInfoSbBuffer.Length();
       
  2662                 numOfSbInMessage++;
       
  2663                 }
       
  2664 
       
  2665            // If given aTftOperation is "CreateNew" or "AddPacketFilters"
       
  2666            // of "ReplacePacketFilters"
       
  2667            else if ( ( GPDS_TFT_CREATE_NEW == tftOperation ) ||
       
  2668                 ( GPDS_TFT_ADD_PACKET_FILTERS == tftOperation ) ||
       
  2669                 ( GPDS_TFT_REPLACE_PACKET_FILTERS == tftOperation ) )
       
  2670                 {
       
  2671                 // If there is one or more PacketFilters
       
  2672                 if ( NULL != aPacketFilterPtr )
       
  2673                     {
       
  2674                     // Initialize variable which indicates current filter
       
  2675                     TUint8 filterIndex( 0 );
       
  2676                     // Copy all given PacketFilters to gpdsContextModifyReq
       
  2677                     // There can be from 1 to 8 PacketFilters
       
  2678                     while ( filterIndex < aPacketFilterPtr->Count() )
       
  2679                         {
       
  2680                         AddPacketFilterInfo(
       
  2681                             pdpType,
       
  2682                             &( aPacketFilterPtr->At( filterIndex ) ),
       
  2683                             gpdsTftInfoSbBuffer );
       
  2684                         // Increasing filterIndex by one, pointing to
       
  2685                         // the next PacketFilter item
       
  2686                         filterIndex++;
       
  2687 
       
  2688                         numOfSbsInsideSb++;
       
  2689                         }
       
  2690                     }
       
  2691                 // no else
       
  2692 
       
  2693                 // Add GPDS_TFT_INFO subblock, which includes tftInfo
       
  2694                 // buffer and total number of PacketFilter items
       
  2695                 // Complete GPDS_TFT_INFO sub block and set sub block count
       
  2696                 TBuf8<KSubBlockCount1> sbCountBuff;
       
  2697                 sbCountBuff.Append( numOfSbsInsideSb );
       
  2698                 gpdsTftInfoSbBuffer.Insert(
       
  2699                     GPDS_TFT_INFO_OFFSET_NUMBEROFSUBBLOCKS, sbCountBuff );
       
  2700                 gpdsContextModifyReq.CopyData(
       
  2701                     currentMsgOffset, gpdsTftInfoSubBlock.CompleteSubBlock() );
       
  2702                 // Set new message offset and increase messages subblock count
       
  2703                 currentMsgOffset =
       
  2704                     currentMsgOffset + gpdsTftInfoSbBuffer.Length();
       
  2705                 numOfSbInMessage++;
       
  2706                 }
       
  2707             // no special handling is required for GPDS_TFT_NO_OPERATION and
       
  2708             // GPDS_TFT_DELETE_EXISTING besides what is done in preamble
       
  2709             // no else
       
  2710             }
       
  2711 
       
  2712         // If there were no errors
       
  2713         if ( KErrNone == ret )
       
  2714             {
       
  2715             // Set number of subblocs in GPDS_CONTEXT_MODIFY_REQ message
       
  2716             gpdsContextModifyReq.Set8bit(
       
  2717                 ISI_HEADER_SIZE +
       
  2718                 GPDS_CONTEXT_MODIFY_REQ_OFFSET_NUMBEROFSUBBLOCKS,
       
  2719                 numOfSbInMessage );
       
  2720             // Send GPDS_CONTEXT_MODIFY_REQ message
       
  2721             ret = iPhoNetSender->Send( gpdsContextModifyReq.Complete() );
       
  2722             }
       
  2723         // no else
       
  2724         }
       
  2725     // no else
       
  2726 
       
  2727     return ret;
       
  2728     }
       
  2729 
       
  2730 // -----------------------------------------------------------------------------
       
  2731 // CMmPacketContextMessHandler::GpdsContextModifyResp
       
  2732 // This method breaks the response to the context modify request.
       
  2733 // -----------------------------------------------------------------------------
       
  2734 //
       
  2735 void CMmPacketContextMessHandler::GpdsContextModifyResp(
       
  2736     const TIsiReceiveC& aIsiMessage )
       
  2737     {
       
  2738     TUint8 cause ( GPDS_CAUSE_UNKNOWN );
       
  2739     TUint8 rejectionCause( GPDS_CAUSE_UNKNOWN );
       
  2740 
       
  2741     // Local link configure resp message
       
  2742     TUint sbStartOffSet( 0 );
       
  2743 
       
  2744     TInt errorValue( KErrNone );
       
  2745     TUint8 contextId( aIsiMessage.Get8bit(
       
  2746         ISI_HEADER_SIZE + GPDS_CONTEXT_MODIFY_RESP_OFFSET_CID ) );
       
  2747 
       
  2748     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::GpdsContextModifyResp. Context id:%d", contextId );
       
  2749 OstTraceExt1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTMODIFYRESP, "CMmPacketContextMessHandler::GpdsContextModifyResp;contextId=%hhu", contextId );
       
  2750 
       
  2751     sbStartOffSet = 0;
       
  2752 
       
  2753     if( GPDS_CID_VOID != contextId )
       
  2754         {
       
  2755 
       
  2756         TFLOGSTRING("TSY: CMmPacketContextMessHandler::GpdsContextModifyResp. Context != GPDS_CID_VOID");
       
  2757 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTMODIFYRESP, "CMmPacketContextMessHandler::GpdsContextModifyResp, Context != GPDS_CID_VOID" );
       
  2758 
       
  2759         // Get transaction id
       
  2760         TUint8 transactionId( aIsiMessage.Get8bit(
       
  2761            ISI_HEADER_SIZE + GPDS_CONTEXT_MODIFY_RESP_OFFSET_UTID ) );
       
  2762         TUint8 modifyTraId( GenerateTraId( contextId ) );
       
  2763 
       
  2764         if( modifyTraId == transactionId )
       
  2765             {
       
  2766             // Get status
       
  2767             TUint8 status( aIsiMessage.Get8bit(
       
  2768                 ISI_HEADER_SIZE + GPDS_CONTEXT_MODIFY_RESP_OFFSET_STATUS ) );
       
  2769 
       
  2770             if ( GPDS_OK != status )
       
  2771                 {
       
  2772                 cause = aIsiMessage.Get8bit( sbStartOffSet +
       
  2773                     GPDS_CONTEXT_MODIFY_RESP_OFFSET_CAUSE );
       
  2774                 errorValue = CMmStaticUtility::PacketDataCSCauseToEpocError(
       
  2775                     cause );
       
  2776                 }
       
  2777             // no else
       
  2778 
       
  2779             if ( GPDS_CAUSE_AUTHENTICATION == cause )
       
  2780                 {
       
  2781                 TInt retValue( aIsiMessage.FindSubBlockOffsetById(
       
  2782                     ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_MODIFY_RESP,
       
  2783                     GPDS_SHARED_POLICY_CONTROL_REJ_CODE_INFO,
       
  2784                     EIsiSubBlockTypeId8Len8,
       
  2785                     sbStartOffSet ) );
       
  2786 
       
  2787                 if( KErrNone == retValue)
       
  2788                     {
       
  2789                     rejectionCause = aIsiMessage.Get8bit( sbStartOffSet +
       
  2790                     GPDS_SHARED_POLICY_CONTROL_REJ_CODE_INFO_OFFSET_REJECTIONCAUSE
       
  2791                    );
       
  2792 
       
  2793                     errorValue =
       
  2794                         CMmStaticUtility::PacketDataCSCauseToEpocError(
       
  2795                             cause );
       
  2796                     }
       
  2797                 // no else
       
  2798                 }
       
  2799             // no else
       
  2800 
       
  2801             // CompleteModifyActiveContext
       
  2802             TInfoName contextName;
       
  2803             TBuf8<1> rejectionCauseBuf;
       
  2804             rejectionCauseBuf.Zero();
       
  2805             rejectionCauseBuf.Append( rejectionCause );
       
  2806 
       
  2807             TFLOGSTRING4("TSY: CMmPacketContextMessHandler::GpdsContextModifyResp. status:%d, errorValue:%d, rejCause:%d", status, errorValue, rejectionCause);
       
  2808 OstTraceExt3( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_GPDSCONTEXTMODIFYRESP, "CMmPacketContextMessHandler::GpdsContextModifyResp;status=%hhu;errorValue=%d;rejectionCause=%hhu", status, errorValue, rejectionCause );
       
  2809 
       
  2810             // Make sure that buffer is empty if rejection code is not there
       
  2811             if( KErrNone == rejectionCause )
       
  2812                 {
       
  2813                 rejectionCauseBuf.Zero();
       
  2814                 }
       
  2815             // no else
       
  2816 
       
  2817             TInt found( iContextList->
       
  2818                 GetContextNameByContextId( contextId, contextName ) );
       
  2819 
       
  2820             if( KErrNone == found )
       
  2821                {
       
  2822                 CMmDataPackage data;
       
  2823                 data.PackData( &contextName, &rejectionCauseBuf );
       
  2824                 iMessageRouter->Complete(
       
  2825                     EPacketContextModifyActiveContext,
       
  2826                     &data,
       
  2827                     errorValue );
       
  2828                }
       
  2829             // no else
       
  2830             }
       
  2831         // no else
       
  2832         }
       
  2833     // no else
       
  2834     }
       
  2835 
       
  2836 // -----------------------------------------------------------------------------
       
  2837 // CMmPacketContextMessHandler::AddPacketFilterInfo
       
  2838 // Add packet filter info to Configure or Modify Req Isi-message.
       
  2839 // -----------------------------------------------------------------------------
       
  2840 //
       
  2841 TUint16 CMmPacketContextMessHandler::AddPacketFilterInfo(
       
  2842     const TUint8 aPdpType,
       
  2843     RPacketContext::TPacketFilterV2* aFilter,
       
  2844     TDes8& aBuffer ) const
       
  2845     {
       
  2846 
       
  2847     TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo");
       
  2848 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo" );
       
  2849 
       
  2850     // Initialize variable which indicates number of components
       
  2851     // in PacketFilter
       
  2852     TUint8 numberOfSubSubBlocks( 0 );
       
  2853     // Create tftFilterInfo
       
  2854     TBuf8<KMaximumLengthOfGpdsTftFilterInfo> tftFilterInfo;
       
  2855     TIsiSubBlock tftFilterInfoSubBlock(
       
  2856         tftFilterInfo,
       
  2857         GPDS_TFT_FILTER_INFO,
       
  2858         EIsiSubBlockTypeId8Len8 );
       
  2859     // Add TftFilterInfo parameters into buffer
       
  2860     // In API docs ID can have values from 1 to 8 and
       
  2861     // in GPDS docs it can have values from 0 to 7
       
  2862     TUint8 id( static_cast<TUint8>( aFilter->iId - KFilterArray ) );
       
  2863     tftFilterInfo.Append( id );
       
  2864     TUint8 evaluationPrecedenceIndex( static_cast<TUint8>(
       
  2865         aFilter->iEvaluationPrecedenceIndex - KFilterArray ) );
       
  2866     tftFilterInfo.Append( evaluationPrecedenceIndex );
       
  2867     tftFilterInfo.Append( KGpdsPadding );
       
  2868     tftFilterInfo.Append( KGpdsPadding );
       
  2869     tftFilterInfo.Append( KGpdsPadding );
       
  2870 
       
  2871     // FlowLabel value can exist only when IPv6 Address is included.
       
  2872     // Checking also is given value valid. Value 0 means Optional
       
  2873     if ( ( 0 < aFilter->iFlowLabel ) && ( GPDS_PDP_TYPE_IPV6 == aPdpType ) )
       
  2874         {
       
  2875 
       
  2876         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. GPDS_PDP_TYPE_IPV6");
       
  2877 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo, GPDS_PDP_TYPE_IPV6" );
       
  2878 
       
  2879         AppendGpdsFilterFlowLabelInfo( *aFilter, tftFilterInfo,
       
  2880                                        numberOfSubSubBlocks );
       
  2881         }
       
  2882     // no else
       
  2883 
       
  2884     // If TOSorTrafficClass have valid value
       
  2885     // Value 0 means Optional
       
  2886     if ( 0 < aFilter->iTOSorTrafficClass )
       
  2887         {
       
  2888         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. TOSorTrafficClass have valid value");
       
  2889 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo, TOSorTrafficClass have valid value" );
       
  2890 
       
  2891         AppendGpdsFilterTosInfo( *aFilter, tftFilterInfo, numberOfSubSubBlocks );
       
  2892         }
       
  2893     // no else
       
  2894 
       
  2895     // If IPSecSPI have valid value
       
  2896     // Value 0 means Optional
       
  2897     if ( 0 < aFilter->iIPSecSPI )
       
  2898         {
       
  2899         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. IPSecSPI have valid value");
       
  2900 OstTrace0( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo, IPSecSPI have valid value" );
       
  2901 
       
  2902         AppendGpdsFilterSpiInfo( *aFilter, tftFilterInfo, numberOfSubSubBlocks );
       
  2903         }
       
  2904     // no else
       
  2905 
       
  2906     // If SrcPortMin and SrcPortMax both have valid value
       
  2907     // Value 0 means Optional
       
  2908     if ( ( 0 < aFilter->iSrcPortMin ) && ( 0 < aFilter->iSrcPortMax ) )
       
  2909         {
       
  2910 
       
  2911         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. SrcPortMin and SrcPortMax both have valid value");
       
  2912 OstTrace0( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo, SrcPortMin and SrcPortMax both have valid value" );
       
  2913 
       
  2914         AppendGpdsFilterSrcPortRangeInfo( *aFilter, tftFilterInfo,
       
  2915                                           numberOfSubSubBlocks );
       
  2916         }
       
  2917     // no else
       
  2918 
       
  2919     // If DestPortMin and DestPortMax both have valid value
       
  2920     // Value 0 means Optional
       
  2921     if ( ( 0 < aFilter->iDestPortMin ) && ( 0 < aFilter->iDestPortMax ) )
       
  2922         {
       
  2923         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. DestPortMin and DestPortMax both have valid value");
       
  2924 OstTrace0( TRACE_NORMAL, DUP5_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo, DestPortMin and DestPortMax both have valid value" );
       
  2925 
       
  2926         AppendGpdsFilterDstPortRangeInfo( *aFilter, tftFilterInfo,
       
  2927                                           numberOfSubSubBlocks );
       
  2928         }
       
  2929     // no else
       
  2930 
       
  2931     // If ProtocolNumberOrNextHeader have valid value
       
  2932     // Value 0 means Optional
       
  2933     if ( 0 < aFilter->iProtocolNumberOrNextHeader )
       
  2934         {
       
  2935         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. ProtocolNumberOrNextHeader have valid value");
       
  2936 OstTrace0( TRACE_NORMAL, DUP6_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo, ProtocolNumberOrNextHeader have valid value" );
       
  2937 
       
  2938         AppendGpdsFilterProtocolInfo( *aFilter, tftFilterInfo,
       
  2939                                       numberOfSubSubBlocks );
       
  2940         }
       
  2941     // no else
       
  2942 
       
  2943     // If given aPdpType indicates the Src Addr is type IPv4
       
  2944     if ( GPDS_PDP_TYPE_IPV4 == aPdpType )
       
  2945         {
       
  2946         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. aPdpType == GPDS_PDP_TYPE_IPV4");
       
  2947 OstTrace0( TRACE_NORMAL, DUP7_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo, aPdpType == GPDS_PDP_TYPE_IPV4" );
       
  2948 
       
  2949         AppendGpdsFilterSrcIPv4AddressInfo( *aFilter, tftFilterInfo,
       
  2950                                             numberOfSubSubBlocks );
       
  2951         }
       
  2952     // If given aPdpType indicates the Src Addr is type IPv6
       
  2953     else if ( GPDS_PDP_TYPE_IPV6 == aPdpType )
       
  2954         {
       
  2955         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. aPdpType == GPDS_PDP_TYPE_IPV6");
       
  2956 OstTrace0( TRACE_NORMAL, DUP8_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo, aPdpType == GPDS_PDP_TYPE_IPV6" );
       
  2957 
       
  2958         AppendGpdsFilterSrcIPv6AddressInfo( *aFilter, tftFilterInfo,
       
  2959                                             numberOfSubSubBlocks );
       
  2960         }
       
  2961     // no else
       
  2962 
       
  2963     // set number of sub sub blocks to GPDS_TFT_FILTER_INFO
       
  2964     TBuf8<KSubBlockCount1> sbCountBuf;
       
  2965     sbCountBuf.Append( numberOfSubSubBlocks );
       
  2966     tftFilterInfo.Insert(
       
  2967         GPDS_TFT_FILTER_INFO_OFFSET_NUMBEROFSUBBLOCKS, sbCountBuf );
       
  2968     // Add GPDS_TFT_FILTER_INFO subblock
       
  2969     aBuffer.Append( tftFilterInfoSubBlock.CompleteSubBlock() );
       
  2970 
       
  2971     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::AddPacketFilterInfo. Return tftFilterInfo length: %d", tftFilterInfo.Length() );
       
  2972 OstTrace1( TRACE_NORMAL, DUP9_CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTERINFO, "CMmPacketContextMessHandler::AddPacketFilterInfo;Return tftFilterInfo length=%d", tftFilterInfo.Length() );
       
  2973 
       
  2974     return static_cast<TUint16>( tftFilterInfo.Length() );
       
  2975     }
       
  2976 
       
  2977 // -----------------------------------------------------------------------------
       
  2978 // CMmPacketContextMessHandler::SetAuthenticationConfigReq
       
  2979 // Create an Isi-message for seting context authentication configuration.
       
  2980 // -----------------------------------------------------------------------------
       
  2981 //
       
  2982 TInt CMmPacketContextMessHandler::SetAuthenticationConfigReq(
       
  2983     const TUint8 aTransactionId,
       
  2984     const TUint8 aContextId,
       
  2985     RPacketContext::TAuthInfo aAuthInfo,
       
  2986     RPacketContext::TAuthData aResponse,
       
  2987     RPacketContext::TAuthData aChallenge,
       
  2988     TUint8  aId )
       
  2989     {
       
  2990 
       
  2991     TFLOGSTRING3("TSY: CMmPacketContextMessHandler::SetAuthenticationConfigReq. TransId: %d ContextId: %d", aTransactionId, aContextId );
       
  2992 OstTraceExt2( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_SETAUTHENTICATIONCONFIGREQ, "CMmPacketContextMessHandler::SetAuthenticationConfigReq;aTransactionId=%hhu;aContextId=%hhu", aTransactionId, aContextId );
       
  2993 
       
  2994     TInt ret( KErrNone );
       
  2995 
       
  2996     // Create isi message
       
  2997     TIsiSend gpdsContextAuthReq( iPhoNetSender->SendBufferDes() );
       
  2998     gpdsContextAuthReq.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_GPDS );
       
  2999 
       
  3000     // Set the Gpds Context Auth Req data
       
  3001     gpdsContextAuthReq.Set8bit(
       
  3002         ISI_HEADER_OFFSET_TRANSID, aTransactionId );
       
  3003     gpdsContextAuthReq.Set8bit(
       
  3004         ISI_HEADER_OFFSET_MESSAGEID, GPDS_CONTEXT_AUTH_REQ );
       
  3005     gpdsContextAuthReq.Set8bit(
       
  3006         ISI_HEADER_SIZE + GPDS_CONTEXT_AUTH_REQ_OFFSET_CID,
       
  3007         aContextId );
       
  3008 
       
  3009     // Initialize message offset and subblock count
       
  3010     TInt currentMsgOffset(
       
  3011         ISI_HEADER_SIZE + SIZE_GPDS_CONTEXT_AUTH_REQ );
       
  3012     TUint8 numOfSbInMessage( 0 );
       
  3013 
       
  3014     if ( RPacketContext::KMaxAuthDataLength >=
       
  3015             aAuthInfo.iUsername.Length() )
       
  3016         {
       
  3017 
       
  3018         TFLOGSTRING2("TSY: CMmPacketContextMessHandler::SetAuthenticationConfigReq. aAuthInfo.iUsername.Length: %d", aAuthInfo.iUsername.Length());
       
  3019 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_SETAUTHENTICATIONCONFIGREQ, "CMmPacketContextMessHandler::SetAuthenticationConfigReq;aAuthInfo.iUsername.Length=%d", aAuthInfo.iUsername.Length() );
       
  3020 
       
  3021         // Add GPDS_USERNAME_INFO subblock
       
  3022         // Set the Username info
       
  3023         // Length must correspond to KMaxAuthDataLength (+6 for ISI message)
       
  3024         const TInt KBytesForISIMessage( 6 );
       
  3025         TBuf8<RPacketContext::KMaxAuthDataLength + KBytesForISIMessage>
       
  3026             usernameInfo;
       
  3027         TIsiSubBlock usernameInfoSubBlock(
       
  3028             usernameInfo,
       
  3029             GPDS_USERNAME_INFO,
       
  3030             EIsiSubBlockTypeId8Len8 );
       
  3031 
       
  3032         usernameInfo.Append(
       
  3033             static_cast<TUint8>( aAuthInfo.iUsername.Length() ) );
       
  3034 
       
  3035         // If username length is more than zero, append authInfo.iUsername
       
  3036         if ( 0 < aAuthInfo.iUsername.Length() )
       
  3037             {
       
  3038             usernameInfo.Append( aAuthInfo.iUsername );
       
  3039             }
       
  3040         // no else
       
  3041 
       
  3042         gpdsContextAuthReq.CopyData(
       
  3043             currentMsgOffset, usernameInfoSubBlock.CompleteSubBlock() );
       
  3044         // Set new offset and increase subblock count
       
  3045         currentMsgOffset =
       
  3046             currentMsgOffset + usernameInfo.Length();
       
  3047         numOfSbInMessage++;
       
  3048         }
       
  3049 
       
  3050     // Gpds limits the combined length of username + password
       
  3051     if ( ( RPacketContext::EProtocolPAP == aAuthInfo.iProtocol ) &&
       
  3052         ( RPacketContext::KMaxAuthDataLength >=
       
  3053             aAuthInfo.iUsername.Length() ) &&
       
  3054         ( RPacketContext::KMaxAuthDataLength >=
       
  3055             aAuthInfo.iPassword.Length() ) )
       
  3056         {
       
  3057 
       
  3058         TFLOGSTRING("TSY: CMmPacketContextMessHandler::SetAuthenticationConfigReq. Protocol EProtocolPAP");
       
  3059 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_SETAUTHENTICATIONCONFIGREQ, "CMmPacketContextMessHandler::SetAuthenticationConfigReq, Protocol EProtocolPAP" );
       
  3060 
       
  3061         // Add GPDS_PASSWORD_INFO subblock
       
  3062         // Set the Password info
       
  3063         // Length must correspond to KMaxAuthDataLength (+6 for isi message)
       
  3064         TBuf8<RPacketContext::KMaxAuthDataLength + 6> passwordInfo;
       
  3065         TIsiSubBlock pswdInfoSubBlock(
       
  3066             passwordInfo,
       
  3067             GPDS_PASSWORD_INFO,
       
  3068             EIsiSubBlockTypeId8Len8 );
       
  3069 
       
  3070         passwordInfo.Append(
       
  3071             static_cast<TUint8>( aAuthInfo.iPassword.Length() ) );
       
  3072 
       
  3073         // If password length is more than zero, append authInfo.iPassword
       
  3074         if ( 0 < aAuthInfo.iPassword.Length() )
       
  3075             {
       
  3076             passwordInfo.Append( aAuthInfo.iPassword );
       
  3077             }
       
  3078         // no else
       
  3079 
       
  3080         gpdsContextAuthReq.CopyData(
       
  3081             currentMsgOffset, pswdInfoSubBlock.CompleteSubBlock() );
       
  3082         // Set new offset and increase subblock count
       
  3083         currentMsgOffset =
       
  3084             currentMsgOffset + passwordInfo.Length();
       
  3085         numOfSbInMessage++;
       
  3086         }
       
  3087     // Gpds limits the combined length of username + response
       
  3088     else if ( ( RPacketContext::EProtocolCHAP == aAuthInfo.iProtocol ) &&
       
  3089         ( RPacketContext::KMaxAuthDataLength >=
       
  3090             aAuthInfo.iUsername.Length() ) &&
       
  3091         ( RPacketContext::KMaxAuthDataLength >= aResponse.Length() ) )
       
  3092         {
       
  3093 
       
  3094         TFLOGSTRING("TSY: CMmPacketContextMessHandler::SetAuthenticationConfigReq. Protocol EProtocolCHAP");
       
  3095 OstTrace0( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_SETAUTHENTICATIONCONFIGREQ, "CMmPacketContextMessHandler::SetAuthenticationConfigReq, Protocol EProtocolCHAP" );
       
  3096 
       
  3097         // Add GPDS_CHALLENGE_INFO subblock
       
  3098         // Set the Challenge info
       
  3099         // Length must correspond to KMaxAuthDataLength (+6 for ISI message)
       
  3100         TBuf8<RPacketContext::KMaxAuthDataLength + 6> challengeInfo;
       
  3101         TIsiSubBlock challengeInfoSubBlock(
       
  3102             challengeInfo,
       
  3103             GPDS_CHALLENGE_INFO,
       
  3104             EIsiSubBlockTypeId8Len8 );
       
  3105 
       
  3106         // Add length
       
  3107         challengeInfo.Append(
       
  3108             static_cast<TUint8>( aChallenge.Length() ) );
       
  3109 
       
  3110         // If challenge length is more than zero, append authInfo.iChallenge
       
  3111         if ( 0 < aChallenge.Length() )
       
  3112             {
       
  3113             challengeInfo.Append( aChallenge );
       
  3114             }
       
  3115         // no else
       
  3116 
       
  3117         gpdsContextAuthReq.CopyData(
       
  3118             currentMsgOffset, challengeInfoSubBlock.CompleteSubBlock() );
       
  3119         // Set new offset and increase subblock count
       
  3120         currentMsgOffset =
       
  3121             currentMsgOffset + challengeInfo.Length();
       
  3122         numOfSbInMessage++;
       
  3123 
       
  3124         // Add GPDS_RESPONSE_INFO subblock
       
  3125         // Set the Response info
       
  3126         // Length must correspond to KMaxAuthDataLength (+6 for isi message)
       
  3127         TBuf8<RPacketContext::KMaxAuthDataLength + 6> responseInfo;
       
  3128         TIsiSubBlock respInfoSubBlock(
       
  3129             responseInfo,
       
  3130             GPDS_RESPONSE_INFO,
       
  3131             EIsiSubBlockTypeId8Len8 );
       
  3132 
       
  3133         // Add Id
       
  3134         responseInfo.Append( aId );
       
  3135         responseInfo.Append(
       
  3136             static_cast<TUint8>( aResponse.Length() ) );
       
  3137 
       
  3138         // If response length is more than zero, append authInfo.iResponse
       
  3139         if ( 0 < aResponse.Length() )
       
  3140             {
       
  3141             responseInfo.Append( aResponse );
       
  3142             }
       
  3143         // no else
       
  3144 
       
  3145         gpdsContextAuthReq.CopyData(
       
  3146             currentMsgOffset, respInfoSubBlock.CompleteSubBlock() );
       
  3147         // Set new offset and increase subblock count
       
  3148         currentMsgOffset =
       
  3149             currentMsgOffset + responseInfo.Length();
       
  3150         numOfSbInMessage++;
       
  3151         }
       
  3152     else
       
  3153         {
       
  3154 
       
  3155         TFLOGSTRING("TSY: CMmPacketContextMessHandler::SetAuthenticationConfigReq. return KErrTooBig");
       
  3156 OstTrace0( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_SETAUTHENTICATIONCONFIGREQ, "CMmPacketContextMessHandler::SetAuthenticationConfigReq,return KErrTooBig" );
       
  3157 
       
  3158         ret = KErrTooBig;
       
  3159         }
       
  3160 
       
  3161     if ( KErrNone == ret )
       
  3162         {
       
  3163         // Set number of subblocs in GPDS_CONTEXT_AUTH_REQ message
       
  3164         gpdsContextAuthReq.Set8bit(
       
  3165             ISI_HEADER_SIZE + GPDS_CONTEXT_AUTH_REQ_OFFSET_NUMBEROFSUBBLOCKS,
       
  3166             numOfSbInMessage );
       
  3167 
       
  3168         TFLOGSTRING("TSY: CMmPacketContextMessHandler::SetAuthenticationConfigReq. Send GPDS_CONTEXT_AUTH_REQ message");
       
  3169 OstTrace0( TRACE_NORMAL, DUP5_CMMPACKETCONTEXTMESSHANDLER_SETAUTHENTICATIONCONFIGREQ, "CMmPacketContextMessHandler::SetAuthenticationConfigReq, Send GPDS_CONTEXT_AUTH_REQ message" );
       
  3170 
       
  3171         // Send GPDS_CONTEXT_AUTH_REQ message
       
  3172         ret = iPhoNetSender->Send( gpdsContextAuthReq.Complete() );
       
  3173         }
       
  3174     // no else
       
  3175 
       
  3176     return ret;
       
  3177     }
       
  3178 
       
  3179 // -----------------------------------------------------------------------------
       
  3180 // CMmPacketContextMessHandler::ExtFuncL
       
  3181 // Entry point for messages received from Symbian OS layer (Message manager).
       
  3182 // -----------------------------------------------------------------------------
       
  3183 //
       
  3184 TInt CMmPacketContextMessHandler::ExtFuncL(
       
  3185     TInt aIpc,
       
  3186     const CMmDataPackage* aDataPackage )
       
  3187     {
       
  3188 
       
  3189     TFLOGSTRING2( "TSY: CMmPacketContextMessHandler::ExtFuncL. IPC: %d", aIpc );
       
  3190 OstTrace1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_EXTFUNCL, "CMmPacketContextMessHandler::ExtFuncL;aIpc=%d", aIpc );
       
  3191 
       
  3192     // add the usage of ASSERT MACRO for aDataPackage when it's available
       
  3193     TInt ret( KErrNotSupported );
       
  3194 
       
  3195     switch ( aIpc )
       
  3196         {
       
  3197         case EPacketContextGetDataVolumeTransferred:
       
  3198             {
       
  3199             ret = GpdsContextStatusReq( *aDataPackage );
       
  3200             break;
       
  3201             }
       
  3202         case EPacketContextInitialiseContext:
       
  3203             {
       
  3204             ret = InitialiseContext( *aDataPackage );
       
  3205             break;
       
  3206             }
       
  3207         case EPacketContextDelete:
       
  3208             {
       
  3209             ret = Delete( *aDataPackage );
       
  3210             break;
       
  3211             }
       
  3212         case EPacketContextSetConfig:
       
  3213             {
       
  3214             ret = SetConfigL( *aDataPackage );
       
  3215             break;
       
  3216             }
       
  3217         case EPacketContextActivate:
       
  3218             {
       
  3219             ret = iMmPipeController->PnsPipeEnableReq( *aDataPackage );
       
  3220             break;
       
  3221             }
       
  3222         case EPacketContextDeactivate:
       
  3223             {
       
  3224             ret = GpdsContextDeactivateReq( *aDataPackage );
       
  3225             break;
       
  3226             }
       
  3227         case EPacketContextAddPacketFilter:
       
  3228             {
       
  3229             ret = AddPacketFilter( aDataPackage );
       
  3230             break;
       
  3231             }
       
  3232 
       
  3233         case EPacketContextModifyActiveContext:
       
  3234             {
       
  3235             ret = GpdsContextModifyReq( aDataPackage );
       
  3236             break;
       
  3237             }
       
  3238 
       
  3239         case EPacketAddMediaAuthorization:
       
  3240             {
       
  3241             ret = AddMediaAuthorizationL( aDataPackage );
       
  3242             break;
       
  3243             }
       
  3244         case ECustomSetDriveModeIPC:
       
  3245             {
       
  3246             //packed parameter: TSetDriveMode ( mode status )
       
  3247             RMmCustomAPI::TSetDriveMode modeStatus;
       
  3248             aDataPackage->UnPackData( modeStatus );
       
  3249             // Setting DCM drive mode flag on / off.
       
  3250             if ( RMmCustomAPI::EDeactivateDriveMode == modeStatus )
       
  3251                 {
       
  3252                 iDriveModeFlag = EFalse;
       
  3253                 iMessageRouter->Complete( ECustomSetDriveModeIPC, KErrNone );
       
  3254                 }
       
  3255             else
       
  3256                 {
       
  3257                 iDriveModeFlag = ETrue;
       
  3258                 iMessageRouter->Complete( ECustomSetDriveModeIPC, KErrNone );
       
  3259                 }
       
  3260             ret = KErrNone;
       
  3261             break;
       
  3262             }
       
  3263         default:
       
  3264             {
       
  3265 
       
  3266             TFLOGSTRING2("TSY: CMmPacketContextMessHandler::ExtFuncL - Unknown IPC: %d", aIpc);
       
  3267 
       
  3268 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_EXTFUNCL, "CMmPacketContextMessHandler::ExtFuncL;Unknown aIpc=%d", aIpc );
       
  3269             break;
       
  3270             }
       
  3271         }
       
  3272 
       
  3273     return ret;
       
  3274     }
       
  3275 
       
  3276 // -----------------------------------------------------------------------------
       
  3277 // CMmPacketContextMessHandler::InitialiseContext
       
  3278 // This function starts the three phase context initialisation.
       
  3279 // -----------------------------------------------------------------------------
       
  3280 //
       
  3281 TInt CMmPacketContextMessHandler::InitialiseContext(
       
  3282     const CMmDataPackage& aDataPackage )
       
  3283     {
       
  3284 
       
  3285     TFLOGSTRING( "TSY: CMmPacketContextMessHandler::InitialiseContext");
       
  3286 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_INITIALISECONTEXT, "CMmPacketContextMessHandler::InitialiseContext" );
       
  3287 
       
  3288     TUint8 channelId( KTUint8NotDefined );
       
  3289     TInfoName* contextName = NULL;
       
  3290     TInfoName* hostCidName = NULL;
       
  3291     TInt ret( KErrNone );
       
  3292     iInitialiseError = KErrNone;
       
  3293     TUint8 objectId( 0 );
       
  3294 
       
  3295     aDataPackage.UnPackData( &contextName, &hostCidName );
       
  3296 
       
  3297     // don't allow new context creation if allowing incoming call
       
  3298     // (for allow incoming call feature)
       
  3299     if ( CALL_MODEM_ID_NONE != iCallModemResourceCallId )
       
  3300         {
       
  3301         ret = KErrServerBusy;
       
  3302         }
       
  3303     //no else
       
  3304 
       
  3305     if( KErrNone == ret )
       
  3306         {
       
  3307         ret = iContextList->GenerateProxyId( channelId );
       
  3308 
       
  3309         if( KErrNone == ret )
       
  3310             {
       
  3311             TBuf8<KBuffProxyIdForChannel> proxyIdForChannel;
       
  3312             TInt ret = iPhoNetSender->
       
  3313                 GetChannelInfo( channelId, proxyIdForChannel );
       
  3314 
       
  3315             if( KErrNone == ret  )
       
  3316                 {
       
  3317                 // Object id is taken from proxyIdForChannel bytes 0 and 1.
       
  3318                 objectId = ( static_cast<TUint16>(
       
  3319                     proxyIdForChannel[0]) << KShift8Bits ) +
       
  3320                         proxyIdForChannel[1];
       
  3321 
       
  3322                 ret = iContextList->AddObject( objectId, channelId,
       
  3323                     // 1. object id 2. channel id ( proxy )
       
  3324                     *contextName, *hostCidName );
       
  3325                 }
       
  3326             // no else
       
  3327             }
       
  3328         // no else
       
  3329 
       
  3330         if( KErrNone == ret  )
       
  3331             {
       
  3332             TUint8 pipehandle( iContextList->
       
  3333                 PipeHandleByContextName( contextName ) );
       
  3334 
       
  3335             if ( KInvalidPipeHandle == pipehandle )
       
  3336                 {
       
  3337 
       
  3338 #ifdef DUMMY_NIF_PEP_FOR_PACKET_DATA_TESTING_DOS
       
  3339                 // Create unique trans id
       
  3340                 // This is due all context have same proxyId in testing
       
  3341                 // environment and valid contextId not yet available
       
  3342                 TInt proxyInt( static_cast<TInt>( channelId ) );
       
  3343                 TInt tempInt( proxyInt - iTransIdForProxies );
       
  3344                 channelId = static_cast<TUint8>( tempInt );
       
  3345                 iTransIdForProxies++;
       
  3346 #endif // DUMMY_NIF_PEP_FOR_PACKET_DATA_TESTING_DOS
       
  3347 
       
  3348                 ret = iContextList->OpenChannel( channelId );
       
  3349                 if ( KErrNone == ret )
       
  3350                     {
       
  3351                     ret = iContextList->
       
  3352                         SetPipeCreateTransId( channelId, contextName );
       
  3353                     }
       
  3354 
       
  3355                 if( KErrNone == ret )
       
  3356                     {
       
  3357                     TUint8 pep1ObjectNum( iContextList->
       
  3358                         ProxyIdByContextName( contextName ) );
       
  3359 
       
  3360                     ret = iMmPipeController->PnsPipeCreateReq(
       
  3361                         channelId, PN_PIPE_DISABLE, objectId);
       
  3362 
       
  3363                     if ( KErrNone == ret )
       
  3364                         {
       
  3365                         ret = iContextList->
       
  3366                             SetCreateContextIdTransId( objectId , contextName);
       
  3367                         }
       
  3368                     // no else
       
  3369                     }
       
  3370                 // no else
       
  3371                }
       
  3372             else
       
  3373                 {
       
  3374                 // Pipe has been already created. E.g. Initialise has been
       
  3375                 // called once but it did not succeed, and then the pipe has
       
  3376                 // been tried to remove but the removing did not succeed.
       
  3377                 // Hence we can strike straight into InitialiseContextPhase2L.
       
  3378                 iContextList->
       
  3379                     SetCreateContextIdTransId( objectId , contextName );
       
  3380 
       
  3381                 ret = InitialiseContextPhase2( pipehandle );
       
  3382                 // iInitialiseError is set at InitialiseContextPhase2L() if
       
  3383                 // there occured error
       
  3384                 if ( KErrNone != ret )
       
  3385                     {
       
  3386                     ret = iInitialiseError;
       
  3387                     }
       
  3388                 // no else
       
  3389                 }
       
  3390             }
       
  3391         // no else
       
  3392         }
       
  3393     // no else
       
  3394 
       
  3395     return ret;
       
  3396     }
       
  3397 
       
  3398 // -----------------------------------------------------------------------------
       
  3399 // CMmPacketContextMessHandler::InitialiseContextPhase2
       
  3400 // This function starts the second phase of context initialisation.
       
  3401 // -----------------------------------------------------------------------------
       
  3402 //
       
  3403 TInt CMmPacketContextMessHandler::InitialiseContextPhase2(
       
  3404     TUint8 aPipeHandle )
       
  3405     {
       
  3406 
       
  3407     TFLOGSTRING("TSY: CMmPacketContextGsmWcdmaExt::InitialiseContextPhase2.");
       
  3408 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_INITIALISECONTEXTPHASE2, "CMmPacketContextMessHandler::InitialiseContextPhase2" );
       
  3409 
       
  3410     TInt ret( KErrNone );
       
  3411     TUint8 createContextIdTransId( iContextList->
       
  3412         CreateContextIdTransIdByPipeHandle( aPipeHandle ) );
       
  3413 
       
  3414     if( KTUint8NotDefined !=  createContextIdTransId )
       
  3415         {
       
  3416         ret = GpdsContextIdCreateReq( createContextIdTransId );
       
  3417 
       
  3418         if ( KErrNone != ret )
       
  3419             {
       
  3420             iInitialiseError = ret;
       
  3421 
       
  3422             ret = iMmPipeController->PnsPipeRemoveReq(
       
  3423                 createContextIdTransId, aPipeHandle );
       
  3424             if ( KErrNone == ret )
       
  3425                 {
       
  3426                 // Store the trans id
       
  3427                 ret = iContextList->
       
  3428                     SetRemovePipeTraId( createContextIdTransId, aPipeHandle );
       
  3429                 }
       
  3430             // no else
       
  3431 
       
  3432             TFLOGSTRING2("TSY: CMmPacketContextGsmWcdmaExt::InitialiseContextPhase2. Error(0=OK) %d", ret );
       
  3433 
       
  3434 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_INITIALISECONTEXTPHASE2, "CMmPacketContextMessHandler::InitialiseContextPhase2;Error(0=OK) %d", ret );
       
  3435             }
       
  3436         // no else
       
  3437         }
       
  3438     // no else
       
  3439 
       
  3440     return ret;
       
  3441     }
       
  3442 
       
  3443 // -----------------------------------------------------------------------------
       
  3444 // CMmPacketContextMessHandler::InitialiseContextPhase3
       
  3445 // This function starts the third phase of the context initialisation.
       
  3446 // -----------------------------------------------------------------------------
       
  3447 //
       
  3448 void CMmPacketContextMessHandler::InitialiseContextPhase3(
       
  3449     const TUint8 aStatus,
       
  3450     const TUint8 aContextId )
       
  3451     {
       
  3452 
       
  3453     TFLOGSTRING3("TSY: CMmPacketContextGsmWcdmaExt::InitialiseContextPhase3. ContextId:%d aStatus:%d", aContextId, aStatus );
       
  3454 OstTraceExt2( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_INITIALISECONTEXTPHASE3, "CMmPacketContextMessHandler::InitialiseContextPhase3;aContextId=%d;aStatus=%d", aContextId, aStatus );
       
  3455 
       
  3456     TInt ret( KErrGeneral );
       
  3457 
       
  3458     if ( GPDS_OK == aStatus )
       
  3459         {
       
  3460         // get pipehandle
       
  3461         TUint8 pipeHandle( iContextList->PipeHandleByContextId( aContextId ) );
       
  3462         if ( KInvalidPipeHandle != pipeHandle )
       
  3463             {
       
  3464             TUint8 gpdsLlConfigureTraId( GenerateTraId( aContextId ) );
       
  3465 
       
  3466             if( KTUint8NotDefined != gpdsLlConfigureTraId )
       
  3467                 {
       
  3468                 ret = GpdsLlConfigureReq(
       
  3469                     gpdsLlConfigureTraId, aContextId, pipeHandle );
       
  3470                 }
       
  3471             // no else
       
  3472 
       
  3473             if ( KErrNone == ret )
       
  3474                 {
       
  3475                 ret = iContextList->
       
  3476                     SetGpdsLlConfigureTraId( gpdsLlConfigureTraId, aContextId );
       
  3477                 }
       
  3478             // no else
       
  3479             }
       
  3480         else
       
  3481             {
       
  3482             // pipehandle not found
       
  3483             ret = KErrNotFound;
       
  3484             }
       
  3485         }
       
  3486     // no else
       
  3487 
       
  3488     if ( KErrNone != ret )
       
  3489         {
       
  3490         TInfoName contextname;
       
  3491         CMmDataPackage data;
       
  3492         TInt found( iContextList->
       
  3493             GetContextNameByContextId( aContextId, contextname ) );
       
  3494 
       
  3495         TFLOGSTRING2("TSY: CMmPacketContextGsmWcdmaExt::InitialiseContextPhase3. Error:%d", ret );
       
  3496 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_INITIALISECONTEXTPHASE3, "CMmPacketContextMessHandler::InitialiseContextPhase3;Error=%d", ret );
       
  3497 
       
  3498         iInitialiseError = ret;
       
  3499         // Remove the pipe
       
  3500         // Context not found->pipehandle not found
       
  3501         if( KErrNotFound == ret )
       
  3502             {
       
  3503             TUint8 pipeRemoveTraId( GenerateTraId( aContextId ) );
       
  3504             TUint8 pipeHandle( iContextList->
       
  3505                 PipeHandleByContextId( aContextId ) );
       
  3506 
       
  3507             ret = iMmPipeController->PnsPipeRemoveReq(
       
  3508                 pipeRemoveTraId, pipeHandle );
       
  3509 
       
  3510             if ( KErrNone == ret )
       
  3511                 {
       
  3512                 // Store the trans id
       
  3513                 ret = iContextList->
       
  3514                     SetRemovePipeTraId( pipeRemoveTraId, pipeHandle );
       
  3515                 }
       
  3516             else
       
  3517                 {
       
  3518                 if( KErrNone == found )
       
  3519                     {
       
  3520                     // Complete initialisation; Context not found
       
  3521                     data.PackData( &contextname );
       
  3522                     iMessageRouter->Complete(
       
  3523                         EPacketContextInitialiseContext,
       
  3524                         &data,
       
  3525                         KErrNotFound );
       
  3526                     }
       
  3527                 // no else
       
  3528                 }
       
  3529             }
       
  3530         // some error in gprs server
       
  3531         else if( KErrGeneral == ret )
       
  3532             {
       
  3533             if( KErrNone == found )
       
  3534                 {
       
  3535                 if ( GPDS_ERROR == aStatus )
       
  3536                     {
       
  3537                     // If GPDS_STATUS in GPDS_CONTEXT_ID_CREATE_RESP is
       
  3538                     // GPDS_ERROR, max number of contexts already in use
       
  3539                     // (~=ALL_PIPES_IN_USE). => remove pipe if created
       
  3540                     TUint8 pipeRemoveTraId( GenerateTraId( aContextId ) );
       
  3541                     TUint8 pipeHandle( iContextList->
       
  3542                         PipeHandleByContextName( &contextname ) );
       
  3543 
       
  3544                     ret = iMmPipeController->PnsPipeRemoveReq(
       
  3545                         pipeRemoveTraId, pipeHandle );
       
  3546 
       
  3547                     if ( KErrNone == ret )
       
  3548                         {
       
  3549                         // Store the trans id
       
  3550                         ret = iContextList->
       
  3551                             SetRemovePipeTraId( pipeRemoveTraId, pipeHandle );
       
  3552                         }
       
  3553                     ret = CMmStaticUtility::EpocErrorCode(
       
  3554                         KErrOverflow, KErrUmtsMaxNumOfContextExceededByPhone );
       
  3555                      }
       
  3556                 // no else
       
  3557                 data.PackData( &contextname );
       
  3558                 iMessageRouter->Complete(
       
  3559                     EPacketContextInitialiseContext,
       
  3560                     &data,
       
  3561                     ret );
       
  3562                 }
       
  3563             // no else
       
  3564             }
       
  3565         // no else
       
  3566         }
       
  3567     // no else
       
  3568     }
       
  3569 
       
  3570 // -----------------------------------------------------------------------------
       
  3571 // CMmPacketContextMessHandler::CompletePipeOperation
       
  3572 // Handles pipe related response messages and completes operations.
       
  3573 // -----------------------------------------------------------------------------
       
  3574 //
       
  3575 void CMmPacketContextMessHandler::CompletePipeOperation(
       
  3576     const TInt aMessageId,
       
  3577     const TUint8 aTransactionId,
       
  3578     const TUint8 aPipeHandle,
       
  3579     const TUint8 aErrorCause )
       
  3580     {
       
  3581 
       
  3582     TFLOGSTRING3("TSY: CMmPacketContextMessHandler::CompletePipeOperation. MessageId:%d Pipe handle:%d", aMessageId, aPipeHandle );
       
  3583 OstTraceExt2( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation;aMessageId=%d;aPipeHandle=%hhu", aMessageId, aPipeHandle );
       
  3584     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::CompletePipeOperation. Error cause:%d", aErrorCause );
       
  3585 OstTraceExt1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation;aErrorCause=%hhu", aErrorCause );
       
  3586 
       
  3587     TInt errorCause( KErrNone );
       
  3588 
       
  3589     if ( PN_PIPE_NO_ERROR != aErrorCause )
       
  3590         {
       
  3591         if ( ( PNS_PIPE_CREATE_RESP == aMessageId ) &&
       
  3592              ( PN_PIPE_ERR_ALL_PIPES_IN_USE == aErrorCause ) )
       
  3593             {
       
  3594             // If reason is that all pipe already used then use specific error
       
  3595             errorCause = CMmStaticUtility::EpocErrorCode(
       
  3596                 KErrOverflow, KErrUmtsMaxNumOfContextExceededByPhone );
       
  3597             }
       
  3598         else
       
  3599             {
       
  3600             // Map the Pipe error to Epoc error
       
  3601             errorCause = CMmStaticUtility::PacketDataCSCauseToEpocError(
       
  3602                 aErrorCause, PN_PIPE );
       
  3603             }
       
  3604         }
       
  3605     // no else
       
  3606 
       
  3607     switch ( aMessageId )
       
  3608         {
       
  3609         case PNS_PIPE_CREATE_RESP:
       
  3610             {
       
  3611             if ( PN_PIPE_NO_ERROR == aErrorCause )
       
  3612                 {
       
  3613                 // Store the pipe handle
       
  3614                 TInt ret( iContextList->
       
  3615                     SetPipeHandle( aTransactionId, aPipeHandle ) );
       
  3616 
       
  3617                 if( ret == KErrNone )
       
  3618                     {
       
  3619                     // Call InitialiseContextPhase2L
       
  3620                     ret = InitialiseContextPhase2( aPipeHandle );
       
  3621                     if ( KErrNone != ret )
       
  3622                         {
       
  3623                         //This is executed if ContextId Createreq or
       
  3624                         //piperemovereq or setcontextidTraId fails
       
  3625                         //Get Contextname from CMmPacketMesshandlerContextList
       
  3626                         TUint8 contextId( iContextList->
       
  3627                             ContextIdByPipeHandle( aPipeHandle ) );
       
  3628 
       
  3629                         if( GPDS_CID_VOID != contextId )
       
  3630                             {
       
  3631                             TInfoName contextname;
       
  3632                             TInt ret2( iContextList->GetContextNameByContextId(
       
  3633                                 contextId, contextname ) );
       
  3634 
       
  3635                             if( KErrNone == ret2  )
       
  3636                                 {
       
  3637                                 CMmDataPackage data;
       
  3638                                 data.PackData( &contextname );
       
  3639                                 iMessageRouter->Complete(
       
  3640                                     EPacketContextInitialiseContext,
       
  3641                                     &data,
       
  3642                                     iInitialiseError );
       
  3643                                 }
       
  3644                             // no else
       
  3645 
       
  3646                             if( KErrNone != ret2 )
       
  3647                                 {
       
  3648 
       
  3649                                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::CompletePipeOperation. Cannot Complete Initialisation");
       
  3650 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation, Cannot Complete Initialisation" );
       
  3651                                 }
       
  3652                             // no else
       
  3653                             }
       
  3654                         // no else
       
  3655                         }
       
  3656                     // no else
       
  3657                     }
       
  3658                 // no else
       
  3659                 }
       
  3660             else
       
  3661                 {
       
  3662                 if( PN_PIPE_ERR_ALL_PIPES_IN_USE == aErrorCause )
       
  3663                     {
       
  3664                     TInfoName contextname;
       
  3665                     // Get context name by proxy id, i.e used transactionId id
       
  3666                     // pipeCreateRequest
       
  3667                     TInt ret( iContextList->
       
  3668                         ContextNameByProxyId( aTransactionId, contextname ) );
       
  3669 
       
  3670                     if( KErrNone == ret  )
       
  3671                         {
       
  3672                         // Completion because of some error in PIPE
       
  3673                         CMmDataPackage data;
       
  3674                         data.PackData( &contextname );
       
  3675                         iMessageRouter->Complete(
       
  3676                             EPacketContextInitialiseContext,
       
  3677                             &data,
       
  3678                             errorCause );
       
  3679 
       
  3680                         // remove context from list
       
  3681                         iContextList->RemoveObjectByName( &contextname );
       
  3682                         }
       
  3683                     // no else
       
  3684                     if( KErrNone != ret )
       
  3685                         {
       
  3686 
       
  3687                         TFLOGSTRING("LTSY: CMmPacketContextMessHandler::CompletePipeOperationL. Cannot Complete failed initialisation" );
       
  3688 OstTrace0( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation, Cannot Complete failed initialisation" );
       
  3689                         }
       
  3690                     // no else
       
  3691                     }
       
  3692                 else if( PN_PIPE_ERR_GENERAL == aErrorCause  )
       
  3693                     {
       
  3694                     TInfoName contextname;
       
  3695                     // Get context name by proxy id, i.e used transactionId id
       
  3696                     // pipeCreateRequest
       
  3697                     TInt ret( iContextList->
       
  3698                         ContextNameByProxyId( aTransactionId, contextname ) );
       
  3699 
       
  3700                     if( KErrNone == ret  )
       
  3701                         {
       
  3702 
       
  3703                         TFLOGSTRING2("LTSY: CMmPacketContextMessHandler::CompletePipeOperationL.Complete context initialisation with %d", errorCause );
       
  3704 
       
  3705 OstTraceExt1( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation;Complete context initialisation with=%hhu", aErrorCause );
       
  3706                         //Completion because of some error in PIPE
       
  3707                         CMmDataPackage data;
       
  3708                         data.PackData( &contextname );
       
  3709                         iMessageRouter->Complete(
       
  3710                             EPacketContextInitialiseContext,
       
  3711                             &data,
       
  3712                             errorCause );
       
  3713 
       
  3714                         iContextList->RemoveObjectByName( &contextname );
       
  3715                         }
       
  3716                     // no else
       
  3717 
       
  3718                     if( KErrNone != ret )
       
  3719                         {
       
  3720 
       
  3721                         TFLOGSTRING("LTSY: CMmPacketContextMessHandler::CompletePipeOperationL. Cannot Complete failed initialisation");
       
  3722 OstTrace0( TRACE_NORMAL, DUP5_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation, Cannot Complete failed initialisation" );
       
  3723                         }
       
  3724                     // no else
       
  3725                     }
       
  3726                 else
       
  3727                     {
       
  3728                     // Call CompleteInitialiseContext with error
       
  3729                     TUint8 contextId( iContextList->
       
  3730                         ContextIdByPipeHandle( aPipeHandle ) );
       
  3731 
       
  3732                     if( GPDS_CID_VOID != contextId )
       
  3733                         {
       
  3734                         TInfoName contextname;
       
  3735                         TInt ret( iContextList->
       
  3736                             GetContextNameByContextId( contextId, contextname )
       
  3737                             );
       
  3738 
       
  3739                         if( KErrNone == ret  )
       
  3740                             {
       
  3741                             //Completion because of some error in PIPE
       
  3742                             CMmDataPackage data;
       
  3743                             data.PackData( &contextname );
       
  3744                             iMessageRouter->Complete(
       
  3745                                 EPacketContextInitialiseContext,
       
  3746                                 &data,
       
  3747                                 errorCause );
       
  3748                             }
       
  3749                         // no else
       
  3750 
       
  3751                         if( KErrNone != ret )
       
  3752                             {
       
  3753 
       
  3754                             TFLOGSTRING("TSY: CMmPacketContextMessHandler::CompletePipeOperation. Cannot Complete Initialisation");
       
  3755 OstTrace0( TRACE_NORMAL, DUP6_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation, Cannot Complete Initialisation" );
       
  3756                             }
       
  3757                         // no else
       
  3758                         }
       
  3759                     // no else
       
  3760                     }
       
  3761                 }
       
  3762             break;
       
  3763             }
       
  3764         case PNS_PIPE_ENABLE_RESP:
       
  3765             {
       
  3766 
       
  3767             if ( PN_PIPE_NO_ERROR == aErrorCause )
       
  3768                 {
       
  3769                 // Pipe status is enabled
       
  3770                 iContextList->SetPipeStatus( aPipeHandle, PN_PIPE_ENABLE );
       
  3771                 // Call ActivatePhase2L
       
  3772                 ActivatePhase2( aPipeHandle, aTransactionId );
       
  3773                 }
       
  3774             // no else
       
  3775 
       
  3776             // This is executed in special case when user has cancelled
       
  3777             // activation, NIF's pep is desctructed and due that pipe server
       
  3778             // returns an error in PNS_PIPE_ENABLE_RESP message.
       
  3779             if ( PN_PIPE_ERR_GENERAL == aErrorCause )
       
  3780                 {
       
  3781                 TUint8 contextId( iContextList->
       
  3782                     ContextIdByPipeHandle( aPipeHandle ) );
       
  3783 
       
  3784                 TInfoName contextname;
       
  3785                 TInt ret( iContextList->
       
  3786                     GetContextNameByContextId( contextId, contextname ) );
       
  3787 
       
  3788                 if ( ret == KErrNone )
       
  3789                     {
       
  3790 
       
  3791                     TFLOGSTRING("LTSY: CMmPacketContextMessHandler::CompletePipeOperationL.Complete ACTIVATION with KErrGeneral");
       
  3792 OstTrace0( TRACE_NORMAL, DUP7_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation, Complete ACTIVATION with KErrGeneral" );
       
  3793 
       
  3794                     CMmDataPackage data;
       
  3795                     TAny* ptr = NULL;
       
  3796                     data.PackData( &contextname, ptr );
       
  3797                     iMessageRouter->Complete(
       
  3798                         EPacketContextActivate,
       
  3799                         &data,
       
  3800                         KErrGeneral );
       
  3801                     }
       
  3802                 // no else
       
  3803 
       
  3804                 TUint8 pipeHandle( iContextList->
       
  3805                     PipeHandleByContextName( &contextname ) );
       
  3806 
       
  3807                 ret = iMmPipeController->
       
  3808                     PnsPipeRemoveReq( aTransactionId, pipeHandle );
       
  3809 
       
  3810                 iContextList->RemoveObjectByName( &contextname );
       
  3811                 }
       
  3812             // no else
       
  3813             break;
       
  3814             }
       
  3815         case PNS_PIPE_RESET_RESP:
       
  3816             {
       
  3817             if ( PN_PIPE_NO_ERROR == aErrorCause )
       
  3818                 {
       
  3819                 // Pipe status is disabled
       
  3820                 iContextList->SetPipeStatus( aPipeHandle, PN_PIPE_DISABLE );
       
  3821                 }
       
  3822             // no else
       
  3823             break;
       
  3824             }
       
  3825         case PNS_PIPE_REMOVE_RESP:
       
  3826             {
       
  3827             TUint8 channelId( iContextList->ProxyIdByPipeHandle( aPipeHandle ) );
       
  3828             TFLOGSTRING2("TSY: CMmPacketContextMessHandler::CompletePipeOperation;closing channelId=%d", channelId);
       
  3829             OstTraceExt1( TRACE_NORMAL, DUP9_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation;closing channelId=%hhu", channelId );
       
  3830             iContextList->CloseChannel( channelId );
       
  3831             TUint8 contextId( iContextList->
       
  3832                 ContextIdByPipeHandle( aPipeHandle ) );
       
  3833 
       
  3834             if( iContextList->GetInitialiseMember( aPipeHandle ) )
       
  3835                 {
       
  3836                 //context id not found
       
  3837                 if( GPDS_CID_VOID != contextId)
       
  3838                     {
       
  3839                     iContextList->SetInitialiseMember( contextId, EFalse );
       
  3840                     TInfoName contextName;
       
  3841                     iContextList->
       
  3842                         GetContextNameByContextId( contextId, contextName );
       
  3843 
       
  3844                     CMmDataPackage data;
       
  3845                     data.PackData( &contextName );
       
  3846                     iMessageRouter->Complete(
       
  3847                         EPacketContextDelete,
       
  3848                         &data,
       
  3849                         errorCause );
       
  3850                     }
       
  3851                 // no else
       
  3852                 }
       
  3853             else
       
  3854                 {
       
  3855                 // context id not found
       
  3856                 if( GPDS_CID_VOID != contextId)
       
  3857                     {
       
  3858                     iContextList->SetInitialiseMember( contextId, EFalse );
       
  3859                     TInfoName contextName;
       
  3860                     iContextList->
       
  3861                         GetContextNameByContextId( contextId, contextName );
       
  3862 
       
  3863                     CMmDataPackage data;
       
  3864                     data.PackData( &contextName );
       
  3865                     iMessageRouter->Complete(
       
  3866                         EPacketContextInitialiseContext,
       
  3867                         &data,
       
  3868                         iInitialiseError );
       
  3869                     }
       
  3870                 // no else
       
  3871                 }
       
  3872 
       
  3873             if ( PN_PIPE_NO_ERROR == aErrorCause ||
       
  3874                  PN_PIPE_ERR_GENERAL == aErrorCause )
       
  3875                 {
       
  3876                 // Reset pipe handle and pipe status
       
  3877                 iContextList->ResetPipeHandleAndStatus( aPipeHandle );
       
  3878 
       
  3879                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::CompletePipeOperation.");
       
  3880 OstTrace0( TRACE_NORMAL, DUP8_CMMPACKETCONTEXTMESSHANDLER_COMPLETEPIPEOPERATION, "CMmPacketContextMessHandler::CompletePipeOperation" );
       
  3881 
       
  3882                 iContextList->RemoveObject( contextId );
       
  3883                 }
       
  3884             // no else
       
  3885             break;
       
  3886             }
       
  3887         default:
       
  3888             {
       
  3889             break;
       
  3890             }
       
  3891         }
       
  3892     }
       
  3893 
       
  3894 // -----------------------------------------------------------------------------
       
  3895 // CMmPacketContextMessHandler::Delete
       
  3896 // Delete context related to the network e.g. pipe deletion.
       
  3897 // -----------------------------------------------------------------------------
       
  3898 //
       
  3899 TInt CMmPacketContextMessHandler::Delete(
       
  3900     const CMmDataPackage& aDataPackage )
       
  3901     {
       
  3902 
       
  3903     TFLOGSTRING("TSY: CMmPacketContextMessHandler::Delete");
       
  3904 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_DELETE, "CMmPacketContextMessHandler::Delete" );
       
  3905 
       
  3906     TInt ret( KErrNone );
       
  3907     TInfoName* contextName = NULL;
       
  3908     aDataPackage.UnPackData( &contextName );
       
  3909 
       
  3910     TUint8 contextId( iContextList->
       
  3911         GetContextIdByContextName( contextName ) );
       
  3912 
       
  3913     if ( GPDS_CID_VOID != contextId )
       
  3914         {
       
  3915         // transActionId creation.
       
  3916         TUint8 transId( GenerateTraId( contextId ) );
       
  3917         TUint8 pipeHandle( iContextList->
       
  3918             PipeHandleByContextName( contextName ) );
       
  3919 
       
  3920         ret = iContextList->SetDeletionTraId(
       
  3921             contextId, transId );
       
  3922         if ( ret != KErrNotFound )
       
  3923             {
       
  3924             ret = iMmPipeController->PnsPipeRemoveReq( transId, pipeHandle );
       
  3925             }
       
  3926         // no else
       
  3927         }
       
  3928     // no else
       
  3929 
       
  3930     return ret;
       
  3931     }
       
  3932 
       
  3933 // -----------------------------------------------------------------------------
       
  3934 // CMmPacketContextMessHandler::SetConfigL
       
  3935 // Set configuration data for the context.
       
  3936 // -----------------------------------------------------------------------------
       
  3937 //
       
  3938 TInt CMmPacketContextMessHandler::SetConfigL(
       
  3939     const CMmDataPackage& aDataPackage )
       
  3940     {
       
  3941 
       
  3942     TFLOGSTRING("TSY: CMmPacketContextMessHandler::SetConfigL");
       
  3943 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL" );
       
  3944 
       
  3945     TInt ret( KErrNone );
       
  3946     TInfoName* contextName = NULL;
       
  3947     TPacketDataConfigBase* config = NULL;
       
  3948 
       
  3949     aDataPackage.UnPackData( &config, &contextName );
       
  3950 
       
  3951     TUint8 contextId( iContextList->
       
  3952         GetContextIdByContextName( contextName ) );
       
  3953 
       
  3954     iContextList->SetInitialiseMember( contextId, ETrue );
       
  3955 
       
  3956     // Check that the mode given in aConfig is GPRS
       
  3957     if ( TPacketDataConfigBase::KConfigGPRS == config->ExtensionId() )
       
  3958         {
       
  3959         if ( GPDS_CID_VOID != contextId )
       
  3960             {
       
  3961 
       
  3962             TFLOGSTRING("TSY: CMmPacketContextMessHandler::SetConfig -> Rel97");
       
  3963 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL -> Rel97" );
       
  3964 
       
  3965             iContextList->SetContextConfigurationType(
       
  3966                 contextId, TPacketDataConfigBase::KConfigGPRS );
       
  3967 
       
  3968             RPacketContext::TContextConfigGPRS& configGPRS =
       
  3969                 *reinterpret_cast<RPacketContext::TContextConfigGPRS*>(
       
  3970                     config );
       
  3971 
       
  3972             TFLOGSTRING2("TSY: CMmPacketContextMessHandler::SetConfig iPrimaryDns:%S", &configGPRS.iProtocolConfigOption.iDnsAddresses.iPrimaryDns );
       
  3973 
       
  3974 OstTraceExt1( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL;iPrimaryDns=%s", configGPRS.iProtocolConfigOption.iDnsAddresses.iPrimaryDns );
       
  3975             TFLOGSTRING2("TSY: CMmPacketContextMessHandler::SetConfig iSecondaryDns:%S", &configGPRS.iProtocolConfigOption.iDnsAddresses.iSecondaryDns);
       
  3976 OstTraceExt1( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL;iSecondaryDns=%s", configGPRS.iProtocolConfigOption.iDnsAddresses.iSecondaryDns );
       
  3977 
       
  3978             // save authentication data
       
  3979             ret = iContextList->SaveConfig(
       
  3980                 contextId,
       
  3981                 TPacketDataConfigBase::KConfigGPRS,
       
  3982                 &configGPRS,
       
  3983                 NULL );
       
  3984 
       
  3985             // if config mode was OK
       
  3986             if( KErrNone == ret )
       
  3987                 {
       
  3988                 // Map the client side Pdp type to Gpds server's pdp type
       
  3989                 TUint8 pdpType( 0 );
       
  3990                 ret = MapPdpType( pdpType, configGPRS.iPdpType );
       
  3991 
       
  3992                 // Anonymous access is not supported
       
  3993                 if ( ( KErrNone == ret ) && ( RPacketContext::ERequired ==
       
  3994                     configGPRS.iAnonymousAccessReqd ) )
       
  3995                     {
       
  3996                     ret = KErrNotSupported;
       
  3997                     }
       
  3998                 // no else
       
  3999 
       
  4000                 if ( KErrNone == ret )
       
  4001                     {
       
  4002                     // DNS addresses requested all the time
       
  4003                     TBool dnsAddressRequested( ETrue );
       
  4004 
       
  4005                     // Boolean for signalling info
       
  4006                     TBool pcscfAddress( EFalse );
       
  4007 
       
  4008                     // Set data compression
       
  4009                     TUint8 dataCompression( GPDS_PDP_DCOMP_OFF );
       
  4010 
       
  4011                     if ( configGPRS.iPdpCompression &
       
  4012                         RPacketContext::KPdpDataCompression )
       
  4013                         {
       
  4014                         dataCompression = GPDS_PDP_DCOMP_ON;
       
  4015                         }
       
  4016                     // no else
       
  4017 
       
  4018                     // Set header compression
       
  4019                     TUint8 headerCompression( GPDS_PDP_HCOMP_OFF );
       
  4020 
       
  4021                     if ( configGPRS.iPdpCompression &
       
  4022                         RPacketContext::KPdpHeaderCompression )
       
  4023                         {
       
  4024                         headerCompression = GPDS_PDP_HCOMP_ON;
       
  4025                         }
       
  4026                     // no else
       
  4027 
       
  4028                     TUint8 contextType( GPDS_CONT_TYPE_NORMAL );
       
  4029                     // primary or secondary context
       
  4030                     if( !configGPRS.iNWIContext )
       
  4031                         {
       
  4032                         // MO initiated context
       
  4033                         contextType = iContextList->
       
  4034                             GetContextTypeByName( contextName );
       
  4035                         }
       
  4036                     else
       
  4037                         {
       
  4038                         // MT initiated context
       
  4039                         contextType = GPDS_CONT_TYPE_NWI;
       
  4040                         }
       
  4041 
       
  4042                     TInfoName hostCidName = iContextList->
       
  4043                         GetHostCidName( contextName );
       
  4044                     TUint8 primaryContextId( iContextList->
       
  4045                         GetContextIdByContextName( &hostCidName ) );
       
  4046 
       
  4047                     TUint8 transActionId( GenerateTraId( contextId ) );
       
  4048 
       
  4049                     // use the iMiscBuffer to check P-CSCF discovery request
       
  4050                     TInt isOnMiscBuffer( KErrNotFound );
       
  4051                     RPacketContext::TPcoId pcoItem(
       
  4052                         RPacketContext::EEtelPcktPCSCFAddressRequest );
       
  4053 
       
  4054                     TInt len( configGPRS.iProtocolConfigOption.
       
  4055                         iMiscBuffer.Length() );
       
  4056 
       
  4057                     TPtr8 ptrToTLVdata( configGPRS.iProtocolConfigOption.
       
  4058                         iMiscBuffer.LeftTPtr(
       
  4059                             configGPRS.iProtocolConfigOption.iMiscBuffer.
       
  4060                                 MaxLength() ) );
       
  4061                     ptrToTLVdata.SetLength( configGPRS.
       
  4062                         iProtocolConfigOption.iMiscBuffer.Length());
       
  4063 
       
  4064                     const TInt KBigEnoughBuf( 1 );
       
  4065                     TBuf8<KBigEnoughBuf> smallBuffer;
       
  4066                     smallBuffer.SetLength( KBigEnoughBuf );
       
  4067                     smallBuffer.FillZ();
       
  4068 
       
  4069                     TTlvStruct<RPacketContext::TPcoId,
       
  4070                         RPacketContext::TPcoItemDataLength>tlv(
       
  4071                             ptrToTLVdata, KPtrToTLVdata );
       
  4072 
       
  4073                     TPtr8 zeroSizePtr(
       
  4074                         const_cast<TUint8*>( smallBuffer.Ptr() ),
       
  4075                         smallBuffer.Length(),
       
  4076                         smallBuffer.MaxLength() );
       
  4077 
       
  4078                     isOnMiscBuffer=tlv.NextItemL( pcoItem, zeroSizePtr );
       
  4079 
       
  4080                     if( KErrNone == isOnMiscBuffer )
       
  4081                         {
       
  4082                         // if pcscfAddress info exist
       
  4083                         pcscfAddress = ETrue;
       
  4084                         isOnMiscBuffer = KErrNotFound;
       
  4085                         tlv.ResetCursorPos();
       
  4086                         }
       
  4087                     // no else
       
  4088 
       
  4089                     ret = GpdsContextConfigureReq(
       
  4090                         transActionId, contextId, pdpType,
       
  4091                         contextType, primaryContextId,
       
  4092                         dataCompression, headerCompression,
       
  4093                         configGPRS.iAccessPointName,
       
  4094                         NULL, NULL, EFalse, pcscfAddress,
       
  4095                         dnsAddressRequested );
       
  4096                     }
       
  4097                 // no else
       
  4098                 }
       
  4099             // no else
       
  4100             }
       
  4101         else
       
  4102             {
       
  4103             ret = KErrNotReady;
       
  4104             }
       
  4105         }
       
  4106 
       
  4107     else if ( TPacketDataConfigBase::KConfigRel99Rel4 == config->ExtensionId()
       
  4108         || TPacketDataConfigBase::KConfigRel5 == config->ExtensionId() )
       
  4109         {
       
  4110         if ( GPDS_CID_VOID != contextId )
       
  4111             {
       
  4112             if ( TPacketDataConfigBase::KConfigRel5 == config->ExtensionId() )
       
  4113                 {
       
  4114 
       
  4115                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::SetConfig -> R5");
       
  4116 OstTrace0( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL -> R5" );
       
  4117                 }
       
  4118             else
       
  4119                 {
       
  4120 
       
  4121                 TFLOGSTRING("TSY: CMmPacketContextMessHandler::SetConfig -> R99");
       
  4122 OstTrace0( TRACE_NORMAL, DUP5_CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL -> R99" );
       
  4123                 }
       
  4124 
       
  4125             iContextList->SetContextConfigurationType(
       
  4126                 contextId, TPacketDataConfigBase::KConfigRel99Rel4 );
       
  4127 
       
  4128             RPacketContext::TContextConfigR99_R4& configR99_R4 =
       
  4129                 *reinterpret_cast<RPacketContext::TContextConfigR99_R4*>(
       
  4130                     config );
       
  4131 
       
  4132             // save authentication data
       
  4133             // No need to save REL5 type-> more complexity later as there is no
       
  4134             // own class for Rel5 Config.
       
  4135             ret = iContextList->SaveConfig( contextId,
       
  4136                 TPacketDataConfigBase::KConfigRel99Rel4,
       
  4137                 NULL,
       
  4138                 &configR99_R4 );
       
  4139 
       
  4140             TFLOGSTRING2("TSY: CMmPacketContextMessHandler::SetConfig iMiscBuffer:%S", &configR99_R4.iProtocolConfigOption.iMiscBuffer );
       
  4141 OstTraceExt1( TRACE_NORMAL, DUP6_CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL;iMiscBuffer=%s", configR99_R4.iProtocolConfigOption.iMiscBuffer );
       
  4142             TFLOGSTRING2("TSY: CMmPacketContextMessHandler::SetConfig iPrimaryDns:%S", &configR99_R4.iProtocolConfigOption.iDnsAddresses.iPrimaryDns );
       
  4143 OstTraceExt1( TRACE_NORMAL, DUP7_CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL;iPrimaryDns=%s", configR99_R4.iProtocolConfigOption.iDnsAddresses.iPrimaryDns );
       
  4144             TFLOGSTRING2("TSY: CMmPacketContextMessHandler::SetConfig iSecondaryDns:%S",&configR99_R4.iProtocolConfigOption.iDnsAddresses.iSecondaryDns );
       
  4145 OstTraceExt1( TRACE_NORMAL, DUP8_CMMPACKETCONTEXTMESSHANDLER_SETCONFIGL, "CMmPacketContextMessHandler::SetConfigL;iSecondaryDns=%s", configR99_R4.iProtocolConfigOption.iDnsAddresses.iSecondaryDns );
       
  4146 
       
  4147             // Config saved succesfully
       
  4148             if ( KErrNone == ret )
       
  4149                 {
       
  4150                 // Boolean for signalling info
       
  4151                 TBool signallingIndication( EFalse );
       
  4152                 TBool pcscfAddress( EFalse );
       
  4153                 TBool dnsAddress( EFalse );
       
  4154 
       
  4155                 // Map the client side Pdp type to Gpds server's pdp type
       
  4156                 TUint8 pdpType( 0 );
       
  4157                 ret = MapPdpType( pdpType, configR99_R4.iPdpType );
       
  4158 
       
  4159                 if ( KErrNone == ret )
       
  4160                     {
       
  4161                     TUint8 contextType( GPDS_CONT_TYPE_NORMAL );
       
  4162                     // primary or secondary context
       
  4163                     if( !configR99_R4.iNWIContext )
       
  4164                         {
       
  4165                         // MO initiated context
       
  4166                         contextType = iContextList->
       
  4167                             GetContextTypeByName( contextName );
       
  4168                         }
       
  4169                     else
       
  4170                         {
       
  4171                         // MT initiated context
       
  4172                         contextType = GPDS_CONT_TYPE_NWI;
       
  4173                         }
       
  4174 
       
  4175                     TInfoName hostCidName = iContextList->
       
  4176                         GetHostCidName( contextName );
       
  4177                     TUint8 primaryContextId( iContextList->
       
  4178                         GetContextIdByContextName( &hostCidName ) );
       
  4179                     TUint8 transActionId( iContextList->
       
  4180                         ProxyIdByContextName( contextName ) );
       
  4181 
       
  4182                     // if Rel5 is used, then use the iMiscBuffer to check
       
  4183                     // DNS Address are requested or not
       
  4184                     if ( TPacketDataConfigBase::KConfigRel5 ==
       
  4185                             config->ExtensionId() )
       
  4186                         {
       
  4187                         TInt isOnMiscBuffer( KErrNotFound );
       
  4188                         RPacketContext::TPcoId pcoItem(
       
  4189                             RPacketContext::EEtelPcktPCSCFAddressRequest );
       
  4190 
       
  4191                         TInt len( configR99_R4.iProtocolConfigOption.
       
  4192                             iMiscBuffer.Length() );
       
  4193                         TPtr8 ptrToTLVdata( configR99_R4.iProtocolConfigOption.
       
  4194                             iMiscBuffer.LeftTPtr(
       
  4195                                 configR99_R4.iProtocolConfigOption.iMiscBuffer.
       
  4196                                     MaxLength() ) );
       
  4197                         ptrToTLVdata.SetLength( configR99_R4.
       
  4198                             iProtocolConfigOption.iMiscBuffer.Length());
       
  4199 
       
  4200                         const TInt KBigEnoughBuf( 1 );
       
  4201                         TBuf8<KBigEnoughBuf> smallBuffer;
       
  4202                         smallBuffer.SetLength( KBigEnoughBuf );
       
  4203                         smallBuffer.FillZ();
       
  4204 
       
  4205                         TTlvStruct<RPacketContext::TPcoId,
       
  4206                             RPacketContext::TPcoItemDataLength>tlv(
       
  4207                                 ptrToTLVdata, KPtrToTLVdata );
       
  4208 
       
  4209                         TPtr8 zeroSizePtr(
       
  4210                             const_cast<TUint8*>( smallBuffer.Ptr() ),
       
  4211                             smallBuffer.Length(),
       
  4212                             smallBuffer.MaxLength() );
       
  4213 
       
  4214                         isOnMiscBuffer=tlv.NextItemL( pcoItem, zeroSizePtr );
       
  4215 
       
  4216                         if( KErrNone == isOnMiscBuffer )
       
  4217                             {
       
  4218                             // if pcscfAddress info exist
       
  4219                             pcscfAddress = ETrue;
       
  4220                             isOnMiscBuffer = KErrNotFound;
       
  4221                             tlv.ResetCursorPos();
       
  4222                             }
       
  4223                         // no else
       
  4224 
       
  4225                         pcoItem = RPacketContext::
       
  4226                             EEtelPcktIMCNMSSubsystemSignallingFlag;
       
  4227                         isOnMiscBuffer = tlv.NextItemL( pcoItem, zeroSizePtr );
       
  4228 
       
  4229                         if( KErrNone == isOnMiscBuffer )
       
  4230                             {
       
  4231                             // if PCSCF info indication exist.
       
  4232                             signallingIndication = ETrue;
       
  4233                             isOnMiscBuffer = KErrNotFound;
       
  4234                             tlv.ResetCursorPos();
       
  4235                             }
       
  4236                         // no else
       
  4237 
       
  4238                         pcoItem = RPacketContext::
       
  4239                             EEtelPcktDNSServerAddressRequest;
       
  4240                         isOnMiscBuffer = tlv.NextItemL( pcoItem, zeroSizePtr );
       
  4241 
       
  4242                         if( KErrNone == isOnMiscBuffer )
       
  4243                             {
       
  4244                             // if Dns request flag found
       
  4245                             dnsAddress = ETrue;
       
  4246                             isOnMiscBuffer = KErrNotFound;
       
  4247                             tlv.ResetCursorPos();
       
  4248                             }
       
  4249                         // no else
       
  4250                         }
       
  4251                     else
       
  4252                         // Rel99 in use.Request DNS addresses all the time
       
  4253                         {
       
  4254                         dnsAddress = ETrue;
       
  4255                         }
       
  4256 
       
  4257                     // Call GpdsContextConfigureReq
       
  4258                     ret = GpdsContextConfigureReq( transActionId,
       
  4259                         contextId, pdpType, contextType, primaryContextId,
       
  4260                         GPDS_PDP_HCOMP_DEFAULT, GPDS_PDP_HCOMP_DEFAULT,
       
  4261                         configR99_R4.iAccessPointName, NULL,NULL,
       
  4262                         signallingIndication, pcscfAddress, dnsAddress );
       
  4263                     }
       
  4264                 // no else
       
  4265                 }
       
  4266             // no else
       
  4267             }
       
  4268         else
       
  4269             {
       
  4270             ret = KErrNotReady;
       
  4271             }
       
  4272         }
       
  4273     // no else
       
  4274 
       
  4275     return ret;
       
  4276     }
       
  4277 
       
  4278 // -----------------------------------------------------------------------------
       
  4279 // CMmPacketContextMessHandler::AddPacketFilter
       
  4280 // Add TFT packet filter for context.
       
  4281 // -----------------------------------------------------------------------------
       
  4282 //
       
  4283 TInt CMmPacketContextMessHandler::AddPacketFilter(
       
  4284     const CMmDataPackage* aDataPackage )
       
  4285     {
       
  4286 
       
  4287     TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddPacketFilter" );
       
  4288 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_ADDPACKETFILTER, "CMmPacketContextMessHandler::AddPacketFilter" );
       
  4289 
       
  4290     // includes context configuration information
       
  4291     TInt contextConfigurationType;
       
  4292     RPacketContext::TContextConfigGPRS config;
       
  4293     CArrayFixFlat<RPacketContext::TPacketFilterV2>* filterTemporaryArray = NULL;
       
  4294     const CMmPacketDataPackage* data =
       
  4295         reinterpret_cast<const CMmPacketDataPackage*>( aDataPackage );
       
  4296 
       
  4297     #if (NCP_COMMON_S60_VERSION_SUPPORT==S60_VERSION_32)
       
  4298     data->GetConfigAndFilter( &config, contextConfigurationType );
       
  4299     #else
       
  4300     data->GetConfig( &config, contextConfigurationType );
       
  4301     #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  4302 
       
  4303     TInfoName* contextName;
       
  4304     data->UnPackData( &contextName, &filterTemporaryArray );
       
  4305 
       
  4306     TInt ret( KErrGeneral );
       
  4307     TUint8 pdpType( 0 );
       
  4308     TUint8 contextId(iContextList->GetContextIdByContextName( contextName ) );
       
  4309 
       
  4310     if( GPDS_CID_VOID != contextId && NULL != filterTemporaryArray )
       
  4311         {
       
  4312         iContextList->SetContextConfigurationType(
       
  4313             contextId, TPacketDataConfigBase::KConfigGPRS );
       
  4314         //save authentication data
       
  4315         ret = iContextList->SaveConfig(
       
  4316             contextId, TPacketDataConfigBase::KConfigGPRS, &config, NULL );
       
  4317 
       
  4318         TInfoName hostCidName = iContextList->
       
  4319             GetHostCidName( contextName );
       
  4320         TUint8 primaryContextId( iContextList->
       
  4321             GetContextIdByContextName( &hostCidName ) );
       
  4322         TUint8 contextType( GPDS_CONT_TYPE_NORMAL );
       
  4323 
       
  4324         // Primary Context found
       
  4325         if( GPDS_CID_VOID != primaryContextId )
       
  4326             {
       
  4327             contextType = GPDS_CONT_TYPE_SEC;
       
  4328             }
       
  4329 
       
  4330         MapPdpType( pdpType, config.iPdpType );
       
  4331 
       
  4332         TUint8 dataCompression( GPDS_PDP_DCOMP_OFF );
       
  4333         TUint8 headerCompression(GPDS_PDP_HCOMP_OFF );
       
  4334 
       
  4335         if ( TPacketDataConfigBase::KConfigRel99Rel4 !=
       
  4336             contextConfigurationType )
       
  4337             {
       
  4338             if ( config.iPdpCompression &
       
  4339                 RPacketContext::KPdpDataCompression )
       
  4340                 {
       
  4341                 dataCompression = GPDS_PDP_DCOMP_ON;
       
  4342                 }
       
  4343             // no else
       
  4344 
       
  4345             if ( config.iPdpCompression &
       
  4346                 RPacketContext::KPdpHeaderCompression )
       
  4347                 {
       
  4348                 headerCompression = GPDS_PDP_HCOMP_ON;
       
  4349                 }
       
  4350             // no else
       
  4351             }
       
  4352         else
       
  4353             {
       
  4354             dataCompression  = GPDS_PDP_DCOMP_DEFAULT;
       
  4355             headerCompression = GPDS_PDP_HCOMP_DEFAULT;
       
  4356             }
       
  4357 
       
  4358         TUint8 traId( GenerateTraId( contextId ) );
       
  4359 
       
  4360         ret = GpdsContextConfigureReq(
       
  4361             traId, contextId, pdpType, contextType,
       
  4362             primaryContextId, dataCompression, headerCompression,
       
  4363             config.iAccessPointName, filterTemporaryArray, NULL );
       
  4364         }
       
  4365     // no else
       
  4366 
       
  4367     return ret;
       
  4368     }
       
  4369 
       
  4370 // -----------------------------------------------------------------------------
       
  4371 // CMmPacketContextMessHandler::ActivatePhase2
       
  4372 // This function starts the second phase of the context activation.
       
  4373 // -----------------------------------------------------------------------------
       
  4374 //
       
  4375 void CMmPacketContextMessHandler::ActivatePhase2(
       
  4376     const TUint8 aPipeHandle,
       
  4377     const TUint8 aTransactionId )
       
  4378     {
       
  4379 
       
  4380     TFLOGSTRING("TSY: CMmPacketContextMessHandler::ActivatePhase2.");
       
  4381 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_ACTIVATEPHASE2, "CMmPacketContextMessHandler::ActivatePhase2" );
       
  4382 
       
  4383     TUint8 pdpType( 0 );
       
  4384     TInt ret( KErrNone );
       
  4385     TUint8 contextId( iContextList->
       
  4386         ContextIdByPipeHandle( aPipeHandle ) );
       
  4387     TInt configurationType( iContextList->
       
  4388         GetContextConfigurationType( contextId ) );
       
  4389 
       
  4390     TPacketDataConfigBase* configBase = NULL;
       
  4391     configBase = iContextList->
       
  4392         GetConfig( contextId, configurationType );
       
  4393 
       
  4394     if( NULL!= configBase )
       
  4395         {
       
  4396         if( TPacketDataConfigBase::KConfigGPRS == configurationType )
       
  4397             {
       
  4398             RPacketContext::TContextConfigGPRS* config = NULL;
       
  4399             config = reinterpret_cast<RPacketContext::TContextConfigGPRS*>(
       
  4400                 configBase );
       
  4401             MapPdpType( pdpType, config->iPdpType );
       
  4402             ret = GpdsContextActivateReq(
       
  4403                 aTransactionId, contextId, config->iPdpAddress, pdpType );
       
  4404             }
       
  4405         else if( TPacketDataConfigBase::KConfigRel99Rel4 == configurationType )
       
  4406             {
       
  4407             RPacketContext::TContextConfigR99_R4* config99 = NULL;
       
  4408             config99 = reinterpret_cast<RPacketContext::TContextConfigR99_R4*>(
       
  4409                 configBase );
       
  4410             MapPdpType( pdpType, config99->iPdpType );
       
  4411             ret = GpdsContextActivateReq(
       
  4412                 aTransactionId, contextId, config99->iPdpAddress, pdpType );
       
  4413             }
       
  4414         // no else
       
  4415 
       
  4416         if ( KErrNone != ret )
       
  4417             {
       
  4418 
       
  4419             TFLOGSTRING2("TSY: CMmPacketContextGsmWcdmaExt::ActivatePhase2. Error: %d", ret );
       
  4420 
       
  4421 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_ACTIVATEPHASE2, "CMmPacketContextMessHandler::ActivatePhase2;Error=%d", ret );
       
  4422             TInfoName contextname;
       
  4423             // Context name found
       
  4424             if( KErrNone == iContextList->
       
  4425                 GetContextNameByContextId( contextId, contextname ) )
       
  4426                 {
       
  4427                 CMmDataPackage data;
       
  4428                 // due succesfull case has Config in package
       
  4429                 TAny* ptr = NULL;
       
  4430                 data.PackData( &contextname, ptr );
       
  4431                 iMessageRouter->Complete(
       
  4432                     EPacketContextActivate,
       
  4433                     &data,
       
  4434                     ret );
       
  4435                 // Complete with KErrNone -> setLastErrorCause is NOT set then.
       
  4436                 iMessageRouter->Complete(
       
  4437                     EPacketContextNotifyConfigChanged,
       
  4438                     &data,
       
  4439                     ret );
       
  4440                 TUint8 transId( GenerateTraId( contextId ) );
       
  4441 
       
  4442                 // Reset the pipe
       
  4443                 ret = iMmPipeController->PnsPipeResetReq(
       
  4444                     transId, aPipeHandle, PN_PIPE_DISABLE );
       
  4445 
       
  4446                 if ( KErrNone == ret )
       
  4447                     {
       
  4448                     // Store the trans id
       
  4449                     iContextList->SetPipeResetTraId( contextId, transId );
       
  4450                     }
       
  4451                 else if( KErrNotFound == ret)
       
  4452                     {
       
  4453 
       
  4454                     TFLOGSTRING("TSY: CMmPacketContextMessHandler::ActivatePhase2. SetPipeResetTraId failed");
       
  4455 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_ACTIVATEPHASE2, "CMmPacketContextMessHandler::ActivatePhase2, SetPipeResetTraId failed" );
       
  4456                     }
       
  4457                 // no else
       
  4458                 }
       
  4459             // no else
       
  4460             }
       
  4461         // no else
       
  4462         }
       
  4463     // no else
       
  4464     }
       
  4465 
       
  4466 // -----------------------------------------------------------------------------
       
  4467 // CMmPacketContextMessHandler::MapPdpType
       
  4468 // This function maps the client pdp type to Gpds server pdp type.
       
  4469 // -----------------------------------------------------------------------------
       
  4470 //
       
  4471 TInt CMmPacketContextMessHandler::MapPdpType(
       
  4472     TUint8& aPdpTypeServer,
       
  4473     const RPacketContext::TProtocolType aPdpTypeClient )
       
  4474     {
       
  4475 
       
  4476     TFLOGSTRING("TSY: CMmPacketContextMessHandler::MapPdpType");
       
  4477 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_MAPPDPTYPE, "CMmPacketContextMessHandler::MapPdpType" );
       
  4478 
       
  4479     TInt ret( KErrNone );
       
  4480 
       
  4481     switch ( aPdpTypeClient )
       
  4482         {
       
  4483         case RPacketContext::EPdpTypeIPv4:
       
  4484             {
       
  4485             aPdpTypeServer = GPDS_PDP_TYPE_IPV4;
       
  4486             break;
       
  4487             }
       
  4488         case RPacketContext::EPdpTypeIPv6:
       
  4489             {
       
  4490             aPdpTypeServer = GPDS_PDP_TYPE_IPV6;
       
  4491             break;
       
  4492             }
       
  4493         case RPacketContext::EPdpTypePPP:
       
  4494         case RPacketContext::EPdpTypeX25:
       
  4495         case RPacketContext::EPdpTypeCDPD:
       
  4496             {
       
  4497             ret = KErrNotSupported;
       
  4498             break;
       
  4499             }
       
  4500         default:
       
  4501             {
       
  4502 
       
  4503             TFLOGSTRING("TSY: CMmPacketContextMessHandler::MapPdpType. Switch aPdpTypeClient case - default");
       
  4504 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_MAPPDPTYPE, "CMmPacketContextMessHandler::MapPdpType,Switch aPdpTypeClient case - default" );
       
  4505 
       
  4506             ret = KErrArgument;
       
  4507             break;
       
  4508             }
       
  4509         }
       
  4510     return ret;
       
  4511     }
       
  4512 
       
  4513 // -----------------------------------------------------------------------------
       
  4514 // CMmPacketContextMessHandler::MapConnectionSpeed
       
  4515 // Map the Gpds server connection speed to the client connection speed.
       
  4516 // -----------------------------------------------------------------------------
       
  4517 //
       
  4518 void CMmPacketContextMessHandler::MapConnectionSpeed(
       
  4519     const TUint8 aConnectionSpeedServer,
       
  4520     TInt& aConnectionSpeedClient )
       
  4521     {
       
  4522 
       
  4523     TFLOGSTRING("TSY: CMmPacketContextMessHandler::MapConnectionSpeed");
       
  4524 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_MAPCONNECTIONSPEED, "CMmPacketContextMessHandler::MapConnectionSpeed" );
       
  4525 
       
  4526     switch ( aConnectionSpeedServer )
       
  4527         {
       
  4528         // Connection speed rate varies between 0 and 2097152 bps
       
  4529         case GPDS_QOS_PETC_1:
       
  4530             {
       
  4531             aConnectionSpeedClient = KClientSpeeed8192;
       
  4532             break;
       
  4533             }
       
  4534         case GPDS_QOS_PETC_2:
       
  4535             {
       
  4536             aConnectionSpeedClient = KClientSpeeed16384;
       
  4537             break;
       
  4538             }
       
  4539         case GPDS_QOS_PETC_3:
       
  4540             {
       
  4541             aConnectionSpeedClient = KClientSpeeed32768;
       
  4542             break;
       
  4543             }
       
  4544         case GPDS_QOS_PETC_4:
       
  4545             {
       
  4546             aConnectionSpeedClient = KClientSpeeed65536;
       
  4547             break;
       
  4548             }
       
  4549         case GPDS_QOS_PETC_5:
       
  4550             {
       
  4551             aConnectionSpeedClient = KClientSpeeed131072;
       
  4552             break;
       
  4553             }
       
  4554         case GPDS_QOS_PETC_6:
       
  4555             {
       
  4556             aConnectionSpeedClient = KClientSpeeed262144;
       
  4557             break;
       
  4558             }
       
  4559         case GPDS_QOS_PETC_7:
       
  4560             {
       
  4561             aConnectionSpeedClient = KClientSpeeed524288;
       
  4562             break;
       
  4563             }
       
  4564         case GPDS_QOS_PETC_8:
       
  4565             {
       
  4566             aConnectionSpeedClient = KClientSpeeed1048576;
       
  4567             break;
       
  4568             }
       
  4569         case GPDS_QOS_PETC_9:
       
  4570             {
       
  4571             aConnectionSpeedClient = KClientSpeeed2097152;
       
  4572             break;
       
  4573             }
       
  4574         // case GPDS_QOS_PETC_0:
       
  4575         default:
       
  4576             {
       
  4577 
       
  4578             TFLOGSTRING("TSY: CMmPacketContextMessHandler::MapConnectionSpeed. Switch aConnectionSpeedServer case - default");
       
  4579 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_MAPCONNECTIONSPEED, "CMmPacketContextMessHandler::MapConnectionSpeed, Switch aConnectionSpeedServer case - default" );
       
  4580 
       
  4581             aConnectionSpeedClient = KClientSpeeed0;
       
  4582             break;
       
  4583             }
       
  4584         }
       
  4585 
       
  4586     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::SetConnectionSpeed. Connection Speed: %d bps", aConnectionSpeedClient );
       
  4587 
       
  4588 OstTrace1( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_MAPCONNECTIONSPEED, "CMmPacketContextMessHandler::MapConnectionSpeed;Connection Speed=%d bps", aConnectionSpeedClient );
       
  4589     }
       
  4590 
       
  4591 // -----------------------------------------------------------------------------
       
  4592 // CMmPacketContextMessHandler::GenerateTraId
       
  4593 // Generate transaction id for use of current context.
       
  4594 // -----------------------------------------------------------------------------
       
  4595 //
       
  4596 TUint8 CMmPacketContextMessHandler::GenerateTraId(
       
  4597     const TUint8 aContextId )
       
  4598     {
       
  4599 
       
  4600     TFLOGSTRING("TSY: CMmPacketContextMessHandler::GenerateTraId");
       
  4601 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_GENERATETRAID, "CMmPacketContextMessHandler::GenerateTraId" );
       
  4602 
       
  4603     TUint8 proxyId( iContextList->
       
  4604         ProxyIdByContextId( aContextId ) );
       
  4605 
       
  4606 #ifdef DUMMY_NIF_PEP_FOR_PACKET_DATA_TESTING_DOS
       
  4607     // due all contexts have same proxyId. DialUp context uses 0xFF
       
  4608     // because no proxyId found
       
  4609     TInt proxyInt( static_cast<TInt>( proxyId ) );
       
  4610     TInt contextIdInt( static_cast<TInt>( aContextId ) );
       
  4611     TInt tempInt( proxyInt - contextIdInt );
       
  4612     proxyId = static_cast<TUint8>( tempInt );
       
  4613 #endif // DUMMY_NIF_PEP_FOR_PACKET_DATA_TESTING_DOS
       
  4614 
       
  4615     return proxyId;
       
  4616     }
       
  4617 
       
  4618 // -----------------------------------------------------------------------------
       
  4619 // CMmPacketContextMessHandler::MapTftOperation
       
  4620 // Map the Client TFT operation to the Gpds server TFT operation.
       
  4621 // -----------------------------------------------------------------------------
       
  4622 //
       
  4623 void CMmPacketContextMessHandler::MapTftOperation(
       
  4624     const TInt aClientTypeOperation,
       
  4625     TUint8& aTftOperation )
       
  4626     {
       
  4627 
       
  4628     TFLOGSTRING("TSY: CMmPacketContextMessHandler::MapTftOperation");
       
  4629 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_MAPTFTOPERATION, "CMmPacketContextMessHandler::MapTftOperation" );
       
  4630 
       
  4631     switch( aClientTypeOperation )
       
  4632         {
       
  4633         case ETftCreateNew:
       
  4634             {
       
  4635             aTftOperation = GPDS_TFT_CREATE_NEW;
       
  4636             break;
       
  4637             }
       
  4638         case EDeleteExisting:
       
  4639             {
       
  4640             aTftOperation = GPDS_TFT_DELETE_EXISTING;
       
  4641             break;
       
  4642             }
       
  4643         case EAddPacketFilters:
       
  4644             {
       
  4645             aTftOperation = GPDS_TFT_ADD_PACKET_FILTERS;
       
  4646             break;
       
  4647             }
       
  4648         case EReplacePacketFilters:
       
  4649             {
       
  4650             aTftOperation = GPDS_TFT_REPLACE_PACKET_FILTERS;
       
  4651             break;
       
  4652             }
       
  4653         case EDeletePacketFilters:
       
  4654             {
       
  4655             aTftOperation = GPDS_TFT_DELETE_PACKET_FILTERS;
       
  4656             break;
       
  4657             }
       
  4658         case ETftNoOperation:
       
  4659             {
       
  4660             aTftOperation = GPDS_TFT_NO_OPERATION;
       
  4661             break;
       
  4662             }
       
  4663         default:
       
  4664             {
       
  4665 
       
  4666             TFLOGSTRING("TSY: CMmPacketContextMessHandler::MapTftOperation. Switch aClientTypeOperation case - default");
       
  4667 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_MAPTFTOPERATION, "CMmPacketContextMessHandler::MapTftOperation,Switch aClientTypeOperation case - default" );
       
  4668 
       
  4669             aTftOperation = GPDS_TFT_DELETE_EXISTING;
       
  4670             break;
       
  4671             }
       
  4672         }
       
  4673     }
       
  4674 
       
  4675 // -----------------------------------------------------------------------------
       
  4676 // CMmPacketContextMessHandler::AddMediaAuthorizationL
       
  4677 // Create an Isi-message for requesting media authorization params.
       
  4678 // -----------------------------------------------------------------------------
       
  4679 //
       
  4680 TInt CMmPacketContextMessHandler::AddMediaAuthorizationL(
       
  4681     const CMmDataPackage* aDataPackage )
       
  4682     {
       
  4683 
       
  4684     TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddMediaAuthorizationL.");
       
  4685 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_ADDMEDIAAUTHORIZATIONL, "CMmPacketContextMessHandler::AddMediaAuthorizationL" );
       
  4686 
       
  4687     const CMmPacketDataPackage* data =
       
  4688         reinterpret_cast<const CMmPacketDataPackage*>( aDataPackage );
       
  4689 
       
  4690     TInt ret( KErrGeneral );
       
  4691 
       
  4692     //Initialise params
       
  4693     TInt contextConfigurationType;
       
  4694     TUint8 pdpType( 0 );
       
  4695     RPacketContext::TContextConfigGPRS config;
       
  4696     RPacketContext::CTFTMediaAuthorizationV3* mediaAuthorization = NULL;
       
  4697     TInfoName* contextName = NULL;
       
  4698 
       
  4699     #if (NCP_COMMON_S60_VERSION_SUPPORT==S60_VERSION_32)
       
  4700     data->GetConfigAndFilter( &config, contextConfigurationType );
       
  4701     #else
       
  4702     data->GetConfig( &config, contextConfigurationType );
       
  4703     #endif // NCP_COMMON_S60_VERSION_SUPPORT
       
  4704 
       
  4705     //Unpack data
       
  4706     data->UnPackData( &contextName, &mediaAuthorization );
       
  4707 
       
  4708     //Get necessary params
       
  4709     TUint8 contextId( iContextList->
       
  4710         GetContextIdByContextName( contextName ) );
       
  4711 
       
  4712     TInfoName hostCidName = iContextList->GetHostCidName( contextName );
       
  4713 
       
  4714     TUint8 primaryContextId( iContextList->
       
  4715         GetContextIdByContextName( &hostCidName ) );
       
  4716 
       
  4717     TUint8 contextType( GPDS_CONT_TYPE_NORMAL );
       
  4718 
       
  4719     // Primary Context found
       
  4720     if( GPDS_CID_VOID != primaryContextId )
       
  4721         {
       
  4722         contextType = GPDS_CONT_TYPE_SEC;
       
  4723         }
       
  4724     // no else
       
  4725 
       
  4726     MapPdpType( pdpType, config.iPdpType );
       
  4727     TUint8 traId( GenerateTraId( contextId ) );
       
  4728 
       
  4729     ret = GpdsContextConfigureReq(
       
  4730         traId, contextId, pdpType, contextType,
       
  4731         primaryContextId, GPDS_PDP_HCOMP_DEFAULT,
       
  4732         GPDS_PDP_HCOMP_DEFAULT, config.iAccessPointName,
       
  4733         NULL, mediaAuthorization );
       
  4734 
       
  4735     return ret;
       
  4736     }
       
  4737 
       
  4738 // -----------------------------------------------------------------------------
       
  4739 // CMmPacketContextMessHandler::AddMediaAuthorizationInfo
       
  4740 // Create subblocks to GpdsContextConfigureOrModifyReq.
       
  4741 // -----------------------------------------------------------------------------
       
  4742 //
       
  4743 TInt CMmPacketContextMessHandler::AddMediaAuthorizationInfo(
       
  4744     CArrayFixFlat<RPacketContext::CTFTMediaAuthorizationV3>*
       
  4745         aMediaAuthorizationArray,
       
  4746     TDes8& aBuffer,
       
  4747     TUint8& aNumOfSbs ) const
       
  4748     {
       
  4749     // Initialise variables
       
  4750     TInt count( aMediaAuthorizationArray->Count() );
       
  4751     TInt ret( 0 == count && aMediaAuthorizationArray ?
       
  4752         KErrNone : KErrGeneral );
       
  4753     TInt arrayIndex( 0 );
       
  4754 
       
  4755     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::AddMediaAuthorizationInfo. aMediaAuthorizationArray count: %d", count);
       
  4756 OstTrace1( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_ADDMEDIAAUTHORIZATIONINFO, "CMmPacketContextMessHandler::AddMediaAuthorizationInfo;aMediaAuthorizationArray count=%d", count );
       
  4757 
       
  4758     while ( KErrNone == ret && count > 0 )
       
  4759         {
       
  4760         ret = AppendMediaAuthorizationUnit(
       
  4761                             aMediaAuthorizationArray->At( arrayIndex ),
       
  4762                             aBuffer, aNumOfSbs );
       
  4763         count--;
       
  4764         arrayIndex++;
       
  4765         }
       
  4766 
       
  4767     return ret;
       
  4768     }
       
  4769 
       
  4770 // -----------------------------------------------------------------------------
       
  4771 // CMmPacketContextMessHandler::AppendMediaAuthorizationUnit
       
  4772 // Create subblocks for one message authorization unit.
       
  4773 // -----------------------------------------------------------------------------
       
  4774 //
       
  4775 TInt CMmPacketContextMessHandler::AppendMediaAuthorizationUnit(
       
  4776     const RPacketContext::CTFTMediaAuthorizationV3& aMediaAuthorization,
       
  4777     TDes8& aBuffer,
       
  4778     TUint8& aNumOfSbs ) const
       
  4779     {
       
  4780 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendMediaAuthorizationUnit");
       
  4781 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDMEDIAAUTHORIZATIONUNIT, "CMmPacketContextMessHandler::AppendMediaAuthorizationUnit" );
       
  4782     //Add GPDS_SHARED_TFT_PARAMETER_AUTH_TOKEN_INFO sub block
       
  4783     TInt ret = AppendGpdsSharedTFTParameterAuthTokenInfo(
       
  4784             aMediaAuthorization.iAuthorizationToken, aBuffer, aNumOfSbs );
       
  4785 
       
  4786     //GPDS_SHARED_TFT_PARAMETER_IP_FLOW_INFO sub block
       
  4787     if ( KErrNone == ret )
       
  4788         {
       
  4789         ret = AppendGpdsSharedTFTParameterIPFlowInfo(
       
  4790                 aMediaAuthorization.iFlowIds[0], aBuffer, aNumOfSbs );
       
  4791         }
       
  4792 
       
  4793     // GPDS_SHARED_TFT_PARAMETER_AUTH_TOKEN_INFO (= 0xF1)
       
  4794     // Make sub block for (2 and 3)
       
  4795     if ( KErrNone == ret )
       
  4796         {
       
  4797 TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddMediaAuthorizationUnit. Make sub block for (2 and 3)");
       
  4798 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_APPENDMEDIAAUTHORIZATIONUNIT, "CMmPacketContextMessHandler::AppendMediaAuthorizationUnit, Make sub block for (2 and 3)" );
       
  4799         ret = AppendGpdsSharedTFTParameterAuthTokenInfo(
       
  4800                 aMediaAuthorization.iAuthorizationToken, aBuffer, aNumOfSbs );
       
  4801         }
       
  4802     // GPDS_SHARED_TFT_PARAMETER_IP_FLOW_INFO (2 and 3)
       
  4803     // make sure that there is more than one class in Array
       
  4804     TInt flowIdsArrayCount( aMediaAuthorization.iFlowIds.Count() );
       
  4805     if ( KErrNone == ret && KGdpsSharedTftParamIPFlowInfo2 <= flowIdsArrayCount )
       
  4806         {
       
  4807 TFLOGSTRING("TSY: CMmPacketContextMessHandler::AddMediaAuthorizationUnit. make sure that there is more than one class in Array");
       
  4808 OstTrace0( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_APPENDMEDIAAUTHORIZATIONUNIT, "CMmPacketContextMessHandler::AppendMediaAuthorizationUnit, Make sure that there is more than one class in Array" );
       
  4809         for (TInt flowIdsArrayIndex = KFlowIdsArrayIndex1;
       
  4810              flowIdsArrayIndex < flowIdsArrayCount && KErrNone == ret;
       
  4811              flowIdsArrayIndex++)
       
  4812             {
       
  4813             ret = AppendGpdsSharedTFTParameterIPFlowInfo(
       
  4814                     aMediaAuthorization.iFlowIds[flowIdsArrayIndex],
       
  4815                     aBuffer, aNumOfSbs );
       
  4816             }
       
  4817         }
       
  4818 TFLOGSTRING2("TSY:CMmPacketContextMessHandler::AppendMediaAuthorizationUnit;ret=%d", ret);
       
  4819 OstTrace1( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_APPENDMEDIAAUTHORIZATIONUNIT, "CMmPacketContextMessHandler::AppendMediaAuthorizationUnit;ret=%d", ret );
       
  4820     return ret;
       
  4821     }
       
  4822 
       
  4823 // -----------------------------------------------------------------------------
       
  4824 // CMmPacketContextMessHandler::AllowIncomingCallActivationL
       
  4825 // This methods checks if secondary contexts needs to be deactivated
       
  4826 // and allows incoming call (for allow incoming call feature).
       
  4827 // (other items were commented in a header).
       
  4828 // -----------------------------------------------------------------------------
       
  4829 //
       
  4830 void CMmPacketContextMessHandler::AllowIncomingCallActivationL()
       
  4831     {
       
  4832 TFLOGSTRING("TSY: CMmPacketContextMessHandler::AllowIncomingCallActivationL");
       
  4833 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_ALLOWINCOMINGCALLACTIVATIONL, "CMmPacketContextMessHandler::AllowIncomingCallActivationL" );
       
  4834 
       
  4835     if ( CALL_MODEM_ID_NONE != iCallModemResourceCallId &&
       
  4836         NULL == iDeactivateContextList )
       
  4837         {
       
  4838         TUint8 contextId( GPDS_CID_VOID );
       
  4839         TInt contextCount( iContextList->NumberOfContexts() );
       
  4840 
       
  4841         // initialize context list
       
  4842         iDeactivateContextList = new (ELeave) CArrayFixFlat<TUint8>(
       
  4843             KMmMaxNumberOfContexts );
       
  4844         iDeactivateContextList->Reset();
       
  4845 
       
  4846         TFLOGSTRING("TSY: CMmPacketContextMessHandler::AllowIncomingCallActivationL, Find secondary context");
       
  4847 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_ALLOWINCOMINGCALLACTIVATIONL, "CMmPacketContextMessHandler::AllowIncomingCallActivationL, Find secondary context" );
       
  4848         // check if there is contexts created
       
  4849         if ( 1 < contextCount )
       
  4850             {
       
  4851             // check if there is active secondary context
       
  4852             for ( TInt i = 0; i < contextCount; i++ )
       
  4853                 {
       
  4854                 contextId = iContextList->ContextIdByListIndex( i );
       
  4855 
       
  4856                 if ( ( GPDS_CID_VOID != contextId ) &&
       
  4857                      ( GPDS_CONT_TYPE_SEC == iContextList->
       
  4858                          GetContextTypeById( contextId ) ) &&
       
  4859                      ( PN_PIPE_ENABLE == iContextList->
       
  4860                          GetPipeStatus( contextId ) ))
       
  4861                     {
       
  4862 
       
  4863                     TFLOGSTRING2("TSY: CMmPacketContextMessHandler::AllowIncomingCallActivationL, Secondary context found, List index: %d", i );
       
  4864 OstTrace1( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_ALLOWINCOMINGCALLACTIVATIONL, "CMmPacketContextMessHandler::AllowIncomingCallActivationL;, Secondary context found, List index=%d", i );
       
  4865                     // secondary context found
       
  4866                     iDeactivateContextList->AppendL( contextId );
       
  4867                     // break the loop
       
  4868                     i = contextCount;
       
  4869                     }
       
  4870                 //no else
       
  4871                 }
       
  4872             }
       
  4873             //no else
       
  4874 
       
  4875         // check if there is active secondary dial-up context
       
  4876         TInfoName contextName( KStringExternal2 );
       
  4877         contextId = iContextList->GetDialUpContextIdByName( &contextName );
       
  4878         if ( GPDS_CID_VOID != contextId )
       
  4879             {
       
  4880 
       
  4881             TFLOGSTRING("TSY: CMmPacketContextMessHandler::AllowIncomingCallActivationL, Secondary dial-up context found");
       
  4882 OstTrace0( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_ALLOWINCOMINGCALLACTIVATIONL, "CMmPacketContextMessHandler::AllowIncomingCallActivationL, Secondary dial-up context found" );
       
  4883             // secondary context found
       
  4884             iDeactivateContextList->AppendL( contextId );
       
  4885             }
       
  4886         //no else
       
  4887         }
       
  4888     //no else
       
  4889 
       
  4890     if ( iDeactivateContextList &&
       
  4891         CALL_MODEM_ID_NONE != iCallModemResourceCallId )
       
  4892         {
       
  4893         // if secondary context found => request deactivation
       
  4894         if ( 0 < iDeactivateContextList->Count() )
       
  4895             {
       
  4896             TUint8 transactionId(
       
  4897                 GenerateTraId( iDeactivateContextList->At( 0 ) ) );
       
  4898 
       
  4899             TFLOGSTRING2("TSY: CMmPacketContextMessHandler::AllowIncomingCallActivationL, Deactivating context, ContextId: %d", iDeactivateContextList->At( 0 ) );
       
  4900 
       
  4901 OstTrace1( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_ALLOWINCOMINGCALLACTIVATIONL, "CMmPacketContextMessHandler::AllowIncomingCallActivationL;ContextId=%d", iDeactivateContextList->At( 0 ) );
       
  4902             // Set the message data that consists of one parameter
       
  4903             TBuf8<1> messageData;
       
  4904             // deactivate first context from the list
       
  4905             messageData.Append( iDeactivateContextList->At( 0 ) );
       
  4906 
       
  4907             // Send Isi message via Phonet
       
  4908             TInt ret ( iPhoNetSender->Send(
       
  4909                 PN_GPDS, transactionId,
       
  4910                 GPDS_CONTEXT_DEACTIVATE_REQ, messageData ) );
       
  4911             if ( KErrNone != ret )
       
  4912                 {
       
  4913                 // couldn't send message, can't allow call activation
       
  4914                 iCallModemResourceCallId = CALL_MODEM_ID_NONE;
       
  4915                 iDeactivateContextList->Reset();
       
  4916                 delete iDeactivateContextList;
       
  4917                 iDeactivateContextList = NULL;
       
  4918                 CallModemResourceReqDenied();
       
  4919                 }
       
  4920             //no else
       
  4921             }
       
  4922         else // no secondary contexts found => allow incoming call
       
  4923             {
       
  4924             CallModemResourceReqAllowed();
       
  4925             iCallModemResourceCallId = CALL_MODEM_ID_NONE;
       
  4926             iDeactivateContextList->Reset();
       
  4927             delete iDeactivateContextList;
       
  4928             iDeactivateContextList = NULL;
       
  4929             }
       
  4930         }
       
  4931     //no else
       
  4932     }
       
  4933 
       
  4934 // -----------------------------------------------------------------------------
       
  4935 // CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterAuthTokenInfo
       
  4936 // Adds GPDS_SHARED_TFT_PARAMETER_AUTH_TOKEN_INFO to the buffer and increases
       
  4937 // aNumOfSbs by 1
       
  4938 // -----------------------------------------------------------------------------
       
  4939 //
       
  4940 TInt CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterAuthTokenInfo(
       
  4941         const TDesC8& aAuthorizationToken,
       
  4942         TDes8& aBuffer,
       
  4943         TUint8& aNumOfSbs ) const
       
  4944     {
       
  4945 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterAuthTokenInfo");
       
  4946 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSSHAREDTFTPARAMETERAUTHTOKENINFO, "CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterAuthTokenInfo" );
       
  4947     TInt ret( KErrTooBig );
       
  4948     TInt authTokenLength( aAuthorizationToken.Length() );
       
  4949 
       
  4950     if ( authTokenLength < ( KMaximumLengthOfGpdsTftAuthTokenInfo -
       
  4951             KAuthTokenInfoChecking ) )
       
  4952         {
       
  4953 TFLOGSTRING("TSY: CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterAuthTokenInfo. Add GPDS_SHARED_TFT_PARAMETER_AUTH_TOKEN_INFO sub block");
       
  4954 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSSHAREDTFTPARAMETERAUTHTOKENINFO, "CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterAuthTokenInfo, Add GPDS_SHARED_TFT_PARAMETER_AUTH_TOKEN_INFO sub block" );
       
  4955         ret = KErrNone;
       
  4956         TBuf<RPacketContext::KMaxFQDNLength> tempAuthorizationTokenInfo;
       
  4957         tempAuthorizationTokenInfo.Copy( aAuthorizationToken );
       
  4958         TBuf8<KMaximumLengthOfGpdsTftAuthTokenInfo>
       
  4959              authorizationTokenInfo;
       
  4960         TIsiSubBlock authTokenSubBlock(
       
  4961             authorizationTokenInfo,
       
  4962             GPDS_SHARED_TFT_PARAMETER_AUTH_TOKEN_INFO,
       
  4963             EIsiSubBlockTypeId8Len8 );
       
  4964 
       
  4965         authorizationTokenInfo.Append(
       
  4966             static_cast<TUint8>( authTokenLength ) );
       
  4967         authorizationTokenInfo.Append( KGpdsPadding );
       
  4968         authorizationTokenInfo.Append( tempAuthorizationTokenInfo );
       
  4969         // add subblock
       
  4970         aBuffer.Append( authTokenSubBlock.CompleteSubBlock() );
       
  4971         // increase subblock count
       
  4972         aNumOfSbs++;
       
  4973         }
       
  4974 TFLOGSTRING2("TSY:CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterAuthTokenInfo;ret=%d", ret);
       
  4975 OstTrace1( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSSHAREDTFTPARAMETERAUTHTOKENINFO, "CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterAuthTokenInfo;ret=%d", ret );
       
  4976     return ret;
       
  4977     }
       
  4978 
       
  4979 // -----------------------------------------------------------------------------
       
  4980 // CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterIPFlowInfo
       
  4981 // Adds GPDS_SHARED_TFT_PARAMETER_IP_FLOW_INFO to the buffer and increases
       
  4982 // aNumOfSbs by 1
       
  4983 // -----------------------------------------------------------------------------
       
  4984 //
       
  4985 TInt CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterIPFlowInfo(
       
  4986         const RPacketContext::CTFTMediaAuthorizationV3::TFlowIdentifier&
       
  4987         aFlowIdentifier,
       
  4988         TDes8& aBuffer,
       
  4989         TUint8& aNumOfSbs ) const
       
  4990     {
       
  4991 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterIPFlowInfo");
       
  4992 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSSHAREDTFTPARAMETERIPFLOWINFO, "CMmPacketContextMessHandler::AppendGpdsSharedTFTParameterIPFlowInfo" );
       
  4993     TBuf8<SIZE_GPDS_SHARED_TFT_PARAMETER_IP_FLOW_INFO> tempIPFlowInfo;
       
  4994     TIsiSubBlock ipFlowInfoSubBlock( tempIPFlowInfo,
       
  4995         GPDS_SHARED_TFT_PARAMETER_IP_FLOW_INFO,
       
  4996         EIsiSubBlockTypeId8Len8 );
       
  4997 
       
  4998     TUint16 mediaComponentNumber( aFlowIdentifier.iMediaComponentNumber );
       
  4999     TUint16 ipFlowNumber( aFlowIdentifier.iIPFlowNumber );
       
  5000 
       
  5001     tempIPFlowInfo.Append( KGpdsPadding );
       
  5002     tempIPFlowInfo.Append( KGpdsPadding );
       
  5003     tempIPFlowInfo.Append( static_cast<TUint8>( mediaComponentNumber )
       
  5004             << KShift8Bits );
       
  5005     tempIPFlowInfo.Append( static_cast<TUint8>( mediaComponentNumber ) );
       
  5006     tempIPFlowInfo.Append( static_cast<TUint8>( ipFlowNumber )
       
  5007             << KShift8Bits );
       
  5008     tempIPFlowInfo.Append( static_cast<TUint8>( ipFlowNumber ) );
       
  5009 
       
  5010     // add subblock
       
  5011     TDes8& completed( ipFlowInfoSubBlock.CompleteSubBlock() );
       
  5012     aBuffer.Append( ipFlowInfoSubBlock.CompleteSubBlock() );
       
  5013     // increase subblock count
       
  5014     aNumOfSbs++;
       
  5015 
       
  5016     return KErrNone; // we dont want to mask the panic since this is coding error
       
  5017     }
       
  5018 
       
  5019 // -----------------------------------------------------------------------------
       
  5020 // CMmPacketContextMessHandler::FillGpdsTFTInfo
       
  5021 // Adds GPDS_TFT_INFO to the buffer
       
  5022 // -----------------------------------------------------------------------------
       
  5023 //
       
  5024 TInt CMmPacketContextMessHandler::FillGpdsTFTInfo(TUint8 aOperation,
       
  5025         RPacketContext::CTFTMediaAuthorizationV3* aMediaAuthorization,
       
  5026         CArrayFixFlat<RPacketContext::TPacketFilterV2>* aPacketFilterPtr,
       
  5027         TUint8 aPdpType,
       
  5028         TDes8& aBuffer ) const
       
  5029     {
       
  5030 TFLOGSTRING("TSY:CMmPacketContextMessHandler::FillGpdsTFTInfo");
       
  5031 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_FILLGPDSTFTINFO, "CMmPacketContextMessHandler::FillGpdsTFTInfo" );
       
  5032     TInt ret( KErrNone );
       
  5033     TUint8 numOfSbsInsideSb( 0 );
       
  5034 
       
  5035     // setting desired operation
       
  5036     aBuffer.Append( aOperation );
       
  5037 
       
  5038     // Add subblocks to GPDS_TFT_INFO subblock
       
  5039     // GPDS_SHARED_TFT_PARAMETER_AUTH_TOKEN_INFO
       
  5040     // and GPDS_SHARED_TFT_PARAMETER_IP_FLOW_INFO of GPDS_TFT_INFO
       
  5041     if ( aMediaAuthorization )
       
  5042         {
       
  5043 TFLOGSTRING("TSY: CMmPacketContextMessHandler::AppendGpdsTFTInfo. MediaAuthorization");
       
  5044 OstTrace0( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_FILLGPDSTFTINFO, "CMmPacketContextMessHandler::FillGpdsTFTInfo, MediaAuthorization" );
       
  5045          ret = AppendMediaAuthorizationUnit( *aMediaAuthorization, aBuffer,
       
  5046                                              numOfSbsInsideSb );
       
  5047         }
       
  5048     // end for sub blocks GPDS_SHARED_TFT_PARAMETER_AUTH_TOKEN_INFO
       
  5049     // and GPDS_SHARED_TFT_PARAMETER_IP_FLOW_INFO of GPDS_TFT_INFO
       
  5050 
       
  5051     // If there is one or more PacketFilters
       
  5052     // GPDS_TFT_FILTER_INFO of GPDS_TFT_INFO
       
  5053     if ( KErrNone == ret && aPacketFilterPtr )
       
  5054         {
       
  5055         // Initialize variable which indicates current filter
       
  5056         TUint8 filterIndex( 0 );
       
  5057         // Initialize variable which indicates the length of this subblock.
       
  5058         TUint16 lengthOfGpdsTftInfoSubBlock( 0 );
       
  5059 
       
  5060         // Copy all given PacketFilters to GPDS_TFT_INFO
       
  5061         // There can be from 1 to 8 PacketFilters
       
  5062         while ( filterIndex < aPacketFilterPtr->Count() )
       
  5063             {
       
  5064             // Counting the total length of PacketFilters
       
  5065             lengthOfGpdsTftInfoSubBlock =
       
  5066                 lengthOfGpdsTftInfoSubBlock +
       
  5067                     AddPacketFilterInfo(
       
  5068                         aPdpType,
       
  5069                         &( aPacketFilterPtr->At( filterIndex ) ),
       
  5070                         aBuffer );
       
  5071 
       
  5072            // If the maximum length of GPDS_TFT_INFO is exceeded, return value
       
  5073            // is set to KErrTooBig
       
  5074             if ( lengthOfGpdsTftInfoSubBlock > KMaximumLengthOfGpdsTftInfo )
       
  5075                 {
       
  5076                 ret = KErrTooBig;
       
  5077                 filterIndex = static_cast<TUint8>( aPacketFilterPtr->Count() );
       
  5078                 }
       
  5079             // no else
       
  5080 
       
  5081             // increase subblock count
       
  5082             numOfSbsInsideSb++;
       
  5083             // Increasing filterIndex by one, pointing to
       
  5084             // the next PacketFilter item
       
  5085             filterIndex++;
       
  5086             }
       
  5087         }
       
  5088         // no else
       
  5089 
       
  5090     // Complete GPDS_TFT_INFO subblock and set subblock count
       
  5091     TBuf8<1> sbCountbuf;
       
  5092     sbCountbuf.Append( numOfSbsInsideSb );
       
  5093     aBuffer.Insert( GPDS_TFT_INFO_OFFSET_NUMBEROFSUBBLOCKS, sbCountbuf );
       
  5094 TFLOGSTRING2("TSY:CMmPacketContextMessHandler::FillGpdsTFTInfo;ret=%d", ret);
       
  5095 OstTrace1( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_FILLGPDSTFTINFO, "CMmPacketContextMessHandler::FillGpdsTFTInfo;ret=%d", ret );
       
  5096     return ret;
       
  5097     }
       
  5098 
       
  5099 // -----------------------------------------------------------------------------
       
  5100 // CMmPacketContextMessHandler::FillGpdsQos99ReqInfo
       
  5101 // Fills in GPDS_QOS99_REQ_INFO to the buffer
       
  5102 // -----------------------------------------------------------------------------
       
  5103 //
       
  5104 TInt CMmPacketContextMessHandler::FillGpdsQos99ReqInfo(
       
  5105         const RPacketQoS::TQoSR99_R4Requested& aQos99Params,
       
  5106         TDes8& aBuffer)
       
  5107     {
       
  5108 TFLOGSTRING("TSY:CMmPacketContextMessHandler::FillGpdsQos99ReqInfo");
       
  5109 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_FILLGPDSQOS99REQINFO, "CMmPacketContextMessHandler::FillGpdsQos99ReqInfo" );
       
  5110     TInt ret( KErrNone );
       
  5111     CMmPacketQoSMessHandler::TQoS99Info qoS99ReqInfoServer;
       
  5112 
       
  5113     // Map classified QoS R99 requested parameter values to server
       
  5114     // side struct
       
  5115     ret = iMmPacketQoSMessHandler->MapQoS99InfoToServer(
       
  5116         qoS99ReqInfoServer,
       
  5117         aQos99Params.iReqTrafficClass,
       
  5118         aQos99Params.iReqDeliveryOrderReqd,
       
  5119         aQos99Params.iReqDeliverErroneousSDU,
       
  5120         aQos99Params.iReqBER,
       
  5121         aQos99Params.iReqSDUErrorRatio,
       
  5122         aQos99Params.iReqTrafficHandlingPriority );
       
  5123 
       
  5124     // Copy numerical QoS R99 requested parameter values to server
       
  5125     // side struct
       
  5126     if ( KErrNone == ret )
       
  5127         {
       
  5128         ret = iMmPacketQoSMessHandler->CopyQoS99ValuesToServer(
       
  5129             qoS99ReqInfoServer,
       
  5130             aQos99Params.iReqTransferDelay,
       
  5131             aQos99Params.iReqMaxSDUSize,
       
  5132             aQos99Params.iReqMaxRate,
       
  5133             aQos99Params.iReqGuaranteedRate );
       
  5134         }
       
  5135     // no else
       
  5136 
       
  5137     if ( KErrNone == ret )
       
  5138         {
       
  5139         aBuffer.Append( qoS99ReqInfoServer.iTrafficClass );
       
  5140         aBuffer.Append( qoS99ReqInfoServer.iDeliveryOrderReqd );
       
  5141         aBuffer.Append( qoS99ReqInfoServer.iDeliverErroneousSDU );
       
  5142         aBuffer.Append( qoS99ReqInfoServer.iBER );
       
  5143         aBuffer.Append( qoS99ReqInfoServer.iSDUErrorRatio );
       
  5144         aBuffer.Append( qoS99ReqInfoServer.iTrafficHandlingPriority );
       
  5145 
       
  5146         aBuffer.Append( static_cast<TUint8>(
       
  5147             qoS99ReqInfoServer.iTransferDelay >> KShift8Bits ) );
       
  5148         aBuffer.Append( static_cast<TUint8>(
       
  5149             qoS99ReqInfoServer.iTransferDelay ) );
       
  5150 
       
  5151         aBuffer.Append( static_cast<TUint8>(
       
  5152             qoS99ReqInfoServer.iMaxSDUSize >> KShift8Bits ) );
       
  5153         aBuffer.Append( static_cast<TUint8>(
       
  5154             qoS99ReqInfoServer.iMaxSDUSize ) );
       
  5155 
       
  5156         aBuffer.Append( static_cast<TUint8>(
       
  5157             qoS99ReqInfoServer.iMaxUplinkRate >> KShift8Bits ) );
       
  5158         aBuffer.Append( static_cast<TUint8>(
       
  5159             qoS99ReqInfoServer.iMaxUplinkRate ) );
       
  5160 
       
  5161         aBuffer.Append( static_cast<TUint8>(
       
  5162             qoS99ReqInfoServer.iMaxDownlinkRate >> KShift8Bits ) );
       
  5163         aBuffer.Append( static_cast<TUint8>(
       
  5164             qoS99ReqInfoServer.iMaxDownlinkRate ) );
       
  5165 
       
  5166         aBuffer.Append( static_cast<TUint8>(
       
  5167             qoS99ReqInfoServer.iGuaranteedUplinkRate >> KShift8Bits ) );
       
  5168         aBuffer.Append( static_cast<TUint8>(
       
  5169             qoS99ReqInfoServer.iGuaranteedUplinkRate ) );
       
  5170 
       
  5171         aBuffer.Append( static_cast<TUint8>(
       
  5172             qoS99ReqInfoServer.iGuaranteedDownlinkRate >> KShift8Bits ) );
       
  5173         aBuffer.Append( static_cast<TUint8>(
       
  5174             qoS99ReqInfoServer.iGuaranteedDownlinkRate ) );
       
  5175         }
       
  5176 TFLOGSTRING2("TSY:CMmPacketContextMessHandler::FillGpdsQos99ReqInfo;ret=%d", ret);
       
  5177 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_FILLGPDSQOS99REQINFO, "CMmPacketContextMessHandler::FillGpdsQos99ReqInfo;ret=%d", ret );
       
  5178     return ret;
       
  5179     }
       
  5180 
       
  5181 // -----------------------------------------------------------------------------
       
  5182 // CMmPacketContextMessHandler::FillGpdsQosReqInfo
       
  5183 // Adds GPDS_QOS_REQ_INFO to the buffer
       
  5184 // -----------------------------------------------------------------------------
       
  5185 //
       
  5186 TInt CMmPacketContextMessHandler::FillGpdsQosReqInfo(
       
  5187         const RPacketQoS::TQoSGPRSRequested& aQos97Params,
       
  5188         TDes8& aBuffer )
       
  5189     {
       
  5190 TFLOGSTRING("TSY:CMmPacketContextMessHandler::FillGpdsQosReqInfo");
       
  5191 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_FILLGPDSQOSREQINFO, "CMmPacketContextMessHandler::FillGpdsQosReqInfo" );
       
  5192     TInt ret( KErrNone );
       
  5193 
       
  5194     // Map QoS R97/98 requested parameter values to server
       
  5195     // side struct
       
  5196     CMmPacketQoSMessHandler::TQoSInfo qosInfo;
       
  5197 
       
  5198     ret = iMmPacketQoSMessHandler->MapQoSInfoToServer(
       
  5199         qosInfo,
       
  5200         aQos97Params.iReqPrecedence,
       
  5201         aQos97Params.iReqDelay,
       
  5202         aQos97Params.iReqReliability,
       
  5203         aQos97Params.iReqPeakThroughput,
       
  5204         aQos97Params.iReqMeanThroughput );
       
  5205 
       
  5206     if ( KErrNone == ret )
       
  5207         {
       
  5208         aBuffer.Append( qosInfo.iPrecedence );
       
  5209         aBuffer.Append( qosInfo.iDelay );
       
  5210         aBuffer.Append( qosInfo.iReliability );
       
  5211         aBuffer.Append( qosInfo.iPeakThroughput );
       
  5212         aBuffer.Append( qosInfo.iMeanThroughput );
       
  5213         aBuffer.Append( KGpdsPadding );
       
  5214         }
       
  5215 TFLOGSTRING2("TSY:CMmPacketContextMessHandler::FillGpdsQosReqInfo;ret=%d", ret);
       
  5216 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_FILLGPDSQOSREQINFO, "CMmPacketContextMessHandler::FillGpdsQosReqInfo;ret=%d", ret );
       
  5217     return ret;
       
  5218     }
       
  5219 
       
  5220 // -----------------------------------------------------------------------------
       
  5221 // CMmPacketContextMessHandler::AppendGpdsFilterFlowLabelInfo
       
  5222 // Adds GPDS_FILT_FLOW_LABEL_INFO to the buffer
       
  5223 // -----------------------------------------------------------------------------
       
  5224 //
       
  5225 TInt CMmPacketContextMessHandler::AppendGpdsFilterFlowLabelInfo(
       
  5226         const RPacketContext::TPacketFilterV2& aFilter,
       
  5227         TDes8& aBuffer,
       
  5228         TUint8& aNumOfSbs ) const
       
  5229     {
       
  5230 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsFilterFlowLabelInfo");
       
  5231 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSFILTERFLOWLABELINFO, "CMmPacketContextMessHandler::AppendGpdsFilterFlowLabelInfo" );
       
  5232     // Create flowlabelInfo buffer for parameters
       
  5233     TBuf8<SIZE_GPDS_FILT_FLOW_LABEL_INFO> flowLabelInfo;
       
  5234     TIsiSubBlock flowLabelInfoSubBlock(
       
  5235         flowLabelInfo,
       
  5236         GPDS_FILT_FLOW_LABEL_INFO,
       
  5237         EIsiSubBlockTypeId8Len8 );
       
  5238 
       
  5239     flowLabelInfo.Append( KGpdsPadding );
       
  5240     flowLabelInfo.Append( KGpdsPadding );
       
  5241     // Adding iFlowLabel value into buffer
       
  5242     // conforming to the rules of endianess
       
  5243     flowLabelInfo.Append( static_cast<TUint8>(
       
  5244         aFilter.iFlowLabel >> KShift24Bits ) );
       
  5245     flowLabelInfo.Append( static_cast<TUint8>(
       
  5246         aFilter.iFlowLabel >> KShift16Bits ) );
       
  5247     flowLabelInfo.Append( static_cast<TUint8>(
       
  5248         aFilter.iFlowLabel >> KShift8Bits ) );
       
  5249     flowLabelInfo.Append( static_cast<TUint8>(
       
  5250         aFilter.iFlowLabel ) );
       
  5251 
       
  5252     // Add GPDS_LABEL_FILTER_INFO subblock
       
  5253     aBuffer.Append( flowLabelInfoSubBlock.CompleteSubBlock() );
       
  5254     aNumOfSbs++;
       
  5255 
       
  5256     return KErrNone; // dont mask the panic on overflow to avoid the change in
       
  5257                      // the functionality
       
  5258     }
       
  5259 
       
  5260 // -----------------------------------------------------------------------------
       
  5261 // CMmPacketContextMessHandler::AppendGpdsFilterTosInfo
       
  5262 // Adds GPDS_FILT_TOS_INFO to the buffer
       
  5263 // -----------------------------------------------------------------------------
       
  5264 //
       
  5265 TInt CMmPacketContextMessHandler::AppendGpdsFilterTosInfo(
       
  5266         const RPacketContext::TPacketFilterV2& aFilter,
       
  5267         TDes8& aBuffer,
       
  5268         TUint8& aNumOfSbs ) const
       
  5269     {
       
  5270 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsFilterTosInfo");
       
  5271 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSFILTERTOSINFO, "CMmPacketContextMessHandler::AppendGpdsFilterTosInfo" );
       
  5272     // Create tosInfo buffer for parameters
       
  5273     TBuf8<SIZE_GPDS_FILT_TOS_INFO> tosInfo;
       
  5274     TIsiSubBlock tosInfoSubBlock(
       
  5275         tosInfo,
       
  5276         GPDS_FILT_TOS_INFO,
       
  5277         EIsiSubBlockTypeId8Len8 );
       
  5278 
       
  5279     // Adding iTOSorTrafficClass value into buffer
       
  5280     tosInfo.Append( static_cast<TUint8>(
       
  5281         aFilter.iTOSorTrafficClass >> KShift8Bits ) );
       
  5282     tosInfo.Append( static_cast<TUint8>(
       
  5283         aFilter.iTOSorTrafficClass & KTUint8NotDefined ) );
       
  5284 
       
  5285     // Add GPDS_TOS_FILTER_INFO subblock
       
  5286     aBuffer.Append( tosInfoSubBlock.CompleteSubBlock() );
       
  5287     // Increasing numberOfSubSubBlocks by one
       
  5288     aNumOfSbs++;
       
  5289 
       
  5290     return KErrNone; // dont mask the panic on overflow to avoid the change in
       
  5291                      // the functionality
       
  5292     }
       
  5293 
       
  5294 // -----------------------------------------------------------------------------
       
  5295 // CMmPacketContextMessHandler::AppendGpdsFilterSpiInfo
       
  5296 // Adds GPDS_FILT_SPI_INFO to the buffer
       
  5297 // -----------------------------------------------------------------------------
       
  5298 //
       
  5299 TInt CMmPacketContextMessHandler::AppendGpdsFilterSpiInfo(
       
  5300         const RPacketContext::TPacketFilterV2& aFilter,
       
  5301         TDes8& aBuffer,
       
  5302         TUint8& aNumOfSbs ) const
       
  5303     {
       
  5304 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsFilterSpiInfo");
       
  5305 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSFILTERSPIINFO, "CMmPacketContextMessHandler::AppendGpdsFilterSpiInfo" );
       
  5306     // Create spiInfo buffer for parameters
       
  5307     TBuf8<SIZE_GPDS_FILT_SPI_INFO> spiInfo;
       
  5308     TIsiSubBlock spiInfoSubBlock(
       
  5309         spiInfo,
       
  5310         GPDS_FILT_SPI_INFO,
       
  5311         EIsiSubBlockTypeId8Len8 );
       
  5312 
       
  5313     spiInfo.Append( KGpdsPadding );
       
  5314     spiInfo.Append( KGpdsPadding );
       
  5315     // Adding iIPSecSPI value into buffer
       
  5316     // conforming to the rules of endianess
       
  5317     spiInfo.Append( static_cast<TUint8>(
       
  5318         aFilter.iIPSecSPI >> KShift24Bits ) );
       
  5319     spiInfo.Append( static_cast<TUint8>(
       
  5320         aFilter.iIPSecSPI >> KShift16Bits ) );
       
  5321     spiInfo.Append( static_cast<TUint8>(
       
  5322         aFilter.iIPSecSPI >> KShift8Bits ) );
       
  5323     spiInfo.Append( static_cast<TUint8>(
       
  5324         aFilter.iIPSecSPI ) );
       
  5325 
       
  5326     // Add GPDS_SPI_FILTER_INFO subblock
       
  5327     aBuffer.Append( spiInfoSubBlock.CompleteSubBlock() );
       
  5328     // Increasing numberOfSubSubBlocks by one
       
  5329     aNumOfSbs++;
       
  5330 
       
  5331     return KErrNone; // dont mask the panic on overflow to avoid the change in
       
  5332                      // the functionality
       
  5333     }
       
  5334 
       
  5335 // -----------------------------------------------------------------------------
       
  5336 // CMmPacketContextMessHandler::AppendGpdsFilterSpiInfo
       
  5337 // Adds GPDS_FILT_SRC_PORT_RANGE_INFO to the buffer
       
  5338 // -----------------------------------------------------------------------------
       
  5339 //
       
  5340 TInt CMmPacketContextMessHandler::AppendGpdsFilterSrcPortRangeInfo(
       
  5341         const RPacketContext::TPacketFilterV2& aFilter,
       
  5342         TDes8& aBuffer,
       
  5343         TUint8& aNumOfSbs ) const
       
  5344     {
       
  5345 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsFilterSrcPortRangeInfo");
       
  5346 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSFILTERSRCPORTRANGEINFO, "CMmPacketContextMessHandler::AppendGpdsFilterSrcPortRangeInfo" );
       
  5347     // Create srcPortRangeInfo buffer for parameters
       
  5348     TBuf8<SIZE_GPDS_FILT_SRC_PORT_RANGE_INFO> srcPortRangeInfo;
       
  5349     TIsiSubBlock srcPortRangeSubBlock(
       
  5350         srcPortRangeInfo,
       
  5351         GPDS_FILT_SRC_PORT_RANGE_INFO,
       
  5352         EIsiSubBlockTypeId8Len8 );
       
  5353 
       
  5354     // Adding iSrcPortMin value into buffer
       
  5355     // conforming to the rules of endianess
       
  5356     srcPortRangeInfo.Append( static_cast<TUint8>(
       
  5357         aFilter.iSrcPortMin >> KShift8Bits ) );
       
  5358     srcPortRangeInfo.Append( static_cast<TUint8>(
       
  5359         aFilter.iSrcPortMin ) );
       
  5360 
       
  5361     // Adding iSrcPortMax value into buffer
       
  5362     // conforming to the rules of endianess
       
  5363     srcPortRangeInfo.Append( static_cast<TUint8>(
       
  5364         aFilter.iSrcPortMax >> KShift8Bits ) );
       
  5365     srcPortRangeInfo.Append( static_cast<TUint8>(
       
  5366         aFilter.iSrcPortMax ) );
       
  5367 
       
  5368     srcPortRangeInfo.Append( KGpdsPadding );
       
  5369     srcPortRangeInfo.Append( KGpdsPadding );
       
  5370 
       
  5371     // Add GPDS_SRC_PORT_FILTER_INFO subblock
       
  5372     aBuffer.Append( srcPortRangeSubBlock.CompleteSubBlock() );
       
  5373     // Increasing numberOfSubSubBlocks by one
       
  5374     aNumOfSbs++;
       
  5375 
       
  5376     return KErrNone; // dont mask the panic on overflow to avoid the change in
       
  5377                      // the functionality
       
  5378     }
       
  5379 
       
  5380 // -----------------------------------------------------------------------------
       
  5381 // CMmPacketContextMessHandler::AppendGpdsFilterSpiInfo
       
  5382 // Adds GPDS_FILT_DST_PORT_RANGE_INFO to the buffer
       
  5383 // -----------------------------------------------------------------------------
       
  5384 //
       
  5385 TInt CMmPacketContextMessHandler::AppendGpdsFilterDstPortRangeInfo(
       
  5386         const RPacketContext::TPacketFilterV2& aFilter,
       
  5387         TDes8& aBuffer, TUint8& aNumOfSbs ) const
       
  5388     {
       
  5389 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsFilterDstPortRangeInfo");
       
  5390 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSFILTERDSTPORTRANGEINFO, "CMmPacketContextMessHandler::AppendGpdsFilterDstPortRangeInfo" );
       
  5391     // Create destPortRangeInfo buffer for parameters
       
  5392     TBuf8<SIZE_GPDS_FILT_DST_PORT_RANGE_INFO> destPortRangeInfo;
       
  5393     TIsiSubBlock destPortRangeSubBlock(
       
  5394         destPortRangeInfo,
       
  5395         GPDS_FILT_DST_PORT_RANGE_INFO,
       
  5396         EIsiSubBlockTypeId8Len8 );
       
  5397 
       
  5398     // Adding iDestPortMin value into buffer
       
  5399     // conforming to the rules of endianess
       
  5400     destPortRangeInfo.Append( static_cast<TUint8>(
       
  5401         aFilter.iDestPortMin >> KShift8Bits ) );
       
  5402     destPortRangeInfo.Append( static_cast<TUint8>(
       
  5403         aFilter.iDestPortMin ) );
       
  5404 
       
  5405     // Adding iDestPortMax value into buffer
       
  5406     // conforming to the rules of endianess
       
  5407     destPortRangeInfo.Append( static_cast<TUint8>(
       
  5408         aFilter.iDestPortMax >> KShift8Bits ) );
       
  5409     destPortRangeInfo.Append( static_cast<TUint8>(
       
  5410         aFilter.iDestPortMax ) );
       
  5411 
       
  5412     destPortRangeInfo.Append( KGpdsPadding );
       
  5413     destPortRangeInfo.Append( KGpdsPadding );
       
  5414 
       
  5415     // Add GPDS_DEST_PORT_RANGE_FILTER_INFO subblock
       
  5416     aBuffer.Append( destPortRangeSubBlock.CompleteSubBlock() );
       
  5417     // Increasing numberOfSubSubBlocks by one
       
  5418     aNumOfSbs++;
       
  5419 
       
  5420     return KErrNone; // dont mask the panic on overflow to avoid the change in
       
  5421                      // the functionality
       
  5422     }
       
  5423 
       
  5424 // -----------------------------------------------------------------------------
       
  5425 // CMmPacketContextMessHandler::AppendGpdsFilterSpiInfo
       
  5426 // Adds GPDS_FILT_PROTOCOL_INFO to the buffer
       
  5427 // -----------------------------------------------------------------------------
       
  5428 //
       
  5429 TInt CMmPacketContextMessHandler::AppendGpdsFilterProtocolInfo(
       
  5430         const RPacketContext::TPacketFilterV2& aFilter,
       
  5431         TDes8& aBuffer,
       
  5432         TUint8& aNumOfSbs ) const
       
  5433     {
       
  5434 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsFilterProtocolInfo");
       
  5435 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSFILTERPROTOCOLINFO, "CMmPacketContextMessHandler::AppendGpdsFilterProtocolInfo" );
       
  5436     // Create protocolInfo buffer for parameter, length 1 byte
       
  5437     TBuf8<SIZE_GPDS_FILT_PROTOCOL_INFO> protocolInfo;
       
  5438     TIsiSubBlock protocolInfoSubBlock(
       
  5439         protocolInfo,
       
  5440         GPDS_FILT_PROTOCOL_INFO,
       
  5441         EIsiSubBlockTypeId8Len8 );
       
  5442 
       
  5443     TUint8 protocolNumberOrNextHeader( static_cast<TUint8>(
       
  5444         aFilter.iProtocolNumberOrNextHeader ) );
       
  5445     protocolInfo.Append( protocolNumberOrNextHeader );
       
  5446     protocolInfo.Append( KGpdsPadding );
       
  5447 
       
  5448     // Add GPDS_FILT_PROTOCOL_INFO subblock
       
  5449     aBuffer.Append( protocolInfoSubBlock.CompleteSubBlock() );
       
  5450     // Increasing numberOfSubSubBlocks by one
       
  5451     aNumOfSbs++;
       
  5452 
       
  5453     return KErrNone; // dont mask the panic on overflow to avoid the change in
       
  5454                      // the functionality
       
  5455     }
       
  5456 
       
  5457 // -----------------------------------------------------------------------------
       
  5458 // CMmPacketContextMessHandler::AppendGpdsFilterSrcIPv4AddressInfo
       
  5459 // Appends GPDS_FILT_SRC_IPV4_ADDR_INFO subblock to the passed buffer.
       
  5460 // -----------------------------------------------------------------------------
       
  5461 //
       
  5462 TInt CMmPacketContextMessHandler::AppendGpdsFilterSrcIPv4AddressInfo(
       
  5463         const RPacketContext::TPacketFilterV2& aFilter,
       
  5464         TDes8& aBuffer,
       
  5465         TUint8& aNumOfSbs ) const
       
  5466     {
       
  5467 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsFilterSrcIPv4AddressInfo");
       
  5468 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSFILTERSRCIPV4ADDRESSINFO, "CMmPacketContextMessHandler::AppendGpdsFilterSrcIPv4AddressInfo" );
       
  5469     // Create ipv4AddrInfo buffer for parameters
       
  5470     TBuf8<SIZE_GPDS_FILT_SRC_IPV4_ADDR_INFO> ipv4AddrInfo;
       
  5471     TIsiSubBlock ipv4AddrInfoSubBlock(
       
  5472         ipv4AddrInfo,
       
  5473         GPDS_FILT_SRC_IPV4_ADDR_INFO,
       
  5474         EIsiSubBlockTypeId8Len8 );
       
  5475 
       
  5476     if ( KErrNone == AppendIpAddressInfo(
       
  5477             TPtrC8( aFilter.iSrcAddr, KIpv4AddressLen ),
       
  5478             TPtrC8( aFilter.iSrcAddrSubnetMask, KIpv4AddressLen ),
       
  5479             ipv4AddrInfo ) )
       
  5480         {
       
  5481         // Add GPDS_FILT_SRC_IPV4_ADDR_INFO subblock
       
  5482         aBuffer.Append( ipv4AddrInfoSubBlock.CompleteSubBlock() );
       
  5483         // Increasing numberOfSubSubBlocks by one
       
  5484         aNumOfSbs++;
       
  5485         }
       
  5486 
       
  5487     return KErrNone; // dont mask the panic on overflow to avoid the change in
       
  5488                      // the functionality
       
  5489     }
       
  5490 
       
  5491 // -----------------------------------------------------------------------------
       
  5492 // CMmPacketContextMessHandler::AppendGpdsFilterSrcIPv6AddressInfo
       
  5493 // Appends GPDS_FILT_SRC_IPV4_ADDR_INFO subblock to the passed buffer.
       
  5494 // -----------------------------------------------------------------------------
       
  5495 //
       
  5496 TInt CMmPacketContextMessHandler::AppendGpdsFilterSrcIPv6AddressInfo(
       
  5497         const RPacketContext::TPacketFilterV2& aFilter,
       
  5498         TDes8& aBuffer,
       
  5499         TUint8& aNumOfSbs ) const
       
  5500     {
       
  5501 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsFilterSrcIPv6AddressInfo");
       
  5502 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSFILTERSRCIPV6ADDRESSINFO, "CMmPacketContextMessHandler::AppendGpdsFilterSrcIPv6AddressInfo" );
       
  5503     // Create ipv6AddrInfo buffer for parameters
       
  5504     TBuf8<SIZE_GPDS_FILT_SRC_IPV6_ADDR_INFO> ipv6AddrInfo;
       
  5505     TIsiSubBlock ipv6AddrInfoSubBlock(
       
  5506             ipv6AddrInfo,
       
  5507         GPDS_FILT_SRC_IPV6_ADDR_INFO,
       
  5508         EIsiSubBlockTypeId8Len8 );
       
  5509 
       
  5510     if ( KErrNone == AppendIpAddressInfo(
       
  5511             TPtrC8( aFilter.iSrcAddr, KIpv6AddressLen ),
       
  5512             TPtrC8( aFilter.iSrcAddrSubnetMask, KIpv6AddressLen ),
       
  5513             ipv6AddrInfo ) )
       
  5514         {
       
  5515         // Add GPDS_FILT_SRC_IPV4_ADDR_INFO subblock
       
  5516         aBuffer.Append( ipv6AddrInfoSubBlock.CompleteSubBlock() );
       
  5517         // Increasing numberOfSubSubBlocks by one
       
  5518         aNumOfSbs++;
       
  5519         }
       
  5520 
       
  5521     return KErrNone; // dont mask the panic on overflow to avoid the change in
       
  5522                      // the functionality
       
  5523     }
       
  5524 
       
  5525 // -----------------------------------------------------------------------------
       
  5526 // CMmPacketContextMessHandler::AppendIpAddressInfo
       
  5527 // Appends GPDS IP source address information to the buffer.
       
  5528 // -----------------------------------------------------------------------------
       
  5529 //
       
  5530 TInt CMmPacketContextMessHandler::AppendIpAddressInfo(
       
  5531         const TDesC8& aInputIpAddress,
       
  5532         const TDesC8& aInputIpAddressMask,
       
  5533         TDes8& aBuffer ) const
       
  5534     {
       
  5535 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendIpAddressInfo");
       
  5536 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDIPADDRESSINFO, "CMmPacketContextMessHandler::AppendIpAddressInfo" );
       
  5537     TInt ret( KErrArgument );
       
  5538 
       
  5539     // check that address 0.0.0.0 is not used.
       
  5540     TUint addressCounter( 0 );
       
  5541     for ( TInt i = 0; i < aInputIpAddress.Length(); i++ )
       
  5542         {
       
  5543         addressCounter += aInputIpAddress[i];
       
  5544         }
       
  5545 
       
  5546     if (0 != addressCounter)
       
  5547         {
       
  5548         ret = KErrNone;
       
  5549 
       
  5550         TInt ipAddressMaskLength( aInputIpAddressMask.Length() );
       
  5551         // Count the number of '1' bits in Src Addr Subnet Mask
       
  5552         TInt amountOfBitsMasked( 0 );
       
  5553         for ( TUint i = 0; ( ( i < ipAddressMaskLength ) &&
       
  5554             ( 0 < aInputIpAddressMask[i] ) ); i++ )
       
  5555             {
       
  5556             // If number between dots is 255 = 0xFF
       
  5557             if ( KTUint8NotDefined == aInputIpAddressMask[i] )
       
  5558                 {
       
  5559                 // All are '1' bits and so the count is
       
  5560                 // increased by eight
       
  5561                 amountOfBitsMasked += KShift8Bits;
       
  5562                 }
       
  5563             // Otherwise there is less than eight '1' bits
       
  5564             else
       
  5565                 {
       
  5566                 // Initializing mask to 0x80 = 1000 0000 b
       
  5567                 TUint8 mask( KInitMask0x80 );
       
  5568                 for ( TUint k = 0; k < KShift8Bits; k++ )
       
  5569                     {
       
  5570                     // Count the number of '1' bits from the byte
       
  5571                     if ( aInputIpAddressMask[i] & mask )
       
  5572                         {
       
  5573                         amountOfBitsMasked++;
       
  5574                         mask = static_cast<TUint8>( mask >> KShift1Bit );
       
  5575                         }
       
  5576                     else
       
  5577                         {
       
  5578                         k = KShift8Bits;
       
  5579                         }
       
  5580                     }
       
  5581                 // Rest of the Src Addr Subnet Mask is 0's,
       
  5582                 // so we break the loop
       
  5583                 i = ipAddressMaskLength;
       
  5584                 }
       
  5585             }
       
  5586 
       
  5587         aBuffer.Append( amountOfBitsMasked );
       
  5588         aBuffer.Append( KGpdsPadding );
       
  5589         aBuffer.Append( aInputIpAddress );
       
  5590         }
       
  5591 TFLOGSTRING2("TSY:CMmPacketContextMessHandler::AppendIpAddressInfo;ret=%d", ret);
       
  5592 OstTrace1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_APPENDIPADDRESSINFO, "CMmPacketContextMessHandler::AppendIpAddressInfo;ret=%d", ret );
       
  5593     return ret;
       
  5594     }
       
  5595 
       
  5596 // -----------------------------------------------------------------------------
       
  5597 // CMmPacketContextMessHandler::AppendGpdsTftFilterInfo
       
  5598 // Appends GPDS_TFT_FILTER_INFO subblock.
       
  5599 // -----------------------------------------------------------------------------
       
  5600 //
       
  5601 TInt CMmPacketContextMessHandler::AppendGpdsTftFilterInfo(
       
  5602         TUint8 aFilterId,
       
  5603         TDes8& aBuffer,
       
  5604         TUint8& aNumOfSbs ) const
       
  5605     {
       
  5606 TFLOGSTRING("TSY:CMmPacketContextMessHandler::AppendGpdsTftFilterInfo");
       
  5607 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_APPENDGPDSTFTFILTERINFO, "CMmPacketContextMessHandler::AppendGpdsTftFilterInfo" );
       
  5608     // Add GPDS_TFT_FILTER_INFO subblock
       
  5609     TBuf8<SIZE_GPDS_TFT_FILTER_INFO> filterInfoSbBuffer;
       
  5610     TIsiSubBlock gpdsFilterInfoSubBlock(
       
  5611         filterInfoSbBuffer,
       
  5612         GPDS_TFT_FILTER_INFO,
       
  5613         EIsiSubBlockTypeId8Len8 );
       
  5614 
       
  5615     // In API docs ID can have values from 1 to 8 and
       
  5616     // in GPDS docs it can have values from 0 to 7
       
  5617     TUint8 filterArray( static_cast<TUint8>(
       
  5618             aFilterId - KFilterArray ) );
       
  5619     filterInfoSbBuffer.Append( filterArray );
       
  5620     filterInfoSbBuffer.Append( KGpdsPadding );
       
  5621     // add fillers
       
  5622     filterInfoSbBuffer.Append( KGpdsPadding );
       
  5623     filterInfoSbBuffer.Append( KGpdsPadding );
       
  5624     filterInfoSbBuffer.Append( KGpdsPadding );
       
  5625     aBuffer.Append(
       
  5626         gpdsFilterInfoSubBlock.CompleteSubBlock() );
       
  5627     aNumOfSbs++;
       
  5628 
       
  5629     return KErrNone;
       
  5630     }
       
  5631 
       
  5632 // -----------------------------------------------------------------------------
       
  5633 // CMmPacketContextMessHandler::CallModemResourceIndL
       
  5634 // This method breaks call modem resource indication message and
       
  5635 // initiates secondary contexts deactivation to allow incoming call
       
  5636 // -----------------------------------------------------------------------------
       
  5637 //
       
  5638 void CMmPacketContextMessHandler::CallModemResourceIndL(
       
  5639     const TIsiReceiveC &aIsiMessage )
       
  5640     {
       
  5641 TFLOGSTRING( "TSY: CMmPacketContextMessHandler::CallModemResourceIndL" );
       
  5642 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEINDL, "CMmPacketContextMessHandler::CallModemResourceIndL" );
       
  5643 
       
  5644     TUint sbStartOffset( 0 );
       
  5645     //Default, 0 is unused value
       
  5646     TUint resourceId( 0 );
       
  5647     // Default, emergency call mode not possible in MT call
       
  5648     TUint8 callMode( CALL_MODEM_MODE_EMERGENCY );
       
  5649     // Make a copy of received message. Allocate heap memory.
       
  5650     // Can leave if out of mem.
       
  5651     iResourceControlMsg = HBufC8::NewL( aIsiMessage.GetBuffer().Length() );
       
  5652     // Copy data.
       
  5653     *iResourceControlMsg = aIsiMessage.GetBuffer();
       
  5654 
       
  5655 TFLOGSTRING("TSY: CMmPacketContextMessHandler::CallModemResourceIndL, messagedata saved");
       
  5656 OstTrace0( TRACE_NORMAL, DUP9_CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEINDL, "CMmPacketContextMessHandler::CallModemResourceIndL, messagedata saved" );
       
  5657 
       
  5658     TUint8 callId = aIsiMessage.Get8bit(
       
  5659         ISI_HEADER_SIZE + CALL_MODEM_RESOURCE_IND_OFFSET_CALLID );
       
  5660 
       
  5661     if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  5662         ISI_HEADER_SIZE + SIZE_CALL_MODEM_RESOURCE_IND,
       
  5663         CALL_MODEM_SB_RESOURCE,
       
  5664         EIsiSubBlockTypeId8Len8,
       
  5665         sbStartOffset ) )
       
  5666         {
       
  5667         resourceId = aIsiMessage.Get16bit(
       
  5668             sbStartOffset + CALL_MODEM_SB_RESOURCE_OFFSET_RES );
       
  5669         }
       
  5670 
       
  5671     if ( KErrNone == aIsiMessage.FindSubBlockOffsetById(
       
  5672         ISI_HEADER_SIZE + SIZE_CALL_MODEM_RESOURCE_IND,
       
  5673         CALL_MODEM_SB_MODE,
       
  5674         EIsiSubBlockTypeId8Len8,
       
  5675         sbStartOffset ) )
       
  5676         {
       
  5677         callMode = aIsiMessage.Get8bit(
       
  5678             sbStartOffset + CALL_MODEM_SB_MODE_OFFSET_MODE );
       
  5679         }
       
  5680     // check request
       
  5681     if ( ( CALL_MODEM_RES_ID_MT_INIT == resourceId ) &&
       
  5682          ( CALL_MODEM_ID_NONE != callId ) &&
       
  5683          ( CALL_MODEM_MODE_SPEECH == callMode ||
       
  5684            CALL_MODEM_MODE_ALS_LINE_2 == callMode ||
       
  5685            CALL_MODEM_MODE_MULTIMEDIA == callMode ) )
       
  5686         {
       
  5687         // if DCM drive mode flag is enabled
       
  5688         if ( iDriveModeFlag )
       
  5689             {
       
  5690 TFLOGSTRING( "TSY: CMmPacketContextMessHandler::CallModemResourceIndL - DCM Drive Mode enabled" );
       
  5691 OstTrace0( TRACE_NORMAL, DUP8_CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEINDL, "CMmPacketContextMessHandler::CallModemResourceIndL - DCM Drive Mode enabled" );
       
  5692 
       
  5693             // Complete DCM specific functionality
       
  5694             // Drive mode rejects automatically incoming calls
       
  5695             CompleteDCMdrivemodeFunctionalityL();
       
  5696             CallModemResourceReqDenied();
       
  5697             }
       
  5698         else
       
  5699             {
       
  5700 TFLOGSTRING( "TSY: CMmPacketContextMessHandler::CallModemResourceIndL - Allow incoming call activation" );
       
  5701 OstTrace0( TRACE_NORMAL, DUP6_CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEINDL, "CMmPacketContextMessHandler::CallModemResourceIndL - Allow incoming call activation" );
       
  5702 
       
  5703             // allow incoming call activation
       
  5704             iCallModemResourceCallId = callId;
       
  5705             AllowIncomingCallActivationL();
       
  5706             }
       
  5707         }
       
  5708     else
       
  5709         {
       
  5710         iCallModemResourceCallId = CALL_MODEM_ID_NONE;
       
  5711         }
       
  5712     }
       
  5713 
       
  5714 // -----------------------------------------------------------------------------
       
  5715 // CMmPacketContextMessHandler::CallModemResourceReqAllowed
       
  5716 // CALL_MODEM_RESOURCE_REQ is used to configure resource control
       
  5717 // Client shall use CALL_MODEM_RESOURCE_REQ to allow or deny resource and
       
  5718 // modify parameters for the resource.
       
  5719 // -----------------------------------------------------------------------------
       
  5720 //
       
  5721 void CMmPacketContextMessHandler::CallModemResourceReqAllowed()
       
  5722     {
       
  5723 TFLOGSTRING( "TSY: CMmPacketContextMessHandler::CallModemResourceReqAllowed" );
       
  5724 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEREQALLOWED, "CMmPacketContextMessHandler::CallModemResourceReqAllowed" );
       
  5725 
       
  5726     TIsiSend callModemResourceReq( iPhoNetSender->SendBufferDes() );
       
  5727 
       
  5728     // Copy message from buffer.
       
  5729     const TDesC8& message( *iResourceControlMsg );
       
  5730 
       
  5731     TIsiReceiveC isimessage( ( TIsiReceiveC ) message );
       
  5732 
       
  5733     callModemResourceReq.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_MODEM_CALL );
       
  5734 
       
  5735     // Set the CallModemResourceReq data
       
  5736     callModemResourceReq.Set8bit(
       
  5737         ISI_HEADER_OFFSET_MESSAGEID, CALL_MODEM_RESOURCE_REQ );
       
  5738 
       
  5739     TUint callId = isimessage.Get8bit( ISI_HEADER_SIZE +
       
  5740         CALL_MODEM_RESOURCE_IND_OFFSET_CALLID );
       
  5741 
       
  5742     // Set call id
       
  5743     callModemResourceReq.Set8bit(
       
  5744         ISI_HEADER_SIZE + CALL_MODEM_RESOURCE_REQ_OFFSET_CALLID, callId );
       
  5745 
       
  5746     // get subblocks from message
       
  5747     TUint8 numOfSubBlocks = isimessage.Get8bit( ISI_HEADER_SIZE +
       
  5748         CALL_MODEM_RESOURCE_IND_OFFSET_SUBBLOCKS );
       
  5749 
       
  5750     TUint sbStartOffSet( 0 );
       
  5751 
       
  5752     // buffer for CALL_MODEM_SB_RESOURCE_STATUS subblock
       
  5753     TBuf8<SIZE_CALL_MODEM_SB_RESOURCE_STATUS> resourceStatus;
       
  5754 
       
  5755     // Add CALL_MODEM_SB_RESOURCE_STATUS [M] subblock
       
  5756     TIsiSubBlock resourceStatusSb(
       
  5757         resourceStatus,
       
  5758         CALL_MODEM_SB_RESOURCE_STATUS,
       
  5759         EIsiSubBlockTypeId8Len8 );
       
  5760     // resource status + filler byte
       
  5761     resourceStatus.Append( CALL_MODEM_RESOURCE_ALLOWED );
       
  5762     resourceStatus.Append( KCallPadding );
       
  5763 
       
  5764     TInt currentMsgOffset(
       
  5765         ISI_HEADER_SIZE + SIZE_CALL_MODEM_RESOURCE_REQ );
       
  5766 
       
  5767     callModemResourceReq.CopyData(
       
  5768         currentMsgOffset, resourceStatusSb.CompleteSubBlock() );
       
  5769 
       
  5770     // Set new offset and increase subblock count
       
  5771     currentMsgOffset =
       
  5772         currentMsgOffset + resourceStatus.Length();
       
  5773 
       
  5774     // loop for finding all subblocks from CALL_MODEM_RESOURCE_IND
       
  5775     for ( TInt sbIndex = 1; sbIndex <= numOfSubBlocks; sbIndex++ )
       
  5776         {
       
  5777         if ( KErrNone == isimessage.FindSubBlockOffsetByIndex(
       
  5778             ISI_HEADER_SIZE + SIZE_CALL_MODEM_RESOURCE_IND,
       
  5779             sbIndex,
       
  5780             EIsiSubBlockTypeId8Len8,
       
  5781             sbStartOffSet ) )
       
  5782             {
       
  5783             // get length of subblock
       
  5784             TUint8 sbLen = isimessage.Get8bit(
       
  5785                 sbStartOffSet + KSubBlockLengthOffset1 );
       
  5786 
       
  5787             callModemResourceReq.CopyData(
       
  5788                 currentMsgOffset,
       
  5789                 isimessage.GetData( sbStartOffSet, sbLen ) );
       
  5790             // Check if handled sub block is CALL_MODEM_SB_MODE
       
  5791             if ( CALL_MODEM_SB_MODE == isimessage.Get8bit( sbStartOffSet ) )
       
  5792                 {
       
  5793                 // Clients shall set the value to '0' when sending requests
       
  5794                 // to Modem Call Server.
       
  5795                 callModemResourceReq.Set8bit(
       
  5796                     currentMsgOffset + CALL_MODEM_SB_MODE_OFFSET_MODEINFO,
       
  5797                     0x00 );
       
  5798                 }
       
  5799             // Set new offset and increase subblock count
       
  5800             currentMsgOffset =
       
  5801                 currentMsgOffset + sbLen;
       
  5802             }
       
  5803         }
       
  5804 
       
  5805     callModemResourceReq.Set8bit(
       
  5806         ISI_HEADER_SIZE + CALL_MODEM_RESOURCE_REQ_OFFSET_SUBBLOCKS,
       
  5807         numOfSubBlocks + 1 );
       
  5808     // Message sent via Phonet
       
  5809     iPhoNetSender->Send( callModemResourceReq.Complete() );
       
  5810 
       
  5811     // Delete used message.
       
  5812     delete iResourceControlMsg;
       
  5813     iResourceControlMsg = NULL;
       
  5814 
       
  5815     }
       
  5816 
       
  5817 // -----------------------------------------------------------------------------
       
  5818 // CMmPacketContextMessHandler::CallModemResourceResp
       
  5819 // CALL_MODEM_RESOURCE_RESP is used to configure resource control
       
  5820 // When Call Server has accepted the request CALL_MODEM_RESOURCE_RESP is
       
  5821 // sent back to the requester.
       
  5822 // -----------------------------------------------------------------------------
       
  5823 //
       
  5824 void CMmPacketContextMessHandler::CallModemResourceResp(
       
  5825     const TIsiReceiveC &aIsiMessage )
       
  5826     {
       
  5827 TFLOGSTRING( "TSY: CMmPacketContextMessHandler::CallModemResourceResp" );
       
  5828 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCERESP, "CMmPacketContextMessHandler::CallModemResourceResp" );
       
  5829 
       
  5830     TUint8 callId( aIsiMessage.Get8bit(
       
  5831         ISI_HEADER_SIZE + CALL_MODEM_RESOURCE_RESP_OFFSET_CALLID ) );
       
  5832 
       
  5833 TFLOGSTRING2("TSY: CMmPacketContextMessHandler::CallModemResourceResp, CallId %d", callId );
       
  5834 OstTraceExt1( TRACE_NORMAL, DUP1_CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCERESP, "CMmPacketContextMessHandler::CallModemResourceResp - CallId=%hhu", callId );
       
  5835 
       
  5836     }
       
  5837 
       
  5838 // -----------------------------------------------------------------------------
       
  5839 // CMmPacketContextMessHandler::CallModemResourceReqDenied
       
  5840 // Creates callModemResourceDenied ISI message to modem call server.
       
  5841 // (other items were commented in a header).
       
  5842 // -----------------------------------------------------------------------------
       
  5843 //
       
  5844 void CMmPacketContextMessHandler::CallModemResourceReqDenied()
       
  5845    {
       
  5846 TFLOGSTRING("TSY: CMmPacketContextMessHandler::CallModemResourceReqDenied");
       
  5847 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEREQDENIED, "CMmPacketContextMessHandler::CallModemResourceReqDenied" );
       
  5848 
       
  5849     TIsiSend callModemResourceDenied( iPhoNetSender->SendBufferDes() );
       
  5850 
       
  5851     // Copy message from buffer.
       
  5852     const TDesC8& message( *iResourceControlMsg );
       
  5853 
       
  5854     TIsiReceiveC isimessage( ( TIsiReceiveC ) message );
       
  5855 
       
  5856     callModemResourceDenied.Set8bit( ISI_HEADER_OFFSET_RESOURCEID, PN_MODEM_CALL );
       
  5857 
       
  5858     // Set the callModemResourceDenied data
       
  5859     callModemResourceDenied.Set8bit(
       
  5860         ISI_HEADER_OFFSET_MESSAGEID, CALL_MODEM_RESOURCE_REQ );
       
  5861 
       
  5862     TUint callId = isimessage.Get8bit( ISI_HEADER_SIZE +
       
  5863         CALL_MODEM_RESOURCE_IND_OFFSET_CALLID );
       
  5864 
       
  5865     // Set call id
       
  5866     callModemResourceDenied.Set8bit(
       
  5867         ISI_HEADER_SIZE + CALL_MODEM_RESOURCE_REQ_OFFSET_CALLID, callId );
       
  5868 
       
  5869     TInt aCurrentMsgOffset(
       
  5870         ISI_HEADER_SIZE + SIZE_CALL_MODEM_RESOURCE_REQ );
       
  5871 
       
  5872     TUint8 numOfSbInMessage( 0 );
       
  5873 
       
  5874     // buffer for CALL_MODEM_SB_RESOURCE_STATUS subblock
       
  5875     TBuf8<CALL_MODEM_SB_RESOURCE_STATUS> resourceStatus;
       
  5876 
       
  5877     // Add CALL_MODEM_SB_RESOURCE_STATUS subblock
       
  5878     TIsiSubBlock resourceStatusSb(
       
  5879         resourceStatus,
       
  5880         CALL_MODEM_SB_RESOURCE_STATUS,
       
  5881         EIsiSubBlockTypeId8Len8 );
       
  5882     // resource status + filler byte
       
  5883     resourceStatus.Append( CALL_MODEM_RESOURCE_DENIED );
       
  5884     resourceStatus.Append( KCallPadding );
       
  5885 
       
  5886     callModemResourceDenied.CopyData(
       
  5887         aCurrentMsgOffset, resourceStatusSb.CompleteSubBlock() );
       
  5888     // Set new offset and increase subblock count
       
  5889     aCurrentMsgOffset =
       
  5890         aCurrentMsgOffset + resourceStatus.Length();
       
  5891     // increase subblock count
       
  5892     numOfSbInMessage++;
       
  5893 
       
  5894 TFLOGSTRING2("TSY: CMmPacketContextMessHandler::CallModemResourceReqDenied - CALL_MODEM_SB_RESOURCE_STATUS - Subblock Count:  %d", numOfSbInMessage );
       
  5895 OstTraceExt1( TRACE_NORMAL, DUP2_CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEREQDENIED, "CMmPacketContextMessHandler::CallModemResourceReqDenied- CALL_MODEM_SB_RESOURCE_STATUS - Subblock Count=%hhu", numOfSbInMessage );
       
  5896 
       
  5897     // buffer for CALL_MODEM_SB_CAUSE subblock
       
  5898     TBuf8<CALL_MODEM_SB_CAUSE> modemSbCause;
       
  5899 
       
  5900     // Add CALL_MODEM_SB_CAUSE subblock
       
  5901     TIsiSubBlock modemSbCauseSb(
       
  5902         modemSbCause,
       
  5903         CALL_MODEM_SB_CAUSE,
       
  5904         EIsiSubBlockTypeId8Len8 );
       
  5905     // cause type + cause
       
  5906     modemSbCause.Append( CALL_MODEM_CAUSE_TYPE_CLIENT );
       
  5907     modemSbCause.Append( CALL_MODEM_CAUSE_RELEASE_BY_USER );
       
  5908 
       
  5909     callModemResourceDenied.CopyData(
       
  5910         aCurrentMsgOffset, modemSbCauseSb.CompleteSubBlock() );
       
  5911     // Set new offset and increase subblock count
       
  5912     aCurrentMsgOffset =
       
  5913         aCurrentMsgOffset + modemSbCause.Length();
       
  5914     // increase subblock count
       
  5915     numOfSbInMessage++;
       
  5916 
       
  5917 TFLOGSTRING2("TSY: CMmPacketContextMessHandler::CallModemResourceReqDenied - CALL_MODEM_SB_CAUSE - Subblock Count:  %d", numOfSbInMessage );
       
  5918 OstTraceExt1( TRACE_NORMAL, DUP4_CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEREQDENIED, "CMmPacketContextMessHandler::CallModemResourceReqDenied- CALL_MODEM_SB_CAUSE - Subblock Count=%hhu", numOfSbInMessage );
       
  5919 
       
  5920     // buffer for CALL_MODEM_SB_DETAILED_CAUSE subblock
       
  5921     TBuf8<CALL_MODEM_SB_DETAILED_CAUSE> detailedCause;
       
  5922 
       
  5923     // Add CALL_MODEM_SB_DETAILED_CAUSE subblock
       
  5924     TIsiSubBlock detailedCauseSb(
       
  5925         detailedCause,
       
  5926         CALL_MODEM_SB_DETAILED_CAUSE,
       
  5927         EIsiSubBlockTypeId8Len8 );
       
  5928     // cause length + cause values ( 4 ) + filler
       
  5929     detailedCause.Append( KDiagnosticsOctet2 );
       
  5930     detailedCause.Append( KDiagnosticsOctet3 );
       
  5931     detailedCause.Append( KDiagnosticsOctet4 );
       
  5932     detailedCause.Append( KDiagnosticsOctet5 );
       
  5933     detailedCause.Append( KDiagnosticsOctet6 );
       
  5934     detailedCause.Append( KCallPadding );
       
  5935 
       
  5936     callModemResourceDenied.CopyData(
       
  5937         aCurrentMsgOffset, detailedCauseSb.CompleteSubBlock() );
       
  5938     // Set new offset and increase subblock count
       
  5939     aCurrentMsgOffset =
       
  5940         aCurrentMsgOffset + detailedCause.Length();
       
  5941     // increase subblock count
       
  5942     numOfSbInMessage++;
       
  5943 
       
  5944 TFLOGSTRING2("TSY: CMmPacketContextMessHandler::CallModemResourceReqDenied - CALL_MODEM_SB_DETAILED_CAUSE - Subblock Count:  %d", numOfSbInMessage );
       
  5945 OstTraceExt1( TRACE_NORMAL, DUP3_CMMPACKETCONTEXTMESSHANDLER_CALLMODEMRESOURCEREQDENIED, "CMmPacketContextMessHandler::CallModemResourceReqDenied- CALL_MODEM_SB_DETAILED_CAUSE - Subblock Count=%hhu", numOfSbInMessage );
       
  5946 
       
  5947     // Set number of subblokcs in CALL_MODEM_RESOURCE_REQ message
       
  5948     callModemResourceDenied.Set8bit(
       
  5949         ISI_HEADER_SIZE + CALL_MODEM_RESOURCE_REQ_OFFSET_SUBBLOCKS,
       
  5950         numOfSbInMessage );
       
  5951 
       
  5952     // Message sent via Phonet
       
  5953     iPhoNetSender->Send( callModemResourceDenied.Complete() );
       
  5954 
       
  5955     // Delete iResourceControlMsg
       
  5956     delete iResourceControlMsg;
       
  5957     iResourceControlMsg = NULL;
       
  5958 
       
  5959     }
       
  5960 
       
  5961 // -----------------------------------------------------------------------------
       
  5962 // CMmPacketContextMessHandler::CompleteDCMdrivemodeFunctionalityL
       
  5963 // This methods completes DCM drive mode specific functionality, if drive mode
       
  5964 // flag is enabled.
       
  5965 // (other items were commented in a header).
       
  5966 // -----------------------------------------------------------------------------
       
  5967 //
       
  5968 void CMmPacketContextMessHandler::CompleteDCMdrivemodeFunctionalityL()
       
  5969     {
       
  5970 TFLOGSTRING("TSY: CMmPacketContextMessHandler::CompleteDCMdrivemodeFunctionalityL");
       
  5971 OstTrace0( TRACE_NORMAL, CMMPACKETCONTEXTMESSHANDLER_COMPLETEDCMDRIVEMODEFUNCTIONALITYL, "CMmPacketContextMessHandler::CompleteDCMdrivemodeFunctionalityL" );
       
  5972 
       
  5973     TInt result( KErrNone );
       
  5974 
       
  5975     // Create call package (used for all completions)
       
  5976     CCallDataPackage callData;
       
  5977 
       
  5978     // This is for call info required for incoming call
       
  5979     RMobileCall::TMobileCallInfoV1 iIncomingCallId;
       
  5980 
       
  5981     // Call is first notified like normal incoming call,
       
  5982     // then it is notified as disconnecting and idle
       
  5983     iIncomingCallId.iStatus = RMobileCall::EStatusRinging;
       
  5984 
       
  5985     // COMPLETE INCOMING CALL
       
  5986     // Pack mobile call info
       
  5987     callData.PackData( &iIncomingCallId );
       
  5988     // Complete IncomingCall notification
       
  5989     iMessageRouter->Complete(
       
  5990         EEtelLineNotifyIncomingCall,
       
  5991         &callData,
       
  5992         KErrNone );
       
  5993 
       
  5994     // COMPLETE MOBILE CALL INFO CHANGE
       
  5995     // (Get mobile call information is always completed before
       
  5996     // call status change)
       
  5997     // pack mobile call info
       
  5998     // pass call information to the Symbian OS layer
       
  5999     callData.PackData( &iIncomingCallId );
       
  6000     iMessageRouter->Complete(
       
  6001         EMobileCallGetMobileCallInfo,
       
  6002         &callData,
       
  6003         KErrNone );
       
  6004 
       
  6005     // COMPLETE MOBILE CALL STATUS CHANGE
       
  6006     // Pack call status
       
  6007     callData.PackData( &iIncomingCallId.iStatus );
       
  6008     // Complete status change indication
       
  6009     iMessageRouter->Complete(
       
  6010         EMobileCallNotifyMobileCallStatusChange,
       
  6011         &callData,
       
  6012         KErrNone );
       
  6013 
       
  6014     // status disconnecting
       
  6015     iIncomingCallId.iStatus = RMobileCall::EStatusDisconnecting;
       
  6016 
       
  6017     // COMPLETE MOBILE CALL INFO CHANGE
       
  6018     // (Get mobile call information is always completed before
       
  6019     // call status change)
       
  6020     // pack mobile call info
       
  6021     // pass call information to the Symbian OS layer
       
  6022     callData.PackData( &iIncomingCallId );
       
  6023     iMessageRouter->Complete(
       
  6024         EMobileCallGetMobileCallInfo,
       
  6025         &callData,
       
  6026         KErrNone );
       
  6027 
       
  6028     // COMPLETE MOBILE CALL STATUS CHANGE
       
  6029     // Pack call status
       
  6030     callData.PackData( &iIncomingCallId.iStatus );
       
  6031     // Complete status change indication
       
  6032     iMessageRouter->Complete(
       
  6033         EMobileCallNotifyMobileCallStatusChange,
       
  6034         &callData,
       
  6035         result );
       
  6036 
       
  6037     // status idle
       
  6038     iIncomingCallId.iStatus = RMobileCall::EStatusIdle;
       
  6039 
       
  6040     // COMPLETE MOBILE CALL INFO CHANGE
       
  6041     // (Get mobile call information is always completed before
       
  6042     // call status change)
       
  6043     // Pack mobile call info
       
  6044     // Pass call information to the Symbian OS layer
       
  6045     callData.PackData( &iIncomingCallId );
       
  6046     iMessageRouter->Complete(
       
  6047         EMobileCallGetMobileCallInfo,
       
  6048         &callData,
       
  6049         KErrNone );
       
  6050 
       
  6051     // COMPLETE MOBILE CALL STATUS CHANGE
       
  6052     // Pack call status
       
  6053     callData.PackData( &iIncomingCallId.iStatus );
       
  6054     // Complete status change indication
       
  6055     iMessageRouter->Complete(
       
  6056         EMobileCallNotifyMobileCallStatusChange,
       
  6057         &callData,
       
  6058         result );
       
  6059 
       
  6060     }
       
  6061 
       
  6062 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
  6063 
       
  6064     // None
       
  6065 
       
  6066 // End of File