#include <ip4_hdr.h>
class TInet6HeaderIP4 |
Public Attributes | |
---|---|
TUint8 | i |
TUint32 | iAlign |
Public Member Enumerations | |
---|---|
enum | TOffsets { O_TotalLength, O_FragmentOffset, O_TTL, O_Protocol } |
Public Member Functions | |
---|---|
TInt | Checksum() |
TInt | DF() |
TUint32 | DstAddr() |
TUint32 & | DstAddrRef() |
TBool | EcnIsCongestion() |
TUint8 * | EndPtr() |
TInt | Flags() |
TInt | FragmentOffset() |
TInt | HeaderLength() |
TInt | HostHeaderLength() |
TInt | HostProtocol() |
TInt | Identification() |
void | Init(TInt) |
TInt | MF() |
TInt | MaxHeaderLength() |
TInt | MinHeaderLength() |
TPtrC8 | Options() |
TPtr8 | Options() |
TInt | Protocol() |
void | SetChecksum(TInt) |
void | SetDstAddr(TUint32) |
void | SetFlags(TUint8) |
void | SetFragmentOffset(TUint16) |
void | SetHeaderLength(TInt) |
void | SetIdentification(TInt) |
void | SetProtocol(TInt) |
void | SetSrcAddr(TUint32) |
void | SetTOS(TInt) |
void | SetTotalLength(TInt) |
void | SetTtl(TInt) |
void | SetVersion(TInt) |
TUint32 | SrcAddr() |
TUint32 & | SrcAddrRef() |
void | Swap() |
TInt | TOS() |
TInt | TotalLength() |
TInt | Ttl() |
TInt | Version() |
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
TInt | Checksum | ( | ) | const [inline] |
Gets the Header Checksum from the header.
Returns: Header Checksum (in NETWORK byte order)
TInt | DF | ( | ) | const [inline] |
Gets the DF flag from the header.
Returns: DF flag (= KInet4IP_DF, if set and zero otherwise)
TUint32 | DstAddr | ( | ) | const [inline] |
Gets the destination address from the header.
Returns: Destination address (in host byte order)
TUint32 & | DstAddrRef | ( | ) | const [inline] |
Gets a raw reference to the destination address in network byte order.
Returns: Raw reference to the destination address
TBool | EcnIsCongestion | ( | ) | [inline] |
Gets ECN congestion status.
see RFC-3168 for details.
Returns: True, if CE bit is set on an ECN capable packet.
TUint8 * | EndPtr | ( | ) | [inline] |
Returns: Pointer to the byte following the header
TInt | Flags | ( | ) | const [inline] |
returns flags byte as is, may include bits of fragment offset!
Returns: Flags
TInt | FragmentOffset | ( | ) | const [inline] |
Gets the Fragment Offset from the header.
Returns: Fragment Offset (raw 8 octet units, not a bytes offset!)
TInt | HeaderLength | ( | ) | const [inline] |
Gets the header length.
Returns: Header length in bytes (based on IHL field)
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
TInt | Identification | ( | ) | const [inline] |
Gets the Identification from the header.
Returns: Identification [0..65535]
void | Init | ( | TInt | aTOS = 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)
Parameter | Description |
---|---|
aTOS | initial value for TOS (= 0) |
TInt | MF | ( | ) | const [inline] |
Gets the MF flag from the header.
Returns: MF flag (= KInet4IP_MF, if set and zero otherwise)
TInt | MaxHeaderLength | ( | ) | [static, inline] |
Returns: Maximum header length (= 60)
TInt | MinHeaderLength | ( | ) | [static, inline] |
Returns: Minimum header length (= 20)
TPtrC8 | Options | ( | ) | const [inline] |
This relies on correct value of IHL! Must not be used with corrupt headers (will panic if IHL < 5!).
Returns: Options
TPtr8 | Options | ( | ) | [inline] |
This relies on correct value of IHL! Must not be used with corrupt headers (will panic if IHL < 5!).
Returns: Options
void | SetChecksum | ( | TInt | aSum | ) | [inline] |
Sets the Header Checksum in the header.
Parameter | Description |
---|---|
aSum | Header Checksum [0..65535] (16 least significant bits stored as is (assumed to be in NETWORK byte order). |
void | SetDstAddr | ( | TUint32 | aAddr | ) | [inline] |
Sets the destination address in the header.
Parameter | Description |
---|---|
aAddr | Destination IPv4 address (32 bit integer) in host byte order |
void | SetFlags | ( | TUint8 | aFlags | ) | [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()).
Parameter | Description |
---|---|
aFlags | contains the new flags |
void | SetFragmentOffset | ( | TUint16 | aOffset | ) | [inline] |
Sets the Fragment Offset in the header.
Parameter | Description |
---|---|
aOffset | Fragment Offset (8 octet units, not in bytes) |
void | SetHeaderLength | ( | TInt | aLength | ) | [inline] |
Sets the header length (IHL).
Parameter | Description |
---|---|
aLength | the length of the IPv4 header in BYTES. The IHL is computed from this, without any sanity checks. The valid range is [20..60]. |
void | SetIdentification | ( | TInt | aId | ) | [inline] |
Sets the Identification in the header.
Parameter | Description |
---|---|
aId | the value to be set (only 16 least significant bits are used, rest is ignored). |
void | SetProtocol | ( | TInt | aProtocol | ) | [inline] |
Sets the Protocol in the header.
Parameter | Description |
---|---|
aProtocol | Protocol [0..255] |
void | SetSrcAddr | ( | TUint32 | aAddr | ) | [inline] |
Sets the source address in the header.
Parameter | Description |
---|---|
aAddr | Source address (IPv4, 32 bit integer in host byte order) |
void | SetTOS | ( | TInt | aTos | ) | [inline] |
Sets the TOS in the header.
Parameter | Description |
---|---|
aTos | The TOS value to set [0..255] |
void | SetTotalLength | ( | TInt | aLength | ) | [inline] |
Sets the Total Length in the header.
Parameter | Description |
---|---|
aLength | the 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. |
void | SetVersion | ( | TInt | aVersion | ) | [inline] |
Sets the IP version in the header.
Parameter | Description |
---|---|
aVersion | the value to be set [0..15] |
TUint32 | SrcAddr | ( | ) | const [inline] |
Gets the source address from the header.
Returns: Source address (in host byte order)
TUint32 & | SrcAddrRef | ( | ) | const [inline] |
Gets a raw reference to the source address in network byte order.
Returns: Raw reference to the source address
void | Swap | ( | ) | [inline] |
Swaps the byte order in the header. DeprecatedThere is no reason to use swapped headers
TInt | TotalLength | ( | ) | const [inline] |
Gets the Total Length from the header.
Returns: Total Length (includes IP header and payload)
TInt | Version | ( | ) | const [inline] |
Gets the IP version from the header.
Returns: IP version (should be 4 for IPv4)