mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 00:51:42 +01:00 
			
		
		
		
	Merge branch 'feature/esp_tls_add_getter_setter_v5.1' into 'release/v5.1'
esp-tls: Added getter/setter function for the conn_state. (v5.1) See merge request espressif/esp-idf!23408
This commit is contained in:
		@@ -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
 | 
			
		||||
 *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user