linklayerprotocols/pppnif/SPPP/pppscpr.cpp
changeset 0 af10295192d8
child 19 3652a10b304a
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // PPP SCpr
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 
       
    24 #include <comms-infras/linkmessages.h>
       
    25 #include <comms-infras/nifif.h>
       
    26 #include "pppscpr.h"
       
    27 #include "pppmessages.h"
       
    28 #include "CAgentAdapter.h"
       
    29 
       
    30 #include <elements/sd_mintercept.h>
       
    31 
       
    32 using namespace Messages;
       
    33 using namespace ESock;
       
    34 using namespace MeshMachine;
       
    35 
       
    36 #ifdef __CFLOG_ACTIVE
       
    37 #define KPppSCprTag KESockSubConnectionTag
       
    38 _LIT8(KPppSCprSubTag, "pppscpr");
       
    39 #endif
       
    40 
       
    41 //We reserve space for two preallocated activities that may start concurrently on the SCPR
       
    42 //node: destroy and data client stop.
       
    43 static const TUint KDefaultMaxPreallocatedActivityCount = 2;
       
    44 static const TUint KMaxPreallocatedActivitySize = sizeof(MeshMachine::CNodeRetryParallelActivity) + sizeof(MeshMachine::APreallocatedOriginators<4>);
       
    45 static const TUint KPPPSCPRPreallocatedActivityBufferSize = KDefaultMaxPreallocatedActivityCount * KMaxPreallocatedActivitySize;
       
    46 
       
    47 namespace PppSCprStates
       
    48 {
       
    49 
       
    50 
       
    51 DEFINE_SMELEMENT(TAwaitingPppLinkStatusChange, NetStateMachine::MState, PppSCprStates::TContext)
       
    52 TBool TAwaitingPppLinkStatusChange::Accept()
       
    53 	{
       
    54 	return iContext.iMessage.IsMessage<TPPPMessage::TPppLinkExpectingCallback>();
       
    55 	}
       
    56 
       
    57 DEFINE_SMELEMENT(TProcessPppLinkStatusChange, NetStateMachine::MStateTransition, PppSCprStates::TContext)
       
    58 void TProcessPppLinkStatusChange::DoL()
       
    59     {
       
    60    
       
    61     /* ------------------------------------------------------
       
    62      * Logic from Nifman's CNifAgentRef::LinkLayerDown
       
    63      * ------------------------------------------------------
       
    64      * iState is the state held in the CAgentAdapter
       
    65      *
       
    66      * iState = EConnecting;
       
    67      * iConnectType=EAgentStartCallBack;
       
    68      * iAgent->Connect(iConnectType);
       
    69      */
       
    70 
       
    71     iContext.Node().NotificationToAgent (EFlowToAgentEventTypeLinkLayerDown, NULL);
       
    72     iContext.Node().ConnectAgent(EAgentStartCallBack);
       
    73     }
       
    74 
       
    75 } // namespace PppSCprStates
       
    76 
       
    77 
       
    78 
       
    79 
       
    80 
       
    81 namespace PppSCprLinkStatusChangeActivity
       
    82 {
       
    83 DECLARE_DEFINE_NODEACTIVITY(ECFPppLinkStatusChangeActivity, PppLinkStatusChange, TPPPMessage::TPppLinkExpectingCallback)
       
    84 	FIRST_NODEACTIVITY_ENTRY(PppSCprStates::TAwaitingPppLinkStatusChange, MeshMachine::TNoTag)
       
    85     LAST_NODEACTIVITY_ENTRY(KNoTag, PppSCprStates::TProcessPppLinkStatusChange)
       
    86 NODEACTIVITY_END()
       
    87 }
       
    88 
       
    89 
       
    90 // PPP Activity Map
       
    91 namespace PppSCprActivities
       
    92 {
       
    93 DECLARE_DEFINE_ACTIVITY_MAP(pppSCprActivities)
       
    94    ACTIVITY_MAP_ENTRY(PppSCprLinkStatusChangeActivity, PppLinkStatusChange)
       
    95 ACTIVITY_MAP_END_BASE(AgentSCprActivities, agentSCprActivities)
       
    96 }
       
    97 
       
    98 
       
    99 // Basic constructor passing in an alternative activity map for the AgentSCpr
       
   100 CPppSubConnectionProvider* CPppSubConnectionProvider::NewL(ESock::CSubConnectionProviderFactoryBase& aFactory)
       
   101     {
       
   102     CPppSubConnectionProvider* self = new (ELeave) CPppSubConnectionProvider(aFactory, PppSCprActivities::pppSCprActivities::Self());
       
   103     CleanupStack::PushL(self);
       
   104     self->ConstructL(KPPPSCPRPreallocatedActivityBufferSize);
       
   105     CleanupStack::Pop();
       
   106     return self;
       
   107     }
       
   108 
       
   109 
       
   110 // C'tor
       
   111 CPppSubConnectionProvider::CPppSubConnectionProvider(ESock::CSubConnectionProviderFactoryBase& aFactory,
       
   112 	    const MeshMachine::TNodeActivityMap& aActivityMap)
       
   113 	: CAgentSubConnectionProvider(aFactory, aActivityMap)
       
   114     {
       
   115     // NOTE: We don't do a LOG_CREATE_NODE here because its already being done by
       
   116     // the base class. This class doesn't add anything and only overrides the activity
       
   117     // map. So for all intents and purposes this is still just an AgentSCpr.
       
   118     }
       
   119 
       
   120 
       
   121 
       
   122