DeepCover Embedded Security in IoT: Public-key Secured Data Paths

Dependencies:   MaximInterface

The MAXREFDES155# is an internet-of-things (IoT) embedded-security reference design, built to authenticate and control a sensing node using elliptic-curve-based public-key cryptography with control and notification from a web server.

The hardware includes an ARM® mbed™ shield and attached sensor endpoint. The shield contains a DS2476 DeepCover® ECDSA/SHA-2 coprocessor, Wifi communication, LCD push-button controls, and status LEDs. The sensor endpoint is attached to the shield using a 300mm cable and contains a DS28C36 DeepCover ECDSA/SHA-2 authenticator, IR-thermal sensor, and aiming laser for the IR sensor. The MAXREFDES155# is equipped with a standard Arduino® form-factor shield connector for immediate testing using an mbed board such as the MAX32600MBED#. The combination of these two devices represent an IoT device. Communication to the web server is accomplished with the shield Wifi circuitry. Communication from the shield to the attached sensor module is accomplished over I2C . The sensor module represents an IoT endpoint that generates small data with a requirement for message authenticity/integrity and secure on/off operational control.

The design is hierarchical with each mbed platform and shield communicating data from the sensor node to a web server that maintains a centralized log and dispatches notifications as necessary. The simplicity of this design enables rapid integration into any star-topology IoT network to provide security with the low overhead and cost provided by the ECDSA-P256 asymmetric-key and SHA-256 symmetric-key algorithms.

More information about the MAXREFDES155# is available on the Maxim Integrated website.

Committer:
IanBenzMaxim
Date:
Fri Feb 24 11:23:12 2017 -0600
Revision:
0:33d4e66780c0
Initial commit.

Who changed what in which revision?

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