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: address@hidden
Subject: Re: [lwip-users] LwIP PCBs reset
Date: Mon, 13 Jan 2020 22:18:23 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

Am 13.01.2020 um 09:27 schrieb Amena El Homsi:
Hi, thanks for your reply, please check my answers below.

On Thu, Jan 9, 2020 at 6:35 PM goldsimon <address@hidden
<mailto: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?

Calling lwip_init() won't work. It's not meant to. You cannot just call
an init function at runtime and expect it to work.


     >
     >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()?

Ehrm, not MEMP_MEM_INIT=1 is wrong, but calling memp_init() after the
init phase is wrong. (BTW, with lwip_init(), calling memp_init()
yourself is always wrong as it is called for you)



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

So the actual bug is that netif_remove() doesn't call dhcp_stop() if
DHCP is running? That might be worth a bug report...

I'm not sure I get the rest of your problem though.

Regads,
Simon



     >
     >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 <mailto:address@hidden>
    https://lists.nongnu.org/mailman/listinfo/lwip-users



--

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

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





reply via email to

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