Hi Sandra,
I e-mailed you directly as I don't like appearing on the lwIP mail list.
I'm the wrong person to ask as I use the socket API. The only place
where I use the lwIP functions is in the interface layer which binds the
Ethernet drivers to lwIP, hence the abstraction layer functions such as
ipReconfigure etc...
Probably worth posting the question though.
Cheers,
Adam.
On 05/06/2015 14:05, Sandra Gilge wrote:
Hallo,
thanks, I’m doing the dhcp_release and can see it in wireshark now.
Since I work with lwipv1.4.1 I use the netifapi functions. For dhcp
release I call netifapi_netif_common(netif, NULL, dhcp_release);
That leads to another questions:
Wouldn’t it make sense to have a define in netifapi.h for dhcp_release
as follows:
#define netifapi_dhcp_release(n) netifapi_netif_common(n, NULL,
dhcp_release)
Best regards,
Sandra
*Gesendet:* Freitag, 5. Juni 2015 11:07
*An:* Sandra Gilge
*Betreff:* Fwd: [lwip-users] DHCP usage
Hi,
I had issues with this too. This is what I did and it has worked with
out change from lwIP V1.3.2 to current:
typedef struct _NVDHCP
{
uint8_t pbyIpAddress[4];
uint8_t pbyAddressMask[4];
uint8_t pbyGatewayAddress[4];
uint8_t byEnableDHCP;
} NVDHCP,
*PNVDHCP;
/******************************************************************************
* Function Name: ipReconfigure
* Description : Function to re-configure the interface
* Arguments : IN pszInterface - The symbolic link name of the
interface
* IN pIpConfig - Pointer to the new configuration
* Return Value : 0 for success or -1 on error
******************************************************************************/
int32_t ipReconfigure(int8_t *pszInterface, PNVDHCP pIpConfig)
{
PRTEIP pEtherC = ipFindNetIf(&gpEtherC, pszInterface);
if (pEtherC)
{
if (pIpConfig->byEnableDHCP == 0U)
{
_Bool bfLinkUp = false;
pEtherC->ipConfig = *pIpConfig;
/* If DHCP was previously on */
if (pEtherC->ipConfig.byEnableDHCP)
{
/* Stop it */
tcpip_callback((void(*)(void*))dhcp_release,
&pEtherC->ipNetIf);
tcpip_callback((void(*)(void*))dhcp_stop,
&pEtherC->ipNetIf);
}
/* Set the fixed address */
memcpy(&pEtherC->ipNetIf.ip_addr.addr,
pEtherC->ipConfig.pbyIpAddress,
sizeof(struct ip_addr));
memcpy(&pEtherC->ipNetIf.netmask.addr,
pEtherC->ipConfig.pbyAddressMask,
sizeof(struct ip_addr));
memcpy(&pEtherC->ipNetIf.gw.addr,
pEtherC->ipConfig.pbyGatewayAddress,
sizeof(struct ip_addr));
/* Check the state of the link */
if ((control(pEtherC->iEtherC, CTL_GET_LINK_STATE,
&bfLinkUp) == 0U)
&& (bfLinkUp))
{
/* Tell lwIP that the data link is up */
tcpip_callback((void(*)(void*))netif_set_up,
&pEtherC->ipNetIf);
}
}
else
{
if (pEtherC->ipConfig.byEnableDHCP == 0U)
{
pEtherC->ipConfig = *pIpConfig;
/* Protect against concurrent access,
specifically in the ARP modules */
tcpip_callback((void(*)(void*))netif_set_link_down,
&pEtherC->ipNetIf);
/* Also have to do this one as well. Is it not obvious
that if the physical link has been set down that
the data link is down too? */
tcpip_callback((void(*)(void*))netif_set_down,
&pEtherC->ipNetIf);
/* Tell lwIP to start DHCP */
tcpip_callback((void(*)(void*))dhcp_start,
&pEtherC->ipNetIf);
}
else
{
pEtherC->ipConfig = *pIpConfig;
}
}
return 0;
}
return -1;
}
/******************************************************************************
End of function ipReconfigure
******************************************************************************/
The code comes from a system using an RTOS so the calls are made by
call-backs to the TCPIP task.
Good luck!
Adam.
-------- Forwarded Message --------
*Subject: ***
[lwip-users] DHCP usage
*Date: ***
Fri, 5 Jun 2015 10:37:00 +0200
*From: ***
Sandra Gilge <[email protected]> <mailto:[email protected]>
*Reply-To: ***
Mailing list for lwIP users <[email protected]>
<mailto:[email protected]>
*To: ***
[email protected] <mailto:[email protected]>
Hallo,
The IP configuration in our embedded system is reconfigurable by the
user during runtime.
The user can also switch on DHCP or switch it off and use a static IP
address.
What is the correct way to switch DHCP off. Do I have to call
netifapi_dhcp_stop(), when switching off DHCP?
I tried this, but I could not see a DHCP message on wireshark.
This is how it works right now:
Any configuration change:
netifapi_netif_set_down()
DHCP switched off:
netifapi_netif_set_addr()
netifapi_netif_set_up()
DHCP switched on:
netifapi_dhcp_start()
wait up to 7 secs for DHCP_BOUND
Best regards,
Sandra
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users