1# BSD Sockets compatible API 2 3# Copyright (c) 2017 Linaro Limited. 4# SPDX-License-Identifier: Apache-2.0 5 6menuconfig NET_SOCKETS 7 bool "BSD Sockets compatible API" 8 select FDTABLE 9 help 10 Provide BSD Sockets like API on top of native Zephyr networking API. 11 12if NET_SOCKETS 13 14config NET_SOCKETS_PRIORITY_DEFAULT 15 int "Default processing priority for sockets" 16 default 50 17 help 18 Default processing priority for socket implementations. This defines 19 the order of processing of particular socket implementations when 20 creating a new socket, lower value indicate earlier processing. This 21 allows to for instance prioritize offloaded socket processing during 22 socket creation over the native one, or vice versa. 23 24config NET_SOCKETS_POSIX_NAMES 25 bool "POSIX names for Sockets API (without full POSIX API)" 26 default y if !POSIX_API 27 depends on !POSIX_API 28 help 29 With this option, Socket API functions are available under the 30 standard POSIX names like socket(), recv(), and close(), etc., 31 even if full POSIX API (CONFIG_POSIX_API) is not enabled. (Note 32 that close() may require a special attention, as in POSIX it 33 closes any file descriptor, while with this option enabled, it 34 will apply only to sockets.) 35 36 Various networking libraries require either 37 CONFIG_NET_SOCKETS_POSIX_NAMES or CONFIG_POSIX_API to be set. 38 If both are disabled, Zephyr's socket functions will be 39 available (only) with ``zsock_`` prefix, (e.g. `zsock_socket`). 40 This is useful only in peculiar cases, e.g. when integrating 41 with 3rd-party socket libraries. 42 43config NET_SOCKETS_POLL_MAX 44 int "Max number of supported poll() entries" 45 default 3 46 help 47 Maximum number of entries supported for poll() call. 48 49config NET_SOCKETS_CONNECT_TIMEOUT 50 int "Timeout value in milliseconds to CONNECT" 51 default 3000 52 range 0 60000 53 help 54 This variable specifies time in milliseconds after connect() 55 API call will timeout if we have not received SYN-ACK from 56 peer. 57 58config NET_SOCKETS_DNS_TIMEOUT 59 int "Timeout value in milliseconds for DNS queries" 60 default 2000 61 range 1000 300000 62 depends on DNS_RESOLVER 63 help 64 This variable specifies time in milliseconds after which DNS 65 query is considered timeout. Minimum timeout is 1 second and 66 maximum timeout is 5 min. 67 68config NET_SOCKET_MAX_SEND_WAIT 69 int "Max time in milliseconds waiting for a send command" 70 default 10000 71 help 72 The maximum time a socket is waiting for a blocked connection before 73 returning an ENOBUFS error. 74 75config NET_SOCKETS_SOCKOPT_TLS 76 bool "TCP TLS socket option support [EXPERIMENTAL]" 77 imply TLS_CREDENTIALS 78 select MBEDTLS if NET_NATIVE 79 select EXPERIMENTAL 80 help 81 Enable TLS socket option support which automatically establishes 82 a TLS connection to the remote host. 83 84config NET_SOCKETS_TLS_PRIORITY 85 int "Default processing priority for TLS sockets" 86 default 45 87 help 88 Processing priority for TLS sockets. Should be lower than 89 NET_SOCKETS_PRIORITY_DEFAULT in order to be processed correctly. 90 91config NET_SOCKETS_TLS_SET_MAX_FRAGMENT_LENGTH 92 bool "Set Maximum Fragment Length (MFL)" 93 default y 94 help 95 Call mbedtls_ssl_conf_max_frag_len() on created TLS context 96 configuration, so that Maximum Fragment Length (MFL) will be sent to 97 peer using RFC 6066 max_fragment_length extension. 98 99 Maximum Fragment Length (MFL) value is automatically chosen based on 100 MBEDTLS_SSL_OUT_CONTENT_LEN and MBEDTLS_SSL_IN_CONTENT_LEN mbed TLS 101 macros (which are configured by CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN in 102 case of default mbed TLS config). 103 104 This is mostly useful for TLS client side to tell TLS server what is 105 the maximum supported receive record length. 106 107config NET_SOCKETS_ENABLE_DTLS 108 bool "DTLS socket support [EXPERIMENTAL]" 109 depends on NET_SOCKETS_SOCKOPT_TLS 110 select MBEDTLS_DTLS if NET_NATIVE 111 select EXPERIMENTAL 112 help 113 Enable DTLS socket support. By default only TLS over TCP is supported. 114 115config NET_SOCKETS_DTLS_TIMEOUT 116 int "Timeout value in milliseconds for DTLS connection" 117 default 5000 118 depends on NET_SOCKETS_ENABLE_DTLS 119 help 120 This variable specifies time in milliseconds after which DTLS 121 connection is considered dead by TLS server and DTLS resources are 122 freed. This is needed to prevent situation when DTLS client shuts down 123 without closing connection gracefully, which can prevent other peers 124 from connecting. Value of 0 indicates no timeout - resources will be 125 freed only when connection is gracefully closed by peer sending TLS 126 notification or socket is closed. 127 128config NET_SOCKETS_TLS_MAX_CONTEXTS 129 int "Maximum number of TLS/DTLS contexts" 130 default 1 131 depends on NET_SOCKETS_SOCKOPT_TLS 132 help 133 "This variable specifies maximum number of TLS/DTLS contexts that can 134 be allocated at the same time." 135 136config NET_SOCKETS_TLS_MAX_CREDENTIALS 137 int "Maximum number of TLS/DTLS credentials per socket" 138 default 4 139 depends on NET_SOCKETS_SOCKOPT_TLS 140 help 141 This variable sets maximum number of TLS/DTLS credentials that can be 142 used with a specific socket. 143 144config NET_SOCKETS_TLS_MAX_CIPHERSUITES 145 int "Maximum number of TLS/DTLS ciphersuites per socket" 146 default 4 147 depends on NET_SOCKETS_SOCKOPT_TLS 148 help 149 This variable sets maximum number of TLS/DTLS ciphersuites that can 150 be used with specific socket, if set explicitly by socket option. 151 By default, all ciphersuites that are available in the system are 152 available to the socket. 153 154config NET_SOCKETS_TLS_MAX_APP_PROTOCOLS 155 int "Maximum number of supported application layer protocols" 156 default 2 157 depends on NET_SOCKETS_SOCKOPT_TLS && MBEDTLS_SSL_ALPN 158 help 159 This variable sets maximum number of supported application layer 160 protocols over TLS/DTLS that can be set explicitly by a socket option. 161 By default, no supported application layer protocol is set. 162 163config NET_SOCKETS_TLS_MAX_CLIENT_SESSION_COUNT 164 int "Maximum number of stored client TLS/DTLS sessions" 165 default 1 166 depends on NET_SOCKETS_SOCKOPT_TLS 167 help 168 This variable specifies maximum number of stored TLS/DTLS sessions, 169 used for TLS/DTLS session resumption. 170 171config NET_SOCKETS_OFFLOAD 172 bool "Offload Socket APIs" 173 help 174 Enables direct offloading of socket operations to dedicated TCP/IP 175 hardware. 176 This feature is intended to save resources by bypassing the Zephyr 177 TCP/IP stack in the case where there is only one network interface 178 required in the system, providing full BSD socket offload capability. 179 As a result, it bypasses any potential IP routing that Zephyr might 180 provide between multiple network interfaces. 181 See NET_OFFLOAD for a more deeply integrated approach which offloads 182 from the net_context() API within the Zephyr IP stack. 183 184config NET_SOCKETS_OFFLOAD_PRIORITY 185 int "Default processing priority for offloaded sockets" 186 default 40 187 help 188 Processing priority for offloaded sockets. 189 190 If native TLS is enabled, lower value than NET_SOCKETS_TLS_PRIORITY 191 means that TLS will be offloaded as well (if supported by offloaded 192 socket implementation). Higher value than NET_SOCKETS_TLS_PRIORITY 193 means that native TLS will be used. 194 195config NET_SOCKETS_OFFLOAD_DISPATCHER 196 bool "Intermediate socket offloading layer" 197 depends on NET_SOCKETS_OFFLOAD 198 help 199 If enabled, an intermediate socket offloading layer is included 200 (called socket dispatcher), allowing to select an offloaded network 201 interface and thus socket implementation with SO_BINDTODEVICE socket 202 option. This can be useful, when multiple offloaded sockets 203 implementations are available in the system, allowing to easily bind 204 a socket to a particular implementation. 205 206config NET_SOCKETS_OFFLOAD_DISPATCHER_CONTEXT_MAX 207 int "Maximum number of dispatcher sockets created" 208 default 4 209 depends on NET_SOCKETS_OFFLOAD_DISPATCHER 210 help 211 Maximum number of dispatcher sockets created at a time. Note, that 212 only sockets that has not been dispatched yet count into the limit. 213 After a proper socket has been created for a given file descriptor, 214 the dispatcher context is released and can be reused. 215 216config NET_SOCKETS_PACKET 217 bool "Packet socket support" 218 select NET_CONNECTION_SOCKETS 219 help 220 This is an initial version of packet socket support (special type 221 raw socket). Packets are passed to and from the device driver 222 without any changes in the packet headers. It's API caller 223 responsibility to provide all the headers (e.g L2, L3 and so on) 224 while sending. While receiving, packets (including all the headers) 225 will be fed to sockets unchanged as provided by the driver. 226 227config NET_SOCKETS_PACKET_DGRAM 228 bool "Packet socket SOCK_DGRAM support" 229 depends on NET_SOCKETS_PACKET 230 default y 231 help 232 For AF_PACKET sockets with SOCK_DGRAM type, the L2 header 233 is removed before the packet is passed to the user. Packets sent 234 through a SOCK_DGRAM packet socket get a suitable L2 header based 235 on the information in the sockaddr_ll destination address before 236 they are queued. 237 238config NET_SOCKETS_CAN 239 bool "Socket CAN support [EXPERIMENTAL]" 240 select NET_L2_CANBUS_RAW 241 select NET_CONNECTION_SOCKETS 242 select EXPERIMENTAL 243 help 244 The value depends on your network needs. 245 246config NET_SOCKETS_CAN_RECEIVERS 247 int "How many simultaneous SocketCAN receivers are allowed" 248 default 1 249 depends on NET_SOCKETS_CAN 250 help 251 The value tells how many sockets can receive data from same 252 Socket-CAN interface. 253 254config NET_SOCKETPAIR 255 bool "Support for socketpair" 256 select PIPES 257 help 258 Communicate over a pair of connected, unnamed UNIX domain sockets. 259 260if NET_SOCKETPAIR 261 262config NET_SOCKETPAIR_BUFFER_SIZE 263 int "Size of the intermediate buffer, in bytes" 264 default 64 265 range 1 4096 266 help 267 Buffer size for socketpair(2) 268 269choice 270 prompt "Memory management for socketpair" 271 default NET_SOCKETPAIR_HEAP if HEAP_MEM_POOL_SIZE != 0 272 273config NET_SOCKETPAIR_STATIC 274 bool "Pre-allocate memory statically" 275 276config NET_SOCKETPAIR_HEAP 277 bool "Use heap for allocating socketpairs" 278 depends on HEAP_MEM_POOL_SIZE != 0 279 280endchoice 281 282if NET_SOCKETPAIR_STATIC 283config NET_SOCKETPAIR_MAX 284 int "How many socketpairs to pre-allocate" 285 default 1 286endif 287endif 288 289config NET_SOCKETS_NET_MGMT 290 bool "Network management socket support [EXPERIMENTAL]" 291 depends on NET_MGMT_EVENT 292 select NET_MGMT_EVENT_INFO 293 select EXPERIMENTAL 294 help 295 Select this if you want to use socket API to get network 296 managements events to your application. 297 298config NET_SOCKETS_NET_MGMT_MAX_LISTENERS 299 int "Max number of sockets to listen" 300 default 1 301 depends on NET_SOCKETS_NET_MGMT 302 help 303 This sets the maximum number of net_mgmt sockets that can 304 be set by the socket interface. So if you have two separate 305 sockets that are used for listening events, you need to set 306 this to two. 307 308module = NET_SOCKETS 309module-dep = NET_LOG 310module-str = Log level for BSD sockets compatible API calls 311module-help = Enables logging for sockets code. 312source "subsys/net/Kconfig.template.log_config.net" 313 314endif # NET_SOCKETS 315