linklayerprotocols/tunnelnif/src/TunnelAgentHandler.cpp
changeset 0 af10295192d8
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 // Agent Handling routines for Tunnel
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <comms-infras/nifprvar.h>			// for TAgentToFlowEventType
       
    24 #include "TunnelAgentHandler.h"
       
    25 #include "tunnelProvision.h"
       
    26 #include "tunnelnifvar.h"
       
    27 
       
    28 using namespace MeshMachine;
       
    29 using namespace Messages;
       
    30 
       
    31 CTunnelAgentHandler::CTunnelAgentHandler(const TTunnelInfo& aTunnelInfo)
       
    32   : iTunnelInfo(aTunnelInfo)
       
    33 	{
       
    34 	}
       
    35 
       
    36 void CTunnelAgentHandler::ServiceStarted()
       
    37 	{
       
    38 	// Notify Agent of the CFProtocol name.  iTunnelInfo points to provisioning information
       
    39 	// in AccessPointConfig.  This is valid while we are valid, but if there's ever a need
       
    40 	// to decouple this in future, then GetExtension[L]() can be called to retrieve the
       
    41 	// provisioning information on-the-fly.
       
    42 	NotificationToAgent(static_cast<TFlowToAgentEventType>(ENifToAgentEventTypeSetIfName), (TAny*)&iTunnelInfo.iIfName);
       
    43 	}
       
    44 
       
    45 TInt CTunnelAgentHandler::NotificationFromAgent(TAgentToFlowEventType aEvent, TAny* aInfo)
       
    46 /**
       
    47 Deal with notification calls from the Agent.
       
    48 
       
    49 Mainly the update/set address notifications that indicate a new Tunnel address.  A suitable
       
    50 TTunnelAddressMsg message is formed and sent to the CFProtocol.
       
    51 */
       
    52 	{
       
    53 	TBool updateFlag = EFalse;
       
    54 	switch (aEvent)
       
    55 		{
       
    56 	case EAgentToNifEventTypeUpdateAddress:
       
    57 		updateFlag = ETrue;
       
    58 		/* FALLTHROUGH */
       
    59 	case EAgentToNifEventTypeSetAddress:
       
    60 		{
       
    61         TInetIfConfig* ifConfig = reinterpret_cast<TInetIfConfig*>(aInfo);
       
    62 
       
    63 		// The TInetIfConfig object pointed to by aInfo is on the stack (not the heap) of the
       
    64 		// VPNConnAgt.  Consequently, the information is copied into a TunnelAddressMsg message
       
    65 		// and sent over to the Tunnel CFProtocol.  There can be several of these messages internally
       
    66 		// generated one after another in the Agent when the Tunnel address changes.
       
    67 		//
       
    68 		// Note that the message only contains those fields of TInetIfConfig that are
       
    69 		// actually used by the Tunnel CFProtocol.  This keeps the message size small and
       
    70 		// avoids having to use a "blob" message.
       
    71 #ifndef __GCCXML__
       
    72         //Using Null TCommsId, as PostMessageToFlow will substitue it properly.
       
    73 		return AnonPostMessageToFlow(
       
    74         		TTunnelAgentMessage::TTunnelSetAddress(
       
    75         				updateFlag,
       
    76         				ifConfig->iAddress,
       
    77         				ifConfig->iNameSer1,
       
    78         				ifConfig->iNameSer2
       
    79         				).CRef()
       
    80         		); // This will set the NodeChannelId properly before routing the message to the Flow.
       
    81 #else
       
    82 		return 0;
       
    83 #endif
       
    84 		}
       
    85 
       
    86 	default:
       
    87 		// All other messages handled in default base class manner.
       
    88 		return CAgentNotificationHandler::NotificationFromAgent(aEvent, aInfo);
       
    89 		}
       
    90 	}
       
    91