The DHCP layer of the Modtronix TCP/IP stack is implemented by the file "dhcp.c". The header file "dhcp.h" defines the services provided by the layer. DHCP is an active layer that broadcasts DHCP requests and automatically receives and decodes DHCP responses. Its main features include:
The DHCP module is implemented as a cooperative task, performing automatic operations without the knowledge of the main application. The actual DHCP integration and control is done by the Stack Manager; it handles all required operations as part of its standard task, using the DHCP APIs to control the moduleÆs behavior. The user does not need to know about DHCP in order to use it.
- Configuration of the IP and gateway addresses and subnet mask
- Automatic DHCP lease time and lease renewal management
- Fully automatic operation without user application intervention
A user application may also choose to call some of the APIs to directly control DHCP operation, such as whether DHCP is configured or not, and whether to permanently stop DHCP. Normally, the user's application should not need to directly interact with DHCP at all. To use the DHCP module, the user project files must be modified as follows:
When DHCP is implemented, the user application must not attempt network communications until DHCP is configured properly. Normally, if a user application contains one or more client applications that require communications on power-up or RESET, the application must check that DHCP is configured before transmitting any data using the lower layer modules. This can be done with the function DHCPIsBound()
- Uncomment STACK_USE_DHCP in the header file "StackTsk.h".
- Include the "dhcp.c" and "udp.c" files in the project.
- Increase MAX_UDP_SOCKETS by one (at least one UDP socket must be available for DCHP; adjust the numbers of sockets based on UDP and DCHP needs).
The official DHCP specification (RFC1541) requires the DHCP client to renew its IP configuration before its lease time expires. To track lease time, the user application must make sure that TickUpdate() is called as required, and that reasonable time accuracy is maintained (refer to the source code file "websrvr.c" for a working example). The time resolution required is 15 minutes, plus or minus, which means that TickUpdate() may be called at a very low priority.
For the DHCP module to automatically configure the addresses and subnet mask, there must be at least one DHCP server on the network. It is the userÆs responsibility to implement some method for "publishing" the configurations back to potential users. Options range from manually reading the information from a display on each node, to storing the information in a central server. DHCP updates the values of MY_IP_BYTE?, MY_GATE_BYTE? and MY_MASK_BYTE? as a result of automatic configuration.
For details on configuring this module, see Configuration section of dhcp.h file.
| ||DHCP client Module for Modtronix TCP/IP Stack. |
Generated on Mon Oct 9 13:22:09 2006 for SBC65EC Web Server by