Skip to content

Add a more complete option to set the fields of a sockaddr with a more complex network address string - #673

Open
Keith Horton (keith-horton) wants to merge 2 commits into
microsoft:masterfrom
keith-horton:network-complete-address
Open

Keith Horton (keith-horton) wants to merge 2 commits into
microsoft:masterfrom
keith-horton:network-complete-address

Conversation

@keith-horton

Copy link
Copy Markdown
Member

Summary

  • Add complete IPv4/IPv6 parsing with optional ports and scope IDs.
  • Cover ANSI/Unicode throwing and nothrow overloads, field resets, formatting roundtrips, and invalid inputs.
  • Correct scope ID storage to host byte order, matching native Winsock and TCP/IP behavior. (we took many steps to prove Windows will consistently return v6 sockaddr structures with the scope_id in host-byte-order)

The naming matches the existing "

Validation

Networking tests passed in normal and noexcept builds (2697 and 1759 assertions respectively).

Parse IPv4 and IPv6 addresses with optional ports and scope IDs. Cover ANSI and Unicode throwing and nothrow overloads, reset behavior, formatting round-trips, and invalid inputs. Store IPv6 scope IDs in host byte order to match native Windows APIs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5fc64de7-6803-4598-8ede-edf4a27aa737
- network.h: value-initialize the SOCKADDR_INET union member. Clang's
  'm_sockaddr{}' only zero-initialized the first union member (SOCKADDR_IN),
  leaving bytes 16-27 uninitialized, which failed the reset_complete_address
  failure-path memcmp test in the clang CI jobs.
- NetworkTests: add Verifying_byte_order_with_os_apis, validating port and
  IPv6 scope id byte-order against RtlIpv4/Ipv6StringToAddressExW,
  RtlIpv4/Ipv6AddressToStringExW, GetUnicastIpAddressTable,
  GetAdaptersAddresses, and binding to link-local addresses with the
  host-byte-order (succeeds) vs network-byte-order (fails) scope id.
- NetworkTests: add an inbound Windows Firewall rule (INetFwPolicy2) for the
  test executable while socket tests run, to prevent the firewall prompt;
  warns and continues when not elevated.
- Link iphlpapi.lib for the tests; document elevation in README.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b4a8161d-23a4-4145-9937-0fc0ca9a43a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant