Loading...
Searching...
No Matches
IPv4 header

IPv4 header types and helper functions. More...

Detailed Description

IPv4 header types and helper functions.

The authoritative source on the IPv4 header is RFC 791. In this RFC, the bit positions are noted left to right, with the most significant bit on the left (bit 0). Refer to Appendix B of the RFC for more information.

Files

file  hdr.h
 IPv4 header type and helper function definitions.
 

Data Structures

struct  ipv4_hdr_t
 Data type to represent an IPv4 packet header. More...
 

Functions

static void ipv4_hdr_set_version (ipv4_hdr_t *hdr)
 Sets the version field of hdr to 4.
 
static uint8_t ipv4_hdr_get_version (ipv4_hdr_t *hdr)
 Gets the value of the version field of hdr.
 
static void ipv4_hdr_set_ihl (ipv4_hdr_t *hdr, uint16_t ihl)
 Sets the Internet Header Length field of hdr.
 
static uint16_t ipv4_hdr_get_ihl (ipv4_hdr_t *hdr)
 Gets the value of the Internet Header Length field of hdr.
 
static void ipv4_hdr_set_flags (ipv4_hdr_t *hdr, uint8_t flags)
 Sets the Version Control Flags field of hdr.
 
static uint8_t ipv4_hdr_get_flags (ipv4_hdr_t *hdr)
 Gets the value of the Version Control Flags field of hdr.
 
static void ipv4_hdr_set_fo (ipv4_hdr_t *hdr, uint16_t fo)
 Sets the Fragment Offset field of hdr.
 
static uint16_t ipv4_hdr_get_fo (ipv4_hdr_t *hdr)
 Gets the value of the Fragment Offset field of hdr.
 

IPv4 Header Flags

See also
RFC 791, section 3.1
#define IPV4_HDR_FLAGS_RESERVED   (0x04)
 reserved
 
#define IPV4_HDR_FLAGS_DF   (0x02)
 do not fragment
 
#define IPV4_HDR_FLAGS_MF   (0x01)
 more fragments
 

Macro Definition Documentation

◆ IPV4_HDR_FLAGS_DF

#define IPV4_HDR_FLAGS_DF   (0x02)

do not fragment

Definition at line 43 of file hdr.h.

◆ IPV4_HDR_FLAGS_MF

#define IPV4_HDR_FLAGS_MF   (0x01)

more fragments

Definition at line 44 of file hdr.h.

◆ IPV4_HDR_FLAGS_RESERVED

#define IPV4_HDR_FLAGS_RESERVED   (0x04)

reserved

Definition at line 42 of file hdr.h.

Function Documentation

◆ ipv4_hdr_get_flags()

static uint8_t ipv4_hdr_get_flags ( ipv4_hdr_t * hdr)
inlinestatic

Gets the value of the Version Control Flags field of hdr.

Parameters
[in]hdrPointer to an IPv4 header.
Returns
Value of the Version Control field of hdr

Definition at line 186 of file hdr.h.

◆ ipv4_hdr_get_fo()

static uint16_t ipv4_hdr_get_fo ( ipv4_hdr_t * hdr)
inlinestatic

Gets the value of the Fragment Offset field of hdr.

Parameters
[in]hdrPointer to an IPv4 header.
Returns
Value of the Fragment Offset field of hdr

Definition at line 211 of file hdr.h.

◆ ipv4_hdr_get_ihl()

static uint16_t ipv4_hdr_get_ihl ( ipv4_hdr_t * hdr)
inlinestatic

Gets the value of the Internet Header Length field of hdr.

Parameters
[in]hdrPointer to an IPv4 header.
Returns
Size in bytes of the Internet Header Length field of hdr

Definition at line 162 of file hdr.h.

◆ ipv4_hdr_get_version()

static uint8_t ipv4_hdr_get_version ( ipv4_hdr_t * hdr)
inlinestatic

Gets the value of the version field of hdr.

Parameters
[in]hdrPointer to an IPv4 header.
Returns
Value of the version field of hdr.

Definition at line 135 of file hdr.h.

◆ ipv4_hdr_set_flags()

static void ipv4_hdr_set_flags ( ipv4_hdr_t * hdr,
uint8_t flags )
inlinestatic

Sets the Version Control Flags field of hdr.

Parameters
[out]hdrPointer to an IPv4 header.
[in]flagsThe new value of flags

Definition at line 173 of file hdr.h.

◆ ipv4_hdr_set_fo()

static void ipv4_hdr_set_fo ( ipv4_hdr_t * hdr,
uint16_t fo )
inlinestatic

Sets the Fragment Offset field of hdr.

Parameters
[out]hdrPointer to an IPv4 header.
[in]foThe new value of fragment offset

Definition at line 197 of file hdr.h.

◆ ipv4_hdr_set_ihl()

static void ipv4_hdr_set_ihl ( ipv4_hdr_t * hdr,
uint16_t ihl )
inlinestatic

Sets the Internet Header Length field of hdr.

Parameters
[out]hdrPointer to an IPv4 header.
[in]ihlSize in bytes of the Internet Header Length (including padding)

Definition at line 146 of file hdr.h.

◆ ipv4_hdr_set_version()

static void ipv4_hdr_set_version ( ipv4_hdr_t * hdr)
inlinestatic

Sets the version field of hdr to 4.

Parameters
[out]hdrPointer to an IPv4 header.

Definition at line 122 of file hdr.h.