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

Update some names in Dnssd to be more consistent across the board #13083

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
7 changes: 4 additions & 3 deletions examples/chip-tool/commands/pairing/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ class PairOnNetworkShort : public PairingCommand
public:
PairOnNetworkShort() :
PairingCommand("onnetwork-short", PairingMode::OnNetwork, PairingNetworkType::None,
chip::Dnssd::DiscoveryFilterType::kShort)
chip::Dnssd::DiscoveryFilterType::kShortDiscriminator)
{}
};

class PairOnNetworkLong : public PairingCommand
{
public:
PairOnNetworkLong() :
PairingCommand("onnetwork-long", PairingMode::OnNetwork, PairingNetworkType::None, chip::Dnssd::DiscoveryFilterType::kLong)
PairingCommand("onnetwork-long", PairingMode::OnNetwork, PairingNetworkType::None,
chip::Dnssd::DiscoveryFilterType::kLongDiscriminator)
{}
};

Expand All @@ -71,7 +72,7 @@ class PairOnNetworkVendor : public PairingCommand
public:
PairOnNetworkVendor() :
PairingCommand("onnetwork-vendor", PairingMode::OnNetwork, PairingNetworkType::None,
chip::Dnssd::DiscoveryFilterType::kVendor)
chip::Dnssd::DiscoveryFilterType::kVendorId)
{}
};

Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ CHIP_ERROR PairingCommand::PairWithMdns(NodeId remoteId)
{
case chip::Dnssd::DiscoveryFilterType::kNone:
break;
case chip::Dnssd::DiscoveryFilterType::kShort:
case chip::Dnssd::DiscoveryFilterType::kLong:
case chip::Dnssd::DiscoveryFilterType::kShortDiscriminator:
case chip::Dnssd::DiscoveryFilterType::kLongDiscriminator:
case chip::Dnssd::DiscoveryFilterType::kCompressedFabricId:
case chip::Dnssd::DiscoveryFilterType::kVendor:
case chip::Dnssd::DiscoveryFilterType::kVendorId:
case chip::Dnssd::DiscoveryFilterType::kDeviceType:
filter.code = mDiscoveryFilterCode;
break;
Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ class PairingCommand : public CHIPCommand,
{
case chip::Dnssd::DiscoveryFilterType::kNone:
break;
case chip::Dnssd::DiscoveryFilterType::kShort:
case chip::Dnssd::DiscoveryFilterType::kShortDiscriminator:
AddArgument("discriminator", 0, 15, &mDiscoveryFilterCode);
break;
case chip::Dnssd::DiscoveryFilterType::kLong:
case chip::Dnssd::DiscoveryFilterType::kLongDiscriminator:
AddArgument("discriminator", 0, 4096, &mDiscoveryFilterCode);
break;
case chip::Dnssd::DiscoveryFilterType::kVendor:
case chip::Dnssd::DiscoveryFilterType::kVendorId:
AddArgument("vendor-id", 0, UINT16_MAX, &mDiscoveryFilterCode);
break;
case chip::Dnssd::DiscoveryFilterType::kCompressedFabricId:
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal-mdns/advertiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ int main(int argc, char ** args)
.SetCommissioningMode(gOptions.commissioningMode)
.SetDeviceType(gOptions.deviceType)
.SetDeviceName(gOptions.deviceName)
.SetRotatingId(gOptions.rotatingId)
.SetPairingInstr(gOptions.pairingInstr)
.SetRotatingDeviceId(gOptions.rotatingId)
.SetPairingInstruction(gOptions.pairingInstr)
.SetPairingHint(gOptions.pairingHint));
}
else if (gOptions.advertisingMode == AdvertisingMode::kOperational)
Expand Down
4 changes: 2 additions & 2 deletions src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi
}
else
{
advertiseParameters.SetPairingInstr(chip::Optional<const char *>::Value(pairingInst));
advertiseParameters.SetPairingInstruction(chip::Optional<const char *>::Value(pairingInst));
}
}
else
Expand All @@ -380,7 +380,7 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi
}
else
{
advertiseParameters.SetPairingInstr(chip::Optional<const char *>::Value(pairingInst));
advertiseParameters.SetPairingInstruction(chip::Optional<const char *>::Value(pairingInst));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ CHIP_ERROR Server::SendUserDirectedCommissioningRequest(chip::Transport::PeerAdd
ChipLogDetail(AppServer, "SendUserDirectedCommissioningRequest2");

CHIP_ERROR err;
char nameBuffer[chip::Dnssd::Commissionable::kInstanceNameMaxLength + 1];
char nameBuffer[chip::Dnssd::Commission::kInstanceNameMaxLength + 1];
err = app::DnssdServer::Instance().GetCommissionableInstanceName(nameBuffer, sizeof(nameBuffer));
if (err != CHIP_NO_ERROR)
{
Expand Down
6 changes: 3 additions & 3 deletions src/controller/SetUpCodePairer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ CHIP_ERROR SetUpCodePairer::StopConnectOverBle()
CHIP_ERROR SetUpCodePairer::StartDiscoverOverIP(uint16_t discriminator, bool isShort)
{
#if CHIP_DEVICE_CONFIG_ENABLE_DNSSD
currentFilter.type = isShort ? Dnssd::DiscoveryFilterType::kShort : Dnssd::DiscoveryFilterType::kLong;
currentFilter.type = isShort ? Dnssd::DiscoveryFilterType::kShortDiscriminator : Dnssd::DiscoveryFilterType::kLongDiscriminator;
currentFilter.code = discriminator;
return mCommissioner->DiscoverCommissionableNodes(currentFilter);
#else
Expand Down Expand Up @@ -166,9 +166,9 @@ bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData &
{
switch (currentFilter.type)
{
case Dnssd::DiscoveryFilterType::kShort:
case Dnssd::DiscoveryFilterType::kShortDiscriminator:
return ((nodeData.longDiscriminator >> 8) & 0x0F) == currentFilter.code;
case Dnssd::DiscoveryFilterType::kLong:
case Dnssd::DiscoveryFilterType::kLongDiscriminator:
return nodeData.longDiscriminator == currentFilter.code;
default:
return false;
Expand Down
6 changes: 3 additions & 3 deletions src/controller/python/ChipDeviceController-ScriptBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,22 +410,22 @@ ChipError::StorageType
pychip_DeviceController_DiscoverCommissionableNodesLongDiscriminator(chip::Controller::DeviceCommissioner * devCtrl,
uint16_t long_discriminator)
{
Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kLong, long_discriminator);
Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kLongDiscriminator, long_discriminator);
return devCtrl->DiscoverCommissionableNodes(filter).AsInteger();
}

ChipError::StorageType
pychip_DeviceController_DiscoverCommissionableNodesShortDiscriminator(chip::Controller::DeviceCommissioner * devCtrl,
uint16_t short_discriminator)
{
Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kShort, short_discriminator);
Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kShortDiscriminator, short_discriminator);
return devCtrl->DiscoverCommissionableNodes(filter).AsInteger();
}

ChipError::StorageType pychip_DeviceController_DiscoverCommissionableNodesVendor(chip::Controller::DeviceCommissioner * devCtrl,
uint16_t vendor)
{
Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kVendor, vendor);
Dnssd::DiscoveryFilter filter(Dnssd::DiscoveryFilterType::kVendorId, vendor);
return devCtrl->DiscoverCommissionableNodes(filter).AsInteger();
}

Expand Down
12 changes: 7 additions & 5 deletions src/lib/dnssd/Advertiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class OperationalAdvertisingParameters : public BaseAdvertisingParams<Operationa
}
PeerId GetPeerId() const { return mPeerId; }

