mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-16 04:22:22 +00:00
bugfix for add ttl for ping socket
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user