mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp-tls: Added getter/setter function for the conn_state.
* Added the setter function to set the connection sockfd value Closes https://github.com/espressif/esp-idf/issues/10871
This commit is contained in:
parent
d020a58be1
commit
e24e674e2f
@ -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) {
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user