David Fletcher / Mbed 2 deprecated cc3100_test

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cc3100_socket.h Source File

cc3100_socket.h

00001 /*
00002  * socket.h - CC31xx/CC32xx Host Driver Implementation
00003  *
00004  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 
00005  * 
00006  * 
00007  *  Redistribution and use in source and binary forms, with or without 
00008  *  modification, are permitted provided that the following conditions 
00009  *  are met:
00010  *
00011  *    Redistributions of source code must retain the above copyright 
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  *    Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the 
00016  *    documentation and/or other materials provided with the   
00017  *    distribution.
00018  *
00019  *    Neither the name of Texas Instruments Incorporated nor the names of
00020  *    its contributors may be used to endorse or promote products derived
00021  *    from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
00027  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00028  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00029  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00032  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00033  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  *
00035 */
00036  
00037 #ifndef __SL_SOCKET_H__
00038 #define __SL_SOCKET_H__
00039 
00040 /*****************************************************************************/
00041 /* Include files                                                             */
00042 /*****************************************************************************/
00043 #include "cc3100_simplelink.h"
00044 
00045 
00046 #ifdef    __cplusplus
00047 extern "C" {
00048 #endif
00049 
00050 /*!
00051 
00052     \addtogroup socket
00053     @{
00054 
00055 */
00056 
00057 /*****************************************************************************/
00058 /* Macro declarations                                                        */
00059 /*****************************************************************************/
00060 
00061 #define SL_FD_SETSIZE                         SL_MAX_SOCKETS         /* Number of sockets to select on - same is max sockets!               */
00062 #define BSD_SOCKET_ID_MASK                     (0x0F)                 /* Index using the LBS 4 bits for socket id 0-7 */
00063 /* Define some BSD protocol constants.  */
00064 #define SL_SOCK_STREAM                         (1)                       /* TCP Socket                                                          */
00065 #define SL_SOCK_DGRAM                          (2)                       /* UDP Socket                                                          */
00066 #define SL_SOCK_RAW                            (3)                       /* Raw socket                                                          */
00067 #define SL_IPPROTO_TCP                         (6)                       /* TCP Raw Socket                                                      */
00068 #define SL_IPPROTO_UDP                         (17)                      /* UDP Raw Socket                                                      */
00069 #define SL_IPPROTO_RAW                         (255)                     /* Raw Socket                                                          */
00070 #define SL_SEC_SOCKET                          (100)                     /* Secured Socket Layer (SSL,TLS)                                      */
00071 
00072 /* Address families.  */
00073 #define     SL_AF_INET                         (2)                       /* IPv4 socket (UDP, TCP, etc)                                          */
00074 #define     SL_AF_INET6                        (3)                       /* IPv6 socket (UDP, TCP, etc)                                          */
00075 #define     SL_AF_INET6_EUI_48                 (9)
00076 #define     SL_AF_RF                           (6)                       /* data include RF parameter, All layer by user (Wifi could be disconnected) */ 
00077 #define     SL_AF_PACKET                       (17)
00078 /* Protocol families, same as address families.  */
00079 #define     SL_PF_INET                         AF_INET
00080 #define     SL_PF_INET6                        AF_INET6
00081 #define     SL_INADDR_ANY                      (0)                       /*  bind any address  */
00082 
00083 /* error codes */
00084 #define SL_SOC_ERROR                          (-1)  /* Failure.                                                             */
00085 #define SL_SOC_OK                             ( 0)  /* Success.                                                             */
00086 #define SL_INEXE                              (-8)   /* socket command in execution  */
00087 #define SL_EBADF                              (-9)   /* Bad file number */
00088 #define SL_ENSOCK                             (-10)  /* The system limit on the total number of open socket, has been reached */
00089 #define SL_EAGAIN                             (-11)  /* Try again */
00090 #define SL_EWOULDBLOCK                        SL_EAGAIN
00091 #define SL_ENOMEM                             (-12)  /* Out of memory */
00092 #define SL_EACCES                             (-13)  /* Permission denied */
00093 #define SL_EFAULT                             (-14)  /* Bad address */
00094 #define SL_ECLOSE                             (-15)  /* close socket operation failed to transmit all queued packets */
00095 #define SL_EALREADY_ENABLED                   (-21)  /* Transceiver - Transceiver already ON. there could be only one */
00096 #define SL_EINVAL                             (-22)  /* Invalid argument */
00097 #define SL_EAUTO_CONNECT_OR_CONNECTING        (-69)  /* Transceiver - During connection, connected or auto mode started */
00098 #define SL_CONNECTION_PENDING                  (-72)  /* Transceiver - Device is connected, disconnect first to open transceiver */
00099 #define SL_EUNSUPPORTED_ROLE                  (-86)  /* Transceiver - Trying to start when WLAN role is AP or P2P GO */
00100 #define SL_EDESTADDRREQ                       (-89)  /* Destination address required */
00101 #define SL_EPROTOTYPE                         (-91)  /* Protocol wrong type for socket */
00102 #define SL_ENOPROTOOPT                        (-92)  /* Protocol not available */
00103 #define SL_EPROTONOSUPPORT                    (-93)  /* Protocol not supported */
00104 #define SL_ESOCKTNOSUPPORT                    (-94)  /* Socket type not supported */
00105 #define SL_EOPNOTSUPP                         (-95)  /* Operation not supported on transport endpoint */
00106 #define SL_EAFNOSUPPORT                       (-97)  /* Address family not supported by protocol */
00107 #define SL_EADDRINUSE                         (-98)  /* Address already in use */
00108 #define SL_EADDRNOTAVAIL                      (-99)  /* Cannot assign requested address */
00109 #define SL_ENETUNREACH                        (-101) /* Network is unreachable */
00110 #define SL_ENOBUFS                            (-105) /* No buffer space available */
00111 #define SL_EOBUFF                             SL_ENOBUFS 
00112 #define SL_EISCONN                            (-106) /* Transport endpoint is already connected */
00113 #define SL_ENOTCONN                           (-107) /* Transport endpoint is not connected */
00114 #define SL_ETIMEDOUT                          (-110) /* Connection timed out */
00115 #define SL_ECONNREFUSED                       (-111) /* Connection refused */
00116 #define SL_EALREADY                           (-114) /* Non blocking connect in progress, try again */ 
00117 
00118 #define SL_ESEC_RSA_WRONG_TYPE_E              (-130)  /* RSA wrong block type for RSA function */
00119 #define SL_ESEC_RSA_BUFFER_E                  (-131)  /* RSA buffer error, output too small or */
00120 #define SL_ESEC_BUFFER_E                      (-132)  /* output buffer too small or input too large */
00121 #define SL_ESEC_ALGO_ID_E                     (-133)  /* setting algo id error */
00122 #define SL_ESEC_PUBLIC_KEY_E                  (-134)  /* setting public key error */
00123 #define SL_ESEC_DATE_E                        (-135)  /* setting date validity error */
00124 #define SL_ESEC_SUBJECT_E                     (-136)  /* setting subject name error */
00125 #define SL_ESEC_ISSUER_E                      (-137)  /* setting issuer  name error */
00126 #define SL_ESEC_CA_TRUE_E                     (-138)  /* setting CA basic constraint true error */
00127 #define SL_ESEC_EXTENSIONS_E                  (-139)  /* setting extensions error */
00128 #define SL_ESEC_ASN_PARSE_E                   (-140)  /* ASN parsing error, invalid input */
00129 #define SL_ESEC_ASN_VERSION_E                 (-141)  /* ASN version error, invalid number */
00130 #define SL_ESEC_ASN_GETINT_E                  (-142)  /* ASN get big _i16 error, invalid data */
00131 #define SL_ESEC_ASN_RSA_KEY_E                 (-143)  /* ASN key init error, invalid input */
00132 #define SL_ESEC_ASN_OBJECT_ID_E               (-144)  /* ASN object id error, invalid id */
00133 #define SL_ESEC_ASN_TAG_NULL_E                (-145)  /* ASN tag error, not null */
00134 #define SL_ESEC_ASN_EXPECT_0_E                (-146)  /* ASN expect error, not zero */
00135 #define SL_ESEC_ASN_BITSTR_E                  (-147)  /* ASN bit string error, wrong id */
00136 #define SL_ESEC_ASN_UNKNOWN_OID_E             (-148)  /* ASN oid error, unknown sum id */
00137 #define SL_ESEC_ASN_DATE_SZ_E                 (-149)  /* ASN date error, bad size */
00138 #define SL_ESEC_ASN_BEFORE_DATE_E             (-150)  /* ASN date error, current date before */
00139 #define SL_ESEC_ASN_AFTER_DATE_E              (-151)  /* ASN date error, current date after */
00140 #define SL_ESEC_ASN_SIG_OID_E                 (-152)  /* ASN signature error, mismatched oid */
00141 #define SL_ESEC_ASN_TIME_E                    (-153)  /* ASN time error, unknown time type */
00142 #define SL_ESEC_ASN_INPUT_E                   (-154)  /* ASN input error, not enough data */
00143 #define SL_ESEC_ASN_SIG_CONFIRM_E             (-155)  /* ASN sig error, confirm failure */
00144 #define SL_ESEC_ASN_SIG_HASH_E                (-156)  /* ASN sig error, unsupported hash type */
00145 #define SL_ESEC_ASN_SIG_KEY_E                 (-157)  /* ASN sig error, unsupported key type */
00146 #define SL_ESEC_ASN_DH_KEY_E                  (-158)  /* ASN key init error, invalid input */
00147 #define SL_ESEC_ASN_NTRU_KEY_E                (-159)  /* ASN ntru key decode error, invalid input */
00148 #define SL_ESEC_ECC_BAD_ARG_E                 (-170)  /* ECC input argument of wrong type */
00149 #define SL_ESEC_ASN_ECC_KEY_E                 (-171)  /* ASN ECC bad input */
00150 #define SL_ESEC_ECC_CURVE_OID_E               (-172)  /* Unsupported ECC OID curve type */
00151 #define SL_ESEC_BAD_FUNC_ARG                  (-173)  /* Bad function argument provided */
00152 #define SL_ESEC_NOT_COMPILED_IN               (-174)  /* Feature not compiled in */
00153 #define SL_ESEC_UNICODE_SIZE_E                (-175)  /* Unicode password too big */
00154 #define SL_ESEC_NO_PASSWORD                   (-176)  /* no password provided by user */
00155 #define SL_ESEC_ALT_NAME_E                    (-177)  /* alt name size problem, too big */
00156 #define SL_ESEC_AES_GCM_AUTH_E                (-180)  /* AES-GCM Authentication check failure */
00157 #define SL_ESEC_AES_CCM_AUTH_E                (-181)  /* AES-CCM Authentication check failure */
00158 /* ssl tls security start with -300 offset */
00159 #define SL_ESEC_CLOSE_NOTIFY                  (-300) /* ssl/tls alerts */   
00160 #define SL_ESEC_UNEXPECTED_MESSAGE            (-310) /* ssl/tls alerts */   
00161 #define SL_ESEC_BAD_RECORD_MAC                (-320) /* ssl/tls alerts */                 
00162 #define SL_ESEC_DECRYPTION_FAILED             (-321) /* ssl/tls alerts */   
00163 #define SL_ESEC_RECORD_OVERFLOW               (-322) /* ssl/tls alerts */    
00164 #define SL_ESEC_DECOMPRESSION_FAILURE         (-330) /* ssl/tls alerts */                 
00165 #define SL_ESEC_HANDSHAKE_FAILURE             (-340) /* ssl/tls alerts */    
00166 #define SL_ESEC_NO_CERTIFICATE                (-341) /* ssl/tls alerts */    
00167 #define SL_ESEC_BAD_CERTIFICATE               (-342) /* ssl/tls alerts */          
00168 #define SL_ESEC_UNSUPPORTED_CERTIFICATE       (-343) /* ssl/tls alerts */     
00169 #define SL_ESEC_CERTIFICATE_REVOKED           (-344) /* ssl/tls alerts */                 
00170 #define SL_ESEC_CERTIFICATE_EXPIRED           (-345) /* ssl/tls alerts */                 
00171 #define SL_ESEC_CERTIFICATE_UNKNOWN           (-346) /* ssl/tls alerts */                 
00172 #define SL_ESEC_ILLEGAL_PARAMETER             (-347) /* ssl/tls alerts */                 
00173 #define SL_ESEC_UNKNOWN_CA                    (-348) /* ssl/tls alerts */                
00174 #define SL_ESEC_ACCESS_DENIED                 (-349) /* ssl/tls alerts */                
00175 #define SL_ESEC_DECODE_ERROR                  (-350) /* ssl/tls alerts */   
00176 #define SL_ESEC_DECRYPT_ERROR                 (-351) /* ssl/tls alerts */   
00177 #define SL_ESEC_EXPORT_RESTRICTION            (-360) /* ssl/tls alerts */    
00178 #define SL_ESEC_PROTOCOL_VERSION              (-370) /* ssl/tls alerts */    
00179 #define SL_ESEC_INSUFFICIENT_SECURITY         (-371) /* ssl/tls alerts */   
00180 #define SL_ESEC_INTERNAL_ERROR                (-380) /* ssl/tls alerts */   
00181 #define SL_ESEC_USER_CANCELLED                (-390) /* ssl/tls alerts */   
00182 #define SL_ESEC_NO_RENEGOTIATION              (-400) /* ssl/tls alerts */   
00183 #define SL_ESEC_UNSUPPORTED_EXTENSION         (-410) /* ssl/tls alerts */   
00184 #define SL_ESEC_CERTIFICATE_UNOBTAINABLE      (-411) /* ssl/tls alerts */         
00185 #define SL_ESEC_UNRECOGNIZED_NAME             (-412) /* ssl/tls alerts */   
00186 #define SL_ESEC_BAD_CERTIFICATE_STATUS_RESPONSE  (-413) /* ssl/tls alerts */   
00187 #define SL_ESEC_BAD_CERTIFICATE_HASH_VALUE    (-414) /* ssl/tls alerts */   
00188 /* propierty secure */
00189 #define SL_ESECGENERAL                        (-450)  /* error secure level general error */
00190 #define SL_ESECDECRYPT                        (-451)  /* error secure level, decrypt recv packet fail */
00191 #define SL_ESECCLOSED                         (-452)  /* secure layrer is closed by other size , tcp is still connected  */
00192 #define SL_ESECSNOVERIFY                      (-453)  /* Connected without server verification */
00193 #define SL_ESECNOCAFILE                       (-454)  /* error secure level CA file not found*/
00194 #define SL_ESECMEMORY                         (-455)  /* error secure level No memory  space available */
00195 #define SL_ESECBADCAFILE                      (-456)  /* error secure level bad CA file */
00196 #define SL_ESECBADCERTFILE                    (-457)  /* error secure level bad Certificate file */
00197 #define SL_ESECBADPRIVATEFILE                 (-458)  /* error secure level bad private file */
00198 #define SL_ESECBADDHFILE                      (-459)  /* error secure level bad DH file */
00199 #define SL_ESECT00MANYSSLOPENED               (-460)  /* MAX SSL Sockets are opened */
00200 #define SL_ESECDATEERROR                      (-461)  /* connected with certificate date verification error */
00201 #define SL_ESECHANDSHAKETIMEDOUT              (-462)  /* connection timed out due to handshake time */
00202 
00203 /* end error codes */
00204 
00205 /* Max payload size by protocol */
00206 #define SL_SOCKET_PAYLOAD_TYPE_MASK            (0xF0)  /*4 bits type, 4 bits sockets id */
00207 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4        (0x00)  /* 1472 bytes */
00208 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4        (0x10)  /* 1460 bytes */
00209 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6        (0x20)  /* 1452 bytes */
00210 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6        (0x30)  /* 1440 bytes */
00211 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4_SECURE (0x40)  /*            */
00212 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4_SECURE (0x50)  /*            */
00213 #define SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6_SECURE (0x60)  /*            */
00214 #define SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6_SECURE (0x70)  /*            */
00215 #define SL_SOCKET_PAYLOAD_TYPE_RAW_TRANCEIVER  (0x80)  /* 1536 bytes */
00216 #define SL_SOCKET_PAYLOAD_TYPE_RAW_PACKET      (0x90)  /* 1536 bytes */
00217 #define SL_SOCKET_PAYLOAD_TYPE_RAW_IP4         (0xa0)  
00218 #define SL_SOCKET_PAYLOAD_TYPE_RAW_IP6         (SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 )  
00219 
00220   
00221 
00222 #define SL_SOL_SOCKET          (1)   /* Define the socket option category. */
00223 #define SL_IPPROTO_IP          (2)   /* Define the IP option category.     */
00224 #define SL_SOL_PHY_OPT         (3)   /* Define the PHY option category.    */
00225 
00226 #define SL_SO_RCVBUF           (8)   /* Setting TCP receive buffer size */
00227 #define SL_SO_KEEPALIVE        (9)   /* Connections are kept alive with periodic messages */
00228 #define SL_SO_RCVTIMEO         (20)  /* Enable receive timeout */
00229 #define SL_SO_NONBLOCKING      (24)  /* Enable . disable nonblocking mode  */
00230 #define SL_SO_SECMETHOD        (25)  /* security metohd */
00231 #define SL_SO_SECURE_MASK      (26)  /* security mask */
00232 #define SL_SO_SECURE_FILES     (27)  /* security files */
00233 #define SL_SO_CHANGE_CHANNEL   (28)  /* This option is available only when transceiver started */
00234 #define SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME (30) /* This option used to configue secure file */
00235 #define SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME (31) /* This option used to configue secure file */
00236 #define SL_SO_SECURE_FILES_CA_FILE_NAME          (32) /* This option used to configue secure file */
00237 #define SL_SO_SECURE_FILES_DH_KEY_FILE_NAME      (33) /* This option used to configue secure file */
00238 
00239 #define SL_IP_MULTICAST_IF     (60) /* Specify outgoing multicast interface */
00240 #define SL_IP_MULTICAST_TTL    (61) /* Specify the TTL value to use for outgoing multicast packet. */
00241 #define SL_IP_ADD_MEMBERSHIP   (65) /* Join IPv4 multicast membership */
00242 #define SL_IP_DROP_MEMBERSHIP  (66) /* Leave IPv4 multicast membership */
00243 #define SL_IP_HDRINCL          (67) /* Raw socket IPv4 header included. */
00244 #define SL_IP_RAW_RX_NO_HEADER (68) /* Proprietary socket option that does not includeIPv4/IPv6 header (and extension headers) on received raw sockets*/
00245 #define SL_IP_RAW_IPV6_HDRINCL (69) /* Transmitted buffer over IPv6 socket contains IPv6 header. */
00246 
00247 #define SL_SO_PHY_RATE              (100)   /* WLAN Transmit rate */
00248 #define SL_SO_PHY_TX_POWER          (101)   /* TX Power level */  
00249 #define SL_SO_PHY_NUM_FRAMES_TO_TX  (102)   /* Number of frames to transmit */
00250 #define SL_SO_PHY_PREAMBLE          (103)   /* Preamble for transmission */
00251 
00252 #define SL_SO_SEC_METHOD_SSLV3                             (0)  /* security metohd SSL v3*/
00253 #define SL_SO_SEC_METHOD_TLSV1                             (1)  /* security metohd TLS v1*/
00254 #define SL_SO_SEC_METHOD_TLSV1_1                           (2)  /* security metohd TLS v1_1*/
00255 #define SL_SO_SEC_METHOD_TLSV1_2                           (3)  /* security metohd TLS v1_2*/
00256 #define SL_SO_SEC_METHOD_SSLv3_TLSV1_2                     (4)  /* use highest possible version from SSLv3 - TLS 1.2*/
00257 #define SL_SO_SEC_METHOD_DLSV1                             (5)  /* security metohd DTL v1  */
00258 
00259 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA               (1 << 0)
00260 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_MD5               (1 << 1)
00261 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA           (1 << 2)
00262 #define SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_CBC_SHA       (1 << 3)
00263 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA     (1 << 4)
00264 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_RC4_128_SHA         (1 << 5)
00265 #define SL_SEC_MASK_SECURE_DEFAULT                         ((SEC_MASK_TLS_ECDHE_RSA_WITH_RC4_128_SHA  <<  1)  -  1)
00266 
00267 #define SL_MSG_DONTWAIT                                   (0x00000008)  /* Nonblocking IO */
00268 
00269 /* AP DHCP Server - IP Release reason code */
00270 #define SL_IP_LEASE_PEER_RELEASE     (0)
00271 #define SL_IP_LEASE_PEER_DECLINE     (1)
00272 #define SL_IP_LEASE_EXPIRED          (2)
00273 
00274 /* possible types when receiving SL_SOCKET_ASYNC_EVENT*/
00275 #define SSL_ACCEPT                                (1) /* accept failed due to ssl issue ( tcp pass) */
00276 #define RX_FRAGMENTATION_TOO_BIG                  (2) /* connection less mode, rx packet fragmentation > 16K, packet is being released */
00277 #define OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED   (3) /* remote side down from secure to unsecure */
00278 
00279 
00280 
00281 #ifdef SL_INC_STD_BSD_API_NAMING
00282 
00283 #define FD_SETSIZE                          SL_FD_SETSIZE        
00284                                                                        
00285 #define SOCK_STREAM                         SL_SOCK_STREAM        
00286 #define SOCK_DGRAM                          SL_SOCK_DGRAM         
00287 #define SOCK_RAW                            SL_SOCK_RAW           
00288 #define IPPROTO_TCP                         SL_IPPROTO_TCP        
00289 #define IPPROTO_UDP                         SL_IPPROTO_UDP        
00290 #define IPPROTO_RAW                         SL_IPPROTO_RAW        
00291                                                                        
00292 #define AF_INET                             SL_AF_INET            
00293 #define AF_INET6                            SL_AF_INET6           
00294 #define AF_INET6_EUI_48                     SL_AF_INET6_EUI_48
00295 #define AF_RF                               SL_AF_RF              
00296 #define AF_PACKET                           SL_AF_PACKET              
00297                                                                        
00298 #define PF_INET                             SL_PF_INET            
00299 #define PF_INET6                            SL_PF_INET6           
00300                                                                        
00301 #define INADDR_ANY                          SL_INADDR_ANY                                                   
00302 #define ERROR                               SL_SOC_ERROR                                                                                                                
00303 #define INEXE                               SL_INEXE                 
00304 #define EBADF                               SL_EBADF                 
00305 #define ENSOCK                              SL_ENSOCK                
00306 #define EAGAIN                              SL_EAGAIN                
00307 #define EWOULDBLOCK                         SL_EWOULDBLOCK           
00308 #define ENOMEM                              SL_ENOMEM                
00309 #define EACCES                              SL_EACCES                
00310 #define EFAULT                              SL_EFAULT                
00311 #define EINVAL                              SL_EINVAL                
00312 #define EDESTADDRREQ                        SL_EDESTADDRREQ          
00313 #define EPROTOTYPE                          SL_EPROTOTYPE            
00314 #define ENOPROTOOPT                         SL_ENOPROTOOPT           
00315 #define EPROTONOSUPPORT                     SL_EPROTONOSUPPORT       
00316 #define ESOCKTNOSUPPORT                     SL_ESOCKTNOSUPPORT       
00317 #define EOPNOTSUPP                          SL_EOPNOTSUPP            
00318 #define EAFNOSUPPORT                        SL_EAFNOSUPPORT          
00319 #define EADDRINUSE                          SL_EADDRINUSE            
00320 #define EADDRNOTAVAIL                       SL_EADDRNOTAVAIL         
00321 #define ENETUNREACH                         SL_ENETUNREACH           
00322 #define ENOBUFS                             SL_ENOBUFS               
00323 #define EOBUFF                              SL_EOBUFF                
00324 #define EISCONN                             SL_EISCONN               
00325 #define ENOTCONN                            SL_ENOTCONN              
00326 #define ETIMEDOUT                           SL_ETIMEDOUT             
00327 #define ECONNREFUSED                        SL_ECONNREFUSED          
00328 
00329 #define SOL_SOCKET                          SL_SOL_SOCKET         
00330 #define IPPROTO_IP                          SL_IPPROTO_IP                     
00331 #define SO_KEEPALIVE                        SL_SO_KEEPALIVE            
00332                                                                        
00333 #define SO_RCVTIMEO                         SL_SO_RCVTIMEO        
00334 #define SO_NONBLOCKING                      SL_SO_NONBLOCKING     
00335                                                                        
00336 #define IP_MULTICAST_IF                     SL_IP_MULTICAST_IF    
00337 #define IP_MULTICAST_TTL                    SL_IP_MULTICAST_TTL   
00338 #define IP_ADD_MEMBERSHIP                   SL_IP_ADD_MEMBERSHIP  
00339 #define IP_DROP_MEMBERSHIP                  SL_IP_DROP_MEMBERSHIP 
00340                                                                        
00341 #define socklen_t                           SlSocklen_t
00342 #define timeval                             SlTimeval_t
00343 #define sockaddr                            SlSockAddr_t
00344 #define in6_addr                            SlIn6Addr_t
00345 #define sockaddr_in6                        SlSockAddrIn6_t
00346 #define in_addr                             SlInAddr_t
00347 #define sockaddr_in                         SlSockAddrIn_t
00348                                                                        
00349 #define MSG_DONTWAIT                        SL_MSG_DONTWAIT       
00350                                                                        
00351 #define FD_SET                              SL_FD_SET  
00352 #define FD_CLR                              SL_FD_CLR  
00353 #define FD_ISSET                            SL_FD_ISSET
00354 #define FD_ZERO                             SL_FD_ZERO 
00355 #define fd_set                              SlFdSet_t    
00356 
00357 #define socket                              sl_Socket
00358 #define close                               sl_Close
00359 #define accept                              sl_Accept
00360 #define bind                                sl_Bind
00361 #define listen                              sl_Listen
00362 #define connect                             sl_Connect
00363 #define select                              sl_Select
00364 #define setsockopt                          sl_SetSockOpt
00365 #define getsockopt                          sl_GetSockOpt
00366 #define recv                                sl_Recv
00367 #define recvfrom                            sl_RecvFrom
00368 #define _write                               sl_Write //Changed write to _write
00369 #define send                                sl_Send
00370 #define sendto                              sl_SendTo
00371 #define gethostbyname                       sl_NetAppDnsGetHostByName
00372 #define htonl                               sl_Htonl
00373 #define ntohl                               sl_Ntohl
00374 #define htons                               sl_Htons
00375 #define ntohs                               sl_Ntohs
00376 #endif
00377 
00378 /*****************************************************************************/
00379 /* Structure/Enum declarations                                               */
00380 /*****************************************************************************/
00381 
00382 /* Internet address   */
00383 typedef struct SlInAddr_t
00384 {
00385 #ifndef s_addr 
00386     _u32           s_addr;             /* Internet address 32 bits */
00387 #else
00388     union S_un {
00389        struct { _u8 s_b1,s_b2,s_b3,s_b4; } S_un_b;
00390        struct { _u8 s_w1,s_w2; } S_un_w;
00391         _u32 S_addr;
00392     } S_un;
00393 #endif
00394 }SlInAddr_t;
00395 
00396 
00397 /* sockopt */
00398 typedef struct 
00399 {
00400     _u32 KeepaliveEnabled; /* 0 = disabled;1 = enabled; default = 1*/
00401 }SlSockKeepalive_t;
00402 
00403 typedef struct 
00404 {
00405     _u32 ReuseaddrEnabled; /* 0 = disabled; 1 = enabled; default = 1*/
00406 }SlSockReuseaddr_t;
00407 
00408 typedef struct 
00409 {
00410     _u32 Winsize;          /* receive window size for tcp sockets  */
00411 }SlSockWinsize_t;
00412 
00413 typedef struct 
00414 {
00415     _u32 NonblockingEnabled;/* 0 = disabled;1 = enabled;default = 1*/
00416 }SlSockNonblocking_t;
00417 
00418 typedef struct
00419 {
00420     _u8   sd;
00421     _u8   type;
00422     _u16  val;
00423 } SlSocketAsyncEvent_t;
00424 
00425 typedef struct
00426 {
00427    _i16          status;
00428    _u16        sd;
00429    SlSocketAsyncEvent_t socketAsyncEvent;
00430 } SlSockEventData_t;
00431 
00432 
00433 typedef struct
00434 {
00435    _u32                    Event;
00436    SlSockEventData_t       EventData;
00437 } SlSockEvent_t;
00438 
00439 
00440 typedef struct
00441 {
00442     _u32    secureMask;
00443 } SlSockSecureMask;
00444 
00445 typedef struct
00446 {
00447     _u8     secureMethod;
00448 } SlSockSecureMethod;
00449 
00450 typedef enum
00451 {
00452   SL_BSD_SECURED_PRIVATE_KEY_IDX = 0,
00453   SL_BSD_SECURED_CERTIFICATE_IDX,
00454   SL_BSD_SECURED_CA_IDX,
00455   SL_BSD_SECURED_DH_IDX
00456 }slBsd_secureSocketFilesIndex_e;
00457 
00458 typedef struct 
00459 {
00460     SlInAddr_t   imr_multiaddr;     /* The IPv4 multicast address to join */
00461     SlInAddr_t   imr_interface;     /* The interface to use for this group */
00462 } SlSockIpMreq;
00463 
00464 
00465 /* sockopt */
00466 typedef _u32   SlTime_t;
00467 typedef _u32   SlSuseconds_t;
00468 
00469 typedef struct SlTimeval_t
00470 {
00471     SlTime_t          tv_sec;             /* Seconds      */
00472     SlSuseconds_t     tv_usec;            /* Microseconds */
00473 }SlTimeval_t;
00474 
00475 typedef _u16 SlSocklen_t;
00476 
00477 /* IpV4 socket address */
00478 typedef struct SlSockAddr_t
00479 {
00480     _u16          sa_family;     /* Address family (e.g. , AF_INET)     */
00481     _u8           sa_data[14];  /* Protocol- specific address information*/
00482 }SlSockAddr_t;
00483 
00484 
00485 /* IpV6 or Ipv6 EUI64 */
00486 typedef struct SlIn6Addr_t
00487 {
00488     union 
00489     {
00490         _u8   _S6_u8[16];
00491         _u32  _S6_u32[4];
00492     } _S6_un;
00493 }SlIn6Addr_t;
00494 
00495 typedef struct SlSockAddrIn6_t
00496 {
00497     _u16           sin6_family;                 /* AF_INET6 || AF_INET6_EUI_48*/
00498     _u16           sin6_port;                   /* Transport layer port.  */
00499     _u32           sin6_flowinfo;               /* IPv6 flow information. */
00500     SlIn6Addr_t             sin6_addr;                   /* IPv6 address. */
00501     _u32           sin6_scope_id;               /* set of interfaces for a scope. */
00502 }SlSockAddrIn6_t;
00503 
00504 /* Socket address, Internet style. */
00505 
00506 typedef struct SlSockAddrIn_t
00507 {
00508     _u16              sin_family;         /* Internet Protocol (AF_INET).                    */
00509     _u16              sin_port;           /* Address port (16 bits).                         */
00510     SlInAddr_t                  sin_addr;           /* Internet address (32 bits).                     */
00511     _i8               sin_zero[8];        /* Not used.                                       */
00512 }SlSockAddrIn_t;
00513 
00514 typedef struct
00515 {
00516     _u32 ip;
00517     _u32 gateway;
00518     _u32 dns;
00519 }SlIpV4AcquiredAsync_t;
00520 
00521 typedef struct  
00522 {
00523     _u32 type;
00524     _u32 ip[4];
00525     _u32 gateway[4];
00526     _u32 dns[4];
00527 }SlIpV6AcquiredAsync_t;
00528 
00529 typedef struct
00530 {
00531    _u32    ip_address;
00532    _u32    lease_time;
00533    _u8     mac[6];
00534    _u16    padding;
00535 }SlIpLeasedAsync_t;
00536 
00537 typedef struct
00538 {
00539   _u32    ip_address;
00540   _u8     mac[6];
00541   _u16    reason;
00542 }SlIpReleasedAsync_t;
00543 
00544 
00545 typedef union
00546 {
00547   SlIpV4AcquiredAsync_t    ipAcquiredV4; /*SL_NETAPP_IPV4_IPACQUIRED_EVENT*/
00548   SlIpV6AcquiredAsync_t    ipAcquiredV6; /*SL_NETAPP_IPV6_IPACQUIRED_EVENT*/
00549   _u32                      sd;           /*SL_SOCKET_TX_FAILED_EVENT*/ 
00550   SlIpLeasedAsync_t        ipLeased;     /* SL_NETAPP_IP_LEASED_EVENT   */
00551   SlIpReleasedAsync_t      ipReleased;   /* SL_NETAPP_IP_RELEASED_EVENT */
00552 } SlNetAppEventData_u;
00553 
00554 typedef struct
00555 {
00556    _u32                     Event;
00557    SlNetAppEventData_u       EventData;
00558 }SlNetAppEvent_t;
00559 
00560 
00561 typedef struct sock_secureFiles
00562 {
00563     _u8                     secureFiles[4];
00564 }SlSockSecureFiles_t;
00565 
00566 
00567 typedef struct SlFdSet_t                    /* The select socket array manager */
00568 { 
00569    _u32        fd_array[(SL_FD_SETSIZE + 31)/32]; /* Bit map of SOCKET Descriptors */
00570 } SlFdSet_t;
00571 
00572 typedef struct
00573 {
00574     _u8   rate;               /* Recevied Rate  */
00575     _u8   channel;            /* The received channel*/
00576     _i8    rssi;               /* The computed RSSI value in db of current frame */
00577     _u8   padding;                                           /* pad to align to 32 bits */
00578     _u32  timestamp;          /* Timestamp in microseconds,     */
00579 }SlTransceiverRxOverHead_t;
00580 
00581 
00582 
00583 /*****************************************************************************/
00584 /* Function prototypes                                                       */
00585 /*****************************************************************************/
00586 
00587 /*!
00588 
00589     \brief create an endpoint for communication
00590  
00591     The socket function creates a new socket of a certain socket type, identified 
00592     by an integer number, and allocates system resources to it.
00593     This function is called by the application layer to obtain a socket handle.
00594  
00595     \param[in] domain           specifies the protocol family of the created socket.
00596                                 For example:
00597                                    AF_INET for network protocol IPv4
00598                                    AF_RF for starting transceiver mode. Notes: 
00599                                    - sending and receiving any packet overriding 802.11 header
00600                                    - for optimized power consumption the socket will be started in TX 
00601                                      only mode until receive command is activated
00602                                    AF_INET6 for IPv6
00603 
00604 
00605     \param[in] type              specifies the communication semantic, one of:
00606                                    SOCK_STREAM (reliable stream-oriented service or Stream Sockets)
00607                                    SOCK_DGRAM (datagram service or Datagram Sockets)
00608                                    SOCK_RAW (raw protocols atop the network layer)
00609                                    when used with AF_RF:
00610                                                                      SOCK_DGRAM - L2 socket
00611                                                                      SOCK_RAW - L1 socket - bypass WLAN CCA (Clear Channel Assessment)
00612 
00613     \param[in] protocol         specifies a particular transport to be used with 
00614                                 the socket.
00615                                 The most common are IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP, 
00616                                 IPPROTO_DCCP.
00617                                 The value 0 may be used to select a default 
00618                                 protocol from the selected domain and type
00619 
00620  
00621     \return                     On success, socket handle that is used for consequent socket operations. 
00622                                 A successful return code should be a positive number (int16)
00623                                 On error, a negative (int16) value will be returned specifying the error code.
00624                            SL_EAFNOSUPPORT  - illegal domain parameter
00625                            SL_EPROTOTYPE  - illegal type parameter
00626                            SL_EACCES   - permission denied
00627                            SL_ENSOCK  - exceeded maximal number of socket 
00628                            SL_ENOMEM  - memory allocation error
00629                            SL_EINVAL  - error in socket configuration
00630                            SL_EPROTONOSUPPORT  - illegal protocol parameter
00631                            SL_EOPNOTSUPP  - illegal combination of protocol and type parameters
00632  
00633  
00634     \sa                         sl_Close
00635     \note                       belongs to \ref basic_api
00636     \warning
00637 */
00638 #if _SL_INCLUDE_FUNC(sl_Socket)
00639 _i16 sl_Socket(_i16 Domain, _i16 Type, _i16 Protocol);
00640 #endif
00641 
00642 /*!
00643     \brief gracefully close socket
00644 
00645     This function causes the system to release resources allocated to a socket.  \n
00646     In case of TCP, the connection is terminated.
00647 
00648     \param[in] sd               socket handle (received in sl_Socket)
00649 
00650     \return                        On success, zero is returned. 
00651                                 On error, a negative number is returned.                               
00652 
00653     \sa                         sl_Socket
00654     \note                       belongs to \ref ext_api
00655     \warning
00656 */
00657 #if _SL_INCLUDE_FUNC(sl_Close)
00658 _i16 sl_Close(_i16 sd);
00659 #endif
00660 
00661 /*!
00662     \brief Accept a connection on a socket
00663     
00664     This function is used with connection-based socket types (SOCK_STREAM).
00665     It extracts the first connection request on the queue of pending 
00666     connections, creates a new connected socket, and returns a new file 
00667     descriptor referring to that socket.
00668     The newly created socket is not in the listening state. The 
00669     original socket sd is unaffected by this call. 
00670     The argument sd is a socket that has been created with 
00671     sl_Socket(), bound to a local address with sl_Bind(), and is 
00672     listening for connections after a sl_Listen(). The argument \b 
00673     \e addr is a pointer to a sockaddr structure. This structure 
00674     is filled in with the address of the peer socket, as known to 
00675     the communications layer. The exact format of the address 
00676     returned addr is determined by the socket's address family. 
00677     The \b \e addrlen argument is a value-result argument: it 
00678     should initially contain the size of the structure pointed to 
00679     by addr, on return it will contain the actual length (in 
00680     bytes) of the address returned.
00681     
00682     \param[in] sd               socket descriptor (handle)
00683     \param[out] addr            the argument addr is a pointer 
00684                                 to a sockaddr structure. This
00685                                 structure is filled in with the
00686                                 address of the peer socket, as
00687                                 known to the communications
00688                                 layer. The exact format of the
00689                                 address returned addr is
00690                                 determined by the socket's
00691                                 address\n
00692                                 sockaddr:\n - code for the
00693                                 address format. On this version
00694                                 only AF_INET is supported.\n -
00695                                 socket address, the length
00696                                 depends on the code format
00697     \param[out] addrlen         the addrlen argument is a value-result 
00698                                 argument: it should initially contain the
00699                                 size of the structure pointed to by addr
00700     
00701     \return                        On success, a socket handle.
00702                                 On a non-blocking accept a possible negative value is SL_EAGAIN.
00703                                 On failure, negative value.
00704                                 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00705                                  In this case try again later or increase MAX_CONCURRENT_ACTIONS
00706     
00707     \sa                         sl_Socket  sl_Bind  sl_Listen
00708     \note                       belongs to \ref server_side
00709     \warning
00710 */
00711 #if _SL_INCLUDE_FUNC(sl_Accept)
00712 _i16 sl_Accept(_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen);
00713 #endif
00714 
00715 /*!
00716     \brief assign a name to a socket
00717  
00718     This function gives the socket the local address addr.
00719     addr is addrlen bytes long. Traditionally, this is called
00720     When a socket is created with socket, it exists in a name
00721     space (address family) but has no name assigned.
00722     It is necessary to assign a local address before a SOCK_STREAM
00723     socket may receive connections.
00724  
00725     \param[in] sd                socket descriptor (handle)
00726     \param[in] addr              specifies the destination 
00727                                 addrs\n sockaddr:\n - code for
00728                                 the address format. On this
00729                                 version only AF_INET is
00730                                 supported.\n - socket address,
00731                                 the length depends on the code
00732                                 format
00733     \param[in] addrlen          contains the size of the structure pointed to by addr
00734  
00735     \return                        On success, zero is returned. On error, a negative error code is returned.
00736  
00737     \sa                         sl_Socket  sl_Accept sl_Listen
00738     \note                       belongs to \ref basic_api
00739     \warning
00740 */
00741 #if _SL_INCLUDE_FUNC(sl_Bind)
00742 _i16 sl_Bind(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
00743 #endif
00744 
00745 /*!
00746     \brief listen for connections on a socket
00747  
00748     The willingness to accept incoming connections and a queue
00749     limit for incoming connections are specified with listen(),
00750     and then the connections are accepted with accept.
00751     The listen() call applies only to sockets of type SOCK_STREAM
00752     The backlog parameter defines the maximum length the queue of
00753     pending connections may grow to. 
00754  
00755     \param[in] sd               socket descriptor (handle)
00756     \param[in] backlog          specifies the listen queue depth. 
00757                                 
00758  
00759     \return                    On success, zero is returned. On error, a negative error code is returned.
00760  
00761     \sa                         sl_Socket  sl_Accept  sl_Bind
00762     \note                       belongs to \ref server_side
00763     \warning
00764 */
00765 #if _SL_INCLUDE_FUNC(sl_Listen)
00766 _i16 sl_Listen(_i16 sd, _i16 backlog);
00767 #endif
00768 
00769 /*!
00770     \brief Initiate a connection on a socket 
00771    
00772     Function connects the socket referred to by the socket 
00773     descriptor sd, to the address specified by addr. The addrlen 
00774     argument specifies the size of addr. The format of the 
00775     address in addr is determined by the address space of the 
00776     socket. If it is of type SOCK_DGRAM, this call specifies the 
00777     peer with which the socket is to be associated; this address 
00778     is that to which datagrams are to be sent, and the only 
00779     address from which datagrams are to be received.  If the 
00780     socket is of type SOCK_STREAM, this call attempts to make a 
00781     connection to another socket. The other socket is specified 
00782     by address, which is an address in the communications space 
00783     of the socket. 
00784    
00785    
00786     \param[in] sd               socket descriptor (handle)
00787     \param[in] addr             specifies the destination addr\n
00788                                 sockaddr:\n - code for the
00789                                 address format. On this version
00790                                 only AF_INET is supported.\n -
00791                                 socket address, the length
00792                                 depends on the code format
00793    
00794     \param[in] addrlen          contains the size of the structure pointed 
00795                                 to by addr
00796  
00797     \return                     On success, a socket handle.
00798                                 On a non-blocking connect a possible negative value is SL_EALREADY.
00799                                 On failure, negative value.
00800                                 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00801                                   In this case try again later or increase MAX_CONCURRENT_ACTIONS
00802  
00803     \sa                         sl_Socket
00804     \note                       belongs to \ref client_side
00805     \warning
00806 */
00807 #if _SL_INCLUDE_FUNC(sl_Connect)
00808 _i16 sl_Connect(_i16 sd, const SlSockAddr_t *addr, _i16 addrlen);
00809 #endif
00810 
00811 /*!
00812     \brief Monitor socket activity
00813    
00814     Select allow a program to monitor multiple file descriptors,
00815     waiting until one or more of the file descriptors become 
00816     "ready" for some class of I/O operation 
00817    
00818    
00819     \param[in]  nfds        the highest-numbered file descriptor in any of the
00820                             three sets, plus 1.
00821     \param[out] readsds     socket descriptors list for read monitoring and accept monitoring
00822     \param[out] writesds    socket descriptors list for connect monitoring only, write monitoring is not supported
00823     \param[out] exceptsds   socket descriptors list for exception monitoring, not supported.
00824     \param[in]  timeout     is an upper bound on the amount of time elapsed
00825                             before select() returns. Null or above 0xffff seconds means 
00826                             infinity timeout. The minimum timeout is 10 milliseconds,
00827                             less than 10 milliseconds will be set automatically to 10 milliseconds. 
00828                             Max microseconds supported is 0xfffc00.
00829    
00830     \return                    On success, select()  returns the number of
00831                             file descriptors contained in the three returned
00832                             descriptor sets (that is, the total number of bits that
00833                             are set in readfds, writefds, exceptfds) which may be
00834                             zero if the timeout expires before anything interesting
00835                             happens. On error, a negative value is returned.
00836                             readsds - return the sockets on which Read request will
00837                             return without delay with valid data.
00838                             writesds - return the sockets on which Write request 
00839                             will return without delay.
00840                             exceptsds - return the sockets closed recently. 
00841                             SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00842                                In this case try again later or increase MAX_CONCURRENT_ACTIONS
00843  
00844     \sa     sl_Socket
00845     \note   If the timeout value set to less than 5ms it will automatically set 
00846             to 5ms to prevent overload of the system
00847             belongs to \ref basic_api
00848             
00849             Only one sl_Select can be handled at a time.
00850             Calling this API while the same command is called from another thread, may result
00851                 in one of the two scenarios:
00852             1. The command will wait (internal) until the previous command finish, and then be executed.
00853             2. There are not enough resources and SL_POOL_IS_EMPTY error will return. 
00854             In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00855             again later to issue the command.
00856    
00857     \warning
00858 */
00859 #if _SL_INCLUDE_FUNC(sl_Select)
00860 _i16 sl_Select(_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, struct SlTimeval_t *timeout);
00861 
00862 
00863 /*!
00864     \brief Select's SlFdSet_t SET function
00865    
00866     Sets current socket descriptor on SlFdSet_t container
00867 */
00868 void SL_FD_SET(_i16 fd, SlFdSet_t *fdset);
00869 
00870 /*!
00871     \brief Select's SlFdSet_t CLR function
00872    
00873     Clears current socket descriptor on SlFdSet_t container
00874 */
00875 void SL_FD_CLR(_i16 fd, SlFdSet_t *fdset);
00876 
00877 
00878 /*!
00879     \brief Select's SlFdSet_t ISSET function
00880    
00881     Checks if current socket descriptor is set (TRUE/FALSE)
00882 
00883     \return            Returns TRUE if set, FALSE if unset
00884 
00885 */
00886 _i16  SL_FD_ISSET(_i16 fd, SlFdSet_t *fdset);
00887 
00888 /*!
00889     \brief Select's SlFdSet_t ZERO function
00890    
00891     Clears all socket descriptors from SlFdSet_t
00892 */
00893 void SL_FD_ZERO(SlFdSet_t *fdset);
00894 
00895 
00896 
00897 #endif
00898 
00899 /*!
00900     \brief set socket options
00901  
00902     This function manipulate the options associated with a socket.
00903     Options may exist at multiple protocol levels; they are always
00904     present at the uppermost socket level.
00905  
00906     When manipulating socket options the level at which the option resides
00907     and the name of the option must be specified.  To manipulate options at
00908     the socket level, level is specified as SOL_SOCKET.  To manipulate
00909     options at any other level the protocol number of the appropriate proto-
00910     col controlling the option is supplied.  For example, to indicate that an
00911     option is to be interpreted by the TCP protocol, level should be set to
00912     the protocol number of TCP; 
00913  
00914     The parameters optval and optlen are used to access optval - 
00915     ues for setsockopt().  For getsockopt() they identify a 
00916     buffer in which the value for the requested option(s) are to 
00917     be returned.  For getsockopt(), optlen is a value-result 
00918     parameter, initially containing the size of the buffer 
00919     pointed to by option_value, and modified on return to 
00920     indicate the actual size of the value returned.  If no option 
00921     value is to be supplied or returned, option_value may be 
00922     NULL.
00923    
00924     \param[in] sd               socket handle
00925     \param[in] level            defines the protocol level for this option
00926                                 - <b>SL_SOL_SOCKET</b>   Socket level configurations (L4, transport layer)
00927                                 - <b>SL_IPPROTO_IP</b>   IP level configurations (L3, network layer)
00928                                 - <b>SL_SOL_PHY_OPT</b>  Link level configurations (L2, link layer)
00929     \param[in] optname          defines the option name to interrogate
00930                                 - <b>SL_SOL_SOCKET</b>
00931                                   - <b>SL_SO_KEEPALIVE</b>  \n
00932                                                  Enable/Disable periodic keep alive.
00933                                                  Keeps TCP connections active by enabling the periodic transmission of messages \n
00934                                                  Timeout is 5 minutes.\n
00935                                                  Default: Enabled \n
00936                                                  This options takes SlSockKeepalive_t struct as parameter
00937                                   - <b>SL_SO_RCVTIMEO</b>  \n
00938                                                  Sets the timeout value that specifies the maximum amount of time an input function waits until it completes. \n
00939                                                  Default: No timeout \n
00940                                                  This options takes SlTimeval_t struct as parameter
00941                                   - <b>SL_SO_RCVBUF</b>  \n
00942                                                  Sets tcp max recv window size. \n
00943                                                  This options takes SlSockWinsize_t struct as parameter
00944                                   - <b>SL_SO_NONBLOCKING</b> \n
00945                                                  Sets socket to non-blocking operation Impacts: connect, accept, send, sendto, recv and recvfrom. \n
00946                                                  Default: Blocking.
00947                                                  This options takes SlSockNonblocking_t struct as parameter
00948                                   - <b>SL_SO_SECMETHOD</b> \n
00949                                                  Sets method to tcp secured socket (SL_SEC_SOCKET) \n
00950                                                  Default: SL_SO_SEC_METHOD_SSLv3_TLSV1_2 \n
00951                                                  This options takes SlSockSecureMethod struct as parameter
00952                                   - <b>SL_SO_SEC_MASK</b> \n
00953                                                  Sets specific cipher to tcp secured socket (SL_SEC_SOCKET) \n
00954                                                  Default: "Best" cipher suitable to method \n
00955                                                  This options takes SlSockSecureMask struct as parameter
00956                                   - <b>SL_SO_SECURE_FILES_CA_FILE_NAME</b> \n
00957                                                  Map secured socket to CA file by name \n
00958                                                  This options takes <b>_u8</b> buffer as parameter 
00959                                   - <b>SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME</b> \n
00960                                                  Map secured socket to private key by name \n
00961                                                  This options takes <b>_u8</b> buffer as parameter 
00962                                   - <b>SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME</b> \n
00963                                                  Map secured socket to certificate file by name \n
00964                                                  This options takes <b>_u8</b> buffer as parameter 
00965                                   - <b>SL_SO_SECURE_FILES_DH_KEY_FILE_NAME</b> \n
00966                                                  Map secured socket to Diffie Hellman file by name \n
00967                                                  This options takes <b>_u8</b> buffer as parameter 
00968                                   - <b>SL_SO_CHANGE_CHANNEL</b> \n
00969                                                  Sets channel in transceiver mode.
00970                                                  This options takes <b>_u32</b> as channel number parameter
00971                                 - <b>SL_IPPROTO_IP</b> 
00972                                   - <b>SL_IP_MULTICAST_TTL</b> \n
00973                                                  Set the time-to-live value of outgoing multicast packets for this socket. \n
00974                                                  This options takes <b>_u8</b> as parameter 
00975                                   - <b>SL_IP_ADD_MEMBERSHIP</b> \n
00976                                                  UDP socket, Join a multicast group. \n
00977                                                  This options takes SlSockIpMreq struct as parameter
00978                                   - <b>SL_IP_DROP_MEMBERSHIP</b> \n
00979                                                  UDP socket, Leave a multicast group \n
00980                                                  This options takes SlSockIpMreq struct as parameter
00981                                   - <b>SL_IP_RAW_RX_NO_HEADER</b> \n                 
00982                                                  Raw socket remove IP header from received data. \n
00983                                                  Default: data includes ip header \n
00984                                                  This options takes <b>_u32</b> as parameter
00985                                   - <b>SL_IP_HDRINCL</b> \n
00986                                                  RAW socket only, the IPv4 layer generates an IP header when sending a packet unless \n
00987                                                  the IP_HDRINCL socket option is enabled on the socket.    \n
00988                                                  When it is enabled, the packet must contain an IP header. \n
00989                                                  Default: disabled, IPv4 header generated by Network Stack \n
00990                                                  This options takes <b>_u32</b> as parameter
00991                                   - <b>SL_IP_RAW_IPV6_HDRINCL</b> (inactive) \n
00992                                                  RAW socket only, the IPv6 layer generates an IP header when sending a packet unless \n
00993                                                  the IP_HDRINCL socket option is enabled on the socket. When it is enabled, the packet must contain an IP header \n
00994                                                  Default: disabled, IPv4 header generated by Network Stack \n
00995                                                  This options takes <b>_u32</b> as parameter
00996                                 - <b>SL_SOL_PHY_OPT</b>
00997                                   - <b>SL_SO_PHY_RATE</b> \n
00998                                                  RAW socket, set WLAN PHY transmit rate \n
00999                                                  The values are based on RateIndex_e    \n
01000                                                  This options takes <b>_u32</b> as parameter
01001                                   - <b>SL_SO_PHY_TX_POWER</b> \n
01002                                                  RAW socket, set WLAN PHY TX power \n
01003                                                  Valid rage is 1-15 \n
01004                                                  This options takes <b>_u32</b> as parameter
01005                                   - <b>SL_SO_PHY_NUM_FRAMES_TO_TX</b> \n
01006                                                  RAW socket, set number of frames to transmit in transceiver mode.
01007                                                  Default: 1 packet
01008                                                  This options takes <b>_u32</b> as parameter
01009                                   - <b>SL_SO_PHY_PREAMBLE</b> \n
01010                                                  RAW socket, set WLAN PHY preamble for Long/Short\n
01011                                                  This options takes <b>_u32</b> as parameter
01012   
01013     \param[in] optval           specifies a value for the option
01014     \param[in] optlen           specifies the length of the 
01015         option value
01016  
01017     \return                     On success, zero is returned. 
01018                                 On error, a negative value is returned. 
01019     \sa     sl_getsockopt
01020     \note   belongs to \ref basic_api  
01021     \warning
01022     \par   Examples:
01023     \par   
01024     <b> SL_SO_KEEPALIVE: </b>(disable Keepalive)
01025     \code       
01026            SlSockKeepalive_t enableOption;
01027            enableOption.KeepaliveEnabled = 0;
01028            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_KEEPALIVE, (_u8 *)&enableOption,sizeof(enableOption));  
01029     \endcode
01030     \par   
01031     <b> SL_SO_RCVTIMEO: </b>
01032     \code
01033            struct SlTimeval_t timeVal;
01034            timeVal.tv_sec =  1;             // Seconds
01035            timeVal.tv_usec = 0;             // Microseconds. 10000 microseconds resolution
01036            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal));    // Enable receive timeout 
01037     \endcode
01038     \par   
01039     <b>    SL_SO_RCVBUF: </b>
01040     \code
01041            SlSockWinsize_t size;
01042            size.Winsize = 3000;  // bytes
01043            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVBUF, (_u8 *)&size, sizeof(size));
01044     \endcode
01045     \par   
01046     <b>    SL_SO_NONBLOCKING: </b>
01047     \code
01048            SlSockNonblocking_t enableOption;
01049            enableOption.NonblockingEnabled = 1;
01050            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_NONBLOCKING, (_u8 *)&enableOption,sizeof(enableOption)); // Enable/disable nonblocking mode
01051     \endcode
01052     \par   
01053     <b>    SL_SO_SECMETHOD:</b>
01054     \code
01055            SlSockSecureMethod method;
01056            method.secureMethod = SL_SO_SEC_METHOD_SSLV3;                                 // security method we want to use
01057            SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
01058            sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECMETHOD, (_u8 *)&method, sizeof(method));
01059     \endcode
01060     \par   
01061     <b>   SL_SO_SECURE_MASK:</b>
01062     \code 
01063            SlSockSecureMask cipher;
01064            cipher.secureMask = SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA;                   // cipher type
01065            SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
01066            sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SEC_MASK,(_u8 *)&cipher, sizeof(cipher));
01067     \endcode
01068     \par   
01069     <b>   SL_SO_SECURE_FILES_CA_FILE_NAME:</b>
01070     \code           
01071            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CA_FILE_NAME,"exuifaxCaCert.der",strlen("exuifaxCaCert.der"));
01072      \endcode
01073 
01074    \par   
01075     <b>   SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME:</b>
01076      \code           
01077            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME,"myPrivateKey.der",strlen("myPrivateKey.der"));
01078      \endcode
01079 
01080    \par   
01081     <b>   SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME:</b>
01082      \code
01083            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME,"myCertificate.der",strlen("myCertificate.der"));
01084      \endcode
01085 
01086    \par   
01087     <b>   SL_SO_SECURE_FILES_DH_KEY_FILE_NAME:</b>
01088      \code
01089            sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_DH_KEY_FILE_NAME,"myDHinServerMode.der",strlen("myDHinServerMode.der"));
01090      \endcode
01091 
01092    \par   
01093     <b>   SL_IP_MULTICAST_TTL:</b>
01094      \code
01095            _u8 ttl = 20;
01096            sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_MULTICAST_TTL, &ttl, sizeof(ttl));
01097      \endcode
01098 
01099    \par   
01100     <b>   SL_IP_ADD_MEMBERSHIP:</b>
01101      \code
01102            SlSockIpMreq mreq;
01103            sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
01104     \endcode
01105 
01106    \par   
01107     <b>   SL_IP_DROP_MEMBERSHIP:</b>
01108     \code
01109            SlSockIpMreq mreq;
01110            sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
01111     \endcode
01112 
01113    \par   
01114     <b>   SL_SO_CHANGE_CHANNEL:</b>
01115     \code
01116           _u32 newChannel = 6; // range is 1-13
01117           sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_CHANGE_CHANNEL, &newChannel, sizeof(newChannel));  
01118     \endcode
01119 
01120     \par   
01121     <b>   SL_IP_RAW_RX_NO_HEADER:</b>
01122     \code
01123           _u32 header = 1;  // remove ip header
01124           sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_RX_NO_HEADER, &header, sizeof(header));
01125     \endcode
01126 
01127    \par   
01128     <b>   SL_IP_HDRINCL:</b>
01129     \code
01130          _u32 header = 1;
01131          sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_HDRINCL, &header, sizeof(header));
01132     \endcode
01133    \par   
01134     <b>   SL_IP_RAW_IPV6_HDRINCL:</b>
01135     \code
01136           _u32 header = 1;
01137           sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_IPV6_HDRINCL, &header, sizeof(header));
01138     \endcode
01139 
01140    \par   
01141     <b>   SL_SO_PHY_RATE:</b>
01142     \code
01143           _u32 rate = 6; // see wlan.h RateIndex_e for values
01144           sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_RATE, &rate, sizeof(rate));  
01145     \endcode
01146 
01147    \par   
01148     <b>   SL_SO_PHY_TX_POWER:</b>
01149     \code
01150           _u32 txpower = 1; // valid range is 1-15
01151           sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_TX_POWER, &txpower, sizeof(txpower));
01152     \endcode
01153 
01154    \par   
01155     <b>   SL_SO_PHY_NUM_FRAMES_TO_TX:</b>
01156     \code
01157           _u32 numframes = 1;
01158           sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_NUM_FRAMES_TO_TX, &numframes, sizeof(numframes));
01159     \endcode
01160 
01161    \par   
01162     <b>   SL_SO_PHY_PREAMBLE:</b>
01163     \code
01164           _u32 preamble = 1;
01165           sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_PREAMBLE, &preamble, sizeof(preamble));
01166     \endcode
01167 
01168 */
01169 #if _SL_INCLUDE_FUNC(sl_SetSockOpt)
01170 _i16 sl_SetSockOpt(_i16 sd, _i16 level, _i16 optname, const void *optval, SlSocklen_t optlen);
01171 #endif
01172 
01173 /*!
01174     \brief Get socket options
01175     
01176     This function manipulate the options associated with a socket.
01177     Options may exist at multiple protocol levels; they are always
01178     present at the uppermost socket level.
01179     
01180     When manipulating socket options the level at which the option resides
01181     and the name of the option must be specified.  To manipulate options at
01182     the socket level, level is specified as SOL_SOCKET.  To manipulate
01183     options at any other level the protocol number of the appropriate proto-
01184     col controlling the option is supplied.  For example, to indicate that an
01185     option is to be interpreted by the TCP protocol, level should be set to
01186     the protocol number of TCP; 
01187     
01188     The parameters optval and optlen are used to access optval - 
01189     ues for setsockopt().  For getsockopt() they identify a 
01190     buffer in which the value for the requested option(s) are to 
01191     be returned.  For getsockopt(), optlen is a value-result 
01192     parameter, initially containing the size of the buffer 
01193     pointed to by option_value, and modified on return to 
01194     indicate the actual size of the value returned.  If no option 
01195     value is to be supplied or returned, option_value may be 
01196     NULL. 
01197     
01198     
01199     \param[in]  sd              socket handle
01200     \param[in]  level           defines the protocol level for this option
01201     \param[in]  optname         defines the option name to interrogate
01202     \param[out] optval          specifies a value for the option
01203     \param[out] optlen          specifies the length of the 
01204                                 option value
01205     
01206     \return                        On success, zero is returned. 
01207                                 On error, a negative value is returned.
01208     \sa     sl_SetSockOpt
01209     \note   See sl_SetSockOpt
01210             belongs to \ref ext_api
01211     \warning
01212 */
01213 #if _SL_INCLUDE_FUNC(sl_GetSockOpt)
01214 _i16 sl_GetSockOpt(_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t *optlen);
01215 #endif
01216 
01217 /*!
01218     \brief read data from TCP socket
01219      
01220     function receives a message from a connection-mode socket
01221      
01222     \param[in]  sd              socket handle
01223     \param[out] buf             Points to the buffer where the 
01224                                 message should be stored.
01225     \param[in]  Len             Specifies the length in bytes of 
01226                                 the buffer pointed to by the buffer argument. 
01227                                 Range: 1-16000 bytes
01228     \param[in]  flags           Specifies the type of message 
01229                                 reception. On this version, this parameter is not
01230                                 supported.
01231     
01232     \return                     return the number of bytes received, 
01233                                 or a negative value if an error occurred.
01234                                 using a non-blocking recv a possible negative value is SL_EAGAIN.
01235                                 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
01236                                  In this case try again later or increase MAX_CONCURRENT_ACTIONS
01237     
01238     \sa     sl_RecvFrom
01239     \note                       belongs to \ref recv_api
01240     \warning
01241     \par        Examples:
01242     \code       An example of receiving data using TCP socket:
01243     
01244                 SlSockAddrIn_t  Addr;
01245                 SlSockAddrIn_t  LocalAddr;
01246                 _i16 AddrSize = sizeof(SlSockAddrIn_t);
01247                 _i16 SockID, newSockID;
01248                 _i16 Status;
01249                 _i8 Buf[RECV_BUF_LEN];
01250 
01251                 LocalAddr.sin_family = SL_AF_INET;
01252                 LocalAddr.sin_port = sl_Htons(5001);
01253                 LocalAddr.sin_addr.s_addr = 0;
01254 
01255                 Addr.sin_family = SL_AF_INET;
01256                 Addr.sin_port = sl_Htons(5001);
01257                 Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
01258 
01259                 SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
01260                 Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
01261                 Status = sl_Listen(SockID, 0);
01262                 newSockID = sl_Accept(SockID, (SlSockAddr_t*)&Addr, (SlSocklen_t*) &AddrSize);
01263                 Status = sl_Recv(newSockID, Buf, 1460, 0);
01264     \endcode
01265     \code      Example code for Rx transceiver mode using a raw socket
01266                _i8 buffer[1536];
01267                _i16 sd;
01268                _u16 size;
01269                SlTransceiverRxOverHead_t *transHeader;
01270                sd = sl_Socket(SL_AF_RF,SL_SOCK_RAW,11); // channel 11
01271                while(1)
01272                {
01273                   size = sl_Recv(sd,buffer,1536,0);
01274                   transHeader = (SlTransceiverRxOverHead_t *)buffer;
01275                   printf("RSSI is %d frame type is 0x%x size %d\n",transHeader->rssi,buffer[sizeof(SlTransceiverRxOverHead_t)],size);
01276                }      
01277     \endcode
01278 */
01279 #if _SL_INCLUDE_FUNC(sl_Recv)
01280 _i16 sl_Recv(_i16 sd, void *buf, _i16 Len, _i16 flags);
01281 #endif
01282 
01283 /*!
01284     \brief read data from socket
01285     
01286     function receives a message from a connection-mode or
01287     connectionless-mode socket
01288     
01289     \param[in]  sd              socket handle 
01290     \param[out] buf             Points to the buffer where the message should be stored.
01291     \param[in]  Len             Specifies the length in bytes of the buffer pointed to by the buffer argument.
01292                                 Range: 1-16000 bytes
01293     \param[in]  flags           Specifies the type of message
01294                                 reception. On this version, this parameter is not
01295                                 supported.
01296     \param[in]  from            pointer to an address structure 
01297                                 indicating the source
01298                                 address.\n sockaddr:\n - code
01299                                 for the address format. On this
01300                                 version only AF_INET is
01301                                 supported.\n - socket address,
01302                                 the length depends on the code
01303                                 format
01304     \param[in]  fromlen         source address structure
01305                                 size. This parameter MUST be set to the size of the structure pointed to by addr.
01306     
01307     
01308     \return                     return the number of bytes received, 
01309                                 or a negative value if an error occurred.
01310                                 using a non-blocking recv a possible negative value is SL_EAGAIN.
01311                                 SL_RET_CODE_INVALID_INPUT (-2) will be returned if fromlen has incorrect length. 
01312                                 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
01313                                  In this case try again later or increase MAX_CONCURRENT_ACTIONS
01314     
01315     \sa     sl_Recv
01316     \note                       belongs to \ref recv_api
01317     \warning
01318     \par        Example:
01319     \code       An example of receiving data:
01320     
01321                 SlSockAddrIn_t  Addr;
01322                 SlSockAddrIn_t  LocalAddr;
01323                 _i16 AddrSize = sizeof(SlSockAddrIn_t);
01324                 _i16 SockID;
01325                 _i16 Status;
01326                 _i8 Buf[RECV_BUF_LEN];
01327 
01328                 LocalAddr.sin_family = SL_AF_INET;
01329                 LocalAddr.sin_port = sl_Htons(5001);
01330                 LocalAddr.sin_addr.s_addr = 0;
01331 
01332                 SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
01333                 Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
01334                 Status = sl_RecvFrom(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, (SlSocklen_t*)&AddrSize);
01335 
01336     \endcode
01337 */
01338 #if _SL_INCLUDE_FUNC(sl_RecvFrom)
01339 _i16 sl_RecvFrom(_i16 sd, void *buf, _i16 Len, _i16 flags, SlSockAddr_t *from, SlSocklen_t *fromlen);
01340 #endif
01341 
01342 /*!
01343     \brief write data to TCP socket
01344     
01345     This function is used to transmit a message to another socket.
01346     Returns immediately after sending data to device.
01347     In case of TCP failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
01348     be received.
01349     In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the 
01350     frame data buffer for WLAN FCS 
01351      
01352     \param[in] sd               socket handle
01353     \param[in] buf              Points to a buffer containing 
01354                                 the message to be sent
01355     \param[in] Len              message size in bytes. Range: 1-1460 bytes
01356     \param[in] flags            Specifies the type of message 
01357                                 transmission. On this version, this parameter is not
01358                                 supported for TCP.
01359                                 For transceiver mode, the SL_RAW_RF_TX_PARAMS macro can be used to determine
01360                                 transmission parameters (channel,rate,tx_power,preamble)
01361     
01362     
01363     \return                     Return the number of bytes transmitted, 
01364                                 or -1 if an error occurred
01365     
01366     \sa     sl_SendTo 
01367     \note                       belongs to \ref send_api
01368     \warning   
01369     \par        Example:
01370     \code       An example of sending data:
01371     
01372                 SlSockAddrIn_t  Addr;
01373                 _i16 AddrSize = sizeof(SlSockAddrIn_t);
01374                 _i16 SockID;
01375                 _i16 Status;
01376                 _i8 Buf[SEND_BUF_LEN];
01377 
01378                 Addr.sin_family = SL_AF_INET;
01379                 Addr.sin_port = sl_Htons(5001);
01380                 Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
01381 
01382                 SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
01383                 Status = sl_Connect(SockID, (SlSockAddr_t *)&Addr, AddrSize);
01384                 Status = sl_Send(SockID, Buf, 1460, 0 );
01385  
01386     \endcode
01387  */ 
01388 #if _SL_INCLUDE_FUNC(sl_Send )
01389 _i16 sl_Send(_i16 sd, const void *buf, _i16 Len, _i16 flags);
01390 #endif
01391 
01392 /*!
01393     \brief write data to socket
01394     
01395     This function is used to transmit a message to another socket
01396     (connection less socket SOCK_DGRAM,  SOCK_RAW).
01397     Returns immediately after sending data to device.
01398     In case of transmission failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
01399     be received.
01400     
01401     \param[in] sd               socket handle
01402     \param[in] buf              Points to a buffer containing 
01403                                 the message to be sent
01404     \param[in] Len              message size in bytes. Range: 1-1460 bytes
01405     \param[in] flags            Specifies the type of message 
01406                                 transmission. On this version, this parameter is not
01407                                 supported 
01408     \param[in] to               pointer to an address structure 
01409                                 indicating the destination
01410                                 address.\n sockaddr:\n - code
01411                                 for the address format. On this
01412                                 version only AF_INET is
01413                                 supported.\n - socket address,
01414                                 the length depends on the code
01415                                 format
01416     \param[in] tolen            destination address structure size 
01417     
01418     \return                     Return the number of transmitted bytes, 
01419                                 or -1 if an error occurred
01420     
01421     \sa     sl_Send
01422     \note                       belongs to \ref send_api
01423     \warning
01424     \par        Example:
01425     \code       An example of sending data:
01426     
01427                 SlSockAddrIn_t  Addr;
01428                 _i16 AddrSize = sizeof(SlSockAddrIn_t);
01429                 _i16 SockID;
01430                 _i16 Status;
01431                 _i8 Buf[SEND_BUF_LEN];
01432 
01433                 Addr.sin_family = SL_AF_INET;
01434                 Addr.sin_port = sl_Htons(5001);
01435                 Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
01436 
01437                 SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
01438                 Status = sl_SendTo(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, AddrSize);
01439 
01440     \endcode
01441 */
01442 #if _SL_INCLUDE_FUNC(sl_SendTo)
01443 _i16 sl_SendTo(_i16 sd, const void *buf, _i16 Len, _i16 flags, const SlSockAddr_t *to, SlSocklen_t tolen);
01444 #endif
01445 
01446 /*!
01447     \brief Reorder the bytes of a 32-bit unsigned value
01448     
01449     This function is used to Reorder the bytes of a 32-bit unsigned value from processor order to network order.
01450      
01451     \param[in] var              variable to reorder 
01452     
01453     \return                     Return the reorder variable, 
01454     
01455     \sa     sl_SendTo  sl_Bind  sl_Connect  sl_RecvFrom  sl_Accept
01456     \note                       belongs to \ref send_api
01457     \warning   
01458 */
01459 #if _SL_INCLUDE_FUNC(sl_Htonl )
01460 _u32 sl_Htonl( _u32 val );
01461 
01462 #define sl_Ntohl sl_Htonl  /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
01463 #endif
01464 
01465 /*!
01466     \brief Reorder the bytes of a 16-bit unsigned value
01467     
01468     This function is used to Reorder the bytes of a 16-bit unsigned value from processor order to network order.
01469      
01470     \param[in] var              variable to reorder 
01471     
01472     \return                     Return the reorder variable, 
01473     
01474     \sa     sl_SendTo  sl_Bind    sl_Connect  sl_RecvFrom  sl_Accept
01475     \note                       belongs to \ref send_api
01476     \warning   
01477 */
01478 #if _SL_INCLUDE_FUNC(sl_Htons )
01479 _u16 sl_Htons( _u16 val );
01480 
01481 #define sl_Ntohs sl_Htons   /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
01482 #endif
01483 
01484 /*!
01485 
01486  Close the Doxygen group.
01487  @}
01488 
01489  */
01490 
01491 
01492 #ifdef  __cplusplus
01493 }
01494 #endif /* __cplusplus */
01495 
01496 #endif /* __SOCKET_H__ */
01497 
01498 
01499