vpnengine/ikeutils/inc/pfkeysocketif.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:  VPN PFKEY socket interface
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_PFKEYSOCKET_H
       
    19 #define C_PFKEYSOCKET_H
       
    20 
       
    21 #include <es_sock.h>
       
    22 #include <in_sock.h>
       
    23 #include <lib_pfkey.h>
       
    24 #include "pfkeymsg.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class TIpsecSAData;
       
    28 class RSocketServ;
       
    29 class MIkeDebug;
       
    30 
       
    31 class MPFKeyMessageListener
       
    32     {
       
    33 public:
       
    34     virtual void PfkeyMessageReceived( const TPfkeyMessage& aReq ) = 0;
       
    35     };
       
    36 
       
    37 
       
    38 class TPendingSpiRequest
       
    39     {
       
    40 public:
       
    41     TPendingSpiRequest(TUint32& aSpi, TRequestStatus& aClientStatus): 
       
    42                        iSpi(aSpi), iClientStatus(aClientStatus){}
       
    43     
       
    44     TUint32& iSpi;
       
    45     TRequestStatus& iClientStatus;   
       
    46     };
       
    47 
       
    48 //
       
    49 // Register for ESP
       
    50 // and stay listening the PFKEY socket
       
    51 //
       
    52 class CPFKeySocketIf : public CActive
       
    53     {
       
    54 public:
       
    55     IMPORT_C static CPFKeySocketIf* NewL( MPFKeyMessageListener* aListener,
       
    56                                           MIkeDebug& aDebug );
       
    57 	~CPFKeySocketIf() ;
       
    58 
       
    59     //PFKEY related functions
       
    60 	void GetSpi( const TUint8 aType,
       
    61                  const TUint32 aSeq,
       
    62                  const TInetAddr& aSrc,
       
    63                  const TInetAddr& aDst,
       
    64                  TUint32& aSpi,
       
    65                  TRequestStatus& aClientStatus);
       
    66 	void CancelGetSpi(TRequestStatus& aClientStatus);
       
    67     
       
    68 	IMPORT_C void AcquireSAError( const TIpsecSAData& aSAData,
       
    69                                   const TInt aError );
       
    70     
       
    71 	IMPORT_C void UpdateSAL( const TIpsecSAData& aSAData );
       
    72     
       
    73 	IMPORT_C void AddSAL( const TIpsecSAData& aSAData );
       
    74     
       
    75 	IMPORT_C void DeleteSA( const TUint32 aSPI,
       
    76                             const TInetAddr& aSrc,
       
    77                             const TInetAddr& aDst,
       
    78                             const TUint8 aProtocol );
       
    79     
       
    80 	IMPORT_C void FlushSAs();    
       
    81 	
       
    82 private:
       
    83     CPFKeySocketIf( MPFKeyMessageListener* aListener,
       
    84                     MIkeDebug& aDebug );
       
    85     void ConstructL();        
       
    86 
       
    87     void AddUpdateSAL( const TUint8 aType,
       
    88                        const TIpsecSAData& aSAData );
       
    89     
       
    90     TUint32 NewSpi();
       
    91 
       
    92 #ifdef _DEBUG           
       
    93     void ShowMessageL( TPfkeyRecvMsg& aMsg );
       
    94 #endif  
       
    95     
       
    96 // from base class CActive    
       
    97     void RunL();
       
    98     void DoCancel();
       
    99     TInt RunError( TInt aError );     
       
   100 
       
   101 protected: // data
       
   102     MPFKeyMessageListener*  iListener;
       
   103     
       
   104 private: // data
       
   105     
       
   106     RSocketServ             iSocketServer;
       
   107     RSADB                   iSadb;    
       
   108     
       
   109     TPfkeyRecvMsg           iMsg;
       
   110     TUint32                 iSeq;    
       
   111     TUint32                 iSpiBase;        
       
   112     
       
   113     MIkeDebug&              iDebug;
       
   114     
       
   115     RArray<TPendingSpiRequest> iPendingSpiRequests;
       
   116     };
       
   117 
       
   118 #endif // C_PFKEYSOCKET_H