]>
Commit | Line | Data |
---|---|---|
67c8f8a1 A |
1 | /* -*- Mode: C; tab-width: 4 -*- |
2 | * | |
8e92c31c A |
3 | * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved. |
4 | * | |
67c8f8a1 A |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8e92c31c | 8 | * |
67c8f8a1 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
8e92c31c | 10 | * |
67c8f8a1 A |
11 | * Unless required by applicable law or agreed to in writing, software |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
8e92c31c | 15 | * limitations under the License. |
8e92c31c A |
16 | |
17 | Change History (most recent first): | |
18 | ||
19 | $Log: uDNS.h,v $ | |
32bb7e43 A |
20 | Revision 1.93 2008/09/24 23:48:05 cheshire |
21 | Don't need to pass whole ServiceRecordSet reference to GetServiceTarget; | |
22 | it only needs to access the embedded SRV member of the set | |
23 | ||
9f29194f A |
24 | Revision 1.92 2008/06/19 23:42:03 mcguire |
25 | <rdar://problem/4206534> Use all configured DNS servers | |
26 | ||
27 | Revision 1.91 2008/06/19 01:20:50 mcguire | |
28 | <rdar://problem/4206534> Use all configured DNS servers | |
29 | ||
030b743d A |
30 | Revision 1.90 2007/12/22 02:25:30 cheshire |
31 | <rdar://problem/5661128> Records and Services sometimes not re-registering on wake from sleep | |
32 | ||
33 | Revision 1.89 2007/12/15 01:12:27 cheshire | |
34 | <rdar://problem/5526796> Need to remove active LLQs from server upon question cancellation, on sleep, and on shutdown | |
35 | ||
96f69b28 A |
36 | Revision 1.88 2007/10/25 20:06:13 cheshire |
37 | Don't try to do SOA queries using private DNS (TLS over TCP) queries | |
38 | ||
39 | Revision 1.87 2007/10/24 22:40:06 cheshire | |
40 | Renamed: RecordRegistrationCallback -> RecordRegistrationGotZoneData | |
41 | Renamed: ServiceRegistrationZoneDataComplete -> ServiceRegistrationGotZoneData | |
42 | ||
43 | Revision 1.86 2007/10/18 23:06:42 cheshire | |
44 | <rdar://problem/5519458> BTMM: Machines don't appear in the sidebar on wake from sleep | |
45 | Additional fixes and refinements | |
46 | ||
47 | Revision 1.85 2007/10/18 20:23:17 cheshire | |
48 | Moved SuspendLLQs into mDNS.c, since it's only called from one place | |
49 | ||
50 | Revision 1.84 2007/10/17 22:49:54 cheshire | |
51 | <rdar://problem/5519458> BTMM: Machines don't appear in the sidebar on wake from sleep | |
52 | ||
53 | Revision 1.83 2007/10/17 22:37:23 cheshire | |
54 | <rdar://problem/5536979> BTMM: Need to create NAT port mapping for receiving LLQ events | |
55 | ||
56 | Revision 1.82 2007/10/17 21:53:51 cheshire | |
57 | Improved debugging messages; renamed startLLQHandshakeCallback to LLQGotZoneData | |
58 | ||
59 | Revision 1.81 2007/10/16 21:16:50 cheshire | |
60 | Get rid of unused uDNS_Sleep() routine | |
61 | ||
62 | Revision 1.80 2007/10/16 20:59:41 cheshire | |
63 | Export SuspendLLQs/SleepServiceRegistrations/SleepRecordRegistrations so they're callable from other files | |
64 | ||
67c8f8a1 A |
65 | Revision 1.79 2007/09/20 01:13:19 cheshire |
66 | Export CacheGroupForName so it's callable from other files | |
67 | ||
68 | Revision 1.78 2007/09/14 21:26:09 cheshire | |
69 | <rdar://problem/5482627> BTMM: Need to manually avoid port conflicts when using UPnP gateways | |
70 | ||
71 | Revision 1.77 2007/09/12 23:03:08 cheshire | |
72 | <rdar://problem/5476978> DNSServiceNATPortMappingCreate callback not giving correct interface index | |
73 | ||
74 | Revision 1.76 2007/09/12 19:22:19 cheshire | |
75 | Variable renaming in preparation for upcoming fixes e.g. priv/pub renamed to intport/extport | |
76 | Made NAT Traversal packet handlers take typed data instead of anonymous "mDNSu8 *" byte pointers | |
77 | ||
78 | Revision 1.75 2007/08/28 23:53:21 cheshire | |
79 | Rename serviceRegistrationCallback -> ServiceRegistrationZoneDataComplete | |
80 | ||
81 | Revision 1.74 2007/08/24 00:15:20 cheshire | |
82 | Renamed GetAuthInfoForName() to GetAuthInfoForName_internal() to make it clear that it may only be called with the lock held | |
83 | ||
84 | Revision 1.73 2007/08/01 03:09:22 cheshire | |
85 | <rdar://problem/5344587> BTMM: Create NAT port mapping for autotunnel port | |
86 | ||
87 | Revision 1.72 2007/08/01 00:04:13 cheshire | |
88 | <rdar://problem/5261696> Crash in tcpKQSocketCallback | |
89 | Half-open TCP connections were not being cancelled properly | |
90 | ||
91 | Revision 1.71 2007/07/30 23:31:26 cheshire | |
92 | Code for respecting TTL received in uDNS responses should exclude LLQ-type responses | |
93 | ||
94 | Revision 1.70 2007/07/27 20:52:29 cheshire | |
95 | Made uDNS_recvLLQResponse() return tri-state result: LLQ_Not, LLQ_First, or LLQ_Events | |
96 | ||
97 | Revision 1.69 2007/07/27 19:30:40 cheshire | |
98 | Changed mDNSQuestionCallback parameter from mDNSBool to QC_result, | |
99 | to properly reflect tri-state nature of the possible responses | |
100 | ||
101 | Revision 1.68 2007/07/27 18:38:56 cheshire | |
102 | Rename "uDNS_CheckQuery" to more informative "uDNS_CheckCurrentQuestion" | |
103 | ||
104 | Revision 1.67 2007/07/20 23:11:12 cheshire | |
105 | Fix code layout | |
05292456 | 106 | |
67c8f8a1 A |
107 | Revision 1.66 2007/07/16 23:54:48 cheshire |
108 | <rdar://problem/5338850> Crash when removing or changing DNS keys | |
f5e6e86c | 109 | |
67c8f8a1 A |
110 | Revision 1.65 2007/07/16 20:14:22 vazquez |
111 | <rdar://problem/3867231> LegacyNATTraversal: Need complete rewrite | |
7cb34e5c | 112 | |
67c8f8a1 A |
113 | Revision 1.64 2007/07/11 02:53:36 cheshire |
114 | <rdar://problem/5303807> Register IPv6-only hostname and don't create port mappings for AutoTunnel services | |
115 | Add ServiceRecordSet parameter in GetServiceTarget | |
283ee3ff | 116 | |
67c8f8a1 A |
117 | Revision 1.63 2007/06/29 00:09:24 vazquez |
118 | <rdar://problem/5301908> Clean up NAT state machine (necessary for 6 other fixes) | |
283ee3ff | 119 | |
67c8f8a1 A |
120 | Revision 1.62 2007/05/14 23:53:00 cheshire |
121 | Export mDNS_StartQuery_internal and mDNS_StopQuery_internal so they can be called from uDNS.c | |
7f0064bd | 122 | |
67c8f8a1 A |
123 | Revision 1.61 2007/05/07 20:43:45 cheshire |
124 | <rdar://problem/4241419> Reduce the number of queries and announcements | |
7f0064bd | 125 | |
67c8f8a1 A |
126 | Revision 1.60 2007/05/04 21:46:10 cheshire |
127 | Get rid of uDNS_Close (synonym for uDNS_Sleep) | |
7f0064bd | 128 | |
67c8f8a1 A |
129 | Revision 1.59 2007/05/03 22:40:38 cheshire |
130 | <rdar://problem/4669229> mDNSResponder ignores bogus null target in SRV record | |
7f0064bd | 131 | |
67c8f8a1 A |
132 | Revision 1.58 2007/05/02 22:21:33 cheshire |
133 | <rdar://problem/5167331> RegisterRecord and RegisterService need to cancel StartGetZoneData | |
7f0064bd | 134 | |
67c8f8a1 A |
135 | Revision 1.57 2007/04/27 19:28:02 cheshire |
136 | Any code that calls StartGetZoneData needs to keep a handle to the structure, so | |
137 | it can cancel it if necessary. (First noticed as a crash in Apple Remote Desktop | |
138 | -- it would start a query and then quickly cancel it, and then when | |
139 | StartGetZoneData completed, it had a dangling pointer and crashed.) | |
7f0064bd | 140 | |
67c8f8a1 A |
141 | Revision 1.56 2007/04/25 02:14:38 cheshire |
142 | <rdar://problem/4246187> uDNS: Identical client queries should reference a single shared core query | |
143 | Additional fixes to make LLQs work properly | |
7f0064bd | 144 | |
67c8f8a1 A |
145 | Revision 1.55 2007/04/22 06:02:03 cheshire |
146 | <rdar://problem/4615977> Query should immediately return failure when no server | |
7f0064bd | 147 | |
67c8f8a1 A |
148 | Revision 1.54 2007/04/04 21:48:53 cheshire |
149 | <rdar://problem/4720694> Combine unicast authoritative answer list with multicast list | |
7f0064bd | 150 | |
67c8f8a1 A |
151 | Revision 1.53 2007/03/28 15:56:37 cheshire |
152 | <rdar://problem/5085774> Add listing of NAT port mapping and GetAddrInfo requests in SIGINFO output | |
7f0064bd | 153 | |
67c8f8a1 A |
154 | Revision 1.52 2007/02/28 01:44:26 cheshire |
155 | <rdar://problem/5027863> Byte order bugs in uDNS.c, uds_daemon.c, dnssd_clientstub.c | |
7f0064bd | 156 | |
67c8f8a1 A |
157 | Revision 1.51 2007/01/27 03:34:27 cheshire |
158 | Made GetZoneData use standard queries (and cached results); | |
159 | eliminated GetZoneData_Callback() packet response handler | |
7f0064bd | 160 | |
67c8f8a1 A |
161 | Revision 1.50 2007/01/19 21:17:32 cheshire |
162 | StartLLQPolling needs to call SetNextQueryTime() to cause query to be done in a timely fashion | |
7f0064bd | 163 | |
67c8f8a1 A |
164 | Revision 1.49 2007/01/17 21:35:31 cheshire |
165 | For clarity, rename zoneData_t field "isPrivate" to "zonePrivate" | |
7f0064bd | 166 | |
67c8f8a1 A |
167 | Revision 1.48 2007/01/10 22:51:57 cheshire |
168 | <rdar://problem/4917539> Add support for one-shot private queries as well as long-lived private queries | |
7f0064bd | 169 | |
67c8f8a1 A |
170 | Revision 1.47 2007/01/05 08:30:43 cheshire |
171 | Trim excessive "$Log" checkin history from before 2006 | |
172 | (checkin history still available via "cvs log ..." of course) | |
7f0064bd | 173 | |
67c8f8a1 A |
174 | Revision 1.46 2007/01/04 01:41:47 cheshire |
175 | Use _dns-update-tls/_dns-query-tls/_dns-llq-tls instead of creating a new "_tls" subdomain | |
8e92c31c | 176 | |
67c8f8a1 A |
177 | Revision 1.45 2006/12/22 20:59:49 cheshire |
178 | <rdar://problem/4742742> Read *all* DNS keys from keychain, | |
179 | not just key for the system-wide default registration domain | |
8e92c31c | 180 | |
67c8f8a1 A |
181 | Revision 1.44 2006/12/20 04:07:35 cheshire |
182 | Remove uDNS_info substructure from AuthRecord_struct | |
8e92c31c | 183 | |
67c8f8a1 A |
184 | Revision 1.43 2006/12/16 01:58:32 cheshire |
185 | <rdar://problem/4720673> uDNS: Need to start caching unicast records | |
8e92c31c | 186 | |
67c8f8a1 A |
187 | Revision 1.42 2006/11/30 23:07:56 herscher |
188 | <rdar://problem/4765644> uDNS: Sync up with Lighthouse changes for Private DNS | |
8e92c31c | 189 | |
67c8f8a1 A |
190 | Revision 1.41 2006/11/18 05:01:30 cheshire |
191 | Preliminary support for unifying the uDNS and mDNS code, | |
192 | including caching of uDNS answers | |
8e92c31c | 193 | |
67c8f8a1 A |
194 | Revision 1.40 2006/11/10 07:44:04 herscher |
195 | <rdar://problem/4825493> Fix Daemon locking failures while toggling BTMM | |
8e92c31c | 196 | |
67c8f8a1 A |
197 | Revision 1.39 2006/10/20 05:35:05 herscher |
198 | <rdar://problem/4720713> uDNS: Merge unicast active question list with multicast list. | |
8e92c31c | 199 | |
67c8f8a1 A |
200 | Revision 1.38 2006/09/26 01:54:02 herscher |
201 | <rdar://problem/4245016> NAT Port Mapping API (for both NAT-PMP and UPnP Gateway Protocol) | |
8e92c31c | 202 | |
67c8f8a1 A |
203 | Revision 1.37 2006/09/15 21:20:15 cheshire |
204 | Remove uDNS_info substructure from mDNS_struct | |
8e92c31c | 205 | |
67c8f8a1 A |
206 | Revision 1.36 2006/08/14 23:24:23 cheshire |
207 | Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0 | |
8e92c31c | 208 | |
67c8f8a1 A |
209 | Revision 1.35 2006/07/30 05:45:36 cheshire |
210 | <rdar://problem/4304215> Eliminate MIN_UCAST_PERIODIC_EXEC | |
211 | ||
212 | Revision 1.34 2006/07/15 02:01:29 cheshire | |
213 | <rdar://problem/4472014> Add Private DNS client functionality to mDNSResponder | |
214 | Fix broken "empty string" browsing | |
215 | ||
216 | Revision 1.33 2006/07/05 22:53:28 cheshire | |
217 | <rdar://problem/4472014> Add Private DNS client functionality to mDNSResponder | |
8e92c31c | 218 | |
67c8f8a1 | 219 | */ |
8e92c31c A |
220 | |
221 | #ifndef __UDNS_H_ | |
222 | #define __UDNS_H_ | |
223 | ||
7f0064bd | 224 | #include "mDNSEmbeddedAPI.h" |
8e92c31c A |
225 | #include "DNSCommon.h" |
226 | ||
227 | #ifdef __cplusplus | |
228 | extern "C" { | |
229 | #endif | |
230 | ||
7cb34e5c | 231 | #define RESTART_GOODBYE_DELAY (6 * mDNSPlatformOneSecond) // delay after restarting LLQ before nuking previous known answers (avoids flutter if we restart before we have networking up) |
7cb34e5c A |
232 | #define INIT_UCAST_POLL_INTERVAL (3 * mDNSPlatformOneSecond) // this interval is used after send failures on network transitions |
233 | // which typically heal quickly, so we start agressively and exponentially back off | |
283ee3ff | 234 | #define MAX_UCAST_POLL_INTERVAL (60 * 60 * mDNSPlatformOneSecond) |
67c8f8a1 | 235 | //#define MAX_UCAST_POLL_INTERVAL (1 * 60 * mDNSPlatformOneSecond) |
05292456 | 236 | #define LLQ_POLL_INTERVAL (15 * 60 * mDNSPlatformOneSecond) // Polling interval for zones w/ an advertised LLQ port (ie not static zones) if LLQ fails due to NAT, etc. |
7cb34e5c | 237 | #define RESPONSE_WINDOW (60 * mDNSPlatformOneSecond) // require server responses within one minute of request |
9f29194f | 238 | #define MAX_UCAST_UNANSWERED_QUERIES 2 // the number of unanswered queries from any one uDNS server before trying another server |
ca3eca6b | 239 | #define DNSSERVER_PENALTY_TIME (60 * mDNSPlatformOneSecond) // number of seconds for which new questions don't pick this server |
67c8f8a1 | 240 | |
283ee3ff | 241 | #define DEFAULT_UPDATE_LEASE 7200 |
67c8f8a1 A |
242 | |
243 | #define QuestionIntervalStep 3 | |
244 | #define QuestionIntervalStep2 (QuestionIntervalStep*QuestionIntervalStep) | |
245 | #define QuestionIntervalStep3 (QuestionIntervalStep*QuestionIntervalStep*QuestionIntervalStep) | |
246 | #define InitialQuestionInterval ((mDNSPlatformOneSecond + QuestionIntervalStep-1) / QuestionIntervalStep) | |
247 | ||
8e92c31c A |
248 | // Entry points into unicast-specific routines |
249 | ||
96f69b28 A |
250 | extern void LLQGotZoneData(mDNS *const m, mStatus err, const ZoneData *zoneInfo); |
251 | extern void startLLQHandshake(mDNS *m, DNSQuestion *q); | |
030b743d | 252 | extern void sendLLQRefresh(mDNS *m, DNSQuestion *q); |
67c8f8a1 | 253 | |
96f69b28 A |
254 | extern void SleepServiceRegistrations(mDNS *m); |
255 | extern void SleepRecordRegistrations(mDNS *m); | |
256 | ||
7f0064bd A |
257 | // uDNS_UpdateRecord |
258 | // following fields must be set, and the update validated, upon entry. | |
259 | // rr->NewRData | |
260 | // rr->newrdlength | |
261 | // rr->UpdateCallback | |
262 | ||
263 | extern mStatus uDNS_AddRecordToService(mDNS *const m, ServiceRecordSet *sr, ExtraResourceRecord *extra); | |
264 | extern mStatus uDNS_UpdateRecord(mDNS *m, AuthRecord *rr); | |
67c8f8a1 A |
265 | |
266 | extern void SetNextQueryTime(mDNS *const m, const DNSQuestion *const q); | |
267 | extern CacheGroup *CacheGroupForName(const mDNS *const m, const mDNSu32 slot, const mDNSu32 namehash, const domainname *const name); | |
268 | extern mStatus mDNS_Register_internal(mDNS *const m, AuthRecord *const rr); | |
269 | // mDNS_Dereg_normal is used for most calls to mDNS_Deregister_internal | |
270 | // mDNS_Dereg_conflict is used to indicate that this record is being forcibly deregistered because of a conflict | |
271 | // mDNS_Dereg_repeat is used when cleaning up, for records that may have already been forcibly deregistered | |
272 | typedef enum { mDNS_Dereg_normal, mDNS_Dereg_conflict, mDNS_Dereg_repeat } mDNS_Dereg_type; | |
273 | extern mStatus mDNS_Deregister_internal(mDNS *const m, AuthRecord *const rr, mDNS_Dereg_type drt); | |
274 | extern mStatus mDNS_StartQuery_internal(mDNS *const m, DNSQuestion *const question); | |
275 | extern mStatus mDNS_StopQuery_internal(mDNS *const m, DNSQuestion *const question); | |
276 | extern mStatus mDNS_StartNATOperation_internal(mDNS *const m, NATTraversalInfo *traversal); | |
277 | ||
96f69b28 | 278 | extern void RecordRegistrationGotZoneData(mDNS *const m, mStatus err, const ZoneData *zoneData); |
8e92c31c A |
279 | extern mStatus uDNS_DeregisterRecord(mDNS *const m, AuthRecord *const rr); |
280 | ||
96f69b28 | 281 | extern void ServiceRegistrationGotZoneData(mDNS *const m, mStatus err, const ZoneData *result); |
32bb7e43 | 282 | extern const domainname *GetServiceTarget(mDNS *m, AuthRecord *const rr); |
8e92c31c | 283 | extern mStatus uDNS_DeregisterService(mDNS *const m, ServiceRecordSet *srs); |
8e92c31c | 284 | |
67c8f8a1 A |
285 | extern void uDNS_CheckCurrentQuestion(mDNS *const m); |
286 | ||
8e92c31c A |
287 | // integer fields of msg header must be in HOST byte order before calling this routine |
288 | extern void uDNS_ReceiveMsg(mDNS *const m, DNSMessage *const msg, const mDNSu8 *const end, | |
67c8f8a1 | 289 | const mDNSAddr *const srcaddr, const mDNSIPPort srcport); |
8e92c31c A |
290 | |
291 | // returns time of next scheduled event | |
292 | extern void uDNS_Execute(mDNS *const m); | |
ca3eca6b | 293 | extern void ResetDNSServerPenalties(mDNS *m); |
8e92c31c | 294 | |
67c8f8a1 A |
295 | extern mStatus uDNS_SetupDNSConfig(mDNS *const m); |
296 | extern mStatus uDNS_RegisterSearchDomains(mDNS *const m); | |
297 | ||
298 | typedef enum | |
299 | { | |
300 | uDNS_LLQ_Not = 0, // Normal uDNS answer: Flush any stale records from cache, and respect record TTL | |
96f69b28 A |
301 | uDNS_LLQ_Ignore, // LLQ initial challenge packet: ignore -- has no useful records for us |
302 | uDNS_LLQ_Entire, // LLQ initial set of answers: Flush any stale records from cache, but assume TTL is 2 x LLQ refresh interval | |
67c8f8a1 A |
303 | uDNS_LLQ_Events // LLQ event packet: don't flush cache; assume TTL is 2 x LLQ refresh interval |
304 | } uDNS_LLQType; | |
305 | ||
306 | extern uDNS_LLQType uDNS_recvLLQResponse(mDNS *const m, const DNSMessage *const msg, const mDNSu8 *const end, const mDNSAddr *const srcaddr, const mDNSIPPort srcport); | |
307 | extern DomainAuthInfo *GetAuthInfoForName_internal(mDNS *m, const domainname *const name); | |
96f69b28 | 308 | extern DomainAuthInfo *GetAuthInfoForQuestion(mDNS *m, const DNSQuestion *const q); |
67c8f8a1 A |
309 | extern void DisposeTCPConn(struct tcpInfo_t *tcp); |
310 | ||
311 | // NAT traversal | |
312 | extern void uDNS_ReceiveNATPMPPacket(mDNS *m, const mDNSInterfaceID InterfaceID, mDNSu8 *pkt, mDNSu16 len); // Called for each received NAT-PMP packet | |
313 | extern void natTraversalHandleAddressReply(mDNS *const m, mDNSu16 err, mDNSv4Addr ExtAddr); | |
314 | extern void natTraversalHandlePortMapReply(mDNS *const m, NATTraversalInfo *n, const mDNSInterfaceID InterfaceID, mDNSu16 err, mDNSIPPort extport, mDNSu32 lease); | |
315 | ||
8e92c31c A |
316 | #ifdef __cplusplus |
317 | } | |
318 | #endif | |
319 | ||
320 | #endif // __UDNS_H_ |