Network Control Initialization Procedure (NETCTRL)
4-19
Initialization and Configuration
4.3
Network Control Initialization Procedure (NETCTRL)
4.3.1
Synopsis
As previously mentioned, the configuration and initialization of the stack is per-
haps the most tedious part of its operation. For this reason, the stack library
includes code to perform system initialization based on a configuration
constructed by the programmer. This configuration can be manually built
through the configuration API, or can be built by the end user with a configura-
tion utility (not included in the stack).
The basic initialization the scheduling routines are performed by a network
control layer called NETCTRL. The source code to this layer is user service-
able. See the NDK User’s Guide and the NDK Porting Guide for more details.
4.3.2
Basics
The basic process of stack initialization is as follows:
1) Initialize the operating system environment with the initialization function
NC_SystemOpen(). This function must always be called first – before any
other TCP/IP stack related function.
2) Create a new configuration via CfgNew().
3) Build the new configuration via configuration API calls, or load a previous
configuration from non-volatile memory using CfgLoad().
4) Boot the stack with the configuration by calling NC_NetStart( hCfg,
pfnStart, pfnStop, pfnNetIP ) with a handle to the configuration, plus point-
ers to three user supplied callback functions for “start”, “stop”, and IP ad-
dress change operations. The NC_NetStart() function does not return until
the stack session has terminated. The configuration handle hCfg be-
comes the default configuration for the system.
5) After some preliminary initialization, the NC_NetStart() function creates a
new thread that calls the user supplied callback function for the “start” op-
eration. At this point, the callback function creates task threads for its net-
working requirements. This “start” function does not need to return imme-
diately, but should return at some point – i.e., the callback function should
not take permanent control of the calling thread. If system shutdown is initi-
ated before the “start” function returns, some resources may not be freed.