From 18907c2c8ff71d6a04d112f71e7b8fef61f23134 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 12 Sep 2025 16:56:08 +0200 Subject: [PATCH] fix(lwip): Remove deprecated ping wrappers over lwip raw api --- components/lwip/CMakeLists.txt | 2 - components/lwip/apps/ping/esp_ping.c | 167 ---------- components/lwip/apps/ping/ping.c | 311 ------------------ components/lwip/include/apps/esp_ping.h | 112 ------- components/lwip/include/apps/ping/ping.h | 60 ---- .../release-6.x/6.0/networking.rst | 28 ++ .../release-6.x/6.0/networking.rst | 27 ++ tools/ci/check_copyright_ignore.txt | 3 - 8 files changed, 55 insertions(+), 655 deletions(-) delete mode 100644 components/lwip/apps/ping/esp_ping.c delete mode 100644 components/lwip/apps/ping/ping.c delete mode 100644 components/lwip/include/apps/esp_ping.h delete mode 100644 components/lwip/include/apps/ping/ping.h diff --git a/components/lwip/CMakeLists.txt b/components/lwip/CMakeLists.txt index 5c193065b7c..160e89a020f 100644 --- a/components/lwip/CMakeLists.txt +++ b/components/lwip/CMakeLists.txt @@ -158,8 +158,6 @@ if(NOT ${target} STREQUAL "linux") if(CONFIG_LWIP_ICMP) list(APPEND srcs - "apps/ping/esp_ping.c" - "apps/ping/ping.c" "apps/ping/ping_sock.c") endif() diff --git a/components/lwip/apps/ping/esp_ping.c b/components/lwip/apps/ping/esp_ping.c deleted file mode 100644 index 7b493b6c444..00000000000 --- a/components/lwip/apps/ping/esp_ping.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include "esp_ping.h" - -#include "lwip/ip_addr.h" -typedef struct _ping_option { - ip_addr_t ping_target; - uint32_t ping_count; - uint32_t ping_rcv_timeout; - uint32_t ping_delay; - uint32_t interface; - size_t ping_data_len; - uint16_t ping_id; - u8_t ping_tos; - u8_t ping_ttl; - esp_ping_found_fn ping_res_fn; - esp_ping_found ping_res; - void *ping_reserve; -} ping_option; - -static ping_option ping_option_info[1]; - -esp_err_t esp_ping_set_target(ping_target_id_t opt_id, void *opt_val, uint32_t opt_len) -{ - esp_err_t ret = ESP_OK; - - if (opt_val == NULL) { - return ESP_ERR_PING_INVALID_PARAMS; - } - - switch (opt_id) { - case PING_TARGET_IP_ADDRESS: - ipaddr_aton(opt_val, &(ping_option_info->ping_target)); - break; - case PING_TARGET_IP_ADDRESS_COUNT: - ESP_PING_CHECK_OPTLEN(opt_len, uint32_t); - ping_option_info->ping_count = *(uint32_t *)opt_val; - break; - case PING_TARGET_IF_INDEX: - ESP_PING_CHECK_OPTLEN(opt_len, uint32_t); - ping_option_info->interface = *(uint32_t *)opt_val; - break; - case PING_TARGET_RCV_TIMEO: - ESP_PING_CHECK_OPTLEN(opt_len, uint32_t); - ping_option_info->ping_rcv_timeout = (*(uint32_t *)opt_val); - break; - case PING_TARGET_DELAY_TIME: - ESP_PING_CHECK_OPTLEN(opt_len, uint32_t); - ping_option_info->ping_delay = (*(uint32_t *)opt_val); - break; - case PING_TARGET_DATA_LEN: - ESP_PING_CHECK_OPTLEN(opt_len, size_t); - ping_option_info->ping_data_len = (*(size_t *)opt_val); - break; - case PING_TARGET_ID: - ESP_PING_CHECK_OPTLEN(opt_len, uint16_t); - ping_option_info->ping_id = *(uint16_t *)opt_val; - break; - case PING_TARGET_IP_TOS: - ESP_PING_CHECK_OPTLEN(opt_len, u8_t); - ping_option_info->ping_tos = *(u8_t *)opt_val; - break; - case PING_TARGET_RES_FN: - ping_option_info->ping_res_fn = opt_val; - break; - case PING_TARGET_RES_RESET: - memset(&ping_option_info->ping_res, 0, sizeof(ping_option_info->ping_res)); - break; - default: - ret = ESP_ERR_PING_INVALID_PARAMS; - break; - } - - return ret; -} - -esp_err_t esp_ping_get_target(ping_target_id_t opt_id, void *opt_val, uint32_t opt_len) -{ - esp_err_t ret = ESP_OK; - - if (opt_val == NULL) { - return ESP_ERR_PING_INVALID_PARAMS; - } - - switch (opt_id) { - case PING_TARGET_IP_ADDRESS: - ip_addr_copy(*(ip_addr_t*)opt_val, ping_option_info->ping_target); - break; - case PING_TARGET_IP_ADDRESS_COUNT: - ESP_PING_CHECK_OPTLEN(opt_len, uint32_t); - *(uint32_t *)opt_val = ping_option_info->ping_count; - break; - case PING_TARGET_IF_INDEX: - ESP_PING_CHECK_OPTLEN(opt_len, uint32_t); - *(uint32_t *)opt_val = ping_option_info->interface; - break; - case PING_TARGET_RCV_TIMEO: - ESP_PING_CHECK_OPTLEN(opt_len, uint32_t); - *(uint32_t *)opt_val = ping_option_info->ping_rcv_timeout; - break; - case PING_TARGET_DELAY_TIME: - ESP_PING_CHECK_OPTLEN(opt_len, uint32_t); - *(uint32_t *)opt_val = ping_option_info->ping_delay; - break; - case PING_TARGET_DATA_LEN: - ESP_PING_CHECK_OPTLEN(opt_len, size_t); - *(size_t *)opt_val = ping_option_info->ping_data_len; - break; - case PING_TARGET_ID: - ESP_PING_CHECK_OPTLEN(opt_len, uint16_t); - *(uint16_t *)opt_val = ping_option_info->ping_id; - break; - case PING_TARGET_IP_TOS: - ESP_PING_CHECK_OPTLEN(opt_len, uint16_t); - *(uint16_t *)opt_val = ping_option_info->ping_tos; - break; - default: - ret = ESP_ERR_PING_INVALID_PARAMS; - break; - } - - return ret; -} - -esp_err_t esp_ping_result(uint8_t res_val, uint16_t ping_len, uint32_t ping_time) -{ - esp_err_t ret = ESP_OK; - - ping_option_info->ping_res.ping_err = res_val; - - if (res_val != PING_RES_FINISH) { - ping_option_info->ping_res.bytes = ping_len; - ping_option_info->ping_res.resp_time = ping_time; - ping_option_info->ping_res.total_bytes += ping_len; - ping_option_info->ping_res.send_count ++; - - if (res_val == PING_RES_TIMEOUT) { - ping_option_info->ping_res.timeout_count ++; - } else { - if (!ping_option_info->ping_res.min_time || (ping_time < ping_option_info->ping_res.min_time)) { - ping_option_info->ping_res.min_time = ping_time; - } - - if (ping_time > ping_option_info->ping_res.max_time) { - ping_option_info->ping_res.max_time = ping_time; - } - - - ping_option_info->ping_res.total_time += ping_time; - ping_option_info->ping_res.recv_count ++; - } - } - - if (ping_option_info->ping_res_fn) { - ping_option_info->ping_res_fn(PING_TARGET_RES_FN, &ping_option_info->ping_res); - if (res_val == PING_RES_FINISH) { - memset(&ping_option_info->ping_res, 0, sizeof(esp_ping_found)); - } - } - - return ret; -} diff --git a/components/lwip/apps/ping/ping.c b/components/lwip/apps/ping/ping.c deleted file mode 100644 index 21c39ac5049..00000000000 --- a/components/lwip/apps/ping/ping.c +++ /dev/null @@ -1,311 +0,0 @@ -/** - * @file - * Ping sender module - * - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -/** - * This is an example of a "ping" sender (with raw API and socket API). - * It can be used as a start point to maintain opened a network connection, or - * like a network "watchdog" for your device. - * - */ - -#include "lwip/opt.h" - -#if LWIP_IPV4 && LWIP_RAW /* don't build if not configured for use in lwipopts.h */ - -#include "ping/ping.h" - -#include "lwip/mem.h" -#include "lwip/raw.h" -#include "lwip/icmp.h" -#include "lwip/netif.h" -#include "lwip/sys.h" -#include "lwip/timeouts.h" -#include "lwip/inet_chksum.h" - -#if PING_USE_SOCKETS -#include "lwip/sockets.h" -#include "lwip/inet.h" -#include "esp_task.h" -#include "ping/ping_sock.h" -#endif /* PING_USE_SOCKETS */ - -#ifdef ESP_PING -#include "esp_ping.h" -#include "lwip/ip_addr.h" -#endif -/** - * PING_DEBUG: Enable debugging for PING. - */ -#ifndef PING_DEBUG -#define PING_DEBUG LWIP_DBG_OFF -#endif - -/** ping target - should be an "ip4_addr_t" */ -#ifndef PING_TARGET -#define PING_TARGET (netif_default ? *netif_ip4_gw(netif_default) : (*IP4_ADDR_ANY)) -#endif - -/** ping receive timeout - in milliseconds */ -#ifndef PING_RCV_TIMEO -#define PING_RCV_TIMEO 1000 -#endif - -/** ping delay - in milliseconds */ -#ifndef PING_DELAY -#define PING_DELAY 1000 -#endif - -/** ping identifier - must fit on a u16_t */ -#ifndef PING_ID -#define PING_ID 0xAFAF -#endif - -/** ping additional data size to include in the packet */ -#ifndef PING_DATA_SIZE -#define PING_DATA_SIZE 32 -#endif - -/** ping result action - no default action */ -#ifndef PING_RESULT -#define PING_RESULT(ping_ok) -#endif - -#define PING_TIME_DIFF_MS(_end, _start) ((uint32_t)(((_end).tv_sec - (_start).tv_sec) * 1000 + (_end.tv_usec - _start.tv_usec)/1000)) -#define PING_TIME_DIFF_SEC(_end, _start) ((uint32_t)((_end).tv_sec - (_start).tv_sec)) - -#if PING_USE_SOCKETS -/* ping handle */ -static esp_ping_handle_t ping = NULL; -#else -static struct raw_pcb *ping_pcb; -static u16_t ping_seq_num; -static struct timeval ping_time; - -/** Prepare a echo ICMP request */ -static void -ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len) -{ - size_t i; - size_t data_len = len - sizeof(struct icmp_echo_hdr); - - ICMPH_TYPE_SET(iecho, ICMP_ECHO); - ICMPH_CODE_SET(iecho, 0); - iecho->chksum = 0; - iecho->id = PING_ID; - iecho->seqno = htons(++ping_seq_num); - - /* fill the additional data buffer with some data */ - for(i = 0; i < data_len; i++) { - ((char*)iecho)[sizeof(struct icmp_echo_hdr) + i] = (char)i; - } - - iecho->chksum = inet_chksum(iecho, len); -} - -/* Ping using the raw ip */ -static u8_t -ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr) -{ - struct icmp_echo_hdr *iecho; - struct timeval now; - - LWIP_UNUSED_ARG(arg); - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(addr); - LWIP_ASSERT("p != NULL", p != NULL); - - if ((p->tot_len >= (PBUF_IP_HLEN + sizeof(struct icmp_echo_hdr))) && - pbuf_header(p, -PBUF_IP_HLEN) == 0) { - iecho = (struct icmp_echo_hdr *)p->payload; - - if ((iecho->id == PING_ID) && (iecho->seqno == htons(ping_seq_num))) { - LWIP_DEBUGF( PING_DEBUG, ("ping: recv ")); - ip_addr_debug_print(PING_DEBUG, addr); - gettimeofday(&now, NULL); - LWIP_DEBUGF( PING_DEBUG, (" %"U32_F" ms\n", PING_TIME_DIFF_MS(now, ping_time))); - - /* do some ping result processing */ - PING_RESULT(1); - pbuf_free(p); - return 1; /* eat the packet */ - } - /* not eaten, restore original packet */ - pbuf_header(p, PBUF_IP_HLEN); - } - - return 0; /* don't eat the packet */ -} - -static void -ping_send(struct raw_pcb *raw, ip_addr_t *addr) -{ - struct pbuf *p; - struct icmp_echo_hdr *iecho; - size_t ping_size = sizeof(struct icmp_echo_hdr) + PING_DATA_SIZE; - - LWIP_DEBUGF( PING_DEBUG, ("ping: send ")); - ip_addr_debug_print(PING_DEBUG, addr); - LWIP_DEBUGF( PING_DEBUG, ("\n")); - LWIP_ASSERT("ping_size <= 0xffff", ping_size <= 0xffff); - - p = pbuf_alloc(PBUF_IP, (u16_t)ping_size, PBUF_RAM); - if (!p) { - return; - } - if ((p->len == p->tot_len) && (p->next == NULL)) { - iecho = (struct icmp_echo_hdr *)p->payload; - - ping_prepare_echo(iecho, (u16_t)ping_size); - - raw_sendto(raw, p, addr); - ping_time = system_get_time(); - } - pbuf_free(p); -} - -static void -ping_timeout(void *arg) -{ - struct raw_pcb *pcb = (struct raw_pcb*)arg; - ip_addr_t ping_target; - - LWIP_ASSERT("ping_timeout: no pcb given!", pcb != NULL); - - ip_addr_copy_from_ip4(ping_target, PING_TARGET); - ping_send(pcb, &ping_target); - sys_timeout(PING_DELAY, ping_timeout, pcb); -} - -static void -ping_raw_init(void) -{ - ping_pcb = raw_new(IP_PROTO_ICMP); - LWIP_ASSERT("ping_pcb != NULL", ping_pcb != NULL); - - raw_recv(ping_pcb, ping_recv, NULL); - raw_bind(ping_pcb, IP_ADDR_ANY); - sys_timeout(PING_DELAY, ping_timeout, ping_pcb); -} - -void -ping_send_now(void) -{ - ip_addr_t ping_target; - LWIP_ASSERT("ping_pcb != NULL", ping_pcb != NULL); - ip_addr_copy_from_ip4(ping_target, PING_TARGET); - ping_send(ping_pcb, &ping_target); -} - -#endif /* PING_USE_SOCKETS */ - -/** - * - * Re-implement ping_init and ping_deinit with the APIs from ping_sock.h for back-ward compatibility sake. - * It's highly recommended that users should use the new APIs from ping_sock.h. - * ToDo: ping.h and esp_ping.h are deprecated now and should be removed in idf v5.x. - * - */ - -static void -on_ping_success(esp_ping_handle_t hdl, void *args) -{ - uint32_t elapsed_time, recv_len; - esp_ping_get_profile(hdl, ESP_PING_PROF_SIZE, &recv_len, sizeof(recv_len)); - esp_ping_get_profile(hdl, ESP_PING_PROF_TIMEGAP, &elapsed_time, sizeof(elapsed_time)); - esp_ping_result(PING_RES_OK, recv_len, elapsed_time); -} - -static void -on_ping_timeout(esp_ping_handle_t hdl, void *args) -{ - uint32_t elapsed_time, recv_len; - esp_ping_get_profile(hdl, ESP_PING_PROF_SIZE, &recv_len, sizeof(recv_len)); - esp_ping_get_profile(hdl, ESP_PING_PROF_TIMEGAP, &elapsed_time, sizeof(elapsed_time)); - esp_ping_result(PING_RES_TIMEOUT, recv_len, elapsed_time); -} - -static void -on_ping_end(esp_ping_handle_t hdl, void *args) -{ - esp_ping_result(PING_RES_FINISH, 0, 0); - esp_ping_delete_session(hdl); -} - -int -ping_init(void) -{ -#if PING_USE_SOCKETS - uint32_t tos = 0; - uint32_t ping_timeout = PING_RCV_TIMEO; - uint32_t ping_delay = PING_DELAY; - uint32_t ping_count_max = 3; - uint32_t interface = 0; - ip_addr_t ipaddr; - - esp_ping_get_target(PING_TARGET_IP_ADDRESS_COUNT, &ping_count_max, sizeof(ping_count_max)); - esp_ping_get_target(PING_TARGET_RCV_TIMEO, &ping_timeout, sizeof(ping_timeout)); - esp_ping_get_target(PING_TARGET_DELAY_TIME, &ping_delay, sizeof(ping_delay)); - esp_ping_get_target(PING_TARGET_IP_ADDRESS, &ipaddr, sizeof(ip_addr_t)); - esp_ping_get_target(PING_TARGET_IP_TOS, &tos, sizeof(tos)); - esp_ping_get_target(PING_TARGET_IF_INDEX, &interface, sizeof(interface)); - - esp_ping_config_t config = ESP_PING_DEFAULT_CONFIG(); - config.count = ping_count_max; - config.timeout_ms = ping_timeout; - config.interval_ms = ping_delay; - config.target_addr = ipaddr; - config.tos = tos; - config.interface = interface; - - esp_ping_callbacks_t cbs = { - .on_ping_end = on_ping_end, - .on_ping_success = on_ping_success, - .on_ping_timeout = on_ping_timeout, - }; - - esp_ping_new_session(&config, &cbs, &ping); - esp_ping_start(ping); -#else /* PING_USE_SOCKETS */ - ping_raw_init(); -#endif /* PING_USE_SOCKETS */ - return ERR_OK; -} - -void -ping_deinit(void) -{ - esp_ping_stop(ping); - esp_ping_delete_session(ping); -} - -#endif /* LWIP_IPV4 && LWIP_RAW */ diff --git a/components/lwip/include/apps/esp_ping.h b/components/lwip/include/apps/esp_ping.h deleted file mode 100644 index 86dcc6ac012..00000000000 --- a/components/lwip/include/apps/esp_ping.h +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef ESP_PING_H_ -#define ESP_PING_H_ - -#include "esp_err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// gen_esp_err_to_name.py: include this as "esp_ping.h" because "components/lwip/include/apps/" is in the compiler path -// and not "components/lwip/include" - -#define ESP_ERR_PING_BASE 0xa000 - -#define ESP_ERR_PING_INVALID_PARAMS ESP_ERR_PING_BASE + 0x01 -#define ESP_ERR_PING_NO_MEM ESP_ERR_PING_BASE + 0x02 - -#define ESP_PING_CHECK_OPTLEN(optlen, opttype) do { if ((optlen) < sizeof(opttype)) { return ESP_ERR_PING_INVALID_PARAMS; }}while(0) - -typedef struct _ping_found { - uint32_t resp_time; - uint32_t timeout_count; - uint32_t send_count; - uint32_t recv_count; - uint32_t err_count; - uint32_t bytes; - uint32_t total_bytes; - uint32_t total_time; - uint32_t min_time; - uint32_t max_time; - int8_t ping_err; -} esp_ping_found; - -typedef enum { - PING_TARGET_IP_ADDRESS = 50, /**< target IP address */ - PING_TARGET_IP_ADDRESS_COUNT = 51, /**< target IP address total counter */ - PING_TARGET_RCV_TIMEO = 52, /**< receive timeout in milliseconds */ - PING_TARGET_DELAY_TIME = 53, /**< delay time in milliseconds */ - PING_TARGET_ID = 54, /**< identifier */ - PING_TARGET_RES_FN = 55, /**< ping result callback function */ - PING_TARGET_RES_RESET = 56, /**< ping result statistic reset */ - PING_TARGET_DATA_LEN = 57, /**< ping data length*/ - PING_TARGET_IP_TOS = 58, /**< ping QOS*/ - PING_TARGET_IF_INDEX = 59 /**< ping if index*/ -} ping_target_id_t; - -typedef enum { - PING_RES_TIMEOUT = 0, - PING_RES_OK = 1, - PING_RES_FINISH = 2, -} ping_res_t; - -typedef void (* esp_ping_found_fn)(ping_target_id_t found_id, esp_ping_found *found_val); - -/** - * @brief Set PING function option - * - * @param[in] opt_id: option index, 50 for IP, 51 for COUNT, 52 for RCV TIMEOUT, 53 for DELAY TIME, 54 for ID - * @param[in] opt_val: option parameter - * @param[in] opt_len: option length - * - * @return - * - ESP_OK - * - ESP_ERR_PING_INVALID_PARAMS - */ -esp_err_t esp_ping_set_target(ping_target_id_t opt_id, void *opt_val, uint32_t opt_len); - -/** - * @brief Get PING function option - * - * @param[in] opt_id: option index, 50 for IP, 51 for COUNT, 52 for RCV TIMEOUT, 53 for DELAY TIME, 54 for ID - * @param[in] opt_val: option parameter - * @param[in] opt_len: option length - * - * @return - * - ESP_OK - * - ESP_ERR_PING_INVALID_PARAMS - */ -esp_err_t esp_ping_get_target(ping_target_id_t opt_id, void *opt_val, uint32_t opt_len); - -/** - * @brief Get PING function result action - * - * @param[in] res_val: ping function action, 1 for successful, 0 for fail. - * res_len: response bytes - * res_time: response time - * - * @return - * - ESP_OK - * - ESP_ERR_PING_INVALID_PARAMS - */ -esp_err_t esp_ping_result(uint8_t res_val, uint16_t res_len, uint32_t res_time); - -#ifdef __cplusplus -} -#endif - -#endif /* ESP_PING_H_ */ diff --git a/components/lwip/include/apps/ping/ping.h b/components/lwip/include/apps/ping/ping.h deleted file mode 100644 index 6d17856555a..00000000000 --- a/components/lwip/include/apps/ping/ping.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#ifndef LWIP_PING_H -#define LWIP_PING_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used - */ -#ifndef PING_USE_SOCKETS -#define PING_USE_SOCKETS LWIP_SOCKET -#endif - - -int ping_init(void) __attribute__ ((deprecated)); - -#ifdef ESP_PING -void ping_deinit(void) __attribute__ ((deprecated)); -#endif - -#if !PING_USE_SOCKETS -void ping_send_now(void); -#endif /* !PING_USE_SOCKETS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_PING_H */ diff --git a/docs/en/migration-guides/release-6.x/6.0/networking.rst b/docs/en/migration-guides/release-6.x/6.0/networking.rst index bfa754e4504..a02249ab87e 100644 --- a/docs/en/migration-guides/release-6.x/6.0/networking.rst +++ b/docs/en/migration-guides/release-6.x/6.0/networking.rst @@ -174,3 +174,31 @@ SNTP Header File Removal ------------------------ The deprecated ``sntp.h`` header file has been removed in IDF v6.0. Applications should now include ``esp_sntp.h`` instead of ``sntp.h`` for SNTP functionality. + +Ping API Removal +---------------- + +The deprecated ping APIs and headers have been removed in IDF v6.0: + +- ``esp_ping.h`` header file has been removed +- ``ping.h`` header file has been removed +- Functions ``ping_init()``, ``ping_deinit()``, ``esp_ping_set_target()``, ``esp_ping_get_target()``, and ``esp_ping_result()`` have been removed + +Applications should now use the socket-based ping API from ``ping/ping_sock.h``: + +.. code-block:: c + + #include "ping/ping_sock.h" + // Create ping session + esp_ping_config_t config = ESP_PING_DEFAULT_CONFIG(); + config.target_addr = target_ip; + esp_ping_callbacks_t cbs = { + .on_ping_success = on_ping_success, + .on_ping_timeout = on_ping_timeout, + .on_ping_end = on_ping_end, + }; + esp_ping_handle_t ping; + esp_ping_new_session(&config, &cbs, &ping); + esp_ping_start(ping); + +For a complete example, see :example:`protocols/icmp_echo`. diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/networking.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/networking.rst index d311dcd2304..2b640de9466 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/networking.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/networking.rst @@ -175,3 +175,30 @@ SNTP 头文件移除 已弃用的 ``sntp.h`` 头文件在 IDF v6.0 中已被移除。应用程序现在应该包含 ``esp_sntp.h`` 而不是 ``sntp.h`` 来使用 SNTP 功能。 +Ping API 移除 +------------- + +已弃用的 ping API 和头文件在 IDF v6.0 中已被移除: + +- ``esp_ping.h`` 头文件已被移除 +- ``ping.h`` 头文件已被移除 +- 函数 ``ping_init()``、``ping_deinit()``、``esp_ping_set_target()``、``esp_ping_get_target()`` 和 ``esp_ping_result()`` 已被移除 + +应用程序现在应该使用来自 ``ping/ping_sock.h`` 的基于套接字的 ping API: + +.. code-block:: c + + #include "ping/ping_sock.h" + // 创建 ping 会话 + esp_ping_config_t config = ESP_PING_DEFAULT_CONFIG(); + config.target_addr = target_ip; + esp_ping_callbacks_t cbs = { + .on_ping_success = on_ping_success, + .on_ping_timeout = on_ping_timeout, + .on_ping_end = on_ping_end, + }; + esp_ping_handle_t ping; + esp_ping_new_session(&config, &cbs, &ping); + esp_ping_start(ping); + +完整示例请参考 :example:`protocols/icmp_echo`。 diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 2d3b43a29cc..229dde405d7 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -466,9 +466,6 @@ components/hal/spi_slave_hal.c components/hal/spi_slave_hal_iram.c components/idf_test/include/idf_performance.h components/log/host_test/log_test/main/log_test.cpp -components/lwip/apps/ping/ping.c -components/lwip/include/apps/esp_ping.h -components/lwip/include/apps/ping/ping.h components/mbedtls/esp_crt_bundle/test_gen_crt_bundle/test_gen_crt_bundle.py components/mbedtls/port/aes/esp_aes_xts.c components/mbedtls/port/include/aes/esp_aes.h