lwip hooks
Posted: Sun Sep 12, 2021 10:35 am
Mainly based on https://github.com/espressif/esp-idf/issues/6261, I tried to implement my LWIP_HOOK_IP4_INPUT as follows:
CMakeLists.txt:
(also tried "lwipcode" and "${COMPONENT_TARGET}" instead of "${lwip} – the latter does build but does not work as expected)
httpd/lwip_hooks.h:
httpd/myhook.h:
httpd/myhook.c:
What is the correct target to use in target_compile_definitions? Anything wrong with the rest of my incantation?
Running ESP-IDF 4.3.0 under platform.io.
Would be amazing to have an ESP-IDF example for using the hooks feature.
Sincerely,
Steffen
CMakeLists.txt:
Code: Select all
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*)
idf_component_register(SRCS ${app_sources})
target_compile_definitions(${lwip} PRIVATE "-DESP_IDF_LWIP_HOOK_FILENAME=\"httpd/lwip_hooks.h\"")
httpd/lwip_hooks.h:
Code: Select all
#pragma once
#define LWIP_HOOK_IP4_INPUT lwip_hook_ip4_input
Code: Select all
#pragma once
#include "lwip/netif.h"
#include "lwip/pbuf.h"
#ifdef __cplusplus
extern "C" {
#endif
int IRAM_ATTR lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif);
#ifdef __cplusplus
}
#endif
Code: Select all
#include "driver/gpio.h"
#include "lwip/netif.h"
#include "lwip/pbuf.h"
int IRAM_ATTR lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif) {
gpio_set_level(GPIO_NUM_2, 1);
return 0; // we don't consume the packet
}
Running ESP-IDF 4.3.0 under platform.io.
Would be amazing to have an ESP-IDF example for using the hooks feature.
Sincerely,
Steffen