2 * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
23 Change History (most recent first):
26 Revision 1.20 2005/01/25 08:12:52 shersche
27 <rdar://problem/3947417> Enable Unicast and add Dynamic DNS support.
30 Revision 1.19 2004/12/15 07:34:45 shersche
31 Add platform support for IPv4 and IPv6 unicast sockets
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().
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.
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
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"
50 Revision 1.14 2004/07/13 21:24:25 rpantos
51 Fix for <rdar://problem/3701120>.
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
57 Revision 1.12 2004/06/18 05:22:16 rpantos
58 Integrate Scott's changes
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.
68 Revision 1.10 2003/10/24 23:23:02 bradley
69 Removed legacy port 53 support as it is no longer needed.
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.
82 Revision 1.8 2003/08/12 19:56:27 cheshire
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
89 Revision 1.6 2003/07/02 21:20:04 cheshire
90 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
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
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")
98 Revision 1.3 2002/09/21 20:44:54 zarzycki
101 Revision 1.2 2002/09/20 05:55:16 bradley
102 Multicast DNS platform plugin for Win32
106 #ifndef __MDNS_WIN32__
107 #define __MDNS_WIN32__
109 #include "CommonServices.h"
111 #if( !defined( _WIN32_WCE ) )
115 #include "mDNSEmbeddedAPI.h"
122 //---------------------------------------------------------------------------------------------------------------------------
123 /*! @struct mDNSInterfaceData
125 @abstract Structure containing interface-specific data.
128 typedef struct mDNSInterfaceData mDNSInterfaceData
;
129 struct mDNSInterfaceData
131 mDNSInterfaceData
* next
;
136 #if( !defined( _WIN32_WCE ) )
137 LPFN_WSARECVMSG wsaRecvMsgFunctionPtr
;
139 HANDLE readPendingEvent
;
140 NetworkInterfaceInfo interfaceInfo
;
141 mDNSAddr defaultAddr
;
142 mDNSBool hostRegistered
;
145 //---------------------------------------------------------------------------------------------------------------------------
146 /*! @typedef IdleThreadCallback
148 @abstract mDNSWin32 core will call out through this function pointer
149 after calling mDNS_Execute
151 typedef mDNSs32 (*IdleThreadCallback
)(mDNS
* const inMDNS
, mDNSs32 interval
);
152 //---------------------------------------------------------------------------------------------------------------------------
154 //---------------------------------------------------------------------------------------------------------------------------
155 /*! @typedef InterfaceListChangedCallback
157 @abstract mDNSWin32 core will call out through this function pointer
158 after detecting an interface list changed event
160 typedef void (*InterfaceListChangedCallback
)(mDNS
* const inMDNS
);
161 //---------------------------------------------------------------------------------------------------------------------------
164 //---------------------------------------------------------------------------------------------------------------------------
165 /*! @typedef HostDescriptionChangedCallback
167 @abstract mDNSWin32 core will call out through this function pointer
168 after detecting that the computer description has changed
170 typedef void (*HostDescriptionChangedCallback
)(mDNS
* const inMDNS
);
171 //---------------------------------------------------------------------------------------------------------------------------
174 //---------------------------------------------------------------------------------------------------------------------------
175 /*! @struct mDNS_PlatformSupport_struct
177 @abstract Structure containing platform-specific data.
180 struct mDNS_PlatformSupport_struct
182 CRITICAL_SECTION lock
;
183 mDNSBool lockInitialized
;
186 HANDLE interfaceListChangedEvent
;
187 HANDLE descChangedEvent
; // Computer description changed event
188 HANDLE ddnsChangedEvent
; // DynDNS config changed
194 SocketRef interfaceListChangedSocket
;
196 mDNSInterfaceData
* interfaceList
;
197 mDNSInterfaceData
* inactiveInterfaceList
;
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
;
208 SocketRef unicastSock6
;
209 HANDLE unicastSock6ReadEvent
;
210 mDNSAddr unicastSock6DestAddr
;
211 #if( !defined( _WIN32_WCE ) )
212 LPFN_WSARECVMSG unicastSock6RecvMsgPtr
;
216 //---------------------------------------------------------------------------------------------------------------------------
219 @abstract Interface information
224 struct ifaddrs
* ifa_next
;
227 struct sockaddr
* ifa_addr
;
228 struct sockaddr
* ifa_netmask
;
229 struct sockaddr
* ifa_broadaddr
;
230 struct sockaddr
* ifa_dstaddr
;
241 //---------------------------------------------------------------------------------------------------------------------------
242 /*! @function GetWindowsVersionString
244 @abstract Stores Windows version information in the string passed in (inBuffer)
247 OSStatus
GetWindowsVersionString( char *inBuffer
, size_t inBufferSize
);
250 //---------------------------------------------------------------------------------------------------------------------------
251 /*! @function getifaddrs
253 @abstract Builds a linked list of interfaces. Caller must free using freeifaddrs if successful.
256 int getifaddrs( struct ifaddrs
**outAddrs
);
258 //---------------------------------------------------------------------------------------------------------------------------
259 /*! @function freeifaddrs
261 @abstract Frees a linked list of interfaces built with getifaddrs.
264 void freeifaddrs( struct ifaddrs
*inAddrs
);
267 //---------------------------------------------------------------------------------------------------------------------------
268 // Registry Constants
269 //---------------------------------------------------------------------------------------------------------------------------
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"
284 #endif // __MDNS_WIN32__