feature: network utils supports#19
Merged
Merged
Conversation
…next PLAN and ROADMAP had stalled at 'Phase 2 complete' while PR#17 (structure gates + STRUCTURE-TASTE) and PR#18 (PERFORMANCE + io/tar/cmp/md5sum/sed streaming + google-benchmark harness) landed on main. Sync the batch tables, restate baseline 436 GTest / 439 KB / 123 applet, point next at Phase 3 network, and leave a backfilled batch note.
First slice of Phase 3 networking: a header-only cfbox::socket primitive layer and the first applet that consumes it. - include/cfbox/socket.hpp: make/resolve/connect_fd/set_reuseaddr/dial/ listen_on/bound_port/accept_one/format_addr. Reuses cfbox::io::unique_fd for fd lifetime (DRY: a socket is a fd; no separate SocketFd class). Plaintext, dual-stack, errors via base::Result. - src/applets/nc.cpp: connect mode (nc HOST PORT) and listen mode (nc -l -p PORT). Single-process poll(2) relay bridges stdin->sock and sock->stdout; SHUT_WR half-close on stdin EOF so a peer can still reply. No fork (keeps cfbox process state clean). - Registered in APPLET_REGISTRY, Config.cmake CFBOX_APPLETS, and applet_config.hpp.in. - tests/unit/test_socket.cpp: loopback echo + resolve + v4/v6 format. - tests/integration/test_nc.sh: server listens, client sends one line. Verified: 440/440 GTest (+4 SocketTest), structure gate PASS, size-opt 451 KB (+12, <=550 budget), 55 integration scripts green.
Add Phase 3 batch table to PLAN (batch 1 = socket.hpp + nc, 10f811f), bump top-line baseline to 440 GTest / 451 KB / 124 applet, and leave a batch note covering the three pitfalls hit (CFBOX_TRY in int-returning entry, relay 4-fd bridge, test_nc.sh set -e) plus the SocketFd->unique_fd DRY decision.
Ran the armhf gap that PR#18 left open (compile-only, no qemu run): static build with /opt/arm-gnu-toolchain is clean at -WConversion, and qemu-arm-static runs the five streamed applets (io/md5sum/tar/sed/cmp) plus nc loopback echo end to end. No 32-bit regression. armhf static 1235 KB.
…wave 1a) Wave 1 first slice: a read-only interface layer plus the ifconfig display path. Mutations (addr/up/down/mtu) and ip/route/netstat come later. - include/cfbox/net_util.hpp: InterfaceInfo + read_interfaces() (parses /proc/net/dev for counters, ioctl SIOCGIF* for flags/mtu/hwaddr/ipv4) + format_ifconfig() in BusyBox multi-line style. Hand-rolled field parser avoids <sstream>. - src/applets/ifconfig.cpp: 'ifconfig' (up only), '-a' (all), 'ifconfig IFACE'. - ipv4_from_ioctl helper memcpy's sockaddr->sockaddr_in instead of casting, sidestepping -Wcast-align on 32-bit ARM (x86-64 is silent; armhf -Werror caught it). - tests/unit/test_net_util.cpp: live /proc/net/dev + format coverage. - tests/integration/test_ifconfig.sh: -a/no-arg/named/bogus-exit. Verified: 446/446 GTest (+6 NetUtilTest), structure gate PASS, size-opt 455 KB (+4), 56 integration scripts green, armhf static clean + qemu ifconfig.
Add batch 2 row to Phase 3 table (f4279d6), bump baseline to 446 GTest / 455 KB / 125 applet, and note the armhf -Wcast-align catch (sockaddr -> sockaddr_in memcpy via ipv4_from_ioctl) plus the loopback Bcast and collisions/txqueuelen output fixes.
…e 3 wave 1b) Wave 1b: two new display applets and the hostname options, all built on the net_util layer from wave 1a. - include/cfbox/net_util.hpp: RouteEntry + read_routes() (parses /proc/net/route tab-separated hex fields) + format_route_table() (BusyBox route -n layout) + hex_to_ipv4 (host-endian hex → dotted) + prefix_len. hex_to_ipv4 explicitly casts strtoul's unsigned long to uint32_t (-Wshorten-64-to-32 on x86-64). - src/applets/ip.cpp: 'ip addr [show] [IFACE]' — iproute2-style index, flags, mtu, link, inet/prefix/scope. addr subtree only (link/route/add later). - src/applets/route.cpp: 'route [-n]' — prints the table; add/del rejected. - src/applets/hostname.cpp: add -i (resolve_ipv4 via getaddrinfo, memcpy to dodge -Wcast-align), -f (FQDN via AI_CANONNAME), -d (domain part). - tests: NetUtil +3 (hex/prefix/route-table), IpTest +3, test_ip.sh, test_route.sh. Verified: 452/452 GTest (+9), structure gate PASS, size-opt 463 KB (+8), 58 integration scripts green, armhf static clean + qemu ip/route/hostname.
Add batch 3 row (f0ff0db), bump baseline to 452 GTest / 463 KB / 127 applet, and note the strtoul-uint32 shorten catch plus the getaddrinfo ai_addr memcpy (reusing the ipv4_from_ioctl cast-align pattern from wave 1a).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.