blob: 2bca806587b5d1f929a55c0e9e3284dab8981225 [file] [log] [blame]
/*
*
* Copyright (c) 2021 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <lib/support/Fold.h>
#include <algorithm>
#include <initializer_list>
namespace chip {
namespace Dnssd {
/*
* Matter DNS host settings
*/
constexpr size_t kHostNameMaxLength = 16; // MAC or 802.15.4 Extended Address in hex
/*
* Matter DNS service subtypes
*/
constexpr size_t kSubTypeShortDiscriminatorMaxLength = 4; // _S<dd>
constexpr size_t kSubTypeLongDiscriminatorMaxLength = 6; // _L<dddd>
constexpr size_t kSubTypeVendorMaxLength = 7; // _V<ddddd>
constexpr size_t kSubTypeDeviceTypeMaxLength = 5; // _T<ddd>
constexpr size_t kSubTypeCommissioningModeMaxLength = 3; // _C<d>
constexpr size_t kSubTypeAdditionalCommissioningMaxLength = 3; // _A<d>
constexpr size_t kSubTypeCompressedFabricIdMaxLength = 18; // _I<16-hex-digits>
/*
* Matter operational node service settings
*/
namespace Operational {
#define SUBTYPES (std::initializer_list<size_t>{ kSubTypeCompressedFabricIdMaxLength })
constexpr size_t kInstanceNameMaxLength = 33; // <NodeId>-<FabricId> in hex (16 + 1 + 16)
constexpr size_t kSubTypeMaxNumber = SUBTYPES.size();
constexpr size_t kSubTypeMaxLength = std::max(SUBTYPES);
constexpr size_t kSubTypeTotalLength = chip::Sum(SUBTYPES);
#undef SUBTYPES
} // namespace Operational
/*
* Matter commissionable/commissioner node service constants.
*/
namespace Commissionable {
#define SUBTYPES \
(std::initializer_list<size_t>{ kSubTypeShortDiscriminatorMaxLength, kSubTypeLongDiscriminatorMaxLength, \
kSubTypeVendorMaxLength, kSubTypeDeviceTypeMaxLength, kSubTypeCommissioningModeMaxLength, \
kSubTypeAdditionalCommissioningMaxLength })
constexpr size_t kInstanceNameMaxLength = 16; // 64-bit random number in hex
constexpr size_t kSubTypeMaxNumber = SUBTYPES.size();
constexpr size_t kSubTypeMaxLength = std::max(SUBTYPES);
constexpr size_t kSubTypeTotalLength = chip::Sum(SUBTYPES);
#undef SUBTYPES
} // namespace Commissionable
/*
* 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);
} // namespace Common
} // namespace Dnssd
} // namespace chip