Merge branch 'feature/esp_tls_add_getter_setter' into 'master'

esp-tls: Added getter/setter function for the conn_state.

Closes IDFGH-9514

See merge request espressif/esp-idf!23128
This commit is contained in:
Mahavir Jain 2023-04-16 22:15:28 +08:00
commit 225be9a6ce
2 changed files with 66 additions and 0 deletions

View File

@ -698,6 +698,36 @@ esp_err_t esp_tls_get_conn_sockfd(esp_tls_t *tls, int *sockfd)
return ESP_OK;
}
esp_err_t esp_tls_set_conn_sockfd(esp_tls_t *tls, int sockfd)
{
if (!tls || sockfd < 0) {
ESP_LOGE(TAG, "Invalid arguments passed");
return ESP_ERR_INVALID_ARG;
}
tls->sockfd = sockfd;
return ESP_OK;
}
esp_err_t esp_tls_get_conn_state(esp_tls_t *tls, esp_tls_conn_state_t *conn_state)
{
if (!tls || !conn_state) {
ESP_LOGE(TAG, "Invalid arguments passed");
return ESP_ERR_INVALID_ARG;
}
*conn_state = tls->conn_state;
return ESP_OK;
}
esp_err_t esp_tls_set_conn_state(esp_tls_t *tls, esp_tls_conn_state_t conn_state)
{
if (!tls || conn_state < ESP_TLS_INIT || conn_state > ESP_TLS_DONE) {
ESP_LOGE(TAG, "Invalid arguments passed");
return ESP_ERR_INVALID_ARG;
}
tls->conn_state = conn_state;
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) {

View File

@ -502,6 +502,42 @@ ssize_t esp_tls_get_bytes_avail(esp_tls_t *tls);
*/
esp_err_t esp_tls_get_conn_sockfd(esp_tls_t *tls, int *sockfd);
/**
* @brief Sets the connection socket file descriptor for the esp_tls session
*
* @param[in] tls handle to esp_tls context
*
* @param[in] sockfd sockfd value to set.
*
* @return - ESP_OK on success and value of sockfd for the tls connection shall updated withthe provided value
* - ESP_ERR_INVALID_ARG if (tls == NULL || sockfd < 0)
*/
esp_err_t esp_tls_set_conn_sockfd(esp_tls_t *tls, int sockfd);
/**
* @brief Gets the connection state for the esp_tls session
*
* @param[in] tls handle to esp_tls context
*
* @param[out] conn_state pointer to the connection state value.
*
* @return - ESP_OK on success and value of sockfd for the tls connection shall updated withthe provided value
* - ESP_ERR_INVALID_ARG (Invalid arguments)
*/
esp_err_t esp_tls_get_conn_state(esp_tls_t *tls, esp_tls_conn_state_t *conn_state);
/**
* @brief Sets the connection state for the esp_tls session
*
* @param[in] tls handle to esp_tls context
*
* @param[in] conn_state connection state value to set.
*
* @return - ESP_OK on success and value of sockfd for the tls connection shall updated withthe provided value
* - ESP_ERR_INVALID_ARG (Invalid arguments)
*/
esp_err_t esp_tls_set_conn_state(esp_tls_t *tls, esp_tls_conn_state_t conn_state);
/**
* @brief Returns the ssl context
*