BSD Sockets#

Functions#

int32_t
rsi_web_socket_create(int8_t flags, uint8_t *server_ip_addr, uint16_t server_port, uint16_t device_port, uint8_t *webs_resource_name, uint8_t *webs_host_name, int32_t *socket_id, void(*web_socket_data_receive_notify_callback)(uint32_t sock_no, uint8_t *buffer, uint32_t length))

Create a web socket client. This is a non-blocking API.

int32_t
rsi_web_socket_send_async(int32_t sockID, uint8_t opcode, int8_t *msg, int32_t msg_length)

Send data from the web socket client. This is a non-blocking API.

int32_t
rsi_web_socket_close(int32_t sockID)

Close the web socket client. This is a non-blocking API.

int
rsi_fd_isset(uint32_t fd, struct rsi_fd_set_s *fds_p)

Check for the bit set in the bitmap. This is a non-blocking API.

void
rsi_set_fd(uint32_t fd, struct rsi_fd_set_s *fds_p)

Set the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.

void
rsi_fd_clr(uint32_t fd, struct rsi_fd_set_s *fds_p)

Clear the bit in the bitmap. This is a non-blocking API.

int32_t
rsi_socket_async(int32_t protocolFamily, int32_t type, int32_t protocol, void(*callback)(uint32_t sock_no, uint8_t *buffer, uint32_t length))

Create a socket and register a callback that will be used by the driver to forward the received packets asynchronously to the application (on packet reception) without waiting for recv API call. This is a non-blocking API.

int32_t
rsi_socket(int32_t protocolFamily, int32_t type, int32_t protocol)

Create and return a socket instance, also referred to as an endpoint of communication. This is a non-blocking API.

int32_t
rsi_bind(int32_t sockID, struct rsi_sockaddr *localAddress, int32_t addressLength)

Assign an address to a socket. This is a non-blocking API for TCP and a blocking API for UDP.

int32_t
rsi_connect(int32_t sockID, struct rsi_sockaddr *remoteAddress, int32_t addressLength)

Connect the socket to the specified remote address. This is a non-blocking API if socket_connect_response handler() is registered through rsi_wlan_register_callbacks(), otherwise it is a blocking API.

int32_t
rsi_listen(int32_t sockID, int32_t backlog)

Enable socket to listen for a remote connection request in passive mode. This is a blocking API.

int32_t
rsi_accept_non_rom(int32_t sockID, struct rsi_sockaddr *ClientAddress, int32_t *addressLength)

Accept the connection request from the remote peer. This API extracts the connection request from the queue of pending connections on listening socket and accepts it.

int32_t
rsi_accept(int32_t sockID, struct rsi_sockaddr *ClientAddress, int32_t *addressLength)

Accept the connection request from the remote peer. This API extracts the connection request from the queue of pending connections on listening socket and accepts it. This is a blocking API.

int32_t
rsi_recv_large_data_sync(int32_t sockID, int8_t *buffer, int32_t requested_length, int32_t flags, struct rsi_sockaddr *fromAddr, int32_t *fromAddrLen)

Receive large data on a given socket synchronously.

int32_t
rsi_recvfrom(int32_t sockID, int8_t *buffer, int32_t buffersize, int32_t flags, struct rsi_sockaddr *fromAddr, int32_t *fromAddrLen)

Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.

int32_t
rsi_recv(int32_t sockID, void *rcvBuffer, int32_t bufferLength, int32_t flags)

Retrieve the data from the remote peer on a specified socket. This is a blocking API.

int32_t
rsi_sendto(int32_t sockID, int8_t *msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr *destAddr, int32_t destAddrLen)

Send data to specific remote peer on a given socket synchronously. This is a blocking API.

