Function esp_idf_sys::mbedtls_ssl_write
source · pub unsafe extern "C" fn mbedtls_ssl_write(
ssl: *mut mbedtls_ssl_context,
buf: *const c_uchar,
len: usize,
) -> c_int
Expand description
\brief Try to write exactly ‘len’ application data bytes
\warning This function will do partial writes in some cases. If the return value is non-negative but less than length, the function must be called again with updated arguments: buf + ret, len - ret (if ret is the return value) until it returns a value equal to the last ‘len’ argument.
\param ssl SSL context \param buf buffer holding the data \param len how many bytes must be written
\return The (non-negative) number of bytes actually written if successful (may be less than \p len). \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE if the handshake is incomplete and waiting for data to be available for reading from or writing to the underlying transport - in this case you must call this function again when the underlying transport is ready for the operation. \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous operation is in progress (see mbedtls_ssl_conf_async_private_cb()) - in this case you must call this function again when the operation is ready. \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic operation is in progress (see mbedtls_ecp_set_max_ops()) - in this case you must call this function again to complete the handshake when you’re done attending other tasks. \return Another SSL error code - in this case you must stop using the context (see below).
\warning If this function returns something other than a non-negative value, #MBEDTLS_ERR_SSL_WANT_READ, #MBEDTLS_ERR_SSL_WANT_WRITE, #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, you must stop using the SSL context for reading or writing, and either free it or call \c mbedtls_ssl_session_reset() on it before re-using it for a new connection; the current connection must be closed.
\note When this function returns #MBEDTLS_ERR_SSL_WANT_WRITE/READ, it must be called later with the same arguments, until it returns a value greater than or equal to 0. When the function returns #MBEDTLS_ERR_SSL_WANT_WRITE there may be some partial data in the output buffer, however this is not yet sent.
\note If the requested length is greater than the maximum fragment length (either the built-in limit or the one set or negotiated with the peer), then: - with TLS, less bytes than requested are written. - with DTLS, MBEDTLS_ERR_SSL_BAD_INPUT_DATA is returned. \c mbedtls_ssl_get_max_out_record_payload() may be used to query the active maximum fragment length.
\note Attempting to write 0 bytes will result in an empty TLS application record being sent.