lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] LwIP PCBs reset


From: Amena El Homsi
Subject: Re: [lwip-users] LwIP PCBs reset
Date: Mon, 13 Jan 2020 10:27:22 +0200

Hi, thanks for your reply, please check my answers below.

On Thu, Jan 9, 2020 at 6:35 PM goldsimon <address@hidden> wrote:


Amena El Homsi wrote:
>Hello,
>
>After disconnecting from an AP I have to reset the PCBs pools. If I did
>not
>do that and I reconnect to the AP and If I tried to bind a socket to a
>port
>that I already used in the previous connection, binding fails (port in
>use).

That should not be required. Why don't you just close all connections instead of such a hack? You might have SO_REUSE or something like that...

 Sometimes the AP disassociates the STA, it doesn't make sense to go over the connections and reset them (it is useless to send tcp fin segment or dhcp release packet).
That's why we need a way to reset everything in lwip. Currently I am calling lwip_init() everytime I associate to an AP and after that I set the netif and start network connections.
what's wrong on this?
>
>To reset the PCBs I have to call memp_init() with MEMP_MEM_INIT set to
>1,
>right?

No, no, no! Hack! Don't do that. And just so that everyone reading your post knows this is wrong, I *had* to answer this :-)
 why is MEMP_MEM_INIT added to opt.h if we should not use it?! 
If I did not set to 1, PCBs will not be reset if we disconnected from the AP.

So there is no way to reset everything, I have to go over the active connections and memset the PCB structures, without calling lwip_init()?

>
>When I call memp_init(), even if I did not set MEMP_MEM_INIT to 1, DHCP
>fails.

Ok, that's strange, but your problem lies somewhere else. Just "randomly" wiping some memory (memp_init) might make your problems go away for now, but others will arise!
 This is happening because dhcp_dec_pcb_refcount() is not called unless dhcp_stop() is called. 
After disconnecting, I am calling netif_remove(), I thought it is enough because it doesn't make sense to send DHCP release packet if we already disassociated from the AP.
Anyway, the problem is solved by calling dhcp_stop() and then netif_remove().

>
>According to wireshark capture, we send DHCP discover packet, the AP
>replies with the Offer, however we didn't enter dhcp_handle_offer()
>function.
>
>Do you have any idea what is happening?

No.

Regards,
Simon

_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users


--

Amena El-Homsi
Computer & Communication Engineer
Dipl. Eng,  M.S.

reply via email to

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