int32_t
rsi_sendto_async(int32_t sockID, int8_t *msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr *destAddr, int32_t destAddrLen, void(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data to specific remote peer on a given socket asynchronously.

int32_t
rsi_send(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags)

Send data to remote peer on a given socket synchronously. This is a blocking API.

void

Reset all the socket related information.

int32_t
rsi_send_large_data_sync(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags)

Send large data on a given socket synchronously.

void
rsi_chunk_data_tx_done_cb(int32_t sockID, const uint16_t length)

Callback function used to send one chunk of data at a time.

int32_t
rsi_send_large_data_async(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags, void(*rsi_sock_data_tx_done_cb)(int32_t sockID, int16_t status, uint16_t total_data_sent))

Send large data on a given socket. This is a blocking API.

uint32_t
rsi_find_socket_data_pending(uint32_t event_map)

Find which socket the data is pending, according to the event that is set from the map.

void

Retrieve the packet from protocol TX data pending queue and forward to the module.

int32_t
rsi_send_async(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags, void(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data on a given socket asynchronously.

int32_t
rsi_shutdown(int32_t sockID, int32_t how)

Closes the socket specified in a socket descriptor. This is a blocking API.

int32_t

Get the application socket descriptor from module socket descriptor.

void
rsi_clear_sockets(int32_t sockID)

Clear socket information.

int
rsi_fill_tls_extension(int32_t sockID, int extension_type, const void *option_value, rsi_socklen_t extension_len)

Configure TLS extensions.

int
rsi_setsockopt(int32_t sockID, int level, int option_name, const void *option_value, rsi_socklen_t option_len)

Set the socket options. This is a non-blocking API.

int
rsi_getsockopt(int32_t sockID, int level, int option_name, const void *option_value, rsi_socklen_t option_len)

Get the socket options. This is a non-blocking API.

int32_t
rsi_select(int32_t nfds, rsi_fd_set *readfds, rsi_fd_set *writefds, rsi_fd_set *exceptfds, struct rsi_timeval *timeout, void(*callback)(rsi_fd_set *fd_read, rsi_fd_set *fd_write, rsi_fd_set *fd_except, int32_t status))

Select is a BSD API which allow a program to monitor multiple socket (file descriptors), waiting until one or more of the sockets become ready to perform receive or send operation.If callback is NULL or not provided, it is a blocking API otherwise it is a non-blocking API.

uint8_t
calculate_buffers_required(uint8_t type, uint16_t length)

Calculate the buffers required.

int32_t
rsi_accept_async(int32_t sockID, void(*callback)(int32_t sock_id, int16_t dest_port, uint8_t *ip_addr, int16_t ip_version))

Accept the connection request from the remote peer and register a callback that will be used by the driver to forward the received connection request asynchronously to the application. This is a non-blocking API.

int32_t

Get the application socket descriptor from available socket pool.

int32_t
rsi_get_socket_id(uint32_t src_port, uint32_t dst_port)

Function to get the primary socket ID from port number.

int32_t
rsi_get_primary_socket_id(uint8_t *port_num)

Get the primary socket ID from port number.

int32_t
rsi_certificate_valid(uint16_t valid, uint16_t socket_id)

Host indicate the status to module after validating the server certificate received from module. This is a non-blocking API.

int32_t
rsi_socket_create_async(int32_t sockID, int32_t type, int32_t backlog)

Send socket create request to the module and receive the response asynchronously. This is a non-blocking API if socket_connect_response_handler is registered. Otherwise it is a blocking API.

int32_t
rsi_get_socket_descriptor(uint8_t *src_port, uint8_t *dst_port, uint8_t *ip_addr, uint16_t ip_version, uint16_t sockid)

Get the primary socket ID based on source port number, destination port number, destination IP address, and the IP version. This is a non-blocking API.

int32_t
rsi_socket_async_non_rom(int32_t protocolFamily, int32_t type, int32_t protocol, void(*callback)(uint32_t sock_no, uint8_t *buffer, uint32_t length))

Create a socket and register a callback that will be used by the driver to forward the received packets asynchronously to the application (on packet reception) without waiting for recv API call. This is a non-blocking API.

int32_t
rsi_socket_connect(int32_t sockID, struct rsi_sockaddr *remoteAddress, int32_t addressLength)

Connect the socket to specified remote address. This is a non-blocking API if socket_connect_response handler() is registered through rsi_wlan_register_callbacks() otherwise it is a blocking API.

int32_t
rsi_socket_recvfrom(int32_t sockID, int8_t *buffer, int32_t buffersize, int32_t flags, struct rsi_sockaddr *fromAddr, int32_t *fromAddrLen)

Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.

int32_t
rsi_socket_listen(int32_t sockID, int32_t backlog)

Enable socket to listen for remote connection request in passive mode. This is a blocking API.

int32_t
rsi_socket_shutdown(int32_t sockID, int32_t how)

Close the socket specified in a socket descriptor. This is a blocking API.

int32_t
rsi_socket_bind(int32_t sockID, struct rsi_sockaddr *localAddress, int32_t addressLength)

Assign address to the socket. This is a non-blocking API for TCP and a blocking API for UDP.

rsi_error_t
rsi_wait_on_socket_semaphore(rsi_semaphore_handle_t *semaphore, uint32_t timeout_ms)

Wireless Library to acquire or wait for NWK semaphore.

int32_t

Get the application socket descriptor from module socket descriptor. This is a non-blocking API.

int32_t

Return WLAN status. This is a non-blocking API.

void
rsi_wlan_socket_set_status(int32_t status, int32_t sockID)

Set WLAN status. This is a non-blocking API.

int32_t
rsi_select_get_status(int32_t selectid)

Get the status of the socket specified in the select ID.

void
rsi_select_set_status(int32_t status, int32_t selectid)

Set the status of the socket specified in the select ID.

int32_t
rsi_send_async_non_rom(int32_t sockID, const int8_t *msg, int32_t msgLength, int32_t flags, void(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data on a given socket asynchronously.

int32_t
rsi_sendto_async_non_rom(int32_t sockID, int8_t *msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr *destAddr, int32_t destAddrLen, void(*data_transfer_complete_handler)(int32_t sockID, uint16_t length))

Send data to specific remote peer on a given socket.

void

Clear socket information.

int32_t
ROM_WL_rsi_get_application_socket_descriptor(global_cb_t *global_cb_p, int32_t sock_id)

Get the application socket descriptor from module socket descriptor. This is a non-blocking API.

int32_t
ROM_WL_rsi_get_primary_socket_id(global_cb_t *global_cb_p, uint16_t port_number)

Get socket descriptor from port_number. This is a non-blocking API.

uint8_t
ROM_WL_calculate_buffers_required(global_cb_t *global_cb_p, uint8_t type, uint16_t length)

Calculate number of buffers required for the data packet. This is a non-blocking API.

uint16_t
ROM_WL_calculate_length_to_send(global_cb_t *global_cb_p, uint8_t type, uint8_t buffers)

Caluculate the msg length sent using available buffers. This is a non-blocking API.

int32_t

Set the socket configuration parameters. Using this command (optional) is highly recommended. Based on the socket configuration, module will use available buffers effectively. This is a blocking API.

Function Documentation#

rsi_web_socket_create#

int32_t rsi_web_socket_create (int8_t flags, uint8_t * server_ip_addr, uint16_t server_port, uint16_t device_port, uint8_t * webs_resource_name, uint8_t * webs_host_name, int32_t * socket_id, void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length) web_socket_data_receive_notify_callback, sock_no, buffer, length)

Create a web socket client. This is a non-blocking API.

Parameters
[in]flags

- Select IP version and security BIT(0) - RSI_IPV6 Set this bit to enable IPv6 , by default it is configured to IPv4 BIT(1) - RSI_SSL_ENABLE Set this bit to enable SSL feature

[in]server_ip_addr

- Web server IP address

[in]server_port

- Web server socket port

[in]device_port

- Local port

[in]webs_resource_name

- Web resource name

[in]webs_host_name

- Web host name

[in]socket_id

- Socket id

[in]web_socket_data_receive_notify_callback

- Callback when data packet is received on the created socket

[out]sock_no

- Application socket ID

[out]buffer

- Buffer pointer

[out]length

- Length of data

Returns

  • Zero - Success Negative Value - Failure -2 - Invalid parameter -4 - Buffer not available to serve the command


Definition at line 51 of file network/protocols/rsi_web_socket.c

rsi_web_socket_send_async#

int32_t rsi_web_socket_send_async (int32_t sockID, uint8_t opcode, int8_t * msg, int32_t msg_length)

Send data from the web socket client. This is a non-blocking API.

Parameters
[in]sockID

- Application socket id

[in]opcode

- opcode (type of the packet to be included in web socket header).

[in]msg

- Data

[in]msg_length

- Data length

Returns

  • 0 - Success Negative Value - Failure


Definition at line 328 of file network/protocols/rsi_web_socket.c

rsi_web_socket_close#

int32_t rsi_web_socket_close (int32_t sockID)

Close the web socket client. This is a non-blocking API.

Parameters
[in]sockID

- Socket id of particular socket

Returns

  • 0 - Success Negative Value - Failure


Definition at line 350 of file network/protocols/rsi_web_socket.c

rsi_fd_isset#

int rsi_fd_isset (uint32_t fd, struct rsi_fd_set_s * fds_p)

Check for the bit set in the bitmap. This is a non-blocking API.

Parameters
[in]fd

- Socket id

[in]fds_p

- Pointer to the rsi_fd_set_s structure

Returns

  • Positive Value - Success Zero - Failure


Definition at line 40 of file network/socket/rsi_socket.c

rsi_set_fd#

void rsi_set_fd (uint32_t fd, struct rsi_fd_set_s * fds_p)

Set the bit for the file descriptor FD in the file descriptor set rsi_fd_set. This is a non-blocking API.

Parameters
[in]fd

- Socket id

[in]fds_p

- Pointer to the rsi_fd_set_structure

Returns

  • Void


Definition at line 58 of file network/socket/rsi_socket.c

rsi_fd_clr#

void rsi_fd_clr (uint32_t fd, struct rsi_fd_set_s * fds_p)

Clear the bit in the bitmap. This is a non-blocking API.

Parameters
[in]fd

- Socket id

[in]fds_p

- Pointer to the rsi_fd_set_s structure

Returns

  • Void


Definition at line 76 of file network/socket/rsi_socket.c

rsi_socket_async#

int32_t rsi_socket_async (int32_t protocolFamily, int32_t type, int32_t protocol, void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length) callback, sock_no, buffer, length)

Create a socket and register a callback that will be used by the driver to forward the received packets asynchronously to the application (on packet reception) without waiting for recv API call. This is a non-blocking API.

Parameters
[in]protocolFamily

- Protocol family to select IPv4 or IPv6 AF_INET (2) : Select IPv4 AF_INET6 (3) : Select IPv6

[in]type

- Select socket type UDP or TCP SOCK_STREAM (1) : Select TCP SOCK_DGRM (2) : Select UDP

[in]protocol

- 0: Non SSL sockets 1: SSL sockets BIT(5) Must be enabled to select the certificate index 0<<12 for index 0 1<<12 for index 1 Note: Certificates must be loaded in to RAM to select the certificate index feature.

[in]callback

- Callback function to read data asynchronously from socket

[out]sock_no

- Application socket number

[out]buffer

- Pointer to buffer that holds data

[out]length

- Length of the buffer

Returns

  • Succes - RSI_SUCCESS Failure - Negative Value Possible error codes : 0xFFF8, 0xFF80, 0xFF6D, 0xFF85, 0xBB33, 0xBB22

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 113 of file network/socket/rsi_socket.c

rsi_socket#

int32_t rsi_socket (int32_t protocolFamily, int32_t type, int32_t protocol)

Create and return a socket instance, also referred to as an endpoint of communication. This is a non-blocking API.

Parameters
[in]protocolFamily

- Protocol family to select IPv4 or IPv6 AF_INET (2): Select IPv4 AF_INET6 (3): Select IPv6

[in]type

- Select socket type UDP or TCP SOCK_STREAM (1): Select TCP TCP SOCK_DGRM (2): Select UDP

[in]protocol

- 0: Non SSL sockets 1: SSL sockets BIT(5) Must be enabled to select the certificate index 0<<12 for index 0 1<<12 for index 1 Note: Certificates must be loaded in to RAM to select the certificate index feature.

Returns

  • Success - Return sock_id of the created socket Failure - Non-Zero value

RSI_ERROR_COMMAND_GIVEN_IN_WRONG_STATE - Command entered in wrong state

RSI_SOCK_ERROR - Error in creating socket


Definition at line 150 of file network/socket/rsi_socket.c

rsi_bind#

int32_t rsi_bind (int32_t sockID, struct rsi_sockaddr * localAddress, int32_t addressLength)

Assign an address to a socket. This is a non-blocking API for TCP and a blocking API for UDP.

Parameters
[in]sockID

- Socket descriptor ID

[in]localAddress

- Address assigned to the socket. The format is compatible with BSD socket

[in]addressLength

- Length of the address measured in bytes

Returns

  • Zero - Success Negative Value - Failure


Definition at line 187 of file network/socket/rsi_socket.c

rsi_connect#

int32_t rsi_connect (int32_t sockID, struct rsi_sockaddr * remoteAddress, int32_t addressLength)

Connect the socket to the specified remote address. This is a non-blocking API if socket_connect_response handler() is registered through rsi_wlan_register_callbacks(), otherwise it is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]remoteAddress

- Remote peer address. The format is compatible with BSD socket.

[in]addressLength

- Length of the address in bytes

Returns

  • Zero - Success Negative Value - Failure

Note

  • For asynchronous behaviour, user needs to register RSI_WLAN_SOCKET_CONNECT_NOTIFY_CB callback id.


Definition at line 209 of file network/socket/rsi_socket.c

rsi_listen#

int32_t rsi_listen (int32_t sockID, int32_t backlog)

Enable socket to listen for a remote connection request in passive mode. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]backlog

- Maximum length to which the queue of pending connections can be held

  • rsi_bind() API needs to be called before this API.

Returns

  • Zero - Success Negative Value - Failure


Definition at line 230 of file network/socket/rsi_socket.c

rsi_accept_non_rom#

int32_t rsi_accept_non_rom (int32_t sockID, struct rsi_sockaddr * ClientAddress, int32_t * addressLength)

Accept the connection request from the remote peer. This API extracts the connection request from the queue of pending connections on listening socket and accepts it.

Parameters
[in]sockID

- Socket descriptor ID

[in]ClientAddress

- Remote peer address

[in]addressLength

- Length of the address measured in bytes

Returns

  • Zero - Success Negative Value - Failure


Definition at line 248 of file network/socket/rsi_socket.c

rsi_accept#

int32_t rsi_accept (int32_t sockID, struct rsi_sockaddr * ClientAddress, int32_t * addressLength)

Accept the connection request from the remote peer. This API extracts the connection request from the queue of pending connections on listening socket and accepts it. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor

[in]ClientAddress

- Remote peer address

[in]addressLength

- Length of the address measured in bytes

Returns

  • Zero - Success Negative Value - Failure


Definition at line 477 of file network/socket/rsi_socket.c

rsi_recv_large_data_sync#

int32_t rsi_recv_large_data_sync (int32_t sockID, int8_t * buffer, int32_t requested_length, int32_t flags, struct rsi_sockaddr * fromAddr, int32_t * fromAddrLen)

Receive large data on a given socket synchronously.

Parameters
[in]sockID

- Socket descriptor

[in]buffer

- Pointer to buffer to hold receive data

[in]requested_length

- Requested buffer length

[in]flags

- Reserved

[in]fromAddr

- Address of remote peer, from where current packet was received

[in]fromAddrLen

- Pointer that contains remote peer address (fromAddr) length

Returns

  • Positive Value - Success, returns the number of bytes received successfully Negative Value - Failure zero - Socket close error


Definition at line 497 of file network/socket/rsi_socket.c

Referenced by rsi_recvfrom , and rsi_recv

rsi_recvfrom#

int32_t rsi_recvfrom (int32_t sockID, int8_t * buffer, int32_t buffersize, int32_t flags, struct rsi_sockaddr * fromAddr, int32_t * fromAddrLen)

Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor

[in]buffer

- Pointer to buffer to hold receive data

[in]buffersize

- Size of the buffer supplied

[in]flags

- Reserved

[in]fromAddr

- Address of remote peer, from where current packet was received

[in]fromAddrLen

- Pointer that contains remote peer address (fromAddr) length

Returns

  • Positive Value - Success, returns the number of bytes received successfully Negative Value - Failure zero - Socket close error


Definition at line 575 of file network/socket/rsi_socket.c

rsi_recv#

int32_t rsi_recv (int32_t sockID, void * rcvBuffer, int32_t bufferLength, int32_t flags)

Retrieve the data from the remote peer on a specified socket. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]rcvBuffer

- Pointer to the buffer to hold the data received from the remote peer

[in]bufferLength

- Length of the buffer

[in]flags

- Reserved

Returns

  • Positive Value - Success, returns the number of bytes received successfully Negative Value - Failure zero - Socket close error


Definition at line 614 of file network/socket/rsi_socket.c

rsi_sendto#

int32_t rsi_sendto (int32_t sockID, int8_t * msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr * destAddr, int32_t destAddrLen)

Send data to specific remote peer on a given socket synchronously. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

- Pointer to data buffer containing data to send to remote peer

[in]msgLength

- Length of the buffer

[in]flags

- Reserved

[in]destAddr

- Address of the remote peer to send data

[in]destAddrLen

- Length of the address in bytes

Returns

  • Positive Value - Success, returns the number of bytes sent successfully Negative Value - Failure zero - Socket close error


Definition at line 652 of file network/socket/rsi_socket.c

rsi_sendto_async#

int32_t rsi_sendto_async (int32_t sockID, int8_t * msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr * destAddr, int32_t destAddrLen, void(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)

Send data to specific remote peer on a given socket asynchronously.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

- Pointer to data buffer containing data to send to remote peer

[in]msgLength

- Length of data to send

[in]flags

- Reserved

[in]destAddr

- Address of the remote peer to send data

[in]destAddrLen

- Length of the address in bytes

[in]data_transfer_complete_handler

- Pointer to callback function called after complete data transfer

[out]sockID

- Socket Descriptor ID

[out]length

- Number of bytes transfered

Returns

  • Positive Value - Success, returns the number of bytes sent successfully Negative Value - Failure zero - Socket close error


Definition at line 685 of file network/socket/rsi_socket.c

rsi_send#

int32_t rsi_send (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags)

Send data to remote peer on a given socket synchronously. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

- Pointer to the buffer containing data to send to the remote peer

[in]msgLength

- Length of the buffer

[in]flags

- Reserved

Returns

  • Positive Value - Success, returns the number of bytes sent successfully Negative Value - Failure Zero Value - Socket close error


Definition at line 715 of file network/socket/rsi_socket.c

rsi_reset_per_socket_info#

void rsi_reset_per_socket_info (int32_t sockID)

Reset all the socket related information.

Parameters
[in]sockID

- Socket descriptor ID

Returns

  • Void


Definition at line 738 of file network/socket/rsi_socket.c

rsi_send_large_data_sync#

int32_t rsi_send_large_data_sync (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags)

Send large data on a given socket synchronously.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

- Pointer to data that needs to be sent to remote peer

[in]msgLength

- Length of data to send

[in]flags

- Reserved

Returns

  • Zero - Success Negative Value - Failure


Definition at line 763 of file network/socket/rsi_socket.c

rsi_chunk_data_tx_done_cb#

void rsi_chunk_data_tx_done_cb (int32_t sockID, const uint16_t length)

Callback function used to send one chunk of data at a time.

Parameters
[in]sockID

- Socket descriptor ID

[in]length

- Length of data to send

Returns

  • Void


Definition at line 826 of file network/socket/rsi_socket.c

rsi_send_large_data_async#

int32_t rsi_send_large_data_async (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags, void(*)(int32_t sockID, int16_t status, uint16_t total_data_sent) rsi_sock_data_tx_done_cb, sockID, status, total_data_sent)

Send large data on a given socket. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

- Pointer to data that needs to be sent to remote peer

[in]msgLength

- Length of data to send

[in]flags

- Reserved

[in]rsi_sock_data_tx_done_cb

- Pointer to the callback function that will be called after one chunk of data transfer completion

[out]sockID

- Application socket ID

[out]status

- Status of the data transfer

[out]total_data_sent

- Total length of data sent

Returns

  • Zero - Success, number of bytes sent successfully Negative Value - Failure


Definition at line 917 of file network/socket/rsi_socket.c

rsi_find_socket_data_pending#

uint32_t rsi_find_socket_data_pending (uint32_t event_map)

Find which socket the data is pending, according to the event that is set from the map.

Parameters
[in]event_map

- Event map

Returns

  • SockID - Return the SockID from the event map


Definition at line 999 of file network/socket/rsi_socket.c

rsi_socket_event_handler#

void rsi_socket_event_handler (void )

Retrieve the packet from protocol TX data pending queue and forward to the module.

Parameters
[in]

Returns

  • Void


Definition at line 1020 of file network/socket/rsi_socket.c

rsi_send_async#

int32_t rsi_send_async (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags, void(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)

Send data on a given socket asynchronously.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

- Pointer to the buffer containing data to send to the remote peer

[in]msgLength

- Length of the buffer

[in]flags

- Reserved

[in]data_transfer_complete_handler

- Pointer to callback function called after complete data transfer

[out]sockID

- Socket Descriptor ID

[out]length

- Number of bytes transfered

Returns

  • Positive Value - Success, returns the number of bytes sent successfully Negative Value - Failure Zero Value - Socket close error


Definition at line 1055 of file network/socket/rsi_socket.c

rsi_shutdown#

int32_t rsi_shutdown (int32_t sockID, int32_t how)

Closes the socket specified in a socket descriptor. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]how

- 0: Close the specified socket 1: Close all the sockets open on a specified socket's source port number

Returns

  • 0 - Success Negative Value - Failure


Definition at line 1080 of file network/socket/rsi_socket.c

rsi_get_application_socket_descriptor#

int32_t rsi_get_application_socket_descriptor (int32_t sock_id)

Get the application socket descriptor from module socket descriptor.

Parameters
[in]sock_id

- Module's socket descriptor ID

Returns

  • Positive Value - Application index Negative Value - If index is not found


Definition at line 1133 of file network/socket/rsi_socket.c

rsi_clear_sockets#

void rsi_clear_sockets (int32_t sockID)

Clear socket information.

Parameters
[in]sockID

- Socket descriptor ID

Returns

  • Void


Definition at line 1146 of file network/socket/rsi_socket.c

rsi_fill_tls_extension#

int rsi_fill_tls_extension (int32_t sockID, int extension_type, const void * option_value, rsi_socklen_t extension_len)

Configure TLS extensions.

Parameters
[in]sockID

- Socket descriptor ID

[in]extension_type

- Type of TLS extension

[in]option_value

- TLS extension data

[in]extension_len

- TLS extension data length

Returns

  • Zero - Success Negative Value - Failure


Definition at line 1164 of file network/socket/rsi_socket.c

rsi_setsockopt#

int rsi_setsockopt (int32_t sockID, int level, int option_name, const void * option_value, rsi_socklen_t option_len)

Set the socket options. This is a non-blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]level

- Set the socket option, take the socket level

[in]option_name

- Provide the name of the ID 1.SO_MAX_RETRY - Select TCP max retry count 2.SO_SOCK_VAP_ID - Select the VAP id 3.SO_TCP_KEEP_ALIVE-Configure the TCP keep alive initial time 4.SO_RCVBUF - Configure the application buffer for receiving server certificate 5.SO_SSL_ENABLE-Configure SSL socket 6.SO_HIGH_PERFORMANCE_SOCKET-Configure high performance socket

[in]option_value

- Value of the parameter

[in]option_len

- Length of the parameter

Returns

  • 0 - Success -2 - Invalid parameters -3 - Command given in wrong state -4 - Buffer not available to serve the command


Definition at line 1216 of file network/socket/rsi_socket.c

rsi_getsockopt#

int rsi_getsockopt (int32_t sockID, int level, int option_name, const void * option_value, rsi_socklen_t option_len)

Get the socket options. This is a non-blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]level

- Set the socket option, take the socket level

[in]option_name

- Provide the name of the ID

[in]option_value

- Value of the parameter

[in]option_len

- Length of the parameter

Returns

  • Zero - Success Negative Value - Failure


Definition at line 1425 of file network/socket/rsi_socket.c

rsi_select#

int32_t rsi_select (int32_t nfds, rsi_fd_set * readfds, rsi_fd_set * writefds, rsi_fd_set * exceptfds, struct rsi_timeval * timeout, void(*)(rsi_fd_set *fd_read, rsi_fd_set *fd_write, rsi_fd_set *fd_except, int32_t status) callback, fd_read, fd_write, fd_except, status)

Select is a BSD API which allow a program to monitor multiple socket (file descriptors), waiting until one or more of the sockets become ready to perform receive or send operation.If callback is NULL or not provided, it is a blocking API otherwise it is a non-blocking API.

Parameters
[in]nfds

- The Highest-numbered file descriptor in any of the three sets, plus 1

[in]readfds

- Socket descriptors to watch to see if data become available for receive

[in]writefds

- Socket descriptors to watch to see if space is available in socket to send data.

[in]exceptfds

- Socket descriptors to watch for exception

[in]timeout

- Timeout value to break the wait for select. If both fields of the timeval structure are zero, then select() returns immediately. (This is useful for polling.) If timeout is NULL (no timeout), rsi_select() can block indefinitely.

