Chapter 4 - Description of NAT services
This chapter contains a description of all NetX Duo NAT API services (listed below) in alphabetical order.
| In the Return Values section in the following API descriptions, values in BOLD are not affected by the NX_DISABLE_ERROR_CHECKING define that is used to disable API error checking, while non-bold values are completely disabled. |
nx_nat_create
Create a NAT Server
Prototype
UINT nx_nat_create(
NX_NAT_DEVICE *nat_ptr,
NX_IP *ip_ptr,
UINT global_interface_index,
VOID *dynamic_cache_memory,
UINT dynamic_cache_size);
Input Parameters
-
nat_ptr: Pointer to NAT instance to create
-
ip_ptr Pointer: to IP instance
-
global_interface_index: Index to the global network interface
-
dynamic_cache_memory: Pointer memory area to NAT table
-
dynamic_cache_size: Size of memory area for NAT table
Return Values
-
NX_SUCCESS (0x00) NAT server successfully created
-
NX_PTR_ERROR (0x07) Invalid input pointer parameter
-
NX_NAT_PARAM_ERROR (0xD01) Invalid non pointer input
-
NX_NAT_CACHE_ERROR (0xD02) Invalid cache pointer input
Example
#define NX_NAT_ENTRY_CACHE_SIZE 20480
static UCHAR nat_cache[NX_NAT_ENTRY_CACHE_SIZE];
UINT global_interface_index = 0;
/* Create a NAT Server and cache with a global interface index. */
status = nx_nat_create(nat_ptr, ip_ptr, global_interface_index,
nat_cache, NX_NAT_ENTRY_CACHE_SIZE);
/* If status = NX_SUCCESS, the NAT instance was successfully
created. */
nx_nat_delete
nx_nat_enable
nx_nat_disable
nx_nat_cache_notify_set
Set a cache full notify callback function
Prototype
UINT nx_nat_cache_notify_set(
NX_NAT_DEVICE *nat_ptr,
VOID (*cache_full_notify_cb)(NX_NAT_DEVICE *nat_ptr)));
Description
This service registers the cache full callback with the input function pointer cache_full_notify_cb which points to a user defined cache full notify function.
Input Parameters
-
nat_ptr: Pointer to NAT instance
-
cache_full_notify_cb: Pointer to cache full notify function
nx_nat_inbound_entry_create
Create an inbound entry in the NAT translation table
Prototype
UINT nx_nat_inbound_entry_create(
NX_NAT_DEVICE *nat_ptr,
NX_NAT_TRANSLATION_ENTRY *entry_ptr
ULONG local_ip_address,
USHORT external_port,
USHORT local_port,
UCHAR protocol);
Description
This service creates an inbound entry as static (permanent entry, never expires) and adds it to the NAT translation table. These entries are usually created for local host servers where a connection is initiated from a host on the outside network. The NAT server checks that the external port is not already in use in the translation table or bound by a previously existing NetX Duo socket of the same protocol.
Input Parameters
-
nat_ptr: Pointer to NAT instance
-
entry_ptr: Pointer to translation entry
-
local_ip_address: Local host IP address
-
external_port: Destination port on the external network
-
local_port: Source (local host) port
-
protocol: Packet protocol (e.g TCP)
nx_nat_inbound_entry_delete
Delete an inbound entry in the NAT translation table
Prototype
UINT nx_nat_inbound_entry_delete(
NX_NAT_DEVICE *nat_ptr,
NX_NAT_TRANSLATION_ENTRY *delete_entry_ptr)
Input Parameters
-
nat_ptr: Pointer to NAT instance
-
delete_entry_ptr: Pointer to the NAT translation entry