From eb8dad2fa668ef8b676afcf2636fc80c9bb351dc Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Mon, 6 May 2024 14:17:36 +0530 Subject: [PATCH] fix: Add warning to enable LWIP_NETIF_LOOPBACK to use control socket API Closes https://github.com/espressif/esp-idf/issues/13659 --- components/esp_http_server/src/util/ctrl_sock.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/esp_http_server/src/util/ctrl_sock.c b/components/esp_http_server/src/util/ctrl_sock.c index 65d6e7f972..36eb5b055b 100644 --- a/components/esp_http_server/src/util/ctrl_sock.c +++ b/components/esp_http_server/src/util/ctrl_sock.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -11,7 +11,7 @@ #include #include #include "sdkconfig.h" - +#include "esp_log.h" #include "ctrl_sock.h" #if CONFIG_IDF_TARGET_LINUX @@ -22,11 +22,20 @@ #define IPV6_ENABLED CONFIG_LWIP_IPV6 #endif // !CONFIG_IDF_TARGET_LINUX +#if !CONFIG_LWIP_NETIF_LOOPBACK +static const char *TAG = "esp_http_server"; +#endif + /* Control socket, because in some network stacks select can't be woken up any * other way */ int cs_create_ctrl_sock(int port) { +#if !CONFIG_LWIP_NETIF_LOOPBACK + ESP_LOGE(TAG, "Please enable LWIP_NETIF_LOOPBACK for %s API", __func__); + return -1; +#endif + int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (fd < 0) { return -1;