This commit is contained in:
Christien Rioux 2024-03-02 18:31:07 -05:00
parent 89c51ff069
commit 931d145719

View File

@ -281,8 +281,7 @@ impl PlatformSupportApple {
}
async fn refresh_default_route_interfaces(&mut self) {
self.default_route_interfaces.clear();
loop {
let mut mib = [CTL_NET, PF_ROUTE, 0, 0, NET_RT_FLAGS, RTF_GATEWAY];
let mut sa_tab: [*const sockaddr; RTAX_MAX as usize] =
[std::ptr::null(); RTAX_MAX as usize];
@ -319,10 +318,13 @@ impl PlatformSupportApple {
)
} < 0
{
error!("Unable to get memory size for routing table");
return;
debug!("routing table changed length between interface checks, trying again");
continue;
}
// Clear old interfaces
self.default_route_interfaces.clear();
// Process each routing message
let mut mib_ptr = rt_buf.as_ptr();
let mib_end = unsafe { mib_ptr.add(rt_buf_len) };
@ -338,7 +340,8 @@ impl PlatformSupportApple {
sa_tab[i] = sa;
sa = unsafe {
let sa_len = (*sa).sa_len;
sa = ((sa as *const u8).add(round_up!(sa_len as usize))) as *const sockaddr;
sa = ((sa as *const u8).add(round_up!(sa_len as usize)))
as *const sockaddr;
sa
};
}
@ -369,6 +372,9 @@ impl PlatformSupportApple {
mib_ptr = unsafe { mib_ptr.add((*rt).rtm_msglen.into()) };
}
break;
}
}
fn get_interface_flags(&self, index: u32, flags: c_int) -> InterfaceFlags {