networkprotocols/iphook/inhook6example/inc/exaout.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 // exaout.h - outbound plugin example protocol module (dummy)
       
    15 //
       
    16 
       
    17 #ifndef __EXAOUT_H
       
    18 #define __EXAOUT_H
       
    19 /**
       
    20 * @file exaout.h
       
    21 * Outbound plugin example protocol module (dummy).
       
    22 * @internalComponent
       
    23 */
       
    24 
       
    25 #include <posthook.h>
       
    26 
       
    27 /**
       
    28 * @name The exaout identification
       
    29 *
       
    30 * The protocol is identified by (address family, protocol number). This
       
    31 * should be unique among all protocols known to the socket server.
       
    32 *
       
    33 * Unfortunately there are no rules or registration for these values, and
       
    34 * the protocol writer just has to pick a combination that is supposed to
       
    35 * be unique.
       
    36 *
       
    37 * In this example, neither of these values have any significance to the
       
    38 * implementation. Any values will work.
       
    39 * @{
       
    40 */
       
    41 /** The address family constant. Use the UID value of this protocol module. */
       
    42 const TUint KAfExaout			= 0x10000942;
       
    43 /** The protocol number. Because the family is unique, 1000 should not confuse anyone. */
       
    44 const TUint KProtocolExaout	= 1000;
       
    45 /** @} */
       
    46 
       
    47 class CExaoutFlowInfo;
       
    48 
       
    49 class CProtocolExaout : public CProtocolPosthook
       
    50 	/**
       
    51 	* A protocol plugin for outbound flows.
       
    52 	*
       
    53 	* This is a minimal definition for a protocol plugin class
       
    54 	* (hook), which wants to attach outbound flows to monitor or
       
    55 	* modify the packets.
       
    56 	*/
       
    57 	{
       
    58 public:
       
    59 	CProtocolExaout();
       
    60 	virtual ~CProtocolExaout();
       
    61 
       
    62 	// CProtocolBase
       
    63 	virtual void Identify(TServerProtocolDesc *aDesc) const;
       
    64 
       
    65 	// CProtocolPosthook
       
    66 	virtual void NetworkAttachedL();
       
    67 	virtual void NetworkDetached();
       
    68 
       
    69 	//Outbound Flow
       
    70 	virtual MFlowHook *OpenL(TPacketHead& /*aHead*/, CFlowContext *aFlow);
       
    71 
       
    72 	// ProtocolModule glue
       
    73 	static void Describe(TServerProtocolDesc& anEntry);
       
    74 private:
       
    75 	TDblQue<CExaoutFlowInfo>	iFlowList;
       
    76 	};
       
    77 
       
    78 class CExaoutFlowInfo : public CBase, public MFlowHook
       
    79 	/**
       
    80 	* An internal flow context within the plugin.
       
    81 	*
       
    82 	* The exaout example plugin attaches an instance of
       
    83 	* this internal  context to each outbound flow.
       
    84 	* A per flow instance is required, if the plugin
       
    85 	* needs to maintain own flow specific context.
       
    86 	*
       
    87 	* The exadump is an alternative example for a plugin
       
    88 	* which does not need any flow specific context.
       
    89 	*/
       
    90 	{
       
    91 public:
       
    92 	CExaoutFlowInfo(CFlowContext &aFlow);
       
    93 	virtual ~CExaoutFlowInfo();
       
    94 
       
    95 	virtual void Open();
       
    96 	virtual TInt ReadyL(TPacketHead &);
       
    97 	virtual TInt ApplyL(RMBufSendPacket &, RMBufSendInfo &);
       
    98 	virtual void Close();
       
    99 
       
   100 	/**
       
   101 	* The flow context. This is a direct reference to the
       
   102 	* object inside the TCP/IP stack. Be careful with it!
       
   103 	*/ 
       
   104 	CFlowContext&		iFlow;
       
   105 
       
   106 	/**
       
   107 	* A back pointer to the protocol itself.
       
   108 	* NULL, if not attaced to the protocol (via iDLink)
       
   109 	*/
       
   110 	CProtocolExaout*	iMgr;
       
   111 
       
   112 	/**
       
   113 	* Object reference count. This object is automaticly
       
   114 	* deleted when the last reference disappears. (This is
       
   115 	* the required from MFlowHook)
       
   116 	*/
       
   117 	TInt				iRefs;
       
   118 	/** Links context information together. The head is in CProtocolExaout. */
       
   119 	TDblQueLink			iDLink;
       
   120 	static const TInt	iOffset;
       
   121 	};
       
   122 
       
   123 #endif