summaryrefslogblamecommitdiff
path: root/nuttx/drivers/wireless/cc3000/cc3000_socket.h
blob: 0e3f969b0ffeaf4d0d31ac7ff9110bc7dbcafc14 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660



















































































































































































































































































































































































































































































































































































































































































                                                                                                              
/*****************************************************************************
 * drivers/wireless/cc3000_socket.h  - CC3000 Host Driver Implementation.
 *  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *    Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 *    Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the
 *    distribution.
 *
 *    Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

#ifndef __DRIVERS_WIRELESS_CC3000_SOCKET_H
#define __DRIVERS_WIRELESS_CC3000_SOCKET_H

/****************************************************************************
 * Included Files
 ****************************************************************************/

#include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>

/*****************************************************************************
 * Pre-processor Definitions
 *****************************************************************************/

#define CC3000_HOSTNAME_MAX_LENGTH    (230)  /* 230 bytes + header shouldn't exceed 8
                                              * bit value */

/*--------- Address Families --------*/

#define  CC3000_AF_INET                2
#define  CC3000_AF_INET6               23


/*------------ Socket Types ------------*/

#define  CC3000_SOCK_STREAM     1
#define  CC3000_SOCK_DGRAM      2
#define  CC3000_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 */
#define  CC3000_SOCK_RDM        4
#define  CC3000_SOCK_SEQPACKET  5

/*----------- Socket Protocol ----------*/

#define CC3000_IPPROTO_IP              0                        /* Dummy for IP */
#define CC3000_IPPROTO_ICMP            1                        /* Control message protocol */
#define CC3000_IPPROTO_IPV4            CC3000_IPPROTO_IP        /* IP inside IP */
#define CC3000_IPPROTO_TCP             6                        /* TCP */
#define CC3000_IPPROTO_UDP             17                       /* User datagram protocol */
#define CC3000_IPPROTO_IPV6            41                       /* IPv6 in IPv6 */
#define CC3000_IPPROTO_NONE            59                       /* No next header */
#define CC3000_IPPROTO_RAW             255                      /* Raw IP packet */
#define CC3000_IPPROTO_MAX             256

/*----------- Socket retunr codes  -----------*/

#define CC3000_SOC_ERROR               (-1)        /* Error  */
#define CC3000_SOC_IN_PROGRESS         (-2)        /* Socket in progress */

/*----------- Socket Options -----------*/
#define  CC3000_SOL_SOCKET              0xffff     /* Socket level */
#define  CC3000_SOCKOPT_RECV_NONBLOCK   0          /* recv non block mode, set SOCK_ON or
                                                    * SOCK_OFF (default block mode) */
#define  CC3000_SOCKOPT_RECV_TIMEOUT    1          /* optname to configure recv and recvfromtimeout */
#define  CC3000_SOCKOPT_ACCEPT_NONBLOCK 2          /* accept non block mode, set SOCK_ON or SOCK_OFF
                                                    * (default block mode) */
#define  CC3000_SOCK_ON                 0          /* socket non-blocking mode  is enabled */
#define  CC3000_SOCK_OFF                1          /* socket blocking mode is enabled */

#define  CC3000_TCP_NODELAY             0x0001
#define  CC3000_TCP_BSDURGENT           0x7000

#define  CC3000_MAX_PACKET_SIZE         1500
#define  CC3000_MAX_LISTEN_QUEUE        4

#define  CC3000_IOCTL_SOCKET_EVENTMASK

#define CC3000_FD_SETSIZE             32

#define  CC3000_ASIC_ADDR_LEN           8

#define CC3000_NO_QUERY_RECIVED        -3

/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */

#define __NFDBITS               (8 * sizeof (__fd_mask))
#define __FDELT(d)              ((d) / __NFDBITS)
#define __FDMASK(d)             ((__fd_mask) 1 << ((d) % __NFDBITS))

#define __FDS_BITS(set)        ((set)->fds_bits)

/* We don't use `memset' because this would require a prototype and
 *   the array isn't too big.
 */

#define __FD_ZERO(set) \
  do { \
    unsigned int __i; \
    TICC3000fd_set *__arr = (set); \
    for (__i = 0; __i < sizeof (TICC3000fd_set) / sizeof (__fd_mask); ++__i) \
      __FDS_BITS (__arr)[__i] = 0; \
  } while (0)
#define __FD_SET(d, set)       (__FDS_BITS (set)[__FDELT (d)] |= __FDMASK (d))
#define __FD_CLR(d, set)       (__FDS_BITS (set)[__FDELT (d)] &= ~__FDMASK (d))
#define __FD_ISSET(d, set)     (__FDS_BITS (set)[__FDELT (d)] & __FDMASK (d))

