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