]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/mDNSWin32.h
mDNSResponder-58.8.tar.gz
[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 * 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.9.2.1 2004/04/03 05:26:08 bradley
27 Integrated changes from TOT to remove legacy port 53 support.
28
29 Revision 1.10 2003/10/24 23:23:02 bradley
30 Removed legacy port 53 support as it is no longer needed.
31
32 Revision 1.9 2003/08/20 06:21:25 bradley
33 Updated to latest internal version of the Rendezvous for Windows platform plugin: Added support
34 for Windows CE/PocketPC 2003; re-did interface-related code to emulate getifaddrs/freeifaddrs for
35 restricting usage to only active, multicast-capable, and non-point-to-point interfaces and to ease
36 the addition of IPv6 support in the future; Changed init code to serialize thread initialization to
37 enable ThreadID improvement to wakeup notification; Define platform support structure locally to
38 allow portable mDNS_Init usage; Removed dependence on modified mDNSCore: define interface ID<->name
39 structures/prototypes locally; Changed to use _beginthreadex()/_endthreadex() on non-Windows CE
40 platforms (re-mapped to CreateThread on Window CE) to avoid a leak in the Microsoft C runtime;
41 Added IPv4/IPv6 string<->address conversion routines; Cleaned up some code and added HeaderDoc.
42
43 Revision 1.8 2003/08/12 19:56:27 cheshire
44 Update to APSL 2.0
45
46 Revision 1.7 2003/07/23 02:23:01 cheshire
47 Updated mDNSPlatformUnlock() to work correctly, now that <rdar://problem/3160248>
48 "ScheduleNextTask needs to be smarter" has refined the way m->NextScheduledEvent is set
49
50 Revision 1.6 2003/07/02 21:20:04 cheshire
51 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
52
53 Revision 1.5 2003/04/29 00:06:09 cheshire
54 <rdar://problem/3242673> mDNSWindows needs a wakeupEvent object to signal the main thread
55
56 Revision 1.4 2003/03/22 02:57:44 cheshire
57 Updated mDNSWindows to use new "mDNS_Execute" model (see "mDNSCore/Implementer Notes.txt")
58
59 Revision 1.3 2002/09/21 20:44:54 zarzycki
60 Added APSL info
61
62 Revision 1.2 2002/09/20 05:55:16 bradley
63 Multicast DNS platform plugin for Win32
64
65 */
66
67 #ifndef __MDNS_WIN32__
68 #define __MDNS_WIN32__
69
70 #if( !defined( WIN32_LEAN_AND_MEAN ) )
71 #define WIN32_LEAN_AND_MEAN // Needed to avoid redefinitions by Windows interfaces.
72 #endif
73
74 #include <windows.h>
75 #include <winsock2.h>
76 #include <Ws2tcpip.h>
77
78 #include "mDNSClientAPI.h"
79
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83
84 //---------------------------------------------------------------------------------------------------------------------------
85 /*! @typedef SocketRef
86
87 @abstract Socket file descriptor alias for improved readability.
88 */
89
90 typedef SOCKET SocketRef;
91
92 //---------------------------------------------------------------------------------------------------------------------------
93 /*! @struct mDNSInterfaceData
94
95 @abstract Structure containing interface-specific data.
96 */
97
98 typedef struct mDNSInterfaceData mDNSInterfaceData;
99 struct mDNSInterfaceData
100 {
101 mDNSInterfaceData * next;
102 char name[ 256 ];
103 SocketRef sock;
104 HANDLE readPendingEvent;
105 NetworkInterfaceInfo hostSet;
106 mDNSBool hostRegistered;
107
108 int sendMulticastCounter;
109 int sendUnicastCounter;
110 int sendErrorCounter;
111
112 int recvCounter;
113 int recvErrorCounter;
114 };
115
116 //---------------------------------------------------------------------------------------------------------------------------
117 /*! @struct mDNS_PlatformSupport_struct
118
119 @abstract Structure containing platform-specific data.
120 */
121
122 struct mDNS_PlatformSupport_struct
123 {
124 CRITICAL_SECTION lock;
125 mDNSBool lockInitialized;
126 HANDLE cancelEvent;
127 HANDLE quitEvent;
128 HANDLE interfaceListChangedEvent;
129 HANDLE wakeupEvent;
130 HANDLE initEvent;
131 mStatus initStatus;
132
133 SocketRef interfaceListChangedSocketRef;
134 int interfaceCount;
135 mDNSInterfaceData * interfaceList;
136 DWORD threadID;
137 };
138
139 //---------------------------------------------------------------------------------------------------------------------------
140 /*! @struct ifaddrs
141
142 @abstract Interface information
143 */
144
145 struct ifaddrs
146 {
147 struct ifaddrs * ifa_next;
148 char * ifa_name;
149 u_int ifa_flags;
150 struct sockaddr * ifa_addr;
151 struct sockaddr * ifa_netmask;
152 struct sockaddr * ifa_broadaddr;
153 struct sockaddr * ifa_dstaddr;
154 void * ifa_data;
155 };
156
157 //---------------------------------------------------------------------------------------------------------------------------
158 /*! @function getifaddrs
159
160 @abstract Builds a linked list of interfaces. Caller must free using freeifaddrs if successful.
161 */
162
163 int getifaddrs( struct ifaddrs **outAddrs );
164
165 //---------------------------------------------------------------------------------------------------------------------------
166 /*! @function freeifaddrs
167
168 @abstract Frees a linked list of interfaces built with getifaddrs.
169 */
170
171 void freeifaddrs( struct ifaddrs *inAddrs );
172
173 //---------------------------------------------------------------------------------------------------------------------------
174 /*! @function sock_pton
175
176 @abstract Converts a 'p'resentation address string into a 'n'umeric sockaddr structure.
177
178 @result 0 if successful or an error code on failure.
179 */
180
181 int sock_pton( const char *inString, int inFamily, void *outAddr, size_t inAddrSize, size_t *outAddrSize );
182
183 //---------------------------------------------------------------------------------------------------------------------------
184 /*! @function sock_ntop
185
186 @abstract Converts a 'n'umeric sockaddr structure into a 'p'resentation address string.
187
188 @result Ptr to 'p'resentation address string buffer if successful or NULL on failure.
189 */
190
191 char * sock_ntop( const void *inAddr, size_t inAddrSize, char *inBuffer, size_t inBufferSize );
192
193 #ifdef __cplusplus
194 }
195 #endif
196
197 #endif // __MDNS_WIN32__