/* Access macros for 'TICC3000fd_set' */

#define CC3000_FD_SET(fd, fdsetp)      __FD_SET (fd, fdsetp)
#define CC3000_FD_CLR(fd, fdsetp)      __FD_CLR (fd, fdsetp)
#define CC3000_FD_ISSET(fd, fdsetp)    __FD_ISSET (fd, fdsetp)
#define CC3000_FD_ZERO(fdsetp)         __FD_ZERO (fdsetp)


/* mDNS port - 5353    mDNS multicast address - 224.0.0.251 */

#define SET_mDNS_ADD(sockaddr)            sockaddr.sa_data[0] = 0x14; \
                                          sockaddr.sa_data[1] = 0xe9; \
                                          sockaddr.sa_data[2] = 0xe0; \
                                          sockaddr.sa_data[3] = 0x0; \
                                          sockaddr.sa_data[4] = 0x0; \
                                          sockaddr.sa_data[5] = 0xfb;

/*****************************************************************************
 * Public Types
 *****************************************************************************/

/* The fd_set member is required to be an array of longs. */

typedef long int __fd_mask;

/* fd_set for select and pselect. */

typedef struct
{
  __fd_mask fds_bits[CC3000_FD_SETSIZE / __NFDBITS];
} TICC3000fd_set;

/*****************************************************************************
 * Public Data
 *****************************************************************************/

