Driver for CC3000 Wi-Fi module

Dependencies:   NVIC_set_all_priorities

Dependents:   CC3000_Simple_Socket Wi-Go_IOT_Demo

Information

The current code has been reworked to a full object oriented application and contains an mbed socket compatible API.

CC3000 Wi-Fi module library

Info

This is the low level driver for TI's SimpleLink CC3000 device.
Port from Avnet's Wi-Go KEIL code (based on TI's CC3000 code).
Special thanks to Jim Carver from Avnet for providing the Wi-Go board and for his assistance.

Differences with TI's original code

The code functionality stays exactly the same.
In order to make it easier to use the code, following changes were made :

  • Addition of a tool to shift all IRQ priorities to a lower level since it is very important to keep the SPI handler at the highest system priority, the WLAN interrupt the second highest and all other system interrupts at a lower priority, so their handlers can be preempted by the CC3000 interrupts.
  • Addition of low level I/O controls and conditional compiler controls in cc3000_common.h.
  • CC3000 initialisation, pin declarations, SPI and WLAN irq priorities are set in Init_HostDriver , we need to call this function at the start of the main function.
  • The SPI and HCI code are joined into one file.
  • The include list has been rearranged - Only #include "wlan.h" is needed in the user API.
  • Part of the CC3000's user eeprom memory is used to store additional info (52 bytes in NVMEM_USER_FILE_1):
# bytesDescriptionInfo
1First time config parameterUseful when connecting
2Firmware updater versionused with the Firmware update tool
2Service Pack versionused with the Firmware update tool
3Driver Versionused with the Firmware update tool
3Firmware Versionused with the Firmware update tool
1CIK validation (Client Interface Key)
40CIK data (Client Interface Key)used with the exosite

Using the Library

A user API is needed to access the CC3000 functions.
Examples:

Using the library with other processors

cc3000_common.cpp loads the irq tool for all targets:
All current mbed targets are supported by this library.

#include "NVIC_set_all_priorities.h"


All low level settings that need to change are available in cc3000_common.h

//*****************************************************************************
//              PIN CONTROLS & COMPILE CONTROLS
//*****************************************************************************
// Compiler control
#define CC3000_UNENCRYPTED_SMART_CONFIG   // No encryption
//#define CC3000_TINY_DRIVER                // Driver for small memory model CPUs

//Interrupt controls
#define NVIC_ALL_IRQ        NVIC_set_all_irq_priorities(3);         // Set ALL interrupt priorities to level 3
#define NVIC_SPI_IRQ        NVIC_SetPriority(SPI0_IRQn, 0x0);       // Wi-Fi SPI interrupt must be higher priority than SysTick
#define NVIC_PORT_IRQ       NVIC_SetPriority(PORTA_IRQn, 0x1);
#define NVIC_SYSTICK_IRQ    NVIC_SetPriority(SysTick_IRQn, 0x2);    // SysTick set to lower priority than Wi-Fi SPI bus interrupt
//#define NVIC_ADC_IRQ        NVIC_SetPriority(ADC0_IRQn, 0x3);       // ADC is the lowest of all

// Wlan controls
#define WLAN_ISF_PCR        PORTA->PCR[16]
#define WLAN_ISF_ISFR       PORTA->ISFR
#define WLAN_ISF_MASK       (1<<16)

#define WLAN_ASSERT_CS      wlan_cs = 0;   //CS : active low
#define WLAN_DEASSERT_CS    wlan_cs = 1;

#define WLAN_ASSERT_EN      wlan_en = 1;   //EN : active high
#define WLAN_DEASSERT_EN    wlan_en = 0;

#define WLAN_READ_IRQ       wlan_int

#define WLAN_ENABLE_IRQ     wlan_int.fall(&WLAN_IRQHandler);
#define WLAN_DISABLE_IRQ    wlan_int.fall(NULL);

#define WLAN_IRQ_PIN_CREATE         InterruptIn wlan_int (PTA16);
#define WLAN_EN_PIN_CREATE          DigitalOut  wlan_en  (PTA13);
#define WLAN_CS_PIN_CREATE          DigitalOut  wlan_cs  (PTD0);
#define WLAN_SPI_PORT_CREATE        SPI wlan(PTD2, PTD3, PTC5); // mosi, miso, sclk

#define WLAN_SPI_PORT_INIT          wlan.format(8,1);
#define WLAN_SPI_SET_FREQ           wlan.frequency(12000000);
#define WLAN_SPI_SET_IRQ_HANDLER    wlan_int.fall(&WLAN_IRQHandler);

#define WLAN_SPI_WRITE              wlan.write(*data++);
#define WLAN_SPI_READ               wlan.write(0x03);          // !! DO NOT MODIFY the 0x03 parameter (CC3000 will not respond).

API documentation

Due to a little problem with the links on the mbed site, the API documentation is not directly accessible (will be solved in a next release).
Currently, it is only accessible by adding modules.html to the API doc link: http://mbed.org/users/frankvnk/code/CC3000_Hostdriver/docs/tip/modules.html