[in]callback

- Callback called when asynchronous response reach the select request.

[out]fd_read

- Pointer that holds bitmap for the select on read operation

[out]fd_write

- Pointer that holds bitmap for the select on write operation

[out]fd_except

- Pointer that holds bitmap for the select on exceptional operation

[out]status

- Status code

Returns

  • Zero - Time out Positive Value - Indicate total number of bits ready across all the descriptor sets Negative Value - Failure

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 1507 of file network/socket/rsi_socket.c

calculate_buffers_required#

uint8_t calculate_buffers_required (uint8_t type, uint16_t length)

Calculate the buffers required.

Parameters
[in]type

- Type

[in]length

- Length

Returns

  • Zero - Success Negative Value - Failure


Definition at line 1735 of file network/socket/rsi_socket.c

rsi_accept_async#

int32_t rsi_accept_async (int32_t sockID, void(*)(int32_t sock_id, int16_t dest_port, uint8_t *ip_addr, int16_t ip_version) callback, sock_id, dest_port, ip_addr, ip_version)

Accept the connection request from the remote peer and register a callback that will be used by the driver to forward the received connection request asynchronously to the application. This is a non-blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]callback

- Callback function to indicate the socket parameters connected

[out]sock_id

- Socket descriptor ID

[out]dest_port

