IPv6 header

IPv6 header types and helper functions. More...

Detailed Description

Files

file  ipv6/hdr.h
 IPv6 header type and helper function definitions.
 

Data Structures

struct  ipv6_hdr_t
 Data type to represent an IPv6 packet header. More...
 

Functions

static void ipv6_hdr_set_version (ipv6_hdr_t *hdr)
 Sets the version field of hdr to 6. More...
 
static uint8_t ipv6_hdr_get_version (const ipv6_hdr_t *hdr)
 Gets the value of the version field of hdr. More...
 
static bool ipv6_hdr_is (const ipv6_hdr_t *hdr)
 Checks if the version field is set to 6. More...
 
static void ipv6_hdr_set_tc (ipv6_hdr_t *hdr, uint8_t tc)
 Sets the traffic class field of hdr. More...
 
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. More...
 
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. More...
 
static uint8_t ipv6_hdr_get_tc (const ipv6_hdr_t *hdr)
 Gets the value of the traffic class field of hdr. More...
 
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. More...
 
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. More...
 
static void ipv6_hdr_set_fl (ipv6_hdr_t *hdr, uint32_t fl)
 Sets the flow label field of hdr. More...
 
static uint32_t ipv6_hdr_get_fl (const ipv6_hdr_t *hdr)
 Gets the value of the flow label field of hdr. More...
 
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. More...
 
void ipv6_hdr_print (ipv6_hdr_t *hdr)
 Outputs an IPv6 header to stdout. More...
 

Function Documentation

◆ ipv6_hdr_get_fl()

static uint32_t ipv6_hdr_get_fl ( const ipv6_hdr_t hdr)
inlinestatic
Parameters
[in]hdrPointer to an IPv6 header.
Returns
Value of the flow label field of hdr.

Definition at line 263 of file ipv6/hdr.h.

◆ ipv6_hdr_get_tc()

static uint8_t ipv6_hdr_get_tc ( const ipv6_hdr_t hdr)
inlinestatic
Parameters
[in]hdrPointer to an IPv6 header.
Returns
Value of the traffic class field of hdr.

Definition at line 197 of file ipv6/hdr.h.

◆ ipv6_hdr_get_tc_dscp()

static uint8_t ipv6_hdr_get_tc_dscp ( const ipv6_hdr_t hdr)
inlinestatic

The field is needed e.g. in context of 6LoWPAN header compression

See also
RFC 2474, section 3
Parameters
[in]hdrPointer to an IPv6 header.
Returns
Value of the DSCP part of the traffic class field of hdr.

Definition at line 237 of file ipv6/hdr.h.

◆ ipv6_hdr_get_tc_ecn()

static uint8_t ipv6_hdr_get_tc_ecn ( const ipv6_hdr_t hdr)
inlinestatic

The field is needed e.g. in context of 6LoWPAN header compression

See also
RFC 3168, section 5
Parameters
[in]hdrPointer to an IPv6 header.
Returns
Value of the ECN part of the traffic class field of hdr.

Definition at line 217 of file ipv6/hdr.h.

◆ ipv6_hdr_get_version()

static uint8_t ipv6_hdr_get_version ( const ipv6_hdr_t hdr)
inlinestatic
Parameters
[in]hdrPointer to an IPv6 header.
Returns
Value of the version field of hdr.

Definition at line 116 of file ipv6/hdr.h.

◆ ipv6_hdr_inet_csum()

static uint16_t ipv6_hdr_inet_csum ( uint16_t  sum,
ipv6_hdr_t hdr,
uint8_t  prot_num,
uint16_t  len 
)
inlinestatic
See also
RFC 2460, section 8.1
Parameters
[in]sumPreinialized value of the sum.
[in]prot_numThe Protocol Numbers you want to calculate the checksum for. Can not be inferred from ipv6_hdr_t::nh, since it can be an IPv6 exentension header.
[in]hdrAn IPv6 header to derive the Pseudo Header from.
[in]lenThe upper-layer packet length for the pseudo header. Can not be inferred from ipv6_hdr_t::len, since there can be extension headers between the IPv6 header and the payload.
Returns
The non-normalized Internet Checksum of the given IPv6 pseudo header.

Definition at line 288 of file ipv6/hdr.h.

◆ ipv6_hdr_is()

static bool ipv6_hdr_is ( const ipv6_hdr_t hdr)
inlinestatic
Parameters
[in]hdrPointer to an IPv6 header.
Returns
true, if version field is 6
false, otherwise

Definition at line 129 of file ipv6/hdr.h.

◆ ipv6_hdr_print()

void ipv6_hdr_print ( ipv6_hdr_t hdr)
Parameters
[in]hdrAn IPv6 header.

◆ ipv6_hdr_set_fl()

static void ipv6_hdr_set_fl ( ipv6_hdr_t hdr,
uint32_t  fl 
)
inlinestatic
Parameters
[out]hdrPointer to an IPv6 header.
[in]flThe new value for the flow label field in host byte order.

Definition at line 249 of file ipv6/hdr.h.

◆ ipv6_hdr_set_tc()

static void ipv6_hdr_set_tc ( ipv6_hdr_t hdr,
uint8_t  tc 
)
inlinestatic
Parameters
[out]hdrPointer to an IPv6 header.
[in]tcThe new value for the traffic class field.

Definition at line 140 of file ipv6/hdr.h.

◆ ipv6_hdr_set_tc_dscp()

static void ipv6_hdr_set_tc_dscp ( ipv6_hdr_t hdr,
uint8_t  dscp 
)
inlinestatic

The field is needed e.g. in context of 6LoWPAN header compression

See also
RFC 2474, section 3
Parameters
[out]hdrPointer to an IPv6 header.
[in]dscpThe new value for the 6-bit DSCP part of the traffic class field.

Definition at line 182 of file ipv6/hdr.h.

◆ ipv6_hdr_set_tc_ecn()

static void ipv6_hdr_set_tc_ecn ( ipv6_hdr_t hdr,
uint8_t  ecn 
)
inlinestatic

The field is needed e.g. in context of 6LoWPAN header compression

See also
RFC 3168, section 5
Parameters
[out]hdrPointer to an IPv6 header.
[in]ecnThe new value for the 2-bit ECN part of the traffic class field.

Definition at line 162 of file ipv6/hdr.h.

◆ ipv6_hdr_set_version()

static void ipv6_hdr_set_version ( ipv6_hdr_t hdr)
inlinestatic
Parameters
[out]hdrPointer to an IPv6 header.

Definition at line 103 of file ipv6/hdr.h.