Commit Graph
134 Commits
Author SHA1 Message Date
boykopovar ea086b2374 fix(netctl): restore initialization and callback validation 2026-10-21 21:51:41 +03:00
boykopovar 04f2d9a60f fix(net): reject unsupported diagnostic output after initialization 2026-10-21 21:50:44 +03:00
boykopovar 1a214787ce fix(net): correct allocation size and flag handling 2026-10-21 21:47:59 +03:00
boykopovar 0f6161f885 fix(net): enforce initialization for sleep and random calls 2026-10-21 21:47:58 +03:00
boykopovar 9a09fc0a78 fix(net): restore dns cache argument validation 2026-10-21 21:47:32 +03:00
jagrat Singh 54d1a8d6d6 feat(libSceNet): implement sceNetShowRoute6 2026-10-21 12:44:40 +02:00
Dean 7ef094f7d4 Merge pull request #8222 from jagrat04/feat/libSceNet-show-route
feat(libSceNet): implement sceNetShowRoute
2026-10-21 20:19:56 +13:00
Dean 7e6830ec55 Merge pull request #8268 from Athen2045/feat/net-dns-info
feat(libSceNet): implement sceNetGetDnsInfo
2026-10-21 11:50:31 +13:00
xXPBSXxandClaude Sonnet 5.5 3fb021f9bb fix(libSceNet): map every host socket error through the guest errno table
sceNet translated only 21 host socket errors and reported every other one
as EIO. libkernel already owns the complete FreeBSD table in
GuestSockets::GuestErrorFromHost, so use it for net_error. The new check
makes a stream socket with the UDP protocol fail with EPROTONOSUPPORT (43)
instead of EIO (5).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 19:24:33 +02:00
Allan JohnandClaude Opus 5.5 8ab6ecb17a feat(libSceNet): implement sceNetGetDnsInfo
Report the host IPv4 DNS servers of the interface sceNetCtlGetInfo
uses, through a helper libSceNetCtl exports, and return their count.
The signature and layout follow the OpenOrbis musl resolver and Net.h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 13:19:12 +05:30
Dean 26f157ba15 Merge pull request #7959 from Lindamea1/fix/libscenet-getsockinfo-fill
fix(libSceNet): fill the address and port fields in sceNetGetSockInfo
2026-10-20 20:07:23 +13:00
Dean 138351d714 Merge pull request #8056 from ntamas94/fix/sce-net-inet-pton-ex-aton
fix(libSceNet): parse sceNetInetPtonEx IPv4 text as the PS4 does
2026-10-20 19:31:57 +13:00
Lindamea1andClaude Opus 5.5 a05db60c87 fix(libSceNet): fill the address and port fields in sceNetGetSockInfo
sceNetGetSockInfo returned 0 for a known socket and wrote nothing, so
callers read uninitialised bytes as the socket's endpoints. Monster
Hunter Wilds (PPSA24191) calls it after bind, connect and accept and
stores the local and remote address and port it reads back.

It now writes one 0xA0-byte record in the layout SharpProspero and
shadPS4 give: the socket id, the socket type, the local and remote
IPv4 address and port of the host socket in network byte order, the
SELF and NONBLOCK status flags, and the receive and send buffer sizes
sceNetGetsockopt reports for the socket. The other fields are 0. It
returns 1, the number of records written, and EINVAL for a null record
or an n below 1, as shadPS4 does.

