xref: /netbsd-src/external/apache2/mDNSResponder/dist/mDNSShared/dnssd_errstring.c (revision 32d1c65c71fbdb65a012e8392a62a757dd6853e9)
1 /*
2  * Copyright (c) 2021-2024 Apple Inc. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "dns_sd_private.h"
18 #include "mdns_strict.h"
19 
20 const char * DNSSD_API
21 DNSServiceErrorCodeToString(DNSServiceErrorType error_code)
22 {
23 #define CASE_TO_STR(s) case kDNSServiceErr_ ## s: return (#s);
24 	switch (error_code) {
25 		CASE_TO_STR(NoError)
26 		CASE_TO_STR(Unknown)
27 		CASE_TO_STR(NoSuchName)
28 		CASE_TO_STR(NoMemory)
29 		CASE_TO_STR(BadParam)
30 		CASE_TO_STR(BadReference)
31 		CASE_TO_STR(BadState)
32 		CASE_TO_STR(BadFlags)
33 		CASE_TO_STR(Unsupported)
34 		CASE_TO_STR(NotInitialized)
35 		CASE_TO_STR(AlreadyRegistered)
36 		CASE_TO_STR(NameConflict)
37 		CASE_TO_STR(Invalid)
38 		CASE_TO_STR(Firewall)
39 		CASE_TO_STR(Incompatible)
40 		CASE_TO_STR(BadInterfaceIndex)
41 		CASE_TO_STR(Refused)
42 		CASE_TO_STR(NoSuchRecord)
43 		CASE_TO_STR(NoAuth)
44 		CASE_TO_STR(NoSuchKey)
45 		CASE_TO_STR(NATTraversal)
46 		CASE_TO_STR(DoubleNAT)
47 		CASE_TO_STR(BadTime)
48 		CASE_TO_STR(BadSig)
49 		CASE_TO_STR(BadKey)
50 		CASE_TO_STR(Transient)
51 		CASE_TO_STR(ServiceNotRunning)
52 		CASE_TO_STR(NATPortMappingUnsupported)
53 		CASE_TO_STR(NATPortMappingDisabled)
54 		CASE_TO_STR(NoRouter)
55 		CASE_TO_STR(PollingMode)
56 		CASE_TO_STR(Timeout)
57 		CASE_TO_STR(DefunctConnection)
58 		CASE_TO_STR(PolicyDenied)
59 		CASE_TO_STR(NotPermitted)
60 		default:
61 			return "<INVALID ERROR CODE>";
62 	}
63 #undef CASE_TO_STR
64 }
65 
66