Commit Graph

47 Commits

Author SHA1 Message Date
vasilito 1fb1638615 relibc: round 17 — IPv6 inet_ntop + netinet/ip.h + getaddrinfo hints + FIONREAD + accept4
Per NETWORKING-AND-DRIVERS-CODE-ASSESSMENT-2026-07-27.md §15
Tier A + Tier B quick wins (Q3/Q4/Q5/Q6/Q2):

- arpa_inet::inet_ntop: add IPv6 branch (RFC 5952). Real
  longest-run '::' compression with tie-break; rejects
  AFs other than INET/INET6; proper ENOSPC on size<46.
  9 unit tests cover unspecified, loopback, routable,
  link-local, no-compression, tie-break, trailing-run,
  size-too-small, and unsupported-family cases.

- netinet_ip: populate the 3-line skeleton with the
  glibc netinet/ip.h constant set (IP_OPTIONS, IP_TTL,
  IP_HDRINCL, IP_RECVOPTS, IP_RECVDSTADDR, IP_PKTINFO,
  IP_RECVPKTINFO, IP_MINTTL, IP_RECVERR, IP_DONTFRAG,
  IP_PMTUDISC_*, IP_BOUND_IF, IP_ORIGDSTADDR, etc.) plus
  struct ip (BSD) and struct iphdr (Linux) and four
  accessors. 5 unit tests cover roundtrip / alignment /
  constant values / PMTUDISC distinctness.

- netdb::lookup: add lookup_host_v6 (AAAA DNS query type
  0x001c, 16-byte answer parse) and parse_ipv6_string
  delegating to inet_pton(AF_INET6, ...). Shared
  lookup_host_query helper for A + AAAA. lookup_host
  refactored to share the query path.

- netdb::getaddrinfo: full POSIX hints implementation.
  Honors ai_family (AF_UNSPEC / AF_INET / AF_INET6),
  ai_socktype, ai_protocol. Validates flag combinations
  (EAI_BADFLAGS for unknown bits, AI_NUMERICSERV with
  no service, AI_CANONNAME with no node). Implements
  AI_NUMERICHOST (v4 and v6), AI_NUMERICSERV (with
  numeric and getservbyname fallback), AI_PASSIVE
  (0.0.0.0 vs 127.0.0.1 default), AI_CANONNAME (sets
  canonname on first emitted entry), AI_V4MAPPED
  (synthesize ::ffff:a.b.c.d from A results when no
  AAAA and AF_INET6 requested). Emits IPv6 entries with
  proper sockaddr_in6 (16 bytes) when v6 results exist.
  9 unit tests cover numeric-v4, socktype/protocol
  filter, unknown-flag rejection, canonname-without-node
  rejection, numerichost+unparseable, numericserv
  rejection, numericserv+numeric success, IPv6 parse
  roundtrip, garbage rejection, and IPv4-mapped-IPv6
  construction.

- sys_ioctl::ioctl_inner: add FIONREAD handler that
  attempts dup_read(fd, 'fionread', &count). Returns
  ENOTTY if the scheme does not advertise a fionread
  path (consistent with Linux's TIOCNOTTY behavior for
  unsupported ioctls).

- PalSocket::accept4: new trait method. Linux impl uses
  __NR_accept4 (288 on x86_64, 242 on aarch64) via
  sc::syscall5 with EINVAL on unknown flag bits. Redox
  impl falls back to accept() + fcntl() for SOCK_CLOEXEC
  / SOCK_NONBLOCK (mirrors the Linux 2.6.27 pre-syscall
  situation; the race is documented). Public C-callable
  accept4 added in header/sys_socket/mod.rs. Closes
  the #1 gap for Qt / glib compatibility.

