aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
8 daysMerge branch 'honor-dns-port' into 'master'HEADmasterSamuel Thibault5-18/+67
fix: honor dns server port number on macos See merge request slirp/libslirp!153
9 daysfix: honor dns server port number on macosIhar Hrachyshka5-18/+67
Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
2025-05-26tcp: Fix starting the linger2 timer on socket shutdownSamuel Thibault2-1/+11
If the socket is completely shut down just before we get our FIN ack-ed, the socket state has SS_NOFDREF instead of SS_FCANTRCVMORE. If the socket sees write() shut down (and we thus switch to FIN_WAIT_1), and we get our FIN acked before seeing read() shut down, when we eventually see that we need to start the linger2 timer. This way, it's only if we still have a live Internet socket that we stay in the TCPS_FIN_WAIT_2 state without a timer, and we let the host decide the linger2 timer. Fixes #86 (hopefully)
2025-05-26tcp: Reduce linger time to two minutesSamuel Thibault2-2/+2
BSD & Linux do this to avoid non-cooperative peers, as TCP protocols usually don't stay idle for long after one peer shuts down its side. We could otherwise be waiting for FIN from the guest indefinitely without keepalive. Suggested-by: Fabian Merki
2025-05-26tcp: on input during init, reset TCPT_KEEP to TCPTV_KEEP_INITSamuel Thibault1-1/+4
rather than TCPTV_KEEP_IDLE: until it's established, we should be more demanding.
2025-05-26tcp: on input, reset TCPT_KEEP to TCPTV_KEEP_IDLE rather than TCPTV_KEEPINTVLSamuel Thibault1-4/+1
When receiving input, we should wait for 2h before trying to probe again for keepalive. We do not need to wake again until that.
2025-05-22Modified util.c to handle WSA function return values closer to ↵Jack Doherty1-16/+16
specification. Explicit checks for INVALID_SOCKET and SOCKET_ERROR are made.
2025-03-26apple: Fix getting IPv4 DNS server address when IPv4 and IPv4 are interleavedSamuel Thibault1-2/+5
When getting an IPv4 DNS server address, if libresolv returns IPv4 IPv6 IPv4 IPv6 (or just IPv4 and IPv6) we would still have found == 1 on the second iteration and thus take the IPv6 even if it's not the proper af. We can as well just completely ignore the non-matching af entries. Fixes #85
2025-01-30Fix assertionSamuel Thibault1-1/+1
2025-01-30Provide stubs for inet_ntop() and inet_pton()B. Scott Michel2-5/+82
for Windows versions earlier than Windows 7.
2025-01-30winver.h: Introduce header that forces defining WINVER and _WIN32_WINNTSamuel Thibault3-21/+34
2025-01-30ensure that WINVER and _WIN32_WINNT are unconditionally setB. Scott Michel1-2/+12
if TARGET_WINVER is defined.
2025-01-30sbuf.c: CleanupsB. Scott Michel1-24/+68
- sbcopy(): Make the code a little clearer to follow, with comments. - Type consistency - Eliminate type slices (size_t -> int) - Use ssize_t when doing pointer arithmetic. - Eliminate signed/unsigned comparisons. - Add range checking assertions.
2024-11-26fix for slirp ftp proxying putting slirp placeholder host ip in PORT commandsrakslice1-1/+15
Fixes #82
2024-11-19Merge branch 'strerror-consistency' into 'master'Samuel Thibault7-29/+29
Prefer g_strerror() to strerror() See merge request slirp/libslirp!146
2024-11-18Prefer g_strerror() to strerror()B. Scott Michel7-29/+29
Use g_strerror() for better cross platform compatibility: glib handles the Windows "deprecation" (i.e., use strerror_s instead of strerror), fewer warnings at compile time.
2024-11-18vmstate.h: Prefer __typeof__ vice typeofB. Scott Michel1-2/+8
Clang masquerading as gcc on macOS (i.e., "gcc") borks on typeof(), but happily accepts __typeof__(). N.B., __typeof__ has been accepted by GCC and Clang for a long time, and recently MS decided to support it as well.
2024-11-14Review comments.B. Scott Michel1-5/+12
2024-11-14cksum: NetBSD-adapted cksum()B. Scott Michel2-109/+238
Update cksum() to use more recent NetBSD-based checksum implementation. The updated implementation includes both a 64-bit and 32-bit (the default) implementations. The 64-bit implementation has a longer stride length, which may be beneficial to overall performance. Update the return types for cksum() and ip6_cksum() to uint16_t, which is what the checksum algorithm computes.
2024-11-14Introduce SLIRP_PRIsize/ssize_tB. Scott Michel1-0/+29
2024-11-10arp_table: use size_t to index arrays.B. Scott Michel1-2/+2
2024-11-01Debugging APIScott Michel6-51/+88
2024-11-01slirp_(un)register_poll_socket: void returning valueB. Scott Michel1-14/+16
void functions don't return values.
2024-10-09Restore SlirpAddPollCb, {,un}register_poll_fdSamuel Thibault10-26/+125
as they were before 72f85005a230 ("socket abstraction: slirp_os_socket"): that broke the ABI. Better introduce SlirpAddPollCbSocket, {,un}register_poll_socket that people can use instead, and wrappers for the old API, for a smooth API/ABI upgrade.
2024-10-01Fix calling slirp_bind_outbound on tcp_fconnectSamuel Thibault1-1/+1
Fixes 72f85005a230 ("socket abstraction: slirp_os_socket")
2024-09-26socket abstraction: slirp_os_socketB. Scott Michel15-162/+266
Use a typedef to abstract socket identifiers because Windows just has to be different (SOCKET type.) Moreover, SOCKET on Win64 is 64-bits and generates copious type slicing warnings. Other related changes: - Explicitly cast curtime's assignment to unsigned int to tamp down on type slicing warning. - Ensure that errno.h is always included. Important for Windows, which would otherwise #define errno as WSAGetLastError(); errno.h #define-s errno as a function, i.e., "*errno()". - Export slirp_inet_aton() utility function for Win32/64. - tcpx_listen() - WSASetLastError() unnecessary. - Use have_valid_socket() to check socket in error cleanup code (vs. "s >= 0").
2024-09-26tcp_listen: Missing register_poll_fdB. Scott Michel2-0/+3
Bug fix: tcpx_listen() needs to invoke the socket's register_poll_fd() callback so that platforms can add the socket to their collection of sockets-of-interest (primarily Windows, also platforms that use select() and not poll()). Same for udpx_listen(). Register the created socket! For Windows, host forwarding "now works gooder!" The socket is eventually unregistered via the two use cases in which tcpx_listen() is used: - slirp_add_hostfwd, slirp_add_hostxfwd: The corresponding "remove" functions (slirp_remove_hostfwd, slirp_remove_hostxfwd) invoke unregister_poll_fd(). - TCP emulation (tcp_emu() in tcp_subr.c): All calls to tcp_listen() set the SS_FACCEPTONCE flag, making the accept() a one-shot event. By carefully examining tcp_subr.c, lines 523-531, one sees that tcp_connect() unregisters the one-shot accept(). QED.
2024-07-30bootp: Fill siaddr with tftp addr as per RFC2131Arusekk1-1/+19
Signed-off-by: Arusekk <arek_koz@o2.pl>
2024-06-01windows: allow static linking with LIBSLIRP_STATIC macroBiswapriyo Nath1-1/+3
When the macro is defined it will help to link with libslirp statically. Otherwise, dllimport attribute is added with function symbols and linker errors are shown as following for static linking. undefined reference to `__imp_slirp_input' undefined reference to `__imp_slirp_cleanup' undefined reference to `__imp_slirp_remove_hostfwd' etc.
2024-05-12Use simpler test linker script for detectiong --version-script optionSamuel Thibault1-0/+9
Otherwise e.g. mold complains that it doesn't find all these slirp_* symbols. Fixes #77
2024-04-26icmp6: Add echo request forwarding supportSamuel Thibault4-8/+250
2024-04-25fuzz: Add IPv6 casesSamuel Thibault1-0/+2
2024-04-25mbuf: Do not reallocate when the requested size already fits exactlySamuel Thibault1-1/+1
2024-04-25mbuf: Fix copying headersSamuel Thibault1-1/+2
Since we increase m->m_len by header_size, we mustn't add header_size again when copying. n->m_len also needs to be subtracted header_size, since we advance n->m_data by header_size. This only had effect for ipv6 trafic with debug builds
2024-04-25eth: pad ethernet frames to 60 bytesSamuel Thibault2-1/+12
Fixes #34
2024-04-25udp: Make cleanup loop clearerSamuel Thibault1-1/+1
382bff02f21b ("Fix possible infinite loops and use-after-free") rewrote the loop to make it cleaner that we go through items, but was always detaching the first elements, which happens to be right, but less clear than detaching the element being processed. Fixes #32 Reported-by: Peter Maydell
2024-04-25tftp: cleanup sessions remaining at slirp shutdownSamuel Thibault3-0/+18
To avoid leak reports.
2024-04-25tftp: Fix use-after-freeSamuel Thibault1-2/+2
Spotted thanks to ASAN & fuzzing.
2024-04-25tcp: hack syn/ackMarc-André Lureau1-0/+14
We don't know in advance what the trace will have received as sequence number, so when fuzzing tcp, just align on what the trace says
2024-04-25tcp: Fix testing for last fragmentSamuel Thibault1-1/+1
Spotted thanks to ASAN & fuzzing.
2024-04-24icmp: Fix msg duplication for debuggingSamuel Thibault1-2/+3
In case of socket error, we are not consuming the package. So duplicate it after socket operations, once we are sure that we will consume the packet.
2024-04-24tcp: Fix allocating roomSamuel Thibault2-4/+5
For reassembly, tcpiphdr2qlink needs an additional struct qlink before the tcpiphdr
2024-04-24mbuf: Be extra careful with freed pointerSamuel Thibault1-2/+5
As coverity reports, we are not supposed to do anything with a freed pointer, not even assigning it to m. So break the loop before doing so.
2024-04-24mbuf: remove '#define if*' member accessorsMarc-André Lureau4-35/+29
Making the code unnecessarily complicated. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2024-04-24m_cleanup_list: Fix missing cleanup packets from the same sessionSamuel Thibault3-16/+33
When several packets are queued for emission for the same socket session, we need to clean them all. Spotted thanks to ASAN & fuzzing. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2024-04-23tcp-input: inline TCP_REASSMarc-André Lureau1-22/+22
The macro just makes things more difficult to debug, inline it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2024-04-23ip: remove second argument from ip_stripoptions()Marc-André Lureau4-7/+4
It's not being used. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-10-22Document endianness of slirp_add_hostfwd parametersSamuel Thibault1-1/+4
Fixes #70
2023-08-13Avoid including <sys/param.h> on windowsSamuel Thibault1-0/+2
Fixes #72
2023-07-25Document functionsSamuel Thibault25-115/+315