Skip to content
Closed
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/2687.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixed IPV6_PKTINFO/IP_PKTINFO sockopt type from bool to in6_pktinfo/in_pktinfo
8 changes: 4 additions & 4 deletions src/sys/socket/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,12 +1052,12 @@ sockopt_impl!(
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
/// Pass an `IP_PKTINFO` ancillary message that contains a pktinfo
/// structure that supplies some information about the incoming packet.
/// structure that supplies some information about the outgoing packet.
Ipv4PacketInfo,
Both,
libc::IPPROTO_IP,
libc::IP_PKTINFO,
bool
libc::in_pktinfo
);
#[cfg(any(linux_android, bsd))]
#[cfg(feature = "net")]
Expand All @@ -1077,12 +1077,12 @@ sockopt_impl!(
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
/// Pass an `IPV6_PKTINFO` ancillary message that contains a in6_pktinfo
/// structure that supplies some information about the incoming packet.
/// structure that supplies some information about the outgoing packet.
Ipv6PacketInfo,
Both,
libc::IPPROTO_IPV6,
libc::IPV6_PKTINFO,
bool
libc::in6_pktinfo
);
#[cfg(bsd)]
#[cfg(feature = "net")]
Expand Down
16 changes: 15 additions & 1 deletion test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,21 @@ pub fn test_recv_ipv4pktinfo() {
bind(receive.as_raw_fd(), &lo).expect("bind failed");
let sa: SockaddrIn =
getsockname(receive.as_raw_fd()).expect("getsockname failed");
setsockopt(&receive, Ipv4PacketInfo, &true).expect("setsockopt failed");
cfg_if! {
if #[cfg(target_os = "netbsd")] {
let pi = libc::in_pktinfo {
ipi_ifindex: 0,
ipi_addr: libc::in_addr { s_addr: 0 },
};
} else {
let pi = libc::in_pktinfo {
ipi_ifindex: 0,
ipi_addr: libc::in_addr { s_addr: 0 },
ipi_spec_dst: libc::in_addr { s_addr: 0 },
};
}
}
setsockopt(&receive, Ipv4PacketInfo, &pi).expect("setsockopt failed");

{
let slice = [1u8, 2, 3, 4, 5, 6, 7, 8];
Expand Down
Loading