commands/ping/in_icmp.h
changeset 0 7f656887cf89
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // Copyright (c) 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 //
       
    15 #ifndef __IN_ICMP_H__
       
    16 #define __IN_ICMP_H__
       
    17 
       
    18 #include "in_ip.h"
       
    19 
       
    20 class ThdrICMP_Echo
       
    21 {
       
    22 public:
       
    23 	inline static ThdrICMP_Echo* Ptr(ThdrICMP* aHdr);
       
    24 	inline TUint16 NetGetId();
       
    25 	inline void NetSetId(TUint16 aId);
       
    26 	inline TInt GetId();
       
    27 	inline void SetId(TUint16 aId);
       
    28 	inline TUint16 NetGetSeq();
       
    29 	inline void NetSetSeq(TUint16 aSeq);
       
    30 	inline TInt GetSeq();
       
    31 	inline void SetSeq(TUint16 aSeq);
       
    32 protected:
       
    33 	union
       
    34 		{
       
    35 		TUint8	iData8[8];
       
    36 		TUint16	iData16[4];
       
    37 		TUint32	iData32[2];
       
    38 		} u;
       
    39 };
       
    40 
       
    41 
       
    42 // specific for ECHO calls. (id and seq fields)
       
    43 //Net order
       
    44 inline TUint16 ThdrICMP_Echo::NetGetId()
       
    45 	{ return u.iData16[2]; }
       
    46 inline void ThdrICMP_Echo::NetSetId(TUint16 aId)
       
    47 	{ u.iData16[2] = aId; }
       
    48 //Host order
       
    49 inline TInt ThdrICMP_Echo::GetId()
       
    50 	{ 
       
    51 	return (u.iData8[4] << 8) + u.iData8[5];}
       
    52 inline void ThdrICMP_Echo::SetId(TUint16 aId)
       
    53 	{
       
    54 		u.iData8[4] = (TUint8)(aId >> 8);
       
    55 		u.iData8[5] = (TUint8)aId;
       
    56 	}
       
    57 //Net order
       
    58 inline TUint16 ThdrICMP_Echo::NetGetSeq()
       
    59 	{ return u.iData16[3]; }
       
    60 inline void ThdrICMP_Echo::NetSetSeq(TUint16 aSeq)
       
    61 	{ u.iData16[3] = aSeq; }
       
    62 //Host order
       
    63 inline TInt ThdrICMP_Echo::GetSeq()
       
    64 	{ return (u.iData8[6] << 8) + u.iData8[7];}
       
    65 inline void ThdrICMP_Echo::SetSeq(TUint16 aSeq)
       
    66 	{
       
    67 		u.iData8[6] = (TUint8)(aSeq >> 8);
       
    68 		u.iData8[7] = (TUint8)aSeq;
       
    69 	}
       
    70 
       
    71 
       
    72 #endif