I'm trying to enable NAT by using lwip from esp-idf, but the function to do it seems that isn't working properly.
The first image shows the "if" that must work to execute the ip_napt_init function where the necessary structures are initialized, but here this 'if' is never executed, so the NAT is never enabled. This function do not returns a error when the process did not work properly, so I will know that it didn't work only when I try to disable the NAT, in this case, the ip_napt_deinit is called (more below in the same image).
The second image is the code from ip_napt_init
The third image is ip_napt_deinit function, the board is crashing because it tries to free a memory that wasn't allocate before.
Problem when enabling/disabling NAT on esp-idf 4.3.2
-
- Posts: 8
- Joined: Wed Sep 25, 2019 8:31 pm
Re: Problem when enabling/disabling NAT on esp-idf 4.3.2
Hi,
Most probably, your interface is either not up yet, or it has not been allocated an IP address. Quick workaround would be to sleep for a couple of seconds (until interface is up and DHCP allocates an IP address to it). Better solution would be to check the status of the interface using function. Then, all you need is to wait until the interface is up and running before calling for that interface. Hope it helps.
Regards,
Mladen
Most probably, your interface is either not up yet, or it has not been allocated an IP address. Quick workaround would be to sleep for a couple of seconds (until interface is up and DHCP allocates an IP address to it). Better solution would be to check the status of the interface using
Code: Select all
esp_netif_is_netif_up()
Code: Select all
ip_napt_enable()
Regards,
Mladen
Who is online
Users browsing this forum: No registered users and 354 guests