Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
nat64-dns64.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
* NAT64 DNS64 translation (RFC 6147).
37
*
38
* Rewrites outgoing DNS messages so that an IPv4 resolver
39
* sees A queries and the IoT node sees AAAA responses with
40
* IPv4 addresses synthesized into the NAT64 prefix. All
41
* translation happens in-place or single-pass into a caller-
42
* supplied buffer; no DNS state is kept across calls.
43
* \author
44
* Nicolas Tsiftes <nicolas.tsiftes@ri.se>
45
*/
46
47
#ifndef NAT64_DNS64_H_
48
#define NAT64_DNS64_H_
49
50
#include <stdint.h>
51
52
/**
53
* \brief Rewrite an outgoing DNS query from AAAA to A.
54
* \param data DNS payload buffer (modified in place).
55
* \param len Length of the DNS payload.
56
*
57
* Modifies QTYPE fields in-place so that the upstream IPv4 DNS server
58
* receives an A query instead of AAAA (RFC 6147).
59
*/
60
void
nat64_dns64_6to4
(uint8_t *data, uint16_t len);
61
62
/**
63
* \brief Rewrite an incoming DNS response from A to AAAA.
64
* \param ipv4data Original DNS response from the IPv4 server (read-only).
65
* \param ipv4len Length of the original response.
66
* \param ipv6data Output buffer for the rewritten response.
67
* \param ipv6len Length of the data already copied into ipv6data.
68
* \param ipv6bufsiz Total size of the ipv6data output buffer.
69
* \return New payload length (>= ipv6len due to 4-to-16 byte address growth).
70
*
71
* Converts A records to AAAA records by synthesizing IPv6 addresses
72
* using the NAT64 prefix. Each A record grows by 12 bytes. Stops
73
* translating if the output would exceed ipv6bufsiz.
74
*/
75
uint16_t
nat64_dns64_4to6
(
const
uint8_t *ipv4data, uint16_t ipv4len,
76
uint8_t *ipv6data, uint16_t ipv6len,
77
uint16_t ipv6bufsiz);
78
79
/** @} */
80
81
#endif
/* NAT64_DNS64_H_ */
nat64_dns64_4to6
uint16_t nat64_dns64_4to6(const uint8_t *ipv4data, uint16_t ipv4len, uint8_t *ipv6data, uint16_t ipv6len, uint16_t ipv6bufsiz)
Rewrite an incoming DNS response from A to AAAA.
Definition
nat64-dns64.c:144
nat64_dns64_6to4
void nat64_dns64_6to4(uint8_t *data, uint16_t len)
Rewrite an outgoing DNS query from AAAA to A.
Definition
nat64-dns64.c:109
os
services
nat64
nat64-dns64.h
Generated on
for Contiki-NG by
1.17.0