NAT Port Mapping
B-18
-
void * pUserData;
This field is reserved for use by proxy filter callback functions. It is not used
by the system software.
The NAT information structure of little importance when only port mapping is
required. Its real function is for use in NAT proxy filters.
B.2.4 NAT API Functions
Create a NAT Entry (for Port Mapping)
NatNew
Syntax
HANDLE NatNew( IPN IPLocal, UINT16 PortLocal,
IPN IPForeign, UINT16 PortForeign,
UINT8 Protocol, UINT16 PortMapped,
UINT32 Timeout );
Parameter(s)
IPLocal
IP address (in network format) of host on the LAN to map
PortLocal
TCP/UDP port value of host on the LAN to map
IPForeign
IP address of WAN peer (usually NULL/wild for port
mappings)
PortForeign
TCP/UDP port of WAN peer (usually NULL/wild)
Protocol
IP protocol (IPPROTO_TCP or IPPROTO_UDP)
PortMapped
Port on router’s public WAN to map (usually a “well-known”
port)
Timeout
Timeout of entry in seconds (NULL for STATIC)
Return Value
Handle to NAT entry, or NULL on error.
Description
This function creates a NAT entry with the parameters as specified.
For example, to allow a host on a virtual IP address of 1.2.3.4 to run a Telnet
server reachable via the router’s public (physical) IP address, a mapping
would be installed to map TCP port 23 (telnet) to 1.2.3.4:23. If the connection
were to be open to all foreign hosts, then IPForeign and PortForeign would be
left NULL. The value of Timeout would also be NULL to make the entry STAT-
IC
…
hNatTelnet = NatNew( htonl(0x01020304), 23, 0, 0, IPPROTO_TCP, 23, 0 );
The function returns a handle to the NAT entry created. This handle should be
freed with NatFree() when the mapping is no longer desired.