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