Skip to content

fix(libSceNet): follow FreeBSD inet text rules - #4886

Closed
EagleBearerYS wants to merge 2 commits into
boykopovar:mainfrom
EagleBearerYS:fix/libscenet-inet-text-rules
Closed

EagleBearerYS wants to merge 2 commits into
boykopovar:mainfrom
EagleBearerYS:fix/libscenet-inet-text-rules

Conversation

@EagleBearerYS

Copy link
Copy Markdown
Contributor

What

On Windows, sceNetInetPton and sceNetInetNtop (libSceNet/Export.cpp) call Winsock's InetPtonA and InetNtopA, whose text rules differ from FreeBSD 11.4's. This is the libSceNet half of #3126. #3530 fixed the same difference in libkernel's inet_pton and inet_ntop, and #3126 notes that the libSceNet calls "still use the host functions and have the same difference".

Measured on this PC with Winsock, which main's functions return as is, and with glibc, whose rules match FreeBSD's:

Call Windows on main Linux, and FreeBSD
sceNetInetNtop of ::ffff:0.0.0.1 ::ffff:0:1 ::ffff:0.0.0.1
sceNetInetNtop of ::ffff:0:102:304 ::ffff:0:1.2.3.4 ::ffff:0:102:304
sceNetInetNtop of fe80::5efe:102:304 fe80::5efe:1.2.3.4 fe80::5efe:102:304
sceNetInetPton of ::01.2.3.4 1 0
sceNetInetPton of ::1.2.3.04 1 0
sceNetInetPton of ::ffff:01.2.3.4 1 0

FreeBSD:

Both functions now convert with libkernel's __inet_pton_nid_postfix and __inet_ntop_nid_postfix. libSceNet's own checks stay:

  • null pointers give EINVAL, and another family gives EAFNOSUPPORT;
  • a short buffer still gives ENOSPC (28) through sceNetErrnoLoc, now taken from libkernel's errno.

The NET_ENOSPC constant had no other use and is removed. Linux already follows these rules through glibc, so nothing changes there. No title is claimed. The new debt entry says that the rules are libkernel's and unverified on a console, as libkernel's own entry does.

Tested

Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release, -DBUILD_TESTING=ON, on main at 0c3dc9c:

  • guest_sce_net checks three more round trips with CheckAddressText: ::ffff:0.0.0.1, ::ffff:0:102:304 and fe80::5efe:102:304. Each goes from text to an address and back, with ENOSPC for every buffer shorter than the text.
  • New CheckRejectedAddressText checks that sceNetInetPton returns 0 and leaves the destination untouched for ::01.2.3.4 and ::ffff:01.2.3.4.
  • With main's Export.cpp the test aborts at the first new check, where sceNetInetNtop returns ::ffff:0:1. With the change it passes 20 runs in a row.
  • 147 tests pass:
    • guest_sce_net, guest_memory_pool_stats and guest_resolver;
    • the guest_datagram_* and guest_socket_host_write_* tests;
    • the tests registered in core/libs/prx/libc/CMakeLists.txt and core/libs/prx/libkernel/CMakeLists.txt that build on Windows, libkernel's guest_addresses among them.
  • tools/check_conventions.py --base origin/main passes.
  • Linux: WSL2 (Ubuntu 24.04, GCC 13.3.0, Release with CI's configure flags), same commit. guest_sce_net passes with main's Export.cpp, because glibc already follows these rules. With the change it passes 20 runs in a row.
  • Not tested: macOS, any title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

sceNetInetPton and sceNetInetNtop called Winsock's InetPtonA and
InetNtopA on Windows. Those print IPv4-translated and ISATAP addresses
with a dotted tail, print ::ffff:0.0.0.1 as ::ffff:0:1, and accept a
leading zero in a dotted tail, where FreeBSD does neither. Both now
convert with libkernel's inet_pton and inet_ntop, which follow the
FreeBSD 11.4 rules since boykopovar#3530.
boykopovar#5124 adds an entry after sceNetShowNetstat at the end of the unknown function info list, so adding the inet entry there made the two pull requests conflict.
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#3897 docs/dev/debt/libSceNet.md L6

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants