![]() |
SimpleLink Host Driver
0.0.5.1
|
Macros | |
#define | sl_Ntohl sl_Htonl /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */ |
#define | sl_Ntohs sl_Htons /* Reorder the bytes of a 16-bit unsigned value from network order to processor orde. */ |
Functions | |
int | sl_Socket (int Domain, int Type, int Protocol) |
create an endpoint for communication More... | |
int | sl_Close (int sd) |
gracefully close socket More... | |
int | sl_Accept (int sd, SlSockAddr_t *addr, SlSocklen_t *addrlen) |
Accept a connection on a socket. More... | |
int | sl_Bind (int sd, const SlSockAddr_t *addr, int addrlen) |
assign a name to a socket More... | |
int | sl_Listen (int sd, int backlog) |
listen for connections on a socket More... | |
int | sl_Connect (int sd, const SlSockAddr_t *addr, int addrlen) |
Initiate a connection on a socket. More... | |
int | sl_Select (int nfds, SlFdSet_t *readsds, SlFdSet_t *writesds, SlFdSet_t *exceptsds, struct SlTimeval_t *timeout) |
Monitor socket activity. More... | |
void | SL_FD_SET (int fd, SlFdSet_t *fdset) |
Select's SlFdSet_t SET function. More... | |
void | SL_FD_CLR (int fd, SlFdSet_t *fdset) |
Select's SlFdSet_t CLR function. More... | |
int | SL_FD_ISSET (int fd, SlFdSet_t *fdset) |
Select's SlFdSet_t ISSET function. More... | |
void | SL_FD_ZERO (SlFdSet_t *fdset) |
Select's SlFdSet_t ZERO function. More... | |
int | sl_SetSockOpt (int sd, int level, int optname, const void *optval, SlSocklen_t optlen) |
set socket options More... | |
int | sl_GetSockOpt (int sd, int level, int optname, void *optval, SlSocklen_t *optlen) |
Get socket options. More... | |
int | sl_Recv (int sd, void *buf, int Len, int flags) |
read data from TCP socket More... | |
int | sl_RecvFrom (int sd, void *buf, int Len, int flags, SlSockAddr_t *from, SlSocklen_t *fromlen) |
read data from socket More... | |
int | sl_Send (int sd, const void *buf, int Len, int flags) |
write data to TCP socket More... | |
int | sl_SendTo (int sd, const void *buf, int Len, int flags, const SlSockAddr_t *to, SlSocklen_t tolen) |
write data to socket More... | |
unsigned long | sl_Htonl (unsigned long val) |
Reorder the bytes of a 32-bit unsigned value. More... | |
unsigned short | sl_Htons (unsigned short val) |
Reorder the bytes of a 16-bit unsigned value. More... | |
int sl_Accept | ( | int | 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 |
int sl_Bind | ( | int | sd, |
const SlSockAddr_t * | addr, | ||
int | 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 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 |
int sl_Close | ( | int | 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) |
int sl_Connect | ( | int | sd, |
const SlSockAddr_t * | addr, | ||
int | 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 |
void SL_FD_CLR | ( | int | fd, |
SlFdSet_t * | fdset | ||
) |
int SL_FD_ISSET | ( | int | fd, |
SlFdSet_t * | fdset | ||
) |
Select's SlFdSet_t ISSET function.
Checks if current socket descriptor is set (TRUE/FALSE)
void SL_FD_SET | ( | int | fd, |
SlFdSet_t * | fdset | ||
) |
void SL_FD_ZERO | ( | SlFdSet_t * | fdset | ) |
int sl_GetSockOpt | ( | int | sd, |
int | level, | ||
int | 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 |
unsigned long sl_Htonl | ( | unsigned long | 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] | var | variable to reorder |
unsigned short sl_Htons | ( | unsigned short | 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] | var | variable to reorder |
int sl_Listen | ( | int | sd, |
int | 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. |
int sl_Recv | ( | int | sd, |
void * | buf, | ||
int | Len, | ||
int | 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. |
int sl_RecvFrom | ( | int | sd, |
void * | buf, | ||
int | Len, | ||
int | 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. |
int sl_Select | ( | int | 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
[in] | nfds | the highest-numbered file descriptor in any of the three sets, plus 1. |
[out] | writesds | socket descriptors list for write monitoring |
[out] | readsds | socket descriptors list for read monitoring |
[out] | exceptsds | socket descriptors list for exception monitoring |
[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. |
Only one sl_Select can be handled at a time. Calling this API while the same command is called from another thread, may result in one of the two scenarios:
int sl_Send | ( | int | sd, |
const void * | buf, | ||
int | Len, | ||
int | 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_NETAPP_SOCKET_TX_FAILED 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_RAW_RF_TX_PARAMS macro can be used to determine transmission parameters (channel,rate,tx_power,preamble) |
int sl_SendTo | ( | int | sd, |
const void * | buf, | ||
int | Len, | ||
int | 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_NETAPP_SOCKET_TX_FAILED 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 |
int sl_SetSockOpt | ( | int | sd, |
int | level, | ||
int | 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 |
int sl_Socket | ( | int | Domain, |
int | Type, | ||
int | 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: AF_INET for network protocol IPv4 AF_RF for starting transceiver mode. Notes:
|
[in] | type | specifies the communication semantic, one of: SOCK_STREAM (reliable stream-oriented service or Stream Sockets) SOCK_DGRAM (datagram service or Datagram Sockets) SOCK_SEQPACKET (reliable sequenced packet service) SOCK_RAW (raw protocols atop the network layer) when used with AF_RF: SOCK_DGRAM - L2 socket SOCK_RAW - L1 socket - bypass WLAN CCA (Clear Channel Assessment) |
[in] | protocol | specifies a particular transport to be used with the socket. The most common are IPPROTO_TCP, IPPROTO_SCTP, IPPROTO_UDP, IPPROTO_DCCP. The value 0 may be used to select a default protocol from the selected domain and type |