vpnengine/ikesocket/inc/localaddressresolver.h
changeset 0 33413c0669b9
equal deleted inserted replaced
-1:000000000000 0:33413c0669b9
       
     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:  Local address resolver
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_LOCALADDRRESOLVER_H
       
    20 #define C_LOCALADDRRESOLVER_H
       
    21 
       
    22 #include <in_sock.h>
       
    23 #include "ikesocketdefs.h"
       
    24 
       
    25 // FORWARD DECLARATIONS
       
    26 class MIkeDebug;
       
    27 
       
    28 /**
       
    29  *  Local address resolver.
       
    30  *
       
    31  *  This class resolves local IP addresses (IPv4 and/or IPv6) for network
       
    32  *  connection (RConnection).
       
    33  *
       
    34  *  @lib ikesocket.lib
       
    35  */
       
    36 NONSHARABLE_CLASS( CLocalAddressResolver ) : public CBase
       
    37     { 
       
    38 public:
       
    39     /**
       
    40      * Two-phased constructor.
       
    41      * @param aSocketServer Socket server
       
    42      * @param aConnection RConnection which is used for resolving
       
    43      * @param aDebug Debug trace interface
       
    44      */
       
    45     static CLocalAddressResolver* NewL( RSocketServ& aSocketServer,
       
    46                                         RConnection& aConnection,
       
    47                                         MIkeDebug& aDebug);
       
    48     
       
    49     /**
       
    50      * Destructor.
       
    51      */
       
    52     ~CLocalAddressResolver();
       
    53     
       
    54     /**
       
    55      * Returns information about whether local IP address has been resolved.
       
    56      * @param aIpVersion IP version of local address (IPv4/IPv6)
       
    57      * @return Local IP address resolved or not.
       
    58      */
       
    59     TBool HasIPAddr( const IkeSocket::TIpVersion aIpVersion )  const;
       
    60     
       
    61     /**
       
    62      * Returns resolved local IP address.
       
    63      * @param aIpVersion IP version of local address (IPv4/IPv6)
       
    64      * @return Local IP address.
       
    65      */
       
    66     const TInetAddr& IPAddr( const IkeSocket::TIpVersion aIpVersion ) const;
       
    67     
       
    68     /**
       
    69      * Refreshes local IP addresses (IPv4 and/or IPv6). 
       
    70      * @param aIpVersion IP version of local address (IPv4/IPv6)
       
    71      * @return Local IP address.
       
    72      */
       
    73     TInt RefreshLocalAddresses();
       
    74 
       
    75     /**
       
    76      * Gets local IP address of interface.
       
    77      *
       
    78      * @param aIpVersion IP version of local IP address
       
    79      * @param aLocalIp Local IP address (returned)
       
    80      * @return Error status. KErrNotFound if address is not found.
       
    81      */
       
    82     TInt GetLocalAddress( const IkeSocket::TIpVersion aIpVersion,
       
    83                           TInetAddr& aLocalIp );
       
    84 
       
    85 private:
       
    86 
       
    87     CLocalAddressResolver( RSocketServ& aSocketServer,
       
    88                            RConnection& aConnection,
       
    89                            MIkeDebug& aDebug );
       
    90 
       
    91     void ConstructL();
       
    92     
       
    93     /**
       
    94      * Mathches information of an interface and the connection. 
       
    95      * @param aInfo Information of interface
       
    96      * @return aQuery Query for interface
       
    97      */
       
    98     TBool Match( const TSoInetInterfaceInfo& aInfo,
       
    99                  const TSoInetIfQuery& aQuery) const;
       
   100     
       
   101     /**
       
   102      * Sets local IP address if not yet set. 
       
   103      * @param aAddr IP address
       
   104      */
       
   105     void SetAddressIfNotSet( const TInetAddr& aAddr );
       
   106     
       
   107     /**
       
   108      * Sets local IPv4 address if not yet set. 
       
   109      * @param aAddr IP address
       
   110      */
       
   111     void SetIPv4AddressIfNotSet( const TInetAddr& aAddr );
       
   112     
       
   113     /**
       
   114      * Sets local IPv6 address if not yet set. 
       
   115      * @param aAddr IP address
       
   116      */
       
   117     void SetIPv6AddressIfNotSet( const TInetAddr& aAddr );    
       
   118 
       
   119 private: // data
       
   120     /**
       
   121      * IAP id of the connection.
       
   122      * Own.
       
   123      */
       
   124     TUint32             iIapId;
       
   125     
       
   126     /**
       
   127      * Socket server.
       
   128      * Not own.
       
   129      */
       
   130     RSocketServ&        iSocketServer;
       
   131     
       
   132     /**
       
   133      * Connection.
       
   134      * Not own.
       
   135      */
       
   136     RConnection&        iConnection;
       
   137     
       
   138     /**
       
   139      * Local IPv4 address.
       
   140      * Own.
       
   141      */
       
   142     TInetAddr           iIPv4Addr;
       
   143     
       
   144     /**
       
   145      * Local IPv6 address.
       
   146      * Own.
       
   147      */
       
   148     TInetAddr           iIPv6Addr;
       
   149     
       
   150     /**
       
   151      * Debug trace interface.
       
   152      * Not own.
       
   153      */
       
   154     MIkeDebug&          iDebug;
       
   155     };
       
   156     
       
   157 #endif // C_LOCALADDRRESOLVER_H
       
   158 
       
   159