From 38e3bdb6baf5fdd421bc8e0203b8e6d10138e277 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 9 Oct 2024 09:11:54 -0400 Subject: [PATCH] Remove separate member for accessing fabric index --- src/app/CommandHandlerImpl.cpp | 2 -- src/app/InteractionModelEngine.cpp | 2 +- src/app/data-model-provider/OperationTypes.h | 9 ++++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/CommandHandlerImpl.cpp b/src/app/CommandHandlerImpl.cpp index 8c875c8924ecd4..2d8e76441bb083 100644 --- a/src/app/CommandHandlerImpl.cpp +++ b/src/app/CommandHandlerImpl.cpp @@ -395,7 +395,6 @@ Status CommandHandlerImpl::ProcessCommandDataIB(CommandDataIB::Parser & aCommand request.path = concretePath; request.subjectDescriptor = GetSubjectDescriptor(); - request.accessingFabricIndex = GetAccessingFabricIndex(); request.invokeFlags.Set(DataModel::InvokeFlags::kTimed, IsTimedInvoke()); Status preCheckStatus = mpCallback->ValidateCommandCanBeDispatched(request); @@ -518,7 +517,6 @@ Status CommandHandlerImpl::ProcessGroupCommandDataIB(CommandDataIB::Parser & aCo request.path = concretePath; request.subjectDescriptor = GetSubjectDescriptor(); - request.accessingFabricIndex = GetAccessingFabricIndex(); request.invokeFlags.Set(DataModel::InvokeFlags::kTimed, IsTimedInvoke()); Status preCheckStatus = mpCallback->ValidateCommandCanBeDispatched(request); diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 770f5386eabe70..5f0e392c26177a 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -1763,7 +1763,7 @@ Protocols::InteractionModel::Status InteractionModelEngine::CheckCommandFlags(co // Fabric-scoped commands are not allowed before a specific accessing fabric is available. // This is mostly just during a PASE session before AddNOC. - if (aRequest.accessingFabricIndex == kUndefinedFabricIndex) + if (aRequest.GetAccessingFabricIndex() == kUndefinedFabricIndex) { return Status::UnsupportedAccess; } diff --git a/src/app/data-model-provider/OperationTypes.h b/src/app/data-model-provider/OperationTypes.h index b13ec8f224b4fe..bef7b6f3f3281c 100644 --- a/src/app/data-model-provider/OperationTypes.h +++ b/src/app/data-model-provider/OperationTypes.h @@ -56,6 +56,14 @@ struct OperationRequest /// /// NOTE: once kInternal flag is removed, this will become non-optional std::optional subjectDescriptor; + + /// Accessing fabric index is the subjectDescriptor fabric index (if any). + /// This is a readability convenience function. + /// + /// Returns kUndefinedFabricIndex if no subject descriptor is available + FabricIndex GetAccessingFabricIndex() const { + return subjectDescriptor.has_value() ? subjectDescriptor->fabricIndex : kUndefinedFabricIndex; + } }; enum class ReadFlags : uint32_t @@ -100,7 +108,6 @@ struct InvokeRequest : OperationRequest { ConcreteCommandPath path; BitFlags invokeFlags; - FabricIndex accessingFabricIndex = kUndefinedFabricIndex; }; } // namespace DataModel