X-Git-Url: https://git.saurik.com/apple/mdnsresponder.git/blobdiff_plain/4aea607d357d16eb4a69db265dc8f5c7faef7405..9f221bca50017164b24018386876f8780876ef6d:/mDNSWindows/mDNSWin32.h diff --git a/mDNSWindows/mDNSWin32.h b/mDNSWindows/mDNSWin32.h index 1a9755d..6b5b435 100755 --- a/mDNSWindows/mDNSWin32.h +++ b/mDNSWindows/mDNSWin32.h @@ -1,116 +1,19 @@ -/* +/* -*- Mode: C; tab-width: 4 -*- + * * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * http://www.apache.org/licenses/LICENSE-2.0 * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ - - Change History (most recent first): - -$Log: mDNSWin32.h,v $ -Revision 1.23 2005/10/05 20:55:14 herscher - Don't call SetLLRoute on loopback interface - -Revision 1.22 2005/03/04 22:44:53 shersche - mDNSResponder did not notice changes to DNS server config - -Revision 1.21 2005/03/03 02:29:00 shersche -Use the RegNames.h header file for registry key names - -Revision 1.20 2005/01/25 08:12:52 shersche - Enable Unicast and add Dynamic DNS support. -Bug #: 3947417 - -Revision 1.19 2004/12/15 07:34:45 shersche -Add platform support for IPv4 and IPv6 unicast sockets - -Revision 1.18 2004/10/11 21:53:15 shersche - 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(). -Bug #: 3832450 - -Revision 1.17 2004/09/17 01:08:57 cheshire -Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h - The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces - declared in that file are ONLY appropriate to single-address-space embedded applications. - For clients on general-purpose computers, the interfaces defined in dns_sd.h should be used. - -Revision 1.16 2004/08/05 05:43:01 shersche - Add HostDescriptionChangedCallback so callers can choose to handle it when mDNSWin32 core detects that the computer description string has changed -Bug #: 3751566 - -Revision 1.15 2004/07/26 05:42:50 shersche -use "Computer Description" for nicename if available, track dynamic changes to "Computer Description" - -Revision 1.14 2004/07/13 21:24:25 rpantos -Fix for . - -Revision 1.13 2004/06/24 15:23:24 shersche -Add InterfaceListChanged callback. This callback is used in Service.c to add link local routes to the routing table -Submitted by: herscher - -Revision 1.12 2004/06/18 05:22:16 rpantos -Integrate Scott's changes - -Revision 1.11 2004/01/30 02:44:32 bradley -Added support for IPv6 (v4 & v6, v4-only, v6-only, AAAA over v4, etc.). Added support for DNS-SD -InterfaceID<->Interface Index mappings. Added support for loopback usage when no other interfaces -are available. Updated unlock signaling to no longer require timenow - NextScheduledTime to be >= 0 -(it no longer is). Added unicast-capable detection to avoid using unicast when there is other mDNS -software running on the same machine. Removed unneeded sock_XtoY routines. Added support for -reporting HINFO records with the Windows and mDNSResponder version information. - -Revision 1.10 2003/10/24 23:23:02 bradley -Removed legacy port 53 support as it is no longer needed. - -Revision 1.9 2003/08/20 06:21:25 bradley -Updated to latest internal version of the mDNSWindows platform layer: Added support -for Windows CE/PocketPC 2003; re-did interface-related code to emulate getifaddrs/freeifaddrs for -restricting usage to only active, multicast-capable, and non-point-to-point interfaces and to ease -the addition of IPv6 support in the future; Changed init code to serialize thread initialization to -enable ThreadID improvement to wakeup notification; Define platform support structure locally to -allow portable mDNS_Init usage; Removed dependence on modified mDNSCore: define interface ID<->name -structures/prototypes locally; Changed to use _beginthreadex()/_endthreadex() on non-Windows CE -platforms (re-mapped to CreateThread on Window CE) to avoid a leak in the Microsoft C runtime; -Added IPv4/IPv6 string<->address conversion routines; Cleaned up some code and added HeaderDoc. - -Revision 1.8 2003/08/12 19:56:27 cheshire -Update to APSL 2.0 - -Revision 1.7 2003/07/23 02:23:01 cheshire -Updated mDNSPlatformUnlock() to work correctly, now that -"ScheduleNextTask needs to be smarter" has refined the way m->NextScheduledEvent is set - -Revision 1.6 2003/07/02 21:20:04 cheshire - Update copyright notices, etc., in source code comments - -Revision 1.5 2003/04/29 00:06:09 cheshire - mDNSWindows needs a wakeupEvent object to signal the main thread - -Revision 1.4 2003/03/22 02:57:44 cheshire -Updated mDNSWindows to use new "mDNS_Execute" model (see "mDNSCore/Implementer Notes.txt") - -Revision 1.3 2002/09/21 20:44:54 zarzycki -Added APSL info - -Revision 1.2 2002/09/20 05:55:16 bradley -Multicast DNS platform plugin for Win32 - -*/ + */ #ifndef __MDNS_WIN32__ #define __MDNS_WIN32__ @@ -122,12 +25,41 @@ Multicast DNS platform plugin for Win32 #endif #include "mDNSEmbeddedAPI.h" -#include "dDNS.h" +#include "uDNS.h" #ifdef __cplusplus extern "C" { #endif + +typedef void ( *TCPUserCallback )(); + +struct TCPSocket_struct +{ + TCPSocketFlags flags; // MUST BE FIRST FIELD -- mDNSCore expects every TCPSocket_struct to begin with TCPSocketFlags flags + SOCKET fd; + BOOL connected; + TCPUserCallback userCallback; + void * userContext; + BOOL closed; + mDNS * m; +}; + + +struct UDPSocket_struct +{ + mDNSIPPort port; // MUST BE FIRST FIELD -- mDNSCoreReceive expects every UDPSocket_struct to begin with mDNSIPPort port + mDNSAddr addr; // This is initialized by our code. If we don't get the + // dstAddr from WSARecvMsg we use this value instead. + SOCKET fd; + LPFN_WSARECVMSG recvMsgPtr; + DNSMessage packet; + struct mDNSInterfaceData *ifd; + UDPSocket *next; + mDNS *m; +}; + + //--------------------------------------------------------------------------------------------------------------------------- /*! @struct mDNSInterfaceData @@ -137,47 +69,20 @@ Multicast DNS platform plugin for Win32 typedef struct mDNSInterfaceData mDNSInterfaceData; struct mDNSInterfaceData { - mDNSInterfaceData * next; char name[ 128 ]; uint32_t index; uint32_t scopeID; - SocketRef sock; -#if( !defined( _WIN32_WCE ) ) - LPFN_WSARECVMSG wsaRecvMsgFunctionPtr; -#endif - HANDLE readPendingEvent; + struct UDPSocket_struct sock; NetworkInterfaceInfo interfaceInfo; - mDNSAddr defaultAddr; mDNSBool hostRegistered; + mDNSInterfaceData * next; }; -//--------------------------------------------------------------------------------------------------------------------------- -/*! @typedef IdleThreadCallback - @abstract mDNSWin32 core will call out through this function pointer - after calling mDNS_Execute -*/ -typedef mDNSs32 (*IdleThreadCallback)(mDNS * const inMDNS, mDNSs32 interval); //--------------------------------------------------------------------------------------------------------------------------- - -//--------------------------------------------------------------------------------------------------------------------------- -/*! @typedef InterfaceListChangedCallback - - @abstract mDNSWin32 core will call out through this function pointer - after detecting an interface list changed event +/*! @typedef ReportStatusFunc */ -typedef void (*InterfaceListChangedCallback)(mDNS * const inMDNS); -//--------------------------------------------------------------------------------------------------------------------------- - - -//--------------------------------------------------------------------------------------------------------------------------- -/*! @typedef HostDescriptionChangedCallback - - @abstract mDNSWin32 core will call out through this function pointer - after detecting that the computer description has changed -*/ -typedef void (*HostDescriptionChangedCallback)(mDNS * const inMDNS); -//--------------------------------------------------------------------------------------------------------------------------- +typedef void (*ReportStatusFunc)(int inType, const char *inFormat, ...); //--------------------------------------------------------------------------------------------------------------------------- @@ -188,41 +93,25 @@ typedef void (*HostDescriptionChangedCallback)(mDNS * const inMDNS); struct mDNS_PlatformSupport_struct { - CRITICAL_SECTION lock; - mDNSBool lockInitialized; - HANDLE cancelEvent; - HANDLE quitEvent; - HANDLE interfaceListChangedEvent; - HANDLE descChangedEvent; // Computer description changed event - HANDLE tcpipChangedEvent; // TCP/IP config changed - HANDLE ddnsChangedEvent; // DynDNS config changed - HANDLE wakeupEvent; - HANDLE initEvent; - HKEY descKey; - HKEY tcpipKey; - HKEY ddnsKey; - mStatus initStatus; + HANDLE mainThread; + HANDLE checkFileSharesTimer; + mDNSs32 checkFileSharesTimeout; + ReportStatusFunc reportStatusFunc; + time_t nextDHCPLeaseExpires; + char nbname[ 32 ]; + char nbdomain[ 32 ]; + mDNSBool smbFileSharing; + mDNSBool smbPrintSharing; + ServiceRecordSet smbSRS; + AuthRecord smbSubTypes[ 2 ]; mDNSBool registeredLoopback4; - SocketRef interfaceListChangedSocket; int interfaceCount; mDNSInterfaceData * interfaceList; mDNSInterfaceData * inactiveInterfaceList; - DWORD threadID; - IdleThreadCallback idleThreadCallback; - InterfaceListChangedCallback interfaceListChangedCallback; - HostDescriptionChangedCallback hostDescriptionChangedCallback; - SocketRef unicastSock4; - HANDLE unicastSock4ReadEvent; - mDNSAddr unicastSock4DestAddr; -#if( !defined( _WIN32_WCE ) ) - LPFN_WSARECVMSG unicastSock4RecvMsgPtr; -#endif - SocketRef unicastSock6; - HANDLE unicastSock6ReadEvent; - mDNSAddr unicastSock6DestAddr; -#if( !defined( _WIN32_WCE ) ) - LPFN_WSARECVMSG unicastSock6RecvMsgPtr; -#endif + struct UDPSocket_struct unicastSock4; + struct UDPSocket_struct unicastSock6; + DWORD osMajorVersion; + DWORD osMinorVersion; }; //--------------------------------------------------------------------------------------------------------------------------- @@ -240,6 +129,10 @@ struct ifaddrs struct sockaddr * ifa_netmask; struct sockaddr * ifa_broadaddr; struct sockaddr * ifa_dstaddr; + BYTE ifa_physaddr[6]; + BOOL ifa_dhcpEnabled; + time_t ifa_dhcpLeaseExpires; + mDNSu8 ifa_womp; void * ifa_data; struct @@ -250,30 +143,17 @@ struct ifaddrs }; -//--------------------------------------------------------------------------------------------------------------------------- -/*! @function GetWindowsVersionString - - @abstract Stores Windows version information in the string passed in (inBuffer) -*/ - -OSStatus GetWindowsVersionString( char *inBuffer, size_t inBufferSize ); - - -//--------------------------------------------------------------------------------------------------------------------------- -/*! @function getifaddrs - - @abstract Builds a linked list of interfaces. Caller must free using freeifaddrs if successful. -*/ - -int getifaddrs( struct ifaddrs **outAddrs ); - -//--------------------------------------------------------------------------------------------------------------------------- -/*! @function freeifaddrs - - @abstract Frees a linked list of interfaces built with getifaddrs. -*/ - -void freeifaddrs( struct ifaddrs *inAddrs ); +extern void InterfaceListDidChange( mDNS * const inMDNS ); +extern void ComputerDescriptionDidChange( mDNS * const inMDNS ); +extern void TCPIPConfigDidChange( mDNS * const inMDNS ); +extern void DynDNSConfigDidChange( mDNS * const inMDNS ); +extern void FileSharingDidChange( mDNS * const inMDNS ); +extern void FirewallDidChange( mDNS * const inMDNS ); +extern mStatus TCPAddSocket( mDNS * const inMDNS, TCPSocket *sock ); +extern mStatus SetupInterfaceList( mDNS * const inMDNS ); +extern mStatus TearDownInterfaceList( mDNS * const inMDNS ); +extern BOOL IsWOMPEnabled(); +extern void DispatchSocketEvents( mDNS * const inMDNS ); #ifdef __cplusplus