Committer:
frankvnk
Date:
Fri Jun 28 17:48:37 2013 +0000
Revision:
0:c44f0314d6ec
Child:
4:d8255a5aad46
Initial release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
frankvnk 0:c44f0314d6ec 1 /*****************************************************************************
frankvnk 0:c44f0314d6ec 2 *
frankvnk 0:c44f0314d6ec 3 * socket.h - CC3000 Host Driver Implementation.
frankvnk 0:c44f0314d6ec 4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
frankvnk 0:c44f0314d6ec 5 *
frankvnk 0:c44f0314d6ec 6 * Redistribution and use in source and binary forms, with or without
frankvnk 0:c44f0314d6ec 7 * modification, are permitted provided that the following conditions
frankvnk 0:c44f0314d6ec 8 * are met:
frankvnk 0:c44f0314d6ec 9 *
frankvnk 0:c44f0314d6ec 10 * Redistributions of source code must retain the above copyright
frankvnk 0:c44f0314d6ec 11 * notice, this list of conditions and the following disclaimer.
frankvnk 0:c44f0314d6ec 12 *
frankvnk 0:c44f0314d6ec 13 * Redistributions in binary form must reproduce the above copyright
frankvnk 0:c44f0314d6ec 14 * notice, this list of conditions and the following disclaimer in the
frankvnk 0:c44f0314d6ec 15 * documentation and/or other materials provided with the
frankvnk 0:c44f0314d6ec 16 * distribution.
frankvnk 0:c44f0314d6ec 17 *
frankvnk 0:c44f0314d6ec 18 * Neither the name of Texas Instruments Incorporated nor the names of
frankvnk 0:c44f0314d6ec 19 * its contributors may be used to endorse or promote products derived
frankvnk 0:c44f0314d6ec 20 * from this software without specific prior written permission.
frankvnk 0:c44f0314d6ec 21 *
frankvnk 0:c44f0314d6ec 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
frankvnk 0:c44f0314d6ec 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
frankvnk 0:c44f0314d6ec 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
frankvnk 0:c44f0314d6ec 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
frankvnk 0:c44f0314d6ec 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
frankvnk 0:c44f0314d6ec 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
frankvnk 0:c44f0314d6ec 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
frankvnk 0:c44f0314d6ec 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
frankvnk 0:c44f0314d6ec 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
frankvnk 0:c44f0314d6ec 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
frankvnk 0:c44f0314d6ec 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
frankvnk 0:c44f0314d6ec 33 *
frankvnk 0:c44f0314d6ec 34 *****************************************************************************/
frankvnk 0:c44f0314d6ec 35 #ifndef __SOCKET_H__
frankvnk 0:c44f0314d6ec 36 #define __SOCKET_H__
frankvnk 0:c44f0314d6ec 37
frankvnk 0:c44f0314d6ec 38 //#include "mbed.h"
frankvnk 0:c44f0314d6ec 39 #include "GlobalAssigns.h"
frankvnk 0:c44f0314d6ec 40 /** CC3000 Host driver - Socket API
frankvnk 0:c44f0314d6ec 41 *
frankvnk 0:c44f0314d6ec 42 */
frankvnk 0:c44f0314d6ec 43 //*****************************************************************************
frankvnk 0:c44f0314d6ec 44 //
frankvnk 0:c44f0314d6ec 45 //! \addtogroup socket_api
frankvnk 0:c44f0314d6ec 46 //! @{
frankvnk 0:c44f0314d6ec 47 //
frankvnk 0:c44f0314d6ec 48 //*****************************************************************************
frankvnk 0:c44f0314d6ec 49
frankvnk 0:c44f0314d6ec 50
frankvnk 0:c44f0314d6ec 51 //*****************************************************************************
frankvnk 0:c44f0314d6ec 52 //
frankvnk 0:c44f0314d6ec 53 // If building with a C++ compiler, make all of the definitions in this header
frankvnk 0:c44f0314d6ec 54 // have a C binding.
frankvnk 0:c44f0314d6ec 55 //
frankvnk 0:c44f0314d6ec 56 //*****************************************************************************
frankvnk 0:c44f0314d6ec 57 #ifdef __cplusplus
frankvnk 0:c44f0314d6ec 58 extern "C" {
frankvnk 0:c44f0314d6ec 59 #endif
frankvnk 0:c44f0314d6ec 60
frankvnk 0:c44f0314d6ec 61 #define HOSTNAME_MAX_LENGTH (230) // 230 bytes + header shouldn't exceed 8 bit value
frankvnk 0:c44f0314d6ec 62
frankvnk 0:c44f0314d6ec 63 //--------- Address Families --------
frankvnk 0:c44f0314d6ec 64
frankvnk 0:c44f0314d6ec 65 #define AF_INET 2
frankvnk 0:c44f0314d6ec 66 #define AF_INET6 23
frankvnk 0:c44f0314d6ec 67
frankvnk 0:c44f0314d6ec 68 //------------ Socket Types ------------
frankvnk 0:c44f0314d6ec 69
frankvnk 0:c44f0314d6ec 70 #define SOCK_STREAM 1
frankvnk 0:c44f0314d6ec 71 #define SOCK_DGRAM 2
frankvnk 0:c44f0314d6ec 72 #define SOCK_RAW 3 // Raw sockets allow new IPv4 protocols to be implemented in user space. A raw socket receives or sends the raw datagram not including link level headers
frankvnk 0:c44f0314d6ec 73 #define SOCK_RDM 4
frankvnk 0:c44f0314d6ec 74 #define SOCK_SEQPACKET 5
frankvnk 0:c44f0314d6ec 75
frankvnk 0:c44f0314d6ec 76 //----------- Socket Protocol ----------
frankvnk 0:c44f0314d6ec 77
frankvnk 0:c44f0314d6ec 78 #define IPPROTO_IP 0 // dummy for IP
frankvnk 0:c44f0314d6ec 79 #define IPPROTO_ICMP 1 // control message protocol
frankvnk 0:c44f0314d6ec 80 #define IPPROTO_IPV4 IPPROTO_IP // IP inside IP
frankvnk 0:c44f0314d6ec 81 #define IPPROTO_TCP 6 // tcp
frankvnk 0:c44f0314d6ec 82 #define IPPROTO_UDP 17 // user datagram protocol
frankvnk 0:c44f0314d6ec 83 #define IPPROTO_IPV6 41 // IPv6 in IPv6
frankvnk 0:c44f0314d6ec 84 #define IPPROTO_NONE 59 // No next header
frankvnk 0:c44f0314d6ec 85 #define IPPROTO_RAW 255 // raw IP packet
frankvnk 0:c44f0314d6ec 86 #define IPPROTO_MAX 256
frankvnk 0:c44f0314d6ec 87
frankvnk 0:c44f0314d6ec 88 //----------- Socket retunr codes -----------
frankvnk 0:c44f0314d6ec 89
frankvnk 0:c44f0314d6ec 90 #define SOC_ERROR (-1) // error
frankvnk 0:c44f0314d6ec 91 #define SOC_IN_PROGRESS (-2) // socket in progress
frankvnk 0:c44f0314d6ec 92
frankvnk 0:c44f0314d6ec 93 //----------- Socket Options -----------
frankvnk 0:c44f0314d6ec 94 #define SOL_SOCKET 0xffff // socket level
frankvnk 0:c44f0314d6ec 95 #define SOCKOPT_RECV_TIMEOUT 1 // optname to configure recv and recvfromtimeout
frankvnk 0:c44f0314d6ec 96 #define SOCKOPT_NONBLOCK 2 // accept non block mode set SOCK_ON or SOCK_OFF (default block mode )
frankvnk 0:c44f0314d6ec 97 #define SOCK_ON 0 // socket non-blocking mode is enabled
frankvnk 0:c44f0314d6ec 98 #define SOCK_OFF 1 // socket blocking mode is enabled
frankvnk 0:c44f0314d6ec 99
frankvnk 0:c44f0314d6ec 100 #define TCP_NODELAY 0x0001
frankvnk 0:c44f0314d6ec 101 #define TCP_BSDURGENT 0x7000
frankvnk 0:c44f0314d6ec 102
frankvnk 0:c44f0314d6ec 103 #define MAX_PACKET_SIZE 1500
frankvnk 0:c44f0314d6ec 104 #define MAX_LISTEN_QUEUE 4
frankvnk 0:c44f0314d6ec 105
frankvnk 0:c44f0314d6ec 106 #define IOCTL_SOCKET_EVENTMASK
frankvnk 0:c44f0314d6ec 107
frankvnk 0:c44f0314d6ec 108 #define ENOBUFS 55 // No buffer space available
frankvnk 0:c44f0314d6ec 109
frankvnk 0:c44f0314d6ec 110 #define __FD_SETSIZE 32
frankvnk 0:c44f0314d6ec 111
frankvnk 0:c44f0314d6ec 112 #define ASIC_ADDR_LEN 8
frankvnk 0:c44f0314d6ec 113
frankvnk 0:c44f0314d6ec 114 #define NO_QUERY_RECIVED -3
frankvnk 0:c44f0314d6ec 115
frankvnk 0:c44f0314d6ec 116
frankvnk 0:c44f0314d6ec 117 typedef struct _in_addr_t
frankvnk 0:c44f0314d6ec 118 {
frankvnk 0:c44f0314d6ec 119 unsigned long s_addr; // load with inet_aton()
frankvnk 0:c44f0314d6ec 120 } in_addr;
frankvnk 0:c44f0314d6ec 121
frankvnk 0:c44f0314d6ec 122 typedef struct _sockaddr_t
frankvnk 0:c44f0314d6ec 123 {
frankvnk 0:c44f0314d6ec 124 unsigned short int sa_family;
frankvnk 0:c44f0314d6ec 125 unsigned char sa_data[14];
frankvnk 0:c44f0314d6ec 126 } sockaddr;
frankvnk 0:c44f0314d6ec 127
frankvnk 0:c44f0314d6ec 128 typedef struct _sockaddr_in_t
frankvnk 0:c44f0314d6ec 129 {
frankvnk 0:c44f0314d6ec 130 short sin_family; // e.g. AF_INET
frankvnk 0:c44f0314d6ec 131 unsigned short sin_port; // e.g. htons(3490)
frankvnk 0:c44f0314d6ec 132 in_addr sin_addr; // see struct in_addr, below
frankvnk 0:c44f0314d6ec 133 char sin_zero[8]; // zero this if you want to
frankvnk 0:c44f0314d6ec 134 } sockaddr_in;
frankvnk 0:c44f0314d6ec 135
frankvnk 0:c44f0314d6ec 136 typedef unsigned long socklen_t;
frankvnk 0:c44f0314d6ec 137
frankvnk 0:c44f0314d6ec 138 // The fd_set member is required to be an array of longs.
frankvnk 0:c44f0314d6ec 139 typedef long int __fd_mask;
frankvnk 0:c44f0314d6ec 140
frankvnk 0:c44f0314d6ec 141 // It's easier to assume 8-bit bytes than to get CHAR_BIT.
frankvnk 0:c44f0314d6ec 142 #define __NFDBITS (8 * sizeof (__fd_mask))
frankvnk 0:c44f0314d6ec 143 #define __FDELT(d) ((d) / __NFDBITS)
frankvnk 0:c44f0314d6ec 144 #define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))
frankvnk 0:c44f0314d6ec 145
frankvnk 0:c44f0314d6ec 146 // fd_set for select and pselect.
frankvnk 0:c44f0314d6ec 147 typedef struct
frankvnk 0:c44f0314d6ec 148 {
frankvnk 0:c44f0314d6ec 149 __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
frankvnk 0:c44f0314d6ec 150 #define __FDS_BITS(set) ((set)->fds_bits)
frankvnk 0:c44f0314d6ec 151 } fd_set;
frankvnk 0:c44f0314d6ec 152
frankvnk 0:c44f0314d6ec 153 // We don't use `memset' because this would require a prototype and
frankvnk 0:c44f0314d6ec 154 // the array isn't too big.
frankvnk 0:c44f0314d6ec 155 #define __FD_ZERO(set) \
frankvnk 0:c44f0314d6ec 156 do { \
frankvnk 0:c44f0314d6ec 157 unsigned int __i; \
frankvnk 0:c44f0314d6ec 158 fd_set *__arr = (set); \
frankvnk 0:c44f0314d6ec 159 for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
frankvnk 0:c44f0314d6ec 160 __FDS_BITS (__arr)[__i] = 0; \
frankvnk 0:c44f0314d6ec 161 } while (0)
frankvnk 0:c44f0314d6ec 162 #define __FD_SET(d, set) (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
frankvnk 0:c44f0314d6ec 163 #define __FD_CLR(d, set) (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d))
frankvnk 0:c44f0314d6ec 164 #define __FD_ISSET(d, set) (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d))
frankvnk 0:c44f0314d6ec 165
frankvnk 0:c44f0314d6ec 166 // Access macros for 'fd_set'.
frankvnk 0:c44f0314d6ec 167 #define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
frankvnk 0:c44f0314d6ec 168 #define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
frankvnk 0:c44f0314d6ec 169 #define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
frankvnk 0:c44f0314d6ec 170 #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
frankvnk 0:c44f0314d6ec 171
frankvnk 0:c44f0314d6ec 172 //Use in case of Big Endian only
frankvnk 0:c44f0314d6ec 173
frankvnk 0:c44f0314d6ec 174 #define htonl(A) ((((unsigned long)(A) & 0xff000000) >> 24) | \
frankvnk 0:c44f0314d6ec 175 (((unsigned long)(A) & 0x00ff0000) >> 8) | \
frankvnk 0:c44f0314d6ec 176 (((unsigned long)(A) & 0x0000ff00) << 8) | \
frankvnk 0:c44f0314d6ec 177 (((unsigned long)(A) & 0x000000ff) << 24))
frankvnk 0:c44f0314d6ec 178
frankvnk 0:c44f0314d6ec 179 #define ntohl htonl
frankvnk 0:c44f0314d6ec 180
frankvnk 0:c44f0314d6ec 181 //Use in case of Big Endian only
frankvnk 0:c44f0314d6ec 182 #define htons(A) ((((unsigned long)(A) & 0xff00) >> 8) | \
frankvnk 0:c44f0314d6ec 183 (((unsigned long)(A) & 0x00ff) << 8))
frankvnk 0:c44f0314d6ec 184
frankvnk 0:c44f0314d6ec 185
frankvnk 0:c44f0314d6ec 186 #define ntohs htons
frankvnk 0:c44f0314d6ec 187
frankvnk 0:c44f0314d6ec 188 // mDNS port - 5353 mDNS multicast address - 224.0.0.251
frankvnk 0:c44f0314d6ec 189 #define SET_mDNS_ADD(sockaddr) sockaddr.sa_data[0] = 0x14; \
frankvnk 0:c44f0314d6ec 190 sockaddr.sa_data[1] = 0xe9; \
frankvnk 0:c44f0314d6ec 191 sockaddr.sa_data[2] = 0xe0; \
frankvnk 0:c44f0314d6ec 192 sockaddr.sa_data[3] = 0x0; \
frankvnk 0:c44f0314d6ec 193 sockaddr.sa_data[4] = 0x0; \
frankvnk 0:c44f0314d6ec 194 sockaddr.sa_data[5] = 0xfb;
frankvnk 0:c44f0314d6ec 195
frankvnk 0:c44f0314d6ec 196
frankvnk 0:c44f0314d6ec 197 //*****************************************************************************
frankvnk 0:c44f0314d6ec 198 //
frankvnk 0:c44f0314d6ec 199 // Prototypes for the APIs.
frankvnk 0:c44f0314d6ec 200 //
frankvnk 0:c44f0314d6ec 201 //*****************************************************************************
frankvnk 0:c44f0314d6ec 202
frankvnk 0:c44f0314d6ec 203 //*****************************************************************************
frankvnk 0:c44f0314d6ec 204 //
frankvnk 0:c44f0314d6ec 205 //! socket
frankvnk 0:c44f0314d6ec 206 //!
frankvnk 0:c44f0314d6ec 207 //! @param domain selects the protocol family which will be used for
frankvnk 0:c44f0314d6ec 208 //! communication. On this version only AF_INET is supported
frankvnk 0:c44f0314d6ec 209 //! @param type specifies the communication semantics. On this version
frankvnk 0:c44f0314d6ec 210 //! only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported
frankvnk 0:c44f0314d6ec 211 //! @param protocol specifies a particular protocol to be used with the
frankvnk 0:c44f0314d6ec 212 //! socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are
frankvnk 0:c44f0314d6ec 213 //! supported.
frankvnk 0:c44f0314d6ec 214 //!
frankvnk 0:c44f0314d6ec 215 //! @return On success, socket handle that is used for consequent socket
frankvnk 0:c44f0314d6ec 216 //! operations. On error, -1 is returned.
frankvnk 0:c44f0314d6ec 217 //!
frankvnk 0:c44f0314d6ec 218 //! @brief create an endpoint for communication
frankvnk 0:c44f0314d6ec 219 //! The socket function creates a socket that is bound to a specific
frankvnk 0:c44f0314d6ec 220 //! transport service provider. This function is called by the
frankvnk 0:c44f0314d6ec 221 //! application layer to obtain a socket handle.
frankvnk 0:c44f0314d6ec 222 //
frankvnk 0:c44f0314d6ec 223 //*****************************************************************************
frankvnk 0:c44f0314d6ec 224 extern int socket(long domain, long type, long protocol);
frankvnk 0:c44f0314d6ec 225
frankvnk 0:c44f0314d6ec 226 //*****************************************************************************
frankvnk 0:c44f0314d6ec 227 //
frankvnk 0:c44f0314d6ec 228 //! closesocket
frankvnk 0:c44f0314d6ec 229 //!
frankvnk 0:c44f0314d6ec 230 //! @param sd socket handle.
frankvnk 0:c44f0314d6ec 231 //!
frankvnk 0:c44f0314d6ec 232 //! @return On success, zero is returned. On error, -1 is returned.
frankvnk 0:c44f0314d6ec 233 //!
frankvnk 0:c44f0314d6ec 234 //! @brief The socket function closes a created socket.
frankvnk 0:c44f0314d6ec 235 //
frankvnk 0:c44f0314d6ec 236 //*****************************************************************************
frankvnk 0:c44f0314d6ec 237 extern long closesocket(long sd);
frankvnk 0:c44f0314d6ec 238
frankvnk 0:c44f0314d6ec 239 //*****************************************************************************
frankvnk 0:c44f0314d6ec 240 //
frankvnk 0:c44f0314d6ec 241 //! accept
frankvnk 0:c44f0314d6ec 242 //!
frankvnk 0:c44f0314d6ec 243 //! @param[in] sd socket descriptor (handle)
frankvnk 0:c44f0314d6ec 244 //! @param[out] addr the argument addr is a pointer to a sockaddr structure
frankvnk 0:c44f0314d6ec 245 //! This structure is filled in with the address of the
frankvnk 0:c44f0314d6ec 246 //! peer socket, as known to the communications layer.
frankvnk 0:c44f0314d6ec 247 //! determined. The exact format of the address returned
frankvnk 0:c44f0314d6ec 248 //! addr is by the socket's address sockaddr.
frankvnk 0:c44f0314d6ec 249 //! On this version only AF_INET is supported.
frankvnk 0:c44f0314d6ec 250 //! This argument returns in network order.
frankvnk 0:c44f0314d6ec 251 //! @param[out] addrlen the addrlen argument is a value-result argument:
frankvnk 0:c44f0314d6ec 252 //! it should initially contain the size of the structure
frankvnk 0:c44f0314d6ec 253 //! pointed to by addr.
frankvnk 0:c44f0314d6ec 254 //!
frankvnk 0:c44f0314d6ec 255 //! @return For socket in blocking mode:
frankvnk 0:c44f0314d6ec 256 //! On success, socket handle. on failure negative
frankvnk 0:c44f0314d6ec 257 //! For socket in non-blocking mode:
frankvnk 0:c44f0314d6ec 258 //! - On connection establishment, socket handle
frankvnk 0:c44f0314d6ec 259 //! - On connection pending, SOC_IN_PROGRESS (-2)
frankvnk 0:c44f0314d6ec 260 //! - On failure, SOC_ERROR (-1)
frankvnk 0:c44f0314d6ec 261 //!
frankvnk 0:c44f0314d6ec 262 //! @brief accept a connection on a socket:
frankvnk 0:c44f0314d6ec 263 //! This function is used with connection-based socket types
frankvnk 0:c44f0314d6ec 264 //! (SOCK_STREAM). It extracts the first connection request on the
frankvnk 0:c44f0314d6ec 265 //! queue of pending connections, creates a new connected socket, and
frankvnk 0:c44f0314d6ec 266 //! returns a new file descriptor referring to that socket.
frankvnk 0:c44f0314d6ec 267 //! The newly created socket is not in the listening state.
frankvnk 0:c44f0314d6ec 268 //! The original socket sd is unaffected by this call.
frankvnk 0:c44f0314d6ec 269 //! The argument sd is a socket that has been created with socket(),
frankvnk 0:c44f0314d6ec 270 //! bound to a local address with bind(), and is listening for
frankvnk 0:c44f0314d6ec 271 //! connections after a listen(). The argument addr is a pointer
frankvnk 0:c44f0314d6ec 272 //! to a sockaddr structure. This structure is filled in with the
frankvnk 0:c44f0314d6ec 273 //! address of the peer socket, as known to the communications layer.
frankvnk 0:c44f0314d6ec 274 //! The exact format of the address returned addr is determined by the
frankvnk 0:c44f0314d6ec 275 //! socket's address family. The addrlen argument is a value-result
frankvnk 0:c44f0314d6ec 276 //! argument: it should initially contain the size of the structure
frankvnk 0:c44f0314d6ec 277 //! pointed to by addr, on return it will contain the actual
frankvnk 0:c44f0314d6ec 278 //! length (in bytes) of the address returned.
frankvnk 0:c44f0314d6ec 279 //!
frankvnk 0:c44f0314d6ec 280 //! @sa socket ; bind ; listen
frankvnk 0:c44f0314d6ec 281 //
frankvnk 0:c44f0314d6ec 282 //*****************************************************************************
frankvnk 0:c44f0314d6ec 283 extern long accept(long sd, sockaddr *addr, socklen_t *addrlen);
frankvnk 0:c44f0314d6ec 284
frankvnk 0:c44f0314d6ec 285 //*****************************************************************************
frankvnk 0:c44f0314d6ec 286 //
frankvnk 0:c44f0314d6ec 287 //! bind
frankvnk 0:c44f0314d6ec 288 //!
frankvnk 0:c44f0314d6ec 289 //! @param[in] sd socket descriptor (handle)
frankvnk 0:c44f0314d6ec 290 //! @param[out] addr specifies the destination address. On this version
frankvnk 0:c44f0314d6ec 291 //! only AF_INET is supported.
frankvnk 0:c44f0314d6ec 292 //! @param[out] addrlen contains the size of the structure pointed to by addr.
frankvnk 0:c44f0314d6ec 293 //!
frankvnk 0:c44f0314d6ec 294 //! @return On success, zero is returned. On error, -1 is returned.
frankvnk 0:c44f0314d6ec 295 //!
frankvnk 0:c44f0314d6ec 296 //! @brief assign a name to a socket
frankvnk 0:c44f0314d6ec 297 //! This function gives the socket the local address addr.
frankvnk 0:c44f0314d6ec 298 //! addr is addrlen bytes long. Traditionally, this is called when a
frankvnk 0:c44f0314d6ec 299 //! socket is created with socket, it exists in a name space (address
frankvnk 0:c44f0314d6ec 300 //! family) but has no name assigned.
frankvnk 0:c44f0314d6ec 301 //! It is necessary to assign a local address before a SOCK_STREAM
frankvnk 0:c44f0314d6ec 302 //! socket may receive connections.
frankvnk 0:c44f0314d6ec 303 //!
frankvnk 0:c44f0314d6ec 304 //! @sa socket ; accept ; listen
frankvnk 0:c44f0314d6ec 305 //
frankvnk 0:c44f0314d6ec 306 //*****************************************************************************
frankvnk 0:c44f0314d6ec 307 extern long bind(long sd, const sockaddr *addr, long addrlen);
frankvnk 0:c44f0314d6ec 308
frankvnk 0:c44f0314d6ec 309 //*****************************************************************************
frankvnk 0:c44f0314d6ec 310 //
frankvnk 0:c44f0314d6ec 311 //! listen
frankvnk 0:c44f0314d6ec 312 //!
frankvnk 0:c44f0314d6ec 313 //! @param[in] sd socket descriptor (handle)
frankvnk 0:c44f0314d6ec 314 //! @param[in] backlog specifies the listen queue depth. On this version
frankvnk 0:c44f0314d6ec 315 //! backlog is not supported.
frankvnk 0:c44f0314d6ec 316 //! @return On success, zero is returned. On error, -1 is returned.
frankvnk 0:c44f0314d6ec 317 //!
frankvnk 0:c44f0314d6ec 318 //! @brief listen for connections on a socket
frankvnk 0:c44f0314d6ec 319 //! The willingness to accept incoming connections and a queue
frankvnk 0:c44f0314d6ec 320 //! limit for incoming connections are specified with listen(),
frankvnk 0:c44f0314d6ec 321 //! and then the connections are accepted with accept.
frankvnk 0:c44f0314d6ec 322 //! The listen() call applies only to sockets of type SOCK_STREAM
frankvnk 0:c44f0314d6ec 323 //! The backlog parameter defines the maximum length the queue of
frankvnk 0:c44f0314d6ec 324 //! pending connections may grow to.
frankvnk 0:c44f0314d6ec 325 //!
frankvnk 0:c44f0314d6ec 326 //! @sa socket ; accept ; bind
frankvnk 0:c44f0314d6ec 327 //!
frankvnk 0:c44f0314d6ec 328 //! @note On this version, backlog is not supported
frankvnk 0:c44f0314d6ec 329 //
frankvnk 0:c44f0314d6ec 330 //*****************************************************************************
frankvnk 0:c44f0314d6ec 331 extern long listen(long sd, long backlog);
frankvnk 0:c44f0314d6ec 332
frankvnk 0:c44f0314d6ec 333 //*****************************************************************************
frankvnk 0:c44f0314d6ec 334 //
frankvnk 0:c44f0314d6ec 335 //! gethostbyname
frankvnk 0:c44f0314d6ec 336 //!
frankvnk 0:c44f0314d6ec 337 //! @param[in] hostname host name
frankvnk 0:c44f0314d6ec 338 //! @param[in] usNameLen name length
frankvnk 0:c44f0314d6ec 339 //! @param[out] out_ip_addr This parameter is filled in with host IP address.
frankvnk 0:c44f0314d6ec 340 //! In case that host name is not resolved,
frankvnk 0:c44f0314d6ec 341 //! out_ip_addr is zero.
frankvnk 0:c44f0314d6ec 342 //! @return On success, positive is returned. On error, negative is returned
frankvnk 0:c44f0314d6ec 343 //!
frankvnk 0:c44f0314d6ec 344 //! @brief Get host IP by name. Obtain the IP Address of machine on network,
frankvnk 0:c44f0314d6ec 345 //! by its name.
frankvnk 0:c44f0314d6ec 346 //!
frankvnk 0:c44f0314d6ec 347 //! @note On this version, only blocking mode is supported. Also note that
frankvnk 0:c44f0314d6ec 348 //! the function requires DNS server to be configured prior to its usage.
frankvnk 0:c44f0314d6ec 349 //
frankvnk 0:c44f0314d6ec 350 //*****************************************************************************
frankvnk 0:c44f0314d6ec 351 #ifndef CC3000_TINY_DRIVER
frankvnk 0:c44f0314d6ec 352 extern int gethostbyname(char * hostname, unsigned short usNameLen, unsigned long* out_ip_addr);
frankvnk 0:c44f0314d6ec 353 #endif
frankvnk 0:c44f0314d6ec 354
frankvnk 0:c44f0314d6ec 355
frankvnk 0:c44f0314d6ec 356 //*****************************************************************************
frankvnk 0:c44f0314d6ec 357 //
frankvnk 0:c44f0314d6ec 358 //! connect
frankvnk 0:c44f0314d6ec 359 //!
frankvnk 0:c44f0314d6ec 360 //! @param[in] sd socket descriptor (handle)
frankvnk 0:c44f0314d6ec 361 //! @param[in] addr specifies the destination addr. On this version
frankvnk 0:c44f0314d6ec 362 //! only AF_INET is supported.
frankvnk 0:c44f0314d6ec 363 //! @param[out] addrlen contains the size of the structure pointed to by addr
frankvnk 0:c44f0314d6ec 364 //! @return On success, zero is returned. On error, -1 is returned
frankvnk 0:c44f0314d6ec 365 //!
frankvnk 0:c44f0314d6ec 366 //! @brief initiate a connection on a socket
frankvnk 0:c44f0314d6ec 367 //! Function connects the socket referred to by the socket descriptor
frankvnk 0:c44f0314d6ec 368 //! sd, to the address specified by addr. The addrlen argument
frankvnk 0:c44f0314d6ec 369 //! specifies the size of addr. The format of the address in addr is
frankvnk 0:c44f0314d6ec 370 //! determined by the address space of the socket. If it is of type
frankvnk 0:c44f0314d6ec 371 //! SOCK_DGRAM, this call specifies the peer with which the socket is
frankvnk 0:c44f0314d6ec 372 //! to be associated; this address is that to which datagrams are to be
frankvnk 0:c44f0314d6ec 373 //! sent, and the only address from which datagrams are to be received.
frankvnk 0:c44f0314d6ec 374 //! If the socket is of type SOCK_STREAM, this call attempts to make a
frankvnk 0:c44f0314d6ec 375 //! connection to another socket. The other socket is specified by
frankvnk 0:c44f0314d6ec 376 //! address, which is an address in the communications space of the
frankvnk 0:c44f0314d6ec 377 //! socket. Note that the function implements only blocking behavior
frankvnk 0:c44f0314d6ec 378 //! thus the caller will be waiting either for the connection
frankvnk 0:c44f0314d6ec 379 //! establishment or for the connection establishment failure.
frankvnk 0:c44f0314d6ec 380 //!
frankvnk 0:c44f0314d6ec 381 //! @sa socket
frankvnk 0:c44f0314d6ec 382 //
frankvnk 0:c44f0314d6ec 383 //*****************************************************************************
frankvnk 0:c44f0314d6ec 384 extern long connect(long sd, const sockaddr *addr, long addrlen);
frankvnk 0:c44f0314d6ec 385
frankvnk 0:c44f0314d6ec 386 //*****************************************************************************
frankvnk 0:c44f0314d6ec 387 //
frankvnk 0:c44f0314d6ec 388 //! select
frankvnk 0:c44f0314d6ec 389 //!
frankvnk 0:c44f0314d6ec 390 //! @param[in] nfds the highest-numbered file descriptor in any of the
frankvnk 0:c44f0314d6ec 391 //! three sets, plus 1.
frankvnk 0:c44f0314d6ec 392 //! @param[out] writesds socket descriptors list for write monitoring
frankvnk 0:c44f0314d6ec 393 //! @param[out] readsds socket descriptors list for read monitoring
frankvnk 0:c44f0314d6ec 394 //! @param[out] exceptsds socket descriptors list for exception monitoring
frankvnk 0:c44f0314d6ec 395 //! @param[in] timeout is an upper bound on the amount of time elapsed
frankvnk 0:c44f0314d6ec 396 //! before select() returns. Null means infinity
frankvnk 0:c44f0314d6ec 397 //! timeout. The minimum timeout is 5 milliseconds,
frankvnk 0:c44f0314d6ec 398 //! less than 5 milliseconds will be set
frankvnk 0:c44f0314d6ec 399 //! automatically to 5 milliseconds.
frankvnk 0:c44f0314d6ec 400 //! @return On success, select() returns the number of file descriptors
frankvnk 0:c44f0314d6ec 401 //! contained in the three returned descriptor sets (that is, the
frankvnk 0:c44f0314d6ec 402 //! total number of bits that are set in readfds, writefds,
frankvnk 0:c44f0314d6ec 403 //! exceptfds) which may be zero if the timeout expires before
frankvnk 0:c44f0314d6ec 404 //! anything interesting happens.
frankvnk 0:c44f0314d6ec 405 //! On error, -1 is returned.
frankvnk 0:c44f0314d6ec 406 //! *readsds - return the sockets on which Read request will
frankvnk 0:c44f0314d6ec 407 //! return without delay with valid data.
frankvnk 0:c44f0314d6ec 408 //! *writesds - return the sockets on which Write request
frankvnk 0:c44f0314d6ec 409 //! will return without delay.
frankvnk 0:c44f0314d6ec 410 //! *exceptsds - return the sockets which closed recently.
frankvnk 0:c44f0314d6ec 411 //!
frankvnk 0:c44f0314d6ec 412 //! @brief Monitor socket activity
frankvnk 0:c44f0314d6ec 413 //! Select allow a program to monitor multiple file descriptors,
frankvnk 0:c44f0314d6ec 414 //! waiting until one or more of the file descriptors become
frankvnk 0:c44f0314d6ec 415 //! "ready" for some class of I/O operation
frankvnk 0:c44f0314d6ec 416 //!
frankvnk 0:c44f0314d6ec 417 //! @Note If the timeout value set to less than 5ms it will automatically set
frankvnk 0:c44f0314d6ec 418 //! to 5ms to prevent overload of the system
frankvnk 0:c44f0314d6ec 419 //!
frankvnk 0:c44f0314d6ec 420 //! @sa socket
frankvnk 0:c44f0314d6ec 421 //
frankvnk 0:c44f0314d6ec 422 //*****************************************************************************
frankvnk 0:c44f0314d6ec 423 extern int select(long nfds, fd_set *readsds, fd_set *writesds,
frankvnk 0:c44f0314d6ec 424 fd_set *exceptsds, struct timeval *timeout);
frankvnk 0:c44f0314d6ec 425
frankvnk 0:c44f0314d6ec 426 //*****************************************************************************
frankvnk 0:c44f0314d6ec 427 //
frankvnk 0:c44f0314d6ec 428 //! setsockopt
frankvnk 0:c44f0314d6ec 429 //!
frankvnk 0:c44f0314d6ec 430 //! @param[in] sd socket handle
frankvnk 0:c44f0314d6ec 431 //! @param[in] level defines the protocol level for this option
frankvnk 0:c44f0314d6ec 432 //! @param[in] optname defines the option name to Interrogate
frankvnk 0:c44f0314d6ec 433 //! @param[in] optval specifies a value for the option
frankvnk 0:c44f0314d6ec 434 //! @param[in] optlen specifies the length of the option value
frankvnk 0:c44f0314d6ec 435 //! @return On success, zero is returned. On error, -1 is returned
frankvnk 0:c44f0314d6ec 436 //!
frankvnk 0:c44f0314d6ec 437 //! @brief set socket options
frankvnk 0:c44f0314d6ec 438 //! This function manipulate the options associated with a socket.
frankvnk 0:c44f0314d6ec 439 //! Options may exist at multiple protocol levels; they are always
frankvnk 0:c44f0314d6ec 440 //! present at the uppermost socket level.
frankvnk 0:c44f0314d6ec 441 //! When manipulating socket options the level at which the option
frankvnk 0:c44f0314d6ec 442 //! resides and the name of the option must be specified.
frankvnk 0:c44f0314d6ec 443 //! To manipulate options at the socket level, level is specified as
frankvnk 0:c44f0314d6ec 444 //! SOL_SOCKET. To manipulate options at any other level the protocol
frankvnk 0:c44f0314d6ec 445 //! number of the appropriate protocol controlling the option is
frankvnk 0:c44f0314d6ec 446 //! supplied. For example, to indicate that an option is to be
frankvnk 0:c44f0314d6ec 447 //! interpreted by the TCP protocol, level should be set to the
frankvnk 0:c44f0314d6ec 448 //! protocol number of TCP;
frankvnk 0:c44f0314d6ec 449 //! The parameters optval and optlen are used to access optval -
frankvnk 0:c44f0314d6ec 450 //! use for setsockopt(). For getsockopt() they identify a buffer
frankvnk 0:c44f0314d6ec 451 //! in which the value for the requested option(s) are to
frankvnk 0:c44f0314d6ec 452 //! be returned. For getsockopt(), optlen is a value-result
frankvnk 0:c44f0314d6ec 453 //! parameter, initially containing the size of the buffer
frankvnk 0:c44f0314d6ec 454 //! pointed to by option_value, and modified on return to
frankvnk 0:c44f0314d6ec 455 //! indicate the actual size of the value returned. If no option
frankvnk 0:c44f0314d6ec 456 //! value is to be supplied or returned, option_value may be NULL.
frankvnk 0:c44f0314d6ec 457 //!
frankvnk 0:c44f0314d6ec 458 //! @Note On this version the following two socket options are enabled:
frankvnk 0:c44f0314d6ec 459 //! The only protocol level supported in this version
frankvnk 0:c44f0314d6ec 460 //! is SOL_SOCKET (level).
frankvnk 0:c44f0314d6ec 461 //! 1. SOCKOPT_RECV_TIMEOUT (optname)
frankvnk 0:c44f0314d6ec 462 //! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
frankvnk 0:c44f0314d6ec 463 //! in milliseconds.
frankvnk 0:c44f0314d6ec 464 //! In that case optval should be pointer to unsigned long.
frankvnk 0:c44f0314d6ec 465 //! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on
frankvnk 0:c44f0314d6ec 466 //! or off.
frankvnk 0:c44f0314d6ec 467 //! In that case optval should be SOCK_ON or SOCK_OFF (optval).
frankvnk 0:c44f0314d6ec 468 //!
frankvnk 0:c44f0314d6ec 469 //! @sa getsockopt
frankvnk 0:c44f0314d6ec 470 //
frankvnk 0:c44f0314d6ec 471 //*****************************************************************************
frankvnk 0:c44f0314d6ec 472 #ifndef CC3000_TINY_DRIVER
frankvnk 0:c44f0314d6ec 473 extern int setsockopt(long sd, long level, long optname, const void *optval,
frankvnk 0:c44f0314d6ec 474 socklen_t optlen);
frankvnk 0:c44f0314d6ec 475 #endif
frankvnk 0:c44f0314d6ec 476 //*****************************************************************************
frankvnk 0:c44f0314d6ec 477 //
frankvnk 0:c44f0314d6ec 478 //! getsockopt
frankvnk 0:c44f0314d6ec 479 //!
frankvnk 0:c44f0314d6ec 480 //! @param[in] sd socket handle
frankvnk 0:c44f0314d6ec 481 //! @param[in] level defines the protocol level for this option
frankvnk 0:c44f0314d6ec 482 //! @param[in] optname defines the option name to Interrogate
frankvnk 0:c44f0314d6ec 483 //! @param[out] optval specifies a value for the option
frankvnk 0:c44f0314d6ec 484 //! @param[out] optlen specifies the length of the option value
frankvnk 0:c44f0314d6ec 485 //! @return On success, zero is returned. On error, -1 is returned
frankvnk 0:c44f0314d6ec 486 //!
frankvnk 0:c44f0314d6ec 487 //! @brief set socket options
frankvnk 0:c44f0314d6ec 488 //! This function manipulate the options associated with a socket.
frankvnk 0:c44f0314d6ec 489 //! Options may exist at multiple protocol levels; they are always
frankvnk 0:c44f0314d6ec 490 //! present at the uppermost socket level.
frankvnk 0:c44f0314d6ec 491 //! When manipulating socket options the level at which the option
frankvnk 0:c44f0314d6ec 492 //! resides and the name of the option must be specified.
frankvnk 0:c44f0314d6ec 493 //! To manipulate options at the socket level, level is specified as
frankvnk 0:c44f0314d6ec 494 //! SOL_SOCKET. To manipulate options at any other level the protocol
frankvnk 0:c44f0314d6ec 495 //! number of the appropriate protocol controlling the option is
frankvnk 0:c44f0314d6ec 496 //! supplied. For example, to indicate that an option is to be
frankvnk 0:c44f0314d6ec 497 //! interpreted by the TCP protocol, level should be set to the
frankvnk 0:c44f0314d6ec 498 //! protocol number of TCP;
frankvnk 0:c44f0314d6ec 499 //! The parameters optval and optlen are used to access optval -
frankvnk 0:c44f0314d6ec 500 //! use for setsockopt(). For getsockopt() they identify a buffer
frankvnk 0:c44f0314d6ec 501 //! in which the value for the requested option(s) are to
frankvnk 0:c44f0314d6ec 502 //! be returned. For getsockopt(), optlen is a value-result
frankvnk 0:c44f0314d6ec 503 //! parameter, initially containing the size of the buffer
frankvnk 0:c44f0314d6ec 504 //! pointed to by option_value, and modified on return to
frankvnk 0:c44f0314d6ec 505 //! indicate the actual size of the value returned. If no option
frankvnk 0:c44f0314d6ec 506 //! value is to be supplied or returned, option_value may be NULL.
frankvnk 0:c44f0314d6ec 507 //!
frankvnk 0:c44f0314d6ec 508 //! @Note On this version the following two socket options are enabled:
frankvnk 0:c44f0314d6ec 509 //! The only protocol level supported in this version
frankvnk 0:c44f0314d6ec 510 //! is SOL_SOCKET (level).
frankvnk 0:c44f0314d6ec 511 //! 1. SOCKOPT_RECV_TIMEOUT (optname)
frankvnk 0:c44f0314d6ec 512 //! SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
frankvnk 0:c44f0314d6ec 513 //! in milliseconds.
frankvnk 0:c44f0314d6ec 514 //! In that case optval should be pointer to unsigned long.
frankvnk 0:c44f0314d6ec 515 //! 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on
frankvnk 0:c44f0314d6ec 516 //! or off.
frankvnk 0:c44f0314d6ec 517 //! In that case optval should be SOCK_ON or SOCK_OFF (optval).
frankvnk 0:c44f0314d6ec 518 //!
frankvnk 0:c44f0314d6ec 519 //! @sa setsockopt
frankvnk 0:c44f0314d6ec 520 //
frankvnk 0:c44f0314d6ec 521 //*****************************************************************************
frankvnk 0:c44f0314d6ec 522 extern int getsockopt(long sd, long level, long optname, void *optval,
frankvnk 0:c44f0314d6ec 523 socklen_t *optlen);
frankvnk 0:c44f0314d6ec 524
frankvnk 0:c44f0314d6ec 525 //*****************************************************************************
frankvnk 0:c44f0314d6ec 526 //
frankvnk 0:c44f0314d6ec 527 //! recv
frankvnk 0:c44f0314d6ec 528 //!
frankvnk 0:c44f0314d6ec 529 //! @param[in] sd socket handle
frankvnk 0:c44f0314d6ec 530 //! @param[out] buf Points to the buffer where the message should be stored
frankvnk 0:c44f0314d6ec 531 //! @param[in] len Specifies the length in bytes of the buffer pointed to
frankvnk 0:c44f0314d6ec 532 //! by the buffer argument.
frankvnk 0:c44f0314d6ec 533 //! @param[in] flags Specifies the type of message reception.
frankvnk 0:c44f0314d6ec 534 //! On this version, this parameter is not supported.
frankvnk 0:c44f0314d6ec 535 //!
frankvnk 0:c44f0314d6ec 536 //! @return Return the number of bytes received, or -1 if an error
frankvnk 0:c44f0314d6ec 537 //! occurred
frankvnk 0:c44f0314d6ec 538 //!
frankvnk 0:c44f0314d6ec 539 //! @brief function receives a message from a connection-mode socket
frankvnk 0:c44f0314d6ec 540 //!
frankvnk 0:c44f0314d6ec 541 //! @sa recvfrom
frankvnk 0:c44f0314d6ec 542 //!
frankvnk 0:c44f0314d6ec 543 //! @Note On this version, only blocking mode is supported.
frankvnk 0:c44f0314d6ec 544 //
frankvnk 0:c44f0314d6ec 545 //*****************************************************************************
frankvnk 0:c44f0314d6ec 546 extern int recv(long sd, void *buf, long len, long flags);
frankvnk 0:c44f0314d6ec 547
frankvnk 0:c44f0314d6ec 548 //*****************************************************************************
frankvnk 0:c44f0314d6ec 549 //
frankvnk 0:c44f0314d6ec 550 //! recvfrom
frankvnk 0:c44f0314d6ec 551 //!
frankvnk 0:c44f0314d6ec 552 //! @param[in] sd socket handle
frankvnk 0:c44f0314d6ec 553 //! @param[out] buf Points to the buffer where the message should be stored
frankvnk 0:c44f0314d6ec 554 //! @param[in] len Specifies the length in bytes of the buffer pointed to
frankvnk 0:c44f0314d6ec 555 //! by the buffer argument.
frankvnk 0:c44f0314d6ec 556 //! @param[in] flags Specifies the type of message reception.
frankvnk 0:c44f0314d6ec 557 //! On this version, this parameter is not supported.
frankvnk 0:c44f0314d6ec 558 //! @param[in] from pointer to an address structure indicating the source
frankvnk 0:c44f0314d6ec 559 //! address: sockaddr. On this version only AF_INET is
frankvnk 0:c44f0314d6ec 560 //! supported.
frankvnk 0:c44f0314d6ec 561 //! @param[in] fromlen source address structure size
frankvnk 0:c44f0314d6ec 562 //!
frankvnk 0:c44f0314d6ec 563 //! @return Return the number of bytes received, or -1 if an error
frankvnk 0:c44f0314d6ec 564 //! occurred
frankvnk 0:c44f0314d6ec 565 //!
frankvnk 0:c44f0314d6ec 566 //! @brief read data from socket
frankvnk 0:c44f0314d6ec 567 //! function receives a message from a connection-mode or
frankvnk 0:c44f0314d6ec 568 //! connectionless-mode socket. Note that raw sockets are not
frankvnk 0:c44f0314d6ec 569 //! supported.
frankvnk 0:c44f0314d6ec 570 //!
frankvnk 0:c44f0314d6ec 571 //! @sa recv
frankvnk 0:c44f0314d6ec 572 //!
frankvnk 0:c44f0314d6ec 573 //! @Note On this version, only blocking mode is supported.
frankvnk 0:c44f0314d6ec 574 //
frankvnk 0:c44f0314d6ec 575 //*****************************************************************************
frankvnk 0:c44f0314d6ec 576 extern int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from,
frankvnk 0:c44f0314d6ec 577 socklen_t *fromlen);
frankvnk 0:c44f0314d6ec 578
frankvnk 0:c44f0314d6ec 579 //*****************************************************************************
frankvnk 0:c44f0314d6ec 580 //
frankvnk 0:c44f0314d6ec 581 //! send
frankvnk 0:c44f0314d6ec 582 //!
frankvnk 0:c44f0314d6ec 583 //! @param sd socket handle
frankvnk 0:c44f0314d6ec 584 //! @param buf Points to a buffer containing the message to be sent
frankvnk 0:c44f0314d6ec 585 //! @param len message size in bytes
frankvnk 0:c44f0314d6ec 586 //! @param flags On this version, this parameter is not supported
frankvnk 0:c44f0314d6ec 587 //!
frankvnk 0:c44f0314d6ec 588 //! @return Return the number of bytes transmitted, or -1 if an
frankvnk 0:c44f0314d6ec 589 //! error occurred
frankvnk 0:c44f0314d6ec 590 //!
frankvnk 0:c44f0314d6ec 591 //! @brief Write data to TCP socket
frankvnk 0:c44f0314d6ec 592 //! This function is used to transmit a message to another
frankvnk 0:c44f0314d6ec 593 //! socket.
frankvnk 0:c44f0314d6ec 594 //!
frankvnk 0:c44f0314d6ec 595 //! @Note On this version, only blocking mode is supported.
frankvnk 0:c44f0314d6ec 596 //!
frankvnk 0:c44f0314d6ec 597 //! @sa sendto
frankvnk 0:c44f0314d6ec 598 //
frankvnk 0:c44f0314d6ec 599 //*****************************************************************************
frankvnk 0:c44f0314d6ec 600
frankvnk 0:c44f0314d6ec 601 extern int send(long sd, const void *buf, long len, long flags);
frankvnk 0:c44f0314d6ec 602
frankvnk 0:c44f0314d6ec 603 //*****************************************************************************
frankvnk 0:c44f0314d6ec 604 //
frankvnk 0:c44f0314d6ec 605 //! sendto
frankvnk 0:c44f0314d6ec 606 //!
frankvnk 0:c44f0314d6ec 607 //! @param sd socket handle
frankvnk 0:c44f0314d6ec 608 //! @param buf Points to a buffer containing the message to be sent
frankvnk 0:c44f0314d6ec 609 //! @param len message size in bytes
frankvnk 0:c44f0314d6ec 610 //! @param flags On this version, this parameter is not supported
frankvnk 0:c44f0314d6ec 611 //! @param to pointer to an address structure indicating the destination
frankvnk 0:c44f0314d6ec 612 //! address: sockaddr. On this version only AF_INET is
frankvnk 0:c44f0314d6ec 613 //! supported.
frankvnk 0:c44f0314d6ec 614 //! @param tolen destination address structure size
frankvnk 0:c44f0314d6ec 615 //!
frankvnk 0:c44f0314d6ec 616 //! @return Return the number of bytes transmitted, or -1 if an
frankvnk 0:c44f0314d6ec 617 //! error occurred
frankvnk 0:c44f0314d6ec 618 //!
frankvnk 0:c44f0314d6ec 619 //! @brief Write data to TCP socket
frankvnk 0:c44f0314d6ec 620 //! This function is used to transmit a message to another
frankvnk 0:c44f0314d6ec 621 //! socket.
frankvnk 0:c44f0314d6ec 622 //!
frankvnk 0:c44f0314d6ec 623 //! @Note On this version, only blocking mode is supported.
frankvnk 0:c44f0314d6ec 624 //!
frankvnk 0:c44f0314d6ec 625 //! @sa send
frankvnk 0:c44f0314d6ec 626 //
frankvnk 0:c44f0314d6ec 627 //*****************************************************************************
frankvnk 0:c44f0314d6ec 628
frankvnk 0:c44f0314d6ec 629 extern int sendto(long sd, const void *buf, long len, long flags,
frankvnk 0:c44f0314d6ec 630 const sockaddr *to, socklen_t tolen);
frankvnk 0:c44f0314d6ec 631
frankvnk 0:c44f0314d6ec 632 //*****************************************************************************
frankvnk 0:c44f0314d6ec 633 //
frankvnk 0:c44f0314d6ec 634 //! mdnsAdvertiser
frankvnk 0:c44f0314d6ec 635 //!
frankvnk 0:c44f0314d6ec 636 //! @param[in] mdnsEnabled flag to enable/disable the mDNS feature
frankvnk 0:c44f0314d6ec 637 //! @param[in] deviceServiceName Service name as part of the published
frankvnk 0:c44f0314d6ec 638 //! canonical domain name
frankvnk 0:c44f0314d6ec 639 //! @param[in] deviceServiceNameLength Length of the service name
frankvnk 0:c44f0314d6ec 640 //!
frankvnk 0:c44f0314d6ec 641 //!
frankvnk 0:c44f0314d6ec 642 //! @return On success, zero is returned, return SOC_ERROR if socket was not
frankvnk 0:c44f0314d6ec 643 //! opened successfully, or if an error occurred.
frankvnk 0:c44f0314d6ec 644 //!
frankvnk 0:c44f0314d6ec 645 //! @brief Set CC3000 in mDNS advertiser mode in order to advertise itself.
frankvnk 0:c44f0314d6ec 646 //
frankvnk 0:c44f0314d6ec 647 //*****************************************************************************
frankvnk 0:c44f0314d6ec 648 extern int mdnsAdvertiser(unsigned short mdnsEnabled, char * deviceServiceName, unsigned short deviceServiceNameLength);
frankvnk 0:c44f0314d6ec 649
frankvnk 0:c44f0314d6ec 650 //*****************************************************************************
frankvnk 0:c44f0314d6ec 651 //
frankvnk 0:c44f0314d6ec 652 // Close the Doxygen group.
frankvnk 0:c44f0314d6ec 653 //! @}
frankvnk 0:c44f0314d6ec 654 //
frankvnk 0:c44f0314d6ec 655 //*****************************************************************************
frankvnk 0:c44f0314d6ec 656
frankvnk 0:c44f0314d6ec 657
frankvnk 0:c44f0314d6ec 658 //*****************************************************************************
frankvnk 0:c44f0314d6ec 659 //
frankvnk 0:c44f0314d6ec 660 // Mark the end of the C bindings section for C++ compilers.
frankvnk 0:c44f0314d6ec 661 //
frankvnk 0:c44f0314d6ec 662 //*****************************************************************************
frankvnk 0:c44f0314d6ec 663 #ifdef __cplusplus
frankvnk 0:c44f0314d6ec 664 }
frankvnk 0:c44f0314d6ec 665 #endif // __cplusplus
frankvnk 0:c44f0314d6ec 666
frankvnk 0:c44f0314d6ec 667 #endif // __SOCKET_H__
frankvnk 0:c44f0314d6ec 668
frankvnk 0:c44f0314d6ec 669