SimpleLink CC3120/CC3220 Host Driver
Version 2.0.1.22
Simplifies the implementation of Internet connectivity
|
Controls standard client/server sockets programming options and capabilities. More...
Functions | |
_i16 | sl_Socket (_i16 Domain, _i16 Type, _i16 Protocol) |
Create an endpoint for communication. More... | |
_i16 | sl_Close (_i16 sd) |
Gracefully close socket. More... | |
_i16 | sl_Accept (_i16 sd, SlSockAddr_t *addr, SlSocklen_t *addrlen) |
Accept a connection on a socket. More... | |
_i16 | sl_Bind (_i16 sd, const SlSockAddr_t *addr, _i16 addrlen) |
Assign a name to a socket. More... | |
_i16 | sl_Listen (_i16 sd, _i16 backlog) |
Listen for connections on a socket. More... | |
_i16 | sl_Connect (_i16 sd, const SlSockAddr_t *addr, _i16 addrlen) |
Initiate a connection on a socket. More... | |
_i16 | sl_Select (_i16 nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, struct SlTimeval_t *timeout) |
Monitor socket activity. More... | |
_i16 | sl_SetSockOpt (_i16 sd, _i16 level, _i16 optname, const void *optval, SlSocklen_t optlen) |
Set socket options-. More... | |
_i16 | sl_GetSockOpt (_i16 sd, _i16 level, _i16 optname, void *optval, SlSocklen_t *optlen) |
Get socket options. More... | |
_i16 | sl_Recv (_i16 sd, void *buf, _i16 len, _i16 flags) |
Read data from TCP socket. More... | |
_i16 | sl_RecvFrom (_i16 sd, void *buf, _i16 len, _i16 flags, SlSockAddr_t *from, SlSocklen_t *fromlen) |
Read data from socket. More... | |
_i16 | sl_Send (_i16 sd, const void *buf, _i16 len, _i16 flags) |
Write data to TCP socket. More... | |
_i16 | sl_SendTo (_i16 sd, const void *buf, _i16 len, _i16 flags, const SlSockAddr_t *to, SlSocklen_t tolen) |
Write data to socket. More... | |
_u32 | sl_Htonl (_u32 val) |
Reorder the bytes of a 32-bit unsigned value. More... | |
_u16 | sl_Htons (_u16 val) |
Reorder the bytes of a 16-bit unsigned value. More... | |
Typedefs | |
typedef struct SlInAddr_t | SlInAddr_t |
typedef struct SlIn6Addr_t | SlIn6Addr_t |
typedef _i32 | SlTime_t |
typedef _i32 | SlSuseconds_t |
typedef struct SlTimeval_t | SlTimeval_t |
typedef _u16 | SlSocklen_t |
typedef struct SlSockAddr_t | SlSockAddr_t |
typedef struct SlSockAddrIn6_t | SlSockAddrIn6_t |
typedef struct SlSockAddrIn_t | SlSockAddrIn_t |
typedef struct SlFdSet_t | SlFdSet_t |
Controls standard client/server sockets programming options and capabilities.
_i16 sl_Accept | ( | _i16 | sd, |
SlSockAddr_t * | addr, | ||
SlSocklen_t * | addrlen | ||
) |
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 sl_Socket(), bound to a local address with sl_Bind(), and is listening for connections after a sl_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.
[in] | sd | Socket descriptor (handle) |
[out] | 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. The exact format of the address returned addr is determined by the socket's address sockaddr: - code for the address format. On this version only AF_INET is supported. - socket address, the length depends on the code format |
[out] | addrlen | The addrlen argument is a value-result argument: it should initially contain the size of the structure pointed to by addr |
Definition at line 708 of file sl_socket.c.
_i16 sl_Bind | ( | _i16 | sd, |
const SlSockAddr_t * | addr, | ||
_i16 | addrlen | ||
) |
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.
[in] | sd | Socket descriptor (handle) |
[in] | addr | Specifies the destination addrs sockaddr: - code for the address format. On this version only SL_AF_INET is supported. - socket address, the length depends on the code format |
[in] | addrlen | Contains the size of the structure pointed to by addr |
Definition at line 247 of file sl_socket.c.
_i16 sl_Close | ( | _i16 | sd | ) |
Gracefully close socket.
This function causes the system to release resources allocated to a socket.
In case of TCP, the connection is terminated.
[in] | sd | Socket handle (received in sl_Socket) |
Definition at line 187 of file sl_socket.c.
_i16 sl_Connect | ( | _i16 | sd, |
const SlSockAddr_t * | addr, | ||
_i16 | addrlen | ||
) |
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.
[in] | sd | Socket descriptor (handle) |
[in] | addr | Specifies the destination addr sockaddr: - code for the address format. On this version only AF_INET is supported. - socket address, the length depends on the code format |
[in] | addrlen | Contains the size of the structure pointed to by addr |
Definition at line 464 of file sl_socket.c.
_i16 sl_GetSockOpt | ( | _i16 | sd, |
_i16 | level, | ||
_i16 | optname, | ||
void * | optval, | ||
SlSocklen_t * | optlen | ||
) |
Get 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 proto- col 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 - ues 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.
[in] | sd | Socket handle |
[in] | level | Defines the protocol level for this option |
[in] | optname | defines the option name to interrogate |
[out] | optval | Specifies a value for the option |
[out] | optlen | Specifies the length of the option value |
Definition at line 986 of file sl_socket.c.
_u32 sl_Htonl | ( | _u32 | val | ) |
Reorder the bytes of a 32-bit unsigned value.
This function is used to Reorder the bytes of a 32-bit unsigned value from processor order to network order.
[in] | val | Variable to reorder |
Definition at line 813 of file sl_socket.c.
_u16 sl_Htons | ( | _u16 | val | ) |
Reorder the bytes of a 16-bit unsigned value.
This function is used to Reorder the bytes of a 16-bit unsigned value from processor order to network order.
[in] | val | Variable to reorder |
Definition at line 834 of file sl_socket.c.
_i16 sl_Listen | ( | _i16 | sd, |
_i16 | backlog | ||
) |
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.
[in] | sd | Socket descriptor (handle) |
[in] | backlog | Specifies the listen queue depth. |
Definition at line 672 of file sl_socket.c.
_i16 sl_Recv | ( | _i16 | sd, |
void * | buf, | ||
_i16 | len, | ||
_i16 | flags | ||
) |
Read data from TCP socket.
Function receives a message from a connection-mode socket
[in] | sd | Socket handle |
[out] | buf | Points to the buffer where the message should be stored. |
[in] | len | Specifies the length in bytes of the buffer pointed to by the buffer argument. Range: 1-16000 bytes |
[in] | flags | Specifies the type of message reception. On this version, this parameter is not supported. |
Definition at line 892 of file sl_socket.c.
_i16 sl_RecvFrom | ( | _i16 | sd, |
void * | buf, | ||
_i16 | len, | ||
_i16 | flags, | ||
SlSockAddr_t * | from, | ||
SlSocklen_t * | fromlen | ||
) |
Read data from socket.
Function receives a message from a connection-mode or connectionless-mode socket
[in] | sd | Socket handle |
[out] | buf | Points to the buffer where the message should be stored. |
[in] | len | Specifies the length in bytes of the buffer pointed to by the buffer argument. Range: 1-16000 bytes |
[in] | flags | Specifies the type of message reception. On this version, this parameter is not supported. |
[in] | from | Pointer to an address structure indicating the source address. sockaddr: - code for the address format. On this version only AF_INET is supported. - socket address, the length depends on the code format |
[in] | fromlen | Source address structure size. This parameter MUST be set to the size of the structure pointed to by addr. |
Definition at line 375 of file sl_socket.c.
_i16 sl_Select | ( | _i16 | nfds, |
SlFdSet_t * | readsds, | ||
SlFdSet_t * | writesds, | ||
SlFdSet_t * | exceptsds, | ||
struct SlTimeval_t * | timeout | ||
) |
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. If trigger mode is enabled the active fdset is the one that was retrieved in the first triggered call. To enable the trigger mode, an handler must be statically registered as slcb_SocketTriggerEventHandler in user.h
[in] | nfds | The highest-numbered file descriptor in any of the three sets, plus 1. |
[out] | readsds | Socket descriptors list for read monitoring and accept monitoring |
[out] | writesds | Socket descriptors list for connect monitoring only, write monitoring is not supported |
[out] | exceptsds | Socket descriptors list for exception monitoring, not supported. |
[in] | timeout | Is an upper bound on the amount of time elapsed before select() returns. Null or above 0xffff seconds means infinity timeout. The minimum timeout is 10 milliseconds, less than 10 milliseconds will be set automatically to 10 milliseconds. Max microseconds supported is 0xfffc00. In trigger mode the timout fields must be set to zero. |
Several threads can call sl_Select at the same time.Calling this API while the same command is called from another thread, may result in one of the following scenarios:
In case all the user sockets are open, sl_Select will exhibit the behaviour mentioned in (2) This is due to the fact sl_select supports multiple callers by utilizing one user socket internally. User who wish to ensure multiple select calls at any given time, must reserve one socket out of the 16 given.
Definition at line 1728 of file sl_socket.c.
_i16 sl_Send | ( | _i16 | sd, |
const void * | buf, | ||
_i16 | len, | ||
_i16 | flags | ||
) |
Write data to TCP socket.
This function is used to transmit a message to another socket. Returns immediately after sending data to device. In case of TCP failure an async event SL_SOCKET_TX_FAILED_EVENT is going to be received.
In case of a RAW socket (transceiver mode), extra 4 bytes should be reserved at the end of the frame data buffer for WLAN FCS
[in] | sd | Socket handle |
[in] | buf | Points to a buffer containing the message to be sent |
[in] | len | Message size in bytes. Range: 1-1460 bytes |
[in] | flags | Specifies the type of message transmission. On this version, this parameter is not supported for TCP. For transceiver mode, the SL_WLAN_RAW_RF_TX_PARAMS macro can be used to determine transmission parameters (channel,rate,tx_power,preamble) |
Definition at line 606 of file sl_socket.c.
_i16 sl_SendTo | ( | _i16 | sd, |
const void * | buf, | ||
_i16 | len, | ||
_i16 | flags, | ||
const SlSockAddr_t * | to, | ||
SlSocklen_t | tolen | ||
) |
Write data to socket.
This function is used to transmit a message to another socket (connection less socket SOCK_DGRAM, SOCK_RAW).
Returns immediately after sending data to device.
In case of transmission failure an async event SL_SOCKET_TX_FAILED_EVENT is going to be received.
[in] | sd | Socket handle |
[in] | buf | Points to a buffer containing the message to be sent |
[in] | len | message size in bytes. Range: 1-1460 bytes |
[in] | flags | Specifies the type of message transmission. On this version, this parameter is not supported |
[in] | to | Pointer to an address structure indicating the destination address. sockaddr: - code for the address format. On this version only AF_INET is supported. - socket address, the length depends on the code format |
[in] | tolen | Destination address structure size |
Definition at line 296 of file sl_socket.c.
_i16 sl_SetSockOpt | ( | _i16 | sd, |
_i16 | level, | ||
_i16 | optname, | ||
const void * | optval, | ||
SlSocklen_t | optlen | ||
) |
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 proto- col 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 - ues 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.
[in] | sd | Socket handle |
[in] | level | Defines the protocol level for this option
|
[in] | optname | Defines the option name to interrogate
|
[in] | optval | Specifies a value for the option |
[in] | optlen | Specifies the length of the option value |
Definition at line 943 of file sl_socket.c.
_i16 sl_Socket | ( | _i16 | Domain, |
_i16 | Type, | ||
_i16 | Protocol | ||
) |
Create an endpoint for communication.
The socket function creates a new socket of a certain socket type, identified by an integer number, and allocates system resources to it.
This function is called by the application layer to obtain a socket handle.
[in] | Domain | Specifies the protocol family of the created socket. For example:
|
[in] | Type | specifies the communication semantic, one of:
|
[in] | Protocol | specifies a particular transport to be used with the socket. The most common are
|
Definition at line 143 of file sl_socket.c.
struct SlInAddr_t |
Definition at line 221 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | s_addr | |
union S_un | S_un |
struct SlIn6Addr_t |
Definition at line 235 of file sl_socket.h.
Data Fields | ||
---|---|---|
union SlIn6Addr_t | _S6_un |
union SlIn6Addr_t._S6_un |
Definition at line 237 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | _S6_u32[4] | |
_u8 | _S6_u8[16] |
struct SlSockKeepalive_t |
Definition at line 246 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | KeepaliveEnabled |
struct SlSockReuseaddr_t |
Definition at line 251 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | ReuseaddrEnabled |
struct SlSockRxNoIpBoundary_t |
Definition at line 256 of file sl_socket.h.
Data Fields | ||
---|---|---|
_i32 | RxIpNoBoundaryEnabled |
struct SlSockWinsize_t |
Definition at line 262 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | WinSize |
struct SlSockNonblocking_t |
Definition at line 267 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | NonBlockingEnabled |
struct SlSocketAsyncEvent_t |
Definition at line 272 of file sl_socket.h.
Data Fields | ||
---|---|---|
_i8 | pExtraInfo[128] | |
_u8 | Sd | |
_u8 | Type | |
_i16 | Val |
struct SlSockTxFailEventData_t |
Definition at line 280 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u8 | Padding | |
_u8 | Sd | |
_i16 | Status |
union SlSockEventData_u |
Definition at line 288 of file sl_socket.h.
Data Fields | ||
---|---|---|
SlSocketAsyncEvent_t | SockAsyncData | |
SlSockTxFailEventData_t | SockTxFailData |
struct SlSockEvent_t |
Definition at line 295 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | Event | |
SlSockEventData_u | SocketAsyncEvent |
struct SlSockTriggerEvent_t |
Definition at line 301 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | Event | |
_u32 | EventData |
struct SlSockSecureALPN_t |
Definition at line 308 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | SecureALPN |
struct SlSockSecureMask_t |
Definition at line 313 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | SecureMask |
struct SlSockSecureMethod_t |
Definition at line 318 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u8 | SecureMethod |
struct SlSockSSLCertInfo_t |
Definition at line 323 of file sl_socket.h.
struct SlSockSSLConnectionParams_t |
Definition at line 337 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | SecureALPNChosenProtocol | |
_u32 | SecureCipherSuit | |
_u32 | SecureIsPeerValidated | |
SlSockSSLCertInfo_t | SecurePeerCertinfo | |
_u32 | SecureVersion |
struct SlSockIpMreq_t |
Definition at line 360 of file sl_socket.h.
Data Fields | ||
---|---|---|
SlInAddr_t | imr_interface | |
SlInAddr_t | imr_multiaddr |
struct SlSockIpV6Mreq_t |
Definition at line 366 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | ipv6mr_interface | |
SlIn6Addr_t | ipv6mr_multiaddr |
struct SlSocklinger_t |
Definition at line 371 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | l_linger | |
_u32 | l_onoff |
struct SlTimeval_t |
Definition at line 381 of file sl_socket.h.
Data Fields | ||
---|---|---|
SlTime_t | tv_sec | |
SlSuseconds_t | tv_usec |
struct SlSockAddr_t |
Definition at line 390 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u8 | sa_data[14] | |
_u16 | sa_family |
struct SlSockAddrIn6_t |
Definition at line 397 of file sl_socket.h.
Data Fields | ||
---|---|---|
SlIn6Addr_t | sin6_addr | |
_u16 | sin6_family | |
_u32 | sin6_flowinfo | |
_u16 | sin6_port | |
_u32 | sin6_scope_id |
struct SlSockAddrIn_t |
Definition at line 408 of file sl_socket.h.
Data Fields | ||
---|---|---|
SlInAddr_t | sin_addr | |
_u16 | sin_family | |
_u16 | sin_port | |
_i8 | sin_zero[8] |
struct SlSockSecureFiles_t |
Definition at line 417 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u8 | SecureFiles[4] |
struct SlFdSet_t |
Definition at line 423 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u32 | fd_array[(SL_FD_SETSIZE+(_u8) 31)/(_u8) 32] |
struct SlTransceiverRxOverHead_t |
Definition at line 428 of file sl_socket.h.
Data Fields | ||
---|---|---|
_u8 | Channel | |
_u8 | Padding | |
_u8 | Rate | |
_i8 | Rssi | |
_u32 | Timestamp |