Skip to content
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

ch8/ch8-mac: Clear Unicast/Multicast bit #101

Open
wants to merge 1 commit into
base: 1st-edition
Choose a base branch
from

Conversation

ewenmcneill
Copy link

To match MAC address specification (eg, as summarised at https://en.wikipedia.org/wiki/MAC_address#Address_details) and Figure 8.4 of the text, clear the LSB of the 1st octet when generating the MAC address, rather than setting it. Also update check for "is_unicast()" to match.

Equivalent fix (from 2020-08-13) in the ch8-mget example: #7 (comment), which seems to have already been fixed when the first edition of the book was released (7d7955e):

impl MacAddress {
pub fn new() -> MacAddress {
let mut octets: [u8; 6] = [0; 6];
rand::thread_rng().fill_bytes(&mut octets); // <1>
octets[0] |= 0b_0000_0010; // <2>
octets[0] &= 0b_1111_1110; // <3>
MacAddress { 0: octets }
}
}

but apparently ch8/ch8-mac did not get fixed at the same time.

To match MAC address specification (eg, as summarised at
https://en.wikipedia.org/wiki/MAC_address#Address_details)
and Figure 8.4 of the text, clear the LSB of the 1st octet
when generating the MAC address, rather than setting it.
Also update check for "is_unicast()" to match.

Equivalent fix (from 2020-08-13) in the ch8-mget example:
rust-in-action#7 (comment)
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