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

feat: ControlMessageOwned::{Ipv4RecvIf,Ipv4RecvDstAddr} for DragonFlyBSD #2240

Merged
merged 4 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog/2240.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable `ControlMessageOwned::Ipv4RecvIf` and `ControlMessageOwned::Ipv4RecvDstAddr` for DragonFlyBSD
8 changes: 4 additions & 4 deletions src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,11 +748,11 @@ pub enum ControlMessageOwned {
#[cfg(feature = "net")]
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Ipv6PacketInfo(libc::in6_pktinfo),
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
#[cfg(bsd)]
#[cfg(feature = "net")]
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Ipv4RecvIf(libc::sockaddr_dl),
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
#[cfg(bsd)]
#[cfg(feature = "net")]
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Ipv4RecvDstAddr(libc::in_addr),
Expand Down Expand Up @@ -931,13 +931,13 @@ impl ControlMessageOwned {
let info = unsafe { ptr::read_unaligned(p as *const libc::in_pktinfo) };
ControlMessageOwned::Ipv4PacketInfo(info)
}
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
#[cfg(bsd)]
#[cfg(feature = "net")]
(libc::IPPROTO_IP, libc::IP_RECVIF) => {
let dl = unsafe { ptr::read_unaligned(p as *const libc::sockaddr_dl) };
ControlMessageOwned::Ipv4RecvIf(dl)
},
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
#[cfg(bsd)]
#[cfg(feature = "net")]
(libc::IPPROTO_IP, libc::IP_RECVDSTADDR) => {
let dl = unsafe { ptr::read_unaligned(p as *const libc::in_addr) };
Expand Down
4 changes: 2 additions & 2 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ sockopt_impl!(
libc::IPV6_RECVPKTINFO,
bool
);
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
#[cfg(bsd)]
#[cfg(feature = "net")]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Expand All @@ -854,7 +854,7 @@ sockopt_impl!(
libc::IP_RECVIF,
bool
);
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
#[cfg(bsd)]
#[cfg(feature = "net")]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
Expand Down
16 changes: 2 additions & 14 deletions test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,14 +1750,7 @@ pub fn test_syscontrol() {
// connect(fd.as_raw_fd(), &sockaddr).expect("connect failed");
}

#[cfg(any(
target_os = "android",
target_os = "freebsd",
apple_targets,
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
#[cfg(any(bsd, linux_android))]
fn loopback_address(
family: AddressFamily,
) -> Option<nix::ifaddrs::InterfaceAddress> {
Expand Down Expand Up @@ -1880,12 +1873,7 @@ pub fn test_recv_ipv4pktinfo() {
}
}

#[cfg(any(
target_os = "freebsd",
apple_targets,
target_os = "netbsd",
target_os = "openbsd",
))]
#[cfg(bsd)]
// qemu doesn't seem to be emulating this correctly in these architectures
#[cfg_attr(
all(
Expand Down