From cd8f1bb44fc8340d35742d03dc74039eed739228 Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Sun, 16 Jul 2023 15:46:32 +0900 Subject: [PATCH] Fix macOS Implemented because of the possibility, but removed because it is unstable and currently unnecessary. --- src/gateway/macos.rs | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/gateway/macos.rs b/src/gateway/macos.rs index f445776..3110286 100644 --- a/src/gateway/macos.rs +++ b/src/gateway/macos.rs @@ -175,35 +175,10 @@ unsafe fn sa_to_ip(sa: &sockaddr) -> Option { } } -unsafe fn sa_to_link(sa: &sockaddr) -> Option<(Option<[u8; 6]>, u16)> { - match sa.sa_family as u32 { - AF_LINK => { - let sa_dl = sa as *const _ as *const sockaddr_dl; - let ifindex = (*sa_dl).sdl_index; - let mac; - if (*sa_dl).sdl_alen >= 6 { - let i = (*sa_dl).sdl_nlen as usize; - - let a = (*sa_dl).sdl_data[i + 0] as u8; - let b = (*sa_dl).sdl_data[i + 1] as u8; - let c = (*sa_dl).sdl_data[i + 2] as u8; - let d = (*sa_dl).sdl_data[i + 3] as u8; - let e = (*sa_dl).sdl_data[i + 4] as u8; - let f = (*sa_dl).sdl_data[i + 5] as u8; - mac = Some([a, b, c, d, e, f]); - } else { - mac = None; - } - Some((mac, ifindex)) - } - _ => None, - } -} - fn message_to_route(hdr: &rt_msghdr, msg: *mut u8) -> Option { let destination; let mut gateway = None; - let mut ifindex = None; + let ifindex = None; if hdr.rtm_addrs & (1 << RTAX_DST) == 0 { return None; @@ -226,11 +201,6 @@ fn message_to_route(hdr: &rt_msghdr, msg: *mut u8) -> Option { gateway = sa_to_ip(gw_sa); - if gateway.is_none() { - if let Some((_mac, ifidx)) = sa_to_link(gw_sa) { - ifindex = Some(ifidx as u32); - } - } } }