lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Behavior of netif_set_link_down


From: Richner Simon
Subject: Re: [lwip-users] Behavior of netif_set_link_down
Date: Wed, 1 May 2013 12:43:06 +0200

Well, I guess this solved my first problem: 

So when I try to send the next packet, my driver will have to return something 
like "ERR_CONN" which tells the application it has to stop sending.

My new problem is: 

I noticed, that when I use dhcp to get an IP-Address and then change the 
subnet, dhcp fails to get me an IP in that new subnet.
I figured the reason for this is, that any udp packet with local IP set to 
0.0.0.0 use the outgoing network interface IP as source (which is part of the 
old subnet). So in a new subnet, we need to use 0.0.0.0 as source IP again 
(like on initialization).

=> So would it be a good idea to call <netif_set_addr(&myNetif, &ip_zero, 
&ip_zero, &ip_zero)> when I find my link is down, or is there a better approach?


@ Marshall: I think you got me wrong. My probem was not how to find out if the 
link was up or down, but was (and still confuses me) that <netif_set_link_down> 
has no influnce on the LwIP core what so ever, it just sets a flag in the netif 
that is never checked by anyone! So why call this function unless you use the 
flag in your own code?


Regards
Simon


-----Ursprüngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im Auftrag von Nikolas Karakotas
Gesendet: Mittwoch, 1. Mai 2013 12:12
An: Mailing list for lwIP users
Betreff: Re: [lwip-users] Behavior of netif_set_link_down

Hi,

For example the lpc1769 has a producer and a consumer index. If there is a free 
buffer available then the data will be copied to the register else it will wait 
until a buffer is available.
You can return and ERR_OK when data has been copied or some other error if not, 
or timeout.

Nick

-----Original Message-----
From: Richner Simon
Sent: Wednesday, May 01, 2013 7:31 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Behavior of netif_set_link_down

Thanks for your help guys

@ Marshall: Yes, you can check "NETIF_FLAG_LINK_UP", but this won't stop LwIP 
from sending, as <ip_route> checks "NETIF_FLAG_UP". So you must have a second 
mechanisme for this like Nikolas suggests...

@ Nikolas: So if I get you right, you would not activly stop the application 
from sending, but just return "ERR_CONN" in my driver send routine if the 
connection was down?

Regards
Simon


-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Im Auftrag von Marshall Brown
Gesendet: Mittwoch, 1. Mai 2013 11:12
An: Mailing list for lwIP users
Betreff: Re: [lwip-users] Behavior of netif_set_link_down

Here's how I do mine

/* Call the PHY status update state machine once in a while
       to keep the link status up-to-date */
    if (lpc_phy_sts_sm(netif_eth0) != 0) {
    /* Set the state of the LED to on if the ethernet link is
       active or off is disconnected. */
    if (netif_eth0->flags & NETIF_FLAG_LINK_UP){
    rtu_led_RequestLEDColour(LED_ALARM_PRIORITY_8, ALARM_CLEAR); //request a 
low level alarm for ethernet not connected we should be able to run without it
    }
    else{
    rtu_led_RequestLEDColour(LED_ALARM_PRIORITY_8, ALARM_SET); //request a low 
level alarm for ethernet not connected we should be able to run without it
    }
    }


Courtesy of the internet somewhere

Regards
Marshall

-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of Nikolas Karakotas
Sent: Wednesday, 1 May 2013 9:02 p.m.
To: Mailing list for lwIP users
Subject: Re: [lwip-users] Behavior of netif_set_link_down

I believe it has to do with your ethernet driver and how it is implemented.
Even if you send data to your hardware you should control this with a 
incrementer for example just like a round robin.

Regards,
Nick

-----Original Message-----
From: Richner Simon
Sent: Wednesday, May 01, 2013 6:18 PM
To: Mailing list for lwIP users
Subject: [lwip-users] Behavior of netif_set_link_down

Hi,

In my driver I call <netif_set_link_up> and <netif_set_link_down> when I detect 
that a cable was connected to / removed from my device. However, I noticed, 
that only setting the link up triggers <dhcp_network_changed> and not setting 
link down. So when a cable gets removed, the NETIF_FLAG_UP stays true.

In my application, I send some data periodically to a predefined IP.
When now the cable gets disconnected, the application doesn't get informed 
about this, neighter gets the netif set down. So my application continues to 
spam my hardware and sooner or later I get a buffer overflow on my hardware!

=> What is calling <netif_set_link_down> good for, when it doesn't bring the 
interface down?

=> What would be the best way to tell my application to stop streaming?



Best Regards
Simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]