An s below 0 lists the sockets as shadPS4 does: with a null record it
returns their number, otherwise it writes up to n records in socket
order and returns how many it wrote. Unlike shadPS4, which lists IPv6
sockets with zero addresses and ignores flags, an IPv6 socket fails
with EAFNOSUPPORT and is left out of the count and the list, and a
flags bit other than 0x40 fails with EINVAL. SharpProspero names 0x40
SockInfoTimeWait; closed sockets leave the table at once, so it lists
the same sockets. docs/dev/debt/libSceNet.md lists the fields left 0
and these differences.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 07:23:51 +01:00
Dean df56570fe2 Merge pull request #8054 from HQasper/feat/net-interface-names
feat(libSceNet): implement interface names, random values and net memory
2026-10-20 18:31:02 +13:00
Dean 9d6470ea21 Merge pull request #7991 from MarrasFederico/feat/sce-net-resolver-aton6
feat(libSceNet): reverse-resolve IPv6 addresses in sceNetResolverStartAton6
2026-10-20 17:50:03 +13:00
Dean ca5cd3128b Merge pull request #8013 from MarrasFederico/feat/sce-net-clear-dns-cache
feat(libSceNet): accept sceNetClearDnsCache with no library DNS cache to drop
2026-10-20 17:46:56 +13:00
jagrat Singh 50375074d0 feat(libSceNet): implement sceNetShowRoute
Implement sceNetShowRoute as a silent stub returning 0, matching the (void) signature in shadPS4 and the behavior of sceNetShowIfconfig and sceNetShowNetstat. Adds guest unit tests in GuestSceNet.cpp and updates technical debt documentation.
2026-10-20 09:51:48 +05:30
xXPBSXxandClaude Sonnet 5.5 ba0755337d fix(libSceNet): pass MSG_DONTWAIT to the wait for a local address on Windows
sceNetRecv, sceNetRecvfrom and sceNetRecvmsg on a datagram socket without a
local address waited in wait_for_local_address until the socket was bound,
connected or written to, because only a non-blocking socket made that wait
fail. FreeBSD 11.4 soreceive_dgram fails a MSG_DONTWAIT receive without data
with EWOULDBLOCK. The flags now reach wait_for_local_address and the test
covers an unbound socket.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 06:05:03 +02:00
xXPBSXxandClaude Sonnet 5.5 a39effcef9 fix(libSceNet): honour MSG_DONTWAIT in the send and receive calls on Windows
sceNetSend, sceNetSendto, sceNetSendmsg, sceNetRecv, sceNetRecvfrom and
sceNetRecvmsg failed with EOPNOTSUPP for MSG_DONTWAIT on Windows, where
FreeBSD 11.4 sosend_generic and soreceive_generic make the one call
non-blocking and fail with EWOULDBLOCK when it would wait. Winsock has no
per-call flag, so the call now asks WSAPoll with a zero timeout whether the
socket is ready and fails with EAGAIN when it is not. The Windows branch of
the test that expected EOPNOTSUPP now runs the checks of the other hosts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-20 06:05:03 +02:00
Dean 500cc640bd Merge pull request #7987 from MarrasFederico/fix/sce-net-ipv6-loopback-errors
test(libSceNet): accept every unusable IPv6 loopback error in guest_sce_net
2026-10-20 14:53:04 +13:00
Adrià 9f9cf38bb0 Merge pull request #7493 from Lindamea1/fix/scenet-tcp-nodelay
fix(libSceNet): support TCP_NODELAY in sceNetSetsockopt and sceNetGetsockopt
2026-10-20 01:01:26 +02:00
ntamas94andClaude Opus 5.5 ad52647cd9 fix(libSceNet): parse sceNetInetPtonEx IPv4 text as the PS4 does
On PS4 firmware 10.71 sceNetInetPtonEx reads IPv4 text the way
inet_aton does, not the way sceNetInetPton does: "1.2.3" is 1.2.0.3,
"127.1" is 127.0.0.1, hex and octal parts are accepted, a part value
wraps at 32 bits ("1.4294967296" is 1.0.0.0) and the text ends at the
first whitespace. Two differences from BSD inet_aton were measured: a
part starting with "09" is decimal ("0989" is 989), and an octal part
containing 8 or 9 fails.

The flags argument changed nothing for 0, every single bit up to
0x100, 0x10000, 0x80000000 and -1, so it is ignored instead of
throwing. IPv6 still converts as sceNetInetPton does, which matches
the console.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 21:10:55 +02:00
Claude b0a9676844 feat(libSceNet): implement interface names, random values and net memory
Implement sceNetGetIfName, sceNetGetRandom, sceNetMemoryAllocate and
sceNetMemoryFree with the signatures shadPS4 uses, and cover them in
guest_sce_net_tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 18:29:29 +00:00
Federico Marras 1537dff78b feat(libSceNet): accept sceNetClearDnsCache with no library DNS cache to drop 2026-10-19 19:41:49 +02:00
Federico Marras 87bd71d64c feat(libSceNet): reverse-resolve IPv6 addresses in sceNetResolverStartAton6 2026-10-19 18:57:12 +02:00
Federico Marras 4877716673 test(libSceNet): accept every unusable IPv6 loopback error in guest_sce_net
guest_sce_net skips its IPv6 checks when sending to ::1 fails and
HostIpv6LoopbackUnavailable confirms the host cannot reach it. The host
probe accepts EADDRNOTAVAIL, ENETUNREACH and EHOSTUNREACH, but the guest
check accepted only ENETUNREACH (51). On a Linux host without ::1 the
send can fail with EADDRNOTAVAIL instead, which the guest sees as 49,
and the test aborted in CheckUnspecifiedIpv6 instead of skipping.

