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