williamr@2
|
1 |
/**
|
williamr@2
|
2 |
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
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
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description:
|
williamr@2
|
15 |
* Networking packet logging utility
|
williamr@2
|
16 |
*
|
williamr@2
|
17 |
*
|
williamr@2
|
18 |
*/
|
williamr@2
|
19 |
|
williamr@2
|
20 |
|
williamr@2
|
21 |
|
williamr@2
|
22 |
|
williamr@2
|
23 |
|
williamr@2
|
24 |
/**
|
williamr@2
|
25 |
@file
|
williamr@2
|
26 |
*/
|
williamr@2
|
27 |
|
williamr@2
|
28 |
#ifndef __PACKETLOGGER_H__
|
williamr@2
|
29 |
#define __PACKETLOGGER_H__
|
williamr@2
|
30 |
|
williamr@2
|
31 |
//this file defines the __FLOG_ACTIVE flag
|
williamr@2
|
32 |
#include <comms-infras/commsdebugutility.h>
|
williamr@2
|
33 |
|
williamr@2
|
34 |
#if defined __FLOG_ACTIVE
|
williamr@2
|
35 |
|
williamr@2
|
36 |
#include <e32base.h>
|
williamr@2
|
37 |
#include <es_mbuf.h>
|
williamr@2
|
38 |
class RFileLogger;
|
williamr@2
|
39 |
|
williamr@2
|
40 |
/**
|
williamr@2
|
41 |
* Class containing methods for dumping ip
|
williamr@2
|
42 |
* packets of different formats.
|
williamr@2
|
43 |
* The output is written to the log file
|
williamr@2
|
44 |
* produced by comms debug utility.
|
williamr@2
|
45 |
* The supported output formats are listed with the
|
williamr@2
|
46 |
* TDumpType enum.
|
williamr@2
|
47 |
* This class cannot be derived from.
|
williamr@2
|
48 |
* This class should be active only if __FLOG_ACTIVE
|
williamr@2
|
49 |
* flag is defined. To ensure that use the macros
|
williamr@2
|
50 |
* defined below. A sample usage would be:
|
williamr@2
|
51 |
* @code
|
williamr@2
|
52 |
* __PACKETLOG_DECLARATION_MEMBER
|
williamr@2
|
53 |
* __PACKETLOG_NEWL(aTag, aFileName, aDumpType, aLinkType);
|
williamr@2
|
54 |
* ...
|
williamr@2
|
55 |
* __PACKETLOG_WRITE_PACKET(aPacket, aDirection);
|
williamr@2
|
56 |
* ...
|
williamr@2
|
57 |
* __PACKETLOG_DELETE;
|
williamr@2
|
58 |
* @endcode
|
williamr@2
|
59 |
* If the __FLOG_ACTIVE flag is not set, the macros map
|
williamr@2
|
60 |
* to nothing.
|
williamr@2
|
61 |
*/
|
williamr@2
|
62 |
class CPacketLogger : public CBase
|
williamr@2
|
63 |
{
|
williamr@2
|
64 |
public:
|
williamr@2
|
65 |
/** Output dump formats supported by this class */
|
williamr@2
|
66 |
enum TDumpType
|
williamr@2
|
67 |
{
|
williamr@2
|
68 |
/** Produced dump will be in tcp dump format */
|
williamr@2
|
69 |
ETcpDump,
|
williamr@2
|
70 |
/** Produced dump will be in ppp dump format */
|
williamr@2
|
71 |
EPppDump
|
williamr@2
|
72 |
};
|
williamr@2
|
73 |
|
williamr@2
|
74 |
public:
|
williamr@2
|
75 |
IMPORT_C static CPacketLogger* NewL(const TDesC8& aTag, const TDesC8& aFileName, const TDumpType aDumpType, const TInt aLinkType);
|
williamr@2
|
76 |
IMPORT_C ~CPacketLogger();
|
williamr@2
|
77 |
IMPORT_C void WritePacket(const RMBufChain& aPacket, const TUint8 aDirection);
|
williamr@2
|
78 |
IMPORT_C void WritePacket(const TDesC8& aPacket, const TUint8 aDirection);
|
williamr@2
|
79 |
IMPORT_C void WriteText(const TDesC8& aText);
|
williamr@2
|
80 |
|
williamr@2
|
81 |
private:
|
williamr@2
|
82 |
void ConstructL(const TDesC8& aTag, const TDesC8& aFileName, const TDumpType aDumpType, const TInt aLinkType);
|
williamr@2
|
83 |
CPacketLogger();
|
williamr@2
|
84 |
|
williamr@2
|
85 |
private:
|
williamr@2
|
86 |
void WriteTcpDumpHeader(const TInt aLinkType);
|
williamr@2
|
87 |
void TcpDumpPacket(const TDesC8& aPacket);
|
williamr@2
|
88 |
|
williamr@2
|
89 |
void WritePppDumpHeader();
|
williamr@2
|
90 |
void PppDumpPacket(const TDesC8& aPacket, const TUint8 aDirection);
|
williamr@2
|
91 |
|
williamr@2
|
92 |
private:
|
williamr@2
|
93 |
/** Specifies the output format for the dumps */
|
williamr@2
|
94 |
TDumpType iDumpType;
|
williamr@2
|
95 |
/** Marks the start time when the last packet was received for dumping */
|
williamr@2
|
96 |
TInt64 iTimeLastPacket;
|
williamr@2
|
97 |
/** The time between system ticks, in microseconds. */
|
williamr@2
|
98 |
TInt64 iTickPeriod;
|
williamr@2
|
99 |
/** Counter for the number of packets successfully dumped */
|
williamr@2
|
100 |
TUint32 iPacketCounter;
|
williamr@2
|
101 |
/** Internal buffer to optimize memory allocation for WritePacket(const RMBufChain& aPacket, const TUint8 aDirection)*/
|
williamr@2
|
102 |
HBufC8* iHBuf;
|
williamr@2
|
103 |
/** Used for directing output to comms debug utility */
|
williamr@2
|
104 |
__FLOG_DECLARATION_MEMBER;
|
williamr@2
|
105 |
};
|
williamr@2
|
106 |
|
williamr@2
|
107 |
#define __PACKETLOG_DECLARATION_MEMBER CPacketLogger* __packetLogger__
|
williamr@2
|
108 |
|
williamr@2
|
109 |
#define __PACKETLOG_NEWL(aTag, aFileName, aDumpType, aDumpFormat) __packetLogger__ = CPacketLogger::NewL(aTag, aFileName, aDumpType, aDumpFormat)
|
williamr@2
|
110 |
|
williamr@2
|
111 |
#define __PACKETLOG_DELETE delete __packetLogger__; __packetLogger__ = NULL
|
williamr@2
|
112 |
|
williamr@2
|
113 |
#define __PACKETLOG_WRITE_PACKET(aPacket, aDirection) __packetLogger__->WritePacket(aPacket, aDirection)
|
williamr@2
|
114 |
|
williamr@2
|
115 |
#define __PACKETLOG_LOG(aText) __packetLogger__->WriteText(aText)
|
williamr@2
|
116 |
|
williamr@2
|
117 |
#else //__FLOG_ACTIVE
|
williamr@2
|
118 |
|
williamr@2
|
119 |
#define __PACKETLOG_DECLARATION_MEMBER TInt32 __noLogger__
|
williamr@2
|
120 |
|
williamr@2
|
121 |
#define __PACKETLOG_NEWL(aTag, aFileName, aDumpType, aDumpFormat)
|
williamr@2
|
122 |
|
williamr@2
|
123 |
#define __PACKETLOG_DELETE
|
williamr@2
|
124 |
|
williamr@2
|
125 |
#define __PACKETLOG_WRITE_PACKET(aPacket, aDirection)
|
williamr@2
|
126 |
|
williamr@2
|
127 |
#define __PACKETLOG_LOG(aText) __packetLogger__->WriteText(aText)
|
williamr@2
|
128 |
|
williamr@2
|
129 |
#endif //__FLOG_ACTIVE
|
williamr@2
|
130 |
|
williamr@2
|
131 |
#endif // __PACKETLOGGER_H__
|