From 8fedb78f98276c31b1b6d146f5ae90af7d2b750a Mon Sep 17 00:00:00 2001 From: Ishan Jain Date: Thu, 27 Jun 2024 12:52:57 +0530 Subject: [PATCH] Add IPV6_PKTINFO, Correct documentationn for IPV6_RECVPKTINFO (#2113) * Add IPV6_PKTINFO, Correct documentationn for IPV6_RECVPKTINFO * Update src/sys/socket/sockopt.rs Co-authored-by: SteveLauC * Update src/sys/socket/sockopt.rs Co-authored-by: SteveLauC * revert documentation changes for IPV6_RECVPKTINFO * updated changelog --------- Co-authored-by: SteveLauC --- changelog/2113.added.md | 1 + src/sys/socket/sockopt.rs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelog/2113.added.md diff --git a/changelog/2113.added.md b/changelog/2113.added.md new file mode 100644 index 0000000000..be654b5dd5 --- /dev/null +++ b/changelog/2113.added.md @@ -0,0 +1 @@ +Add socket option `IPV6_PKTINFO` for BSDs/Linux/Android, also `IPV6_RECVPKTINFO` for DragonFlyBSD \ No newline at end of file diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 810340041d..0b6b07a948 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -905,7 +905,7 @@ sockopt_impl!( libc::IP_PKTINFO, bool ); -#[cfg(any(linux_android, target_os = "freebsd", apple_targets, netbsdlike))] +#[cfg(any(linux_android, bsd))] #[cfg(feature = "net")] sockopt_impl!( #[cfg_attr(docsrs, doc(cfg(feature = "net")))] @@ -917,6 +917,19 @@ sockopt_impl!( libc::IPV6_RECVPKTINFO, bool ); + +#[cfg(any(linux_android, bsd))] +#[cfg(feature = "net")] +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. + Ipv6PacketInfo, + Both, + libc::IPPROTO_IPV6, + libc::IPV6_PKTINFO, + bool +); #[cfg(bsd)] #[cfg(feature = "net")] sockopt_impl!(