Service Calling Conventions
6-2
6.1
Service Calling Conventions
6.1.1
Specifying Network Services Using the Configuration
Although each service has it own specific API, it is usually more convenient to
add services by specifying the service in the system configuration as opposed
to calling their individual Open and Close API functions. Included the descrip-
tion of each network service is a description of its direct API as well as an exam-
ple of specifying the service in the system configuration.
6.1.1.1
Service Report Function
All the configuration examples in this section use a common service report call-
back function. The following is a very simple implementation of a service report
function that calls printf() to print service status.
Note that this function relies on the physical value of items in the configuration
specification found in the file: src\nettools\netcfg.h
static char *TaskName[]={”Telnet”,”HTTP”,”NAT”,”DHCPS”,”DHCPC”,”DNS”,”SNMP”};
static char *ReportStr[]={””,”Running”,”Updated”,”Complete”,”Fault”};
static char *StatusStr[]={”Disabled”,”Waiting”,”IPTerm”,”Failed”,”Enabled”};
static void ServiceReport( uint Item, uint Status, uint Report, HANDLE h )
{
printf( ”Service Status: %–9s: %–9s: %–9s: %03d\n”,
TaskName[Item–1], StatusStr[Status],
ReportStr[Report/256], Report&0xFF );
}
6.1.2
Invoking Network Services by NETTOOLS API
Each service API uses a common calling format. This allows the services to
be invoked by the configuration system using callback functions provided in
the Network Control software (which also performs system initialization). In
fact, it is preferable to launch services via the configuration system over manu-
ally calling each Open and Close function described in the following sections.
However, since the source to the Network Control software uses these calls,
they are documented here.
The common calling interface consists of a simple Open and Close concept.
The Open function initiates the service and returns a service handle, while the
Close function shuts down the service using the service handle returned from
the Open call.
Each service Open call takes at least one parameter. This parameter is a point-
er to a common argument structure called NTARGS. The specification of this
structure is as follows: