natfw/natfwconnectionmultiplexer/src/cncmicmpsender.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 15:35:13 +0300
branchRCL_3
changeset 45 3f7c7e6eea8a
parent 0 1bce908db942
permissions -rw-r--r--
Revision: 201032 Kit: 201035

/*
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:    ICMP sender
*
*/




#include "cncmicmpsender.h"
#include "ncmconnectionmultiplexerlogs.h"

// ---------------------------------------------------------------------------
// CNcmIcmpSender::CNcmIcmpSender
// ---------------------------------------------------------------------------
//
CNcmIcmpSender::CNcmIcmpSender( RSocket& aSocket ) :
    CActive( EPriorityUserInput ),
    iIcmpSocket( aSocket )
    {
    CActiveScheduler::Add( this );
    }


// ---------------------------------------------------------------------------
// CNcmIcmpSender::~CNcmIcmpSender
// ---------------------------------------------------------------------------
//
CNcmIcmpSender::~CNcmIcmpSender()
    {
    __CONNECTIONMULTIPLEXER( "CNcmIcmpSender::~CNcmIcmpSender" )
    
    Cancel();
    delete iData;
    }


// -----------------------------------------------------------------------------
// CNcmIcmpSender::NewL
// -----------------------------------------------------------------------------
//
CNcmIcmpSender* CNcmIcmpSender::NewL( RSocket& aSocket )
    {
    CNcmIcmpSender* self =
        new ( ELeave ) CNcmIcmpSender( aSocket );
    return self;
    }

    
// ---------------------------------------------------------------------------
// CNcmIcmpSender::Send
// ---------------------------------------------------------------------------
//
void CNcmIcmpSender::Send( const TDesC8& aMessage,
    const TInetAddr& aDestinationAddr )
    {
    __CONNECTIONMULTIPLEXER_ADDRLOG(
        "CNcmIcmpSender::Send - ADDRESS: ", aDestinationAddr )
    
    iDestination = aDestinationAddr;
    if ( !IsActive() )
        {
        if ( aDestinationAddr.IsUnspecified() )
            {
            __CONNECTIONMULTIPLEXER( 
                "CNcmIcmpSender::Send - Error, DESTINATION not set" )

            return;
            }
        else
            {
            delete iData;
            iData = NULL;
            iData = aMessage.Alloc();

            if ( iData )
                {
                iIcmpSocket.SendTo( *iData, iDestination, 0, iStatus );
                SetActive();
                }
            }
        }
    }


// ---------------------------------------------------------------------------
// From class CActive
//
// CNcmIcmpSender::RunL
// ---------------------------------------------------------------------------
//
void CNcmIcmpSender::RunL()
    {
    __CONNECTIONMULTIPLEXER_INT1( "CNcmIcmpSender::RunL STATUS: ", iStatus.Int() )
    }

    
// ---------------------------------------------------------------------------
// From class CActive
//
// CNcmIcmpSender::DoCancel
// ---------------------------------------------------------------------------
//
void CNcmIcmpSender::DoCancel()
    {
    __CONNECTIONMULTIPLEXER( "CNcmIcmpSender::DoCancel" )
         
    iIcmpSocket.CancelSend();
    }