diff --git a/src/unix.rs b/src/unix.rs index f0a4321..709bb80 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -136,8 +136,14 @@ impl PktInfoUdpSocket { let mut addr_src: MaybeUninit = MaybeUninit::uninit(); let mut msg_iov = IoSliceMut::new(buf); let mut cmsg = { - let space = unsafe { - libc::CMSG_SPACE(mem::size_of::() as libc::c_uint) as usize + let space = if self.domain == Domain::IPV4 { + unsafe { + libc::CMSG_SPACE(mem::size_of::() as libc::c_uint) as usize + } + } else { + unsafe { + libc::CMSG_SPACE(mem::size_of::() as libc::c_uint) as usize + } }; Vec::::with_capacity(space) }; diff --git a/tests/ipv6_test.rs b/tests/ipv6_test.rs index f16c396..ffd771b 100644 --- a/tests/ipv6_test.rs +++ b/tests/ipv6_test.rs @@ -70,6 +70,7 @@ fn ipv6_test() -> io::Result<()> { "Multicast packet received on interface index {} from src {} with destination ip {}", info.if_index, info.addr_src, info.addr_dst, ); + assert!(info.if_index != 0); Ok(()) }