25 #ifndef ROHC_PROTOCOLS_IPV6_H 26 #define ROHC_PROTOCOLS_IPV6_H 41 #define IPV6_ADDR_FORMAT \ 42 "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x" 46 #define IPV6_ADDR_IN6(x) \ 47 IPV6_ADDR_RAW((x)->u8) 51 #define IPV6_ADDR_RAW(x) \ 52 (x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], (x)[6], (x)[7], \ 53 (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], (x)[15] 66 } __attribute__((packed));
67 } __attribute__((packed));
71 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ 72 (defined(__GNUC__) && defined(__GNUC_MINOR__) && \ 73 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))) 74 _Static_assert(
sizeof(
struct ipv6_addr) == 16,
75 "IPv6 address should exactly 16-byte long");
87 #define IPV6_VERSION_MASK 0xf0000000U 88 #define IPV6_TC_MASK 0x0ff00000U 89 #define IPV6_FLOW_MASK 0x000fffffU 92 #if WORDS_BIGENDIAN == 1 104 } __attribute__((packed));
107 #if WORDS_BIGENDIAN == 1 121 } __attribute__((packed));
123 } __attribute__((packed));
131 } __attribute__((packed));
135 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ 136 (defined(__GNUC__) && defined(__GNUC_MINOR__) && \ 137 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))) 138 _Static_assert(
sizeof(
struct ipv6_hdr) == 40,
139 "IPv6 header should exactly 40-byte long");
144 #define IPV6_OPT_HDR_LEN_FIELD_MAX_VAL 4U 146 #define IPV6_OPT_HDR_LEN_MAX ((IPV6_OPT_HDR_LEN_FIELD_MAX_VAL + 1U) * 8U) 148 #define IPV6_OPT_CTXT_LEN_MAX (IPV6_OPT_HDR_LEN_MAX - 2U) 157 } __attribute__((packed));
161 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ 162 (defined(__GNUC__) && defined(__GNUC_MINOR__) && \ 163 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))) 164 _Static_assert(
sizeof(
struct ipv6_opt) == 3,
165 "IPv6 option header should exactly 3-byte long");
170 __attribute__((warn_unused_result,
nonnull(1), pure));
180 __attribute__((warn_unused_result,
nonnull(1), pure));
185 __attribute__((warn_unused_result,
nonnull(1), pure));
187 const uint32_t flow_label)
191 __attribute__((warn_unused_result,
nonnull(1), pure));
202 return ((ipv6->
tc1 << 4) | ipv6->
tc2);
214 ipv6->
tc1 = (tc >> 4) & 0x0f;
215 ipv6->
tc2 = tc & 0x0f;
230 ipv6_set_tc(ipv6, ((dscp << 2) & 0xfc) | (ecn & 0x03));
254 ipv6->
dscp1 = (dscp >> 2) & 0x0f;
255 ipv6->
dscp2 = dscp & 0x03;
278 const uint32_t flow_label)
280 ipv6->
flow1 = (flow_label >> 16);
293 return ((opt->
length + 1) * 8);
uint8_t value[1]
Definition: ipv6.h:156
uint16_t flow2_
Definition: ipv6.h:120
struct ipv6_addr daddr
Definition: ipv6.h:129
static uint32_t ipv6_get_flow_label(const struct ipv6_hdr *const ipv6)
Get the Flow Label of the given IPv6 packet.
Definition: ipv6.h:265
uint8_t next_header
Definition: ipv6.h:154
uint16_t flow2
Definition: ipv6.h:103
uint8_t hl
Definition: ipv6.h:127
uint8_t ecn
Definition: ipv6.h:117
static void ipv6_set_flow_label(struct ipv6_hdr *const ipv6, const uint32_t flow_label)
Set the Flow Label of the given IPv6 packet.
Definition: ipv6.h:277
static size_t ipv6_opt_get_length(const struct ipv6_opt *const opt)
get the length (in bytes) of the IPv6 option header
Definition: ipv6.h:291
static void ipv6_set_dscp(struct ipv6_hdr *const ipv6, const uint8_t dscp)
Set the Differentiated Services Code Point (DSCP) of the given IPv6 packet.
Definition: ipv6.h:252
The IPv6 header.
Definition: ipv6.h:82
uint8_t dscp2
Definition: ipv6.h:118
Miscellaneous utils for ROHC libraries.
uint8_t tc2
Definition: ipv6.h:101
struct ipv6_addr saddr
Definition: ipv6.h:128
static void ipv6_set_dscp_ecn(struct ipv6_hdr *const ipv6, const uint8_t dscp, const uint8_t ecn)
Set the DSCP and ECN of the given IPv6 packet.
Definition: ipv6.h:226
uint8_t version
Definition: ipv6.h:99
#define IPV6_FLOW_MASK
Definition: ipv6.h:89
uint8_t flowl1_
Definition: ipv6.h:116
static uint8_t ipv6_get_dscp(const struct ipv6_hdr *const ipv6)
Get the Differentiated Services Code Point (DSCP) of the given IPv6 packet.
Definition: ipv6.h:240
static uint8_t ipv6_get_tc(const struct ipv6_hdr *const ipv6)
Get the Traffic Class (TC) of the given IPv6 packet.
Definition: ipv6.h:200
uint16_t rohc_hton16(const uint16_t host16)
Convert a 16-bit short integer from host to network byte orders.
Definition: rohc_utils.c:104
uint32_t version_tc_flow
Definition: ipv6.h:86
uint8_t u8[16]
Definition: ipv6.h:63
uint8_t dscp1
Definition: ipv6.h:114
uint32_t u32[4]
Definition: ipv6.h:65
uint16_t plen
Definition: ipv6.h:125
uint8_t length
Definition: ipv6.h:155
uint32_t rohc_ntoh32(const uint32_t net32)
Convert a 32-bit long integer from network to host byte orders.
Definition: rohc_utils.c:55
static void ipv6_set_tc(struct ipv6_hdr *const ipv6, const uint8_t tc)
Set the Traffic Class (TC) of the given IPv6 packet.
Definition: ipv6.h:212
uint8_t version_
Definition: ipv6.h:115
uint8_t tc1
Definition: ipv6.h:98
The IPv6 address.
Definition: ipv6.h:59
uint8_t flow1
Definition: ipv6.h:100
uint8_t nh
Definition: ipv6.h:126
uint16_t u16[8]
Definition: ipv6.h:64