Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Convert ipv4 address to native/host byte order before further conversions #834

Merged
merged 1 commit into from
Aug 29, 2024
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
4 changes: 2 additions & 2 deletions flecs-core/src/relic/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ impl TryFrom<ifaddrs> for NetworkAddress {
}
SaFamily::Inet4 => {
let s = unsafe { *(value.ifa_addr as *const sockaddr_in) };
let addr: Ipv4Addr = s.sin_addr.s_addr.into();
let addr: Ipv4Addr = u32::from_be(s.sin_addr.s_addr).into();
let addr = addr.to_string();
let s = unsafe { *(value.ifa_netmask as *const sockaddr_in) };
let subnet_mask: Ipv4Addr = s.sin_addr.s_addr.into();
let subnet_mask: Ipv4Addr = u32::from_be(s.sin_addr.s_addr).into();
let subnet_mask = subnet_mask.to_string();
Ok(NetworkAddress {
address: Address::Ipv4(IpAddr { addr, subnet_mask }),
Expand Down