]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/mDNSWin32.h
492dbb6a366d62caf9a8c63362517bc05ca0eb5e
[apple/mdnsresponder.git] / mDNSWindows / mDNSWin32.h
1 /*
2 * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24
25 Change History (most recent first):
26
27 $Log: mDNSWin32.h,v $
28 Revision 1.9 2003/08/20 06:21:25 bradley
29 Updated to latest internal version of the Rendezvous for Windows platform plugin: Added support
30 for Windows CE/PocketPC 2003; re-did interface-related code to emulate getifaddrs/freeifaddrs for
31 restricting usage to only active, multicast-capable, and non-point-to-point interfaces and to ease
32 the addition of IPv6 support in the future; Changed init code to serialize thread initialization to
33 enable ThreadID improvement to wakeup notification; Define platform support structure locally to
34 allow portable mDNS_Init usage; Removed dependence on modified mDNSCore: define interface ID<->name
35 structures/prototypes locally; Changed to use _beginthreadex()/_endthreadex() on non-Windows CE
36 platforms (re-mapped to CreateThread on Window CE) to avoid a leak in the Microsoft C runtime;
37 Added IPv4/IPv6 string<->address conversion routines; Cleaned up some code and added HeaderDoc.
38
39 Revision 1.8 2003/08/12 19:56:27 cheshire
40 Update to APSL 2.0
41
42 Revision 1.7 2003/07/23 02:23:01 cheshire
43 Updated mDNSPlatformUnlock() to work correctly, now that <rdar://problem/3160248>
44 "ScheduleNextTask needs to be smarter" has refined the way m->NextScheduledEvent is set
45
46 Revision 1.6 2003/07/02 21:20:04 cheshire
47 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
48
49 Revision 1.5 2003/04/29 00:06:09 cheshire
50 <rdar://problem/3242673> mDNSWindows needs a wakeupEvent object to signal the main thread
51
52 Revision 1.4 2003/03/22 02:57:44 cheshire
53 Updated mDNSWindows to use new "mDNS_Execute" model (see "mDNSCore/Implementer Notes.txt")
54
55 Revision 1.3 2002/09/21 20:44:54 zarzycki
56 Added APSL info
57
58 Revision 1.2 2002/09/20 05:55:16 bradley
59 Multicast DNS platform plugin for Win32
60
61 */
62
63 #ifndef __MDNS_WIN32__
64 #define __MDNS_WIN32__
65
66 #if( !defined( WIN32_LEAN_AND_MEAN ) )
67 #define WIN32_LEAN_AND_MEAN // Needed to avoid redefinitions by Windows interfaces.
68 #endif
69
70 #include <windows.h>
71 #include <winsock2.h>
72 #include <Ws2tcpip.h>
73
74 #include "mDNSClientAPI.h"
75
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79
80 //---------------------------------------------------------------------------------------------------------------------------
81 /*! @typedef SocketRef
82
83 @abstract Socket file descriptor alias for improved readability.
84 */
85
86 typedef SOCKET SocketRef;
87
88 //---------------------------------------------------------------------------------------------------------------------------
89 /*! @struct mDNSInterfaceData
90
91 @abstract Structure containing interface-specific data.
92 */
93
94 typedef struct mDNSInterfaceData mDNSInterfaceData;
95 struct mDNSInterfaceData
96 {
97 mDNSInterfaceData * next;
98 char name[ 256 ];
99 SocketRef multicastSocketRef;
100 HANDLE multicastReadPendingEvent;
101 SocketRef unicastSocketRef;
102 HANDLE unicastReadPendingEvent;
103 NetworkInterfaceInfo hostSet;
104 mDNSBool hostRegistered;
105
106 int sendMulticastCounter;
107 int sendUnicastCounter;
108 int sendErrorCounter;
109
110 int recvMulticastCounter;
111 int recvUnicastCounter;
112 int recvErrorCounter;
113 };
114
115 //---------------------------------------------------------------------------------------------------------------------------
116 /*! @struct mDNS_PlatformSupport_struct
117
118 @abstract Structure containing platform-specific data.
119 */
120
121 struct mDNS_PlatformSupport_struct
122 {
123 CRITICAL_SECTION lock;
124 mDNSBool lockInitialized;
125 HANDLE cancelEvent;
126 HANDLE quitEvent;
127 HANDLE interfaceListChangedEvent;
128 HANDLE wakeupEvent;
129 HANDLE initEvent;
130 mStatus initStatus;
131
132 SocketRef interfaceListChangedSocketRef;
133 int interfaceCount;
134 mDNSInterfaceData * interfaceList;
135 DWORD threadID;
136 };
137
138 //---------------------------------------------------------------------------------------------------------------------------
139 /*! @struct ifaddrs
140
141 @abstract Interface information
142 */
143
144 struct ifaddrs
145 {
146 struct ifaddrs * ifa_next;
147 char * ifa_name;
148 u_int ifa_flags;
149 struct sockaddr * ifa_addr;
150 struct sockaddr * ifa_netmask;
151 struct sockaddr * ifa_broadaddr;
152 struct sockaddr * ifa_dstaddr;
153 void * ifa_data;
154 };
155
156 //---------------------------------------------------------------------------------------------------------------------------
157 /*! @function getifaddrs
158
159 @abstract Builds a linked list of interfaces. Caller must free using freeifaddrs if successful.
160 */
161
162 int getifaddrs( struct ifaddrs **outAddrs );
163
164 //---------------------------------------------------------------------------------------------------------------------------
165 /*! @function freeifaddrs
166
167 @abstract Frees a linked list of interfaces built with getifaddrs.
168 */
169
170 void freeifaddrs( struct ifaddrs *inAddrs );
171
172 //---------------------------------------------------------------------------------------------------------------------------
173 /*! @function sock_pton
174
175 @abstract Converts a 'p'resentation address string into a 'n'umeric sockaddr structure.
176
177 @result 0 if successful or an error code on failure.
178 */
179
180 int sock_pton( const char *inString, int inFamily, void *outAddr, size_t inAddrSize, size_t *outAddrSize );
181
182 //---------------------------------------------------------------------------------------------------------------------------
183 /*! @function sock_ntop
184
185 @abstract Converts a 'n'umeric sockaddr structure into a 'p'resentation address string.
186
187 @result Ptr to 'p'resentation address string buffer if successful or NULL on failure.
188 */
189
190 char * sock_ntop( const void *inAddr, size_t inAddrSize, char *inBuffer, size_t inBufferSize );
191
192 #ifdef __cplusplus
193 }
194 #endif
195
196 #endif // __MDNS_WIN32__