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

Explicitly implement is_unicast_link_local #2

Merged
merged 1 commit into from
Apr 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,13 @@ fn cmp_socket_addr(l: SocketAddr, r: SocketAddr) -> bool {
}
}

// TODO replace with Ipv6Addr's is_unicast_link_local once that is stablized
fn is_unicast_link_local(addr: &Ipv6Addr) -> bool {
// Copied from Ipv6Addr::is_unicast_link_local, whose stabilization has not seen any activity
// in years
(addr.segments()[0] & 0xffc0) == 0xfe80
}

fn update_local_addr(addrs: &mut Vec<LocalAddress>, rtnl_msg: &RtnlMessage) -> Option<()> {
match rtnl_msg {
RtnlMessage::NewAddress(na_msg) => {
Expand All @@ -693,9 +700,7 @@ fn update_local_addr(addrs: &mut Vec<LocalAddress>, rtnl_msg: &RtnlMessage) -> O
let ip_addr = addr_from_vec(a)?;
match ip_addr {
IpAddr::V6(a6) => {
// TODO enable once is_unicast_link_local is stablized
//if a6.is_unicast_link_local() {
if false {
if is_unicast_link_local(&a6) {
SocketAddr::V6(SocketAddrV6::new(a6, 0, 0, na_msg.header.index))
} else {
SocketAddr::new(ip_addr, 0)
Expand Down