![Texas TMS320C6000 Programmer'S Reference Manual Download Page 133](http://html.mh-extra.com/html/texas/tms320c6000/tms320c6000_programmers-reference-manual_1093844133.webp)
Network Address Translation (NAT) Service
6-20
nat_service_example()
{
CI_SERVICE_NAT nat;
bzero( &nat, sizeof(nat) );
// Don’t start NAT until we resolve an IP address on its IF
nat.cisargs.Mode = CIS_FLG_IFIDXVALID |
CIS_FLG_RESOLVEIP | CIS_FLG_RESTARTIPTERM;
nat.cisargs.IfIdx = natIdx;
nat.cisargs.pCbSrv = &ServiceReport;
// Include all 192.168.x.x addresses in NAT group
nat.param.IPVirt = htonl(0xc0a80000);
nat.param.IPMask = htonl(0xffff0000);
CfgAddEntry( hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_NAT, 0,
sizeof(nat), (UINT8 *)&nat, 0 );
}
The above code is all that is required when using the configuration system to
invoke this service.
6.7.5
Invoking the Service via NETTOOLS API
In addition to the configuration option, this service can also be created and de-
stroyed directly through this NETTOOLS API. If an application wishes to by-
pass the configuration system and launch the service directly, these calls can
be used.
Enable the NAT Service
NATOpen
Syntax
HANDLE NATOpen( NTARGS *pNTA, NTPARAM_NAT *pNTP );
Parameter(s)
pNTA
Pointer to common argument structure used by all services
pNTP
Pointer to NAT parameter structure
Return Value
Returns a handle to the NAT instance (1), or NULL if the service could not be
created. This handle is used with NATClose() to disable the service when its
no longer needed.
Description
Enables the Network Address Translation Service. Although the function re-
turns a handle for compatibility with the standard NETTOOLS API, only one
instance of the NAT service is allowed.
This service utilizes the virtual and external network information using the con-
figuration system. If the configuration system was not used to create the net-
work records, this function will fail.
The NAT service executes on a specific public interface. Thus, it is compat-
ible with NT_MODE_IFIDX only.