1 /*
2  * sl_socket.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
5  *
6  *
7  *  Redistribution and use in source and binary forms, with or without
8  *  modification, are permitted provided that the following conditions
9  *  are met:
10  *
11  *    Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
14  *    Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the
17  *    distribution.
18  *
19  *    Neither the name of Texas Instruments Incorporated nor the names of
20  *    its contributors may be used to endorse or promote products derived
21  *    from this software without specific prior written permission.
22  *
23  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35 */
36 
37 /*****************************************************************************/
38 /* Include files                                                             */
39 /*****************************************************************************/
40 #include <ti/drivers/net/wifi/simplelink.h>
41 
42 #ifndef __SL_SOCKET_H__
43 #define __SL_SOCKET_H__
44 
45 
46 #ifdef    __cplusplus
47 extern "C" {
48 #endif
49 
50 /*!
51     \defgroup Socket
52     \short Controls standard client/server sockets programming options and capabilities
53 
54 */
55 /*!
56 
57     \addtogroup Socket
58     @{
59 
60 */
61 
62 /*****************************************************************************/
63 /* Macro declarations                                                        */
64 /*****************************************************************************/
65 #undef SL_FD_SETSIZE
66 #define SL_FD_SETSIZE                                         SL_MAX_SOCKETS  /* Number of sockets to select on - same is max sockets! */
67 #define SL_BSD_SOCKET_ID_MASK                                 (0x1F)          /* Index using the LBS 4 bits for socket id 0-7 */
68 
69 /* Define some BSD protocol constants.  */
70 #define SL_SOCK_STREAM                                        (1)   /* TCP Socket */
71 #define SL_SOCK_DGRAM                                         (2)   /* UDP Socket */
72 #define SL_SOCK_RAW                                           (3)   /* Raw socket */
73 #define SL_SOCK_RX_MTR                                        (4)   /* Used for traffic RX metrics                                         */
74 #define SL_IPPROTO_TCP                                        (6)   /* TCP Raw Socket */
75 #define SL_IPPROTO_UDP                                        (17)  /* UDP Raw Socket */
76 #define SL_IPPROTO_RAW                                        (255) /* Raw Socket */
77 #define SL_SEC_SOCKET                                         (100) /* Secured Socket Layer (SSL,TLS) */
78 
79 /* Address families.  */
80 #define     SL_AF_INET                                        (2)   /* IPv4 socket (UDP, TCP, etc) */
81 #define     SL_AF_INET6                                       (3)   /* IPv6 socket (UDP, TCP, etc) */
82 #define     SL_AF_RF                                          (6)   /* data include RF parameter, All layer by user (Wifi could be disconnected) */
83 #define     SL_AF_PACKET                                      (17)
84 /* Protocol families, same as address families.  */
85 #define     SL_PF_INET                                        AF_INET
86 #define     SL_PF_INET6                                       AF_INET6
87 #define     SL_INADDR_ANY                                     (0)   /* bind any address */
88 #define     SL_IN6ADDR_ANY                                    (0)
89 
90 
91 /* Max payload size by protocol */
92 #define SL_SOCKET_PAYLOAD_TYPE_MASK                           (0xF0)  /*4 bits type, 4 bits sockets id */
93 #define SL_SOCKET_PAYLOAD_TYPE_RAW_TRANCEIVER                 (0x80)  /* 1536 bytes */
94 
95 /* SL_SOCKET_EVENT_CLASS_BSD user events */
96 #define    SL_SOCKET_TX_FAILED_EVENT                          (1)
97 #define    SL_SOCKET_ASYNC_EVENT                              (2)
98 
99 
100 /* SL_SOCKET_EVENT_CLASS_BSD user trigger events */
101 #define    SL_SOCKET_TRIGGER_EVENT_SELECT                     (1)
102 
103 #define SL_SOL_SOCKET                                         (1)  /* Define the socket option category. */
104 #define SL_IPPROTO_IP                                         (2)  /* Define the IP option category.     */
105 #define SL_SOL_PHY_OPT                                        (3)  /* Define the PHY option category.    */
106 
107 #define SL_SO_RCVBUF                                          (8)  /* Setting TCP receive buffer size */
108 #define SL_SO_KEEPALIVE                                       (9)  /* Connections are kept alive with periodic messages */
109 #define SL_SO_LINGER                                          (13) /* Socket lingers on close pending remaining send/receive packets. */
110 #define SL_SO_RCVTIMEO                                        (20) /* Enable receive timeout */
111 #define SL_SO_NONBLOCKING                                     (24) /* Enable . disable nonblocking mode  */
112 #define SL_SO_SECMETHOD                                       (25) /* security metohd */
113 #define SL_SO_SECURE_MASK                                     (26) /* security mask */
114 #define SL_SO_SECURE_FILES                                    (27) /* security files */
115 #define SL_SO_CHANGE_CHANNEL                                  (28) /* This option is available only when transceiver started */
116 #define SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME              (30) /* This option used to configue secure file */
117 #define SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME              (31) /* This option used to configue secure file */
118 #define SL_SO_SECURE_FILES_CA_FILE_NAME                       (32) /* This option used to configue secure file */
119 #define SL_SO_SECURE_FILES_PEER_CERT_OR_DH_KEY_FILE_NAME      (33) /* This option used to configue secure file - in server mode DH params file, and in client mode peer cert for domain verification */
120 #define SL_SO_STARTTLS                                        (35) /* initiate STARTTLS on non secure socket */
121 #define SL_SO_SSL_CONNECTION_PARAMS                           (36) /* retrieve by getsockopt the connection params of the current SSL connection in to SlSockSSLConnectionParams_t*/
122 #define SL_SO_KEEPALIVETIME                                   (37) /* keepalive time out  */
123 #define SL_SO_SECURE_DISABLE_CERTIFICATE_STORE                (38) /* disable certificate store */
124 #define SL_SO_RX_NO_IP_BOUNDARY                               (39) /* connectionless socket disable rx boundary */
125 #define SL_SO_SECURE_ALPN                                     (40) /* set the ALPN bitmap list */
126 #define SL_SO_SECURE_EXT_CLIENT_CHLNG_RESP                    (41) /*set external challange for client certificate */
127 #define SL_SO_SECURE_DOMAIN_NAME_VERIFICATION                 (42) /* set a domain name for verification */
128 #define SL_SO_SECURE_ENABLE_OCSP                              (43) /* enable OCSP and OCSP stapling */
129 #define SL_SO_SECURE_ALPN_GENERAL                             (44) /* set ALPN protocol name by string - only one protocol name can be set */
130 
131 #define SL_IP_MULTICAST_IF                                    (60) /* Specify outgoing multicast interface */
132 #define SL_IP_MULTICAST_TTL                                   (61) /* Specify the TTL value to use for outgoing multicast packet. */
133 #define SL_IP_ADD_MEMBERSHIP                                  (65) /* Join IPv4 multicast membership */
134 #define SL_IP_DROP_MEMBERSHIP                                 (66) /* Leave IPv4 multicast membership */
135 #define SL_IP_HDRINCL                                         (67) /* Raw socket IPv4 header included. */
136 #define SL_IP_RAW_RX_NO_HEADER                                (68) /* Proprietary socket option that does not includeIPv4/IPv6 header (and extension headers) on received raw sockets*/
137 #define SL_IP_RAW_IPV6_HDRINCL                                (69) /* Transmitted buffer over IPv6 socket contains IPv6 header. */
138 #define SL_IPV6_ADD_MEMBERSHIP                                (70) /* Join IPv6 multicast membership */
139 #define SL_IPV6_DROP_MEMBERSHIP                               (71) /* Leave IPv6 multicast membership */
140 #define SL_IPV6_MULTICAST_HOPS                                (72) /* Specify the hops value to use for outgoing multicast packet. */
141 
142 #define SL_SO_PHY_RATE                                        (100) /* WLAN Transmit rate */
143 #define SL_SO_PHY_TX_POWER                                    (101) /* TX Power level */
144 #define SL_SO_PHY_NUM_FRAMES_TO_TX                            (102) /* Number of frames to transmit */
145 #define SL_SO_PHY_PREAMBLE                                    (103) /* Preamble for transmission */
146 #define SL_SO_PHY_TX_INHIBIT_THRESHOLD                        (104) /* TX Inhibit Threshold (CCA) */
147 #define SL_SO_PHY_TX_TIMEOUT                                  (105) /* TX timeout for Transceiver frames (lifetime) in miliseconds (max value is 100ms) */
148 #define SL_SO_PHY_ALLOW_ACKS                                  (106) /* Enable sending ACKs in transceiver mode */
149 #define SL_SO_PHY_RX_BSSID_DATA_FRAMES                        (107) /* Collect mertics from all data frames in the BSS on the RX metrics socket */
150 
151 typedef enum
152 {
153     SL_TX_INHIBIT_THRESHOLD_MIN = 1,
154     SL_TX_INHIBIT_THRESHOLD_LOW = 2,
155     SL_TX_INHIBIT_THRESHOLD_DEFAULT = 3,
156     SL_TX_INHIBIT_THRESHOLD_MED = 4,
157     SL_TX_INHIBIT_THRESHOLD_HIGH = 5,
158     SL_TX_INHIBIT_THRESHOLD_MAX = 6
159 } SlTxInhibitThreshold_e;
160 
161 #define SL_SO_SEC_METHOD_SSLV3                                       (0)  /* security metohd SSL v3*/
162 #define SL_SO_SEC_METHOD_TLSV1                                       (1)  /* security metohd TLS v1*/
163 #define SL_SO_SEC_METHOD_TLSV1_1                                     (2)  /* security metohd TLS v1_1*/
164 #define SL_SO_SEC_METHOD_TLSV1_2                                     (3)  /* security metohd TLS v1_2*/
165 #define SL_SO_SEC_METHOD_SSLv3_TLSV1_2                               (4)  /* use highest possible version from SSLv3 - TLS 1.2*/
166 #define SL_SO_SEC_METHOD_DLSV1                                       (5)  /* security metohd DTL v1  */
167 
168 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA                         (1 << 0)
169 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_MD5                         (1 << 1)
170 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA                     (1 << 2)
171 #define SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_CBC_SHA                 (1 << 3)
172 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA               (1 << 4)
173 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_RC4_128_SHA                   (1 << 5)
174 #define SL_SEC_MASK_TLS_RSA_WITH_AES_128_CBC_SHA256                  (1 << 6)
175 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA256                  (1 << 7)
176 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256            (1 << 8)
177 #define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256          (1 << 9)
178 #define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA             (1 << 10)
179 #define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA             (1 << 11)
180 #define SL_SEC_MASK_TLS_RSA_WITH_AES_128_GCM_SHA256                  (1 << 12)
181 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_GCM_SHA384                  (1 << 13)
182 #define SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256              (1 << 14)
183 #define SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384              (1 << 15)
184 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256            (1 << 16)
185 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384            (1 << 17)
186 #define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256          (1 << 18)
187 #define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384          (1 << 19)
188 #define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256    (1 << 20)
189 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256      (1 << 21)
190 #define SL_SEC_MASK_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256        (1 << 22)
191 
192 #define SL_SEC_MASK_SECURE_DEFAULT                                   ((SL_SEC_MASK_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256  <<  1)  -  1)
193 
194 #define SL_SECURE_ALPN_H1                                            (1 << 0)
195 #define SL_SECURE_ALPN_H2                                            (1 << 1)
196 #define SL_SECURE_ALPN_H2C                                           (1 << 2)
197 #define SL_SECURE_ALPN_H2_14                                         (1 << 3)
198 #define SL_SECURE_ALPN_H2_16                                         (1 << 4)
199 #define SL_SECURE_ALPN_FULL_LIST                                     ((SL_SECURE_ALPN_H2_16 << 1 ) - 1)
200 
201 #define SL_MSG_DONTWAIT                                              (0x00000008)  /* Nonblocking IO */
202 
203 /* AP DHCP Server - IP Release reason code */
204 #define SL_IP_LEASE_PEER_RELEASE     (0)
205 #define SL_IP_LEASE_PEER_DECLINE     (1)
206 #define SL_IP_LEASE_EXPIRED          (2)
207 
208 /* possible types when receiving SL_SOCKET_ASYNC_EVENT*/
209 #define SL_SSL_ACCEPT                                        (0) /* accept failed due to ssl issue ( tcp pass) */
210 #define SL_RX_FRAGMENTATION_TOO_BIG                          (1) /* connection less mode, rx packet fragmentation > 16K, packet is being released */
211 #define SL_OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED           (2) /* remote side down from secure to unsecure */
212 #define SL_SSL_NOTIFICATION_CONNECTED_SECURED                (3) /* STARTTLS success */
213 #define SL_SSL_NOTIFICATION_HANDSHAKE_FAILED                 (4) /* STARTTLS handshake faild */
214 #define SL_SSL_NOTIFICATION_WRONG_ROOT_CA                    (5) /* Root CA configured is wrong, the name is in SocketAsyncEvent.EventData.extraInfo */
215 #define SL_SOCKET_ASYNC_EVENT_SSL_NOTIFICATION_WRONG_ROOT_CA (5)
216 #define SL_MAX_ISSUER_AND_SUBJECT_NAME_LEN                   (16)
217 
218 /*****************************************************************************/
219 /* Structure/Enum declarations                                               */
220 /*****************************************************************************/
221 
222 /* Internet address   */
223 typedef struct SlInAddr_t
224 {
225 #ifndef s_addr
226     _u32           s_addr;             /* Internet address 32 bits */
227 #else
228     union S_un {
229        struct { _u8 s_b1,s_b2,s_b3,s_b4; } S_un_b;
230        struct { _u16 s_w1,s_w2; } S_un_w;
231         _u32 S_addr;
232     } S_un;
233 #endif
234 }SlInAddr_t;
235 
236 /* IpV6 or Ipv6 EUI64 */
237 typedef struct SlIn6Addr_t
238 {
239     union
240     {
241         _u8   _S6_u8[16];
242         _u32  _S6_u32[4];
243     } _S6_un;
244 }SlIn6Addr_t;
245 
246 
247 /* sockopt */
248 typedef struct
249 {
250     _u32 KeepaliveEnabled; /* 0 = disabled;1 = enabled; default = 1*/
251 }SlSockKeepalive_t;
252 
253 typedef struct
254 {
255     _u32 ReuseaddrEnabled; /* 0 = disabled; 1 = enabled; default = 1*/
256 }SlSockReuseaddr_t;
257 
258 typedef struct
259 {
260     _i32 RxIpNoBoundaryEnabled;  /* 0 = keep IP boundary; 1 = don`t keep ip boundary; default = 0; */
261 } SlSockRxNoIpBoundary_t;
262 
263 typedef struct
264 {
265     _u32 WinSize;          /* receive window size for tcp sockets  */
266 }SlSockWinsize_t;
267 
268 typedef struct
269 {
270     _u32 NonBlockingEnabled;/* 0 = disabled;1 = enabled;default = 1*/
271 }SlSockNonblocking_t;
272 
273 typedef struct
274 {
275     _u8   Sd;
276     _u8   Type;
277     _i16  Val;
278     _i8   pExtraInfo[128];
279 } SlSocketAsyncEvent_t;
280 
281 typedef struct
282 {
283    _i16        Status;
284     _u8        Sd;
285     _u8        Padding;
286 } SlSockTxFailEventData_t;
287 
288 
289 typedef union
290 {
291     SlSockTxFailEventData_t   SockTxFailData;
292     SlSocketAsyncEvent_t      SockAsyncData;
293 } SlSockEventData_u;
294 
295 
296 typedef struct
297 {
298    _u32                    Event;
299     SlSockEventData_u      SocketAsyncEvent;
300 } SlSockEvent_t;
301 
302 typedef struct
303 {
304    _u32         Event;
305    _u32         EventData;
306 } SlSockTriggerEvent_t;
307 
308 
309 typedef struct
310 {
311     _u32    SecureALPN;
312 } SlSockSecureALPN_t;
313 
314 typedef struct
315 {
316     _u32    SecureMask;
317 } SlSockSecureMask_t;
318 
319 typedef struct
320 {
321     _u8     SecureMethod;
322 } SlSockSecureMethod_t;
323 
324 typedef struct
325 {
326     _u16 SubjectNameXoredSha1;
327     _u16 IssuerNameXoredSha1;
328     _i8  FromDate[8];
329     _i8  ToDate[8];
330     _i8  SubjectName[SL_MAX_ISSUER_AND_SUBJECT_NAME_LEN];
331     _i8  IssuerName[SL_MAX_ISSUER_AND_SUBJECT_NAME_LEN];
332     _i8  SubjectNameLen;
333     _i8  IssuerNameLen;
334     _i8  Padding[2];
335 } SlSockSSLCertInfo_t;
336 
337 
338 typedef struct
339 {
340     _u32     SecureVersion;              /* what version of SSL decided in the handshake    */
341     _u32     SecureCipherSuit;           /* what Cipher Index was decided in the handshake  */
342     _u32     SecureIsPeerValidated;      /* was the other peer verified         */
343     _u32     SecureALPNChosenProtocol;    /* bit indicate one of the protocol defined above
344                                          SL_SECURE_ALPN_H1
345                                          SL_SECURE_ALPN_H2
346                                          SL_SECURE_ALPN_H2C
347                                          SL_SECURE_ALPN_H2_14
348                                          SL_SECURE_ALPN_H2_16
349                                          */
350     SlSockSSLCertInfo_t SecurePeerCertinfo;
351 } SlSockSSLConnectionParams_t;
352 
353 
354 typedef struct
355 {
356     _u16 type;   /* holds the type of the info frame, currently only value 1 indicating DATA frame */
357     _u16 length; /* holds the length of the info frame recevied */
358 }SlRxMetrics_TLV_t;
359 
360 
361 typedef enum
362 {
363     SL_SOCK_TX_RATE_1M         = 1,
364     SL_SOCK_TX_RATE_2M         = 2,
365     SL_SOCK_TX_RATE_5_5M       = 3,
366     SL_SOCK_TX_RATE_11M        = 4,
367     SL_SOCK_TX_RATE_6M         = 6,
368     SL_SOCK_TX_RATE_9M         = 7,
369     SL_SOCK_TX_RATE_12M        = 8,
370     SL_SOCK_TX_RATE_18M        = 9,
371     SL_SOCK_TX_RATE_24M        = 10,
372     SL_SOCK_TX_RATE_36M        = 11,
373     SL_SOCK_TX_RATE_48M        = 12,
374     SL_SOCK_TX_RATE_54M        = 13,
375     SL_SOCK_TX_RATE_MCS_0      = 14,
376     SL_SOCK_TX_RATE_MCS_1      = 15,
377     SL_SOCK_TX_RATE_MCS_2      = 16,
378     SL_SOCK_TX_RATE_MCS_3      = 17,
379     SL_SOCK_TX_RATE_MCS_4      = 18,
380     SL_SOCK_TX_RATE_MCS_5      = 19,
381     SL_SOCK_TX_RATE_MCS_6      = 20,
382     SL_SOCK_TX_RATE_MCS_7      = 21,
383     SL_SOCK_TX_MAX_NUM_RATES   = 0xFF
384 }slSockTransceiverTXRateTable_e;
385 
386 
387 typedef enum
388 {
389     SL_SOCK_RX_RATE_1M       =  0,
390     SL_SOCK_RX_RATE_2M       =  1,
391     SL_SOCK_RX_RATE_5_5M     =  2,
392     SL_SOCK_RX_RATE_11M      =  3,
393     SL_SOCK_RX_RATE_6M       =  4,
394     SL_SOCK_RX_RATE_9M       =  5,
395     SL_SOCK_RX_RATE_12M      =  6,
396     SL_SOCK_RX_RATE_18M      =  7,
397     SL_SOCK_RX_RATE_24M      =  8,
398     SL_SOCK_RX_RATE_36M      =  9,
399     SL_SOCK_RX_RATE_48M      =  10,
400     SL_SOCK_RX_RATE_54M      =  11,
401     SL_SOCK_RX_RATE_MCS0     =  12, /* 6.5Mbps */
402     SL_SOCK_RX_RATE_MCS1     =  13, /* 13Mbps */
403     SL_SOCK_RX_RATE_MCS2     =  14, /* 19.5Mbps */
404     SL_SOCK_RX_RATE_MCS3     =  15, /* 26Mbps */
405     SL_SOCK_RX_RATE_MCS4     =  16, /* 39Mbps */
406     SL_SOCK_RX_RATE_MCS5     =  17, /* 52Mbps */
407     SL_SOCK_RX_RATE_MCS6     =  18, /* 58.5Mbps */
408     SL_SOCK_RX_RATE_MCS7     =  19, /* 65Mbps */
409     SL_SOCK_RX_RATE_MCS7_SGI =  20, /* 65Mbps+10% */
410 
411 }SlSockTransceiverRXRates_e;
412 
413 typedef enum
414 {
415   SL_BSD_SECURED_PRIVATE_KEY_IDX = 0,
416   SL_BSD_SECURED_CERTIFICATE_IDX,
417   SL_BSD_SECURED_CA_IDX,
418   SL_BSD_SECURED_DH_IDX
419 }SlSockSecureSocketFilesIndex_e;
420 
421 typedef struct
422 {
423     SlInAddr_t   imr_multiaddr;   /* The IPv4 multicast address to join */
424     SlInAddr_t   imr_interface;   /* The interface to use for this group */
425 }SlSockIpMreq_t;
426 
427 typedef struct{
428     SlIn6Addr_t ipv6mr_multiaddr; /* IPv6 multicast address of group */
429     _u32        ipv6mr_interface; /*should be 0 to choose the default multicast interface*/
430 }SlSockIpV6Mreq_t;
431 
432 typedef struct
433 {
434     _u32 l_onoff;                 /* 0 = disabled; 1 = enabled; default = 0;*/
435     _u32 l_linger;                /* linger time in seconds; default = 0;*/
436 }SlSocklinger_t;
437 
438 /* sockopt */
439 typedef _i32   SlTime_t;
440 typedef _i32   SlSuseconds_t;
441 
442 typedef struct SlTimeval_t
443 {
444     SlTime_t          tv_sec;     /* Seconds */
445     SlSuseconds_t     tv_usec;    /* Microseconds */
446 }SlTimeval_t;
447 
448 typedef _u16 SlSocklen_t;
449 
450 /* IpV4 socket address */
451 typedef struct SlSockAddr_t
452 {
453     _u16          sa_family;     /* Address family (e.g. , AF_INET)     */
454     _u8           sa_data[14];  /* Protocol- specific address information*/
455 }SlSockAddr_t;
456 
457 typedef struct SlSockAddrIn6_t
458 {
459     _u16           sin6_family;                 /* AF_INET6 || AF_INET6_EUI_48*/
460     _u16           sin6_port;                   /* Transport layer port.  */
461     _u32           sin6_flowinfo;               /* IPv6 flow information. */
462     SlIn6Addr_t    sin6_addr;                   /* IPv6 address. */
463     _u32           sin6_scope_id;               /* set of interfaces for a scope. */
464 }SlSockAddrIn6_t;
465 
466 /* Socket address, Internet style. */
467 
468 typedef struct SlSockAddrIn_t
469 {
470     _u16              sin_family;         /* Internet Protocol (AF_INET). */
471     _u16              sin_port;           /* Address port (16 bits). */
472     SlInAddr_t        sin_addr;           /* Internet address (32 bits). */
473     _i8               sin_zero[8];        /* Not used. */
474 }SlSockAddrIn_t;
475 
476 typedef struct
477 {
478     _u8  SecureFiles[4];
479 }SlSockSecureFiles_t;
480 
481 typedef struct SlFdSet_t  /* The select socket array manager */
482 {
483    _u32        fd_array[(SL_FD_SETSIZE + (_u8)31)/(_u8)32]; /* Bit map of SOCKET Descriptors */
484 } SlFdSet_t;
485 
486 typedef struct
487 {
488     _u8    Rate;               /* Received Rate, refer to slSockTransceiverRXRateTable_e  */
489     _u8    Channel;            /* The received channel*/
490     _i8    Rssi;               /* The computed RSSI value in db of current frame */
491     _u8    Padding;            /* pad to align to 32 bits */
492     _u32   Timestamp;          /* Timestamp in microseconds */
493 }SlTransceiverRxOverHead_t;
494 
495 typedef struct
496 {
497     _u32 enableDisable; /* 1 to enable collecting metrics from BSS, 0 - collecting metrics from AP only. (0 is the default state) */
498 }SlRxMetricsEnableDisableRXOnBSS_t;
499 
500 
501 /*****************************************************************************/
502 /* Function prototypes                                                       */
503 /*****************************************************************************/
504 
505 /*!
506 
507     \brief Create an endpoint for communication
508 
509     The socket function creates a new socket of a certain socket type, identified
510     by an integer number, and allocates system resources to it.\n
511     This function is called by the application layer to obtain a socket handle.
512 
513     \param[in] Domain           Specifies the protocol family of the created socket.
514                                 For example:
515                                    - SL_AF_INET for network protocol IPv4
516                                    - SL_AF_INET6 for network protocol IPv6
517                                    - SL_AF_RF for starting transceiver mode. Notes:
518                                         - sending and receiving any packet overriding 802.11 header
519                                         - for optimized power consumption the socket will be started in TX
520                                           only mode until receive command is activated
521 
522     \param[in] Type              specifies the communication semantic, one of:
523                                    - SL_SOCK_STREAM (reliable stream-oriented service or Stream Sockets)
524                                    - SL_SOCK_DGRAM (datagram service or Datagram Sockets)
525                                    - SL_SOCK_RAW (raw protocols atop the network layer)
526                                    - when used with AF_RF:
527                                       - SL_SOCK_DGRAM - L2 socket
528                                       - SL_SOCK_RAW - L1 socket - bypass WLAN CCA (Clear Channel Assessment)
529                                         The Protocol parameter is used to set the channel number.
530                                         Within this parameter, low power low rate flag can be set by using the macro SL_WLAN_RAW_RF_SOCKET_CHANNEL.
531                                         i.e sl_Socket(SL_AF_RF, SL_SOCK_RAW, SL_WLAN_RAW_RF_SOCKET_CHANNEL(36, TRANSCEIVER_5G_LOW_POWER_LOW_RATE));
532                                       - SL_SOCK_RX_MTR - opening socket to receive information frames with the following format in STA and P2P client only.
533                                         | SlRxMetrics_TLV_t | SlTransceiverRxOverHead_t | WLAN header (24 / 26 bytes depending on QOS) payload |
534                                         collecting WLAN headers and RX metrics between the device and the AP.
535                                         if used with the setsockopt - SL_SO_PHY_RX_BSSID_DATA_FRAMES, the device start collecting
536                                         WLAN headers of other devices in the BSS
537 
538     \param[in] Protocol         specifies a particular transport to be used with
539                                 the socket. \n
540                                 The most common are
541                                     - SL_IPPROTO_TCP
542                                     - SL_IPPROTO_UDP
543                                 The value 0 may be used to select a default
544                                 protocol from the selected domain and type
545 
546     \return                     On success, socket handle that is used for consequent socket operations. \n
547                                 A successful return code should be a positive number (int16)\n
548                                 On error, a negative (int16) value will be returned specifying the error code.
549                                    - SL_EAFNOSUPPORT  - illegal domain parameter
550                                    - SL_EPROTOTYPE  - illegal type parameter
551                                    - SL_EACCES   - permission denied
552                                    - SL_ENSOCK  - exceeded maximal number of socket
553                                    - SL_ENOMEM  - memory allocation error
554                                    - SL_EINVAL  - error in socket configuration
555                                    - SL_EPROTONOSUPPORT  - illegal protocol parameter
556                                    - SL_EOPNOTSUPP  - illegal combination of protocol and type parameters
557 
558     \sa                         sl_Close
559     \note                       belongs to \ref basic_api
560     \warning
561 */
562 #if _SL_INCLUDE_FUNC(sl_Socket)
563 _i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol);
564 #endif
565 
566 /*!
567     \brief Gracefully close socket
568 
569     This function causes the system to release resources allocated to a socket.  \n
570     In case of TCP, the connection is terminated.
571 
572     \param[in] sd               Socket handle (received in sl_Socket)
573 
574     \return                     Zero on success, or negative error code on failure
575 
576     \sa                         sl_Socket
577     \note                       belongs to \ref ext_api
578     \warning
579 */
580 #if _SL_INCLUDE_FUNC(sl_Close)
581 _i16 sl_Close(_i16 sd);
582 #endif
583 
584 /*!
585     \brief Accept a connection on a socket
586 
587     This function is used with connection-based socket types (SOCK_STREAM).\n
588     It extracts the first connection request on the queue of pending
589     connections, creates a new connected socket, and returns a new file
590     descriptor referring to that socket.\n
591     The newly created socket is not in the listening state. The
592     original socket sd is unaffected by this call. \n
593     The argument sd is a socket that has been created with
594     sl_Socket(), bound to a local address with sl_Bind(), and is
595     listening for connections after a sl_Listen(). The argument \b
596     \e addr is a pointer to a sockaddr structure. This structure
597     is filled in with the address of the peer socket, as known to
598     the communications layer. The exact format of the address
599     returned addr is determined by the socket's address family. \n
600     The \b \e addrlen argument is a value-result argument: it
601     should initially contain the size of the structure pointed to
602     by addr, on return it will contain the actual length (in
603     bytes) of the address returned.
604 
605     \param[in] sd               Socket descriptor (handle)
606     \param[out] addr            The argument addr is a pointer
607                                 to a sockaddr structure. This
608                                 structure is filled in with the
609                                 address of the peer socket, as
610                                 known to the communications
611                                 layer. The exact format of the
612                                 address returned addr is
613                                 determined by the socket's
614                                 address\n
615                                 sockaddr:\n - code for the
616                                 address format. On this version
617                                 only AF_INET is supported.\n -
618                                 socket address, the length
619                                 depends on the code format
620     \param[out] addrlen         The addrlen argument is a value-result
621                                 argument: it should initially contain the
622                                 size of the structure pointed to by addr
623 
624     \return                     On success, a socket handle.\n
625                                 On a non-blocking accept a possible negative value is SL_EAGAIN.\n
626                                 On failure, negative error code.\n
627                                 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
628                                  In this case try again later or increase MAX_CONCURRENT_ACTIONS
629 
630     \sa                         sl_Socket  sl_Bind  sl_Listen
631     \note                       Belongs to \ref server_side
632     \warning
633 */
634 #if _SL_INCLUDE_FUNC(sl_Accept)
635 _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen);
636 #endif
637 
638 /*!
639     \brief Assign a name to a socket
640 
641     This function gives the socket the local address addr.
642     addr is addrlen bytes long. Traditionally, this is called
643     When a socket is created with socket, it exists in a name
644     space (address family) but has no name assigned.
645     It is necessary to assign a local address before a SOCK_STREAM
646     socket may receive connections.
647 
648     \param[in] sd               Socket descriptor (handle)
649     \param[in] addr             Specifies the destination
650                                 addrs\n sockaddr:\n - code for
651                                 the address format. On this
652                                 version only SL_AF_INET is
653                                 supported.\n - socket address,
654                                 the length depends on the code
655                                 format
656     \param[in] addrlen          Contains the size of the structure pointed to by addr
657 
658     \return                     Zero on success, or negative error code on failure
659 
660     \sa                         sl_Socket  sl_Accept sl_Listen
661     \note                       belongs to \ref basic_api
662     \warning
663 */
664 #if _SL_INCLUDE_FUNC(sl_Bind)
665 _i16 sl_Bind(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
666 #endif
667 
668 /*!
669     \brief Listen for connections on a socket
670 
671     The willingness to accept incoming connections and a queue
672     limit for incoming connections are specified with listen(),
673     and then the connections are accepted with accept.
674     The listen() call applies only to sockets of type SOCK_STREAM
675     The backlog parameter defines the maximum length the queue of
676     pending connections may grow to.
677 
678     \param[in] sd               Socket descriptor (handle)
679     \param[in] backlog          Specifies the listen queue depth.
680 
681     \return                     Zero on success, or negative error code on failure
682 
683     \sa                         sl_Socket  sl_Accept  sl_Bind
684     \note                       Belongs to \ref server_side
685     \warning
686 */
687 #if _SL_INCLUDE_FUNC(sl_Listen)
688 _i16 sl_Listen(_i16 sd, _i16 backlog);
689 #endif
690 
691 /*!
692     \brief Initiate a connection on a socket
693 
694     Function connects the socket referred to by the socket
695     descriptor sd, to the address specified by addr. The addrlen
696     argument specifies the size of addr. The format of the
697     address in addr is determined by the address space of the
698     socket. If it is of type SOCK_DGRAM, this call specifies the
699     peer with which the socket is to be associated; this address
700     is that to which datagrams are to be sent, and the only
701     address from which datagrams are to be received.  If the
702     socket is of type SOCK_STREAM, this call attempts to make a
703     connection to another socket. The other socket is specified
704     by address, which is an address in the communications space
705     of the socket.
706 
707 
708     \param[in] sd               Socket descriptor (handle)
709     \param[in] addr             Specifies the destination addr\n
710                                 sockaddr:\n - code for the
711                                 address format. On this version
712                                 only AF_INET is supported.\n -
713                                 socket address, the length
714                                 depends on the code format
715 
716     \param[in] addrlen          Contains the size of the structure pointed
717                                 to by addr
718 
719     \return                     On success, a socket handle.\n
720                                 On a non-blocking connect a possible negative value is SL_EALREADY.
721                                 On failure, negative value.\n
722                                 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
723                                   In this case try again later or increase MAX_CONCURRENT_ACTIONS
724 
725     \sa                         sl_Socket
726     \note                       belongs to \ref client_side
727     \warning
728 */
729 #if _SL_INCLUDE_FUNC(sl_Connect)
730 _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
731 #endif
732 
733 /*!
734     \brief Monitor socket activity
735 
736     Select allow a program to monitor multiple file descriptors,
737     waiting until one or more of the file descriptors become
738     "ready" for some class of I/O operation.
739     If trigger mode is enabled the active fdset is the one that was retrieved in the first triggered call.
740     To enable the trigger mode, an handler must be statically registered as slcb_SocketTriggerEventHandler in user.h
741 
742 
743     \param[in]  nfds        The highest-numbered file descriptor in any of the
744                             three sets, plus 1.
745     \param[out] readsds     Socket descriptors list for read monitoring and accept monitoring
746     \param[out] writesds    Socket descriptors list for connect monitoring only, write monitoring is not supported
747     \param[out] exceptsds   Socket descriptors list for exception monitoring, not supported.
748     \param[in]  timeout     Is an upper bound on the amount of time elapsed
749                             before select() returns. Null or above 0xffff seconds means
750                             infinity timeout. The minimum timeout is 10 milliseconds,
751                             less than 10 milliseconds will be set automatically to 10 milliseconds.
752                             Max microseconds supported is 0xfffc00.
753                             In trigger mode the timout fields must be set to zero.
754 
755     \return                 On success, select()  returns the number of
756                             file descriptors contained in the three returned
757                             descriptor sets (that is, the total number of bits that
758                             are set in readfds, writefds, exceptfds) which may be
759                             zero if the timeout expires before anything interesting
760                             happens.\n On error, a negative value is returned.
761                             readsds - return the sockets on which read request will
762                             return without delay with valid data.\n
763                             writesds - return the sockets on which write request
764                             will return without delay.\n
765                             exceptsds - return the sockets closed recently. \n
766                             SL_POOL_IS_EMPTY may be return in case there are no resources in the system
767                             In this case try again later or increase MAX_CONCURRENT_ACTIONS
768 
769     \sa     sl_Socket
770     \note   If the timeout value set to less than 10ms it will automatically set
771             to 10ms to prevent overload of the system\n
772             Belongs to \ref basic_api
773 
774             Several threads can call sl_Select at the same time.\b
775             Calling this API while the same command is called from another thread, may result
776                 in one of the following scenarios:
777             1. The command will be executed alongside other select callers (success).
778             2. The command will wait (internal) until the previous sl_select finish, and then be executed.
779             3. There are not enough resources and SL_POOL_IS_EMPTY error will return.
780             In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
781             again later to issue the command.
782 
783             In case all the user sockets are open, sl_Select will exhibit the behavior mentioned in (2)
784             This is due to the fact sl_select supports multiple callers by utilizing one user socket internally.
785             User who wish to ensure multiple select calls at any given time, must reserve one socket out of the 16 given.
786 
787     \warning
788             multiple select calls aren't supported when trigger mode is active. The two are mutually exclusive.
789 */
790 #if _SL_INCLUDE_FUNC(sl_Select)
791 _i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, struct SlTimeval_t *timeout);
792 #endif
793 
794 
795 
796 /*!
797     \brief Set socket options-
798 
799     This function manipulate the options associated with a socket.\n
800     Options may exist at multiple protocol levels; they are always
801     present at the uppermost socket level.\n
802 
803     When manipulating socket options the level at which the option resides
804     and the name of the option must be specified.  To manipulate options at
805     the socket level, level is specified as SOL_SOCKET.  To manipulate
806     options at any other level the protocol number of the appropriate proto-
807     col controlling the option is supplied.  For example, to indicate that an
808     option is to be interpreted by the TCP protocol, level should be set to
809     the protocol number of TCP; \n
810 
811     The parameters optval and optlen are used to access optval -
812     ues for setsockopt().  For getsockopt() they identify a
813     buffer in which the value for the requested option(s) are to
814     be returned.  For getsockopt(), optlen is a value-result
815     parameter, initially containing the size of the buffer
816     pointed to by option_value, and modified on return to
817     indicate the actual size of the value returned.  If no option
818     value is to be supplied or returned, option_value may be
819     NULL.
820 
821     \param[in] sd               Socket handle
822     \param[in] level            Defines the protocol level for this option
823                                 - <b>SL_SOL_SOCKET</b>   Socket level configurations (L4, transport layer)
824                                 - <b>SL_IPPROTO_IP</b>   IP level configurations (L3, network layer)
825                                 - <b>SL_SOL_PHY_OPT</b>  Link level configurations (L2, link layer)
826     \param[in] optname          Defines the option name to interrogate
827                                 - <b>SL_SOL_SOCKET</b>
828                                 - <b>SL_SO_KEEPALIVE</b>  \n
829                                                 Enable/Disable periodic keep alive.
830                                                 Keeps TCP connections active by enabling the periodic transmission of messages \n
831                                                 Timeout is 5 minutes.\n
832                                                 Default: Enabled \n
833                                                 This options takes SlSockKeepalive_t struct as parameter
834                                 - <b>SL_SO_KEEPALIVETIME</b>  \n
835                                                 Set keep alive timeout.
836                                                 Value is in seconds \n
837                                                 Default: 5 minutes \n
838                                 - <b>SL_SO_RX_NO_IP_BOUNDARY</b>  \n
839                                                 Enable/Disable rx ip boundary.
840                                                 In connectionless socket (udp/raw), unread data is dropped (when recvfrom len parameter < data size), Enable this option in order to read the left data on the next recvfrom iteration
841                                                 Default: Disabled, IP boundary kept,  \n
842                                                 This options takes SlSockRxNoIpBoundary_t struct as parameter
843                                 - <b>SL_SO_RCVTIMEO</b>  \n
844                                                 Sets the timeout value that specifies the maximum amount of time an input function waits until it completes. \n
845                                                 Default: No timeout \n
846                                                 This options takes SlTimeval_t struct as parameter
847                                 - <b>SL_SO_RCVBUF</b>  \n
848                                                 Sets tcp max recv window size. \n
849                                                 This options takes SlSockWinsize_t struct as parameter
850                                 - <b>SL_SO_NONBLOCKING</b> \n
851                                                 Sets socket to non-blocking operation Impacts: connect, accept, send, sendto, recv and recvfrom. \n
852                                                 Default: Blocking.
853                                                 This options takes SlSockNonblocking_t struct as parameter
854                                 - <b>SL_SO_SECMETHOD</b> \n
855                                                 Sets method to tcp secured socket (SL_SEC_SOCKET) \n
856                                                 Default: SL_SO_SEC_METHOD_SSLv3_TLSV1_2 \n
857                                                 This options takes SlSockSecureMethod_t struct as parameter
858                                 - <b>SL_SO_SECURE_MASK</b> \n
859                                                 Sets specific cipher to tcp secured socket (SL_SEC_SOCKET) \n
860                                                 Default: "Best" cipher suitable to method \n
861                                                 This options takes SlSockSecureMask_t struct as parameter
862                                 - <b>SL_SO_SECURE_FILES_CA_FILE_NAME</b> \n
863                                                 Map secured socket to CA file by name \n
864                                                 This options takes <b>_u8</b> buffer as parameter
865                                 - <b>SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME</b> \n
866                                                 Map secured socket to private key by name \n
867                                                 This options takes <b>_u8</b> buffer as parameter
868                                 - <b>SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME</b> \n
869                                                 Map secured socket to certificate file by name \n
870                                                 This options takes <b>_u8</b> buffer as parameter
871                                 - <b>SL_SO_SECURE_FILES_DH_KEY_FILE_NAME</b> \n
872                                                 Map secured socket to Diffie Hellman file by name \n
873                                                 This options takes <b>_u8</b> buffer as parameter
874                                 - <b>SL_SO_CHANGE_CHANNEL</b> \n
875                                                 Sets channel in transceiver mode.
876                                                 This options takes <b>_u32</b> as channel number parameter
877                                 - <b>SL_SO_SECURE_ALPN</b> \n
878                                                 Sets the ALPN list. the parameter is a bit map consist of or of the following values -
879                                                 SL_SECURE_ALPN_H1
880                                                 SL_SECURE_ALPN_H2
881                                                 SL_SECURE_ALPN_H2C
882                                                 SL_SECURE_ALPN_H2_14
883                                                 SL_SECURE_ALPN_H2_16
884                                                 SL_SECURE_ALPN_FULL_LIST
885                                                 Use getsockopt with the SL_SO_SECURE_ALPN to indicate what protocol is picked by the server after
886                                                 the connection. the bit that stayed set is the one the server picked, if no bit is set, then the server did not pick
887                                                 any protocol.
888                                 - <b>SL_SO_SECURE_ALPN_GENERAL</b> \n
889                                                 Set one free text protocol name -
890                                                 can be used alone too add the ALPN extension to the client hello message and also
891                                                 can be combined with the list of fixed ALPN protocol names if used along with SL_SO_SECURE_ALPN option.
892                                                 This option is available only in client mode.
893                                                 Errors that could return from usage of this API-
894                                                 SL_ERROR_BSD_ESOCKTNOSUPPORT - been used on non tcp socket or server accept socket
895                                                 SL_ERROR_BSD_ESECNOTALLOWEDWHENLISTENING - cannot be used on listener socket
896                                                 SL_ERROR_BSD_EINVAL - length of ALPN name must be less than 256 bytes
897                                                 To retrieve the resault from the server after connection (indicate if this protocol been selected or not),
898                                                 use getsockopt with this opt ID.
899                                                 If the SL_SO_SECURE_ALPN is also used, issue a getsockopt with the SL_SO_SECURE_ALPN, to indicate
900                                                 if the server picked one of the fixed protocol names.
901                                   - <b>SL_SO_SECURE_EXT_CLIENT_CHLNG_RESP</b> \n
902                                                  Set with no parameter to indicate that the client uses external signature using netapp request.\n
903                                                  needs netapp request handler\n
904                                   - <b>SL_SO_SECURE_DOMAIN_NAME_VERIFICATION </b>\n
905                                                  Set a domain name, to check in ssl client connection.
906                                   - <b>SL_SO_SECURE_ENABLE_OCSP </b>\name
907                                                  Enable OCSP check on a secured client socket -
908                                                  supports OCSP legacy,stapling and stapling v2. the method is automatically negotiated with the server.
909                                 - <b>SL_IPPROTO_IP</b>
910                                 - <b>SL_IP_MULTICAST_TTL</b> \n
911                                                 Set the time-to-live value of outgoing multicast packets for this socket. \n
912                                                 This options takes <b>_u8</b> as parameter
913                                 - <b>SL_IP_ADD_MEMBERSHIP</b> \n
914                                                 UDP socket, Join a multicast group. \n
915                                                 This options takes SlSockIpMreq_t struct as parameter
916                                 - <b>SL_IP_DROP_MEMBERSHIP</b> \n
917                                                 UDP socket, Leave a multicast group \n
918                                                 This options takes SlSockIpMreq_t struct as parameter
919                                 - <b>SL_IP_RAW_RX_NO_HEADER</b> \n
920                                                 Raw socket remove IP header from received data. \n
921                                                 Default: data includes ip header \n
922                                                 This options takes <b>_u32</b> as parameter
923                                 - <b>SL_IP_HDRINCL</b> \n
924                                                 RAW socket only, the IPv4 layer generates an IP header when sending a packet unless \n
925                                                 the IP_HDRINCL socket option is enabled on the socket.    \n
926                                                 When it is enabled, the packet must contain an IP header. \n
927                                                 Default: disabled, IPv4 header generated by Network Stack \n
928                                                 This options takes <b>_u32</b> as parameter
929                                 - <b>SL_IP_RAW_IPV6_HDRINCL</b> (inactive) \n
930                                                 RAW socket only, the IPv6 layer generates an IP header when sending a packet unless \n
931                                                 the IP_HDRINCL socket option is enabled on the socket. When it is enabled, the packet must contain an IP header \n
932                                                 Default: disabled, IPv4 header generated by Network Stack \n
933                                                 This options takes <b>_u32</b> as parameter
934                                 - <b>SL_SOL_PHY_OPT</b>
935                                 - <b>SL_SO_PHY_RATE</b> \n
936                                                 RAW socket, set WLAN PHY transmit rate \n
937                                                 The values are based on SlWlanRateIndex_e    \n
938                                                 This options takes <b>_u32</b> as parameter
939                                 - <b>SL_SO_PHY_TX_POWER</b> \n
940                                                 RAW socket, set WLAN PHY TX power \n
941                                                 Valid rage is 1-15 \n
942                                                 This options takes <b>_u32</b> as parameter
943                                 - <b>SL_SO_PHY_NUM_FRAMES_TO_TX</b> \n
944                                                 RAW socket, set number of frames to transmit in transceiver mode.
945                                                 Default: 1 packet
946                                                 This options takes <b>_u32</b> as parameter
947                                 - <b>SL_SO_PHY_PREAMBLE</b> \n
948                                                 RAW socket, set WLAN PHY preamble for Long/Short\n
949                                                 This options takes <b>_u32</b> as parameter
950                                 - <b>SL_SO_PHY_TX_INHIBIT_THRESHOLD</b> \n
951                                                 RAW socket, set WLAN Tx � Set CCA threshold. \n
952                                                 The values are based on SlTxInhibitThreshold_e    \n
953                                                 This options takes <b>_u32</b> as parameter
954                                 - <b>SL_SO_PHY_TX_TIMEOUT</b> \n
955                                                 RAW socket, set WLAN Tx � changes the TX timeout (lifetime) of transceiver frames. \n
956                                                 Value in Ms, maximum value is 100ms    \n
957                                                 This options takes <b>_u32</b> as parameter
958                                 - <b>SL_SO_PHY_ALLOW_ACKS </b> \n
959                                                 RAW socket, set WLAN Tx � Enable\Disable sending ACKs in transceiver mode \n
960                                                 0 = disabled / 1 = enabled    \n
961                                                 This options takes <b>_u32</b> as parameter
962                                 - <b>SL_SO_LINGER</b> \n
963                                                 Socket lingers on close pending remaining send/receive packets\n
964 
965     \param[in] optval           Specifies a value for the option
966     \param[in] optlen           Specifies the length of the
967         option value
968 
969     \return                     Zero on success, or negative error code on failure
970 
971     \par Persistent
972                 All params are <b>Non- Persistent</b>
973     \sa     sl_getsockopt
974     \note   Belongs to \ref basic_api
975     \warning
976     \par   Examples
977 
978     - SL_SO_KEEPALIVE (disable Keepalive):
979     \code
980         SlSockKeepalive_t enableOption;
981         enableOption.KeepaliveEnabled = 0;
982         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_KEEPALIVE, (_u8 *)&enableOption,sizeof(enableOption));
983     \endcode
984     <br>
985 
986     - SL_SO_KEEPALIVETIME (Set Keepalive timeout):
987     \code
988         _i16 Status;
989         _u32 TimeOut = 120;
990         sl_SetSockOpt(Sd, SL_SOL_SOCKET, SL_SO_KEEPALIVETIME,( _u8*) &TimeOut, sizeof(TimeOut));
991     \endcode
992     <br>
993 
994     - SL_SO_RX_NO_IP_BOUNDARY (disable boundary):
995     \code
996         SlSockRxNoIpBoundary_t enableOption;
997         enableOption.RxIpNoBoundaryEnabled = 1;
998         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RX_NO_IP_BOUNDARY, (_u8 *)&enableOption,sizeof(enableOption));
999     \endcode
1000     <br>
1001 
1002     - SL_SO_RCVTIMEO:
1003     \code
1004         struct SlTimeval_t timeVal;
1005         timeVal.tv_sec =  1;             // Seconds
1006         timeVal.tv_usec = 0;             // Microseconds. 10000 microseconds resolution
1007         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal));    // Enable receive timeout
1008     \endcode
1009     <br>
1010 
1011     - SL_SO_RCVBUF:
1012     \code
1013            SlSockWinsize_t size;
1014            size.Winsize = 3000;  // bytes
1015            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVBUF, (_u8 *)&size, sizeof(size));
1016     \endcode
1017     <br>
1018 
1019     - SL_SO_NONBLOCKING:
1020     \code
1021 
1022            SlSockNonblocking_t enableOption;
1023            enableOption.NonBlockingEnabled = 1;
1024            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_NONBLOCKING, (_u8 *)&enableOption,sizeof(enableOption)); // Enable/disable nonblocking mode
1025     \endcode
1026     <br>
1027 
1028     - SL_SO_SECMETHOD:
1029     \code
1030            SlSockSecureMethod_t method;
1031            method.SecureMethod = SL_SO_SEC_METHOD_SSLV3;                                 // security method we want to use
1032            SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
1033            sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECMETHOD, (_u8 *)&method, sizeof(method));
1034     \endcode
1035     <br>
1036 
1037     - SL_SO_SECURE_MASK:
1038     \code
1039            SlSockSecureMask_t cipher;
1040            cipher.SecureMask = SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA;                   // cipher type
1041            SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
1042            sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECURE_MASK,(_u8 *)&cipher, sizeof(cipher));
1043     \endcode
1044     <br>
1045 
1046     - SL_SO_SECURE_FILES_CA_FILE_NAME:
1047     \code
1048         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CA_FILE_NAME,"exuifaxCaCert.der",strlen("exuifaxCaCert.der"));
1049     \endcode
1050     <br>
1051 
1052     - SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME;
1053     \code
1054         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME,"myPrivateKey.der",strlen("myPrivateKey.der"));
1055     \endcode
1056     <br>
1057 
1058     - SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME:
1059      \code
1060         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME,"myCertificate.der",strlen("myCertificate.der"));
1061      \endcode
1062      <br>
1063 
1064     - SL_SO_SECURE_FILES_DH_KEY_FILE_NAME:
1065      \code
1066         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_DH_KEY_FILE_NAME,"myDHinServerMode.der",strlen("myDHinServerMode.der"));
1067      \endcode
1068      <br>
1069 
1070     - SL_SO_SECURE_ENABLE_OCSP
1071      \code
1072         _u32 enable;
1073         enable = 1;
1074         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_ENABLE_OCSP,&enable,sizeof(_u32));
1075      \endcode
1076      <br>
1077 
1078     - SL_IP_MULTICAST_TTL:
1079      \code
1080         _u8 ttl = 20;
1081         sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_MULTICAST_TTL, &ttl, sizeof(ttl));
1082      \endcode
1083      <br>
1084 
1085     - SL_IP_ADD_MEMBERSHIP:
1086      \code
1087         SlSockIpMreq_t mreq;
1088         sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
1089     \endcode
1090     <br>
1091 
1092     - SL_IP_DROP_MEMBERSHIP:
1093     \code
1094         SlSockIpMreq_t mreq;
1095         sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
1096     \endcode
1097     <br>
1098 
1099     - SL_SO_CHANGE_CHANNEL:
1100     \code
1101         _u32 newChannel = 6; // range is 1-13
1102         sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_CHANGE_CHANNEL, &newChannel, sizeof(newChannel));
1103     \endcode
1104     <br>
1105 
1106     - SL_SO_SECURE_ALPN:
1107     \code
1108         SlSockSecureALPN_t alpn;
1109         alpn.SecureALPN = SL_SECURE_ALPN_H2 | SL_SECURE_ALPN_H2_14;
1110         sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECURE_ALPN, &alpn, sizeof(SlSockSecureALPN_t));
1111     \endcode
1112     - SL_SO_SECURE_ALPN_GENERAL
1113     \code
1114         sl_SetSockOpt(sd,SL_SOL_SOCKET,SL_SO_SECURE_ALPN_GENERAL,"h2",strlen("h2"));
1115         sl_Connect(sd, ( SlSockAddr_t *)&addr, addrSize);
1116         length = 10;
1117         sl_GetSockOpt(sd,SL_SOL_SOCKET,SL_SO_SECURE_ALPN_GENERAL,buf,&length);
1118         if(length == 0)
1119         {
1120             //this protocol was not selected by the server
1121         }
1122         else if(memcmp(buf,"h2",length) == 0)
1123         {
1124             //the protocol that was set was picked by the server
1125         }
1126     \endcode
1127     <br>
1128 
1129     -   SL_IP_RAW_RX_NO_HEADER:
1130     \code
1131         _u32 header = 1;  // remove ip header
1132         sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_RX_NO_HEADER, &header, sizeof(header));
1133     \endcode
1134     <br>
1135 
1136     - SL_IP_HDRINCL:
1137     \code
1138         _u32 header = 1;
1139         sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_HDRINCL, &header, sizeof(header));
1140     \endcode
1141     <br>
1142 
1143     - SL_IP_RAW_IPV6_HDRINCL:
1144     \code
1145         _u32 header = 1;
1146         sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_IPV6_HDRINCL, &header, sizeof(header));
1147     \endcode
1148     <br>
1149 
1150     -   SL_SO_PHY_RATE:
1151     \code
1152         _u32 rate = 6; // see wlan.h SlWlanRateIndex_e for values
1153         sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_RATE, &rate, sizeof(rate));
1154     \endcode
1155     <br>
1156 
1157     - SL_SO_PHY_TX_POWER:
1158     \code
1159         _u32 txpower = 1; // valid range is 1-15
1160         sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_TX_POWER, &txpower, sizeof(txpower));
1161     \endcode
1162     <br>
1163 
1164     - SL_SO_PHY_NUM_FRAMES_TO_TX:
1165     \code
1166         _u32 numframes = 1;
1167         sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_NUM_FRAMES_TO_TX, &numframes, sizeof(numframes));
1168     \endcode
1169     <br>
1170 
1171     - SL_SO_PHY_PREAMBLE:
1172     \code
1173         _u32 preamble = 1;
1174         sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_PREAMBLE, &preamble, sizeof(preamble));
1175     \endcode
1176     <br>
1177 
1178     - SL_SO_PHY_TX_INHIBIT_THRESHOLD:
1179     \code
1180         _u32 thrshld = SL_TX_INHIBIT_THRESHOLD_MED;
1181         sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_TX_INHIBIT_THRESHOLD , &thrshld, sizeof(thrshld));
1182     \endcode
1183     <br>
1184 
1185     - SL_SO_PHY_TX_TIMEOUT:
1186     \code
1187         _u32 timeout = 50;
1188         sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_TX_TIMEOUT  , &timeout, sizeof(timeout));
1189     \endcode
1190     <br>
1191 
1192     - SL_SO_PHY_ALLOW_ACKS:
1193     \code
1194         _u32 acks = 1; // 0 = disabled / 1 = enabled
1195         sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_ALLOW_ACKS, &acks, sizeof(acks));
1196     \endcode
1197     <br>
1198     - SL_SO_PHY_RX_BSSID_DATA_FRAMES
1199      \code
1200         SlRxMetricsEnableDisableRXOnBSS_t flag;
1201         flag.enableDisable = 1;
1202         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_PHY_RX_BSSID_DATA_FRAMES,&flag,sizeof(SlRxMetricsEnableDisableRXOnBSS_t));
1203      \endcode
1204      <br>
1205 
1206     - SL_SO_LINGER:
1207     \code
1208         SlSocklinger_t linger;
1209         linger.l_onoff = 1;
1210         linger.l_linger = 10;
1211         sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_LINGER, &linger, sizeof(linger));
1212     \endcode
1213     <br>
1214 
1215     - SL_SO_SECURE_EXT_CLIENT_CHLNG_RESP:
1216     \code
1217         int dummy;
1218         sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECURE_EXT_CLIENT_CHLNG_RESP, &dummy, sizeof(dummy));
1219     \endcode
1220     <br>
1221 
1222     - SL_SO_SECURE_DOMAIN_NAME_VERIFICATION:
1223     \code
1224         sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_DOMAIN_NAME_VERIFICATION,"www.google.co.il",strlen("www.google.co.il"));
1225     \endcode
1226 
1227 */
1228 #if _SL_INCLUDE_FUNC(sl_SetSockOpt)
1229 _i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSocklen_t optlen);
1230 #endif
1231 
1232 /*!
1233     \brief Get socket options
1234 
1235     This function manipulate the options associated with a socket.
1236     Options may exist at multiple protocol levels; they are always
1237     present at the uppermost socket level.\n
1238 
1239     When manipulating socket options the level at which the option resides
1240     and the name of the option must be specified.  To manipulate options at
1241     the socket level, level is specified as SOL_SOCKET.  To manipulate
1242     options at any other level the protocol number of the appropriate
1243     protocol controlling the option is supplied.  For example, to indicate
1244     that an option is to be interpreted by the TCP protocol, level should
1245     be set to the protocol number of TCP; \n
1246 
1247     The parameters optval and optlen are used to access optvalues
1248     for setsockopt().  For getsockopt() they identify a
1249     buffer in which the value for the requested option(s) are to
1250     be returned.  For getsockopt(), optlen is a value-result
1251     parameter, initially containing the size of the buffer
1252     pointed to by option_value, and modified on return to
1253     indicate the actual size of the value returned.  If no option
1254     value is to be supplied or returned, option_value may be
1255     NULL.
1256 
1257 
1258     \param[in]  sd              Socket handle
1259     \param[in]  level           Defines the protocol level for this option
1260     \param[in]  optname         defines the option name to interrogate
1261     \param[out] optval          Specifies a value for the option
1262     \param[out] optlen          Specifies the length of the
1263                                 option value
1264 
1265     \return                     Zero on success, or negative error code on failure
1266     \sa     sl_SetSockOpt
1267     \note   See sl_SetSockOpt
1268             Belongs to \ref ext_api
1269     \warning
1270 */
1271 #if _SL_INCLUDE_FUNC(sl_GetSockOpt)
1272 _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t *optlen);
1273 #endif
1274 
1275 /*!
1276     \brief Read data from TCP socket
1277 
1278     Function receives a message from a connection-mode socket
1279 
1280     \param[in]  sd              Socket handle
1281     \param[out] buf             Points to the buffer where the
1282                                 message should be stored.
1283     \param[in]  len             Specifies the length in bytes of
1284                                 the buffer pointed to by the buffer argument.
1285                                 Range: 1-16000 bytes
1286     \param[in]  flags           Specifies the type of message
1287                                 reception. On this version, this parameter is not
1288                                 supported.
1289 
1290     \return                     Return the number of bytes received,
1291                                 or a negative value if an error occurred.\n
1292                                 Using a non-blocking recv a possible negative value is SL_EAGAIN.\n
1293                                 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
1294                                  In this case try again later or increase MAX_CONCURRENT_ACTIONS
1295 
1296     \sa     sl_RecvFrom
1297     \note                       Belongs to \ref recv_api
1298     \warning
1299     \par        Examples
1300 
1301     - Receiving data using TCP socket:
1302     \code
1303         SlSockAddrIn_t  Addr;
1304         SlSockAddrIn_t  LocalAddr;
1305         _i16 AddrSize = sizeof(SlSockAddrIn_t);
1306         _i16 SockID, newSockID;
1307         _i16 Status;
1308         _i8 Buf[RECV_BUF_LEN];
1309 
1310         LocalAddr.sin_family = SL_AF_INET;
1311         LocalAddr.sin_port = sl_Htons(5001);
1312         LocalAddr.sin_addr.s_addr = 0;
1313 
1314         Addr.sin_family = SL_AF_INET;
1315         Addr.sin_port = sl_Htons(5001);
1316         Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
1317 
1318         SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
1319         Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
1320         Status = sl_Listen(SockID, 0);
1321         newSockID = sl_Accept(SockID, (SlSockAddr_t*)&Addr, (SlSocklen_t*) &AddrSize);
1322         Status = sl_Recv(newSockID, Buf, 1460, 0);
1323     \endcode
1324     <br>
1325 
1326     - Rx transceiver mode using a raw socket:
1327     \code
1328         _i8 buffer[1536];
1329         _i16 sd;
1330         _u16 size;
1331         SlTransceiverRxOverHead_t *transHeader;
1332         sd = sl_Socket(SL_AF_RF,SL_SOCK_RAW,11); // channel 11
1333         while(1)
1334         {
1335             size = sl_Recv(sd,buffer,1536,0);
1336             transHeader = (SlTransceiverRxOverHead_t *)buffer;
1337             printf("RSSI is %d frame type is 0x%x size %d\n",transHeader->rssi,buffer[sizeof(SlTransceiverRxOverHead_t)],size);
1338         }
1339     \endcode
1340 */
1341 #if _SL_INCLUDE_FUNC(sl_Recv)
1342 _i16 sl_Recv(_i16 sd, void *buf, _i16 len, _i16 flags);
1343 #endif
1344 
1345 /*!
1346     \brief Read data from socket
1347 
1348     Function receives a message from a connection-mode or
1349     connectionless-mode socket
1350 
1351     \param[in]  sd              Socket handle
1352     \param[out] buf             Points to the buffer where the message should be stored.
1353     \param[in]  len             Specifies the length in bytes of the buffer pointed to by the buffer argument.
1354                                 Range: 1-16000 bytes
1355     \param[in]  flags           Specifies the type of message
1356                                 reception. On this version, this parameter is not
1357                                 supported.
1358     \param[in]  from            Pointer to an address structure
1359                                 indicating the source
1360                                 address.\n sockaddr:\n - code
1361                                 for the address format. On this
1362                                 version only AF_INET is
1363                                 supported.\n - socket address,
1364                                 the length depends on the code
1365                                 format
1366     \param[in]  fromlen         Source address structure
1367                                 size. This parameter MUST be set to the size of the structure pointed to by addr.
1368 
1369 
1370     \return                     Return the number of bytes received,
1371                                 or a negative value if an error occurred.\n
1372                                 Using a non-blocking recv a possible negative value is SL_EAGAIN.
1373                                 SL_RET_CODE_INVALID_INPUT (-2) will be returned if fromlen has incorrect length. \n
1374                                 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
1375                                  In this case try again later or increase MAX_CONCURRENT_ACTIONS
1376 
1377     \sa     sl_Recv
1378     \note                       Belongs to \ref recv_api
1379     \warning
1380     \par        Example
1381 
1382     - Receiving data:
1383     \code
1384         SlSockAddrIn_t  Addr;
1385         SlSockAddrIn_t  LocalAddr;
1386         _i16 AddrSize = sizeof(SlSockAddrIn_t);
1387         _i16 SockID;
1388         _i16 Status;
1389         _i8 Buf[RECV_BUF_LEN];
1390 
1391         LocalAddr.sin_family = SL_AF_INET;
1392         LocalAddr.sin_port = sl_Htons(5001);
1393         LocalAddr.sin_addr.s_addr = 0;
1394 
1395         SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
1396         Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
1397         Status = sl_RecvFrom(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, (SlSocklen_t*)&AddrSize);
1398 
1399     \endcode
1400 */
1401 #if _SL_INCLUDE_FUNC(sl_RecvFrom)
1402 _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 len, _i16 flags, SlSockAddr_t *from, SlSocklen_t *fromlen);
1403 #endif
1404 
1405 /*!
1406     \brief Write data to TCP socket
1407 
1408     This function is used to transmit a message to another socket.
1409     Returns immediately after sending data to device.
1410     In case of TCP failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
1411     be received.\n
1412     In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the
1413     frame data buffer for WLAN FCS
1414 
1415     \param[in] sd               Socket handle
1416     \param[in] buf              Points to a buffer containing
1417                                 the message to be sent
1418     \param[in] len              Message size in bytes.
1419     \param[in] flags            Specifies the type of message
1420                                 transmission. On this version, this parameter is not
1421                                 supported for TCP.
1422                                 For transceiver mode, the SL_WLAN_RAW_RF_TX_PARAMS macro can be used to determine
1423                                 transmission parameters (channel,rate,tx_power,preamble)
1424                                 -rate need to be define using slSockTransceiverTXRateTable_e
1425 
1426 
1427     \return                      On success, number of transmitted bytes is return, or negative error code on failure
1428 
1429     \sa     sl_SendTo
1430     \note                       Belongs to \ref send_api
1431     \warning
1432     \par        Example
1433 
1434     - Sending data:
1435     \code
1436         SlSockAddrIn_t  Addr;
1437         _i16 AddrSize = sizeof(SlSockAddrIn_t);
1438         _i16 SockID;
1439         _i16 Status;
1440         _i8 Buf[SEND_BUF_LEN];
1441 
1442         Addr.sin_family = SL_AF_INET;
1443         Addr.sin_port = sl_Htons(5001);
1444         Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
1445 
1446         SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
1447         Status = sl_Connect(SockID, (SlSockAddr_t *)&Addr, AddrSize);
1448         Status = sl_Send(SockID, Buf, 1460, 0 );
1449     \endcode
1450  */
1451 #if _SL_INCLUDE_FUNC(sl_Send )
1452 _i16 sl_Send(_i16 sd, const void *buf, _i16 len, _i16 flags);
1453 #endif
1454 
1455 /*!
1456     \brief Write data to socket
1457 
1458     This function is used to transmit a message to another socket
1459     (connection less socket SOCK_DGRAM,  SOCK_RAW).\n
1460     Returns immediately after sending data to device.\n
1461     In case of transmission failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
1462     be received.
1463 
1464     \param[in] sd               Socket handle
1465     \param[in] buf              Points to a buffer containing
1466                                 the message to be sent
1467     \param[in] len              message size in bytes.
1468     \param[in] flags            Specifies the type of message
1469                                 transmission. On this version, this parameter is not
1470                                 supported
1471     \param[in] to               Pointer to an address structure
1472                                 indicating the destination
1473                                 address.\n sockaddr:\n - code
1474                                 for the address format. On this
1475                                 version only AF_INET is
1476                                 supported.\n - socket address,
1477                                 the length depends on the code
1478                                 format
1479     \param[in] tolen            Destination address structure size
1480 
1481     \return                     On success, number of transmitted bytes is return, or negative error code on failure
1482 
1483     \sa     sl_Send
1484     \note                       Belongs to \ref send_api
1485     \warning
1486     \par        Example
1487 
1488     - Sending data:
1489     \code
1490         SlSockAddrIn_t  Addr;
1491         _i16 AddrSize = sizeof(SlSockAddrIn_t);
1492         _i16 SockID;
1493         _i16 Status;
1494         _i8 Buf[SEND_BUF_LEN];
1495 
1496         Addr.sin_family = SL_AF_INET;
1497         Addr.sin_port = sl_Htons(5001);
1498         Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
1499 
1500         SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
1501         Status = sl_SendTo(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, AddrSize);
1502     \endcode
1503 */
1504 #if _SL_INCLUDE_FUNC(sl_SendTo)
1505 _i16 sl_SendTo(_i16 sd, const void *buf, _i16 len, _i16 flags, const SlSockAddr_t *to, SlSocklen_t tolen);
1506 #endif
1507 
1508 /*!
1509     \brief Initiate TLS connection on a socket
1510 
1511     Function Initiate TLS connection on the socket referred to by
1512     the socket descriptor sd. This function will works on blocking
1513     mode until the TLS handshake success or fails.
1514 
1515     \param[in] sd               Socket descriptor (handle)
1516 
1517     \return                     Zero on success, or negative error code on failure
1518 
1519     \sa                         sl_Socket
1520     \note                       belongs to \ref client_side
1521     \warning
1522 */
1523 #if _SL_INCLUDE_FUNC(sl_StartTLS)
1524 _i16 sl_StartTLS(_i16 sd);
1525 #endif
1526 
1527 /*!
1528     \brief Reorder the bytes of a 32-bit unsigned value
1529 
1530     This function is used to Reorder the bytes of a 32-bit unsigned value from processor order to network order.
1531 
1532     \param[in] val              Variable to reorder
1533 
1534     \return                     Return the reorder variable,
1535 
1536     \sa     sl_SendTo  sl_Bind  sl_Connect  sl_RecvFrom  sl_Accept
1537     \note                       Belongs to \ref send_api
1538     \warning
1539 */
1540 #if _SL_INCLUDE_FUNC(sl_Htonl )
1541 _u32 sl_Htonl( _u32 val );
1542 
1543 #define sl_Ntohl sl_Htonl  /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
1544 #endif
1545 
1546 /*!
1547     \brief Reorder the bytes of a 16-bit unsigned value
1548 
1549     This function is used to Reorder the bytes of a 16-bit unsigned value from processor order to network order.
1550 
1551     \param[in] val              Variable to reorder
1552 
1553     \return                     Return the reorder variable,
1554 
1555     \sa     sl_SendTo  sl_Bind    sl_Connect  sl_RecvFrom  sl_Accept
1556     \note                       Belongs to \ref send_api
1557     \warning
1558 */
1559 #if _SL_INCLUDE_FUNC(sl_Htons )
1560 _u16 sl_Htons( _u16 val );
1561 
1562 #define sl_Ntohs sl_Htons   /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
1563 #endif
1564 
1565 /*!
1566     \cond DOXYGEN_IGNORE
1567 */
1568 
1569 /*!
1570     \brief Select's SlFdSet_t SET function
1571 
1572     Sets current socket descriptor on SlFdSet_t container
1573 */
1574 void SL_SOCKET_FD_SET(_i16 fd, SlFdSet_t *fdset);
1575 
1576 /*!
1577     \brief Select's SlFdSet_t CLR function
1578 
1579     Clears current socket descriptor on SlFdSet_t container
1580 */
1581 void SL_SOCKET_FD_CLR(_i16 fd, SlFdSet_t *fdset);
1582 
1583 
1584 /*!
1585     \brief Select's SlFdSet_t ISSET function
1586 
1587     Checks if current socket descriptor is set (TRUE/FALSE)
1588 
1589     \return            Returns TRUE if set, FALSE if unset
1590 
1591 */
1592 _i16  SL_SOCKET_FD_ISSET(_i16 fd, SlFdSet_t *fdset);
1593 
1594 /*!
1595     \brief Select's SlFdSet_t ZERO function
1596 
1597     Clears all socket descriptors from SlFdSet_t
1598 */
1599 void SL_SOCKET_FD_ZERO(SlFdSet_t *fdset);
1600 
1601 /*!
1602     \endcond
1603 */
1604 
1605 /*!
1606 
1607  Close the Doxygen group.
1608  @}
1609 
1610  */
1611 
1612 
1613 #ifdef  __cplusplus
1614 }
1615 #endif /* __cplusplus */
1616 
1617 #endif /* __SOCKET_H__ */
1618 
1619 
1620