diff --git a/src/darwin/Framework/CHIP/MTRError.h b/src/darwin/Framework/CHIP/MTRError.h index 6c5e7fa82e4a82..9b27c835bb674b 100644 --- a/src/darwin/Framework/CHIP/MTRError.h +++ b/src/darwin/Framework/CHIP/MTRError.h @@ -78,6 +78,15 @@ typedef NS_ERROR_ENUM(MTRErrorDomain, MTRErrorCode){ * TLV-level failures. */ MTRErrorCodeTLVDecodeFailed MTR_AVAILABLE(ios(17.0), macos(14.0), watchos(10.0), tvos(17.0)) = 14, + + /** + * MTRErrorCodeDNSSDUnauthorized means that the application is not + * authorized to perform DNS_SD lookups. This typically means missing + * entries for "_matter._tcp" (for operational lookup) and "_matterc._udp" + * (for commissionable lookup) under the NSBonjourServices key in the + * application's Info.plist. + */ + MTRErrorCodeDNSSDUnauthorized MTR_NEWLY_AVAILABLE = 15, }; // clang-format on diff --git a/src/darwin/Framework/CHIP/MTRError.mm b/src/darwin/Framework/CHIP/MTRError.mm index 94cc4cabfe4975..906f63a1538f5b 100644 --- a/src/darwin/Framework/CHIP/MTRError.mm +++ b/src/darwin/Framework/CHIP/MTRError.mm @@ -95,6 +95,9 @@ + (NSError *)errorForCHIPErrorCode:(CHIP_ERROR)errorCode } else if (errorCode == CHIP_ERROR_DECODE_FAILED) { code = MTRErrorCodeTLVDecodeFailed; [userInfo addEntriesFromDictionary:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"TLV decoding failed.", nil) }]; + } else if (errorCode == CHIP_ERROR_DNS_SD_UNAUTHORIZED) { + code = MTRErrorCodeDNSSDUnauthorized; + [userInfo addEntriesFromDictionary:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Access denied to perform DNS-SD lookups. Check that \"_matter._tcp\" and/or \"_matterc._udp\" are listed under the NSBonjourServices key in Info.plist", nil) }]; } else { code = MTRErrorCodeGeneralError; [userInfo addEntriesFromDictionary:@{ @@ -282,6 +285,15 @@ + (CHIP_ERROR)errorToCHIPErrorCode:(NSError * _Nullable)error case MTRErrorCodeBufferTooSmall: code = CHIP_ERROR_BUFFER_TOO_SMALL.AsInteger(); break; + case MTRErrorCodeFabricExists: + code = CHIP_ERROR_FABRIC_EXISTS.AsInteger(); + break; + case MTRErrorCodeTLVDecodeFailed: + code = CHIP_ERROR_DECODE_FAILED.AsInteger(); + break; + case MTRErrorCodeDNSSDUnauthorized: + code = CHIP_ERROR_DNS_SD_UNAUTHORIZED.AsInteger(); + break; case MTRErrorCodeGeneralError: { if (error.userInfo != nil && error.userInfo[@"errorCode"] != nil) { code = static_cast([error.userInfo[@"errorCode"] unsignedLongValue]); diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index d4471f1b996f76..1b621a694fbc8c 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -1449,7 +1449,15 @@ using CHIP_ERROR = ::chip::ChipError; // AVAILABLE: 0xb1 // AVAILABLE: 0xb2 -// AVAILABLE: 0xb3 + +/** + * @def CHIP_ERROR_DNS_SD_UNAUTHORIZED + * + * @brief + * The application is not authorized to do DNS_SD lookups. + * + */ +#define CHIP_ERROR_DNS_SD_UNAUTHORIZED CHIP_CORE_ERROR(0xb3) /** * @def CHIP_ERROR_MDNS_COLLISION diff --git a/src/platform/Darwin/MdnsError.cpp b/src/platform/Darwin/MdnsError.cpp index 0664887ea9bbe0..1a61bbde59691a 100644 --- a/src/platform/Darwin/MdnsError.cpp +++ b/src/platform/Darwin/MdnsError.cpp @@ -104,6 +104,8 @@ CHIP_ERROR ToChipError(DNSServiceErrorType errorCode) return CHIP_ERROR_MDNS_COLLISION; case kDNSServiceErr_NoMemory: return CHIP_ERROR_NO_MEMORY; + case kDNSServiceErr_NoAuth: + return CHIP_ERROR_DNS_SD_UNAUTHORIZED; default: return CHIP_ERROR_INTERNAL; }