Skip to content

Commit

Permalink
Windows Interface.idx implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Feb 28, 2023
1 parent 5db50e8 commit 56ce5b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ mod getifaddrs_windows {
ret.push(Interface {
name: ifaddr.name(),
addr,
idx: None,
idx: ifaddr.index(),
});
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ impl IpAdapterAddresses {
.into_owned()
}

pub fn index(&self) -> Option<u32> {
let if_index = unsafe { (*self.0).Anonymous1.Anonymous.IfIndex };
if if_index == 0 {
None
} else {
Some(if_index)
}
}

pub fn prefixes(&self) -> PrefixesIterator {
PrefixesIterator {
_head: unsafe { &*self.0 },
Expand Down

0 comments on commit 56ce5b5

Please sign in to comment.