CompressedFabricId GetCompressedFabricId() const { return mPeerId.GetCompressedFabricId(); }

private:
PeerId mPeerId;
};
Expand Down Expand Up @@ -194,7 +196,7 @@ class CommissionAdvertisingParameters : public BaseAdvertisingParams<CommissionA
return mDeviceNameHasValue ? Optional<const char *>::Value(mDeviceName) : Optional<const char *>::Missing();
}

CommissionAdvertisingParameters & SetRotatingId(Optional<const char *> rotatingId)
CommissionAdvertisingParameters & SetRotatingDeviceId(Optional<const char *> rotatingId)
{
if (rotatingId.HasValue())
{
Expand All @@ -207,12 +209,12 @@ class CommissionAdvertisingParameters : public BaseAdvertisingParams<CommissionA
}
return *this;
}
Optional<const char *> GetRotatingId() const
Optional<const char *> GetRotatingDeviceId() const
{
return mRotatingIdHasValue ? Optional<const char *>::Value(mRotatingId) : Optional<const char *>::Missing();
}

CommissionAdvertisingParameters & SetPairingInstr(Optional<const char *> pairingInstr)
CommissionAdvertisingParameters & SetPairingInstruction(Optional<const char *> pairingInstr)
{
if (pairingInstr.HasValue())
{
Expand All @@ -225,7 +227,7 @@ class CommissionAdvertisingParameters : public BaseAdvertisingParams<CommissionA
}
return *this;
}
Optional<const char *> GetPairingInstr() const
Optional<const char *> GetPairingInstruction() const
{
return mPairingInstrHasValue ? Optional<const char *>::Value(mPairingInstr) : Optional<const char *>::Missing();
}
Expand Down Expand Up @@ -257,7 +259,7 @@ class CommissionAdvertisingParameters : public BaseAdvertisingParams<CommissionA
char mDeviceName[kKeyDeviceNameMaxLength + 1];
bool mDeviceNameHasValue = false;

