connectivitylayer/isce/p2prouter_dll/src/p2pkernelchannel.cpp
author mikaruus
Tue, 19 Oct 2010 13:16:20 +0300
changeset 9 8486d82aef45
parent 0 63b37f68c1ce
permissions -rw-r--r--
modemadaptation release 2010wk40
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     1
/*
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     3
* All rights reserved.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     8
*
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
     9
* Initial Contributors:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    11
*
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    12
* Contributors:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    13
* 
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    14
* Description: 
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    15
*
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    16
*/
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    17
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    18
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    19
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    20
#include <nk_priv.h>       // For __ASSERT_NO_FAST_MUTEX published partner
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    21
#include <kern_priv.h>     // For __ASSERT_CRITICAL published partner
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    22
#include <dfcs.h>               // For TDfc
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    23
#include "memapi.h"             // For MemApi
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    24
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    25
#include "p2pkernelchannel.h"   // For DP2PKernelChannel
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    26
#include "p2proutertrace.h"     // For TRACEs
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    27
#include "p2pdefs.h"            // For EP2PAmountOfProtocols
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    28
#include "msgqueue.h"           // For DMsgQueue 
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    29
#include "p2pinternaldefs.h"    // For EP2P...
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    30
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    31
// CONST
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    32
const TInt KFirstParam( 0 );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    33
const TInt KSecondParam( 1 );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    34
const TInt KThirdParam( 2 );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    35
const TInt KDestroyChannelMsg( 0xff );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    36
const TInt KP2PKernelChannelMsgQueDfcPrio( 2 ); // LDD FW has one
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    37
const TInt KP2PKernelEmptyRxQueuePrio( 1 );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    38
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    39
enum TP2PKernelChannelFaults
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    40
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    41
    EP2PKernelChannelMemAllocFailure = 0x00,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    42
    EP2PKernelChannelMemAllocFailure2,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    43
    EP2PKernelChannelNotThreadContext,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    44
    EP2PKernelChannelNotThreadContext2,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    45
    EP2PKernelChannelNotThreadContext3,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    46
    EP2PKernelChannelNullParam,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    47
    EP2PKernelChannelNullParam2,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    48
    EP2PKernelChannelNullParam3,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    49
    EP2PKernelChannelNullParam4,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    50
    EP2PKernelChannelNullParam5,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    51
    EP2PKernelChannelNullParam6,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    52
    EP2PKernelChannelWrongParam,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    53
    EP2PKernelChannelWrongParam2,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    54
    EP2PKernelChannelWrongParam3,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    55
    EP2PKernelChannelWrongResponse,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    56
    EP2PKernelChannelNullPtr,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    57
    EP2PKernelChannelWrongRequest,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    58
    EP2PKernelChannelWrongRequest2,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    59
    EP2PKernelChannelWrongRequest3,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    60
    EP2PKernelChannelWrongRequest4,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    61
    EP2PKernelChannelOverTheLimits,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    62
    EP2PKernelChannelOverTheLimits2,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    63
    EP2PKernelChannelOverTheLimits3,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    64
    EP2PKernelChannelOverTheLimits4,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    65
    EP2PKernelChannelSameRequestTwice,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    66
    EP2PKernelChannelDfcAlreadyQueued,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    67
    EP2PKernelChannelRxBufferNotReleased,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    68
    };
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    69
9
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
    70
