1 /**
2  * Copyright (c) 2024 Marcin Niestroj
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef __DRIVERS_NET_NSOS_SOCKET_H__
8 #define __DRIVERS_NET_NSOS_SOCKET_H__
9 
10 #include <stdint.h>
11 
12 /**
13  * @name Socket level options (NSOS_MID_SOL_SOCKET)
14  * @{
15  */
16 /** Socket-level option */
17 #define NSOS_MID_SOL_SOCKET 1
18 
19 /* Socket options for NSOS_MID_SOL_SOCKET level */
20 
21 /** Recording debugging information (ignored, for compatibility) */
22 #define NSOS_MID_SO_DEBUG 1
23 /** address reuse */
24 #define NSOS_MID_SO_REUSEADDR 2
25 /** Type of the socket */
26 #define NSOS_MID_SO_TYPE 3
27 /** Async error */
28 #define NSOS_MID_SO_ERROR 4
29 /** Bypass normal routing and send directly to host (ignored, for compatibility) */
30 #define NSOS_MID_SO_DONTROUTE 5
31 /** Transmission of broadcast messages is supported (ignored, for compatibility) */
32 #define NSOS_MID_SO_BROADCAST 6
33 
34 /** Size of socket send buffer */
35 #define NSOS_MID_SO_SNDBUF 7
36 /** Size of socket recv buffer */
37 #define NSOS_MID_SO_RCVBUF 8
38 
39 /** Enable sending keep-alive messages on connections */
40 #define NSOS_MID_SO_KEEPALIVE 9
41 /** Place out-of-band data into receive stream (ignored, for compatibility) */
42 #define NSOS_MID_SO_OOBINLINE 10
43 /** Socket priority */
44 #define NSOS_MID_SO_PRIORITY 12
45 /** Socket lingers on close (ignored, for compatibility) */
46 #define NSOS_MID_SO_LINGER 13
47 /** Allow multiple sockets to reuse a single port */
48 #define NSOS_MID_SO_REUSEPORT 15
49 
50 /** Receive low watermark (ignored, for compatibility) */
51 #define NSOS_MID_SO_RCVLOWAT 18
52 /** Send low watermark (ignored, for compatibility) */
53 #define NSOS_MID_SO_SNDLOWAT 19
54 
55 /**
56  * Receive timeout
57  * Applies to receive functions like recv(), but not to connect()
58  */
59 #define NSOS_MID_SO_RCVTIMEO 20
60 /** Send timeout */
61 #define NSOS_MID_SO_SNDTIMEO 21
62 
63 /** Bind a socket to an interface */
64 #define NSOS_MID_SO_BINDTODEVICE	25
65 
66 /** Socket accepts incoming connections (ignored, for compatibility) */
67 #define NSOS_MID_SO_ACCEPTCONN 30
68 
69 /** Timestamp TX packets */
70 #define NSOS_MID_SO_TIMESTAMPING 37
71 /** Protocol used with the socket */
72 #define NSOS_MID_SO_PROTOCOL 38
73 
74 /** Domain used with SOCKET */
75 #define NSOS_MID_SO_DOMAIN 39
76 
77 /** Enable SOCKS5 for Socket */
78 #define NSOS_MID_SO_SOCKS5 60
79 
80 /** Socket TX time (when the data should be sent) */
81 #define NSOS_MID_SO_TXTIME 61
82 
83 struct nsos_mid_timeval {
84 	int64_t tv_sec;
85 	int64_t tv_usec;
86 };
87 
88 /** @} */
89 
90 /**
91  * @name TCP level options (NSOS_MID_IPPROTO_TCP)
92  * @{
93  */
94 /* Socket options for NSOS_MID_IPPROTO_TCP level */
95 /** Disable TCP buffering (ignored, for compatibility) */
96 #define NSOS_MID_TCP_NODELAY 1
97 /** Start keepalives after this period (seconds) */
98 #define NSOS_MID_TCP_KEEPIDLE 2
99 /** Interval between keepalives (seconds) */
100 #define NSOS_MID_TCP_KEEPINTVL 3
101 /** Number of keepalives before dropping connection */
102 #define NSOS_MID_TCP_KEEPCNT 4
103 
104 /** @} */
105 
106 /**
107  * @name IPv6 level options (NSOS_MID_IPPROTO_IPV6)
108  * @{
109  */
110 /* Socket options for NSOS_MID_IPPROTO_IPV6 level */
111 /** Set the unicast hop limit for the socket. */
112 #define NSOS_MID_IPV6_UNICAST_HOPS	16
113 
114 /** Set the multicast hop limit for the socket. */
115 #define NSOS_MID_IPV6_MULTICAST_HOPS 18
116 
117 /** Join IPv6 multicast group. */
118 #define NSOS_MID_IPV6_ADD_MEMBERSHIP 20
119 
120 /** Leave IPv6 multicast group. */
121 #define NSOS_MID_IPV6_DROP_MEMBERSHIP 21
122 
123 /** Don't support IPv4 access */
124 #define NSOS_MID_IPV6_V6ONLY 26
125 
126 /** Pass an IPV6_RECVPKTINFO ancillary message that contains a
127  *  in6_pktinfo structure that supplies some information about the
128  *  incoming packet. See RFC 3542.
129  */
130 #define NSOS_MID_IPV6_RECVPKTINFO 49
131 
132 /** @} */
133 
134 #endif /* __DRIVERS_NET_NSOS_SOCKET_H__ */
135