Go to the documentation of this file.
20 #ifndef NET_IPV4_HDR_H
21 #define NET_IPV4_HDR_H
55 typedef struct __attribute__((packed)) {
114 return ((hdr->
v_ih) >> 4);
126 hdr->
v_ih |= 0x0f & (ihl >> 5);
138 return (hdr->
v_ih & 0x0f) << 5;
150 hdr->
fl_fo.
u8[0] |= (0xe0 & (flags << 5));
162 return (((hdr->
fl_fo.
u8[0]) >> 5) & 0x07);
174 hdr->
fl_fo.
u8[0] |= (0x1f & (fo >> 8));
uint8_t protocol
protocol of this packet
ipv4_addr_t src
source address of this packet
network_uint16_t csum
checksum of this packet
Data type to represent an IPv4 address.
static void ipv4_hdr_set_version(ipv4_hdr_t *hdr)
Sets the version field of hdr to 6.
ipv4_addr_t dst
destination address of this packet
Functions to work with different byte orders.
IPv6 address type and helper functions definitions.
A 16 bit integer in big endian aka network byte order.
static void ipv4_hdr_set_ihl(ipv4_hdr_t *hdr, uint16_t ihl)
Sets the Internet Header Length field of hdr.
uint8_t u8[2]
8 bit representation
uint8_t v_ih
Version and Internet Header Length.
network_uint16_t id
identification value of packet
network_uint16_t tl
total length of the datagram
uint8_t ts
type of service of packet
uint8_t ttl
time to live for this packet
network_uint16_t fl_fo
version control flags and Fragment Offset.
static uint8_t ipv4_hdr_get_version(ipv4_hdr_t *hdr)
Gets the value of the version field of hdr.
static uint16_t ipv4_hdr_get_fo(ipv4_hdr_t *hdr)
brief Gets the value of the Fragment Offset field of hdr
static void ipv4_hdr_set_fo(ipv4_hdr_t *hdr, uint16_t fo)
Sets the Fragment Offset field of hdr.
Data type to represent an IPv4 packet header.
static uint16_t ipv4_hdr_get_ihl(ipv4_hdr_t *hdr)
brief Gets the value of the Internet Header Length field of hdr
static uint8_t ipv4_hdr_get_flags(ipv4_hdr_t *hdr)
brief Gets the value of the Version Control Flags field of hdr
static void ipv4_hdr_set_flags(ipv4_hdr_t *hdr, uint8_t flags)
Sets the Version Control Flags field of hdr.