- Port number of remote peer

[out]ip_addr

- Remote peer address

[out]ip_version

- 4 if it is IPV4 connection, 6 if it is IPV6 connection

Returns

  • Zero - Success Negative Value - Failure


Definition at line 1763 of file network/socket/rsi_socket.c

rsi_get_app_socket_descriptor#

int32_t rsi_get_app_socket_descriptor (uint8_t * src_port)

Get the application socket descriptor from available socket pool.

Parameters
[in]src_port

- Pointer to the socket source port

Returns

  • Positive Value - Application index Negative Value - If index is not found


Definition at line 1916 of file network/socket/rsi_socket.c

rsi_get_socket_id#

int32_t rsi_get_socket_id (uint32_t src_port, uint32_t dst_port)

Function to get the primary socket ID from port number.

Parameters
[in]src_port

- Socket source port number

[in]dst_port

- Socket destination port number

Returns

  • Positive Value - Socket descriptor Negative Value - If socket is not found


Definition at line 1947 of file network/socket/rsi_socket.c

rsi_get_primary_socket_id#

int32_t rsi_get_primary_socket_id (uint8_t * port_num)

Get the primary socket ID from port number.

Parameters
[in]port_num

- Pointer to port number

Returns

  • Positive Value - Socket descriptor Negative Value - If socket is not found


Definition at line 1975 of file network/socket/rsi_socket.c

rsi_certificate_valid#

int32_t rsi_certificate_valid (uint16_t valid, uint16_t socket_id)

Host indicate the status to module after validating the server certificate received from module. This is a non-blocking API.

Parameters
[in]valid

- Indicate whether the server certificate is valid or not 1 - Indicate that the server certificate is valid 0 - Indicate that the server certificate is not valid

[in]socket_id

- Socket identifier

Returns

  • 0 - Success Negative Value - Failure


Definition at line 2013 of file network/socket/rsi_socket.c

rsi_socket_create_async#

int32_t rsi_socket_create_async (int32_t sockID, int32_t type, int32_t backlog, backlog)

Send socket create request to the module and receive the response asynchronously. This is a non-blocking API if socket_connect_response_handler is registered. Otherwise it is a blocking API.

Parameters
[in]sockID

- Pointer to the global control block

[in]type

- Socket descriptor ID

[in]backlog

- Type of socket to create

[in]backlog

- Number of backlogs for LTCP socket

Returns

  • 0 - Success Negative Value - Failure


Definition at line 2073 of file network/socket/rsi_socket.c

rsi_get_socket_descriptor#

int32_t rsi_get_socket_descriptor (uint8_t * src_port, uint8_t * dst_port, uint8_t * ip_addr, uint16_t ip_version, uint16_t sockid)

Get the primary socket ID based on source port number, destination port number, destination IP address, and the IP version. This is a non-blocking API.

Parameters
[in]src_port

- Pointer to source port number

[in]dst_port

- Pointer to destination port number

[in]ip_addr

- Pointer to destinaion IP address

[in]ip_version

- IP version either IPv4/IPv6

[in]sockid

- Socket descriptor ID from firmware

Returns

  • 0 - Socket descriptor Negative Value - If socket is not found


Definition at line 2334 of file network/socket/rsi_socket.c

rsi_socket_async_non_rom#

int32_t rsi_socket_async_non_rom (int32_t protocolFamily, int32_t type, int32_t protocol, void(*)(uint32_t sock_no, uint8_t *buffer, uint32_t length) callback, sock_no, buffer, length)

Create a socket and register a callback that will be used by the driver to forward the received packets asynchronously to the application (on packet reception) without waiting for recv API call. This is a non-blocking API.

Parameters
[in]protocolFamily

- Protocol family to select IPv4 or IPv6 AF_INET (2) : Select IPv4 AF_INET6 (3) : Select IPv6

[in]type

- Select socket type UDP or TCP SOCK_STREAM (1) : Select TCP SOCK_DGRM (2) : Select UDP

[in]protocol

- 0: Non-SSL sockets, 1: SSL sockets BIT(5) must be enabled to select the certificate index 0<<12 for index 0 1<<12 for index 1

