mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp32/esp-tls: provide API to retrieve sockfd value from esp_tls_t
This commit is contained in:
parent
0da18955aa
commit
c7418042b4
@ -115,8 +115,9 @@ esp_tls_t *esp_tls_init(void)
|
||||
return NULL;
|
||||
}
|
||||
#ifdef CONFIG_ESP_TLS_USING_MBEDTLS
|
||||
tls->server_fd.fd = tls->sockfd = -1;
|
||||
tls->server_fd.fd = -1;
|
||||
#endif
|
||||
tls->sockfd = -1;
|
||||
return tls;
|
||||
}
|
||||
|
||||
@ -309,7 +310,7 @@ static int esp_tls_low_level_conn(const char *hostname, int hostlen, int port, c
|
||||
*/
|
||||
esp_tls_t *esp_tls_conn_new(const char *hostname, int hostlen, int port, const esp_tls_cfg_t *cfg)
|
||||
{
|
||||
esp_tls_t *tls = (esp_tls_t *)calloc(1, sizeof(esp_tls_t));
|
||||
esp_tls_t *tls = esp_tls_init();
|
||||
if (!tls) {
|
||||
return NULL;
|
||||
}
|
||||
@ -432,6 +433,16 @@ ssize_t esp_tls_get_bytes_avail(esp_tls_t *tls)
|
||||
return _esp_tls_get_bytes_avail(tls);
|
||||
}
|
||||
|
||||
esp_err_t esp_tls_get_conn_sockfd(esp_tls_t *tls, int *sockfd)
|
||||
{
|
||||
if (!tls || !sockfd) {
|
||||
ESP_LOGE(TAG, "Invalid arguments passed");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
*sockfd = tls->sockfd;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_tls_get_and_clear_last_error(esp_tls_error_handle_t h, int *esp_tls_code, int *esp_tls_flags)
|
||||
{
|
||||
if (!h) {
|
||||
|
@ -477,6 +477,18 @@ void esp_tls_conn_delete(esp_tls_t *tls);
|
||||
*/
|
||||
ssize_t esp_tls_get_bytes_avail(esp_tls_t *tls);
|
||||
|
||||
/**
|
||||
* @brief Returns the connection socket file descriptor from esp_tls session
|
||||
*
|
||||
* @param[in] tls handle to esp_tls context
|
||||
*
|
||||
* @param[out] sockfd int pointer to sockfd value.
|
||||
*
|
||||
* @return - ESP_OK on success and value of sockfd will be updated with socket file descriptor for connection
|
||||
* - ESP_ERR_INVALID_ARG if (tls == NULL || sockfd == NULL)
|
||||
*/
|
||||
esp_err_t esp_tls_get_conn_sockfd(esp_tls_t *tls, int *sockfd);
|
||||
|
||||
/**
|
||||
* @brief Create a global CA store, initially empty.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user