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

DHCP
[User Protocols]

Dynamic host configuration protocol. More...

Data Structures

struct  DYNCFG

Functions

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

int NutDhcpDiscover (UDPSOCKET *sock, u_long daddr, u_short dport, struct bootp *bp, DYNCFG *cfgp)
 Broadcast a DHCP discover telegram.

int NutDhcpRequest (UDPSOCKET *sock, u_long daddr, u_short dport, struct bootp *bp, DYNCFG *cfgp)
int NutDhcpRelease (UDPSOCKET *sock, u_long daddr, u_short dport, struct bootp *bp, DYNCFG *cfgp)
 NutDhcpClient (void *arg)
 DHCP client thread.

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

int NutNetAutoConfig (CONST char *name)
 Automatically configure a network interface.


Detailed Description

Dynamic host configuration protocol.


Function Documentation

int NutDhcpDiscover UDPSOCKET   sock,
u_long    daddr,
u_short    dport,
struct bootp   bp,
DYNCFG *    cfgp
 

Broadcast a DHCP discover telegram.

Parameters:
sock Socket descriptor. This pointer must have been retrieved by calling NutUdpCreateSocket().
daddr Destination IP address, typically INADDR_BROADCAST.
dport Destination port, typically 67.
bp Pointer to a buffer to be used for transmission. No specific initialization required.
cfgp Pointer to an initialized DYNCFG structure.
Returns:
0 on success, -1 if send failed.

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 wiill 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.
Returns:
0 on success or -1, if no IP configuration could have been received within the specified timeout.

Bug:
The client doesn't send update information to the server. To avoid loosing the assignment while Ethernut is down, addresses can be fixed in the DHCP server tables.
Examples:
httpd/httpserv.c.

int NutDhcpParse DYNCFG *    cfgp,
struct bootp   bp,
int    len
 

Parse a DHCP reply telegram.

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

int NutDhcpRelease UDPSOCKET   sock,
u_long    daddr,
u_short    dport,
struct bootp   bp,
DYNCFG *    cfgp
 

Release our ip address.

int NutDhcpRequest UDPSOCKET   sock,
u_long    daddr,
u_short    dport,
struct bootp   bp,
DYNCFG *    cfgp
 

Broadcast the offered settings.

Parameters:
sock Socket descriptor. This pointer must have been retrieved by calling NutUdpCreateSocket().
daddr Destination IP address, typically INADDR_BROADCAST.
dport Destination port, typically 67.
bp Pointer to a buffer to be used for transmission.
cfgp Pointer to an initialized DYNCFG structure.
Returns:
0 on success, -1 if send failed.

int NutNetAutoConfig CONST char *    name
 

Automatically configure a network interface.

This function is deprecated. New applications should call NutDhcpIfConfig().

Parameters:
name Name of the device.
Returns:
0 on success, -1 otherwise.


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