Skip to content

feat(net): parse Ethernet address strings - #8204

Merged
oneandonlydean merged 8 commits into
boykopovar:mainfrom
realshinmalphur:feat/net-ether-address-parser
Oct 22, 2026
Merged

oneandonlydean merged 8 commits into
boykopovar:mainfrom
realshinmalphur:feat/net-ether-address-parser

Conversation

@realshinmalphur

@realshinmalphur realshinmalphur commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

Implement sceNetEtherStrton(const char*, NetEtherAddr*), replacing the throwing placeholder added by #8106. Updated after @orezraey's PS5 firmware 13.60 probe and log and @oneandonlydean's review:

  • Decode fixed pairs at offsets 0–1, 3–4, 6–7, 9–10, 12–13 and 15–16. Ignore separator characters and trailing text. ASCII letters beyond f keep their alphabetic values, and pair arithmetic truncates to eight bits.
  • Null arguments return guest EINVAL (0x80410116, errno 22). Successful calls preserve guest errno and write exactly six bytes.
  • Deliberate safety difference: a NUL within the first 17 bytes returns EINVAL without changing the destination. Do not reproduce the console's reads beyond the terminating NUL. This includes short single-digit-group inputs.
  • Non-ASCII digit bytes throw because their decoding is unmeasured. Non-ASCII separator bytes are ignored. Remaining gaps are recorded in the existing debt entry.

The original behavioral reference was the strict shadPS4 parser at d615b388, lines 1274–1297; the PS5 measurements supersede that validation behavior. The PS5 3.20 inventory confirms the export name and NID b-bFZvNV59I.

Current main already declares this export, so this adds an implementation, not a new declared export. Previous attempt #6250 is closed/unmerged. No title-unblock or performance claim. Main was integrated through GitHub's conflict-resolution merge, not a history-rewriting rebase; the duplicate placeholder and its obsolete debt bullet are removed.

Overlap coordination (2026-10-22): compared #9506 at bed7b5c2e with this PR updated on main 6ef5a1c4c. No shared export implementation or CMake/test insertion: this PR changes only sceNetEtherStrton, adds CheckEtherAddress to existing GuestSceNet, and replaces its debt entry. #9506 changes DNS state/getters/setters, adds GuestNetDnsInfo and its CMake registration, and changes separate DNS debt entries. A pairwise merge auto-merges Export.cpp; the only textual conflict is adjacent Ether/DNS debt lines. From this PR author's side, #9506 may land first without depending on #8204; retain both entries and resolve that textual conflict whichever lands second. No functional dependency, so Depends on: none. This is our author-side consent, not a claim that #9506's author has already confirmed a bilateral order or resolved its other overlaps.

Tested

Linux 7.2.9-2-cachyos, GCC 16.2.1 and Clang 23.1.3. Main integration tested against d34da5d69:

  • Built the actual complete libc, libkernel, libSceNet and libSceNetCtl shared targets using an external isolated CMake harness with repository-pinned ZArchive/zstd sources. This is not a full-project build. The external focused harness was updated to link libSceNetCtl after main's test additions.
  • Full current GuestSceNet executable and focused parser tests each pass ten consecutive runs: 2/2 tests, 12.03 seconds total.
  • Tests cover 256 six-octet round trips, mixed case, arbitrary separators, ignored trailing text, all ASCII letters/digits plus measured punctuation in both pair positions, eight-bit truncation, all short prefix lengths, embedded NUL at every position, an exactly 17-byte non-terminated input, null arguments, errno preservation, unchanged output on errors and adjacent output guards. Non-ASCII digit bytes throw without modifying output; non-ASCII separators are ignored.
  • The updated regression tests fail against the previously published strict implementation (exit 134), before rebuilding the libraries.
  • Actual Export.cpp and focused tests pass Clang AddressSanitizer and UndefinedBehaviorSanitizer, linked to GCC-built dependencies (the dependencies are not sanitizer-instrumented).
  • Conventions and whitespace checks pass. Published file contents are verified against the tested local tree.

Console measurements belong to @orezraey; I have no PS5 and did not independently reproduce them. No full-project build, Windows test or title execution was performed. Please run the collaborator-triggered full Linux/Windows Build workflow before merge. The overlap tool's GitHub step requires local gh authentication, which is unavailable; the automatic overlap check remains needed.

