frag.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef NET_IPV6_EXT_FRAG_H
22 #define NET_IPV6_EXT_FRAG_H
23 
24 #include <stdbool.h>
25 #include <stdint.h>
26 
27 #include "byteorder.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define IPV6_EXT_FRAG_OFFSET_MASK (0xFFF8)
34 #define IPV6_EXT_FRAG_M (0x0001)
39 typedef struct __attribute__((packed)) {
40  uint8_t nh;
41  uint8_t resv;
54 
62 static inline unsigned ipv6_ext_frag_get_offset(const ipv6_ext_frag_t *frag)
63 {
64  /* The offset is left-shifted by 3 bytes in the header * (equivalent to
65  * multiplication with 8), and the offset is in units 8 bytes
66  * so no shifting or multiplying necessary to get offset in bytes */
68 }
69 
78 static inline bool ipv6_ext_frag_more(const ipv6_ext_frag_t *frag)
79 {
81 }
82 
93 static inline void ipv6_ext_frag_set_offset(ipv6_ext_frag_t *frag,
94  unsigned offset)
95 {
96  /* The offset is left-shifted by 3 bytes in the header * (equivalent to
97  * multiplication with 8), and the offset is a multiple of 8 bytes
98  * so no shifting or division necessary to set offset in units of 8 bytes */
100 }
101 
109 static inline void ipv6_ext_frag_set_more(ipv6_ext_frag_t *frag)
110 {
111  frag->offset_flags.u8[1] |= IPV6_EXT_FRAG_M;
112 }
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /* NET_IPV6_EXT_FRAG_H */
119 
uint8_t resv
reserved
Definition: frag.h:41
Fragment header definition.
Definition: frag.h:39
network_uint32_t id
identification
Definition: frag.h:52
static unsigned ipv6_ext_frag_get_offset(const ipv6_ext_frag_t *frag)
Get offset of fragment in bytes.
Definition: frag.h:62
network_uint16_t offset_flags
11-bit fragment offset and flags
Definition: frag.h:51
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:87
static void ipv6_ext_frag_set_offset(ipv6_ext_frag_t *frag, unsigned offset)
Sets the offset field of a fragment header.
Definition: frag.h:93
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
#define IPV6_EXT_FRAG_M
M flag.
Definition: frag.h:34
static void ipv6_ext_frag_set_more(ipv6_ext_frag_t *frag)
Sets the M flag of a fragment header.
Definition: frag.h:109
static bool ipv6_ext_frag_more(const ipv6_ext_frag_t *frag)
Checks if more fragments are coming after the given fragment.
Definition: frag.h:78
uint8_t nh
next header
Definition: frag.h:40
static network_uint16_t byteorder_htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
Definition: byteorder.h:437
Functions to work with different byte orders.
#define IPV6_EXT_FRAG_OFFSET_MASK
Mask for the offset.
Definition: frag.h:33
uint8_t u8[2]
8 bit representation
Definition: byteorder.h:79
static uint16_t byteorder_ntohs(network_uint16_t v)
Convert from network byte order to host byte order, 16 bit.
Definition: byteorder.h:458