[En-Nut-Discussion] DHCP client and losing UDP packets
Harald Kipp
harald.kipp at egnite.de
Fri Apr 16 09:54:14 CEST 2004
Michel,
There are many problems with changing the MAC:
1. The ARP table on other systems needs to be updated
2. Some switches get problems
3. The mechanism with Ethernut, empty EEPROMs and
temporarily unavailable DHCP is a bit complicated.
There may be others.
How did you change Ethernut's MAC address? Calling NutDhcpIfConfig()
with MAC address is not the intended way.
You should call NutDhcpIfConfig("eth0", 0, 60000) first, if you
want to use DHCP. This will fail, if DHCP is not available _and_
the EEPROM is empty. If the EEPROM is empty, the application
needs to supply a MAC address and try again, calling
NutDhcpIfConfig("eth0", mac, 60000). Again, if this fails, you
are sure, that you are running without EEPROM and without
DHCP. Last thing you can do is calling
NutNetIfConfig("eth0", mac, ip_addr, ip_mask)
However, after this call DHCP will be disabled in further boots.
If you call NutDhcpIfConfig("eth0", 0, 60000), Ethernut will
use the IP address you specified in NutNetIfConfig().
This mechanism serves all states of EEPROM and DHCP availability.
Internally the EEPROM stores two IP addresses, a soft and a hard
one. The soft IP is the one, that had been received from last
DHCP query and will be re-used in case DHCP is not available.
If the hard IP is set to something different than zero, this
hard IP will be used and DHCP will not be queried.
Almost all samples use this general method, because it works in
all environments without a preconfigured EEPROM. Real applications
will usually provide some special routines to let the user
configure the EEPROM. They do never start with empty EEPROMs.
Harald
More information about the En-Nut-Discussion
mailing list