Line 12: |
Line 12: |
| ! Cmd || Name | | ! Cmd || Name |
| |- | | |- |
− | | 0 || RegisterClient ([[#Initialize]]) | + | | 0 || [[#RegisterClient]] |
| |- | | |- |
| | 1 || StartMonitoring | | | 1 || StartMonitoring |
Line 76: |
Line 76: |
| | 31 || [7.0.0+] EventFd | | | 31 || [7.0.0+] EventFd |
| |- | | |- |
− | | 32 || [7.0.0+] [[#RegisterForStatistics]] | + | | 32 || [7.0.0+] [[#RegisterResourceStatisticsName]] |
| |- | | |- |
− | | 33 || [10.0.0+] [[#Initialize2]] | + | | 33 || [10.0.0+] [[#RegisterClientShared]] |
| |- | | |- |
| | 34 || [15.0.0+] GetSocketStatistics | | | 34 || [15.0.0+] GetSocketStatistics |
| + | |- |
| + | | 35 || [17.0.0+] NifIoctl |
| |- | | |- |
| | 200 || [15.0.0+] SetThreadCoreMask | | | 200 || [15.0.0+] SetThreadCoreMask |
Line 87: |
Line 89: |
| |} | | |} |
| | | |
− | == Initialize == | + | == RegisterClient == |
− | Takes a [[#BsdBufferConfig]] (made-up name), the PID, the size of the transfer memory and a copy-handle of the latter. | + | Takes a [[#LibraryConfigData]], the PID, the size of the transfer memory and a copy-handle of the latter. |
− | | |
− | === BsdBufferConfig ===
| |
− | /// Configuration structure for bsdInitalize
| |
− | typedef struct {
| |
− | u32 version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.0.
| |
− |
| |
− | u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed).
| |
− | u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed).
| |
− | u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value.
| |
− | u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value.
| |
− |
| |
− | u32 udp_tx_buf_size; ///< Size of the UDP transfer (send) buffer (typically 0x2400 bytes).
| |
− | u32 udp_rx_buf_size; ///< Size of the UDP receive buffer (typically 0xA500 bytes).
| |
− |
| |
− | u32 sb_efficiency; ///< Number of buffers for each socket (standard values range from 1 to 8).
| |
− | } BsdBufferConfig;
| |
− | | |
− | | |
− | The transfer memory must be larger than a the computed size below. Should the transfer memory be smaller than that, the BSD sockets service would only send ZeroWindow packets (for TCP), resulting in a transfer rate not exceeding 1 byte/s.
| |
− | | |
− | static size_t _bsdGetTransferMemSizeForBufferConfig(const BsdBufferConfig *config)
| |
− | {
| |
− | u32 tcp_tx_buf_max_size = config->tcp_tx_buf_max_size != 0 ? config->tcp_tx_buf_max_size : config->tcp_tx_buf_size;
| |
− | u32 tcp_rx_buf_max_size = config->tcp_rx_buf_max_size != 0 ? config->tcp_rx_buf_max_size : config->tcp_rx_buf_size;
| |
− | u32 sum = tcp_tx_buf_max_size + tcp_rx_buf_max_size + config->udp_tx_buf_size + config->udp_rx_buf_size;
| |
− |
| |
− | sum = ((sum + 0xFFF) >> 12) << 12; // page round-up
| |
− | return (size_t)(config->sb_efficiency * sum);
| |
− | }
| |
| | | |
| == Socket == | | == Socket == |
Line 166: |
Line 139: |
| [7.0.0+] The buffers were replaced with a type-0x6 output buffer. | | [7.0.0+] The buffers were replaced with a type-0x6 output buffer. |
| | | |
− | == RegisterForStatistics == | + | == RegisterResourceStatisticsName == |
| With [10.0.0+] this now takes an additional 8-bytes of input. | | With [10.0.0+] this now takes an additional 8-bytes of input. |
| | | |
− | == Initialize2 == | + | == RegisterClientShared == |
− | Same input/output as [[#Initalize]] except this doesn't take an input handle. | + | Same input/output as [[#RegisterClient]] except this doesn't take an input handle. |
| | | |
| The work-buffer (size is still specified with this cmd) is backed by memory in the sysmodule, instead of TransferMemory. The size (after alignment) must be >=0x1000 and <=0x13F000. | | The work-buffer (size is still specified with this cmd) is backed by memory in the sysmodule, instead of TransferMemory. The size (after alignment) must be >=0x1000 and <=0x13F000. |
| | | |
− | sdknso will only use this cmd when two flags in the input config are set: the first one being set indicates that the bsd:s service is used, while the second flag enables using this cmd. An error is thrown if the work-buffer size is <0x1000. Otherwise when these flags aren't set, [[#Initialize]] is used as usual. | + | sdknso will only use this cmd when two flags in the input config are set: the first one being set indicates that the bsd:s service is used, while the second flag enables using this cmd. An error is thrown if the work-buffer size is <0x1000. Otherwise when these flags aren't set, [[#RegisterClient]] is used as usual. |
| | | |
| = bsdcfg = | | = bsdcfg = |
Line 663: |
Line 636: |
| | | |
| The handle is the service-session handle for "nn::anif::detail::ISfNetworkInterfaceService". | | The handle is the service-session handle for "nn::anif::detail::ISfNetworkInterfaceService". |
| + | |
| + | === LibraryConfigData === |
| + | This is "nn::socket::sf::LibraryConfigData". |
| + | |
| + | /// Configuration structure for bsdInitalize |
| + | typedef struct { |
| + | u32 version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.0. |
| + | |
| + | u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed). |
| + | u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed). |
| + | u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value. |
| + | u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value. |
| + | |
| + | u32 udp_tx_buf_size; ///< Size of the UDP transfer (send) buffer (typically 0x2400 bytes). |
| + | u32 udp_rx_buf_size; ///< Size of the UDP receive buffer (typically 0xA500 bytes). |
| + | |
| + | u32 sb_efficiency; ///< Number of buffers for each socket (standard values range from 1 to 8). |
| + | } BsdBufferConfig; |
| + | |
| + | |
| + | The transfer memory must be larger than a the computed size below. Should the transfer memory be smaller than that, the BSD sockets service would only send ZeroWindow packets (for TCP), resulting in a transfer rate not exceeding 1 byte/s. |
| + | |
| + | static size_t _bsdGetTransferMemSizeForBufferConfig(const BsdBufferConfig *config) |
| + | { |
| + | u32 tcp_tx_buf_max_size = config->tcp_tx_buf_max_size != 0 ? config->tcp_tx_buf_max_size : config->tcp_tx_buf_size; |
| + | u32 tcp_rx_buf_max_size = config->tcp_rx_buf_max_size != 0 ? config->tcp_rx_buf_max_size : config->tcp_rx_buf_size; |
| + | u32 sum = tcp_tx_buf_max_size + tcp_rx_buf_max_size + config->udp_tx_buf_size + config->udp_rx_buf_size; |
| + | |
| + | sum = ((sum + 0xFFF) >> 12) << 12; // page round-up |
| + | return (size_t)(config->sb_efficiency * sum); |
| + | } |
| | | |
| = DeleteMode = | | = DeleteMode = |