natfw/natfwconnectionmultiplexer/src/cncmicmpsender.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    ICMP sender
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "cncmicmpsender.h"
       
    22 #include "ncmconnectionmultiplexerlogs.h"
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // CNcmIcmpSender::CNcmIcmpSender
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CNcmIcmpSender::CNcmIcmpSender( RSocket& aSocket ) :
       
    29     CActive( EPriorityUserInput ),
       
    30     iIcmpSocket( aSocket )
       
    31     {
       
    32     CActiveScheduler::Add( this );
       
    33     }
       
    34 
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CNcmIcmpSender::~CNcmIcmpSender
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CNcmIcmpSender::~CNcmIcmpSender()
       
    41     {
       
    42     __CONNECTIONMULTIPLEXER( "CNcmIcmpSender::~CNcmIcmpSender" )
       
    43     
       
    44     Cancel();
       
    45     delete iData;
       
    46     }
       
    47 
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CNcmIcmpSender::NewL
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CNcmIcmpSender* CNcmIcmpSender::NewL( RSocket& aSocket )
       
    54     {
       
    55     CNcmIcmpSender* self =
       
    56         new ( ELeave ) CNcmIcmpSender( aSocket );
       
    57     return self;
       
    58     }
       
    59 
       
    60     
       
    61 // ---------------------------------------------------------------------------
       
    62 // CNcmIcmpSender::Send
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CNcmIcmpSender::Send( const TDesC8& aMessage,
       
    66     const TInetAddr& aDestinationAddr )
       
    67     {
       
    68     __CONNECTIONMULTIPLEXER_ADDRLOG(
       
    69         "CNcmIcmpSender::Send - ADDRESS: ", aDestinationAddr )
       
    70     
       
    71     iDestination = aDestinationAddr;
       
    72     if ( !IsActive() )
       
    73         {
       
    74         if ( aDestinationAddr.IsUnspecified() )
       
    75             {
       
    76             __CONNECTIONMULTIPLEXER( 
       
    77                 "CNcmIcmpSender::Send - Error, DESTINATION not set" )
       
    78 
       
    79             return;
       
    80             }
       
    81         else
       
    82             {
       
    83             delete iData;
       
    84             iData = NULL;
       
    85             iData = aMessage.Alloc();
       
    86 
       
    87             if ( iData )
       
    88                 {
       
    89                 iIcmpSocket.SendTo( *iData, iDestination, 0, iStatus );
       
    90                 SetActive();
       
    91                 }
       
    92             }
       
    93         }
       
    94     }
       
    95 
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // From class CActive
       
    99 //
       
   100 // CNcmIcmpSender::RunL
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CNcmIcmpSender::RunL()
       
   104     {
       
   105     __CONNECTIONMULTIPLEXER_INT1( "CNcmIcmpSender::RunL STATUS: ", iStatus.Int() )
       
   106     }
       
   107 
       
   108     
       
   109 // ---------------------------------------------------------------------------
       
   110 // From class CActive
       
   111 //
       
   112 // CNcmIcmpSender::DoCancel
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CNcmIcmpSender::DoCancel()
       
   116     {
       
   117     __CONNECTIONMULTIPLEXER( "CNcmIcmpSender::DoCancel" )
       
   118          
       
   119     iIcmpSocket.CancelSend();
       
   120     }