Skip to content

Commit

Permalink
Put back AccessingFabricIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
andreilitvin committed Apr 18, 2024
1 parent d24fe15 commit e1d22c6
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
9 changes: 4 additions & 5 deletions src/app/AttributeValueDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ class AttributeValueDecoder
mTriedDecode = true;
// The WriteRequest comes with no fabric index, this will happen when receiving a write request on a PASE session before
// AddNOC.
VerifyOrReturnError(GetSubjectDescriptor().fabricIndex != kUndefinedFabricIndex, CHIP_IM_GLOBAL_STATUS(UnsupportedAccess));
VerifyOrReturnError(AccessingFabricIndex() != kUndefinedFabricIndex, CHIP_IM_GLOBAL_STATUS(UnsupportedAccess));
ReturnErrorOnFailure(DataModel::Decode(mReader, aArg));
aArg.SetFabricIndex(GetSubjectDescriptor().fabricIndex);
aArg.SetFabricIndex(AccessingFabricIndex());
return CHIP_NO_ERROR;
}

bool TriedDecode() const { return mTriedDecode; }

/**
* The accessing subject descriptor for this write interaction.
*/
const Access::SubjectDescriptor & GetSubjectDescriptor() const { return mSubjectDescriptor; }

FabricIndex AccessingFabricIndex() const { return GetSubjectDescriptor().fabricIndex; }

private:
TLV::TLVReader & mReader;
bool mTriedDecode = false;
Expand Down
7 changes: 4 additions & 3 deletions src/app/AttributeValueEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ class AttributeValueEncoder
// If we are encoding for a fabric filtered attribute read and the fabric index does not match that present in the
// request, skip encoding this list item.
VerifyOrReturnError(!mAttributeValueEncoder.mIsFabricFiltered ||
aArg.GetFabricIndex() == mAttributeValueEncoder.GetSubjectDescriptor().fabricIndex,
aArg.GetFabricIndex() == mAttributeValueEncoder.AccessingFabricIndex(),
CHIP_NO_ERROR);
return mAttributeValueEncoder.EncodeListItem(mAttributeValueEncoder.GetSubjectDescriptor().fabricIndex,
std::forward<T>(aArg));
return mAttributeValueEncoder.EncodeListItem(mAttributeValueEncoder.AccessingFabricIndex(), std::forward<T>(aArg));
}

template <typename T, std::enable_if_t<!DataModel::IsFabricScoped<T>::value, bool> = true>
Expand Down Expand Up @@ -150,6 +149,8 @@ class AttributeValueEncoder

const Access::SubjectDescriptor & GetSubjectDescriptor() const { return mSubjectDescriptor; }

FabricIndex AccessingFabricIndex() const { return GetSubjectDescriptor().fabricIndex; }

