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