Merge branch 'feature/esp_tls_api_cleanup' into 'master'

esp-tls: mark esp_tls_conn_delete API as deprecated

See merge request espressif/esp-idf!16647
pull/8201/head
Mahavir Jain 2022-01-05 07:04:09 +00:00
commit 6e1f534cab
8 zmienionych plików z 15 dodań i 36 usunięć

Wyświetl plik

@ -20,11 +20,6 @@ if(CONFIG_ESP_TLS_USING_WOLFSSL)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${wolfssl})
endif()
if(CONFIG_ESP_TLS_USE_SE)
idf_component_get_property(cryptoauthlib esp-cryptoauthlib COMPONENT_LIB)
target_link_libraries(${COMPONENT_LIB} PUBLIC ${cryptoauthlib})
endif()
# Increase link multiplicity to get some lwip symbols correctly resolved by the linker
# due to cyclic dependencies present in IDF for lwip/esp_netif/mbedtls
idf_component_get_property(lwip lwip COMPONENT_LIB)

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -92,11 +92,6 @@ static ssize_t tcp_write(esp_tls_t *tls, const char *data, size_t datalen)
/**
* @brief Close the TLS connection and free any allocated resources.
*/
void esp_tls_conn_delete(esp_tls_t *tls)
{
esp_tls_conn_destroy(tls);
}
int esp_tls_conn_destroy(esp_tls_t *tls)
{
if (tls != NULL) {
@ -463,14 +458,14 @@ esp_tls_t *esp_tls_conn_new(const char *hostname, int hostlen, int port, const e
if (ret == 1) {
return tls;
} else if (ret == -1) {
esp_tls_conn_delete(tls);
esp_tls_conn_destroy(tls);
ESP_LOGE(TAG, "Failed to open new connection");
return NULL;
} else if (ret == 0 && cfg->timeout_ms >= 0) {
size_t timeout_ticks = pdMS_TO_TICKS(cfg->timeout_ms);
uint32_t expired = xTaskGetTickCount() - start;
if (expired >= timeout_ticks) {
esp_tls_conn_delete(tls);
esp_tls_conn_destroy(tls);
ESP_LOGE(TAG, "Failed to open new connection in specified timeout");
return NULL;
}
@ -544,7 +539,7 @@ esp_tls_t *esp_tls_conn_http_new(const char *url, const esp_tls_cfg_t *cfg)
get_port(url, &u), cfg, tls) == 1) {
return tls;
}
esp_tls_conn_delete(tls);
esp_tls_conn_destroy(tls);
return NULL;
}

Wyświetl plik

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -499,11 +499,9 @@ static inline ssize_t esp_tls_conn_read(esp_tls_t *tls, void *data, size_t data
/**
* @brief Compatible version of esp_tls_conn_destroy() to close the TLS/SSL connection
*
* @note This API will be removed in IDFv5.0
*
* @param[in] tls pointer to esp-tls as esp-tls handle.
*/
void esp_tls_conn_delete(esp_tls_t *tls);
void esp_tls_conn_delete(esp_tls_t *tls) __attribute__((deprecated("Please use esp_tls_conn_destroy() instead")));
/**
* @brief Close the TLS/SSL connection and free any allocated resources.

Wyświetl plik

@ -11,7 +11,7 @@ All the configuration can be specified in the ``esp_tls_cfg_t`` data structure.
* :cpp:func:`esp_tls_conn_new`: for opening a new TLS connection.
* :cpp:func:`esp_tls_conn_read`: for reading from the connection.
* :cpp:func:`esp_tls_conn_write`: for writing into the connection.
* :cpp:func:`esp_tls_conn_delete`: for freeing up the connection.
* :cpp:func:`esp_tls_conn_destroy`: for freeing up the connection.
Any application layer protocol like HTTP1, HTTP2 etc can be executed on top of this layer.

Wyświetl plik

@ -1,16 +1,8 @@
// Copyright 2017 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: 2017-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
@ -280,7 +272,7 @@ void sh2lib_free(struct sh2lib_handle *hd)
hd->http2_sess = NULL;
}
if (hd->http2_tls) {
esp_tls_conn_delete(hd->http2_tls);
esp_tls_conn_destroy(hd->http2_tls);
hd->http2_tls = NULL;
}
if (hd->hostname) {

Wyświetl plik

@ -159,7 +159,7 @@ static void https_get_request(esp_tls_cfg_t cfg, const char *WEB_SERVER_URL, con
} while (1);
exit:
esp_tls_conn_delete(tls);
esp_tls_conn_destroy(tls);
for (int countdown = 10; countdown >= 0; countdown--) {
ESP_LOGI(TAG, "%d...", countdown);
vTaskDelay(1000 / portTICK_PERIOD_MS);

Wyświetl plik

@ -72,7 +72,7 @@ static void https_get_task(void *pvParameters)
ESP_LOGE(TAG, "Could not connect to %s", web_urls[i]);
}
esp_tls_conn_delete(tls);
esp_tls_conn_destroy(tls);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}

Wyświetl plik

@ -2711,7 +2711,6 @@ examples/protocols/esp_local_ctrl/main/app_main.c
examples/protocols/esp_local_ctrl/main/esp_local_ctrl_service.c
examples/protocols/esp_local_ctrl/scripts/esp_local_ctrl.py
examples/protocols/esp_local_ctrl/scripts/proto_lc.py
examples/protocols/http2_request/components/sh2lib/sh2lib.c
examples/protocols/http2_request/components/sh2lib/sh2lib.h
examples/protocols/http2_request/main/http2_request_example_main.c
examples/protocols/http_request/main/http_request_example_main.c