Go to the documentation of this file.
20 #ifndef NET_IPV6_HDR_H
21 #define NET_IPV6_HDR_H
66 typedef 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);
237 return ((((hdr->
v_tc_fl.
u8[0]) & 0x03) << 4) |
285 uint8_t prot_num, uint16_t len)
287 if (((uint32_t)sum + len + prot_num) > 0xffff) {
static uint8_t ipv6_hdr_get_tc(const ipv6_hdr_t *hdr)
Gets the value of the traffic class field of hdr.
uint8_t u8[16]
divided by 16 8-bit words.
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.
A 32 bit integer in big endian aka network byte order.
network_uint16_t len
payload length of this packet.
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.
Functions to work with different byte orders.
A 16 bit integer in big endian aka network byte order.
Data type to represent an IPv6 address.
Definitions for IPv6 addresses.
static void ipv6_hdr_set_version(ipv6_hdr_t *hdr)
Sets the version field of hdr to 6.
static void ipv6_hdr_set_tc(ipv6_hdr_t *hdr, uint8_t tc)
Sets 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 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 uint32_t byteorder_ntohl(network_uint32_t v)
Convert from network byte order to host byte order, 32 bit.
static uint8_t ipv6_hdr_get_version(const ipv6_hdr_t *hdr)
Gets the value of the version field of hdr.
static void ipv6_hdr_set_fl(ipv6_hdr_t *hdr, uint32_t fl)
Sets the flow label field of hdr.
uint8_t nh
type of next header in this packet.
static network_uint32_t byteorder_htonl(uint32_t v)
Convert from host byte order to network byte order, 32 bit.
static uint32_t ipv6_hdr_get_fl(const ipv6_hdr_t *hdr)
Gets the value of the flow label field of hdr.
uint8_t hl
hop limit for this packet.
ipv6_addr_t src
source address of this packet.
ipv6_addr_t dst
destination address of this packet.
uint8_t u8[4]
8 bit representation
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.
void ipv6_hdr_print(ipv6_hdr_t *hdr)
Outputs an IPv6 header to stdout.
uint16_t u16[2]
16 bit representation
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.
Data type to represent an IPv6 packet header.
Internet Checksum definitions.
network_uint32_t v_tc_fl
Version, traffic class, and flow label.
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.