|
From: | Bram Peeters |
Subject: | [lwip-users] DHCP usage with latest git code version |
Date: | Thu, 10 Sep 2015 11:01:37 +0000 |
Hi,
What is the recommended sequence to start DHCP with the latest git sources (anno 20150910) ? In the past dhcp_start() would automatically bring up the interface, and there is still a lot of references floating around to that way of working. Eg in netif.c /** * Bring an interface up, available for processing * traffic. *
* @note: Enabling DHCP on a down interface will make it come * up once configured. *
* @see dhcp_start() */
void netif_set_up(struct netif *netif) { if (!(netif->flags & NETIF_FLAG_UP)) { netif->flags |= NETIF_FLAG_UP; So that note is wrong now because dhcp_start has an error on a down interface: err_t dhcp_start(struct netif *netif) { struct dhcp *dhcp; err_t result; LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;); LWIP_ERROR("netif is not up, old style port?", netif_is_up(netif), return ERR_ARG;);
I have some stm cubemx generated code that says the following: void LWIP_Init(void) { tcpip_init( NULL, NULL );
ipaddr.addr = 0; netmask.addr = 0; gw.addr = 0;
/* add the network interface */ netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input); /* Registers the default network interface */ netif_set_default(&gnetif); if (netif_is_link_up(&gnetif)) { /* When the netif is fully configured this function must be called */ netif_set_up(&gnetif); } else { /* When the netif link is down this function must be called */
netif_set_down(&gnetif); }
dhcp_start(&gnetif); ... } But this appears incorrect (netif_is_link_up checks a flag that is set by netif_set_up, does not seem to make any sense at all in a chicken vs egg kind of way ??). I tried the following in my polling loop which checks the phy for the link status: if ( regvalue
& PHY_C1R_LINK_STATUS ) /* Link detected */ But that still triggers the
LWIP_ERROR("netif is not up, old style port?", netif_is_up(netif), return ERR_ARG;); in dhcp_start.
Suggestions are welcome ... |
[Prev in Thread] | Current Thread | [Next in Thread] |