Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how group multicast addresses are constructed. #19023

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
#endif
);

err = mListener.Init(&mTransports);
err = mListener.Init(this);
SuccessOrExit(err);
mGroupsProvider->SetListener(&mListener);

Expand Down Expand Up @@ -309,7 +309,7 @@ void Server::RejoinExistingMulticastGroups()
while (iterator->Next(groupInfo))
{
err = mTransports.MulticastGroupJoinLeave(
Transport::PeerAddress::Multicast(fabric.GetFabricIndex(), groupInfo.group_id), true);
Transport::PeerAddress::Multicast(fabric.GetFabricId(), groupInfo.group_id), true);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Error when trying to join Group %u of fabric index %u : %" CHIP_ERROR_FORMAT,
Expand Down
29 changes: 22 additions & 7 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,30 +270,45 @@ class Server
public:
GroupDataProviderListener() {}

CHIP_ERROR Init(ServerTransportMgr * transports)
CHIP_ERROR Init(Server * server)
{
VerifyOrReturnError(transports != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(server != nullptr, CHIP_ERROR_INVALID_ARGUMENT);

mTransports = transports;
mServer = server;
return CHIP_NO_ERROR;
};

void OnGroupAdded(chip::FabricIndex fabric_index, const Credentials::GroupDataProvider::GroupInfo & new_group) override
{
if (mTransports->MulticastGroupJoinLeave(Transport::PeerAddress::Multicast(fabric_index, new_group.group_id), true) !=
CHIP_NO_ERROR)
FabricInfo * fabric = mServer->GetFabricTable().FindFabricWithIndex(fabric_index);
if (fabric == nullptr)
{
ChipLogError(AppServer, "Group added to nonexistent fabric?");
return;
}

if (mServer->GetTransportManager().MulticastGroupJoinLeave(
Transport::PeerAddress::Multicast(fabric->GetFabricId(), new_group.group_id), true) != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Unable to listen to group");
}
};

void OnGroupRemoved(chip::FabricIndex fabric_index, const Credentials::GroupDataProvider::GroupInfo & old_group) override
{
mTransports->MulticastGroupJoinLeave(Transport::PeerAddress::Multicast(fabric_index, old_group.group_id), false);
FabricInfo * fabric = mServer->GetFabricTable().FindFabricWithIndex(fabric_index);
if (fabric == nullptr)
{
ChipLogError(AppServer, "Group added to nonexistent fabric?");
return;
}

mServer->GetTransportManager().MulticastGroupJoinLeave(
Transport::PeerAddress::Multicast(fabric->GetFabricId(), old_group.group_id), false);
};

private:
ServerTransportMgr * mTransports;
Server * mServer;
};

class ServerFabricDelegate final : public chip::FabricTable::Delegate
Expand Down
Loading