//  Create a common Kernel channel FW (P2P, ISI, etc..) after APIs are locked
0
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    71
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    72
DP2PKernelChannel::DP2PKernelChannel(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    73
        // None
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    74
        ) :
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    75
        iP2PProtocolId( EP2PAmountOfProtocols ),
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    76
        iKernelChMsgQue( MsgQDfc, this, NULL, KP2PKernelChannelMsgQueDfcPrio )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    77
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    78
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    79
    C_TRACE( ( _T( "DP2PKernelChannel::DP2PKernelChannel 0x%x 0x%x>" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    80
    iRouterIf = MP2PChRouterIf::GetIf();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    81
    ASSERT_RESET_ALWAYS( iRouterIf, ( EP2PKernelChannelMemAllocFailure | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    82
    iRequests = new DP2PKernelAsyncRequests( EP2PLastAsyncRequest );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    83
    iRx = new DMsgQueue( KP2PLddRxQueuSize );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    84
    iEmptyRxDfc = new TDfc( EmptyRxDfc, this, iRouterIf->GetDfcThread( MP2PChRouterIf::EP2PDfcThread ), KP2PKernelEmptyRxQueuePrio );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    85
    ASSERT_RESET_ALWAYS( ( iEmptyRxDfc && iRequests && iRx ), ( EP2PKernelChannelMemAllocFailure2 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    86
    iKernelChMsgQue.SetDfcQ( iRouterIf->GetDfcThread( MP2PChRouterIf::EP2PDfcThread ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    87
    iKernelChMsgQue.Receive();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    88
    C_TRACE( ( _T( "DP2PKernelChannel::DP2PKernelChannel 0x%x 0x%x<" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    89
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    90
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    91
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    92
DP2PKernelChannel::~DP2PKernelChannel(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    93
        // None
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    94
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    95
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    96
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    97
    C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel 0x%x 0x%x>" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    98
    // Send channel destroyed message to complete with EFalse.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
    99
    TThreadMessage& m=Kern::Message();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   100
    m.iValue = KDestroyChannelMsg;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   101
    m.SendReceive( &iKernelChMsgQue );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   102
    iP2PProtocolId = EP2PAmountOfProtocols;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   103
    C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel iRx 0x%x" ), iRx ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   104
    // Only modified in constructor, if not created already reseted.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   105
    delete iRx;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   106
    iRx = NULL;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   107
    C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel iEmptyRxDfc 0x%x" ), iEmptyRxDfc ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   108
    // Only modified in constructor, if not created already reseted.
9
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
   109
    if (iEmptyRxDfc)
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
   110
    {	
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
   111
       iEmptyRxDfc->Cancel();
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
   112
    } 
0
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   113
    delete iEmptyRxDfc;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   114
    iEmptyRxDfc = NULL;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   115
    iPtrPtrToRxBuf = NULL;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   116
    iRouterIf = NULL;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   117
    C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel iRequests 0x%x" ), iEmptyRxDfc ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   118
    // Only modified in constructor, if not created already reseted.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   119
    delete iRequests;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   120
    iRequests = NULL;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   121
    C_TRACE( ( _T( "DP2PKernelChannel::~DP2PKernelChannel 0x%x 0x%x<" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   122
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   123
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   124
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   125
// Handling of the request from kernel api
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   126
// Puts calling thread waiting until TThreadMessage::SendReceive is completed
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   127
TInt DP2PKernelChannel::HandleRequest(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   128
        TThreadMessage& aMsg
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   129
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   130
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   131
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   132
    C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, aMsg.iValue ) );
9
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
   133
0
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   134
    __ASSERT_CRITICAL;      // From kern_priv.h published partner
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   135
    __ASSERT_NO_FAST_MUTEX; // From nk_priv.h published partner.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   136
    ASSERT_THREAD_CONTEXT_ALWAYS( ( EP2PKernelChannelNotThreadContext | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   137
    C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest 0x%x == 0x%x " ), iP2PProtocolId, EP2PAmountOfProtocols ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   138
    TInt valueToReturn( KErrAlreadyExists );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   139
    // Channel is not open, either still closed or open is pending.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   140
    if( EP2PAmountOfProtocols <= iP2PProtocolId )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   141
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   142
        // Accept only open and close calls
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   143
        switch( aMsg.iValue )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   144
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   145
            // Open and close calls are legal
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   146
            case EP2PAsyncOpen:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   147
            case EP2PClose:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   148
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   149
                C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest open or close 0x%x" ), this ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   150
                valueToReturn = aMsg.SendReceive( &iKernelChMsgQue );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   151
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   152
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   153
            case KMaxTInt:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   154
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   155
                // Accept only open cancellation when channel is not open.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   156
                ASSERT_RESET_ALWAYS( ( KMaxTInt & aMsg.Int0() == EP2PAsyncOpen ), ( EP2PKernelChannelWrongParam3 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   157
                C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest open cancel 0x%x" ), this ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   158
                valueToReturn = aMsg.SendReceive( &iKernelChMsgQue );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   159
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   160
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   161
            default:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   162
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   163
                ASSERT_RESET_ALWAYS( ( 0 ), ( EP2PKernelChannelWrongParam | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   164
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   165
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   166
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   167
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   168
    // Channel is open.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   169
    else
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   170
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   171
        // Accept all calls except open.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   172
        if( EP2PAsyncOpen != aMsg.iValue )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   173
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   174
            valueToReturn = aMsg.SendReceive( &iKernelChMsgQue );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   175
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   176
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   177
    C_TRACE( ( _T( "DP2PKernelChannel::HandleRequest 0x%x 0x%x %d<" ), this, iP2PProtocolId, valueToReturn ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   178
    return valueToReturn;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   179
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   180
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   181
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   182
// From MP2PRouterChIf start
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   183
// Called only in router extension thread context.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   184
void DP2PKernelChannel::ConnectionLost()
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   185
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   186
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   187
    C_TRACE( ( _T( "DP2PKernelChannel::ConnectionLost 0x%x 0x%x %d %d 0x%x>" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   188
    EnqueChannelRequestCompleteDfc( EP2PAsyncConnectionLost, KErrNotReady );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   189
    ResetQueues();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   190
    //Closing( iP2PProtocolId );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   191
    C_TRACE( ( _T( "DP2PKernelChannel::ConnectionLost 0x%x 0x%x %d %d 0x%x<" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   192
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   193
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   194
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   195
// Called only in router extension thread context.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   196
void DP2PKernelChannel::EnqueChannelRequestCompleteDfc(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   197
        TInt aRequest,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   198
        TInt aStatusToComplete
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   199
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   200
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   201
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   202
    C_TRACE( ( _T( "DP2PKernelChannel::EnqueChannelRequestCompleteDfc 0x%x 0x%x %d %d 0x%x>" ), this, iP2PProtocolId, aRequest, aStatusToComplete ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   203
    ASSERT_THREAD_CONTEXT_ALWAYS( ( EP2PKernelChannelNotThreadContext2 | EDP2PKernelChannelId << KClassIdentifierShift ) );
9
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
   204
    //  assert router ext thread context
0
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   205
    if( aRequest == EP2PAsyncOpen )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   206
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   207
        iP2PProtocolId = ( KErrNone == aStatusToComplete || KErrInUse == aStatusToComplete ) ? ~iP2PProtocolId : EP2PAmountOfProtocols;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   208
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   209
    iRequests->Complete( aRequest, aStatusToComplete );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   210
    C_TRACE( ( _T( "DP2PKernelChannel::EnqueChannelRequestCompleteDfc 0x%x 0x%x %d %d 0x%x<" ), this, iP2PProtocolId, aRequest, aStatusToComplete ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   211
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   212
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   213
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   214
// Called in 1...N transceivers thread context
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   215
void DP2PKernelChannel::ReceiveMsg(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   216
        const TDesC8& aMessage
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   217
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   218
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   219
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   220
    C_TRACE( ( _T( "DP2PKernelChannel::ReceiveMsg 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, &aMessage ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   221
    ASSERT_THREAD_CONTEXT_ALWAYS( ( EP2PKernelChannelNotThreadContext3 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   222
    iRx->Add( aMessage );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   223
    iEmptyRxDfc->Enque();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   224
    C_TRACE( ( _T( "DP2PKernelChannel::ReceiveMsg 0x%x 0x%x 0x%x<" ), this, iP2PProtocolId, &aMessage ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   225
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   226
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   227
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   228
// From MP2PRouterChIf end
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   229
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   230
// Internal functions
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   231
void DP2PKernelChannel::EmptyRxDfc(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   232
        TAny* aPtr // self
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   233
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   234
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   235
    
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   236
    DP2PKernelChannel& chTmp = *reinterpret_cast<DP2PKernelChannel*>( aPtr );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   237
    C_TRACE( ( _T( "DP2PKernelChannel::EmptyRxDfc 0x%x 0x%x>" ), &chTmp, chTmp.iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   238
    if( chTmp.iRequests->IsPending( EP2PAsyncReceive ) && chTmp.iRx->Count() > 0 )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   239
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   240
        C_TRACE( ( _T( "DP2PKernelChannel::EmptyRxDfc 0x%x 0x%x writing to kernel client" ), &chTmp, chTmp.iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   241
        TDes8*& tmpWrite = *chTmp.iPtrPtrToRxBuf;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   242
        tmpWrite = &chTmp.iRx->Get();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   243
        C_TRACE( ( _T( "DP2PKernelChannel::EmptyRxDfc 0x%x 0x%x 0x%x 0x%x clientRx 0x%x " ), &chTmp, chTmp.iP2PProtocolId, chTmp.iPtrPtrToRxBuf, &chTmp.iPtrPtrToRxBuf, *chTmp.iPtrPtrToRxBuf ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   244
        chTmp.EnqueChannelRequestCompleteDfc( EP2PAsyncReceive, KErrNone );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   245
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   246
    else
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   247
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   248
        C_TRACE( ( _T( "DP2PKernelChannel::EmptyRxDfc 0x%x 0x%x no receive active or no message" ), &chTmp, chTmp.iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   249
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   250
    C_TRACE( ( _T( "DP2PKernelChannel::EmptyRxDfc 0x%x 0x%x <" ), &chTmp, chTmp.iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   251
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   252
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   253
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   254
void DP2PKernelChannel::MsgQDfc(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   255
        TAny* aPtr
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   256
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   257
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   258
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   259
    C_TRACE( ( _T( "DP2PKernelChannel::MsgQDfc>" ) ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   260
    DP2PKernelChannel* tmp = reinterpret_cast<DP2PKernelChannel*>( aPtr );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   261
    tmp->HandleThreadMsg( static_cast<TThreadMessage&>(*tmp->iKernelChMsgQue.iMessage ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   262
    C_TRACE( ( _T( "DP2PKernelChannel::MsgQDfc<" ) ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   263
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   264
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   265
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   266
void DP2PKernelChannel::HandleThreadMsg(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   267
         TThreadMessage& aMsg
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   268
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   269
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   270
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   271
    C_TRACE( ( _T( "DP2PKernelChannel::HandleThreadMsg 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, &aMsg ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   272
    TThreadMessage& m = ( aMsg );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   273
    TInt completeValue( KErrNone );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   274
    TBool complete( ETrue );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   275
    switch( m.iValue )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   276
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   277
        // All asynchronous requests. Return result after DFC function is run.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   278
        case EP2PAsyncReceive:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   279
        case EP2PAsyncOpen:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   280
        case EP2PAsyncConnectionLost:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   281
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   282
            // No need to check return value in async functions, completed to client from DFC.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   283
            HandleDfcRequest( m );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   284
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   285
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   286
        // From synchronized request return the result immediately
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   287
        case EP2PClose:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   288
        case EP2PAllocateBlock:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   289
        case EP2PDeallocateBlock:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   290
        case EP2PSend:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   291
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   292
            completeValue = HandleSyncRequest( m );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   293
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   294
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   295
        case KDestroyChannelMsg:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   296
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   297
            completeValue = KErrNone;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   298
            // Don't receive anymore messages.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   299
            complete = EFalse;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   300
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   301
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   302
        case KMaxTInt:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   303
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   304
            completeValue = KErrNone;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   305
            DoCancel( KMaxTInt, m.Int0() );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   306
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   307
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   308
        default:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   309
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   310
            ASSERT_RESET_ALWAYS( 0, ( EP2PKernelChannelWrongRequest | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   311
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   312
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   313
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   314
    m.Complete( completeValue, complete );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   315
    C_TRACE( ( _T( "DP2PKernelChannel::HandleThreadMsg 0x%x 0x%x<" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   316
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   317
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   318
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   319
void DP2PKernelChannel::HandleDfcRequest(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   320
        TThreadMessage& aMsg
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   321
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   322
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   323
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   324
    C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, &aMsg ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   325
    TThreadMessage& m = ( aMsg );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   326
    TInt request( m.iValue );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   327
    ASSERT_RESET_ALWAYS( m.iArg, ( EP2PKernelChannelNullParam | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   328
    // If request already active.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   329
    ASSERT_RESET_ALWAYS( EP2PLastAsyncRequest > ( request ), ( EP2PKernelChannelWrongRequest4 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   330
    if( iRequests->IsPending( request) )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   331
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   332
        C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest existing 0x%x 0x%x request 0x%x" ), this, iP2PProtocolId, request ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   333
        TRACE_ASSERT_INFO( 0, ( (TUint8)iP2PProtocolId << KProtocolIdShift | (TUint8)request << KExtraInfoShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   334
        // Should not give same request object twice before completing the first one.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   335
        ASSERT_RESET_ALWAYS( 0, ( EP2PKernelChannelSameRequestTwice | static_cast<TUint8>( iP2PProtocolId ) << KProtocolIdShift | static_cast<TUint8>( request ) << KExtraInfoShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   336
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   337
    else
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   338
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   339
        C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest 0x%x 0x%x handling %d" ), this, iP2PProtocolId, request ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   340
        //NOTE! These are tight to parameter passing!!
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   341
        TUint32* tablePtr = reinterpret_cast<TUint32*>( m.Ptr0() );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   342
        TInt* dfcStatus = reinterpret_cast<TInt*>( tablePtr[ 0 ] );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   343
        TDfc* dfc = reinterpret_cast<TDfc*>( tablePtr[ 1 ] );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   344
        ASSERT_RESET_ALWAYS( dfcStatus, ( EP2PKernelChannelNullParam2 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   345
        ASSERT_RESET_ALWAYS( dfc, ( EP2PKernelChannelNullParam3 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   346
        iRequests->SetPending( request, dfc, dfcStatus );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   347
        switch( request )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   348
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   349
            case EP2PAsyncOpen:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   350
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   351
                iP2PProtocolId = tablePtr[ KThirdParam ];
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   352
                iP2PProtocolId = ~iP2PProtocolId;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   353
                C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest EP2PNokiaKernelOpen 0x%x 0x%x 0x%x" ), this, iP2PProtocolId, ~iP2PProtocolId ) );
9
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
   354
                iRouterIf->Connect( ~iP2PProtocolId, this );
0
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   355
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   356
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   357
            case EP2PAsyncReceive:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   358
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   359
                ASSERT_RESET_ALWAYS( !iPtrPtrToRxBuf, ( EP2PKernelChannelRxBufferNotReleased | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   360
                iPtrPtrToRxBuf = reinterpret_cast<TDes8**>( tablePtr[ KThirdParam ] );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   361
                C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest EIADAsyncReceive 0x%x 0x%x 0x%x 0x%x" ), this, iP2PProtocolId, iPtrPtrToRxBuf, &iPtrPtrToRxBuf ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   362
                iEmptyRxDfc->Enque();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   363
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   364
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   365
            case EP2PAsyncConnectionLost:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   366
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   367
                C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest EP2PAsyncConnectionLost 0x%x 0x%x" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   368
                // If the connection is already lost when function is called return immediately.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   369
                // This might happend in between calls to ::Open and ::NotifyClose
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   370
                if( !iRouterIf->ConnectionExist( iP2PProtocolId ) )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   371
                    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   372
                    EnqueChannelRequestCompleteDfc( EP2PAsyncConnectionLost, KErrNotReady );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   373
                    ResetQueues();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   374
                    //Closing( iP2PProtocolId );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   375
                    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   376
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   377
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   378
            default:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   379
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   380
                ASSERT_RESET_ALWAYS( 0, ( EP2PKernelChannelWrongRequest2 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   381
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   382
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   383
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   384
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   385
    C_TRACE( ( _T( "DP2PKernelChannel::HandleDfcRequest 0x%x 0x%x 0x%x<" ), this, iP2PProtocolId, &aMsg ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   386
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   387
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   388
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   389
TInt DP2PKernelChannel::HandleSyncRequest(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   390
        TThreadMessage& aMsg
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   391
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   392
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   393
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   394
    C_TRACE( ( _T( "DP2PKernelChannel::HandleSyncRequest 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, &aMsg ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   395
    TThreadMessage& m = ( aMsg );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   396
    TInt request( m.iValue );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   397
    ASSERT_RESET_ALWAYS( m.iArg, ( EP2PKernelChannelNullParam4 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   398
    TInt returnValue( KErrNone );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   399
    C_TRACE( ( _T( "DP2PKernelChannel::HandleSyncRequest 0x%x 0x%x handling %d" ), this, iP2PProtocolId, request ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   400
    TUint32* tablePtr = reinterpret_cast<TUint32*>( m.Ptr0() );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   401
    // NOTE! values depend on the P2P Kernel API parameters
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   402
    switch( request )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   403
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   404
        case EP2PClose:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   405
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   406
            C_TRACE( ( _T( "DP2PKernelChannel::HandleSyncRequest EP2PClose 0x%x 0x%x" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   407
            Closing( iP2PProtocolId );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   408
            C_TRACE( ( _T( "DP2PKernelChannel::HandleSyncRequest EP2PClose 0x%x 0x%x" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   409
            returnValue = KErrNone;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   410
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   411
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   412
        case EP2PAllocateBlock:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   413
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   414
            const TInt size = *reinterpret_cast<TInt*>( tablePtr[ KFirstParam ] );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   415
            TDes8*& block = *(reinterpret_cast<TDes8**>( tablePtr[ KSecondParam ] ));
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   416
            C_TRACE( ( _T( "DP2PKernelChannel:: EP2PAllocateBlock 0x%x 0x%x block 0x%x %d" ), this, iP2PProtocolId, block, size ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   417
            block = ( &MemApi::AllocBlock( size ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   418
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   419
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   420
        case EP2PDeallocateBlock:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   421
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   422
            TDes8& block = *reinterpret_cast<TDes8*>( tablePtr[ KFirstParam ] );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   423
            C_TRACE( ( _T( "DP2PKernelChannel::HandleSyncRequest EP2PAllocateBlock 0x%x 0x%x block 0x%x" ), this, iP2PProtocolId, &block ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   424
            // Needed to ensure that right channel is deleting the right block. (Could it be done otherways too?)
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   425
            if( iPtrPtrToRxBuf )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   426
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   427
                if ( &block == *iPtrPtrToRxBuf )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   428
                    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   429
                    C_TRACE( ( _T( "DP2PKernelChannel::HandleSyncRequest release 0x%x 0x%x clientRx 0x%x"), iPtrPtrToRxBuf, &iPtrPtrToRxBuf, *iPtrPtrToRxBuf ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   430
                    iPtrPtrToRxBuf = NULL;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   431
                    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   432
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   433
            MemApi::DeallocBlock( block );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   434
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   435
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   436
        case EP2PSend:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   437
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   438
            TDes8& block = *reinterpret_cast<TDes8*>( tablePtr[ KFirstParam ] );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   439
            C_TRACE( ( _T( "DISAKernelChannel::HandleSyncRequest EP2PSend 0x%x 0x%x block 0x%x" ), this, iP2PProtocolId, &block ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   440
            returnValue = iRouterIf->Send( block, iP2PProtocolId );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   441
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   442
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   443
        default:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   444
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   445
            ASSERT_RESET_ALWAYS( 0, ( EP2PKernelChannelWrongRequest3 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   446
            break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   447
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   448
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   449
    C_TRACE( ( _T( "DP2PKernelChannel::HandleSyncRequest 0x%x 0x%x 0x%x %d<" ), this, iP2PProtocolId, &aMsg, returnValue ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   450
    return returnValue;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   451
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   452
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   453
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   454
void DP2PKernelChannel::DoCancel(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   455
        TInt aRequest,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   456
        TInt aMask )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   457
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   458
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   459
    C_TRACE( ( _T( "DP2PKernelChannel::DoCancel 0x%x 0x%x>" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   460
    ASSERT_RESET_ALWAYS( EP2PLastAsyncRequest > ( aMask&aRequest ), EP2PKernelChannelOverTheLimits | EDP2PKernelChannelId << KClassIdentifierShift );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   461
    if( iRequests->IsPending( aMask&aRequest ) )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   462
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   463
        switch( aMask&aRequest )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   464
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   465
            case EP2PAsyncOpen:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   466
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   467
                C_TRACE( ( _T( "DP2PKernelChannel::DoCancel EP2PAsyncOpen 0x%x 0x%x" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   468
                ResetQueues();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   469
                Close( ~iP2PProtocolId );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   470
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   471
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   472
            case EP2PAsyncReceive:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   473
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   474
                C_TRACE( ( _T( "DP2PKernelChannel::DoCancel EIADAsyncReceive 0x%x 0x%x ptrs 0x%x 0x%x" ), this, iP2PProtocolId, iPtrPtrToRxBuf, &iPtrPtrToRxBuf ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   475
                iPtrPtrToRxBuf = NULL;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   476
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   477
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   478
            case EP2PAsyncConnectionLost:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   479
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   480
                C_TRACE( ( _T( "DP2PKernelChannel::DoCancel EP2PAsyncConnectionLost 0x%x 0x%x" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   481
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   482
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   483
            default:
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   484
                {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   485
                ASSERT_RESET_ALWAYS( 0, EP2PKernelChannelWrongRequest | EDP2PKernelChannelId << KClassIdentifierShift );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   486
                break;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   487
                }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   488
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   489
        EnqueChannelRequestCompleteDfc( aMask&aRequest, KErrCancel );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   490
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   491
    else
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   492
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   493
        C_TRACE( ( _T( "DP2PKernelChannel::DoCancel nothing to cancel 0x%x 0x%x" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   494
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   495
    C_TRACE( ( _T( "DP2PKernelChannel::DoCancel 0x%x 0x%x<" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   496
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   497
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   498
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   499
void DP2PKernelChannel::Close(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   500
        const TUint8 aP2PProtocolId
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   501
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   502
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   503
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   504
    C_TRACE( ( _T( "DP2PKernelChannel::Close 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, aP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   505
    if( EP2PAmountOfProtocols != iP2PProtocolId )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   506
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   507
        C_TRACE( ( _T( "DP2PKernelChannel::Close closing 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, aP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   508
        iRouterIf->Close( aP2PProtocolId );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   509
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   510
    iP2PProtocolId = EP2PAmountOfProtocols;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   511
    C_TRACE( ( _T( "DP2PKernelChannel::Close 0x%x 0x%x 0x%x<" ), this, iP2PProtocolId, aP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   512
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   513
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   514
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   515
void DP2PKernelChannel::Closing(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   516
        const TUint8 aP2PProtocolId
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   517
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   518
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   519
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   520
    C_TRACE( ( _T( "DP2PKernelChannel::Closing 0x%x 0x%x 0x%x>" ), this, iP2PProtocolId, aP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   521
    ResetQueues();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   522
    for( TInt i( EP2PLastSyncRequest ); i < EP2PLastAsyncRequest; ++i )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   523
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   524
        C_TRACE( ( _T( "DP2PKernelChannel::CancelRequests req to cancel %d" ), i ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   525
        DoCancel( KMaxTInt, i );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   526
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   527
    Close( iP2PProtocolId );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   528
    C_TRACE( ( _T( "DP2PKernelChannel::Closing 0x%x 0x%x 0x%x<" ), this, iP2PProtocolId, aP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   529
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   530
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   531
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   532
void DP2PKernelChannel::ResetQueues(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   533
        // None
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   534
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   535
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   536
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   537
    C_TRACE( ( _T( "DP2PKernelChannel::ResetQueues 0x%x 0x%x>" ), this, iP2PProtocolId ) );
9
8486d82aef45 modemadaptation release 2010wk40
mikaruus
parents: 0
diff changeset
   538
    //  assert router ext thread context
0
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   539
    if( iRx )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   540
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   541
        C_TRACE( ( _T( "DP2PKernelChannel::ResetQueues 0x%x 0x%x iRx 0x%x" ), this, iP2PProtocolId, iRx ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   542
        while( iRx->Count() )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   543
            {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   544
            MemApi::DeallocBlock( iRx->Get() );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   545
            }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   546
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   547
    C_TRACE( ( _T( "DP2PKernelChannel::ResetQueues 0x%x 0x%x<" ), this, iP2PProtocolId ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   548
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   549
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   550
// Internal functions
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   551
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   552
// Internal class
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   553
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   554
DP2PKernelChannel::DP2PKernelAsyncRequests::DP2PKernelAsyncRequests(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   555
        const TInt aSize
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   556
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   557
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   558
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   559
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::DP2PKernelAsyncRequests size %d>" ), aSize ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   560
    iRequestLock = new NFastMutex();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   561
    iShDfcFunctionList = new TDfc*[ aSize ];
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   562
    iShRequestStatusList = new TInt*[ aSize ];
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   563
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::DP2PKernelAsyncRequests<" ) ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   564
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   565
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   566
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   567
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   568
DP2PKernelChannel::DP2PKernelAsyncRequests::~DP2PKernelAsyncRequests()
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   569
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   570
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   571
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::~DP2PKernelAsyncRequests>" ) ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   572
    // Delete space reserved for the array not the contents of the array, so mem behind pointers that are not owned are not deleted.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   573
    delete iShDfcFunctionList;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   574
    delete iShRequestStatusList;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   575
    // Deletes lock
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   576
    delete iRequestLock;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   577
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::~DP2PKernelAsyncRequests<" ) ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   578
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   579
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   580
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   581
void DP2PKernelChannel::DP2PKernelAsyncRequests::SetPending(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   582
        const TUint aRequest,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   583
        TDfc* aDfc,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   584
        TInt* aStatus
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   585
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   586
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   587
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   588
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::SetPending %d 0x%x 0x%x>" ), aRequest, aDfc, aStatus ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   589
    ASSERT_RESET_ALWAYS( aDfc, ( EP2PKernelChannelNullParam5 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   590
    ASSERT_RESET_ALWAYS( aStatus, ( EP2PKernelChannelNullParam5 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   591
    ASSERT_RESET_ALWAYS( ( EP2PLastAsyncRequest > aRequest && EP2PAsyncReceive <= aRequest ), ( EP2PKernelChannelOverTheLimits2 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   592
    // Note asserts must be done before holding the lock.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   593
    NKern::FMWait( iRequestLock );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   594
    iShDfcFunctionList[ aRequest ] = aDfc;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   595
    iShRequestStatusList[ aRequest ] = aStatus;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   596
    *iShRequestStatusList[ aRequest ] = KRequestPending;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   597
    NKern::FMSignal( iRequestLock );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   598
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::SetPending %d 0x%x 0x%x<" ), aRequest, aDfc, aStatus ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   599
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   600
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   601
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   602
TBool DP2PKernelChannel::DP2PKernelAsyncRequests::IsPending(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   603
        const TUint aRequest
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   604
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   605
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   606
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   607
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::IsPending %d>" ), aRequest ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   608
    ASSERT_RESET_ALWAYS( ( EP2PLastAsyncRequest > aRequest && EP2PAsyncReceive <= aRequest ), ( EP2PKernelChannelOverTheLimits3 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   609
    TBool ret( EFalse );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   610
    NKern::FMWait( iRequestLock );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   611
    ret = ( iShDfcFunctionList[ aRequest ] && iShRequestStatusList[ aRequest ] ) ? ETrue : EFalse;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   612
    NKern::FMSignal( iRequestLock );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   613
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::IsPending %d %d<" ), aRequest, ret ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   614
    return ret;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   615
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   616
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   617
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   618
void DP2PKernelChannel::DP2PKernelAsyncRequests::Complete(
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   619
        const TUint aRequest,
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   620
        const TInt aStatusToComplete
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   621
        )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   622
    {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   623
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   624
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::Complete %d>" ), aRequest ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   625
    // Check that request is legal.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   626
    ASSERT_RESET_ALWAYS( ( EP2PLastAsyncRequest > aRequest && EP2PAsyncReceive <= aRequest ), ( EP2PKernelChannelOverTheLimits4 | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   627
    NKern::FMWait( iRequestLock );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   628
    TDfc* completeDfc = iShDfcFunctionList[ aRequest ];
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   629
    if( ( completeDfc && iShRequestStatusList[ aRequest ] ) )
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   630
        {
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   631
        // Writing straight to clients pointer. There is a risk that malfunctioning client can mess up it's own pointer, if used out side of rx dfc, but what can you do..
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   632
        *iShRequestStatusList[ aRequest ] = aStatusToComplete;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   633
        ASSERT_RESET_ALWAYS( !completeDfc->Queued(), ( EP2PKernelChannelDfcAlreadyQueued | EDP2PKernelChannelId << KClassIdentifierShift ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   634
        completeDfc->Enque();
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   635
        iShDfcFunctionList[ aRequest ] = NULL;
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   636
        }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   637
    NKern::FMSignal( iRequestLock );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   638
    C_TRACE( ( _T( "DP2PKernelAsyncRequests::Complete %d<" ), aRequest ) );
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   639
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   640
    }
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   641
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   642
// Internal class
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   643
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   644
// End of file.
63b37f68c1ce First Contribution. Vanilla as it came from Nokia
<dalarub>
parents:
diff changeset
   645