bugfix for add ttl for ping socket

This commit is contained in:
xueyunfei
2022-06-06 14:11:19 +08:00
parent cd55014c33
commit b569f4069a
5 changed files with 23 additions and 29 deletions

View File

@@ -1,16 +1,8 @@
// 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.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include "esp_ping.h"
@@ -25,6 +17,7 @@ typedef struct _ping_option {
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;

View File

@@ -271,6 +271,9 @@ esp_err_t esp_ping_new_session(const esp_ping_config_t *config, const esp_ping_c
/* set tos */
setsockopt(ep->sock, IPPROTO_IP, IP_TOS, &config->tos, sizeof(config->tos));
/* set ttl */
setsockopt(ep->sock, IPPROTO_IP, IP_TTL, &config->ttl, sizeof(config->ttl));
/* set socket address */
if (IP_IS_V4(&config->target_addr)) {
struct sockaddr_in *to4 = (struct sockaddr_in *)&ep->target_addr;