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