2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Networking packet logging utility
28 #ifndef __PACKETLOGGER_H__
29 #define __PACKETLOGGER_H__
31 //this file defines the __FLOG_ACTIVE flag
32 #include <comms-infras/commsdebugutility.h>
34 #if defined __FLOG_ACTIVE
41 * Class containing methods for dumping ip
42 * packets of different formats.
43 * The output is written to the log file
44 * produced by comms debug utility.
45 * The supported output formats are listed with the
47 * This class cannot be derived from.
48 * This class should be active only if __FLOG_ACTIVE
49 * flag is defined. To ensure that use the macros
50 * defined below. A sample usage would be:
52 * __PACKETLOG_DECLARATION_MEMBER
53 * __PACKETLOG_NEWL(aTag, aFileName, aDumpType, aLinkType);
55 * __PACKETLOG_WRITE_PACKET(aPacket, aDirection);
59 * If the __FLOG_ACTIVE flag is not set, the macros map
62 class CPacketLogger : public CBase
65 /** Output dump formats supported by this class */
68 /** Produced dump will be in tcp dump format */
70 /** Produced dump will be in ppp dump format */
75 IMPORT_C static CPacketLogger* NewL(const TDesC8& aTag, const TDesC8& aFileName, const TDumpType aDumpType, const TInt aLinkType);
76 IMPORT_C ~CPacketLogger();
77 IMPORT_C void WritePacket(const RMBufChain& aPacket, const TUint8 aDirection);
78 IMPORT_C void WritePacket(const TDesC8& aPacket, const TUint8 aDirection);
79 IMPORT_C void WriteText(const TDesC8& aText);
82 void ConstructL(const TDesC8& aTag, const TDesC8& aFileName, const TDumpType aDumpType, const TInt aLinkType);
86 void WriteTcpDumpHeader(const TInt aLinkType);
87 void TcpDumpPacket(const TDesC8& aPacket);
89 void WritePppDumpHeader();
90 void PppDumpPacket(const TDesC8& aPacket, const TUint8 aDirection);
93 /** Specifies the output format for the dumps */
95 /** Marks the start time when the last packet was received for dumping */
96 TInt64 iTimeLastPacket;
97 /** The time between system ticks, in microseconds. */
99 /** Counter for the number of packets successfully dumped */
100 TUint32 iPacketCounter;
101 /** Internal buffer to optimize memory allocation for WritePacket(const RMBufChain& aPacket, const TUint8 aDirection)*/
103 /** Used for directing output to comms debug utility */
104 __FLOG_DECLARATION_MEMBER;
107 #define __PACKETLOG_DECLARATION_MEMBER CPacketLogger* __packetLogger__
109 #define __PACKETLOG_NEWL(aTag, aFileName, aDumpType, aDumpFormat) __packetLogger__ = CPacketLogger::NewL(aTag, aFileName, aDumpType, aDumpFormat)
111 #define __PACKETLOG_DELETE delete __packetLogger__; __packetLogger__ = NULL
113 #define __PACKETLOG_WRITE_PACKET(aPacket, aDirection) __packetLogger__->WritePacket(aPacket, aDirection)
115 #define __PACKETLOG_LOG(aText) __packetLogger__->WriteText(aText)
117 #else //__FLOG_ACTIVE
119 #define __PACKETLOG_DECLARATION_MEMBER TInt32 __noLogger__
121 #define __PACKETLOG_NEWL(aTag, aFileName, aDumpType, aDumpFormat)
123 #define __PACKETLOG_DELETE
125 #define __PACKETLOG_WRITE_PACKET(aPacket, aDirection)
127 #define __PACKETLOG_LOG(aText) __packetLogger__->WriteText(aText)
129 #endif //__FLOG_ACTIVE
131 #endif // __PACKETLOGGER_H__