From 2ea2dd19e2c6e17acbaf03128c648eb80af46045 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Thu, 16 Oct 2025 15:48:57 +0800 Subject: [PATCH] mctp-estack: Add clear_eid() A counterpart of set_eid(). set_eid() doesn't allow setting a NULL EID. Signed-off-by: Matt Johnston --- mctp-estack/src/lib.rs | 7 ++++++- mctp-estack/src/router.rs | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mctp-estack/src/lib.rs b/mctp-estack/src/lib.rs index dc787cf..2d07ee2 100644 --- a/mctp-estack/src/lib.rs +++ b/mctp-estack/src/lib.rs @@ -49,7 +49,7 @@ pub use heapless::Vec; use heapless::{Entry, FnvIndexMap}; -use mctp::{Eid, Error, MsgIC, MsgType, Result, Tag, TagValue}; +use mctp::{Eid, Error, MsgIC, MsgType, Result, Tag, TagValue, MCTP_ADDR_NULL}; #[cfg(not(any(feature = "log", feature = "defmt")))] compile_error!("Either log or defmt feature must be enabled"); @@ -490,6 +490,11 @@ impl Stack { Ok(()) } + /// Clears the local Endpoint ID. + pub fn clear_eid(&mut self) { + self.own_eid = MCTP_ADDR_NULL; + } + /// Retrieves the local Endpoint ID. pub fn eid(&self) -> Eid { self.own_eid diff --git a/mctp-estack/src/router.rs b/mctp-estack/src/router.rs index 23644f8..d664bd3 100644 --- a/mctp-estack/src/router.rs +++ b/mctp-estack/src/router.rs @@ -812,6 +812,12 @@ impl<'r> Router<'r> { let mut inner = self.inner.lock().await; inner.stack.set_eid(eid.0) } + + /// Clears the EID assigned to the local stack + pub async fn clear_eid(&self) { + let mut inner = self.inner.lock().await; + inner.stack.clear_eid(); + } } impl core::fmt::Debug for Router<'_> {