lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] DHCP Problem?


From: Jim Gibbons
Subject: Re: [lwip-users] DHCP Problem?
Date: Fri, 03 Sep 2004 15:11:31 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707

I don't know very much about your operating environment, so my comments may be inappropriate.  I'm assuming that you are using some kind of multi-tasking system.  If so, you may be calling sys_timeout in the wrong place.

sys_timeout places the function to be called in a list of timeouts.  In general there will be multiple lists of timeouts.  This is handled by sys_arch_timeouts in sys_arch.c.  I'm using uCosII, and in our sys_arch, there is one list per task.

The timeouts are actually called as a side-effect of calling the function to pend on an mbox or the function to wait on a semaphore.  See sys.c for details.  These functions also call sys_arch_timeouts to get a list of timeouts to be considered while waiting.

So, at least in my RTOS environment, if I call the initial sys_timeout from outside a task context (like my main function) or from the context of a task that never uses sys_sem_wait or sys_mbox_fetch, I'll never see a call to my timeout handler.

One way to handle this is to move the initial calls to sys_timeout into your tcpip_init_done. function.  tcpip_init_done gets called from the tcpip task context, after it is done with its initializations and before it pends on its mbox.  In my RTOS environment, that means that the timeout handlers will be placed in the list associated with the tcpip task, and that they will be called as a side effect of the tcpip task waiting on its mbox.

Again, this may all be irrelevant in your environment.  I don't even know if you are using an RTOS, and even if you are, I don't know how your sys_arch.c implements the timeout lists.  I hope this will be of some help, though.

xcb wrote:
lwip-users
	i use lwip 1.0.0 and want to use DHCP ,but not succfull.what is the problem?
my init code :
	struct netif  nif;
	struct ip_addr ipaddr, netmask, gw;
	sys_sem_t sem;
	err_t err;

//    lwip init......
	sem = sys_sem_new(0);
	tcpip_init(tcpip_init_done, &sem);
	sys_sem_wait(sem);
	sys_sem_free(sem);

	netif_init();
	
	sys_timeout(DHCP_FINE_TIMER_MSECS,
		(sys_timeout_handler)dhcp_fine_timer, NULL);
	sys_timeout((u32_t)DHCP_COARSE_TIMER_SECS * 1000,
		(sys_timeout_handler)dhcp_coarse_timer, NULL);

	IP4_ADDR(&gw, 0,0,0,0);
	IP4_ADDR(&ipaddr, 0,0,0,0);
	IP4_ADDR(&netmask, 255,255,255,255);

	netif_set_default(netif_add(&nif,&ipaddr, &netmask, &gw,NULL, ethernetif_init,
		tcpip_input));

	err = dhcp_start(&nif);   
	if(err!=ERR_OK)
	{
		printf("DHCP start failed\n");		
	}

{
void dhcp_fine_timer(void *arg)
{
	dhcp_fine_tmr();
	sys_timeout(DHCP_FINE_TIMER_MSECS, (sys_timeout_handler)dhcp_fine_timer, 
		NULL);
}

void dhcp_coarse_timer(void *arg)
{
	dhcp_coarse_tmr();
	sys_timeout((u32_t)DHCP_COARSE_TIMER_SECS * 1000,
		(sys_timeout_handler)dhcp_coarse_timer, NULL);
}
}



_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users
  

--
E-mail signature
Jim Gibbons
address@hidden
Gibbons and Associates, Inc.
TEL: (408) 984-1441
900 Lafayette, Suite 704, Santa Clara, CA
FAX: (408) 247-6395



reply via email to

[Prev in Thread] Current Thread [Next in Thread]