Socket Configuration#

This section provides a reference for the socket configuration API functions.

These functions enable various socket-related configurations, including ciphers used for secure communication.

Modules#

sl_si91x_socket_config_t

sl_si91x_socket_type_length_value_t

SiWx91x Socket Ciphers

SiWx91x Socket Extended Ciphers

Functions#

sl_status_t
sl_si91x_config_socket(sl_si91x_socket_config_t socket_config)

Configures SiWx91x specific socket settings.

void
sl_si91x_set_socket_cipherlist(uint32_t cipher_list)

Sets the list of standard TLS ciphers (TLSv1.0 / TLSv1.1 / TLSv1.2) to be used when creating secure sockets on the SiWx91x.

void
sl_si91x_set_extended_socket_cipherlist(uint32_t extended_cipher_list)

Sets the list of extended TLS ciphers (including TLSv1.3) to be used when creating secure sockets on the SiWx91x.

Function Documentation#

sl_si91x_config_socket#

sl_status_t sl_si91x_config_socket (sl_si91x_socket_config_t socket_config)

Configures SiWx91x specific socket settings.

Parameters
TypeDirectionArgument NameDescription
sl_si91x_socket_config_t[in]socket_config

Socket configuration of type sl_si91x_socket_config_t. Field values must satisfy the constraints documented in sl_si91x_socket_config_t (for example, total_sockets must equal the sum of TCP and UDP sockets and must not exceed the stack-level SI91X_MAX_SOCKETS).

This function sets up the socket configuration specific to the SiWx91x. It must be called before invoking any socket-creation API. The configuration includes setting parameters such as socket type, protocol, and other options specific to the SiWx91x series.

Applies to all socket families. The configuration values (TCP/UDP/TLS slot counts, MSS, RX/TX buffer sizes, TLS extensions) are applied to the underlying SiWx91x network stack and therefore affect all three socket families — BSD sockets (socket), IoT sockets (iotSocketCreate), and native SiWx91x sockets (sl_si91x_socket / sl_si91x_socket_async) — because they share the same firmware resources.

  • Post-conditions:

    • On success the supplied configuration is applied to the SiWx91x socket pool and all subsequent socket-creation calls (regardless of family) observe the new limits.

    • On failure the firmware configuration is unchanged.

Returns

Return values

  • SL_STATUS_OK: Configuration applied successfully.

  • SL_STATUS_NOT_INITIALIZED: Wi-Fi/Net stack is not initialized.

  • SL_STATUS_INVALID_PARAMETER: One of the fields in

  • SL_STATUS_SI91X_INVALID_CONFIG: Firmware rejected the configuration (for example, MSS/buffer sizes out of range).

  • SL_STATUS_BUSY: A previous socket-configuration request is still in progress.

Note

  • Thread safety:

    • Not thread-safe. Must be invoked by a single thread at initialization time, before any socket is created.

  • Side effects:

    • Allocates/releases firmware buffers used by the SiWx91x socket pool.

    • Affects every subsequent socket-creation call across BSD, IoT, and SiWx91x families.

See Also

  • Example#

    Configure the SiWx91x socket pool before creating application sockets:

    sl_si91x_socket_config_t socket_cfg = {
      .total_sockets                   = 3,
      .total_tcp_sockets               = 2,
      .total_udp_sockets               = 1,
      .tcp_tx_only_sockets             = 1,
      .tcp_rx_only_sockets             = 1,
      .udp_tx_only_sockets             = 1,
      .udp_rx_only_sockets             = 0,
      .tcp_rx_high_performance_sockets = 1,
      .tcp_rx_window_size_cap          = 10,
      .tcp_rx_window_div_factor        = 0,
    };
    
    sl_status_t status = sl_si91x_config_socket(socket_cfg);
    if (status != SL_STATUS_OK) {
      printf("sl_si91x_config_socket() failed, 0x%lx\r\n", (unsigned long)status);
      return status;
    }
    

sl_si91x_set_socket_cipherlist#

void sl_si91x_set_socket_cipherlist (uint32_t cipher_list)

Sets the list of standard TLS ciphers (TLSv1.0 / TLSv1.1 / TLSv1.2) to be used when creating secure sockets on the SiWx91x.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]cipher_list

A bitmap of the selected ciphers from SiWx91x Socket Ciphers. Multiple ciphers can be OR-ed together.

This function stores the cipher-suite bitmap in an internal global (sl_si91x_socket_selected_ciphers). When a secure socket is subsequently created, the SiWx91x socket layer copies this bitmap into the socket-create command sent to the firmware (see ssl_ciphers_bitmap in sli_create_and_send_socket_request()), and the firmware uses it during the TLS handshake.

Applicability by socket family#

  • BSD sockets (socket) — Applies whenever TLS is enabled on the socket (e.g., via setsockopt with the SiWx91x TLS option before connect). This is the primary use case.

  • SiWx91x (proprietary) sockets (sl_si91x_socket, sl_si91x_socket_async) — Applies whenever TLS is enabled on the socket.

  • IoT sockets (iotSocketCreate) — The IoT Socket API surface itself does not expose TLS enablement (iotSocketCreate accepts only IOT_SOCKET_IPPROTO_TCP / IOT_SOCKET_IPPROTO_UDP, and iotSocketSetOpt has no TLS options). The cipher configuration therefore has no effect on a pure IoT-Socket-API usage.

  • Pre-conditions:

    • The Wi-Fi / network stack must be initialized.

    • Must be called before creating the secure socket(s) that need to use the selected ciphers. Existing secure sockets are not updated retroactively.

  • Post-conditions:

    • The supplied cipher bitmap is stored and applied to every secure socket created afterwards until the cipher list is changed again.

Note

  • Thread safety: Not thread-safe — the cipher list is held in an unsynchronized process-global. Call once from an initialization thread before any secure socket is created.

  • For TLSv1.3 ciphers use sl_si91x_set_extended_socket_cipherlist.

See Also

  • Example#

    Select a set of TLSv1.2 ciphers for every subsequent secure socket (BSD or SiWx91x family):

    sl_si91x_set_socket_cipherlist(BIT(SL_SI91X_TLS_RSA_WITH_AES_256_CBC_SHA256)
                                   | BIT(SL_SI91X_TLS_RSA_WITH_AES_128_CBC_SHA256));
    

sl_si91x_set_extended_socket_cipherlist#

void sl_si91x_set_extended_socket_cipherlist (uint32_t extended_cipher_list)

Sets the list of extended TLS ciphers (including TLSv1.3) to be used when creating secure sockets on the SiWx91x.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]extended_cipher_list

A bitmap of the selected extended ciphers from SiWx91x Socket Extended Ciphers. Multiple ciphers can be OR-ed together.

This function stores the extended cipher-suite bitmap in an internal global (sl_si91x_socket_selected_extended_ciphers). When a secure socket is subsequently created, the SiWx91x socket layer copies this bitmap into the socket-create command sent to the firmware (see ssl_ext_ciphers_bitmap in sli_create_and_send_socket_request(), under SLI_SI917), and the firmware uses it during the TLS handshake. Extended ciphers include the TLSv1.3 suites and other suites not covered by sl_si91x_set_socket_cipherlist.

Applicability by socket family#

  • BSD sockets (socket) — Applies whenever TLS is enabled on the socket. Primary use case.

  • SiWx91x (proprietary) sockets (sl_si91x_socket, sl_si91x_socket_async) — Applies whenever TLS is enabled on the socket.

  • IoT sockets (iotSocketCreate) — No effect when using the IoT Socket API in isolation, because that API does not expose TLS enablement.

  • Pre-conditions:

    • The Wi-Fi / network stack must be initialized.

    • Must be called before creating the secure socket(s) that need to use the selected ciphers. Existing secure sockets are not updated retroactively.

  • Post-conditions:

    • The supplied extended cipher bitmap is stored and applied to every secure socket created afterwards until the extended cipher list is changed again.

Note

  • Thread safety: Not thread-safe — the extended cipher list is held in an unsynchronized process-global. Call once from an initialization thread before any secure socket is created.

See Also

  • Example#

    Enable the TLSv1.3 AES-128-GCM-SHA256 suite for every subsequent secure socket (BSD or SiWx91x family):

    sl_si91x_set_extended_socket_cipherlist(BIT(SL_SI91X_TLS13_AES_128_GCM_SHA256));