Skip to main content
Visitor II
May 22, 2020
Solved

LwIP set link down - why it is required?

  • May 22, 2020
  • 4 replies
  • 1523 views

Hi,

Why it is required (or recommended, as I see in examples) to set the link down when the cable is plugged out from the ethernet connector? It works when I once set the link up and leave it up forever. It doesn't matter when I plug out and in the cable, it continues to work afterwards without any problem.

    This topic has been closed for replies.
    Best answer by alister

    > It doesn't matter when I plug out and in the cable

    Link up/down handling is optional.

    Change of peer or network may be important.

    Restarting DHCP client or server?

    IPv6 discover?

    Re-subscribing or re-advertising services?

    See also https://lwip.fandom.com/wiki/DHCP.

    4 replies

    alisterAnswer
    Explorer
    May 23, 2020

    > It doesn't matter when I plug out and in the cable

    Link up/down handling is optional.

    Change of peer or network may be important.

    Restarting DHCP client or server?

    IPv6 discover?

    Re-subscribing or re-advertising services?

    See also https://lwip.fandom.com/wiki/DHCP.

    Graduate II
    May 30, 2020

    You are a developer and you have the source code. Look at it!

    http://git.savannah.nongnu.org/cgit/lwip.git/tree/src/core/netif.c#n1013

    You don't even have to understand it deeply. The function names already answer your question pretty clearly!

    kurta999Author
    Visitor II
    May 30, 2020

    I looked but it didn't helped. I was qurious WHY this callback exists, but the first answer was helpful like re-starting DHCP. (in case if I plug in another cable not the one that I plugged out.)

    Graduate II
    May 30, 2020

    Yes, discovery is one reason. Also, as you can see from function names, AutoIP needs it. And in real projects one will often want to report link status to application code for LED/GUI indication and/or logging purposes. :)