![Texas TMS320C6000 Programmer'S Reference Manual Download Page 209](http://html.mh-extra.com/html/texas/tms320c6000/tms320c6000_programmers-reference-manual_1093844209.webp)
NAT Port Mapping
B-16
B.2 NAT Port Mapping
B.2.1 Synopsis
NAT port mapping allows a client machine on the LAN (or home network) to
appear on a specific port of the router’s public WAN IP address. This API (and
NAT in general) is only used when the TCP/IP stack is acting as an IP router,
and when one the IP network on one side of the router is using virtual IP ad-
dresses.
The functions described in this section illustrates how to install and remove
port mappings. The functional operation of NAT and NAT Port Mapping is dis-
cussed in more detail in section B.2.3.
B.2.2 Function Overview
The following functions are used to create and destroy port mappings:
NatNew() – Create a new NAT entry (for port mapping)
NatFree() – Free a NAT entry
NatGetPNI() – Get a pointer to a NAT entry’s NATINFO structure
B.2.3 NAT Entry Information Structure
A port mapping is in actuality just a NAT entry. Each NAT entry has its own infor-
mation structure. This NATINFO structure allows the programmer to examine
the status of a particular entry.
The specification of the NATINFO structure is as follows:
typedef struct _natinfo {
uint TcpState; // Current TCP State (Simplified)
#define NI_TCP_CLOSED 0 // Closed or closing
#define NI_TCP_SYNSENT 1 // Connecting
#define NI_TCP_ESTAB 2 // Established
IPN IPLocal; // Translated IP Address
UINT16 PortLocal; // Translated TCP/UDP Port
IPN IPForeign; // IP Adress of Foreign Peer
UINT16 PortForeign; // Port of Foreign Peer
UINT8 Protocol; // IP Potocol
UINT16 PortMapped; // Locally Mapped TCP/UDP Port (router)
HANDLE hProxyEntry; // Handle to Proxy Entry (if any)
UINT32 Timeout; // Expiration time in SECONDS
void *pUserData; // Pointer to proxy callback data
} NATINFO;
The individual fields are defined as follows:
-
uint TcpState;
This is a condensed version of the state of the TCP connection that is be-
ing translated by this entry. This field is only valid when the Protocol field is
set to IPPROTO_TCP. The defined values are: