Skip to content

Conversation

@jglogan
Copy link
Contributor

@jglogan jglogan commented Jan 3, 2026

- Simplifies processing and validation of MAC addresses
  for apple/container#1005, where we need to create MAC
  addresses and corresponding link local IPv6 addresses.
- Adds Codable for IPAddress and CIDR for
  apple/container#1006, so we can parse and relay IP
  addresses regardless of address family for port
  forwards.
Comment on lines 35 to 36
/// - Parameter string: The IPv4 address string in dotted decimal notation (e.g., "192.168.1.1")
/// - Throws: `IPAddressError.unableToParse` if the string is not a valid IPv4 address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem to be related to this type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

/// MACAddress.parse("01:23:45:67:89:ab") // Returns: 0x00000123456789ab
/// MACAddress.parse("01-23-45-67-89-AB") // Returns: 0x00000123456789ab
/// MACAddress.parse("00:00:00:00:00:00") // Returns: 0x0000000000000000
/// MACAddress.parse("ff:ff:ff:ff:ff:ff") // Returns: 0xffffffffffffffff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it's not ignoring the top 16 bits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

for byte in utf8 {
// ASCII whitespace: space(32), tab(9), newline(10), return(13)
if byte == 32 || byte == 9 || byte == 10 || byte == 13 {
throw IPAddressError.unableToParse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh maybe my prior comment was only partially wrong, but I would expect we return some MacAddressError instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed IPAddressError to AddressError instead of creating a redundant error type, but I can create a separate MACAddressError for this type if we think it's useful.

@jglogan jglogan merged commit 452f354 into apple:main Jan 5, 2026
2 checks passed
@jglogan jglogan deleted the mac-address branch January 5, 2026 19:31
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.

2 participants