Contiki-NG
Loading...
Searching...
No Matches
nat64-tcp.c File Reference

NAT64 TCP splice proxy. More...

#include "nat64-tcp.h"
#include "nat64.h"
#include "nat64-platform.h"
#include "ipv6/ip64-addr.h"
#include "net/ipv6/tcpip.h"
#include "lib/sha-256.h"
#include <string.h>
#include <sys/time.h>
#include "sys/log.h"

Go to the source code of this file.

Functions

static void nat64_tcp_send_pending (struct tcp_seqstate *ts)
 Inject the next paced chunk from a session's receive buffer.
 
static void nat64_tcp_ack_confirmed (struct tcp_seqstate *ts)
 Promote the in-flight segment to acknowledged and queue what's next.
 
static void inject_tcp (const struct nat64_session *s, struct tcp_seqstate *ts, uint8_t flags, const uint8_t *payload, uint16_t payload_len)
 Fabricate and inject an IPv6+TCP segment toward the IoT node.
 
int nat64_tcp_output (const uint8_t *pkt, uint16_t len)
 Process an outgoing IPv6+TCP packet from an IoT node.
 
void nat64_tcp_flush_acks (void)
 Flush deferred TCP ACKs.
 
void nat64_tcp_init (void)
 Initialize the TCP splice proxy.
 
void nat64_tcp_set_isn_secret (const uint8_t key[16])
 Set the 128-bit secret key for TCP ISN generation.
 
bool nat64_tcp_has_pending_data (const struct nat64_session *s)
 Check whether a session has buffered data awaiting delivery.
 
bool nat64_tcp_peer_fin_received (const struct nat64_session *s)
 Check whether the IoT node has already half-closed the session.
 
void nat64_tcp_free_seqstate (const struct nat64_session *s)
 Free any TCP sequence state associated with a session.
 
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_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.
 

Detailed Description

NAT64 TCP splice proxy.

Implements per-session sequence-number state, RFC 6528 ISN generation, fabrication of IPv6/TCP segments back to the IoT node, ACK-paced delivery of server data and half-close handling. See nat64-tcp.h for the public API and os/services/nat64/README.md for the high-level design rationale.

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

Definition in file nat64-tcp.c.