SimpleLink Host Driver  1.0.0.1
 All Data Structures Functions Variables Groups Pages
socket.h
1 /*
2  * socket.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2014 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 #ifndef __SL_SOCKET_H__
38 #define __SL_SOCKET_H__
39 
40 /*****************************************************************************/
41 /* Include files */
42 /*****************************************************************************/
43 #include "simplelink.h"
44 
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
57 /*****************************************************************************/
58 /* Macro declarations */
59 /*****************************************************************************/
60 
61 #define SL_FD_SETSIZE SL_MAX_SOCKETS /* Number of sockets to select on - same is max sockets! */
62 #define BSD_SOCKET_ID_MASK (0x0F) /* Index using the LBS 4 bits for socket id 0-7 */
63 /* Define some BSD protocol constants. */
64 #define SL_SOCK_STREAM (1) /* TCP Socket */
65 #define SL_SOCK_DGRAM (2) /* UDP Socket */
66 #define SL_SOCK_RAW (3) /* Raw socket */
67 #define SL_IPPROTO_TCP (6) /* TCP Raw Socket */
68 #define SL_IPPROTO_UDP (17) /* UDP Raw Socket */
69 #define SL_IPPROTO_RAW (255) /* Raw Socket */
70 #define SL_SEC_SOCKET (100) /* Secured Socket Layer (SSL,TLS) */
71 
72 /* Address families. */
73 #define SL_AF_INET (2) /* IPv4 socket (UDP, TCP, etc) */
74 #define SL_AF_INET6 (3) /* IPv6 socket (UDP, TCP, etc) */
75 #define SL_AF_INET6_EUI_48 (9)
76 #define SL_AF_RF (6) /* data include RF parameter, All layer by user (Wifi could be disconnected) */
77 #define SL_AF_PACKET (17)
78 /* Protocol families, same as address families. */
79 #define SL_PF_INET AF_INET
80 #define SL_PF_INET6 AF_INET6
81 #define SL_INADDR_ANY (0) /* bind any address */
82 
83 /* error codes */
84 #define SL_SOC_ERROR (-1) /* Failure. */
85 #define SL_SOC_OK ( 0) /* Success. */
86 #define SL_INEXE (-8) /* socket command in execution */
87 #define SL_EBADF (-9) /* Bad file number */
88 #define SL_ENSOCK (-10) /* The system limit on the total number of open socket, has been reached */
89 #define SL_EAGAIN (-11) /* Try again */
90 #define SL_EWOULDBLOCK SL_EAGAIN
91 #define SL_ENOMEM (-12) /* Out of memory */
92 #define SL_EACCES (-13) /* Permission denied */
93 #define SL_EFAULT (-14) /* Bad address */
94 #define SL_ECLOSE (-15) /* close socket operation failed to transmit all queued packets */
95 #define SL_EALREADY_ENABLED (-21) /* Transceiver - Transceiver already ON. there could be only one */
96 #define SL_EINVAL (-22) /* Invalid argument */
97 #define SL_EAUTO_CONNECT_OR_CONNECTING (-69) /* Transceiver - During connection, connected or auto mode started */
98 #define SL_CONNECTION_PENDING (-72) /* Transceiver - Device is connected, disconnect first to open transceiver */
99 #define SL_EUNSUPPORTED_ROLE (-86) /* Transceiver - Trying to start when WLAN role is AP or P2P GO */
100 #define SL_EDESTADDRREQ (-89) /* Destination address required */
101 #define SL_EPROTOTYPE (-91) /* Protocol wrong type for socket */
102 #define SL_ENOPROTOOPT (-92) /* Protocol not available */
103 #define SL_EPROTONOSUPPORT (-93) /* Protocol not supported */
104 #define SL_ESOCKTNOSUPPORT (-94) /* Socket type not supported */
105 #define SL_EOPNOTSUPP (-95) /* Operation not supported on transport endpoint */
106 #define SL_EAFNOSUPPORT (-97) /* Address family not supported by protocol */
107 #define SL_EADDRINUSE (-98) /* Address already in use */
108 #define SL_EADDRNOTAVAIL (-99) /* Cannot assign requested address */
109 #define SL_ENETUNREACH (-101) /* Network is unreachable */
110 #define SL_ENOBUFS (-105) /* No buffer space available */
111 #define SL_EOBUFF SL_ENOBUFS
112 #define SL_EISCONN (-106) /* Transport endpoint is already connected */
113 #define SL_ENOTCONN (-107) /* Transport endpoint is not connected */
114 #define SL_ETIMEDOUT (-110) /* Connection timed out */
115 #define SL_ECONNREFUSED (-111) /* Connection refused */
116 #define SL_EALREADY (-114) /* Non blocking connect in progress, try again */
117 
118 #define SL_ESEC_RSA_WRONG_TYPE_E (-130) /* RSA wrong block type for RSA function */
119 #define SL_ESEC_RSA_BUFFER_E (-131) /* RSA buffer error, output too small or */
120 #define SL_ESEC_BUFFER_E (-132) /* output buffer too small or input too large */
121 #define SL_ESEC_ALGO_ID_E (-133) /* setting algo id error */
122 #define SL_ESEC_PUBLIC_KEY_E (-134) /* setting public key error */
123 #define SL_ESEC_DATE_E (-135) /* setting date validity error */
124 #define SL_ESEC_SUBJECT_E (-136) /* setting subject name error */
125 #define SL_ESEC_ISSUER_E (-137) /* setting issuer name error */
126 #define SL_ESEC_CA_TRUE_E (-138) /* setting CA basic constraint true error */
127 #define SL_ESEC_EXTENSIONS_E (-139) /* setting extensions error */
128 #define SL_ESEC_ASN_PARSE_E (-140) /* ASN parsing error, invalid input */
129 #define SL_ESEC_ASN_VERSION_E (-141) /* ASN version error, invalid number */
130 #define SL_ESEC_ASN_GETINT_E (-142) /* ASN get big _i16 error, invalid data */
131 #define SL_ESEC_ASN_RSA_KEY_E (-143) /* ASN key init error, invalid input */
132 #define SL_ESEC_ASN_OBJECT_ID_E (-144) /* ASN object id error, invalid id */
133 #define SL_ESEC_ASN_TAG_NULL_E (-145) /* ASN tag error, not null */
134 #define SL_ESEC_ASN_EXPECT_0_E (-146) /* ASN expect error, not zero */
135 #define SL_ESEC_ASN_BITSTR_E (-147) /* ASN bit string error, wrong id */
136 #define SL_ESEC_ASN_UNKNOWN_OID_E (-148) /* ASN oid error, unknown sum id */
137 #define SL_ESEC_ASN_DATE_SZ_E (-149) /* ASN date error, bad size */
138 #define SL_ESEC_ASN_BEFORE_DATE_E (-150) /* ASN date error, current date before */
139 #define SL_ESEC_ASN_AFTER_DATE_E (-151) /* ASN date error, current date after */
140 #define SL_ESEC_ASN_SIG_OID_E (-152) /* ASN signature error, mismatched oid */
141 #define SL_ESEC_ASN_TIME_E (-153) /* ASN time error, unknown time type */
142 #define SL_ESEC_ASN_INPUT_E (-154) /* ASN input error, not enough data */
143 #define SL_ESEC_ASN_SIG_CONFIRM_E (-155) /* ASN sig error, confirm failure */
144 #define SL_ESEC_ASN_SIG_HASH_E (-156) /* ASN sig error, unsupported hash type */
145 #define SL_ESEC_ASN_SIG_KEY_E (-157) /* ASN sig error, unsupported key type */
146 #define SL_ESEC_ASN_DH_KEY_E (-158) /* ASN key init error, invalid input */
147 #define SL_ESEC_ASN_NTRU_KEY_E (-159) /* ASN ntru key decode error, invalid input */
148 #define SL_ESEC_ECC_BAD_ARG_E (-170) /* ECC input argument of wrong type */
149 #define SL_ESEC_ASN_ECC_KEY_E (-171) /* ASN ECC bad input */
150 #define SL_ESEC_ECC_CURVE_OID_E (-172) /* Unsupported ECC OID curve type */
151 #define SL_ESEC_BAD_FUNC_ARG (-173) /* Bad function argument provided */
152 #define SL_ESEC_NOT_COMPILED_IN (-174) /* Feature not compiled in */
153 #define SL_ESEC_UNICODE_SIZE_E (-175) /* Unicode password too big */
154 #define SL_ESEC_NO_PASSWORD (-176) /* no password provided by user */
155 #define SL_ESEC_ALT_NAME_E (-177) /* alt name size problem, too big */
156 #define SL_ESEC_AES_GCM_AUTH_E (-180) /* AES-GCM Authentication check failure */
157 #define SL_ESEC_AES_CCM_AUTH_E (-181) /* AES-CCM Authentication check failure */
158 /* ssl tls security start with -300 offset */
159 #define SL_ESEC_CLOSE_NOTIFY (-300) /* ssl/tls alerts */
160 #define SL_ESEC_UNEXPECTED_MESSAGE (-310) /* ssl/tls alerts */
161 #define SL_ESEC_BAD_RECORD_MAC (-320) /* ssl/tls alerts */
162 #define SL_ESEC_DECRYPTION_FAILED (-321) /* ssl/tls alerts */
163 #define SL_ESEC_RECORD_OVERFLOW (-322) /* ssl/tls alerts */
164 #define SL_ESEC_DECOMPRESSION_FAILURE (-330) /* ssl/tls alerts */
165 #define SL_ESEC_HANDSHAKE_FAILURE (-340) /* ssl/tls alerts */
166 #define SL_ESEC_NO_CERTIFICATE (-341) /* ssl/tls alerts */
167 #define SL_ESEC_BAD_CERTIFICATE (-342) /* ssl/tls alerts */
168 #define SL_ESEC_UNSUPPORTED_CERTIFICATE (-343) /* ssl/tls alerts */
169 #define SL_ESEC_CERTIFICATE_REVOKED (-344) /* ssl/tls alerts */
170 #define SL_ESEC_CERTIFICATE_EXPIRED (-345) /* ssl/tls alerts */
171 #define SL_ESEC_CERTIFICATE_UNKNOWN (-346) /* ssl/tls alerts */
172 #define SL_ESEC_ILLEGAL_PARAMETER (-347) /* ssl/tls alerts */
173 #define SL_ESEC_UNKNOWN_CA (-348) /* ssl/tls alerts */
174 #define SL_ESEC_ACCESS_DENIED (-349) /* ssl/tls alerts */
175 #define SL_ESEC_DECODE_ERROR (-350) /* ssl/tls alerts */
176 #define SL_ESEC_DECRYPT_ERROR (-351) /* ssl/tls alerts */
177 #define SL_ESEC_EXPORT_RESTRICTION (-360) /* ssl/tls alerts */
178 #define SL_ESEC_PROTOCOL_VERSION (-370) /* ssl/tls alerts */
179 #define SL_ESEC_INSUFFICIENT_SECURITY (-371) /* ssl/tls alerts */
180 #define SL_ESEC_INTERNAL_ERROR (-380) /* ssl/tls alerts */
181 #define SL_ESEC_USER_CANCELLED (-390) /* ssl/tls alerts */
182 #define SL_ESEC_NO_RENEGOTIATION (-400) /* ssl/tls alerts */
183 #define SL_ESEC_UNSUPPORTED_EXTENSION (-410) /* ssl/tls alerts */
184 #define SL_ESEC_CERTIFICATE_UNOBTAINABLE (-411) /* ssl/tls alerts */
185 #define SL_ESEC_UNRECOGNIZED_NAME (-412) /* ssl/tls alerts */
186 #define SL_ESEC_BAD_CERTIFICATE_STATUS_RESPONSE (-413) /* ssl/tls alerts */
187 #define SL_ESEC_BAD_CERTIFICATE_HASH_VALUE (-414) /* ssl/tls alerts */
188 /* propierty secure */
189 #define SL_ESECGENERAL (-450) /* error secure level general error */
190 #define SL_ESECDECRYPT (-451) /* error secure level, decrypt recv packet fail */
191 #define SL_ESECCLOSED (-452) /* secure layrer is closed by other size , tcp is still connected */
192 #define SL_ESECSNOVERIFY (-453) /* Connected without server verification */
193 #define SL_ESECNOCAFILE (-454) /* error secure level CA file not found*/
194 #define SL_ESECMEMORY (-455) /* error secure level No memory space available */
195 #define SL_ESECBADCAFILE (-456) /* error secure level bad CA file */
196 #define SL_ESECBADCERTFILE (-457) /* error secure level bad Certificate file */
197 #define SL_ESECBADPRIVATEFILE (-458) /* error secure level bad private file */
198 #define SL_ESECBADDHFILE (-459) /* error secure level bad DH file */
199 #define SL_ESECT00MANYSSLOPENED (-460) /* MAX SSL Sockets are opened */
200 #define SL_ESECDATEERROR (-461) /* connected with certificate date verification error */
201 #define SL_ESECHANDSHAKETIMEDOUT (-462) /* connection timed out due to handshake time */
202 
203 /* end error codes */
204 
205 /* Max payload size by protocol */
206 #define SL_SOCKET_PAYLOAD_TYPE_MASK (0xF0) /*4 bits type, 4 bits sockets id */
207 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4 (0x00) /* 1472 bytes */
208 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4 (0x10) /* 1460 bytes */
209 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6 (0x20) /* 1452 bytes */
210 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6 (0x30) /* 1440 bytes */
211 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4_SECURE (0x40) /* */
212 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4_SECURE (0x50) /* */
213 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6_SECURE (0x60) /* */
214 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6_SECURE (0x70) /* */
215 #define SL_SOCKET_PAYLOAD_TYPE_RAW_TRANCEIVER (0x80) /* 1536 bytes */
216 #define SL_SOCKET_PAYLOAD_TYPE_RAW_PACKET (0x90) /* 1536 bytes */
217 #define SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 (0xa0)
218 #define SL_SOCKET_PAYLOAD_TYPE_RAW_IP6 (SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 )
219 
220 
221 
222 #define SL_SOL_SOCKET (1) /* Define the socket option category. */
223 #define SL_IPPROTO_IP (2) /* Define the IP option category. */
224 #define SL_SOL_PHY_OPT (3) /* Define the PHY option category. */
225 
226 #define SL_SO_RCVBUF (8) /* Setting TCP receive buffer size */
227 #define SL_SO_KEEPALIVE (9) /* Connections are kept alive with periodic messages */
228 #define SL_SO_RCVTIMEO (20) /* Enable receive timeout */
229 #define SL_SO_NONBLOCKING (24) /* Enable . disable nonblocking mode */
230 #define SL_SO_SECMETHOD (25) /* security metohd */
231 #define SL_SO_SECURE_MASK (26) /* security mask */
232 #define SL_SO_SECURE_FILES (27) /* security files */
233 #define SL_SO_CHANGE_CHANNEL (28) /* This option is available only when transceiver started */
234 #define SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME (30) /* This option used to configue secure file */
235 #define SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME (31) /* This option used to configue secure file */
236 #define SL_SO_SECURE_FILES_CA_FILE_NAME (32) /* This option used to configue secure file */
237 #define SL_SO_SECURE_FILES_DH_KEY_FILE_NAME (33) /* This option used to configue secure file */
238 
239 #define SL_IP_MULTICAST_IF (60) /* Specify outgoing multicast interface */
240 #define SL_IP_MULTICAST_TTL (61) /* Specify the TTL value to use for outgoing multicast packet. */
241 #define SL_IP_ADD_MEMBERSHIP (65) /* Join IPv4 multicast membership */
242 #define SL_IP_DROP_MEMBERSHIP (66) /* Leave IPv4 multicast membership */
243 #define SL_IP_HDRINCL (67) /* Raw socket IPv4 header included. */
244 #define SL_IP_RAW_RX_NO_HEADER (68) /* Proprietary socket option that does not includeIPv4/IPv6 header (and extension headers) on received raw sockets*/
245 #define SL_IP_RAW_IPV6_HDRINCL (69) /* Transmitted buffer over IPv6 socket contains IPv6 header. */
246 
247 #define SL_SO_PHY_RATE (100) /* WLAN Transmit rate */
248 #define SL_SO_PHY_TX_POWER (101) /* TX Power level */
249 #define SL_SO_PHY_NUM_FRAMES_TO_TX (102) /* Number of frames to transmit */
250 #define SL_SO_PHY_PREAMBLE (103) /* Preamble for transmission */
251 
252 #define SL_SO_SEC_METHOD_SSLV3 (0) /* security metohd SSL v3*/
253 #define SL_SO_SEC_METHOD_TLSV1 (1) /* security metohd TLS v1*/
254 #define SL_SO_SEC_METHOD_TLSV1_1 (2) /* security metohd TLS v1_1*/
255 #define SL_SO_SEC_METHOD_TLSV1_2 (3) /* security metohd TLS v1_2*/
256 #define SL_SO_SEC_METHOD_SSLv3_TLSV1_2 (4) /* use highest possible version from SSLv3 - TLS 1.2*/
257 #define SL_SO_SEC_METHOD_DLSV1 (5) /* security metohd DTL v1 */
258 
259 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA (1 << 0)
260 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_MD5 (1 << 1)
261 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA (1 << 2)
262 #define SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_CBC_SHA (1 << 3)
263 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (1 << 4)
264 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_RC4_128_SHA (1 << 5)
265 #define SL_SEC_MASK_SECURE_DEFAULT ((SEC_MASK_TLS_ECDHE_RSA_WITH_RC4_128_SHA << 1) - 1)
266 
267 #define SL_MSG_DONTWAIT (0x00000008) /* Nonblocking IO */
268 
269 /* AP DHCP Server - IP Release reason code */
270 #define SL_IP_LEASE_PEER_RELEASE (0)
271 #define SL_IP_LEASE_PEER_DECLINE (1)
272 #define SL_IP_LEASE_EXPIRED (2)
273 
274 /* possible types when receiving SL_SOCKET_ASYNC_EVENT*/
275 #define SSL_ACCEPT (1) /* accept failed due to ssl issue ( tcp pass) */
276 #define RX_FRAGMENTATION_TOO_BIG (2) /* connection less mode, rx packet fragmentation > 16K, packet is being released */
277 #define OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED (3) /* remote side down from secure to unsecure */
278 
279 
280 
281 #ifdef SL_INC_STD_BSD_API_NAMING
282 
283 #define FD_SETSIZE SL_FD_SETSIZE
284 
285 #define SOCK_STREAM SL_SOCK_STREAM
286 #define SOCK_DGRAM SL_SOCK_DGRAM
287 #define SOCK_RAW SL_SOCK_RAW
288 #define IPPROTO_TCP SL_IPPROTO_TCP
289 #define IPPROTO_UDP SL_IPPROTO_UDP
290 #define IPPROTO_RAW SL_IPPROTO_RAW
291 
292 #define AF_INET SL_AF_INET
293 #define AF_INET6 SL_AF_INET6
294 #define AF_INET6_EUI_48 SL_AF_INET6_EUI_48
295 #define AF_RF SL_AF_RF
296 #define AF_PACKET SL_AF_PACKET
297 
298 #define PF_INET SL_PF_INET
299 #define PF_INET6 SL_PF_INET6
300 
301 #define INADDR_ANY SL_INADDR_ANY
302 #define ERROR SL_SOC_ERROR
303 #define INEXE SL_INEXE
304 #define EBADF SL_EBADF
305 #define ENSOCK SL_ENSOCK
306 #define EAGAIN SL_EAGAIN
307 #define EWOULDBLOCK SL_EWOULDBLOCK
308 #define ENOMEM SL_ENOMEM
309 #define EACCES SL_EACCES
310 #define EFAULT SL_EFAULT
311 #define EINVAL SL_EINVAL
312 #define EDESTADDRREQ SL_EDESTADDRREQ
313 #define EPROTOTYPE SL_EPROTOTYPE
314 #define ENOPROTOOPT SL_ENOPROTOOPT
315 #define EPROTONOSUPPORT SL_EPROTONOSUPPORT
316 #define ESOCKTNOSUPPORT SL_ESOCKTNOSUPPORT
317 #define EOPNOTSUPP SL_EOPNOTSUPP
318 #define EAFNOSUPPORT SL_EAFNOSUPPORT
319 #define EADDRINUSE SL_EADDRINUSE
320 #define EADDRNOTAVAIL SL_EADDRNOTAVAIL
321 #define ENETUNREACH SL_ENETUNREACH
322 #define ENOBUFS SL_ENOBUFS
323 #define EOBUFF SL_EOBUFF
324 #define EISCONN SL_EISCONN
325 #define ENOTCONN SL_ENOTCONN
326 #define ETIMEDOUT SL_ETIMEDOUT
327 #define ECONNREFUSED SL_ECONNREFUSED
328 
329 #define SOL_SOCKET SL_SOL_SOCKET
330 #define IPPROTO_IP SL_IPPROTO_IP
331 #define SO_KEEPALIVE SL_SO_KEEPALIVE
332 
333 #define SO_RCVTIMEO SL_SO_RCVTIMEO
334 #define SO_NONBLOCKING SL_SO_NONBLOCKING
335 
336 #define IP_MULTICAST_IF SL_IP_MULTICAST_IF
337 #define IP_MULTICAST_TTL SL_IP_MULTICAST_TTL
338 #define IP_ADD_MEMBERSHIP SL_IP_ADD_MEMBERSHIP
339 #define IP_DROP_MEMBERSHIP SL_IP_DROP_MEMBERSHIP
340 
341 #define socklen_t SlSocklen_t
342 #define timeval SlTimeval_t
343 #define sockaddr SlSockAddr_t
344 #define in6_addr SlIn6Addr_t
345 #define sockaddr_in6 SlSockAddrIn6_t
346 #define in_addr SlInAddr_t
347 #define sockaddr_in SlSockAddrIn_t
348 
349 #define MSG_DONTWAIT SL_MSG_DONTWAIT
350 
351 #define FD_SET SL_FD_SET
352 #define FD_CLR SL_FD_CLR
353 #define FD_ISSET SL_FD_ISSET
354 #define FD_ZERO SL_FD_ZERO
355 #define fd_set SlFdSet_t
356 
357 #define socket sl_Socket
358 #define close sl_Close
359 #define accept sl_Accept
360 #define bind sl_Bind
361 #define listen sl_Listen
362 #define connect sl_Connect
363 #define select sl_Select
364 #define setsockopt sl_SetSockOpt
365 #define getsockopt sl_GetSockOpt
366 #define recv sl_Recv
367 #define recvfrom sl_RecvFrom
368 #define write sl_Write
369 #define send sl_Send
370 #define sendto sl_SendTo
371 #define gethostbyname sl_NetAppDnsGetHostByName
372 #define htonl sl_Htonl
373 #define ntohl sl_Ntohl
374 #define htons sl_Htons
375 #define ntohs sl_Ntohs
376 #endif
377 
378 /*****************************************************************************/
379 /* Structure/Enum declarations */
380 /*****************************************************************************/
381 
382 /* Internet address */
383 typedef struct SlInAddr_t
384 {
385 #ifndef s_addr
386  _u32 s_addr; /* Internet address 32 bits */
387 #else
388  union S_un {
389  struct { _u8 s_b1,s_b2,s_b3,s_b4; } S_un_b;
390  struct { _u8 s_w1,s_w2; } S_un_w;
391  _u32 S_addr;
392  } S_un;
393 #endif
394 }SlInAddr_t;
395 
396 
397 /* sockopt */
398 typedef struct
399 {
400  _u32 KeepaliveEnabled; /* 0 = disabled;1 = enabled; default = 1*/
402 
403 typedef struct
404 {
405  _u32 ReuseaddrEnabled; /* 0 = disabled; 1 = enabled; default = 1*/
407 
408 typedef struct
409 {
410  _u32 Winsize; /* receive window size for tcp sockets */
412 
413 typedef struct
414 {
415  _u32 NonblockingEnabled;/* 0 = disabled;1 = enabled;default = 1*/
417 
418 typedef struct
419 {
420  _u8 sd;
421  _u8 type;
422  _u16 val;
424 
425 typedef struct
426 {
427  _i16 status;
428  _u16 sd;
429  SlSocketAsyncEvent_t socketAsyncEvent;
431 
432 
433 typedef struct
434 {
435  _u32 Event;
436  SlSockEventData_t EventData;
437 } SlSockEvent_t;
438 
439 
440 typedef struct
441 {
442  _u32 secureMask;
444 
445 typedef struct
446 {
447  _u8 secureMethod;
449 
450 typedef enum
451 {
452  SL_BSD_SECURED_PRIVATE_KEY_IDX = 0,
453  SL_BSD_SECURED_CERTIFICATE_IDX,
454  SL_BSD_SECURED_CA_IDX,
455  SL_BSD_SECURED_DH_IDX
456 }slBsd_secureSocketFilesIndex_e;
457 
458 typedef struct
459 {
460  SlInAddr_t imr_multiaddr; /* The IPv4 multicast address to join */
461  SlInAddr_t imr_interface; /* The interface to use for this group */
462 } SlSockIpMreq;
463 
464 
465 /* sockopt */
466 typedef _u32 SlTime_t;
467 typedef _u32 SlSuseconds_t;
468 
469 typedef struct SlTimeval_t
470 {
471  SlTime_t tv_sec; /* Seconds */
472  SlSuseconds_t tv_usec; /* Microseconds */
473 }SlTimeval_t;
474 
475 typedef _u16 SlSocklen_t;
476 
477 /* IpV4 socket address */
478 typedef struct SlSockAddr_t
479 {
480  _u16 sa_family; /* Address family (e.g. , AF_INET) */
481  _u8 sa_data[14]; /* Protocol- specific address information*/
482 }SlSockAddr_t;
483 
484 
485 /* IpV6 or Ipv6 EUI64 */
486 typedef struct SlIn6Addr_t
487 {
488  union
489  {
490  _u8 _S6_u8[16];
491  _u32 _S6_u32[4];
492  } _S6_un;
493 }SlIn6Addr_t;
494 
495 typedef struct SlSockAddrIn6_t
496 {
497  _u16 sin6_family; /* AF_INET6 || AF_INET6_EUI_48*/
498  _u16 sin6_port; /* Transport layer port. */
499  _u32 sin6_flowinfo; /* IPv6 flow information. */
500  SlIn6Addr_t sin6_addr; /* IPv6 address. */
501  _u32 sin6_scope_id; /* set of interfaces for a scope. */
503 
504 /* Socket address, Internet style. */
505 
506 typedef struct SlSockAddrIn_t
507 {
508  _u16 sin_family; /* Internet Protocol (AF_INET). */
509  _u16 sin_port; /* Address port (16 bits). */
510  SlInAddr_t sin_addr; /* Internet address (32 bits). */
511  _i8 sin_zero[8]; /* Not used. */
513 
514 typedef struct
515 {
516  _u32 ip;
517  _u32 gateway;
518  _u32 dns;
520 
521 typedef struct
522 {
523  _u32 type;
524  _u32 ip[4];
525  _u32 gateway[4];
526  _u32 dns[4];
528 
529 typedef struct
530 {
531  _u32 ip_address;
532  _u32 lease_time;
533  _u8 mac[6];
534  _u16 padding;
536 
537 typedef struct
538 {
539  _u32 ip_address;
540  _u8 mac[6];
541  _u16 reason;
543 
544 
545 typedef union
546 {
547  SlIpV4AcquiredAsync_t ipAcquiredV4; /*SL_NETAPP_IPV4_IPACQUIRED_EVENT*/
548  SlIpV6AcquiredAsync_t ipAcquiredV6; /*SL_NETAPP_IPV6_IPACQUIRED_EVENT*/
549  _u32 sd; /*SL_SOCKET_TX_FAILED_EVENT*/
550  SlIpLeasedAsync_t ipLeased; /* SL_NETAPP_IP_LEASED_EVENT */
551  SlIpReleasedAsync_t ipReleased; /* SL_NETAPP_IP_RELEASED_EVENT */
553 
554 typedef struct
555 {
556  _u32 Event;
557  SlNetAppEventData_u EventData;
559 
560 
561 typedef struct sock_secureFiles
562 {
563  _u8 secureFiles[4];
565 
566 
567 typedef struct SlFdSet_t /* The select socket array manager */
568 {
569  _u32 fd_array[(SL_FD_SETSIZE + 31)/32]; /* Bit map of SOCKET Descriptors */
570 } SlFdSet_t;
571 
572 typedef struct
573 {
574  _u8 rate; /* Recevied Rate */
575  _u8 channel; /* The received channel*/
576  _i8 rssi; /* The computed RSSI value in db of current frame */
577  _u8 padding; /* pad to align to 32 bits */
578  _u32 timestamp; /* Timestamp in microseconds, */
580 
581 
582 
583 /*****************************************************************************/
584 /* Function prototypes */
585 /*****************************************************************************/
586 
638 #if _SL_INCLUDE_FUNC(sl_Socket)
639 _i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol);
640 #endif
641 
657 #if _SL_INCLUDE_FUNC(sl_Close)
658 _i16 sl_Close(_i16 sd);
659 #endif
660 
711 #if _SL_INCLUDE_FUNC(sl_Accept)
712 _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen);
713 #endif
714 
741 #if _SL_INCLUDE_FUNC(sl_Bind)
742 _i16 sl_Bind(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
743 #endif
744 
765 #if _SL_INCLUDE_FUNC(sl_Listen)
766 _i16 sl_Listen(_i16 sd, _i16 backlog);
767 #endif
768 
807 #if _SL_INCLUDE_FUNC(sl_Connect)
808 _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
809 #endif
810 
859 #if _SL_INCLUDE_FUNC(sl_Select)
860 _i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, struct SlTimeval_t *timeout);
861 
862 
868 void SL_FD_SET(_i16 fd, SlFdSet_t *fdset);
869 
875 void SL_FD_CLR(_i16 fd, SlFdSet_t *fdset);
876 
877 
886 _i16 SL_FD_ISSET(_i16 fd, SlFdSet_t *fdset);
887 
893 void SL_FD_ZERO(SlFdSet_t *fdset);
894 
895 
896 
897 #endif
898 
1169 #if _SL_INCLUDE_FUNC(sl_SetSockOpt)
1170 _i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSocklen_t optlen);
1171 #endif
1172 
1213 #if _SL_INCLUDE_FUNC(sl_GetSockOpt)
1214 _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t *optlen);
1215 #endif
1216 
1279 #if _SL_INCLUDE_FUNC(sl_Recv)
1280 _i16 sl_Recv(_i16 sd, void *buf, _i16 Len, _i16 flags);
1281 #endif
1282 
1338 #if _SL_INCLUDE_FUNC(sl_RecvFrom)
1339 _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, SlSocklen_t *fromlen);
1340 #endif
1341 
1388 #if _SL_INCLUDE_FUNC(sl_Send )
1389 _i16 sl_Send(_i16 sd, const void *buf, _i16 Len, _i16 flags);
1390 #endif
1391 
1442 #if _SL_INCLUDE_FUNC(sl_SendTo)
1443 _i16 sl_SendTo(_i16 sd, const void *buf, _i16 Len, _i16 flags, const SlSockAddr_t *to, SlSocklen_t tolen);
1444 #endif
1445 
1459 #if _SL_INCLUDE_FUNC(sl_Htonl )
1460 _u32 sl_Htonl( _u32 val );
1461 
1462 #define sl_Ntohl sl_Htonl /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
1463 #endif
1464 
1478 #if _SL_INCLUDE_FUNC(sl_Htons )
1479 _u16 sl_Htons( _u16 val );
1480 
1481 #define sl_Ntohs sl_Htons /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
1482 #endif
1483 
1492 #ifdef __cplusplus
1493 }
1494 #endif /* __cplusplus */
1495 
1496 #endif /* __SOCKET_H__ */
1497 
1498 
Definition: socket.h:561
Definition: socket.h:440
Definition: socket.h:445
Definition: socket.h:486
Definition: socket.h:495
Definition: socket.h:554
Definition: socket.h:398
Definition: socket.h:529
Definition: socket.h:506
Definition: socket.h:413
Definition: socket.h:383
Definition: socket.h:567
Definition: socket.h:572
Definition: socket.h:521
Definition: socket.h:425
Definition: socket.h:418
Definition: socket.h:408
Definition: socket.h:469
Definition: socket.h:545
Definition: socket.h:458
Definition: socket.h:514
Definition: socket.h:478
Definition: socket.h:433
Definition: socket.h:537
Definition: socket.h:403