66typedef struct __attribute__((packed)) {
129 return (((hdr->
v_tc_fl.
u8[0]) & 0xf0) == 0x60);
141 hdr->
v_tc_fl.
u8[0] |= (0x0f & (tc >> 4));
143 hdr->
v_tc_fl.
u8[1] |= (0xf0 & (tc << 4));
163 hdr->
v_tc_fl.
u8[0] |= (0x0c & (ecn << 2));
183 hdr->
v_tc_fl.
u8[0] |= (0x03 & (dscp >> 4));
185 hdr->
v_tc_fl.
u8[1] |= (0xf0 & (dscp << 4));
197 return ((((hdr->
v_tc_fl.
u8[0]) & 0x0f) << 4) |
217 return (((hdr->
v_tc_fl.
u8[0]) & 0x0c) >> 2);
236 return ((((hdr->
v_tc_fl.
u8[0]) & 0x03) << 4) |
284 uint8_t prot_num, uint16_t len)
286 if (((uint32_t)sum + len + prot_num) > 0xffff) {
Functions to work with different byte orders.
static uint32_t byteorder_ntohl(network_uint32_t v)
Convert from network byte order to host byte order, 32 bit.
static network_uint32_t byteorder_htonl(uint32_t v)
Convert from host byte order to network byte order, 32 bit.
static uint16_t inet_csum(uint16_t sum, const uint8_t *buf, uint16_t len)
Calculates the unnormalized Internet Checksum of buf, where the buffer provides a standalone domain f...
static void ipv6_hdr_set_fl(ipv6_hdr_t *hdr, uint32_t fl)
Sets the flow label field of hdr.
static uint8_t ipv6_hdr_get_tc(const ipv6_hdr_t *hdr)
Gets the value of the traffic class field of hdr.
static uint8_t ipv6_hdr_get_version(const ipv6_hdr_t *hdr)
Gets the value of the version field of hdr.
static uint32_t ipv6_hdr_get_fl(const ipv6_hdr_t *hdr)
Gets the value of the flow label field of hdr.
static void ipv6_hdr_set_tc_ecn(ipv6_hdr_t *hdr, uint8_t ecn)
Sets the value of the Explicit Congestion Notification (ECN) part of the traffic class field of hdr.
static uint8_t ipv6_hdr_get_tc_ecn(const ipv6_hdr_t *hdr)
Gets the value of the Explicit Congestion Notification (ECN) part of the traffic class field of hdr.
static uint8_t ipv6_hdr_get_tc_dscp(const ipv6_hdr_t *hdr)
Gets the value of the Differentiated Service Codepoint (DSCP) part of the traffic class field of hdr.
static void ipv6_hdr_set_version(ipv6_hdr_t *hdr)
Sets the version field of hdr to 6.
void ipv6_hdr_print(ipv6_hdr_t *hdr)
Outputs an IPv6 header to stdout.
static void ipv6_hdr_set_tc_dscp(ipv6_hdr_t *hdr, uint8_t dscp)
Sets the value of the Differentiated Service Codepoint (DSCP) part of the traffic class field of hdr.
static bool ipv6_hdr_is(const ipv6_hdr_t *hdr)
Checks if the version field is set to 6.
static uint16_t ipv6_hdr_inet_csum(uint16_t sum, ipv6_hdr_t *hdr, uint8_t prot_num, uint16_t len)
Calculates the Internet Checksum for the IPv6 Pseudo Header.
static void ipv6_hdr_set_tc(ipv6_hdr_t *hdr, uint8_t tc)
Sets the traffic class field of hdr.
Internet Checksum definitions.
Definitions for IPv6 addresses.
Data type to represent an IPv6 packet header.
network_uint32_t v_tc_fl
Version, traffic class, and flow label.
uint8_t nh
type of next header in this packet.
uint8_t hl
hop limit for this packet.
network_uint16_t len
payload length of this packet.
ipv6_addr_t src
source address of this packet.
ipv6_addr_t dst
destination address of this packet.
A 16 bit integer in big endian aka network byte order.
A 32 bit integer in big endian aka network byte order.
uint16_t u16[2]
16 bit representation
uint8_t u8[4]
8 bit representation
Data type to represent an IPv6 address.
uint8_t u8[16]
divided by 16 8-bit words.