Skip to content

Commit 9809c63

Browse files
[nrf noup] include: net: add SO_SENDCB to NCS extensions
nrf-squash! [nrf noup] include: net: add NCS extensions The SO_SENDCB socket option allows to set a callback to be called when a send operation is completed by lower layers. Signed-off-by: Kacper Radoszewski <[email protected]>
1 parent 9804956 commit 9809c63

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

include/zephyr/net/socket_ncs.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
extern "C" {
1717
#endif
1818

19+
#include <stddef.h>
20+
1921
/* When CONFIG_NET_SOCKETS_OFFLOAD is enabled, offloaded sockets take precedence
2022
* when creating a new socket. Combine this flag with a socket type when
2123
* creating a socket, to enforce native socket creation (e. g. SOCK_STREAM | SOCK_NATIVE).
@@ -116,6 +118,41 @@ extern "C" {
116118
*/
117119
#define RAI_WAIT_MORE 5
118120

121+
/** sockopt: set a callback to be called when a send operation is done sending data on air and
122+
* the data has been acknowledged by the peer, if required by the network protocol, or until the
123+
* timeout, given by the SO_SNDTIMEO socket option, is reached. Valid timeout values are
124+
* 1 to 600 seconds.
125+
* This option takes a @ref socket_ncs_sendcb structure.
126+
*
127+
* @note The callback is executed in an interrupt context.
128+
* Take care to offload any processing as appropriate.
129+
*
130+
* @note This is only supported by the following modem firmware:
131+
* - mfw_nrf9151-ntn
132+
*
133+
* This socket option cannot be used along the @ref MSG_WAITACK send flag.
134+
*/
135+
#define SO_SENDCB (NET_SOCKET_NCS_BASE + 63)
136+
137+
/** Parameters returned in the @ref socket_ncs_sendcb_t callback. */
138+
struct socket_ncs_sendcb_params {
139+
/** Socket handle. */
140+
int fd;
141+
/** Status. Can be 0 on successful send or EAGAIN on timeout. */
142+
int status;
143+
/** Number of bytes that was sent. */
144+
size_t bytes_sent;
145+
};
146+
147+
/** Callback type in the @ref socket_ncs_sendcb structure. */
148+
typedef void (*socket_ncs_sendcb_t)(const struct socket_ncs_sendcb_params *params);
149+
150+
/** Option value for the @ref SO_SENDCB socket option. */
151+
struct socket_ncs_sendcb {
152+
/** Callback function. */
153+
socket_ncs_sendcb_t callback;
154+
};
155+
119156
/* NCS specific IPPROTO_ALL level socket options */
120157

121158
/** IPv4 and IPv6 protocol level (pseudo-val) for nRF sockets. */

0 commit comments

Comments
 (0)