DHCP renewal in uIP

deeaitch wrote on Wednesday, February 25, 2009:

Hello

I have now successfully implemented the uIP DHCP application (files dhcpc.c and dhcpc.h) in the uIP package. The router gives an IP address when my MCB2360 development board in attached. Everything is great.

But, has anyone solved the issue with IP renewal? I.e. when the ethernet cable is disconnected for a while and then re-connected.

I debuggded the source file to see if the code enters the related functions when an IP is received. But it newer does.

So, do anyone have an idea of how to make the application to start send "DHCP discover" packages to the router again after ethernet cable removal?

/Dee

davedoors wrote on Wednesday, February 25, 2009:

I would recommend asking your question on the uIP support mailing list. They are usually very helpful.

incrediball wrote on Monday, March 02, 2009:

I can’t agree. Getting on to the mailing list in the first place was a major pain and compared to forums such as this, it all seemed a bit strange. However when I finally was able to send what I wanted to send, I just got my email back with some spam rating plus another one in Chinese, which apparently says that they have received my mail.

Why Chinese? I thought uIP came from Sweden…?

spreetsingh wrote on Tuesday, March 10, 2009:

I am trying to add code to get the  IP address for my 236x board which is running uIP stack. Can you share your DHCP code?
Thanks,

incrediball wrote on Tuesday, March 17, 2009:

I am now also using the dhcp client in uIP. Did you have problems with the handle_dhcp protothread calling send_discover() at high speed in an endless loop? I found that adding a PT_YIELD(&s.pt) after send_discover() and after send_request() allowed the caller to actually send the packet so that the uip_newdata() in the following PT_WAIT_UNTIL statement actually had some meaning.

Anyway, regarding address renewal:

1. Is it necessary to renew the address if the cable has been disconnected? A lease for the address is granted and so is not the address "ours" until the end of the lease regardless of whether the cable is disconnected or not?

2. Otherwise we only need to handle the lease expiry, which sadly was not implemented. Perhaps it is sufficient to simply replace the:

while(1) {
    PT_YIELD(&s.pt);
}

with:

timer_set (&s.timer, ntohs(s->lease_time[0])*65536ul + ntohs(s->lease_time[1]));
PT_WAIT_UNTIL(&s.pt, timer_expired(&s.timer));

The following PT_END should then restart the DHCP thread. Does anyone know if this is adequate? I don’t really want to have to wait a week for my IP address to expire, only to find it hasn’t worked…

Sorry, I know talking about DHCP on here is called hijacking but the uIP mailing list is a bit of a joke in my opinion…

incrediball wrote on Wednesday, March 18, 2009:

I made some mistakes, I meant:

timer_start (&s.timer, (ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1])) * CLOCK_SECOND);

spreetsingh wrote on Thursday, March 19, 2009:

I have the demo code working on the MCB 2360 with fixed IP address. Can someone guide me in writing the code for getting the IP address from the DHCP server on MCB 2360 board instaed of setting a fixed IP address.

Thanks