vpnengine/kmdserver/inc/kmdserver.h
changeset 0 33413c0669b9
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:  KMD server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_KMDSERVER_H
       
    20 #define C_KMDSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "ikesocketdefs.h"
       
    25 #include "vpnmandefs.h"
       
    26 
       
    27 _LIT( KKmdServerName, "!KMD server" );
       
    28 _LIT( KKmdServerImg, "kmdserver" );
       
    29 
       
    30 const TUid KServerUid3 = { 0x1000088A };
       
    31 
       
    32 const TInt KMyServerStackSize = 0x2000;           //  8KB
       
    33 const TInt KMyServerInitHeapSize = 0x1000;        //  4KB
       
    34 const TInt KMyServerMaxHeapSize = 0x1000000;      // 16MB
       
    35 
       
    36 const TInt KKmdServMajorVersion = 1;
       
    37 const TInt KKmdServMinorVersion = 0;
       
    38 const TInt KKmdServBuildVersion = 0;
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 class CIkeConnectionInterface;
       
    42 class CIkePluginHandler;
       
    43 class CIkePluginSessionHandler;
       
    44 class CKmdSession;
       
    45 class CVpnConnection;
       
    46 class CKmdDebugLogger;
       
    47 class CKmdEventLogger;
       
    48 class CSecpolReader;
       
    49 class MIkeDebug;
       
    50 class MIkePluginSessionHandlerCallback;
       
    51 
       
    52 /**
       
    53  *  KMD server.
       
    54  *  Implementation of KMD (Key Management Daemon) server. Handles creating of
       
    55  *  server-side client sessions.
       
    56  *
       
    57  *  @lib internal (kmdserver.exe)
       
    58  */
       
    59 class CKmdServer : public CPolicyServer
       
    60     {
       
    61 public:
       
    62 
       
    63     /**  KMD commands */
       
    64     enum 
       
    65         { 
       
    66         KKmdStartConnection,
       
    67         KKmdCancelStartConnection, 
       
    68         KKmdActivateAsync,
       
    69         KKmdCancelActivateAsync,        
       
    70         KKmdStopConnection,
       
    71         KKmdResolveAddress,
       
    72         KKmdCancelResolveAddress        
       
    73         };
       
    74     
       
    75     /**
       
    76      * Two-phased constructor. Called from kmd_starter.
       
    77      */    
       
    78     static CKmdServer* NewL();
       
    79     
       
    80     /**
       
    81      * Destructor.
       
    82      */
       
    83     ~CKmdServer();
       
    84     
       
    85     /**
       
    86      * Informs KMD server that KMD session has been closed.
       
    87      */
       
    88     void KmdSessionClosed();
       
    89     
       
    90     /**
       
    91      * Creates VPN connection object.
       
    92      * @param aVpnIapId VPN IAP Id
       
    93      */
       
    94     CVpnConnection& CreateVpnConnectionL( TUint32 aVpnIapId );
       
    95     
       
    96     /**
       
    97      * Gets VPN connection object.
       
    98      * @param aVpnIapId VPN IAP Id
       
    99      */
       
   100     CVpnConnection& GetVpnConnectionL( TUint32 aVpnIapId );
       
   101     
       
   102     /**
       
   103      * Deletes VPN connection object.
       
   104      * @param aVpnIapId VPN IAP Id
       
   105      */
       
   106     void DeleteVpnConnection( TUint32 aVpnIapId );
       
   107     
       
   108     /**
       
   109      * Creates IKE plugin session.
       
   110      * @param aIkeVersion IKE version
       
   111      * @param aIpVersion IP version
       
   112      * @param aConnection IKE connection interface
       
   113      * @param aVpnIapId VPN IAP id
       
   114      * @param aVpnNetId VPN NET id
       
   115      * @param aVpnInterfaceIndex VPN interface index
       
   116      * @param aDnsServerAddr DNS server address from IKE policy.
       
   117      * @param aCallback Callback interface
       
   118      * @return IKE plugin session handler
       
   119      */
       
   120     CIkePluginSessionHandler& CreateIkePluginSessionL( TInt aIkeVersion,
       
   121                                                        IkeSocket::TIpVersion aIpVersion,
       
   122                                                        CIkeConnectionInterface& aConnection,
       
   123                                                        TUint32 aVpnIapId,
       
   124                                                        TUint32 aVpnNetId,
       
   125                                                        TUint32 aVpnInterfaceIndex,
       
   126                                                        const TInetAddr& aDnsServerAddr,
       
   127                                                        MIkePluginSessionHandlerCallback& aCallback );    
       
   128     /**
       
   129      * Deletes IKE plugin session.
       
   130      * @param aIkeVersion IKE version
       
   131      * @param aVpnIapId VPN IAP Id
       
   132      */
       
   133     void DeleteIkePluginSession( TInt aIkeVersion,
       
   134                                  TUint32 aVpnIapId );
       
   135     
       
   136     /**
       
   137      * Returns debug trace interface.
       
   138      */
       
   139     MIkeDebug& Debug();
       
   140 
       
   141 // from base class CPolicyServer
       
   142 
       
   143     CSession2* NewSessionL( const TVersion& aVersion,
       
   144                             const RMessage2& aMessage ) const;
       
   145 
       
   146 private:
       
   147     CKmdServer();
       
   148     void ConstructL();            
       
   149 
       
   150     /**
       
   151      * Stops KMD server if there are no more KMD sessions or VPN connections.
       
   152      */
       
   153     void StopKmdServer();
       
   154 
       
   155 private: // data
       
   156     
       
   157     /**
       
   158      * KMD session count.
       
   159      * Own.
       
   160      */
       
   161     mutable TInt32                              iSessionCount;
       
   162     
       
   163     /**
       
   164      * VPN connections.
       
   165      * Own.
       
   166      */
       
   167     RPointerArray<CVpnConnection>               iVpnConnections;
       
   168     
       
   169     /**
       
   170      * IKE plugin handlers.
       
   171      * Own.
       
   172      */
       
   173     CIkePluginHandler*                          iIkePluginHandlers[2];
       
   174     
       
   175     /**
       
   176      * Debug logger.
       
   177      * Own.
       
   178      */
       
   179     CKmdDebugLogger*                            iDebugLogger;
       
   180     
       
   181     /**
       
   182      * Event logger.
       
   183      * Own.
       
   184      */
       
   185     CKmdEventLogger*                            iEventLogger;
       
   186     
       
   187     /**
       
   188      * Secpol reader.
       
   189      * Own.
       
   190      */
       
   191     CSecpolReader*                              iSecpolReader;
       
   192     
       
   193     /**
       
   194      * Policy server.
       
   195      * Own.
       
   196      */    
       
   197     RIpsecPolicyServ                            iIpsecPolicyServ;
       
   198 
       
   199     /**
       
   200      * KMD server range count.
       
   201      * Own.
       
   202      */
       
   203     static const TUint                          iKmdServerRangeCount;
       
   204     
       
   205     /**
       
   206      * KMD server ranges.
       
   207      * Own.
       
   208      */
       
   209     static const TInt                           iKmdServerRanges[];
       
   210     
       
   211     /**
       
   212      * KMD server element index.
       
   213      * Own.
       
   214      */
       
   215     static const TUint8                         iKmdServerElementIndex[];
       
   216 
       
   217     /**
       
   218      * KMD server elements.
       
   219      * Own.
       
   220      */
       
   221     static const CPolicyServer::TPolicyElement  iKmdServerElements[];
       
   222     
       
   223     /**
       
   224      * KMD server policy.
       
   225      * Own.
       
   226      */
       
   227     static const CPolicyServer::TPolicy         iKmdServerPolicy;
       
   228     };
       
   229 
       
   230 #endif // C_KMDSERVER_H