Zephyr API 3.6.99
Loading...
Searching...
No Matches
socket_ncs.h File Reference

NCS specific additions to the BSD sockets API definitions. More...

#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  socket_ncs_sendcb_params
 Parameters returned in the socket_ncs_sendcb_t callback. More...
 
struct  socket_ncs_sendcb
 Option value for the SO_SENDCB socket option. More...
 
struct  socket_ncs_pollcb_params
 Parameters returned in the socket_ncs_pollcb_t callback. More...
 
struct  socket_ncs_pollcb
 Option value for the SO_POLLCB socket option. More...
 

Macros

#define SOCK_NATIVE   0x80000000
 
#define SOCK_NATIVE_TLS   0x40000000
 
#define NET_SOCKET_NCS_BASE   1000
 Define a base for NCS specific socket options to prevent overlaps with Zephyr's socket options.
 
#define TLS_DTLS_HANDSHAKE_TIMEO   (NET_SOCKET_NCS_BASE + 18)
 Socket option to set DTLS handshake timeout, specifically for nRF sockets.
 
#define TLS_DTLS_CONN_SAVE   (NET_SOCKET_NCS_BASE + 19)
 Socket option to save DTLS connection, specifically for nRF sockets.
 
#define TLS_DTLS_CONN_LOAD   (NET_SOCKET_NCS_BASE + 20)
 Socket option to load DTLS connection, specifically for nRF sockets.
 
#define TLS_DTLS_HANDSHAKE_STATUS   (NET_SOCKET_NCS_BASE + 21)
 Socket option to get result of latest TLS/DTLS completed handshakes end status, specifically for nRF sockets.
 
#define TLS_DTLS_HANDSHAKE_TIMEO_NONE   0
 No timeout.
 
#define TLS_DTLS_HANDSHAKE_TIMEO_1S   1
 1 second
 
#define TLS_DTLS_HANDSHAKE_TIMEO_3S   3
 1s + 2s
 
#define TLS_DTLS_HANDSHAKE_TIMEO_7S   7
 1s + 2s + 4s
 
#define TLS_DTLS_HANDSHAKE_TIMEO_15S   15
 1s + 2s + 4s + 8s
 
#define TLS_DTLS_HANDSHAKE_TIMEO_31S   31
 1s + 2s + 4s + 8s + 16s
 
#define TLS_DTLS_HANDSHAKE_TIMEO_63S   63
 1s + 2s + 4s + 8s + 16s + 32s
 
#define TLS_DTLS_HANDSHAKE_TIMEO_123S   123
 1s + 2s + 4s + 8s + 16s + 32s + 60s
 
#define TLS_DTLS_HANDSHAKE_STATUS_FULL   0
 
#define TLS_DTLS_HANDSHAKE_STATUS_CACHED   1
 
#define TLS_DTLS_FRAG_EXT   (NET_SOCKET_NCS_BASE + 22)
 Socket option to enable the DTLS fragmentation extension.
 
#define DTLS_FRAG_EXT_DISABLED   0
 Disabled - The DTLS fragmentation extension is not included in the Client Hello.
 
#define DTLS_FRAG_EXT_512_ENABLED   1
 Enabled - The DTLS fragmentation extension is included in the Client Hello with the fragment size of 512 bytes.
 
#define DTLS_FRAG_EXT_1024_ENABLED   2
 Enabled - The DTLS fragmentation extension is included in the Client Hello with the fragment size of 1024 bytes.
 
#define SO_EXCEPTIONAL_DATA   (NET_SOCKET_NCS_BASE + 33)
 sockopt: enable sending data as part of exceptional events
 
#define SO_KEEPOPEN   (NET_SOCKET_NCS_BASE + 34)
 sockopt: Keep socket open when its PDN connection is lost or the device is put into flight mode.
 
#define SO_BINDTOPDN   (NET_SOCKET_NCS_BASE + 40)
 sockopt: bind to PDN
 
#define SO_RAI   (NET_SOCKET_NCS_BASE + 61)
 sockopt: Release assistance indication (RAI).
 
#define RAI_NO_DATA   1
 Release assistance indication (RAI).
 
#define RAI_LAST   2
 Release assistance indication (RAI).
 
#define RAI_ONE_RESP   3
 Release assistance indication (RAI).
 
#define RAI_ONGOING   4
 Release assistance indication (RAI).
 
#define RAI_WAIT_MORE   5
 Release assistance indication (RAI).
 
#define SO_SENDCB   (NET_SOCKET_NCS_BASE + 63)
 sockopt: set a callback to be called when a send request is acknowledged by the network and the data has been acknowledged by the peer, if required by the network protocol, or until the timeout, given by the SO_SNDTIMEO socket option, is reached.
 
#define SO_POLLCB   (NET_SOCKET_NCS_BASE + 64)
 sockopt: set a callback to be called upon the selected poll events.
 
#define IPPROTO_ALL   512
 IPv4 and IPv6 protocol level (pseudo-val) for nRF sockets.
 
#define SO_SILENCE_ALL   (NET_SOCKET_NCS_BASE + 30)
 sockopt: disable all replies to unexpected traffics
 
#define SO_IP_ECHO_REPLY   (NET_SOCKET_NCS_BASE + 31)
 sockopt: enable IPv4 ICMP replies
 
#define SO_IPV6_ECHO_REPLY   (NET_SOCKET_NCS_BASE + 32)
 sockopt: enable IPv6 ICMP replies
 
#define SO_IPV6_DELAYED_ADDR_REFRESH   (NET_SOCKET_NCS_BASE + 62)
 sockopt: Delay IPv6 address refresh during power saving mode

 
#define SO_TCP_SRV_SESSTIMEO   (NET_SOCKET_NCS_BASE + 55)
 sockopt: Configurable TCP server session timeout in minutes.
 
#define AI_PDNSERV   0x1000
 Assume service contains a Packet Data Network (PDN) ID.
 
#define MSG_WAITACK   0x200
 Request a blocking send operation until the request is acknowledged.
 

Typedefs

typedef void(* socket_ncs_sendcb_t) (const struct socket_ncs_sendcb_params *params)
 Callback type in the socket_ncs_sendcb structure.
 
typedef void(* socket_ncs_pollcb_t) (const struct socket_ncs_pollcb_params *params)
 Callback type in the socket_ncs_pollcb structure.
 

Detailed Description

NCS specific additions to the BSD sockets API definitions.

Macro Definition Documentation

◆ AI_PDNSERV

#define AI_PDNSERV   0x1000

Assume service contains a Packet Data Network (PDN) ID.

When specified together with the AI_NUMERICSERV flag, service shall be formatted as follows: "port:pdn_id" where "port" is the port number and "pdn_id" is the PDN ID. Example: "8080:1", port 8080 PDN ID 1. Example: "42:0", port 42 PDN ID 0.

◆ DTLS_FRAG_EXT_1024_ENABLED

#define DTLS_FRAG_EXT_1024_ENABLED   2

Enabled - The DTLS fragmentation extension is included in the Client Hello with the fragment size of 1024 bytes.

Note
The user data size in send requests also becomes limited to a maximum of 1024 bytes.

◆ DTLS_FRAG_EXT_512_ENABLED

#define DTLS_FRAG_EXT_512_ENABLED   1

Enabled - The DTLS fragmentation extension is included in the Client Hello with the fragment size of 512 bytes.

Note
The user data size in send requests also becomes limited to a maximum of 512 bytes.

◆ DTLS_FRAG_EXT_DISABLED

#define DTLS_FRAG_EXT_DISABLED   0

Disabled - The DTLS fragmentation extension is not included in the Client Hello.

◆ IPPROTO_ALL

#define IPPROTO_ALL   512

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

◆ MSG_WAITACK

#define MSG_WAITACK   0x200

Request a blocking send operation until the request is acknowledged.

When used in send() or sendto(), the request will not return until the send operation is completed by lower layers, or until the timeout, given by the SO_SNDTIMEO socket option, is reached. Valid timeout values are 1 to 600 seconds.

◆ NET_SOCKET_NCS_BASE

#define NET_SOCKET_NCS_BASE   1000

Define a base for NCS specific socket options to prevent overlaps with Zephyr's socket options.

◆ RAI_LAST

#define RAI_LAST   2

Release assistance indication (RAI).

Indicate that the application does not intend to send more data after the next call to send() or sendto(). This lets the modem exit connected mode more quickly after sending the data.

◆ RAI_NO_DATA

#define RAI_NO_DATA   1

Release assistance indication (RAI).

Indicate that the application does not intend to send more data. This applies immediately and lets the modem exit connected mode more quickly.

Note
This requires the socket to be connected.

◆ RAI_ONE_RESP

#define RAI_ONE_RESP   3

Release assistance indication (RAI).

Indicate that the application is expecting to receive just one data packet after the next call to send() or sendto(). This lets the modem exit connected mode more quickly after having received the data.

◆ RAI_ONGOING

#define RAI_ONGOING   4

Release assistance indication (RAI).

Indicate that the socket is in active use by a client application. This lets the modem stay in connected mode longer.

◆ RAI_WAIT_MORE

#define RAI_WAIT_MORE   5

Release assistance indication (RAI).

Indicate that the socket is in active use by a server application. This lets the modem stay in connected mode longer.

◆ SO_BINDTOPDN

#define SO_BINDTOPDN   (NET_SOCKET_NCS_BASE + 40)

sockopt: bind to PDN

◆ SO_EXCEPTIONAL_DATA

#define SO_EXCEPTIONAL_DATA   (NET_SOCKET_NCS_BASE + 33)

sockopt: enable sending data as part of exceptional events

◆ SO_IP_ECHO_REPLY

#define SO_IP_ECHO_REPLY   (NET_SOCKET_NCS_BASE + 31)

sockopt: enable IPv4 ICMP replies

◆ SO_IPV6_DELAYED_ADDR_REFRESH

#define SO_IPV6_DELAYED_ADDR_REFRESH   (NET_SOCKET_NCS_BASE + 62)

sockopt: Delay IPv6 address refresh during power saving mode

◆ SO_IPV6_ECHO_REPLY

#define SO_IPV6_ECHO_REPLY   (NET_SOCKET_NCS_BASE + 32)

sockopt: enable IPv6 ICMP replies

◆ SO_KEEPOPEN

#define SO_KEEPOPEN   (NET_SOCKET_NCS_BASE + 34)

sockopt: Keep socket open when its PDN connection is lost or the device is put into flight mode.

◆ SO_POLLCB

#define SO_POLLCB   (NET_SOCKET_NCS_BASE + 64)

sockopt: set a callback to be called upon the selected poll events.

This option takes a socket_ncs_pollcb structure.

Note
The callback is executed in an interrupt context. Take care to offload any processing as appropriate.

◆ SO_RAI

#define SO_RAI   (NET_SOCKET_NCS_BASE + 61)

sockopt: Release assistance indication (RAI).

The option accepts an integer, indicating the type of RAI. Accepted values for the option are: RAI_NO_DATA, RAI_LAST, RAI_ONE_RESP, RAI_ONGOING, RAI_WAIT_MORE.

◆ SO_SENDCB

#define SO_SENDCB   (NET_SOCKET_NCS_BASE + 63)

sockopt: set a callback to be called when a send request is acknowledged by the network and the data has been acknowledged by the peer, if required by the network protocol, or until the timeout, given by the SO_SNDTIMEO socket option, is reached.

Valid timeout values are 1 to 600 seconds. This option takes a socket_ncs_sendcb structure.

Note
The callback is executed in an interrupt context. Take care to offload any processing as appropriate.
This is only supported by the following modem firmware:
  • mfw_nrf9151-ntn

This socket option cannot be used along with the MSG_WAITACK send flag.

◆ SO_SILENCE_ALL

#define SO_SILENCE_ALL   (NET_SOCKET_NCS_BASE + 30)

sockopt: disable all replies to unexpected traffics

◆ SO_TCP_SRV_SESSTIMEO

#define SO_TCP_SRV_SESSTIMEO   (NET_SOCKET_NCS_BASE + 55)

sockopt: Configurable TCP server session timeout in minutes.

Range is 0 to 135. 0 is no timeout and 135 is 2 h 15 min. Default is 0 (no timeout).

