vpnengine/ikev2lib/inc/ikev2receiver.h
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Receiver of UDP datagrams
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_IKEV2RECEIVER_H
       
    20 #define C_IKEV2RECEIVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <in_sock.h>
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class MIkeDataInterface;
       
    27 class ThdrISAKMP;
       
    28 
       
    29 /**
       
    30  *  IKEv2 receiver callback interface.
       
    31  *  Callback interface which is used by CIkev2Receiver object to notify
       
    32  *  about received IKE message.
       
    33  * 
       
    34  *  @lib internal (ikev2lib.lib)
       
    35   */
       
    36 NONSHARABLE_CLASS(MIkev2ReceiverCallback)
       
    37     {
       
    38 public:        
       
    39     /**
       
    40      * Notifies about received IKE message.
       
    41      *
       
    42      * @param aIkeMsg IKE message
       
    43      * @param aSrcAddr Source IP address/port
       
    44      * @param aLocalPort Local port
       
    45      */
       
    46     virtual void IkeMsgReceived( const ThdrISAKMP& aIkeMsg,
       
    47                                  const TInetAddr& aSrcAddr,
       
    48                                  TInt aLocalPort ) = 0;
       
    49     
       
    50     /**
       
    51      * Notifies about receive error.
       
    52      * @param aStatus Error value
       
    53      */
       
    54     virtual void ReceiveError( TInt aError ) = 0;    
       
    55     };
       
    56 
       
    57 /**
       
    58  *  IKEv2 receiver.
       
    59  *  Active object provides functionality for receiving UDP datagrams.
       
    60  *
       
    61  *  @lib internal (ikev2lib.lib)
       
    62   */
       
    63 NONSHARABLE_CLASS(CIkev2Receiver) : public CActive
       
    64     {
       
    65 public:
       
    66     /**
       
    67      * Two-phased constructor.
       
    68      * @param aDataInterface IKE data interface
       
    69      * @param aCallback Callback interface
       
    70      */
       
    71     static CIkev2Receiver* NewL( MIkeDataInterface& aDataInterface,
       
    72                                  MIkev2ReceiverCallback& aCallback );
       
    73 
       
    74     /**
       
    75     * Destructor.
       
    76     */
       
    77     ~CIkev2Receiver();
       
    78 
       
    79     /**
       
    80     * Starts receiving.
       
    81     */
       
    82     void StartReceive();
       
    83     
       
    84     /**
       
    85     * Stops receiving.
       
    86     */
       
    87     void StopReceive();
       
    88     
       
    89 private:
       
    90     
       
    91     CIkev2Receiver( MIkeDataInterface& aDataInterface,
       
    92                     MIkev2ReceiverCallback& aCallback );
       
    93 
       
    94     void ConstructL();
       
    95     
       
    96     /**
       
    97      * Receives UDP data.
       
    98      */    
       
    99     void DoReceive();
       
   100     
       
   101 // from base class CActive            
       
   102     
       
   103     /**
       
   104      * From CActive
       
   105      * Handles completion of receive.
       
   106      */    
       
   107     void RunL();
       
   108 
       
   109     /**
       
   110      * From CActive
       
   111      * Handles cancellation of receive.
       
   112      */    
       
   113     void DoCancel();
       
   114         
       
   115 private: // data
       
   116     
       
   117     /**
       
   118      * UDP data.
       
   119      * Own.
       
   120      */
       
   121     HBufC8*                     iUdpData;
       
   122     
       
   123     /**
       
   124      * Source IP address/port.
       
   125      * Own.
       
   126      */
       
   127     TInetAddr                   iSrcAddr;
       
   128     
       
   129     /**
       
   130      * Local port.
       
   131      * Own.
       
   132      */
       
   133     TInt                        iLocalPort;
       
   134     
       
   135     /**
       
   136      * Informs if data is received.
       
   137      * Own.
       
   138      */
       
   139     TBool                       iReceivingData;
       
   140     
       
   141     /**
       
   142      * IKE data interface.
       
   143      * Not own.
       
   144      */
       
   145     MIkeDataInterface&          iDataInterface;
       
   146     
       
   147     /**
       
   148      * Callback interface.
       
   149      * Not own.
       
   150      */
       
   151     MIkev2ReceiverCallback&     iCallback;
       
   152     };
       
   153 
       
   154 #endif // C_Ikev2Receiver_H