Accept the guest numbers of the same three errors (49, 51 and 65).
2026-10-19 18:57:12 +02:00
Dean 240255fcf8 Merge pull request #7924 from realshinmalphur/feat/net-process-time
feat(net): implement process-relative system time
2026-10-20 05:53:14 +13:00
Lindamea1andClaude Opus 5.5 0c84ec45f0 fix(libSceNet): support TCP_NODELAY in sceNetSetsockopt and sceNetGetsockopt
sceNetSetsockopt and sceNetGetsockopt failed with EOPNOTSUPP
(0x8041012d) for every level other than SOL_SOCKET, so TCP_NODELAY
could not be set on a libSceNet stream socket; libkernel setsockopt on
such a socket failed the same way. FreeBSD 11.4's sosetopt and sogetopt
(uipc_socket.c) pass any other level to the protocol: tcp_ctloutput
sets TF_NODELAY and returns 0, a get returns t_flags & TF_NODELAY (4),
an option it does not know fails with ENOPROTOOPT, and on a UDP or raw
socket ip_ctloutput and rip_ctloutput fail the IPPROTO_TCP level with
EINVAL. Set TCP_NODELAY on the host socket of a stream socket, read it
back as TF_NODELAY, fail other IPPROTO_TCP options on a stream socket
with ENOPROTOOPT (0x8041012a), and fail the IPPROTO_TCP level with
EINVAL on other socket types, as libkernel already does for its own
sockets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 18:01:00 +02:00
ntamas94andClaude Opus 5.5 522e67dcf6 test(libSceNet): place the sceNetInetPton whitespace checks before CheckInetPtonEx
#7924 adds its check between CheckInetPtonEx and CheckUsleep, where
these checks were, so the two pull requests conflicted in
GuestSceNet.cpp. The checks now sit after CheckAddressText.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:24:21 +02:00
ShinMalphur d16086d841 test(net): cover process-relative system time 2026-10-19 20:40:37 +06:30
ntamas94andClaude Opus 5.5 be7068bd81 fix(libSceNet): end IPv4 sceNetInetPton text at whitespace as the PS4 does
PS4 firmware 10.71 converts "1.2.3.4" followed by a space, tab, LF,
VT, FF or CR, and anything after it ("1.2.3.4 x"), to 1.2.3.4 and
returns 1, where host inet_pton returns 0. Leading whitespace, other
trailing bytes (0x01, 0xa0), "1.2.3 " and IPv6 text with whitespace
still fail there.

A failed conversion leaves the destination and sceNetErrnoLoc
unchanged on the console; Winsock inet_pton writes the parsed prefix
before failing, so the conversion now goes through a local buffer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 16:05:36 +02:00
Chikimaro a84a2b1240 feat(libSceNet): implement sceNetUsleep and sceNetInetPtonEx
sceNetUsleep fails with EINVAL for a negative count and otherwise sleeps
through libkernel's sceKernelUsleep, a cancellation point. sceNetInetPtonEx
converts as sceNetInetPton does when its flags are 0 and throws for any
other flags, whose meaning is unknown. The signatures follow shadPS4 and
are recorded as unverified in the libSceNet technical debt.
2026-10-19 09:01:14 +00:00
xXPBSXxandClaude Sonnet 5.5 ba9dbc208a test(libSceNetCtl): cover the plain callback registration in guest_sce_net
sceNetCtlRegisterCallback and sceNetCtlUnregisterCallback share the
callback table logic with the V6 pair, which guest_sce_net checks, but
the plain pair is not called by any test. The new block mirrors the V6
one (null function, null output, eight slots, the ninth refused, invalid
ids, slot reuse) with the guest-ABI IgnoreNetCtlEvent callback, and checks
that the two tables are separate.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-19 06:01:26 +02:00
Adrià 25648aa121 Merge pull request #6494 from Ondra97/codex/fix-net-accept-inherited-mode
fix(libSceNet): inherit nonblocking mode on accepted sockets
2026-10-19 04:30:22 +02:00
fdfawef324andClaude Opus 5.5 2ae7896b6d fix(libSceNetCtl): keep the callback argument and deliver the state from sceNetCtlCheckCallback
sceNetCtlRegisterCallback and sceNetCtlRegisterCallbackV6 stored only
the function and dropped its argument, and sceNetCtlCheckCallback
returned 0 without calling anything, so a title that polls
sceNetCtlCheckCallback until its callback reports IPOBTAINED never
got the event.