[in]callback

- Callback function to read data asynchronously from socket

[out]sock_no

- Application socket number

[out]buffer

- Pointer to buffer holding the data

[out]length

- Length of the response buffer

Returns

  • 0 - Success Negative Value - Failure

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 2442 of file network/socket/rsi_socket.c

Referenced by rsi_socket_async , and rsi_socket

rsi_socket_connect#

int32_t rsi_socket_connect (int32_t sockID, struct rsi_sockaddr * remoteAddress, int32_t addressLength)

Connect the socket to specified remote address. This is a non-blocking API if socket_connect_response handler() is registered through rsi_wlan_register_callbacks() otherwise it is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]remoteAddress

- Remote peer address structure

[in]addressLength

- Remote peer address structrue length

Returns

  • 0 - Success Negative Value - Failure


Definition at line 2615 of file network/socket/rsi_socket.c

rsi_socket_recvfrom#

int32_t rsi_socket_recvfrom (int32_t sockID, int8_t * buffer, int32_t buffersize, int32_t flags, struct rsi_sockaddr * fromAddr, int32_t * fromAddrLen)

Retrieve the received data from the remote peer on a given socket descriptor. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[out]buffer

- Pointer to buffer to hold receive data

[in]buffersize

- Size of the buffer supplied

[in]flags

- Reserved

[out]fromAddr

- Sddress of remote peer, from where current packet was received

[in]fromAddrLen

- Pointer that contains remote peer address (fromAddr) length

Returns

  • Value

    Description

    Positive Value

    Number of bytes received successfully

    0

    Socket close error

    Negative Value

    Failure


Definition at line 2744 of file network/socket/rsi_socket.c

rsi_socket_listen#

int32_t rsi_socket_listen (int32_t sockID, int32_t backlog)

Enable socket to listen for remote connection request in passive mode. This is a blocking API.

Parameters
[in]sockID

- Socket descriptor ID

[in]backlog

- Maximum number of pending connections requests

Returns

  • 0 - Success Negative Value - Failure


Definition at line 3011 of file network/socket/rsi_socket.c

rsi_socket_shutdown#

int32_t rsi_socket_shutdown (int32_t sockID, int32_t how)

Close the socket specified in a socket descriptor. This is a blocking API.

Parameters
[in]sockID

: Socket descriptor ID

[in]how

0: Close the specified socket 1: Close all the sockets open on a specified socket's source port number.

Note

  • 1. how = 1 is valid for passively open sockets (listen) with more than one backlogs specified.

    1. If EXT_TCP_IP_WAIT_FOR_SOCKET_CLOSE (BIT(16)) in RSI_EXT_TCPIP_FEATURE_BITMAP is enabled, then to close LTCP socket, argument "how" should be 1.

    2. If EXT_TCP_IP_WAIT_FOR_SOCKET_CLOSE (BIT(16)) in RSI_EXT_TCPIP_FEATURE_BITMAP is enabled, though remote socket has terminated connection, socket is disconnected and deleted only if host issues rsi_shutdown().

Returns

  • 0 - Success Negative Value - Failure


Definition at line 3105 of file network/socket/rsi_socket.c

rsi_socket_bind#

int32_t rsi_socket_bind (int32_t sockID, struct rsi_sockaddr * localAddress, int32_t addressLength)

Assign address to the socket. This is a non-blocking API for TCP and a blocking API for UDP.

Parameters
[in]sockID

- Socket descriptor ID

[in]localAddress

- Address that needs to be assign

[in]addressLength

- Length of the socket address

Returns

  • 0 - Success Negative Value - Failure


Definition at line 3240 of file network/socket/rsi_socket.c

rsi_wait_on_socket_semaphore#

rsi_error_t rsi_wait_on_socket_semaphore (rsi_semaphore_handle_t * semaphore, uint32_t timeout_ms)

Wireless Library to acquire or wait for NWK semaphore.

Parameters
[in]semaphore

- Semaphore handle pointer

[in]timeout_ms

- Maximum time to wait to acquire semaphore. If timeout_ms is 0, then wait till semaphore is acquired.

Returns

  • 0 - Success Negative Value - Failure


Definition at line 3386 of file network/socket/rsi_socket.c

rsi_application_socket_descriptor#

int32_t rsi_application_socket_descriptor (int32_t sock_id)

Get the application socket descriptor from module socket descriptor. This is a non-blocking API.

Parameters
[in]sock_id

- Module's socket descriptor ID

Returns

  • Positive Value - Application index Negative Value - If index is not found


Definition at line 3412 of file network/socket/rsi_socket.c

rsi_wlan_socket_get_status#

int32_t rsi_wlan_socket_get_status (int32_t sockID)

Return WLAN status. This is a non-blocking API.

Parameters
[in]sockID

- Application socket ID

Returns

  • WLAN status


Definition at line 3445 of file network/socket/rsi_socket.c

rsi_wlan_socket_set_status#

void rsi_wlan_socket_set_status (int32_t status, int32_t sockID)

Set WLAN status. This is a non-blocking API.

Parameters
[in]status

- Status value to be set

[in]sockID

- Application socket ID

Returns

  • Void


Definition at line 3458 of file network/socket/rsi_socket.c

rsi_select_get_status#

int32_t rsi_select_get_status (int32_t selectid)

Get the status of the socket specified in the select ID.

Parameters
[in]selectid

- Socket ID to get the status

Returns

  • Zero - Success Negative Value - Failure


Definition at line 3473 of file network/socket/rsi_socket.c

rsi_select_set_status#

void rsi_select_set_status (int32_t status, int32_t selectid)

Set the status of the socket specified in the select ID.

Parameters
[in]status

- Status value to be set

[in]selectid

- Socket ID on which the status is set

Returns

  • Void


Definition at line 3493 of file network/socket/rsi_socket.c

rsi_send_async_non_rom#

