Skip to content

Commit a4e0c95

Browse files
authored
feat: ControlMessageOwned::{Ipv4RecvIf,Ipv4RecvDstAddr} for DragonFlyBSD (#2240)
* feat: Enable ControlMessageOwned::{Ipv4RecvIf,Ipv4RecvDstAddr} for DragonFlyBSD * fix DrafonFlyBSD * fix Linux * fix cfg
1 parent e95162f commit a4e0c95

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

changelog/2240.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Enable `ControlMessageOwned::Ipv4RecvIf` and `ControlMessageOwned::Ipv4RecvDstAddr` for DragonFlyBSD

src/sys/socket/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,11 +748,11 @@ pub enum ControlMessageOwned {
748748
#[cfg(feature = "net")]
749749
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
750750
Ipv6PacketInfo(libc::in6_pktinfo),
751-
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
751+
#[cfg(bsd)]
752752
#[cfg(feature = "net")]
753753
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
754754
Ipv4RecvIf(libc::sockaddr_dl),
755-
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
755+
#[cfg(bsd)]
756756
#[cfg(feature = "net")]
757757
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
758758
Ipv4RecvDstAddr(libc::in_addr),
@@ -931,13 +931,13 @@ impl ControlMessageOwned {
931931
let info = unsafe { ptr::read_unaligned(p as *const libc::in_pktinfo) };
932932
ControlMessageOwned::Ipv4PacketInfo(info)
933933
}
934-
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
934+
#[cfg(bsd)]
935935
#[cfg(feature = "net")]
936936
(libc::IPPROTO_IP, libc::IP_RECVIF) => {
937937
let dl = unsafe { ptr::read_unaligned(p as *const libc::sockaddr_dl) };
938938
ControlMessageOwned::Ipv4RecvIf(dl)
939939
},
940-
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
940+
#[cfg(bsd)]
941941
#[cfg(feature = "net")]
942942
(libc::IPPROTO_IP, libc::IP_RECVDSTADDR) => {
943943
let dl = unsafe { ptr::read_unaligned(p as *const libc::in_addr) };

src/sys/socket/sockopt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ sockopt_impl!(
842842
libc::IPV6_RECVPKTINFO,
843843
bool
844844
);
845-
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
845+
#[cfg(bsd)]
846846
#[cfg(feature = "net")]
847847
sockopt_impl!(
848848
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
@@ -854,7 +854,7 @@ sockopt_impl!(
854854
libc::IP_RECVIF,
855855
bool
856856
);
857-
#[cfg(any(target_os = "freebsd", apple_targets, netbsdlike))]
857+
#[cfg(bsd)]
858858
#[cfg(feature = "net")]
859859
sockopt_impl!(
860860
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]

test/sys/test_socket.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,14 +1750,7 @@ pub fn test_syscontrol() {
17501750
// connect(fd.as_raw_fd(), &sockaddr).expect("connect failed");
17511751
}
17521752

1753-
#[cfg(any(
1754-
target_os = "android",
1755-
target_os = "freebsd",
1756-
apple_targets,
1757-
target_os = "linux",
1758-
target_os = "netbsd",
1759-
target_os = "openbsd",
1760-
))]
1753+
#[cfg(any(bsd, linux_android))]
17611754
fn loopback_address(
17621755
family: AddressFamily,
17631756
) -> Option<nix::ifaddrs::InterfaceAddress> {
@@ -1880,12 +1873,7 @@ pub fn test_recv_ipv4pktinfo() {
18801873
}
18811874
}
18821875

1883-
#[cfg(any(
1884-
target_os = "freebsd",
1885-
apple_targets,
1886-
target_os = "netbsd",
1887-
target_os = "openbsd",
1888-
))]
1876+
#[cfg(bsd)]
18891877
// qemu doesn't seem to be emulating this correctly in these architectures
18901878
#[cfg_attr(
18911879
all(

0 commit comments

Comments
 (0)