ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
lwip_glue_stubs.cpp
Go to the documentation of this file.
1/*
2 * Linker wrap stubs for the lwIP2 glue's dead DHCP entry points.
3 *
4 * The ESP8266 SDK blobs call dhcp_cleanup() and dhcp_release() when the
5 * station leaves an access point (cnx_sta_leave, wifi_station_dhcpc_stop).
6 * In the prebuilt lwIP2 glue (liblwip2-*.a, glue-esp/lwip-esp.c) these are
7 * stubs whose only effect is printing "STUB: dhcp_cleanup" and
8 * "STUB: dhcp_release"; the real DHCP teardown happens through lwIP2's
9 * renamed dhcp_cleanup_LWIP2()/dhcp_release_LWIP2() functions.
10 *
11 * On ESP8266 .rodata lives in DRAM, so those message strings waste scarce
12 * RAM. Wrapping the stubs with silent equivalents lets the linker garbage
13 * collect the glue stub bodies together with their strings.
14 *
15 * Saves 38 bytes of RAM and removes the "STUB:" log noise on Wi-Fi
16 * disconnect. Behavior is otherwise unchanged.
17 */
18
19#if defined(USE_ESP8266)
20
21namespace esphome::esp8266 {}
22
23// NOLINTBEGIN(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
24extern "C" {
25
26// The callers are closed-source SDK blobs; the netif argument is unused.
27void __wrap_dhcp_cleanup(void * /*netif*/) {}
28
29// The glue stub returns ERR_ABRT (-8; lwIP 1.4 err_t is a signed char).
30signed char __wrap_dhcp_release(void * /*netif*/) { return -8; }
31
32} // extern "C"
33// NOLINTEND(bugprone-reserved-identifier,cert-dcl37-c,cert-dcl51-cpp,readability-identifier-naming)
34
35#endif // USE_ESP8266
void __wrap_dhcp_cleanup(void *)
signed char __wrap_dhcp_release(void *)