/**
* AttributeValueEncoder is a short lived object, and the state is persisted by mEncodeState and restored by constructor.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ CHIP_ERROR AccessControlAttribute::WriteImpl(const ConcreteDataAttributePath & a

CHIP_ERROR AccessControlAttribute::WriteAcl(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
{
FabricIndex accessingFabricIndex = aDecoder.GetSubjectDescriptor().fabricIndex;
FabricIndex accessingFabricIndex = aDecoder.AccessingFabricIndex();

size_t oldCount;
ReturnErrorOnFailure(GetAccessControl().GetEntryCount(accessingFabricIndex, oldCount));
Expand Down Expand Up @@ -293,7 +293,7 @@ CHIP_ERROR AccessControlAttribute::WriteExtension(const ConcreteDataAttributePat
{
auto & storage = Server::GetInstance().GetPersistentStorage();

FabricIndex accessingFabricIndex = aDecoder.GetSubjectDescriptor().fabricIndex;
FabricIndex accessingFabricIndex = aDecoder.AccessingFabricIndex();

uint8_t buffer[kExtensionDataMaxLength] = { 0 };
uint16_t size = static_cast<uint16_t>(sizeof(buffer));
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void BindingTableAccess::OnListWriteEnd(const app::ConcreteAttributePath & aPath

CHIP_ERROR BindingTableAccess::WriteBindingTable(const ConcreteDataAttributePath & path, AttributeValueDecoder & decoder)
{
mAccessingFabricIndex = decoder.GetSubjectDescriptor().fabricIndex;
mAccessingFabricIndex = decoder.AccessingFabricIndex();
if (!path.IsListOperation() || path.mListOp == ConcreteDataAttributePath::ListOperation::ReplaceAll)
{
DecodableBindingListType newBindingList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface

CHIP_ERROR WriteGroupKeyMap(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
{
auto fabric_index = aDecoder.GetSubjectDescriptor().fabricIndex;
auto fabric_index = aDecoder.AccessingFabricIndex();
auto provider = GetGroupDataProvider();

if (!aPath.IsListItemOperation())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class OperationalCredentialsAttrAccess : public AttributeAccessInterface

CHIP_ERROR OperationalCredentialsAttrAccess::ReadNOCs(EndpointId endpoint, AttributeValueEncoder & aEncoder)
{
auto accessingFabricIndex = aEncoder.GetSubjectDescriptor().fabricIndex;
auto accessingFabricIndex = aEncoder.AccessingFabricIndex();

return aEncoder.EncodeList([accessingFabricIndex](const auto & encoder) -> CHIP_ERROR {
const auto & fabricTable = Server::GetInstance().GetFabricTable();
Expand Down Expand Up @@ -252,7 +252,7 @@ CHIP_ERROR OperationalCredentialsAttrAccess::Read(const ConcreteReadAttributePat
return ReadRootCertificates(aPath.mEndpointId, aEncoder);
}
case Attributes::CurrentFabricIndex::Id: {
return aEncoder.Encode(aEncoder.GetSubjectDescriptor().fabricIndex);
return aEncoder.Encode(aEncoder.AccessingFabricIndex());
}
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/ota-requestor/ota-requestor-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ CHIP_ERROR OtaSoftwareUpdateRequestorAttrAccess::WriteDefaultOtaProviders(const
DataModel::DecodableList<OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> list;
ReturnErrorOnFailure(aDecoder.Decode(list));

ReturnErrorOnFailure(requestor->ClearDefaultOtaProviderList(aDecoder.GetSubjectDescriptor().fabricIndex));
ReturnErrorOnFailure(requestor->ClearDefaultOtaProviderList(aDecoder.AccessingFabricIndex()));

auto iter = list.begin();
while (iter.Next())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ CHIP_ERROR TestAttrAccess::WriteListFabricScopedAttribute(const ConcreteDataAttr
size_t srcIndex = 0, dstIndex = 0;
while (srcIndex < gListFabricScopedAttributeLen)
{
if (gListFabricScopedAttributeValue[srcIndex].fabricIndex != aDecoder.GetSubjectDescriptor().fabricIndex)
if (gListFabricScopedAttributeValue[srcIndex].fabricIndex != aDecoder.AccessingFabricIndex())
{
auto & dstEntry = gListFabricScopedAttributeValue[dstIndex];
auto & srcEntry = gListFabricScopedAttributeValue[srcIndex];
Expand Down
2 changes: 1 addition & 1 deletion src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ CHIP_ERROR GlobalAttributeReader::EncodeCommandList(const ConcreteClusterPath &
// Helper function for trying to read an attribute value via an
// AttributeAccessInterface. On failure, the read has failed. On success, the
// aTriedEncode outparam is set to whether the AttributeAccessInterface tried to encode a value.
CHIP_ERROR ReadViaAccessInterface(const SubjectDescriptor &subjectDescriptor, bool aIsFabricFiltered,
CHIP_ERROR ReadViaAccessInterface(const SubjectDescriptor & subjectDescriptor, bool aIsFabricFiltered,
const ConcreteReadAttributePath & aPath, AttributeReportIBs::Builder & aAttributeReports,
AttributeEncodeState * aEncoderState, AttributeAccessInterface * aAccessInterface,
bool * aTriedEncode)
Expand Down

0 comments on commit e1d22c6

Please sign in to comment.