Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
nat64-6lowpan.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2026, RISE Research Institutes of Sweden AB.
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the copyright holder nor the names of its
14
* contributors may be used to endorse or promote products derived
15
* from this software without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
* OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
/**
32
* \addtogroup nat64
33
* @{
34
*
35
* \file
36
* 6LoWPAN compression context for the NAT64 prefix.
37
*
38
* Registers the upper 64 bits of the NAT64 prefix as IPHC
39
* context 1, saving ~8 header bytes per NAT64-bound packet.
40
* Must be included from project-conf.h on both the border
41
* router and every IoT node sending NAT64 traffic; the two
42
* sides must agree on prefix and context number, otherwise
43
* frames silently fail to decompress.
44
*
45
* TODO: replace with runtime distribution once Contiki-NG
46
* implements RFC 6775 ยง4.2 (6CO option in RAs).
47
*
48
* \author
49
* Nicolas Tsiftes <nicolas.tsiftes@ri.se>
50
*/
51
52
#ifndef NAT64_6LOWPAN_H_
53
#define NAT64_6LOWPAN_H_
54
55
/**
56
* \brief Upper 64 bits of the NAT64 prefix as 8 bytes.
57
*
58
* Defaults to the well-known `64:ff9b::/96` (RFC 6052). Override
59
* only for a non-standard prefix; both ends must match.
60
*/
61
#ifndef NAT64_6LOWPAN_PREFIX_BYTES
62
#define NAT64_6LOWPAN_PREFIX_BYTES 0x00, 0x64, 0xff, 0x9b, \
63
0x00, 0x00, 0x00, 0x00
64
#endif
65
66
/* Reserve slot 0 for the network prefix and slot 1 for NAT64. */
67
#ifndef SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS
68
#define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 2
69
#elif SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS < 2
70
#error "NAT64 6LoWPAN context requires SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS >= 2"
71
#endif
72
73
/* Install the NAT64 prefix into context slot 1 from sicslowpan_init().
74
* Only the upper 64 bits are elided; the embedded IPv4 in the lower
75
* 64 bits is carried inline via IPHC SAM=01 (8 bytes). */
76
#define SICSLOWPAN_CONF_ADDR_CONTEXT_1 \
77
do { \
78
static const uint8_t nat64_ctx_prefix[8] = { \
79
NAT64_6LOWPAN_PREFIX_BYTES \
80
}; \
81
memcpy(addr_contexts[1].prefix, nat64_ctx_prefix, 8); \
82
} while(0)
83
84
/** @} */
85
86
#endif
/* NAT64_6LOWPAN_H_ */
os
services
nat64
nat64-6lowpan.h
Generated on
for Contiki-NG by
1.17.0