Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


DHCP renewal in uIP

Posted by DeeAitch on February 25, 2009

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?


RE: DHCP renewal in uIP

Posted by Dave on February 25, 2009
I would recommend asking your question on the uIP support mailing list. They are usually very helpful.

RE: DHCP renewal in uIP

Posted by incrediball on March 2, 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...?

RE: DHCP renewal in uIP

Posted by spreet on 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?

RE: DHCP renewal in uIP

Posted by incrediball on 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) {


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...

RE: DHCP renewal in uIP

Posted by incrediball on 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);

RE: DHCP renewal in uIP

Posted by spreet on 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.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner