Skip to content

Commit 99c1bcd

Browse files
committed
[nrf noup] include: net: socket_ncs: prevent overlaps
nrf-squash! [nrf noup] include: net: add NCS extensions Adds a base value for NCS specific socket options to prevent overlaps with Zephyr's socket options. Signed-off-by: Mirko Covizzi <[email protected]>
1 parent e413bef commit 99c1bcd

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

include/zephyr/net/socket_ncs.h

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,34 @@ extern "C" {
2525
#define SOCK_NATIVE 0x80000000
2626
#define SOCK_NATIVE_TLS 0x40000000
2727

28+
/** Define a base for NCS specific socket options to prevent overlaps with Zephyr's socket options.
29+
* Allocates to NCS specific socket options the signed integer range 1073741824 to INT32_MAX.
30+
*/
31+
#define NET_SOCKET_NCS_BASE 0x4000000
32+
2833
/* NCS specific TLS level socket options */
2934

3035
/** Socket option to set DTLS handshake timeout, specifically for nRF sockets.
3136
* The option accepts an integer, indicating the total handshake timeout,
3237
* including retransmissions, in seconds.
3338
* Accepted values for the option are: 1, 3, 7, 15, 31, 63, 123.
3439
*/
35-
#define TLS_DTLS_HANDSHAKE_TIMEO 18
40+
#define TLS_DTLS_HANDSHAKE_TIMEO (NET_SOCKET_NCS_BASE + 18)
3641

3742
/** Socket option to save DTLS connection, specifically for nRF sockets.
3843
*/
39-
#define TLS_DTLS_CONN_SAVE 19
44+
#define TLS_DTLS_CONN_SAVE (NET_SOCKET_NCS_BASE + 19)
4045

4146
/** Socket option to load DTLS connection, specifically for nRF sockets.
4247
*/
43-
#define TLS_DTLS_CONN_LOAD 20
48+
#define TLS_DTLS_CONN_LOAD (NET_SOCKET_NCS_BASE + 20)
4449

4550
/** Socket option to get result of latest TLS/DTLS completed handshakes end status,
4651
* specifically for nRF sockets.
4752
* The option accepts an integer, indicating the setting.
4853
* Accepted vaules for the option are: 0 and 1.
4954
*/
50-
#define TLS_DTLS_HANDSHAKE_STATUS 21
55+
#define TLS_DTLS_HANDSHAKE_STATUS (NET_SOCKET_NCS_BASE + 21)
5156

5257
/* Valid values for TLS_DTLS_HANDSHAKE_TIMEO option */
5358
#define TLS_DTLS_HANDSHAKE_TIMEO_NONE 0 /**< No timeout */
@@ -66,20 +71,20 @@ extern "C" {
6671
/* NCS specific socket options */
6772

6873
/** sockopt: enable sending data as part of exceptional events */
69-
#define SO_EXCEPTIONAL_DATA 33
74+
#define SO_EXCEPTIONAL_DATA (NET_SOCKET_NCS_BASE + 33)
7075
/** sockopt: Keep socket open when its PDN connection is lost
7176
* or the device is put into flight mode.
7277
*/
73-
#define SO_KEEPOPEN 34
78+
#define SO_KEEPOPEN (NET_SOCKET_NCS_BASE + 34)
7479
/** sockopt: bind to PDN */
75-
#define SO_BINDTOPDN 40
80+
#define SO_BINDTOPDN (NET_SOCKET_NCS_BASE + 40)
7681

7782
/** sockopt: Release assistance indication (RAI).
7883
* The option accepts an integer, indicating the type of RAI.
7984
* Accepted values for the option are: @ref RAI_NO_DATA, @ref RAI_LAST, @ref RAI_ONE_RESP,
8085
* @ref RAI_ONGOING, @ref RAI_WAIT_MORE.
8186
*/
82-
#define SO_RAI 61
87+
#define SO_RAI (NET_SOCKET_NCS_BASE + 61)
8388

8489
/** Release assistance indication (RAI).
8590
* Indicate that the application does not intend to send more data.
@@ -117,27 +122,27 @@ extern "C" {
117122
/** IPv4 and IPv6 protocol level (pseudo-val) for nRF sockets. */
118123
#define IPPROTO_ALL 512
119124
/** sockopt: disable all replies to unexpected traffics */
120-
#define SO_SILENCE_ALL 30
125+
#define SO_SILENCE_ALL (NET_SOCKET_NCS_BASE + 30)
121126

122127
/* NCS specific IPPROTO_IP level socket options */
123128

124129
/** sockopt: enable IPv4 ICMP replies */
125-
#define SO_IP_ECHO_REPLY 31
130+
#define SO_IP_ECHO_REPLY (NET_SOCKET_NCS_BASE + 31)
126131

127132
/* NCS specific IPPROTO_IPV6 level socket options */
128133

129134
/** sockopt: enable IPv6 ICMP replies */
130-
#define SO_IPV6_ECHO_REPLY 32
135+
#define SO_IPV6_ECHO_REPLY (NET_SOCKET_NCS_BASE + 32)
131136

132137
/** sockopt: Delay IPv6 address refresh during power saving mode */
133-
#define SO_IPV6_DELAYED_ADDR_REFRESH 62
138+
#define SO_IPV6_DELAYED_ADDR_REFRESH (NET_SOCKET_NCS_BASE + 62)
134139

135140
/* NCS specific TCP level socket options */
136141

137142
/** sockopt: Configurable TCP server session timeout in minutes.
138143
* Range is 0 to 135. 0 is no timeout and 135 is 2 h 15 min. Default is 0 (no timeout).
139144
*/
140-
#define SO_TCP_SRV_SESSTIMEO 55
145+
#define SO_TCP_SRV_SESSTIMEO (NET_SOCKET_NCS_BASE + 55)
141146

142147
/* NCS specific gettaddrinfo() flags */
143148

0 commit comments

Comments
 (0)