From f878f1893cb8446049c841d44ac8bbb711b52801 Mon Sep 17 00:00:00 2001 From: Sigvart Hovland Date: Tue, 18 Aug 2026 15:05:23 +0200 Subject: [PATCH] feat: gate MLD behind multicast feature For embedded devices it's important to have things configurable and tunable to ensure that you don't use flash space for features you don't use. --- src/iface/interface/ipv6.rs | 1 + src/wire/icmpv6.rs | 4 ++++ src/wire/mld.rs | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/iface/interface/ipv6.rs b/src/iface/interface/ipv6.rs index 1bf6066b7..27795c36e 100644 --- a/src/iface/interface/ipv6.rs +++ b/src/iface/interface/ipv6.rs @@ -562,6 +562,7 @@ impl InterfaceInner { )) } + #[cfg(feature = "multicast")] pub(super) fn mldv2_report_packet<'any>( &self, records: &'any [MldAddressRecordRepr<'any>], diff --git a/src/wire/icmpv6.rs b/src/wire/icmpv6.rs index 3f6c6d58a..d47383ee1 100644 --- a/src/wire/icmpv6.rs +++ b/src/wire/icmpv6.rs @@ -605,6 +605,7 @@ pub enum Repr<'a> { }, #[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))] Ndisc(NdiscRepr<'a>), + #[cfg(feature = "multicast")] Mld(MldRepr<'a>), #[cfg(feature = "proto-rpl")] Rpl(RplRepr<'a>), @@ -698,6 +699,7 @@ impl<'a> Repr<'a> { }), #[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))] (msg_type, 0) if msg_type.is_ndisc() => NdiscRepr::parse(packet).map(Repr::Ndisc), + #[cfg(feature = "multicast")] (msg_type, 0) if msg_type.is_mld() => MldRepr::parse(packet).map(Repr::Mld), #[cfg(feature = "proto-rpl")] (Message::RplControl, _) => RplRepr::parse(packet).map(Repr::Rpl), @@ -720,6 +722,7 @@ impl<'a> Repr<'a> { } #[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))] &Repr::Ndisc(ndisc) => ndisc.buffer_len(), + #[cfg(feature = "multicast")] &Repr::Mld(mld) => mld.buffer_len(), #[cfg(feature = "proto-rpl")] Repr::Rpl(rpl) => rpl.buffer_len(), @@ -827,6 +830,7 @@ impl<'a> Repr<'a> { #[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))] Repr::Ndisc(ndisc) => ndisc.emit(packet), + #[cfg(feature = "multicast")] Repr::Mld(mld) => mld.emit(packet), #[cfg(feature = "proto-rpl")] diff --git a/src/wire/mld.rs b/src/wire/mld.rs index 968120897..d1d66652d 100644 --- a/src/wire/mld.rs +++ b/src/wire/mld.rs @@ -455,7 +455,7 @@ impl<'a> Repr<'a> { } } -#[cfg(test)] +#[cfg(all(test, feature = "multicast"))] mod test { use super::*; use crate::phy::ChecksumCapabilities;