Loading...
Searching...
No Matches
frag.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
20
21#include <stdbool.h>
22#include <stdint.h>
23
24#include "byteorder.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#define IPV6_EXT_FRAG_OFFSET_MASK (0xFFF8)
31#define IPV6_EXT_FRAG_M (0x0001)
32
36typedef struct __attribute__((packed)) {
37 uint8_t nh;
38 uint8_t resv;
51
59static inline unsigned ipv6_ext_frag_get_offset(const ipv6_ext_frag_t *frag)
60{
61 /* The offset is left-shifted by 3 bytes in the header * (equivalent to
62 * multiplication with 8), and the offset is in units 8 bytes
63 * so no shifting or multiplying necessary to get offset in bytes */
65}
66
75static inline bool ipv6_ext_frag_more(const ipv6_ext_frag_t *frag)
76{
78}
79
91 unsigned offset)
92{
93 /* The offset is left-shifted by 3 bytes in the header * (equivalent to
94 * multiplication with 8), and the offset is a multiple of 8 bytes
95 * so no shifting or division necessary to set offset in units of 8 bytes */
97}
98
107{
108 frag->offset_flags.u8[1] |= IPV6_EXT_FRAG_M;
109}
110
111#ifdef __cplusplus
112}
113#endif
114
Functions to work with different byte orders.
be_uint32_t network_uint32_t
A 32 bit integer in network byte order.
Definition byteorder.h:109
be_uint16_t network_uint16_t
A 16 bit integer in network byte order.
Definition byteorder.h:104
static network_uint16_t byteorder_htons(uint16_t v)
Convert from host byte order to network byte order, 16 bit.
Definition byteorder.h:481
static uint16_t byteorder_ntohs(network_uint16_t v)
Convert from network byte order to host byte order, 16 bit.
Definition byteorder.h:502
#define IPV6_EXT_FRAG_M
M flag.
Definition frag.h:31
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:90
static unsigned ipv6_ext_frag_get_offset(const ipv6_ext_frag_t *frag)
Get offset of fragment in bytes.
Definition frag.h:59
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:75
static void ipv6_ext_frag_set_more(ipv6_ext_frag_t *frag)
Sets the M flag of a fragment header.
Definition frag.h:106
#define IPV6_EXT_FRAG_OFFSET_MASK
Mask for the offset.
Definition frag.h:30
Fragment header definition.
Definition frag.h:36
network_uint16_t offset_flags
11-bit fragment offset and flags
Definition frag.h:48
network_uint32_t id
identification
Definition frag.h:49
uint8_t resv
reserved
Definition frag.h:38
uint8_t nh
next header
Definition frag.h:37
uint8_t u8[2]
8 bit representation
Definition byteorder.h:72