2026-10-22 refresh: integrated main 6ef5a1c4c, retaining its new debt entries and keeping only the updated EtherStrton entry. Parser implementation and behavioral tests are unchanged. Rebuilt the same actual library targets and reran the current complete GuestSceNet executable and focused parser test three times each: 2/2 pass, 3.60 seconds total. Conventions and whitespace checks pass. This was not a combined runtime test of #9506. @lost9409 separately reports one Windows 11 focused guest_sce_net pass in 1.42 seconds, applying our earlier f923ebb files to base a6dcea9 with unrelated fixes #8310/#9056; that is contributor-provided evidence, not our own Windows/full-suite run.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Codex)

@github-actions

github-actions Bot commented Oct 20, 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
PR 9506 docs/dev/debt/libSceNet.md L15-16

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5836 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 6044 core/libs/tests/GuestSceNet.cpp
PR 6879 core/libs/prx/libSceNet/Export.cpp
PR 7201 core/libs/prx/libSceNet/Export.cpp
PR 8225 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 8232 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 8234 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 8235 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 8254 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 8362 core/libs/prx/libSceNet/Export.cpp
core/libs/tests/GuestSceNet.cpp
docs/dev/debt/libSceNet.md
PR 8398 core/libs/tests/GuestSceNet.cpp

@oneandonlydean oneandonlydean self-assigned this Oct 20, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks, the parser looks right. I compared it against the shadPS4 function you cite on 4 million generated strings, and the results and outputs matched in every case. One thing blocks the merge, plus two small text fixes:

  1. Rebase, and remove main's placeholder. feat(prx): declare the missing PS5 3.20 system exports #8106 has since added a throwing declaration int sceNetEtherStrton(const char* str, void* address) to core/libs/prx/libSceNet/Export.cpp (after sceNetEmulationGet), in the same extern "C" block. Git merges the file cleanly, but the result doesn't compile: error: conflicting declaration of C function 'int sceNetEtherStrton(const char*, void*)'. Please delete that placeholder on rebase, along with its bullet in docs/dev/debt/libSceNet.md ("its signature follows SharpProspero … the throwing declaration only resolves the import"), and keep your own bullet. That also clears the current docs conflict.
  2. Reference link. In shadPS4 at d615b388, sceNetEtherStrton is at lines 1274-1297 of net.cpp. Lines 1206-1228 are epoll code. Please update the anchor in the debt entry and in the description.
  3. Description. "Absent from current main" and the "+1 declared export" progress note no longer apply after feat(prx): declare the missing PS5 3.20 system exports #8106.

@orezraey

Copy link
Copy Markdown
Contributor

A data point from a PS5, in case it helps this PR. I measured sceNetEtherStrton in a payload process on firmware 13.60 (libSceNet.sprx via dlopen/dlsym), with the output pre-filled with 0x5a. The console doesn't validate its input:

  • It returns 0 for any non-null text.
  • It reads the character pairs at offsets 0-1, 3-4, 6-7, 9-10, 12-13 and 15-16, ignores whatever is between them, and reads past the terminating NUL when the text is short.
  • Each byte is hi * 16 + lo truncated to 8 bits. Digits are c - '0', letters c - 'a' + 10 or c - 'A' + 10 (so g gives 16 and x 33), and :, -, ., space, + and NUL give 0x7f.
  • A null text or a null address returns 0x80410116 (EINVAL, errno 22), not EFAULT.
Text Bytes written (between the 0x5a guards)
00:01:02:0A:0b:0F 00 01 02 0a 0b 0f
0:1:2:a:B:f 7f f2 1f ff 08 21
0-1-2-a-B-f 7f f2 1f ff 6f 90
000:1:2:3:4:5 00 f1 9f f4 cf f1, with no error
0:1:2:3:4:g 7f f2 af 00 8c f2, with no error
"" fc ce e2 e2 5f b5: the bytes after the NUL

So the strict validation and the EFAULT here would differ from the console for anything other than a well-formed 17-character address. The probe source and the full log (24 strton cases) are in this gist.

AI-assisted: yes (Claude Code). The measurements are from a console I have access to.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@realshinmalphur, and thanks @orezraey for measuring it on a console. That measurement changes what this function should do: the parser here (and the shadPS4 version I compared it against) validates its input, but firmware 13.60 doesn't. Against that, sceNetEtherStrton in this PR differs in three places:

  1. A null text or address returns NET_EFAULT here; the console returns 0x80410116 (EINVAL).
  2. Malformed or short text returns NET_EINVAL here; the console returns 0 and stores whatever its pair decoding produces (:, -, ., space, + and NUL count as 0x7f).
  3. Single-digit groups (a:b:c:d:e:f) are accepted here; the console always reads the pairs at offsets 0-1, 3-4, 6-7, 9-10, 12-13 and 15-16.

