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] 57 #define IPV6_ADDR_CMP(x, y) \ 58 ((x)->u32[0] == (y)->u32[0] && (x)->u32[1] == (y)->u32[1] && \ 59 (x)->u32[2] == (y)->u32[2] && (x)->u32[3] == (y)->u32[3]) 72 } __attribute__((packed));
73 } __attribute__((packed));
77 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ 78 (defined(__GNUC__) && defined(__GNUC_MINOR__) && \ 79 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))) 80 _Static_assert(
sizeof(
struct ipv6_addr) == 16,
81 "IPv6 address should exactly 16-byte long");
93 #define IPV6_VERSION_MASK 0xf0000000U 94 #define IPV6_TC_MASK 0x0ff00000U 95 #define IPV6_FLOW_MASK 0x000fffffU 98 #if WORDS_BIGENDIAN == 1 110 } __attribute__((packed));
113 #if WORDS_BIGENDIAN == 1 127 } __attribute__((packed));
129 } __attribute__((packed));
137 } __attribute__((packed));
141 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ 142 (defined(__GNUC__) && defined(__GNUC_MINOR__) && \ 143 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))) 144 _Static_assert(
sizeof(
struct ipv6_hdr) == 40,
145 "IPv6 header should exactly 40-byte long");
150 #define IPV6_OPT_HDR_LEN_FIELD_MAX_VAL 0xffU 152 #define IPV6_OPT_HDR_LEN_MAX ((IPV6_OPT_HDR_LEN_FIELD_MAX_VAL + 1) * 8) 154 #define IPV6_OPT_CTXT_LEN_MAX (IPV6_OPT_HDR_LEN_MAX - 2) 163 } __attribute__((packed));
167 #if ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ 168 (defined(__GNUC__) && defined(__GNUC_MINOR__) && \ 169 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))) 170 _Static_assert(
sizeof(
struct ipv6_opt) == 3,
171 "IPv6 option header should exactly 3-byte long");
176 __attribute__((warn_unused_result, nonnull(1), pure));
178 __attribute__((nonnull(1)));
183 __attribute__((nonnull(1)));
186 __attribute__((warn_unused_result, nonnull(1), pure));
188 __attribute__((nonnull(1)));
191 __attribute__((warn_unused_result, nonnull(1), pure));
193 const uint32_t flow_label)
194 __attribute__((nonnull(1)));
197 __attribute__((warn_unused_result, nonnull(1), pure));
208 return ((ipv6->
tc1 << 4) | ipv6->
tc2);
220 ipv6->
tc1 = (tc >> 4) & 0x0f;
221 ipv6->
tc2 = tc & 0x0f;
236 ipv6_set_tc(ipv6, ((dscp << 2) & 0xfc) | (ecn & 0x03));
260 ipv6->
dscp1 = (dscp >> 2) & 0x0f;
261 ipv6->
dscp2 = dscp & 0x03;
284 const uint32_t flow_label)
286 ipv6->
flow1 = (flow_label >> 16);
299 return ((opt->
length + 1) * 8);
uint16_t flow2_
Definition: ipv6.h:126
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:271
uint8_t next_header
Definition: ipv6.h:160
uint16_t flow2
Definition: ipv6.h:109
uint8_t hl
Definition: ipv6.h:133
uint8_t ecn
Definition: ipv6.h:123
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:283
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:297
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:258
The IPv6 header.
Definition: ipv6.h:88
uint8_t dscp2
Definition: ipv6.h:124
Miscellaneous utils for ROHC libraries.
uint8_t tc2
Definition: ipv6.h:107
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:232
uint8_t version
Definition: ipv6.h:105
#define IPV6_FLOW_MASK
Definition: ipv6.h:95
uint8_t flowl1_
Definition: ipv6.h:122
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:246
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:206
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:92
uint8_t u8[16]
Definition: ipv6.h:69
uint8_t dscp1
Definition: ipv6.h:120
uint32_t u32[4]
Definition: ipv6.h:71
uint16_t plen
Definition: ipv6.h:131
uint8_t length
Definition: ipv6.h:161
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:218
uint8_t version_
Definition: ipv6.h:121
uint8_t tc1
Definition: ipv6.h:104
The IPv6 address.
Definition: ipv6.h:65
uint8_t flow1
Definition: ipv6.h:106
uint8_t nh
Definition: ipv6.h:132
uint16_t u16[8]
Definition: ipv6.h:70