vpnengine/kmdserver/inc/ikepcaptrace.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:  Class that logs ike messages in pcap format
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef IKEPCAPTRACE_H
       
    19 #define IKEPCAPTRACE_H
       
    20 
       
    21 #include <f32file.h>
       
    22 
       
    23 class TInetAddr;
       
    24 
       
    25 /**
       
    26  *  PCap tracer of IKE messages.
       
    27  *
       
    28  *  Class that logs ike messages in pcap format
       
    29  * 
       
    30  */
       
    31 class CIkePcapTrace : public CBase
       
    32     {        
       
    33 public:
       
    34     enum TEncryptionType
       
    35         {
       
    36         EEncrDes = 2, 
       
    37         EEncrDes3 = 3,
       
    38         EEncrAesCbc = 12
       
    39         };
       
    40     
       
    41     static CIkePcapTrace* NewL(const TDesC& aLogFolder);
       
    42     ~CIkePcapTrace();
       
    43 
       
    44 
       
    45     /**
       
    46      * Traces the IKE message. 
       
    47      *
       
    48      * @param aMessage Traced IKE message
       
    49      * @param aSourceAddress IP address of the message sender (only IPv4 is supported)
       
    50      * @param aDestinationAddress IP address of the message receiver  (only IPv4 is supported)
       
    51      * @param aEncryptionType Used encryption algorithm. 
       
    52      *                        If the aMessage datagram is IKEv1 or if the IKEv2 datagram
       
    53      *                        does not contain encryption payload this parameter is not used.
       
    54      */
       
    55     void TraceMessage(const TDesC8& aMessage, 
       
    56                       const TInetAddr& aSourceAddress, 
       
    57                       const TInetAddr& aDestinationAddress,
       
    58                       TEncryptionType aEncryptionType);
       
    59     
       
    60 private:
       
    61     CIkePcapTrace();
       
    62     void ConstructL(const TDesC& aLogFolder);
       
    63 
       
    64     void DoTraceMessage(TPtr8& aMsgCopy, 
       
    65                         const TInetAddr& aSourceAddress, 
       
    66                         const TInetAddr& aDestinationAddress,
       
    67                         TEncryptionType aEncryptionType);
       
    68     
       
    69     
       
    70     TInt WritePcapHeader();
       
    71     
       
    72     TInt WriteRecordHeader(TUint32 aIkeMsgLength);
       
    73     TInt WriteIpAndUdpHeader(const TDesC8& aMessage,
       
    74                              TInetAddr aSourceAddress, 
       
    75                              TInetAddr aDestinationAddress);
       
    76     TInt WriteNonEspMarker();
       
    77     TInt WriteIkeMessage(TPtr8& aMsgCopy, TEncryptionType aEncryptionType);
       
    78     TInt WriteIkeV1Message(TPtr8& aMsgCopy);
       
    79     TInt WriteIkeV2Message(TPtr8& aMsgCopy, TEncryptionType aEncryptionType);
       
    80 
       
    81     
       
    82     RFs     iFileServer;
       
    83     RFile   iPcapFile;
       
    84     
       
    85     TBool iWriteTrace;
       
    86     };
       
    87 
       
    88 #endif //IKEPCAPTRACE_H
       
    89 
       
    90