Skip to content

Commit ff8d249

Browse files
committed
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
1 parent 6619d8d commit ff8d249

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

changelog/2736.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Changed the Ipv6MembershipRequest::new function to accept an interface index.

src/sys/socket/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,20 @@ pub struct Ipv6MembershipRequest(libc::ipv6_mreq);
633633

634634
impl Ipv6MembershipRequest {
635635
/// Instantiate a new `Ipv6MembershipRequest`
636-
pub const fn new(group: net::Ipv6Addr) -> Self {
636+
/// If the interface argument is None, the interface index will be
637+
/// specified as 0.
638+
pub const fn new(group: net::Ipv6Addr, interface: Option<libc::c_uint>) -> Self {
637639
Ipv6MembershipRequest(libc::ipv6_mreq {
638640
ipv6mr_multiaddr: ipv6addr_to_libc(&group),
639-
ipv6mr_interface: 0,
641+
ipv6mr_interface:
642+
match interface {
643+
None => 0,
644+
Some(n) => {
645+
#[cfg(target_os = "android")]
646+
let n = n as libc::c_int;
647+
n
648+
}
649+
}
640650
})
641651
}
642652
}

0 commit comments

Comments
 (0)