Skip to content

Commit fd74695

Browse files
committed
Fix test_recv_ipv4pktinfo
1 parent 44865ad commit fd74695

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/sys/test_socket.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1859,7 +1859,21 @@ pub fn test_recv_ipv4pktinfo() {
18591859
bind(receive.as_raw_fd(), &lo).expect("bind failed");
18601860
let sa: SockaddrIn =
18611861
getsockname(receive.as_raw_fd()).expect("getsockname failed");
1862-
setsockopt(&receive, Ipv4PacketInfo, &true).expect("setsockopt failed");
1862+
cfg_if! {
1863+
if #[cfg(target_os = "netbsd")] {
1864+
let pi = libc::in_pktinfo {
1865+
ipi_ifindex: 0,
1866+
ipi_addr: libc::in_addr { s_addr: 0 },
1867+
};
1868+
} else {
1869+
let pi = libc::in_pktinfo {
1870+
ipi_ifindex: 0,
1871+
ipi_addr: libc::in_addr { s_addr: 0 },
1872+
ipi_spec_dst: libc::in_addr { s_addr: 0 },
1873+
};
1874+
}
1875+
}
1876+
setsockopt(&receive, Ipv4PacketInfo, &pi).expect("setsockopt failed");
18631877

18641878
{
18651879
let slice = [1u8, 2, 3, 4, 5, 6, 7, 8];

0 commit comments

Comments
 (0)