Skip to content

Commit

Permalink
Add Ipv6MulticastHops as socket option (#2234) (#2234)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon B. Gasse <sgasse@users.noreply.github.com>
  • Loading branch information
sgasse and sgasse committed Dec 4, 2023
1 parent 8d656e3 commit 75bddf2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/2234.added.md
@@ -0,0 +1 @@
Added `Ipv6MulticastHops` as socket option to set and read.
11 changes: 11 additions & 0 deletions src/sys/socket/sockopt.rs
Expand Up @@ -355,6 +355,17 @@ sockopt_impl!(
u8
);
#[cfg(feature = "net")]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
/// Set or read the hop limit value of outgoing IPv6 multicast packets for
/// this socket.
Ipv6MulticastHops,
Both,
libc::IPPROTO_IPV6,
libc::IPV6_MULTICAST_HOPS,
libc::c_int
);
#[cfg(feature = "net")]
sockopt_impl!(
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
/// Set or read a boolean integer argument that determines whether sent
Expand Down
13 changes: 13 additions & 0 deletions test/sys/test_sockopt.rs
Expand Up @@ -325,6 +325,19 @@ fn test_ttl_opts() {
.expect("setting ipv6ttl on an inet6 socket should succeed");
}

#[test]
fn test_ipv6_multicast_hops() {
let fd6 = socket(
AddressFamily::Inet6,
SockType::Datagram,
SockFlag::empty(),
None,
)
.unwrap();
setsockopt(&fd6, sockopt::Ipv6MulticastHops, &7)
.expect("setting ipv6multicasthops on an inet6 socket should succeed");
}

#[test]
#[cfg(apple_targets)]
fn test_dontfrag_opts() {
Expand Down

0 comments on commit 75bddf2

Please sign in to comment.