int32_t rsi_send_async_non_rom (int32_t sockID, const int8_t * msg, int32_t msgLength, int32_t flags, void(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)

Send data on a given socket asynchronously.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

- Pointer to data that needs to be sent to remote peer

[in]msgLength

- Length of data to send

[in]flags

- Reserved

[in]data_transfer_complete_handler

- Pointer to callback function called after complete data transfer

[out]sockID

- Socket Descriptor ID

[out]length

- Number of bytes transfered

Returns

  • Zero - Success Negative Value - Failure

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 3516 of file network/socket/rsi_socket.c

rsi_sendto_async_non_rom#

int32_t rsi_sendto_async_non_rom (int32_t sockID, int8_t * msg, int32_t msgLength, int32_t flags, struct rsi_sockaddr * destAddr, int32_t destAddrLen, void(*)(int32_t sockID, uint16_t length) data_transfer_complete_handler, sockID, length)

Send data to specific remote peer on a given socket.

Parameters
[in]sockID

- Socket descriptor ID

[in]msg

- Pointer to data that needs to be sent to remote peer

[in]msgLength

- Length of data to send

[in]flags

- Reserved

[in]destAddr

- Remote peer address to send data

[in]destAddrLen

- Remote peer address length

[in]data_transfer_complete_handler

- Pointer to callback function called after complete data transfer

[out]sockID

- Socket Descriptor ID

[out]length

- Number of bytes transfered

Returns

  • Positive Value - Success, Returns the number of bytes sent successfully Negative Value - Failure zero - Socket close error

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 3599 of file network/socket/rsi_socket.c

rsi_clear_sockets_non_rom#

void rsi_clear_sockets_non_rom (int32_t sockID)

Clear socket information.

Parameters
[in]sockID

- Socket descriptor ID

Returns

  • Void


Definition at line 3810 of file network/socket/rsi_socket.c

ROM_WL_rsi_get_application_socket_descriptor#

int32_t ROM_WL_rsi_get_application_socket_descriptor (global_cb_t * global_cb_p, int32_t sock_id)

Get the application socket descriptor from module socket descriptor. This is a non-blocking API.

Parameters
[in]global_cb_p

- Pointer to the global control block

[in]sock_id

- Module's socket descriptor

Returns

  • Positive value - Application index Negative value - If index is not found


Definition at line 34 of file network/socket/rsi_socket_rom.c

ROM_WL_rsi_get_primary_socket_id#

int32_t ROM_WL_rsi_get_primary_socket_id (global_cb_t * global_cb_p, uint16_t port_number)

Get socket descriptor from port_number. This is a non-blocking API.

Parameters
[in]global_cb_p

- Pointer to the global control block

[in]port_number

- Port number

Returns

  • Positive value - Socket descriptor Negative value - If socket is not found


Definition at line 64 of file network/socket/rsi_socket_rom.c

ROM_WL_calculate_buffers_required#

uint8_t ROM_WL_calculate_buffers_required (global_cb_t * global_cb_p, uint8_t type, uint16_t length)

Calculate number of buffers required for the data packet. This is a non-blocking API.

Parameters
[in]global_cb_p

- Pointer to the global control block

[in]type

- Type of socket to create

[in]length

- Length of the message

Returns

  • The number of buffers required for a data packet


Definition at line 93 of file network/socket/rsi_socket_rom.c

ROM_WL_calculate_length_to_send#

uint16_t ROM_WL_calculate_length_to_send (global_cb_t * global_cb_p, uint8_t type, uint8_t buffers)

Caluculate the msg length sent using available buffers. This is a non-blocking API.

Parameters
[in]global_cb_p

- Pointer to the global control block

[in]type

- Type of the socket stream

[in]buffers

- Available buffers

Returns

  • Length - Length available in the buffer for msg.


Definition at line 145 of file network/socket/rsi_socket_rom.c

rsi_socket_config#

int32_t rsi_socket_config (void )

Set the socket configuration parameters. Using this command (optional) is highly recommended. Based on the socket configuration, module will use available buffers effectively. This is a blocking API.

Parameters
N/A

Parameters

Description

total socket

Desired total number of sockets to open

total_tcp_sockets

Desired total number of TCP sockets to open

total_udp_sockets

Desired total number of UDP sockets to open

tcp_tx_only_sockets

Desired total number of TCP sockets to open which are used only for data transmission

tcp_rx_only_sockets

Desired total number of TCP sockets to open which are used only for data reception

udp_tx_only_sockets

Desired total number of UDP sockets to open which are used only for data transmission

udp_rx_only_sockets

Desired total number of UDP sockets to open which are used only for data reception

tcp_rx_high_performance_sockets

Desired total number of high performance TCP sockets to open. High performance sockets can be

allocated with more buffers based on the buffers availability. This option is valid only for TCP

data receive sockets. Socket can be opened as high performance by setting high performance bit in

socket create command.

tcp_rx_window_size_cap

Desired total to increase the TCP RX window size

tcp_ack_window_div_factor

In case of high latency networks to configure the TCP ACK division factor with respective to the

window size

Note:

Default value is tcp_rx_window_size_cap.

The following conditions must be met: total_sockets <= Maximum allowed sockets(10) (total_tcp_sockets + total_udp_sockets) <= total_sockets (total_tcp_tx_only_sockets + total_tcp_rx_only_sockets) <= total_tcp_sockets (total_udp_tx_only_sockets + total_udp_rx_only_sockets) <= total_udp_sockets total_tcp_rx_high_performance_sockets <= total_tcp_rx_only_sockets

  • Must be given after IP configuration command and before any socket creation.

Returns

  • Zero - Success Non-Zero Value - Failure If return value is greater than 0 0x0021,0x0025,0x002C,0xFF6D

Note

  • Refer to Error Codes section for the description of the above error codes Error Codes.


Definition at line 6302 of file wlan/rsi_wlan_apis.c