TInet6HeaderIP4 Class Reference

#include <ip4_hdr.h>

class TInet6HeaderIP4

Detailed Description

Encapsulates an IPv4 IP header.

  ************************
  Extract from the RFC-791
  ************************
  0                   1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |Version|  IHL  |Type of Service|          Total Length         |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |         Identification        |Flags|      Fragment Offset    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |  Time to Live |    Protocol   |         Header Checksum       |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                       Source Address                          |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                    Destination Address                        |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                    Options                    |    Padding    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  
  Version:  4 bits = 4
  IHL:  4 bits

    Internet Header Length is the length of the internet header in 32
    bit words, and thus points to the beginning of the data.  Note that
    the minimum value for a correct header is 5

  Type of Service:  8 bits
      Bits 0-2:  Precedence.
      Bit    3:  0 = Normal Delay,      1 = Low Delay.
      Bits   4:  0 = Normal Throughput, 1 = High Throughput.
      Bits   5:  0 = Normal Relibility, 1 = High Relibility.
      Bit  6-7:  Reserved for Future Use.

	  Precedence

          111 - Network Control
          110 - Internetwork Control
          101 - CRITIC/ECP
          100 - Flash Override
          011 - Flash
          010 - Immediate
          001 - Priority
          000 - Routine
  Total Length:  16 bits
    Total Length is the length of the datagram, measured in octets,
    including internet header and data.

  Identification:  16 bits
    An identifying value assigned by the sender to aid in assembling the
    fragments of a datagram.

  Flags:  3 bits
    Various Control Flags.

      Bit 0: reserved, must be zero
      Bit 1: (DF) 0 = May Fragment,  1 = Don't Fragment.
      Bit 2: (MF) 0 = Last Fragment, 1 = More Fragments.

  Fragment Offset:  13 bits

    This field indicates where in the datagram this fragment belongs.
    The fragment offset is measured in units of 8 octets (64 bits).  The
    first fragment has offset zero.

  Time to Live:  8 bits
  Protocol:  8 bits
  Header Checksum:  16 bits
  Source Address:  32 bits
  Destination Address:  32 bits
Since
v7.0

Member Attribute Documentation

i

iAlign

TUint32 iAlign

Member Enumeration Documentation

Enum TOffsets

EnumeratorValueDescription
O_TotalLength2
O_FragmentOffset6
O_TTL8
O_Protocol9

Member Function Documentation

Checksum ( )

TInt Checksum()const [inline]

Gets the Header Checksum from the header.

Returns: Header Checksum (in NETWORK byte order)

DF ( )

TInt DF()const [inline]

Gets the DF flag from the header.

Returns: DF flag (= KInet4IP_DF, if set and zero otherwise)

DstAddr ( )

TUint32 DstAddr()const [inline]

Gets the destination address from the header.

Returns: Destination address (in host byte order)

DstAddrRef ( )

TUint32 &DstAddrRef()const [inline]

Gets a raw reference to the destination address in network byte order.

Returns: Raw reference to the destination address

EcnIsCongestion ( )

TBool EcnIsCongestion()[inline]

Gets ECN congestion status.

see RFC-3168 for details.

Returns: True, if CE bit is set on an ECN capable packet.

EndPtr ( )

TUint8 *EndPtr()[inline]
Gets a pointer to the byte following the header.
Since
v7.0

Returns: Pointer to the byte following the header

Flags ( )

TInt Flags()const [inline]
Gets the Flags from the header.
Note:

returns flags byte as is, may include bits of fragment offset!

Returns: Flags

FragmentOffset ( )

TInt FragmentOffset()const [inline]

Gets the Fragment Offset from the header.

Returns: Fragment Offset (raw 8 octet units, not a bytes offset!)

HeaderLength ( )

TInt HeaderLength()const [inline]

Gets the header length.

Returns: Header length in bytes (based on IHL field)

HostHeaderLength ( )

TInt HostHeaderLength()const [inline]

HostProtocol ( )

TInt HostProtocol()const [inline]

Gets the Protocol from a header that is in Host byte order. DeprecatedThere is no reason to use swapped headers

Returns: Protocol

Identification ( )

TInt Identification()const [inline]

Gets the Identification from the header.

Returns: Identification [0..65535]

Init ( TInt )

voidInit(TIntaTOS = 0)[inline]

Initialises the IPv4 header to basic initial values.

  • Version = 4

  • IHL = 5

  • Total Length = 20

  • Identification = 0

  • Fragment Offset = 0

  • Flags = 0

  • TTL = 0

  • Checksum = 0

  • TOS = aTOS (optional parameter, default = 0)

However, address fields are not touched, because they are most often set separately in any case.

ParameterDescription
aTOSinitial value for TOS (= 0)

