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