xref: /titanic_41/usr/src/cmd/cmd-inet/usr.lib/mdnsd/uDNS.h (revision b509e89b2befbaa42939abad9da1d7f5a8c6aaae)
1 /* -*- Mode: C; tab-width: 4 -*-
2  *
3  * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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
15  * limitations under the License.
16 
17     Change History (most recent first):
18 
19 $Log: uDNS.h,v $
20 Revision 1.32.2.1  2006/08/29 06:24:23  cheshire
21 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
22 
23 Revision 1.32  2005/07/29 19:46:10  ksekar
24 <rdar://problem/4191860> reduce polling period on failed LLQs to 15 minutes
25 
26 Revision 1.31  2005/03/31 02:19:56  cheshire
27 <rdar://problem/4021486> Fix build warnings
28 Reviewed by: Scott Herscher
29 
30 Revision 1.30  2005/03/04 03:00:03  ksekar
31 <rdar://problem/4026546> Retransmissions happen too early, causing registrations to conflict with themselves
32 
33 Revision 1.29  2005/01/11 22:50:53  ksekar
34 Fixed constant naming (was using kLLQ_DefLease for update leases)
35 
36 Revision 1.28  2004/12/22 00:13:49  ksekar
37 <rdar://problem/3873993> Change version, port, and polling interval for LLQ
38 
39 Revision 1.27  2004/11/23 04:06:50  cheshire
40 Get rid of floating point constant -- in a small embedded device, bringing in all
41 the floating point libraries just to halve an integer value is a bit too heavyweight.
42 
43 Revision 1.26  2004/11/22 17:49:15  ksekar
44 Changed INIT_REFRESH from fraction to decimal
45 
46 Revision 1.25  2004/11/22 17:16:20  ksekar
47 <rdar://problem/3854298> Unicast services don't disappear when you disable all networking
48 
49 Revision 1.24  2004/11/19 04:24:08  ksekar
50 <rdar://problem/3682609> Security: Enforce a "window" on one-shot wide-area queries
51 
52 Revision 1.23  2004/11/18 18:04:21  ksekar
53 Add INIT_REFRESH constant
54 
55 Revision 1.22  2004/11/15 20:09:24  ksekar
56 <rdar://problem/3719050> Wide Area support for Add/Remove record
57 
58 Revision 1.21  2004/11/11 20:14:55  ksekar
59 <rdar://problem/3719574> Wide-Area registrations not deregistered on sleep
60 
61 Revision 1.20  2004/10/16 00:16:59  cheshire
62 <rdar://problem/3770558> Replace IP TTL 255 check with local subnet source address check
63 
64 Revision 1.19  2004/09/17 01:08:49  cheshire
65 Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
66   The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
67   declared in that file are ONLY appropriate to single-address-space embedded applications.
68   For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used.
69 
70 Revision 1.18  2004/09/03 19:23:05  ksekar
71 <rdar://problem/3788460>: Need retransmission mechanism for wide-area service registrations
72 
73 Revision 1.17  2004/09/01 03:59:29  ksekar
74 <rdar://problem/3783453>: Conditionally compile out uDNS code on Windows
75 
76 Revision 1.16  2004/08/25 00:37:27  ksekar
77 <rdar://problem/3774635>: Cleanup DynDNS hostname registration code
78 
79 Revision 1.15  2004/07/30 17:40:06  ksekar
80 <rdar://problem/3739115>: TXT Record updates not available for wide-area services
81 
82 Revision 1.14  2004/07/29 19:27:15  ksekar
83 NATPMP Support - minor fixes and cleanup
84 
85 Revision 1.13  2004/07/29 02:03:35  ksekar
86 Delete unused #define and structure field
87 
88 Revision 1.12  2004/07/26 22:49:30  ksekar
89 <rdar://problem/3651409>: Feature #9516: Need support for NATPMP in client
90 
91 Revision 1.11  2004/06/17 01:13:11  ksekar
92 <rdar://problem/3696616>: polling interval too short
93 
94 Revision 1.10  2004/06/11 05:45:03  ksekar
95 <rdar://problem/3682397>: Change SRV names for LLQ/Update port lookups
96 
97 Revision 1.9  2004/06/01 23:46:50  ksekar
98 <rdar://problem/3675149>: DynDNS: dynamically look up LLQ/Update ports
99 
100 Revision 1.8  2004/05/28 23:42:37  ksekar
101 <rdar://problem/3258021>: Feature: DNS server->client notification on record changes (#7805)
102 
103 Revision 1.7  2004/05/18 23:51:25  cheshire
104 Tidy up all checkin comments to use consistent "<rdar://problem/xxxxxxx>" format for bug numbers
105 
106 Revision 1.6  2004/03/13 01:57:33  ksekar
107 <rdar://problem/3192546>: DynDNS: Dynamic update of service records
108 
109 Revision 1.5  2004/02/21 08:56:58  bradley
110 Wrap prototypes with extern "C" for C++ builds.
111 
112 Revision 1.4  2004/02/06 23:04:19  ksekar
113 Basic Dynamic Update support via mDNS_Register (dissabled via
114 UNICAST_REGISTRATION #define)
115 
116 Revision 1.3  2004/01/24 03:38:27  cheshire
117 Fix minor syntactic error: Headers should use "extern" declarations, not "mDNSexport"
118 
119 Revision 1.2  2004/01/23 23:23:15  ksekar
120 Added TCP support for truncated unicast messages.
121 
122 Revision 1.1  2003/12/13 03:05:27  ksekar
123 <rdar://problem/3192548>: DynDNS: Unicast query of service records
124 
125 
126  */
127 
128 #pragma ident	"%Z%%M%	%I%	%E% SMI"
129 
130 #ifndef __UDNS_H_
131 #define __UDNS_H_
132 
133 #include "mDNSEmbeddedAPI.h"
134 #include "DNSCommon.h"
135 
136 #ifdef	__cplusplus
137 	extern "C" {
138 #endif
139 
140 #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)
141 #define MIN_UCAST_PERIODIC_EXEC  (5 * mDNSPlatformOneSecond)
142 #define INIT_UCAST_POLL_INTERVAL (3 * mDNSPlatformOneSecond) // this interval is used after send failures on network transitions
143 	                                                         // which typically heal quickly, so we start agressively and exponentially back off
144 #define MAX_UCAST_POLL_INTERVAL (60 * 60 * mDNSPlatformOneSecond)
145 #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.
146 #define RESPONSE_WINDOW (60 * mDNSPlatformOneSecond)         // require server responses within one minute of request
147 #define UPDATE_PORT_NAME "_dns-update._udp."
148 #define LLQ_PORT_NAME "_dns-llq._udp"
149 #define DEFAULT_UPDATE_LEASE 7200
150 
151 // Entry points into unicast-specific routines
152 
153 extern mStatus uDNS_StartQuery(mDNS *const m, DNSQuestion *const question);
154 extern mDNSBool uDNS_IsActiveQuery(DNSQuestion *const question, uDNS_GlobalInfo *u);  // returns true if OK to call StopQuery
155 extern mStatus uDNS_StopQuery(mDNS *const m, DNSQuestion *const question);
156 
157 extern void uDNS_Init(mDNS *const m);
158 extern void uDNS_Sleep(mDNS *const m);
159 extern void uDNS_Wake(mDNS *const m);
160 #define uDNS_Close uDNS_Sleep
161 
162 // uDNS_UpdateRecord
163 // following fields must be set, and the update validated, upon entry.
164 // rr->NewRData
165 // rr->newrdlength
166 // rr->UpdateCallback
167 
168 extern mStatus uDNS_AddRecordToService(mDNS *const m, ServiceRecordSet *sr, ExtraResourceRecord *extra);
169 extern mStatus uDNS_UpdateRecord(mDNS *m, AuthRecord *rr);
170 
171 extern mStatus uDNS_RegisterRecord(mDNS *const m, AuthRecord *const rr);
172 extern mStatus uDNS_DeregisterRecord(mDNS *const m, AuthRecord *const rr);
173 
174 extern mStatus uDNS_RegisterService(mDNS *const m, ServiceRecordSet *srs);
175 extern mStatus uDNS_DeregisterService(mDNS *const m, ServiceRecordSet *srs);
176 
177 // integer fields of msg header must be in HOST byte order before calling this routine
178 extern void uDNS_ReceiveMsg(mDNS *const m, DNSMessage *const msg, const mDNSu8 *const end,
179 	const mDNSAddr *const srcaddr, const mDNSIPPort srcport, const mDNSAddr *const dstaddr,
180 	const mDNSIPPort dstport, const mDNSInterfaceID InterfaceID);
181 
182 extern void uDNS_ReceiveNATMap(mDNS *m, mDNSu8 *pkt, mDNSu16 len);
183 
184 // returns time of next scheduled event
185 extern void uDNS_Execute(mDNS *const m);
186 
187 
188 #ifdef	__cplusplus
189 	}
190 #endif
191 
192 #endif // __UDNS_H_
193