Loading...
Searching...
No Matches
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
30extern "C" {
31#endif
32
33#define IPV6_EXT_FRAG_OFFSET_MASK (0xFFF8)
34#define IPV6_EXT_FRAG_M (0x0001)
39typedef struct __attribute__((packed)) {
40 uint8_t nh;
41 uint8_t resv;
54
62static 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
78static inline bool ipv6_ext_frag_more(const ipv6_ext_frag_t *frag)
79{
81}
82
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
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 */
Functions to work with different byte orders.
static network_uint16_t byteorder_htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
Definition byteorder.h:485
static uint16_t byteorder_ntohs(network_uint16_t v)
Convert from network byte order to host byte order, 16 bit.
Definition byteorder.h:506
#define IPV6_EXT_FRAG_M
M flag.
Definition frag.h:34
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
static unsigned ipv6_ext_frag_get_offset(const ipv6_ext_frag_t *frag)
Get offset of fragment in bytes.
Definition frag.h:62
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
static void ipv6_ext_frag_set_more(ipv6_ext_frag_t *frag)
Sets the M flag of a fragment header.
Definition frag.h:109
#define IPV6_EXT_FRAG_OFFSET_MASK
Mask for the offset.
Definition frag.h:33
Fragment header definition.
Definition frag.h:39
network_uint16_t offset_flags
11-bit fragment offset and flags
Definition frag.h:51
network_uint32_t id
identification
Definition frag.h:52
uint8_t resv
reserved
Definition frag.h:41
uint8_t nh
next header
Definition frag.h:40
A 16 bit integer in big endian aka network byte order.
Definition byteorder.h:74
uint8_t u8[2]
8 bit representation
Definition byteorder.h:76
A 32 bit integer in big endian aka network byte order.
Definition byteorder.h:84