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