[En-Nut-Discussion] DHCP and four Ethernuts, IP conflict

Mgr. Pavel Chromy chromy at asix.cz
Wed Apr 30 11:31:47 CEST 2003


Wednesday, April 30, 2003, 11:13:23 AM Lars wrote:

> If I understand it correctly the xid variable will be assigned the value equal to the address where the nif struct is pointing to. In case I liked to generate some random value for xid, is this the
> place where this should be done?

That's right.
But it is not that easy to obtain a real random value, pseudorandom
common pseudorandom generator is not good for this task, especially
when several devices are powered from single power suply, in this case
taking system timer as initialization value for random generator may
also fail. Good solution is to use some kind of hash from mac address
or from combination of mac address and system timer.

Another aproach is to enable NutOS to receive unicast UDP datagrams
when IP is unconfigured, which would enable using unicast DHCP
(Linux dhcpd is using this by default).
This could be done in NutIpInpuit() in ipin.c
by changing this:
        /*
         * Silently discard datagrams for other destinations.
         * However, if we haven't got an IP address yet, we
         * allow ICMP datagrams to support dynamic IP ARP method.
         */
        if (dst == 0 || dst != nif->if_local_ip) {
to:
        if (dst == 0 || (dst!=nif->if_local_ip &&
            (nif->if_local_ip || ip->ip_p!=IPPROTO_UDP || bcast))) {


Mgr. Pavel Chromy
ASIX s.r.o.
Staropramenna 4
150 00 Praha 5




More information about the En-Nut-Discussion mailing list