SimpleLink CC3100/CC3200 Host Driver  Version 1.0.1.6
Simplifies the implementation of Internet connectivity
socket.h
1 /*
2  * socket.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2015 Texas Instruments Incorporated - https://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 "simplelink.h"
41 
42 #ifndef __SL_SOCKET_H__
43 #define __SL_SOCKET_H__
44 
45 
46 
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
59 /*****************************************************************************/
60 /* Macro declarations */
61 /*****************************************************************************/
62 
63 #define SL_FD_SETSIZE SL_MAX_SOCKETS /* Number of sockets to select on - same is max sockets! */
64 #define BSD_SOCKET_ID_MASK (0x0F) /* Index using the LBS 4 bits for socket id 0-7 */
65 /* Define some BSD protocol constants. */
66 #define SL_SOCK_STREAM (1) /* TCP Socket */
67 #define SL_SOCK_DGRAM (2) /* UDP Socket */
68 #define SL_SOCK_RAW (3) /* Raw socket */
69 #define SL_IPPROTO_TCP (6) /* TCP Raw Socket */
70 #define SL_IPPROTO_UDP (17) /* UDP Raw Socket */
71 #define SL_IPPROTO_RAW (255) /* Raw Socket */
72 #define SL_SEC_SOCKET (100) /* Secured Socket Layer (SSL,TLS) */
73 
74 /* Address families. */
75 #define SL_AF_INET (2) /* IPv4 socket (UDP, TCP, etc) */
76 #define SL_AF_INET6 (3) /* IPv6 socket (UDP, TCP, etc) */
77 #define SL_AF_INET6_EUI_48 (9)
78 #define SL_AF_RF (6) /* data include RF parameter, All layer by user (Wifi could be disconnected) */
79 #define SL_AF_PACKET (17)
80 /* Protocol families, same as address families. */
81 #define SL_PF_INET AF_INET
82 #define SL_PF_INET6 AF_INET6
83 #define SL_INADDR_ANY (0) /* bind any address */
84 
85 /* error codes */
86 #define SL_SOC_ERROR (-1) /* Failure. */
87 #define SL_SOC_OK ( 0) /* Success. */
88 #define SL_INEXE (-8) /* socket command in execution */
89 #define SL_EBADF (-9) /* Bad file number */
90 #define SL_ENSOCK (-10) /* The system limit on the total number of open socket, has been reached */
91 #define SL_EAGAIN (-11) /* Try again */
92 #define SL_EWOULDBLOCK SL_EAGAIN
93 #define SL_ENOMEM (-12) /* Out of memory */
94 #define SL_EACCES (-13) /* Permission denied */
95 #define SL_EFAULT (-14) /* Bad address */
96 #define SL_ECLOSE (-15) /* close socket operation failed to transmit all queued packets */
97 #define SL_EALREADY_ENABLED (-21) /* Transceiver - Transceiver already ON. there could be only one */
98 #define SL_EINVAL (-22) /* Invalid argument */
99 #define SL_EAUTO_CONNECT_OR_CONNECTING (-69) /* Transceiver - During connection, connected or auto mode started */
100 #define SL_CONNECTION_PENDING (-72) /* Transceiver - Device is connected, disconnect first to open transceiver */
101 #define SL_EUNSUPPORTED_ROLE (-86) /* Transceiver - Trying to start when WLAN role is AP or P2P GO */
102 #define SL_EDESTADDRREQ (-89) /* Destination address required */
103 #define SL_EPROTOTYPE (-91) /* Protocol wrong type for socket */
104 #define SL_ENOPROTOOPT (-92) /* Protocol not available */
105 #define SL_EPROTONOSUPPORT (-93) /* Protocol not supported */
106 #define SL_ESOCKTNOSUPPORT (-94) /* Socket type not supported */
107 #define SL_EOPNOTSUPP (-95) /* Operation not supported on transport endpoint */
108 #define SL_EAFNOSUPPORT (-97) /* Address family not supported by protocol */
109 #define SL_EADDRINUSE (-98) /* Address already in use */
110 #define SL_EADDRNOTAVAIL (-99) /* Cannot assign requested address */
111 #define SL_ENETUNREACH (-101) /* Network is unreachable */
112 #define SL_ENOBUFS (-105) /* No buffer space available */
113 #define SL_EOBUFF SL_ENOBUFS
114 #define SL_EISCONN (-106) /* Transport endpoint is already connected */
115 #define SL_ENOTCONN (-107) /* Transport endpoint is not connected */
116 #define SL_ETIMEDOUT (-110) /* Connection timed out */
117 #define SL_ECONNREFUSED (-111) /* Connection refused */
118 #define SL_EALREADY (-114) /* Non blocking connect in progress, try again */
119 
120 #define SL_ESEC_RSA_WRONG_TYPE_E (-130) /* RSA wrong block type for RSA function */
121 #define SL_ESEC_RSA_BUFFER_E (-131) /* RSA buffer error, output too small or */
122 #define SL_ESEC_BUFFER_E (-132) /* output buffer too small or input too large */
123 #define SL_ESEC_ALGO_ID_E (-133) /* setting algo id error */
124 #define SL_ESEC_PUBLIC_KEY_E (-134) /* setting public key error */
125 #define SL_ESEC_DATE_E (-135) /* setting date validity error */
126 #define SL_ESEC_SUBJECT_E (-136) /* setting subject name error */
127 #define SL_ESEC_ISSUER_E (-137) /* setting issuer name error */
128 #define SL_ESEC_CA_TRUE_E (-138) /* setting CA basic constraint true error */
129 #define SL_ESEC_EXTENSIONS_E (-139) /* setting extensions error */
130 #define SL_ESEC_ASN_PARSE_E (-140) /* ASN parsing error, invalid input */
131 #define SL_ESEC_ASN_VERSION_E (-141) /* ASN version error, invalid number */
132 #define SL_ESEC_ASN_GETINT_E (-142) /* ASN get big _i16 error, invalid data */
133 #define SL_ESEC_ASN_RSA_KEY_E (-143) /* ASN key init error, invalid input */
134 #define SL_ESEC_ASN_OBJECT_ID_E (-144) /* ASN object id error, invalid id */
135 #define SL_ESEC_ASN_TAG_NULL_E (-145) /* ASN tag error, not null */
136 #define SL_ESEC_ASN_EXPECT_0_E (-146) /* ASN expect error, not zero */
137 #define SL_ESEC_ASN_BITSTR_E (-147) /* ASN bit string error, wrong id */
138 #define SL_ESEC_ASN_UNKNOWN_OID_E (-148) /* ASN oid error, unknown sum id */
139 #define SL_ESEC_ASN_DATE_SZ_E (-149) /* ASN date error, bad size */
140 #define SL_ESEC_ASN_BEFORE_DATE_E (-150) /* ASN date error, current date before */
141 #define SL_ESEC_ASN_AFTER_DATE_E (-151) /* ASN date error, current date after */
142 #define SL_ESEC_ASN_SIG_OID_E (-152) /* ASN signature error, mismatched oid */
143 #define SL_ESEC_ASN_TIME_E (-153) /* ASN time error, unknown time type */
144 #define SL_ESEC_ASN_INPUT_E (-154) /* ASN input error, not enough data */
145 #define SL_ESEC_ASN_SIG_CONFIRM_E (-155) /* ASN sig error, confirm failure */
146 #define SL_ESEC_ASN_SIG_HASH_E (-156) /* ASN sig error, unsupported hash type */
147 #define SL_ESEC_ASN_SIG_KEY_E (-157) /* ASN sig error, unsupported key type */
148 #define SL_ESEC_ASN_DH_KEY_E (-158) /* ASN key init error, invalid input */
149 #define SL_ESEC_ASN_NTRU_KEY_E (-159) /* ASN ntru key decode error, invalid input */
150 #define SL_ESEC_ECC_BAD_ARG_E (-170) /* ECC input argument of wrong type */
151 #define SL_ESEC_ASN_ECC_KEY_E (-171) /* ASN ECC bad input */
152 #define SL_ESEC_ECC_CURVE_OID_E (-172) /* Unsupported ECC OID curve type */
153 #define SL_ESEC_BAD_FUNC_ARG (-173) /* Bad function argument provided */
154 #define SL_ESEC_NOT_COMPILED_IN (-174) /* Feature not compiled in */
155 #define SL_ESEC_UNICODE_SIZE_E (-175) /* Unicode password too big */
156 #define SL_ESEC_NO_PASSWORD (-176) /* no password provided by user */
157 #define SL_ESEC_ALT_NAME_E (-177) /* alt name size problem, too big */
158 #define SL_ESEC_AES_GCM_AUTH_E (-180) /* AES-GCM Authentication check failure */
159 #define SL_ESEC_AES_CCM_AUTH_E (-181) /* AES-CCM Authentication check failure */
160 #define SL_SOCKET_ERROR_E (-208) /* Error state on socket */
161 
162 #define SL_ESEC_MEMORY_ERROR (-203) /* out of memory */
163 #define SL_ESEC_VERIFY_FINISHED_ERROR (-204) /* verify problem on finished */
164 #define SL_ESEC_VERIFY_MAC_ERROR (-205) /* verify mac problem */
165 #define SL_ESEC_UNKNOWN_HANDSHAKE_TYPE (-207) /* weird handshake type */
166 #define SL_ESEC_SOCKET_ERROR_E (-208) /* error state on socket */
167 #define SL_ESEC_SOCKET_NODATA (-209) /* expected data, not there */
168 #define SL_ESEC_INCOMPLETE_DATA (-210) /* don't have enough data to complete task */
169 #define SL_ESEC_UNKNOWN_RECORD_TYPE (-211) /* unknown type in record hdr */
170 #define SL_ESEC_FATAL_ERROR (-213) /* recvd alert fatal error */
171 #define SL_ESEC_ENCRYPT_ERROR (-214) /* error during encryption */
172 #define SL_ESEC_NO_PEER_KEY (-216) /* need peer's key */
173 #define SL_ESEC_NO_PRIVATE_KEY (-217) /* need the private key */
174 #define SL_ESEC_RSA_PRIVATE_ERROR (-218) /* error during rsa priv op */
175 #define SL_ESEC_NO_DH_PARAMS (-219) /* server missing DH params */
176 #define SL_ESEC_BUILD_MSG_ERROR (-220) /* build message failure */
177 #define SL_ESEC_BAD_HELLO (-221) /* client hello malformed */
178 #define SL_ESEC_DOMAIN_NAME_MISMATCH (-222) /* peer subject name mismatch */
179 #define SL_ESEC_WANT_READ (-223) /* want read, call again */
180 #define SL_ESEC_NOT_READY_ERROR (-224) /* handshake layer not ready */
181 #define SL_ESEC_PMS_VERSION_ERROR (-225) /* pre m secret version error */
182 #define SL_ESEC_VERSION_ERROR (-226) /* record layer version error */
183 #define SL_ESEC_WANT_WRITE (-227) /* want write, call again */
184 #define SL_ESEC_BUFFER_ERROR (-228) /* malformed buffer input */
185 #define SL_ESEC_VERIFY_CERT_ERROR (-229) /* verify cert error */
186 #define SL_ESEC_VERIFY_SIGN_ERROR (-230) /* verify sign error */
187 
188 #define SL_ESEC_LENGTH_ERROR (-241) /* record layer length error */
189 #define SL_ESEC_PEER_KEY_ERROR (-242) /* can't decode peer key */
190 #define SL_ESEC_ZERO_RETURN (-243) /* peer sent close notify */
191 #define SL_ESEC_SIDE_ERROR (-244) /* wrong client/server type */
192 #define SL_ESEC_NO_PEER_CERT (-245) /* peer didn't send key */
193 #define SL_ESEC_ECC_CURVETYPE_ERROR (-250) /* Bad ECC Curve Type */
194 #define SL_ESEC_ECC_CURVE_ERROR (-251) /* Bad ECC Curve */
195 #define SL_ESEC_ECC_PEERKEY_ERROR (-252) /* Bad Peer ECC Key */
196 #define SL_ESEC_ECC_MAKEKEY_ERROR (-253) /* Bad Make ECC Key */
197 #define SL_ESEC_ECC_EXPORT_ERROR (-254) /* Bad ECC Export Key */
198 #define SL_ESEC_ECC_SHARED_ERROR (-255) /* Bad ECC Shared Secret */
199 #define SL_ESEC_NOT_CA_ERROR (-257) /* Not a CA cert error */
200 #define SL_ESEC_BAD_PATH_ERROR (-258) /* Bad path for opendir */
201 #define SL_ESEC_BAD_CERT_MANAGER_ERROR (-259) /* Bad Cert Manager */
202 #define SL_ESEC_MAX_CHAIN_ERROR (-268) /* max chain depth exceeded */
203 #define SL_ESEC_SUITES_ERROR (-271) /* suites pointer error */
204 #define SL_ESEC_SSL_NO_PEM_HEADER (-272) /* no PEM header found */
205 #define SL_ESEC_OUT_OF_ORDER_E (-273) /* out of order message */
206 #define SL_ESEC_SANITY_CIPHER_E (-275) /* sanity check on cipher error */
207 #define SL_ESEC_GEN_COOKIE_E (-277) /* Generate Cookie Error */
208 #define SL_ESEC_NO_PEER_VERIFY (-278) /* Need peer cert verify Error */
209 #define SL_ESEC_UNKNOWN_SNI_HOST_NAME_E (-281) /* Unrecognized host name Error */
210 /* begin negotiation parameter errors */
211 #define SL_ESEC_UNSUPPORTED_SUITE (-290) /* unsupported cipher suite */
212 #define SL_ESEC_MATCH_SUITE_ERROR (-291 ) /* can't match cipher suite */
213 
214 /* ssl tls security start with -300 offset */
215 #define SL_ESEC_CLOSE_NOTIFY (-300) /* ssl/tls alerts */
216 #define SL_ESEC_UNEXPECTED_MESSAGE (-310) /* ssl/tls alerts */
217 #define SL_ESEC_BAD_RECORD_MAC (-320) /* ssl/tls alerts */
218 #define SL_ESEC_DECRYPTION_FAILED (-321) /* ssl/tls alerts */
219 #define SL_ESEC_RECORD_OVERFLOW (-322) /* ssl/tls alerts */
220 #define SL_ESEC_DECOMPRESSION_FAILURE (-330) /* ssl/tls alerts */
221 #define SL_ESEC_HANDSHAKE_FAILURE (-340) /* ssl/tls alerts */
222 #define SL_ESEC_NO_CERTIFICATE (-341) /* ssl/tls alerts */
223 #define SL_ESEC_BAD_CERTIFICATE (-342) /* ssl/tls alerts */
224 #define SL_ESEC_UNSUPPORTED_CERTIFICATE (-343) /* ssl/tls alerts */
225 #define SL_ESEC_CERTIFICATE_REVOKED (-344) /* ssl/tls alerts */
226 #define SL_ESEC_CERTIFICATE_EXPIRED (-345) /* ssl/tls alerts */
227 #define SL_ESEC_CERTIFICATE_UNKNOWN (-346) /* ssl/tls alerts */
228 #define SL_ESEC_ILLEGAL_PARAMETER (-347) /* ssl/tls alerts */
229 #define SL_ESEC_UNKNOWN_CA (-348) /* ssl/tls alerts */
230 #define SL_ESEC_ACCESS_DENIED (-349) /* ssl/tls alerts */
231 #define SL_ESEC_DECODE_ERROR (-350) /* ssl/tls alerts */
232 #define SL_ESEC_DECRYPT_ERROR (-351) /* ssl/tls alerts */
233 #define SL_ESEC_EXPORT_RESTRICTION (-360) /* ssl/tls alerts */
234 #define SL_ESEC_PROTOCOL_VERSION (-370) /* ssl/tls alerts */
235 #define SL_ESEC_INSUFFICIENT_SECURITY (-371) /* ssl/tls alerts */
236 #define SL_ESEC_INTERNAL_ERROR (-380) /* ssl/tls alerts */
237 #define SL_ESEC_USER_CANCELLED (-390) /* ssl/tls alerts */
238 #define SL_ESEC_NO_RENEGOTIATION (-400) /* ssl/tls alerts */
239 #define SL_ESEC_UNSUPPORTED_EXTENSION (-410) /* ssl/tls alerts */
240 #define SL_ESEC_CERTIFICATE_UNOBTAINABLE (-411) /* ssl/tls alerts */
241 #define SL_ESEC_UNRECOGNIZED_NAME (-412) /* ssl/tls alerts */
242 #define SL_ESEC_BAD_CERTIFICATE_STATUS_RESPONSE (-413) /* ssl/tls alerts */
243 #define SL_ESEC_BAD_CERTIFICATE_HASH_VALUE (-414) /* ssl/tls alerts */
244 /* propierty secure */
245 #define SL_ESECGENERAL (-450) /* error secure level general error */
246 #define SL_ESECDECRYPT (-451) /* error secure level, decrypt recv packet fail */
247 #define SL_ESECCLOSED (-452) /* secure layrer is closed by other size , tcp is still connected */
248 #define SL_ESECSNOVERIFY (-453) /* Connected without server verification */
249 #define SL_ESECNOCAFILE (-454) /* error secure level CA file not found*/
250 #define SL_ESECMEMORY (-455) /* error secure level No memory space available */
251 #define SL_ESECBADCAFILE (-456) /* error secure level bad CA file */
252 #define SL_ESECBADCERTFILE (-457) /* error secure level bad Certificate file */
253 #define SL_ESECBADPRIVATEFILE (-458) /* error secure level bad private file */
254 #define SL_ESECBADDHFILE (-459) /* error secure level bad DH file */
255 #define SL_ESECT00MANYSSLOPENED (-460) /* MAX SSL Sockets are opened */
256 #define SL_ESECDATEERROR (-461) /* connected with certificate date verification error */
257 #define SL_ESECHANDSHAKETIMEDOUT (-462) /* connection timed out due to handshake time */
258 
259 /* end error codes */
260 
261 /* Max payload size by protocol */
262 #define SL_SOCKET_PAYLOAD_TYPE_MASK (0xF0) /*4 bits type, 4 bits sockets id */
263 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4 (0x00) /* 1472 bytes */
264 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4 (0x10) /* 1460 bytes */
265 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6 (0x20) /* 1452 bytes */
266 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6 (0x30) /* 1440 bytes */
267 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4_SECURE (0x40) /* */
268 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4_SECURE (0x50) /* */
269 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6_SECURE (0x60) /* */
270 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6_SECURE (0x70) /* */
271 #define SL_SOCKET_PAYLOAD_TYPE_RAW_TRANCEIVER (0x80) /* 1536 bytes */
272 #define SL_SOCKET_PAYLOAD_TYPE_RAW_PACKET (0x90) /* 1536 bytes */
273 #define SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 (0xa0)
274 #define SL_SOCKET_PAYLOAD_TYPE_RAW_IP6 (SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 )
275 
276 
277 
278 #define SL_SOL_SOCKET (1) /* Define the socket option category. */
279 #define SL_IPPROTO_IP (2) /* Define the IP option category. */
280 #define SL_SOL_PHY_OPT (3) /* Define the PHY option category. */
281 
282 #define SL_SO_RCVBUF (8) /* Setting TCP receive buffer size */
283 #define SL_SO_KEEPALIVE (9) /* Connections are kept alive with periodic messages */
284 #define SL_SO_RCVTIMEO (20) /* Enable receive timeout */
285 #define SL_SO_NONBLOCKING (24) /* Enable . disable nonblocking mode */
286 #define SL_SO_SECMETHOD (25) /* security metohd */
287 #define SL_SO_SECURE_MASK (26) /* security mask */
288 #define SL_SO_SECURE_FILES (27) /* security files */
289 #define SL_SO_CHANGE_CHANNEL (28) /* This option is available only when transceiver started */
290 #define SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME (30) /* This option used to configue secure file */
291 #define SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME (31) /* This option used to configue secure file */
292 #define SL_SO_SECURE_FILES_CA_FILE_NAME (32) /* This option used to configue secure file */
293 #define SL_SO_SECURE_FILES_DH_KEY_FILE_NAME (33) /* This option used to configue secure file */
294 #define SO_SECURE_DOMAIN_NAME_VERIFICATION (35)
295 #define SECURE_MAX_DOMAIN_LENGTH (64)
296 
297 #define SL_IP_MULTICAST_IF (60) /* Specify outgoing multicast interface */
298 #define SL_IP_MULTICAST_TTL (61) /* Specify the TTL value to use for outgoing multicast packet. */
299 #define SL_IP_ADD_MEMBERSHIP (65) /* Join IPv4 multicast membership */
300 #define SL_IP_DROP_MEMBERSHIP (66) /* Leave IPv4 multicast membership */
301 #define SL_IP_HDRINCL (67) /* Raw socket IPv4 header included. */
302 #define SL_IP_RAW_RX_NO_HEADER (68) /* Proprietary socket option that does not includeIPv4/IPv6 header (and extension headers) on received raw sockets*/
303 #define SL_IP_RAW_IPV6_HDRINCL (69) /* Transmitted buffer over IPv6 socket contains IPv6 header. */
304 
305 #define SL_SO_PHY_RATE (100) /* WLAN Transmit rate */
306 #define SL_SO_PHY_TX_POWER (101) /* TX Power level */
307 #define SL_SO_PHY_NUM_FRAMES_TO_TX (102) /* Number of frames to transmit */
308 #define SL_SO_PHY_PREAMBLE (103) /* Preamble for transmission */
309 
310 #define SL_SO_SEC_METHOD_SSLV3 (0) /* security metohd SSL v3*/
311 #define SL_SO_SEC_METHOD_TLSV1 (1) /* security metohd TLS v1*/
312 #define SL_SO_SEC_METHOD_TLSV1_1 (2) /* security metohd TLS v1_1*/
313 #define SL_SO_SEC_METHOD_TLSV1_2 (3) /* security metohd TLS v1_2*/
314 #define SL_SO_SEC_METHOD_SSLv3_TLSV1_2 (4) /* use highest possible version from SSLv3 - TLS 1.2*/
315 #define SL_SO_SEC_METHOD_DLSV1 (5) /* security metohd DTL v1 */
316 
317 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA (1 << 0)
318 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_MD5 (1 << 1)
319 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA (1 << 2)
320 #define SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_CBC_SHA (1 << 3)
321 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (1 << 4)
322 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_RC4_128_SHA (1 << 5)
323 #define SL_SEC_MASK_TLS_RSA_WITH_AES_128_CBC_SHA256 (1 << 6)
324 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA256 (1 << 7)
325 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (1 << 8)
326 #define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 (1 << 9)
327 
328 
329 #define SL_SEC_MASK_SECURE_DEFAULT ((SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 << 1) - 1)
330 
331 #define SL_MSG_DONTWAIT (0x00000008) /* Nonblocking IO */
332 
333 /* AP DHCP Server - IP Release reason code */
334 #define SL_IP_LEASE_PEER_RELEASE (0)
335 #define SL_IP_LEASE_PEER_DECLINE (1)
336 #define SL_IP_LEASE_EXPIRED (2)
337 
338 /* possible types when receiving SL_SOCKET_ASYNC_EVENT*/
339 #define SSL_ACCEPT (0) /* accept failed due to ssl issue ( tcp pass) */
340 #define RX_FRAGMENTATION_TOO_BIG (1) /* connection less mode, rx packet fragmentation > 16K, packet is being released */
341 #define OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED (2) /* remote side down from secure to unsecure */
342 
343 
344 
345 #ifdef SL_INC_STD_BSD_API_NAMING
346 
347 #define FD_SETSIZE SL_FD_SETSIZE
348 
349 #define SOCK_STREAM SL_SOCK_STREAM
350 #define SOCK_DGRAM SL_SOCK_DGRAM
351 #define SOCK_RAW SL_SOCK_RAW
352 #define IPPROTO_TCP SL_IPPROTO_TCP
353 #define IPPROTO_UDP SL_IPPROTO_UDP
354 #define IPPROTO_RAW SL_IPPROTO_RAW
355 
356 #define AF_INET SL_AF_INET
357 #define AF_INET6 SL_AF_INET6
358 #define AF_INET6_EUI_48 SL_AF_INET6_EUI_48
359 #define AF_RF SL_AF_RF
360 #define AF_PACKET SL_AF_PACKET
361 
362 #define PF_INET SL_PF_INET
363 #define PF_INET6 SL_PF_INET6
364 
365 #define INADDR_ANY SL_INADDR_ANY
366 #define ERROR SL_SOC_ERROR
367 #define INEXE SL_INEXE
368 #define EBADF SL_EBADF
369 #define ENSOCK SL_ENSOCK
370 #define EAGAIN SL_EAGAIN
371 #define EWOULDBLOCK SL_EWOULDBLOCK
372 #define ENOMEM SL_ENOMEM
373 #define EACCES SL_EACCES
374 #define EFAULT SL_EFAULT
375 #define EINVAL SL_EINVAL
376 #define EDESTADDRREQ SL_EDESTADDRREQ
377 #define EPROTOTYPE SL_EPROTOTYPE
378 #define ENOPROTOOPT SL_ENOPROTOOPT
379 #define EPROTONOSUPPORT SL_EPROTONOSUPPORT
380 #define ESOCKTNOSUPPORT SL_ESOCKTNOSUPPORT
381 #define EOPNOTSUPP SL_EOPNOTSUPP
382 #define EAFNOSUPPORT SL_EAFNOSUPPORT
383 #define EADDRINUSE SL_EADDRINUSE
384 #define EADDRNOTAVAIL SL_EADDRNOTAVAIL
385 #define ENETUNREACH SL_ENETUNREACH
386 #define ENOBUFS SL_ENOBUFS
387 #define EOBUFF SL_EOBUFF
388 #define EISCONN SL_EISCONN
389 #define ENOTCONN SL_ENOTCONN
390 #define ETIMEDOUT SL_ETIMEDOUT
391 #define ECONNREFUSED SL_ECONNREFUSED
392 
393 #define SOL_SOCKET SL_SOL_SOCKET
394 #define IPPROTO_IP SL_IPPROTO_IP
395 #define SO_KEEPALIVE SL_SO_KEEPALIVE
396 
397 #define SO_RCVTIMEO SL_SO_RCVTIMEO
398 #define SO_NONBLOCKING SL_SO_NONBLOCKING
399 
400 #define IP_MULTICAST_IF SL_IP_MULTICAST_IF
401 #define IP_MULTICAST_TTL SL_IP_MULTICAST_TTL
402 #define IP_ADD_MEMBERSHIP SL_IP_ADD_MEMBERSHIP
403 #define IP_DROP_MEMBERSHIP SL_IP_DROP_MEMBERSHIP
404 
405 #define socklen_t SlSocklen_t
406 #define timeval SlTimeval_t
407 #define sockaddr SlSockAddr_t
408 #define in6_addr SlIn6Addr_t
409 #define sockaddr_in6 SlSockAddrIn6_t
410 #define in_addr SlInAddr_t
411 #define sockaddr_in SlSockAddrIn_t
412 
413 #define MSG_DONTWAIT SL_MSG_DONTWAIT
414 
415 #define FD_SET SL_FD_SET
416 #define FD_CLR SL_FD_CLR
417 #define FD_ISSET SL_FD_ISSET
418 #define FD_ZERO SL_FD_ZERO
419 #define fd_set SlFdSet_t
420 
421 #define socket sl_Socket
422 #define close sl_Close
423 #define accept sl_Accept
424 #define bind sl_Bind
425 #define listen sl_Listen
426 #define connect sl_Connect
427 #define select sl_Select
428 #define setsockopt sl_SetSockOpt
429 #define getsockopt sl_GetSockOpt
430 #define recv sl_Recv
431 #define recvfrom sl_RecvFrom
432 #define write sl_Write
433 #define send sl_Send
434 #define sendto sl_SendTo
435 #define gethostbyname sl_NetAppDnsGetHostByName
436 #define htonl sl_Htonl
437 #define ntohl sl_Ntohl
438 #define htons sl_Htons
439 #define ntohs sl_Ntohs
440 #endif
441 
442 /*****************************************************************************/
443 /* Structure/Enum declarations */
444 /*****************************************************************************/
445 
446 /* Internet address */
447 typedef struct SlInAddr_t
448 {
449 #ifndef s_addr
450  _u32 s_addr; /* Internet address 32 bits */
451 #else
452  union S_un {
453  struct { _u8 s_b1,s_b2,s_b3,s_b4; } S_un_b;
454  struct { _u8 s_w1,s_w2; } S_un_w;
455  _u32 S_addr;
456  } S_un;
457 #endif
458 }SlInAddr_t;
459 
460 
461 /* sockopt */
462 typedef struct
463 {
464  _u32 KeepaliveEnabled; /* 0 = disabled;1 = enabled; default = 1*/
466 
467 typedef struct
468 {
469  _u32 ReuseaddrEnabled; /* 0 = disabled; 1 = enabled; default = 1*/
471 
472 typedef struct
473 {
474  _u32 Winsize; /* receive window size for tcp sockets */
476 
477 typedef struct
478 {
479  _u32 NonblockingEnabled;/* 0 = disabled;1 = enabled;default = 1*/
481 
482 
483 typedef struct
484 {
485  _u8 sd;
486  _u8 type;
487  _i16 val;
488  _u8* pExtraInfo;
490 
491 typedef struct
492 {
493  _i16 status;
494  _u8 sd;
495  _u8 padding;
497 
498 
499 typedef union
500 {
501  SlSockTxFailEventData_t SockTxFailData;
502  SlSocketAsyncEvent_t SockAsyncData;
504 
505 
506 typedef struct
507 {
508  _u32 Event;
509  SlSockEventData_u socketAsyncEvent;
510 } SlSockEvent_t;
511 
512 
513 
514 
515 
516 
517 typedef struct
518 {
519  _u32 secureMask;
521 
522 typedef struct
523 {
524  _u8 secureMethod;
526 
527 typedef enum
528 {
529  SL_BSD_SECURED_PRIVATE_KEY_IDX = 0,
530  SL_BSD_SECURED_CERTIFICATE_IDX,
531  SL_BSD_SECURED_CA_IDX,
532  SL_BSD_SECURED_DH_IDX
533 }slBsd_secureSocketFilesIndex_e;
534 
535 typedef struct
536 {
537  SlInAddr_t imr_multiaddr; /* The IPv4 multicast address to join */
538  SlInAddr_t imr_interface; /* The interface to use for this group */
539 } SlSockIpMreq;
540 
541 
542 /* sockopt */
543 typedef _u32 SlTime_t;
544 typedef _u32 SlSuseconds_t;
545 
546 typedef struct SlTimeval_t
547 {
548  SlTime_t tv_sec; /* Seconds */
549  SlSuseconds_t tv_usec; /* Microseconds */
550 }SlTimeval_t;
551 
552 typedef _u16 SlSocklen_t;
553 
554 /* IpV4 socket address */
555 typedef struct SlSockAddr_t
556 {
557  _u16 sa_family; /* Address family (e.g. , AF_INET) */
558  _u8 sa_data[14]; /* Protocol- specific address information*/
559 }SlSockAddr_t;
560 
561 
562 /* IpV6 or Ipv6 EUI64 */
563 typedef struct SlIn6Addr_t
564 {
565  union
566  {
567  _u8 _S6_u8[16];
568  _u32 _S6_u32[4];
569  } _S6_un;
570 }SlIn6Addr_t;
571 
572 typedef struct SlSockAddrIn6_t
573 {
574  _u16 sin6_family; /* AF_INET6 || AF_INET6_EUI_48*/
575  _u16 sin6_port; /* Transport layer port. */
576  _u32 sin6_flowinfo; /* IPv6 flow information. */
577  SlIn6Addr_t sin6_addr; /* IPv6 address. */
578  _u32 sin6_scope_id; /* set of interfaces for a scope. */
580 
581 /* Socket address, Internet style. */
582 
583 typedef struct SlSockAddrIn_t
584 {
585  _u16 sin_family; /* Internet Protocol (AF_INET). */
586  _u16 sin_port; /* Address port (16 bits). */
587  SlInAddr_t sin_addr; /* Internet address (32 bits). */
588  _i8 sin_zero[8]; /* Not used. */
590 
591 typedef struct
592 {
593  _u32 ip;
594  _u32 gateway;
595  _u32 dns;
597 
598 typedef struct
599 {
600  _u32 type;
601  _u32 ip[4];
602  _u32 gateway[4];
603  _u32 dns[4];
605 
606 typedef struct
607 {
608  _u32 ip_address;
609  _u32 lease_time;
610  _u8 mac[6];
611  _u16 padding;
613 
614 typedef struct
615 {
616  _u32 ip_address;
617  _u8 mac[6];
618  _u16 reason;
620 
621 
622 typedef union
623 {
624  SlIpV4AcquiredAsync_t ipAcquiredV4; /*SL_NETAPP_IPV4_IPACQUIRED_EVENT*/
625  SlIpV6AcquiredAsync_t ipAcquiredV6; /*SL_NETAPP_IPV6_IPACQUIRED_EVENT*/
626  _u32 sd; /*SL_SOCKET_TX_FAILED_EVENT*/
627  SlIpLeasedAsync_t ipLeased; /* SL_NETAPP_IP_LEASED_EVENT */
628  SlIpReleasedAsync_t ipReleased; /* SL_NETAPP_IP_RELEASED_EVENT */
630 
631 typedef struct
632 {
633  _u32 Event;
634  SlNetAppEventData_u EventData;
636 
637 
638 typedef struct sock_secureFiles
639 {
640  _u8 secureFiles[4];
642 
643 
644 typedef struct SlFdSet_t /* The select socket array manager */
645 {
646  _u32 fd_array[(SL_FD_SETSIZE + (_u8)31)/(_u8)32]; /* Bit map of SOCKET Descriptors */
647 } SlFdSet_t;
648 
649 typedef struct
650 {
651  _u8 rate; /* Recevied Rate */
652  _u8 channel; /* The received channel*/
653  _i8 rssi; /* The computed RSSI value in db of current frame */
654  _u8 padding; /* pad to align to 32 bits */
655  _u32 timestamp; /* Timestamp in microseconds, */
657 
658 
659 
660 /*****************************************************************************/
661 /* Function prototypes */
662 /*****************************************************************************/
663 
715 #if _SL_INCLUDE_FUNC(sl_Socket)
716 _i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol);
717 #endif
718 
734 #if _SL_INCLUDE_FUNC(sl_Close)
735 _i16 sl_Close(_i16 sd);
736 #endif
737 
788 #if _SL_INCLUDE_FUNC(sl_Accept)
789 _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen);
790 #endif
791 
818 #if _SL_INCLUDE_FUNC(sl_Bind)
819 _i16 sl_Bind(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
820 #endif
821 
842 #if _SL_INCLUDE_FUNC(sl_Listen)
843 _i16 sl_Listen(_i16 sd, _i16 backlog);
844 #endif
845 
884 #if _SL_INCLUDE_FUNC(sl_Connect)
885 _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
886 #endif
887 
936 #if _SL_INCLUDE_FUNC(sl_Select)
937 _i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, struct SlTimeval_t *timeout);
938 
939 
945 void SL_FD_SET(_i16 fd, SlFdSet_t *fdset);
946 
952 void SL_FD_CLR(_i16 fd, SlFdSet_t *fdset);
953 
954 
963 _i16 SL_FD_ISSET(_i16 fd, SlFdSet_t *fdset);
964 
970 void SL_FD_ZERO(SlFdSet_t *fdset);
971 
972 
973 
974 #endif
975 
1246 #if _SL_INCLUDE_FUNC(sl_SetSockOpt)
1247 _i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSocklen_t optlen);
1248 #endif
1249 
1290 #if _SL_INCLUDE_FUNC(sl_GetSockOpt)
1291 _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t *optlen);
1292 #endif
1293 
1356 #if _SL_INCLUDE_FUNC(sl_Recv)
1357 _i16 sl_Recv(_i16 sd, void *buf, _i16 Len, _i16 flags);
1358 #endif
1359 
1415 #if _SL_INCLUDE_FUNC(sl_RecvFrom)
1416 _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, SlSocklen_t *fromlen);
1417 #endif
1418 
1465 #if _SL_INCLUDE_FUNC(sl_Send )
1466 _i16 sl_Send(_i16 sd, const void *buf, _i16 Len, _i16 flags);
1467 #endif
1468 
1519 #if _SL_INCLUDE_FUNC(sl_SendTo)
1520 _i16 sl_SendTo(_i16 sd, const void *buf, _i16 Len, _i16 flags, const SlSockAddr_t *to, SlSocklen_t tolen);
1521 #endif
1522 
1536 #if _SL_INCLUDE_FUNC(sl_Htonl )
1537 _u32 sl_Htonl( _u32 val );
1538 
1539 #define sl_Ntohl sl_Htonl /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
1540 #endif
1541 
1555 #if _SL_INCLUDE_FUNC(sl_Htons )
1556 _u16 sl_Htons( _u16 val );
1557 
1558 #define sl_Ntohs sl_Htons /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
1559 #endif
1560 
1569 #ifdef __cplusplus
1570 }
1571 #endif /* __cplusplus */
1572 
1573 #endif /* __SOCKET_H__ */
1574 
1575 
_i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen)
Initiate a connection on a socket.
_i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t *optlen)
Get socket options.
void SL_FD_ZERO(SlFdSet_t *fdset)
Select's SlFdSet_t ZERO function.
_i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, SlSocklen_t *fromlen)
read data from socket
void SL_FD_SET(_i16 fd, SlFdSet_t *fdset)
Select's SlFdSet_t SET function.
_i16 sl_Recv(_i16 sd, void *buf, _i16 Len, _i16 flags)
read data from TCP socket
void SL_FD_CLR(_i16 fd, SlFdSet_t *fdset)
Select's SlFdSet_t CLR function.
_i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen)
Accept a connection on a socket.
_i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol)
create an endpoint for communication
_u32 sl_Htonl(_u32 val)
Reorder the bytes of a 32-bit unsigned value.
_i16 sl_Send(_i16 sd, const void *buf, _i16 Len, _i16 flags)
write data to TCP socket
_i16 sl_Listen(_i16 sd, _i16 backlog)
listen for connections on a socket
_i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSocklen_t optlen)
set socket options
_i16 sl_SendTo(_i16 sd, const void *buf, _i16 Len, _i16 flags, const SlSockAddr_t *to, SlSocklen_t tolen)
write data to socket
_i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, struct SlTimeval_t *timeout)
Monitor socket activity.
_i16 sl_Bind(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen)
assign a name to a socket
_i16 SL_FD_ISSET(_i16 fd, SlFdSet_t *fdset)
Select's SlFdSet_t ISSET function.
_u16 sl_Htons(_u16 val)
Reorder the bytes of a 16-bit unsigned value.
_i16 sl_Close(_i16 sd)
gracefully close socket