User`s guide

KwikNet Low Level Services
K
A
DAK
135
4.5 KwikNet Network Interface Services
Introduction to Network Interfaces
Most embedded systems include one or two network interfaces to connect the system to
external networks. For such systems, the simplest approach to incorporating the interface
into your application is to use the KwikNet Configuration Builder to add the network
interface to your KwikNet Library. KwikNet will then automatically add the network
interface to its list of available networks and initialize the interface as soon as KwikNet is
started. Each of these prebuilt networks is opened and made ready for use by your
application.
In some cases, there may be a need for the application to control the interface startup
process. To meet this requirement, KwikNet provides a collection of network interface
management services which you can use to dynamically add, open and close networks at
runtime. These services also allow you to control the operation of your prebuilt
networks. By dynamically adding your network interface, you can also configure it to
make use of advanced features offered by the Turbo Treck TCP/IP Stack but not
automatically available with KwikNet's prebuilt networks. All KwikNet network interface
management services are documented in Chapter 4.6.
To add an Ethernet, SLIP or PPP network interface, you must call KwikNet procedure
kn_ifadd(), identifying the interface device driver. The device driver definition
provides the same set of parameters used to define prebuilt networks using the KwikNet
Configuration Builder. Once added, the interface remains in place until KwikNet is shut
down, if ever. Note that a Treck network interface cannot be removed.
If a SLIP or PPP network interface requires modem support, you must call procedure
kn_ifmodem() to attach the KwikNet Modem Driver to the interface and specify its
operating characteristics.
If you require notification whenever the network interface is opened, you must call
procedure kn_ifnethook() to install a pointer to your network startup hook function.
Your function must operate as described in Appendix A.1 of the KwikNet Device Driver
Technical Reference Manual.
Once a network interface has been added, you can call Treck functions to customize the
interface option settings if necessary to meet your particular operating requirements.
The network interface is opened with a call to kn_ifopen(). When you open the
interface, you must provide its network parameters such as the local IP address, subnet
mask and default gateway IP address. These parameters match those used to define
prebuilt networks using the
KwikNet Configuration Builder. When an Ethernet network is
opened, KwikNet will automatically start DHCP, BOOTP or Auto IP negotiation to
acquire a network IP address if the interface has been so configured. When a PPP
network is opened,
KwikNet will automatically negotiate the PPP connection according to
the requirements specified by you when you opened the interface.
The network interface is closed with a call to
kn_ifclose(). Once closed, the device
driver and modem driver are detached from the network interface. The interface remains
closed until you next request that it be opened.