◆ SOCK_NATIVE

#define SOCK_NATIVE   0x80000000

◆ SOCK_NATIVE_TLS

#define SOCK_NATIVE_TLS   0x40000000

◆ TLS_DTLS_CONN_LOAD

#define TLS_DTLS_CONN_LOAD   (NET_SOCKET_NCS_BASE + 20)

Socket option to load DTLS connection, specifically for nRF sockets.

◆ TLS_DTLS_CONN_SAVE

#define TLS_DTLS_CONN_SAVE   (NET_SOCKET_NCS_BASE + 19)

Socket option to save DTLS connection, specifically for nRF sockets.

◆ TLS_DTLS_FRAG_EXT

#define TLS_DTLS_FRAG_EXT   (NET_SOCKET_NCS_BASE + 22)

Socket option to enable the DTLS fragmentation extension.

Accepted values for the option are: DTLS_FRAG_EXT_DISABLED, DTLS_FRAG_EXT_512_ENABLED, DTLS_FRAG_EXT_1024_ENABLED.

◆ TLS_DTLS_HANDSHAKE_STATUS

#define TLS_DTLS_HANDSHAKE_STATUS   (NET_SOCKET_NCS_BASE + 21)

Socket option to get result of latest TLS/DTLS completed handshakes end status, specifically for nRF sockets.

The option accepts an integer, indicating the setting. Accepted vaules for the option are: 0 and 1.

◆ TLS_DTLS_HANDSHAKE_STATUS_CACHED

#define TLS_DTLS_HANDSHAKE_STATUS_CACHED   1

◆ TLS_DTLS_HANDSHAKE_STATUS_FULL

#define TLS_DTLS_HANDSHAKE_STATUS_FULL   0

◆ TLS_DTLS_HANDSHAKE_TIMEO

#define TLS_DTLS_HANDSHAKE_TIMEO   (NET_SOCKET_NCS_BASE + 18)

Socket option to set DTLS handshake timeout, specifically for nRF sockets.

The option accepts an integer, indicating the total handshake timeout, including retransmissions, in seconds. Accepted values for the option are: 1, 3, 7, 15, 31, 63, 123.

◆ TLS_DTLS_HANDSHAKE_TIMEO_123S

#define TLS_DTLS_HANDSHAKE_TIMEO_123S   123

1s + 2s + 4s + 8s + 16s + 32s + 60s

◆ TLS_DTLS_HANDSHAKE_TIMEO_15S

#define TLS_DTLS_HANDSHAKE_TIMEO_15S   15

1s + 2s + 4s + 8s

◆ TLS_DTLS_HANDSHAKE_TIMEO_1S

#define TLS_DTLS_HANDSHAKE_TIMEO_1S   1

1 second

◆ TLS_DTLS_HANDSHAKE_TIMEO_31S

#define TLS_DTLS_HANDSHAKE_TIMEO_31S   31

1s + 2s + 4s + 8s + 16s

◆ TLS_DTLS_HANDSHAKE_TIMEO_3S

#define TLS_DTLS_HANDSHAKE_TIMEO_3S   3

1s + 2s

◆ TLS_DTLS_HANDSHAKE_TIMEO_63S

#define TLS_DTLS_HANDSHAKE_TIMEO_63S   63

1s + 2s + 4s + 8s + 16s + 32s

◆ TLS_DTLS_HANDSHAKE_TIMEO_7S

#define TLS_DTLS_HANDSHAKE_TIMEO_7S   7

1s + 2s + 4s

◆ TLS_DTLS_HANDSHAKE_TIMEO_NONE

#define TLS_DTLS_HANDSHAKE_TIMEO_NONE   0

No timeout.

Typedef Documentation

◆ socket_ncs_pollcb_t

typedef void(* socket_ncs_pollcb_t) (const struct socket_ncs_pollcb_params *params)

Callback type in the socket_ncs_pollcb structure.

◆ socket_ncs_sendcb_t

typedef void(* socket_ncs_sendcb_t) (const struct socket_ncs_sendcb_params *params)

Callback type in the socket_ncs_sendcb structure.