summaryrefslogtreecommitdiff
path: root/nuttx/drivers/wireless/cc3000/socket.c
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-10-16 13:18:53 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-10-16 13:18:53 -0600
commit5fb28da6abfea7651ad01c7f4bd8d90839b25a58 (patch)
tree81bbbdc64144d23647c6d3eb89f0352563e5e1e3 /nuttx/drivers/wireless/cc3000/socket.c
parent520885d4d0f94d730a73e12c88a0bad8f52acbff (diff)
downloadpx4-nuttx-5fb28da6abfea7651ad01c7f4bd8d90839b25a58.tar.gz
px4-nuttx-5fb28da6abfea7651ad01c7f4bd8d90839b25a58.tar.bz2
px4-nuttx-5fb28da6abfea7651ad01c7f4bd8d90839b25a58.zip
CC3000 driver changes from David Sidrane
Diffstat (limited to 'nuttx/drivers/wireless/cc3000/socket.c')
-rw-r--r--nuttx/drivers/wireless/cc3000/socket.c241
1 files changed, 120 insertions, 121 deletions
diff --git a/nuttx/drivers/wireless/cc3000/socket.c b/nuttx/drivers/wireless/cc3000/socket.c
index 878065b39..a8858b0c6 100644
--- a/nuttx/drivers/wireless/cc3000/socket.c
+++ b/nuttx/drivers/wireless/cc3000/socket.c
@@ -183,6 +183,11 @@ int HostFlowControlConsumeBuff(int sd)
/*****************************************************************************
* Name: socket
*
+ * 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
@@ -196,12 +201,6 @@ int HostFlowControlConsumeBuff(int sd)
* On success, socket handle that is used for consequent socket
* operations. On error, -1 is returned.
*
- * 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.
- *
*****************************************************************************/
int socket(long domain, long type, long protocol)
@@ -239,15 +238,15 @@ int socket(long domain, long type, long protocol)
/*****************************************************************************
* Name: closesocket
*
+ * 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.
*
- * Decription:
- * The socket function closes a created socket.
- *
*****************************************************************************/
long closesocket(long sd)
@@ -285,6 +284,25 @@ long closesocket(long sd)
/*****************************************************************************
* Name: accept
*
+ * 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
@@ -306,25 +324,6 @@ long closesocket(long sd)
* - On connection pending, SOC_IN_PROGRESS (-2)
* - On failure, SOC_ERROR (-1)
*
- * 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.
- *
*****************************************************************************/
long accept(long sd, sockaddr *addr, socklen_t *addrlen)
@@ -375,15 +374,6 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen)
/*****************************************************************************
* Name: bind
*
- * 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.
- *
* Decription:
* assign a name to a socket
* This function gives the socket the local address addr.
@@ -393,6 +383,15 @@ long accept(long sd, sockaddr *addr, socklen_t *addrlen)
* 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 bind(long sd, const sockaddr *addr, long addrlen)
@@ -430,14 +429,6 @@ long bind(long sd, const sockaddr *addr, long addrlen)
/*****************************************************************************
* Name: listen
*
- * 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.
- *
* Decription:
* listen for connections on a socket
* The willingness to accept incoming connections and a queue
@@ -449,6 +440,14 @@ long bind(long sd, const sockaddr *addr, long addrlen)
*
* 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 listen(long sd, long backlog)
@@ -481,6 +480,14 @@ long listen(long sd, long backlog)
/*****************************************************************************
* Name: gethostbyname
*
+ * 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
@@ -491,14 +498,6 @@ long listen(long sd, long backlog)
* Returned Value:
* On success, positive is returned. On error, negative is returned
*
- * 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.
- *
*****************************************************************************/
#ifndef CC3000_TINY_DRIVER
@@ -543,15 +542,6 @@ int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_add
/*****************************************************************************
* Name: connect
*
- * 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
- *
* Decription:
* initiate a connection on a socket
* Function connects the socket referred to by the socket descriptor
@@ -568,6 +558,15 @@ int gethostbyname(char * hostname, uint16_t usNameLen, unsigned long* out_ip_add
* 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 connect(long sd, const sockaddr *addr, long addrlen)
@@ -604,6 +603,15 @@ long connect(long sd, const sockaddr *addr, long addrlen)
/*****************************************************************************
* Name: select
*
+ * 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.
@@ -629,15 +637,6 @@ long connect(long sd, const sockaddr *addr, long addrlen)
* will return without delay.
* *exceptsds - return the sockets which closed recently.
*
- * 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
- *
*****************************************************************************/
int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
@@ -724,16 +723,6 @@ int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
/*****************************************************************************
* Name: setsockopt
*
- * 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
- *
* Decription:
* set socket options
* This function manipulate the options associated with a socket.
@@ -767,6 +756,16 @@ int select(long nfds, TICC3000fd_set *readsds, TICC3000fd_set *writesds,
* 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
+ *
*****************************************************************************/
#ifndef CC3000_TINY_DRIVER
@@ -811,16 +810,6 @@ int setsockopt(long sd, long level, long optname, const void *optval, socklen_t
/*****************************************************************************
* Name: getsockopt
*
- * 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
- *
* Decription:
* set socket options
* This function manipulate the options associated with a socket.
@@ -854,6 +843,16 @@ int setsockopt(long sd, long level, long optname, const void *optval, socklen_t
* 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 getsockopt (long sd, long level, long optname, void *optval, socklen_t *optlen)
@@ -958,6 +957,11 @@ int simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from,
/*****************************************************************************
* Name: recv
*
+ * 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
@@ -970,11 +974,6 @@ int simple_link_recv(long sd, void *buf, long len, long flags, sockaddr *from,
* Return the number of bytes received, or -1 if an error
* occurred
*
- * Decription:
- * function receives a message from a connection-mode socket
- *
- * NOTE: On this version, only blocking mode is supported.
- *
*****************************************************************************/
int recv(long sd, void *buf, long len, long flags)
@@ -985,6 +984,14 @@ int recv(long sd, void *buf, long len, long flags)
/*****************************************************************************
* Name: recvfrom
*
+ * 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
@@ -1001,14 +1008,6 @@ int recv(long sd, void *buf, long len, long flags)
* Return the number of bytes received, or -1 if an error
* occurred
*
- * 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.
- *
*****************************************************************************/
int recvfrom(long sd, void *buf, long len, long flags, sockaddr *from,
@@ -1137,6 +1136,13 @@ int simple_link_send(long sd, const void *buf, long len, long flags,
/*****************************************************************************
* Name: send
*
+ * 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
@@ -1147,13 +1153,6 @@ int simple_link_send(long sd, const void *buf, long len, long flags,
* Return the number of bytes transmitted, or -1 if an
* error occurred
*
- * 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.
- *
*****************************************************************************/
int send(long sd, const void *buf, long len, long flags)
@@ -1164,6 +1163,13 @@ int send(long sd, const void *buf, long len, long flags)
/*****************************************************************************
* Name: sendto
*
+ * 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
@@ -1178,13 +1184,6 @@ int send(long sd, const void *buf, long len, long flags)
* Return the number of bytes transmitted, or -1 if an
* error occurred
*
- * 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.
- *
*****************************************************************************/
int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
@@ -1196,6 +1195,9 @@ int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
/*****************************************************************************
* Name: mdnsAdvertiser
*
+ * 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
@@ -1206,9 +1208,6 @@ int sendto(long sd, const void *buf, long len, long flags, const sockaddr *to,
* On success, zero is returned, return SOC_ERROR if socket was not
* opened successfully, or if an error occurred.
*
- * Decription:
- * Set CC3000 in mDNS advertiser mode in order to advertise itself.
- * NOTE:
*****************************************************************************/
int mdnsAdvertiser(uint16_t mdnsEnabled, char * deviceServiceName,