Each callback slot now keeps the function, its argument and the last
event it received; unregistration clears the slot. With no IPv4
callback registered, sceNetCtlCheckCallback returns 0 without querying
the host. Otherwise it takes the state from the same host-interface
predicate as sceNetCtlGetState, IPOBTAINED (3) or DISCONNECTED (1)
(shadPS4 src/core/libraries/network/net_ctl_codes.h L27-29
@15abf68c9b52), marks the IPv4 slots whose last event differs and
calls them on the calling thread with their argument after the lock is
released, so a callback can unregister itself. Delivery once per state
change and slot follows KytyPS5 src/libs/network.cpp @9e41d8320a27
(NetCtlCallbackSlot L3447-3451, NetCtlCheckCallback L3648-3661,
NetCtlRegisterCallback L3687-3707); shadPS4 net_ctl_obj.cpp L47-57
delivers on every check instead, and the debt entry records the
difference and that KytyPS5 calls the callbacks under its lock.
sceNetCtlTerm clears both tables, as KytyPS5 NetCtlTerm (L3625-3633)
does. V6 slots keep their argument but get no event, since no source
says which call delivers them.

NetCtlCallback is now an APS5_VABI pointer, so the Windows build calls
the guest function with the System V ABI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 18:31:00 +02:00
Dean 3f4a7f3b22 Merge pull request #6142 from milescoviello/fix/net-setsockopt-kernel-socket
fix(libSceNet): set an option on a libkernel socket through sceNetSetsockopt
2026-10-19 04:23:20 +13:00
milescovielloandClaude Opus 5.5 8b81fa09bf fix(libSceNet): close a libkernel socket through sceNetSocketClose
MXGP 26 (PPSA30839) opens TCP sockets with libkernel's socket() and
later closes them with sceNetSocketClose. libSceNet only looked in its
own socket table, so every one of those closes failed with
SCE_NET_ERROR_EBADF and the host socket stayed open. On the console both
calls work on the same kernel sockets.

A descriptor libSceNet does not own but libkernel has open as a socket
is now closed through libkernel's close(). Anything else still fails
with EBADF. The fallback runs after g_mutex is released, because
libkernel's close() first asks libSceNet's socket closer, which takes it.

guest_sce_net closes a libkernel TCP socket with sceNetSocketClose,
checks that libkernel no longer has it open, and checks that a second
close fails with EBADF.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 18:31:38 +00:00
milescovielloandClaude Opus 5.5 9c9311af8f test(libSceNet): set TCP_NODELAY on a libkernel socket through sceNetSetsockopt
The call MXGP 26 makes; libkernel answers it since #5565.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 13:22:34 +00:00
milescovielloandClaude Opus 5.5 3573289f2f fix(libSceNet): set an option on a libkernel socket through sceNetSetsockopt
MXGP 26 (PPSA30839) opens TCP sockets with libkernel's socket() and
turns on TCP_NODELAY with sceNetSetsockopt. libSceNet only looked in its
own socket table, so the call failed with SCE_NET_ERROR_EBADF. On the
console both calls work on the same kernel sockets.

A descriptor libSceNet does not own but libkernel has open as a socket
now goes to libkernel's setsockopt(), which answers the options it
models. Anything else still fails with EBADF. The fallback runs after
g_mutex is released.

