From ff8d249376be43dd246b724661df2cfbaff181bc Mon Sep 17 00:00:00 2001 From: Skye Soss Date: Thu, 5 Feb 2026 15:46:45 -0600 Subject: [PATCH] Add interface argument to Ipv6MembershipRequest::new This commit adds an additional argument to the Ipv6MembershipRequest::new function that allows the user to specify the interface index for which the membership request is associated with. Closes #323 --- changelog/2736.changed.md | 1 + src/sys/socket/mod.rs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 changelog/2736.changed.md diff --git a/changelog/2736.changed.md b/changelog/2736.changed.md new file mode 100644 index 0000000000..e7423ae6fc --- /dev/null +++ b/changelog/2736.changed.md @@ -0,0 +1 @@ +Changed the Ipv6MembershipRequest::new function to accept an interface index. diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 4faa3010f7..b4bb70c6e5 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -633,10 +633,20 @@ pub struct Ipv6MembershipRequest(libc::ipv6_mreq); impl Ipv6MembershipRequest { /// Instantiate a new `Ipv6MembershipRequest` - pub const fn new(group: net::Ipv6Addr) -> Self { + /// If the interface argument is None, the interface index will be + /// specified as 0. + pub const fn new(group: net::Ipv6Addr, interface: Option) -> Self { Ipv6MembershipRequest(libc::ipv6_mreq { ipv6mr_multiaddr: ipv6addr_to_libc(&group), - ipv6mr_interface: 0, + ipv6mr_interface: + match interface { + None => 0, + Some(n) => { + #[cfg(target_os = "android")] + let n = n as libc::c_int; + n + } + } }) } }