]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/mDNSWin32.h
mDNSResponder-170.tar.gz
[apple/mdnsresponder.git] / mDNSWindows / mDNSWin32.h
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2002-2004 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: mDNSWin32.h,v $
20 Revision 1.26 2006/08/14 23:25:21 cheshire
21 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
22
23 Revision 1.25 2006/07/06 00:05:44 cheshire
24 "dDNS.h" renamed to "uDNS.h"
25
26 Revision 1.24 2006/02/26 19:31:04 herscher
27 <rdar://problem/4455038> Bonjour For Windows takes 90 seconds to start. This was caused by a bad interaction between the VirtualPC check, and the removal of the WMI dependency. The problem was fixed by: 1) checking to see if WMI is running before trying to talk to it. 2) Retrying the VirtualPC check every 10 seconds upon failure, stopping after 10 unsuccessful tries.
28
29 Revision 1.23 2005/10/05 20:55:14 herscher
30 <rdar://problem/4096464> Don't call SetLLRoute on loopback interface
31
32 Revision 1.22 2005/03/04 22:44:53 shersche
33 <rdar://problem/4022802> mDNSResponder did not notice changes to DNS server config
34
35 Revision 1.21 2005/03/03 02:29:00 shersche
36 Use the RegNames.h header file for registry key names
37
38 Revision 1.20 2005/01/25 08:12:52 shersche
39 <rdar://problem/3947417> Enable Unicast and add Dynamic DNS support.
40 Bug #: 3947417
41
42 Revision 1.19 2004/12/15 07:34:45 shersche
43 Add platform support for IPv4 and IPv6 unicast sockets
44
45 Revision 1.18 2004/10/11 21:53:15 shersche
46 <rdar://problem/3832450> Change GetWindowsVersionString link scoping from static to non-static so that it can be accessed from other compilation units. The information returned in this function will be used to determine what service dependencies to use when calling CreateService().
47 Bug #: 3832450
48
49 Revision 1.17 2004/09/17 01:08:57 cheshire
50 Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
51 The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
52 declared in that file are ONLY appropriate to single-address-space embedded applications.
53 For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used.
54
55 Revision 1.16 2004/08/05 05:43:01 shersche
56 <rdar://problem/3751566> Add HostDescriptionChangedCallback so callers can choose to handle it when mDNSWin32 core detects that the computer description string has changed
57 Bug #: 3751566
58
59 Revision 1.15 2004/07/26 05:42:50 shersche
60 use "Computer Description" for nicename if available, track dynamic changes to "Computer Description"
61
62 Revision 1.14 2004/07/13 21:24:25 rpantos
63 Fix for <rdar://problem/3701120>.
64
65 Revision 1.13 2004/06/24 15:23:24 shersche
66 Add InterfaceListChanged callback. This callback is used in Service.c to add link local routes to the routing table
67 Submitted by: herscher
68
69 Revision 1.12 2004/06/18 05:22:16 rpantos
70 Integrate Scott's changes
71
72 Revision 1.11 2004/01/30 02:44:32 bradley
73 Added support for IPv6 (v4 & v6, v4-only, v6-only, AAAA over v4, etc.). Added support for DNS-SD
74 InterfaceID<->Interface Index mappings. Added support for loopback usage when no other interfaces
75 are available. Updated unlock signaling to no longer require timenow - NextScheduledTime to be >= 0
76 (it no longer is). Added unicast-capable detection to avoid using unicast when there is other mDNS
77 software running on the same machine. Removed unneeded sock_XtoY routines. Added support for
78 reporting HINFO records with the Windows and mDNSResponder version information.
79
80 Revision 1.10 2003/10/24 23:23:02 bradley
81 Removed legacy port 53 support as it is no longer needed.
82
83 Revision 1.9 2003/08/20 06:21:25 bradley
84 Updated to latest internal version of the mDNSWindows platform layer: Added support
85 for Windows CE/PocketPC 2003; re-did interface-related code to emulate getifaddrs/freeifaddrs for
86 restricting usage to only active, multicast-capable, and non-point-to-point interfaces and to ease
87 the addition of IPv6 support in the future; Changed init code to serialize thread initialization to
88 enable ThreadID improvement to wakeup notification; Define platform support structure locally to
89 allow portable mDNS_Init usage; Removed dependence on modified mDNSCore: define interface ID<->name
90 structures/prototypes locally; Changed to use _beginthreadex()/_endthreadex() on non-Windows CE
91 platforms (re-mapped to CreateThread on Window CE) to avoid a leak in the Microsoft C runtime;
92 Added IPv4/IPv6 string<->address conversion routines; Cleaned up some code and added HeaderDoc.
93
94 Revision 1.8 2003/08/12 19:56:27 cheshire
95 Update to APSL 2.0
96
97 Revision 1.7 2003/07/23 02:23:01 cheshire
98 Updated mDNSPlatformUnlock() to work correctly, now that <rdar://problem/3160248>
99 "ScheduleNextTask needs to be smarter" has refined the way m->NextScheduledEvent is set
100
101 Revision 1.6 2003/07/02 21:20:04 cheshire
102 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
103
104 Revision 1.5 2003/04/29 00:06:09 cheshire
105 <rdar://problem/3242673> mDNSWindows needs a wakeupEvent object to signal the main thread
106
107 Revision 1.4 2003/03/22 02:57:44 cheshire
108 Updated mDNSWindows to use new "mDNS_Execute" model (see "mDNSCore/Implementer Notes.txt")
109
110 Revision 1.3 2002/09/21 20:44:54 zarzycki
111 Added APSL info
112
113 Revision 1.2 2002/09/20 05:55:16 bradley
114 Multicast DNS platform plugin for Win32
115
116 */
117
118 #ifndef __MDNS_WIN32__
119 #define __MDNS_WIN32__
120
121 #include "CommonServices.h"
122
123 #if( !defined( _WIN32_WCE ) )
124 #include <mswsock.h>
125 #endif
126
127 #include "mDNSEmbeddedAPI.h"
128 #include "uDNS.h"
129
130 #ifdef __cplusplus
131 extern "C" {
132 #endif
133
134 //---------------------------------------------------------------------------------------------------------------------------
135 /*! @struct mDNSInterfaceData
136
137 @abstract Structure containing interface-specific data.
138 */
139
140 typedef struct mDNSInterfaceData mDNSInterfaceData;
141 struct mDNSInterfaceData
142 {
143 mDNSInterfaceData * next;
144 char name[ 128 ];
145 uint32_t index;
146 uint32_t scopeID;
147 SocketRef sock;
148 #if( !defined( _WIN32_WCE ) )
149 LPFN_WSARECVMSG wsaRecvMsgFunctionPtr;
150 #endif
151 HANDLE readPendingEvent;
152 NetworkInterfaceInfo interfaceInfo;
153 mDNSAddr defaultAddr;
154 mDNSBool hostRegistered;
155 };
156
157 //---------------------------------------------------------------------------------------------------------------------------
158 /*! @typedef IdleThreadCallback
159
160 @abstract mDNSWin32 core will call out through this function pointer
161 after calling mDNS_Execute
162 */
163 typedef mDNSs32 (*IdleThreadCallback)(mDNS * const inMDNS, mDNSs32 interval);
164 //---------------------------------------------------------------------------------------------------------------------------
165
166 //---------------------------------------------------------------------------------------------------------------------------
167 /*! @typedef InterfaceListChangedCallback
168
169 @abstract mDNSWin32 core will call out through this function pointer
170 after detecting an interface list changed event
171 */
172 typedef void (*InterfaceListChangedCallback)(mDNS * const inMDNS);
173 //---------------------------------------------------------------------------------------------------------------------------
174
175
176 //---------------------------------------------------------------------------------------------------------------------------
177 /*! @typedef HostDescriptionChangedCallback
178
179 @abstract mDNSWin32 core will call out through this function pointer
180 after detecting that the computer description has changed
181 */
182 typedef void (*HostDescriptionChangedCallback)(mDNS * const inMDNS);
183 //---------------------------------------------------------------------------------------------------------------------------
184
185
186 //---------------------------------------------------------------------------------------------------------------------------
187 /*! @struct mDNS_PlatformSupport_struct
188
189 @abstract Structure containing platform-specific data.
190 */
191
192 struct mDNS_PlatformSupport_struct
193 {
194 CRITICAL_SECTION lock;
195 mDNSBool lockInitialized;
196 HANDLE cancelEvent;
197 HANDLE quitEvent;
198 HANDLE interfaceListChangedEvent;
199 HANDLE descChangedEvent; // Computer description changed event
200 HANDLE tcpipChangedEvent; // TCP/IP config changed
201 HANDLE ddnsChangedEvent; // DynDNS config changed
202 HANDLE wakeupEvent;
203 HANDLE initEvent;
204 HANDLE vpcCheckEvent; // Timer handle to check if we're running in Virtual PC
205 int vpcCheckCount;
206 HKEY descKey;
207 HKEY tcpipKey;
208 HKEY ddnsKey;
209 mStatus initStatus;
210 mDNSBool inVirtualPC;
211 int timersCount;
212 mDNSBool registeredLoopback4;
213 SocketRef interfaceListChangedSocket;
214 int interfaceCount;
215 mDNSInterfaceData * interfaceList;
216 mDNSInterfaceData * inactiveInterfaceList;
217 DWORD threadID;
218 IdleThreadCallback idleThreadCallback;
219 InterfaceListChangedCallback interfaceListChangedCallback;
220 HostDescriptionChangedCallback hostDescriptionChangedCallback;
221 SocketRef unicastSock4;
222 HANDLE unicastSock4ReadEvent;
223 mDNSAddr unicastSock4DestAddr;
224 #if( !defined( _WIN32_WCE ) )
225 LPFN_WSARECVMSG unicastSock4RecvMsgPtr;
226 #endif
227 SocketRef unicastSock6;
228 HANDLE unicastSock6ReadEvent;
229 mDNSAddr unicastSock6DestAddr;
230 #if( !defined( _WIN32_WCE ) )
231 LPFN_WSARECVMSG unicastSock6RecvMsgPtr;
232 #endif
233 };
234
235 //---------------------------------------------------------------------------------------------------------------------------
236 /*! @struct ifaddrs
237
238 @abstract Interface information
239 */
240
241 struct ifaddrs
242 {
243 struct ifaddrs * ifa_next;
244 char * ifa_name;
245 u_int ifa_flags;
246 struct sockaddr * ifa_addr;
247 struct sockaddr * ifa_netmask;
248 struct sockaddr * ifa_broadaddr;
249 struct sockaddr * ifa_dstaddr;
250 void * ifa_data;
251
252 struct
253 {
254 uint32_t index;
255
256 } ifa_extra;
257 };
258
259
260 //---------------------------------------------------------------------------------------------------------------------------
261 /*! @function GetWindowsVersionString
262
263 @abstract Stores Windows version information in the string passed in (inBuffer)
264 */
265
266 OSStatus GetWindowsVersionString( char *inBuffer, size_t inBufferSize );
267
268
269 //---------------------------------------------------------------------------------------------------------------------------
270 /*! @function getifaddrs
271
272 @abstract Builds a linked list of interfaces. Caller must free using freeifaddrs if successful.
273 */
274
275 int getifaddrs( struct ifaddrs **outAddrs );
276
277 //---------------------------------------------------------------------------------------------------------------------------
278 /*! @function freeifaddrs
279
280 @abstract Frees a linked list of interfaces built with getifaddrs.
281 */
282
283 void freeifaddrs( struct ifaddrs *inAddrs );
284
285
286 #ifdef __cplusplus
287 }
288 #endif
289
290 #endif // __MDNS_WIN32__