Contiki-NG
Loading...
Searching...
No Matches
nat64.h File Reference

NAT64 gateway core API. More...

#include <stdbool.h>
#include <stdint.h>
#include "net/ipv6/uip.h"

Go to the source code of this file.

Macros

ICMPv6 Destination Unreachable codes (RFC 4443 ยง3.1)
#define NAT64_ICMP6_NOROUTE   0
 No route to destination.
 
#define NAT64_ICMP6_ADMIN   1
 Communication administratively prohibited.
 
#define NAT64_ICMP6_ADDR   3
 Address unreachable.
 
#define NAT64_ICMP6_PORT   4
 Port unreachable.
 

Functions

int nat64_output (const uint8_t *ipv6_pkt, uint16_t len)
 Process an outgoing IPv6 packet destined for an IPv4 host.
 
bool nat64_is_ip64_addr (const uip_ip6addr_t *addr)
 Check whether an IPv6 address embeds an IPv4 address via the NAT64 prefix.
 
void nat64_activate (void)
 Initialize the NAT64 gateway.
 
Platform-to-core callbacks

Called by the platform layer (e.g., the select loop in nat64-sock.c) when data arrives on an IPv4 socket or a TCP connection changes state.

Each callback fabricates the corresponding IPv6 packet and injects it into the uIP stack via tcpip_input().

void nat64_udp_input (struct nat64_session *s, const uint8_t *payload, uint16_t len)
 Inject a UDP response from an IPv4 server.
 
void nat64_tcp_established (struct nat64_session *s)
 Notify that a TCP connection to an IPv4 server completed.
 
void nat64_tcp_data_in (struct nat64_session *s, const uint8_t *data, uint16_t len)
 Forward TCP data from an IPv4 server to the IoT node.
 
void nat64_tcp_closed (struct nat64_session *s)
 Notify that an IPv4 server closed a TCP connection.
 
void nat64_icmp_input (struct nat64_session *s, const uint8_t *icmp_pkt, uint16_t len)
 Inject an ICMPv4 Echo Reply received from an IPv4 host.
 
ICMPv6 Destination Unreachable synthesis

The gateway synthesizes ICMPv6 errors toward the IoT node when a packet cannot be delivered (forbidden destination, connection refused, host unreachable, session table exhaustion, ...).

The errors are queued and drained by nat64_flush_icmp6() from the platform layer's select loop, to avoid re-entrancy with tcpip_input() from output paths.

void nat64_queue_icmp6_unreach (const uint8_t *invoking_pkt, uint16_t invoking_len, uint8_t code)
 Queue an ICMPv6 Destination Unreachable for delivery to the IoT node.
 
void nat64_queue_icmp6_unreach_tuple (const uip_ip6addr_t *ip6_src, uint16_t src_port, const uip_ip4addr_t *ip4_dst, uint16_t dst_port, uint8_t ipproto, uint8_t code)
 Queue an ICMPv6 Destination Unreachable for a 5-tuple whose connection failed.
 
void nat64_flush_icmp6 (void)
 Drain the queue of pending ICMPv6 errors into the uIP stack.
 

Detailed Description

NAT64 gateway core API.

Public entry points used by the platform layer (output path) and by transport-specific helpers to inject translated packets back into the uIP stack.

Author
Nicolas Tsiftes nicol.nosp@m.as.t.nosp@m.sifte.nosp@m.s@ri.nosp@m..se

Definition in file nat64.h.