char mRotatingId[kKeyRotatingIdMaxLength + 1];
char mRotatingId[kKeyRotatingDeviceIdMaxLength + 1];
bool mRotatingIdHasValue = false;

char mPairingInstr[kKeyPairingInstructionMaxLength + 1];
Expand Down
22 changes: 11 additions & 11 deletions src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class AdvertiserMinMdns : public ServiceAdvertiser,
char mrpRetryIntervalIdleBuf[KeySize(TxtFieldKey::kMrpRetryIntervalIdle) + ValSize(TxtFieldKey::kMrpRetryIntervalIdle) + 2];
char mrpRetryIntervalActiveBuf[KeySize(TxtFieldKey::kMrpRetryIntervalActive) +
ValSize(TxtFieldKey::kMrpRetryIntervalActive) + 2];
char tcpSupportedBuf[KeySize(TxtFieldKey::kTcpSupport) + ValSize(TxtFieldKey::kTcpSupport) + 2];
char tcpSupportedBuf[KeySize(TxtFieldKey::kTcpSupported) + ValSize(TxtFieldKey::kTcpSupported) + 2];
};
template <class Derived>
CHIP_ERROR AddCommonTxtEntries(const BaseAdvertisingParams<Derived> & params, CommonTxtEntryStorage & storage,
Expand Down Expand Up @@ -437,7 +437,7 @@ CHIP_ERROR AdvertiserMinMdns::Advertise(const OperationalAdvertisingParameters &

CHIP_ERROR AdvertiserMinMdns::GetCommissionableInstanceName(char * instanceName, size_t maxLength)
{
if (maxLength < (Commissionable::kInstanceNameMaxLength + 1))
if (maxLength < (Commission::kInstanceNameMaxLength + 1))
{
return CHIP_ERROR_NO_MEMORY;
}
Expand Down Expand Up @@ -514,7 +514,7 @@ CHIP_ERROR AdvertiserMinMdns::Advertise(const CommissionAdvertisingParameters &
if (params.GetVendorId().HasValue())
{
MakeServiceSubtype(nameBuffer, sizeof(nameBuffer),
DiscoveryFilter(DiscoveryFilterType::kVendor, params.GetVendorId().Value()));
DiscoveryFilter(DiscoveryFilterType::kVendorId, params.GetVendorId().Value()));
FullQName vendorServiceName =
allocator->AllocateQName(nameBuffer, kSubtypeServiceNamePart, serviceType, kCommissionProtocol, kLocalDomain);
ReturnErrorCodeIf(vendorServiceName.nameCount == 0, CHIP_ERROR_NO_MEMORY);
Expand Down Expand Up @@ -552,7 +552,7 @@ CHIP_ERROR AdvertiserMinMdns::Advertise(const CommissionAdvertisingParameters &
{
{
MakeServiceSubtype(nameBuffer, sizeof(nameBuffer),
DiscoveryFilter(DiscoveryFilterType::kShort, params.GetShortDiscriminator()));
DiscoveryFilter(DiscoveryFilterType::kShortDiscriminator, params.GetShortDiscriminator()));
FullQName shortServiceName =
allocator->AllocateQName(nameBuffer, kSubtypeServiceNamePart, serviceType, kCommissionProtocol, kLocalDomain);
ReturnErrorCodeIf(shortServiceName.nameCount == 0, CHIP_ERROR_NO_MEMORY);
Expand All @@ -569,7 +569,7 @@ CHIP_ERROR AdvertiserMinMdns::Advertise(const CommissionAdvertisingParameters &

{
MakeServiceSubtype(nameBuffer, sizeof(nameBuffer),
DiscoveryFilter(DiscoveryFilterType::kLong, params.GetLongDiscriminator()));
DiscoveryFilter(DiscoveryFilterType::kLongDiscriminator, params.GetLongDiscriminator()));
FullQName longServiceName =
allocator->AllocateQName(nameBuffer, kSubtypeServiceNamePart, serviceType, kCommissionProtocol, kLocalDomain);
ReturnErrorCodeIf(longServiceName.nameCount == 0, CHIP_ERROR_NO_MEMORY);
Expand Down Expand Up @@ -682,18 +682,18 @@ FullQName AdvertiserMinMdns::GetCommissioningTxtEntries(const CommissionAdvertis
if (params.GetCommissionAdvertiseMode() == CommssionAdvertiseMode::kCommissionableNode)
{
// a discriminator always exists
char txtDiscriminator[chip::Dnssd::kKeyDiscriminatorMaxLength + 3];
char txtDiscriminator[chip::Dnssd::kKeyLongDiscriminatorMaxLength + 3];
snprintf(txtDiscriminator, sizeof(txtDiscriminator), "D=%d", params.GetLongDiscriminator());
txtFields[numTxtFields++] = txtDiscriminator;

char txtCommissioningMode[chip::Dnssd::kKeyCommissioningModeMaxLength + 4];
snprintf(txtCommissioningMode, sizeof(txtCommissioningMode), "CM=%d", static_cast<int>(params.GetCommissioningMode()));
txtFields[numTxtFields++] = txtCommissioningMode;

char txtRotatingDeviceId[chip::Dnssd::kKeyRotatingIdMaxLength + 4];
if (params.GetRotatingId().HasValue())
char txtRotatingDeviceId[chip::Dnssd::kKeyRotatingDeviceIdMaxLength + 4];
if (params.GetRotatingDeviceId().HasValue())
{
snprintf(txtRotatingDeviceId, sizeof(txtRotatingDeviceId), "RI=%s", params.GetRotatingId().Value());
snprintf(txtRotatingDeviceId, sizeof(txtRotatingDeviceId), "RI=%s", params.GetRotatingDeviceId().Value());
txtFields[numTxtFields++] = txtRotatingDeviceId;
}

Expand All @@ -705,9 +705,9 @@ FullQName AdvertiserMinMdns::GetCommissioningTxtEntries(const CommissionAdvertis
}

char txtPairingInstr[chip::Dnssd::kKeyPairingInstructionMaxLength + 4];
if (params.GetPairingInstr().HasValue())
if (params.GetPairingInstruction().HasValue())
{
snprintf(txtPairingInstr, sizeof(txtPairingInstr), "PI=%s", params.GetPairingInstr().Value());
snprintf(txtPairingInstr, sizeof(txtPairingInstr), "PI=%s", params.GetPairingInstruction().Value());
txtFields[numTxtFields++] = txtPairingInstr;
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/lib/dnssd/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ constexpr size_t kHostNameMaxLength = 16; // MAC or 802.15.4 Extended Address in

constexpr size_t kSubTypeShortDiscriminatorMaxLength = 4; // _S<dd>
constexpr size_t kSubTypeLongDiscriminatorMaxLength = 6; // _L<dddd>
constexpr size_t kSubTypeVendorMaxLength = 7; // _V<ddddd>
constexpr size_t kSubTypeVendorIdMaxLength = 7; // _V<ddddd>
constexpr size_t kSubTypeDeviceTypeMaxLength = 5; // _T<ddd>
constexpr size_t kSubTypeCommissioningModeMaxLength = 3; // _C<d>
constexpr size_t kSubTypeAdditionalCommissioningMaxLength = 3; // _A<d>
Expand All @@ -64,11 +64,11 @@ constexpr size_t kSubTypeTotalLength = chip::Sum(SUBTYPES);
* Matter commissionable/commissioner node service constants.
*/

namespace Commissionable {
namespace Commission {
andy31415 marked this conversation as resolved.
Show resolved Hide resolved

#define SUBTYPES \
(std::initializer_list<size_t>{ kSubTypeShortDiscriminatorMaxLength, kSubTypeLongDiscriminatorMaxLength, \
kSubTypeVendorMaxLength, kSubTypeDeviceTypeMaxLength, kSubTypeCommissioningModeMaxLength, \
kSubTypeVendorIdMaxLength, kSubTypeDeviceTypeMaxLength, kSubTypeCommissioningModeMaxLength, \
kSubTypeAdditionalCommissioningMaxLength })

constexpr size_t kInstanceNameMaxLength = 16; // 64-bit random number in hex
Expand All @@ -78,18 +78,18 @@ constexpr size_t kSubTypeTotalLength = chip::Sum(SUBTYPES);

#undef SUBTYPES

} // namespace Commissionable
} // namespace Commission

/*
* Constants for any Matter service.
*/

namespace Common {

constexpr size_t kInstanceNameMaxLength = std::max(Operational::kInstanceNameMaxLength, Commissionable::kInstanceNameMaxLength);
constexpr size_t kSubTypeMaxNumber = std::max(Operational::kSubTypeMaxNumber, Commissionable::kSubTypeMaxNumber);
constexpr size_t kSubTypeMaxLength = std::max(Operational::kSubTypeMaxLength, Commissionable::kSubTypeMaxLength);
constexpr size_t kSubTypeTotalLength = std::max(Operational::kSubTypeTotalLength, Commissionable::kSubTypeTotalLength);
constexpr size_t kInstanceNameMaxLength = std::max(Operational::kInstanceNameMaxLength, Commission::kInstanceNameMaxLength);
constexpr size_t kSubTypeMaxNumber = std::max(Operational::kSubTypeMaxNumber, Commission::kSubTypeMaxNumber);
constexpr size_t kSubTypeMaxLength = std::max(Operational::kSubTypeMaxLength, Commission::kSubTypeMaxLength);
constexpr size_t kSubTypeTotalLength = std::max(Operational::kSubTypeTotalLength, Commission::kSubTypeTotalLength);

} // namespace Common

Expand Down
Loading