ESP8266 lwip2 hooks

Hi, I’ve exhausted all the information I have about using lwip2 hooks with espressif8266, framework Arduino. Could someone please provide a working example? I’m currently trying to perform custom routing using LWIP_HOOK_IP4_ROUTE, but I think any other working hook example could help me figure out what I’m missing.

What did you try and what errors did you encounter?

My first instinct would be to clone the Arduino-ESP8266, then follow the instructions at Arduino/tools/sdk/lwip2 at master · esp8266/Arduino · GitHub how to compile the LWIP2 library (with unmodified configs), then with modified lwipopts.h with that macro you want. Once the binaries are produced and include / config files updated, you should be able to overwrite the old ones (<user folder>/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lwip2) with the newly generated ones.

No error at all. I ended up by opening the source codes of lwip2 for esp8266 of my Arduino IDE and tracking where the hooks are in the code, and what do they need to execute, then I checked all the conditions to be defined (most of them were by default) then I defined the macro LWIP_HOOK_IP4_ROUTE acording to this and called it inside mi setup function just for make sure it was working, and it was, but never got invoked while routing like I supposed it would.

so, those are not recompiled every time? that explains why “/framework-arduinoespressif8266/tools/sdk/lwip2” does not include source files like arduino ide’s esp8266 directory
thank’s for the reply, I will try it as soon as I can.

Yes, that’s absolutely crucial. LWIP2 is not compiled from source. Changes to the config file absolutely don’t matter / take effect if you don’t recompile the library and change the static .a lwip2 library files in The Makefiles / builder scripts help you to produce these files.

this really got me on track, but i’m unable to compile it

can’t find any tutorial, I’ve tryed by my self anyway and failed, could you please elaborate?

How exactly does it fail? On which OS are you trying this? I’d recommend Linux and the toolchain from GitHub - earlephilhower/esp-quick-toolchain: GCC toolchain for esp8266/arduino on MacOS, Linux, ARM64, Raspberry Pi, and Windows