1 /*
2  * Copyright (c) 2017-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33  /*!
34 
35 
36   \page SlNetSock_overview SlNetSock
37 
38   \section intro_sec Introduction
39 
40 SlNetSock provides a standard BSD API for TCP and UDP transport
41 layers, and a lower-level SlNetSock API for basic and extended
42 usage. Supported use cases include:
43 
44  - Support of multi interface (WiFi NS, Ethernet NDK)
45  - Selecting which interfaces the host will use, one or more.
46  - Support of different types of sockets (TCP, TLS, UDP, RAW, RF, etc.)
47  - BSD and proprietary errors
48 
49  The SlNetSock API's lead to easier portability to microcontrollers,
50  without compromising the capabilities and robustness of the final
51  application.
52 
53 
54  \section modules_sec Module Names
55  TI's SlNetSock layer is divided into the following software modules:
56      -# \ref SlNet      - Interface for general SlNet services
57      -# \ref SlNetSock  - Controls standard client/server sockets options and capabilities
58      -# \ref SlNetIf    - Controls standard stack/interface options and capabilities
59      -# \ref SlNetUtils - Provides sockets related commands and configuration
60      -# \ref SlNetErr   - Provide BSD and proprietary errors
61 
62 In addition, SlNetSock provides a standard BSD API, built atop the
63 SlNet* APIs.  The BSD headers are placed in ti/net/bsd directory,
64 which users should place on their include path.
65 
66 Also, there is a light
67 \subpage porting_guide "SL Interface Porting Guide"
68 with information available for adding SlNetSock support for other stacks.
69 
70   \page porting_guide SL Interface Porting Guide
71 
72  \section Introduction
73 
74 The generic SlNetSock layer sits between the application/service and
75 the interface stack.  This guide describes the details of adding a network stack into the SlNetSock environment.
76 
77 The porting steps for adding new interface:
78     -# Create slnetifxxx file for the new interface
79     -# Select the capabilities set
80     -# Adding the interface to your application/service
81     -# Add the relevant functions to your application/service
82     -# Test your code to validate the correctness of your porting
83 
84   \subsection porting_step1   Step 1 - slnetifxxx.c and slnetifxxx.h file for your interface
85 
86  - Create slnetifxxx file (replace xxx with your interface/stack
87    name).  Likely you will copy from an existing port.
88 
89  - Implement the needed API's.
90 
91 Each interface needs to provide a set of API's to work with the
92 interface.  Some are mandatory, others are optional (but recommended).
93 
94  - Mandatory API's:
95   - \ref SlNetIf_Config_t.sockCreate            "sockCreate"
96   - \ref SlNetIf_Config_t.sockClose             "sockClose"
97   - \ref SlNetIf_Config_t.sockSelect            "sockSelect"
98   - \ref SlNetIf_Config_t.sockSetOpt            "sockSetOpt"
99   - \ref SlNetIf_Config_t.sockGetOpt            "sockGetOpt"
100   - \ref SlNetIf_Config_t.sockRecvFrom          "sockRecvFrom"
101   - \ref SlNetIf_Config_t.sockSendTo            "sockSendTo"
102   - \ref SlNetIf_Config_t.ifGetIPAddr           "ifGetIPAddr"
103   - \ref SlNetIf_Config_t.ifGetConnectionStatus "ifGetConnectionStatus"
104 
105  - The non-mandatory API's set:
106   - \ref SlNetIf_Config_t.sockShutdown          "sockShutdown"
107   - \ref SlNetIf_Config_t.sockAccept            "sockAccept"
108   - \ref SlNetIf_Config_t.sockBind              "sockBind"
109   - \ref SlNetIf_Config_t.sockListen            "sockListen"
110   - \ref SlNetIf_Config_t.sockConnect           "sockConnect"
111   - \ref SlNetIf_Config_t.sockGetPeerName       "sockGetPeerName"
112   - \ref SlNetIf_Config_t.sockGetLocalName      "sockGetLocalName"
113   - \ref SlNetIf_Config_t.sockRecv              "sockRecv"
114   - \ref SlNetIf_Config_t.sockSend              "sockSend"
115   - \ref SlNetIf_Config_t.sockstartSec          "sockstartSec"
116   - \ref SlNetIf_Config_t.utilGetHostByName     "utilGetHostByName"
117   - \ref SlNetIf_Config_t.ifLoadSecObj          "ifLoadSecOjb"
118   - \ref SlNetIf_Config_t.ifCreateContext       "ifCreateContext"
119 
120 
121   \note The list of API's and more data can be found in ::SlNetIf_Config_t structure in SlNetIf module \n \n
122 
123  \subsection    porting_step2   Step 2 - Select the capabilities set
124 
125  The capabilities prototype should be declared in your slnetifxxx.h and implemented in your slnetifxxx.c
126 
127  Each mandatory API's must be set, additional API's can be set or must
128  be set to NULL.
129 
130  An example config declaration for TI's SimpleLink CC31XX/CC32xx
131 
132  \code
133  SlNetIfConfig SlNetIfConfigWiFi =
134  {
135     SlNetIfWifi_socket,              // Callback function sockCreate in slnetif module
136     SlNetIfWifi_close,               // Callback function sockClose in slnetif module
137     NULL,                            // Callback function sockShutdown in slnetif module
138     SlNetIfWifi_accept,              // Callback function sockAccept in slnetif module
139     SlNetIfWifi_bind,                // Callback function sockBind in slnetif module
140     SlNetIfWifi_listen,              // Callback function sockListen in slnetif module
141     SlNetIfWifi_connect,             // Callback function sockConnect in slnetif module
142     NULL,                            // Callback function sockGetPeerName in slnetif module
143     NULL,                            // Callback function sockGetLocalName in slnetif module
144     SlNetIfWifi_select,              // Callback function sockSelect in slnetif module
145     SlNetIfWifi_setSockOpt,          // Callback function sockSetOpt in slnetif module
146     SlNetIfWifi_getSockOpt,          // Callback function sockGetOpt in slnetif module
147     SlNetIfWifi_recv,                // Callback function sockRecv in slnetif module
148     SlNetIfWifi_recvFrom,            // Callback function sockRecvFrom in slnetif module
149     SlNetIfWifi_send,                // Callback function sockSend in slnetif module
150     SlNetIfWifi_sendTo,              // Callback function sockSendTo in slnetif module
151     SlNetIfWifi_sockstartSec,        // Callback function sockstartSec in slnetif module
152     SlNetIfWifi_getHostByName,       // Callback function utilGetHostByName in slnetif module
153     SlNetIfWifi_getIPAddr,           // Callback function ifGetIPAddr in slnetif module
154     SlNetIfWifi_getConnectionStatus, // Callback function ifGetConnectionStatus in slnetif module
155     SlNetIfWifi_loadSecObj,          // Callback function ifLoadSecObj in slnetif module
156     NULL                             // Callback function ifCreateContext in slnetif module
157  };
158  \endcode
159 
160  In the example above the following API's are not supported by the interface,
161  and are set to NULL:
162  - sockShutdown
163  - sockGetPeerName
164  - sockGetLocalName
165  - utilGetHostByName
166  - ifCreateContext
167 
168  \subsection    porting_step3   Step 3 - Adding the interface to your application/service
169 
170  \b Include the new file in the board header file in the application.
171 
172  \subsection    porting_step4   Step 4 - Add the relevant functions to your application/service
173 
174   After configuring the capabilities of the interface, Adding the interface to the SlNetSock
175   is required.
176 
177   Use ::SlNetIf_add in order to add the interface and set his ID, Name, function list and priority.
178   Later on you need to use the BSD API's or SlNetSock API's for socket handling.
179 
180  \subsection    porting_step5   Step 5 - Test your code to validate the correctness of your porting
181 
182  After porting the layer into your setup, validate that your code work as expected
183 
184 */
185 
186 /*****************************************************************************/
187 /* Include files                                                             */
188 /*****************************************************************************/
189 
190 #ifndef __SL_NET_SOCK_H__
191 #define __SL_NET_SOCK_H__
192 
193 #include <stdint.h>
194 /*
195  * Commented out to prevent zsock_timeval from being redefined
196  * Can remove this if support for CONFIG_NET_SOCKETS_POSIX_NAMES
197  * is dropped someday
198  */
199 #ifndef CONFIG_NET_SOCKETS_POSIX_NAMES
200 #include <sys/time.h>
201 #endif
202 
203 #ifdef    __cplusplus
204 extern "C" {
205 #endif
206 
207 
208 /*!
209     \defgroup SlNetSock SlNetSock group
210 
211     \short Controls standard client/server sockets options and capabilities
212 
213 */
214 /*!
215 
216     \addtogroup SlNetSock
217     @{
218 
219 */
220 
221 /*****************************************************************************/
222 /* Macro declarations                                                        */
223 /*****************************************************************************/
224 
225 #define SLNETSOCK_MAX_CONCURRENT_SOCKETS                                    (32)  /**< Declares the maximum sockets that can be opened */
226 
227 /* Address families.  */
228 #define SLNETSOCK_AF_UNSPEC                                                 (0)   /**< Unspecified address family      */
229 #define SLNETSOCK_AF_INET                                                   (2)   /**< IPv4 socket (UDP, TCP, etc)     */
230 #define SLNETSOCK_AF_INET6                                                  (3)   /**< IPv6 socket (UDP, TCP, etc)     */
231 #define SLNETSOCK_AF_RF                                                     (6)   /**< Data include RF parameter, All layer by user (Wifi could be disconnected) */
232 #define SLNETSOCK_AF_PACKET                                                 (17)  /**< Network bypass                  */
233 
234 /* Protocol families, same as address families. */
235 #define SLNETSOCK_PF_UNSPEC                                                 SLNETSOCK_AF_UNSPEC
236 #define SLNETSOCK_PF_INET                                                   SLNETSOCK_AF_INET
237 #define SLNETSOCK_PF_INET6                                                  SLNETSOCK_AF_INET6
238 
239 /* Define argument types specifies the socket type.  */
240 #define SLNETSOCK_SOCK_STREAM                                               (1)   /**< TCP Socket                      */
241 #define SLNETSOCK_SOCK_DGRAM                                                (2)   /**< UDP Socket                      */
242 #define SLNETSOCK_SOCK_RAW                                                  (3)   /**< Raw socket                      */
243 #define SLNETSOCK_SOCK_RX_MTR                                               (4)   /**< RX Metrics socket               */
244 #define SLNETSOCK_SOCK_MAC_WITH_CCA                                         (5)
245 #define SLNETSOCK_SOCK_MAC_WITH_NO_CCA                                      (6)
246 #define SLNETSOCK_SOCK_BRIDGE                                               (7)
247 #define SLNETSOCK_SOCK_ROUTER                                               (8)
248 
249 /* Define some BSD protocol constants.  */
250 #define SLNETSOCK_PROTO_TCP                                                 (6)   /**< TCP Raw Socket                  */
251 #define SLNETSOCK_PROTO_UDP                                                 (17)  /**< UDP Raw Socket                  */
252 #define SLNETSOCK_PROTO_RAW                                                 (255) /**< Raw Socket                      */
253 #define SLNETSOCK_PROTO_SECURE                                              (100) /**< Secured Socket Layer (SSL,TLS)  */
254 
255 /* bind any addresses */
256 #define SLNETSOCK_INADDR_ANY                                                (0)
257 #define SLNETSOCK_IN6ADDR_ANY                                               (0)
258 
259 
260 /* socket options */
261 
262 /* possible values for the level parameter in slNetSock_setOpt / slNetSock_getOpt */
263 #define SLNETSOCK_LVL_SOCKET                                                (1)   /**< Define the socket option category. */
264 #define SLNETSOCK_LVL_IP                                                    (2)   /**< Define the IP option category.     */
265 #define SLNETSOCK_LVL_PHY                                                   (3)   /**< Define the PHY option category.    */
266 
267 /* possible values for the option parameter in slNetSock_setOpt / slNetSock_getOpt */
268 
269 /* socket level options (SLNETSOCK_LVL_SOCKET) */
270 #define SLNETSOCK_OPSOCK_RCV_BUF                                            (8)   /**< Setting TCP receive buffer size (window size) - This options takes SlNetSock_Winsize_t struct as parameter                 */
271 #define SLNETSOCK_OPSOCK_SND_BUF                                            (202) /**< Sets or gets the maximum socket send buffer in bytes. - This option takes an int as a parameter                            */
272 #define SLNETSOCK_OPSOCK_RCV_TIMEO                                          (20)  /**< Enable receive timeout - This options takes SlNetSock_Timeval_t struct as parameter                                        */
273 #define SLNETSOCK_OPSOCK_SND_TIMEO                                          (21)  /**< Enable send timeout - This options takes SlNetSock_Timeval_t struct as parameter                                           */
274 #define SLNETSOCK_OPSOCK_KEEPALIVE                                          (9)   /**< Connections are kept alive with periodic messages - This options takes SlNetSock_Keepalive_t struct as parameter           */
275 #define SLNETSOCK_OPSOCK_KEEPALIVE_TIME                                     (37)  /**< keepalive time out - This options takes <b>uint32_t</b> as parameter                                                       */
276 #define SLNETSOCK_OPSOCK_LINGER                                             (13)  /**< Socket lingers on close pending remaining send/receive packets - This options takes SlNetSock_linger_t struct as parameter */
277 #define SLNETSOCK_OPSOCK_NON_BLOCKING                                       (24)  /**< Enable/disable nonblocking mode - This options takes SlNetSock_Nonblocking_t struct as parameter                           */
278 #define SLNETSOCK_OPSOCK_NON_IP_BOUNDARY                                    (39)  /**< connectionless socket disable rx boundary - This options takes SlNetSock_NonIpBoundary_t struct as parameter               */
279 #define SLNETSOCK_OPSOCK_ERROR                                              (58)  /**< Socket level error code                                                                                                    */
280 #define SLNETSOCK_OPSOCK_SLNETSOCKSD                                        (59)  /**< Used by the BSD layer in order to retrieve the slnetsock sd                                                                */
281 #define SLNETSOCK_OPSOCK_BROADCAST                                          (200) /**< Enable/disable broadcast signals - This option takes SlNetSock_Broadcast_t struct as parameters                            */
282 #define SLNETSOCK_OPSOCK_REUSEADDR                                          (201) /**< Enable/disable allowing reuse of local addresses for bind calls - This option takes an int as a parameter                  */
283 #define SLNETSOCK_OPSOCK_REUSEPORT                                          (203) /**< Enable/disable multiple sockets to be bound to an identical socket address. - This option takes an int as a parameter      */
284 
285 /* IP level options (SLNETSOCK_LVL_IP) */
286 #define SLNETSOCK_OPIP_MULTICAST_TTL                                        (61)  /**< Specify the TTL value to use for outgoing multicast packet. - This options takes <b>uint8_t</b> as parameter                                                      */
287 #define SLNETSOCK_OPIP_ADD_MEMBERSHIP                                       (65)  /**< Join IPv4 multicast membership - This options takes SlNetSock_IpMreq_t struct as parameter                                                                        */
288 #define SLNETSOCK_OPIP_DROP_MEMBERSHIP                                      (66)  /**< Leave IPv4 multicast membership - This options takes SlNetSock_IpMreq_t struct as parameter                                                                       */
289 #define SLNETSOCK_OPIP_HDRINCL                                              (67)  /**< Raw socket IPv4 header included - This options takes <b>uint32_t</b> as parameter                                                                                 */
290 #define SLNETSOCK_OPIP_RAW_RX_NO_HEADER                                     (68)  /**< Proprietary socket option that does not includeIPv4/IPv6 header (and extension headers) on received raw sockets - This options takes <b>uint32_t</b> as parameter */
291 #define SLNETSOCK_OPIP_RAW_IPV6_HDRINCL                                     (69)  /**< Transmitted buffer over IPv6 socket contains IPv6 header - This options takes <b>uint32_t</b> as parameter                                                        */
292 #define SLNETSOCK_OPIPV6_ADD_MEMBERSHIP                                     (70)  /**< Join IPv6 multicast membership - This options takes SlNetSock_IpV6Mreq_t struct as parameter                                                                      */
293 #define SLNETSOCK_OPIPV6_DROP_MEMBERSHIP                                    (71)  /**< Leave IPv6 multicast membership - This options takes SlNetSock_IpV6Mreq_t struct as parameter                                                                     */
294 #define SLNETSOCK_OPIPV6_MULTICAST_HOPS                                     (72)  /**< Specify the hops value to use for outgoing multicast packet.                                                                                                      */
295 
296 /* PHY level options (SLNETSOCK_LVL_PHY) */
297 #define SLNETSOCK_OPPHY_CHANNEL                                             (28)  /**< This option is available only when transceiver started - This options takes <b>uint32_t</b> as channel number parameter            */
298 #define SLNETSOCK_OPPHY_RATE                                                (100) /**< WLAN Transmit rate - This options takes <b>uint32_t</b> as parameter based on SlWlanRateIndex_e                                    */
299 #define SLNETSOCK_OPPHY_TX_POWER                                            (101) /**< TX Power level - This options takes <b>uint32_t</b> as parameter                                                                   */
300 #define SLNETSOCK_OPPHY_NUM_FRAMES_TO_TX                                    (102) /**< Number of frames to transmit - This options takes <b>uint32_t</b> as parameter                                                     */
301 #define SLNETSOCK_OPPHY_PREAMBLE                                            (103) /**< Preamble for transmission - This options takes <b>uint32_t</b> as parameter                                                        */
302 #define SLNETSOCK_OPPHY_TX_INHIBIT_THRESHOLD                                (104) /**< TX Inhibit Threshold (CCA) - This options takes <b>uint32_t</b> as parameter based on SlNetSockTxInhibitThreshold_e                */
303 #define SLNETSOCK_OPPHY_TX_TIMEOUT                                          (105) /**< TX timeout for Transceiver frames (lifetime) in miliseconds (max value is 100ms) - This options takes <b>uint32_t</b> as parameter */
304 #define SLNETSOCK_OPPHY_ALLOW_ACKS                                          (106) /**< Enable sending ACKs in transceiver mode - This options takes <b>uint32_t</b> as parameter                                          */
305 
306 /* TCP level options (SLNETSOCK_PROTO_TCP) */
307 #define SLNETSOCK_TCP_NODELAY                                               (203) /**< Disables TCP send delay/coalesce algorithm - This option takes SLNetSock_NoDelay_t struct as a parameter                                                 */
308 #define SLNETSOCK_TCP_MAXSEG                                                (204) /**< Set the maximum TCP segment size - This option takes SLNetSock_MaxSeg_t struct as a parameter                                                            */
309 #define SLNETSOCK_TCP_NOPUSH                                                (205) /**< Do not send data just to finish a data block (attempt to coalesce). - This option takes SLNetSock_NoPush_t struct as a parameter                         */
310 #define SLNETSOCK_TCP_NOOPT                                                 (206) /**< Do not use TCP options. - This option takes SLNetSock_NoOpt_t struct as a parameter                                                                      */
311 #define SLNETSOCK_TCP_SACKPERMITTED                                         (207) /**< Permit RFC-2018 Selective Acknowledgment(SACK) conformant connection - This option takes SLNetSock_SackPermitted_t struct as a parameter                 */
312 #define SLNETSOCK_TCP_MAXRTT                                                (208) /**< The maximum TCP Round Trip Time value allowed in the determination of the estimated TCP RTT - This option takes SLNetSock_MaxRtt_t struct as a parameter */
313 
314 /*!
315     \brief The SlNetSockTxInhibitThreshold_e enumerations is used in SLNETSOCK_OPPHY_TX_INHIBIT_THRESHOLD PHY level option
316 */
317 typedef enum
318 {
319     SLNETSOCK_TX_INHIBIT_THRESHOLD_MIN     = 1,
320     SLNETSOCK_TX_INHIBIT_THRESHOLD_LOW     = 2,
321     SLNETSOCK_TX_INHIBIT_THRESHOLD_DEFAULT = 3,
322     SLNETSOCK_TX_INHIBIT_THRESHOLD_MED     = 4,
323     SLNETSOCK_TX_INHIBIT_THRESHOLD_HIGH    = 5,
324     SLNETSOCK_TX_INHIBIT_THRESHOLD_MAX     = 6
325 } SlNetSockTxInhibitThreshold_e;
326 
327 /*!
328     \brief  The SlNetSockSecAttrib_e enumerations are used to declare security
329             attribute objects in SlNetSock_secAttribSet().
330 
331     \sa     SlNetSock_secAttribSet()
332 */
333 typedef enum
334 {
335      SLNETSOCK_SEC_ATTRIB_PRIVATE_KEY               = 0,
336      SLNETSOCK_SEC_ATTRIB_LOCAL_CERT                = 1,
337      SLNETSOCK_SEC_ATTRIB_PEER_ROOT_CA              = 2,
338      SLNETSOCK_SEC_ATTRIB_DH_KEY                    = 3,
339      SLNETSOCK_SEC_ATTRIB_METHOD                    = 4,
340      SLNETSOCK_SEC_ATTRIB_CIPHERS                   = 5,
341      SLNETSOCK_SEC_ATTRIB_ALPN                      = 6,
342      SLNETSOCK_SEC_ATTRIB_EXT_CLIENT_CHLNG_RESP     = 7,
343      SLNETSOCK_SEC_ATTRIB_DOMAIN_NAME               = 8,
344 
345      /*!
346             @c SLNETSOCK_SEC_ATTRIB_DISABLE_CERT_STORE is
347             currently only supported on CC3xxx devices.
348 
349             The certificate store is a file, provided by TI,
350             containing a list of known and trusted root CAs by TI.
351             For more information, see the CC3xxx documentation.
352 
353             The certificate store is used only in client mode. Servers
354             use a proprietary root CA to authenticate clients, and
355             therefore cannot use the certificate store.
356 
357             Using this attribute allows using root CA which isn't a
358             part of the provided certificate store.
359      */
360 
361      SLNETSOCK_SEC_ATTRIB_DISABLE_CERT_STORE = 9
362 } SlNetSockSecAttrib_e;
363 
364 /* available values for SLNETSOCK_SEC_ATTRIB_METHOD */
365 #define SLNETSOCK_SEC_METHOD_SSLV3                                          (0)   /**< security method SSL v3                            */
366 #define SLNETSOCK_SEC_METHOD_TLSV1                                          (1)   /**< security method TLS v1                            */
367 #define SLNETSOCK_SEC_METHOD_TLSV1_1                                        (2)   /**< security method TLS v1_1                          */
368 #define SLNETSOCK_SEC_METHOD_TLSV1_2                                        (3)   /**< security method TLS v1_2                          */
369 #define SLNETSOCK_SEC_METHOD_SSLv3_TLSV1_2                                  (4)   /**< use highest possible version from SSLv3 - TLS 1.2 */
370 #define SLNETSOCK_SEC_METHOD_DLSV1                                          (5)   /**< security method DTL v1                            */
371 
372 /* available values for SLNETSOCK_SEC_ATTRIB_CIPHERS. The value is bitmap! */
373 #define SLNETSOCK_SEC_CIPHER_SSL_RSA_WITH_RC4_128_SHA                       (1 << 0)
374 #define SLNETSOCK_SEC_CIPHER_SSL_RSA_WITH_RC4_128_MD5                       (1 << 1)
375 #define SLNETSOCK_SEC_CIPHER_TLS_RSA_WITH_AES_256_CBC_SHA                   (1 << 2)
376 #define SLNETSOCK_SEC_CIPHER_TLS_DHE_RSA_WITH_AES_256_CBC_SHA               (1 << 3)
377 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA             (1 << 4)
378 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_RSA_WITH_RC4_128_SHA                 (1 << 5)
379 #define SLNETSOCK_SEC_CIPHER_TLS_RSA_WITH_AES_128_CBC_SHA256                (1 << 6)
380 #define SLNETSOCK_SEC_CIPHER_TLS_RSA_WITH_AES_256_CBC_SHA256                (1 << 7)
381 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256          (1 << 8)
382 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256        (1 << 9)
383 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA           (1 << 10)
384 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA           (1 << 11)
385 #define SLNETSOCK_SEC_CIPHER_TLS_RSA_WITH_AES_128_GCM_SHA256                (1 << 12)
386 #define SLNETSOCK_SEC_CIPHER_TLS_RSA_WITH_AES_256_GCM_SHA384                (1 << 13)
387 #define SLNETSOCK_SEC_CIPHER_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256            (1 << 14)
388 #define SLNETSOCK_SEC_CIPHER_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384            (1 << 15)
389 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256          (1 << 16)
390 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384          (1 << 17)
391 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256        (1 << 18)
392 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384        (1 << 19)
393 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256  (1 << 20)
394 #define SLNETSOCK_SEC_CIPHER_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256    (1 << 21)
395 #define SLNETSOCK_SEC_CIPHER_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256      (1 << 22)
396 #define SLNETSOCK_SEC_CIPHER_FULL_LIST                                      (0xFFFFFFFF)
397 
398 /* available values for SLNETSOCK_SEC_ATTRIB_ALPN */
399 #define SLNETSOCK_SEC_ALPN_H1                                               (1 << 0)
400 #define SLNETSOCK_SEC_ALPN_H2                                               (1 << 1)
401 #define SLNETSOCK_SEC_ALPN_H2C                                              (1 << 2)
402 #define SLNETSOCK_SEC_ALPN_H2_14                                            (1 << 3)
403 #define SLNETSOCK_SEC_ALPN_H2_16                                            (1 << 4)
404 #define SLNETSOCK_SEC_ALPN_FULL_LIST                                        ((SLNETSOCK_SEC_ALPN_H2_16 << 1 ) - 1)
405 
406 /* available values for the flags of the SlNetSock_startSec function */
407 #define SLNETSOCK_SEC_START_SECURITY_SESSION_ONLY                           (1 << 0) /**< Sends the command that will start the security session for a specific socket descriptor */
408 #define SLNETSOCK_SEC_BIND_CONTEXT_ONLY                                     (1 << 1) /**< Binds the security context to a specific socket descriptor */
409 #define SLNETSOCK_SEC_IS_SERVER                                             (1 << 2) /**< Used to define if the socket is client/server socket       */
410 
411 /* available values for the flags of the SlNetSock_create function */
412 
413 #define SLNETSOCK_CREATE_IF_STATE_ENABLE                                    (1 << 0) /**< Creation of the socket will be on enabled state      */
414 #define SLNETSOCK_CREATE_IF_STATUS_CONNECTED                                (1 << 1) /**< Creation of the socket will be on status connected   */
415 #define SLNETSOCK_CREATE_ALLOW_PARTIAL_MATCH                                (1 << 2) /**< Creation of the socket will be on the interface with
416                                                                                         the highest priority if the other flags will fail    */
417 
418 /* Definitions for shutting down some or all parts of a full duplex connection */
419 #define SLNETSOCK_SHUT_RD                                                   (0) /**< Further receptions will be disallowed                   */
420 #define SLNETSOCK_SHUT_WR                                                   (1) /**< Further transmissions will be disallowed                */
421 #define SLNETSOCK_SHUT_RDWR                                                 (2) /**< Further receptions and transmissions will be disallowed */
422 
423 /* Length of address string representation  */
424 #define SLNETSOCK_INET6_ADDRSTRLEN                                          (46)
425 #define SLNETSOCK_INET_ADDRSTRLEN                                           (16)
426 
427 /* flags used in send/recv and friends.
428  *
429  * Note these flags must not exceed 24-bits.  The implementation will
430  * OR the 8-bits of security flags into the remaining high 8 bits of
431  * 32-bit flag variables.
432  */
433 #define SLNETSOCK_MSG_OOB         (0x0001)
434 #define SLNETSOCK_MSG_PEEK        (0x0002)
435 #define SLNETSOCK_MSG_WAITALL     (0x0004)
436 #define SLNETSOCK_MSG_DONTWAIT    (0x0008)
437 #define SLNETSOCK_MSG_DONTROUTE   (0x0010)
438 #define SLNETSOCK_MSG_NOSIGNAL    (0x0020)
439 
440 
441 /*****************************************************************************/
442 /* Structure/Enum declarations                                               */
443 /*****************************************************************************/
444 
445 /*!
446     \brief Internet address
447 */
448 typedef struct SlNetSock_InAddr_t
449 {
450 #ifndef s_addr
451     uint32_t s_addr;  /* Internet address 32 bits */
452 #else
453 /*!
454     \brief Different representations for in addr for different hosts.
455 */
456     union S_un
457     {
458         uint32_t S_addr;
459         struct
460         {
461             uint8_t s_b1,s_b2,s_b3,s_b4;
462         } S_un_b;
463         struct
464         {
465             uint16_t s_w1,s_w2;
466         } S_un_w;
467     } S_un;
468 #endif
469 } SlNetSock_InAddr_t;
470 
471 /*!
472     \brief IpV6 or Ipv6 EUI64
473 */
474 typedef struct SlNetSock_In6Addr_t
475 {
476     union
477     {
478         uint8_t  _S6_u8[16];
479         uint16_t _S6_u16[8];
480         uint32_t _S6_u32[4];
481     } _S6_un;
482 } SlNetSock_In6Addr_t;
483 
484 /*!
485     \brief The SlNetSock_NoDelay_t structure is used in #SLNETSOCK_TCP_NODELAY TCP level option
486 */
487 typedef struct SlNetSock_NoDelay_t
488 {
489     uint32_t noDelayEnabled;      /**< 0 = disabled;1 = enabled; default = 0 */
490 } SlNetSock_NoDelay_t;
491 
492 /*!
493     \brief The SlNetSock_MaxSeg_t structure is used in #SLNETSOCK_TCP_MAXSEG TCP level option
494 */
495 typedef struct SlNetSock_MaxSeg_t
496 {
497     uint32_t maxSeg;               /**< Maximum TCP segment size. Default = 536 */
498 } SlNetSock_MaxSeg_t;
499 
500 /*!
501     \brief The SlNetSock_NoPush_t structure is used in #SLNETSOCK_TCP_NOPUSH TCP level option
502 */
503 typedef struct SlNetSock_NoPush_t
504 {
505     uint32_t noPushEnabled;      /**< 0 = disabled;1 = enabled; default = 0 */
506 } SlNetSock_NoPush_t;
507 
508 /*!
509     \brief The SlNetSock_NoOpt_t structure is used in #SLNETSOCK_TCP_NOOPT TCP level option
510 */
511 typedef struct SlNetSock_NoOpt_t
512 {
513     uint32_t noOptEnabled;      /**< 0 = disabled;1 = enabled; default = 0 */
514 } SlNetSock_NoOpt_t;
515 
516 /*!
517     \brief The SlNetSock_SackPermitted_t structure is used in #SLNETSOCK_TCP_NOPUSH TCP level option
518 */
519 typedef struct SlNetSock_SackPermitted_t
520 {
521     uint32_t sackPermittedEnabled;      /**< 0 = disabled;1 = enabled; default = 0 */
522 } SlNetSock_SackPermitted_t;
523 
524 /*!
525     \brief The SlNetSock_MaxRtt_t structure is used in #SLNETSOCK_TCP_MAXRTT TCP level option
526 */
527 typedef struct SlNetSock_MaxRtt_t
528 {
529     uint32_t maxRtt;               /**< Maximum TCP Round Trip Time value allowed; Default = 360000000 */
530 } SlNetSock_MaxRtt_t;
531 
532 /*!
533     \brief The SlNetSock_Keepalive_t structure is used in #SLNETSOCK_OPSOCK_KEEPALIVE socket level option
534 */
535 typedef struct SlNetSock_Keepalive_t
536 {
537     uint32_t keepaliveEnabled;      /**< 0 = disabled;1 = enabled; default = 1 */
538 } SlNetSock_Keepalive_t;
539 
540 /*!
541     \brief The SlNetSock_NonIpBoundary_t structure is used in #SLNETSOCK_OPSOCK_NON_IP_BOUNDARY socket level option
542 */
543 typedef struct SlNetSock_NonIpBoundary_t
544 {
545     int32_t nonIpBoundaryEnabled;   /**< 0 = keep IP boundary; 1 = don`t keep ip boundary; default = 0; */
546 } SlNetSock_NonIpBoundary_t;
547 
548 /*!
549     \brief The SlNetSock_Winsize_t structure is used in #SLNETSOCK_OPSOCK_RCV_BUF socket level option
550 */
551 typedef struct SlNetSock_Winsize_t
552 {
553     uint32_t winSize;               /**< receive window size for tcp sockets   */
554 } SlNetSock_Winsize_t;
555 
556 /*!
557     \brief The SlNetSock_Nonblocking_t structure is used in #SLNETSOCK_OPSOCK_NON_BLOCKING socket level option
558 */
559 typedef struct SlNetSock_Nonblocking_t
560 {
561     uint32_t nonBlockingEnabled;    /**< 0 = disabled, 1 = enabled, default = 1*/
562 } SlNetSock_Nonblocking_t;
563 
564 /*!
565     \brief The SlNetSock_Broadcast_t structure is used in #SLNETSOCK_OPSOCK_BROADCAST socket level option
566 */
567 typedef struct SlNetSock_Broadcast_t
568 {
569     uint32_t broadcastEnabled;    /**< 0 = disabled, 1 = enabled, default = 0*/
570 } SlNetSock_Broadcast_t;
571 
572 /*!
573     \brief Secure socket attribute context
574 */
575 typedef struct SlNetSock_SecAttribNode_t
576 {
577     SlNetSockSecAttrib_e              attribName;    /**< Security attribute name          */
578     uint8_t                          *attribBuff;    /**< Security attribute buffer        */
579     uint16_t                          attribBuffLen; /**< Security attribute buffer length */
580     struct SlNetSock_SecAttribNode_t *next;
581 } SlNetSock_SecAttribNode_t;
582 
583 /*!
584     \brief Secure socket attribute handler
585 */
586 typedef SlNetSock_SecAttribNode_t * SlNetSockSecAttrib_t;
587 
588 /*!
589     \brief Secure ALPN structure
590 */
591 typedef struct SlNetSock_SecureALPN_t
592 {
593     uint32_t secureALPN;
594 } SlNetSock_SecureALPN_t;
595 
596 /*!
597     \brief Secure Mask structure
598 */
599 typedef struct SlNetSock_SecureMask_t
600 {
601     uint32_t secureMask;
602 } SlNetSock_SecureMask_t;
603 
604 /*!
605     \brief Secure Method structure
606 */
607 typedef struct SlNetSock_SecureMethod_t
608 {
609     uint8_t secureMethod;
610 } SlNetSock_SecureMethod_t;
611 
612 /*!
613     \brief The SlNetSock_IpMreq_t structure is used in #SLNETSOCK_OPIP_ADD_MEMBERSHIP and #SLNETSOCK_OPIP_DROP_MEMBERSHIP IP level option
614 */
615 typedef struct SlNetSock_IpMreq_t
616 {
617     SlNetSock_InAddr_t imr_multiaddr;     /**< The IPv4 multicast address to join  */
618     uint32_t           imr_interface;     /**< The interface to use for this group */
619 } SlNetSock_IpMreq_t;
620 
621 /*!
622     \brief The SlNetSock_IpV6Mreq_t structure is used in #SLNETSOCK_OPIPV6_ADD_MEMBERSHIP and #SLNETSOCK_OPIPV6_DROP_MEMBERSHIP IP level option
623 */
624 typedef struct SlNetSock_IpV6Mreq_t
625 {
626     SlNetSock_In6Addr_t ipv6mr_multiaddr; /**< IPv6 multicast address of group                       */
627     uint32_t            ipv6mr_interface; /**< should be 0 to choose the default multicast interface */
628 } SlNetSock_IpV6Mreq_t;
629 
630 /*!
631     \brief The SlNetSock_linger_t structure is used in #SLNETSOCK_OPSOCK_LINGER socket level option
632 */
633 typedef struct SlNetSock_linger_t
634 {
635     uint32_t l_onoff;                    /**< 0 = disabled; 1 = enabled; default = 0; */
636     uint32_t l_linger;                   /**< linger time in seconds; default = 0;    */
637 } SlNetSock_linger_t;
638 
639 /*!
640     \brief      The @c SlNetSock_Timeval_t structure is used in the
641                 #SLNETSOCK_OPSOCK_RCV_TIMEO and #SLNETSOCK_OPSOCK_SND_TIMEO
642                 socket level options
643 
644     \remarks    Note that @c SlNetSock_Timeval_t is intentionally defined
645                 to be equivalent to the POSIX-defined <tt>struct
646                 timeval</tt> data type.
647 */
648 typedef struct timeval SlNetSock_Timeval_t;
649 
650 /*!
651     \brief The SlNetSocklen_t is used for declaring the socket length parameter
652 */
653 typedef uint16_t SlNetSocklen_t;
654 
655 /*!
656     \brief IpV4 socket address
657 */
658 typedef struct SlNetSock_Addr_t
659 {
660     uint16_t sa_family;                  /**< Address family (e.g. AF_INET)          */
661     uint8_t  sa_data[14];                /**< Protocol- specific address information */
662 } SlNetSock_Addr_t;
663 
664 /*!
665     \brief SlNetSock IPv6 address, Internet style
666 */
667 typedef struct SlNetSock_AddrIn6_t
668 {
669     uint16_t            sin6_family;     /**< SLNETSOCK_AF_INET6             */
670     uint16_t            sin6_port;       /**< Transport layer port.          */
671     uint32_t            sin6_flowinfo;   /**< IPv6 flow information.         */
672     SlNetSock_In6Addr_t sin6_addr;       /**< IPv6 address.                  */
673     uint32_t            sin6_scope_id;   /**< set of interfaces for a scope. */
674 } SlNetSock_AddrIn6_t;
675 
676 /*!
677     \brief SlNetSock IPv4 address, Internet style
678 */
679 typedef struct SlNetSock_AddrIn_t
680 {
681     uint16_t           sin_family;       /**< Internet Protocol (AF_INET). */
682     uint16_t           sin_port;         /**< Address port (16 bits).      */
683     SlNetSock_InAddr_t sin_addr;         /**< Internet address (32 bits).  */
684     int8_t             sin_zero[8];      /**< Not used.                    */
685 } SlNetSock_AddrIn_t;
686 
687 /* ss_family + pad must be large enough to hold max of
688  * _SlNetSock_AddrIn6_t or _SlNetSock_AddrIn_t
689  */
690 /*!
691     \brief Generic socket address type to hold either IPv4 or IPv6 address
692 */
693 typedef struct SlNetSock_SockAddrStorage_t
694 {
695     uint16_t ss_family;
696     uint8_t  pad[26];
697 } SlNetSock_SockAddrStorage_t;
698 
699 /*!
700     \brief The SlNetSock_SdSet_t structure holds the sd array for SlNetSock_select function
701 */
702 typedef struct SlNetSock_SdSet_t         /**< The select socket array manager */
703 {
704     uint32_t sdSetBitmap[(SLNETSOCK_MAX_CONCURRENT_SOCKETS + (uint8_t)31)/(uint8_t)32]; /* Bitmap of SOCKET Descriptors */
705 } SlNetSock_SdSet_t;
706 
707 
708 /*!
709     \brief The SlNetSock_TransceiverRxOverHead_t structure holds the data for Rx transceiver mode using a raw socket when using SlNetSock_recv function
710 */
711 typedef struct SlNetSock_TransceiverRxOverHead_t
712 {
713     uint8_t  rate;                       /**< Received Rate                                  */
714     uint8_t  channel;                    /**< The received channel                           */
715     int8_t   rssi;                       /**< The computed RSSI value in db of current frame */
716     uint8_t  padding;                    /**< pad to align to 32 bits                        */
717     uint32_t timestamp;                  /**< Timestamp in microseconds                      */
718 } SlNetSock_TransceiverRxOverHead_t;
719 
720 
721 /*****************************************************************************/
722 /* Function prototypes                                                       */
723 /*****************************************************************************/
724 
725 /*!
726 
727     \brief Initialize the SlNetSock module
728 
729     \param[in] flags            Reserved
730 
731     \return                     Zero on success, or negative error code on failure
732 
733     \par    Examples
734     \snippet ti/net/test/snippets/slnetif.c SlNetSock_init snippet
735 
736 */
737 int32_t SlNetSock_init(int32_t flags);
738 
739 /*!
740 
741     \brief Create an endpoint for communication
742 
743     SlNetSock_create() creates a new socket of a certain socket type,
744     identified by an integer number, and allocates system resources to it.\n
745     This function is called by the application layer to obtain a socket descriptor (handle).
746 
747     \param[in] domain           Specifies the protocol family of the created socket.
748                                 For example:
749                                    - #SLNETSOCK_AF_INET for network protocol IPv4
750                                    - #SLNETSOCK_AF_INET6 for network protocol IPv6
751                                    - #SLNETSOCK_AF_RF for starting transceiver mode.
752                                         Notes:
753                                         - sending and receiving any packet overriding 802.11 header
754                                         - for optimized power consumption the socket will be started in TX
755                                             only mode until receive command is activated
756     \param[in] type             Specifies the socket type, which determines the semantics of communication over
757                                 the socket. The socket types supported by the system are implementation-dependent.
758                                 Possible socket types include:
759                                    - #SLNETSOCK_SOCK_STREAM (reliable stream-oriented service or Stream Sockets)
760                                    - #SLNETSOCK_SOCK_DGRAM  (datagram service or Datagram Sockets)
761                                    - #SLNETSOCK_SOCK_RAW    (raw protocols atop the network layer)
762                                    - when used with AF_RF:
763                                       - #SLNETSOCK_SOCK_RX_MTR
764                                       - #SLNETSOCK_SOCK_MAC_WITH_CCA
765                                       - #SLNETSOCK_SOCK_MAC_WITH_NO_CCA
766                                       - #SLNETSOCK_SOCK_BRIDGE
767                                       - #SLNETSOCK_SOCK_ROUTER
768     \param[in] protocol         Specifies a particular transport to be used with the socket.\n
769                                 The most common are
770                                     - #SLNETSOCK_PROTO_TCP
771                                     - #SLNETSOCK_PROTO_UDP
772                                     - #SLNETSOCK_PROTO_RAW
773                                     - #SLNETSOCK_PROTO_SECURE
774     \param[in] ifBitmap         Specifies the interface(s) which the socket will be created on
775                                 according to priority until one of them will return an answer.\n
776                                 Value 0 is used in order to choose automatic interfaces selection
777                                 according to the priority interface list.
778                                 Value can be a combination of interfaces by OR'ing multiple interfaces bit identifiers
779                                 (SLNETIFC_IDENT_ defined in slnetif.h)
780                                 Note: interface identifier bit must be configured prior to this socket creation
781                                 using SlNetIf_add().
782     \param[in] flags            Specifies flags.
783                                    - #SLNETSOCK_CREATE_IF_STATE_ENABLE     - Creation of the socket will be on enabled state
784                                    - #SLNETSOCK_CREATE_IF_STATUS_CONNECTED - Creation of the socket will be on status connected
785                                    - #SLNETSOCK_CREATE_ALLOW_PARTIAL_MATCH - Creation of the socket will be on the interface with
786                                                                             the highest priority if the other flags will fail
787                                 The value 0 may be used in order to run the default flags:
788                                    - #SLNETSOCK_CREATE_IF_STATE_ENABLE
789                                    - #SLNETSOCK_CREATE_IF_STATUS_CONNECTED
790 
791     \return                     On success, socket descriptor (handle) that is used for consequent socket operations. \n
792                                 A successful return code should be a positive number\n
793                                 On error, a negative value will be returned specifying the error code.
794                                    - #SLNETERR_BSD_EAFNOSUPPORT    - illegal domain parameter
795                                    - #SLNETERR_BSD_EPROTOTYPE      - illegal type parameter
796                                    - #SLNETERR_BSD_EACCES          - permission denied
797                                    - #SLNETERR_BSD_ENSOCK          - exceeded maximal number of socket
798                                    - #SLNETERR_BSD_ENOMEM          - memory allocation error
799                                    - #SLNETERR_BSD_EINVAL          - error in socket configuration
800                                    - #SLNETERR_BSD_EPROTONOSUPPORT - illegal protocol parameter
801                                    - #SLNETERR_BSD_EOPNOTSUPP      - illegal combination of protocol and type parameters
802 
803     \slnetsock_init_precondition
804 
805     \remark     Not all platforms support all options.
806 
807     \remark     A @c protocol value of zero can be used to select the default protocol from the selected @c domain and @c type.
808 
809     \remark     SlNetSock_create() uses the highest priority interface from the ifBitmap, subject to the constraints specified
810                 in the flags parameter. An interface that does not satisfy the constraints is ignored, without regards to its
811                 priority level.
812 
813     \par    Examples
814     \snippet ti/net/test/snippets/slnetif.c SlNetSock_create TCP IPv4 snippet
815     \snippet ti/net/test/snippets/slnetif.c SlNetSock_create TCP IPv6 snippet
816     \snippet ti/net/test/snippets/slnetif.c SlNetSock_create UDP IPv4 snippet
817 
818     \sa         SlNetSock_close()
819 */
820 int16_t SlNetSock_create(int16_t domain, int16_t type, int16_t protocol, uint32_t ifBitmap, int16_t flags);
821 
822 
823 /*!
824     \brief Gracefully close socket
825 
826     Release resources allocated to a socket.
827 
828     \param[in] sd               Socket descriptor (handle), received in SlNetSock_create()
829 
830     \return                     Zero on success, or negative error code on failure
831 
832     \slnetsock_init_precondition
833 
834     \remark     In the case of TCP, the connection is terminated.
835 
836     \remark     After this function returns there is no way to access the socket
837                 identified by @c sd. The SlNetSock socket is closed regardless
838                 of the status of the underlying interface's socket.
839 
840     \par    Examples
841     \snippet ti/net/test/snippets/slnetif.c SlNetSock_close snippet
842 
843     \sa                         SlNetSock_create()
844 */
845 int32_t SlNetSock_close(int16_t sd);
846 
847 
848 /*!
849     \brief Shutting down parts of a full-duplex connection
850 
851     Shuts down parts of a full-duplex connection according to how parameter.\n
852 
853     \param[in] sd               Socket descriptor (handle), received in SlNetSock_create
854     \param[in] how              Specifies which part of a full-duplex connection to shutdown. \n
855                                 The options are
856                                     - #SLNETSOCK_SHUT_RD   - further receptions will be disallowed
857                                     - #SLNETSOCK_SHUT_WR   - further transmissions will be disallowed
858                                     - #SLNETSOCK_SHUT_RDWR - further receptions and transmissions will be disallowed
859 
860     \return                     Zero on success, or negative error code on failure
861 
862     \slnetsock_init_precondition
863 
864     \sa                         SlNetSock_create()
865     \sa                         SlNetSock_connect()
866     \sa                         SlNetSock_accept()
867 */
868 int32_t SlNetSock_shutdown(int16_t sd, int16_t how);
869 
870 
871 /*!
872     \brief Accept a connection on a socket
873 
874     The SlNetSock_accept function is used with connection-based socket types (#SLNETSOCK_SOCK_STREAM).
875 
876     It extracts the first connection request on the queue of pending
877     connections, creates a new connected socket, and returns a new file
878     descriptor referring to that socket.
879 
880     The newly created socket is not in the listening state. The
881     original socket sd is unaffected by this call.
882 
883     The argument sd is a socket that has been created with
884     SlNetSock_create(), bound to a local address with
885     SlNetSock_bind(), and is listening for connections after a
886     SlNetSock_listen().
887 
888     The argument \c addr is a pointer to a sockaddr structure. This
889     structure is filled in with the address of the peer socket, as
890     known to the communications layer.
891 
892     The exact format of the address returned \c addr is determined by the socket's address family.
893 
894     \c addrlen is a value-result argument: it should initially contain
895     the size of the structure pointed to by addr, on return it will
896     contain the actual length (in bytes) of the address returned.
897 
898     \param[in]  sd              Socket descriptor (handle)
899     \param[out] addr            The argument addr is a pointer
900                                 to a sockaddr structure. This
901                                 structure is filled in with the
902                                 address of the peer socket, as
903                                 known to the communications
904                                 layer. The exact format of the
905                                 address returned addr is
906                                 determined by the socket's
907                                 address\n
908                                 sockaddr:\n - code for the
909                                 address format.\n -
910                                 socket address, the length
911                                 depends on the code format
912     \param[out] addrlen         The addrlen argument is a value-result
913                                 argument: it should initially contain the
914                                 size of the structure pointed to by addr
915 
916     \return                     On success, a socket descriptor.\n
917                                 On a non-blocking accept a possible negative value is #SLNETERR_BSD_EAGAIN.\n
918                                 On failure, negative error code.\n
919                                 #SLNETERR_BSD_ENOMEM may be return in case there are no resources in the system
920 
921     \slnetsock_init_precondition
922 
923     \sa                         SlNetSock_create()
924     \sa                         SlNetSock_bind()
925     \sa                         SlNetSock_listen()
926 */
927 int16_t SlNetSock_accept(int16_t sd, SlNetSock_Addr_t *addr, SlNetSocklen_t *addrlen);
928 
929 
930 /*!
931     \brief Assign a name to a socket
932 
933     This SlNetSock_bind function gives the socket the local address
934     addr.  addr is addrlen bytes long.
935 
936     Traditionally, this is called when a socket is created with
937     socket, it exists in a name space (address family) but has no name
938     assigned.
939 
940     It is necessary to assign a local address before a #SLNETSOCK_SOCK_STREAM
941     socket may receive connections.
942 
943     \param[in] sd               Socket descriptor (handle)
944     \param[in] addr             Specifies the destination
945                                 addrs\n sockaddr:\n - code for
946                                 the address format.\n - socket address,
947                                 the length depends on the code
948                                 format
949     \param[in] addrlen          Contains the size of the structure pointed to by addr
950 
951     \return                     Zero on success, or negative error code on failure
952 
953     \slnetsock_init_precondition
954 
955     \sa                         SlNetSock_create()
956     \sa                         SlNetSock_accept()
957     \sa                         SlNetSock_listen()
958 */
959 int32_t SlNetSock_bind(int16_t sd, const SlNetSock_Addr_t *addr, int16_t addrlen);
960 
961 
962 /*!
963     \brief Listen for connections on a socket
964 
965     The willingness to accept incoming connections and a queue
966     limit for incoming connections are specified with SlNetSock_listen(),
967     and then the connections are accepted with SlNetSock_accept().
968 
969     \param[in] sd               Socket descriptor (handle)
970     \param[in] backlog          Specifies the listen queue depth.
971 
972     \return                     Zero on success, or negative error code on failure
973 
974     \slnetsock_init_precondition
975 
976     \remark     The SlNetSock_listen() call applies only to sockets of
977                 type #SLNETSOCK_SOCK_STREAM.
978 
979     \remark     The \c backlog parameter defines the maximum length the queue of
980                 pending connections may grow to.
981 
982     \sa                         SlNetSock_create()
983     \sa                         SlNetSock_accept()
984     \sa                         SlNetSock_bind()
985 */
986 int32_t SlNetSock_listen(int16_t sd, int16_t backlog);
987 
988 
989 /*!
990     \brief Initiate a connection on a socket
991 
992     Function connects the socket referred to by the socket
993     descriptor sd, to the address specified by \c addr.
994 
995     The format of the address in addr is determined by the address
996     space of the socket.
997 
998     If it is of type #SLNETSOCK_SOCK_DGRAM, this call specifies the
999     peer with which the socket is to be associated; this address is
1000     that to which datagrams are to be sent, and the only address from
1001     which datagrams are to be received.
1002 
1003     If the socket is of type #SLNETSOCK_SOCK_STREAM, this call
1004     attempts to make a connection to another socket.
1005 
1006     The other socket is specified by address, which is an address in
1007     the communications space of the socket.
1008 
1009     \param[in] sd               Socket descriptor (handle)
1010     \param[in] addr             Specifies the destination addr\n
1011                                 sockaddr:\n - code for the
1012                                 address format.\n -
1013                                 socket address, the length
1014                                 depends on the code format
1015     \param[in] addrlen          Contains the size of the structure pointed
1016                                 to by addr
1017 
1018     \return                     On success, a socket descriptor (handle).\n
1019                                 On failure, negative value.\n
1020                                 On a non-blocking connect a possible negative value is #SLNETERR_BSD_EALREADY.
1021                                 #SLNETERR_POOL_IS_EMPTY may be returned in case there are no resources in the system
1022 
1023     \slnetsock_init_precondition
1024 
1025     \sa                         SlNetSock_create()
1026 */
1027 int32_t SlNetSock_connect(int16_t sd, const SlNetSock_Addr_t *addr, SlNetSocklen_t addrlen);
1028 
1029 /*!
1030     \brief Return address info about the remote side of the connection
1031 
1032     Returns a struct SlNetSock_AddrIn_t
1033     filled with information about the peer device that is connected
1034     on the other side of the socket descriptor.
1035 
1036     \param[in]  sd              Socket descriptor (handle)
1037     \param[out] addr            returns the struct addr\n
1038                                 SlNetSockAddrIn filled with information
1039                                 about the peer device:\n - code for the
1040                                 address format.\n -
1041                                 socket address, the length
1042                                 depends on the code format
1043     \param[out] addrlen         Contains the size of the structure pointed
1044                                 to by addr
1045 
1046     \return                     Zero on success, or negative error code on failure
1047 
1048     \slnetsock_init_precondition
1049 
1050     \sa                         SlNetSock_accept()
1051     \sa                         SlNetSock_connect()
1052 */
1053 int32_t SlNetSock_getPeerName(int16_t sd, SlNetSock_Addr_t *addr, SlNetSocklen_t *addrlen);
1054 
1055 
1056 /*!
1057     \brief Get local address info by socket descriptor
1058 
1059     Returns the local address info of the socket descriptor.
1060 
1061     \param[in]  sd              Socket descriptor (handle)
1062     \param[out] addr            The argument addr is a pointer
1063                                 to a SlNetSock_Addr_t structure. This
1064                                 structure is filled in with the
1065                                 address of the peer socket, as
1066                                 known to the communications
1067                                 layer. The exact format of the
1068                                 address returned addr is
1069                                 determined by the socket's
1070                                 address\n
1071                                 SlNetSock_Addr_t:\n - code for the
1072                                 address format.\n -
1073                                 socket address, the length
1074                                 depends on the code format
1075     \param[out] addrlen         The addrlen argument is a value-result
1076                                 argument: it should initially contain the
1077                                 size of the structure pointed to by addr
1078 
1079     \return                     Zero on success, or negative on failure.
1080 
1081     \slnetsock_init_precondition
1082 
1083     \remark     If the provided buffer is too small the returned address
1084                 will be truncated and \c addrlen will contain the
1085                 actual size of the socket address.
1086 
1087     \sa         SlNetSock_create()
1088     \sa         SlNetSock_bind()
1089 */
1090 int32_t SlNetSock_getSockName(int16_t sd, SlNetSock_Addr_t *addr, SlNetSocklen_t *addrlen);
1091 
1092 
1093 /*!
1094     \brief Monitor socket activity
1095 
1096     SlNetSock_select() allow a program to monitor multiple file descriptors,
1097     waiting until one or more of the file descriptors become
1098     "ready" for some class of I/O operation.
1099 
1100     \param[in]     nsds        The highest-numbered file descriptor in any of the
1101                                three sets, plus 1.
1102     \param[in,out] readsds     Socket descriptors list for read monitoring and accept monitoring
1103     \param[in,out] writesds    Socket descriptors list for connect monitoring only, write monitoring is not supported
1104     \param[in,out] exceptsds   Socket descriptors list for exception monitoring, not supported.
1105     \param[in]     timeout     Is an upper bound on the amount of time elapsed
1106                                before SlNetSock_select() returns. Null or above 0xffff seconds means
1107                                infinity timeout. The minimum timeout is 10 milliseconds,
1108                                less than 10 milliseconds will be set automatically to 10 milliseconds.
1109                                Max microseconds supported is 0xfffc00.
1110                                In trigger mode the timeout fields must be set to zero.
1111 
1112     \return                    On success, SlNetSock_select() returns the number of
1113                                file descriptors contained in the three returned
1114                                descriptor sets (that is, the total number of bits that
1115                                are set in readsds, writesds, exceptsds) which may be
1116                                zero if the timeout expires before anything interesting
1117                                happens.\n On error, a negative value is returned.
1118                                readsds - return the sockets on which Read request will
1119                                return without delay with valid data.\n
1120                                writesds - return the sockets on which Write request
1121                                will return without delay.\n
1122                                exceptsds - return the sockets closed recently. \n
1123                                #SLNETERR_BSD_ENOMEM may be return in case there are no resources in the system
1124 
1125     \slnetsock_init_precondition
1126 
1127     \remark     If \c timeout is set to less than 10ms it will
1128                 automatically set to 10ms to prevent overload of the
1129                 system
1130 
1131     \sa         SlNetSock_create()
1132 */
1133 int32_t SlNetSock_select(int16_t nsds, SlNetSock_SdSet_t *readsds, SlNetSock_SdSet_t *writesds, SlNetSock_SdSet_t *exceptsds, SlNetSock_Timeval_t *timeout);
1134 
1135 
1136 /*!
1137     \brief SlNetSock_select's SlNetSock_SdSet_t SET function
1138 
1139     Sets current socket descriptor on SlNetSock_SdSet_t container
1140 */
1141 int32_t SlNetSock_sdsSet(int16_t sd, SlNetSock_SdSet_t *sdset);
1142 
1143 
1144 /*!
1145     \brief SlNetSock_select's SlNetSock_SdSet_t CLR function
1146 
1147     Clears current socket descriptor on SlNetSock_SdSet_t container
1148 */
1149 int32_t SlNetSock_sdsClr(int16_t sd, SlNetSock_SdSet_t *sdset);
1150 
1151 
1152 /*!
1153     \brief SlNetSock_select's SlNetSock_SdSet_t ZERO function
1154 
1155     Clears all socket descriptors from SlNetSock_SdSet_t
1156 */
1157 int32_t SlNetSock_sdsClrAll(SlNetSock_SdSet_t *sdset);
1158 
1159 
1160 /*!
1161     \brief SlNetSock_select's SlNetSock_SdSet_t ISSET function
1162 
1163     Checks if current socket descriptor is set (true/false)
1164 
1165     \return            Returns true if set, false if unset
1166 
1167 */
1168 int32_t SlNetSock_sdsIsSet(int16_t sd, SlNetSock_SdSet_t *sdset);
1169 
1170 
1171 /*!
1172     \brief Set socket options
1173 
1174     SlNetSock_setOpt() manipulates the options associated with a socket.
1175 
1176     Options may exist at multiple protocol levels; they are always
1177     present at the uppermost socket level.
1178 
1179     When manipulating socket options the level at which the option resides
1180     and the name of the option must be specified.  To manipulate options at
1181     the socket level, level is specified as #SLNETSOCK_LVL_SOCKET.  To manipulate
1182     options at any other level the protocol number of the appropriate protocol
1183     controlling the option is supplied.  For example, to indicate that an
1184     option is to be interpreted by the TCP protocol, level should be set to
1185     the protocol number of TCP.
1186 
1187     \c optval and \c optlen are used to access opt_values
1188     for SlNetSock_setOpt().  For SlNetSock_getOpt() they identify a
1189     buffer in which the value for the requested option(s) are to
1190     be returned.  For SlNetSock_getOpt(), \c optlen is a value-result
1191     parameter, initially containing the size of the buffer
1192     pointed to by option_value, and modified on return to
1193     indicate the actual size of the value returned.  If no option
1194     value is to be supplied or returned, \c optval may be \c NULL.
1195 
1196     \param[in] sd               Socket descriptor (handle)
1197     \param[in] level            Defines the protocol level for this option
1198                                 - #SLNETSOCK_LVL_SOCKET - Socket level configurations (L4, transport layer)
1199                                 - #SLNETSOCK_LVL_IP - IP level configurations (L3, network layer)
1200                                 - #SLNETSOCK_LVL_PHY - Link level configurations (L2, link layer)
1201     \param[in] optname          Defines the option name to interrogate
1202                                 - #SLNETSOCK_LVL_SOCKET
1203                                   - #SLNETSOCK_OPSOCK_RCV_BUF\n
1204                                                  Sets tcp max recv window size.\n
1205                                                  This options takes SlNetSock_Winsize_t struct as parameter
1206                                   - #SLNETSOCK_OPSOCK_RCV_TIMEO\n
1207                                                  Sets the timeout value that specifies the maximum amount of time an input function waits until it completes.\n
1208                                                  Default: No timeout\n
1209                                                  This options takes SlNetSock_Timeval_t struct as parameter
1210                                   - #SLNETSOCK_OPSOCK_KEEPALIVE\n
1211                                                  Enable or Disable periodic keep alive.
1212                                                  Keeps TCP connections active by enabling the periodic transmission of messages \n
1213                                                  Timeout is 5 minutes.\n
1214                                                  Default: Enabled \n
1215                                                  This options takes SlNetSock_Keepalive_t struct as parameter
1216                                   - #SLNETSOCK_OPSOCK_KEEPALIVE_TIME\n
1217                                                  Set keep alive timeout.
1218                                                  Value is in seconds \n
1219                                                  Default: 5 minutes \n
1220                                   - #SLNETSOCK_OPSOCK_LINGER\n
1221                                                  Socket lingers on close pending remaining send/receive packets\n
1222                                   - #SLNETSOCK_OPSOCK_NON_BLOCKING\n
1223                                                  Sets socket to non-blocking operation Impacts: connect, accept, send, sendto, recv and recvfrom. \n
1224                                                  Default: Blocking.
1225                                                  This options takes SlNetSock_Nonblocking_t struct as parameter
1226                                   - #SLNETSOCK_OPSOCK_NON_IP_BOUNDARY\n
1227                                                  Enable or Disable rx ip boundary.
1228                                                  In connectionless socket (udp/raw), unread data is dropped (when SlNetSock_recvFrom() len parameter < data size), Enable this option in order to read the left data on the next SlNetSock_recvFrom() iteration\n
1229                                                  Default: Disabled, IP boundary kept\n
1230                                                  This options takes SlNetSock_NonIpBoundary_t struct as parameter
1231                                 - #SLNETSOCK_LVL_IP
1232                                   - #SLNETSOCK_OPIP_MULTICAST_TTL\n
1233                                                  Set the time-to-live value of outgoing multicast packets for this socket. \n
1234                                                  This options takes <b>uint8_t</b> as parameter
1235                                   - #SLNETSOCK_OPIP_ADD_MEMBERSHIP \n
1236                                                  UDP socket, Join a multicast group. \n
1237                                                  This options takes SlNetSock_IpMreq_t struct as parameter
1238                                   - #SLNETSOCK_OPIP_DROP_MEMBERSHIP \n
1239                                                  UDP socket, Leave a multicast group \n
1240                                                  This options takes SlNetSock_IpMreq_t struct as parameter
1241                                   - #SLNETSOCK_OPIP_HDRINCL \n
1242                                                  RAW socket only, the IPv4 layer generates an IP header when sending a packet unless \n
1243                                                  the IP_HDRINCL socket option is enabled on the socket.    \n
1244                                                  When it is enabled, the packet must contain an IP header. \n
1245                                                  Default: disabled, IPv4 header generated by Network Stack \n
1246                                                  This options takes <b>uint32_t</b> as parameter
1247                                   - #SLNETSOCK_OPIP_RAW_RX_NO_HEADER \n
1248                                                  Raw socket remove IP header from received data. \n
1249                                                  Default: data includes ip header \n
1250                                                  This options takes <b>uint32_t</b> as parameter
1251                                   - #SLNETSOCK_OPIP_RAW_IPV6_HDRINCL (inactive) \n
1252                                                  RAW socket only, the IPv6 layer generates an IP header when sending a packet unless \n
1253                                                  the IP_HDRINCL socket option is enabled on the socket. When it is enabled, the packet must contain an IP header \n
1254                                                  Default: disabled, IPv4 header generated by Network Stack \n
1255                                                  This options takes <b>uint32_t</b> as parameter
1256                                 - #SLNETSOCK_LVL_PHY
1257                                   - #SLNETSOCK_OPPHY_CHANNEL \n
1258                                                  Sets channel in transceiver mode.
1259                                                  This options takes <b>uint32_t</b> as channel number parameter
1260                                   - #SLNETSOCK_OPPHY_RATE \n
1261                                                  RAW socket, set WLAN PHY transmit rate \n
1262                                                  The values are based on SlWlanRateIndex_e    \n
1263                                                  This options takes <b>uint32_t</b> as parameter
1264                                   - #SLNETSOCK_OPPHY_TX_POWER \n
1265                                                  RAW socket, set WLAN PHY TX power \n
1266                                                  Valid rage is 1-15 \n
1267                                                  This options takes <b>uint32_t</b> as parameter
1268                                   - #SLNETSOCK_OPPHY_NUM_FRAMES_TO_TX \n
1269                                                  RAW socket, set number of frames to transmit in transceiver mode.
1270                                                  Default: 1 packet
1271                                                  This options takes <b>uint32_t</b> as parameter
1272                                   - #SLNETSOCK_OPPHY_PREAMBLE \n
1273                                                  RAW socket, set WLAN PHY preamble for Long/Short\n
1274                                                  This options takes <b>uint32_t</b> as parameter
1275                                   - #SLNETSOCK_OPPHY_TX_INHIBIT_THRESHOLD \n
1276                                                  RAW socket, set WLAN Tx - Set CCA threshold. \n
1277                                                  The values are based on SlNetSockTxInhibitThreshold_e \n
1278                                                  This options takes <b>uint32_t</b> as parameter
1279                                   - #SLNETSOCK_OPPHY_TX_TIMEOUT \n
1280                                                  RAW socket, set WLAN Tx - changes the TX timeout (lifetime) of transceiver frames. \n
1281                                                  Value in Ms, maximum value is 10ms \n
1282                                                  This options takes <b>uint32_t</b> as parameter
1283                                   - #SLNETSOCK_OPPHY_ALLOW_ACKS  \n
1284                                                  RAW socket, set WLAN Tx - Enable or Disable sending ACKs in transceiver mode \n
1285                                                  0 = disabled / 1 = enabled \n
1286                                                  This options takes <b>uint32_t</b> as parameter
1287                                 - #SLNETSOCK_PROTO_TCP
1288                                   - #SLNETSOCK_TCP_NODELAY \n
1289                                                  Disables TCP send delay/coalesce algorithm. \n
1290                                                  This option takes SLNetSock_NoDelay_t struct as a parameter.
1291                                   - #SLNETSOCK_TCP_MAXSEG \n
1292                                                  Set the maximum TCP segment size \n
1293                                                  This option takes SLNetSock_MaxSeg_t struct as a parameter.
1294                                   - #SLNETSOCK_TCP_NOPUSH \n
1295                                                  Do not send data just to finish a data block (attempt to coalesce). \n
1296                                                  This option takes SLNetSock_NoPush_t struct as a parameter
1297                                   - #SLNETSOCK_TCP_NOOPT \n
1298                                                  Do not use TCP options. \n
1299                                                  This option takes SLNetSock_NoOpt_t struct as a parameter.
1300                                   - #SLNETSOCK_TCP_SACKPERMITTED \n
1301                                                  Permit RFC-2018 Selective Acknowledgment(SACK) conformant connection
1302                                                  This option takes SLNetSock_SackPermitted_t struct as a parameter
1303                                   - #SLNETSOCK_TCP_MAXRTT \n
1304                                                  The maximum TCP Round Trip Time value allowed in the determination of the estimated TCP RTT. \n
1305                                                  This option takes SLNetSock_MaxRtt_t struct as a parameter
1306 
1307     \param[in] optval           Specifies a value for the option
1308     \param[in] optlen           Specifies the length of the
1309         option value
1310 
1311     \return                     Zero on success, or negative error code on failure
1312 
1313     \par Persistent
1314                 All params are <b>Non- Persistent</b>
1315 
1316     \slnetsock_init_precondition
1317 
1318     \par    Examples
1319 
1320     - SLNETSOCK_OPSOCK_RCV_BUF:
1321     \code
1322            SlNetSock_Winsize_t size;
1323            size.winsize = 3000; // bytes
1324            SlNetSock_setOpt(SockID, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPSOCK_RCV_BUF, (uint8_t *)&size, sizeof(size));
1325     \endcode
1326     <br>
1327 
1328     - SLNETSOCK_OPSOCK_RCV_TIMEO:
1329     \code
1330         struct SlNetSock_Timeval_t timeVal;
1331         timeVal.tv_sec =  1; // Seconds
1332         timeVal.tv_usec = 0; // Microseconds. 10000 microseconds resolution
1333         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPSOCK_RCV_TIMEO, (uint8_t *)&timeVal, sizeof(timeVal)); // Enable receive timeout
1334     \endcode
1335     <br>
1336 
1337     - SLNETSOCK_OPSOCK_KEEPALIVE: //disable Keepalive
1338     \code
1339         SlNetSock_Keepalive_t enableOption;
1340         enableOption.keepaliveEnabled = 0;
1341         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPSOCK_KEEPALIVE, (uint8_t *)&enableOption, sizeof(enableOption));
1342     \endcode
1343     <br>
1344 
1345     - SLNETSOCK_OPSOCK_KEEPALIVE_TIME: //Set Keepalive timeout
1346     \code
1347         int16_t Status;
1348         uint32_t TimeOut = 120;
1349         SlNetSock_setOpt(Sd, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPSOCK_KEEPALIVE_TIME, (uint8_t *)&TimeOut, sizeof(TimeOut));
1350     \endcode
1351     <br>
1352 
1353     - SLNETSOCK_OPSOCK_NON_BLOCKING: //Enable or disable nonblocking mode
1354     \code
1355            SlNetSock_Nonblocking_t enableOption;
1356            enableOption.nonBlockingEnabled = 1;
1357            SlNetSock_setOpt(SockID, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPSOCK_NON_BLOCKING, (uint8_t *)&enableOption, sizeof(enableOption));
1358     \endcode
1359     <br>
1360 
1361     - SLNETSOCK_OPSOCK_NON_IP_BOUNDARY: //disable boundary
1362     \code
1363         SlNetSock_NonIpBoundary_t enableOption;
1364         enableOption.nonIpBoundaryEnabled = 1;
1365         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPSOCK_NON_IP_BOUNDARY, (uint8_t *)&enableOption, sizeof(enableOption));
1366     \endcode
1367     <br>
1368 
1369     - SLNETSOCK_OPSOCK_LINGER:
1370     \code
1371         SlNetSock_linger_t linger;
1372         linger.l_onoff = 1;
1373         linger.l_linger = 10;
1374         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPSOCK_LINGER, &linger, sizeof(linger));
1375     \endcode
1376     <br>
1377 
1378     - SLNETSOCK_OPIP_MULTICAST_TTL:
1379      \code
1380            uint8_t ttl = 20;
1381            SlNetSock_setOpt(SockID, SLNETSOCK_LVL_IP, SLNETSOCK_OPIP_MULTICAST_TTL, &ttl, sizeof(ttl));
1382      \endcode
1383      <br>
1384 
1385     - SLNETSOCK_OPIP_ADD_MEMBERSHIP:
1386      \code
1387            SlNetSock_IpMreq_t mreq;
1388            SlNetSock_setOpt(SockID, SLNETSOCK_LVL_IP, SLNETSOCK_OPIP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
1389     \endcode
1390     <br>
1391 
1392     - SLNETSOCK_OPIP_DROP_MEMBERSHIP:
1393     \code
1394         SlNetSock_IpMreq_t mreq;
1395         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_IP, SLNETSOCK_OPIP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
1396     \endcode
1397     <br>
1398 
1399     - SLNETSOCK_OPIP_RAW_RX_NO_HEADER:
1400     \code
1401         uint32_t header = 1;  // remove ip header
1402         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_IP, SLNETSOCK_OPIP_RAW_RX_NO_HEADER, &header, sizeof(header));
1403     \endcode
1404     <br>
1405 
1406     - SLNETSOCK_OPIP_HDRINCL:
1407     \code
1408         uint32_t header = 1;
1409         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_IP, SLNETSOCK_OPIP_HDRINCL, &header, sizeof(header));
1410     \endcode
1411     <br>
1412 
1413     - SLNETSOCK_OPIP_RAW_IPV6_HDRINCL:
1414     \code
1415         uint32_t header = 1;
1416         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_IP, SLNETSOCK_OPIP_RAW_IPV6_HDRINCL, &header, sizeof(header));
1417     \endcode
1418     <br>
1419 
1420     - SLNETSOCK_OPPHY_CHANNEL:
1421     \code
1422         uint32_t newChannel = 6; // range is 1-13
1423         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_SOCKET, SLNETSOCK_OPPHY_CHANNEL, &newChannel, sizeof(newChannel));
1424     \endcode
1425     <br>
1426 
1427     - SLNETSOCK_OPPHY_RATE:
1428     \code
1429         uint32_t rate = 6; // see wlan.h SlWlanRateIndex_e for values
1430         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_PHY, SLNETSOCK_OPPHY_RATE, &rate, sizeof(rate));
1431     \endcode
1432     <br>
1433 
1434     - SLNETSOCK_OPPHY_TX_POWER:
1435     \code
1436         uint32_t txpower = 1; // valid range is 1-15
1437         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_PHY, SLNETSOCK_OPPHY_TX_POWER, &txpower, sizeof(txpower));
1438     \endcode
1439     <br>
1440 
1441     - SLNETSOCK_OPPHY_NUM_FRAMES_TO_TX:
1442     \code
1443         uint32_t numframes = 1;
1444         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_PHY, SLNETSOCK_OPPHY_NUM_FRAMES_TO_TX, &numframes, sizeof(numframes));
1445     \endcode
1446     <br>
1447 
1448     - SLNETSOCK_OPPHY_PREAMBLE:
1449     \code
1450         uint32_t preamble = 1;
1451         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_PHY, SLNETSOCK_OPPHY_PREAMBLE, &preamble, sizeof(preamble));
1452     \endcode
1453     <br>
1454 
1455     - SLNETSOCK_OPPHY_TX_INHIBIT_THRESHOLD:
1456     \code
1457         uint32_t thrshld = SLNETSOCK_TX_INHIBIT_THRESHOLD_MED;
1458         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_PHY, SLNETSOCK_OPPHY_TX_INHIBIT_THRESHOLD, &thrshld, sizeof(thrshld));
1459     \endcode
1460     <br>
1461 
1462     - SLNETSOCK_OPPHY_TX_TIMEOUT:
1463     \code
1464         uint32_t timeout = 50;
1465         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_PHY, SLNETSOCK_OPPHY_TX_TIMEOUT, &timeout, sizeof(timeout));
1466     \endcode
1467     <br>
1468 
1469     - SLNETSOCK_OPPHY_ALLOW_ACKS:
1470     \code
1471         uint32_t acks = 1; // 0 = disabled / 1 = enabled
1472         SlNetSock_setOpt(SockID, SLNETSOCK_LVL_PHY, SLNETSOCK_OPPHY_ALLOW_ACKS, &acks, sizeof(acks));
1473     \endcode
1474 
1475     \sa     slNetSock_create()
1476     \sa     SlNetSock_getOpt()
1477 */
1478 int32_t SlNetSock_setOpt(int16_t sd, int16_t level, int16_t optname, void *optval, SlNetSocklen_t optlen);
1479 
1480 
1481 /*!
1482     \brief Get socket options
1483 
1484     The SlNetSock_getOpt function gets the options associated with a socket.
1485     Options may exist at multiple protocol levels; they are always
1486     present at the uppermost socket level.
1487 
1488     The parameters optval and optlen identify a
1489     buffer in which the value for the requested option(s) are to
1490     be returned.  \c optlen is a value-result
1491     parameter, initially containing the size of the buffer
1492     pointed to by option_value, and modified on return to
1493     indicate the actual size of the value returned.  If no option
1494     value is to be supplied or returned, \c optval may be \c NULL.
1495 
1496 
1497     \param[in]  sd              Socket descriptor (handle)
1498     \param[in]  level           Defines the protocol level for this option
1499     \param[in]  optname         defines the option name to interrogate
1500     \param[out] optval          Specifies a value for the option
1501     \param[out] optlen          Specifies the length of the
1502                                 option value
1503 
1504     \return                     Zero on success, or negative error code on failure
1505 
1506     \slnetsock_init_precondition
1507 
1508     \sa     SlNetSock_create()
1509     \sa     SlNetSock_setOpt()
1510 */
1511 int32_t SlNetSock_getOpt(int16_t sd, int16_t level, int16_t optname, void *optval, SlNetSocklen_t *optlen);
1512 
1513 
1514 /*!
1515     \brief Read data from TCP socket
1516 
1517     The SlNetSock_recv function receives a message from a connection-mode socket
1518 
1519     \param[in]  sd              Socket descriptor (handle)
1520     \param[out] buf             Points to the buffer where the
1521                                 message should be stored.
1522     \param[in]  len             Specifies the length in bytes of
1523                                 the buffer pointed to by the buffer argument.
1524                                 Range: 1-16000 bytes
1525     \param[in]  flags           Specifies the type of message
1526                                 reception. On this version, this parameter is not
1527                                 supported.
1528 
1529     \return                     Return the number of bytes received,
1530                                 or a negative value if an error occurred.\n
1531                                 Using a non-blocking recv a possible negative value is #SLNETERR_BSD_EAGAIN.\n
1532                                 #SLNETERR_BSD_ENOMEM may be return in case there are no resources in the system
1533 
1534     \slnetsock_init_precondition
1535 
1536     \par    Examples
1537     \snippet ti/net/test/snippets/slnetif.c SlNetSock_recv snippet
1538 
1539     \sa     SlNetSock_create()
1540     \sa     SlNetSock_recvFrom()
1541 */
1542 int32_t SlNetSock_recv(int16_t sd, void *buf, uint32_t len, uint32_t flags);
1543 
1544 
1545 /*!
1546     \brief Read data from socket
1547 
1548     SlNetSock_recvFrom function receives a message from a connection-mode or
1549     connectionless-mode socket
1550 
1551     \param[in]  sd              Socket descriptor (handle)
1552     \param[out] buf             Points to the buffer where the message should be stored.
1553     \param[in]  len             Specifies the length in bytes of the buffer pointed to by the buffer argument.
1554                                 Range: 1-16000 bytes
1555     \param[in]  flags           Specifies the type of message
1556                                 reception. On this version, this parameter is not
1557                                 supported
1558     \param[in]  from            Pointer to an address structure
1559                                 indicating the source
1560                                 address.\n sockaddr:\n - code
1561                                 for the address format.\n - socket address,
1562                                 the length depends on the code
1563                                 format
1564     \param[in]  fromlen         Source address structure
1565                                 size. This parameter MUST be set to the size of the structure pointed to by addr.
1566 
1567 
1568     \return                     Return the number of bytes received,
1569                                 or a negative value if an error occurred.\n
1570                                 Using a non-blocking recv a possible negative value is #SLNETERR_BSD_EAGAIN.
1571                                 #SLNETERR_RET_CODE_INVALID_INPUT will be returned if fromlen has incorrect length.\n
1572                                 #SLNETERR_BSD_ENOMEM may be return in case there are no resources in the system
1573 
1574     \slnetsock_init_precondition
1575 
1576     \par        Example
1577     \snippet ti/net/test/snippets/slnetif.c SlNetSock_recvFrom snippet
1578 
1579     \sa     SlNetSock_create()
1580     \sa     SlNetSock_recv()
1581 */
1582 int32_t SlNetSock_recvFrom(int16_t sd, void *buf, uint32_t len, uint32_t flags, SlNetSock_Addr_t *from, SlNetSocklen_t *fromlen);
1583 
1584 
1585 /*!
1586     \brief Write data to TCP socket
1587 
1588     Transmits a message to another socket.
1589     Returns immediately after sending data to device.
1590     In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the
1591     frame data buffer for WLAN FCS
1592 
1593     \param[in] sd               Socket descriptor (handle)
1594     \param[in] buf              Points to a buffer containing
1595                                 the message to be sent
1596     \param[in] len              Message size in bytes.
1597     \param[in] flags            Specifies the type of message
1598                                 transmission. On this version, this parameter is not
1599                                 supported for TCP.
1600 
1601     \return                     Return the number of bytes sent,
1602                                 or a negative value if an error occurred.
1603 
1604     \slnetsock_init_precondition
1605 
1606     \par        Example
1607     \snippet ti/net/test/snippets/slnetif.c SlNetSock_send snippet
1608 
1609     \sa     SlNetSock_create()
1610     \sa     SlNetSock_sendTo()
1611 */
1612 int32_t SlNetSock_send(int16_t sd, const void *buf, uint32_t len, uint32_t flags);
1613 
1614 
1615 /*!
1616     \brief Write data to socket
1617 
1618     The SlNetSock_sendTo function is used to transmit a message on a connectionless socket
1619     (connection less socket #SLNETSOCK_SOCK_DGRAM, #SLNETSOCK_SOCK_RAW).
1620 
1621     Returns immediately after sending data to device.
1622 
1623     \param[in] sd               Socket descriptor (handle)
1624     \param[in] buf              Points to a buffer containing
1625                                 the message to be sent
1626     \param[in] len              message size in bytes.
1627     \param[in] flags            Specifies the type of message
1628                                 transmission. On this version, this parameter is not
1629                                 supported
1630     \param[in] to               Pointer to an address structure
1631                                 indicating the destination
1632                                 address.\n sockaddr:\n - code
1633                                 for the address format.\n - socket address,
1634                                 the length depends on the code
1635                                 format
1636     \param[in] tolen            Destination address structure size
1637 
1638     \return                     Return the number of bytes sent,
1639                                 or a negative value if an error occurred.\n
1640 
1641     \slnetsock_init_precondition
1642 
1643     \par    Example
1644     \snippet ti/net/test/snippets/slnetif.c SlNetSock_sendTo snippet
1645 
1646     \sa     SlNetSock_create()
1647     \sa     SlNetSock_send()
1648 */
1649 int32_t SlNetSock_sendTo(int16_t sd, const void *buf, uint32_t len, uint32_t flags, const SlNetSock_Addr_t *to, SlNetSocklen_t tolen);
1650 
1651 
1652 /*!
1653     \brief Get interface ID from socket descriptor (sd)
1654 
1655     \param[in] sd         Specifies the socket descriptor which its
1656                           interface identifier needs to be retrieved.\n
1657 
1658     \return               The interface identifier value of the
1659                           interface on success, or negative error code
1660                           on failure. The values of the interface
1661                           identifier is defined with the prefix
1662                           @c SLNETIF_ID_ in slnetif.h.
1663 
1664     \slnetsock_init_precondition
1665 
1666     \par    Examples
1667     \snippet ti/net/test/snippets/slnetif.c SlNetSock_getIfID snippet
1668 
1669     \sa         SlNetSock_create()
1670     \sa         SlNetIf_add()
1671     \sa         SlNetIf_getIDByName()
1672 */
1673 int32_t SlNetSock_getIfID(uint16_t sd);
1674 
1675 
1676 /*!
1677     \brief Creates a security attributes object
1678 
1679     Create a security attribute, which is required in order to start a secure session.
1680 
1681     \remark     When the security attributes object is no longer needed, call
1682                 SlNetSock_secAttribDelete() to destroy it.
1683 
1684     \remark     A single security object can be used to initiate several secure
1685                 sessions (provided they all have the same security attributes).
1686 
1687     \slnetsock_init_precondition
1688 
1689     \sa         SlNetSock_startSec()
1690     \sa         SlNetSock_secAttribDelete()
1691 */
1692 SlNetSockSecAttrib_t *SlNetSock_secAttribCreate(void);
1693 
1694 
1695 /*!
1696     \brief Deletes a security attributes object
1697 
1698     \param[in] secAttrib        Secure attribute handle
1699 
1700     \return                     Zero on success, or negative error code
1701                                 on failure
1702 
1703     \slnetsock_init_precondition
1704 
1705     \remark     \c secAttrib must be created using SlNetSock_secAttribCreate()
1706 
1707     \sa         SlNetSock_secAttribCreate()
1708     \sa         SlNetSock_secAttribSet()
1709     \sa         SlNetSock_startSec()
1710 */
1711 int32_t SlNetSock_secAttribDelete(SlNetSockSecAttrib_t *secAttrib);
1712 
1713 
1714 /*!
1715     \brief set a security attribute
1716 
1717     The SlNetSock_secAttribSet function is used to set a security
1718     attribute of a security attribute object.
1719 
1720     \param[in] secAttrib        Secure attribute handle
1721     \param[in] attribName       Define the actual attribute to set. Applicable values:
1722                                     - #SLNETSOCK_SEC_ATTRIB_PRIVATE_KEY \n
1723                                           Sets the private key corresponding to the local certificate \n
1724                                           This attribute takes the name of security object containing the private key and the name's length (including the NULL terminating character) as parameters \n
1725                                     - #SLNETSOCK_SEC_ATTRIB_LOCAL_CERT \n
1726                                           Sets the local certificate chain \n
1727                                           This attribute takes the name of the security object containing the certificate and the name's length (including the NULL terminating character) as parameters \n
1728                                           For certificate chains, each certificate in the chain can be added via a separate call to SlNetSock_secAttribSet, starting with the root certificate of the chain \n
1729                                     - #SLNETSOCK_SEC_ATTRIB_PEER_ROOT_CA \n
1730                                           Sets the root CA certificate \n
1731                                           This attribute takes the name of the security object containing the certificate and the name's length (including the NULL terminating character) as parameters \n
1732                                     - #SLNETSOCK_SEC_ATTRIB_DH_KEY \n
1733                                           Sets the DH Key \n
1734                                           This attribute takes the name of the security object containing the DH Key and the name's length (including the NULL terminating character) as parameters \n
1735                                     - #SLNETSOCK_SEC_ATTRIB_METHOD \n
1736                                           Sets the TLS protocol version \n
1737                                           This attribute takes a <b>SLNETSOCK_SEC_METHOD_*</b> option and <b>sizeof(uint8_t)</b> as parameters \n
1738                                     - #SLNETSOCK_SEC_ATTRIB_CIPHERS \n
1739                                           Sets the ciphersuites to be used for the connection \n
1740                                           This attribute takes a bit mask formed using <b>SLNETSOCK_SEC_CIPHER_*</b> options and <b>sizeof(uint32_t)</b> as parameters \n
1741                                     - #SLNETSOCK_SEC_ATTRIB_ALPN \n
1742                                           Sets the ALPN \n
1743                                           This attribute takes a bit mask formed using <b>SLNETSOCK_SEC_ALPN_*</b> options and <b>sizeof(uint32_t)</b> as parameters \n
1744                                     - #SLNETSOCK_SEC_ATTRIB_EXT_CLIENT_CHLNG_RESP \n
1745                                           Sets the EXT CLIENT CHLNG RESP \n
1746                                           Format TBD \n
1747                                     - #SLNETSOCK_SEC_ATTRIB_DOMAIN_NAME \n
1748                                           Sets the domain name for verification during connection \n
1749                                           This attribute takes a string with the domain name and the string's length (including the NULL-terminating character) as parameters \n
1750                                     - #SLNETSOCK_SEC_ATTRIB_DISABLE_CERT_STORE\n
1751                                           Sets whether to disable the certificate store \n
1752                                           This attribute takes <b>1</b> (disable) or <b>0</b> (enable) and <b>sizeof(uint32_t)</b> as parameters \n
1753 
1754     \param[in] val
1755     \param[in] len
1756 
1757     \return                     Zero on success, or negative error code
1758                                 on failure
1759 
1760     \slnetsock_init_precondition
1761 
1762     \note   Once an attribute is set, it cannot be unset or set to something
1763             different. Doing so may result in undefined behavior.
1764             Instead, SlNetSock_secAttribDelete() should be called on the
1765             existing object, and a new security object should be created with
1766             the new attribute set.
1767 
1768     \note   The #SLNETSOCK_SEC_ATTRIB_DISABLE_CERT_STORE value
1769             is currently being evaluated, and may be removed in a
1770             future release.  It is currently only supported on CC3xxx
1771             devices.
1772 
1773     \par    Examples
1774 
1775     - SLNETSOCK_SEC_ATTRIB_PRIVATE_KEY:
1776     \code
1777            #define PRIVATE_KEY_FILE      "DummyKey"
1778            SlNetIf_loadSecObj(SLNETIF_SEC_OBJ_TYPE_RSA_PRIVATE_KEY, PRIVATE_KEY_FILE, strlen(PRIVATE_KEY_FILE), srvKeyPem, srvKeyPemLen, SLNETIF_ID_2);
1779            SlNetSock_secAttribSet(secAttrib, SLNETSOCK_SEC_ATTRIB_PRIVATE_KEY, PRIVATE_KEY_FILE, sizeof(PRIVATE_KEY_FILE));
1780     \endcode
1781     <br>
1782 
1783     - SLNETSOCK_SEC_ATTRIB_LOCAL_CERT:
1784     \code
1785            #define ROOT_CA_CERT_FILE     "DummyCA"
1786            #define TRUSTED_CERT_FILE     "DummyTrustedCert"
1787 
1788            // create a local certificate chain
1789            SlNetIf_loadSecObj(SLNETIF_SEC_OBJ_TYPE_CERTIFICATE, ROOT_CA_CERT_FILE, strlen(ROOT_CA_CERT_FILE), srvCAPem, srvCAPemLen, SLNETIF_ID_2);
1790            SlNetIf_loadSecObj(SLNETIF_SEC_OBJ_TYPE_CERTIFICATE, TRUSTED_CERT_FILE, strlen(TRUSTED_CERT_FILE), srvCertPem, srvCertPemLen, SLNETIF_ID_2);
1791            SlNetSock_secAttribSet(secAttrib, SLNETSOCK_SEC_ATTRIB_LOCAL_CERT, ROOT_CA_CERT_FILE, sizeof(ROOT_CA_CERT_FILE));
1792            SlNetSock_secAttribSet(secAttrib, SLNETSOCK_SEC_ATTRIB_LOCAL_CERT, TRUSTED_CERT_FILE, sizeof(TRUSTED_CERT_FILE));
1793     \endcode
1794     <br>
1795 
1796     - SLNETSOCK_SEC_ATTRIB_PEER_ROOT_CA:
1797     \code
1798            #define ROOT_CA_CERT_FILE     "DummyCA"
1799            SlNetIf_loadSecObj(SLNETIF_SEC_OBJ_TYPE_CERTIFICATE, ROOT_CA_CERT_FILE, strlen(ROOT_CA_CERT_FILE), srvCAPem, srvCAPemLen, SLNETIF_ID_2);
1800            SlNetSock_secAttribSet(secAttrib, SLNETSOCK_SEC_ATTRIB_PEER_ROOT_CA, ROOT_CA_CERT_FILE, sizeof(ROOT_CA_CERT_FILE));
1801     \endcode
1802     <br>
1803 
1804     - SLNETSOCK_SEC_ATTRIB_METHOD:
1805     \code
1806         uint8_t  SecurityMethod = SLNETSOCK_SEC_METHOD_SSLV3;
1807         SlNetSock_secAttribSet(secAttrib, SLNETSOCK_SEC_ATTRIB_METHOD, (void *)&(SecurityMethod), sizeof(SecurityMethod));
1808     \endcode
1809     <br>
1810 
1811     - SLNETSOCK_SEC_ATTRIB_CIPHERS:
1812     \code
1813         uint32_t SecurityCipher = SLNETSOCK_SEC_CIPHER_SSL_RSA_WITH_RC4_128_SHA | SLNETSOCK_SEC_CIPHER_TLS_RSA_WITH_AES_256_CBC_SHA;
1814         SlNetSock_secAttribSet(secAttrib, SLNETSOCK_SEC_ATTRIB_METHOD, (void *)&(SecurityCipher), sizeof(SecurityCipher));
1815     \endcode
1816     <br>
1817 
1818     - SLNETSOCK_SEC_ATTRIB_DOMAIN_NAME:
1819     \code
1820         char addr[] = "www.ti.com";
1821         SlNetSock_secAttribSet(secAttrib, SLNETSOCK_SEC_ATTRIB_DOMAIN_NAME, (void *)addr, strlen(addr) + 1);
1822     \endcode
1823     <br>
1824 
1825 
1826     \sa         SlNetSock_secAttribCreate()
1827 */
1828 int32_t SlNetSock_secAttribSet(SlNetSockSecAttrib_t *secAttrib, SlNetSockSecAttrib_e attribName, void *val, uint16_t len);
1829 
1830 
1831 /*!
1832     \brief Start a security session on an opened socket
1833 
1834     \param[in] sd               Socket descriptor (handle)
1835     \param[in] secAttrib        Secure attribute handle. This can be NULL only
1836                                 if the SLNETSOCK_SEC_BIND_CONTEXT_ONLY flag is
1837                                 not thrown.
1838     \param[in] flags            Specifies flags. \n
1839                                 The available flags are:
1840                                     - #SLNETSOCK_SEC_START_SECURITY_SESSION_ONLY
1841                                     - #SLNETSOCK_SEC_BIND_CONTEXT_ONLY
1842                                     - #SLNETSOCK_SEC_IS_SERVER
1843 
1844     \return                     Zero on success, or negative error code
1845                                 on failure
1846 
1847     \slnetsock_init_precondition
1848 
1849     \remark     If the return value indicates failure, the socket should be
1850                 closed.
1851 
1852     \remark     If \c secAttrib is \c NULL, the session will be started with
1853                 default security settings.
1854 
1855     \sa         SlNetSock_create()
1856     \sa         SlNetSock_secAttribCreate()
1857 */
1858 int32_t SlNetSock_startSec(int16_t sd, SlNetSockSecAttrib_t *secAttrib, uint8_t flags);
1859 
1860 
1861 /*!
1862 
1863  Close the Doxygen group.
1864  @}
1865 
1866 */
1867 
1868 
1869 #ifdef  __cplusplus
1870 }
1871 #endif /* __cplusplus */
1872 
1873 #endif /* __NET_SOCK_H__ */
1874