os: std/network addresses and network interfaces (OS slice 5) #129
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
Slice 5 of
docs/design/OS.mdsection 10:std/osanswers which network interfaces the machine has, with their addresses, status, kind and traffic (NetworkInterface,InterfaceAddress,InterfaceStatus,InterfaceKind,InterfaceTraffic, section 5.5), and the address values they are made of exist as pure types. Windows, Linux and macOS; FreeBSD and the browser answerOsError.Unsupporteduntil slice 7, like the other slices.Source
std/os"the rest of their slices" (#126 to #131). Its dependency #126 (slice 2) is closed.What changed since OS.md was written
The design proposed a new pure
std/networkforIpv4Address,Ipv6Address,IpAddress,MacAddressandSubnet. URI.md section 8a decided otherwise and it is built: the pure package isstd/ip(three of the five values, with parsers, RFC 5952 display and tests, andSocketAddress), andstd/networkis the socket package that re-exports it. What this slice adds isSubnet,MacAddressand the interfaces. See the decision comment below.Epic: why, and the steps
The slice spans two pure types, three runtime files (
windows.c,posix.c,bsd.c), three TorbScript layers and two reading natives per system: more than one PR of one or two commits. Per the definition of ready it is an epic; this issue carries noreadylabel and each step is filed when it starts next.Subnetinstd/ip,MacAddressinstd/os, an audit of the IPv6 parser tests, the OS.md records corrected (#528)InterfaceAddress.subnet()andNetworkInterface.allon LinuxNetworkInterface.allon macOS (theAF_LINKentry ofPosix.interfaceEntries,std/os/src/macos/network.trb)NetworkInterface.allon Windows (GetAdaptersAddresses)InterfaceTraffic(Subtract),NetworkInterface.traffic(Linux/proc/net/devparser, WindowsGetIfEntry2,Bsd.linkTraffic),NetworkInterface.throughput(two readings and a sleep, aTask),docs/standard-library/os.md, then OS.md slice 5 marked done with a "How slice 5 landed" noteAcceptance criteria (of the epic)
NetworkInterface.all()on Windows, Linux and macOS answers the loopback interface withLoopbackkind and a loopback address, and every address'ssubnet().contains(address)holdsdocs/standard-library/os.mdandip.mddocument the whole network APISeed impact
None for any step: no syntax change, no new driver flag, no std name the compiler looks up by string; the natives of steps 2 and 3 are declared in
natives.trblike the processors' and volumes'. The compiler does not importNetworkInterface.Dependencies
lib.trb,natives.trbandos.mdwith this one; a rebase settles that.[loop:torbscript] intake: in scope (author orion, label loop), source OS.md slice 5, not a duplicate. Depends on #126. next: waiting (dependency #126) until 2026-10-10T04:00:00Z
[loop:torbscript] claim refine by session:loop-torbscript-20261027 until 2026-10-27T05:15Z
SubnetandMacAddress(step 1 of #129, OS slice 5) #528[loop:torbscript] decided by the loop:
loop,ready); steps 2 and 3 are filed when they start next. This issue gets noready.std/ip(built), andstd/networkis the socket package. So the sketch's "new purestd/network" is superseded; the slice addsSubnetandMacAddressonly. The shapes as built (octets(): List<Int>) stand; OS.md is corrected in step 1.Subnetinstd/ip,MacAddressinstd/os(module of its own).std/ipholds "nothing that is not IP" (URI.md 8a); a MAC is link-layer. A module of its own, notnetwork.trb, so parsing a MAC needs nostd/os/networksandbox grant (OS.md section 8).Subnetis always a network: the text192.168.1.23/24is refused (host bits set),InterfaceAddress.subnet()masks. Why: the value hasEqualsandHash, and two spellings of one network must not be two values.OsError.Unsupporteduntil slice 7, like slices 2 to 4; "every supported system" in the old criteria means Windows, Linux and macOS.IpAddress,Subnet, ...) is a compiler change that OS.md only calls a candidate; not part of this slice.[loop:torbscript] refine: the dependency #126 is closed. Body rewritten to the definition of ready as an epic (goal, source, what changed since OS.md, three-step checklist, epic acceptance criteria, seed impact none); step 1 filed as #528 (
Subnet,MacAddress, IPv6 parser test audit, OS.md corrected; pure TorbScript, one PR in two commits) withloopandready. #129 carries noready. Claim by session:loop-torbscript-20261027 released. next: epic (step 1 = #528 implement; steps 2 and 3 filed when they start). Worker usage: about 130k tokens (sonnet).SubnetandMacAddress(step 1 of #129, OS slice 5) #528[loop:torbscript] claim refine (step 1 #528 landed, cut step 2) by session:loop-torbscript-20261028 until 2026-10-28T08:45Z
[loop:torbscript] refine: verified on
mainthat step 1 landed (#528 closed;Subnetinstd/ip,MacAddressinstd/os, commits81e1067and29b5cb9) and ticked it in the body. Step 2 spans five types, three systems and three runtime files, more than one PR of one or two commits, so only its first sub-step is filed: #539 (types, pure parsers,InterfaceAddress.subnet(),NetworkInterface.allon Linux; macOS and Windows answerOsError.Unsupporteduntil step 2b) withloopandready; no duplicate among the open issues. The epic checklist now lists 2a (#539) and 2b (filed when 2a lands); step 3 not filed. Seed impact none. Claim by session:loop-torbscript-20261028 released. next: waiting (epic; step 2a is #539, implement). Worker usage: about 60k tokens (sonnet).[loop:torbscript] claim refine (next step after the landed one) by session:loop-torbscript-20261029 until 2026-10-29T08:35Z
[loop:torbscript] decided by the loop: step 2b is macOS alone and Windows becomes 2c. macOS shares
getifaddrs,Posix.interfaceEntries(itsAF_LINKhook is already stubbed inposix.c) and the grouping with Linux and later FreeBSD; Windows needs a different native (GetAdaptersAddresses) and file, so it is its own PR. Wi-Fi is not told apart from Ethernet on macOS in 2b (needs a framework; documented). Seed impact none.[loop:torbscript] refine: verified on
main(152d95a) that step 2a landed (#539 closed;std/os/src/network.trb,std/os/src/linux/network.trb,Posix.interfaceEntriesinruntime/os/posix.c, tests instd/os/tests/network.test.trb); #548 (UnixListener and UnixStream) is closed and belongs to #119, not to this epic. Ticked 2a, split old 2b into 2b (macOS) and 2c (Windows) in the checklist. Filed #569 (NetworkInterface.allon macOS; goal, acceptance criteria, OS.md 5.5 pointer, seed impact none, one PR in two commits) withloopandready; no duplicate among open and closed issues (keywords: network, interface, macOS). Step 2c and step 3 are not filed. Claim by session:loop-torbscript-20261029 released. next: ready (#569). Worker usage: about 70k tokens (sonnet).