vpnengine/ikeutils/src/vpnaddrinfo.cpp
changeset 0 33413c0669b9
child 10 68dc8923de26
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:  Utility for building internal address info.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ikedebug.h"
       
    20 #include "internaladdress.h"
       
    21 #include "vpnmandefs.h"
       
    22 
       
    23 // CLASS HEADER
       
    24 #include "vpnaddrinfo.h"
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // Build internal address info object from internal address information. 
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 void VPNAddrInfo::BuildVPNAddrInfo( const CInternalAddress* aInternalAddr,
       
    33                                     const TInetAddr& aDnsServerAddr,
       
    34                                     TVPNAddress& aVPNAddress,
       
    35                                     MIkeDebug& aDebug )
       
    36     {
       
    37     __ASSERT_DEBUG( aInternalAddr != NULL,
       
    38                     User::Invariant() );
       
    39     
       
    40     aVPNAddress.iVPNIfAddr = aInternalAddr->iClientIntAddr;
       
    41 
       
    42     //
       
    43     // Add DNS address(es) to the virtual TVPNAddress object
       
    44     // 
       
    45     TInt dnsCount = aInternalAddr->Count();
       
    46     if ( dnsCount )
       
    47         {
       
    48         aVPNAddress.iVPNIfDNS1 = *(aInternalAddr->At(0));
       
    49         if ( dnsCount > 1 )
       
    50             {
       
    51             aVPNAddress.iVPNIfDNS2 = *(aInternalAddr->At(1));          
       
    52             }
       
    53         }
       
    54     else
       
    55         {
       
    56         if ( aDnsServerAddr.Address() != KAFUnspec )
       
    57             {
       
    58 #ifdef _DEBUG                   
       
    59             TBuf<39> addrBuf;
       
    60             aDnsServerAddr.OutputWithScope( addrBuf );
       
    61             aDebug.LogWriteF(_L("DNS Server Address in IKE data %S"), &addrBuf);
       
    62 #endif //_DEBUG                         
       
    63             aVPNAddress.iVPNIfDNS1 = aDnsServerAddr;
       
    64             }
       
    65         else
       
    66             {
       
    67 #ifdef _DEBUG            
       
    68             aDebug.LogWrite(_L("DNS server not defined in policy"));            
       
    69 #endif // _DEBUG            
       
    70             }
       
    71         }   
       
    72     }   
       
    73 
       
    74