Three pre-existing errors in ld_so/dso.rs and ld_so/linker.rs
remain in the working tree but are unrelated to this commit.
2026-07-27 23:00:28 +09:00
auronandace 805b920bd8 apply some clippy lints to arpa_inet header 2026-06-11 08:11:23 +01:00
sourceturner 16abb5d342 fix: implement IPv6 for arpa_inet/inet_pton() 2026-06-11 00:05:58 +02:00
auronandace eca333f18e add descriptions to arpa_inet functions 2026-06-07 14:40:05 +01:00
auronandace 94b2f29beb tackle various clippy lints 2026-06-05 14:36:06 +01:00
sourceturner 125d48e9cd restrict octal prefix to leading zero
the '0o' prefix is only allowed by C2Y, not by C17
POSIX spec defers to C17
2026-06-04 17:33:37 +02:00
sourceturner 538db929cf fix arpa_inet/inet_addr 2026-06-04 17:33:37 +02:00
sourceturner 17b2866d7e fix the inet_pton test of the os-test test suite 2026-06-04 17:33:37 +02:00
Wildan M 4a7f2d80ff Avoid StringWriter cast and string format 2026-05-20 09:10:25 +07:00
auronandace 8cec0c2280 import socklen_t from sys_socket instead of bits 2026-05-03 16:54:46 +01:00
sourceturner 4ffd337b9b add #[allow(deprecated)] annotations
allow using deprecated functions and data structures
in deprecated functions
2026-04-20 21:37:52 +00:00
auronandace d826d1fdc2 verify netinet_in header includes 2026-03-25 10:50:01 +00:00
auronandace 9b76fce0cc move 4 conversion functions from netinet_in to arpa_inet 2026-03-24 11:22:14 +00:00
auronandace 25f059bf67 iterate instead of indexing using a range 2026-03-15 21:39:10 +00:00
auronandace 0a5f8429a3 negate filter predicate 2026-03-13 08:41:41 +00:00
auronandace 29d0cc67ee cargo fmt 2026-03-13 08:23:49 +00:00
auronandace 0d0afac2c8 fix parsing octets with leading zeros in inet_pton 2026-03-13 08:18:01 +00:00
auronandace ae91f48fae remove duplicate socklen_t definition 2026-03-11 12:42:53 +00:00
auronandace 63366e98ef correct the count 2026-03-04 16:35:07 +00:00
auronandace 5ce797af52 partially improve inet_aton 2026-03-04 15:38:15 +00:00
auronandace 6933287a94 enforce borrow-as-ptr clippy lint 2026-03-01 19:54:31 +00:00
auronandace 5d753b7f48 refactor some as casts in arpa_inet 2026-02-17 17:35:13 +00:00
sourceturner defd2ce7c3 Deny deny-unsafe_op_in_unsafe_fn on the crate level 2026-01-21 00:41:57 +01:00
auronandace 6e25b2be7f arpa_inet and semaphore header cleanup 2025-12-31 09:14:21 +00:00
Jeremy Soller 3765148270 Fix incompatible functions 2025-12-19 12:55:43 -07:00
Jeremy Soller 16814d2e32 Fix socklen_t type 2025-11-07 18:10:17 -07:00
Jeremy Soller 82084440ad Support nightly-2025-10-03 2025-10-03 21:51:10 -06:00
Jeremy Soller 863171105d Move htonl, htons, ntohl, ntohs to netinet/in.h to support more packages 2025-05-02 09:49:37 -06:00
Peter Limkilde Svendsen a285728610 Formatting 2025-01-30 21:35:43 +01:00
Peter Limkilde Svendsen f4c75e99cd Align function parameter names and types with POSIX 2025-01-30 21:35:11 +01:00
Peter Limkilde Svendsen b36ae4cab5 Reorder functions alphabetically 2025-01-30 21:23:54 +01:00
Peter Limkilde Svendsen 5ec734a672 Add docstrings and deprecations for arpa/inet.h 2025-01-30 21:19:20 +01:00
Peter Limkilde Svendsen 58bb5a9689 Use unsafe blocks in arpa/inet.h implementation 2024-09-11 21:14:14 +00:00
Peter Limkilde Svendsen a7137512fa Use standard casing and mangling for internal errno 2024-03-01 00:25:42 +00:00
Peter Limkilde Svendsen 9093f6bc47 Use Cell representation for errno 2024-02-29 14:07:40 +00:00
Peter Limkilde Svendsen e4a7186b22 Use C type names in byteorder functions 2020-05-28 20:17:57 +02:00
jD91mZM2 b8c50c7c64 Format 2019-08-04 19:05:45 +02:00
jD91mZM2 c7d499d4f2 Upgrade to the 2018 edition
I didn't think it'd be this useful first, but thank god for `cargo fix --edition`!
2019-08-04 19:05:45 +02:00
Jeremy Soller 52fd4d7e83 Clippy fixes 2018-12-02 08:04:53 -07:00
Jeremy Soller 7f14fcdee0 Remove c_str functions, replace with CStr 2018-09-24 21:08:29 -06:00
jD91mZM2 59d74e194d Fix CI 2018-09-04 15:31:43 +02:00
thedarkula e688d9c4d1 Updated url, implemented missing functions in header/arpa_inet/mod.rs 2018-09-04 02:59:59 +01:00
jD91mZM2 26f953e11f Run fmt.sh 2018-09-02 08:17:52 +02:00
jD91mZM2 6fe3e05ea0 Delete duplicate types
Now that we use cbindgen differently :D
2018-09-02 08:17:15 +02:00
Jeremy Soller 8f5470fd27 Reduce warnings 2018-08-27 07:12:24 -06:00
Jeremy Soller 7ab700315d Fix warnings and add c_str 2018-08-26 15:15:29 -06:00
Jeremy Soller c20ce5ffed Large reorganization of headers (WIP) 2018-08-26 08:11:35 -06:00