Hi
What’s the best way to shutdown a network connection for when say an embedded device is shutting down or going to reboot?
I have the following code I call when I am going to kick off a reboot:
LOG_DEBUG("Network Manager: Ethernet is going down%s",
networkManager->rebootInProgress ?
"..." :
" for reconfiguration...");
netifapi_dhcp_release_and_stop(&networkManager->networkInterfaceContext);
netifapi_netif_set_link_down(&networkManager->networkInterfaceContext);
netifapi_netif_set_down(&networkManager->networkInterfaceContext);
networkManager->ethernetLinkUp
= false;
if (networkManager->rebootInProgress)
{
netifapi_netif_remove(&networkManager->networkInterfaceContext);
}
The trouble is that the link seems to come back up again as soon as it goes down and my state machine starts doing stuff like kicking off a new DHCP request etc, right about the time the hardware reboots.
I added in the call to
netifapi_netif_remove()
quite recently but it doesn’t seem to make any difference.
I could put some more code in my link status state machine for an impending reboot, but this seems more complicated than it probably needs to be, as I’m probably not doing something I should be.
Gary Metalle
Senior Embedded Software Engineer