Perhaps if you could think your actions in terms of OSI layers it would be easier to understand. You say "before IP" but you draw "after IP" (well, sort of...), so I don't really get what you need.
What is it that you are trying to accomplish, do you want to encapsulate TCP/IP into an "ESP" (whatever it is) datagram/frame or do you want to run that "ESP" protocol over IP ? In any way, you just call your protocol function from the correct layer function and it should take care of header and footer stuff. If "ESP" runs over Ethernet, you handle this at the netif level, outside lwIP. Instead of lwIP calling and being called by the netif, you add a netif layer that is outbound: called by lwIP and calls the netif output function. Basically you replace netif->output by your output function, which after adding header and footer calls what was in there. inbound: called by the netif and calls the lwIP input function, which depends on whether you are actually using an OS or not (baremetal). Basically, conversely, you replace netif->input by your function, which after removing header and footer calls what was in there. Running "ESP" over IP requires you use the "raw IP" access functions. Having other TCP/IP stack protocols over this is a bit trickier, since you need to sit "in the middle" inside lwIP. I personally don't know how to do this. Again, please clarify your scenario. _______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users