#ifdef  __cplusplus
extern "C" {
#endif

/*****************************************************************************
 * Public Function Prototypes
 *****************************************************************************/

/*****************************************************************************
 * Name: cc3000_socket_impl
 *
 * Decription:
 *   create an endpoint for communication. The socket function creates a
 *   socket that is bound to a specific transport service provider.  This
 *   function is called by the application layer to obtain a socket handle.
 *
 * Input Parameters:
 *   domain    selects the protocol family which will be used for
 *    communication. On this version only AF_INET is supported
 *   type      specifies the communication semantics. On this version
 *    only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported
 *   protocol  specifies a particular protocol to be used with the
 *    socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are
 *    supported.
 *
 * Returned Value:
 *   On success, socket handle that is used for consequent socket
 *    operations. On error, -1 is returned.
 *
 *****************************************************************************/

int cc3000_socket_impl(long domain, long type, long protocol);

/*****************************************************************************
 * Name: cc3000_closesocket_impl
 *
 * Decription:
 *   The socket function closes a created socket.
 *
 * Input Parameters:
 *   sd    socket handle.
 *
 * Returned Value:
 *   On success, zero is returned. On error, -1 is returned.
 *
 *****************************************************************************/

long cc3000_closesocket_impl(long sd);

/*****************************************************************************
 * Name: cc3000_accept_impl
 *
 * Decription:
 *   accept a connection on a socket:
 *   This function is used with connection-based socket types
 *   (SOCK_STREAM). It extracts the first connection request on the
 *   queue of pending connections, creates a new connected socket, and
 *   returns a new file descriptor referring to that socket.
 *   The newly created socket is not in the listening state.
 *   The original socket sd is unaffected by this call.
 *   The argument sd is a socket that has been created with socket(),
 *   bound to a local address with bind(), and is  listening for
 *   connections after a listen(). The argument addr is a pointer
 *   to a sockaddr structure. This structure is filled in with the
 *   address of the peer socket, as known to the communications layer.
 *   The exact format of the address returned addr is determined by the
 *   socket's address family. The addrlen argument is a value-result
 *   argument: it should initially contain the size of the structure
 *   pointed to by addr, on return it will contain the actual
 *   length (in bytes) of the address returned.
 *
 * Input Parameters:
 *   sd      socket descriptor (handle)
 *   addr    the argument addr is a pointer to a sockaddr structure
 *           This structure is filled in with the address of the
 *           peer socket, as known to the communications layer.
 *           determined. The exact format of the address returned
 *           addr is by the socket's address sockaddr.
 *           On this version only AF_INET is supported.
 *           This argument returns in network order.
 *   addrlen The addrlen argument is a value-result argument:
 *           it should initially contain the size of the structure
 *            pointed to by addr.
 *
 * Returned Value:
 *   For socket in blocking mode:
 *    On success, socket handle. on failure negative
 *     For socket in non-blocking mode:
 *   - On connection establishment, socket handle
 *   - On connection pending, SOC_IN_PROGRESS (-2)
 *   - On failure, SOC_ERROR  (-1)
 *
 *****************************************************************************/

long cc3000_accept_impl(long sd, struct sockaddr *addr, socklen_t *addrlen);

/*****************************************************************************
 * Name: cc3000_bind_impl
 *
 * Decription:
 *   assign a name to a socket
 *   This function gives the socket the local address addr.
 *   addr is addrlen bytes long. Traditionally, this is called when a
 *   socket is created with socket, it exists in a name space (address
 *   family) but has no name assigned.
 *   It is necessary to assign a local address before a SOCK_STREAM
 *   socket may receive connections.
 *
 * Input Parameters:
 *   sd      socket descriptor (handle)
 *   addr    specifies the destination address. On this version
 *    only AF_INET is supported.
 *   addrlen  contains the size of the structure pointed to by addr.
 *
 * Returned Value:
 *   On success, zero is returned. On error, -1 is returned.
 *
 *****************************************************************************/

long cc3000_bind_impl(long sd, FAR const struct sockaddr *addr, socklen_t addrlen);

/*****************************************************************************
 * Name: cc3000_listen_impl
 *
 * Decription:
 *   listen for connections on a socket
 *   The willingness to accept incoming connections and a queue
 *   limit for incoming connections are specified with listen(),
 *   and then the connections are accepted with accept.
 *   The listen() call applies only to sockets of type SOCK_STREAM
 *   The backlog parameter defines the maximum length the queue of
 *   pending connections may grow to.
 *
 * NOTE: On this version, backlog is not supported
 *
 * Input Parameters:
 *   sd  socket descriptor (handle)
 *   backlog  specifies the listen queue depth. On this version
 *    backlog is not supported.
 *
 * Returned Value:
 *   On success, zero is returned. On error, -1 is returned.
 *
 *****************************************************************************/

long cc3000_listen_impl(long sd, long backlog);

/*****************************************************************************
 * Name: cc3000_connect_impl
 *
 * Decription:
 *   initiate a connection on a socket
 *   Function connects the socket referred to by the socket descriptor
 *   sd, to the address specified by addr. The addrlen argument
 *   specifies the size of addr. The format of the address in addr is
 *   determined by the address space of the socket. If it is of type
 *   SOCK_DGRAM, this call specifies the peer with which the socket is
 *   to be associated; this address is that to which datagrams are to be
 *   sent, and the only address from which datagrams are to be received.
 *   If the socket is of type SOCK_STREAM, this call attempts to make a
 *   connection to another socket. The other socket is specified  by
 *   address, which is an address in the communications space of the
 *   socket. Note that the function implements only blocking behavior
 *   thus the caller will be waiting either for the connection
 *   establishment or for the connection establishment failure.
 *
 * Input Parameters:
 *   sd       socket descriptor (handle)
 *   addr     specifies the destination addr. On this version
 *     only AF_INET is supported.
 *   addrlen  contains the size of the structure pointed to by addr
 *
 * Returned Value:
 *   On success, zero is returned. On error, -1 is returned
 *
 *****************************************************************************/

long cc3000_connect_impl(long sd, FAR const struct sockaddr *addr, socklen_t addrlen);

/*****************************************************************************
 * Name: cc3000_select_impl
 *
 * Decription:
 *   Monitor socket activity
 *   Select allow a program to monitor multiple file descriptors,
 *   waiting until one or more of the file descriptors become
 *   "ready" for some class of I/O operation
 *
 * NOTE: If the timeout value set to less than 5ms it will automatically set
 *   to 5ms to prevent overload of the system
 *
 * Input Parameters:
 *   nfds       the highest-numbered file descriptor in any of the
 *     three sets, plus 1.
 *   readfds    socket descriptors list for read monitoring
 *   writefds   socket descriptors list for write monitoring
 *   exceptfds  socket descriptors list for exception monitoring
 *   timeout     is an upper bound on the amount of time elapsed
 *     before select() returns. Null means infinity
 *     timeout. The minimum timeout is 5 milliseconds,
 *    less than 5 milliseconds will be set
 *     automatically to 5 milliseconds.
 *
 * Returned Value:
 *   On success, select() returns the number of file descriptors
 *   contained in the three returned descriptor sets (that is, the
 *   total number of bits that are set in readfds, writefds,
 *   exceptfds) which may be zero if the timeout expires before
 *   anything interesting  happens.
 *   On error, -1 is returned.
 *   *readfds - return the sockets on which Read request will
 *     return without delay with valid data.
 *   *writefds - return the sockets on which Write request
 *     will return without delay.
 *   *exceptfds - return the sockets which closed recently.
 *
 *****************************************************************************/

int cc3000_select_impl(long nfds, TICC3000fd_set *readfds, TICC3000fd_set *writefds,TICC3000fd_set *exceptfds,
           struct timeval *timeout);

int cc3000_select(int nfds, fd_set *readfds, fd_set *writefds,fd_set *exceptfds, struct timeval *timeout);


#ifndef CC3000_TINY_DRIVER
/*****************************************************************************
 * Name: cc3000_setsockopt_impl
 *
 * Decription:
 *   set socket options
 *   This function manipulate the options associated with a socket.
 *   Options may exist at multiple protocol levels; they are always
 *   present at the uppermost socket level.
 *   When manipulating socket options the level at which the option
 *   resides and the name of the option must be specified.
 *   To manipulate options at the socket level, level is specified as
 *   SOL_SOCKET. To manipulate options at any other level the protocol
 *   number of the appropriate protocol controlling the option is
 *   supplied. For example, to indicate that an option is to be
 *   interpreted by the TCP protocol, level should be set to the
 *   protocol number of TCP;
 *   The parameters optval and optlen are used to access optval -
 *   use for setsockopt(). For getsockopt() they identify a buffer
 *   in which the value for the requested option(s) are to
 *   be returned. For getsockopt(), optlen is a value-result
 *   parameter, initially containing the size of the buffer
 *   pointed to by option_value, and modified on return to
 *   indicate the actual size of the value returned. If no option
 *   value is to be supplied or returned, option_value may be NULL.
 *
 * NOTE: On this version the following two socket options are enabled:
 *    The only protocol level supported in this version
 *   is SOL_SOCKET (level).
 *    1. SOCKOPT_RECV_TIMEOUT (optname)
 *     SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
 *    in milliseconds.
 *     In that case optval should be pointer to unsigned long.
 *    2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on
 *    or off.
 *     In that case optval should be SOCK_ON or SOCK_OFF (optval).
 *
 * Input Parameters:
 *   sd          socket handle
 *   level       defines the protocol level for this option
 *   optname     defines the option name to Interrogate
 *   optval      specifies a value for the option
 *   optlen      specifies the length of the option value
 *
 * Returned Value:
 *   On success, zero is returned. On error, -1 is returned
 *
 *****************************************************************************/

int cc3000_setsockopt_impl(long sd, long level, long optname, const void *optval, socklen_t optlen);
#endif

/*****************************************************************************
 * Name: cc3000_getsockopt_impl
 *
 * Decription:
 *   set socket options
 *   This function manipulate the options associated with a socket.
 *   Options may exist at multiple protocol levels; they are always
 *   present at the uppermost socket level.
 *   When manipulating socket options the level at which the option
 *   resides and the name of the option must be specified.
 *   To manipulate options at the socket level, level is specified as
 *   SOL_SOCKET. To manipulate options at any other level the protocol
 *   number of the appropriate protocol controlling the option is
 *   supplied. For example, to indicate that an option is to be
 *   interpreted by the TCP protocol, level should be set to the
 *   protocol number of TCP;
 *   The parameters optval and optlen are used to access optval -
 *   use for setsockopt(). For getsockopt() they identify a buffer
 *   in which the value for the requested option(s) are to
 *   be returned. For getsockopt(), optlen is a value-result
 *   parameter, initially containing the size of the buffer
 *   pointed to by option_value, and modified on return to
 *   indicate the actual size of the value returned. If no option
 *   value is to be supplied or returned, option_value may be NULL.
 *
 * NOTE: On this version the following two socket options are enabled:
 *    The only protocol level supported in this version
 *   is SOL_SOCKET (level).
 *    1. SOCKOPT_RECV_TIMEOUT (optname)
 *     SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout
 *    in milliseconds.
 *     In that case optval should be pointer to unsigned long.
 *    2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on
 *    or off.
 *     In that case optval should be SOCK_ON or SOCK_OFF (optval).
 *
 * Input Parameters:
 *   sd          socket handle
 *   level       defines the protocol level for this option
 *   optname     defines the option name to Interrogate
 *   optval      specifies a value for the option
 *   optlen      specifies the length of the option value
 *
 * Returned Value:
 *   On success, zero is returned. On error, -1 is returned
 *
 *****************************************************************************/

int cc3000_getsockopt_impl(long sd, long level, long optname, void *optval, socklen_t *optlen);


/*****************************************************************************
 * Name: cc3000_recv_impl
 *
 * Decription:
 *     function receives a message from a connection-mode socket
 *
 * NOTE: On this version, only blocking mode is supported.
 *
 * Input Parameters:
 *   sd socket handle
 *   buf    Points to the buffer where the message should be stored
 *   len    Specifies the length in bytes of the buffer pointed to
 *     by the buffer argument.
 *   flags   Specifies the type of message reception.
 *     On this version, this parameter is not supported.
 *
 * Returned Value:
 *     Return the number of bytes received, or -1 if an error
 *     occurred
 *
 *****************************************************************************/

int cc3000_recv_impl(long sd, void *buf, long len, long flags);

/*****************************************************************************
 * Name: cc3000_recvfrom_impl
 *
 * Decription:
 *    read data from socket
 *    function receives a message from a connection-mode or
 *    connectionless-mode socket. Note that raw sockets are not
 *    supported.
 *
 * NOTE: On this version, only blocking mode is supported.
 *
 * Input Parameters:
 *   sd socket handle
 *   buf    Points to the buffer where the message should be stored
 *   len    Specifies the length in bytes of the buffer pointed to
 *     by the buffer argument.
 *   flags   Specifies the type of message reception.
 *     On this version, this parameter is not supported.
 *   from   pointer to an address structure indicating the source
 *    address: sockaddr. On this version only AF_INET is
 *    supported.
 *   fromlen   source address tructure size
 *
 * Returned Value:
 *     Return the number of bytes received, or -1 if an error
 *     occurred
 *
 *****************************************************************************/

int cc3000_recvfrom_impl(long sd, void *buf, long len, long flags,
                             struct sockaddr *from, socklen_t *fromlen);

/*****************************************************************************
 * Name: cc3000_send_impl
 *
 * Decription:
 *     Write data to TCP socket
 *     This function is used to transmit a message to another
 *     socket.
 *
 * NOTE: On this version, only blocking mode is supported.
 *
 * Input Parameters:
 *   sd   socket handle
 *   buf      Points to a buffer containing the message to be sent
 *   len      message size in bytes
 *   flags    On this version, this parameter is not supported
 *
 * Returned Value:
 *     Return the number of bytes transmitted, or -1 if an
 *     error occurred
 *
 *****************************************************************************/

int cc3000_send_impl(long sd, const void *buf, long len, long flags);

/*****************************************************************************
 * Name: cc3000_sendto_impl
 *
 * Decription:
 *     Write data to TCP socket
 *     This function is used to transmit a message to another
 *     socket.
 *
 * NOTE: On this version, only blocking mode is supported.
 *
 * Input Parameters:
 *   sd   socket handle
 *   buf      Points to a buffer containing the message to be sent
 *   len      message size in bytes
 *   flags    On this version, this parameter is not supported
 *   to       pointer to an address structure indicating the destination
 *     address: sockaddr. On this version only AF_INET is
 *     supported.
 *   tolen    destination address structure size
 *
 * Returned Value:
 *     Return the number of bytes transmitted, or -1 if an
 *     error occurred
 *
 *****************************************************************************/

int cc3000_sendto_impl(long sd, FAR const void *buf, long len, long flags,
                      FAR const struct sockaddr *to, socklen_t tolen);

#ifndef CC3000_TINY_DRIVER
/*****************************************************************************
 * Name: cc3000_gethostbyname_impl
 *
 * Decription:
 *   Get host IP by name. Obtain the IP Address of machine on network,
 *   by its name.
 *
 * NOTE: On this version, only blocking mode is supported. Also note that
 *       the function requires DNS server to be configured prior to its
 *       usage.
 *
 * Input Parameters:
 *   hostname     host name
 *   usNameLen    name length
 *   out_ip_addr  This parameter is filled in with host IP address.
 *   In case that host name is not resolved,
 *   out_ip_addr is zero.
 *
 * Returned Value:
 *   On success, positive is returned. On error, negative is returned
 *
 *****************************************************************************/

//struct hostent *gethostbyname(const char *name);
int cc3000_gethostbyname_impl(char * hostname, uint16_t usNameLen, unsigned long* out_ip_addr);
#endif

/*****************************************************************************
 * Name: cc3000_mdnsAdvertiser_impl
 *
 * Decription:
 *     Set CC3000 in mDNS advertiser mode in order to advertise itself.
 *
 * Input Parameters:
 *   mdnsEnabled             flag to enable/disable the mDNS feature
 *   deviceServiceName       Service name as part of the published
 *                           canonical domain name
 *   deviceServiceNameLength Length of the service name
 *
 * Returned Value:
 *   On success, zero is returned, return SOC_ERROR if socket was not
 *   opened successfully, or if an error occurred.
 *
 *****************************************************************************/

int cc3000_mdnsadvertiser_impl(uint16_t mdnsEnabled, char * deviceServiceName,
                   uint16_t deviceServiceNameLength);

#ifdef  __cplusplus
}
#endif // __cplusplus

#endif // __DRIVERS_WIRELESS_CC3000_SOCKET_H