]>
Commit | Line | Data |
---|---|---|
1 | /* -*- Mode: C; tab-width: 4 -*- | |
2 | * | |
3 | * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved. | |
4 | * | |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | ||
18 | #ifndef __MDNS_WIN32__ | |
19 | #define __MDNS_WIN32__ | |
20 | ||
21 | #include "CommonServices.h" | |
22 | ||
23 | #if( !defined( _WIN32_WCE ) ) | |
24 | #include <mswsock.h> | |
25 | #endif | |
26 | ||
27 | #include "mDNSEmbeddedAPI.h" | |
28 | #include "uDNS.h" | |
29 | ||
30 | #ifdef __cplusplus | |
31 | extern "C" { | |
32 | #endif | |
33 | ||
34 | typedef void ( *TCPReadEventHandler )( TCPSocket * sock ); | |
35 | typedef void ( *TCPUserCallback )(); | |
36 | ||
37 | struct TCPSocket_struct | |
38 | { | |
39 | TCPSocketFlags flags; // MUST BE FIRST FIELD -- mDNSCore expects every TCPSocket_struct to begin with TCPSocketFlags flags | |
40 | SOCKET fd; | |
41 | TCPReadEventHandler readEventHandler; | |
42 | HANDLE connectEvent; | |
43 | BOOL connected; | |
44 | TCPUserCallback userCallback; | |
45 | void * userContext; | |
46 | DWORD lastError; | |
47 | BOOL closed;\r | |
48 | OVERLAPPED overlapped; | |
49 | WSABUF wbuf; | |
50 | uint8_t buf[ 4192 ]; | |
51 | uint8_t * bptr; | |
52 | uint8_t * eptr; | |
53 | mDNS * m; | |
54 | }; | |
55 | ||
56 | ||
57 | struct UDPSocket_struct | |
58 | { | |
59 | mDNSIPPort port; // MUST BE FIRST FIELD -- mDNSCoreReceive expects every UDPSocket_struct to begin with mDNSIPPort port | |
60 | mDNSAddr addr; // This is initialized by our code. If we don't get the | |
61 | // dstAddr from WSARecvMsg we use this value instead. | |
62 | SOCKET fd; | |
63 | LPFN_WSARECVMSG recvMsgPtr; | |
64 | OVERLAPPED overlapped; | |
65 | WSAMSG wmsg; | |
66 | WSABUF wbuf; | |
67 | DNSMessage packet; | |
68 | uint8_t controlBuffer[ 128 ]; | |
69 | struct sockaddr_storage srcAddr; // This is filled in by the WSARecv* function | |
70 | INT srcAddrLen; // See above | |
71 | struct mDNSInterfaceData * ifd; | |
72 | UDPSocket * next; | |
73 | mDNS * m; | |
74 | }; | |
75 | ||
76 | ||
77 | typedef void ( *SocketEventHandler )( mDNS * const inMDNS, void * v ); | |
78 | ||
79 | ||
80 | typedef struct SocketEvent | |
81 | { | |
82 | void * sock; | |
83 | SocketEventHandler handler; | |
84 | struct SocketEvent * next; | |
85 | } SocketEvent; | |
86 | ||
87 | ||
88 | typedef struct TCPSocketEvent | |
89 | { | |
90 | struct SocketEvent super; | |
91 | DWORD error; | |
92 | DWORD bytesTransferred; | |
93 | uint8_t buf[ 4192 ]; | |
94 | } TCPSocketEvent; | |
95 | ||
96 | ||
97 | typedef struct UDPSocketEvent | |
98 | { | |
99 | struct SocketEvent super; | |
100 | mDNSInterfaceID iid; | |
101 | DNSMessage packet; | |
102 | mDNSu8 * end; | |
103 | mDNSAddr srcAddr; | |
104 | mDNSIPPort srcPort; | |
105 | mDNSAddr dstAddr; | |
106 | mDNSIPPort dstPort; | |
107 | } UDPSocketEvent; | |
108 | ||
109 | ||
110 | ||
111 | //--------------------------------------------------------------------------------------------------------------------------- | |
112 | /*! @struct mDNSInterfaceData | |
113 | ||
114 | @abstract Structure containing interface-specific data. | |
115 | */ | |
116 | ||
117 | typedef struct mDNSInterfaceData mDNSInterfaceData; | |
118 | struct mDNSInterfaceData | |
119 | { | |
120 | char name[ 128 ]; | |
121 | uint32_t index; | |
122 | uint32_t scopeID; | |
123 | struct UDPSocket_struct sock; | |
124 | NetworkInterfaceInfo interfaceInfo; | |
125 | mDNSBool hostRegistered; | |
126 | mDNSInterfaceData * next; | |
127 | }; | |
128 | ||
129 | ||
130 | //--------------------------------------------------------------------------------------------------------------------------- | |
131 | /*! @typedef RegisterWaitableEventHandler | |
132 | */ | |
133 | typedef void (*RegisterWaitableEventHandler)(mDNS * const inMDNS, HANDLE event, void * context ); | |
134 | ||
135 | //--------------------------------------------------------------------------------------------------------------------------- | |
136 | /*! @typedef RegisterWaitableEventFunc | |
137 | */ | |
138 | typedef mStatus (*RegisterWaitableEventFunc)(mDNS * const inMDNS, HANDLE event, void * context, RegisterWaitableEventHandler handler ); | |
139 | ||
140 | //--------------------------------------------------------------------------------------------------------------------------- | |
141 | /*! @typedef UnregisterWaitableEventHandler | |
142 | */ | |
143 | typedef void (*UnregisterWaitableEventFunc)(mDNS * const inMDNS, HANDLE event ); | |
144 | ||
145 | //--------------------------------------------------------------------------------------------------------------------------- | |
146 | /*! @typedef ReportStatusFunc | |
147 | */ | |
148 | typedef void (*ReportStatusFunc)(int inType, const char *inFormat, ...); | |
149 | ||
150 | ||
151 | //--------------------------------------------------------------------------------------------------------------------------- | |
152 | /*! @struct mDNS_PlatformSupport_struct | |
153 | ||
154 | @abstract Structure containing platform-specific data. | |
155 | */ | |
156 | ||
157 | struct mDNS_PlatformSupport_struct | |
158 | { | |
159 | HANDLE mainThread; | |
160 | HANDLE checkFileSharesTimer; | |
161 | mDNSs32 checkFileSharesTimeout; | |
162 | RegisterWaitableEventFunc registerWaitableEventFunc; | |
163 | UnregisterWaitableEventFunc unregisterWaitableEventFunc; | |
164 | ReportStatusFunc reportStatusFunc; | |
165 | time_t nextDHCPLeaseExpires; | |
166 | char nbname[ 32 ]; | |
167 | char nbdomain[ 32 ]; | |
168 | mDNSBool smbFileSharing; | |
169 | mDNSBool smbPrintSharing; | |
170 | ServiceRecordSet smbSRS; | |
171 | AuthRecord smbSubTypes[ 2 ]; | |
172 | mDNSBool registeredLoopback4; | |
173 | int interfaceCount; | |
174 | mDNSInterfaceData * interfaceList; | |
175 | mDNSInterfaceData * inactiveInterfaceList; | |
176 | struct UDPSocket_struct unicastSock4; | |
177 | struct UDPSocket_struct unicastSock6; | |
178 | }; | |
179 | ||
180 | //--------------------------------------------------------------------------------------------------------------------------- | |
181 | /*! @struct ifaddrs | |
182 | ||
183 | @abstract Interface information | |
184 | */ | |
185 | ||
186 | struct ifaddrs | |
187 | { | |
188 | struct ifaddrs * ifa_next; | |
189 | char * ifa_name; | |
190 | u_int ifa_flags; | |
191 | struct sockaddr * ifa_addr; | |
192 | struct sockaddr * ifa_netmask; | |
193 | struct sockaddr * ifa_broadaddr; | |
194 | struct sockaddr * ifa_dstaddr; | |
195 | BYTE ifa_physaddr[6]; | |
196 | BOOL ifa_dhcpEnabled; | |
197 | time_t ifa_dhcpLeaseExpires; | |
198 | mDNSu8 ifa_womp; | |
199 | void * ifa_data; | |
200 | ||
201 | struct | |
202 | { | |
203 | uint32_t index; | |
204 | ||
205 | } ifa_extra; | |
206 | }; | |
207 | ||
208 | \r | |
209 | extern void InterfaceListDidChange( mDNS * const inMDNS ); | |
210 | extern void ComputerDescriptionDidChange( mDNS * const inMDNS ); | |
211 | extern void TCPIPConfigDidChange( mDNS * const inMDNS ); | |
212 | extern void DynDNSConfigDidChange( mDNS * const inMDNS ); | |
213 | extern void FileSharingDidChange( mDNS * const inMDNS ); | |
214 | extern void FirewallDidChange( mDNS * const inMDNS ); | |
215 | extern mStatus TCPAddSocket( mDNS * const inMDNS, TCPSocket *sock ); | |
216 | extern mStatus SetupInterfaceList( mDNS * const inMDNS ); | |
217 | extern mStatus TearDownInterfaceList( mDNS * const inMDNS ); | |
218 | extern BOOL IsWOMPEnabled(); | |
219 | extern void SetSocketEventsEnabled( mDNS * const inMDNS, BOOL val ); | |
220 | ||
221 | ||
222 | #ifdef __cplusplus | |
223 | } | |
224 | #endif | |
225 | ||
226 | #endif // __MDNS_WIN32__ |