Skip to content

Commit 75bddf2

Browse files
authored
Add Ipv6MulticastHops as socket option (#2234) (#2234)
Co-authored-by: Simon B. Gasse <sgasse@users.noreply.github.com>
1 parent 8d656e3 commit 75bddf2

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

changelog/2234.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added `Ipv6MulticastHops` as socket option to set and read.

src/sys/socket/sockopt.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,17 @@ sockopt_impl!(
355355
u8
356356
);
357357
#[cfg(feature = "net")]
358+
sockopt_impl!(
359+
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
360+
/// Set or read the hop limit value of outgoing IPv6 multicast packets for
361+
/// this socket.
362+
Ipv6MulticastHops,
363+
Both,
364+
libc::IPPROTO_IPV6,
365+
libc::IPV6_MULTICAST_HOPS,
366+
libc::c_int
367+
);
368+
#[cfg(feature = "net")]
358369
sockopt_impl!(
359370
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
360371
/// Set or read a boolean integer argument that determines whether sent

test/sys/test_sockopt.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,19 @@ fn test_ttl_opts() {
325325
.expect("setting ipv6ttl on an inet6 socket should succeed");
326326
}
327327

328+
#[test]
329+
fn test_ipv6_multicast_hops() {
330+
let fd6 = socket(
331+
AddressFamily::Inet6,
332+
SockType::Datagram,
333+
SockFlag::empty(),
334+
None,
335+
)
336+
.unwrap();
337+
setsockopt(&fd6, sockopt::Ipv6MulticastHops, &7)
338+
.expect("setting ipv6multicasthops on an inet6 socket should succeed");
339+
}
340+
328341
#[test]
329342
#[cfg(apple_targets)]
330343
fn test_dontfrag_opts() {

0 commit comments

Comments
 (0)