-
-
Notifications
You must be signed in to change notification settings - Fork 180
uefi-raw: move types to net module #1747
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
d4c0295
to
d63bcbd
Compare
There are a few unexpected changes:
diff --git a/uefi-raw/src/net.rs b/uefi-raw/src/net.rs index 3b4f3e5f..71662aef 100644 --- a/uefi-raw/src/net.rs +++ b/uefi-raw/src/net.rs @@ -43,7 +43,7 @@ impl From<Ipv6Address> for core::net::Ipv6Addr { /// /// Corresponds to the `EFI_IP_ADDRESS` type in the UEFI specification. This /// type is defined in the same way as edk2 for compatibility with C code. Note -/// that this is an **untagged union**, so there's no way to tell which type of +/// that this is an untagged union, so there's no way to tell which type of /// address an `IpAddress` value contains without additional context. #[derive(Clone, Copy)] #[repr(C)] @@ -106,15 +106,7 @@ impl From<core::net::IpAddr> for IpAddress { } } -/// UEFI Media Access Control (MAC) address. -/// -/// UEFI supports multiple network protocols and hardware types, not just -/// Ethernet. Some of them may use MAC addresses longer than 6 bytes. To be -/// protocol-agnostic and future-proof, the UEFI spec chooses a maximum size -/// that can hold any supported media access control address. -/// -/// In most cases, this is just a typical `[u8; 6]` Ethernet style MAC -/// address with the rest of the bytes being zero. +/// A Media Access Control (MAC) address. #[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(transparent)] pub struct MacAddress(pub [u8; 32]); @@ -122,7 +114,12 @@ pub struct MacAddress(pub [u8; 32]); impl From<[u8; 6]> for MacAddress { fn from(octets: [u8; 6]) -> Self { let mut buffer = [0; 32]; - buffer.copy_from_slice(&octets); + buffer[0] = octets[0]; + buffer[1] = octets[1]; + buffer[2] = octets[2]; + buffer[3] = octets[3]; + buffer[4] = octets[4]; + buffer[5] = octets[5]; Self(buffer) } }
In particular, was dropping part of the MacAddress
docstring intentional? The copy_from_slice
change looks like a bugfix, since the slice lengths are different. Might be better to do that as buffer[..6].copy_from_slice(&octets);
, but either way it ideally wouldn't be mixed into the same commit that splits out the module, or at least call it out in the commit message.
Yikes. I was certain I fixed this already 🤔 I work from two different laptops - perhaps I fixed it on one without pushing and continued work on another - anyway, thanks for pointing that out! I'll fix it.
We have enough network-related types to justify a dedicated module: - IpAddress - Ipv4Address - Ipv6Address - MacAddress
d63bcbd
to
6811f02
Compare
Okay, I think it should be fixed now. Thanks for the close attention on this one, good catch
Split-out from #1699.
We have enough network-related types to justify
a dedicated module:
Checklist