Could you change the null case to EINVAL, and either follow the measured decoding or list the remaining difference in the debt entry? Reading past the terminating NUL is a console quirk that doesn't need copying; please say in the debt entry what you do there instead. The rebase that removes #8106's throwing placeholder is still needed, as is the link fix.

@realshinmalphur

Copy link
Copy Markdown
Contributor Author

@oneandonlydean @orezraey Thanks for the review and console measurements. Updated in f923ebb (source: 89da7e6, tests: d5e2042).

  • Integrated main through GitHub’s conflict-resolution merge, removed feat(prx): declare the missing PS5 3.20 system exports #8106’s duplicate throwing declaration and obsolete debt bullet, and confirmed the published tree matches the tested local tree exactly.
  • Null arguments now return EINVAL (0x80410116 / errno 22). Decoding uses fixed character pairs with ignored separators/trailing text, alphabetic values beyond f, and eight-bit truncation.
  • The deliberate short-string difference is explicit in debt: a NUL within the first 17 bytes returns EINVAL and leaves the output untouched; no reads beyond the terminator. Non-ASCII digit bytes throw because their decoding is unmeasured, while separator bytes are ignored.
  • Corrected the shadPS4 anchor to L1274-L1297 and refreshed the description to remove the outdated new-export/progress claims and identify the console measurements as the new reference.

Validation: built the actual complete libc, libkernel, libSceNet and libSceNetCtl targets using the disclosed external harness. Full GuestSceNet and focused parser tests each passed ten consecutive runs (12.03 s total); actual Export.cpp plus focused tests passed Clang ASan/UBSan. Updated tests fail against our previous strict implementation. Conventions/whitespace checks pass. I have no PS5; the console evidence is @orezraey’s, not an independent console rerun. Please rerun the collaborator-triggered full Linux/Windows build for this head. AI-assisted: yes (Codex).

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 21, 2026
@lost9409

Copy link
Copy Markdown
Contributor

Windows test report: guest_sce_net passed in 1.42 seconds.
Environment: Windows 11 Pro build 26200, Intel i7-14700KF, WinLibs GCC 15.2.0 r7, CMake 4.3.1, Ninja 1.13.2.
Applied the changes to Export.cpp and GuestSceNet.cpp from PR commit f923ebb onto base a6dcea9, alongside the unrelated test fixes from #8310 and #9056.
Built guest_sce_net_tests and ran ctest --test-dir build -R "^guest_sce_net$" -V: 1 passed, 0 failed.
One run; no title execution or full-suite rerun after this patch. Log attached.

AnyPS5-net-8204.log

@MarcZX10

Copy link
Copy Markdown
Contributor

I am reviewing #9506, which adds sceNetSetDnsInfo, sceNetSetDns6Info and sceNetGetDns6Info plus a new registered test and debt entry. The overlap bot could not compare some of these branches because of base conflicts, and this PR author has not yet recorded an agreed merge order. Please confirm whether your current changes overlap these exact exports, CMake/test insertion, or debt section, and whether #9506 can land before your PR or should depend on yours. The #9506 author is being asked to record the agreed order in Depends on and the overlap note.

@realshinmalphur

Copy link
Copy Markdown
Contributor Author

@MarcZX10 @Noxy-HNR I compared #9506 at bed7b5c against #8204 updated on main 6ef5a1c. Our update is now published at 24b7977; its full tree matches the locally tested merge exactly.

Author-side ordering confirmation: #9506 may land before #8204 without depending on us. There is no functional prerequisite either way; whichever lands second must resolve the adjacent debt hunk without dropping either change. Depends on remains none, and this confirmation is now in our description. @Noxy-HNR please confirm/record the #9506-first order on your side if that is your preferred landing order; I am not treating this as a bilateral agreement yet or as resolving your other PR overlaps.

Separately resolved #8204’s conflict with current main, preserving main’s new debt entries and removing the reintroduced obsolete EtherStrton placeholder debt bullet. No parser behavior changes. Rebuilt actual libc/libkernel/libSceNet/libSceNetCtl via the previously disclosed external harness; complete current GuestSceNet plus focused parser tests each pass three consecutive runs (2/2, 3.60 seconds total). Conventions/whitespace pass. This is not a combined runtime test of #9506, full-project CI or a console run. @lost9409 thanks for the separately reported Windows focused test. Full Linux/Windows workflow rerun is still requested for this new head. AI-assisted: yes (Codex).

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@oneandonlydean
oneandonlydean merged commit d9c99c9 into boykopovar:main Oct 22, 2026
12 checks passed
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.

5 participants