Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

DHCP
[User Protocols]


Detailed Description

Dynamic host configuration protocol.


Data Structures

struct  dyn_cfg

Defines

#define MIN_DHCP_MSGSIZE
#define MAX_DHCP_MSGSIZE
#define MAX_DHCP_WAIT
#define MAX_OFFERS
#define MAX_DCHP_RETRIES
#define DHCPST_SELECTING
#define DHCPST_REQUESTING
#define DHCPST_REBOOTING
#define DHCPST_BOUND
#define DHCPST_RENEWING
#define DHCPST_REBINDING
#define DHCPST_ERROR
#define DHCPST_RELEASING

Typedefs

typedef dyn_cfg DYNCFG

Functions

int ParseReply (DYNCFG *cfgp, u_long ip, struct bootp *bp, int len)
 Parse a DHCP reply telegram.

 NutDhcpClient (void *arg)
 DHCP client thread.

int NutDhcpIfConfig (CONST char *name, u_char *mac, u_long timeout)
 Automatically configure an Ethernet network interface.

int NutDhcpRelease (CONST char *name, u_long timeout)
 Relinguish our DHCP lease.


Function Documentation

NutDhcpClient void *  arg  ) 
 

DHCP client thread.

This thread implements a DHCP state machine.

Bug:
We are not able to shutdown our interface, which may cause problems if out original DHCP server dies.

int NutDhcpIfConfig CONST char *  name,
u_char mac,
u_long  timeout
 

Automatically configure an Ethernet network interface.

If no MAC address is specified, this routine will try to read a previously stored configuration from the EEPROM. If this retrieves a valid IP configuration, then the network interface will be immediately configured with these values by calling NutNetIfConfig(). If no valid IP configuration has been read, then this routine will start the DHCP client thread and wait upto a given number of milliseconds for a response from a DHCP server.

If a MAC address has been specified, this routine will not read the EEPROM configuration. If the application has set the global CONFNET structure to a valid IP configuration before calling this function, then the network interface will be immediately configured with these values by calling NutNetIfConfig(). Otherwise the DHCP client thread will be started and this routine will wait upto a given number of milliseconds for a response from a DHCP server.

Parameters:
name Name of the registered Ethernet device.
mac MAC address of the destination. Set null to use the configuration stored in the EEPROM.
timeout Maximum number of milliseconds to wait. To disable timeout, set this parameter to NUT_WAIT_INFINITE. This value must be larger than 3 times of MAX_DHCP_WAIT to enable collection of offers from multiple servers.
Returns:
0 on success or -1, if no IP configuration could have been received within the specified timeout.

int NutDhcpRelease CONST char *  name,
u_long  timeout
 

Relinguish our DHCP lease.

This function will be called by the application if we are moving to another network. It helps the DHCP server to tidy up his allocation table, but is not a required DHCP function.

Upon return, the system should be shut down within 20 seconds.

Parameters:
name Name of the registered Ethernet device, currently ignored.
timeout Maximum number of milliseconds to wait, minimum is 11000.
Returns:
0 on success or -1, if DHCP is not in bound state.

int ParseReply DYNCFG *  cfgp,
u_long  ip,
struct bootp bp,
int  len
 

Parse a DHCP reply telegram.

Parameters:
cfgp Pointer to config structure.
ip DHCP server IP address.
bp Pointer to the reply telegram.
len Number of valid bytes in the reply telegram.
Returns:
0 on success, -1 otherwise.


© 2000-2003 by egnite Software GmbH - visit http://www.ethernut.de/