1 /*
2  * Copyright (c) 2019-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 #ifndef __mDNSFeatures_h
18 #define __mDNSFeatures_h
19 
20 #include "general.h"
21 
22 #define HAS_FEATURE_CAT(A, B)       A ## B
23 #define HAS_FEATURE_CHECK_0         1
24 #define HAS_FEATURE_CHECK_1         1
25 #define HAS_FEATURE(X)              ((X) / HAS_FEATURE_CAT(HAS_FEATURE_CHECK_, X))
26 
27 #define MDNSRESPONDER_SUPPORTS(PLATFORM, FEATURE) \
28     (MDNSRESPONDER_PLATFORM_ ## PLATFORM && \
29     HAS_FEATURE(MDNSRESPONDER_SUPPORTS_ ## PLATFORM ## _ ## FEATURE))
30 
31 #ifndef MDNSRESPONDER_PLATFORM_APPLE
32 #define MDNSRESPONDER_PLATFORM_APPLE        0
33 #endif
34 
35 #if MDNSRESPONDER_PLATFORM_APPLE
36 #include "ApplePlatformFeatures.h"
37 #endif
38 
39 // Common Features
40 
41 #undef MDNSRESPONDER_PLATFORM_COMMON
42 #define MDNSRESPONDER_PLATFORM_COMMON       1
43 
44 // Feature: DNS Push
45 // Radar:   <rdar://119684505>
46 // Enabled: No.
47 
48 #if !defined(MDNSRESPONDER_SUPPORTS_COMMON_DNS_PUSH)
49     #define MDNSRESPONDER_SUPPORTS_COMMON_DNS_PUSH 0
50 #endif
51 
52 // Feature: DNS LLQ
53 // Radar:   <rdar://problem/83483790>
54 // Enabled: No.
55 
56 #if !defined(MDNSRESPONDER_SUPPORTS_COMMON_DNS_LLQ)
57     #if MDNSRESPONDER_PLATFORM_APPLE
58         #define MDNSRESPONDER_SUPPORTS_COMMON_DNS_LLQ 0
59     #else
60         #define MDNSRESPONDER_SUPPORTS_COMMON_DNS_LLQ 0
61     #endif
62 #endif
63 
64 // Feature: Use Multicast DNS to discover the local DNS server that is authoritative for a given domain.
65 // Radar:   <rdar://69957139>
66 // Enabled: No
67 
68 #if !defined(MDNSRESPONDER_SUPPORTS_COMMON_LOCAL_DNS_RESOLVER_DISCOVERY)
69     #if MDNSRESPONDER_PLATFORM_APPLE
70         #define MDNSRESPONDER_SUPPORTS_COMMON_LOCAL_DNS_RESOLVER_DISCOVERY 1
71     #else
72         #define MDNSRESPONDER_SUPPORTS_COMMON_LOCAL_DNS_RESOLVER_DISCOVERY 0
73     #endif
74 #endif
75 
76 // Feature: DNS-SD Sleep Proxy Service (SPS) client support
77 // Radar:   No known radar.
78 // Enabled: Compiled for all platforms, except iOS and watchOS (rdar://112912605), and macOS (rdar://118002582).
79 
80 #if !defined(MDNSRESPONDER_SUPPORTS_COMMON_SPS_CLIENT)
81     #if MDNS_OS(iOS) || MDNS_OS(watchOS) || MDNS_OS(macOS)
82         #define MDNSRESPONDER_SUPPORTS_COMMON_SPS_CLIENT 0
83     #else
84         #define MDNSRESPONDER_SUPPORTS_COMMON_SPS_CLIENT 1
85     #endif
86 #endif
87 
88 #if MDNSRESPONDER_SUPPORTS(COMMON, DNS_PUSH)
89     #if MDNSRESPONDER_SUPPORTS(APPLE, DNS_PUSH)
90         #error "MDNSRESPONDER_SUPPORTS(COMMON, DNS_PUSH) and MDNSRESPONDER_SUPPORTS(APPLE, DNS_PUSH) shouldn't be enabled at the same time."
91     #endif
92 #endif
93 
94 #endif  // __mDNSFeatures_h
95