-
Notifications
You must be signed in to change notification settings - Fork 241
Adds MACAddress type. #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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.
| /// - 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.