55typedef struct __attribute__((packed)) {
113 return ((hdr->
v_ih) >> 4);
125 hdr->
v_ih |= 0x0f & (ihl >> 5);
137 return (hdr->
v_ih & 0x0f) << 5;
149 hdr->
fl_fo.
u8[0] |= (0xe0 & (flags << 5));
161 return (((hdr->
fl_fo.
u8[0]) >> 5) & 0x07);
173 hdr->
fl_fo.
u8[0] |= (0x1f & (fo >> 8));
Functions to work with different byte orders.
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.
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)
brief Gets the value of the Internet Header Length field of hdr
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_version(ipv4_hdr_t *hdr)
Sets the version field of hdr to 6.
static void ipv4_hdr_set_fo(ipv4_hdr_t *hdr, uint16_t fo)
Sets the Fragment Offset field of hdr.
IPv4 address type and helper functions definitions.
Data type to represent an IPv4 packet header.
network_uint16_t tl
total length of the datagram
ipv4_addr_t src
source address of this packet
uint8_t protocol
protocol of this packet
uint8_t v_ih
Version and Internet Header Length.
network_uint16_t csum
checksum of this packet
ipv4_addr_t dst
destination address of this packet
network_uint16_t fl_fo
version control flags and Fragment Offset.
uint8_t ttl
time to live for this packet
network_uint16_t id
identification value of packet
uint8_t ts
type of service of packet
A 16 bit integer in big endian aka network byte order.
uint8_t u8[2]
8 bit representation
Data type to represent an IPv4 address.