Loading...
Searching...
No Matches
ipv4_hdr_t Struct Reference

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

Detailed Description

Data type to represent an IPv4 packet header.

The structure of the header is as follows:

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 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
See also
RFC 791, section 3.1

Definition at line 72 of file hdr.h.

#include <hdr.h>

Data Fields

uint8_t v_ihl
 Version and Internet Header Length.
 
uint8_t ts
 type of service of packet
 
network_uint16_t tl
 total length of the datagram
 
network_uint16_t id
 identification value of packet
 
network_uint16_t fl_fo
 Version control flags and Fragment Offset.
 
uint8_t ttl
 time to live for this packet
 
uint8_t protocol
 protocol of this packet
 
network_uint16_t csum
 checksum of this packet
 
ipv4_addr_t src
 source address of this packet
 
ipv4_addr_t dst
 destination address of this packet
 

Field Documentation

◆ csum

network_uint16_t ipv4_hdr_t::csum

checksum of this packet

Definition at line 112 of file hdr.h.

◆ dst

ipv4_addr_t ipv4_hdr_t::dst

destination address of this packet

Definition at line 114 of file hdr.h.

◆ fl_fo

network_uint16_t ipv4_hdr_t::fl_fo

Version control flags and Fragment Offset.

The flags are the 3 most significant bits, and the remaining 13 bits are the fragment offset.

This module provides helper functions to set, get, and check these fields accordingly:

Definition at line 109 of file hdr.h.

◆ id

network_uint16_t ipv4_hdr_t::id

identification value of packet

Definition at line 94 of file hdr.h.

◆ protocol

uint8_t ipv4_hdr_t::protocol

protocol of this packet

Definition at line 111 of file hdr.h.

◆ src

ipv4_addr_t ipv4_hdr_t::src

source address of this packet

Definition at line 113 of file hdr.h.

◆ tl

network_uint16_t ipv4_hdr_t::tl

total length of the datagram

Definition at line 93 of file hdr.h.

◆ ts

uint8_t ipv4_hdr_t::ts

type of service of packet

Definition at line 92 of file hdr.h.

◆ ttl

uint8_t ipv4_hdr_t::ttl

time to live for this packet

Definition at line 110 of file hdr.h.

◆ v_ihl

uint8_t ipv4_hdr_t::v_ihl

Version and Internet Header Length.

The version is encoded in the four most significant bits and the Internet Header Length in the four least significant bits (see above).

The Internet Header Length is the length of the header in 32-bit words, so it must be multiplied by 4 to get the length in bytes. The minimum value is 5 (20 bytes) and the maximum is 15 (60 bytes).

This module provides helper functions to set, get, and check these fields accordingly:

Definition at line 91 of file hdr.h.


The documentation for this struct was generated from the following file: