mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sock: amend API to iterate over stack-internal chunks
With lwIP we have a chunked UDP payload, so just providing the stack-internal buffer is not possible. To be able to iterate over such a chunked payload, this change allows the `sock_*_recv_buf()` functions to use the internal buffer context as an iteration state. As the internal buffer space can be released when the function would return 0, `sock_recv_buf_free()` becomes unnecessary.
This commit is contained in:
parent
ec296f8439
commit
f9e17ac025
@ -245,19 +245,6 @@ struct _sock_tl_ep {
|
||||
uint16_t port; /**< transport layer port (in host byte order) */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Releases the stack-internal buffer space provided by the
|
||||
* `sock_*_recv_buf()` functions.
|
||||
*
|
||||
* @see
|
||||
* - @ref sock_dtls_recv_buf()
|
||||
* - @ref sock_ip_recv_buf()
|
||||
* - @ref sock_udp_recv_buf()
|
||||
*
|
||||
* @param[in] buf_ctx Stack-internal buffer context to release.
|
||||
*/
|
||||
void sock_recv_buf_free(void *buf_ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -615,9 +615,11 @@ ssize_t sock_dtls_recv(sock_dtls_t *sock, sock_dtls_session_t *remote,
|
||||
* Cannot be NULL.
|
||||
* @param[out] data Pointer to a stack-internal buffer space containing the
|
||||
* received data.
|
||||
* @param[out] buf_ctx Stack-internal buffer context. Must be used to release
|
||||
* the buffer space using @ref sock_recv_buf_free() after
|
||||
* the data in @p data was handled.
|
||||
* @param[in,out] buf_ctx Stack-internal buffer context. If it points to a
|
||||
* `NULL` pointer, the stack returns a new buffer space for
|
||||
* a new packet. If it does not point to a `NULL` pointer,
|
||||
* an existing context is assumed to get a next segment in
|
||||
* a buffer.
|
||||
* @param[in] timeout Receive timeout in microseconds.
|
||||
* If 0 and no data is available, the function returns
|
||||
* immediately.
|
||||
@ -626,7 +628,13 @@ ssize_t sock_dtls_recv(sock_dtls_t *sock, sock_dtls_session_t *remote,
|
||||
*
|
||||
* @note Function may block if data is not available and @p timeout != 0
|
||||
*
|
||||
* @return The number of bytes received on success
|
||||
* @note Function blocks if no packet is currently waiting.
|
||||
*
|
||||
* @return The number of bytes received on success. May not be the complete
|
||||
* payload. Continue calling with the returned @p buf_ctx to get more
|
||||
* buffers until result is 0 or an error.
|
||||
* @return 0, if no received data is available, but everything is in order.
|
||||
* If @p buf_ctx was provided, it was released.
|
||||
* @return -EADDRNOTAVAIL, if the local endpoint of @p sock is not set.
|
||||
* @return -EAGAIN, if @p timeout is `0` and no data is available.
|
||||
* @return -EINVAL, if @p remote is invalid or @p sock is not properly
|
||||
|
@ -435,9 +435,11 @@ ssize_t sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len,
|
||||
* @param[in] sock A raw IPv4/IPv6 sock object.
|
||||
* @param[out] data Pointer to a stack-internal buffer space containing the
|
||||
* received data.
|
||||
* @param[out] buf_ctx Stack-internal buffer context. Must be used to release
|
||||
* the buffer space using @ref sock_recv_buf_free() after
|
||||
* the data in @p data was handled.
|
||||
* @param[in,out] buf_ctx Stack-internal buffer context. If it points to a
|
||||
* `NULL` pointer, the stack returns a new buffer space
|
||||
* for a new packet. If it does not point to a `NULL`
|
||||
* pointer, an existing context is assumed to get a next
|
||||
* segment in a buffer.
|
||||
* @param[in] timeout Timeout for receive in microseconds.
|
||||
* If 0 and no data is available, the function returns
|
||||
* immediately.
|
||||
@ -448,8 +450,11 @@ ssize_t sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len,
|
||||
*
|
||||
* @note Function blocks if no packet is currently waiting.
|
||||
*
|
||||
* @return The number of bytes received on success.
|
||||
* @return The number of bytes received on success. May not be the complete
|
||||
* payload. Continue calling with the returned `buf_ctx` to get more
|
||||
* buffers until result is 0 or an error.
|
||||
* @return 0, if no received data is available, but everything is in order.
|
||||
* If @p buf_ctx was provided, it was released.
|
||||
* @return -EADDRNOTAVAIL, if local of @p sock is not given.
|
||||
* @return -EAGAIN, if @p timeout is `0` and no data is available.
|
||||
* @return -EINVAL, if @p remote is invalid or @p sock is not properly
|
||||
|
@ -422,9 +422,11 @@ ssize_t sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len,
|
||||
* @param[in] sock A UDP sock object.
|
||||
* @param[out] data Pointer to a stack-internal buffer space containing the
|
||||
* received data.
|
||||
* @param[out] buf_ctx Stack-internal buffer context. Must be used to release
|
||||
* the buffer space using @ref sock_recv_buf_free() after
|
||||
* the data in @p data was handled.
|
||||
* @param[in,out] buf_ctx Stack-internal buffer context. If it points to a
|
||||
* `NULL` pointer, the stack returns a new buffer space
|
||||
* for a new packet. If it does not point to a `NULL`
|
||||
* pointer, an existing context is assumed to get a next
|
||||
* segment in a buffer.
|
||||
* @param[in] timeout Timeout for receive in microseconds.
|
||||
* If 0 and no data is available, the function returns
|
||||
* immediately.
|
||||
@ -435,8 +437,11 @@ ssize_t sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len,
|
||||
*
|
||||
* @note Function blocks if no packet is currently waiting.
|
||||
*
|
||||
* @return The number of bytes received on success.
|
||||
* @return The number of bytes received on success. May not be the complete
|
||||
* payload. Continue calling with the returned `buf_ctx` to get more
|
||||
* buffers until result is 0 or an error.
|
||||
* @return 0, if no received data is available, but everything is in order.
|
||||
* If @p buf_ctx was provided, it was released.
|
||||
* @return -EADDRNOTAVAIL, if local of @p sock is not given.
|
||||
* @return -EAGAIN, if @p timeout is `0` and no data is available.
|
||||
* @return -EINVAL, if @p remote is invalid or @p sock is not properly
|
||||
|
Loading…
Reference in New Issue
Block a user