linklayerprotocols/pppnif/INC/PPPLOG.H
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent 
       
    19 */
       
    20 
       
    21 #if !defined(__PPPLOG_H__)
       
    22 #define __PPPLOG_H__
       
    23 
       
    24 #include <comms-infras/commsdebugutility.h>
       
    25 #include <comms-infras/ss_protflow.h>
       
    26 #include "PPPSOCK.H"
       
    27 #include "PPPDEF.H"
       
    28 
       
    29 // ss_log.h is included
       
    30 #if !defined(LOG)
       
    31 
       
    32 #if defined (__FLOG_ACTIVE)
       
    33 
       
    34 #define ESOCK_LOGGING_ACTIVE
       
    35 #define LOG(a)		a
       
    36 #else
       
    37 #define LOG(a)
       
    38 #endif
       
    39 
       
    40 #endif
       
    41 
       
    42 const TInt KMaxTcpDumpLogFileName = 58;
       
    43 
       
    44 /** Packet frame file format */
       
    45 enum {EpppDumpLogFormat,ElastLogFormat};
       
    46 
       
    47 /** Format of packets to log in the packet frame file */
       
    48 enum {EpppLogLinkFormat,ErawIpLogLinkFormat,ElastLogLinkFormat};
       
    49 
       
    50 /** Data transfer direction (defined by pppdump log spec) */
       
    51 enum {EpppDirectionSend=1,EpppDirectionReceive=2};
       
    52 
       
    53 /**
       
    54 PPP debug logging class.
       
    55 Manages textual output and binary packet dump files.
       
    56 @internalTechnology
       
    57 */
       
    58 NONSHARABLE_CLASS(CPppLog) : public CBase
       
    59 	{
       
    60 public:
       
    61 	static const TInt KHexDumpWidth = 16;
       
    62 
       
    63 	static CPppLog* NewL();
       
    64 	virtual ~CPppLog();
       
    65 	void SetLogFileNameL(const TDesC& aName);
       
    66 	
       
    67 private:
       
    68 	CPppLog();
       
    69 	void ConstructL();
       
    70 	
       
    71 private:
       
    72 	HBufC* iLogFileName;
       
    73 	TBuf8<KMaxTcpDumpLogFileName> iTcpDumpLogFileName;
       
    74 	__FLOG_DECLARATION_MEMBER;
       
    75 	
       
    76         /** ETrue once the file header has been written to the packet dump file */
       
    77 	TBool iLogHeaderDone;
       
    78 	
       
    79 	/** Packet dump file format to use */
       
    80 	TInt iLogFormat;
       
    81 	
       
    82 	/** What should be logged in the packet dump file */
       
    83 	TInt iLogType;
       
    84 	
       
    85 	/** Time of last packet logged */
       
    86 	TTime iTimeOrigin;
       
    87 
       
    88 public:
       
    89 	virtual void Write(const TDesC& aDes);
       
    90 	virtual void Printf(const TRefByValue<const TDesC> aFmt, ...);
       
    91 	void HexDump(const TText* aHeader, const TText* aMargin, const TUint8* aPtr, TInt aLen, TInt aWidth = KHexDumpWidth);
       
    92 //
       
    93 	void Dump(RMBufChain& aPacket, TInt aChannel);
       
    94 	void DumpPhase(TPppPhase aOldPhase, TPppPhase aNewPhase);
       
    95 	void DumpState(const TText* aFsm, TPppFsmState aOldState, TPppFsmState aNewState);
       
    96     void DumpFrame(TInt direction, const TDesC8& aBuffer);
       
    97     void DumpFrameFileHeader(TInt aLogFormat, TInt aLogType);
       
    98     
       
    99 private:
       
   100 	TInt DumpLcp(TPtrC8& aDes);
       
   101 	TInt DumpPap(TPtrC8& aDes);
       
   102 	TInt DumpChap(TPtrC8& aDes);
       
   103 	TInt DumpCbcp(TPtrC8& aDes);
       
   104 	TInt DumpLcpOption(TPtrC8& aDes);
       
   105 	TInt DumpIpcp(TPtrC8& aDes);
       
   106 	TInt DumpIp6cp(TPtrC8& aDes);
       
   107 	TInt DumpIpcpOption(TPtrC8& aDes);
       
   108 	TInt DumpIp6cpOption(TPtrC8& aDes);
       
   109 	void DumpChapType(const TUint8* aPtr);
       
   110 	TInt DumpCcp(TPtrC8& aDes);
       
   111 	TInt DumpCcpOption(TPtrC8& aDes);
       
   112 	void DumpBytes(const TText* aMargin, const TUint8* aPtr, TInt aLen);
       
   113 	TInt DumpIp(TPtrC8& aDes);
       
   114 	TInt DumpIp6(TPtrC8& aDes);
       
   115 	TInt DumpIp6MainHeader(TPtrC8& aDes);
       
   116 	TInt DumpVjUncompTcp(TPtrC8& aDes);
       
   117 	TInt DumpVjCompTcp(TPtrC8& aDes);
       
   118 	TUint16 DecodeDelta(TUint8 * & aPtr);
       
   119 	TInt16 DecodeSignedDelta(TUint8 * & aPtr);
       
   120 	TInt DumpTcp(TPtrC8& aDes, TUint32 aSrcA, TUint32 aDstA, TInt aLength);
       
   121 	TInt DumpIcmp(TPtrC8& aDes, TInt aLength);
       
   122 	TInt DumpUdp(TPtrC8& aDes, TUint32 aSrcA, TUint32 aDstA, TInt aLength);
       
   123 	TInt DumpDns(TPtrC8& aDes);
       
   124 //
       
   125 	TInt DumpDnsNameAndType(TPtrC8& aDes);
       
   126 	TInt DumpDnsQuery(TPtrC8& aDes);
       
   127 	TInt DumpDnsAnswer(TPtrC8& aDes);
       
   128 	TInt UpdatePtr(TPtrC8& aDes, TUint8* ptr);
       
   129 
       
   130 	const TText* ProtocolToText(TUint aValue);
       
   131 	const TText* PhaseToText(TPppPhase aPhase);
       
   132 	const TText* StateToText(TPppFsmState aState);
       
   133 	const TText* LcpCodeToText(TUint aValue);
       
   134 	const TText* LcpOptToText(TUint aValue);
       
   135 	const TText* FsmCodeToText(TUint aValue);
       
   136 	const TText* CallbackOpToText(TUint aValue);
       
   137 	const TText* PapCodeToText(TUint aValue);
       
   138 	const TText* ChapCodeToText(TUint aValue);
       
   139 	const TText* CbcpCodeToText(TUint aValue);
       
   140 	const TText* IpcpCodeToText(TUint aValue);
       
   141 	const TText* Ip6cpCodeToText(TUint aValue);
       
   142 	const TText* CcpCodeToText(TUint aValue);
       
   143 	const TText* IpProtocolToText(TUint aValue);
       
   144 
       
   145 	void PppDumpFileHeader();
       
   146 	void PppDumpFrame(TInt direction, TUint32 timeStep, const TDesC8& aBuffer);
       
   147 	};
       
   148 
       
   149 #endif