networkprotocols/iphook/inhook6example/inc/exadump.h
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2004-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 // exadump.h - packet dump plugin example module
       
    15 //
       
    16 
       
    17 #ifndef __EXADUMP_H
       
    18 #define __EXADUMP_H
       
    19 
       
    20 /**
       
    21 * @file exadump.h
       
    22 * Packet dump plugin example module.
       
    23 * @internalComponent
       
    24 */
       
    25 
       
    26 // The content of this header is only used in exadump.cpp and
       
    27 // this exists only for technical reasons due to doxygen
       
    28 // setup.
       
    29 
       
    30 #include <posthook.h>
       
    31 
       
    32 
       
    33 class CProtocolExadump : public CProtocolPosthook, public MFlowHook
       
    34 	/**
       
    35 	* Dump <em>cooked</em> packets.
       
    36 	*
       
    37 	* This is an example of a hook that attaches to the inbound path
       
    38 	* just before the upper layer (A) and as a flow hook (D) to the
       
    39 	* outbound path. The (A) and (D) refer to attachement points
       
    40 	* in @ref packet_flows
       
    41 	*
       
    42 	* The term <em>cooked</em> attempts to signify that this hook sees
       
    43 	* only packets that are accepted for the upper layer processing, and after all
       
    44 	* extension header processing have been done (for example, if IPSEC
       
    45 	* is in effect, this hook will see clear incoming packets. For outbound
       
    46 	* packets, whether it sees clear or encrypted packets, depends on the
       
    47 	* posisioning of hook in the list of outbound flow hooks).
       
    48 	*
       
    49 	* This also demonstrates an architecture where the hook itself works
       
    50 	* as a MFlowHook instance for all attached flows. This is possible
       
    51 	* because this hook does not need to maintain any flow specific
       
    52 	* context.
       
    53 	*
       
    54 	* The hook writes each packet (in- or outbound) to a file in
       
    55 	* TCPDUMP format (can be viewed using ethereal utility).
       
    56 	*/
       
    57 	{
       
    58 public:
       
    59 
       
    60 	// Constructors and destructors
       
    61 
       
    62 	CProtocolExadump();
       
    63 	virtual ~CProtocolExadump();
       
    64 
       
    65 	// Pure virtual in CProtocolBase, and MUST be implemented here.
       
    66 	virtual void Identify(TServerProtocolDesc *aDesc) const;
       
    67 
       
    68 	//
       
    69 	// Specific to CProtocolExadump implementation
       
    70 	//
       
    71 	virtual void NetworkAttachedL();
       
    72 	virtual TInt ApplyL(RMBufHookPacket &aPacket, RMBufRecvInfo &aInfo);
       
    73 	virtual MFlowHook *OpenL(TPacketHead &aHead, CFlowContext *aFlow);
       
    74 	//
       
    75 	// MFlowHook methods
       
    76 	//
       
    77 	virtual void Open();
       
    78 	virtual void Close();
       
    79 	virtual TInt ReadyL(TPacketHead &aHead);
       
    80 	virtual TInt ApplyL(RMBufSendPacket &aPacket, RMBufSendInfo &aInfo);
       
    81 	//
       
    82 	// ProtocolModule "glue"
       
    83 	//
       
    84 	static void Describe(TServerProtocolDesc &aDesc);
       
    85 
       
    86 	//
       
    87 	// The nature of the following fields is "private", but in this
       
    88 	// example class they are left public to enable doxygen documentation
       
    89 	// to be generated from them (so that it can be generated with "no private
       
    90 	// methods" option).
       
    91 	//
       
    92 
       
    93 	void DoOpen(TInt aSnapLen);
       
    94 	void DoPacket(const RMBufPacketBase &aPacket, const RMBufPktInfo &aInfo);
       
    95 
       
    96 	/**
       
    97 	* A temporary buffer to hold the packet in contiguous memory. This
       
    98 	* used because, it is assumed that doing RMBufChain copyout combined
       
    99 	* with single write, is faster than doing multiple writes from
       
   100 	* each RMBuf separately.
       
   101 	*
       
   102 	* Also, the Max Length defines the "snap length".
       
   103 	*/
       
   104 	HBufC8 *iBuffer;
       
   105 	//
       
   106 	// The dump file
       
   107 	//
       
   108 	/**
       
   109 	* Status of the file (iDumpFile)
       
   110 	*
       
   111 	* - < 0,
       
   112 	*	an attempt to open the dump file has been made, but it has
       
   113 	*	failed for some reason. Do not try to open again.
       
   114 	* - = 0,
       
   115 	*	the dump file is not open.
       
   116 	* - = 1
       
   117 	*	the dump file is open.
       
   118 	*/
       
   119 	TInt iOpen;
       
   120 	/** The file server handle. */
       
   121 	RFs iFS;
       
   122 	/** The dump file handle */
       
   123 	RFile iDumpFile;
       
   124 	/** The base for the time stamps in the dump file.  (= 1.1.1970) */
       
   125 	TTime iBase;
       
   126 	};
       
   127 
       
   128 #endif