cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP set link down - why it is required?

kurta999
Senior

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.

1 ACCEPTED SOLUTION

Accepted Solutions
alister
Lead

> 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.

View solution in original post

4 REPLIES 4
alister
Lead

> 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.

Piranha
Chief II

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!

kurta999
Senior

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.)

Piranha
Chief II

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. :)