networkprotocols/iphook/inhook6example/src/exain.cpp
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 // exain.cpp - Inbound plugin example module
       
    15 //
       
    16 
       
    17 #include "exain.h"
       
    18 
       
    19 #pragma warning (disable:4100)
       
    20 
       
    21 //
       
    22 // Applies all the modifications needed for every incoming ICMP packet
       
    23 //
       
    24 TInt CProtocolExain::ApplyL(RMBufHookPacket& /*aPacket*/, RMBufRecvInfo& aInfo)
       
    25 	/**
       
    26 	* An IPv4 ICMP header detected.
       
    27 	*
       
    28 	* This example returns always KIp6Hook_PASS without modifying
       
    29 	* the packet in any way. There is some template if statements
       
    30 	* which demonstrate the major paths that would need to be taken,
       
    31 	* if any real processing was to happen.
       
    32 	*/
       
    33 	{
       
    34 /** @code */
       
    35 	if (aInfo.iProtocol != (TInt)KProtocolInetIcmp)
       
    36 		{
       
    37 		// If the CProtocolExain::NetworkAttached only bound the hook for
       
    38 		// IPv4 ICMP, we should never get here...
       
    39 		return KIp6Hook_PASS;
       
    40 		}
       
    41 
       
    42 	if (aInfo.iIcmp != 0)
       
    43 		{
       
    44 		// The ICMPv4 header is in the returned packet of some ICMP error  packet.
       
    45 		//
       
    46 		// aInfo.iOffset
       
    47 		//	offset to the relevant ICMPv4 header
       
    48 		// aInfo.iOffsetIp
       
    49 		//	indicates position of the IP header of the returned packet.
       
    50 		// aInfo.iSrcAddr
       
    51 		//	is the source address of the returned packet (should be my own address)
       
    52 		// aInfo.iDstAddr
       
    53 		//	is the destination address of the returned packet
       
    54 		return KIp6Hook_PASS;
       
    55 		}
       
    56 
       
    57 	// The incoming packet is ICMPv4 addressed to this node.
       
    58 	//
       
    59 	// aInfo.iOffset
       
    60 	//	offset to the relevant ICMPv4 header
       
    61 	// aInfo.iOffsetIp
       
    62 	//	indicates position of the IP header before this ICMPv4 header
       
    63 	//	(usually zero).
       
    64 	// aInfo.iSrcAddr
       
    65 	//	is the source address of the packet
       
    66 	// aInfo.iDstAddr
       
    67 	//	is the destination address of the packet (should be my own
       
    68 	//	address, or some type of multicast/broadcast address).
       
    69 	return KIp6Hook_PASS;
       
    70 /** @endcode */
       
    71 	}
       
    72 
       
    73 #pragma warning (default:4100)