MF ( )

TInt MF()const [inline]

Gets the MF flag from the header.

Returns: MF flag (= KInet4IP_MF, if set and zero otherwise)

MaxHeaderLength ( )

TInt MaxHeaderLength()[static, inline]
Gets the maximum header length.
Since
v7.0

Returns: Maximum header length (= 60)

MinHeaderLength ( )

TInt MinHeaderLength()[static, inline]
Gets the minimum header length.
Since
v7.0

Returns: Minimum header length (= 20)

Options ( )

TPtrC8 Options()const [inline]
Gets the Options from the header (const overload).
Note:

This relies on correct value of IHL! Must not be used with corrupt headers (will panic if IHL < 5!).

Returns: Options

Options ( )

TPtr8 Options()[inline]
Gets the Options from the header.
Note:

This relies on correct value of IHL! Must not be used with corrupt headers (will panic if IHL < 5!).

Returns: Options

Protocol ( )

TInt Protocol()const [inline]

Gets the Protocol from the header.

Returns: Protocol [0..255]

SetChecksum ( TInt )

voidSetChecksum(TIntaSum)[inline]

Sets the Header Checksum in the header.

ParameterDescription
aSumHeader Checksum [0..65535] (16 least significant bits stored as is (assumed to be in NETWORK byte order).

SetDstAddr ( TUint32 )

voidSetDstAddr(TUint32aAddr)[inline]

Sets the destination address in the header.

ParameterDescription
aAddrDestination IPv4 address (32 bit integer) in host byte order

SetFlags ( TUint8 )

voidSetFlags(TUint8aFlags)[inline]

Sets the Flags in the header.

Flags are assumed to be in the three most significant bits of aFlags, in their proper positions. (No individual settings provided, if you need to set a flag without affecting others, use Flags() to get old values, update and store the result with SetFlags()).

ParameterDescription
aFlagscontains the new flags

SetFragmentOffset ( TUint16 )

voidSetFragmentOffset(TUint16aOffset)[inline]

Sets the Fragment Offset in the header.

ParameterDescription
aOffsetFragment Offset (8 octet units, not in bytes)

SetHeaderLength ( TInt )

voidSetHeaderLength(TIntaLength)[inline]

Sets the header length (IHL).

ParameterDescription
aLengththe length of the IPv4 header in BYTES. The IHL is computed from this, without any sanity checks. The valid range is [20..60].

SetIdentification ( TInt )

voidSetIdentification(TIntaId)[inline]

Sets the Identification in the header.

ParameterDescription
aIdthe value to be set (only 16 least significant bits are used, rest is ignored).

SetProtocol ( TInt )

voidSetProtocol(TIntaProtocol)[inline]

Sets the Protocol in the header.

ParameterDescription
aProtocolProtocol [0..255]

SetSrcAddr ( TUint32 )

voidSetSrcAddr(TUint32aAddr)[inline]

Sets the source address in the header.

ParameterDescription
aAddrSource address (IPv4, 32 bit integer in host byte order)

SetTOS ( TInt )

voidSetTOS(TIntaTos)[inline]

Sets the TOS in the header.

ParameterDescription
aTosThe TOS value to set [0..255]

SetTotalLength ( TInt )

voidSetTotalLength(TIntaLength)[inline]

Sets the Total Length in the header.

ParameterDescription
aLengththe length of combined header and payload in bytes (no sanity checks, but the value should be in range [20..65535]). Only 16 least significant bits used.

SetTtl ( TInt )

voidSetTtl(TIntaTTL)[inline]

Sets the Time to Live in the header.

ParameterDescription
aTTLTime to Live [0..255]

SetVersion ( TInt )

voidSetVersion(TIntaVersion)[inline]

Sets the IP version in the header.

ParameterDescription
aVersionthe value to be set [0..15]

SrcAddr ( )

TUint32 SrcAddr()const [inline]

Gets the source address from the header.

Returns: Source address (in host byte order)

SrcAddrRef ( )

TUint32 &SrcAddrRef()const [inline]

Gets a raw reference to the source address in network byte order.

Returns: Raw reference to the source address

Swap ( )

voidSwap()[inline]

Swaps the byte order in the header. DeprecatedThere is no reason to use swapped headers

TOS ( )

TInt TOS()const [inline]

Gets the TOS from the header.

Returns: TOS

TotalLength ( )

TInt TotalLength()const [inline]

Gets the Total Length from the header.

Returns: Total Length (includes IP header and payload)

Ttl ( )

TInt Ttl()const [inline]

Gets the Time to Live from the header.

Returns: Time to Live [0..255]

Version ( )

TInt Version()const [inline]

Gets the IP version from the header.

Returns: IP version (should be 4 for IPv4)