guest_sce_net sets SO_SNDBUF on a libkernel TCP socket through
sceNetSetsockopt, and checks that the call fails with EBADF once the
socket is closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 13:22:34 +00:00
Alexandros Pournaras 4b656882ba fix(libSceNet): store SO_ONESBCAST in sceNetSetsockopt 2026-10-17 11:29:25 +02:00
Adrià c47a4dca52 Merge pull request #5967 from EagleBearerYS/fix/libscenet-timeval-timeouts
fix(libSceNet): read SO_RCVTIMEO and SO_SNDTIMEO as a timeval in sceNetSetsockopt
2026-10-17 06:53:19 +02:00
Adrià bb6bea8093 Merge pull request #5966 from EagleBearerYS/fix/libscenet-unbound-datagram-receive
fix(libSceNet): let a datagram receive on an unbound socket wait on Windows
2026-10-17 06:51:29 +02:00
Kurenaiiiii f00b2ef833 feat(libSceNet): return success from ShowIfconfig and ShowNetstat 2026-10-16 20:51:06 +02:00
Ondra97 1fee29b6ad fix(libSceNet): inherit nonblocking mode on accepted sockets 2026-10-15 19:29:41 +02:00
Yunus Shaikh 896b737700 fix(libSceNet): keep one receive timeout across the wait for a local address
When the address came during the wait, the host receive that followed
waited its whole SO_RCVTIMEO again, so a receive could take up to twice
the timeout. FreeBSD's soreceive_dgram sleeps once per timeout. Now the
receive waits for a datagram with WSAPoll only for what is left of the
timeout, and fails with EAGAIN when it runs out, as before. Nothing
changes when the socket already had an address or has no timeout.
2026-10-15 02:34:12 -07:00
Yunus Shaikh 7333704c72 test(libSceNet): receive on an unbound datagram socket that another thread binds or connects
The test covered a send that names the waiting socket. A bind and a
datagram connect from another thread name it too: each case now waits in
sceNetRecv on the unbound socket, binds or connects it, and checks that a
peer's datagram to the new address reaches the waiting receive.
2026-10-15 02:13:52 -07:00
Yunus Shaikh a9c2717fd0 fix(libSceNet): return 0 from an unbound datagram receive after shutdown or for zero bytes
On Windows a receive on a datagram socket with no local address waits
for one. A sceNetShutdown of the receive side now ends that wait, and
later receives return 0 at once; a zero-length receive returns 0 without
waiting. FreeBSD's soreceive_dgram returns 0 in both cases. Before, a
thread blocked in such a receive kept waiting after the socket was shut
down.
2026-10-15 01:54:10 -07:00
Adrià eea428ca85 Merge pull request #5536 from milescoviello/fix/scenet-getsockopt-buffers
fix(libSceNet): report SO_SNDBUF and SO_RCVBUF from sceNetGetsockopt
2026-10-15 00:29:08 +02:00
Nicolas FalesyandClaude Opus 5.5 62d8eeae76 fix(libkernel): poll libSceNet sockets with the host wait
With libSceNet sockets on ordinary descriptor numbers (#4391), poll on a
libSceNet socket threw "neither a socket nor a pipe": poll only knew
libkernel sockets and pipes, while select already asks libSceNet through
its poller. libSceNet now lends libkernel the host socket behind a
descriptor, together with an owner that keeps it open, so poll puts it in
the same WSAPoll or poll call as libkernel sockets. ProsperoLight
(PPSA99002) stopped here on Linux and now reaches its PC list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EvDbpwUPTa78oCAJqe7m9K
2026-10-14 19:56:10 +02:00
Nicolas FalesyandClaude Opus 5.5 5dcf28d36c fix(libkernel): answer fcntl status flags on libSceNet sockets
With libSceNet sockets on ordinary descriptor numbers (#4391), a title
that makes a libSceNet socket non-blocking with plain fcntl(F_GETFL) and
fcntl(F_SETFL, O_NONBLOCK) reached File::Fcntl, whose classification
throws for a socket. libSceNet now registers a status control with
libkernel, like its option setter: F_GETFL returns O_RDWR with the
socket's non-blocking flag, F_SETFL sets it through SO_NBIO, as fcntl
already does for libkernel sockets. ProsperoLight (PPSA99002) stopped
here on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WeVmjnnPPKdxVTpr2Vjtw
2026-10-14 19:19:54 +02:00