David Fletcher / Mbed 2 deprecated cc3100_Test_websock_Camera_CM4F

Dependencies:   mbed

Committer:
dflet
Date:
Wed Jun 24 09:54:16 2015 +0000
Revision:
0:50cedd586816
Child:
19:3dd3e7f30f8b
First commit work in progress

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:50cedd586816 1 /*
dflet 0:50cedd586816 2 * socket.h - CC31xx/CC32xx Host Driver Implementation
dflet 0:50cedd586816 3 *
dflet 0:50cedd586816 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:50cedd586816 5 *
dflet 0:50cedd586816 6 *
dflet 0:50cedd586816 7 * Redistribution and use in source and binary forms, with or without
dflet 0:50cedd586816 8 * modification, are permitted provided that the following conditions
dflet 0:50cedd586816 9 * are met:
dflet 0:50cedd586816 10 *
dflet 0:50cedd586816 11 * Redistributions of source code must retain the above copyright
dflet 0:50cedd586816 12 * notice, this list of conditions and the following disclaimer.
dflet 0:50cedd586816 13 *
dflet 0:50cedd586816 14 * Redistributions in binary form must reproduce the above copyright
dflet 0:50cedd586816 15 * notice, this list of conditions and the following disclaimer in the
dflet 0:50cedd586816 16 * documentation and/or other materials provided with the
dflet 0:50cedd586816 17 * distribution.
dflet 0:50cedd586816 18 *
dflet 0:50cedd586816 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:50cedd586816 20 * its contributors may be used to endorse or promote products derived
dflet 0:50cedd586816 21 * from this software without specific prior written permission.
dflet 0:50cedd586816 22 *
dflet 0:50cedd586816 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:50cedd586816 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:50cedd586816 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:50cedd586816 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:50cedd586816 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:50cedd586816 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:50cedd586816 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:50cedd586816 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:50cedd586816 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:50cedd586816 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:50cedd586816 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:50cedd586816 34 *
dflet 0:50cedd586816 35 */
dflet 0:50cedd586816 36
dflet 0:50cedd586816 37 /*****************************************************************************/
dflet 0:50cedd586816 38 /* Include files */
dflet 0:50cedd586816 39 /*****************************************************************************/
dflet 0:50cedd586816 40 #include "cc3100_simplelink.h"
dflet 0:50cedd586816 41
dflet 0:50cedd586816 42 #ifndef SL_SOCKET_H_
dflet 0:50cedd586816 43 #define SL_SOCKET_H_
dflet 0:50cedd586816 44
dflet 0:50cedd586816 45 #include "cc3100_protocol.h"
dflet 0:50cedd586816 46
dflet 0:50cedd586816 47 namespace mbed_cc3100 {
dflet 0:50cedd586816 48
dflet 0:50cedd586816 49 //#include "cc3100_driver.h"
dflet 0:50cedd586816 50
dflet 0:50cedd586816 51 /*!
dflet 0:50cedd586816 52
dflet 0:50cedd586816 53 \addtogroup socket
dflet 0:50cedd586816 54 @{
dflet 0:50cedd586816 55
dflet 0:50cedd586816 56 */
dflet 0:50cedd586816 57
dflet 0:50cedd586816 58 /*****************************************************************************/
dflet 0:50cedd586816 59 /* Macro declarations */
dflet 0:50cedd586816 60 /*****************************************************************************/
dflet 0:50cedd586816 61
dflet 0:50cedd586816 62 const uint8_t SL_FD_SETSIZE = SL_MAX_SOCKETS; /* Number of sockets to select on - same is max sockets! */
dflet 0:50cedd586816 63 const uint8_t BSD_SOCKET_ID_MASK = (0x0F); /* Index using the LBS 4 bits for socket id 0-7 */
dflet 0:50cedd586816 64 /* Define some BSD protocol constants. */
dflet 0:50cedd586816 65 const uint8_t SL_SOCK_STREAM = (1); /* TCP Socket */
dflet 0:50cedd586816 66 const uint8_t SL_SOCK_DGRAM = (2); /* UDP Socket */
dflet 0:50cedd586816 67 const uint8_t SL_SOCK_RAW = (3); /* Raw socket */
dflet 0:50cedd586816 68 const uint8_t SL_IPPROTO_TCP = (6); /* TCP Raw Socket */
dflet 0:50cedd586816 69 const uint8_t SL_IPPROTO_UDP = (17); /* UDP Raw Socket */
dflet 0:50cedd586816 70 const uint8_t SL_IPPROTO_RAW = (255); /* Raw Socket */
dflet 0:50cedd586816 71 const uint8_t SL_SEC_SOCKET = (100); /* Secured Socket Layer (SSL,TLS) */
dflet 0:50cedd586816 72
dflet 0:50cedd586816 73 /* Address families. */
dflet 0:50cedd586816 74 const uint8_t SL_AF_INET = (2); /* IPv4 socket (UDP, TCP, etc) */
dflet 0:50cedd586816 75 const uint8_t SL_AF_INET6 = (3); /* IPv6 socket (UDP, TCP, etc) */
dflet 0:50cedd586816 76 const uint8_t SL_AF_INET6_EUI_48 = (9);
dflet 0:50cedd586816 77 const uint8_t AF_INET = SL_AF_INET;
dflet 0:50cedd586816 78 const uint8_t AF_INET6 = SL_AF_INET6;
dflet 0:50cedd586816 79 const uint8_t SL_AF_RF = (6); /* data include RF parameter, All layer by user (Wifi could be disconnected) */
dflet 0:50cedd586816 80 const uint8_t SL_AF_PACKET = (17);
dflet 0:50cedd586816 81 /* Protocol families, same as address families. */
dflet 0:50cedd586816 82 const uint8_t SL_PF_INET = AF_INET;
dflet 0:50cedd586816 83 const uint8_t SL_PF_INET6 = AF_INET6;
dflet 0:50cedd586816 84 const uint8_t SL_INADDR_ANY = (0); /* bind any address */
dflet 0:50cedd586816 85
dflet 0:50cedd586816 86 /* error codes */
dflet 0:50cedd586816 87 const int8_t SL_SOC_ERROR = (-1); /* Failure. */
dflet 0:50cedd586816 88 const int8_t SL_SOC_OK = ( 0); /* Success. */
dflet 0:50cedd586816 89 const int8_t SL_INEXE = (-8); /* socket command in execution */
dflet 0:50cedd586816 90 const int8_t SL_EBADF = (-9); /* Bad file number */
dflet 0:50cedd586816 91 const int8_t SL_ENSOCK = (-10); /* The system limit on the total number of open socket, has been reached */
dflet 0:50cedd586816 92 const int8_t SL_EAGAIN = (-11); /* Try again */
dflet 0:50cedd586816 93 const int8_t SL_EWOULDBLOCK = SL_EAGAIN;
dflet 0:50cedd586816 94 const int8_t SL_ENOMEM = (-12); /* Out of memory */
dflet 0:50cedd586816 95 const int8_t SL_EACCES = (-13); /* Permission denied */
dflet 0:50cedd586816 96 const int8_t SL_EFAULT = (-14); /* Bad address */
dflet 0:50cedd586816 97 const int8_t SL_ECLOSE = (-15); /* close socket operation failed to transmit all queued packets */
dflet 0:50cedd586816 98 const int8_t SL_EALREADY_ENABLED = (-21); /* Transceiver - Transceiver already ON. there could be only one */
dflet 0:50cedd586816 99 const int8_t SL_EINVAL = (-22); /* Invalid argument */
dflet 0:50cedd586816 100 const int8_t SL_EAUTO_CONNECT_OR_CONNECTING = (-69); /* Transceiver - During connection, connected or auto mode started */
dflet 0:50cedd586816 101 const int8_t SL_CONNECTION_PENDING = (-72); /* Transceiver - Device is connected, disconnect first to open transceiver */
dflet 0:50cedd586816 102 const int8_t SL_EUNSUPPORTED_ROLE = (-86); /* Transceiver - Trying to start when WLAN role is AP or P2P GO */
dflet 0:50cedd586816 103 const int8_t SL_EDESTADDRREQ = (-89); /* Destination address required */
dflet 0:50cedd586816 104 const int8_t SL_EPROTOTYPE = (-91); /* Protocol wrong type for socket */
dflet 0:50cedd586816 105 const int8_t SL_ENOPROTOOPT = (-92); /* Protocol not available */
dflet 0:50cedd586816 106 const int8_t SL_EPROTONOSUPPORT = (-93); /* Protocol not supported */
dflet 0:50cedd586816 107 const int8_t SL_ESOCKTNOSUPPORT = (-94); /* Socket type not supported */
dflet 0:50cedd586816 108 const int8_t SL_EOPNOTSUPP = (-95); /* Operation not supported on transport endpoint */
dflet 0:50cedd586816 109 const int8_t SL_EAFNOSUPPORT = (-97); /* Address family not supported by protocol */
dflet 0:50cedd586816 110 const int8_t SL_EADDRINUSE = (-98); /* Address already in use */
dflet 0:50cedd586816 111 const int8_t SL_EADDRNOTAVAIL = (-99); /* Cannot assign requested address */
dflet 0:50cedd586816 112 const int8_t SL_ENETUNREACH = (-101); /* Network is unreachable */
dflet 0:50cedd586816 113 const int8_t SL_ENOBUFS = (-105); /* No buffer space available */
dflet 0:50cedd586816 114 const int8_t SL_EOBUFF = SL_ENOBUFS;
dflet 0:50cedd586816 115 const int8_t SL_EISCONN = (-106); /* Transport endpoint is already connected */
dflet 0:50cedd586816 116 const int8_t SL_ENOTCONN = (-107); /* Transport endpoint is not connected */
dflet 0:50cedd586816 117 const int8_t SL_ETIMEDOUT = (-110); /* Connection timed out */
dflet 0:50cedd586816 118 const int8_t SL_ECONNREFUSED = (-111); /* Connection refused */
dflet 0:50cedd586816 119 const int8_t SL_EALREADY = (-114); /* Non blocking connect in progress, try again */
dflet 0:50cedd586816 120
dflet 0:50cedd586816 121 const int16_t SL_ESEC_RSA_WRONG_TYPE_E = (-130); /* RSA wrong block type for RSA function */
dflet 0:50cedd586816 122 const int16_t SL_ESEC_RSA_BUFFER_E = (-131); /* RSA buffer error, output too small or */
dflet 0:50cedd586816 123 const int16_t SL_ESEC_BUFFER_E = (-132); /* output buffer too small or input too large */
dflet 0:50cedd586816 124 const int16_t SL_ESEC_ALGO_ID_E = (-133); /* setting algo id error */
dflet 0:50cedd586816 125 const int16_t SL_ESEC_PUBLIC_KEY_E = (-134); /* setting public key error */
dflet 0:50cedd586816 126 const int16_t SL_ESEC_DATE_E = (-135); /* setting date validity error */
dflet 0:50cedd586816 127 const int16_t SL_ESEC_SUBJECT_E = (-136); /* setting subject name error */
dflet 0:50cedd586816 128 const int16_t SL_ESEC_ISSUER_E = (-137); /* setting issuer name error */
dflet 0:50cedd586816 129 const int16_t SL_ESEC_CA_TRUE_E = (-138); /* setting CA basic constraint true error */
dflet 0:50cedd586816 130 const int16_t SL_ESEC_EXTENSIONS_E = (-139); /* setting extensions error */
dflet 0:50cedd586816 131 const int16_t SL_ESEC_ASN_PARSE_E = (-140); /* ASN parsing error, invalid input */
dflet 0:50cedd586816 132 const int16_t SL_ESEC_ASN_VERSION_E = (-141); /* ASN version error, invalid number */
dflet 0:50cedd586816 133 const int16_t SL_ESEC_ASN_GETINT_E = (-142); /* ASN get big int16_t error, invalid data */
dflet 0:50cedd586816 134 const int16_t SL_ESEC_ASN_RSA_KEY_E = (-143); /* ASN key init error, invalid input */
dflet 0:50cedd586816 135 const int16_t SL_ESEC_ASN_OBJECT_ID_E = (-144); /* ASN object id error, invalid id */
dflet 0:50cedd586816 136 const int16_t SL_ESEC_ASN_TAG_NULL_E = (-145); /* ASN tag error, not null */
dflet 0:50cedd586816 137 const int16_t SL_ESEC_ASN_EXPECT_0_E = (-146); /* ASN expect error, not zero */
dflet 0:50cedd586816 138 const int16_t SL_ESEC_ASN_BITSTR_E = (-147); /* ASN bit string error, wrong id */
dflet 0:50cedd586816 139 const int16_t SL_ESEC_ASN_UNKNOWN_OID_E = (-148); /* ASN oid error, unknown sum id */
dflet 0:50cedd586816 140 const int16_t SL_ESEC_ASN_DATE_SZ_E = (-149); /* ASN date error, bad size */
dflet 0:50cedd586816 141 const int16_t SL_ESEC_ASN_BEFORE_DATE_E = (-150); /* ASN date error, current date before */
dflet 0:50cedd586816 142 const int16_t SL_ESEC_ASN_AFTER_DATE_E = (-151); /* ASN date error, current date after */
dflet 0:50cedd586816 143 const int16_t SL_ESEC_ASN_SIG_OID_E = (-152); /* ASN signature error, mismatched oid */
dflet 0:50cedd586816 144 const int16_t SL_ESEC_ASN_TIME_E = (-153); /* ASN time error, unknown time type */
dflet 0:50cedd586816 145 const int16_t SL_ESEC_ASN_INPUT_E = (-154); /* ASN input error, not enough data */
dflet 0:50cedd586816 146 const int16_t SL_ESEC_ASN_SIG_CONFIRM_E = (-155); /* ASN sig error, confirm failure */
dflet 0:50cedd586816 147 const int16_t SL_ESEC_ASN_SIG_HASH_E = (-156); /* ASN sig error, unsupported hash type */
dflet 0:50cedd586816 148 const int16_t SL_ESEC_ASN_SIG_KEY_E = (-157); /* ASN sig error, unsupported key type */
dflet 0:50cedd586816 149 const int16_t SL_ESEC_ASN_DH_KEY_E = (-158); /* ASN key init error, invalid input */
dflet 0:50cedd586816 150 const int16_t SL_ESEC_ASN_NTRU_KEY_E = (-159); /* ASN ntru key decode error, invalid input */
dflet 0:50cedd586816 151 const int16_t SL_ESEC_ECC_BAD_ARG_E = (-170); /* ECC input argument of wrong type */
dflet 0:50cedd586816 152 const int16_t SL_ESEC_ASN_ECC_KEY_E = (-171); /* ASN ECC bad input */
dflet 0:50cedd586816 153 const int16_t SL_ESEC_ECC_CURVE_OID_E = (-172); /* Unsupported ECC OID curve type */
dflet 0:50cedd586816 154 const int16_t SL_ESEC_BAD_FUNC_ARG = (-173); /* Bad function argument provided */
dflet 0:50cedd586816 155 const int16_t SL_ESEC_NOT_COMPILED_IN = (-174); /* Feature not compiled in */
dflet 0:50cedd586816 156 const int16_t SL_ESEC_UNICODE_SIZE_E = (-175); /* Unicode password too big */
dflet 0:50cedd586816 157 const int16_t SL_ESEC_NO_PASSWORD = (-176); /* no password provided by user */
dflet 0:50cedd586816 158 const int16_t SL_ESEC_ALT_NAME_E = (-177); /* alt name size problem, too big */
dflet 0:50cedd586816 159 const int16_t SL_ESEC_AES_GCM_AUTH_E = (-180); /* AES-GCM Authentication check failure */
dflet 0:50cedd586816 160 const int16_t SL_ESEC_AES_CCM_AUTH_E = (-181); /* AES-CCM Authentication check failure */
dflet 0:50cedd586816 161 #define SL_SOCKET_ERROR_E (-208) /* Error state on socket */
dflet 0:50cedd586816 162
dflet 0:50cedd586816 163 #define SL_ESEC_MEMORY_ERROR (-203) /* out of memory */
dflet 0:50cedd586816 164 #define SL_ESEC_VERIFY_FINISHED_ERROR (-204) /* verify problem on finished */
dflet 0:50cedd586816 165 #define SL_ESEC_VERIFY_MAC_ERROR (-205) /* verify mac problem */
dflet 0:50cedd586816 166 #define SL_ESEC_UNKNOWN_HANDSHAKE_TYPE (-207) /* weird handshake type */
dflet 0:50cedd586816 167 #define SL_ESEC_SOCKET_ERROR_E (-208) /* error state on socket */
dflet 0:50cedd586816 168 #define SL_ESEC_SOCKET_NODATA (-209) /* expected data, not there */
dflet 0:50cedd586816 169 #define SL_ESEC_INCOMPLETE_DATA (-210) /* don't have enough data to complete task */
dflet 0:50cedd586816 170 #define SL_ESEC_UNKNOWN_RECORD_TYPE (-211) /* unknown type in record hdr */
dflet 0:50cedd586816 171 #define SL_ESEC_FATAL_ERROR (-213) /* recvd alert fatal error */
dflet 0:50cedd586816 172 #define SL_ESEC_ENCRYPT_ERROR (-214) /* error during encryption */
dflet 0:50cedd586816 173 #define SL_ESEC_NO_PEER_KEY (-216) /* need peer's key */
dflet 0:50cedd586816 174 #define SL_ESEC_NO_PRIVATE_KEY (-217) /* need the private key */
dflet 0:50cedd586816 175 #define SL_ESEC_RSA_PRIVATE_ERROR (-218) /* error during rsa priv op */
dflet 0:50cedd586816 176 #define SL_ESEC_NO_DH_PARAMS (-219) /* server missing DH params */
dflet 0:50cedd586816 177 #define SL_ESEC_BUILD_MSG_ERROR (-220) /* build message failure */
dflet 0:50cedd586816 178 #define SL_ESEC_BAD_HELLO (-221) /* client hello malformed */
dflet 0:50cedd586816 179 #define SL_ESEC_DOMAIN_NAME_MISMATCH (-222) /* peer subject name mismatch */
dflet 0:50cedd586816 180 #define SL_ESEC_WANT_READ (-223) /* want read, call again */
dflet 0:50cedd586816 181 #define SL_ESEC_NOT_READY_ERROR (-224) /* handshake layer not ready */
dflet 0:50cedd586816 182 #define SL_ESEC_PMS_VERSION_ERROR (-225) /* pre m secret version error */
dflet 0:50cedd586816 183 #define SL_ESEC_VERSION_ERROR (-226) /* record layer version error */
dflet 0:50cedd586816 184 #define SL_ESEC_WANT_WRITE (-227) /* want write, call again */
dflet 0:50cedd586816 185 #define SL_ESEC_BUFFER_ERROR (-228) /* malformed buffer input */
dflet 0:50cedd586816 186 #define SL_ESEC_VERIFY_CERT_ERROR (-229) /* verify cert error */
dflet 0:50cedd586816 187 #define SL_ESEC_VERIFY_SIGN_ERROR (-230) /* verify sign error */
dflet 0:50cedd586816 188
dflet 0:50cedd586816 189 #define SL_ESEC_LENGTH_ERROR (-241) /* record layer length error */
dflet 0:50cedd586816 190 #define SL_ESEC_PEER_KEY_ERROR (-242) /* can't decode peer key */
dflet 0:50cedd586816 191 #define SL_ESEC_ZERO_RETURN (-243) /* peer sent close notify */
dflet 0:50cedd586816 192 #define SL_ESEC_SIDE_ERROR (-244) /* wrong client/server type */
dflet 0:50cedd586816 193 #define SL_ESEC_NO_PEER_CERT (-245) /* peer didn't send key */
dflet 0:50cedd586816 194 #define SL_ESEC_ECC_CURVETYPE_ERROR (-250) /* Bad ECC Curve Type */
dflet 0:50cedd586816 195 #define SL_ESEC_ECC_CURVE_ERROR (-251) /* Bad ECC Curve */
dflet 0:50cedd586816 196 #define SL_ESEC_ECC_PEERKEY_ERROR (-252) /* Bad Peer ECC Key */
dflet 0:50cedd586816 197 #define SL_ESEC_ECC_MAKEKEY_ERROR (-253) /* Bad Make ECC Key */
dflet 0:50cedd586816 198 #define SL_ESEC_ECC_EXPORT_ERROR (-254) /* Bad ECC Export Key */
dflet 0:50cedd586816 199 #define SL_ESEC_ECC_SHARED_ERROR (-255) /* Bad ECC Shared Secret */
dflet 0:50cedd586816 200 #define SL_ESEC_NOT_CA_ERROR (-257) /* Not a CA cert error */
dflet 0:50cedd586816 201 #define SL_ESEC_BAD_PATH_ERROR (-258) /* Bad path for opendir */
dflet 0:50cedd586816 202 #define SL_ESEC_BAD_CERT_MANAGER_ERROR (-259) /* Bad Cert Manager */
dflet 0:50cedd586816 203 #define SL_ESEC_MAX_CHAIN_ERROR (-268) /* max chain depth exceeded */
dflet 0:50cedd586816 204 #define SL_ESEC_SUITES_ERROR (-271) /* suites pointer error */
dflet 0:50cedd586816 205 #define SL_ESEC_SSL_NO_PEM_HEADER (-272) /* no PEM header found */
dflet 0:50cedd586816 206 #define SL_ESEC_OUT_OF_ORDER_E (-273) /* out of order message */
dflet 0:50cedd586816 207 #define SL_ESEC_SANITY_CIPHER_E (-275) /* sanity check on cipher error */
dflet 0:50cedd586816 208 #define SL_ESEC_GEN_COOKIE_E (-277) /* Generate Cookie Error */
dflet 0:50cedd586816 209 #define SL_ESEC_NO_PEER_VERIFY (-278) /* Need peer cert verify Error */
dflet 0:50cedd586816 210 #define SL_ESEC_UNKNOWN_SNI_HOST_NAME_E (-281) /* Unrecognized host name Error */
dflet 0:50cedd586816 211 /* begin negotiation parameter errors */
dflet 0:50cedd586816 212 #define SL_ESEC_UNSUPPORTED_SUITE (-290) /* unsupported cipher suite */
dflet 0:50cedd586816 213 #define SL_ESEC_MATCH_SUITE_ERROR (-291 ) /* can't match cipher suite */
dflet 0:50cedd586816 214
dflet 0:50cedd586816 215 /* ssl tls security start with -300 offset */
dflet 0:50cedd586816 216 const int16_t SL_ESEC_CLOSE_NOTIFY = (-300); /* ssl/tls alerts */
dflet 0:50cedd586816 217 const int16_t SL_ESEC_UNEXPECTED_MESSAGE = (-310); /* ssl/tls alerts */
dflet 0:50cedd586816 218 const int16_t SL_ESEC_BAD_RECORD_MAC = (-320); /* ssl/tls alerts */
dflet 0:50cedd586816 219 const int16_t SL_ESEC_DECRYPTION_FAILED = (-321); /* ssl/tls alerts */
dflet 0:50cedd586816 220 const int16_t SL_ESEC_RECORD_OVERFLOW = (-322); /* ssl/tls alerts */
dflet 0:50cedd586816 221 const int16_t SL_ESEC_DECOMPRESSION_FAILURE = (-330); /* ssl/tls alerts */
dflet 0:50cedd586816 222 const int16_t SL_ESEC_HANDSHAKE_FAILURE = (-340); /* ssl/tls alerts */
dflet 0:50cedd586816 223 const int16_t SL_ESEC_NO_CERTIFICATE = (-341); /* ssl/tls alerts */
dflet 0:50cedd586816 224 const int16_t SL_ESEC_BAD_CERTIFICATE = (-342); /* ssl/tls alerts */
dflet 0:50cedd586816 225 const int16_t SL_ESEC_UNSUPPORTED_CERTIFICATE = (-343); /* ssl/tls alerts */
dflet 0:50cedd586816 226 const int16_t SL_ESEC_CERTIFICATE_REVOKED = (-344); /* ssl/tls alerts */
dflet 0:50cedd586816 227 const int16_t SL_ESEC_CERTIFICATE_EXPIRED = (-345); /* ssl/tls alerts */
dflet 0:50cedd586816 228 const int16_t SL_ESEC_CERTIFICATE_UNKNOWN = (-346); /* ssl/tls alerts */
dflet 0:50cedd586816 229 const int16_t SL_ESEC_ILLEGAL_PARAMETER = (-347); /* ssl/tls alerts */
dflet 0:50cedd586816 230 const int16_t SL_ESEC_UNKNOWN_CA = (-348); /* ssl/tls alerts */
dflet 0:50cedd586816 231 const int16_t SL_ESEC_ACCESS_DENIED = (-349); /* ssl/tls alerts */
dflet 0:50cedd586816 232 const int16_t SL_ESEC_DECODE_ERROR = (-350); /* ssl/tls alerts */
dflet 0:50cedd586816 233 const int16_t SL_ESEC_DECRYPT_ERROR = (-351); /* ssl/tls alerts */
dflet 0:50cedd586816 234 const int16_t SL_ESEC_EXPORT_RESTRICTION = (-360); /* ssl/tls alerts */
dflet 0:50cedd586816 235 const int16_t SL_ESEC_PROTOCOL_VERSION = (-370); /* ssl/tls alerts */
dflet 0:50cedd586816 236 const int16_t SL_ESEC_INSUFFICIENT_SECURITY = (-371); /* ssl/tls alerts */
dflet 0:50cedd586816 237 const int16_t SL_ESEC_INTERNAL_ERROR = (-380); /* ssl/tls alerts */
dflet 0:50cedd586816 238 const int16_t SL_ESEC_USER_CANCELLED = (-390); /* ssl/tls alerts */
dflet 0:50cedd586816 239 const int16_t SL_ESEC_NO_RENEGOTIATION = (-400); /* ssl/tls alerts */
dflet 0:50cedd586816 240 const int16_t SL_ESEC_UNSUPPORTED_EXTENSION = (-410); /* ssl/tls alerts */
dflet 0:50cedd586816 241 const int16_t SL_ESEC_CERTIFICATE_UNOBTAINABLE = (-411); /* ssl/tls alerts */
dflet 0:50cedd586816 242 const int16_t SL_ESEC_UNRECOGNIZED_NAME = (-412); /* ssl/tls alerts */
dflet 0:50cedd586816 243 const int16_t SL_ESEC_BAD_CERTIFICATE_STATUS_RESPONSE = (-413); /* ssl/tls alerts */
dflet 0:50cedd586816 244 const int16_t SL_ESEC_BAD_CERTIFICATE_HASH_VALUE = (-414); /* ssl/tls alerts */
dflet 0:50cedd586816 245 /* propierty secure */
dflet 0:50cedd586816 246 const int16_t SL_ESECGENERAL = (-450); /* error secure level general error */
dflet 0:50cedd586816 247 const int16_t SL_ESECDECRYPT = (-451); /* error secure level, decrypt recv packet fail */
dflet 0:50cedd586816 248 const int16_t SL_ESECCLOSED = (-452); /* secure layrer is closed by other size , tcp is still connected */
dflet 0:50cedd586816 249 const int16_t SL_ESECSNOVERIFY = (-453); /* Connected without server verification */
dflet 0:50cedd586816 250 const int16_t SL_ESECNOCAFILE = (-454); /* error secure level CA file not found*/
dflet 0:50cedd586816 251 const int16_t SL_ESECMEMORY = (-455); /* error secure level No memory space available */
dflet 0:50cedd586816 252 const int16_t SL_ESECBADCAFILE = (-456); /* error secure level bad CA file */
dflet 0:50cedd586816 253 const int16_t SL_ESECBADCERTFILE = (-457); /* error secure level bad Certificate file */
dflet 0:50cedd586816 254 const int16_t SL_ESECBADPRIVATEFILE = (-458); /* error secure level bad private file */
dflet 0:50cedd586816 255 const int16_t SL_ESECBADDHFILE = (-459); /* error secure level bad DH file */
dflet 0:50cedd586816 256 const int16_t SL_ESECT00MANYSSLOPENED = (-460); /* MAX SSL Sockets are opened */
dflet 0:50cedd586816 257 const int16_t SL_ESECDATEERROR = (-461); /* connected with certificate date verification error */
dflet 0:50cedd586816 258 const int16_t SL_ESECHANDSHAKETIMEDOUT = (-462); /* connection timed out due to handshake time */
dflet 0:50cedd586816 259
dflet 0:50cedd586816 260 /* end error codes */
dflet 0:50cedd586816 261
dflet 0:50cedd586816 262 /* Max payload size by protocol */
dflet 0:50cedd586816 263 const uint8_t SL_SOCKET_PAYLOAD_TYPE_MASK = (0xF0); /*4 bits type, 4 bits sockets id */
dflet 0:50cedd586816 264 const uint8_t SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4 = (0x00); /* 1472 bytes */
dflet 0:50cedd586816 265 const uint8_t SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4 = (0x10); /* 1460 bytes */
dflet 0:50cedd586816 266 const uint8_t SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6 = (0x20); /* 1452 bytes */
dflet 0:50cedd586816 267 const uint8_t SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6 = (0x30); /* 1440 bytes */
dflet 0:50cedd586816 268 const uint8_t SL_SOCKET_PAYLOAD_TYPE_UDP_IPV4_SECURE =(0x40); /* */
dflet 0:50cedd586816 269 const uint8_t SL_SOCKET_PAYLOAD_TYPE_TCP_IPV4_SECURE =(0x50); /* */
dflet 0:50cedd586816 270 const uint8_t SL_SOCKET_PAYLOAD_TYPE_UDP_IPV6_SECURE =(0x60); /* */
dflet 0:50cedd586816 271 const uint8_t SL_SOCKET_PAYLOAD_TYPE_TCP_IPV6_SECURE =(0x70); /* */
dflet 0:50cedd586816 272 const uint8_t SL_SOCKET_PAYLOAD_TYPE_RAW_TRANCEIVER =(0x80); /* 1536 bytes */
dflet 0:50cedd586816 273 const uint8_t SL_SOCKET_PAYLOAD_TYPE_RAW_PACKET = (0x90); /* 1536 bytes */
dflet 0:50cedd586816 274 const uint8_t SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 = (0xa0);
dflet 0:50cedd586816 275 const uint8_t SL_SOCKET_PAYLOAD_TYPE_RAW_IP6 = (SL_SOCKET_PAYLOAD_TYPE_RAW_IP4 );
dflet 0:50cedd586816 276
dflet 0:50cedd586816 277
dflet 0:50cedd586816 278
dflet 0:50cedd586816 279 const uint8_t SL_SOL_SOCKET = (1); /* Define the socket option category. */
dflet 0:50cedd586816 280 const uint8_t SL_IPPROTO_IP = (2); /* Define the IP option category. */
dflet 0:50cedd586816 281 const uint8_t SL_SOL_PHY_OPT = (3); /* Define the PHY option category. */
dflet 0:50cedd586816 282
dflet 0:50cedd586816 283 const uint8_t SL_SO_RCVBUF = (8); /* Setting TCP receive buffer size */
dflet 0:50cedd586816 284 const uint8_t SL_SO_KEEPALIVE = (9); /* Connections are kept alive with periodic messages */
dflet 0:50cedd586816 285 const uint8_t SL_SO_RCVTIMEO = (20); /* Enable receive timeout */
dflet 0:50cedd586816 286 const uint8_t SL_SO_NONBLOCKING = (24); /* Enable . disable nonblocking mode */
dflet 0:50cedd586816 287 const uint8_t SL_SO_SECMETHOD = (25); /* security metohd */
dflet 0:50cedd586816 288 const uint8_t SL_SO_SECURE_MASK = (26); /* security mask */
dflet 0:50cedd586816 289 const uint8_t SL_SO_SECURE_FILES = (27); /* security files */
dflet 0:50cedd586816 290 const uint8_t SL_SO_CHANGE_CHANNEL = (28); /* This option is available only when transceiver started */
dflet 0:50cedd586816 291 const uint8_t SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME =(30); /* This option used to configue secure file */
dflet 0:50cedd586816 292 const uint8_t SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME =(31); /* This option used to configue secure file */
dflet 0:50cedd586816 293 const uint8_t SL_SO_SECURE_FILES_CA_FILE_NAME = (32); /* This option used to configue secure file */
dflet 0:50cedd586816 294 const uint8_t SL_SO_SECURE_FILES_DH_KEY_FILE_NAME = (33); /* This option used to configue secure file */
dflet 0:50cedd586816 295
dflet 0:50cedd586816 296 const uint8_t SL_IP_MULTICAST_IF = (60); /* Specify outgoing multicast interface */
dflet 0:50cedd586816 297 const uint8_t SL_IP_MULTICAST_TTL = (61); /* Specify the TTL value to use for outgoing multicast packet. */
dflet 0:50cedd586816 298 const uint8_t SL_IP_ADD_MEMBERSHIP = (65); /* Join IPv4 multicast membership */
dflet 0:50cedd586816 299 const uint8_t SL_IP_DROP_MEMBERSHIP= (66); /* Leave IPv4 multicast membership */
dflet 0:50cedd586816 300 const uint8_t SL_IP_HDRINCL = (67); /* Raw socket IPv4 header included. */
dflet 0:50cedd586816 301 const uint8_t SL_IP_RAW_RX_NO_HEADER =(68); /* Proprietary socket option that does not includeIPv4/IPv6 header (and extension headers) on received raw sockets*/
dflet 0:50cedd586816 302 const uint8_t SL_IP_RAW_IPV6_HDRINCL =(69); /* Transmitted buffer over IPv6 socket contains IPv6 header. */
dflet 0:50cedd586816 303
dflet 0:50cedd586816 304 const uint8_t SL_SO_PHY_RATE = (100); /* WLAN Transmit rate */
dflet 0:50cedd586816 305 const uint8_t SL_SO_PHY_TX_POWER = (101); /* TX Power level */
dflet 0:50cedd586816 306 const uint8_t SL_SO_PHY_NUM_FRAMES_TO_TX = (102); /* Number of frames to transmit */
dflet 0:50cedd586816 307 const uint8_t SL_SO_PHY_PREAMBLE = (103); /* Preamble for transmission */
dflet 0:50cedd586816 308
dflet 0:50cedd586816 309 const uint8_t SL_SO_SEC_METHOD_SSLV3 = (0); /* security metohd SSL v3*/
dflet 0:50cedd586816 310 const uint8_t SL_SO_SEC_METHOD_TLSV1 = (1); /* security metohd TLS v1*/
dflet 0:50cedd586816 311 const uint8_t SL_SO_SEC_METHOD_TLSV1_1 = (2); /* security metohd TLS v1_1*/
dflet 0:50cedd586816 312 const uint8_t SL_SO_SEC_METHOD_TLSV1_2 = (3); /* security metohd TLS v1_2*/
dflet 0:50cedd586816 313 const uint8_t SL_SO_SEC_METHOD_SSLv3_TLSV1_2 = (4); /* use highest possible version from SSLv3 - TLS 1.2*/
dflet 0:50cedd586816 314 const uint8_t SL_SO_SEC_METHOD_DLSV1 = (5); /* security metohd DTL v1 */
dflet 0:50cedd586816 315
dflet 0:50cedd586816 316 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA (1 << 0)
dflet 0:50cedd586816 317 #define SL_SEC_MASK_SSL_RSA_WITH_RC4_128_MD5 (1 << 1)
dflet 0:50cedd586816 318 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA (1 << 2)
dflet 0:50cedd586816 319 #define SL_SEC_MASK_TLS_DHE_RSA_WITH_AES_256_CBC_SHA (1 << 3)
dflet 0:50cedd586816 320 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (1 << 4)
dflet 0:50cedd586816 321 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_RC4_128_SHA (1 << 5)
dflet 0:50cedd586816 322 #define SL_SEC_MASK_TLS_RSA_WITH_AES_128_CBC_SHA256 (1 << 6)
dflet 0:50cedd586816 323 #define SL_SEC_MASK_TLS_RSA_WITH_AES_256_CBC_SHA256 (1 << 7)
dflet 0:50cedd586816 324 #define SL_SEC_MASK_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (1 << 8)
dflet 0:50cedd586816 325 #define SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 (1 << 9)
dflet 0:50cedd586816 326
dflet 0:50cedd586816 327 #define SL_SEC_MASK_SECURE_DEFAULT ((SL_SEC_MASK_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 << 1) - 1)
dflet 0:50cedd586816 328
dflet 0:50cedd586816 329 const uint32_t SL_MSG_DONTWAIT = (0x00000008); /* Nonblocking IO */
dflet 0:50cedd586816 330
dflet 0:50cedd586816 331 /* AP DHCP Server - IP Release reason code */
dflet 0:50cedd586816 332 const uint8_t SL_IP_LEASE_PEER_RELEASE = (0);
dflet 0:50cedd586816 333 const uint8_t SL_IP_LEASE_PEER_DECLINE = (1);
dflet 0:50cedd586816 334 const uint8_t SL_IP_LEASE_EXPIRED = (2);
dflet 0:50cedd586816 335
dflet 0:50cedd586816 336 /* possible types when receiving SL_SOCKET_ASYNC_EVENT*/
dflet 0:50cedd586816 337 const uint8_t SSL_ACCEPT = (1); /* accept failed due to ssl issue ( tcp pass) */
dflet 0:50cedd586816 338 const uint8_t RX_FRAGMENTATION_TOO_BIG = (2); /* connection less mode, rx packet fragmentation > 16K, packet is being released */
dflet 0:50cedd586816 339 const uint8_t OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED = (3); /* remote side down from secure to unsecure */
dflet 0:50cedd586816 340
dflet 0:50cedd586816 341
dflet 0:50cedd586816 342
dflet 0:50cedd586816 343 #ifdef SL_INC_STD_BSD_API_NAMING
dflet 0:50cedd586816 344
dflet 0:50cedd586816 345 #define FD_SETSIZE SL_FD_SETSIZE
dflet 0:50cedd586816 346
dflet 0:50cedd586816 347 #define SOCK_STREAM SL_SOCK_STREAM
dflet 0:50cedd586816 348 #define SOCK_DGRAM SL_SOCK_DGRAM
dflet 0:50cedd586816 349 #define SOCK_RAW SL_SOCK_RAW
dflet 0:50cedd586816 350 #define IPPROTO_TCP SL_IPPROTO_TCP
dflet 0:50cedd586816 351 #define IPPROTO_UDP SL_IPPROTO_UDP
dflet 0:50cedd586816 352 #define IPPROTO_RAW SL_IPPROTO_RAW
dflet 0:50cedd586816 353
dflet 0:50cedd586816 354 #define AF_INET6_EUI_48 SL_AF_INET6_EUI_48
dflet 0:50cedd586816 355 #define AF_RF SL_AF_RF
dflet 0:50cedd586816 356 #define AF_PACKET SL_AF_PACKET
dflet 0:50cedd586816 357
dflet 0:50cedd586816 358 #define PF_INET SL_PF_INET
dflet 0:50cedd586816 359 #define PF_INET6 SL_PF_INET6
dflet 0:50cedd586816 360
dflet 0:50cedd586816 361 #define INADDR_ANY SL_INADDR_ANY
dflet 0:50cedd586816 362 #define ERROR SL_SOC_ERROR
dflet 0:50cedd586816 363 #define INEXE SL_INEXE
dflet 0:50cedd586816 364 #define EBADF SL_EBADF
dflet 0:50cedd586816 365 #define ENSOCK SL_ENSOCK
dflet 0:50cedd586816 366 #define EAGAIN SL_EAGAIN
dflet 0:50cedd586816 367 #define EWOULDBLOCK SL_EWOULDBLOCK
dflet 0:50cedd586816 368 #define ENOMEM SL_ENOMEM
dflet 0:50cedd586816 369 #define EACCES SL_EACCES
dflet 0:50cedd586816 370 #define EFAULT SL_EFAULT
dflet 0:50cedd586816 371 #define EINVAL SL_EINVAL
dflet 0:50cedd586816 372 #define EDESTADDRREQ SL_EDESTADDRREQ
dflet 0:50cedd586816 373 #define EPROTOTYPE SL_EPROTOTYPE
dflet 0:50cedd586816 374 #define ENOPROTOOPT SL_ENOPROTOOPT
dflet 0:50cedd586816 375 #define EPROTONOSUPPORT SL_EPROTONOSUPPORT
dflet 0:50cedd586816 376 #define ESOCKTNOSUPPORT SL_ESOCKTNOSUPPORT
dflet 0:50cedd586816 377 #define EOPNOTSUPP SL_EOPNOTSUPP
dflet 0:50cedd586816 378 #define EAFNOSUPPORT SL_EAFNOSUPPORT
dflet 0:50cedd586816 379 #define EADDRINUSE SL_EADDRINUSE
dflet 0:50cedd586816 380 #define EADDRNOTAVAIL SL_EADDRNOTAVAIL
dflet 0:50cedd586816 381 #define ENETUNREACH SL_ENETUNREACH
dflet 0:50cedd586816 382 #define ENOBUFS SL_ENOBUFS
dflet 0:50cedd586816 383 #define EOBUFF SL_EOBUFF
dflet 0:50cedd586816 384 #define EISCONN SL_EISCONN
dflet 0:50cedd586816 385 #define ENOTCONN SL_ENOTCONN
dflet 0:50cedd586816 386 #define ETIMEDOUT SL_ETIMEDOUT
dflet 0:50cedd586816 387 #define ECONNREFUSED SL_ECONNREFUSED
dflet 0:50cedd586816 388
dflet 0:50cedd586816 389 #define SOL_SOCKET SL_SOL_SOCKET
dflet 0:50cedd586816 390 #define IPPROTO_IP SL_IPPROTO_IP
dflet 0:50cedd586816 391 #define SO_KEEPALIVE SL_SO_KEEPALIVE
dflet 0:50cedd586816 392
dflet 0:50cedd586816 393 #define SO_RCVTIMEO SL_SO_RCVTIMEO
dflet 0:50cedd586816 394 #define SO_NONBLOCKING SL_SO_NONBLOCKING
dflet 0:50cedd586816 395
dflet 0:50cedd586816 396 #define IP_MULTICAST_IF SL_IP_MULTICAST_IF
dflet 0:50cedd586816 397 #define IP_MULTICAST_TTL SL_IP_MULTICAST_TTL
dflet 0:50cedd586816 398 #define IP_ADD_MEMBERSHIP SL_IP_ADD_MEMBERSHIP
dflet 0:50cedd586816 399 #define IP_DROP_MEMBERSHIP SL_IP_DROP_MEMBERSHIP
dflet 0:50cedd586816 400
dflet 0:50cedd586816 401 #define socklen_t SlSocklen_t
dflet 0:50cedd586816 402 #define timeval SlTimeval_t
dflet 0:50cedd586816 403 #define sockaddr SlSockAddr_t
dflet 0:50cedd586816 404 #define in6_addr SlIn6Addr_t
dflet 0:50cedd586816 405 #define sockaddr_in6 SlSockAddrIn6_t
dflet 0:50cedd586816 406 #define in_addr SlInAddr_t
dflet 0:50cedd586816 407 #define sockaddr_in SlSockAddrIn_t
dflet 0:50cedd586816 408
dflet 0:50cedd586816 409 #define MSG_DONTWAIT SL_MSG_DONTWAIT
dflet 0:50cedd586816 410
dflet 0:50cedd586816 411 #define FD_SET SL_FD_SET
dflet 0:50cedd586816 412 #define FD_CLR SL_FD_CLR
dflet 0:50cedd586816 413 #define FD_ISSET SL_FD_ISSET
dflet 0:50cedd586816 414 #define FD_ZERO SL_FD_ZERO
dflet 0:50cedd586816 415 #define fd_set SlFdSet_t
dflet 0:50cedd586816 416
dflet 0:50cedd586816 417 #define socket sl_Socket
dflet 0:50cedd586816 418 #define close sl_Close
dflet 0:50cedd586816 419 #define accept sl_Accept
dflet 0:50cedd586816 420 #define bind sl_Bind
dflet 0:50cedd586816 421 #define listen sl_Listen
dflet 0:50cedd586816 422 #define connect sl_Connect
dflet 0:50cedd586816 423 #define select sl_Select
dflet 0:50cedd586816 424 #define setsockopt sl_SetSockOpt
dflet 0:50cedd586816 425 #define getsockopt sl_GetSockOpt
dflet 0:50cedd586816 426 #define recv sl_Recv
dflet 0:50cedd586816 427 #define recvfrom sl_RecvFrom
dflet 0:50cedd586816 428 #define write_ sl_Write
dflet 0:50cedd586816 429 #define send sl_Send
dflet 0:50cedd586816 430 #define sendto sl_SendTo
dflet 0:50cedd586816 431 #define gethostbyname sl_NetAppDnsGetHostByName
dflet 0:50cedd586816 432 #define htonl sl_Htonl
dflet 0:50cedd586816 433 #define ntohl sl_Ntohl
dflet 0:50cedd586816 434 #define htons sl_Htons
dflet 0:50cedd586816 435 #define ntohs sl_Ntohs
dflet 0:50cedd586816 436 #endif
dflet 0:50cedd586816 437
dflet 0:50cedd586816 438
dflet 0:50cedd586816 439 /*****************************************************************************/
dflet 0:50cedd586816 440 /* Structure/Enum declarations */
dflet 0:50cedd586816 441 /*****************************************************************************/
dflet 0:50cedd586816 442
dflet 0:50cedd586816 443 /* Internet address */
dflet 0:50cedd586816 444 typedef struct SlInAddr_t {
dflet 0:50cedd586816 445 #ifndef s_addr
dflet 0:50cedd586816 446 uint32_t s_addr; /* Internet address 32 bits */
dflet 0:50cedd586816 447 #else
dflet 0:50cedd586816 448 union S_un {
dflet 0:50cedd586816 449 struct {
dflet 0:50cedd586816 450 uint8_t s_b1,s_b2,s_b3,s_b4;
dflet 0:50cedd586816 451 } S_un_b;
dflet 0:50cedd586816 452 struct {
dflet 0:50cedd586816 453 uint8_t s_w1,s_w2;
dflet 0:50cedd586816 454 } S_un_w;
dflet 0:50cedd586816 455 uint32_t S_addr;
dflet 0:50cedd586816 456 } S_un;
dflet 0:50cedd586816 457 #endif
dflet 0:50cedd586816 458 } SlInAddr_t;
dflet 0:50cedd586816 459
dflet 0:50cedd586816 460
dflet 0:50cedd586816 461 /* sockopt */
dflet 0:50cedd586816 462 typedef struct {
dflet 0:50cedd586816 463 uint32_t KeepaliveEnabled; /* 0 = disabled;1 = enabled; default = 1*/
dflet 0:50cedd586816 464 } SlSockKeepalive_t;
dflet 0:50cedd586816 465
dflet 0:50cedd586816 466 typedef struct {
dflet 0:50cedd586816 467 uint32_t ReuseaddrEnabled; /* 0 = disabled; 1 = enabled; default = 1*/
dflet 0:50cedd586816 468 } SlSockReuseaddr_t;
dflet 0:50cedd586816 469
dflet 0:50cedd586816 470 typedef struct {
dflet 0:50cedd586816 471 uint32_t Winsize; /* receive window size for tcp sockets */
dflet 0:50cedd586816 472 } SlSockWinsize_t;
dflet 0:50cedd586816 473
dflet 0:50cedd586816 474 typedef struct {
dflet 0:50cedd586816 475 uint32_t NonblockingEnabled;/* 0 = disabled;1 = enabled;default = 1*/
dflet 0:50cedd586816 476 } SlSockNonblocking_t;
dflet 0:50cedd586816 477
dflet 0:50cedd586816 478 typedef struct {
dflet 0:50cedd586816 479 uint8_t sd;
dflet 0:50cedd586816 480 uint8_t type;
dflet 0:50cedd586816 481 uint16_t val;
dflet 0:50cedd586816 482 uint8_t* pExtraInfo;
dflet 0:50cedd586816 483 } SlSocketAsyncEvent_t;
dflet 0:50cedd586816 484
dflet 0:50cedd586816 485 typedef struct {
dflet 0:50cedd586816 486 int16_t status;
dflet 0:50cedd586816 487 uint8_t sd;
dflet 0:50cedd586816 488 uint8_t padding;
dflet 0:50cedd586816 489 } SlSockTxFailEventData_t;
dflet 0:50cedd586816 490
dflet 0:50cedd586816 491
dflet 0:50cedd586816 492 typedef union
dflet 0:50cedd586816 493 {
dflet 0:50cedd586816 494 SlSockTxFailEventData_t SockTxFailData;
dflet 0:50cedd586816 495 SlSocketAsyncEvent_t SockAsyncData;
dflet 0:50cedd586816 496 } SlSockEventData_u;
dflet 0:50cedd586816 497
dflet 0:50cedd586816 498
dflet 0:50cedd586816 499 typedef struct {
dflet 0:50cedd586816 500 uint32_t Event;
dflet 0:50cedd586816 501 SlSockEventData_u socketAsyncEvent;
dflet 0:50cedd586816 502 } SlSockEvent_t;
dflet 0:50cedd586816 503
dflet 0:50cedd586816 504
dflet 0:50cedd586816 505 typedef struct {
dflet 0:50cedd586816 506 uint32_t secureMask;
dflet 0:50cedd586816 507 } SlSockSecureMask;
dflet 0:50cedd586816 508
dflet 0:50cedd586816 509 typedef struct {
dflet 0:50cedd586816 510 uint8_t secureMethod;
dflet 0:50cedd586816 511 } SlSockSecureMethod;
dflet 0:50cedd586816 512
dflet 0:50cedd586816 513 typedef enum {
dflet 0:50cedd586816 514 SL_BSD_SECURED_PRIVATE_KEY_IDX = 0,
dflet 0:50cedd586816 515 SL_BSD_SECURED_CERTIFICATE_IDX,
dflet 0:50cedd586816 516 SL_BSD_SECURED_CA_IDX,
dflet 0:50cedd586816 517 SL_BSD_SECURED_DH_IDX
dflet 0:50cedd586816 518 } slBsd_secureSocketFilesIndex_e;
dflet 0:50cedd586816 519
dflet 0:50cedd586816 520 typedef struct {
dflet 0:50cedd586816 521 SlInAddr_t imr_multiaddr; /* The IPv4 multicast address to join */
dflet 0:50cedd586816 522 SlInAddr_t imr_interface; /* The interface to use for this group */
dflet 0:50cedd586816 523 } SlSockIpMreq;
dflet 0:50cedd586816 524
dflet 0:50cedd586816 525
dflet 0:50cedd586816 526 /* sockopt */
dflet 0:50cedd586816 527 typedef uint32_t SlTime_t;
dflet 0:50cedd586816 528 typedef uint32_t SlSuseconds_t;
dflet 0:50cedd586816 529
dflet 0:50cedd586816 530 typedef struct {
dflet 0:50cedd586816 531 SlTime_t tv_sec; /* Seconds */
dflet 0:50cedd586816 532 SlSuseconds_t tv_usec; /* Microseconds */
dflet 0:50cedd586816 533 } SlTimeval_t;
dflet 0:50cedd586816 534
dflet 0:50cedd586816 535 typedef uint16_t SlSocklen_t;
dflet 0:50cedd586816 536
dflet 0:50cedd586816 537 /* IpV4 socket address */
dflet 0:50cedd586816 538 typedef struct {
dflet 0:50cedd586816 539 uint16_t sa_family; /* Address family (e.g. , AF_INET) */
dflet 0:50cedd586816 540 uint8_t sa_data[14]; /* Protocol- specific address information*/
dflet 0:50cedd586816 541 } SlSockAddr_t;
dflet 0:50cedd586816 542
dflet 0:50cedd586816 543
dflet 0:50cedd586816 544 /* IpV6 or Ipv6 EUI64 */
dflet 0:50cedd586816 545 typedef struct {
dflet 0:50cedd586816 546 union {
dflet 0:50cedd586816 547 uint8_t _S6_u8[16];
dflet 0:50cedd586816 548 uint32_t _S6_u32[4];
dflet 0:50cedd586816 549 } _S6_un;
dflet 0:50cedd586816 550 } SlIn6Addr_t;
dflet 0:50cedd586816 551
dflet 0:50cedd586816 552 typedef struct {
dflet 0:50cedd586816 553 uint16_t sin6_family; /* AF_INET6 || AF_INET6_EUI_48*/
dflet 0:50cedd586816 554 uint16_t sin6_port; /* Transport layer port. */
dflet 0:50cedd586816 555 uint32_t sin6_flowinfo; /* IPv6 flow information. */
dflet 0:50cedd586816 556 SlIn6Addr_t sin6_addr; /* IPv6 address. */
dflet 0:50cedd586816 557 uint32_t sin6_scope_id; /* set of interfaces for a scope. */
dflet 0:50cedd586816 558 } SlSockAddrIn6_t;
dflet 0:50cedd586816 559
dflet 0:50cedd586816 560 /* Socket address, Internet style. */
dflet 0:50cedd586816 561
dflet 0:50cedd586816 562 typedef struct {
dflet 0:50cedd586816 563 uint16_t sin_family; /* Internet Protocol (AF_INET). */
dflet 0:50cedd586816 564 uint16_t sin_port; /* Address port (16 bits). */
dflet 0:50cedd586816 565 SlInAddr_t sin_addr; /* Internet address (32 bits). */
dflet 0:50cedd586816 566 int8_t sin_zero[8]; /* Not used. */
dflet 0:50cedd586816 567 } SlSockAddrIn_t;
dflet 0:50cedd586816 568
dflet 0:50cedd586816 569 typedef struct {
dflet 0:50cedd586816 570 uint32_t ip;
dflet 0:50cedd586816 571 uint32_t gateway;
dflet 0:50cedd586816 572 uint32_t dns;
dflet 0:50cedd586816 573 } SlIpV4AcquiredAsync_t;
dflet 0:50cedd586816 574
dflet 0:50cedd586816 575 typedef struct {
dflet 0:50cedd586816 576 uint32_t type;
dflet 0:50cedd586816 577 uint32_t ip[4];
dflet 0:50cedd586816 578 uint32_t gateway[4];
dflet 0:50cedd586816 579 uint32_t dns[4];
dflet 0:50cedd586816 580 } SlIpV6AcquiredAsync_t;
dflet 0:50cedd586816 581
dflet 0:50cedd586816 582 typedef struct {
dflet 0:50cedd586816 583 uint32_t ip_address;
dflet 0:50cedd586816 584 uint32_t lease_time;
dflet 0:50cedd586816 585 uint8_t mac[6];
dflet 0:50cedd586816 586 uint16_t padding;
dflet 0:50cedd586816 587 } SlIpLeasedAsync_t;
dflet 0:50cedd586816 588
dflet 0:50cedd586816 589 typedef struct {
dflet 0:50cedd586816 590 uint32_t ip_address;
dflet 0:50cedd586816 591 uint8_t mac[6];
dflet 0:50cedd586816 592 uint16_t reason;
dflet 0:50cedd586816 593 } SlIpReleasedAsync_t;
dflet 0:50cedd586816 594
dflet 0:50cedd586816 595
dflet 0:50cedd586816 596 typedef union {
dflet 0:50cedd586816 597 SlIpV4AcquiredAsync_t ipAcquiredV4; /*SL_NETAPP_IPV4_IPACQUIRED_EVENT*/
dflet 0:50cedd586816 598 SlIpV6AcquiredAsync_t ipAcquiredV6; /*SL_NETAPP_IPV6_IPACQUIRED_EVENT*/
dflet 0:50cedd586816 599 uint32_t sd; /*SL_SOCKET_TX_FAILED_EVENT*/
dflet 0:50cedd586816 600 SlIpLeasedAsync_t ipLeased; /* SL_NETAPP_IP_LEASED_EVENT */
dflet 0:50cedd586816 601 SlIpReleasedAsync_t ipReleased; /* SL_NETAPP_IP_RELEASED_EVENT */
dflet 0:50cedd586816 602 } SlNetAppEventData_u;
dflet 0:50cedd586816 603
dflet 0:50cedd586816 604 typedef struct {
dflet 0:50cedd586816 605 uint32_t Event;
dflet 0:50cedd586816 606 SlNetAppEventData_u EventData;
dflet 0:50cedd586816 607 } SlNetAppEvent_t;
dflet 0:50cedd586816 608
dflet 0:50cedd586816 609
dflet 0:50cedd586816 610 typedef struct sock_secureFiles {
dflet 0:50cedd586816 611 uint8_t secureFiles[4];
dflet 0:50cedd586816 612 } SlSockSecureFiles_t;
dflet 0:50cedd586816 613
dflet 0:50cedd586816 614
dflet 0:50cedd586816 615 typedef struct SlFdSet_t { /* The select socket array manager */
dflet 0:50cedd586816 616 uint32_t fd_array[(SL_FD_SETSIZE + 31)/32]; /* Bit map of SOCKET Descriptors */
dflet 0:50cedd586816 617 } SlFdSet_t;
dflet 0:50cedd586816 618
dflet 0:50cedd586816 619 typedef struct {
dflet 0:50cedd586816 620 uint8_t rate; /* Recevied Rate */
dflet 0:50cedd586816 621 uint8_t channel; /* The received channel*/
dflet 0:50cedd586816 622 int8_t rssi; /* The computed RSSI value in db of current frame */
dflet 0:50cedd586816 623 uint8_t padding; /* pad to align to 32 bits */
dflet 0:50cedd586816 624 uint32_t timestamp; /* Timestamp in microseconds, */
dflet 0:50cedd586816 625 } SlTransceiverRxOverHead_t;
dflet 0:50cedd586816 626
dflet 0:50cedd586816 627 class cc3100_nonos;
dflet 0:50cedd586816 628
dflet 0:50cedd586816 629 class cc3100_socket
dflet 0:50cedd586816 630 {
dflet 0:50cedd586816 631
dflet 0:50cedd586816 632 public:
dflet 0:50cedd586816 633
dflet 0:50cedd586816 634 #ifndef SL_PLATFORM_MULTI_THREADED
dflet 0:50cedd586816 635 cc3100_socket(cc3100_driver &driver, cc3100_nonos &nonos);
dflet 0:50cedd586816 636 #else
dflet 0:50cedd586816 637 cc3100_socket(cc3100_driver &driver);
dflet 0:50cedd586816 638 #endif
dflet 0:50cedd586816 639 ~cc3100_socket();
dflet 0:50cedd586816 640
dflet 0:50cedd586816 641 /*******************************************************************************/
dflet 0:50cedd586816 642 /* Functions prototypes */
dflet 0:50cedd586816 643 /*******************************************************************************/
dflet 0:50cedd586816 644 void _sl_BuildAddress(const SlSockAddr_t *addr, _SocketAddrCommand_u *pCmd);
dflet 0:50cedd586816 645 void _sl_ParseAddress(_SocketAddrResponse_u *pRsp, SlSockAddr_t *addr, SlSocklen_t *addrlen);
dflet 0:50cedd586816 646 uint16_t _sl_TruncatePayloadByProtocol(const int16_t pSd,const uint16_t length);
dflet 0:50cedd586816 647
dflet 0:50cedd586816 648 /*****************************************************************************/
dflet 0:50cedd586816 649 /* Function prototypes */
dflet 0:50cedd586816 650 /*****************************************************************************/
dflet 0:50cedd586816 651
dflet 0:50cedd586816 652 /*!
dflet 0:50cedd586816 653
dflet 0:50cedd586816 654 \brief create an endpoint for communication
dflet 0:50cedd586816 655
dflet 0:50cedd586816 656 The socket function creates a new socket of a certain socket type, identified
dflet 0:50cedd586816 657 by an integer number, and allocates system resources to it.
dflet 0:50cedd586816 658 This function is called by the application layer to obtain a socket handle.
dflet 0:50cedd586816 659
dflet 0:50cedd586816 660 \param[in] domain specifies the protocol family of the created socket.
dflet 0:50cedd586816 661 For example:
dflet 0:50cedd586816 662 AF_INET for network protocol IPv4
dflet 0:50cedd586816 663 AF_RF for starting transceiver mode. Notes:
dflet 0:50cedd586816 664 - sending and receiving any packet overriding 802.11 header
dflet 0:50cedd586816 665 - for optimized power consumption the socket will be started in TX
dflet 0:50cedd586816 666 only mode until receive command is activated
dflet 0:50cedd586816 667 AF_INET6 for IPv6
dflet 0:50cedd586816 668
dflet 0:50cedd586816 669
dflet 0:50cedd586816 670 \param[in] type specifies the communication semantic, one of:
dflet 0:50cedd586816 671 SOCK_STREAM (reliable stream-oriented service or Stream Sockets)
dflet 0:50cedd586816 672 SOCK_DGRAM (datagram service or Datagram Sockets)
dflet 0:50cedd586816 673 SOCK_RAW (raw protocols atop the network layer)
dflet 0:50cedd586816 674 when used with AF_RF:
dflet 0:50cedd586816 675 SOCK_DGRAM - L2 socket
dflet 0:50cedd586816 676 SOCK_RAW - L1 socket - bypass WLAN CCA (Clear Channel Assessment)
dflet 0:50cedd586816 677
dflet 0:50cedd586816 678 \param[in] protocol specifies a particular transport to be used with
dflet 0:50cedd586816 679 the socket.
dflet 0:50cedd586816 680 The most common are IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP,
dflet 0:50cedd586816 681 IPPROTO_DCCP.
dflet 0:50cedd586816 682 The value 0 may be used to select a default
dflet 0:50cedd586816 683 protocol from the selected domain and type
dflet 0:50cedd586816 684
dflet 0:50cedd586816 685
dflet 0:50cedd586816 686 \return On success, socket handle that is used for consequent socket operations.
dflet 0:50cedd586816 687 A successful return code should be a positive number (int16)
dflet 0:50cedd586816 688 On error, a negative (int16) value will be returned specifying the error code.
dflet 0:50cedd586816 689 SL_EAFNOSUPPORT - illegal domain parameter
dflet 0:50cedd586816 690 SL_EPROTOTYPE - illegal type parameter
dflet 0:50cedd586816 691 SL_EACCES - permission denied
dflet 0:50cedd586816 692 SL_ENSOCK - exceeded maximal number of socket
dflet 0:50cedd586816 693 SL_ENOMEM - memory allocation error
dflet 0:50cedd586816 694 SL_EINVAL - error in socket configuration
dflet 0:50cedd586816 695 SL_EPROTONOSUPPORT - illegal protocol parameter
dflet 0:50cedd586816 696 SL_EOPNOTSUPP - illegal combination of protocol and type parameters
dflet 0:50cedd586816 697
dflet 0:50cedd586816 698
dflet 0:50cedd586816 699 \sa sl_Close
dflet 0:50cedd586816 700 \note belongs to \ref basic_api
dflet 0:50cedd586816 701 \warning
dflet 0:50cedd586816 702 */
dflet 0:50cedd586816 703 #if _SL_INCLUDE_FUNC(sl_Socket)
dflet 0:50cedd586816 704 int16_t sl_Socket(int16_t Domain, int16_t Type, int16_t Protocol);
dflet 0:50cedd586816 705 #endif
dflet 0:50cedd586816 706
dflet 0:50cedd586816 707 /*!
dflet 0:50cedd586816 708 \brief gracefully close socket
dflet 0:50cedd586816 709
dflet 0:50cedd586816 710 This function causes the system to release resources allocated to a socket. \n
dflet 0:50cedd586816 711 In case of TCP, the connection is terminated.
dflet 0:50cedd586816 712
dflet 0:50cedd586816 713 \param[in] sd socket handle (received in sl_Socket)
dflet 0:50cedd586816 714
dflet 0:50cedd586816 715 \return On success, zero is returned.
dflet 0:50cedd586816 716 On error, a negative number is returned.
dflet 0:50cedd586816 717
dflet 0:50cedd586816 718 \sa sl_Socket
dflet 0:50cedd586816 719 \note belongs to \ref ext_api
dflet 0:50cedd586816 720 \warning
dflet 0:50cedd586816 721 */
dflet 0:50cedd586816 722 #if _SL_INCLUDE_FUNC(sl_Close)
dflet 0:50cedd586816 723 int16_t sl_Close(int16_t sd);
dflet 0:50cedd586816 724 #endif
dflet 0:50cedd586816 725
dflet 0:50cedd586816 726 /*!
dflet 0:50cedd586816 727 \brief Accept a connection on a socket
dflet 0:50cedd586816 728
dflet 0:50cedd586816 729 This function is used with connection-based socket types (SOCK_STREAM).
dflet 0:50cedd586816 730 It extracts the first connection request on the queue of pending
dflet 0:50cedd586816 731 connections, creates a new connected socket, and returns a new file
dflet 0:50cedd586816 732 descriptor referring to that socket.
dflet 0:50cedd586816 733 The newly created socket is not in the listening state. The
dflet 0:50cedd586816 734 original socket sd is unaffected by this call.
dflet 0:50cedd586816 735 The argument sd is a socket that has been created with
dflet 0:50cedd586816 736 sl_Socket(), bound to a local address with sl_Bind(), and is
dflet 0:50cedd586816 737 listening for connections after a sl_Listen(). The argument \b
dflet 0:50cedd586816 738 \e addr is a pointer to a sockaddr structure. This structure
dflet 0:50cedd586816 739 is filled in with the address of the peer socket, as known to
dflet 0:50cedd586816 740 the communications layer. The exact format of the address
dflet 0:50cedd586816 741 returned addr is determined by the socket's address family.
dflet 0:50cedd586816 742 The \b \e addrlen argument is a value-result argument: it
dflet 0:50cedd586816 743 should initially contain the size of the structure pointed to
dflet 0:50cedd586816 744 by addr, on return it will contain the actual length (in
dflet 0:50cedd586816 745 bytes) of the address returned.
dflet 0:50cedd586816 746
dflet 0:50cedd586816 747 \param[in] sd socket descriptor (handle)
dflet 0:50cedd586816 748 \param[out] addr the argument addr is a pointer
dflet 0:50cedd586816 749 to a sockaddr structure. This
dflet 0:50cedd586816 750 structure is filled in with the
dflet 0:50cedd586816 751 address of the peer socket, as
dflet 0:50cedd586816 752 known to the communications
dflet 0:50cedd586816 753 layer. The exact format of the
dflet 0:50cedd586816 754 address returned addr is
dflet 0:50cedd586816 755 determined by the socket's
dflet 0:50cedd586816 756 address\n
dflet 0:50cedd586816 757 sockaddr:\n - code for the
dflet 0:50cedd586816 758 address format. On this version
dflet 0:50cedd586816 759 only AF_INET is supported.\n -
dflet 0:50cedd586816 760 socket address, the length
dflet 0:50cedd586816 761 depends on the code format
dflet 0:50cedd586816 762 \param[out] addrlen the addrlen argument is a value-result
dflet 0:50cedd586816 763 argument: it should initially contain the
dflet 0:50cedd586816 764 size of the structure pointed to by addr
dflet 0:50cedd586816 765
dflet 0:50cedd586816 766 \return On success, a socket handle.
dflet 0:50cedd586816 767 On a non-blocking accept a possible negative value is SL_EAGAIN.
dflet 0:50cedd586816 768 On failure, negative value.
dflet 0:50cedd586816 769 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 0:50cedd586816 770 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 0:50cedd586816 771
dflet 0:50cedd586816 772 \sa sl_Socket sl_Bind sl_Listen
dflet 0:50cedd586816 773 \note belongs to \ref server_side
dflet 0:50cedd586816 774 \warning
dflet 0:50cedd586816 775 */
dflet 0:50cedd586816 776 #if _SL_INCLUDE_FUNC(sl_Accept)
dflet 0:50cedd586816 777 int16_t sl_Accept(int16_t sd, SlSockAddr_t *addr, SlSocklen_t *addrlen);
dflet 0:50cedd586816 778 #endif
dflet 0:50cedd586816 779
dflet 0:50cedd586816 780 /*!
dflet 0:50cedd586816 781 \brief assign a name to a socket
dflet 0:50cedd586816 782
dflet 0:50cedd586816 783 This function gives the socket the local address addr.
dflet 0:50cedd586816 784 addr is addrlen bytes long. Traditionally, this is called
dflet 0:50cedd586816 785 When a socket is created with socket, it exists in a name
dflet 0:50cedd586816 786 space (address family) but has no name assigned.
dflet 0:50cedd586816 787 It is necessary to assign a local address before a SOCK_STREAM
dflet 0:50cedd586816 788 socket may receive connections.
dflet 0:50cedd586816 789
dflet 0:50cedd586816 790 \param[in] sd socket descriptor (handle)
dflet 0:50cedd586816 791 \param[in] addr specifies the destination
dflet 0:50cedd586816 792 addrs\n sockaddr:\n - code for
dflet 0:50cedd586816 793 the address format. On this
dflet 0:50cedd586816 794 version only AF_INET is
dflet 0:50cedd586816 795 supported.\n - socket address,
dflet 0:50cedd586816 796 the length depends on the code
dflet 0:50cedd586816 797 format
dflet 0:50cedd586816 798 \param[in] addrlen contains the size of the structure pointed to by addr
dflet 0:50cedd586816 799
dflet 0:50cedd586816 800 \return On success, zero is returned. On error, a negative error code is returned.
dflet 0:50cedd586816 801
dflet 0:50cedd586816 802 \sa sl_Socket sl_Accept sl_Listen
dflet 0:50cedd586816 803 \note belongs to \ref basic_api
dflet 0:50cedd586816 804 \warning
dflet 0:50cedd586816 805 */
dflet 0:50cedd586816 806 #if _SL_INCLUDE_FUNC(sl_Bind)
dflet 0:50cedd586816 807 int16_t sl_Bind(int16_t sd, const SlSockAddr_t *addr, int16_t addrlen);
dflet 0:50cedd586816 808 #endif
dflet 0:50cedd586816 809
dflet 0:50cedd586816 810 /*!
dflet 0:50cedd586816 811 \brief listen for connections on a socket
dflet 0:50cedd586816 812
dflet 0:50cedd586816 813 The willingness to accept incoming connections and a queue
dflet 0:50cedd586816 814 limit for incoming connections are specified with listen(),
dflet 0:50cedd586816 815 and then the connections are accepted with accept.
dflet 0:50cedd586816 816 The listen() call applies only to sockets of type SOCK_STREAM
dflet 0:50cedd586816 817 The backlog parameter defines the maximum length the queue of
dflet 0:50cedd586816 818 pending connections may grow to.
dflet 0:50cedd586816 819
dflet 0:50cedd586816 820 \param[in] sd socket descriptor (handle)
dflet 0:50cedd586816 821 \param[in] backlog specifies the listen queue depth.
dflet 0:50cedd586816 822
dflet 0:50cedd586816 823
dflet 0:50cedd586816 824 \return On success, zero is returned. On error, a negative error code is returned.
dflet 0:50cedd586816 825
dflet 0:50cedd586816 826 \sa sl_Socket sl_Accept sl_Bind
dflet 0:50cedd586816 827 \note belongs to \ref server_side
dflet 0:50cedd586816 828 \warning
dflet 0:50cedd586816 829 */
dflet 0:50cedd586816 830 #if _SL_INCLUDE_FUNC(sl_Listen)
dflet 0:50cedd586816 831 int16_t sl_Listen(int16_t sd, int16_t backlog);
dflet 0:50cedd586816 832 #endif
dflet 0:50cedd586816 833
dflet 0:50cedd586816 834 /*!
dflet 0:50cedd586816 835 \brief Initiate a connection on a socket
dflet 0:50cedd586816 836
dflet 0:50cedd586816 837 Function connects the socket referred to by the socket
dflet 0:50cedd586816 838 descriptor sd, to the address specified by addr. The addrlen
dflet 0:50cedd586816 839 argument specifies the size of addr. The format of the
dflet 0:50cedd586816 840 address in addr is determined by the address space of the
dflet 0:50cedd586816 841 socket. If it is of type SOCK_DGRAM, this call specifies the
dflet 0:50cedd586816 842 peer with which the socket is to be associated; this address
dflet 0:50cedd586816 843 is that to which datagrams are to be sent, and the only
dflet 0:50cedd586816 844 address from which datagrams are to be received. If the
dflet 0:50cedd586816 845 socket is of type SOCK_STREAM, this call attempts to make a
dflet 0:50cedd586816 846 connection to another socket. The other socket is specified
dflet 0:50cedd586816 847 by address, which is an address in the communications space
dflet 0:50cedd586816 848 of the socket.
dflet 0:50cedd586816 849
dflet 0:50cedd586816 850
dflet 0:50cedd586816 851 \param[in] sd socket descriptor (handle)
dflet 0:50cedd586816 852 \param[in] addr specifies the destination addr\n
dflet 0:50cedd586816 853 sockaddr:\n - code for the
dflet 0:50cedd586816 854 address format. On this version
dflet 0:50cedd586816 855 only AF_INET is supported.\n -
dflet 0:50cedd586816 856 socket address, the length
dflet 0:50cedd586816 857 depends on the code format
dflet 0:50cedd586816 858
dflet 0:50cedd586816 859 \param[in] addrlen contains the size of the structure pointed
dflet 0:50cedd586816 860 to by addr
dflet 0:50cedd586816 861
dflet 0:50cedd586816 862 \return On success, a socket handle.
dflet 0:50cedd586816 863 On a non-blocking connect a possible negative value is SL_EALREADY.
dflet 0:50cedd586816 864 On failure, negative value.
dflet 0:50cedd586816 865 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 0:50cedd586816 866 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 0:50cedd586816 867
dflet 0:50cedd586816 868 \sa sl_Socket
dflet 0:50cedd586816 869 \note belongs to \ref client_side
dflet 0:50cedd586816 870 \warning
dflet 0:50cedd586816 871 */
dflet 0:50cedd586816 872 #if _SL_INCLUDE_FUNC(sl_Connect)
dflet 0:50cedd586816 873 int16_t sl_Connect(int16_t sd, const SlSockAddr_t *addr, int16_t addrlen);
dflet 0:50cedd586816 874 #endif
dflet 0:50cedd586816 875
dflet 0:50cedd586816 876 /*!
dflet 0:50cedd586816 877 \brief Monitor socket activity
dflet 0:50cedd586816 878
dflet 0:50cedd586816 879 Select allow a program to monitor multiple file descriptors,
dflet 0:50cedd586816 880 waiting until one or more of the file descriptors become
dflet 0:50cedd586816 881 "ready" for some class of I/O operation
dflet 0:50cedd586816 882
dflet 0:50cedd586816 883
dflet 0:50cedd586816 884 \param[in] nfds the highest-numbered file descriptor in any of the
dflet 0:50cedd586816 885 three sets, plus 1.
dflet 0:50cedd586816 886 \param[out] readsds socket descriptors list for read monitoring and accept monitoring
dflet 0:50cedd586816 887 \param[out] writesds socket descriptors list for connect monitoring only, write monitoring is not supported, non blocking connect is supported
dflet 0:50cedd586816 888 \param[out] exceptsds socket descriptors list for exception monitoring, not supported.
dflet 0:50cedd586816 889 \param[in] timeout is an upper bound on the amount of time elapsed
dflet 0:50cedd586816 890 before select() returns. Null or above 0xffff seconds means
dflet 0:50cedd586816 891 infinity timeout. The minimum timeout is 10 milliseconds,
dflet 0:50cedd586816 892 less than 10 milliseconds will be set automatically to 10 milliseconds.
dflet 0:50cedd586816 893 Max microseconds supported is 0xfffc00.
dflet 0:50cedd586816 894
dflet 0:50cedd586816 895 \return On success, select() returns the number of
dflet 0:50cedd586816 896 file descriptors contained in the three returned
dflet 0:50cedd586816 897 descriptor sets (that is, the total number of bits that
dflet 0:50cedd586816 898 are set in readfds, writefds, exceptfds) which may be
dflet 0:50cedd586816 899 zero if the timeout expires before anything interesting
dflet 0:50cedd586816 900 happens. On error, a negative value is returned.
dflet 0:50cedd586816 901 readsds - return the sockets on which Read request will
dflet 0:50cedd586816 902 return without delay with valid data.
dflet 0:50cedd586816 903 writesds - return the sockets on which Write request
dflet 0:50cedd586816 904 will return without delay.
dflet 0:50cedd586816 905 exceptsds - return the sockets closed recently.
dflet 0:50cedd586816 906 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 0:50cedd586816 907 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 0:50cedd586816 908
dflet 0:50cedd586816 909 \sa sl_Socket
dflet 0:50cedd586816 910 \note If the timeout value set to less than 5ms it will automatically set
dflet 0:50cedd586816 911 to 5ms to prevent overload of the system
dflet 0:50cedd586816 912 belongs to \ref basic_api
dflet 0:50cedd586816 913
dflet 0:50cedd586816 914 Only one sl_Select can be handled at a time.
dflet 0:50cedd586816 915 Calling this API while the same command is called from another thread, may result
dflet 0:50cedd586816 916 in one of the two scenarios:
dflet 0:50cedd586816 917 1. The command will wait (internal) until the previous command finish, and then be executed.
dflet 0:50cedd586816 918 2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
dflet 0:50cedd586816 919 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
dflet 0:50cedd586816 920 again later to issue the command.
dflet 0:50cedd586816 921
dflet 0:50cedd586816 922 \warning
dflet 0:50cedd586816 923 */
dflet 0:50cedd586816 924 #if _SL_INCLUDE_FUNC(sl_Select)
dflet 0:50cedd586816 925 int16_t sl_Select(int16_t nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, SlTimeval_t *timeout);
dflet 0:50cedd586816 926
dflet 0:50cedd586816 927
dflet 0:50cedd586816 928 /*!
dflet 0:50cedd586816 929 \brief Select's SlFdSet_t SET function
dflet 0:50cedd586816 930
dflet 0:50cedd586816 931 Sets current socket descriptor on SlFdSet_t container
dflet 0:50cedd586816 932 */
dflet 0:50cedd586816 933 void SL_FD_SET(int16_t fd, SlFdSet_t *fdset);
dflet 0:50cedd586816 934
dflet 0:50cedd586816 935 /*!
dflet 0:50cedd586816 936 \brief Select's SlFdSet_t CLR function
dflet 0:50cedd586816 937
dflet 0:50cedd586816 938 Clears current socket descriptor on SlFdSet_t container
dflet 0:50cedd586816 939 */
dflet 0:50cedd586816 940 void SL_FD_CLR(int16_t fd, SlFdSet_t *fdset);
dflet 0:50cedd586816 941
dflet 0:50cedd586816 942
dflet 0:50cedd586816 943 /*!
dflet 0:50cedd586816 944 \brief Select's SlFdSet_t ISSET function
dflet 0:50cedd586816 945
dflet 0:50cedd586816 946 Checks if current socket descriptor is set (TRUE/FALSE)
dflet 0:50cedd586816 947
dflet 0:50cedd586816 948 \return Returns TRUE if set, FALSE if unset
dflet 0:50cedd586816 949
dflet 0:50cedd586816 950 */
dflet 0:50cedd586816 951 int16_t SL_FD_ISSET(int16_t fd, SlFdSet_t *fdset);
dflet 0:50cedd586816 952
dflet 0:50cedd586816 953 /*!
dflet 0:50cedd586816 954 \brief Select's SlFdSet_t ZERO function
dflet 0:50cedd586816 955
dflet 0:50cedd586816 956 Clears all socket descriptors from SlFdSet_t
dflet 0:50cedd586816 957 */
dflet 0:50cedd586816 958 void SL_FD_ZERO(SlFdSet_t *fdset);
dflet 0:50cedd586816 959
dflet 0:50cedd586816 960
dflet 0:50cedd586816 961
dflet 0:50cedd586816 962 #endif
dflet 0:50cedd586816 963
dflet 0:50cedd586816 964 /*!
dflet 0:50cedd586816 965 \brief set socket options
dflet 0:50cedd586816 966
dflet 0:50cedd586816 967 This function manipulate the options associated with a socket.
dflet 0:50cedd586816 968 Options may exist at multiple protocol levels; they are always
dflet 0:50cedd586816 969 present at the uppermost socket level.
dflet 0:50cedd586816 970
dflet 0:50cedd586816 971 When manipulating socket options the level at which the option resides
dflet 0:50cedd586816 972 and the name of the option must be specified. To manipulate options at
dflet 0:50cedd586816 973 the socket level, level is specified as SOL_SOCKET. To manipulate
dflet 0:50cedd586816 974 options at any other level the protocol number of the appropriate proto-
dflet 0:50cedd586816 975 col controlling the option is supplied. For example, to indicate that an
dflet 0:50cedd586816 976 option is to be interpreted by the TCP protocol, level should be set to
dflet 0:50cedd586816 977 the protocol number of TCP;
dflet 0:50cedd586816 978
dflet 0:50cedd586816 979 The parameters optval and optlen are used to access optval -
dflet 0:50cedd586816 980 ues for setsockopt(). For getsockopt() they identify a
dflet 0:50cedd586816 981 buffer in which the value for the requested option(s) are to
dflet 0:50cedd586816 982 be returned. For getsockopt(), optlen is a value-result
dflet 0:50cedd586816 983 parameter, initially containing the size of the buffer
dflet 0:50cedd586816 984 pointed to by option_value, and modified on return to
dflet 0:50cedd586816 985 indicate the actual size of the value returned. If no option
dflet 0:50cedd586816 986 value is to be supplied or returned, option_value may be
dflet 0:50cedd586816 987 NULL.
dflet 0:50cedd586816 988
dflet 0:50cedd586816 989 \param[in] sd socket handle
dflet 0:50cedd586816 990 \param[in] level defines the protocol level for this option
dflet 0:50cedd586816 991 - <b>SL_SOL_SOCKET</b> Socket level configurations (L4, transport layer)
dflet 0:50cedd586816 992 - <b>SL_IPPROTO_IP</b> IP level configurations (L3, network layer)
dflet 0:50cedd586816 993 - <b>SL_SOL_PHY_OPT</b> Link level configurations (L2, link layer)
dflet 0:50cedd586816 994 \param[in] optname defines the option name to interrogate
dflet 0:50cedd586816 995 - <b>SL_SOL_SOCKET</b>
dflet 0:50cedd586816 996 - <b>SL_SO_KEEPALIVE</b> \n
dflet 0:50cedd586816 997 Enable/Disable periodic keep alive.
dflet 0:50cedd586816 998 Keeps TCP connections active by enabling the periodic transmission of messages \n
dflet 0:50cedd586816 999 Timeout is 5 minutes.\n
dflet 0:50cedd586816 1000 Default: Enabled \n
dflet 0:50cedd586816 1001 This options takes SlSockKeepalive_t struct as parameter
dflet 0:50cedd586816 1002 - <b>SL_SO_RCVTIMEO</b> \n
dflet 0:50cedd586816 1003 Sets the timeout value that specifies the maximum amount of time an input function waits until it completes. \n
dflet 0:50cedd586816 1004 Default: No timeout \n
dflet 0:50cedd586816 1005 This options takes SlTimeval_t struct as parameter
dflet 0:50cedd586816 1006 - <b>SL_SO_RCVBUF</b> \n
dflet 0:50cedd586816 1007 Sets tcp max recv window size. \n
dflet 0:50cedd586816 1008 This options takes SlSockWinsize_t struct as parameter
dflet 0:50cedd586816 1009 - <b>SL_SO_NONBLOCKING</b> \n
dflet 0:50cedd586816 1010 Sets socket to non-blocking operation Impacts: connect, accept, send, sendto, recv and recvfrom. \n
dflet 0:50cedd586816 1011 Default: Blocking.
dflet 0:50cedd586816 1012 This options takes SlSockNonblocking_t struct as parameter
dflet 0:50cedd586816 1013 - <b>SL_SO_SECMETHOD</b> \n
dflet 0:50cedd586816 1014 Sets method to tcp secured socket (SL_SEC_SOCKET) \n
dflet 0:50cedd586816 1015 Default: SL_SO_SEC_METHOD_SSLv3_TLSV1_2 \n
dflet 0:50cedd586816 1016 This options takes SlSockSecureMethod struct as parameter
dflet 0:50cedd586816 1017 - <b>SL_SO_SEC_MASK</b> \n
dflet 0:50cedd586816 1018 Sets specific cipher to tcp secured socket (SL_SEC_SOCKET) \n
dflet 0:50cedd586816 1019 Default: "Best" cipher suitable to method \n
dflet 0:50cedd586816 1020 This options takes SlSockSecureMask struct as parameter
dflet 0:50cedd586816 1021 - <b>SL_SO_SECURE_FILES_CA_FILE_NAME</b> \n
dflet 0:50cedd586816 1022 Map secured socket to CA file by name \n
dflet 0:50cedd586816 1023 This options takes <b>uint8_t</b> buffer as parameter
dflet 0:50cedd586816 1024 - <b>SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME</b> \n
dflet 0:50cedd586816 1025 Map secured socket to private key by name \n
dflet 0:50cedd586816 1026 This options takes <b>uint8_t</b> buffer as parameter
dflet 0:50cedd586816 1027 - <b>SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME</b> \n
dflet 0:50cedd586816 1028 Map secured socket to certificate file by name \n
dflet 0:50cedd586816 1029 This options takes <b>uint8_t</b> buffer as parameter
dflet 0:50cedd586816 1030 - <b>SL_SO_SECURE_FILES_DH_KEY_FILE_NAME</b> \n
dflet 0:50cedd586816 1031 Map secured socket to Diffie Hellman file by name \n
dflet 0:50cedd586816 1032 This options takes <b>uint8_t</b> buffer as parameter
dflet 0:50cedd586816 1033 - <b>SL_SO_CHANGE_CHANNEL</b> \n
dflet 0:50cedd586816 1034 Sets channel in transceiver mode.
dflet 0:50cedd586816 1035 This options takes <b>uint32_t</b> as channel number parameter
dflet 0:50cedd586816 1036 - <b>SL_IPPROTO_IP</b>
dflet 0:50cedd586816 1037 - <b>SL_IP_MULTICAST_TTL</b> \n
dflet 0:50cedd586816 1038 Set the time-to-live value of outgoing multicast packets for this socket. \n
dflet 0:50cedd586816 1039 This options takes <b>uint8_t</b> as parameter
dflet 0:50cedd586816 1040 - <b>SL_IP_ADD_MEMBERSHIP</b> \n
dflet 0:50cedd586816 1041 UDP socket, Join a multicast group. \n
dflet 0:50cedd586816 1042 This options takes SlSockIpMreq struct as parameter
dflet 0:50cedd586816 1043 - <b>SL_IP_DROP_MEMBERSHIP</b> \n
dflet 0:50cedd586816 1044 UDP socket, Leave a multicast group \n
dflet 0:50cedd586816 1045 This options takes SlSockIpMreq struct as parameter
dflet 0:50cedd586816 1046 - <b>SL_IP_RAW_RX_NO_HEADER</b> \n
dflet 0:50cedd586816 1047 Raw socket remove IP header from received data. \n
dflet 0:50cedd586816 1048 Default: data includes ip header \n
dflet 0:50cedd586816 1049 This options takes <b>uint32_t</b> as parameter
dflet 0:50cedd586816 1050 - <b>SL_IP_HDRINCL</b> \n
dflet 0:50cedd586816 1051 RAW socket only, the IPv4 layer generates an IP header when sending a packet unless \n
dflet 0:50cedd586816 1052 the IP_HDRINCL socket option is enabled on the socket. \n
dflet 0:50cedd586816 1053 When it is enabled, the packet must contain an IP header. \n
dflet 0:50cedd586816 1054 Default: disabled, IPv4 header generated by Network Stack \n
dflet 0:50cedd586816 1055 This options takes <b>uint32_t</b> as parameter
dflet 0:50cedd586816 1056 - <b>SL_IP_RAW_IPV6_HDRINCL</b> (inactive) \n
dflet 0:50cedd586816 1057 RAW socket only, the IPv6 layer generates an IP header when sending a packet unless \n
dflet 0:50cedd586816 1058 the IP_HDRINCL socket option is enabled on the socket. When it is enabled, the packet must contain an IP header \n
dflet 0:50cedd586816 1059 Default: disabled, IPv4 header generated by Network Stack \n
dflet 0:50cedd586816 1060 This options takes <b>uint32_t</b> as parameter
dflet 0:50cedd586816 1061 - <b>SL_SOL_PHY_OPT</b>
dflet 0:50cedd586816 1062 - <b>SL_SO_PHY_RATE</b> \n
dflet 0:50cedd586816 1063 RAW socket, set WLAN PHY transmit rate \n
dflet 0:50cedd586816 1064 The values are based on RateIndex_e \n
dflet 0:50cedd586816 1065 This options takes <b>uint32_t</b> as parameter
dflet 0:50cedd586816 1066 - <b>SL_SO_PHY_TX_POWER</b> \n
dflet 0:50cedd586816 1067 RAW socket, set WLAN PHY TX power \n
dflet 0:50cedd586816 1068 Valid rage is 1-15 \n
dflet 0:50cedd586816 1069 This options takes <b>uint32_t</b> as parameter
dflet 0:50cedd586816 1070 - <b>SL_SO_PHY_NUM_FRAMES_TO_TX</b> \n
dflet 0:50cedd586816 1071 RAW socket, set number of frames to transmit in transceiver mode.
dflet 0:50cedd586816 1072 Default: 1 packet
dflet 0:50cedd586816 1073 This options takes <b>uint32_t</b> as parameter
dflet 0:50cedd586816 1074 - <b>SL_SO_PHY_PREAMBLE</b> \n
dflet 0:50cedd586816 1075 RAW socket, set WLAN PHY preamble for Long/Short\n
dflet 0:50cedd586816 1076 This options takes <b>uint32_t</b> as parameter
dflet 0:50cedd586816 1077
dflet 0:50cedd586816 1078 \param[in] optval specifies a value for the option
dflet 0:50cedd586816 1079 \param[in] optlen specifies the length of the
dflet 0:50cedd586816 1080 option value
dflet 0:50cedd586816 1081
dflet 0:50cedd586816 1082 \return On success, zero is returned.
dflet 0:50cedd586816 1083 On error, a negative value is returned.
dflet 0:50cedd586816 1084 \sa sl_getsockopt
dflet 0:50cedd586816 1085 \note belongs to \ref basic_api
dflet 0:50cedd586816 1086 \warning
dflet 0:50cedd586816 1087 \par Examples:
dflet 0:50cedd586816 1088 \par
dflet 0:50cedd586816 1089 <b> SL_SO_KEEPALIVE: </b>(disable Keepalive)
dflet 0:50cedd586816 1090 \code
dflet 0:50cedd586816 1091 SlSockKeepalive_t enableOption;
dflet 0:50cedd586816 1092 enableOption.KeepaliveEnabled = 0;
dflet 0:50cedd586816 1093 sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_KEEPALIVE, (uint8_t *)&enableOption,sizeof(enableOption));
dflet 0:50cedd586816 1094 \endcode
dflet 0:50cedd586816 1095 \par
dflet 0:50cedd586816 1096 <b> SL_SO_RCVTIMEO: </b>
dflet 0:50cedd586816 1097 \code
dflet 0:50cedd586816 1098 struct SlTimeval_t timeVal;
dflet 0:50cedd586816 1099 timeVal.tv_sec = 1; // Seconds
dflet 0:50cedd586816 1100 timeVal.tv_usec = 0; // Microseconds. 10000 microseconds resolution
dflet 0:50cedd586816 1101 sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (uint8_t *)&timeVal, sizeof(timeVal)); // Enable receive timeout
dflet 0:50cedd586816 1102 \endcode
dflet 0:50cedd586816 1103 \par
dflet 0:50cedd586816 1104 <b> SL_SO_RCVBUF: </b>
dflet 0:50cedd586816 1105 \code
dflet 0:50cedd586816 1106 SlSockWinsize_t size;
dflet 0:50cedd586816 1107 size.Winsize = 3000; // bytes
dflet 0:50cedd586816 1108 sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_RCVBUF, (uint8_t *)&size, sizeof(size));
dflet 0:50cedd586816 1109 \endcode
dflet 0:50cedd586816 1110 \par
dflet 0:50cedd586816 1111 <b> SL_SO_NONBLOCKING: </b>
dflet 0:50cedd586816 1112 \code
dflet 0:50cedd586816 1113 SlSockNonblocking_t enableOption;
dflet 0:50cedd586816 1114 enableOption.NonblockingEnabled = 1;
dflet 0:50cedd586816 1115 sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_NONBLOCKING, (uint8_t *)&enableOption,sizeof(enableOption)); // Enable/disable nonblocking mode
dflet 0:50cedd586816 1116 \endcode
dflet 0:50cedd586816 1117 \par
dflet 0:50cedd586816 1118 <b> SL_SO_SECMETHOD:</b>
dflet 0:50cedd586816 1119 \code
dflet 0:50cedd586816 1120 SlSockSecureMethod method;
dflet 0:50cedd586816 1121 method.secureMethod = SL_SO_SEC_METHOD_SSLV3; // security method we want to use
dflet 0:50cedd586816 1122 SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
dflet 0:50cedd586816 1123 sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SECMETHOD, (uint8_t *)&method, sizeof(method));
dflet 0:50cedd586816 1124 \endcode
dflet 0:50cedd586816 1125 \par
dflet 0:50cedd586816 1126 <b> SL_SO_SECURE_MASK:</b>
dflet 0:50cedd586816 1127 \code
dflet 0:50cedd586816 1128 SlSockSecureMask cipher;
dflet 0:50cedd586816 1129 cipher.secureMask = SL_SEC_MASK_SSL_RSA_WITH_RC4_128_SHA; // cipher type
dflet 0:50cedd586816 1130 SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, SL_SEC_SOCKET);
dflet 0:50cedd586816 1131 sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_SEC_MASK,(uint8_t *)&cipher, sizeof(cipher));
dflet 0:50cedd586816 1132 \endcode
dflet 0:50cedd586816 1133 \par
dflet 0:50cedd586816 1134 <b> SL_SO_SECURE_FILES_CA_FILE_NAME:</b>
dflet 0:50cedd586816 1135 \code
dflet 0:50cedd586816 1136 sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CA_FILE_NAME,"exuifaxCaCert.der",strlen("exuifaxCaCert.der"));
dflet 0:50cedd586816 1137 \endcode
dflet 0:50cedd586816 1138
dflet 0:50cedd586816 1139 \par
dflet 0:50cedd586816 1140 <b> SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME:</b>
dflet 0:50cedd586816 1141 \code
dflet 0:50cedd586816 1142 sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME,"myPrivateKey.der",strlen("myPrivateKey.der"));
dflet 0:50cedd586816 1143 \endcode
dflet 0:50cedd586816 1144
dflet 0:50cedd586816 1145 \par
dflet 0:50cedd586816 1146 <b> SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME:</b>
dflet 0:50cedd586816 1147 \code
dflet 0:50cedd586816 1148 sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CERTIFICATE_FILE_NAME,"myCertificate.der",strlen("myCertificate.der"));
dflet 0:50cedd586816 1149 \endcode
dflet 0:50cedd586816 1150
dflet 0:50cedd586816 1151 \par
dflet 0:50cedd586816 1152 <b> SL_SO_SECURE_FILES_DH_KEY_FILE_NAME:</b>
dflet 0:50cedd586816 1153 \code
dflet 0:50cedd586816 1154 sl_SetSockOpt(SockID,SL_SOL_SOCKET,SL_SO_SECURE_FILES_DH_KEY_FILE_NAME,"myDHinServerMode.der",strlen("myDHinServerMode.der"));
dflet 0:50cedd586816 1155 \endcode
dflet 0:50cedd586816 1156
dflet 0:50cedd586816 1157 \par
dflet 0:50cedd586816 1158 <b> SL_IP_MULTICAST_TTL:</b>
dflet 0:50cedd586816 1159 \code
dflet 0:50cedd586816 1160 uint8_t ttl = 20;
dflet 0:50cedd586816 1161 sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_MULTICAST_TTL, &ttl, sizeof(ttl));
dflet 0:50cedd586816 1162 \endcode
dflet 0:50cedd586816 1163
dflet 0:50cedd586816 1164 \par
dflet 0:50cedd586816 1165 <b> SL_IP_ADD_MEMBERSHIP:</b>
dflet 0:50cedd586816 1166 \code
dflet 0:50cedd586816 1167 SlSockIpMreq mreq;
dflet 0:50cedd586816 1168 sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq));
dflet 0:50cedd586816 1169 \endcode
dflet 0:50cedd586816 1170
dflet 0:50cedd586816 1171 \par
dflet 0:50cedd586816 1172 <b> SL_IP_DROP_MEMBERSHIP:</b>
dflet 0:50cedd586816 1173 \code
dflet 0:50cedd586816 1174 SlSockIpMreq mreq;
dflet 0:50cedd586816 1175 sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
dflet 0:50cedd586816 1176 \endcode
dflet 0:50cedd586816 1177
dflet 0:50cedd586816 1178 \par
dflet 0:50cedd586816 1179 <b> SL_SO_CHANGE_CHANNEL:</b>
dflet 0:50cedd586816 1180 \code
dflet 0:50cedd586816 1181 uint32_t newChannel = 6; // range is 1-13
dflet 0:50cedd586816 1182 sl_SetSockOpt(SockID, SL_SOL_SOCKET, SL_SO_CHANGE_CHANNEL, &newChannel, sizeof(newChannel));
dflet 0:50cedd586816 1183 \endcode
dflet 0:50cedd586816 1184
dflet 0:50cedd586816 1185 \par
dflet 0:50cedd586816 1186 <b> SL_IP_RAW_RX_NO_HEADER:</b>
dflet 0:50cedd586816 1187 \code
dflet 0:50cedd586816 1188 uint32_t header = 1; // remove ip header
dflet 0:50cedd586816 1189 sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_RX_NO_HEADER, &header, sizeof(header));
dflet 0:50cedd586816 1190 \endcode
dflet 0:50cedd586816 1191
dflet 0:50cedd586816 1192 \par
dflet 0:50cedd586816 1193 <b> SL_IP_HDRINCL:</b>
dflet 0:50cedd586816 1194 \code
dflet 0:50cedd586816 1195 uint32_t header = 1;
dflet 0:50cedd586816 1196 sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_HDRINCL, &header, sizeof(header));
dflet 0:50cedd586816 1197 \endcode
dflet 0:50cedd586816 1198 \par
dflet 0:50cedd586816 1199 <b> SL_IP_RAW_IPV6_HDRINCL:</b>
dflet 0:50cedd586816 1200 \code
dflet 0:50cedd586816 1201 uint32_t header = 1;
dflet 0:50cedd586816 1202 sl_SetSockOpt(SockID, SL_IPPROTO_IP, SL_IP_RAW_IPV6_HDRINCL, &header, sizeof(header));
dflet 0:50cedd586816 1203 \endcode
dflet 0:50cedd586816 1204
dflet 0:50cedd586816 1205 \par
dflet 0:50cedd586816 1206 <b> SL_SO_PHY_RATE:</b>
dflet 0:50cedd586816 1207 \code
dflet 0:50cedd586816 1208 uint32_t rate = 6; // see wlan.h RateIndex_e for values
dflet 0:50cedd586816 1209 sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_RATE, &rate, sizeof(rate));
dflet 0:50cedd586816 1210 \endcode
dflet 0:50cedd586816 1211
dflet 0:50cedd586816 1212 \par
dflet 0:50cedd586816 1213 <b> SL_SO_PHY_TX_POWER:</b>
dflet 0:50cedd586816 1214 \code
dflet 0:50cedd586816 1215 uint32_t txpower = 1; // valid range is 1-15
dflet 0:50cedd586816 1216 sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_TX_POWER, &txpower, sizeof(txpower));
dflet 0:50cedd586816 1217 \endcode
dflet 0:50cedd586816 1218
dflet 0:50cedd586816 1219 \par
dflet 0:50cedd586816 1220 <b> SL_SO_PHY_NUM_FRAMES_TO_TX:</b>
dflet 0:50cedd586816 1221 \code
dflet 0:50cedd586816 1222 uint32_t numframes = 1;
dflet 0:50cedd586816 1223 sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_NUM_FRAMES_TO_TX, &numframes, sizeof(numframes));
dflet 0:50cedd586816 1224 \endcode
dflet 0:50cedd586816 1225
dflet 0:50cedd586816 1226 \par
dflet 0:50cedd586816 1227 <b> SL_SO_PHY_PREAMBLE:</b>
dflet 0:50cedd586816 1228 \code
dflet 0:50cedd586816 1229 uint32_t preamble = 1;
dflet 0:50cedd586816 1230 sl_SetSockOpt(SockID, SL_SOL_PHY_OPT, SL_SO_PHY_PREAMBLE, &preamble, sizeof(preamble));
dflet 0:50cedd586816 1231 \endcode
dflet 0:50cedd586816 1232
dflet 0:50cedd586816 1233 */
dflet 0:50cedd586816 1234 #if _SL_INCLUDE_FUNC(sl_SetSockOpt)
dflet 0:50cedd586816 1235 int16_t sl_SetSockOpt(int16_t sd, int16_t level, int16_t optname, const void *optval, SlSocklen_t optlen);
dflet 0:50cedd586816 1236 #endif
dflet 0:50cedd586816 1237
dflet 0:50cedd586816 1238 /*!
dflet 0:50cedd586816 1239 \brief Get socket options
dflet 0:50cedd586816 1240
dflet 0:50cedd586816 1241 This function manipulate the options associated with a socket.
dflet 0:50cedd586816 1242 Options may exist at multiple protocol levels; they are always
dflet 0:50cedd586816 1243 present at the uppermost socket level.
dflet 0:50cedd586816 1244
dflet 0:50cedd586816 1245 When manipulating socket options the level at which the option resides
dflet 0:50cedd586816 1246 and the name of the option must be specified. To manipulate options at
dflet 0:50cedd586816 1247 the socket level, level is specified as SOL_SOCKET. To manipulate
dflet 0:50cedd586816 1248 options at any other level the protocol number of the appropriate proto-
dflet 0:50cedd586816 1249 col controlling the option is supplied. For example, to indicate that an
dflet 0:50cedd586816 1250 option is to be interpreted by the TCP protocol, level should be set to
dflet 0:50cedd586816 1251 the protocol number of TCP;
dflet 0:50cedd586816 1252
dflet 0:50cedd586816 1253 The parameters optval and optlen are used to access optval -
dflet 0:50cedd586816 1254 ues for setsockopt(). For getsockopt() they identify a
dflet 0:50cedd586816 1255 buffer in which the value for the requested option(s) are to
dflet 0:50cedd586816 1256 be returned. For getsockopt(), optlen is a value-result
dflet 0:50cedd586816 1257 parameter, initially containing the size of the buffer
dflet 0:50cedd586816 1258 pointed to by option_value, and modified on return to
dflet 0:50cedd586816 1259 indicate the actual size of the value returned. If no option
dflet 0:50cedd586816 1260 value is to be supplied or returned, option_value may be
dflet 0:50cedd586816 1261 NULL.
dflet 0:50cedd586816 1262
dflet 0:50cedd586816 1263
dflet 0:50cedd586816 1264 \param[in] sd socket handle
dflet 0:50cedd586816 1265 \param[in] level defines the protocol level for this option
dflet 0:50cedd586816 1266 \param[in] optname defines the option name to interrogate
dflet 0:50cedd586816 1267 \param[out] optval specifies a value for the option
dflet 0:50cedd586816 1268 \param[out] optlen specifies the length of the
dflet 0:50cedd586816 1269 option value
dflet 0:50cedd586816 1270
dflet 0:50cedd586816 1271 \return On success, zero is returned.
dflet 0:50cedd586816 1272 On error, a negative value is returned.
dflet 0:50cedd586816 1273 \sa sl_SetSockOpt
dflet 0:50cedd586816 1274 \note See sl_SetSockOpt
dflet 0:50cedd586816 1275 belongs to \ref ext_api
dflet 0:50cedd586816 1276 \warning
dflet 0:50cedd586816 1277 */
dflet 0:50cedd586816 1278 #if _SL_INCLUDE_FUNC(sl_GetSockOpt)
dflet 0:50cedd586816 1279 int16_t sl_GetSockOpt(int16_t sd, int16_t level, int16_t optname, void *optval, SlSocklen_t *optlen);
dflet 0:50cedd586816 1280 #endif
dflet 0:50cedd586816 1281
dflet 0:50cedd586816 1282 /*!
dflet 0:50cedd586816 1283 \brief read data from TCP socket
dflet 0:50cedd586816 1284
dflet 0:50cedd586816 1285 function receives a message from a connection-mode socket
dflet 0:50cedd586816 1286
dflet 0:50cedd586816 1287 \param[in] sd socket handle
dflet 0:50cedd586816 1288 \param[out] buf Points to the buffer where the
dflet 0:50cedd586816 1289 message should be stored.
dflet 0:50cedd586816 1290 \param[in] Len Specifies the length in bytes of
dflet 0:50cedd586816 1291 the buffer pointed to by the buffer argument.
dflet 0:50cedd586816 1292 Range: 1-16000 bytes
dflet 0:50cedd586816 1293 \param[in] flags Specifies the type of message
dflet 0:50cedd586816 1294 reception. On this version, this parameter is not
dflet 0:50cedd586816 1295 supported.
dflet 0:50cedd586816 1296
dflet 0:50cedd586816 1297 \return return the number of bytes received,
dflet 0:50cedd586816 1298 or a negative value if an error occurred.
dflet 0:50cedd586816 1299 using a non-blocking recv a possible negative value is SL_EAGAIN.
dflet 0:50cedd586816 1300 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 0:50cedd586816 1301 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 0:50cedd586816 1302
dflet 0:50cedd586816 1303 \sa sl_RecvFrom
dflet 0:50cedd586816 1304 \note belongs to \ref recv_api
dflet 0:50cedd586816 1305 \warning
dflet 0:50cedd586816 1306 \par Examples:
dflet 0:50cedd586816 1307 \code An example of receiving data using TCP socket:
dflet 0:50cedd586816 1308
dflet 0:50cedd586816 1309 SlSockAddrIn_t Addr;
dflet 0:50cedd586816 1310 SlSockAddrIn_t LocalAddr;
dflet 0:50cedd586816 1311 int16_t AddrSize = sizeof(SlSockAddrIn_t);
dflet 0:50cedd586816 1312 int16_t SockID, newSockID;
dflet 0:50cedd586816 1313 int16_t Status;
dflet 0:50cedd586816 1314 int8_t Buf[RECV_BUF_LEN];
dflet 0:50cedd586816 1315
dflet 0:50cedd586816 1316 LocalAddr.sin_family = SL_AF_INET;
dflet 0:50cedd586816 1317 LocalAddr.sin_port = sl_Htons(5001);
dflet 0:50cedd586816 1318 LocalAddr.sin_addr.s_addr = 0;
dflet 0:50cedd586816 1319
dflet 0:50cedd586816 1320 Addr.sin_family = SL_AF_INET;
dflet 0:50cedd586816 1321 Addr.sin_port = sl_Htons(5001);
dflet 0:50cedd586816 1322 Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
dflet 0:50cedd586816 1323
dflet 0:50cedd586816 1324 SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
dflet 0:50cedd586816 1325 Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
dflet 0:50cedd586816 1326 Status = sl_Listen(SockID, 0);
dflet 0:50cedd586816 1327 newSockID = sl_Accept(SockID, (SlSockAddr_t*)&Addr, (SlSocklen_t*) &AddrSize);
dflet 0:50cedd586816 1328 Status = sl_Recv(newSockID, Buf, 1460, 0);
dflet 0:50cedd586816 1329 \endcode
dflet 0:50cedd586816 1330 \code Example code for Rx transceiver mode using a raw socket
dflet 0:50cedd586816 1331 int8_t buffer[1536];
dflet 0:50cedd586816 1332 int16_t sd;
dflet 0:50cedd586816 1333 uint16_t size;
dflet 0:50cedd586816 1334 SlTransceiverRxOverHead_t *transHeader;
dflet 0:50cedd586816 1335 sd = sl_Socket(SL_AF_RF,SL_SOCK_RAW,11); // channel 11
dflet 0:50cedd586816 1336 while(1)
dflet 0:50cedd586816 1337 {
dflet 0:50cedd586816 1338 size = sl_Recv(sd,buffer,1536,0);
dflet 0:50cedd586816 1339 transHeader = (SlTransceiverRxOverHead_t *)buffer;
dflet 0:50cedd586816 1340 printf("RSSI is %d frame type is 0x%x size %d\n",transHeader->rssi,buffer[sizeof(SlTransceiverRxOverHead_t)],size);
dflet 0:50cedd586816 1341 }
dflet 0:50cedd586816 1342 \endcode
dflet 0:50cedd586816 1343 */
dflet 0:50cedd586816 1344 #if _SL_INCLUDE_FUNC(sl_Recv)
dflet 0:50cedd586816 1345 int16_t sl_Recv(int16_t sd, void *buf, int16_t Len, int16_t flags);
dflet 0:50cedd586816 1346 #endif
dflet 0:50cedd586816 1347
dflet 0:50cedd586816 1348 /*!
dflet 0:50cedd586816 1349 \brief read data from socket
dflet 0:50cedd586816 1350
dflet 0:50cedd586816 1351 function receives a message from a connection-mode or
dflet 0:50cedd586816 1352 connectionless-mode socket
dflet 0:50cedd586816 1353
dflet 0:50cedd586816 1354 \param[in] sd socket handle
dflet 0:50cedd586816 1355 \param[out] buf Points to the buffer where the message should be stored.
dflet 0:50cedd586816 1356 \param[in] Len Specifies the length in bytes of the buffer pointed to by the buffer argument.
dflet 0:50cedd586816 1357 Range: 1-16000 bytes
dflet 0:50cedd586816 1358 \param[in] flags Specifies the type of message
dflet 0:50cedd586816 1359 reception. On this version, this parameter is not
dflet 0:50cedd586816 1360 supported.
dflet 0:50cedd586816 1361 \param[in] from pointer to an address structure
dflet 0:50cedd586816 1362 indicating the source
dflet 0:50cedd586816 1363 address.\n sockaddr:\n - code
dflet 0:50cedd586816 1364 for the address format. On this
dflet 0:50cedd586816 1365 version only AF_INET is
dflet 0:50cedd586816 1366 supported.\n - socket address,
dflet 0:50cedd586816 1367 the length depends on the code
dflet 0:50cedd586816 1368 format
dflet 0:50cedd586816 1369 \param[in] fromlen source address structure
dflet 0:50cedd586816 1370 size. This parameter MUST be set to the size of the structure pointed to by addr.
dflet 0:50cedd586816 1371
dflet 0:50cedd586816 1372
dflet 0:50cedd586816 1373 \return return the number of bytes received,
dflet 0:50cedd586816 1374 or a negative value if an error occurred.
dflet 0:50cedd586816 1375 using a non-blocking recv a possible negative value is SL_EAGAIN.
dflet 0:50cedd586816 1376 SL_RET_CODE_INVALID_INPUT (-2) will be returned if fromlen has incorrect length.
dflet 0:50cedd586816 1377 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 0:50cedd586816 1378 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 0:50cedd586816 1379
dflet 0:50cedd586816 1380 \sa sl_Recv
dflet 0:50cedd586816 1381 \note belongs to \ref recv_api
dflet 0:50cedd586816 1382 \warning
dflet 0:50cedd586816 1383 \par Example:
dflet 0:50cedd586816 1384 \code An example of receiving data:
dflet 0:50cedd586816 1385
dflet 0:50cedd586816 1386 SlSockAddrIn_t Addr;
dflet 0:50cedd586816 1387 SlSockAddrIn_t LocalAddr;
dflet 0:50cedd586816 1388 int16_t AddrSize = sizeof(SlSockAddrIn_t);
dflet 0:50cedd586816 1389 int16_t SockID;
dflet 0:50cedd586816 1390 int16_t Status;
dflet 0:50cedd586816 1391 int8_t Buf[RECV_BUF_LEN];
dflet 0:50cedd586816 1392
dflet 0:50cedd586816 1393 LocalAddr.sin_family = SL_AF_INET;
dflet 0:50cedd586816 1394 LocalAddr.sin_port = sl_Htons(5001);
dflet 0:50cedd586816 1395 LocalAddr.sin_addr.s_addr = 0;
dflet 0:50cedd586816 1396
dflet 0:50cedd586816 1397 SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
dflet 0:50cedd586816 1398 Status = sl_Bind(SockID, (SlSockAddr_t *)&LocalAddr, AddrSize);
dflet 0:50cedd586816 1399 Status = sl_RecvFrom(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, (SlSocklen_t*)&AddrSize);
dflet 0:50cedd586816 1400
dflet 0:50cedd586816 1401 \endcode
dflet 0:50cedd586816 1402 */
dflet 0:50cedd586816 1403 #if _SL_INCLUDE_FUNC(sl_RecvFrom)
dflet 0:50cedd586816 1404 int16_t sl_RecvFrom(int16_t sd, void *buf, int16_t Len, int16_t flags, SlSockAddr_t *from, SlSocklen_t *fromlen);
dflet 0:50cedd586816 1405 #endif
dflet 0:50cedd586816 1406
dflet 0:50cedd586816 1407 /*!
dflet 0:50cedd586816 1408 \brief write data to TCP socket
dflet 0:50cedd586816 1409
dflet 0:50cedd586816 1410 This function is used to transmit a message to another socket.
dflet 0:50cedd586816 1411 Returns immediately after sending data to device.
dflet 0:50cedd586816 1412 In case of TCP failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
dflet 0:50cedd586816 1413 be received.
dflet 0:50cedd586816 1414 In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the
dflet 0:50cedd586816 1415 frame data buffer for WLAN FCS
dflet 0:50cedd586816 1416
dflet 0:50cedd586816 1417 \param[in] sd socket handle
dflet 0:50cedd586816 1418 \param[in] buf Points to a buffer containing
dflet 0:50cedd586816 1419 the message to be sent
dflet 0:50cedd586816 1420 \param[in] Len message size in bytes. Range: 1-1460 bytes
dflet 0:50cedd586816 1421 \param[in] flags Specifies the type of message
dflet 0:50cedd586816 1422 transmission. On this version, this parameter is not
dflet 0:50cedd586816 1423 supported for TCP.
dflet 0:50cedd586816 1424 For transceiver mode, the SL_RAW_RF_TX_PARAMS macro can be used to determine
dflet 0:50cedd586816 1425 transmission parameters (channel,rate,tx_power,preamble)
dflet 0:50cedd586816 1426
dflet 0:50cedd586816 1427
dflet 0:50cedd586816 1428 \return Return the number of bytes transmitted,
dflet 0:50cedd586816 1429 or -1 if an error occurred
dflet 0:50cedd586816 1430
dflet 0:50cedd586816 1431 \sa sl_SendTo
dflet 0:50cedd586816 1432 \note belongs to \ref send_api
dflet 0:50cedd586816 1433 \warning
dflet 0:50cedd586816 1434 \par Example:
dflet 0:50cedd586816 1435 \code An example of sending data:
dflet 0:50cedd586816 1436
dflet 0:50cedd586816 1437 SlSockAddrIn_t Addr;
dflet 0:50cedd586816 1438 int16_t AddrSize = sizeof(SlSockAddrIn_t);
dflet 0:50cedd586816 1439 int16_t SockID;
dflet 0:50cedd586816 1440 int16_t Status;
dflet 0:50cedd586816 1441 int8_t Buf[SEND_BUF_LEN];
dflet 0:50cedd586816 1442
dflet 0:50cedd586816 1443 Addr.sin_family = SL_AF_INET;
dflet 0:50cedd586816 1444 Addr.sin_port = sl_Htons(5001);
dflet 0:50cedd586816 1445 Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
dflet 0:50cedd586816 1446
dflet 0:50cedd586816 1447 SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
dflet 0:50cedd586816 1448 Status = sl_Connect(SockID, (SlSockAddr_t *)&Addr, AddrSize);
dflet 0:50cedd586816 1449 Status = sl_Send(SockID, Buf, 1460, 0 );
dflet 0:50cedd586816 1450
dflet 0:50cedd586816 1451 \endcode
dflet 0:50cedd586816 1452 */
dflet 0:50cedd586816 1453 #if _SL_INCLUDE_FUNC(sl_Send )
dflet 0:50cedd586816 1454 int16_t sl_Send(int16_t sd, const void *buf, int16_t Len, int16_t flags);
dflet 0:50cedd586816 1455 #endif
dflet 0:50cedd586816 1456
dflet 0:50cedd586816 1457 /*!
dflet 0:50cedd586816 1458 \brief write data to socket
dflet 0:50cedd586816 1459
dflet 0:50cedd586816 1460 This function is used to transmit a message to another socket
dflet 0:50cedd586816 1461 (connection less socket SOCK_DGRAM, SOCK_RAW).
dflet 0:50cedd586816 1462 Returns immediately after sending data to device.
dflet 0:50cedd586816 1463 In case of transmission failure an async event SL_SOCKET_TX_FAILED_EVENT is going to
dflet 0:50cedd586816 1464 be received.
dflet 0:50cedd586816 1465
dflet 0:50cedd586816 1466 \param[in] sd socket handle
dflet 0:50cedd586816 1467 \param[in] buf Points to a buffer containing
dflet 0:50cedd586816 1468 the message to be sent
dflet 0:50cedd586816 1469 \param[in] Len message size in bytes. Range: 1-1460 bytes
dflet 0:50cedd586816 1470 \param[in] flags Specifies the type of message
dflet 0:50cedd586816 1471 transmission. On this version, this parameter is not
dflet 0:50cedd586816 1472 supported
dflet 0:50cedd586816 1473 \param[in] to pointer to an address structure
dflet 0:50cedd586816 1474 indicating the destination
dflet 0:50cedd586816 1475 address.\n sockaddr:\n - code
dflet 0:50cedd586816 1476 for the address format. On this
dflet 0:50cedd586816 1477 version only AF_INET is
dflet 0:50cedd586816 1478 supported.\n - socket address,
dflet 0:50cedd586816 1479 the length depends on the code
dflet 0:50cedd586816 1480 format
dflet 0:50cedd586816 1481 \param[in] tolen destination address structure size
dflet 0:50cedd586816 1482
dflet 0:50cedd586816 1483 \return Return the number of transmitted bytes,
dflet 0:50cedd586816 1484 or -1 if an error occurred
dflet 0:50cedd586816 1485
dflet 0:50cedd586816 1486 \sa sl_Send
dflet 0:50cedd586816 1487 \note belongs to \ref send_api
dflet 0:50cedd586816 1488 \warning
dflet 0:50cedd586816 1489 \par Example:
dflet 0:50cedd586816 1490 \code An example of sending data:
dflet 0:50cedd586816 1491
dflet 0:50cedd586816 1492 SlSockAddrIn_t Addr;
dflet 0:50cedd586816 1493 int16_t AddrSize = sizeof(SlSockAddrIn_t);
dflet 0:50cedd586816 1494 int16_t SockID;
dflet 0:50cedd586816 1495 int16_t Status;
dflet 0:50cedd586816 1496 int8_t Buf[SEND_BUF_LEN];
dflet 0:50cedd586816 1497
dflet 0:50cedd586816 1498 Addr.sin_family = SL_AF_INET;
dflet 0:50cedd586816 1499 Addr.sin_port = sl_Htons(5001);
dflet 0:50cedd586816 1500 Addr.sin_addr.s_addr = sl_Htonl(SL_IPV4_VAL(10,1,1,200));
dflet 0:50cedd586816 1501
dflet 0:50cedd586816 1502 SockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0);
dflet 0:50cedd586816 1503 Status = sl_SendTo(SockID, Buf, 1472, 0, (SlSockAddr_t *)&Addr, AddrSize);
dflet 0:50cedd586816 1504
dflet 0:50cedd586816 1505 \endcode
dflet 0:50cedd586816 1506 */
dflet 0:50cedd586816 1507 #if _SL_INCLUDE_FUNC(sl_SendTo)
dflet 0:50cedd586816 1508 int16_t sl_SendTo(int16_t sd, const void *buf, int16_t Len, int16_t flags, const SlSockAddr_t *to, SlSocklen_t tolen);
dflet 0:50cedd586816 1509 #endif
dflet 0:50cedd586816 1510
dflet 0:50cedd586816 1511 /*!
dflet 0:50cedd586816 1512 \brief Reorder the bytes of a 32-bit unsigned value
dflet 0:50cedd586816 1513
dflet 0:50cedd586816 1514 This function is used to Reorder the bytes of a 32-bit unsigned value from processor order to network order.
dflet 0:50cedd586816 1515
dflet 0:50cedd586816 1516 \param[in] var variable to reorder
dflet 0:50cedd586816 1517
dflet 0:50cedd586816 1518 \return Return the reorder variable,
dflet 0:50cedd586816 1519
dflet 0:50cedd586816 1520 \sa sl_SendTo sl_Bind sl_Connect sl_RecvFrom sl_Accept
dflet 0:50cedd586816 1521 \note belongs to \ref send_api
dflet 0:50cedd586816 1522 \warning
dflet 0:50cedd586816 1523 */
dflet 0:50cedd586816 1524 #if _SL_INCLUDE_FUNC(sl_Htonl )
dflet 0:50cedd586816 1525 uint32_t sl_Htonl( uint32_t val );
dflet 0:50cedd586816 1526
dflet 0:50cedd586816 1527 #define sl_Ntohl sl_Htonl /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
dflet 0:50cedd586816 1528 #endif
dflet 0:50cedd586816 1529
dflet 0:50cedd586816 1530 /*!
dflet 0:50cedd586816 1531 \brief Reorder the bytes of a 16-bit unsigned value
dflet 0:50cedd586816 1532
dflet 0:50cedd586816 1533 This function is used to Reorder the bytes of a 16-bit unsigned value from processor order to network order.
dflet 0:50cedd586816 1534
dflet 0:50cedd586816 1535 \param[in] var variable to reorder
dflet 0:50cedd586816 1536
dflet 0:50cedd586816 1537 \return Return the reorder variable,
dflet 0:50cedd586816 1538
dflet 0:50cedd586816 1539 \sa sl_SendTo sl_Bind sl_Connect sl_RecvFrom sl_Accept
dflet 0:50cedd586816 1540 \note belongs to \ref send_api
dflet 0:50cedd586816 1541 \warning
dflet 0:50cedd586816 1542 */
dflet 0:50cedd586816 1543 #if _SL_INCLUDE_FUNC(sl_Htons )
dflet 0:50cedd586816 1544 uint16_t sl_Htons( uint16_t val );
dflet 0:50cedd586816 1545
dflet 0:50cedd586816 1546 #define sl_Ntohs sl_Htons /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */
dflet 0:50cedd586816 1547 #endif
dflet 0:50cedd586816 1548
dflet 0:50cedd586816 1549 private:
dflet 0:50cedd586816 1550
dflet 0:50cedd586816 1551 cc3100_driver &_driver;
dflet 0:50cedd586816 1552 #ifndef SL_PLATFORM_MULTI_THREADED
dflet 0:50cedd586816 1553 cc3100_nonos &_nonos;
dflet 0:50cedd586816 1554 #endif
dflet 0:50cedd586816 1555
dflet 0:50cedd586816 1556 };//class
dflet 0:50cedd586816 1557
dflet 0:50cedd586816 1558
dflet 0:50cedd586816 1559 }//namespace mbed_cc3100
dflet 0:50cedd586816 1560
dflet 0:50cedd586816 1561 /*!
dflet 0:50cedd586816 1562
dflet 0:50cedd586816 1563 Close the Doxygen group.
dflet 0:50cedd586816 1564 @}
dflet 0:50cedd586816 1565
dflet 0:50cedd586816 1566 */
dflet 0:50cedd586816 1567
dflet 0:50cedd586816 1568 #endif /* __SOCKET_H__ */
dflet 0:50cedd586816 1569
dflet 0:50cedd586816 1570
dflet 0:50cedd586816 1571