networkingtestandutils/networkingunittest/dummynif/hungrynif6.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2003-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 // dummynif6.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32hal.h>	// UserHal::MachineInfo()
       
    19 #include <comms-infras/nifif.h>
       
    20 #include <nifvar.h>
       
    21 #include <nifutl.h>
       
    22 #include <es_mbuf.h>
       
    23 #include <in_iface.h>
       
    24 #include <comms-infras/commsdebugutility.h>
       
    25 #include <connectprog.h>
       
    26 
       
    27 #include <in_chk.h>
       
    28 #include <in_sock.h>
       
    29 #include <in6_if.h>	// KSoIface*, KIf*, TSoInet6IfConfig
       
    30 #include "dummynif.h"
       
    31 #include "hungrynif.h"
       
    32 
       
    33 
       
    34 /*
       
    35  * The IPv6 interface binder class
       
    36  */
       
    37 
       
    38 CHungryIf6::CHungryIf6(CHungryIfLink& aLink)
       
    39 	: CDummyIf6(aLink)
       
    40 	{
       
    41 	CDummyIfLog::Printf(_L("CHungryIf6::CHungryIf6()"));
       
    42 
       
    43 	iIfName.Format(_L("hungrynif6[0x%08x]"), this);
       
    44 	}
       
    45 
       
    46 void CHungryIf6::Recv(RMBufChain& aPdu)
       
    47 	{
       
    48 	// get the IP and UDP header from the RMBufChain
       
    49 	TInet6HeaderIP* ip6 = (TInet6HeaderIP*) aPdu.First()->Next()->Ptr();
       
    50 	TInet6HeaderUDP* udp = NULL;
       
    51 
       
    52 	if ((TUint)ip6->NextHeader() == KProtocolInetUdp)
       
    53 		{
       
    54 		// get the udp header as well - assume only udp traffic here
       
    55 		udp = (TInet6HeaderUDP*) ip6->EndPtr();
       
    56 
       
    57 		CDummyIfLog::Printf(_L("CHungryIf6::Recv(...): UDP length %d, src port %d, dst port %d"),
       
    58 			udp->Length(), udp->SrcPort(), udp->DstPort());
       
    59 		}
       
    60 	else
       
    61 		{
       
    62 		CDummyIfLog::Printf(_L("CHungryIf6::Recv(...): IPv6 length %d, next header %d"),
       
    63 			ip6->PayloadLength(), ip6->NextHeader());
       
    64 		}
       
    65 
       
    66 	// just discard the packet, as this NIF is supposed to do.
       
    67 
       
    68 	aPdu.Free();
       
    69 	return;
       
    70 }
       
    71