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