mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 04:22:50 +02:00
socket: automatically detect and use latest bsdsockets version (fix #551)
This commit is contained in:
parent
9439b39631
commit
1bb5a21453
@ -10,8 +10,6 @@ typedef enum {
|
||||
|
||||
/// Configuration structure for socketInitalize
|
||||
typedef struct {
|
||||
u32 bsdsockets_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 receive 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.
|
||||
|
@ -62,8 +62,6 @@ static const devoptab_t g_socketDevoptab = {
|
||||
};
|
||||
|
||||
static const SocketInitConfig g_defaultSocketInitConfig = {
|
||||
.bsdsockets_version = 1,
|
||||
|
||||
.tcp_tx_buf_size = 0x8000,
|
||||
.tcp_rx_buf_size = 0x10000,
|
||||
.tcp_tx_buf_max_size = 0x40000,
|
||||
@ -82,13 +80,35 @@ const SocketInitConfig *socketGetDefaultInitConfig(void) {
|
||||
return &g_defaultSocketInitConfig;
|
||||
}
|
||||
|
||||
static u32 socketSelectVersion(void) {
|
||||
if (hosversionBefore(3,0,0)) {
|
||||
return 1;
|
||||
} else if (hosversionBefore(4,0,0)) {
|
||||
return 2;
|
||||
} else if (hosversionBefore(5,0,0)) {
|
||||
return 3;
|
||||
} else if (hosversionBefore(6,0,0)) {
|
||||
return 4;
|
||||
} else if (hosversionBefore(8,0,0)) {
|
||||
return 5;
|
||||
} else if (hosversionBefore(9,0,0)) {
|
||||
return 6;
|
||||
} else if (hosversionBefore(13,0,0)) {
|
||||
return 7;
|
||||
} else if (hosversionBefore(16,0,0)) {
|
||||
return 8;
|
||||
} else /* latest known version */ {
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
Result socketInitialize(const SocketInitConfig *config) {
|
||||
Result ret = 0;
|
||||
if (!config)
|
||||
config = &g_defaultSocketInitConfig;
|
||||
|
||||
BsdInitConfig bcfg = {
|
||||
.version = config->bsdsockets_version,
|
||||
.version = socketSelectVersion(),
|
||||
|
||||
.tcp_tx_buf_size = config->tcp_tx_buf_size,
|
||||
.tcp_rx_buf_size = config->tcp_rx_buf_size,
|
||||
|
Loading…
Reference in New Issue
Block a user