os: NetworkInterface.all on macOS (OS slice 5, step 2b of #129) #569
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Step 2b of the epic #129 (OS slice 5):
NetworkInterface.all()answers on macOS. Todaystd/os/src/network.trbanswersOsError.Unsupportedfor.MacOs; the Linux half (#539) is built, and the POSIX nativePosix.interfaceEntriesalready writes theinetandinet6lines on every POSIX system and has a stubbedAF_LINKhook for the BSDs (torb_os_posix_link_entryinruntime/os/posix.c).Source
std/os/src/linux/network.trb(pure, tested parsers over the lines ofPosix.interfaceEntries),std/os/tests/network.test.trb.Scope
AF_LINKentry inposix.cso that alinkline carries index, flags, the six-byte hardware address, and, fromstruct if_data, the MTU and the interface type (IFT_*). Keep the line format shared with Linux where it fits; extend it by fields the Linux reader ignores or give the BSD link line its own fields, whichever keepsparseEntriesof Linux unchanged.std/os/src/macos/network.trb: the pure parser/grouping for the BSD link lines (public, so tests run on every machine with sample text),interfaces()overPosix.interfaceEntries, and the mapping: status fromIFF_UP/IFF_RUNNING, kind fromIFT_LOOP(Loopback),IFT_ETHER(Ethernet; see decision below),IFT_GIF/IFT_STF/IFT_PPP/utun-style names (Tunnel), anything elseOther..MacOsinNetworkInterface.all(std/os/src/network.trb); FreeBSD, Windows and the browser stayOsError.Unsupported. Reuse, not duplicate,InterfaceAddress.subnet()and the grouping of Linux where that is a move into../bsdor a shared helper (FreeBSD, slice 7, shares it).NetworkInterface.alldoc comment names macOS as supported; regenerateskills/if the docs change.Acceptance criteria
std/os/tests/network.test.trb(or a macOS-side test file) parses samplelink,inetandinet6lines of a macOS machine into interfaces: loopbacklo0with kindLoopback, flagsUp,127.0.0.1/8and::1/128; anen0with a hardware address, MTU,EthernetorWireless; autuninterface asTunnel; a link with no hardware address giveshardwareAddress: None.subnet().contains(address)holds in the samples.OsError.Malformed, not a panic (as on Linux).macos-arm64in forge CI is green); Linux behaviour and tests are unchanged.NetworkInterface.all()on macOS no longer answersUnsupportedin the source and the doc comment says so.Seed impact
None: no syntax change, no new driver flag, no std name the compiler looks up by string. The change to an existing native's output is declared in the manifest as before (no new native; if one is added it goes to
natives.trblike the processors' and volumes').Size
One PR, two Conventional Commits:
feat(runtime): read the link entries of the BSDs in Posix.interfaceEntriesandfeat(os): NetworkInterface.all on macOS.Decided by the loop
getifaddrsnative and the TorbScript grouping with Linux and later FreeBSD; Windows needs a different native (GetAdaptersAddresses, already loaded inruntime/os/iocp.cfor DNS) and its own file, so it is a separate PR.IFT_ETHERcovers wired and Wi-Fi alike, and telling them apart needs SystemConfiguration/CoreWLAN. No new framework for this slice:IFT_ETHERisEthernet, and the doc comment says Wi-Fi is not told apart on macOS yet.Depends on #539 (landed). Part of #129.
std/networkaddresses and network interfaces (OS slice 5) #129std/networkaddresses and network interfaces (OS slice 5) #129[loop:torbscript] claim implement by session:loop-torbscript-20261029 until 2026-10-29T12:46Z
[loop:torbscript] implement checkpoint: spec read, design settled (shared posix/network.trb for entries/grouping, BSD link line with MTU + IFT type, new macos/network.trb). In flight: writing code. Branch loop/569-networkinterface-macos, worktree code/wt/torbscript-language-569. Next: C native, std/os, tests, PR, CI.
[loop:torbscript] implement checkpoint: PR opened #572 (branch loop/569-networkinterface-macos, worktree code/wt/torbscript-language-569), local VM test 50/50. In flight: forge CI. Next: ci-wait, fix if red, write-back.
[loop:torbscript] implement checkpoint: PR #572 force-pushed (macOS-only link entry; a local zig cc compile found net/if_types.h missing in the macOS headers and FreeBSD not compiling this file yet, so both were dropped from this PR). posix.c compiles clean with -Wall -Wextra -Werror for aarch64-macos, x86_64-macos, x86_64-linux-gnu. Forge CI restarted on the new head; note the forge macos-arm64 cross job runs only on nightly/release, not on PRs. In flight: CI. Branch loop/569-networkinterface-macos, worktree code/wt/torbscript-language-569.
[loop:torbscript] implement: #572, CI pending (forge queue; the first head passed commit messages, scope, pdisc and the linux-x64 bootstrap before it was superseded by a macOS-only force-push, the new head is queued), worker usage ~400k tokens, next: waiting (CI queued, then merge gate: argus review; argus review requested on the PR)