]> git.saurik.com Git - apple/mdnsresponder.git/commitdiff
mDNSResponder-107.6.tar.gz v107.6
authorApple <opensource@apple.com>
Thu, 7 Sep 2006 04:43:12 +0000 (04:43 +0000)
committerApple <opensource@apple.com>
Thu, 7 Sep 2006 04:43:12 +0000 (04:43 +0000)
225 files changed:
APPLE_LICENSE [deleted file]
Clients/BonjourExample/BonjourExample.cpp
Clients/BonjourExample/stdafx.cpp
Clients/BonjourExample/stdafx.h
Clients/DNSServiceBrowser.NET/AssemblyInfo.cs
Clients/DNSServiceBrowser.NET/DNSServiceBrowser.cs
Clients/DNSServiceBrowser.m
Clients/DNSServiceReg.m
Clients/ExplorerPlugin/ClassFactory.cpp
Clients/ExplorerPlugin/ClassFactory.h
Clients/ExplorerPlugin/ExplorerBar.cpp
Clients/ExplorerPlugin/ExplorerBar.h
Clients/ExplorerPlugin/ExplorerBarWindow.cpp
Clients/ExplorerPlugin/ExplorerBarWindow.h
Clients/ExplorerPlugin/ExplorerPlugin.cpp
Clients/ExplorerPlugin/ExplorerPlugin.def
Clients/ExplorerPlugin/ExplorerPlugin.h
Clients/ExplorerPlugin/LoginDialog.cpp
Clients/ExplorerPlugin/LoginDialog.h
Clients/ExplorerPlugin/Resource.h
Clients/ExplorerPlugin/StdAfx.cpp
Clients/ExplorerPlugin/StdAfx.h
Clients/Java/BrowserApp.java
Clients/Java/DNSSDUnitTest.java
Clients/Java/SimpleChat.java
Clients/Java/SwingBrowseListener.java
Clients/Java/SwingDomainListener.java
Clients/Java/SwingQueryListener.java
Clients/Java/SwingResolveListener.java
Clients/Java/nmakefile
Clients/Makefile
Clients/PrinterSetupWizard/FirstPage.cpp
Clients/PrinterSetupWizard/FirstPage.h
Clients/PrinterSetupWizard/FourthPage.cpp
Clients/PrinterSetupWizard/FourthPage.h
Clients/PrinterSetupWizard/PrinterSetupWizardApp.cpp
Clients/PrinterSetupWizard/PrinterSetupWizardApp.h
Clients/PrinterSetupWizard/PrinterSetupWizardSheet.cpp
Clients/PrinterSetupWizard/PrinterSetupWizardSheet.h
Clients/PrinterSetupWizard/SecondPage.cpp
Clients/PrinterSetupWizard/SecondPage.h
Clients/PrinterSetupWizard/ThirdPage.cpp
Clients/PrinterSetupWizard/ThirdPage.h
Clients/PrinterSetupWizard/UtilTypes.h
Clients/PrinterSetupWizard/resource.h
Clients/PrinterSetupWizard/stdafx.cpp
Clients/PrinterSetupWizard/stdafx.h
Clients/SimpleChat.NET/AssemblyInfo.cs
Clients/SimpleChat.NET/SimpleChat.cs
Clients/dns-sd.c
LICENSE [new file with mode: 0644]
Makefile
mDNSCore/DNSCommon.c
mDNSCore/DNSCommon.h
mDNSCore/DNSDigest.c
mDNSCore/mDNS.c
mDNSCore/mDNSDebug.h
mDNSCore/mDNSEmbeddedAPI.h
mDNSCore/uDNS.c
mDNSCore/uDNS.h
mDNSMacOS9/CarbonResource.r
mDNSMacOS9/Mac OS Test Responder.c
mDNSMacOS9/Mac OS Test Searcher.c
mDNSMacOS9/Responder.c
mDNSMacOS9/Searcher.c
mDNSMacOS9/SubTypeTester.c
mDNSMacOS9/mDNSLibrary.c
mDNSMacOS9/mDNSLibraryLoader.c
mDNSMacOS9/mDNSLibraryResources.r
mDNSMacOS9/mDNSMacOS9.c
mDNSMacOS9/mDNSMacOS9.h
mDNSMacOS9/mDNSPrefix.h
mDNSMacOSX/DNSServiceDiscoveryDefines.h
mDNSMacOSX/DNSServiceDiscoveryReply.defs
mDNSMacOSX/DNSServiceDiscoveryRequest.defs
mDNSMacOSX/LegacyNATTraversal.c
mDNSMacOSX/PreferencePane/BonjourPref.icns
mDNSMacOSX/PreferencePane/ConfigurationRights.h
mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.h
mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.m
mDNSMacOSX/PreferencePane/English.lproj/InfoPlist.strings
mDNSMacOSX/PreferencePane/PrivilegedOperations.c
mDNSMacOSX/PreferencePane/PrivilegedOperations.h
mDNSMacOSX/PreferencePane/ddnswriteconfig.m
mDNSMacOSX/PreferencePane/installtool
mDNSMacOSX/SamplemDNSClient.c
mDNSMacOSX/daemon.c
mDNSMacOSX/mDNSMacOSX.c
mDNSMacOSX/mDNSMacOSX.h
mDNSMacOSX/mDNSMacOSXPuma.c
mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj
mDNSPosix/Client.c
mDNSPosix/ExampleClientApp.c
mDNSPosix/ExampleClientApp.h
mDNSPosix/Identify.c
mDNSPosix/Makefile
mDNSPosix/NetMonitor.c
mDNSPosix/PosixDaemon.c
mDNSPosix/ProxyResponder.c
mDNSPosix/ReadMe.txt
mDNSPosix/Responder.c
mDNSPosix/dnsextd.c
mDNSPosix/mDNSPosix.c
mDNSPosix/mDNSPosix.h
mDNSPosix/mDNSUNP.c
mDNSPosix/mDNSUNP.h
mDNSPosix/mdnsd.sh
mDNSPosix/nss_mdns.c
mDNSPosix/nss_mdns.conf
mDNSPosix/parselog.py
mDNSShared/CommonServices.h [new file with mode: 0644]
mDNSShared/DebugServices.c [new file with mode: 0644]
mDNSShared/DebugServices.h [new file with mode: 0644]
mDNSShared/GenLinkedList.c
mDNSShared/GenLinkedList.h
mDNSShared/Java/BaseListener.java
mDNSShared/Java/BrowseListener.java
mDNSShared/Java/DNSRecord.java
mDNSShared/Java/DNSSD.java
mDNSShared/Java/DNSSDException.java
mDNSShared/Java/DNSSDRecordRegistrar.java [new file with mode: 0644]
mDNSShared/Java/DNSSDRegistration.java
mDNSShared/Java/DNSSDService.java
mDNSShared/Java/DomainListener.java
mDNSShared/Java/JNISupport.c
mDNSShared/Java/QueryListener.java
mDNSShared/Java/RegisterListener.java
mDNSShared/Java/RegisterRecordListener.java [new file with mode: 0644]
mDNSShared/Java/ResolveListener.java
mDNSShared/Java/TXTRecord.java
mDNSShared/PlatformCommon.c
mDNSShared/PlatformCommon.h
mDNSShared/dns-sd.1
mDNSShared/dns_sd.h
mDNSShared/dnsextd.8
mDNSShared/dnsextd.c [new file with mode: 0644]
mDNSShared/dnssd_clientlib.c
mDNSShared/dnssd_clientshim.c
mDNSShared/dnssd_clientstub.c
mDNSShared/dnssd_ipc.c
mDNSShared/dnssd_ipc.h
mDNSShared/mDNS.1
mDNSShared/mDNSDebug.c
mDNSShared/mDNSResponder.8
mDNSShared/uds_daemon.c
mDNSShared/uds_daemon.h
mDNSVxWorks/mDNSVxWorks.c
mDNSVxWorks/mDNSVxWorks.h
mDNSVxWorks/mDNSVxWorksIPv4Only.c
mDNSVxWorks/mDNSVxWorksIPv4Only.h
mDNSWindows/CommonServices.h
mDNSWindows/ControlPanel/ConfigDialog.cpp
mDNSWindows/ControlPanel/ConfigDialog.h
mDNSWindows/ControlPanel/ConfigPropertySheet.cpp
mDNSWindows/ControlPanel/ConfigPropertySheet.h
mDNSWindows/ControlPanel/ControlPanel.cpp
mDNSWindows/ControlPanel/ControlPanel.def
mDNSWindows/ControlPanel/ControlPanel.h
mDNSWindows/ControlPanel/FirstPage.cpp
mDNSWindows/ControlPanel/FirstPage.h
mDNSWindows/ControlPanel/SecondPage.cpp
mDNSWindows/ControlPanel/SecondPage.h
mDNSWindows/ControlPanel/SharedSecret.cpp
mDNSWindows/ControlPanel/SharedSecret.h
mDNSWindows/ControlPanel/ThirdPage.cpp
mDNSWindows/ControlPanel/ThirdPage.h
mDNSWindows/ControlPanel/stdafx.cpp
mDNSWindows/ControlPanel/stdafx.h
mDNSWindows/DLL.NET/AssemblyInfo.cpp
mDNSWindows/DLL.NET/PString.h
mDNSWindows/DLL.NET/Stdafx.cpp
mDNSWindows/DLL.NET/Stdafx.h
mDNSWindows/DLL.NET/dnssd_NET.cpp
mDNSWindows/DLL.NET/dnssd_NET.h
mDNSWindows/DLL/dllmain.c
mDNSWindows/DLL/dnssd.def
mDNSWindows/DNSServiceBrowser/Windows/Resources/Application.rc2
mDNSWindows/DNSServiceBrowser/Windows/Sources/AboutDialog.cpp
mDNSWindows/DNSServiceBrowser/Windows/Sources/AboutDialog.h
mDNSWindows/DNSServiceBrowser/Windows/Sources/Application.cpp
mDNSWindows/DNSServiceBrowser/Windows/Sources/Application.h
mDNSWindows/DNSServiceBrowser/Windows/Sources/ChooserDialog.cpp
mDNSWindows/DNSServiceBrowser/Windows/Sources/ChooserDialog.h
mDNSWindows/DNSServiceBrowser/Windows/Sources/LoginDialog.cpp
mDNSWindows/DNSServiceBrowser/Windows/Sources/LoginDialog.h
mDNSWindows/DNSServiceBrowser/Windows/Sources/StdAfx.cpp
mDNSWindows/DNSServiceBrowser/Windows/Sources/StdAfx.h
mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/Application.cpp
mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/Application.h
mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/BrowserDialog.cpp
mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/BrowserDialog.h
mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/StdAfx.cpp
mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/StdAfx.h
mDNSWindows/DNSServiceTest/Tool.c
mDNSWindows/DNSServiceTest/ToolPrefixWindows.h
mDNSWindows/DNSServiceTest/ToolPrefixWindowsDebug.h
mDNSWindows/DNSServices/DNSServiceDiscovery.c
mDNSWindows/DNSServices/DNSServiceDiscovery.h
mDNSWindows/DNSServices/DNSServices.c
mDNSWindows/DNSServices/DNSServices.h
mDNSWindows/DebugServices.c
mDNSWindows/DebugServices.h
mDNSWindows/Java/jdns_sd.rc
mDNSWindows/Java/makefile
mDNSWindows/NSPTool/NSPTool.c
mDNSWindows/NSPTool/Prefix.h
mDNSWindows/RegNames.h
mDNSWindows/SystemService/Firewall.cpp
mDNSWindows/SystemService/Firewall.h
mDNSWindows/SystemService/Prefix.h
mDNSWindows/SystemService/Service.c
mDNSWindows/VPCDetect.cpp
mDNSWindows/VPCDetect.h
mDNSWindows/WinServices.cpp
mDNSWindows/WinServices.h
mDNSWindows/WinVersRes.h
mDNSWindows/dDNS.c
mDNSWindows/dDNS.h
mDNSWindows/isocode.h
mDNSWindows/loclibrary.c
mDNSWindows/loclibrary.h
mDNSWindows/mDNSWin32.c
mDNSWindows/mDNSWin32.h
mDNSWindows/mdnsNSP/mdnsNSP.c
mDNSWindows/mdnsNSP/mdnsNSP.def

diff --git a/APPLE_LICENSE b/APPLE_LICENSE
deleted file mode 100644 (file)
index fe81a60..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-APPLE PUBLIC SOURCE LICENSE
-Version 2.0 - August 6, 2003
-
-Please read this License carefully before downloading this software.
-By downloading or using this software, you are agreeing to be bound by
-the terms of this License. If you do not or cannot agree to the terms
-of this License, please do not download or use the software.
-
-1. General; Definitions. This License applies to any program or other
-work which Apple Computer, Inc. ("Apple") makes publicly available and
-which contains a notice placed by Apple identifying such program or
-work as "Original Code" and stating that it is subject to the terms of
-this Apple Public Source License version 2.0 ("License"). As used in
-this License:
-
-1.1 "Applicable Patent Rights" mean: (a) in the case where Apple is
-the grantor of rights, (i) claims of patents that are now or hereafter
-acquired, owned by or assigned to Apple and (ii) that cover subject
-matter contained in the Original Code, but only to the extent
-necessary to use, reproduce and/or distribute the Original Code
-without infringement; and (b) in the case where You are the grantor of
-rights, (i) claims of patents that are now or hereafter acquired,
-owned by or assigned to You and (ii) that cover subject matter in Your
-Modifications, taken alone or in combination with Original Code.
-
-1.2 "Contributor" means any person or entity that creates or
-contributes to the creation of Modifications.
-
-1.3 "Covered Code" means the Original Code, Modifications, the
-combination of Original Code and any Modifications, and/or any
-respective portions thereof.
-
-1.4 "Externally Deploy" means: (a) to sublicense, distribute or
-otherwise make Covered Code available, directly or indirectly, to
-anyone other than You; and/or (b) to use Covered Code, alone or as
-part of a Larger Work, in any way to provide a service, including but
-not limited to delivery of content, through electronic communication
-with a client other than You.
-
-1.5 "Larger Work" means a work which combines Covered Code or portions
-thereof with code not governed by the terms of this License.
-
-1.6 "Modifications" mean any addition to, deletion from, and/or change
-to, the substance and/or structure of the Original Code, any previous
-Modifications, the combination of Original Code and any previous
-Modifications, and/or any respective portions thereof. When code is
-released as a series of files, a Modification is: (a) any addition to
-or deletion from the contents of a file containing Covered Code;
-and/or (b) any new file or other representation of computer program
-statements that contains any part of Covered Code.
-
-1.7 "Original Code" means (a) the Source Code of a program or other
-work as originally made available by Apple under this License,
-including the Source Code of any updates or upgrades to such programs
-or works made available by Apple under this License, and that has been
-expressly identified by Apple as such in the header file(s) of such
-work; and (b) the object code compiled from such Source Code and
-originally made available by Apple under this License.
-
-1.8 "Source Code" means the human readable form of a program or other
-work that is suitable for making modifications to it, including all
-modules it contains, plus any associated interface definition files,
-scripts used to control compilation and installation of an executable
-(object code).
-
-1.9 "You" or "Your" means an individual or a legal entity exercising
-rights under this License. For legal entities, "You" or "Your"
-includes any entity which controls, is controlled by, or is under
-common control with, You, where "control" means (a) the power, direct
-or indirect, to cause the direction or management of such entity,
-whether by contract or otherwise, or (b) ownership of fifty percent
-(50%) or more of the outstanding shares or beneficial ownership of
-such entity.
-
-2. Permitted Uses; Conditions & Restrictions. Subject to the terms
-and conditions of this License, Apple hereby grants You, effective on
-the date You accept this License and download the Original Code, a
-world-wide, royalty-free, non-exclusive license, to the extent of
-Apple's Applicable Patent Rights and copyrights covering the Original
-Code, to do the following:
-
-2.1 Unmodified Code. You may use, reproduce, display, perform,
-internally distribute within Your organization, and Externally Deploy
-verbatim, unmodified copies of the Original Code, for commercial or
-non-commercial purposes, provided that in each instance:
-
-(a) You must retain and reproduce in all copies of Original Code the
-copyright and other proprietary notices and disclaimers of Apple as
-they appear in the Original Code, and keep intact all notices in the
-Original Code that refer to this License; and
-
-(b) You must include a copy of this License with every copy of Source
-Code of Covered Code and documentation You distribute or Externally
-Deploy, and You may not offer or impose any terms on such Source Code
-that alter or restrict this License or the recipients' rights
-hereunder, except as permitted under Section 6.
-
-2.2 Modified Code. You may modify Covered Code and use, reproduce,
-display, perform, internally distribute within Your organization, and
-Externally Deploy Your Modifications and Covered Code, for commercial
-or non-commercial purposes, provided that in each instance You also
-meet all of these conditions:
-
-(a) You must satisfy all the conditions of Section 2.1 with respect to
-the Source Code of the Covered Code;
-
-(b) You must duplicate, to the extent it does not already exist, the
-notice in Exhibit A in each file of the Source Code of all Your
-Modifications, and cause the modified files to carry prominent notices
-stating that You changed the files and the date of any change; and
-
-(c) If You Externally Deploy Your Modifications, You must make
-Source Code of all Your Externally Deployed Modifications either
-available to those to whom You have Externally Deployed Your
-Modifications, or publicly available. Source Code of Your Externally
-Deployed Modifications must be released under the terms set forth in
-this License, including the license grants set forth in Section 3
-below, for as long as you Externally Deploy the Covered Code or twelve
-(12) months from the date of initial External Deployment, whichever is
-longer. You should preferably distribute the Source Code of Your
-Externally Deployed Modifications electronically (e.g. download from a
-web site).
-
-2.3 Distribution of Executable Versions. In addition, if You
-Externally Deploy Covered Code (Original Code and/or Modifications) in
-object code, executable form only, You must include a prominent
-notice, in the code itself as well as in related documentation,
-stating that Source Code of the Covered Code is available under the
-terms of this License with information on how and where to obtain such
-Source Code.
-
-2.4 Third Party Rights. You expressly acknowledge and agree that
-although Apple and each Contributor grants the licenses to their
-respective portions of the Covered Code set forth herein, no
-assurances are provided by Apple or any Contributor that the Covered
-Code does not infringe the patent or other intellectual property
-rights of any other entity. Apple and each Contributor disclaim any
-liability to You for claims brought by any other entity based on
-infringement of intellectual property rights or otherwise. As a
-condition to exercising the rights and licenses granted hereunder, You
-hereby assume sole responsibility to secure any other intellectual
-property rights needed, if any. For example, if a third party patent
-license is required to allow You to distribute the Covered Code, it is
-Your responsibility to acquire that license before distributing the
-Covered Code.
-
-3. Your Grants. In consideration of, and as a condition to, the
-licenses granted to You under this License, You hereby grant to any
-person or entity receiving or distributing Covered Code under this
-License a non-exclusive, royalty-free, perpetual, irrevocable license,
-under Your Applicable Patent Rights and other intellectual property
-rights (other than patent) owned or controlled by You, to use,
-reproduce, display, perform, modify, sublicense, distribute and
-Externally Deploy Your Modifications of the same scope and extent as
-Apple's licenses under Sections 2.1 and 2.2 above.
-
-4. Larger Works. You may create a Larger Work by combining Covered
-Code with other code not governed by the terms of this License and
-distribute the Larger Work as a single product. In each such instance,
-You must make sure the requirements of this License are fulfilled for
-the Covered Code or any portion thereof.
-
-5. Limitations on Patent License. Except as expressly stated in
-Section 2, no other patent rights, express or implied, are granted by
-Apple herein. Modifications and/or Larger Works may require additional
-patent licenses from Apple which Apple may grant in its sole
-discretion.
-
-6. Additional Terms. You may choose to offer, and to charge a fee for,
-warranty, support, indemnity or liability obligations and/or other
-rights consistent with the scope of the license granted herein
-("Additional Terms") to one or more recipients of Covered Code.
-However, You may do so only on Your own behalf and as Your sole
-responsibility, and not on behalf of Apple or any Contributor. You
-must obtain the recipient's agreement that any such Additional Terms
-are offered by You alone, and You hereby agree to indemnify, defend
-and hold Apple and every Contributor harmless for any liability
-incurred by or claims asserted against Apple or such Contributor by
-reason of any such Additional Terms.
-
-7. Versions of the License. Apple may publish revised and/or new
-versions of this License from time to time. Each version will be given
-a distinguishing version number. Once Original Code has been published
-under a particular version of this License, You may continue to use it
-under the terms of that version. You may also choose to use such
-Original Code under the terms of any subsequent version of this
-License published by Apple. No one other than Apple has the right to
-modify the terms applicable to Covered Code created under this
-License.
-
-8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in
-part pre-release, untested, or not fully tested works. The Covered
-Code may contain errors that could cause failures or loss of data, and
-may be incomplete or contain inaccuracies. You expressly acknowledge
-and agree that use of the Covered Code, or any portion thereof, is at
-Your sole and entire risk. THE COVERED CODE IS PROVIDED "AS IS" AND
-WITHOUT WARRANTY, UPGRADES OR SUPPORT OF ANY KIND AND APPLE AND
-APPLE'S LICENSOR(S) (COLLECTIVELY REFERRED TO AS "APPLE" FOR THE
-PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS EXPRESSLY DISCLAIM
-ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED, INCLUDING, BUT
-NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
-MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR
-PURPOSE, OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD
-PARTY RIGHTS. APPLE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST
-INTERFERENCE WITH YOUR ENJOYMENT OF THE COVERED CODE, THAT THE
-FUNCTIONS CONTAINED IN THE COVERED CODE WILL MEET YOUR REQUIREMENTS,
-THAT THE OPERATION OF THE COVERED CODE WILL BE UNINTERRUPTED OR
-ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE CORRECTED. NO
-ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY APPLE, AN APPLE
-AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY.
-You acknowledge that the Covered Code is not intended for use in the
-operation of nuclear facilities, aircraft navigation, communication
-systems, or air traffic control machines in which case the failure of
-the Covered Code could lead to death, personal injury, or severe
-physical or environmental damage.
-
-9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO
-EVENT SHALL APPLE OR ANY CONTRIBUTOR BE LIABLE FOR ANY INCIDENTAL,
-SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATING
-TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR
-ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY,
-TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF
-APPLE OR SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES AND NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY
-REMEDY. SOME JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF
-INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY
-TO YOU. In no event shall Apple's total liability to You for all
-damages (other than as may be required by applicable law) under this
-License exceed the amount of fifty dollars ($50.00).
-
-10. Trademarks. This License does not grant any rights to use the
-trademarks or trade names "Apple", "Apple Computer", "Mac", "Mac OS",
-"QuickTime", "QuickTime Streaming Server" or any other trademarks,
-service marks, logos or trade names belonging to Apple (collectively
-"Apple Marks") or to any trademark, service mark, logo or trade name
-belonging to any Contributor. You agree not to use any Apple Marks in
-or as part of the name of products derived from the Original Code or
-to endorse or promote products derived from the Original Code other
-than as expressly permitted by and in strict compliance at all times
-with Apple's third party trademark usage guidelines which are posted
-at http://www.apple.com/legal/guidelinesfor3rdparties.html.
-
-11. Ownership. Subject to the licenses granted under this License,
-each Contributor retains all rights, title and interest in and to any
-Modifications made by such Contributor. Apple retains all rights,
-title and interest in and to the Original Code and any Modifications
-made by or on behalf of Apple ("Apple Modifications"), and such Apple
-Modifications will not be automatically subject to this License. Apple
-may, at its sole discretion, choose to license such Apple
-Modifications under this License, or on different terms from those
-contained in this License or may choose not to license them at all.
-
-12. Termination.
-
-12.1 Termination. This License and the rights granted hereunder will
-terminate:
-
-(a) automatically without notice from Apple if You fail to comply with
-any term(s) of this License and fail to cure such breach within 30
-days of becoming aware of such breach;
-
-(b) immediately in the event of the circumstances described in Section
-13.5(b); or
-
-(c) automatically without notice from Apple if You, at any time during
-the term of this License, commence an action for patent infringement
-against Apple; provided that Apple did not first commence
-an action for patent infringement against You in that instance.
-
-12.2 Effect of Termination. Upon termination, You agree to immediately
-stop any further use, reproduction, modification, sublicensing and
-distribution of the Covered Code. All sublicenses to the Covered Code
-which have been properly granted prior to termination shall survive
-any termination of this License. Provisions which, by their nature,
-should remain in effect beyond the termination of this License shall
-survive, including but not limited to Sections 3, 5, 8, 9, 10, 11,
-12.2 and 13. No party will be liable to any other for compensation,
-indemnity or damages of any sort solely as a result of terminating
-this License in accordance with its terms, and termination of this
-License will be without prejudice to any other right or remedy of
-any party.
-
-13. Miscellaneous.
-
-13.1 Government End Users. The Covered Code is a "commercial item" as
-defined in FAR 2.101. Government software and technical data rights in
-the Covered Code include only those rights customarily provided to the
-public as defined in this License. This customary commercial license
-in technical data and software is provided in accordance with FAR
-12.211 (Technical Data) and 12.212 (Computer Software) and, for
-Department of Defense purchases, DFAR 252.227-7015 (Technical Data --
-Commercial Items) and 227.7202-3 (Rights in Commercial Computer
-Software or Computer Software Documentation). Accordingly, all U.S.
-Government End Users acquire Covered Code with only those rights set
-forth herein.
-
-13.2 Relationship of Parties. This License will not be construed as
-creating an agency, partnership, joint venture or any other form of
-legal association between or among You, Apple or any Contributor, and
-You will not represent to the contrary, whether expressly, by
-implication, appearance or otherwise.
-
-13.3 Independent Development. Nothing in this License will impair
-Apple's right to acquire, license, develop, have others develop for
-it, market and/or distribute technology or products that perform the
-same or similar functions as, or otherwise compete with,
-Modifications, Larger Works, technology or products that You may
-develop, produce, market or distribute.
-
-13.4 Waiver; Construction. Failure by Apple or any Contributor to
-enforce any provision of this License will not be deemed a waiver of
-future enforcement of that or any other provision. Any law or
-regulation which provides that the language of a contract shall be
-construed against the drafter will not apply to this License.
-
-13.5 Severability. (a) If for any reason a court of competent
-jurisdiction finds any provision of this License, or portion thereof,
-to be unenforceable, that provision of the License will be enforced to
-the maximum extent permissible so as to effect the economic benefits
-and intent of the parties, and the remainder of this License will
-continue in full force and effect. (b) Notwithstanding the foregoing,
-if applicable law prohibits or restricts You from fully and/or
-specifically complying with Sections 2 and/or 3 or prevents the
-enforceability of either of those Sections, this License will
-immediately terminate and You must immediately discontinue any use of
-the Covered Code and destroy all copies of it that are in your
-possession or control.
-
-13.6 Dispute Resolution. Any litigation or other dispute resolution
-between You and Apple relating to this License shall take place in the
-Northern District of California, and You and Apple hereby consent to
-the personal jurisdiction of, and venue in, the state and federal
-courts within that District with respect to this License. The
-application of the United Nations Convention on Contracts for the
-International Sale of Goods is expressly excluded.
-
-13.7 Entire Agreement; Governing Law. This License constitutes the
-entire agreement between the parties with respect to the subject
-matter hereof. This License shall be governed by the laws of the
-United States and the State of California, except that body of
-California law concerning conflicts of law.
-
-Where You are located in the province of Quebec, Canada, the following
-clause applies: The parties hereby confirm that they have requested
-that this License and all related documents be drafted in English. Les
-parties ont exige que le present contrat et tous les documents
-connexes soient rediges en anglais.
-
-EXHIBIT A.
-
-"Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
-Reserved.
-
-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.
-
-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
-limitations under the License."
index ec448f49fba0173e6b0a9eb1fc05823957a27166..ff50a3981b2ac492e25d036c3a950838a68d7cde 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2005 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: BonjourExample.cpp,v $
+Revision 1.2  2006/08/14 23:23:57  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2005/05/20 22:01:01  bradley
 Bonjour for Windows example code to browse for HTTP services and deliver via Window messages.
 
index 2b2483e08b117288a55cd9e9528a3de9f2a3f6a6..c6899cd105fbf5f750c8f2eaba950b0894d10ee3 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2005 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: stdafx.cpp,v $
+Revision 1.2  2006/08/14 23:23:57  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2005/05/20 22:01:02  bradley
 Bonjour for Windows example code to browse for HTTP services and deliver via Window messages.
 
index 6ded04030fccf0819d7518c695fc635c4f06c820..461d1193a9c8a898ff7191ffdf30b3f2ae718a6b 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2005 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: stdafx.h,v $
+Revision 1.2  2006/08/14 23:23:57  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2005/05/20 22:01:02  bradley
 Bonjour for Windows example code to browse for HTTP services and deliver via Window messages.
 
index 793362b985ab9cc56cafdabce1403299fc813813..588f438d4c5fe8659711d865eea603e51bf5bacc 100755 (executable)
@@ -1,28 +1,25 @@
-/*\r
+/* -*- Mode: C; tab-width: 4 -*-\r
+ *\r
  * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.\r
  *\r
- * @APPLE_LICENSE_HEADER_START@\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
  * \r
- * This file contains Original Code and/or Modifications of Original Code\r
- * as defined in and that are subject to the Apple Public Source License\r
- * Version 2.0 (the 'License'). You may not use this file except in\r
- * compliance with the License. Please obtain a copy of the License at\r
- * http://www.opensource.apple.com/apsl/ and read it before using this\r
- * file.\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
  * \r
- * The Original Code and all software distributed under the License are\r
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER\r
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,\r
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.\r
- * Please see the License for the specific language governing rights and\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * @APPLE_LICENSE_HEADER_END@\r
 \r
     Change History (most recent first):\r
     \r
 $Log: AssemblyInfo.cs,v $
+Revision 1.2  2006/08/14 23:23:58  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/07/19 07:54:24  shersche
 Initial revision
 \r
index f2cf813fb5fd91b9b4f19b0900eb5b64ac3e4490..e279d184b21131d4afd52a9454f2e1ad40bb9309 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: DNSServiceBrowser.cs,v $
+Revision 1.7  2006/08/14 23:23:58  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.6  2005/02/10 22:35:06  cheshire
 <rdar://problem/3727944> Update name
 
index da427802b04539fa1cf4807622c6a3a95765db51..2394a6aa9c5b363f0258331a41e08f81393f4fcc 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: DNSServiceBrowser.m,v $
+Revision 1.31  2006/08/14 23:23:55  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.30  2005/01/27 17:46:16  cheshire
 Added comment
 
index c4a3ee777b442a4e4e7f4c40bf2f79902ad4cac9..49e0c36ddb942a2667dc70e9baf7b1279fed6cc4 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: DNSServiceReg.m,v $
+Revision 1.16  2006/08/14 23:23:55  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.15  2004/06/05 02:01:08  cheshire
 Move DNSServiceRegistration from mDNSMacOSX directory to Clients directory
 
index b4e06c6180b5303f7bd7e2649144e9af7a20953b..f77e1826a2cbc583487ecc0ce6542dbe54f72087 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: ClassFactory.cpp,v $
+Revision 1.3  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:21  rpantos
 Fix for <rdar://problem/3701120>.
 
index 76e4b5ed8a4cfedda5a21d1a434de9a681173318..f5fe9d59c148df1dcff33cddb50c37a403d3d70c 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: ClassFactory.h,v $
+Revision 1.3  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:21  rpantos
 Fix for <rdar://problem/3701120>.
 
index 1c71c9bc59c9e4cd31eebab8b970bd97e0744628..f09d9833492ca27bf8ff2f08e0b41a18115dbfe1 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: ExplorerBar.cpp,v $
+Revision 1.4  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2004/07/26 05:44:08  shersche
 remove extraneous debug statement
 
index fe58176f081b5494e12d76ae9c013270400671d3..5af86eb08646a2862fab43c1e1cd539170a4ef75 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: ExplorerBar.h,v $
+Revision 1.3  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:21  rpantos
 Fix for <rdar://problem/3701120>.
 
index d4ea5c1d6849c8b6a3465f7d7f2b74ca7e151170..88f4858f86ad220c03660ec29ce065a309eef52b 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: ExplorerBarWindow.cpp,v $
+Revision 1.22  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.21  2005/04/06 01:13:07  shersche
 <rdar://problem/4066195> Use the product icon instead of globe icon for 'About' link.
 
index deade955257ee9b59c47938ee6faba7aeff62bef..f035872d880c63b52b7a45a53cd77113e5008004 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: ExplorerBarWindow.h,v $
+Revision 1.8  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.7  2005/02/25 19:57:30  shersche
 <rdar://problem/4023323> Remove FTP browsing from plugin
 
index 34b981e687175033607784a7f66711b4ba6ecbcb..c2c661b0a849f8ec8db36c68713d8858430d5eed 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: ExplorerPlugin.cpp,v $
+Revision 1.9  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.8  2005/06/30 18:01:54  shersche
 <rdar://problem/4130635> Cause IE to rebuild cache so we don't have to reboot following an install.
 
index e82518052ecb1fd3670b4980e9eb7b17ac104cd3..acef773ff9b3443c6cf5201908506700f8b42e91 100644 (file)
@@ -1,28 +1,25 @@
 ;
+;
 ; Copyright (c) 2003-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: ExplorerPlugin.def,v $
+; Revision 1.3  2006/08/14 23:24:00  cheshire
+; Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+;
 ; Revision 1.2  2004/07/13 21:24:21  rpantos
 ; Fix for <rdar://problem/3701120>.
 ;
index 40a709a51315b4e8a41dfd13bfc452b05cfcd116..d14edd3fb66fa7d06133a000c5146b64faff7c30 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: ExplorerPlugin.h,v $
+Revision 1.4  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/01/25 18:35:38  shersche
 Declare APIs for obtaining handles to resource modules
 
index ccee81c153e7706e56345f35a381da93a34d9a54..c2afe223d4014d67e90fa07fc9cd8991e97c7b6c 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: LoginDialog.cpp,v $
+Revision 1.3  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:21  rpantos
 Fix for <rdar://problem/3701120>.
 
index a89c3a6eb72d939005de715177d789dfa63bc73a..0f7bee6725315d90b0749fff4dbef0a7bf55e92b 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: LoginDialog.h,v $
+Revision 1.3  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:21  rpantos
 Fix for <rdar://problem/3701120>.
 
index e6a7b320cab093509e0401cb6c6e5a900a770d83..9b1f0abe49bc84a423a0f1212567b0769891c957 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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):
     
index b97d8648f695dcf2ef62076be07cf232feeb4f2b..1d644951dc0988733c544bdfcb3f925b29f62843 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: StdAfx.cpp,v $
+Revision 1.3  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:21  rpantos
 Fix for <rdar://problem/3701120>.
 
index 407ff3c0a11a390d5a0f81dc00b329103a31cf2a..7976129032d14d1a6c5765adb07abc311dbba9c8 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: StdAfx.h,v $
+Revision 1.4  2006/08/14 23:24:00  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/10/19 19:50:34  herscher
 Workaround a bug in the latest Microsoft Platform SDK when compiling C++ files that include (directly or indirectly) <WspiApi.h>
 
index 0b55fa5d2b936949ae4f139c44192fcf80e95610..cbdd200713b7ef22808025840e82a712054eaddb 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
  * Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
index 786cab739f20f3b1e709bb88bf53f31dc3b88159..121ff61acf035cd180388f13b7920743e4ba13e1 100644 (file)
@@ -1,28 +1,28 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: DNSSDUnitTest.java,v $
+Revision 1.6  2006/08/14 23:24:07  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.5  2006/06/20 23:01:58  rpantos
+<rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
+
 Revision 1.4  2004/08/04 01:07:43  rpantos
 Update unit test for <rdar://problems/3731579&3731582>.
 
@@ -107,6 +107,7 @@ class       DNSSDUnitTest
                fRegTest = new RegTest();
                new BrowseTest();
                new DomainTest();
+               new RegistrarTest();
                
                this.waitForEnd();
        }
@@ -325,3 +326,30 @@ class      QueryTest extends TermReporter implements QueryListener
        }
 }
 
+class  RegistrarTest extends TermReporter implements RegisterRecordListener
+{
+       public          RegistrarTest()
+       {
+               try {
+                       byte[]  kResponsiblePerson = { 'g','r','o','v','e','r' };
+                       fRegistrar = DNSSD.createRecordRegistrar( this);
+                       fRegistrar.registerRecord( DNSSD.UNIQUE, 0,
+                                       "test.registrartest.local", 17 /*ns_t_rp*/, 1, kResponsiblePerson, 3600);
+               } catch( Exception e) { e.printStackTrace(); }
+       }
+
+       public void     recordRegistered( DNSRecord record, int flags)
+       {
+               String s = "RegistrarTest result flags:" + String.valueOf( flags);
+               System.out.println( s);
+
+               try {
+                       byte[]  kResponsiblePerson = { 'e','l','m','o' };
+                       record.update( 0, kResponsiblePerson, 3600);
+                       record.remove();
+               } catch( Exception e) { e.printStackTrace(); }
+       }
+
+       protected DNSSDRecordRegistrar  fRegistrar;
+}
+
index 745b9a0dfe4b17389cb6ca89df03300ee87cee67..a1fee5c018ead48351b4e9ee94d53bf6a9d3e8e1 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
  * Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
index 78bfe4f4b9c1e60940c71dc710deb0403668e3c6..db971b2b43326c5b4cd7a8ce4504c7d59d23ad99 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
  * Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
index c6c380b9c4278865f14d0ac4197fb9bf0d2b0e7a..b67313b7bca37dcefccea5932d96b3b8a93c45a2 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
  * Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
index 5f2de1d2d334a86b62c43b88cdfce4ff66d483b5..fcac75b832d47205800fd139032745a46d4f0d64 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
  * Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
index f2be4b0255a2f2960408895cea1a53cffb967c05..19c17996f81cacea33a0cda63577bf290db66d22 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
  * Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
index 4c016332c926e5eb3ed764af990655e7c54df527..9b08ccbba0bd159dd30d0fdd08167dd52b55cba2 100644 (file)
@@ -1,24 +1,18 @@
+# -*- 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@
-#
 #
 # This Makefile builds .jar files for the DNS-SD Java sample apps.
 # You must have the Java support installed.
index b79bf6f8875c1c38cb9ca671612e73256045946a..c6c2ed2ee3d4bb961262ad560632d7fe0fad5422 100755 (executable)
@@ -1,25 +1,23 @@
+# -*- 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@
 #
 # $Log: Makefile,v $
+# Revision 1.8  2006/08/14 23:23:55  cheshire
+# Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+#
 # Revision 1.7  2006/01/06 01:06:17  cheshire
 # <rdar://problem/3978979> Compile library and client programs in one pass
 #
index b5131dac93c425425d112f3dbb9006d87639e425..8d4b881ff65f4cc1c93cd19b0b26d54d6f625252 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: FirstPage.cpp,v $
+Revision 1.6  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  2005/07/07 17:53:20  shersche
 Fix problems associated with the CUPS printer workaround fix.
 
index a798eb09c6656016de4236b592a0cd9c08c10ca8..c7c96f421478336d162bff9cc817018138c7c31b 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: FirstPage.h,v $
+Revision 1.3  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/07/07 17:53:20  shersche
 Fix problems associated with the CUPS printer workaround fix.
 
index 876e28ba98382b75b9d172935e943c2dbfb25461..66e514572b1060e08be662d062dcb890030f908d 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: FourthPage.cpp,v $
+Revision 1.8  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.7  2005/07/07 17:53:20  shersche
 Fix problems associated with the CUPS printer workaround fix.
 
index fca8cd1f2aee5f36ecefdf92e0afe7030e94dfae..fc7205958e34bb3d079a096bf591dd9ff8d8b022 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: FourthPage.h,v $
+Revision 1.4  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/07/07 17:53:20  shersche
 Fix problems associated with the CUPS printer workaround fix.
 
index 7b6544313604e74af47fcd109d2d7de20ca8349a..e9e255f41080145e1d3ddbde06fd6e11e32184f2 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: PrinterSetupWizardApp.cpp,v $
+Revision 1.9  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.8  2005/04/13 17:43:39  shersche
 <rdar://problem/4081448> Change "PrinterWizard.dll" to "PrinterWizardResources.dll"
 
index 871de5d447c170c46def80a1420c4eb0d776b172..08a182945290ea1698368983a01e930c81fd0ecc 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: PrinterSetupWizardApp.h,v $
+Revision 1.3  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/01/25 08:52:55  shersche
 <rdar://problem/3911084> Add APIs to return localizable and non-localizable resource DLL handles
 Bug #: 3911084
index 6c0c9f3739a7ae467fe292baa1f9b390afa7d2b4..e912716b3a2e0284a0f2976ac8c7ec086c415e3b 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: PrinterSetupWizardSheet.cpp,v $
+Revision 1.35  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.34  2005/10/05 17:32:51  herscher
 <rdar://problem/4141221> Use a case insensitive compare operation to check whether a printer with the same name has already been installed.
 
index 63dc0c0ab0bb5fbb87d25e6d14dba90463f9676b..b9cc5ff1e3c5f1eadf803a9b0dcc2b4af9e63f28 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: PrinterSetupWizardSheet.h,v $
+Revision 1.12  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.11  2005/10/05 17:32:51  herscher
 <rdar://problem/4141221> Use a case insensitive compare operation to check whether a printer with the same name has already been installed.
 
index c64030d203c31289dfff0f0ff25bdf62f501c81d..83e6685b8a7ece996fd15ecb98aa382dc39f4f53 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: SecondPage.cpp,v $
+Revision 1.19  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.18  2005/07/20 17:44:54  shersche
 <rdar://problem/4124524> UI fixes for CUPS workaround
 
index 5cf1852aa8093a5b0c5b0a75bd20fe31bf7405f7..b857334fd08a47c13b8ee984a92ce2a0112317ae 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: SecondPage.h,v $
+Revision 1.9  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.8  2005/03/20 20:08:37  shersche
 <rdar://problem/4055670> Second screen should not select a printer by default
 
@@ -123,14 +120,22 @@ private:
        SetPrinterInformationState( BOOL state );
 
        std::string             m_selectedName;
-\r
-private:\r
-\r
-       CStatic m_printerInformation;\r
-       CStatic m_descriptionLabel;\r
-       CStatic m_descriptionField;\r
-       CStatic m_locationLabel;\r
-       CStatic m_locationField;\r
+
+
+private:
+
+
+
+       CStatic m_printerInformation;
+
+       CStatic m_descriptionLabel;
+
+       CStatic m_descriptionField;
+
+       CStatic m_locationLabel;
+
+       CStatic m_locationField;
+
 
        bool    m_gotChoice;
 };
index bf16fe2cc769c183baec938f6e528e8f9bd9e1ce..ac5ff1fa5474e1032c2aa2627fd985c3169f354e 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: ThirdPage.cpp,v $
+Revision 1.28  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.27  2005/10/05 21:41:45  herscher
 <rdar://problem/4190104> Use "application/octet-stream" to determine if CUPS shared queue supports raw
 
index 8331421fd557c6e0a47eb85d4558a45daf01637d..b21f2199fc3f8afffb3971ac5b0151022d14c1e1 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: ThirdPage.h,v $
+Revision 1.6  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  2005/07/07 17:53:20  shersche
 Fix problems associated with the CUPS printer workaround fix.
 
index e5512b982da3332e0b5e78395c856cc06aa6c678..aad29f1cb250d269a1567f7181aaf71f25c184a8 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: UtilTypes.h,v $
+Revision 1.15  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.14  2005/06/30 18:02:54  shersche
 <rdar://problem/4124524> Workaround for Mac OS X Printer Sharing bug
 
index 5d21d404b112667a18a999905aee09c8ff858564..a44c06f84ceb44069073773a62adc33630394274 100644 (file)
@@ -1,24 +1,18 @@
-/*\r
+/* -*- Mode: C; tab-width: 4 -*-\r
+ *\r
  * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.\r
  *\r
- * @APPLE_LICENSE_HEADER_START@\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
  * \r
- * This file contains Original Code and/or Modifications of Original Code\r
- * as defined in and that are subject to the Apple Public Source License\r
- * Version 2.0 (the 'License'). You may not use this file except in\r
- * compliance with the License. Please obtain a copy of the License at\r
- * http://www.opensource.apple.com/apsl/ and read it before using this\r
- * file.\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
  * \r
- * The Original Code and all software distributed under the License are\r
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER\r
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,\r
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.\r
- * Please see the License for the specific language governing rights and\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * @APPLE_LICENSE_HEADER_END@\r
 \r
     Change History (most recent first):\r
 \r
index 53abf252b277f84623d41859f9e7ce05b3c23a49..548f66f8e676e1934d83fed1d2daea8222d0982e 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: stdafx.cpp,v $
+Revision 1.2  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 04:36:58  rpantos
 First checked in
 
index 8ec4bdb3433535669d48782597395e4113415bef..e1ecec8a160d94a09cac0b09ae3e6c0f5cde4f71 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: stdafx.h,v $
+Revision 1.3  2006/08/14 23:24:09  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/10/19 19:50:35  herscher
 Workaround a bug in the latest Microsoft Platform SDK when compiling C++ files that include (directly or indirectly) <WspiApi.h>
 
index a7784204a7c282a60c516f60436f439e552301fc..4fc7745be319c594084a13d1bf5a7c6051e5b302 100755 (executable)
@@ -1,28 +1,25 @@
-/*\r
+/* -*- Mode: C; tab-width: 4 -*-\r
+ *\r
  * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.\r
  *\r
- * @APPLE_LICENSE_HEADER_START@\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
  * \r
- * This file contains Original Code and/or Modifications of Original Code\r
- * as defined in and that are subject to the Apple Public Source License\r
- * Version 2.0 (the 'License'). You may not use this file except in\r
- * compliance with the License. Please obtain a copy of the License at\r
- * http://www.opensource.apple.com/apsl/ and read it before using this\r
- * file.\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
  * \r
- * The Original Code and all software distributed under the License are\r
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER\r
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,\r
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.\r
- * Please see the License for the specific language governing rights and\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
- * \r
- * @APPLE_LICENSE_HEADER_END@\r
 \r
     Change History (most recent first):\r
     \r
 $Log: AssemblyInfo.cs,v $
+Revision 1.2  2006/08/14 23:24:21  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/07/19 07:57:08  shersche
 Initial revision
 \r
index fb841f2c3192d45f66f0cd5dd7f6eed551f15c11..e7f3b1e2f639db311c7d9023d6c8b1aa51463eff 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: SimpleChat.cs,v $
+Revision 1.6  2006/08/14 23:24:21  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  2004/09/13 19:37:42  shersche
 Change code to reflect namespace and type changes to dnssd.NET library
 
index 34af2d67b7504bce7a100000ef69473a759dee09..31e620d3a7f1cbbbb8d3198fbbf52afbfe0ad7e6 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 2002-2006 Apple Computer, Inc. All rights reserved.
  *
  * Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  * ("Apple") in consideration of your agreement to the following terms, and your
@@ -62,6 +63,9 @@ cl dns-sd.c -I../mDNSShared -DNOT_HAVE_GETOPT ws2_32.lib ..\mDNSWindows\DLL\Rele
 (may require that you run a Visual Studio script such as vsvars32.bat first)
 */
 
+// For testing changes to dnssd_clientstub.c, uncomment this line and the #include below
+// #define __APPLE_API_PRIVATE 1
+
 #include "dns_sd.h"
 #include <ctype.h>
 #include <stdio.h>                     // For stdout, stderr
@@ -79,15 +83,18 @@ typedef int        pid_t;
 #define getpid     _getpid
 #define strcasecmp _stricmp
 #define snprintf   _snprintf
+static const char kFilePathSep = '\\';
 #else
 #include <unistd.h>                    // For getopt() and optind
 #include <netdb.h>                     // For getaddrinfo()
 #include <sys/time.h>          // For struct timeval
-#include <arpa/inet.h>         // For inet_addr()
-#include <netinet/in.h>                // For struct sockaddr_in()
 #include <sys/socket.h>                // For AF_INET
+#include <netinet/in.h>                // For struct sockaddr_in()
+#include <arpa/inet.h>         // For inet_addr()
+static const char kFilePathSep = '/';
 #endif
 
+//#include "../mDNSShared/dnssd_clientstub.c"
 
 //*************************************************************************************************************
 // Globals
@@ -104,7 +111,7 @@ static DNSRecordRef record = NULL;
 static char myhinfoW[14] = "\002PC\012Windows XP";
 static char myhinfoX[ 9] = "\003Mac\004OS X";
 static char updatetest[3] = "\002AA";
-static char bigNULL[4096];
+static char bigNULL[8200];
 
 // Note: the select() implementation on Windows (Winsock2) fails with any timeout much larger than this
 #define LONG_TIME 100000000
@@ -229,48 +236,52 @@ static void DNSSD_API enum_reply(DNSServiceRef client, const DNSServiceFlags fla
        
        (void)client;       // Unused
        (void)ifIndex;      // Unused
-       (void)errorCode;    // Unused
        (void)context;      // Unused
-       
-       if (!*replyDomain) return;
 
        // 1. Print the header
        if (num_printed++ == 0) printf("Timestamp     Recommended %s domain\n", operation == 'E' ? "Registration" : "Browsing");
        printtimestamp();
-       printf("%-10s", DomainMsg(flags));
-       printf("%-8s", (flags & kDNSServiceFlagsMoreComing) ? "(More)" : "");
-       if (partialflags) printf("Flags: %4X  ", partialflags);
-       else printf("             ");
-       
-       // 2. Count the labels
-       while (*replyDomain)
+       if (errorCode)
+               printf("Error code %d\n", errorCode);
+       else if (!*replyDomain)
+               printf("Error: No reply domain\n");
+       else
                {
-               label[labels++] = replyDomain;
-               replyDomain = GetNextLabel(replyDomain, text);
-               }
+               printf("%-10s", DomainMsg(flags));
+               printf("%-8s", (flags & kDNSServiceFlagsMoreComing) ? "(More)" : "");
+               if (partialflags) printf("Flags: %4X  ", partialflags);
+               else printf("             ");
+               
+               // 2. Count the labels
+               while (*replyDomain)
+                       {
+                       label[labels++] = replyDomain;
+                       replyDomain = GetNextLabel(replyDomain, text);
+                       }
+               
+               // 3. Decide if we're going to clump the last two or three labels (e.g. "apple.com", or "nicta.com.au")
+               if      (labels >= 3 && replyDomain - label[labels-1] <= 3 && label[labels-1] - label[labels-2] <= 4) initial = 3;
+               else if (labels >= 2 && replyDomain - label[labels-1] <= 4) initial = 2;
+               else initial = 1;
+               labels -= initial;
        
-       // 3. Decide if we're going to clump the last two or three labels (e.g. "apple.com", or "nicta.com.au")
-       if      (labels >= 3 && replyDomain - label[labels-1] <= 3 && label[labels-1] - label[labels-2] <= 4) initial = 3;
-       else if (labels >= 2 && replyDomain - label[labels-1] <= 4) initial = 2;
-       else initial = 1;
-       labels -= initial;
-
-       // 4. Print the initial one-, two- or three-label clump
-       for (i=0; i<initial; i++)
-               {
-               GetNextLabel(label[labels+i], text);
-               if (i>0) printf(".");
-               printf("%s", text);
-               }
-       printf("\n");
-
-       // 5. Print the remainder of the hierarchy
-       for (depth=0; depth<labels; depth++)
-               {
-               printf("                                             ");
-               for (i=0; i<=depth; i++) printf("- ");
-               GetNextLabel(label[labels-1-depth], text);
-               printf("> %s\n", text);
+               // 4. Print the initial one-, two- or three-label clump
+               for (i=0; i<initial; i++)
+                       {
+                       GetNextLabel(label[labels+i], text);
+                       if (i>0) printf(".");
+                       printf("%s", text);
+                       }
+               printf("\n");
+       
+               // 5. Print the remainder of the hierarchy
+               for (depth=0; depth<labels; depth++)
+                       {
+                       printf("                                             ");
+                       for (i=0; i<=depth; i++) printf("- ");
+                       GetNextLabel(label[labels-1-depth], text);
+                       printf("> %s\n", text);
+                       }
                }
 
        if (!(flags & kDNSServiceFlagsMoreComing)) fflush(stdout);
@@ -281,50 +292,69 @@ static void DNSSD_API browse_reply(DNSServiceRef client, const DNSServiceFlags f
        {
        char *op = (flags & kDNSServiceFlagsAdd) ? "Add" : "Rmv";
        (void)client;       // Unused
-       (void)errorCode;    // Unused
        (void)context;      // Unused
        if (num_printed++ == 0) printf("Timestamp     A/R Flags if %-25s %-25s %s\n", "Domain", "Service Type", "Instance Name");
        printtimestamp();
-       printf("%s%6X%3d %-25s %-25s %s\n", op, flags, ifIndex, replyDomain, replyType, replyName);
+       if (errorCode) printf("Error code %d\n", errorCode);
+       else printf("%s%6X%3d %-25s %-25s %s\n", op, flags, ifIndex, replyDomain, replyType, replyName);
        if (!(flags & kDNSServiceFlagsMoreComing)) fflush(stdout);
        }
 
+static void ShowTXTRecord(uint16_t txtLen, const unsigned char *txtRecord)
+       {
+       const unsigned char *ptr = txtRecord;
+       const unsigned char *max = txtRecord + txtLen;
+       while (ptr < max)
+               {
+               const unsigned char *const end = ptr + 1 + ptr[0];
+               if (end > max) { printf("<< invalid data >>"); break; }
+               if (++ptr < end) printf(" ");   // As long as string is non-empty, begin with a space
+               while (ptr<end)
+                       {
+                       // We'd like the output to be shell-friendly, so that it can be copied and pasted unchanged into a "dns-sd -R" command.
+                       // However, this is trickier than it seems. Enclosing a string in double quotes doesn't necessarily make it
+                       // shell-safe, because shells still expand variables like $foo even when they appear inside quoted strings.
+                       // Enclosing a string in single quotes is better, but when using single quotes even backslash escapes are ignored,
+                       // meaning there's simply no way to represent a single quote (or apostrophe) inside a single-quoted string.
+                       // The only remaining solution is not to surround the string with quotes at all, but instead to use backslash
+                       // escapes to encode spaces and all other known shell metacharacters.
+                       // (If we've missed any known shell metacharacters, please let us know.)
+                       // In addition, non-printing ascii codes (0-31) are displayed as \xHH, using a two-digit hex value.
+                       // Because '\' is itself a shell metacharacter (the shell escape character), it has to be escaped as "\\" to survive
+                       // the round-trip to the shell and back. This means that a single '\' is represented here as EIGHT backslashes:
+                       // The C compiler eats half of them, resulting in four appearing in the output.
+                       // The shell parses those four as a pair of "\\" sequences, passing two backslashes to the "dns-sd -R" command.
+                       // The "dns-sd -R" command interprets this single "\\" pair as an escaped literal backslash. Sigh.
+                       if (strchr(" &;`'\"|*?~<>^()[]{}$", *ptr)) printf("\\");
+                       if      (*ptr == '\\') printf("\\\\\\\\");
+                       else if (*ptr >= ' ' ) printf("%c",        *ptr);
+                       else                   printf("\\\\x%02X", *ptr);
+                       ptr++;
+                       }
+               }
+       }
+
 static void DNSSD_API resolve_reply(DNSServiceRef client, const DNSServiceFlags flags, uint32_t ifIndex, DNSServiceErrorType errorCode,
-       const char *fullname, const char *hosttarget, uint16_t opaqueport, uint16_t txtLen, const char *txtRecord, void *context)
+       const char *fullname, const char *hosttarget, uint16_t opaqueport, uint16_t txtLen, const unsigned char *txtRecord, void *context)
        {
        union { uint16_t s; u_char b[2]; } port = { opaqueport };
        uint16_t PortAsNumber = ((uint16_t)port.b[0]) << 8 | port.b[1];
 
        (void)client;       // Unused
        (void)ifIndex;      // Unused
-       (void)errorCode;    // Unused
        (void)context;      // Unused
 
        printtimestamp();
-       printf("%s can be reached at %s:%u", fullname, hosttarget, PortAsNumber);
-
-       if (flags) printf(" Flags: %X", flags);
-       if (txtLen > 1)     // Don't show degenerate TXT records containing nothing but a single empty string
+       if (errorCode) printf("Error code %d\n", errorCode);
+       else
                {
-               const char *ptr = txtRecord;
-               const char *max = txtRecord + txtLen;
-               printf(" TXT");
-               while (ptr < max)
-                       {
-                       const char *end = ptr + 1 + ptr[0];
-                       if (end > max) { printf("<< invalid data >>"); break; }
-                       if (++ptr < end) printf(" ");   // As long as string is non-empty, begin with a space
-                       while (ptr < end)
-                               {
-                               if      (*ptr == '\\') printf("\\\\");          // '\' displays as "\\"
-                               else if (*ptr == ' ' ) printf("\\ ");           // ' ' displays as "\ "
-                               else if (*ptr >  ' ' ) printf("%c", *ptr);      // Display normal characters as-is
-                               else                   printf("\\x%02X", *ptr); // ther chararacters displayed as "\xHH"
-                               ptr++;
-                               }
-                       }
+               printf("%s can be reached at %s:%u", fullname, hosttarget, PortAsNumber);
+               if (flags) printf(" Flags: %X", flags);
+               // Don't show degenerate TXT records containing nothing but a single empty string
+               if (txtLen > 1) { printf("\n"); ShowTXTRecord(txtLen, txtRecord); }
+               printf("\n");
                }
-       printf("\n");
+
        if (!(flags & kDNSServiceFlagsMoreComing)) fflush(stdout);
        }
 
@@ -389,14 +419,20 @@ static void DNSSD_API reg_reply(DNSServiceRef client, const DNSServiceFlags flag
        (void)context;  // Unused
 
        printf("Got a reply for %s.%s%s: ", name, regtype, domain);
-       switch (errorCode)
+
+       if (errorCode == kDNSServiceErr_NoError)
                {
-               case kDNSServiceErr_NoError:      printf("Name now registered and active\n"); break;
-               case kDNSServiceErr_NameConflict: printf("Name in use, please choose another\n"); exit(-1);
-               default:                          printf("Error %d\n", errorCode); return;
+               printf("Name now registered and active\n");
+               if (operation == 'A' || operation == 'U' || operation == 'N') timeOut = 5;
                }
+       else if (errorCode == kDNSServiceErr_NameConflict)
+               {
+               printf("Name in use, please choose another\n");
+               exit(-1);
+               }
+       else
+               printf("Error %d\n", errorCode);
 
-       if (operation == 'A' || operation == 'U' || operation == 'N') timeOut = 5;
        if (!(flags & kDNSServiceFlagsMoreComing)) fflush(stdout);
        }
 
@@ -407,26 +443,39 @@ static void DNSSD_API qr_reply(DNSServiceRef sdRef, const DNSServiceFlags flags,
        const unsigned char *rd  = rdata;
        const unsigned char *end = (const unsigned char *) rdata + rdlen;
        char rdb[1000];
-       char *p = rdb;
-       const char * const lim = rdb + sizeof(rdb);
+       int unknowntype = 0;
 
        (void)sdRef;    // Unused
        (void)flags;    // Unused
        (void)ifIndex;  // Unused
-       (void)errorCode;// Unused
        (void)ttl;      // Unused
        (void)context;  // Unused
 
-       switch (rrtype)
-               {
-               case kDNSServiceType_A: sprintf(rdb, "%d.%d.%d.%d", rd[0], rd[1], rd[2], rd[3]); break;
-               default :       p += snprintf(p, lim-p, "%d bytes%s", rdlen, rdlen ? ":" : "");
-                                       while (rd < end && p < lim) p += snprintf(p, lim-p, " %02X", *rd++);
-                                       break;
-               }
        if (num_printed++ == 0) printf("Timestamp     A/R Flags if %-30s%4s%4s Rdata\n", "Name", "T", "C");
        printtimestamp();
-       printf("%s%6X%3d %-30s%4d%4d %s\n", op, flags, ifIndex, fullname, rrtype, rrclass, rdb);
+       if (errorCode)
+               printf("Error code %d\n", errorCode);
+       else
+               {
+               switch (rrtype)
+                       {
+                       case kDNSServiceType_A: sprintf(rdb, "%d.%d.%d.%d", rd[0], rd[1], rd[2], rd[3]); break;
+                       case kDNSServiceType_AAAA: sprintf(rdb, "%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X",
+                               rd[0x0], rd[0x1], rd[0x2], rd[0x3], rd[0x4], rd[0x5], rd[0x6], rd[0x7],
+                               rd[0x8], rd[0x9], rd[0xA], rd[0xB], rd[0xC], rd[0xD], rd[0xE], rd[0xF]); break;
+                               break;
+                       default : sprintf(rdb, "%d bytes%s", rdlen, rdlen ? ":" : ""); unknowntype = 1; break;
+                       }
+
+               printf("%s%6X%3d %-30s%4d%4d %s", op, flags, ifIndex, fullname, rrtype, rrclass, rdb);
+               if (unknowntype) while (rd < end) printf(" %02X", *rd++);
+               printf("\n");
+       
+               if (operation == 'C')
+                       if (flags & kDNSServiceFlagsAdd)
+                               DNSServiceReconfirmRecord(flags, ifIndex, fullname, rrtype, rrclass, rdlen, rdata);
+               }
+
        if (!(flags & kDNSServiceFlagsMoreComing)) fflush(stdout);
        }
 
@@ -456,7 +505,7 @@ static void HandleEvents(void)
                if (client2) FD_SET(dns_sd_fd2, &readfds);
 
                // 3. Set up the timeout.
-               tv.tv_sec = timeOut;
+               tv.tv_sec  = timeOut;
                tv.tv_usec = 0;
 
                result = select(nfds, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv);
@@ -481,7 +530,7 @@ static int getfirstoption( int argc, char **argv, const char *optstr, int *pOptI
 // Return the recognized option in optstr and the option index of the next arg.
 #if NOT_HAVE_GETOPT
        {
-       int     i;
+       int i;
        for ( i=1; i < argc; i++)
                {
                if ( argv[i][0] == '-' && &argv[i][1] && 
@@ -495,7 +544,7 @@ static int getfirstoption( int argc, char **argv, const char *optstr, int *pOptI
        }
 #else
        {
-       int     operation = getopt(argc, (char * const *)argv, optstr);
+       int operation = getopt(argc, (char * const *)argv, optstr);
        *pOptInd = optind;
        return operation;
        }
@@ -515,7 +564,7 @@ static void DNSSD_API MyRegisterRecordCallback(DNSServiceRef service, DNSRecordR
                {
                case kDNSServiceErr_NoError:      printf("Name now registered and active\n"); break;
                case kDNSServiceErr_NameConflict: printf("Name in use, please choose another\n"); exit(-1);
-               default:                          printf("Error %d\n", errorCode); return;
+               default:                          printf("Error %d\n", errorCode); break;
                }
        if (!(flags & kDNSServiceFlagsMoreComing)) fflush(stdout);
        }
@@ -544,9 +593,10 @@ static unsigned long getip(const char *const name)
 
 static DNSServiceErrorType RegisterProxyAddressRecord(DNSServiceRef *sdRef, const char *host, const char *ip)
        {
-       // Call getip() after the call DNSServiceCreateConnection(). On the Win32 platform, WinSock must
-       // be initialized for getip() to succeed.  Any DNSService* call will initialize WinSock for us,
-       // so make sure DNSServiceCreateConnection() is called before getip() is.
+       // Call getip() after the call DNSServiceCreateConnection().
+       // On the Win32 platform, WinSock must be initialized for getip() to succeed.
+       // Any DNSService* call will initialize WinSock for us, so we make sure
+       // DNSServiceCreateConnection() is called before getip() is.
        unsigned long addr = 0;
        DNSServiceErrorType err = DNSServiceCreateConnection(sdRef);
        if (err) { fprintf(stderr, "DNSServiceCreateConnection returned %d\n", err); return(err); }
@@ -556,6 +606,12 @@ static DNSServiceErrorType RegisterProxyAddressRecord(DNSServiceRef *sdRef, cons
        // Note, should probably add support for creating proxy AAAA records too, one day
        }
 
+#define HexVal(X) ( ((X) >= '0' && (X) <= '9') ? ((X) - '0'     ) :  \
+                                       ((X) >= 'A' && (X) <= 'F') ? ((X) - 'A' + 10) :  \
+                                       ((X) >= 'a' && (X) <= 'f') ? ((X) - 'a' + 10) : 0)
+
+#define HexPair(P) ((HexVal((P)[0]) << 4) | HexVal((P)[1]))
+
 static DNSServiceErrorType RegisterService(DNSServiceRef *sdRef,
        const char *nam, const char *typ, const char *dom, const char *host, const char *port, int argc, char **argv)
        {
@@ -572,16 +628,22 @@ static DNSServiceErrorType RegisterService(DNSServiceRef *sdRef,
        if (host && *host) printf(" host %s", host);
        printf(" port %s\n", port);
 
-       for (i = 0; i < argc; i++)
+       if (argc)
                {
-               int length = strlen(argv[i]);
-               if (length <= 255)
+               for (i = 0; i < argc; i++)
                        {
-                       *ptr++ = (unsigned char)length;
-                       strcpy((char*)ptr, argv[i]);
-                       ptr += length;
-                       printf("TXT %s\n", argv[i]);
+                       const char *p = argv[i];
+                       *ptr = 0;
+                       while (*p && *ptr < 255 && ptr + 1 + *ptr < txt+sizeof(txt))
+                               {
+                               if      (p[0] != '\\' || p[1] == 0)                       { ptr[++*ptr] = *p;           p+=1; }
+                               else if (p[1] == 'x' && isxdigit(p[2]) && isxdigit(p[3])) { ptr[++*ptr] = HexPair(p+2); p+=4; }
+                               else                                                      { ptr[++*ptr] = p[1];         p+=2; }
+                               }
+                       ptr += 1 + *ptr;
                        }
+               ShowTXTRecord(ptr-txt, txt);
+               printf("\n");
                }
        
        return(DNSServiceRegister(sdRef, /* kDNSServiceFlagsAllowRemoteQuery */ 0, opinterface, nam, typ, dom, host, registerPort.NotAnInteger, (uint16_t) (ptr-txt), txt, reg_reply, NULL));
@@ -589,15 +651,15 @@ static DNSServiceErrorType RegisterService(DNSServiceRef *sdRef,
 
 int main(int argc, char **argv)
        {
-#ifdef _WIN32
-       const char      kFilePathSep = '\\';
-#else
-       const char      kFilePathSep = '/';
-#endif
        DNSServiceErrorType err;
        char *dom;
-       int     optind;
-       const char *progname = strrchr(argv[0], kFilePathSep) ? strrchr(argv[0], kFilePathSep) + 1 : argv[0];
+       int optind;
+
+       // Extract the program name from argv[0], which by convention contains the path to this executable.
+       // Note that this is just a voluntary convention, not enforced by the kernel --
+       // the process calling exec() can pass bogus data in argv[0] if it chooses to.
+       const char *a0 = strrchr(argv[0], kFilePathSep) + 1;
+       if (a0 == (const char *)1) a0 = argv[0];
 
        if (argc > 1 && !strcmp(argv[1], "-lo"))
                {
@@ -616,7 +678,7 @@ int main(int argc, char **argv)
                }
 
        if (argc < 2) goto Fail;        // Minimum command line is the command name and one argument
-       operation = getfirstoption( argc, argv, "EFBLQRPAUNTMI", &optind);
+       operation = getfirstoption( argc, argv, "EFBLRPQCAUNTMI", &optind);
        if (operation == -1) goto Fail;
 
        switch (operation)
@@ -644,7 +706,7 @@ int main(int argc, char **argv)
                                        dom = (argc < optind+3) ? "local" : argv[optind+2];
                                        if (dom[0] == '.' && dom[1] == 0) dom = "local";   // We allow '.' on the command line as a synonym for "local"
                                        printf("Lookup %s.%s.%s\n", argv[optind+0], argv[optind+1], dom);
-                                       err = DNSServiceResolve(&client, 0, opinterface, argv[optind+0], argv[optind+1], dom, resolve_reply, NULL);
+                                       err = DNSServiceResolve(&client, 0, opinterface, argv[optind+0], argv[optind+1], dom, (DNSServiceResolveReply)resolve_reply, NULL);
                                        break;
 
                case 'R':       if (argc < optind+4) goto Fail;
@@ -657,9 +719,10 @@ int main(int argc, char **argv)
                                        err = RegisterService(&client, argv[optind+0], argv[optind+1], argv[optind+2], argv[optind+4], argv[optind+3], argc-(optind+6), argv+(optind+6));
                                        break;
 
-               case 'Q':       {
+               case 'Q':
+               case 'C':       {
                                        uint16_t rrtype, rrclass;
-                                       DNSServiceFlags flags = 0;
+                                       DNSServiceFlags flags = kDNSServiceFlagsReturnCNAME;
                                        if (argc < optind+1) goto Fail;
                                        rrtype = (argc <= optind+1) ? kDNSServiceType_A  : GetRRType(argv[optind+1]);
                                        rrclass = (argc <= optind+2) ? kDNSServiceClass_IN : atoi(argv[optind+2]);
@@ -722,18 +785,19 @@ int main(int argc, char **argv)
        return 0;
 
 Fail:
-       fprintf(stderr, "%s -E                  (Enumerate recommended registration domains)\n", progname);
-       fprintf(stderr, "%s -F                      (Enumerate recommended browsing domains)\n", progname);
-       fprintf(stderr, "%s -B        <Type> <Domain>        (Browse for services instances)\n", progname);
-       fprintf(stderr, "%s -L <Name> <Type> <Domain>           (Look up a service instance)\n", progname);
-       fprintf(stderr, "%s -R <Name> <Type> <Domain> <Port> [<TXT>...] (Register a service)\n", progname);
-       fprintf(stderr, "%s -P <Name> <Type> <Domain> <Port> <Host> <IP> [<TXT>...]  (Proxy)\n", progname);
-       fprintf(stderr, "%s -Q <FQDN> <rrtype> <rrclass> (Generic query for any record type)\n", progname);
-       fprintf(stderr, "%s -A                      (Test Adding/Updating/Deleting a record)\n", progname);
-       fprintf(stderr, "%s -U                                  (Test updating a TXT record)\n", progname);
-       fprintf(stderr, "%s -N                             (Test adding a large NULL record)\n", progname);
-       fprintf(stderr, "%s -T                            (Test creating a large TXT record)\n", progname);
-       fprintf(stderr, "%s -M      (Test creating a registration with multiple TXT records)\n", progname);
-       fprintf(stderr, "%s -I   (Test registering and then immediately updating TXT record)\n", progname);
+       fprintf(stderr, "%s -E                  (Enumerate recommended registration domains)\n", a0);
+       fprintf(stderr, "%s -F                      (Enumerate recommended browsing domains)\n", a0);
+       fprintf(stderr, "%s -B        <Type> <Domain>        (Browse for services instances)\n", a0);
+       fprintf(stderr, "%s -L <Name> <Type> <Domain>           (Look up a service instance)\n", a0);
+       fprintf(stderr, "%s -R <Name> <Type> <Domain> <Port> [<TXT>...] (Register a service)\n", a0);
+       fprintf(stderr, "%s -P <Name> <Type> <Domain> <Port> <Host> <IP> [<TXT>...]  (Proxy)\n", a0);
+       fprintf(stderr, "%s -Q <FQDN> <rrtype> <rrclass> (Generic query for any record type)\n", a0);
+       fprintf(stderr, "%s -C <FQDN> <rrtype> <rrclass>   (Query; reconfirming each result)\n", a0);
+       fprintf(stderr, "%s -A                      (Test Adding/Updating/Deleting a record)\n", a0);
+       fprintf(stderr, "%s -U                                  (Test updating a TXT record)\n", a0);
+       fprintf(stderr, "%s -N                             (Test adding a large NULL record)\n", a0);
+       fprintf(stderr, "%s -T                            (Test creating a large TXT record)\n", a0);
+       fprintf(stderr, "%s -M      (Test creating a registration with multiple TXT records)\n", a0);
+       fprintf(stderr, "%s -I   (Test registering and then immediately updating TXT record)\n", a0);
        return 0;
        }
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..f458904
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+The majority of the source code in the mDNSResponder project is licensed
+under the terms of the Apache License, Version 2.0, available from:
+   <http://www.apache.org/licenses/LICENSE-2.0>
+
+To accommodate license compatibility with the widest possible range
+of client code licenses, the shared library code, which is linked
+at runtime into the same address space as the client using it, is
+licensed under the terms of the "Three-Clause BSD License".
+
+The Linux Name Service Switch code, contributed by National ICT
+Australia Ltd (NICTA) is licensed under the terms of the NICTA Public
+Software Licence (which is substantially similar to the "Three-Clause
+BSD License", with some additional language pertaining to Australian law).
index e4a757441109526b6bcf80f7e913b401bfcade2f..61219d32bd5fed227f3e9de9e3134085113c9623 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
 
 include /Developer/Makefiles/pb_makefiles/platform.make
 
-MVERS = "mDNSResponder-107.5"
+MVERS = "mDNSResponder-107.6"
 
 install:
        cd "$(SRCROOT)/mDNSMacOSX"; xcodebuild install     OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) DSTROOT=$(DSTROOT) MVERS=$(MVERS)
index a1b7dc43d596387399c6e0e418a0095f2ac3e041..08507b02e2227abbe27394a42c2918c90e861536 100644 (file)
@@ -2,28 +2,51 @@
  *
  * Copyright (c) 2002-2003 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: DNSCommon.c,v $
+Revision 1.100.2.1  2006/08/29 06:24:22  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.100  2006/06/08 22:58:46  cheshire
+<rdar://problem/4335605> IPv6 link-local address prefix is FE80::/10, not FE80::/16
+
+Revision 1.99  2006/05/18 01:32:33  cheshire
+<rdar://problem/4472706> iChat: Lost connection with Bonjour
+(mDNSResponder insufficiently defensive against malformed browsing PTR responses)
+
+Revision 1.98  2006/03/19 17:00:58  cheshire
+Define symbol MaxMsg instead of using hard-coded constant value '80'
+
+Revision 1.97  2006/03/18 21:47:56  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
+Revision 1.96  2006/03/10 21:51:42  cheshire
+<rdar://problem/4111464> After record update, old record sometimes remains in cache
+Split out SameRDataBody() into a separate routine so it can be called from other code
+
+Revision 1.95  2006/03/08 22:43:11  cheshire
+Use "localdomain" symbol instead of literal string
+
+Revision 1.94  2006/03/02 21:59:55  cheshire
+<rdar://problem/4395331> Spurious warning "GetLargeResourceRecord: m->rec appears to be already in use"
+Improve sanity checks & debugging support in GetLargeResourceRecord()
+
+Revision 1.93  2006/03/02 20:30:47  cheshire
+Improved GetRRDisplayString to also show priority, weight, and port for SRV records
+
 Revision 1.92  2005/09/16 21:06:49  cheshire
 Use mDNS_TimeNow_NoLock macro, instead of writing "mDNSPlatformRawTime() + m->timenow_adjust" all over the place
 
@@ -445,22 +468,24 @@ mDNSexport char *DNSTypeName(mDNSu16 rrtype)
 // long as this routine is only used for debugging messages, it probably isn't a big problem.
 mDNSexport char *GetRRDisplayString_rdb(const ResourceRecord *rr, RDataBody *rd, char *buffer)
        {
+       #define Max (MaxMsg-1)
        char *ptr = buffer;
-       mDNSu32 length = mDNS_snprintf(buffer, 79, "%4d %##s %s ", rr->rdlength, rr->name->c, DNSTypeName(rr->rrtype));
+       mDNSu32 length = mDNS_snprintf(buffer, Max, "%4d %##s %s ", rr->rdlength, rr->name->c, DNSTypeName(rr->rrtype));
        switch (rr->rrtype)
                {
-               case kDNSType_A:        mDNS_snprintf(buffer+length, 79-length, "%.4a", &rd->ipv4);          break;
+               case kDNSType_A:        mDNS_snprintf(buffer+length, Max-length, "%.4a", &rd->ipv4);          break;
 
                case kDNSType_NS:       // Same as PTR
                case kDNSType_CNAME:// Same as PTR
-               case kDNSType_PTR:      mDNS_snprintf(buffer+length, 79-length, "%##s", rd->name.c);       break;
+               case kDNSType_PTR:      mDNS_snprintf(buffer+length, Max-length, "%##s", rd->name.c);       break;
 
                case kDNSType_HINFO:// Display this the same as TXT (just show first string)
-               case kDNSType_TXT:  mDNS_snprintf(buffer+length, 79-length, "%#s", rd->txt.c);         break;
+               case kDNSType_TXT:  mDNS_snprintf(buffer+length, Max-length, "%#s", rd->txt.c);         break;
 
-               case kDNSType_AAAA:     mDNS_snprintf(buffer+length, 79-length, "%.16a", &rd->ipv6);       break;
-               case kDNSType_SRV:      mDNS_snprintf(buffer+length, 79-length, "%##s", rd->srv.target.c); break;
-               default:                        mDNS_snprintf(buffer+length, 79-length, "RDLen %d: %s", rr->rdlength, rd->data);  break;
+               case kDNSType_AAAA:     mDNS_snprintf(buffer+length, Max-length, "%.16a", &rd->ipv6);       break;
+               case kDNSType_SRV:      mDNS_snprintf(buffer+length, Max-length, "%u %u %u %##s",
+                                                               rd->srv.priority, rd->srv.weight, mDNSVal16(rd->srv.port), rd->srv.target.c); break;
+               default:                        mDNS_snprintf(buffer+length, Max-length, "RDLen %d: %s", rr->rdlength, rd->data);  break;
                }
        for (ptr = buffer; *ptr; ptr++) if (*ptr < ' ') *ptr='.';
        return(buffer);
@@ -482,6 +507,14 @@ mDNSexport mDNSu32 mDNSRandom(mDNSu32 max)
        return (seed & mask);
        }
 
+mDNSexport mDNSu32 mDNSRandomFromFixedSeed(mDNSu32 seed, mDNSu32 max)
+       {
+       mDNSu32 mask = 1;
+       while (mask < max) mask = (mask << 1) | 1;
+       do seed = seed * 21 + 1; while ((seed & mask) > max);
+       return (seed & mask);
+       }
+
 mDNSexport mDNSBool mDNSSameAddress(const mDNSAddr *ip1, const mDNSAddr *ip2)
        {
        if (ip1->type == ip2->type)
@@ -556,10 +589,13 @@ mDNSexport mDNSBool SameDomainName(const domainname *const d1, const domainname
 mDNSexport mDNSBool IsLocalDomain(const domainname *d)
        {
        // Domains that are defined to be resolved via link-local multicast are:
-       // local., 254.169.in-addr.arpa., and 0.8.E.F.ip6.arpa.
-       static const domainname *n0 = (domainname*)"\x5" "local";
-       static const domainname *n1 = (domainname*)"\x3" "254" "\x3" "169"                     "\x7" "in-addr" "\x4" "arpa";
-       static const domainname *n2 = (domainname*)"\x1" "0"   "\x1" "8"   "\x1" "e" "\x1" "f" "\x3" "ip6"     "\x4" "arpa";
+       // local., 254.169.in-addr.arpa., and {8,9,A,B}.E.F.ip6.arpa.
+       static const domainname *nL = (domainname*)"\x5" "local";
+       static const domainname *nR = (domainname*)"\x3" "254" "\x3" "169"         "\x7" "in-addr" "\x4" "arpa";
+       static const domainname *n8 = (domainname*)"\x1" "8"   "\x1" "e" "\x1" "f" "\x3" "ip6"     "\x4" "arpa";
+       static const domainname *n9 = (domainname*)"\x1" "9"   "\x1" "e" "\x1" "f" "\x3" "ip6"     "\x4" "arpa";
+       static const domainname *nA = (domainname*)"\x1" "a"   "\x1" "e" "\x1" "f" "\x3" "ip6"     "\x4" "arpa";
+       static const domainname *nB = (domainname*)"\x1" "b"   "\x1" "e" "\x1" "f" "\x3" "ip6"     "\x4" "arpa";
 
        const domainname *d1, *d2, *d3, *d4, *d5, *d6;  // Top-level domain, second-level domain, etc.
        d1 = d2 = d3 = d4 = d5 = d6 = mDNSNULL;
@@ -569,9 +605,12 @@ mDNSexport mDNSBool IsLocalDomain(const domainname *d)
                d = (domainname*)(d->c + 1 + d->c[0]);
                }
 
-       if (d1 && SameDomainName(d1, n0)) return(mDNStrue);
-       if (d4 && SameDomainName(d4, n1)) return(mDNStrue);
-       if (d6 && SameDomainName(d6, n2)) return(mDNStrue);
+       if (d1 && SameDomainName(d1, nL)) return(mDNStrue);
+       if (d4 && SameDomainName(d4, nR)) return(mDNStrue);
+       if (d6 && SameDomainName(d6, n8)) return(mDNStrue);
+       if (d6 && SameDomainName(d6, n9)) return(mDNStrue);
+       if (d6 && SameDomainName(d6, nA)) return(mDNStrue);
+       if (d6 && SameDomainName(d6, nB)) return(mDNStrue);
        return(mDNSfalse);
        }
 
@@ -872,7 +911,7 @@ mDNSexport mDNSu8 *ConstructServiceName(domainname *const fqdn,
 
        src = type->c;                                                                          // Put the service type into the domain name
        len = *src;
-       if (len < 2 || len >= 0x40 || (len > 15 && !SameDomainName(domain, (domainname*)"\x05" "local")))
+       if (len < 2 || len >= 0x40 || (len > 15 && !SameDomainName(domain, &localdomain)))
                {
                errormsg="Application protocol name must be underscore plus 1-14 characters. See <http://www.dns-sd.org/ServiceTypes.html>";
                goto fail;
@@ -905,6 +944,11 @@ fail:
        return(mDNSNULL);
        }
 
+// A service name has the form: instance.application-protocol.transport-protocol.domain
+// DeconstructServiceName is currently fairly forgiving: It doesn't try to enforce character
+// set or length limits for the protocol names, and the final domain is allowed to be empty.
+// However, if the given FQDN doesn't contain at least three labels,
+// DeconstructServiceName will reject it and return mDNSfalse.
 mDNSexport mDNSBool DeconstructServiceName(const domainname *const fqdn,
        domainlabel *const name, domainname *const type, domainname *const domain)
        {
@@ -913,29 +957,32 @@ mDNSexport mDNSBool DeconstructServiceName(const domainname *const fqdn,
        const mDNSu8 *max = fqdn->c + MAX_DOMAIN_NAME;
        mDNSu8 *dst;
 
-       dst = name->c;                                                                          // Extract the service name from the domain name
+       dst = name->c;                                                                          // Extract the service name
        len = *src;
-       if (len >= 0x40) { debugf("DeconstructServiceName: service name too long"); return(mDNSfalse); }
+       if (!len)        { debugf("DeconstructServiceName: FQDN empty!");            return(mDNSfalse); }
+       if (len >= 0x40) { debugf("DeconstructServiceName: Instance name too long"); return(mDNSfalse); }
        for (i=0; i<=len; i++) *dst++ = *src++;
 
-       dst = type->c;                                                                          // Extract the service type from the domain name
+       dst = type->c;                                                                          // Extract the service type
        len = *src;
-       if (len >= 0x40) { debugf("DeconstructServiceName: service type too long"); return(mDNSfalse); }
+       if (!len)        { debugf("DeconstructServiceName: FQDN contains only one label!");      return(mDNSfalse); }
+       if (len >= 0x40) { debugf("DeconstructServiceName: Application protocol name too long"); return(mDNSfalse); }
        for (i=0; i<=len; i++) *dst++ = *src++;
 
        len = *src;
-       if (len >= 0x40) { debugf("DeconstructServiceName: service type too long"); return(mDNSfalse); }
+       if (!len)        { debugf("DeconstructServiceName: FQDN contains only two labels!");   return(mDNSfalse); }
+       if (len >= 0x40) { debugf("DeconstructServiceName: Transport protocol name too long"); return(mDNSfalse); }
        for (i=0; i<=len; i++) *dst++ = *src++;
-       *dst++ = 0;             // Put the null root label on the end of the service type
+       *dst++ = 0;                                                                                     // Put terminator on the end of service type
 
-       dst = domain->c;                                                                        // Extract the service domain from the domain name
+       dst = domain->c;                                                                        // Extract the service domain
        while (*src)
                {
                len = *src;
                if (len >= 0x40)
-                       { debugf("DeconstructServiceName: service domain label too long"); return(mDNSfalse); }
+                       { debugf("DeconstructServiceName: Label in service domain too long"); return(mDNSfalse); }
                if (src + 1 + len + 1 >= max)
-                       { debugf("DeconstructServiceName: service domain too long"); return(mDNSfalse); }
+                       { debugf("DeconstructServiceName: Total service domain too long"); return(mDNSfalse); }
                for (i=0; i<=len; i++) *dst++ = *src++;
                }
        *dst++ = 0;             // Put the null root label on the end
@@ -1101,25 +1148,32 @@ mDNSexport mDNSu32 RDataHashValue(mDNSu16 const rdlength, const RDataBody *const
        return(sum);
        }
 
-mDNSexport mDNSBool SameRData(const ResourceRecord *const r1, const ResourceRecord *const r2)
+// r1 has to be a full ResourceRecord including rrtype and rdlength
+// r2 is just a bare RDataBody, which MUST be the same rrtype and rdlength as r1
+mDNSexport mDNSBool SameRDataBody(const ResourceRecord *const r1, const RDataBody *const r2)
        {
-       if (r1->rrtype     != r2->rrtype)     return(mDNSfalse);
-       if (r1->rdlength   != r2->rdlength)   return(mDNSfalse);
-       if (r1->rdatahash  != r2->rdatahash)  return(mDNSfalse);
        switch(r1->rrtype)
                {
                case kDNSType_CNAME:// Same as PTR
-               case kDNSType_PTR:      return(SameDomainName(&r1->rdata->u.name, &r2->rdata->u.name));
+               case kDNSType_PTR:      return(SameDomainName(&r1->rdata->u.name, &r2->name));
 
-               case kDNSType_SRV:      return(mDNSBool)(       r1->rdata->u.srv.priority          == r2->rdata->u.srv.priority          &&
-                                                                                               r1->rdata->u.srv.weight            == r2->rdata->u.srv.weight            &&
-                                                                                               r1->rdata->u.srv.port.NotAnInteger == r2->rdata->u.srv.port.NotAnInteger &&
-                                                                                               SameDomainName(&r1->rdata->u.srv.target, &r2->rdata->u.srv.target)       );
+               case kDNSType_SRV:      return(mDNSBool)(       r1->rdata->u.srv.priority          == r2->srv.priority          &&
+                                                                                               r1->rdata->u.srv.weight            == r2->srv.weight            &&
+                                                                                               r1->rdata->u.srv.port.NotAnInteger == r2->srv.port.NotAnInteger &&
+                                                                                               SameDomainName(&r1->rdata->u.srv.target, &r2->srv.target)       );
 
-               default:                        return(mDNSPlatformMemSame(r1->rdata->u.data, r2->rdata->u.data, r1->rdlength));
+               default:                        return(mDNSPlatformMemSame(r1->rdata->u.data, r2->data, r1->rdlength));
                }
        }
 
+mDNSexport mDNSBool SameRData(const ResourceRecord *const r1, const ResourceRecord *const r2)
+       {
+       if (r1->rrtype     != r2->rrtype)     return(mDNSfalse);
+       if (r1->rdlength   != r2->rdlength)   return(mDNSfalse);
+       if (r1->rdatahash  != r2->rdatahash)  return(mDNSfalse);
+       return(SameRDataBody(r1, &r2->rdata->u));
+       }
+
 mDNSexport mDNSBool SameResourceRecord(ResourceRecord *r1, ResourceRecord *r2)
        {
        return (r1->namehash == r2->namehash &&
@@ -1797,11 +1851,10 @@ mDNSexport const mDNSu8 *GetLargeResourceRecord(mDNS *const m, const DNSMessage
        CacheRecord *rr = &largecr->r;
        mDNSu16 pktrdlength;
        
-       if (largecr == &m->rec && rr->resrec.RecordType)
-               LogMsg("GetLargeResourceRecord: m->rec appears to be already in use");
+       if (largecr == &m->rec && largecr->r.resrec.RecordType)
+               LogMsg("GetLargeResourceRecord: m->rec appears to be already in use for %s", CRDisplayString(m, &largecr->r));
 
        rr->next              = mDNSNULL;
-       rr->resrec.RecordType = RecordType;
        rr->resrec.name       = &largecr->namestorage;
 
        rr->NextInKAList      = mDNSNULL;
@@ -1833,7 +1886,7 @@ mDNSexport const mDNSu8 *GetLargeResourceRecord(mDNS *const m, const DNSMessage
        // us to look at. If we decide to copy it into the cache, then we'll update m->NextCacheCheck accordingly.
        pktrdlength           = (mDNSu16)((mDNSu16)ptr[8] <<  8 | ptr[9]);
        if (ptr[2] & (kDNSClass_UniqueRRSet >> 8))
-               rr->resrec.RecordType |= kDNSRecordTypePacketUniqueMask;
+               RecordType |= kDNSRecordTypePacketUniqueMask;
        ptr += 10;
        if (ptr + pktrdlength > end) { debugf("GetResourceRecord: RDATA exceeds end of packet"); return(mDNSNULL); }
        end = ptr + pktrdlength;                // Adjust end to indicate the end of the rdata for this resource record
@@ -1917,6 +1970,8 @@ mDNSexport const mDNSu8 *GetLargeResourceRecord(mDNS *const m, const DNSMessage
        rr->resrec.namehash = DomainNameHashValue(rr->resrec.name);
        SetNewRData(&rr->resrec, mDNSNULL, 0);
 
+       // Success! Now fill in RecordType to show this record contains valid data
+       rr->resrec.RecordType = RecordType;
        return(ptr + pktrdlength);
        }
 
index 13b7ca80f2bc64dbbd1cf8d41316b63559e986c6..3ec6fc346e23548331e9e1c179ea2a755cfa2e15 100644 (file)
@@ -1,28 +1,32 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: DNSCommon.h,v $
+Revision 1.34.2.1  2006/08/29 06:24:22  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.34  2006/03/18 21:47:56  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
+Revision 1.33  2006/03/10 21:51:41  cheshire
+<rdar://problem/4111464> After record update, old record sometimes remains in cache
+Split out SameRDataBody() into a separate routine so it can be called from other code
+
 Revision 1.32  2005/03/21 00:33:51  shersche
 <rdar://problem/4021486> Fix build warnings on Win32 platform
 
@@ -141,6 +145,7 @@ Revision 1.1  2003/12/13 03:05:27  ksekar
        extern "C" {
 #endif
 
+
 // ***************************************************************************
 #if COMPILER_LIKES_PRAGMA_MARK
 #pragma mark - DNS Protocol Constants
@@ -192,6 +197,7 @@ typedef enum
        TSIG_ErrBadTime = 18
        } TSIG_ErrorCode;
        
+
 // ***************************************************************************
 #if COMPILER_LIKES_PRAGMA_MARK
 #pragma mark -
@@ -202,6 +208,7 @@ extern const NetworkInterfaceInfo *GetFirstActiveInterface(const NetworkInterfac
 extern mDNSInterfaceID GetNextActiveInterfaceID(const NetworkInterfaceInfo *intf);
 
 extern mDNSu32 mDNSRandom(mDNSu32 max);
+extern mDNSu32 mDNSRandomFromFixedSeed(mDNSu32 seed, mDNSu32 max);
 
 
 // ***************************************************************************
@@ -235,6 +242,7 @@ extern void mDNS_HostNameCallback(mDNS *const m, AuthRecord *const rr, mStatus r
 
 extern mDNSu32 RDataHashValue(mDNSu16 const rdlength, const RDataBody *const rdb);
 
+extern mDNSBool SameRDataBody(const ResourceRecord *const r1, const RDataBody *const r2);
 extern mDNSBool SameRData(const ResourceRecord *const r1, const ResourceRecord *const r2);
 
 extern mDNSBool ResourceRecordAnswersQuestion(const ResourceRecord *const rr, const DNSQuestion *const q);
@@ -330,6 +338,7 @@ extern const mDNSu8 *LocateAuthorities(const DNSMessage *const msg, const mDNSu8
 
 extern const mDNSu8 *LocateAdditionals(const DNSMessage *const msg, const mDNSu8 *const end);
 
+
 // ***************************************************************************
 #if COMPILER_LIKES_PRAGMA_MARK
 #pragma mark -
@@ -340,6 +349,7 @@ extern const mDNSu8 *LocateAdditionals(const DNSMessage *const msg, const mDNSu8
 extern mStatus mDNSSendDNSMessage(const mDNS *const m, DNSMessage *const msg, mDNSu8 *end,
        mDNSInterfaceID InterfaceID, const mDNSAddr *dst, mDNSIPPort dstport, int sd, uDNS_AuthInfo *authInfo);
 
+
 // ***************************************************************************
 #if COMPILER_LIKES_PRAGMA_MARK
 #pragma mark -
index 89d7b013fd835b80f4d5d161eec39b94c0b26ff8..91b7078cc9ba4088aaa7b29b616474aa20d32a80 100644 (file)
@@ -1,28 +1,31 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: DNSDigest.c,v $
+Revision 1.15.2.1  2006/08/29 06:24:22  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.15  2006/06/20 04:12:30  cheshire
+<rdar://problem/4490961> DNS Update broken
+
+Revision 1.14  2006/02/25 23:12:07  cheshire
+<rdar://problem/4427969> Fix to avoid code generation warning/error on FreeBSD 7
+
 Revision 1.13  2004/12/16 20:12:59  cheshire
 <rdar://problem/3324626> Cache memory management improvements
 
@@ -1410,12 +1413,11 @@ mDNSexport mDNSu8 *DNSDigest_SignMessage(DNSMessage *msg, mDNSu8 **end, mDNSu16
        rdata += 6;                     
        MD5_Update(&c, utc48, 6);
 
-       // fudge
-       buf = mDNSOpaque16fromIntVal(300);     // 300 sec is fudge recommended in RFC 2485
-       rdata[0] = buf.b[0];
-       rdata[1] = buf.b[1];
+       // 300 sec is fudge recommended in RFC 2485
+       rdata[0] = (mDNSu8)((300 >> 8)  & 0xff);
+       rdata[1] = (mDNSu8)( 300        & 0xff);
+       MD5_Update(&c, rdata, sizeof(mDNSOpaque16));
        rdata += sizeof(mDNSOpaque16);
-       MD5_Update(&c, buf.b, sizeof(mDNSOpaque16));
 
        // digest error and other data len (both zero) - we'll add them to the rdata later
        buf.NotAnInteger = 0;
index 2098e1e8a8b5cde8662f772ced92fb7b856eb589..4eb871982aa0cd396101bae0755c8939d2505b15 100755 (executable)
@@ -1,25 +1,18 @@
 /* -*- Mode: C; tab-width: 4 -*-
  *
- * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 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@
  *
  * This code is completely 100% portable C. It does not depend on any external header files
  * from outside the mDNS project -- all the types it expects to find are defined right here.
     Change History (most recent first):
 
 $Log: mDNS.c,v $
+Revision 1.537.2.1  2006/08/29 06:24:22  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.537  2006/03/19 02:00:07  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
+Revision 1.536  2006/03/08 23:29:53  cheshire
+<rdar://problem/4468716> Improve "Service Renamed" log message
+
+Revision 1.535  2006/03/02 20:41:17  cheshire
+<rdar://problem/4111464> After record update, old record sometimes remains in cache
+Minor code tidying and comments to reduce the risk of similar programming errors in future
+
+Revision 1.534  2006/03/02 03:25:46  cheshire
+<rdar://problem/4111464> After record update, old record sometimes remains in cache
+Code to harmonize RRSet TTLs was inadvertently rescuing expiring records
+
+Revision 1.533  2006/02/26 00:54:41  cheshire
+Fixes to avoid code generation warning/error on FreeBSD 7
+
 Revision 1.532  2005/12/02 20:24:36  cheshire
 <rdar://problem/4363209> Adjust cutoff time for KA list by one second
 
@@ -1756,13 +1769,19 @@ mDNSexport const mDNSInterfaceID mDNSInterface_LocalOnly  = (mDNSInterfaceID)1;
 
 mDNSlocal  const mDNSInterfaceID mDNSInterfaceMark        = (mDNSInterfaceID)~0;
 
-#define UnicastDNSPortAsNumber 53
+#define UnicastDNSPortAsNumber   53
+#define NATPMPPortAsNumber       5351
+#define DNSEXTPortAsNumber       5352          // Port used for end-to-end DNS operations like LLQ, Updates with Leases, etc.
 #define MulticastDNSPortAsNumber 5353
+#define LoopbackIPCPortAsNumber  5354
+
 mDNSexport const mDNSIPPort UnicastDNSPort     = { { UnicastDNSPortAsNumber   >> 8, UnicastDNSPortAsNumber   & 0xFF } };
+mDNSexport const mDNSIPPort NATPMPPort         = { { NATPMPPortAsNumber       >> 8, NATPMPPortAsNumber       & 0xFF } };
+mDNSexport const mDNSIPPort DNSEXTPort         = { { DNSEXTPortAsNumber       >> 8, DNSEXTPortAsNumber       & 0xFF } };
 mDNSexport const mDNSIPPort MulticastDNSPort   = { { MulticastDNSPortAsNumber >> 8, MulticastDNSPortAsNumber & 0xFF } };
+mDNSexport const mDNSIPPort LoopbackIPCPort    = { { LoopbackIPCPortAsNumber  >> 8, LoopbackIPCPortAsNumber  & 0xFF } };
+
 mDNSexport const mDNSv4Addr AllDNSAdminGroup   = { { 239, 255, 255, 251 } };
-mDNSexport const mDNSv4Addr AllDNSLinkGroupv4  = { { 224,   0,   0, 251 } };
-mDNSexport const mDNSv6Addr AllDNSLinkGroupv6  = { { 0xFF,0x02,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xFB } };
 mDNSexport const mDNSAddr   AllDNSLinkGroup_v4 = { mDNSAddrType_IPv4, { { { 224,   0,   0, 251 } } } };
 mDNSexport const mDNSAddr   AllDNSLinkGroup_v6 = { mDNSAddrType_IPv6, { { { 0xFF,0x02,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xFB } } } };
 
@@ -1951,8 +1970,8 @@ mDNSexport mDNSu32 mDNS_vsnprintf(char *sbuffer, mDNSu32 buflen, const char *fmt
                                                                                                                "%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X",
                                                                                                                a[0x0], a[0x1], a[0x2], a[0x3], a[0x4], a[0x5], a[0x6], a[0x7],
                                                                                                                a[0x8], a[0x9], a[0xA], a[0xB], a[0xC], a[0xD], a[0xE], a[0xF]); break;
-                                                                       default: i = mDNS_snprintf(mDNS_VACB, sizeof(mDNS_VACB), "%s", "<< ERROR: Must specify address size "
-                                                                                                               "(i.e. %.4a=IPv4, %.6a=Ethernet, %.16a=IPv6) >>"); break;
+                                                                       default: i = mDNS_snprintf(mDNS_VACB, sizeof(mDNS_VACB), "%s", "<< ERROR: Must specify"
+                                                                                                               " address size (i.e. %.4a=IPv4, %.6a=Ethernet, %.16a=IPv6) >>"); break;
                                                                        }
                                                                }
                                                        }
@@ -2024,8 +2043,10 @@ mDNSexport mDNSu32 mDNS_vsnprintf(char *sbuffer, mDNSu32 buflen, const char *fmt
                                                                                if (*a == 0) *s++ = '.';        // Special case for root DNS name
                                                                                while (*a)
                                                                                        {
-                                                                                       if (*a > 63) { s += mDNS_snprintf(s, mDNS_VACB_Remain(s), "<<INVALID LABEL LENGTH %u>>", *a); break; }
-                                                                                       if (s + *a >= &mDNS_VACB[254]) { s += mDNS_snprintf(s, mDNS_VACB_Remain(s), "<<NAME TOO LONG>>"); break; }
+                                                                                       if (*a > 63)
+                                                                                               { s += mDNS_snprintf(s, mDNS_VACB_Remain(s), "<<INVALID LABEL LENGTH %u>>", *a); break; }
+                                                                                       if (s + *a >= &mDNS_VACB[254])
+                                                                                               { s += mDNS_snprintf(s, mDNS_VACB_Remain(s), "<<NAME TOO LONG>>"); break; }
                                                                                        s += mDNS_snprintf(s, mDNS_VACB_Remain(s), "%#s.", a);
                                                                                        a += 1 + *a;
                                                                                        }
@@ -2060,9 +2081,10 @@ mDNSexport mDNSu32 mDNS_vsnprintf(char *sbuffer, mDNSu32 buflen, const char *fmt
                                        } while (i < --F.fieldWidth);
        
                        // Make sure we don't truncate in the middle of a UTF-8 character.
-                       // Note: s[i] is the first eliminated character; i.e. the next character *after* the last character of the allowed output. If s[i] is a
-                       // UTF-8 continuation character, then we've cut a unicode character in half, so back up 'i' until s[i] is no longer a UTF-8 continuation
-                       // character. (if the input was proprly formed, s[i] will now be the UTF-8 start character of the multi-byte character we just eliminated).
+                       // Note: s[i] is the first eliminated character; i.e. the next character *after* the last character of the
+                       // allowed output. If s[i] is a UTF-8 continuation character, then we've cut a unicode character in half,
+                       // so back up 'i' until s[i] is no longer a UTF-8 continuation character. (if the input was proprly
+                       // formed, s[i] will now be the UTF-8 start character of the multi-byte character we just eliminated).
                        if (i > buflen - nwritten)
                                { i = buflen - nwritten; while (i>0 && (s[i] & 0xC0) == 0x80) i--; }
                        for (j=0; j<i; j++) *sbuffer++ = *s++;                  // Write the converted result
@@ -2212,8 +2234,8 @@ mDNSlocal void AnswerLocalOnlyQuestionWithResourceRecord(mDNS *const m, DNSQuest
        m->mDNS_reentrancy--; // Decrement to block mDNS API calls again
        }
 
-// When a new local AuthRecord is created or deleted, AnswerLocalQuestions() runs though our LocalOnlyQuestions delivering answers to each,
-// stopping if it reaches a NewLocalOnlyQuestion -- brand-new questions are handled by AnswerNewLocalOnlyQuestion().
+// When a new local AuthRecord is created or deleted, AnswerLocalQuestions() runs though our LocalOnlyQuestions delivering answers
+// to each, stopping if it reaches a NewLocalOnlyQuestion -- brand-new questions are handled by AnswerNewLocalOnlyQuestion().
 // If the AuthRecord is marked mDNSInterface_LocalOnly, then we also deliver it to any other questions we have using mDNSInterface_Any.
 // Used by AnswerForNewLocalRecords() and mDNS_Deregister_internal()
 mDNSlocal void AnswerLocalQuestions(mDNS *const m, AuthRecord *rr, mDNSBool AddRecord)
@@ -2299,7 +2321,11 @@ mDNSlocal mDNSBool SameResourceRecordSignature(const ResourceRecord *const r1, c
        if (r1->InterfaceID &&
                r2->InterfaceID &&
                r1->InterfaceID != r2->InterfaceID) return(mDNSfalse);
-       return(mDNSBool)(r1->rrtype == r2->rrtype && r1->rrclass == r2->rrclass && r1->namehash == r2->namehash && SameDomainName(r1->name, r2->name));
+       return(mDNSBool)(
+               r1->rrtype == r2->rrtype &&
+               r1->rrclass == r2->rrclass &&
+               r1->namehash == r2->namehash &&
+               SameDomainName(r1->name, r2->name));
        }
 
 // PacketRRMatchesSignature behaves as SameResourceRecordSignature, except that types may differ if our
@@ -2315,7 +2341,10 @@ mDNSlocal mDNSBool PacketRRMatchesSignature(const CacheRecord *const pktrr, cons
                authrr->resrec.InterfaceID &&
                pktrr->resrec.InterfaceID != authrr->resrec.InterfaceID) return(mDNSfalse);
        if (!(authrr->resrec.RecordType & kDNSRecordTypeUniqueMask) && pktrr->resrec.rrtype != authrr->resrec.rrtype) return(mDNSfalse);
-       return(mDNSBool)(pktrr->resrec.rrclass == authrr->resrec.rrclass && pktrr->resrec.namehash == authrr->resrec.namehash && SameDomainName(pktrr->resrec.name, authrr->resrec.name));
+       return(mDNSBool)(
+               pktrr->resrec.rrclass == authrr->resrec.rrclass &&
+               pktrr->resrec.namehash == authrr->resrec.namehash &&
+               SameDomainName(pktrr->resrec.name, authrr->resrec.name));
        }
 
 // IdenticalResourceRecord returns true if two resources records have
@@ -2324,7 +2353,8 @@ mDNSlocal mDNSBool IdenticalResourceRecord(const ResourceRecord *const r1, const
        {
        if (!r1) { LogMsg("IdenticalResourceRecord ERROR: r1 is NULL"); return(mDNSfalse); }
        if (!r2) { LogMsg("IdenticalResourceRecord ERROR: r2 is NULL"); return(mDNSfalse); }
-       if (r1->rrtype != r2->rrtype || r1->rrclass != r2->rrclass || r1->namehash != r2->namehash || !SameDomainName(r1->name, r2->name)) return(mDNSfalse);
+       if (r1->rrtype != r2->rrtype || r1->rrclass != r2->rrclass || r1->namehash != r2->namehash || !SameDomainName(r1->name, r2->name))
+               return(mDNSfalse);
        return(SameRData(r1, r2));
        }
 
@@ -2356,7 +2386,8 @@ mDNSlocal void SetNextAnnounceProbeTime(mDNS *const m, const AuthRecord *const r
        {
        if (rr->resrec.RecordType == kDNSRecordTypeUnique)
                {
-               //LogMsg("ProbeCount %d Next %ld %s", rr->ProbeCount, (rr->LastAPTime + rr->ThisAPInterval) - m->timenow, ARDisplayString(m, rr));
+               //LogMsg("ProbeCount %d Next %ld %s",
+               //      rr->ProbeCount, (rr->LastAPTime + rr->ThisAPInterval) - m->timenow, ARDisplayString(m, rr));
                if (m->NextScheduledProbe - (rr->LastAPTime + rr->ThisAPInterval) >= 0)
                        m->NextScheduledProbe = (rr->LastAPTime + rr->ThisAPInterval);
                }
@@ -2436,7 +2467,8 @@ mDNSlocal void SetTargetToHostName(mDNS *const m, AuthRecord *const rr)
                // changing to the new rdata. However, in practice, we only do SetTargetToHostName for unique records,
                // so when we announce them we'll set the kDNSClass_UniqueRRSet and clear any stale data that way.
                if (rr->RequireGoodbye && rr->resrec.RecordType == kDNSRecordTypeShared)
-                       debugf("Have announced shared record %##s (%s) at least once: should have sent a goodbye packet before updating", rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+                       debugf("Have announced shared record %##s (%s) at least once: should have sent a goodbye packet before updating",
+                               rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
 
                rr->AnnounceCount  = InitialAnnounceCount;
                rr->RequireGoodbye = mDNSfalse;
@@ -2459,8 +2491,10 @@ mDNSlocal void AcknowledgeRecord(mDNS *const m, AuthRecord *const rr)
        }
 
 // Two records qualify to be local duplicates if the RecordTypes are the same, or if one is Unique and the other Verified
-#define RecordLDT(A,B) ((A)->resrec.RecordType == (B)->resrec.RecordType || ((A)->resrec.RecordType | (B)->resrec.RecordType) == (kDNSRecordTypeUnique | kDNSRecordTypeVerified))
-#define RecordIsLocalDuplicate(A,B) ((A)->resrec.InterfaceID == (B)->resrec.InterfaceID && RecordLDT((A),(B)) && IdenticalResourceRecord(&(A)->resrec, &(B)->resrec))
+#define RecordLDT(A,B) ((A)->resrec.RecordType == (B)->resrec.RecordType || \
+       ((A)->resrec.RecordType | (B)->resrec.RecordType) == (kDNSRecordTypeUnique | kDNSRecordTypeVerified))
+#define RecordIsLocalDuplicate(A,B) \
+       ((A)->resrec.InterfaceID == (B)->resrec.InterfaceID && RecordLDT((A),(B)) && IdenticalResourceRecord(&(A)->resrec, &(B)->resrec))
 
 mDNSlocal mStatus mDNS_Register_internal(mDNS *const m, AuthRecord *const rr)
        {
@@ -2484,7 +2518,8 @@ mDNSlocal mStatus mDNS_Register_internal(mDNS *const m, AuthRecord *const rr)
        while (*d && *d != rr) d=&(*d)->next;
        if (*d || *p)
                {
-               LogMsg("Error! Tried to register a AuthRecord %p %##s (%s) that's already in the list", rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+               LogMsg("Error! Tried to register a AuthRecord %p %##s (%s) that's already in the list",
+                       rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
                return(mStatus_AlreadyRegistered);
                }
 
@@ -2710,7 +2745,8 @@ mDNSlocal mStatus mDNS_Deregister_internal(mDNS *const m, AuthRecord *const rr,
                        if (*d)
                                {
                                AuthRecord *dup = *d;
-                               debugf("Duplicate record %p taking over from %p %##s (%s)", dup, rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+                               debugf("Duplicate record %p taking over from %p %##s (%s)",
+                                       dup, rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
                                *d        = dup->next;          // Cut replacement record from DuplicateRecords list
                                dup->next = rr->next;           // And then...
                                rr->next  = dup;                        // ... splice it in right after the record we're about to delete
@@ -2739,14 +2775,16 @@ mDNSlocal mStatus mDNS_Deregister_internal(mDNS *const m, AuthRecord *const rr,
                while (*p && *p != rr) p=&(*p)->next;
                // If we found our record on the duplicate list, then make sure we don't send a goodbye for it
                if (*p) rr->RequireGoodbye = mDNSfalse;
-               if (*p) debugf("DNS_Deregister_internal: Deleting DuplicateRecord %p %##s (%s)", rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+               if (*p) debugf("DNS_Deregister_internal: Deleting DuplicateRecord %p %##s (%s)",
+                       rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
                }
 
        if (!*p)
                {
                // No need to log an error message if we already know this is a potentially repeated deregistration
                if (drt != mDNS_Dereg_repeat)
-                       LogMsg("mDNS_Deregister_internal: Record %p %##s (%s) not found in list", rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+                       LogMsg("mDNS_Deregister_internal: Record %p %##s (%s) not found in list",
+                               rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
                return(mStatus_BadReferenceErr);
                }
 
@@ -2754,7 +2792,8 @@ mDNSlocal mStatus mDNS_Deregister_internal(mDNS *const m, AuthRecord *const rr,
        // we need to retract that announcement before we delete the record
        if (RecordType == kDNSRecordTypeShared && rr->RequireGoodbye)
                {
-               verbosedebugf("mDNS_Deregister_internal: Sending deregister for %##s (%s)", rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+               verbosedebugf("mDNS_Deregister_internal: Sending deregister for %##s (%s)",
+                       rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
                rr->resrec.RecordType    = kDNSRecordTypeDeregistering;
                rr->resrec.rroriginalttl = 0;
                rr->ImmedAnswer          = mDNSInterfaceMark;
@@ -2777,7 +2816,8 @@ mDNSlocal mStatus mDNS_Deregister_internal(mDNS *const m, AuthRecord *const rr,
                                rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
                else
                        {
-                       verbosedebugf("mDNS_Deregister_internal: Deleting record for %##s (%s)", rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+                       verbosedebugf("mDNS_Deregister_internal: Deleting record for %##s (%s)",
+                               rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
                        rr->resrec.RecordType = kDNSRecordTypeUnregistered;
                        }
 
@@ -3067,7 +3107,8 @@ mDNSlocal void SendResponses(mDNS *const m)
                                {
                                for (r2 = m->ResourceRecords; r2; r2=r2->next)
                                        if (ResourceRecordIsValidAnswer(r2))
-                                               if (r2->ImmedAnswer != mDNSInterfaceMark && r2->ImmedAnswer != rr->ImmedAnswer && SameResourceRecordSignature(&r2->resrec, &rr->resrec))
+                                               if (r2->ImmedAnswer != mDNSInterfaceMark &&
+                                                       r2->ImmedAnswer != rr->ImmedAnswer && SameResourceRecordSignature(&r2->resrec, &rr->resrec))
                                                        r2->ImmedAnswer = rr->ImmedAnswer;
                                }
                        else if (rr->ImmedAdditional)   // If we're sending this as additional, see that its whole RRSet is similarly marked
@@ -3301,10 +3342,11 @@ mDNSlocal void SendResponses(mDNS *const m)
 
 // Note: MUST call SetNextCacheCheckTime any time we change:
 // rr->TimeRcvd
-// rr->DelayDelivery
 // rr->resrec.rroriginalttl
 // rr->UnansweredQueries
 // rr->CRActiveQuestion
+// Also, any time we set rr->DelayDelivery we should call SetNextCacheCheckTime to ensure m->NextCacheCheck is set if necessary
+// Clearing rr->DelayDelivery does not require a call to SetNextCacheCheckTime
 mDNSlocal void SetNextCacheCheckTime(mDNS *const m, CacheRecord *const rr)
        {
        rr->NextRequiredQuery = RRExpireTime(rr);
@@ -3315,8 +3357,9 @@ mDNSlocal void SetNextCacheCheckTime(mDNS *const m, CacheRecord *const rr)
                {
                rr->NextRequiredQuery -= TicksTTL(rr)/20 * (MaxUnansweredQueries - rr->UnansweredQueries);
                rr->NextRequiredQuery += mDNSRandom((mDNSu32)TicksTTL(rr)/50);
-               verbosedebugf("SetNextCacheCheckTime: %##s (%s) NextRequiredQuery in %ld sec",
-                       rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), (rr->NextRequiredQuery - m->timenow) / mDNSPlatformOneSecond);
+               verbosedebugf("SetNextCacheCheckTime: %##s (%s) NextRequiredQuery in %ld sec CacheCheckGracePeriod %d ticks",
+                       rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype),
+                       (rr->NextRequiredQuery - m->timenow) / mDNSPlatformOneSecond, CacheCheckGracePeriod(rr));
                }
 
        if (m->NextCacheCheck - (rr->NextRequiredQuery + CacheCheckGracePeriod(rr)) > 0)
@@ -3327,9 +3370,10 @@ mDNSlocal void SetNextCacheCheckTime(mDNS *const m, CacheRecord *const rr)
                        m->NextCacheCheck = rr->DelayDelivery;
        }
 
-#define kDefaultReconfirmTimeForNoAnswer        ((mDNSu32)mDNSPlatformOneSecond * 15)
-#define kDefaultReconfirmTimeForCableDisconnect ((mDNSu32)mDNSPlatformOneSecond *  5)
-#define kMinimumReconfirmTime                   ((mDNSu32)mDNSPlatformOneSecond *  5)
+#define kMinimumReconfirmTime                     ((mDNSu32)mDNSPlatformOneSecond *  5)
+#define kDefaultReconfirmTimeForWake              ((mDNSu32)mDNSPlatformOneSecond *  5)
+#define kDefaultReconfirmTimeForNoAnswer          ((mDNSu32)mDNSPlatformOneSecond * 15)
+#define kDefaultReconfirmTimeForFlappingInterface ((mDNSu32)mDNSPlatformOneSecond * 30)
 
 mDNSlocal mStatus mDNS_Reconfirm_internal(mDNS *const m, CacheRecord *const rr, mDNSu32 interval)
        {
@@ -3342,12 +3386,15 @@ mDNSlocal mStatus mDNS_Reconfirm_internal(mDNS *const m, CacheRecord *const rr,
        if (RRExpireTime(rr) - m->timenow > (mDNSs32)((interval * 4) / 3))
                {
                // Add a 33% random amount to the interval, to avoid synchronization between multiple hosts
-               interval += mDNSRandom(interval/3);
+               // For all the reconfirmations in a given batch, we want to use the same random value
+               // so that the reconfirmation questions can be grouped into a single query packet
+               if (!m->RandomReconfirmDelay) m->RandomReconfirmDelay = 1 + mDNSRandom(0x3FFFFFFF);
+               interval += mDNSRandomFromFixedSeed(m->RandomReconfirmDelay, interval/3);
                rr->TimeRcvd          = m->timenow - (mDNSs32)interval * 3;
-               rr->resrec.rroriginalttl     = interval * 4 / mDNSPlatformOneSecond;
+               rr->resrec.rroriginalttl     = (interval * 4 + mDNSPlatformOneSecond - 1) / mDNSPlatformOneSecond;
                SetNextCacheCheckTime(m, rr);
                }
-       debugf("mDNS_Reconfirm_internal:%5ld ticks to go for %s", RRExpireTime(rr) - m->timenow, CRDisplayString(m, rr));
+       debugf("mDNS_Reconfirm_internal:%6ld ticks to go for %s", RRExpireTime(rr) - m->timenow, CRDisplayString(m, rr));
        return(mStatus_NoError);
        }
 
@@ -3370,7 +3417,8 @@ mDNSlocal mDNSBool BuildQuestion(mDNS *const m, DNSMessage *query, mDNSu8 **quer
                }
        else if (newptr + *answerforecast >= limit)
                {
-               verbosedebugf("BuildQuestion: Retracting question %##s new forecast total %d", q->qname.c, newptr + *answerforecast - query->data);
+               verbosedebugf("BuildQuestion: Retracting question %##s new forecast total %d",
+                       q->qname.c, newptr + *answerforecast - query->data);
                query->h.numQuestions--;
                return(mDNSfalse);
                }
@@ -3553,6 +3601,10 @@ mDNSlocal mDNSBool AccelerateThisQuery(mDNS *const m, DNSQuestion *q)
 
 mDNSlocal void SendQueries(mDNS *const m)
        {
+       mDNSu32 slot;
+       CacheGroup *cg;
+       CacheRecord *cr;
+       AuthRecord *ar;
        int pktcount = 0;
        DNSQuestion *q;
        // For explanation of maxExistingQuestionInterval logic, see comments for maxExistingAnnounceInterval
@@ -3563,8 +3615,6 @@ mDNSlocal void SendQueries(mDNS *const m)
        // 1. If time for a query, work out what we need to do
        if (m->timenow - m->NextScheduledQuery >= 0)
                {
-               mDNSu32 slot;
-               CacheGroup *cg;
                CacheRecord *rr;
                m->NextScheduledQuery = m->timenow + 0x78000000;
 
@@ -3618,7 +3668,8 @@ mDNSlocal void SendQueries(mDNS *const m)
                                (!q->Target.type && ActiveQuestion(q) && q->ThisQInterval <= maxExistingQuestionInterval && AccelerateThisQuery(m,q)))
                                {
                                // If at least halfway to next query time, advance to next interval
-                               // If less than halfway to next query time, treat this as logically a repeat of the last transmission, without advancing the interval
+                               // If less than halfway to next query time, then
+                               // treat this as logically a repeat of the last transmission, without advancing the interval
                                if (m->timenow - (q->LastQTime + q->ThisQInterval/2) >= 0)
                                        {
                                        q->SendQNow = mDNSInterfaceMark;        // Mark this question for sending on all interfaces
@@ -3627,8 +3678,9 @@ mDNSlocal void SendQueries(mDNS *const m)
                                                q->ThisQInterval = MaxQuestionInterval;
                                        else if (q->CurrentAnswers == 0 && q->ThisQInterval == InitialQuestionInterval * 8)
                                                {
-                                               debugf("SendQueries: Zero current answers for %##s (%s); will reconfirm antecedents", q->qname.c, DNSTypeName(q->qtype));
-                                               ReconfirmAntecedents(m, q);             // If sending third query, and no answers yet, time to begin doubting the source
+                                               debugf("SendQueries: Zero current answers for %##s (%s); will reconfirm antecedents",
+                                                       q->qname.c, DNSTypeName(q->qtype));
+                                               ReconfirmAntecedents(m, q);             // Sending third query, and no answers yet; time to begin doubting the source
                                                }
                                        }
 
@@ -3680,7 +3732,8 @@ mDNSlocal void SendQueries(mDNS *const m)
                                        rr->ProbeCount--;
                                        SetNextAnnounceProbeTime(m, rr);
                                        }
-                               // else, if it has now finished probing, move it to state Verified, and update m->NextScheduledResponse so it will be announced
+                               // else, if it has now finished probing, move it to state Verified,
+                               // and update m->NextScheduledResponse so it will be announced
                                else
                                        {
                                        AuthRecord *r2;
@@ -3706,7 +3759,8 @@ mDNSlocal void SendQueries(mDNS *const m)
                        }
                }
 
-       // 3. Now we know which queries and probes we're sending, go through our interface list sending the appropriate queries on each interface
+       // 3. Now we know which queries and probes we're sending,
+       // go through our interface list sending the appropriate queries on each interface
        while (intf)
                {
                AuthRecord *rr;
@@ -3748,11 +3802,13 @@ mDNSlocal void SendQueries(mDNS *const m)
                                                answerforecast = forecast;
                                                rr->SendRNow = (rr->resrec.InterfaceID) ? mDNSNULL : GetNextActiveInterfaceID(intf);
                                                rr->IncludeInProbe = mDNStrue;
-                                               verbosedebugf("SendQueries:   Put Question %##s (%s) probecount %d", rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), rr->ProbeCount);
+                                               verbosedebugf("SendQueries:   Put Question %##s (%s) probecount %d",
+                                                       rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), rr->ProbeCount);
                                                }
                                        else
                                                {
-                                               verbosedebugf("SendQueries:   Retracting Question %##s (%s)", rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+                                               verbosedebugf("SendQueries:   Retracting Question %##s (%s)",
+                                                       rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
                                                m->omsg.h.numQuestions--;
                                                }
                                        }
@@ -3766,7 +3822,8 @@ mDNSlocal void SendQueries(mDNS *const m)
                        mDNSu8 *newptr = PutResourceRecordTTL(&m->omsg, queryptr, &m->omsg.h.numAnswers, &rr->resrec, rr->resrec.rroriginalttl - SecsSinceRcvd);
                        if (newptr)
                                {
-                               verbosedebugf("SendQueries:   Put %##s (%s) at %d - %d", rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), queryptr - m->omsg.data, newptr - m->omsg.data);
+                               verbosedebugf("SendQueries:   Put %##s (%s) at %d - %d",
+                                       rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), queryptr - m->omsg.data, newptr - m->omsg.data);
                                queryptr = newptr;
                                KnownAnswerList = rr->NextInKAList;
                                rr->NextInKAList = mDNSNULL;
@@ -3819,17 +3876,39 @@ mDNSlocal void SendQueries(mDNS *const m)
                        }
                }
 
-       // Final sanity check for debugging purposes
-               {
-               AuthRecord *rr;
-               for (rr = m->ResourceRecords; rr; rr=rr->next)
-                       if (rr->SendRNow)
-                               {
-                               if (rr->resrec.InterfaceID != mDNSInterface_LocalOnly)
-                                       LogMsg("SendQueries: No active interface to send: %s", ARDisplayString(m, rr));
-                               rr->SendRNow = mDNSNULL;
-                               }
-               }
+       // 4. Final housekeeping
+       
+       // 4a. Debugging check: Make sure we announced all our records
+       for (ar = m->ResourceRecords; ar; ar=ar->next)
+               if (ar->SendRNow)
+                       {
+                       if (ar->resrec.InterfaceID != mDNSInterface_LocalOnly)
+                               LogMsg("SendQueries: No active interface to send: %s", ARDisplayString(m, ar));
+                       ar->SendRNow = mDNSNULL;
+                       }
+
+       // 4b. When we have lingering cache records that we're keeping around for a few seconds in the hope
+       // that their interface which went away might come back again, the logic will want to send queries
+       // for those records, but we can't because their interface isn't here any more, so to keep the
+       // state machine ticking over we just pretend we did so.
+       // If the interface does not come back in time, the cache record will expire naturally
+       FORALL_CACHERECORDS(slot, cg, cr)
+               if (cr->CRActiveQuestion && cr->UnansweredQueries < MaxUnansweredQueries && m->timenow - cr->NextRequiredQuery >= 0)
+                       {
+                       cr->UnansweredQueries++;
+                       cr->CRActiveQuestion->SendQNow = mDNSNULL;
+                       SetNextCacheCheckTime(m, cr);
+                       }
+
+       // 4c. Debugging check: Make sure we sent all our planned questions
+       // Do this AFTER the lingering cache records check above, because that will prevent spurious warnings for questions
+       // we legitimately couldn't send because the interface is no longer available
+       for (q = m->Questions; q; q=q->next)
+               if (q->SendQNow)
+                       {
+                       LogMsg("SendQueries: No active interface to send: %##s %s", q->qname.c, DNSTypeName(q->qtype));
+                       q->SendQNow = mDNSNULL;
+                       }
        }
 
 // ***************************************************************************
@@ -3888,7 +3967,7 @@ mDNSlocal void AnswerQuestionWithResourceRecord(mDNS *const m, DNSQuestion *q, C
 
 mDNSlocal void CacheRecordDeferredAdd(mDNS *const m, CacheRecord *rr)
        {
-       rr->DelayDelivery = 0;
+       rr->DelayDelivery = 0;          // Note, only need to call SetNextCacheCheckTime() when DelayDelivery is set, not when it's cleared
        if (m->CurrentQuestion) LogMsg("CacheRecordDeferredAdd ERROR m->CurrentQuestion already set");
        m->CurrentQuestion = m->Questions;
        while (m->CurrentQuestion && m->CurrentQuestion != m->NewQuestions)
@@ -3935,11 +4014,12 @@ mDNSlocal void CacheRecordAdd(mDNS *const m, CacheRecord *rr)
                m->CurrentQuestion = q->next;
                if (ResourceRecordAnswersQuestion(&rr->resrec, q))
                        {
-                       // If this question is one that's actively sending queries, and it's received ten answers within one second of sending the last
-                       // query packet, then that indicates some radical network topology change, so reset its exponential backoff back to the start.
-                       // We must be at least at the eight-second interval to do this. If we're at the four-second interval, or less,
-                       // there's not much benefit accelerating because we will anyway send another query within a few seconds.
-                       // The first reset query is sent out randomized over the next four seconds to reduce possible synchronization between machines.
+                       // If this question is one that's actively sending queries, and it's received ten answers within one
+                       // second of sending the last query packet, then that indicates some radical network topology change,
+                       // so reset its exponential backoff back to the start. We must be at least at the eight-second interval
+                       // to do this. If we're at the four-second interval, or less, there's not much benefit accelerating
+                       // because we will anyway send another query within a few seconds. The first reset query is sent out
+                       // randomized over the next four seconds to reduce possible synchronization between machines.
                        if (q->LastAnswerPktNum != m->PktNum)
                                {
                                q->LastAnswerPktNum = m->PktNum;
@@ -3953,7 +4033,8 @@ mDNSlocal void CacheRecordAdd(mDNS *const m, CacheRecord *rr)
                                        SetNextQueryTime(m,q);
                                        }
                                }
-                       verbosedebugf("CacheRecordAdd %p %##s (%s) %lu", rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), rr->resrec.rroriginalttl);
+                       verbosedebugf("CacheRecordAdd %p %##s (%s) %lu",
+                               rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), rr->resrec.rroriginalttl);
                        q->CurrentAnswers++;
                        if (rr->resrec.rdlength > SmallRecordLimit) q->LargeAnswers++;
                        if (rr->resrec.RecordType & kDNSRecordTypePacketUniqueMask) q->UniqueAnswers++;
@@ -3971,6 +4052,7 @@ mDNSlocal void CacheRecordAdd(mDNS *const m, CacheRecord *rr)
                        }
                }
        m->CurrentQuestion = mDNSNULL;
+       SetNextCacheCheckTime(m, rr);
        }
 
 // NoCacheAnswer is only called from mDNSCoreReceiveResponse, *never* directly as a result of a client API call.
@@ -3986,7 +4068,7 @@ mDNSlocal void CacheRecordAdd(mDNS *const m, CacheRecord *rr)
 mDNSlocal void NoCacheAnswer(mDNS *const m, CacheRecord *rr)
        {
        LogMsg("No cache space: Delivering non-cached result for %##s", m->rec.r.resrec.name->c);
-       if (m->CurrentQuestion) LogMsg("CacheRecordAdd ERROR m->CurrentQuestion already set");
+       if (m->CurrentQuestion) LogMsg("NoCacheAnswer ERROR m->CurrentQuestion already set");
        m->CurrentQuestion = m->Questions;
        while (m->CurrentQuestion)
                {
@@ -4017,9 +4099,10 @@ mDNSlocal void CacheRecordRmv(mDNS *const m, CacheRecord *rr)
                m->CurrentQuestion = q->next;
                if (ResourceRecordAnswersQuestion(&rr->resrec, q))
                        {
-                       verbosedebugf("CacheRecordRmv %p %##s (%s)", rr, rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype));
+                       verbosedebugf("CacheRecordRmv %p %s", rr, CRDisplayString(m, rr));
                        if (q->CurrentAnswers == 0)
-                               LogMsg("CacheRecordRmv ERROR: How can CurrentAnswers already be zero for %p %##s (%s)?", q, q->qname.c, DNSTypeName(q->qtype));
+                               LogMsg("CacheRecordRmv ERROR: How can CurrentAnswers already be zero for %p %##s (%s)?",
+                                       q, q->qname.c, DNSTypeName(q->qtype));
                        else
                                {
                                q->CurrentAnswers--;
@@ -4028,9 +4111,11 @@ mDNSlocal void CacheRecordRmv(mDNS *const m, CacheRecord *rr)
                                }
                        if (q->CurrentAnswers == 0)
                                {
-                               debugf("CacheRecordRmv: Zero current answers for %##s (%s); will reconfirm antecedents", q->qname.c, DNSTypeName(q->qtype));
+                               debugf("CacheRecordRmv: Zero current answers for %##s (%s); will reconfirm antecedents",
+                                       q->qname.c, DNSTypeName(q->qtype));
                                ReconfirmAntecedents(m, q);
                                }
+                       q->FlappingInterface = mDNSNULL;
                        AnswerQuestionWithResourceRecord(m, q, rr, mDNSfalse);
                        // MUST NOT dereference q again after calling AnswerQuestionWithResourceRecord()
                        }
@@ -4053,8 +4138,10 @@ mDNSlocal void ReleaseCacheGroup(mDNS *const m, CacheGroup **cp)
        {
        CacheEntity *e = (CacheEntity *)(*cp);
        //LogMsg("ReleaseCacheGroup: Releasing CacheGroup for %p, %##s", (*cp)->name->c, (*cp)->name->c);
-       if ((*cp)->rrcache_tail != &(*cp)->members) LogMsg("ERROR: (*cp)->members == mDNSNULL but (*cp)->rrcache_tail != &(*cp)->members)");
-       //if ((*cp)->name != (domainname*)((*cp)->namestorage)) LogMsg("ReleaseCacheGroup: %##s, %p %p", (*cp)->name->c, (*cp)->name, (domainname*)((*cp)->namestorage));
+       if ((*cp)->rrcache_tail != &(*cp)->members)
+               LogMsg("ERROR: (*cp)->members == mDNSNULL but (*cp)->rrcache_tail != &(*cp)->members)");
+       //if ((*cp)->name != (domainname*)((*cp)->namestorage))
+       //      LogMsg("ReleaseCacheGroup: %##s, %p %p", (*cp)->name->c, (*cp)->name, (domainname*)((*cp)->namestorage));
        if ((*cp)->name != (domainname*)((*cp)->namestorage)) mDNSPlatformMemFree((*cp)->name);
        (*cp)->name = mDNSNULL;
        *cp = (*cp)->next;                      // Cut record from list
@@ -4068,8 +4155,9 @@ mDNSlocal void ReleaseCacheRecord(mDNS *const m, CacheRecord *r)
        ReleaseCacheEntity(m, (CacheEntity *)r);
        }
 
-// Note: We want to be careful that we deliver all the CacheRecordRmv calls before delivering CacheRecordDeferredAdd calls
-// The in-order nature of the cache lists ensures that all callbacks for old records are delivered before callbacks for newer records
+// Note: We want to be careful that we deliver all the CacheRecordRmv calls before delivering
+// CacheRecordDeferredAdd calls. The in-order nature of the cache lists ensures that all
+// callbacks for old records are delivered before callbacks for newer records.
 mDNSlocal void CheckCacheExpiration(mDNS *const m, CacheGroup *cg)
        {
        CacheRecord **rp = &cg->members;
@@ -4109,11 +4197,13 @@ mDNSlocal void CheckCacheExpiration(mDNS *const m, CacheGroup *cg)
                                                // SendQueries() will see that we have records close to expiration, and send FEQs for them.
                                                m->NextScheduledQuery = m->timenow;
                                                // After sending the query we'll increment UnansweredQueries and call SetNextCacheCheckTime(),
-                                               // which will correctly update m->NextCacheCheck for us
+                                               // which will correctly update m->NextCacheCheck for us.
                                                event = m->timenow + 0x3FFFFFFF;
                                                }
                                        }
                                }
+                       verbosedebugf("CheckCacheExpiration:%6d %5d %s",
+                               (event-m->timenow) / mDNSPlatformOneSecond, CacheCheckGracePeriod(rr), CRDisplayString(m, rr));
                        if (m->NextCacheCheck - (event + CacheCheckGracePeriod(rr)) > 0)
                                m->NextCacheCheck = (event + CacheCheckGracePeriod(rr));
                        rp = &rr->next;
@@ -4202,8 +4292,8 @@ mDNSlocal void AnswerNewQuestion(mDNS *const m)
        m->lock_rrcache = 0;
        }
 
-// When a NewLocalOnlyQuestion is created, AnswerNewLocalOnlyQuestion runs though our ResourceRecords delivering any appropriate answers,
-// stopping if it reaches a NewLocalRecord -- these will be handled by AnswerLocalQuestions
+// When a NewLocalOnlyQuestion is created, AnswerNewLocalOnlyQuestion runs though our ResourceRecords delivering any
+// appropriate answers, stopping if it reaches a NewLocalRecord -- these will be handled by AnswerLocalQuestions
 mDNSlocal void AnswerNewLocalOnlyQuestion(mDNS *const m)
        {
        DNSQuestion *q = m->NewLocalOnlyQuestions;              // Grab the question we're going to answer
@@ -4288,7 +4378,8 @@ mDNSlocal CacheEntity *GetCacheEntity(mDNS *const m, const CacheGroup *const Pre
                                                ReleaseCacheRecord(m, rr);
                                                }
                                        }
-                               if ((*cp)->rrcache_tail != rp) verbosedebugf("GetFreeCacheRR: Updating rrcache_tail[%lu] from %p to %p", slot, (*cp)->rrcache_tail, rp);
+                               if ((*cp)->rrcache_tail != rp)
+                                       verbosedebugf("GetFreeCacheRR: Updating rrcache_tail[%lu] from %p to %p", slot, (*cp)->rrcache_tail, rp);
                                (*cp)->rrcache_tail = rp;
                                if ((*cp)->members || (*cp)==PreserveCG) cp=&(*cp)->next;
                                else ReleaseCacheGroup(m, cp);
@@ -4343,7 +4434,8 @@ mDNSlocal CacheGroup *GetCacheGroup(mDNS *const m, const mDNSu32 slot, const Res
        cg->members      = mDNSNULL;
        cg->rrcache_tail = &cg->members;
        cg->name         = (domainname*)cg->namestorage;
-       //LogMsg("GetCacheGroup: %-10s %d-byte cache name %##s", (namelen > InlineCacheGroupNameSize) ? "Allocating" : "Inline", namelen, rr->name->c);
+       //LogMsg("GetCacheGroup: %-10s %d-byte cache name %##s",
+       //      (namelen > InlineCacheGroupNameSize) ? "Allocating" : "Inline", namelen, rr->name->c);
        if (namelen > InlineCacheGroupNameSize) cg->name = mDNSPlatformMemAllocate(namelen);
        if (!cg->name)
                {
@@ -4421,6 +4513,7 @@ mDNSexport mDNSs32 mDNS_Execute(mDNS *const m)
                                        else ReleaseCacheGroup(m, cp);
                                        }
                                }
+                       LogOperation("Cache checked. Next in %ld ticks", m->NextCacheCheck - m->timenow);
                        }
        
                // 4. See if we can answer any of our new local questions from the cache
@@ -4448,10 +4541,10 @@ mDNSexport mDNSs32 mDNS_Execute(mDNS *const m)
                        {
                        // If the platform code is ready, and we're not suppressing packet generation right now
                        // then send our responses, probes, and questions.
-                       // We check the cache first, because there might be records close to expiring that trigger questions to refresh them
+                       // We check the cache first, because there might be records close to expiring that trigger questions to refresh them.
                        // We send queries next, because there might be final-stage probes that complete their probing here, causing
                        // them to advance to announcing state, and we want those to be included in any announcements we send out.
-                       // Finally, we send responses, including the previously mentioned records that just completed probing
+                       // Finally, we send responses, including the previously mentioned records that just completed probing.
                        m->SuppressSending = 0;
        
                        // 6. Send Query packets. This may cause some probing records to advance to announcing state
@@ -4476,7 +4569,9 @@ mDNSexport mDNSs32 mDNS_Execute(mDNS *const m)
                                }
                        }
 
-               m->RandomQueryDelay = 0;        // Clear m->RandomQueryDelay, ready to pick a new different value, when necessary
+               // Clear RandomDelay values, ready to pick a new different value next time
+               m->RandomQueryDelay     = 0;
+               m->RandomReconfirmDelay = 0;
                }
 
        // Note about multi-threaded systems:
@@ -4562,7 +4657,7 @@ mDNSexport void mDNSCoreMachineSleep(mDNS *const m, mDNSBool sleepstate)
                // 2. Re-validate our cache records
                m->NextCacheCheck  = m->timenow;
                FORALL_CACHERECORDS(slot, cg, cr)
-                       mDNS_Reconfirm_internal(m, cr, kDefaultReconfirmTimeForCableDisconnect);
+                       mDNS_Reconfirm_internal(m, cr, kDefaultReconfirmTimeForWake);
 
                // 3. Retrigger probing and announcing for all our authoritative records
                for (rr = m->ResourceRecords; rr; rr=rr->next)
@@ -4805,8 +4900,8 @@ mDNSlocal CacheRecord *FindIdenticalRecordInCache(const mDNS *const m, ResourceR
 
 // ProcessQuery examines a received query to see if we have any answers to give
 mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, const mDNSu8 *const end,
-       const mDNSAddr *srcaddr, const mDNSInterfaceID InterfaceID, mDNSBool LegacyQuery, mDNSBool QueryWasMulticast, mDNSBool QueryWasLocalUnicast,
-       DNSMessage *const response)
+       const mDNSAddr *srcaddr, const mDNSInterfaceID InterfaceID, mDNSBool LegacyQuery, mDNSBool QueryWasMulticast,
+       mDNSBool QueryWasLocalUnicast, DNSMessage *const response)
        {
        mDNSBool      FromLocalSubnet    = AddressIsLocalSubnet(m, InterfaceID, srcaddr);
        AuthRecord   *ResponseRecords    = mDNSNULL;
@@ -4926,7 +5021,9 @@ mDNSlocal mDNSu8 *ProcessQuery(mDNS *const m, const DNSMessage *const query, con
                                        if (!q->Target.type && ActiveQuestion(q) && m->timenow - q->LastQTxTime > mDNSPlatformOneSecond / 4)
                                                if (!q->InterfaceID || q->InterfaceID == InterfaceID)
                                                        if (q->NextInDQList == mDNSNULL && dqp != &q->NextInDQList)
-                                                               if (q->qtype == pktq.qtype && q->qclass == pktq.qclass && q->qnamehash == pktq.qnamehash && SameDomainName(&q->qname, &pktq.qname))
+                                                               if (q->qtype == pktq.qtype &&
+                                                                       q->qclass == pktq.qclass &&
+                                                                       q->qnamehash == pktq.qnamehash && SameDomainName(&q->qname, &pktq.qname))
                                                                        { *dqp = q; dqp = &q->NextInDQList; }
                        }
                }
@@ -5232,7 +5329,8 @@ mDNSlocal void mDNSCoreReceiveQuery(mDNS *const m, const DNSMessage *const msg,
        
        if (!InterfaceID && mDNSAddrIsDNSMulticast(dstaddr))
                {
-               LogMsg("Ignoring Query from %#-15a:%-5d to %#-15a:%-5d on 0x%p with %2d Question%s %2d Answer%s %2d Authorit%s %2d Additional%s (Multicast, but no InterfaceID)",
+               LogMsg("Ignoring Query from %#-15a:%-5d to %#-15a:%-5d on 0x%p with "
+                       "%2d Question%s %2d Answer%s %2d Authorit%s %2d Additional%s (Multicast, but no InterfaceID)",
                        srcaddr, mDNSVal16(srcport), dstaddr, mDNSVal16(dstport), InterfaceID,
                        msg->h.numQuestions,   msg->h.numQuestions   == 1 ? ", " : "s,",
                        msg->h.numAnswers,     msg->h.numAnswers     == 1 ? ", " : "s,",
@@ -5241,7 +5339,8 @@ mDNSlocal void mDNSCoreReceiveQuery(mDNS *const m, const DNSMessage *const msg,
                return;
                }
        
-       verbosedebugf("Received Query from %#-15a:%-5d to %#-15a:%-5d on 0x%p with %2d Question%s %2d Answer%s %2d Authorit%s %2d Additional%s",
+       verbosedebugf("Received Query from %#-15a:%-5d to %#-15a:%-5d on 0x%p with "
+               "%2d Question%s %2d Answer%s %2d Authorit%s %2d Additional%s",
                srcaddr, mDNSVal16(srcport), dstaddr, mDNSVal16(dstport), InterfaceID,
                msg->h.numQuestions,   msg->h.numQuestions   == 1 ? ", " : "s,",
                msg->h.numAnswers,     msg->h.numAnswers     == 1 ? ", " : "s,",
@@ -5290,7 +5389,8 @@ mDNSlocal void mDNSCoreReceiveResponse(mDNS *const m,
        (void)srcport;
        (void)dstport;
 
-       verbosedebugf("Received Response from %#-15a addressed to %#-15a on %p with %2d Question%s %2d Answer%s %2d Authorit%s %2d Additional%s",
+       verbosedebugf("Received Response from %#-15a addressed to %#-15a on %p with "
+               "%2d Question%s %2d Answer%s %2d Authorit%s %2d Additional%s",
                srcaddr, dstaddr, InterfaceID,
                response->h.numQuestions,   response->h.numQuestions   == 1 ? ", " : "s,",
                response->h.numAnswers,     response->h.numAnswers     == 1 ? ", " : "s,",
@@ -5487,9 +5587,7 @@ mDNSlocal void mDNSCoreReceiveResponse(mDNS *const m,
                                                rr->DelayDelivery = m->timenow + mDNSPlatformOneSecond; // to delay delivery of this 'add' event
                                        else
                                                rr->DelayDelivery = CheckForSoonToExpireRecords(m, rr->resrec.name, rr->resrec.namehash, slot);
-                                       CacheRecordAdd(m, rr);
-                                       // MUST do this AFTER CacheRecordAdd(), because that's what sets CRActiveQuestion for us
-                                       SetNextCacheCheckTime(m, rr);
+                                       CacheRecordAdd(m, rr);  // CacheRecordAdd calls SetNextCacheCheckTime(m, rr); for us
                                        }
                                }
                        }
@@ -5511,13 +5609,20 @@ exit:
                for (r2 = cg ? cg->members : mDNSNULL; r2; r2=r2->next)
                        if (SameResourceRecordSignature(&r1->resrec, &r2->resrec))
                                {
-                               // If record is recent, just ensure the whole RRSet has the same TTL (as required by DNS semantics)
-                               // else, if record is old, mark it to be flushed
-                               if (m->timenow - r2->TimeRcvd < mDNSPlatformOneSecond)
+                               // If record was recently positively received
+                               // (i.e. not counting goodbye packets or cache flush events that set the TTL to 1)
+                               // then we need to ensure the whole RRSet has the same TTL (as required by DNS semantics)
+                               if (r2->resrec.rroriginalttl > 1 && m->timenow - r2->TimeRcvd < mDNSPlatformOneSecond)
+                                       {
+                                       if (r2->resrec.rroriginalttl != r1->resrec.rroriginalttl)
+                                               LogMsg("Correcting TTL from %4d to %4d for %s",
+                                                       r2->resrec.rroriginalttl, r1->resrec.rroriginalttl, CRDisplayString(m, r2));
                                        r2->resrec.rroriginalttl = r1->resrec.rroriginalttl;
-                               else
+                                       r2->TimeRcvd = m->timenow;
+                                       }
+                               else                            // else, if record is old, mark it to be flushed
                                        {
-                                       verbosedebugf("Cache flush %p X %p %##s (%s)", r1, r2, r2->resrec.name->c, DNSTypeName(r2->resrec.rrtype));
+                                       verbosedebugf("Cache flush %p X %p %s", r1, r2, CRDisplayString(m, r2));
                                        // We set stale records to expire in one second.
                                        // This gives the owner a chance to rescue it if necessary.
                                        // This is important in the case of multi-homing and bridged networks:
@@ -5532,11 +5637,12 @@ exit:
                                        r2->resrec.rroriginalttl = 1;
                                        r2->TimeRcvd          = m->timenow;
                                        r2->UnansweredQueries = MaxUnansweredQueries;
-                                       SetNextCacheCheckTime(m, r2);
                                        }
+                               SetNextCacheCheckTime(m, r2);
                                }
                if (r1->DelayDelivery)  // If we were planning to delay delivery of this record, see if we still need to
                        {
+                       // Note, only need to call SetNextCacheCheckTime() when DelayDelivery is set, not when it's cleared
                        r1->DelayDelivery = CheckForSoonToExpireRecords(m, r1->resrec.name, r1->resrec.namehash, slot);
                        if (!r1->DelayDelivery) CacheRecordDeferredAdd(m, r1);
                        }
@@ -5555,9 +5661,7 @@ mDNSexport void mDNSCoreReceive(mDNS *const m, void *const pkt, const mDNSu8 *co
        const mDNSu8 UpdateR = kDNSFlag0_QR_Response | kDNSFlag0_OP_Update;
 
 #ifndef UNICAST_DISABLED       
-       mDNSIPPort NATPort = mDNSOpaque16fromIntVal(NATMAP_PORT);
-
-       if (srcport.NotAnInteger == NATPort.NotAnInteger)
+       if (srcport.NotAnInteger == NATPMPPort.NotAnInteger)
                {
                mDNS_Lock(m);
                uDNS_ReceiveNATMap(m, pkt, (mDNSu16)(end - (mDNSu8 *)pkt));
@@ -5693,17 +5797,15 @@ mDNSlocal mStatus mDNS_StartQuery_internal(mDNS *const m, DNSQuestion *const que
                        return(mStatus_AlreadyRegistered);
                        }
 
-               // If this question is referencing a specific interface, make sure it exists
+               // If this question is referencing a specific interface, verify it exists
                if (question->InterfaceID && question->InterfaceID != mDNSInterface_LocalOnly)
                        {
                        NetworkInterfaceInfo *intf;
                        for (intf = m->HostInterfaces; intf; intf = intf->next)
                                if (intf->InterfaceID == question->InterfaceID) break;
                        if (!intf)
-                               {
-                               debugf("mDNS_StartQuery_internal: Question %##s InterfaceID %p not found", question->qname.c, question->InterfaceID);
-                               return(mStatus_BadInterfaceErr);
-                               }
+                               LogMsg("Note: InterfaceID %p for question %##s not currently found in active interface list",
+                                       question->InterfaceID, question->qname.c);
                        }
 
                if (!ValidateDomainName(&question->qname))
@@ -5718,32 +5820,35 @@ mDNSlocal mStatus mDNS_StartQuery_internal(mDNS *const m, DNSQuestion *const que
                // that we have *no* relevant answers currently in our cache, then it will accelerate that to go out immediately.
                if (!m->RandomQueryDelay) m->RandomQueryDelay = 1 + (mDNSs32)mDNSRandom((mDNSu32)InitialQuestionInterval);
 
-               question->next             = mDNSNULL;
-               question->qnamehash        = DomainNameHashValue(&question->qname);     // MUST do this before FindDuplicateQuestion()
-               question->DelayAnswering   = CheckForSoonToExpireRecords(m, &question->qname, question->qnamehash, HashSlot(&question->qname));
-               question->ThisQInterval    = InitialQuestionInterval * 2;                       // MUST be > zero for an active question
-               question->RequestUnicast   = 2;                                                                         // Set to 2 because is decremented once *before* we check it
-               question->LastQTime        = m->timenow - m->RandomQueryDelay;          // Avoid inter-machine synchronization
-               question->LastAnswerPktNum = m->PktNum;
-               question->RecentAnswerPkts = 0;
-               question->CurrentAnswers   = 0;
-               question->LargeAnswers     = 0;
-               question->UniqueAnswers    = 0;
-               question->DuplicateOf      = FindDuplicateQuestion(m, question);
-               question->NextInDQList     = mDNSNULL;
+               question->next              = mDNSNULL;
+               question->qnamehash         = DomainNameHashValue(&question->qname);    // MUST do this before FindDuplicateQuestion()
+               question->DelayAnswering    = CheckForSoonToExpireRecords(m, &question->qname, question->qnamehash, HashSlot(&question->qname));
+               question->ThisQInterval     = InitialQuestionInterval * 2;                      // MUST be > zero for an active question
+               question->RequestUnicast    = 2;                                                                                // Set to 2 because is decremented once *before* we check it
+               question->LastQTime         = m->timenow - m->RandomQueryDelay;         // Avoid inter-machine synchronization
+               question->LastAnswerPktNum  = m->PktNum;
+               question->RecentAnswerPkts  = 0;
+               question->CurrentAnswers    = 0;
+               question->LargeAnswers      = 0;
+               question->UniqueAnswers     = 0;
+               question->FlappingInterface = mDNSNULL;
+               question->DuplicateOf       = FindDuplicateQuestion(m, question);
+               question->NextInDQList      = mDNSNULL;
                for (i=0; i<DupSuppressInfoSize; i++)
                        question->DupSuppress[i].InterfaceID = mDNSNULL;
                // question->InterfaceID must be already set by caller
-               question->SendQNow         = mDNSNULL;
-               question->SendOnAll        = mDNSfalse;
-               question->LastQTxTime      = m->timenow;
+               question->SendQNow          = mDNSNULL;
+               question->SendOnAll         = mDNSfalse;
+               question->LastQTxTime       = m->timenow;
 
                if (!question->DuplicateOf)
                        verbosedebugf("mDNS_StartQuery_internal: Question %##s (%s) %p %d (%p) started",
-                               question->qname.c, DNSTypeName(question->qtype), question->InterfaceID, question->LastQTime + question->ThisQInterval - m->timenow, question);
+                               question->qname.c, DNSTypeName(question->qtype), question->InterfaceID,
+                               question->LastQTime + question->ThisQInterval - m->timenow, question);
                else
                        verbosedebugf("mDNS_StartQuery_internal: Question %##s (%s) %p %d (%p) duplicate of (%p)",
-                               question->qname.c, DNSTypeName(question->qtype), question->InterfaceID, question->LastQTime + question->ThisQInterval - m->timenow, question, question->DuplicateOf);
+                               question->qname.c, DNSTypeName(question->qtype), question->InterfaceID,
+                               question->LastQTime + question->ThisQInterval - m->timenow, question, question->DuplicateOf);
 
                *q = question;
                if (question->InterfaceID == mDNSInterface_LocalOnly)
@@ -5795,7 +5900,8 @@ mDNSlocal mStatus mDNS_StopQuery_internal(mDNS *const m, DNSQuestion *const ques
                        for (q = m->Questions; q; q=q->next)            // Scan our list of questions
                                if (ActiveQuestion(q) && ResourceRecordAnswersQuestion(&rr->resrec, q))
                                        break;
-                       verbosedebugf("mDNS_StopQuery_internal: Cache RR %##s (%s) setting CRActiveQuestion to %p", rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), q);
+                       verbosedebugf("mDNS_StopQuery_internal: Cache RR %##s (%s) setting CRActiveQuestion to %p",
+                               rr->resrec.name->c, DNSTypeName(rr->resrec.rrtype), q);
                        rr->CRActiveQuestion = q;               // Question used to be active; new value may or may not be null
                        if (!q) m->rrcache_active--;    // If no longer active, decrement rrcache_active count
                        }
@@ -6025,12 +6131,10 @@ mDNSlocal void FoundServiceInfo(mDNS *const m, DNSQuestion *question, const Reso
        if (query->ServiceInfoQueryCallback && query->GotTXT)
                {
                if (++query->Answers >= 100)
-                       {
-                       if (answer->rrtype == kDNSType_A)
-                               debugf("**** WARNING **** have given %lu answers for %##s (A) %.4a",     query->Answers, query->qSRV.qname.c, &answer->rdata->u.ipv4);
-                       else
-                               debugf("**** WARNING **** have given %lu answers for %##s (AAAA) %.16a", query->Answers, query->qSRV.qname.c, &answer->rdata->u.ipv6);
-                       }
+                       debugf(answer->rrtype == kDNSType_A ?
+                               "**** WARNING **** have given %lu answers for %##s (A) %.4a" :
+                               "**** WARNING **** have given %lu answers for %##s (AAAA) %.16a",
+                               query->Answers, query->qSRV.qname.c, &answer->rdata->u.data);
                query->ServiceInfoQueryCallback(m, query);
                }
        }
@@ -6172,7 +6276,10 @@ mDNSexport mStatus mDNS_Update(mDNS *const m, AuthRecord *const rr, mDNSu32 newt
 #endif
 
        if (!ValidateRData(rr->resrec.rrtype, newrdlength, newrdata))
-               { LogMsg("Attempt to update record with invalid rdata: %s", GetRRDisplayString_rdb(&rr->resrec, &newrdata->u, m->MsgBuffer)); return(mStatus_Invalid); }
+               {
+               LogMsg("Attempt to update record with invalid rdata: %s", GetRRDisplayString_rdb(&rr->resrec, &newrdata->u, m->MsgBuffer));
+               return(mStatus_Invalid);
+               }
        
        mDNS_Lock(m);
 
@@ -6195,7 +6302,8 @@ mDNSexport mStatus mDNS_Update(mDNS *const m, AuthRecord *const rr, mDNSu32 newt
 
        if (unicast) { mStatus status = uDNS_UpdateRecord(m, rr); mDNS_Unlock(m); return(status); }
 
-       if (rr->resrec.rroriginalttl == newttl && rr->resrec.rdlength == newrdlength && mDNSPlatformMemSame(rr->resrec.rdata->u.data, newrdata->u.data, newrdlength))
+       if (rr->resrec.rroriginalttl == newttl &&
+               rr->resrec.rdlength == newrdlength && mDNSPlatformMemSame(rr->resrec.rdata->u.data, newrdata->u.data, newrdlength))
                CompleteRDataUpdate(m, rr);
        else
                {
@@ -6221,7 +6329,8 @@ mDNSexport mStatus mDNS_Update(mDNS *const m, AuthRecord *const rr, mDNSu32 newt
                        if (!rr->UpdateBlocked) rr->UpdateBlocked = NonZeroTime(m->timenow + (mDNSs32)delay * mDNSPlatformOneSecond);
                        rr->ThisAPInterval *= 4;
                        rr->LastAPTime = rr->UpdateBlocked - rr->ThisAPInterval;
-                       LogMsg("Excessive update rate for %##s; delaying announcement by %ld second%s", rr->resrec.name->c, delay, delay > 1 ? "s" : "");
+                       LogMsg("Excessive update rate for %##s; delaying announcement by %ld second%s",
+                               rr->resrec.name->c, delay, delay > 1 ? "s" : "");
                        }
                rr->resrec.rroriginalttl = newttl;
                }
@@ -6439,7 +6548,7 @@ mDNSlocal void UpdateInterfaceProtocols(mDNS *const m, NetworkInterfaceInfo *act
                        }
        }
 
-mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *set, mDNSs32 delay)
+mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *set, mDNSBool flapping)
        {
        mDNSBool FirstOfType = mDNStrue;
        NetworkInterfaceInfo **p = &m->HostInterfaces;
@@ -6452,11 +6561,12 @@ mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *s
 
        mDNS_Lock(m);
        
-       // Assume this interface will be active
+       // Assume this interface will be active now, unless we find a duplicate already in the list
        set->InterfaceActive = mDNStrue;
        set->IPv4Available   = (set->ip.type == mDNSAddrType_IPv4 && set->McastTxRx);
        set->IPv6Available   = (set->ip.type == mDNSAddrType_IPv6 && set->McastTxRx);
 
+       // Scan list to see if this InterfaceID is already represented
        while (*p)
                {
                if (*p == set)
@@ -6466,9 +6576,9 @@ mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *s
                        return(mStatus_AlreadyRegistered);
                        }
 
-               // This InterfaceID is already in the list, so mark this interface inactive for now
                if ((*p)->InterfaceID == set->InterfaceID)
                        {
+                       // This InterfaceID already represented by a different interface in the list, so mark this instance inactive for now
                        set->InterfaceActive = mDNSfalse;
                        if (set->ip.type == (*p)->ip.type) FirstOfType = mDNSfalse;
                        if (set->ip.type == mDNSAddrType_IPv4 && set->McastTxRx) (*p)->IPv4Available = mDNStrue;
@@ -6484,12 +6594,12 @@ mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *s
        if (set->Advertise)
                AdvertiseInterface(m, set);
 
-       debugf("mDNS_RegisterInterface: InterfaceID %p %#a %s", set->InterfaceID, &set->ip,
+       LogOperation("mDNS_RegisterInterface: InterfaceID %p %s (%#a) %s", set->InterfaceID, set->ifname, &set->ip,
                set->InterfaceActive ?
                        "not represented in list; marking active and retriggering queries" :
                        "already represented in list; marking inactive for now");
        
-       // In some versions of OS X the IPv6 address remains on an interface even when the interface is turned off,
+       // In early versions of OS X the IPv6 address remains on an interface even when the interface is turned off,
        // giving the false impression that there's an active representative of this interface when there really isn't.
        // Therefore, when registering an interface, we want to re-trigger our questions and re-probe our Resource Records,
        // even if we believe that we previously had an active representative of this interface.
@@ -6497,28 +6607,39 @@ mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *s
                {
                DNSQuestion *q;
                AuthRecord *rr;
-               mDNSs32 initial = InitialQuestionInterval;
+               // If flapping, delay between first and second queries is eight seconds instead of one
+               mDNSs32 delay    = flapping ? mDNSPlatformOneSecond   * 5 : 0;
+               mDNSu8  announce = flapping ? (mDNSu8)1                   : InitialAnnounceCount;
 
                // Use a small amount of randomness:
-               // In the case of a network administrator turning on an Ethernet hub so that all the connected machines establish link at
-               // exactly the same time, we don't want them to all go and hit the network with identical queries at exactly the same moment.
+               // In the case of a network administrator turning on an Ethernet hub so that all the
+               // connected machines establish link at exactly the same time, we don't want them all
+               // to go and hit the network with identical queries at exactly the same moment.
                if (!m->SuppressSending) m->SuppressSending = m->timenow + (mDNSs32)mDNSRandom((mDNSu32)InitialQuestionInterval);
                
-               if (delay)
+               if (flapping)
                        {
-                       LogMsg("Repeated transitions for interface %s (%#a); delaying packets by %d seconds",
-                               set->ifname, &set->ip, delay/mDNSPlatformOneSecond);
-                       initial = InitialQuestionInterval * 8;          // Delay between first and second queries is eight seconds
+                       LogMsg("Note: Frequent transitions for interface %s (%#a); network traffic reduction measures in effect", set->ifname, &set->ip);
                        if (!m->SuppressProbes ||
                                m->SuppressProbes - (m->timenow + delay) < 0)
                                m->SuppressProbes = (m->timenow + delay);
                        }
+
                for (q = m->Questions; q; q=q->next)                                                    // Scan our list of questions
                        if (!q->InterfaceID || q->InterfaceID == set->InterfaceID)      // If non-specific Q, or Q on this specific interface,
                                {                                                                                                               // then reactivate this question
-                               q->ThisQInterval    = initial;                                                  // MUST be > zero for an active question
-                               q->RequestUnicast   = 2;                                                                // Set to 2 because is decremented once *before* we check it
-                               q->LastQTime        = m->timenow - q->ThisQInterval + delay;
+                               mDNSs32 initial  = (flapping && q->FlappingInterface != set->InterfaceID) ? InitialQuestionInterval * 8 : InitialQuestionInterval;
+                               mDNSs32 qdelay   = (flapping && q->FlappingInterface != set->InterfaceID) ? mDNSPlatformOneSecond   * 5 : 0;
+                               if (flapping && q->FlappingInterface == set->InterfaceID)
+                                       LogOperation("No cache records for %##s (%s) expired; no need for immediate question", q->qname.c, DNSTypeName(q->qtype));
+                                       
+                               if (!q->ThisQInterval || q->ThisQInterval > initial)
+                                       {
+                                       q->ThisQInterval = initial;
+                                       q->RequestUnicast = 2; // Set to 2 because is decremented once *before* we check it
+                                       }
+                               if (q->LastQTime - (m->timenow - q->ThisQInterval + qdelay) > 0)
+                                       q->LastQTime = (m->timenow - q->ThisQInterval + qdelay);
                                q->RecentAnswerPkts = 0;
                                SetNextQueryTime(m,q);
                                }
@@ -6530,7 +6651,7 @@ mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *s
                                {
                                if (rr->resrec.RecordType == kDNSRecordTypeVerified && !rr->DependentOn) rr->resrec.RecordType = kDNSRecordTypeUnique;
                                rr->ProbeCount     = DefaultProbeCountForRecordType(rr->resrec.RecordType);
-                               rr->AnnounceCount  = delay ? (mDNSu8)1 : InitialAnnounceCount;
+                               if (rr->AnnounceCount < announce) rr->AnnounceCount  = announce;
                                rr->ThisAPInterval = DefaultAPIntervalForRecordType(rr->resrec.RecordType);
                                InitializeLastAPTime(m, rr);
                                }
@@ -6543,7 +6664,7 @@ mDNSexport mStatus mDNS_RegisterInterface(mDNS *const m, NetworkInterfaceInfo *s
 // NOTE: mDNS_DeregisterInterface calls mDNS_Deregister_internal which can call a user callback, which may change
 // the record list and/or question list.
 // Any code walking either list must use the CurrentQuestion and/or CurrentRecord mechanism to protect against this.
-mDNSexport void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *set)
+mDNSexport void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *set, mDNSBool flapping)
        {
        NetworkInterfaceInfo **p = &m->HostInterfaces;
        
@@ -6579,8 +6700,8 @@ mDNSexport void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *se
                                break;
                if (intf)
                        {
-                       debugf("mDNS_DeregisterInterface: Another representative of InterfaceID %p exists; making it active",
-                               set->InterfaceID);
+                       LogOperation("mDNS_DeregisterInterface: Another representative of InterfaceID %p %s (%#a) exists;"
+                               " making it active", set->InterfaceID, set->ifname, &set->ip);
                        intf->InterfaceActive = mDNStrue;
                        UpdateInterfaceProtocols(m, intf);
                        
@@ -6597,19 +6718,32 @@ mDNSexport void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *se
                        CacheGroup *cg;
                        CacheRecord *rr;
                        DNSQuestion *q;
-                       debugf("mDNS_DeregisterInterface: Last representative of InterfaceID %p deregistered; marking questions etc. dormant",
-                               set->InterfaceID);
+                       LogOperation("mDNS_DeregisterInterface: Last representative of InterfaceID %p %s (%#a) deregistered;"
+                               " marking questions etc. dormant", set->InterfaceID, set->ifname, &set->ip);
 
-                       // 1. Deactivate any questions specific to this interface
+                       if (flapping)
+                               LogMsg("Note: Frequent transitions for interface %s (%#a); network traffic reduction measures in effect",
+                                       set->ifname, &set->ip);
+
+                       // 1. Deactivate any questions specific to this interface, and tag appropriate questions
+                       // so that mDNS_RegisterInterface() knows how swiftly it needs to reactivate them
                        for (q = m->Questions; q; q=q->next)
-                               if (q->InterfaceID == set->InterfaceID)
-                                       q->ThisQInterval = 0;
+                               {
+                               if (q->InterfaceID == set->InterfaceID) q->ThisQInterval = 0;
+                               if (!q->InterfaceID || q->InterfaceID == set->InterfaceID)
+                                       q->FlappingInterface = set->InterfaceID;
+                               }
 
                        // 2. Flush any cache records received on this interface
                        revalidate = mDNSfalse;         // Don't revalidate if we're flushing the records
                        FORALL_CACHERECORDS(slot, cg, rr)
                                if (rr->resrec.InterfaceID == set->InterfaceID)
-                                       PurgeCacheResourceRecord(m, rr);
+                                       {
+                                       // If this interface is deemed flapping,
+                                       // postpone deleting the cache records in case the interface comes back again
+                                       if (!flapping) PurgeCacheResourceRecord(m, rr);
+                                       else mDNS_Reconfirm_internal(m, rr, kDefaultReconfirmTimeForFlappingInterface);
+                                       }
                        }
                }
 
@@ -6628,7 +6762,7 @@ mDNSexport void mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *se
                m->NextCacheCheck = m->timenow;
                FORALL_CACHERECORDS(slot, cg, rr)
                        if (rr->resrec.InterfaceID == set->InterfaceID)
-                               mDNS_Reconfirm_internal(m, rr, kDefaultReconfirmTimeForCableDisconnect);
+                               mDNS_Reconfirm_internal(m, rr, kDefaultReconfirmTimeForFlappingInterface);
                }
 
        mDNS_Unlock(m);
@@ -6713,7 +6847,8 @@ mDNSexport mStatus mDNS_RegisterService(mDNS *const m, ServiceRecordSet *sr,
        else sr->Host.c[0] = 0;
        
        // If port number is zero, that means the client is really trying to do a RegisterNoSuchService
-       if (!port.NotAnInteger) return(mDNS_RegisterNoSuchService(m, &sr->RR_SRV, name, type, domain, mDNSNULL, mDNSInterface_Any, NSSCallback, sr));
+       if (!port.NotAnInteger)
+               return(mDNS_RegisterNoSuchService(m, &sr->RR_SRV, name, type, domain, mDNSNULL, mDNSInterface_Any, NSSCallback, sr));
 
        // Initialize the AuthRecord objects to sane values
        mDNS_SetupResourceRecord(&sr->RR_ADV, mDNSNULL, InterfaceID, kDNSType_PTR, kStandardTTL, kDNSRecordTypeAdvisory, ServiceCallback, sr);
@@ -6822,7 +6957,8 @@ mDNSexport mStatus mDNS_AddRecordToService(mDNS *const m, ServiceRecordSet *sr,
        mStatus status;
 
        extra->next = mDNSNULL;
-       mDNS_SetupResourceRecord(&extra->r, rdata, sr->RR_PTR.resrec.InterfaceID, extra->r.resrec.rrtype, ttl, kDNSRecordTypeUnique, ServiceCallback, sr);
+       mDNS_SetupResourceRecord(&extra->r, rdata, sr->RR_PTR.resrec.InterfaceID,
+               extra->r.resrec.rrtype, ttl, kDNSRecordTypeUnique, ServiceCallback, sr);
        AssignDomainName(extra->r.resrec.name, sr->RR_SRV.resrec.name);
        
 #ifndef UNICAST_DISABLED
@@ -6857,7 +6993,8 @@ mDNSexport mStatus mDNS_AddRecordToService(mDNS *const m, ServiceRecordSet *sr,
        return(status);
        }
 
-mDNSexport mStatus mDNS_RemoveRecordFromService(mDNS *const m, ServiceRecordSet *sr, ExtraResourceRecord *extra, mDNSRecordCallback MemFreeCallback, void *Context)
+mDNSexport mStatus mDNS_RemoveRecordFromService(mDNS *const m, ServiceRecordSet *sr, ExtraResourceRecord *extra,
+       mDNSRecordCallback MemFreeCallback, void *Context)
        {
        ExtraResourceRecord **e;
        mStatus status;
@@ -6904,7 +7041,11 @@ mDNSexport mStatus mDNS_RenameAndReregisterService(mDNS *const m, ServiceRecordS
                IncrementLabelSuffix(&name2, mDNStrue);
                newname = &name2;
                }
-       LogMsg("Service \"%##s\" renamed to \"%#s\"", sr->RR_SRV.resrec.name->c, newname->c);
+       
+       if (SameDomainName(&domain, &localdomain))
+               LogMsg("%##s service renamed from \"%#s\" to \"%#s\"", type.c, name1.c, newname->c);
+       else LogMsg("%##s service (domain %##s) renamed from \"%#s\" to \"%#s\"",type.c, domain.c, name1.c, newname->c);
+
        if (sr->RR_SRV.HostTarget == mDNSfalse && sr->Host.c[0]) host = &sr->Host;
        
        err = mDNS_RegisterService(m, sr, newname, &type, &domain,
@@ -7059,7 +7200,7 @@ mDNSexport mStatus mDNS_Init(mDNS *const m, mDNS_PlatformSupport *const p,
        
        m->p                       = p;
        m->KnownBugs               = 0;
-       m->CanReceiveUnicastOn5353 = mDNSfalse;         // Assume we can't receive unicasts on 5353, unless platform layer tells us otherwise
+       m->CanReceiveUnicastOn5353 = mDNSfalse; // Assume we can't receive unicasts on 5353, unless platform layer tells us otherwise
        m->AdvertiseLocalAddresses = AdvertiseLocalAddresses;
        m->mDNSPlatformStatus      = mStatus_Waiting;
        m->UnicastPort4            = zeroIPPort;
@@ -7092,6 +7233,7 @@ mDNSexport mStatus mDNS_Init(mDNS *const m, mDNS_PlatformSupport *const p,
        m->NextScheduledResponse   = timenow + 0x78000000;
        m->ExpectUnicastResponse   = timenow + 0x78000000;
        m->RandomQueryDelay        = 0;
+       m->RandomReconfirmDelay    = 0;
        m->PktNum                  = 0;
        m->SendDeregistrations     = mDNSfalse;
        m->SendImmediateAnswers    = mDNSfalse;
index 0ff368f3c62a0b49de8a862cdb56d6e067b3aff1..591312b82da848baede713359966a73293af5669 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: mDNSDebug.h,v $
+Revision 1.26.2.1  2006/08/29 06:24:22  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.26  2005/07/04 22:40:26  cheshire
 Additional debugging code to help catch memory corruption
 
index 9f81dc83aa8ad1fda7444d73f84a7dbe5369c9c7..4b4d8ae1686da29ad3bd50f9c3241311b479b672 100755 (executable)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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@
 
 
    NOTE:
     Change History (most recent first):
 
 $Log: mDNSEmbeddedAPI.h,v $
+Revision 1.296.2.1  2006/08/29 06:24:22  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.296  2006/06/29 05:28:01  cheshire
+Added comment about mDNSlocal and mDNSexport
+
+Revision 1.295  2006/06/29 03:02:43  cheshire
+<rdar://problem/4607042> mDNSResponder NXDOMAIN and CNAME support
+
+Revision 1.294  2006/06/28 06:50:08  cheshire
+In future we may want to change definition of mDNSs32 from "signed long" to "signed int"
+I doubt anyone is building mDNSResponder on systems where int is 16-bits,
+but lets add a compile-time assertion to make sure.
+
+Revision 1.293  2006/06/12 18:00:43  cheshire
+To make code a little more defensive, check _ILP64 before _LP64,
+in case both are set by mistake on some platforms
+
+Revision 1.292  2006/03/19 17:00:57  cheshire
+Define symbol MaxMsg instead of using hard-coded constant value '80'
+
+Revision 1.291  2006/03/19 02:00:07  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
+Revision 1.290  2006/03/08 22:42:23  cheshire
+Fix spelling mistake: LocalReverseMapomain -> LocalReverseMapDomain
+
+Revision 1.289  2006/02/26 00:54:41  cheshire
+Fixes to avoid code generation warning/error on FreeBSD 7
+
 Revision 1.288  2005/12/21 03:24:58  cheshire
 <rdar://problem/4388858> Code changes required to compile on EFI
 
@@ -1033,6 +1057,19 @@ Merge in license terms from Quinn's copy, in preparation for Darwin release
 #define mDNSexport
 #endif
 
+// Explanation: These local/export markers are a little habit of mine for signaling the programmers' intentions.
+// When "mDNSlocal" is just a synonym for "static", and "mDNSexport" is a complete no-op, you could be
+// forgiven for asking what purpose they serve. The idea is that if you see "mDNSexport" in front of a
+// function definition it means the programmer intended it to be exported and callable from other files
+// in the project. If you see "mDNSlocal" in front of a function definition it means the programmer
+// intended it to be private to that file. If you see neither in front of a function definition it
+// means the programmer forgot (so you should work out which it is supposed to be, and fix it).
+// Using "mDNSlocal" instead of "static" makes it easier to do a textual searches for one or the other.
+// For example you can do a search for "static" to find if any functions declare any local variables as "static"
+// (generally a bad idea unless it's also "const", because static storage usually risks being non-thread-safe)
+// without the results being cluttered with hundreds of matches for functions declared static.
+// - Stuart Cheshire
+
 // ***************************************************************************
 // Structure packing macro
 
@@ -1118,15 +1155,17 @@ typedef unsigned short mDNSu16;
 //   Macro Name __LP64__ Value 1
 // A quick Google search for "defined(__LP64__)" OR "#ifdef __LP64__" gives 2590 hits and
 // a search for "#if __LP64__" gives only 12, so I think we'll go with the majority and use defined()
-#if defined(_LP64) || defined(__LP64__)
-typedef   signed int   mDNSs32;
-typedef unsigned int   mDNSu32;
-#elif defined(_ILP64) || defined(__ILP64__)
+#if defined(_ILP64) || defined(__ILP64__)
 typedef   signed int32 mDNSs32;
 typedef unsigned int32 mDNSu32;
+#elif defined(_LP64) || defined(__LP64__)
+typedef   signed int   mDNSs32;
+typedef unsigned int   mDNSu32;
 #else
 typedef   signed long  mDNSs32;
 typedef unsigned long  mDNSu32;
+//typedef   signed int mDNSs32;
+//typedef unsigned int mDNSu32;
 #endif
 
 // To enforce useful type checking, we make mDNSInterfaceID be a pointer to a dummy struct
@@ -1866,6 +1905,7 @@ struct DNSQuestion_struct
        mDNSu32               CurrentAnswers;   // Number of records currently in the cache that answer this question
        mDNSu32               LargeAnswers;             // Number of answers with rdata > 1024 bytes
        mDNSu32               UniqueAnswers;    // Number of answers received with kDNSClass_UniqueRRSet bit set
+       mDNSInterfaceID       FlappingInterface;// Set when an interface goes away, to flag if removes are delivered for this Q
        DNSQuestion          *DuplicateOf;
        DNSQuestion          *NextInDQList;
        DupSuppressInfo       DupSuppress[DupSuppressInfoSize];
@@ -1886,6 +1926,7 @@ struct DNSQuestion_struct
        mDNSBool              LongLived;        // Set by client for calls to mDNS_StartQuery to indicate LLQs to unicast layer.
        mDNSBool              ExpectUnique;             // Set by client if it's expecting unique RR(s) for this question, not shared RRs
        mDNSBool              ForceMCast;               // Set by client to force mDNS query, even for apparently uDNS names
+       mDNSBool              ReturnCNAME;              // Set by client to request callbacks for intermediate CNAME records
        mDNSQuestionCallback *QuestionCallback;
        void                 *QuestionContext;
        };
@@ -1936,7 +1977,6 @@ struct ServiceInfoQuery_struct
 #define NATMAP_MAX_TRIES 3                                     // for max 3 tries
 #define NATMAP_DEFAULT_LEASE (60 * 60)  // lease life in seconds
 #define NATMAP_VERS 0
-#define NATMAP_PORT 5351
 #define NATMAP_RESPONSE_MASK 0x80
 
 typedef enum
@@ -2090,7 +2130,8 @@ struct mDNS_struct
        mDNSu8  lock_rrcache;                           // For debugging: Set at times when these lists may not be modified
        mDNSu8  lock_Questions;
        mDNSu8  lock_Records;
-       char MsgBuffer[80];                                     // Temp storage used while building error log messages
+       #define MaxMsg 120
+       char MsgBuffer[MaxMsg];                         // Temp storage used while building error log messages
 
        // Task Scheduling variables
        mDNSs32  timenow_adjust;                        // Correction applied if we ever discover time went backwards
@@ -2104,6 +2145,7 @@ struct mDNS_struct
        mDNSs32  NextScheduledResponse;         // Next time to send authoritative record(s) in responses
        mDNSs32  ExpectUnicastResponse;         // Set when we send a query with the kDNSQClass_UnicastResponse bit set
        mDNSs32  RandomQueryDelay;                      // For de-synchronization of query packets on the wire
+       mDNSu32  RandomReconfirmDelay;          // For de-synchronization of reconfirmation queries on the wire
        mDNSs32  PktNum;                                        // Unique sequence number assigned to each received packet
        mDNSBool SendDeregistrations;           // Set if we need to send deregistrations (immediately)
        mDNSBool SendImmediateAnswers;          // Set if we need to send answers (immediately -- or as soon as SuppressSending clears)
@@ -2169,10 +2211,14 @@ extern const mDNSInterfaceID mDNSInterface_Any;                         // Zero
 extern const mDNSInterfaceID mDNSInterface_LocalOnly;          // Special value
 
 extern const mDNSIPPort      UnicastDNSPort;
+extern const mDNSIPPort      NATPMPPort;
+extern const mDNSIPPort      DNSEXTPort;
 extern const mDNSIPPort      MulticastDNSPort;
+extern const mDNSIPPort      LoopbackIPCPort;
+
 extern const mDNSv4Addr      AllDNSAdminGroup;
-extern const mDNSv4Addr      AllDNSLinkGroupv4;
-extern const mDNSv6Addr      AllDNSLinkGroupv6;
+#define AllDNSLinkGroupv4 (AllDNSLinkGroup_v4.ip.v4)
+#define AllDNSLinkGroupv6 (AllDNSLinkGroup_v6.ip.v6)
 extern const mDNSAddr        AllDNSLinkGroup_v4;
 extern const mDNSAddr        AllDNSLinkGroup_v6;
 
@@ -2183,8 +2229,8 @@ extern const mDNSOpaque16 ResponseFlags;
 extern const mDNSOpaque16 UpdateReqFlags;
 extern const mDNSOpaque16 UpdateRespFlags;
 
-#define localdomain (*(const domainname *)"\x5local")
-#define LocalReverseMapomain (*(const domainname *)"\x3" "254" "\x3" "169" "\x7" "in-addr" "\x4" "arpa")
+#define localdomain (*(const domainname *)"\x5" "local")
+#define LocalReverseMapDomain (*(const domainname *)"\x3" "254" "\x3" "169" "\x7" "in-addr" "\x4" "arpa")
        
 // ***************************************************************************
 #if 0
@@ -2659,8 +2705,8 @@ extern mDNSs32  mDNSPlatformUTC         (void);
 // Platform support modules should provide the following functions to map between opaque interface IDs
 // and interface indexes in order to support the DNS-SD API. If your target platform does not support
 // multiple interfaces and/or does not support the DNS-SD API, these functions can be empty.
-extern mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(const mDNS *const m, mDNSu32 index);
-extern mDNSu32 mDNSPlatformInterfaceIndexfromInterfaceID(const mDNS *const m, mDNSInterfaceID id);
+extern mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(mDNS *const m, mDNSu32 index);
+extern mDNSu32 mDNSPlatformInterfaceIndexfromInterfaceID(mDNS *const m, mDNSInterfaceID id);
 
 // Every platform support module must provide the following functions if it is to support unicast DNS
 // and Dynamic Update.
@@ -2752,8 +2798,8 @@ extern mStatus LNT_UnmapPort(mDNSIPPort PubPort, mDNSBool tcp);
 // not lightweight second-by-second CPU power management modes.)
 
 extern void     mDNS_SetFQDN(mDNS *const m);
-extern mStatus  mDNS_RegisterInterface  (mDNS *const m, NetworkInterfaceInfo *set, mDNSs32 delay);
-extern void     mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *set);
+extern mStatus  mDNS_RegisterInterface  (mDNS *const m, NetworkInterfaceInfo *set, mDNSBool flapping);
+extern void     mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *set, mDNSBool flapping);
 extern void     mDNSCoreInitComplete(mDNS *const m, mStatus result);
 extern void     mDNSCoreReceive(mDNS *const m, void *const msg, const mDNSu8 *const end,
                                                                const mDNSAddr *const srcaddr, const mDNSIPPort srcport,
@@ -2790,6 +2836,7 @@ struct mDNS_CompileTimeAssertionChecks
        char assertA[(sizeof(mDNSOpaque32)     ==   4                          ) ? 1 : -1];
        char assertB[(sizeof(mDNSOpaque128)    ==  16                          ) ? 1 : -1];
        char assertC[(sizeof(CacheRecord  )    >=  sizeof(CacheGroup)          ) ? 1 : -1];
+       char assertD[(sizeof(int)              >=  4                           ) ? 1 : -1];
        };
 
 // ***************************************************************************
index 2e7c354fee6413c97733c6ce073a935a9131a759..20cdadb46be8f859b4b624d683b73712fadf10b3 100755 (executable)
@@ -1,28 +1,38 @@
-/*
- * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
+/* -*- Mode: C; tab-width: 4 -*-
  *
- * @APPLE_LICENSE_HEADER_START@
+ * Copyright (c) 2002-2006 Apple Computer, Inc. All rights reserved.
+ *
+ * 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: uDNS.c,v $
+Revision 1.230.2.1  2006/08/29 06:24:23  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.230  2006/06/29 03:02:44  cheshire
+<rdar://problem/4607042> mDNSResponder NXDOMAIN and CNAME support
+
+Revision 1.229  2006/03/02 22:03:41  cheshire
+<rdar://problem/4395331> Spurious warning "GetLargeResourceRecord: m->rec appears to be already in use"
+Refinement: m->rec.r.resrec.RecordType needs to be cleared *every* time around for loop, not just once at the end
+
+Revision 1.228  2006/02/26 00:54:42  cheshire
+Fixes to avoid code generation warning/error on FreeBSD 7
+
+Revision 1.227  2006/01/09 20:47:05  cheshire
+<rdar://problem/4395331> Spurious warning "GetLargeResourceRecord: m->rec appears to be already in use"
+
 Revision 1.226  2005/12/20 02:46:33  cheshire
 <rdar://problem/4175520> mDNSPosix wide-area registration broken
 Check too strict -- we can still do wide-area registration (without NAT-PMP)
@@ -951,7 +961,7 @@ mDNSexport void mDNS_AddDNSServer(mDNS *const m, const mDNSAddr *addr, const dom
        mDNS_Lock(m);
        if (!d) d = (domainname *)"";
 
-       while (*p)              // Check if we already have this {server,domain} pair registered
+       while (*p)                 // Check if we already have this {server,domain} pair registered
                {
                if (mDNSSameAddress(&(*p)->addr, addr) && SameDomainName(&(*p)->domain, d))
                        LogMsg("Note: DNS Server %#a for domain %##s registered more than once", addr, d->c);
@@ -1133,8 +1143,6 @@ mDNSlocal mDNSBool FreeNATInfo(mDNS *m, NATTraversalInfo *n)
 mDNSlocal void SendNATMsg(NATTraversalInfo *info, mDNS *m)
        {
        mStatus err;
-       mDNSAddr dst;
-       mDNSIPPort dstport;
        uDNS_GlobalInfo *u = &m->uDNS_info;
 
        if (info->state != NATState_Request && info->state != NATState_Refresh)
@@ -1142,15 +1150,12 @@ mDNSlocal void SendNATMsg(NATTraversalInfo *info, mDNS *m)
 
        if (u->Router.ip.v4.NotAnInteger)
                {
-               // send msg     if we have a router
+               // send msg if we have a router
                const mDNSu8 *end = (mDNSu8 *)&info->request;
                if (info->op == NATOp_AddrRequest) end += sizeof(NATAddrRequest);
                else end += sizeof(NATPortMapRequest);
 
-               dst.type = u->Router.type;
-               dst.ip.v4 = u->Router.ip.v4;
-               dstport = mDNSOpaque16fromIntVal(NATMAP_PORT);
-               err = mDNSPlatformSendUDP(m, &info->request, end, 0, &dst, dstport);
+               err = mDNSPlatformSendUDP(m, &info->request, end, 0, &u->Router, NATPMPPort);
                if (!err) (info->ntries++);  // don't increment attempt counter if the send failed
                }
        
@@ -2052,6 +2057,9 @@ mDNSlocal void deriveGoodbyes(mDNS * const m, DNSMessage *msg, const  mDNSu8 *en
                        m->mDNS_reentrancy++; // Increment to allow client to legally make mDNS API calls from the callback
                        question->QuestionCallback(m, question, &ka->resrec, mDNSfalse);
                        m->mDNS_reentrancy--; // Decrement to block mDNS API calls again
+                       // CAUTION: Need to be careful after calling question->QuestionCallback(),
+                       // because the client's callback function is allowed to do anything,
+                       // including starting/stopping queries, registering/deregistering records, etc.
                        if (question != m->uDNS_info.CurrentQuery)
                                {
                                debugf("deriveGoodbyes - question removed via callback.  returning.");
@@ -2097,6 +2105,9 @@ mDNSlocal void deriveGoodbyes(mDNS * const m, DNSMessage *msg, const  mDNSu8 *en
                        m->mDNS_reentrancy++; // Increment to allow client to legally make mDNS API calls from the callback
                        question->QuestionCallback(m, question, &ka->resrec, mDNSfalse);
                        m->mDNS_reentrancy--; // Decrement to block mDNS API calls again
+                       // CAUTION: Need to be careful after calling question->QuestionCallback(),
+                       // because the client's callback function is allowed to do anything,
+                       // including starting/stopping queries, registering/deregistering records, etc.
                        if (question != m->uDNS_info.CurrentQuery)
                                {
                                debugf("deriveGoodbyes - question removed via callback.  returning.");
@@ -2132,9 +2143,10 @@ mDNSlocal void pktResponseHndlr(mDNS * const m, DNSMessage *msg, const  mDNSu8 *
        {
        const mDNSu8 *ptr;
        int i;
-       LargeCacheRecord lcr;
-       CacheRecord *cr = &lcr.r;
-       mDNSBool goodbye, inKAList, followedCName = mDNSfalse;
+       CacheRecord *cr = &m->rec.r;
+       mDNSBool goodbye, inKAList;
+       int     followedCNames = 0;
+       static const int maxCNames = 5;
        LLQ_Info *llqInfo = question->uDNS_info.llq;
        domainname origname;
        origname.c[0] = 0;
@@ -2142,6 +2154,40 @@ mDNSlocal void pktResponseHndlr(mDNS * const m, DNSMessage *msg, const  mDNSu8 *
        if (question != m->uDNS_info.CurrentQuery)
                { LogMsg("ERROR: pktResponseHdnlr called without CurrentQuery ptr set!");  return; }
 
+       if (question->uDNS_info.Answered == 0 && msg->h.numAnswers == 0 && !llq)
+               {
+               /* NXDOMAIN error or empty RR set - notify client */
+               question->uDNS_info.Answered = mDNStrue;
+               
+               /* Create empty resource record */
+               cr->resrec.RecordType = kDNSRecordTypeUnregistered;
+               cr->resrec.InterfaceID = mDNSNULL;
+               cr->resrec.name = &question->qname;
+               cr->resrec.rrtype = question->qtype;
+               cr->resrec.rrclass = question->qclass;
+               cr->resrec.rroriginalttl = 1; /* What should we use for the TTL? TTL from SOA for domain? */
+               cr->resrec.rdlength = 0;
+               cr->resrec.rdestimate = 0;
+               cr->resrec.namehash = 0;
+               cr->resrec.namehash = 0;
+               cr->resrec.rdata = (RData*)&cr->rdatastorage;
+               cr->resrec.rdata->MaxRDLength = cr->resrec.rdlength;
+               
+               /* Pass empty answer to callback */
+               m->mDNS_reentrancy++; // Increment to allow client to legally make mDNS API calls from the callback
+               question->QuestionCallback(m, question, &cr->resrec, 0);
+               m->mDNS_reentrancy--; // Decrement to block mDNS API calls again
+               // CAUTION: Need to be careful after calling question->QuestionCallback(),
+               // because the client's callback function is allowed to do anything,
+               // including starting/stopping queries, registering/deregistering records, etc.
+               m->rec.r.resrec.RecordType = 0; // Clear RecordType to show we're not still using it
+               if (question != m->uDNS_info.CurrentQuery)
+                       {
+                       debugf("pktResponseHndlr - CurrentQuery changed by QuestionCallback - returning.");
+                       return;
+                       }
+               }
+       
        question->uDNS_info.Answered = mDNStrue;
        
        ptr = LocateAnswers(msg, end);
@@ -2149,30 +2195,50 @@ mDNSlocal void pktResponseHndlr(mDNS * const m, DNSMessage *msg, const  mDNSu8 *
 
        for (i = 0; i < msg->h.numAnswers; i++)
                {
-               ptr = GetLargeResourceRecord(m, msg, ptr, end, 0, kDNSRecordTypePacketAns, &lcr);
+               ptr = GetLargeResourceRecord(m, msg, ptr, end, 0, kDNSRecordTypePacketAns, &m->rec);
                if (!ptr) goto pkt_error;
                if (ResourceRecordAnswersQuestion(&cr->resrec, question))
                        {
+                       goodbye = llq ? ((mDNSs32)cr->resrec.rroriginalttl == -1) : mDNSfalse;
                        if (cr->resrec.rrtype == kDNSType_CNAME)
                                {
-                               if (followedCName) LogMsg("Error: multiple CNAME referals for question %##s", question->qname.c);
+                               if (followedCNames > (maxCNames - 1)) LogMsg("Error: too many CNAME referals for question %##s", &origname);
                                else
                                        {
                                        debugf("Following cname %##s -> %##s", question->qname.c, cr->resrec.rdata->u.name.c);
+                                       if (question->ReturnCNAME)
+                                               {
+                                               m->mDNS_reentrancy++; // Increment to allow client to legally make mDNS API calls from the callback
+                                               question->QuestionCallback(m, question, &cr->resrec, !goodbye);
+                                               m->mDNS_reentrancy--; // Decrement to block mDNS API calls again
+                                               // CAUTION: Need to be careful after calling question->QuestionCallback(),
+                                               // because the client's callback function is allowed to do anything,
+                                               // including starting/stopping queries, registering/deregistering records, etc.
+                                               if (question != m->uDNS_info.CurrentQuery)
+                                                       {
+                                                       m->rec.r.resrec.RecordType = 0; // Clear RecordType to show we're not still using it
+                                                       debugf("pktResponseHndlr - CurrentQuery changed by QuestionCallback - returning.");
+                                                       return;
+                                                       }
+                                               }
                                        AssignDomainName(&origname, &question->qname);
                                        AssignDomainName(&question->qname, &cr->resrec.rdata->u.name);
                                        question->qnamehash = DomainNameHashValue(&question->qname);
-                                       followedCName = mDNStrue;
+                                       followedCNames++;
                                        i = -1; // restart packet answer matching
                                        ptr = LocateAnswers(msg, end);
+                                       m->rec.r.resrec.RecordType = 0; // Clear RecordType to show we're not still using it
                                        continue;
                                        }
                                }
                        
-                       goodbye = llq ? ((mDNSs32)cr->resrec.rroriginalttl == -1) : mDNSfalse;
                        inKAList = kaListContainsAnswer(question, cr);
 
-                       if ((goodbye && !inKAList) || (!goodbye && inKAList)) continue;  // list up to date
+                       if ((goodbye && !inKAList) || (!goodbye && inKAList))
+                               {
+                               m->rec.r.resrec.RecordType = 0; // Clear RecordType to show we're not still using it
+                               continue;  // list up to date
+                               }
                        if (!inKAList) addKnownAnswer(question, cr);
                        if (goodbye) removeKnownAnswer(question, cr);
                        m->mDNS_reentrancy++; // Increment to allow client to legally make mDNS API calls from the callback
@@ -2180,16 +2246,15 @@ mDNSlocal void pktResponseHndlr(mDNS * const m, DNSMessage *msg, const  mDNSu8 *
                        m->mDNS_reentrancy--; // Decrement to block mDNS API calls again
                        if (question != m->uDNS_info.CurrentQuery)
                                {
+                               m->rec.r.resrec.RecordType = 0; // Clear RecordType to show we're not still using it
                                debugf("pktResponseHndlr - CurrentQuery changed by QuestionCallback - returning");
                                return;
                                }
                        }
-               else if (!followedCName || !SameDomainName(cr->resrec.name, &origname))
-                       LogMsg("Question %##s %X (%s) %##s unexpected answer %##s %X (%s)",
-                               question->qname.c, question->qnamehash, DNSTypeName(question->qtype), origname.c,
-                               cr->resrec.name->c, cr->resrec.namehash, DNSTypeName(cr->resrec.rrtype));
+
+               m->rec.r.resrec.RecordType = 0; // Clear RecordType to show we're not still using it
                }
-       
+
        if (!llq || llqInfo->state == LLQ_Poll || llqInfo->deriveRemovesOnResume)
                {
                deriveGoodbyes(m, msg, end,question);
@@ -2686,7 +2751,7 @@ mDNSlocal mDNSBool uDNS_ReceiveTestQuestionResponse(mDNS *const m, DNSMessage *c
        if (found && result == DNSServer_Failed)
                LogMsg("NOTE: Wide-Area Service Discovery disabled to avoid crashing defective DNS relay %#a.", srcaddr);
 
-       return(mDNStrue);       // Return mDNStrue to tell uDNS_ReceiveMsg it doens't need to process this packet further
+       return(mDNStrue); // Return mDNStrue to tell uDNS_ReceiveMsg it doens't need to process this packet further
        }
 
 mDNSexport void uDNS_ReceiveMsg(mDNS *const m, DNSMessage *const msg, const mDNSu8 *const end,
@@ -4620,7 +4685,7 @@ mDNSexport mStatus uDNS_AddRecordToService(mDNS *const m, ServiceRecordSet *sr,
        else
                {
                err = SetupRecordRegistration(m, &extra->r);
-               extra->r.uDNS_info.state = regState_ExtraQueued;        // %%% Is it okay to overwrite the previous uDNS_info.state?
+               extra->r.uDNS_info.state = regState_ExtraQueued; // %%% Is it okay to overwrite the previous uDNS_info.state?
                }
        
        if (!err)
@@ -4799,7 +4864,7 @@ mDNSlocal mDNSs32 CheckQueries(mDNS *m, mDNSs32 timenow)
                        {
                        sendtime = q->LastQTime + q->ThisQInterval;
                        if (m->SuppressStdPort53Queries &&
-                               sendtime - m->SuppressStdPort53Queries < 0)             // Don't allow sendtime to be earlier than SuppressStdPort53Queries
+                               sendtime - m->SuppressStdPort53Queries < 0) // Don't allow sendtime to be earlier than SuppressStdPort53Queries
                                sendtime = m->SuppressStdPort53Queries;
                        if (sendtime - timenow < 0)
                                {
@@ -4939,7 +5004,7 @@ mDNSexport void uDNS_Execute(mDNS *const m)
        if (nexte - u->nextevent < 0) u->nextevent = nexte;
 
        if (m->SuppressStdPort53Queries && m->timenow - m->SuppressStdPort53Queries >= 0)
-               m->SuppressStdPort53Queries = 0;        // If suppression time has passed, clear it
+               m->SuppressStdPort53Queries = 0; // If suppression time has passed, clear it
 
        nexte = CheckQueries(m, timenow);
        if (nexte - u->nextevent < 0) u->nextevent = nexte;
index 6d86705370e358c537ae86cb5b44a24f73c057bc..c7e0e7cacab7d21f5d461f1cba916722e16ab010 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: uDNS.h,v $
+Revision 1.32.2.1  2006/08/29 06:24:23  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.32  2005/07/29 19:46:10  ksekar
 <rdar://problem/4191860> reduce polling period on failed LLQs to 15 minutes
 
index 105a3985f47c2c0bad966d472dbb83093816873e..c7a49a02f5561dc8326448a3f59bd052cbc6dee6 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: CarbonResource.r,v $
+Revision 1.6  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  2003/08/12 19:56:24  cheshire
 Update to APSL 2.0
 
index 76a426c232fd729f276d3923a03c840074e8c2a2..cc141734cca480d4ac917a13bbb30a9870f93fa9 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: Mac\040OS\040Test\040Responder.c,v $
+Revision 1.25  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.24  2004/12/16 20:49:34  cheshire
 <rdar://problem/3324626> Cache memory management improvements
 
index fd28def8dfbdf487b7fff750f487d897c5a6550b..ac7b7d473adeec603334f910d91c3caf3c9db41b 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: Mac\040OS\040Test\040Searcher.c,v $
+Revision 1.22  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.21  2004/12/16 20:49:34  cheshire
 <rdar://problem/3324626> Cache memory management improvements
 
index 2e7135e9ccfc3a0637015dc4e164fee59b2a2765..7a1993f6a57d0731ce1ebd1788c3246c59264501 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: Responder.c,v $
+Revision 1.3  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/05/20 18:38:31  cheshire
 Fix build broken by removal of 'kDNSServiceFlagsAutoRename' from dns_sd.h
 
index a0a562f0531729ec6bcbf3930738dcab0ccb6f4d..0e880c9bc7d7fd27a15b2475ac4b45c30a7913bf 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: Searcher.c,v $
+Revision 1.3  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/05/27 06:30:21  cheshire
 Add code to test DNSServiceQueryRecord()
 
index 2206b225be4896e7f7574f37fa3c2b768baecb55..d0eb61389264c959f8fc207da3b44af2f4f940ee 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: SubTypeTester.c,v $
+Revision 1.7  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.6  2004/12/16 20:49:35  cheshire
 <rdar://problem/3324626> Cache memory management improvements
 
index d385cb45ee978468b3dccd64aad0b717a832aaaa..e54ab00fc961d7d06535461058c73d39f93759c5 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: mDNSLibrary.c,v $
+Revision 1.4  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2004/12/16 20:49:35  cheshire
 <rdar://problem/3324626> Cache memory management improvements
 
index d671d777d331cb7ed5ef0012f52c7863867e8951..f829f14f7fab5a496045ebf8c1610d9c789b9705 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: mDNSLibraryLoader.c,v $
+Revision 1.2  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/03/12 21:30:26  cheshire
 Build a System-Context Shared Library from mDNSCore, for the benefit of developers
 like Muse Research who want to be able to use mDNS/DNS-SD from GPL-licensed code.
index a518d9de105ba1b477be90789e04664bf81410ac..b3b37ac2fb072c1e2d08951c9292eec1f35ea9fd 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: mDNSLibraryResources.r,v $
+Revision 1.31.2.1  2006/08/29 06:24:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.31  2005/03/15 02:14:14  cheshire
 mDNSResponder-107
 
index 0dbbe5e397923bf2816c8d89cbcca27b2ee5d9f6..24cf117a5b03076f0201e13e19b3e517cf1c14d2 100644 (file)
@@ -1,28 +1,28 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: mDNSMacOS9.c,v $
+Revision 1.46  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.45  2006/03/19 02:00:14  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
 Revision 1.44  2005/09/16 21:06:50  cheshire
 Use mDNS_TimeNow_NoLock macro, instead of writing "mDNSPlatformRawTime() + m->timenow_adjust" all over the place
 
@@ -406,7 +406,7 @@ mDNSlocal pascal void mDNSNotifier(void *contextPtr, OTEventCode code, OTResult
                                case mOT_Bind:                  OTBind(m->p->ep, (TBind*)&mDNSbindReq, NULL); break;
                                case mOT_Ready:         mDNSinitComplete(m, mStatus_NoError);
                                                                                // Can't do mDNS_RegisterInterface until *after* mDNSinitComplete has set m->mDNSPlatformStatus to mStatus_NoError
-                                                                               mDNS_RegisterInterface(m, &m->p->interface, 0);
+                                                                               mDNS_RegisterInterface(m, &m->p->interface, mDNSfalse);
                                                                                break;
                                default:                LogMsg("Unexpected m->p->mOTstate %d", m->p->mOTstate-1);
                                }
@@ -423,7 +423,7 @@ mDNSlocal pascal void mDNSNotifier(void *contextPtr, OTEventCode code, OTResult
                        if (m->p->mOTstate == mOT_Ready)
                                {
                                m->p->mOTstate = mOT_Closed;
-                               mDNS_DeregisterInterface(m, &m->p->interface);
+                               mDNS_DeregisterInterface(m, &m->p->interface, mDNSfalse);
                                }
                        if (m->p->ep) { OTCloseProvider(m->p->ep); m->p->ep = NULL; }
                        break;                                          // Do we need to do anything?
@@ -645,7 +645,7 @@ extern void mDNSPlatformClose (mDNS *const m)
        if (m->p->mOTstate == mOT_Ready)
                {
                m->p->mOTstate = mOT_Closed;
-               mDNS_DeregisterInterface(m, &m->p->interface);
+               mDNS_DeregisterInterface(m, &m->p->interface, mDNSfalse);
                }
        if (m->p->ep)          { OTCloseProvider   (m->p->ep);          m->p->ep          = NULL; }
        if (m->p->OTTimerTask) { OTDestroyTimerTask(m->p->OTTimerTask); m->p->OTTimerTask = 0;    }
index c4fa3100736de3e5ba7beaab9657a166293fbd1b..149ec0340804e71aedb2f118bcbb504e19f1fe41 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: mDNSMacOS9.h,v $
+Revision 1.11  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.10  2004/03/12 21:30:26  cheshire
 Build a System-Context Shared Library from mDNSCore, for the benefit of developers
 like Muse Research who want to be able to use mDNS/DNS-SD from GPL-licensed code.
index 80adab4697a51b6db5dc51085d92609490fc3341..5cf83fb936546342dffef227d9f69fc2ff7b75fd 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: mDNSPrefix.h,v $
+Revision 1.4  2006/08/14 23:24:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2004/06/11 00:03:28  cheshire
 Add code for testing avail/busy subtypes
 
index c2f50c12b1e23ef8014efd082e019addf5573d90..59bfd038d424649c33ba596153a7d2a398d968a0 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: DNSServiceDiscoveryDefines.h,v $
+Revision 1.7  2006/08/14 23:24:39  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.6  2004/09/20 21:45:27  ksekar
 Mach IPC cleanup
 
index 942fb6b1802216ce7d783fb7dbc84257a8ccf931..b918bee40403b780a34c7297db5e31e6175d238d 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002 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@
  */
  
 subsystem
index b6d9cf8c2a863238cf6c8bf5cdbf04571a5d8044..ad06bdb51fd35fe1bda69793df64679195b87e3d 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002 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@
  */
  
 subsystem
index 3816d58d72ab971af4aec57bf340c7c5e67638d9..371b6fc03ca716ddacdf2eb0d7ff7de9ce0bf6f7 100644 (file)
@@ -2,33 +2,23 @@
  *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
- *
- * 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.
- *
- * 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
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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: LegacyNATTraversal.c,v $
-Revision 1.14  2005/12/08 03:00:33  cheshire
-<rdar://problem/4349971> Byte order bugs in Legacy NAT traversal code
-
-Revision 1.13  2005/09/07 18:23:05  ksekar
-<rdar://problem/4151514> Off-by-one overflow in LegacyNATTraversal
+Revision 1.12.2.1  2006/08/29 06:24:30  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
 
 Revision 1.12  2005/07/22 21:36:16  ksekar
 Fix GCC 4.0/Intel compiler warnings
@@ -112,8 +102,6 @@ Revision 1.1  2004/08/18 17:35:41  ksekar
 // TODO: remove later and do variable length
 #define MAX_SOAPMSGSIZE                65536
 
-// This code accidentally closes fd 0 all over the place
-// To stop that messing up the mDNSResponder core, we trap it and prevent it
 static int safe_close(int fd)
        {
        if (fd < 3) { /* LogMsg("safe_close: ERROR sd %d < 3", fd); */ return(-1); }
@@ -122,10 +110,6 @@ static int safe_close(int fd)
 
 #define close safe_close
 
-// This code uses fprintf(stderr, ...) and similar to log error messages
-// We redirect all of them to syslog using our LogMsg mechanism
-#define fprintf(file, ...) LogMsg(__VA_ARGS__)
-
 ////////////////////////////////////////////////////////////////////////
 // NetAddr Functions
 ////////////////////////////////////////////////////////////////////////
@@ -448,7 +432,7 @@ typedef struct tagIPINFO
 {
         int                             iFlags;
         char                    szIfName[IFNAMELEN];    /* Interface name                       */
-        unsigned char   abIP[IPLEN];
+        unsigned char   abIP[IPLEN];                    /* IP in host byte order        */
         unsigned short  wPort;
 } IPINFO, *PIPINFO, **PPIPINFO;
 
@@ -456,13 +440,10 @@ typedef struct hostent    HOSTENT, *PHOSTENT;
 
 static unsigned long GetNATIPNetmask(unsigned long dwIP)
 {
-       static const union { uint8_t b[4]; uint32_t l; } mask_10 = { { 255, 0,   0, 0 } };      // Mask for 10/8
-       static const union { uint8_t b[4]; uint32_t l; } mask172 = { { 255, 240, 0, 0 } };      // Mask for 172.16/12
-       static const union { uint8_t b[4]; uint32_t l; } mask192 = { { 255, 255, 0, 0 } };      // Mask for 192.168/16
-       uint8_t *p = (uint8_t *)&dwIP;
-       if (p[0] ==  10                       ) return mask_10.l;
-       if (p[0] == 172 && (p[1] & 0xF0) == 16) return mask172.l;
-       if (p[0] == 192 && p[1] == 168        ) return mask192.l;
+       if ((dwIP & 0xFF000000) == 0x0A000000)  return 0xFF000000;
+       if ((dwIP & 0xFFF00000) == 0xAC100000)  return 0xFFF00000;
+       if ((dwIP & 0xFFFF0000) == 0xC0a80000)  return 0xFFFF0000;
+
        return 0;       /* No NAT IP */
 }
 
@@ -546,7 +527,8 @@ static int GetIPInfo(PPIPINFO ppIPInfo)
                {
                case AF_INET:
                        memcpy(pIPInfo[iNum].szIfName, ifr->ifr_name, IFNAMELEN);
-                       dwIP = ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr.s_addr;
+                       dwIP =
+                               ntohl(((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr.s_addr);
                        memcpy(pIPInfo[iNum].abIP, &dwIP, sizeof(unsigned long));
                        if (ifrcopy.ifr_flags & IFF_POINTOPOINT)
                                pIPInfo[iNum].iFlags |= ISPPP;
@@ -619,7 +601,7 @@ static int SSDPListen()
        saddr.sin_family = AF_INET;
        //saddr.sin_addr.s_addr = inet_addr(SSDP_IP);
        //saddr.sin_port = htons(SSDP_PORT);
-       saddr.sin_addr.s_addr = g_dwLocalIP;
+       saddr.sin_addr.s_addr = htonl(g_dwLocalIP);
        saddr.sin_port = 0;
 
        // and set the multicast add_member structure
@@ -664,7 +646,7 @@ static int EventListen()
                bzero(&saddr, sizeof(saddr));
                saddr.sin_len = sizeof(saddr);
                saddr.sin_family = AF_INET;
-               saddr.sin_addr.s_addr = g_dwLocalIP;
+               saddr.sin_addr.s_addr = htonl(g_dwLocalIP);
                saddr.sin_port = htons(g_wEventPort);
 
                // return if okay
@@ -735,7 +717,7 @@ static void DumpHex(char *buf, int len)
                        nexti = i + 16;
                        endj = (nexti > len) ? len : nexti;
                        for (j = i; j < endj; j++)
-                               fprintf(g_log, "%02x %c ", buf[j] & 0xff, buf[j]);
+                               fprintf(g_log, "%02x ", buf[j] & 0xff);
                        if (j == len) {
                                if ((j % 16) != 0) {
                                        char pad[3 * 16 + 1];  // don't need the last 3 bytes anyway
@@ -774,7 +756,7 @@ static char *FindHTTPHeaderNewLine(char *pbuf, int iBufSize, int *pfEOH)
                result = memchr(pbuf, '\r', iBufSize);
                if (result == NULL) {
                        if (g_fLogging & NALOG_INFO0) {
-                               fprintf(g_log, "FindHTTPHeaderNewLine: er @(%d/%d)\n", i, iBufSize);
+                               fprintf(g_log, "FindHTTPHeaderNewLine: er @(%d)\n", i);
                                fflush(g_log);
                        }
                        return NULL;
@@ -912,15 +894,7 @@ static PHTTPResponse NewHTTPResponse_sz(
                pszEOL = FindHTTPHeaderNewLine(pszEOL,
                        iBufferSize - (pszEOL - pBuf),  // remainder size
                        &fEOH);
-               if (pszEOL == NULL) {
-                       if (g_fLogging & NALOG_INFO0) {
-                               fprintf(g_log, "NewHTTPResponse_sz: er reading header field %d @ %lu / %lu\n",
-                                       iNumHeaders, pHeader->pszName - pBuf, iBufferSize);
-                               DumpHex(pszHTTPResponse, iBufferSize);
-                               fflush(g_log);
-                       }
-                       goto cleanup;  // syntax error
-               }
+               if (pszEOL == NULL) goto cleanup;  // syntax error
 
                *pszEOL = '\0';  // terminate this string
                pszEOL += 2;  // point to beginning of next line
@@ -1330,9 +1304,12 @@ static void *TCPProc(void *in)
                char response[2000];
                PHTTPResponse resp;
                int n;
-               sprintf(callback, "%u.%u.%u.%u:%u",
-                       ((uint8_t*)&g_dwLocalIP)[0], ((uint8_t*)&g_dwLocalIP)[1],
-                       ((uint8_t*)&g_dwLocalIP)[2], ((uint8_t*)&g_dwLocalIP)[3], g_wEventPort);
+               sprintf(callback, "%lu.%lu.%lu.%lu:%u", 
+                       (g_dwLocalIP >> 24) & 0xFF,
+                       (g_dwLocalIP >> 16) & 0xFF,
+                       (g_dwLocalIP >> 8) & 0xFF,
+                       (g_dwLocalIP >> 0) & 0xFF,
+                       g_wEventPort);
 
                n = sprintf((char *)buf,
                        szEventMsgSubscribeFMT,
@@ -1347,7 +1324,7 @@ static void *TCPProc(void *in)
                if (n > 0)
                {
                        response[n] = '\0';
-                       resp = NewHTTPResponse_sz((char *)response, n+1, TRUE);
+                       resp = NewHTTPResponse_sz((char *)buf, n, TRUE);
                        if (NULL != resp)
                        {
 ////TracePrint(ELL_TRACE, "UPnP Subscribe returns %s/%d\n", resp->pszStatus, n);
@@ -1523,7 +1500,7 @@ static void *UDPProc(void *in)
 
                if (!FD_ISSET(g_sUDP, &readfds)) continue;
                recvaddrlen = sizeof(recvaddr);
-               n = recvfrom(g_sUDP, buf, sizeof(buf)-1, 0,
+               n = recvfrom(g_sUDP, buf, sizeof(buf), 0,
                        (struct sockaddr *)&recvaddr, &recvaddrlen);
                if (n < 0) {
                        if (g_fLogging & NALOG_ERROR)
@@ -1536,7 +1513,7 @@ static void *UDPProc(void *in)
                }
                buf[n] = '\0';
                if (strncmp((char *)buf, "HTTP/1.1", 8) == 0) {
-                       PHTTPResponse pResponse = NewHTTPResponse_sz((char *)buf, n+1, TRUE);
+                       PHTTPResponse pResponse = NewHTTPResponse_sz((char *)buf, n, TRUE);
                        PrintHTTPResponse(pResponse);
                        if (DiscoverRouter(pResponse) == 0)
                        {
@@ -1555,7 +1532,7 @@ static void *UDPProc(void *in)
                        // temporarily use this to fudge - will have the exact same
                        // parsing, only status/reason set to "*" and "HTTP/1.1".
                        // TODO: add support for HTTP requests
-                       PHTTPResponse pResponse = NewHTTPResponse_sz((char *)buf, n+1, TRUE);
+                       PHTTPResponse pResponse = NewHTTPResponse_sz((char *)buf, n, TRUE);
                        if (DiscoverRouter(pResponse) == 0)
                        {
                                time_t  now = time(NULL);
@@ -1877,14 +1854,13 @@ GetTimeElapsed(&tv_start, &tv_end, &tv_elapsed);
 
                FD_ZERO(&readfds);
                FD_SET(s, &readfds);
-
-               // In testing, the Linksys Wireless-G Broadband Router "WRT54GS" takes
-               // up to four seconds to respond, and even then only a partial response,
-               // with the remainder coming in a second TCP segment half a second later.
-               // Accordingly, we wait up to five seconds for the initial data, and then after that
-               // wait one second after subsequent TCP segments, in care more data is still coming.
-               timeout.tv_sec  = iBufLen ? 1 : 5;
+               //timeout.tv_sec = g_iFunctionTimeout / U_TOGRAN;
+               //timeout.tv_usec = (g_iFunctionTimeout % U_TOGRAN) * 1000000 / U_TOGRAN;
+               // just do flat 2 sec now, since connection already established
+               timeout.tv_sec = 1;
                timeout.tv_usec = 0;
+
+
                iRet = select(s+1, &readfds, NULL, NULL, &timeout);
                if (iRet <= 0)
                {
@@ -1949,7 +1925,7 @@ GetTimeElapsed(&tv_start, &tv_end, &tv_elapsed);
 //fprintf(stderr, "2 -- \n");
 
        if (g_fLogging & NALOG_INFO1)
-               fprintf(g_log, "SendTCPMsg_saddr_2part done recv %d @ %lu\n", iBufLen, time(NULL));
+               fprintf(g_log, "done recv @%lu\n", time(NULL));
 
        if (result == NULL) {    // if caller just want to send/display msgs
                if (g_fLogging & NALOG_DUMP)
@@ -2038,7 +2014,7 @@ static int SendTCPMsg_saddr_parse(
        }
 
        if (g_fLogging & NALOG_INFO1)
-               fprintf(g_log, "SendTCPMsg_saddr_parse: Before Sending TCP Msg: %d == %lu?\n",
+               fprintf(g_log, "SendTCPMsg/parse: Before Sending TCP Msg: %d == %lu?\n",
                        iLen, strlen(msg));
        if (g_fLogging & NALOG_DUMP)
                fprintf(g_log,"Sending TCP msg:\n[%s]\n", msg);
@@ -2090,14 +2066,12 @@ static int SendTCPMsg_saddr_parse(
 
                FD_ZERO(&readfds);
                FD_SET(s, &readfds);
-
-               // In testing, the Linksys Wireless-G Broadband Router "WRT54GS" takes
-               // up to four seconds to respond, and even then only a partial response,
-               // with the remainder coming in a second TCP segment half a second later.
-               // Accordingly, we wait up to five seconds for the initial data, and then after that
-               // wait one second after subsequent TCP segments, in care more data is still coming.
-               timeout.tv_sec  = iBufLen ? 1 : 5;
+               //timeout.tv_sec = g_iFunctionTimeout / U_TOGRAN;
+               //timeout.tv_usec = (g_iFunctionTimeout % U_TOGRAN) * 1000000 / U_TOGRAN;
+               // just do flat 2 sec now, since connection already established
+               timeout.tv_sec = 1;
                timeout.tv_usec = 0;
+
                iRet = select(s+1, &readfds, NULL, NULL, &timeout);
                if (iRet <= 0) {
 //fprintf(stderr, "**********: select failed (%d/%d)\n", iRet, errno);
@@ -2124,8 +2098,6 @@ static int SendTCPMsg_saddr_parse(
                if (resultSize <= iBufLen) {
                        char    t[1000];
                        i = recv(s, &t, 1000, 0);
-                       if (g_fLogging & NALOG_INFO1)
-                               fprintf(g_log, "SendTCPMsg_saddr_parse discarding %d bytes\n", i);
                        if (i== 0) break;
                        // Note that there's no dump here - prevents DoS attack from
                        // flooding the logs/diskspace
@@ -2133,8 +2105,6 @@ static int SendTCPMsg_saddr_parse(
                }
 
                i = recv(s, result + iBufLen, resultSize - iBufLen, 0);
-               if (g_fLogging & NALOG_INFO1)
-                       fprintf(g_log, "SendTCPMsg_saddr_parse read %d bytes (%d/%d)\n", i, iBufLen, resultSize);
                if (0 == i) {
 
                        break;
@@ -2157,7 +2127,7 @@ static int SendTCPMsg_saddr_parse(
 //fprintf(stderr, "p -- \n");
 
        if (g_fLogging & NALOG_INFO1)
-               fprintf(g_log, "SendTCPMsg_saddr_parse done recv %d @ %lu\n", iBufLen, time(NULL));
+               fprintf(g_log, "done recv @%lu\n", time(NULL));
 
        if (result == NULL) {    // if caller just want to send/display msgs
                if (g_fLogging & NALOG_DUMP)
@@ -2269,8 +2239,6 @@ static PHTTPResponse SendSOAPMsgControlAction(
                        &g_saddrRouterSOAP);
        }
 
-       if (g_fLogging & NALOG_INFO1)
-               fprintf(g_log, "SendSOAPMsgControlAction iResultLen %d\n", iResultLen);
        if (iResultLen > 0) {
                if (iResultLen > MAX_SOAPMSGSIZE) {
                        if (g_fLogging & NALOG_ALERT)
@@ -2501,8 +2469,10 @@ static void ParseURL(
        szBuf,
        pszHostPort?pszHostPort:"",
        pszPath?pszPath:"",
-       ((uint8_t*)&psaddr->sin_addr.s_addr)[0], ((uint8_t*)&psaddr->sin_addr.s_addr)[1],
-       ((uint8_t*)&psaddr->sin_addr.s_addr)[2], ((uint8_t*)&psaddr->sin_addr.s_addr)[3],
+       (psaddr->sin_addr.s_addr >> 24) & 0xff,
+       (psaddr->sin_addr.s_addr >> 16) & 0xff,
+       (psaddr->sin_addr.s_addr >> 8) & 0xff,
+       (psaddr->sin_addr.s_addr >> 0) & 0xff,
        psaddr->sin_port);
 #endif
 }
@@ -2632,13 +2602,17 @@ static void GetIPByName(char *hostname, unsigned long *ip_ret)
                if (pHEnt == NULL) {
                        if (g_fLogging & NALOG_ALERT)
                                fprintf(g_log, "Can't translate [%s] to IP...\n", hostname);
-                       g_dwLocalIP = INADDR_ANY;
+                       g_dwLocalIP = htonl(INADDR_ANY);
                        return;
                }
-               ip = *(unsigned long *)(pHEnt->h_addr);
+               ip = ntohl(*(unsigned long *)(pHEnt->h_addr));
                if (g_fLogging & NALOG_INFO1)
-                       fprintf(g_log, "hostname [%s] to ip: %u.%u.%u.%u\n", hostname,
-                               ((uint8_t*)&ip)[0], ((uint8_t*)&ip)[1], ((uint8_t*)&ip)[2], ((uint8_t*)&ip)[3]);
+                       fprintf(g_log, "hostname [%s] to ip: %ld.%ld.%ld.%ld\n",
+                               hostname,
+                               (ip >> 24) & 0xff,
+                               (ip >> 16) & 0xff,
+                               (ip >> 8) & 0xff,
+                               (ip >> 0) & 0xff);
        }
        *ip_ret = ip;
 }
@@ -2706,8 +2680,9 @@ mStatus LNT_UnmapPort(mDNSIPPort PubPort, mDNSBool tcp)
        //unsigned              long dwIP;
        Property                propArgs[3];
        PHTTPResponse   resp;
+    unsigned short port = PubPort.NotAnInteger;
     int protocol = tcp ? IPPROTO_TCP : IPPROTO_UDP;
-       sprintf(szEPort, "%u", mDNSVal16(PubPort));
+       sprintf(szEPort, "%u", port);
 
        bzero(propArgs, sizeof(propArgs));
        propArgs[0].pszName = "NewRemoteHost";
@@ -2755,19 +2730,26 @@ extern mStatus LNT_MapPort(mDNSIPPort priv, mDNSIPPort pub, mDNSBool tcp)
        char                    descr[40];
        Property                propArgs[8];
        PHTTPResponse   resp;
+    unsigned short iport = priv.NotAnInteger;
+    unsigned short eport = pub.NotAnInteger;
     int protocol = tcp ? IPPROTO_TCP : IPPROTO_UDP;
 
-       if (NA_E_EXISTS == GetMappingUnused(mDNSVal16(pub), protocol))
+
+       if (NA_E_EXISTS == GetMappingUnused(eport, protocol))
                return mStatus_AlreadyRegistered;
 
        //DeletePortMapping(eport, protocol);
 
-       sprintf(szEPort, "%u", mDNSVal16(pub));
-       sprintf(szIPort, "%u", mDNSVal16(priv));
+       sprintf(szEPort, "%u", eport);
+
+       sprintf(szIPort, "%u", iport);
 
        dwIP = g_dwLocalIP;
        sprintf(szLocalIP, "%u.%u.%u.%u",
-               ((uint8_t*)&dwIP)[0], ((uint8_t*)&dwIP)[1], ((uint8_t*)&dwIP)[2], ((uint8_t*)&dwIP)[3]);
+               (unsigned int)((dwIP >> 24) & 0xff),
+               (unsigned int)((dwIP >> 16) & 0xff),
+               (unsigned int)((dwIP >> 8) & 0xff),
+               (unsigned int)((dwIP >> 0) & 0xff));
 
        bzero(propArgs, sizeof(propArgs));
        propArgs[0].pszName = "NewRemoteHost";
@@ -2797,7 +2779,7 @@ extern mStatus LNT_MapPort(mDNSIPPort priv, mDNSIPPort pub, mDNSBool tcp)
        propArgs[5].pszValue = "1";
        propArgs[5].pszType = "boolean";
        propArgs[6].pszName = "NewPortMappingDescription";
-       sprintf(descr, "iC%u", mDNSVal16(pub));
+       sprintf(descr, "iC%u", eport);
        //propArgs[6].pszValue = "V";
        propArgs[6].pszValue = descr;
        propArgs[6].pszType = "string";
@@ -2805,15 +2787,9 @@ extern mStatus LNT_MapPort(mDNSIPPort priv, mDNSIPPort pub, mDNSBool tcp)
        propArgs[7].pszValue = "0";
        propArgs[7].pszType = "ui4";
 
-       if (g_fLogging & NALOG_INFO1)
-               fprintf(g_log, "Sending AddPortMapping priv %u pub %u\n", mDNSVal16(priv), mDNSVal16(pub));
-
        resp = SendSOAPMsgControlAction(
                "AddPortMapping", 8, propArgs, FALSE);
 
-       if (g_fLogging & NALOG_INFO1)
-               fprintf(g_log, "AddPortMapping resp %p\n", resp);
-
        if (resp == NULL) {
                return mStatus_NATTraversal;
        }
@@ -2934,13 +2910,11 @@ int LegacyNATInit(void)
        pthread_attr_t  attr;
        int                             iRet;
        //struct timeval        tv;
-       LogOperation("LegacyNATInit");
 
        static int              fFirstInitLocks = TRUE;
        FILE *log = NULL;       
        
        g_fLogging = 0;
-       //g_fLogging = ~0;              // Turns ALL logging on
        g_log = stderr;
 
        SetLocalIP();
index 97b560f6e303dff0cf5b1151c411dd18d4eafae0..5ba4674ee10c023e982bef935a5899d38b3f8bdd 100644 (file)
Binary files a/mDNSMacOSX/PreferencePane/BonjourPref.icns and b/mDNSMacOSX/PreferencePane/BonjourPref.icns differ
index 85f441e18215de83e10ab46119462f02b9c1e2d2..9e59fa50d5b16738bc6af80123851e46af16bc35 100644 (file)
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
     Change History (most recent first):
+
 $Log: ConfigurationRights.h,v $
+Revision 1.2  2006/08/14 23:15:47  cheshire
+Tidy up Change History comment
+
 Revision 1.1  2005/02/05 01:59:19  cheshire
 Add Preference Pane to facilitate testing of DDNS & wide-area features
 
index 21f98f56ef4493136c65a9a90d9ff7b2084b33c0..cf69c9c2e19a7c329725b5928e5318e72363ee90 100644 (file)
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
     Change History (most recent first):
+
 $Log: DNSServiceDiscoveryPref.h,v $
+Revision 1.6  2006/08/14 23:15:47  cheshire
+Tidy up Change History comment
+
 Revision 1.5  2005/02/26 00:44:24  cheshire
 Restore default reg domain if user deletes text and clicks "apply"
 
index e7744980007dfc77722756c53bef09c9cc8dc24a..373e52eba87c69fd6b7dbd76521772c7b2b85719 100644 (file)
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
     Change History (most recent first):
+
 $Log: DNSServiceDiscoveryPref.m,v $
+Revision 1.8  2006/08/14 23:15:47  cheshire
+Tidy up Change History comment
+
+Revision 1.7  2006/07/14 03:59:14  cheshire
+Fix compile warnings: 'sortUsingFunction:context:' comparison function needs to return int
+
 Revision 1.6  2005/02/26 00:44:24  cheshire
 Restore default reg domain if user deletes text and clicks "apply"
 
@@ -70,14 +77,14 @@ Add Preference Pane to facilitate testing of DDNS & wide-area features
 
 @implementation DNSServiceDiscoveryPref
 
-static CFComparisonResult
+static int
 MyArrayCompareFunction(id val1, id val2, void *context)
 {
     return CFStringCompare((CFStringRef)val1, (CFStringRef)val2, kCFCompareCaseInsensitive);
 }
 
 
-static CFComparisonResult
+static int
 MyDomainArrayCompareFunction(id val1, id val2, void *context)
 {
        NSString *domain1 = [val1 objectForKey:(NSString *)SC_DYNDNS_DOMAIN_KEY];
@@ -1200,5 +1207,4 @@ MyDNSServiceAddServiceToRunLoop(MyDNSServiceState * query)
     [self disableControls];
 }
 
-
-@end
\ No newline at end of file
+@end
index e76e125fac018382ff1d61cbb81b481317e61551..c523f4e61e196c00ff06e0e2d0c5b83389108f46 100644 (file)
Binary files a/mDNSMacOSX/PreferencePane/English.lproj/InfoPlist.strings and b/mDNSMacOSX/PreferencePane/English.lproj/InfoPlist.strings differ
index 89b9736caababb867e39c9542b0cf24f518e1073..0ca00dbb2e7b11737755a1580b40f78d2b131ebb 100644 (file)
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
     Change History (most recent first):
+
 $Log: PrivilegedOperations.c,v $
+Revision 1.6  2006/08/14 23:15:47  cheshire
+Tidy up Change History comment
+
+Revision 1.5  2006/06/10 02:07:11  mkrochma
+Whoa.  Make sure code compiles before checking it in.
+
+Revision 1.4  2006/05/27 02:32:38  mkrochma
+Wait for installer script to exit before returning result
+
 Revision 1.3  2005/06/04 04:50:00  cheshire
 <rdar://problem/4138070> ddnswriteconfig (Bonjour PreferencePane) vulnerability
 Use installtool instead of requiring ddnswriteconfig to self-install
@@ -132,8 +142,18 @@ OSStatus EnsureToolInstalled(void)
                {
                        char *installerargs[] = { toolSourcePath, NULL };
                        err = AuthorizationExecuteWithPrivileges(authRef, toolInstallerPath, 0, installerargs, (FILE**) NULL);
-                       if (err == noErr)
-                               gToolApproved = true;
+                       if (err == noErr) {
+                               int status;
+                               int pid = wait(&status);
+                               if (pid > 0 && WIFEXITED(status)) {
+                                       err = WEXITSTATUS(status);
+                                       if (err == noErr) {
+                                               gToolApproved = true;
+                                       }
+                               } else {
+                                       err = -1;
+                               }
+                       }
                        (void) AuthorizationFree(authRef, kAuthorizationFlagDestroyRights);
                }
        }
index c5c68a0b5ad7d3a7d88d51b30e8cc06358a9bc62..e76cb6895e5f1c5bd0d52701ff312fa9d8afde4e 100644 (file)
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
     Change History (most recent first):
+
 $Log: PrivilegedOperations.h,v $
+Revision 1.5  2006/08/14 23:15:47  cheshire
+Tidy up Change History comment
+
 Revision 1.4  2005/06/04 04:50:00  cheshire
 <rdar://problem/4138070> ddnswriteconfig (Bonjour PreferencePane) vulnerability
 Use installtool instead of requiring ddnswriteconfig to self-install
index ff3080ef37193ebd2c9de1872294ab29ca6986c4..3c5398b0962b6081413a93bebf4131e5c6513b9e 100644 (file)
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
     Change History (most recent first):
+
 $Log: ddnswriteconfig.m,v $
+Revision 1.5  2006/08/14 23:15:47  cheshire
+Tidy up Change History comment
+
 Revision 1.4  2005/06/04 04:47:47  cheshire
 <rdar://problem/4138070> ddnswriteconfig (Bonjour PreferencePane) vulnerability
 Remove self-installing capability of ddnswriteconfig
index 8fa79ad018afd2df9ff477f2503a2e5fbf853291..6240d338c11752c1152e778f783903a1812f2a2c 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/perl
+# Emacs settings: -*- tab-width: 4 -*-
 #
 # File: installtool
 # 
 # Change History (most recent first):
 # 
 # $Log: installtool,v $
+# Revision 1.3  2006/09/05 20:00:13  cheshire
+# Moved Emacs settings to second line of file
+#
+# Revision 1.2  2006/08/14 23:15:14  cheshire
+# Added "tab-width" emacs header line
+#
 # Revision 1.1  2005/06/04 04:51:48  cheshire
 # <rdar://problem/4138070> ddnswriteconfig (Bonjour PreferencePane) vulnerability
 # Added separate "installtool" script instead of making ddnswriteconfig self-install
index a387269247f4d26c1a2b0bddf92db585100325a8..1e03989e5bddcb559a5686466b85ec9dc6c38c94 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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@
  *
  * Formatting notes:
  * This code follows the "Whitesmiths style" C indentation rules. Plenty of discussion
     Change History (most recent first):
 
 $Log: SamplemDNSClient.c,v $
+Revision 1.48  2006/08/14 23:24:39  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.47  2006/01/10 02:29:22  cheshire
+<rdar://problem/4403861> Cosmetic IPv6 address display problem in mDNS test tool
+
 Revision 1.46  2004/11/02 01:32:34  cheshire
 <rdar://problem/3861705> Update code so it still compiles when DNSServiceDiscovery.h is deprecated
 
@@ -217,12 +217,14 @@ static void resolve_reply(struct sockaddr *interface, struct sockaddr *address,
         else if (address->sa_family == AF_INET6)
             {
             struct sockaddr_in6 *ip6 = (struct sockaddr_in6 *)address;
-            u_int16_t *w = ip6->sin6_addr.__u6_addr.__u6_addr16;
+            u_int8_t *b = ip6->sin6_addr.__u6_addr.__u6_addr8;
             union { uint16_t s; u_char b[2]; } port = { ip6->sin6_port };
             uint16_t PortAsNumber = ((uint16_t)port.b[0]) << 8 | port.b[1];
             char ipstring[40];
             char ifname[IF_NAMESIZE + 1] = "";
-            sprintf(ipstring, "%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X", w[0], w[1], w[2], w[3], w[4], w[5], w[6], w[7]);
+            sprintf(ipstring, "%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X",
+                               b[0x0], b[0x1], b[0x2], b[0x3], b[0x4], b[0x5], b[0x6], b[0x7],
+                               b[0x8], b[0x9], b[0xA], b[0xB], b[0xC], b[0xD], b[0xE], b[0xF]);
             if (ip6->sin6_scope_id) { ifname[0] = '%';  if_indextoname(ip6->sin6_scope_id, &ifname[1]); }
             printf("%s%s:%u", ipstring, ifname, PortAsNumber);
             }
index d2b1b16148650b46ea188cd82c05f1d178c62579..dab0a3087a38bffed0f3baead57e7ab61470c2e8 100644 (file)
@@ -1,24 +1,18 @@
-/*
- * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
+/* -*- Mode: C; tab-width: 4 -*-
  *
- * @APPLE_LICENSE_HEADER_START@
+ * Copyright (c) 2002-2006 Apple Computer, Inc. All rights reserved.
+ *
+ * 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@
  *
  * Formatting notes:
  * This code follows the "Whitesmiths style" C indentation rules. Plenty of discussion
     Change History (most recent first):
 
 $Log: daemon.c,v $
+Revision 1.265.2.1  2006/08/29 06:24:30  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.265  2006/06/29 07:32:08  cheshire
+Added missing LogOperation logging for DNSServiceBrowse results
+
+Revision 1.264  2006/06/29 05:33:30  cheshire
+<rdar://problem/4607043> mDNSResponder conditional compilation options
+
+Revision 1.263  2006/06/08 23:23:48  cheshire
+Fix errant indentation of curly brace at the end of provide_DNSServiceBrowserCreate_rpc()
+
+Revision 1.262  2006/03/18 21:49:11  cheshire
+Added comment in ShowTaskSchedulingError(mDNS *const m)
+
+Revision 1.261  2006/01/06 01:22:28  cheshire
+<rdar://problem/4108164> Reword "mach_absolute_time went backwards" dialog
+
 Revision 1.260  2005/11/07 01:51:58  cheshire
 <rdar://problem/4331591> Include list of configured DNS servers in SIGINFO output
 
@@ -769,7 +781,8 @@ mDNSexport void LogMemCorruption(const char *format, ...)
        buffer[mDNS_vsnprintf((char *)buffer, sizeof(buffer), format, ptr)] = 0;
        va_end(ptr);
        LogMsg("!!!! %s !!!!", buffer);
-       NotifyOfElusiveBug("Memory Corruption", 0, buffer);
+       NotifyOfElusiveBug("Memory Corruption", buffer);
+       //*(long*)0 = -1;       // Trick to crash and get a stack trace right here, if that's what we want
        }
 
 mDNSlocal void validatelists(mDNS *const m)
@@ -1210,6 +1223,9 @@ mDNSlocal void FoundInstance(mDNS *const m, DNSQuestion *question, const Resourc
        DNSServiceBrowserResult **p = &browser->results;
        while (*p) p = &(*p)->next;
        *p = x;
+
+       LogOperation("%5d: DNSServiceBrowse(%##s, %s) RESULT %s %s",
+               browser->ClientMachPort, question->qname.c, DNSTypeName(question->qtype), AddRecord ? "Add" : "Rmv", RRDisplayString(m, answer));
        }
 
 mDNSlocal mStatus AddDomainToBrowser(DNSServiceBrowser *browser, const domainname *d)
@@ -1259,8 +1275,10 @@ mDNSexport void DefaultBrowseDomainChanged(const domainname *d, mDNSBool add)
                                                *q = (*q)->next;
                                                if (remove->q.LongLived)
                                                        {
-                                                       // give goodbyes for known answers.  note that since events are sent to client via udns_execute(),
-                                                       // we don't need to worry about the question being cancelled mid-loop
+                                                       // Give goodbyes for known answers.
+                                                       // Note that this a special case where we know that the QuestionCallback function is our own
+                                                       // code (it's FoundInstance), and that callback routine doesn't ever cancel its operation, so we
+                                                       // don't need to guard against the question being cancelled mid-loop the way the mDNSCore routines do.
                                                        CacheRecord *ka = remove->q.uDNS_info.knownAnswers;
                                                        while (ka) { remove->q.QuestionCallback(&mDNSStorage, &remove->q, &ka->resrec, mDNSfalse); ka = ka->next; }
                                                        }                                               
@@ -1351,7 +1369,7 @@ fail:
        LogMsg("%5d: DNSServiceBrowse(\"%s\", \"%s\") failed: %s (%ld)", client, regtype, domain, errormsg, err);
        if (SearchDomains) mDNS_FreeDNameList(SearchDomains);
        return(err);
-               }
+       }
 
 //*************************************************************************************************************
 // Resolve Service Info
@@ -1770,13 +1788,15 @@ fail:
        return(err);
        }
 
-mDNSlocal CFUserNotificationRef gNotification    = NULL;
-mDNSlocal CFRunLoopSourceRef    gNotificationRLS = NULL;
 mDNSlocal domainlabel           gNotificationPrefHostLabel;    // The prefs as they were the last time we saw them
 mDNSlocal domainlabel           gNotificationPrefNiceLabel;
 mDNSlocal domainlabel           gNotificationUserHostLabel;    // The prefs as they were the last time the user changed them
 mDNSlocal domainlabel           gNotificationUserNiceLabel;
 
+#ifndef NO_CFUSERNOTIFICATION
+mDNSlocal CFUserNotificationRef gNotification    = NULL;
+mDNSlocal CFRunLoopSourceRef    gNotificationRLS = NULL;
+
 mDNSlocal void NotificationCallBackDismissed(CFUserNotificationRef userNotification, CFOptionFlags responseFlags)
        {
        (void)responseFlags;    // Unused
@@ -1821,6 +1841,7 @@ mDNSlocal void ShowNameConflictNotification(CFStringRef header, CFStringRef subt
 
        CFRelease(dictionary);
        }
+#endif /* NO_CFUSERNOTIFICATION */
 
 // This updates either the text of the field currently labelled "Local Hostname",
 // or the text of the field currently labelled "Computer Name"
@@ -1857,6 +1878,7 @@ mDNSlocal void RecordUpdatedName(const mDNS *const m, const domainlabel *const o
                        LogMsg("RecordUpdatedName: ERROR: Couldn't update SCPreferences");
                else if (m->p->NotifyUser)
                        {
+#ifndef NO_CFUSERNOTIFICATION
                        uid_t uid;
                        gid_t gid;
                        CFStringRef userName = SCDynamicStoreCopyConsoleUser(NULL, &uid, &gid);
@@ -1874,6 +1896,9 @@ mDNSlocal void RecordUpdatedName(const mDNS *const m, const domainlabel *const o
                                append(alertHeader, CFSTR("automatically."));
                                ShowNameConflictNotification(alertHeader, subtext);
                                }
+#else
+                       (void)subtext;
+#endif /*  NO_CFUSERNOTIFICATION */
                        }
                if (s0)          CFRelease(s0);
                if (s1)          CFRelease(s1);
@@ -1906,9 +1931,11 @@ mDNSlocal void mDNS_StatusCallback(mDNS *const m, mStatus result)
                        {
                        gNotificationUserHostLabel = gNotificationPrefHostLabel = m->p->userhostlabel;
                        gNotificationUserNiceLabel = gNotificationPrefNiceLabel = m->p->usernicelabel;
+#ifndef NO_CFUSERNOTIFICATION
                        // If we're showing a name conflict notification, and the user has manually edited
                        // the name to remedy the conflict, we should now remove the notification window.
                        if (gNotificationRLS) CFUserNotificationCancel(gNotification);
+#endif /* NO_CFUSERNOTIFICATION */
                        }
 
                DNSServiceRegistration *r;
@@ -2568,6 +2595,8 @@ mDNSlocal void ShowTaskSchedulingError(mDNS *const m)
 
        LogMsg("Task Scheduling Error: Continuously busy for more than a second");
        
+       // NOTE: To accurately diagnose *why* we're busy, the debugging code here to show needs to mirror the logic in GetNextScheduledEvent
+
        if (m->NewQuestions && (!m->NewQuestions->DelayAnswering || m->timenow - m->NewQuestions->DelayAnswering >= 0))
                LogMsg("Task Scheduling Error: NewQuestion %##s (%s)",
                        m->NewQuestions->qname.c, DNSTypeName(m->NewQuestions->qtype));
index d926cb12f17bb59cee5f68ddad46cd9a935088ec..982192ff3dcbef4a9ec31fb6101e77c9c5bb948c 100644 (file)
@@ -2,28 +2,54 @@
  *
  * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
- *
- * 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.
- *
- * 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
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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: mDNSMacOSX.c,v $
+Revision 1.333.2.1  2006/08/29 06:24:30  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.333  2006/06/29 05:33:30  cheshire
+<rdar://problem/4607043> mDNSResponder conditional compilation options
+
+Revision 1.332  2006/06/28 09:10:36  cheshire
+Extra debugging messages
+
+Revision 1.331  2006/06/21 22:29:42  cheshire
+Make _CFCopySystemVersionDictionary() call more defensive on systems that have no build information set
+
+Revision 1.330  2006/06/20 23:06:00  cheshire
+Fix some keychain API type mismatches (was mDNSu32 instead of UInt32)
+
+Revision 1.329  2006/06/08 23:22:33  cheshire
+Comment changes
+
+Revision 1.328  2006/03/19 03:27:49  cheshire
+<rdar://problem/4118624> Suppress "interface flapping" logic for loopback
+
+Revision 1.327  2006/03/19 02:00:09  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
+Revision 1.326  2006/03/08 22:42:23  cheshire
+Fix spelling mistake: LocalReverseMapomain -> LocalReverseMapDomain
+
+Revision 1.325  2006/01/10 00:39:17  cheshire
+Add comments explaining how IPv6 link-local addresses sometimes have an embedded scope_id
+
+Revision 1.324  2006/01/09 19:28:59  cheshire
+<rdar://problem/4403128> Cap number of "sendto failed" messages we allow mDNSResponder to log
+
 Revision 1.323  2006/01/05 21:45:27  cheshire
 <rdar://problem/4400118> Fix uninitialized structure member in IPv6 code
 
@@ -1015,7 +1041,9 @@ Minor code tidying
 #include <netinet/ip.h>             // For IPTOS_LOWDELAY etc.
 #include <netinet6/in6_var.h>       // For IN6_IFF_NOTREADY etc.
 
+#ifndef NO_SECURITYFRAMEWORK
 #include <Security/Security.h>
+#endif /* NO_SECURITYFRAMEWORK */
 
 #include "dnsinfo.h"
 
@@ -1075,6 +1103,14 @@ mDNSlocal void SetSCPrefsBrowseDomain(mDNS *m, const domainname *d, mDNSBool add
 // ***************************************************************************
 // Functions
 
+// We only attempt to send and receive multicast packets on interfaces that are
+// (a) flagged as multicast-capable
+// (b) *not* flagged as point-to-point (e.g. modem)
+// Typically point-to-point interfaces are modems (including mobile-phone pseudo-modems), and we don't want
+// to run up the user's bill sending multicast traffic over a link where there's only a single device at the
+// other end, and that device (e.g. a modem bank) is probably not answering Multicast DNS queries anyway.
+#define MulticastInterface(i) ((i->ifa_flags & IFF_MULTICAST) && !(i->ifa_flags & IFF_POINTOPOINT))
+
 // routines to allow access to default domain lists from daemon layer
 
 mDNSexport DNameListElem *mDNSPlatformGetSearchDomainList(void)
@@ -1131,6 +1167,7 @@ mDNSlocal void RemoveDefRegDomain(domainname *d)
        debugf("Requested removal of default registration domain %##s not in contained in list", d->c); 
        }
 
+#ifndef NO_CFUSERNOTIFICATION
 mDNSexport void NotifyOfElusiveBug(const char *title, const char *msg) // Both strings are UTF-8 text
        {
        static int notifyCount = 0;
@@ -1164,6 +1201,11 @@ mDNSexport void NotifyOfElusiveBug(const char *title, const char *msg)   // Both s
        CFStringRef alertMessage = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@\r\r%@"), alertBody, alertFooter);
        CFUserNotificationDisplayNotice(0.0, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL, alertHeader, alertMessage, NULL);
        }
+#else
+mDNSexport void NotifyOfElusiveBug(__unused const char *title, __unused const char *msg)
+       {
+       }
+#endif /* NO_CFUSERNOTIFICATION */
 
 mDNSlocal struct ifaddrs* myGetIfAddrs(int refresh)
        {
@@ -1201,26 +1243,42 @@ mDNSlocal int myIfIndexToName(u_short index, char* name)
        return -1;
        }
 
-mDNSexport mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(const mDNS *const m, mDNSu32 index)
+mDNSexport mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(mDNS *const m, mDNSu32 index)
        {
        NetworkInterfaceInfoOSX *i;
        if (index == kDNSServiceInterfaceIndexLocalOnly) return(mDNSInterface_LocalOnly);
-       if (index)
-               for (i = m->p->InterfaceList; i; i = i->next)
-                       // Don't get tricked by inactive interfaces with no InterfaceID set
-                       if (i->ifinfo.InterfaceID && i->scope_id == index) return(i->ifinfo.InterfaceID);
+       if (index == kDNSServiceInterfaceIndexAny      ) return(mDNSNULL);
+
+       // Don't get tricked by inactive interfaces with no InterfaceID set
+       for (i = m->p->InterfaceList; i; i = i->next)
+               if (i->ifinfo.InterfaceID && i->scope_id == index) return(i->ifinfo.InterfaceID);
+
+       // Not found. Make sure our interface list is up to date, then try again.
+       LogOperation("InterfaceID for interface index %d not found; Updating interface list", index);
+       mDNSMacOSXNetworkChanged(m);
+       for (i = m->p->InterfaceList; i; i = i->next)
+               if (i->ifinfo.InterfaceID && i->scope_id == index) return(i->ifinfo.InterfaceID);
+
        return(mDNSNULL);
        }
 
-mDNSexport mDNSu32 mDNSPlatformInterfaceIndexfromInterfaceID(const mDNS *const m, mDNSInterfaceID id)
+mDNSexport mDNSu32 mDNSPlatformInterfaceIndexfromInterfaceID(mDNS *const m, mDNSInterfaceID id)
        {
        NetworkInterfaceInfoOSX *i;
        if (id == mDNSInterface_LocalOnly) return(kDNSServiceInterfaceIndexLocalOnly);
-       if (id)
-               for (i = m->p->InterfaceList; i; i = i->next)
-                       // Don't use i->ifinfo.InterfaceID here, because we DO want to find inactive interfaces, which have no InterfaceID set
-                       if ((mDNSInterfaceID)i == id) return(i->scope_id);
-       return 0;
+       if (id == mDNSInterface_Any      ) return(0);
+
+       // Don't use i->ifinfo.InterfaceID here, because we DO want to find inactive interfaces, which have no InterfaceID set
+       for (i = m->p->InterfaceList; i; i = i->next)
+               if ((mDNSInterfaceID)i == id) return(i->scope_id);
+
+       // Not found. Make sure our interface list is up to date, then try again.
+       LogOperation("Interface index for InterfaceID %p not found; Updating interface list", id);
+       mDNSMacOSXNetworkChanged(m);
+       for (i = m->p->InterfaceList; i; i = i->next)
+               if ((mDNSInterfaceID)i == id) return(i->scope_id);
+
+       return(0);
        }
 
 mDNSlocal mDNSBool AddrRequiresPPPConnection(const struct sockaddr *addr)
@@ -1291,9 +1349,9 @@ mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const ms
                return mStatus_BadParamErr;
                }
 
-       // Don't send if it would cause dial on demand connection initiation.  As an optimization,
-       // don't bother consulting reachability API / routing table when sending Multicast DNS
-       // since we ignore PPP interfaces for mDNS traffic
+       // Don't send if it would cause dial-on-demand connection initiation.
+       // As an optimization, don't bother consulting reachability API / routing
+       // table when sending Multicast DNS since we ignore PPP interfaces for mDNS traffic.
        if (!mDNSAddrIsDNSMulticast(dst) && AddrRequiresPPPConnection((struct sockaddr *)&to))
                {
                debugf("mDNSPlatformSendUDP: Surpressing sending to avoid dial-on-demand connection");
@@ -1314,6 +1372,7 @@ mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const ms
        err = sendto(s, msg, (UInt8*)end - (UInt8*)msg, 0, (struct sockaddr *)&to, to.ss_len);
        if (err < 0)
                {
+               static int MessageCount = 0;
         // Don't report EHOSTDOWN (i.e. ARP failure), ENETDOWN, or no route to host for unicast destinations
                if (!mDNSAddressIsAllDNSLinkGroup(dst))
                        if (errno == EHOSTDOWN || errno == ENETDOWN || errno == EHOSTUNREACH || errno == ENETUNREACH) return(mStatus_TransientErr);
@@ -1323,8 +1382,12 @@ mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const ms
                if (errno == EHOSTUNREACH && (mDNSu32)(mDNSPlatformRawTime()) < (mDNSu32)(mDNSPlatformOneSecond * 180)) return(mStatus_TransientErr);
                // Don't report EADDRNOTAVAIL ("Can't assign requested address") if we're in the middle of a network configuration change
                if (errno == EADDRNOTAVAIL && m->p->NetworkChanged) return(mStatus_TransientErr);
-               LogMsg("mDNSPlatformSendUDP sendto failed to send packet on InterfaceID %p %5s/%ld to %#a:%d skt %d error %d errno %d (%s) %lu",
-                       InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, errno, strerror(errno), (mDNSu32)(m->timenow));
+               if (MessageCount < 1000)
+                       {
+                       MessageCount++;
+                       LogMsg("mDNSPlatformSendUDP sendto failed to send packet on InterfaceID %p %5s/%ld to %#a:%d skt %d error %d errno %d (%s) %lu",
+                               InterfaceID, ifa_name, dst->type, dst, mDNSVal16(dstPort), s, err, errno, strerror(errno), (mDNSu32)(m->timenow));
+                       }
                return(mStatus_UnknownErr);
                }
        
@@ -1463,6 +1526,7 @@ mDNSlocal void myCFSocketCallBack(const CFSocketRef cfs, const CFSocketCallBackT
                        senderAddr.type = mDNSAddrType_IPv6;
                        senderAddr.ip.v6 = *(mDNSv6Addr*)&sin6->sin6_addr;
                        senderPort.NotAnInteger = sin6->sin6_port;
+                       //LogOperation("myCFSocketCallBack received IPv6 packet from %#a to %#a", &senderAddr, &destAddr);
                        }
                else
                        {
@@ -1597,7 +1661,7 @@ mDNSexport mStatus mDNSPlatformTCPConnect(const mDNSAddr *dst, mDNSOpaque16 dstp
        saddr.sin_len = sizeof(saddr);
        memcpy(&saddr.sin_addr, &dst->ip.v4.NotAnInteger, sizeof(saddr.sin_addr));
 
-       // Don't send if it would cause dial on demand connection initiation.
+       // Don't send if it would cause dial-on-demand connection initiation.
        if (AddrRequiresPPPConnection((struct sockaddr *)&saddr))
                {
                debugf("mDNSPlatformTCPConnect: Surpressing sending to avoid dial-on-demand connection");
@@ -1955,8 +2019,8 @@ mDNSlocal mStatus SetupSocket(mDNS *const m, CFSocketSet *cp, mDNSBool mcast, co
                err = setsockopt(skt, IPPROTO_IPV6, IPV6_HOPLIMIT, &on, sizeof(on));
                if (err < 0) { errstr = "setsockopt - IPV6_HOPLIMIT"; goto fail; }
                
-               // We want to receive only IPv6 packets, without this option, we may
-               // get IPv4 addresses as mapped addresses.
+               // We want to receive only IPv6 packets. Without this option we get IPv4 packets too,
+               // with mapped addresses of the form 0:0:0:0:0:FFFF:xxxx:xxxx, where xxxx:xxxx is the IPv4 address
                err = setsockopt(skt, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
                if (err < 0) { errstr = "setsockopt - IPV6_V6ONLY"; goto fail; }
                
@@ -1965,6 +2029,7 @@ mDNSlocal mStatus SetupSocket(mDNS *const m, CFSocketSet *cp, mDNSBool mcast, co
                        // Add multicast group membership on this interface, if it's for multicast receiving
                        int interface_id = if_nametoindex(cp->info->ifa_name);
                        struct ipv6_mreq i6mr;
+                       //LogOperation("SetupSocket: v6 %#a %s %d", ifaddr, cp->info->ifa_name, interface_id);
                        i6mr.ipv6mr_interface = interface_id;
                        i6mr.ipv6mr_multiaddr = *(struct in6_addr*)&AllDNSLinkGroupv6;
                        err = setsockopt(skt, IPPROTO_IPV6, IPV6_JOIN_GROUP, &i6mr, sizeof(i6mr));
@@ -2044,8 +2109,13 @@ mDNSlocal mStatus SetupAddr(mDNSAddr *ip, const struct sockaddr *const sa)
        if (sa->sa_family == AF_INET6)
                {
                struct sockaddr_in6 *ifa_addr = (struct sockaddr_in6 *)sa;
-               ip->type = mDNSAddrType_IPv6;
+               // Inside the BSD kernel they use a hack where they stuff the sin6->sin6_scope_id
+               // value into the second word of the IPv6 link-local address, so they can just
+               // pass around IPv6 address structures instead of full sockaddr_in6 structures.
+               // Those hacked IPv6 addresses aren't supposed to escape the kernel in that form, but they do.
+               // To work around this we always whack the second word of any IPv6 link-local address back to zero.
                if (IN6_IS_ADDR_LINKLOCAL(&ifa_addr->sin6_addr)) ifa_addr->sin6_addr.__u6_addr.__u6_addr16[1] = 0;
+               ip->type = mDNSAddrType_IPv6;
                ip->ip.v6 = *(mDNSv6Addr*)&ifa_addr->sin6_addr;
                return(mStatus_NoError);
                }
@@ -2078,6 +2148,10 @@ mDNSlocal mDNSEthAddr GetBSSID(char *ifa_name)
        return(eth);
        }
 
+// Returns pointer to newly created NetworkInterfaceInfoOSX object, or
+// pointer to already-existing NetworkInterfaceInfoOSX object found in list, or
+// may return NULL if out of memory (unlikely) or parameters are invalid for some reason
+// (e.g. sa_family not AF_INET or AF_INET6)
 mDNSlocal NetworkInterfaceInfoOSX *AddInterfaceToList(mDNS *const m, struct ifaddrs *ifa, mDNSs32 utc)
        {
        mDNSu32 scope_id  = if_nametoindex(ifa->ifa_name);
@@ -2093,6 +2167,8 @@ mDNSlocal NetworkInterfaceInfoOSX *AddInterfaceToList(mDNS *const m, struct ifad
                        {
                        debugf("AddInterfaceToList: Found existing interface %lu %.6a with address %#a at %p", scope_id, &bssid, &ip, *p);
                        (*p)->Exists = mDNStrue;
+                       // If interface was not in getifaddrs list last time we looked, but it is now, update 'AppearanceTime' for this record
+                       if ((*p)->LastSeen != utc) (*p)->AppearanceTime = utc;
                        return(*p);
                        }
 
@@ -2114,11 +2190,14 @@ mDNSlocal NetworkInterfaceInfoOSX *AddInterfaceToList(mDNS *const m, struct ifad
        
        i->next            = mDNSNULL;
        i->Exists          = mDNStrue;
+       i->AppearanceTime  = utc;               // Brand new interface; AppearanceTime is now
        i->LastSeen        = utc;
+       i->Flashing        = mDNSfalse;
+       i->Occulting       = mDNSfalse;
        i->scope_id        = scope_id;
        i->BSSID           = bssid;
        i->sa_family       = ifa->ifa_addr->sa_family;
-       i->Multicast       = (ifa->ifa_flags & IFF_MULTICAST) && !(ifa->ifa_flags & IFF_POINTOPOINT);
+       i->ifa_flags       = ifa->ifa_flags;
 
        i->ss.m     = m;
        i->ss.info  = i;
@@ -2149,8 +2228,10 @@ mDNSlocal mStatus UpdateInterfaceList(mDNS *const m, mDNSs32 utc)
        struct ifaddrs *v6Loopback  = NULL;
        mDNSEthAddr PrimaryMAC      = zeroEthAddr;
        char defaultname[32];
+#ifndef NO_IPV6
        int InfoSocket              = socket(AF_INET6, SOCK_DGRAM, 0);
        if (InfoSocket < 3) LogMsg("UpdateInterfaceList: InfoSocket error %d errno %d (%s)", InfoSocket, errno, strerror(errno));
+#endif
        if (m->SleepState) ifa = NULL;
 
        while (ifa)
@@ -2206,6 +2287,7 @@ mDNSlocal mStatus UpdateInterfaceList(mDNS *const m, mDNSs32 utc)
                                else
                                        {
                                        int ifru_flags6 = 0;
+#ifndef NO_IPV6
                                        if (ifa->ifa_addr->sa_family == AF_INET6 && InfoSocket >= 0)
                                                {
                                                struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
@@ -2217,6 +2299,7 @@ mDNSlocal mStatus UpdateInterfaceList(mDNS *const m, mDNSs32 utc)
                                                        ifru_flags6 = ifr6.ifr_ifru.ifru_flags6;
                                                verbosedebugf("%s %.16a %04X %04X", ifa->ifa_name, &sin6->sin6_addr, ifa->ifa_flags, ifru_flags6);
                                                }
+#endif
                                        if (!(ifru_flags6 & (IN6_IFF_NOTREADY | IN6_IFF_DETACHED | IN6_IFF_DEPRECATED | IN6_IFF_TEMPORARY)))
                                                {
                                                if (ifa->ifa_flags & IFF_LOOPBACK)
@@ -2225,7 +2308,7 @@ mDNSlocal mStatus UpdateInterfaceList(mDNS *const m, mDNSs32 utc)
                                                else
                                                        {
                                                        NetworkInterfaceInfoOSX *i = AddInterfaceToList(m, ifa, utc);
-                                                       if (i && i->Multicast)
+                                                       if (i && MulticastInterface(i))
                                                                {
                                                                if (ifa->ifa_addr->sa_family == AF_INET) foundav4 = mDNStrue;
                                                                else                                     foundav6 = mDNStrue;
@@ -2253,14 +2336,17 @@ mDNSlocal mStatus UpdateInterfaceList(mDNS *const m, mDNSs32 utc)
        for (i = m->p->InterfaceList; i; i = i->next)
                if (i->Exists)
                        {
-                       mDNSBool txrx = i->Multicast && ((i->ifinfo.ip.type == mDNSAddrType_IPv4) || !FindRoutableIPv4(m, i->scope_id));
+                       mDNSBool txrx = MulticastInterface(i) && ((i->ifinfo.ip.type == mDNSAddrType_IPv4) || !FindRoutableIPv4(m, i->scope_id));
                        if (i->ifinfo.McastTxRx != txrx)
                                {
                                i->ifinfo.McastTxRx = txrx;
                                i->Exists = 2; // State change; need to deregister and reregister this interface
                                }
                        }
+
+#ifndef NO_IPV6
        if (InfoSocket >= 0) close(InfoSocket);
+#endif
 
        mDNS_snprintf(defaultname, sizeof(defaultname), "Macintosh-%02X%02X%02X%02X%02X%02X",
                PrimaryMAC.b[0], PrimaryMAC.b[1], PrimaryMAC.b[2], PrimaryMAC.b[3], PrimaryMAC.b[4], PrimaryMAC.b[5]);
@@ -2346,12 +2432,14 @@ mDNSlocal int SetupActiveInterfaces(mDNS *const m, mDNSs32 utc)
                                // If i->LastSeen == utc, then this is a brand-new interface, just created, or an interface that never went away.
                                // If i->LastSeen != utc, then this is an old interface, previously seen, that went away for (utc - i->LastSeen) seconds.
                                // If the interface is an old one that went away and came back in less than a minute, then we're in a flapping scenario.
-                               mDNSBool flapping = (utc - i->LastSeen > 0 && utc - i->LastSeen < 60);
-                               mDNS_RegisterInterface(m, n, flapping ? mDNSPlatformOneSecond * 5 : 0);
+                               i->Occulting = !(i->ifa_flags & IFF_LOOPBACK) && (utc - i->LastSeen > 0 && utc - i->LastSeen < 60);
+                               mDNS_RegisterInterface(m, n, i->Flashing && i->Occulting);
                                if (i->ifinfo.ip.type == mDNSAddrType_IPv4 &&  (i->ifinfo.ip.ip.v4.b[0] != 169 || i->ifinfo.ip.ip.v4.b[1] != 254)) count++;
-                               LogOperation("SetupActiveInterfaces:   Registered    %5s(%lu) %.6a InterfaceID %p %#a/%d%s%s",
+                               LogOperation("SetupActiveInterfaces:   Registered    %5s(%lu) %.6a InterfaceID %p %#a/%d%s%s%s",
                                        i->ifa_name, i->scope_id, &i->BSSID, primary, &n->ip, CountMaskBits(&n->mask),
-                                       flapping ? " (Flapping)" : "", n->InterfaceActive ? " (Primary)" : "");
+                                       i->Flashing        ? " (Flashing)"  : "",
+                                       i->Occulting       ? " (Occulting)" : "",
+                                       n->InterfaceActive ? " (Primary)"   : "");
                                }
        
                        if (!n->McastTxRx)
@@ -2365,12 +2453,14 @@ mDNSlocal int SetupActiveInterfaces(mDNS *const m, mDNSs32 utc)
                                        else          LogMsg("SetupActiveInterfaces:   v4 socket%2d %5s(%lu) %.6a InterfaceID %p %#a/%d FAILED",   primary->ss.sktv4, i->ifa_name, i->scope_id, &i->BSSID, n->InterfaceID, &n->ip, CountMaskBits(&n->mask));
                                        }
                        
+#ifndef NO_IPV6
                                if (i->sa_family == AF_INET6 && primary->ss.sktv6 == -1)
                                        {
                                        mStatus err = SetupSocket(m, &primary->ss, mDNStrue, &i->ifinfo.ip, AF_INET6);
                                        if (err == 0) debugf("SetupActiveInterfaces:   v6 socket%2d %5s(%lu) %.6a InterfaceID %p %#a/%d",          primary->ss.sktv6, i->ifa_name, i->scope_id, &i->BSSID, n->InterfaceID, &n->ip, CountMaskBits(&n->mask));
                                        else          LogMsg("SetupActiveInterfaces:   v6 socket%2d %5s(%lu) %.6a InterfaceID %p %#a/%d FAILED",   primary->ss.sktv6, i->ifa_name, i->scope_id, &i->BSSID, n->InterfaceID, &n->ip, CountMaskBits(&n->mask));
                                        }
+#endif
                                }
                        }
        return count;
@@ -2427,10 +2517,14 @@ mDNSlocal int ClearInactiveInterfaces(mDNS *const m, mDNSs32 utc)
                if (i->ifinfo.InterfaceID)
                        if (i->Exists == 0 || i->Exists == 2 || i->ifinfo.InterfaceID != (mDNSInterfaceID)primary)
                                {
-                               LogOperation("ClearInactiveInterfaces: Deregistering %5s(%lu) %.6a InterfaceID %p %#a/%d%s",
+                               i->Flashing = !(i->ifa_flags & IFF_LOOPBACK) && (utc - i->AppearanceTime < 60);
+                               LogOperation("ClearInactiveInterfaces: Deregistering %5s(%lu) %.6a InterfaceID %p %#a/%d%s%s%s",
                                        i->ifa_name, i->scope_id, &i->BSSID, i->ifinfo.InterfaceID,
-                                       &i->ifinfo.ip, CountMaskBits(&i->ifinfo.mask), i->ifinfo.InterfaceActive ? " (Primary)" : "");
-                               mDNS_DeregisterInterface(m, &i->ifinfo);
+                                       &i->ifinfo.ip, CountMaskBits(&i->ifinfo.mask),
+                                       i->Flashing               ? " (Flashing)"  : "",
+                                       i->Occulting              ? " (Occulting)" : "",
+                                       i->ifinfo.InterfaceActive ? " (Primary)"   : "");
+                               mDNS_DeregisterInterface(m, &i->ifinfo, i->Flashing && i->Occulting);
                                if (i->ifinfo.ip.type == mDNSAddrType_IPv4 && (i->ifinfo.ip.ip.v4.b[0] != 169 || i->ifinfo.ip.ip.v4.b[1] != 254)) count++;
                                i->ifinfo.InterfaceID = mDNSNULL;
                                // NOTE: If n->InterfaceID is set, that means we've called mDNS_RegisterInterface() for this interface,
@@ -2702,7 +2796,7 @@ mDNSlocal void MarkSearchListElem(const char *d)
        if (!MakeDomainNameFromDNSNameString(&domain, d))
                { LogMsg("ERROR: MarkSearchListElem - bad domain %##s", d); return; }
 
-       if (SameDomainName(&domain, &localdomain) || SameDomainName(&domain, &LocalReverseMapomain))
+       if (SameDomainName(&domain, &localdomain) || SameDomainName(&domain, &LocalReverseMapDomain))
                { debugf("MarkSearchListElem - ignoring local domain %##s", domain.c); return; } 
 
        // if domain is in list, mark as pre-existent (0)
@@ -2896,9 +2990,10 @@ mDNSlocal void SCPrefsDynDNSCallback(mDNS *const m, AuthRecord *const rr, mStatu
 
 mDNSlocal void SetSecretForDomain(mDNS *m, const domainname *domain)
        {
+#ifndef NO_SECURITYFRAMEWORK
        OSStatus err = 0;
        char dstring[MAX_ESCAPED_DOMAIN_NAME];
-       mDNSu32 secretlen;
+       UInt32 secretlen;
        void *secret = NULL;
        domainname *d, canon;
        int i, dlen;
@@ -2935,7 +3030,7 @@ mDNSlocal void SetSecretForDomain(mDNS *m, const domainname *domain)
                err = SecKeychainSearchCopyNext(searchRef, &itemRef);
                if (!err)
                        {
-               mDNSu32 tags[1];
+               UInt32 tags[1];
                        SecKeychainAttributeInfo attrInfo;
                        mDNSu32 i;
                        char keybuf[MAX_ESCAPED_DOMAIN_NAME+1];                 
@@ -2975,6 +3070,10 @@ mDNSlocal void SetSecretForDomain(mDNS *m, const domainname *domain)
        if (err && err != errSecItemNotFound) LogMsg("Error: SetSecretForDomain - %s failed with error code %d", failedfn, err);
        if (attrList) SecKeychainItemFreeAttributesAndData(attrList, secret);
        if (itemRef) CFRelease(itemRef);
+#else
+       (void)m; (void)domain;
+       LogMsg("Error: SetSecretForDomain - no keychain support");
+#endif /* NO_SECURITYFRAMEWORK */
        }
 
 mDNSlocal void SetSCPrefsBrowseDomainsFromCFArray(mDNS *m, CFArrayRef browseDomains, mDNSBool add)
@@ -3282,6 +3381,7 @@ exit:
        return(err);
        }
 
+#ifndef NO_IOPOWER
 mDNSlocal void PowerChanged(void *refcon, io_service_t service, natural_t messageType, void *messageArgument)
        {
        mDNS *const m = (mDNS *const)refcon;
@@ -3324,6 +3424,7 @@ mDNSlocal mStatus WatchForPowerChanges(mDNS *const m)
                }
        return(-1);
        }
+#endif /* NO_IOPOWER */
 
 CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(void);
 CF_EXPORT const CFStringRef _kCFSystemVersionProductNameKey;
@@ -3336,7 +3437,7 @@ CF_EXPORT const CFStringRef _kCFSystemVersionBuildVersionKey;
 mDNSexport int mDNSMacOSXSystemBuildNumber(char *HINFO_SWstring)
        {
        int major = 0, minor = 0;
-       char letter = 0, prodname[256]="Mac OS X", prodvers[256]="", buildver[256]="?";
+       char letter = 0, prodname[256]="<Unknown>", prodvers[256]="<Unknown>", buildver[256]="<Unknown>";
        CFDictionaryRef vers = _CFCopySystemVersionDictionary();
        if (vers)
                {
@@ -3349,6 +3450,7 @@ mDNSexport int mDNSMacOSXSystemBuildNumber(char *HINFO_SWstring)
                sscanf(buildver, "%d%c%d", &major, &letter, &minor);
                CFRelease(vers);
                }
+       if (!major) { major=8; LogMsg("Note: No Major Build Version number found; assuming 8"); }
        if (HINFO_SWstring) mDNS_snprintf(HINFO_SWstring, 256, "%s %s (%s), %s", prodname, prodvers, buildver, mDNSResponderVersionString);
        return(major);
        }
@@ -3540,6 +3642,7 @@ mDNSlocal mStatus mDNSPlatformInit_setup(mDNS *const m)
        if (mDNSMacOSXSystemBuildNumber(HINFO_SWstring) < 7) m->KnownBugs |= mDNS_KnownBug_PhantomInterfaces;
        if (mDNSPlatformInit_CanReceiveUnicast())            m->CanReceiveUnicastOn5353 = mDNStrue;
 
+#ifndef NO_HINFO
        mDNSu32 hlen = mDNSPlatformStrLen(HINFO_HWstring);
        mDNSu32 slen = mDNSPlatformStrLen(HINFO_SWstring);
        if (hlen + slen < 254)
@@ -3549,6 +3652,7 @@ mDNSlocal mStatus mDNSPlatformInit_setup(mDNS *const m)
                mDNSPlatformMemCopy(HINFO_HWstring, &m->HIHardware.c[1], hlen);
                mDNSPlatformMemCopy(HINFO_SWstring, &m->HISoftware.c[1], slen);
                }
+#endif /* NO_HINFO */
 
        m->p->unicastsockets.m     = m;
        m->p->unicastsockets.info  = NULL;
@@ -3557,16 +3661,20 @@ mDNSlocal mStatus mDNSPlatformInit_setup(mDNS *const m)
        m->p->unicastsockets.rlsv4 = m->p->unicastsockets.rlsv6 = NULL;
        
        err = SetupSocket(m, &m->p->unicastsockets, mDNSfalse, &zeroAddr, AF_INET);
+#ifndef NO_IPV6
        err = SetupSocket(m, &m->p->unicastsockets, mDNSfalse, &zeroAddr, AF_INET6);
+#endif
 
        struct sockaddr_in s4;
-       struct sockaddr_in6 s6;
        socklen_t n4 = sizeof(s4);
-       socklen_t n6 = sizeof(s6);
        if (getsockname(m->p->unicastsockets.sktv4, (struct sockaddr *)&s4, &n4) < 0) LogMsg("getsockname v4 error %d (%s)", errno, strerror(errno));
        else m->UnicastPort4.NotAnInteger = s4.sin_port;
+#ifndef NO_IPV6
+       struct sockaddr_in6 s6;
+       socklen_t n6 = sizeof(s6);
        if (getsockname(m->p->unicastsockets.sktv6, (struct sockaddr *)&s6, &n6) < 0) LogMsg("getsockname v6 error %d (%s)", errno, strerror(errno));
        else m->UnicastPort6.NotAnInteger = s6.sin6_port;
+#endif
 
        m->p->InterfaceList      = mDNSNULL;
        m->p->userhostlabel.c[0] = 0;
@@ -3579,8 +3687,10 @@ mDNSlocal mStatus mDNSPlatformInit_setup(mDNS *const m)
        err = WatchForNetworkChanges(m);
        if (err) return(err);
        
+#ifndef NO_IOPOWER
        err = WatchForPowerChanges(m);
        if (err) return err;
+#endif /* NO_IOPOWER */
 
        DynDNSRegDomain.c[0] = '\0';
        DynDNSConfigChanged(m);                                         // Get initial DNS configuration
@@ -3606,7 +3716,9 @@ mDNSexport void mDNSPlatformClose(mDNS *const m)
                CFRunLoopRemoveSource(CFRunLoopGetCurrent(), m->p->PowerRLS, kCFRunLoopDefaultMode);
                CFRunLoopSourceInvalidate(m->p->PowerRLS);
                CFRelease(m->p->PowerRLS);
+#ifndef NO_IOPOWER
                IODeregisterForSystemPower(&m->p->PowerNotifier);
+#endif /* NO_IOPOWER */
                m->p->PowerConnection = 0;
                m->p->PowerNotifier   = 0;
                m->p->PowerRLS        = NULL;
index 638f09501a564eae326cbf8ba7964b797798c19a..3e146083ad3589b0a0bfb21824cd7e4fb3406f26 100644 (file)
@@ -1,28 +1,34 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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: mDNSMacOSX.h,v $
+Revision 1.55.2.1  2006/08/29 06:48:07  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.55  2006/06/29 05:33:30  cheshire
+<rdar://problem/4607043> mDNSResponder conditional compilation options
+
+Revision 1.54  2006/03/19 03:27:49  cheshire
+<rdar://problem/4118624> Suppress "interface flapping" logic for loopback
+
+Revision 1.53  2006/03/19 02:00:09  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
 Revision 1.52  2006/01/05 21:41:49  cheshire
 <rdar://problem/4108164> Reword "mach_absolute_time went backwards" dialog
 
@@ -237,12 +243,18 @@ struct NetworkInterfaceInfoOSX_struct
        NetworkInterfaceInfoOSX *next;
        mDNSu32                  Exists;                        // 1 = currently exists in getifaddrs list; 0 = doesn't
                                                                                                // 2 = exists, but McastTxRx state changed
+       mDNSs32                  AppearanceTime;        // Time this interface appeared most recently in getifaddrs list
+                                                                                               // i.e. the first time an interface is seen, AppearanceTime is set.
+                                                                                               // If an interface goes away temporarily and then comes back then
+                                                                                               // AppearanceTime is updated to the time of the most recent appearance.
        mDNSs32                  LastSeen;                      // If Exists==0, last time this interface appeared in getifaddrs list
+       mDNSBool                 Flashing;                      // Set if interface appeared for less than 60 seconds and then vanished
+       mDNSBool                 Occulting;                     // Set if interface vanished for less than 60 seconds and then came back
        char                    *ifa_name;                      // Memory for this is allocated using malloc
        mDNSu32                  scope_id;                      // interface index / IPv6 scope ID
        mDNSEthAddr              BSSID;                         // BSSID of 802.11 base station, if applicable
        u_short                  sa_family;
-       mDNSBool                 Multicast;
+       unsigned int             ifa_flags;
        CFSocketSet              ss;
        };
 
index 7764e2a4626faaad8fc2fefe8fbde603df2d15d3..cf2d86f85929ccd9cd42f2d8663f6a304ebe00a7 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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@
  *
  * This file is not normally used.
  * It can be conditionally compiled in by defining RUN_ON_PUMA_WITHOUT_IFADDRS
@@ -31,6 +25,9 @@
     Change History (most recent first):
 
 $Log: mDNSMacOSXPuma.c,v $
+Revision 1.6  2006/08/14 23:24:40  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  2004/09/20 23:52:02  cheshire
 CFSocket{Puma}.c renamed to mDNSMacOSX{Puma}.c
 
index 6c923772b58c2618587bf59fc3e081f0805f9976..b6d74385cbcefe95db7404d587eabfcf647e184d 100644 (file)
@@ -22,8 +22,8 @@
                        buildSettings = {
                                FRAMEWORK_SEARCH_PATHS = "";
                                GCC_TREAT_WARNINGS_AS_ERRORS = YES;
-                               HEADER_SEARCH_PATHS = "../mDNSShared \"${APPLE_INTERNAL_DEVELOPER_DIR}/Headers\" \"${OBJROOT}/mDNSResponder.build\"";
-                               LIBRARY_SEARCH_PATHS = "\"${OBJROOT}/mDNSResponder.build\"";
+                               HEADER_SEARCH_PATHS = "../mDNSShared \"${APPLE_INTERNAL_DEVELOPER_DIR}/Headers\" \"${CONFIGURATION_TEMP_DIR}\"";
+                               LIBRARY_SEARCH_PATHS = "\"${CONFIGURATION_TEMP_DIR}\"";
                                MACOSX_DEPLOYMENT_TARGET = 10.2;
                                OPTIMIZATION_CFLAGS = "-O0";
                                OTHER_CFLAGS = "-no-cpp-precomp -mdynamic-no-pic -D__MACOSX__ -DmDNSResponderVersion=${MVERS} -D_LEGACY_NAT_TRAVERSAL_ -DMDNS_DEBUGMSGS=1";
                        );
                        buildSettings = {
                                MVERS = "\"mDNSResponder (Engineering Build)\"";
+                               CONFIGURATION_BUILD_DIR = "${BUILD_DIR}";
+                               CONFIGURATION_TEMP_DIR = "${BUILD_DIR}/mDNSResponder.build";
                        };
                        isa = PBXBuildStyle;
                        name = Development;
                        buildSettings = {
                                FRAMEWORK_SEARCH_PATHS = "";
                                GCC_TREAT_WARNINGS_AS_ERRORS = YES;
-                               HEADER_SEARCH_PATHS = "../mDNSShared \"${APPLE_INTERNAL_DEVELOPER_DIR}/Headers\" \"${OBJROOT}/mDNSResponder.build\"";
+                               HEADER_SEARCH_PATHS = "../mDNSShared \"${APPLE_INTERNAL_DEVELOPER_DIR}/Headers\" \"${CONFIGURATION_TEMP_DIR}\"";
                                INSTALL_PATH = /usr/sbin;
-                               LIBRARY_SEARCH_PATHS = "\"${OBJROOT}/mDNSResponder.build\"";
+                               LIBRARY_SEARCH_PATHS = "\"${CONFIGURATION_TEMP_DIR}\"";
                                MACOSX_DEPLOYMENT_TARGET = 10.2;
                                OTHER_CFLAGS = "-no-cpp-precomp -mdynamic-no-pic -D__MACOSX__ -DmDNSResponderVersion=${MVERS} -D_LEGACY_NAT_TRAVERSAL_";
                                OTHER_LDFLAGS = "-ldnsinfo";
                                DB2CC44D0662DD1100335AB3,
                                DB2CC44E0662DD1100335AB3,
                                DB2CC44F0662DD1100335AB3,
+                               FF2C5FB00A48B8680066DA11,
+                               FF2C5FB20A48B86E0066DA11,
                        );
                        isa = PBXGroup;
                        name = "Java Support";
                                DB2CC45F0662DE4C00335AB3,
                                DB2CC4600662DE4C00335AB3,
                                DB2CC4610662DE4D00335AB3,
+                               FF2C5FB10A48B8680066DA11,
+                               FF2C5FB30A48B86E0066DA11,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                JAVA_ARCHIVE_COMPRESSION = YES;
                                JAVA_ARCHIVE_TYPE = JAR;
                                JAVA_COMPILER_DEBUGGING_SYMBOLS = NO;
-                               JAVA_COMPILER_TARGET_VM_VERSION = 1.2;
+                               JAVA_COMPILER_SOURCE_VERSION = 1.4;
+                               JAVA_COMPILER_TARGET_VM_VERSION = 1.4;
                                JAVA_SOURCE_SUBDIR = .;
                                LIBRARY_STYLE = STATIC;
                                MACOSX_DEPLOYMENT_TARGET = 10.2;
                                PURE_JAVA = YES;
                                REZ_EXECUTABLE = YES;
                                SECTORDER_FLAGS = "";
+                               STRIPFLAGS = "-S";
                                WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
                        };
                        comments = "Multiplatform .jar file that implements Java interface to DNS-SD";
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "if [ -d ${OBJROOT}/mDNSResponder.build/${CONFIGURATION} ]; then BUILD_DIR=${OBJROOT}/mDNSResponder.build/${CONFIGURATION}; else BUILD_DIR=${OBJROOT}/mDNSResponder.build; fi\njavah -force -classpath ${BUILD_DIR}/dns_sd.jar.build/JavaClasses/ -o ${BUILD_DIR}/dns_sd.jar.build/DNSSD.java.h com.apple.dnssd.AppleDNSSD com.apple.dnssd.AppleBrowser com.apple.dnssd.AppleResolver com.apple.dnssd.AppleRegistration com.apple.dnssd.AppleQuery com.apple.dnssd.AppleDomainEnum com.apple.dnssd.AppleService";
+                       shellScript = "javah -force -J-Xbootclasspath/p:${CONFIGURATION_TEMP_DIR}/dns_sd.jar.build/JavaClasses -o ${CONFIGURATION_TEMP_DIR}/dns_sd.jar.build/DNSSD.java.h com.apple.dnssd.AppleDNSSD com.apple.dnssd.AppleBrowser com.apple.dnssd.AppleResolver com.apple.dnssd.AppleRegistration com.apple.dnssd.AppleQuery com.apple.dnssd.AppleDomainEnum com.apple.dnssd.AppleService";
                };
                DB2CC4560662DE4500335AB3 = {
                        fileRef = DB2CC4430662DD1100335AB3;
                                DB2CC4650662DF5C00335AB3,
                        );
                        buildSettings = {
-                               DEBUGGING_SYMBOLS = NO;
                                DYLIB_COMPATIBILITY_VERSION = 1;
                                DYLIB_CURRENT_VERSION = 1;
-                               HEADER_SEARCH_PATHS = "../mDNSShared \"${SYSTEM_LIBRARY_DIR}/Frameworks/JavaVM.framework/Versions/A/Headers\" \"${SYSTEM_LIBRARY_DIR}/Frameworks/JavaVM.framework/Versions/1.3.1/Headers\" \"${OBJROOT}/mDNSResponder.build/dns_sd.jar.build\" \"${OBJROOT}/mDNSResponder.build/${CONFIGURATION}/dns_sd.jar.build\"";
+                               HEADER_SEARCH_PATHS = "../mDNSShared \"${SYSTEM_LIBRARY_DIR}/Frameworks/JavaVM.framework/Versions/A/Headers\" \"${SYSTEM_LIBRARY_DIR}/Frameworks/JavaVM.framework/Versions/1.3.1/Headers\" \"${CONFIGURATION_TEMP_DIR}/dns_sd.jar.build\"";
                                INSTALL_PATH = /usr/lib/java;
                                LIBRARY_STYLE = DYNAMIC;
                                MACOSX_DEPLOYMENT_TARGET = 10.2;
                                PRODUCT_NAME = libjdns_sd.jnilib;
                                REZ_EXECUTABLE = YES;
                                SECTORDER_FLAGS = "";
+                               STRIPFLAGS = "-S";
                                WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
                        };
                        comments = "Platform-specific JNI library that bridges dns_sd.jar to <dns_sd.h>.";
                                PREBINDING = NO;
                                PRODUCT_NAME = Bonjour;
                                SECTORDER_FLAGS = "";
+                               STRIPFLAGS = "-S";
                                WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
                                WRAPPER_EXTENSION = prefPane;
                        };
                        isa = PBXTargetDependency;
                        target = FF2609E107B440DD00CE10E5;
                };
+               FF2C5FB00A48B8680066DA11 = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       name = DNSSDRecordRegistrar.java;
+                       path = ../mDNSShared/Java/DNSSDRecordRegistrar.java;
+                       refType = 2;
+               };
+               FF2C5FB10A48B8680066DA11 = {
+                       fileRef = FF2C5FB00A48B8680066DA11;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               FF2C5FB20A48B86E0066DA11 = {
+                       fileEncoding = 4;
+                       isa = PBXFileReference;
+                       name = RegisterRecordListener.java;
+                       path = ../mDNSShared/Java/RegisterRecordListener.java;
+                       refType = 2;
+               };
+               FF2C5FB30A48B86E0066DA11 = {
+                       fileRef = FF2C5FB20A48B86E0066DA11;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
                FF354EB108516C63007C00E1 = {
                        fileEncoding = 4;
                        isa = PBXExecutableFileReference;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "if [ -e /usr/local/include/dnsinfo.h ]\nthen\nrm -f \"${OBJROOT}/mDNSResponder.build/dnsinfo.h\"\nrm -f \"${OBJROOT}/mDNSResponder.build/libdnsinfo.a\"\nelse\necho \"#define MDNS_NO_DNSINFO 1\" > ${OBJROOT}/mDNSResponder.build/dnsinfo.h\ntouch ${OBJROOT}/mDNSResponder.build/empty.c\ncc ${OBJROOT}/mDNSResponder.build/empty.c -c -o \"${OBJROOT}/mDNSResponder.build/libdnsinfo.a\"\nrm -f ${OBJROOT}/mDNSResponder.build/empty.c\nfi";
+                       shellScript = "if [ -e /usr/local/include/dnsinfo.h ]\nthen\nrm -f \"${CONFIGURATION_TEMP_DIR}/dnsinfo.h\"\nrm -f \"${CONFIGURATION_TEMP_DIR}/libdnsinfo.a\"\nelse\necho \"#define MDNS_NO_DNSINFO 1\" > ${CONFIGURATION_TEMP_DIR}/dnsinfo.h\ntouch ${CONFIGURATION_TEMP_DIR}/empty.c\ncc ${CONFIGURATION_TEMP_DIR}/empty.c -c -o \"${CONFIGURATION_TEMP_DIR}/libdnsinfo.a\"\nrm -f ${CONFIGURATION_TEMP_DIR}/empty.c\nfi";
                };
                FF485D5105632E0000130380 = {
                        fileEncoding = 4;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "rm -f ${BUILD_DIR}/${CONFIGURATION}/dns_sd";
+                       shellScript = "rm -f ${CONFIGURATION_BUILD_DIR}/dns_sd";
                };
                FFD41DDF06641BBB00F0C438 = {
                        isa = PBXTargetDependency;
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = "if [ -e /usr/local/include/dnsinfo.h ]\nthen\nrm -f \"${OBJROOT}/mDNSResponder.build/dnsinfo.h\"\nrm -f \"${OBJROOT}/mDNSResponder.build/libdnsinfo.a\"\nelse\necho \"#define MDNS_NO_DNSINFO 1\" > ${OBJROOT}/mDNSResponder.build/dnsinfo.h\ntouch ${OBJROOT}/mDNSResponder.build/empty.c\ncc ${OBJROOT}/mDNSResponder.build/empty.c -c -o \"${OBJROOT}/mDNSResponder.build/libdnsinfo.a\"\nrm -f ${OBJROOT}/mDNSResponder.build/empty.c\nfi";
+                       shellScript = "if [ -e /usr/local/include/dnsinfo.h ]\nthen\nrm -f \"${CONFIGURATION_TEMP_DIR}/dnsinfo.h\"\nrm -f \"${CONFIGURATION_TEMP_DIR}/libdnsinfo.a\"\nelse\necho \"#define MDNS_NO_DNSINFO 1\" > ${CONFIGURATION_TEMP_DIR}/dnsinfo.h\ntouch ${CONFIGURATION_TEMP_DIR}/empty.c\ncc ${CONFIGURATION_TEMP_DIR}/empty.c -c -o \"${CONFIGURATION_TEMP_DIR}/libdnsinfo.a\"\nrm -f ${CONFIGURATION_TEMP_DIR}/empty.c\nfi";
                };
                FFFB0DA407B43BED00B88D48 = {
                        children = (
                                FFFB0DA807B43C9100B88D48,
                        );
                        buildSettings = {
+                               INSTALL_PATH = "/Library/Application Support/Bonjour";
                                MACOSX_DEPLOYMENT_TARGET = 10.2;
                                OTHER_CFLAGS = "";
                                OTHER_LDFLAGS = "";
                                PRODUCT_NAME = ddnswriteconfig;
                                REZ_EXECUTABLE = YES;
                                SECTORDER_FLAGS = "";
+                               STRIPFLAGS = "-S";
                                WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
                        };
                        dependencies = (
                        );
                        isa = PBXToolTarget;
                        name = ddnswriteconfig;
-                       productInstallPath = /usr/local/bin;
+                       productInstallPath = "/Library/Application Support/Bonjour";
                        productName = ddnswriteconfig;
                        productReference = FFFB0DAA07B43C9100B88D48;
                };
index 6aafe37e7d3a6c3ebb93528959bc568bf0660c23..9c23772e184016d8b9ff71e08c821d3fa24a3652 100755 (executable)
@@ -2,28 +2,27 @@
  *
  * 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: Client.c,v $
+Revision 1.18  2006/08/14 23:24:46  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.17  2006/06/12 18:22:42  cheshire
+<rdar://problem/4580067> mDNSResponder building warnings under Red Hat 64-bit (LP64) Linux
+
 Revision 1.16  2005/02/04 01:00:53  cheshire
 Add '-d' command-line option to specify domain to browse
 
@@ -281,7 +280,7 @@ int main(int argc, char **argv)
         result = 2;
     }
     if ( (result != 0) || (gMDNSPlatformPosixVerboseLevel > 0) ) {
-        fprintf(stderr, "%s: Finished with status %ld, result %d\n", gProgramName, status, result);
+        fprintf(stderr, "%s: Finished with status %d, result %d\n", gProgramName, (int)status, result);
     }
 
     return 0;
index 17843afdda3e18e277760297ab4169cfc23f20e4..15bb86ad793187e5d8f4a75a5bfe484ff6b05754 100644 (file)
@@ -2,28 +2,27 @@
  *
  * 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: ExampleClientApp.c,v $
+Revision 1.14  2006/08/14 23:24:46  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.13  2006/02/23 23:38:43  cheshire
+<rdar://problem/4427969> On FreeBSD 4 "arpa/inet.h" requires "netinet/in.h" be included first
+
 Revision 1.12  2004/11/30 22:37:00  cheshire
 Update copyright dates and add "Mode: C; tab-width: 4" headers
 
@@ -55,8 +54,8 @@ Add log header
 #include <string.h>                    // For strlen() etc.
 #include <unistd.h>                    // For select()
 #include <errno.h>                     // For errno, EINTR
-#include <arpa/inet.h>         // For inet_addr()
 #include <netinet/in.h>                // For INADDR_NONE
+#include <arpa/inet.h>         // For inet_addr()
 #include <netdb.h>                     // For gethostbyname()
 #include <signal.h>                    // For SIGINT, etc.
 
index fa9f0fccd14025713eeedda49d58a39ee74af230..3438260c5ec5aeb3cbe609e83989b4bd0306fd64 100644 (file)
@@ -2,28 +2,24 @@
  *
  * Copyright (c) 2002-2003 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: ExampleClientApp.h,v $
+Revision 1.7  2006/08/14 23:24:46  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.6  2004/11/30 22:37:00  cheshire
 Update copyright dates and add "Mode: C; tab-width: 4" headers
 
index c1724f2574120b5df85df606df6acc15ecc6f07c..a9aa3b1b532f623a237858a3db3fec8a5de4a231 100644 (file)
@@ -2,24 +2,17 @@
  *
  * 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@
  *
  * Formatting notes:
  * This code follows the "Whitesmiths style" C indentation rules. Plenty of discussion
     Change History (most recent first):
 
 $Log: Identify.c,v $
+Revision 1.36  2006/08/14 23:24:46  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.35  2006/06/12 18:22:42  cheshire
+<rdar://problem/4580067> mDNSResponder building warnings under Red Hat 64-bit (LP64) Linux
+
 Revision 1.34  2004/12/16 20:17:11  cheshire
 <rdar://problem/3324626> Cache memory management improvements
 
@@ -400,7 +399,7 @@ mDNSexport int main(int argc, char **argv)
        gRRCache, RR_CACHE_SIZE,
        mDNS_Init_DontAdvertiseLocalAddresses,
        mDNS_Init_NoInitCallback, mDNS_Init_NoInitCallbackContext);
-       if (status) { fprintf(stderr, "Daemon start: mDNS_Init failed %ld\n", status); return(status); }
+       if (status) { fprintf(stderr, "Daemon start: mDNS_Init failed %d\n", (int)status); return(status); }
 
        signal(SIGINT, HandleSIG);      // SIGINT is what you get for a Ctrl-C
        signal(SIGTERM, HandleSIG);
index 7176e0ed37e6714e0ea4f6c465ac982dfb5efa3e..57824f4e335cd90c5a772aace5e0e75213dc203a 100755 (executable)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
+# IMPORTANT NOTE: This is a Makefile for *GNU make*
+# On some systems, a different program may be the default "make" command.
+# If "make os=xxx" gives lots of errors like "Missing dependency operator",
+# then try typing "gmake os=xxx" instead.
+#
 # $Log: Makefile,v $
+# Revision 1.71  2006/06/20 23:07:04  rpantos
+# <rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
+#
+# Revision 1.70  2006/05/03 23:35:10  cheshire
+# Add missing dependency: NetMonitor.c textually imports mDNS.c
+#
+# Revision 1.69  2006/02/26 23:18:50  cheshire
+# <rdar://problem/4427969> FreeBSD 4 requires "-pthread" option to compile threaded code
+#
+# Revision 1.68  2006/02/26 01:36:54  cheshire
+# Rename the poorly named "LIBFLAGS" as "LINKOPTS"
+#
+# Revision 1.67  2006/02/25 23:14:29  cheshire
+# Add comment suggesting using "gmake" command
+#
 # Revision 1.66  2006/01/06 01:06:17  cheshire
 # <rdar://problem/3978979> Compile library and client programs in one pass
 #
@@ -253,7 +273,9 @@ CP = cp
 RM = rm
 LN = ln -s -f
 CFLAGS_COMMON = -I. -I$(COREDIR) -I$(SHAREDDIR) -W -Wall -DPID_FILE=\"/var/run/mdnsd.pid\" -DMDNS_UDS_SERVERPATH=\"/var/run/mdnsd\"
-LIBFLAGS =
+CFLAGS_PTHREAD =
+LINKOPTS =
+LINKOPTS_PTHREAD = -lpthread
 LDSUFFIX = so
 JAVACFLAGS_OS = -fPIC -shared -ldns_sd
 
@@ -280,7 +302,7 @@ CFLAGS_OS = -DNOT_HAVE_DAEMON -DNOT_HAVE_SA_LEN -DNOT_HAVE_SOCKLEN_T -DNOT_HAVE_
         -DLOG_PERROR=0 -D_XPG4_2 -D__EXTENSIONS__ -DHAVE_BROKEN_RECVIF_NAME
 CC = gcc
 LD = gcc -shared
-LIBFLAGS = -lsocket -lnsl -lresolv
+LINKOPTS = -lsocket -lnsl -lresolv
 JAVACFLAGS_OS += -I$(JDK)/include/solaris
 ifneq ($(DEBUG),1)
 STRIP = strip
@@ -306,6 +328,14 @@ LOCALBASE?=/usr/local
 INSTBASE=$(LOCALBASE)
 STARTUPSCRIPTNAME=mdns.sh
 CFLAGS_OS =
+# FreeBSD 4 requires threaded code to be compiled and linked using the "-pthread" option,
+# and requires that the "-lpthread" link option NOT be used
+# This appies only to FreeBSD -- "man cc" on FreeBSD says:
+#   FreeBSD SPECIFIC OPTIONS
+#     -pthread
+#       Link a user-threaded process against libc_r instead of libc.
+CFLAGS_PTHREAD   = -pthread -D_THREAD_SAFE
+LINKOPTS_PTHREAD = -pthread
 JAVACFLAGS_OS += -I$(JDK)/include/freebsd
 LDCONFIG = ldconfig
 else
@@ -318,7 +348,7 @@ else
 ifeq ($(os),jaguar)
 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -DNOT_HAVE_SOCKLEN_T
 LD = libtool -dynamic
-LIBFLAGS = -lSystem
+LINKOPTS = -lSystem
 LDSUFFIX = dylib
 JDK = /System/Library/Frameworks/JavaVM.framework/Home
 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM 
@@ -327,7 +357,7 @@ else
 ifeq ($(os),panther)
 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror
 LD = libtool -dynamic
-LIBFLAGS = -lSystem
+LINKOPTS = -lSystem
 LDSUFFIX = dylib
 JDK = /System/Library/Frameworks/JavaVM.framework/Home
 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM 
@@ -337,7 +367,7 @@ ifeq ($(os),tiger)
 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Werror -Wdeclaration-after-statement #-Wunreachable-code
 CC = @gcc-4.0
 LD = $(CC) -dynamiclib
-LIBFLAGS = -lSystem
+LINKOPTS = -lSystem
 LDSUFFIX = dylib
 JDK = /System/Library/Frameworks/JavaVM.framework/Home
 JAVACFLAGS_OS = -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -framework JavaVM 
@@ -433,7 +463,7 @@ Daemon: setup $(BUILDDIR)/mdnsd
        @echo "Responder daemon done"
 
 $(BUILDDIR)/mdnsd: $(DAEMONOBJS)
-       $(CC) -o $@ $+ $(CFLAGS) $(LIBFLAGS)
+       $(CC) -o $@ $+ $(LINKOPTS)
        @$(STRIP) $@
 
 # libdns_sd target builds the client library
@@ -443,7 +473,7 @@ libdns_sd: setup $(BUILDDIR)/libdns_sd.$(LDSUFFIX)
 CLIENTLIBOBJS = $(OBJDIR)/dnssd_clientlib.c.so.o $(OBJDIR)/dnssd_clientstub.c.so.o $(OBJDIR)/dnssd_ipc.c.so.o
 
 $(BUILDDIR)/libdns_sd.$(LDSUFFIX): $(CLIENTLIBOBJS)
-       @$(LD) $(LIBFLAGS) -o $@ $+
+       @$(LD) $(LINKOPTS) -o $@ $+
        @$(STRIP) $@
 
 Clients: setup libdns_sd ../Clients/build/dns-sd
@@ -457,7 +487,7 @@ nss_mdns: setup $(BUILDDIR)/$(NSSLIBFILE)
        @echo "Name Service Switch module done"
 
 $(BUILDDIR)/$(NSSLIBFILE): $(CLIENTLIBOBJS) $(OBJDIR)/nss_mdns.c.so.o
-       @$(LD) $(LIBFLAGS) -o $@ $+
+       @$(LD) $(LINKOPTS) -o $@ $+
        @$(STRIP) $@
 
 #############################################################################
@@ -572,6 +602,8 @@ JARCONTENTS =       $(OBJDIR)/com/apple/dnssd/DNSSDService.class \
                                $(OBJDIR)/com/apple/dnssd/RegisterListener.class \
                                $(OBJDIR)/com/apple/dnssd/QueryListener.class \
                                $(OBJDIR)/com/apple/dnssd/DomainListener.class \
+                               $(OBJDIR)/com/apple/dnssd/RegisterRecordListener.class \
+                               $(OBJDIR)/com/apple/dnssd/DNSSDRecordRegistrar.class \
                                $(OBJDIR)/com/apple/dnssd/DNSSD.class
 
 $(BUILDDIR)/dns_sd.jar: $(JARCONTENTS) setup
@@ -626,24 +658,26 @@ dnsextd: setup $(BUILDDIR)/dnsextd
        @echo "dnsextd done"
 
 $(BUILDDIR)/mDNSClientPosix:         $(APPOBJ)     $(OBJDIR)/Client.c.o
-       $(CC) $+ -o $@ $(LIBFLAGS)
+       $(CC) $+ -o $@ $(LINKOPTS)
 
 $(BUILDDIR)/mDNSResponderPosix:      $(COMMONOBJ)  $(OBJDIR)/Responder.c.o
-       $(CC) $+ -o $@ $(LIBFLAGS)
+       $(CC) $+ -o $@ $(LINKOPTS)
 
 $(BUILDDIR)/mDNSProxyResponderPosix: $(COMMONOBJ)  $(OBJDIR)/ProxyResponder.c.o
-       $(CC) $+ -o $@ $(LIBFLAGS)
+       $(CC) $+ -o $@ $(LINKOPTS)
 
 $(BUILDDIR)/mDNSIdentify:            $(SPECIALOBJ) $(OBJDIR)/Identify.c.o
-       $(CC) $+ -o $@ $(LIBFLAGS)
+       $(CC) $+ -o $@ $(LINKOPTS)
 
 $(OBJDIR)/Identify.c.o:              $(COREDIR)/mDNS.c # Note: Identify.c textually imports mDNS.c
 
 $(BUILDDIR)/mDNSNetMonitor:          $(SPECIALOBJ) $(OBJDIR)/NetMonitor.c.o
-       $(CC) $+ -o $@ $(LIBFLAGS)
+       $(CC) $+ -o $@ $(LINKOPTS)
+
+$(OBJDIR)/NetMonitor.c.o:            $(COREDIR)/mDNS.c # Note: NetMonitor.c textually imports mDNS.c
 
 $(BUILDDIR)/dnsextd:                 $(SPECIALOBJ) $(OBJDIR)/dnsextd.c.threadsafe.o
-       $(CC) $+ -o $@ $(LIBFLAGS) -lpthread
+       $(CC) $+ -o $@ $(LINKOPTS) $(LINKOPTS_PTHREAD)
 
 #############################################################################
 
@@ -658,7 +692,7 @@ $(OBJDIR)/%.c.o:    $(SHAREDDIR)/%.c
        $(CC) $(CFLAGS) -c -o $@ $<
 
 $(OBJDIR)/%.c.threadsafe.o:    %.c
-       $(CC) $(CFLAGS) -D_REENTRANT -c -o $@ $<
+       $(CC) $(CFLAGS) $(CFLAGS_PTHREAD) -D_REENTRANT -c -o $@ $<
 
 $(OBJDIR)/%.c.so.o:    %.c
        $(CC) $(CFLAGS) -c -fPIC -o $@ $<
index 6c53cc8b420e74fe7fb09a73c4f4346b42f63516..da3e63ea32a0e54474542f8802a6682169d19616 100644 (file)
@@ -2,24 +2,17 @@
  *
  * 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@
  *
  * Formatting notes:
  * This code follows the "Whitesmiths style" C indentation rules. Plenty of discussion
     Change History (most recent first):
 
 $Log: NetMonitor.c,v $
+Revision 1.82  2006/08/14 23:24:46  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.81  2006/07/06 00:01:44  cheshire
+<rdar://problem/4472014> Add Private DNS client functionality to mDNSResponder
+Update mDNSSendDNSMessage() to use uDNS_TCPSocket type instead of "int"
+
+Revision 1.80  2006/06/12 18:22:42  cheshire
+<rdar://problem/4580067> mDNSResponder building warnings under Red Hat 64-bit (LP64) Linux
+
+Revision 1.79  2006/04/26 20:48:33  cheshire
+Make final count of unique source addresses show IPv4 and IPv6 counts separately
+
+Revision 1.78  2006/04/25 00:42:24  cheshire
+Add ability to specify a single interface index to capture on,
+e.g. typically "-i 4" for Ethernet and "-i 5" for AirPort
+
+Revision 1.77  2006/03/02 21:50:45  cheshire
+Removed strange backslash at the end of a line
+
+Revision 1.76  2006/02/23 23:38:43  cheshire
+<rdar://problem/4427969> On FreeBSD 4 "arpa/inet.h" requires "netinet/in.h" be included first
+
 Revision 1.75  2006/01/05 22:33:58  cheshire
 Use IFNAMSIZ (more portable) instead of IF_NAMESIZE
 
@@ -297,9 +313,9 @@ Added NetMonitor.c
 #include <signal.h>                    // For SIGINT, SIGTERM
 #include <netdb.h>                     // For gethostbyname()
 #include <sys/socket.h>                // For AF_INET, AF_INET6, etc.
-#include <arpa/inet.h>         // For inet_addr()
 #include <net/if.h>                    // For IF_NAMESIZE
 #include <netinet/in.h>                // For INADDR_NONE
+#include <arpa/inet.h>         // For inet_addr()
 
 #include "mDNSPosix.h"      // Defines the specific types needed to run mDNS on this platform
 #include "ExampleClientApp.h"
@@ -363,7 +379,7 @@ static mDNS mDNSStorage;                                            // mDNS core uses this to store its globals
 static mDNS_PlatformSupport PlatformStorage;   // Stores this platform's globals
 
 struct timeval tv_start, tv_end, tv_interval;
-
+static int FilterInterface = 0;
 static FilterList *Filters;
 #define ExactlyOneFilter (Filters && !Filters->next)
 
@@ -557,7 +573,7 @@ mDNSlocal void SendUnicastQuery(mDNS *const m, HostEntry *entry, domainname *nam
                m->ExpectUnicastResponse = m->timenow;
                }
 
-       mDNSSendDNSMessage(&mDNSStorage, &query, qptr, InterfaceID, target, MulticastDNSPort, -1, mDNSNULL);
+       mDNSSendDNSMessage(&mDNSStorage, &query, qptr, InterfaceID, target, MulticastDNSPort, mDNSNULL, mDNSNULL);
        }
 
 mDNSlocal void AnalyseHost(mDNS *const m, HostEntry *entry, const mDNSInterfaceID InterfaceID)
@@ -694,7 +710,7 @@ mDNSlocal void printstats(int max)
                }
        }
 
-mDNSlocal const mDNSu8 *FindUpdate(mDNS *const m, const DNSMessage *const query, const mDNSu8 *ptr, const mDNSu8 *const end,\
+mDNSlocal const mDNSu8 *FindUpdate(mDNS *const m, const DNSMessage *const query, const mDNSu8 *ptr, const mDNSu8 *const end,
        DNSQuestion *q, LargeCacheRecord *pkt)
        {
        int i;
@@ -987,6 +1003,7 @@ mDNSexport void mDNSCoreReceive(mDNS *const m, DNSMessage *const msg, const mDNS
        const mDNSu8 StdR = kDNSFlag0_QR_Response | kDNSFlag0_OP_StdQuery;
        const mDNSu8 QR_OP = (mDNSu8)(msg->h.flags.b[0] & kDNSFlag0_QROP_Mask);
        mDNSu8 *ptr = (mDNSu8 *)&msg->h.numQuestions;
+       int goodinterface = (FilterInterface == 0);
 
        (void)dstaddr;  // Unused
        (void)dstport;  // Unused
@@ -999,7 +1016,8 @@ mDNSexport void mDNSCoreReceive(mDNS *const m, DNSMessage *const msg, const mDNS
 
        // For now we're only interested in monitoring IPv4 traffic.
        // All IPv6 packets should just be duplicates of the v4 packets.
-       if (AddressMatchesFilterList(srcaddr))
+       if (!goodinterface) goodinterface = (FilterInterface == (int)mDNSPlatformInterfaceIndexfromInterfaceID(m, InterfaceID));
+       if (goodinterface && AddressMatchesFilterList(srcaddr))
                {
                mDNS_Lock(m);
                if (!mDNSAddrIsDNSMulticast(dstaddr))
@@ -1075,7 +1093,14 @@ mDNSlocal mStatus mDNSNetMonitor(void)
        localtime_r((time_t*)&tv_end.tv_sec, &tm);
        mprintf("End          %3d:%02d:%02d.%06d\n", tm.tm_hour, tm.tm_min, tm.tm_sec, tv_end.tv_usec);
        mprintf("Captured for %3d:%02d:%02d.%06d\n", h, m, s, tv_interval.tv_usec);
-       if (!Filters) mprintf("Unique source addresses seen on network: %ld\n", IPv4HostList.num + IPv6HostList.num);
+       if (!Filters)
+               {
+               mprintf("Unique source addresses seen on network:");
+               if (IPv4HostList.num) mprintf(" %ld (IPv4)", IPv4HostList.num);
+               if (IPv6HostList.num) mprintf(" %ld (IPv6)", IPv6HostList.num);
+               if (!IPv4HostList.num && !IPv6HostList.num) mprintf(" None");
+               mprintf("\n");
+               }
        mprintf("\n");
        mprintf("Modern Query        Packets:      %7d   (avg%5d/min)\n", NumPktQ,        NumPktQ        * mul / div);
        mprintf("Legacy Query        Packets:      %7d   (avg%5d/min)\n", NumPktL,        NumPktL        * mul / div);
@@ -1111,34 +1136,43 @@ mDNSexport int main(int argc, char **argv)
 
        for (i=1; i<argc; i++)
                {
-               struct in_addr s4;
-               struct in6_addr s6;
-               FilterList *f;
-               mDNSAddr a;
-               a.type = mDNSAddrType_IPv4;
-
-               if (inet_pton(AF_INET, argv[i], &s4) == 1)
-                       a.ip.v4.NotAnInteger = s4.s_addr;
-               else if (inet_pton(AF_INET6, argv[i], &s6) == 1)
+               if (i+1 < argc && !strcmp(argv[i], "-i") && atoi(argv[i+1]))
                        {
-                       a.type = mDNSAddrType_IPv6;
-                       bcopy(&s6, &a.ip.v6, sizeof(a.ip.v6));
+                       FilterInterface = atoi(argv[i+1]);
+                       i += 2;
+                       printf("Monitoring interface %d\n", FilterInterface);
                        }
                else
                        {
-                       struct hostent *h = gethostbyname(argv[i]);
-                       if (h) a.ip.v4.NotAnInteger = *(long*)h->h_addr;
-                       else goto usage;
+                       struct in_addr s4;
+                       struct in6_addr s6;
+                       FilterList *f;
+                       mDNSAddr a;
+                       a.type = mDNSAddrType_IPv4;
+       
+                       if (inet_pton(AF_INET, argv[i], &s4) == 1)
+                               a.ip.v4.NotAnInteger = s4.s_addr;
+                       else if (inet_pton(AF_INET6, argv[i], &s6) == 1)
+                               {
+                               a.type = mDNSAddrType_IPv6;
+                               bcopy(&s6, &a.ip.v6, sizeof(a.ip.v6));
+                               }
+                       else
+                               {
+                               struct hostent *h = gethostbyname(argv[i]);
+                               if (h) a.ip.v4.NotAnInteger = *(long*)h->h_addr;
+                               else goto usage;
+                               }
+                       
+                       f = malloc(sizeof(*f));
+                       f->FilterAddr = a;
+                       f->next = Filters;
+                       Filters = f;
                        }
-               
-               f = malloc(sizeof(*f));
-               f->FilterAddr = a;
-               f->next = Filters;
-               Filters = f;
                }
 
        status = mDNSNetMonitor();
-       if (status) { fprintf(stderr, "%s: mDNSNetMonitor failed %ld\n", progname, status); return(status); }
+       if (status) { fprintf(stderr, "%s: mDNSNetMonitor failed %d\n", progname, (int)status); return(status); }
        return(0);
 
 usage:
index 5963f20b1bb39dd454621d71287922f6b9d95791..4bd94640787222ab9644b4857cd8cef123cac26b 100644 (file)
@@ -2,24 +2,17 @@
  *
  * Copyright (c) 2003-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@
 
        File:           daemon.c
 
@@ -28,6 +21,9 @@
        Change History (most recent first):
 
 $Log: PosixDaemon.c,v $
+Revision 1.29.2.1  2006/08/29 06:24:34  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.29  2005/08/04 03:37:45  mkrochma
 Temporary workaround to fix posix after mDNS_SetPrimaryInterfaceInfo changed
 
index 293ee0a293a0bc10fc5f839c170b0cbedc0cf534..0daaca75a0ee8a8323e16e947475abd4b6d71523 100644 (file)
@@ -2,28 +2,30 @@
  *
  * 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: ProxyResponder.c,v $
+Revision 1.39  2006/08/14 23:24:46  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.38  2006/06/12 18:22:42  cheshire
+<rdar://problem/4580067> mDNSResponder building warnings under Red Hat 64-bit (LP64) Linux
+
+Revision 1.37  2006/02/23 23:38:43  cheshire
+<rdar://problem/4427969> On FreeBSD 4 "arpa/inet.h" requires "netinet/in.h" be included first
+
 Revision 1.36  2005/08/04 03:12:47  mkrochma
 <rdar://problem/4199236> Register reverse PTR record using multicast
 
@@ -118,8 +120,8 @@ Add "$Log" header
 #include <unistd.h>                            // For select()
 #include <signal.h>                            // For SIGINT, SIGTERM
 #include <errno.h>                             // For errno, EINTR
-#include <arpa/inet.h>                 // For inet_addr()
 #include <netinet/in.h>                        // For INADDR_NONE
+#include <arpa/inet.h>                 // For inet_addr()
 #include <netdb.h>                             // For gethostbyname()
 
 #include "mDNSEmbeddedAPI.h"   // Defines the interface to the client layer above
@@ -326,7 +328,7 @@ mDNSexport int main(int argc, char **argv)
                mDNS_Init_NoCache, mDNS_Init_ZeroCacheSize,
                mDNS_Init_DontAdvertiseLocalAddresses,
                mDNS_Init_NoInitCallback, mDNS_Init_NoInitCallbackContext);
-       if (status) { fprintf(stderr, "Daemon start: mDNS_Init failed %ld\n", status); return(status); }
+       if (status) { fprintf(stderr, "Daemon start: mDNS_Init failed %d\n", (int)status); return(status); }
 
        mDNSPosixListenForSignalInEventLoop(SIGINT);
        mDNSPosixListenForSignalInEventLoop(SIGTERM);
index 35be2b19818164cfc7c7087f90fdc01be877302b..d4bff853b4c1b13801a209b2fb04b8ed85d4cde2 100755 (executable)
@@ -274,9 +274,7 @@ because I don't have access to the physical machine.
 
 Licencing
 ---------
-This code is distributed under the Apple Public Source License.
-Information about the licence is included at the top of each source file.
-
+This source code is Open Source; for details see the "LICENSE" file.
 
 Credits and Version History
 ---------------------------
index 986333b05892b0ba9a293f956f3ea43d332886b2..4f6b186e063c9375d52d78feef8dbe7ab16fc706 100755 (executable)
@@ -2,28 +2,27 @@
  *
  * 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: Responder.c,v $
+Revision 1.32  2006/08/14 23:24:46  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.31  2006/06/12 18:22:42  cheshire
+<rdar://problem/4580067> mDNSResponder building warnings under Red Hat 64-bit (LP64) Linux
+
 Revision 1.30  2005/10/26 22:21:16  cheshire
 <rdar://problem/4149841> Potential buffer overflow in mDNSResponderPosix
 
@@ -832,7 +831,7 @@ int main(int argc, char **argv)
         result = 2;
     }
     if ( (result != 0) || (gMDNSPlatformPosixVerboseLevel > 0) ) {
-        fprintf(stderr, "%s: Finished with status %ld, result %d\n", gProgramName, status, result);
+        fprintf(stderr, "%s: Finished with status %d, result %d\n", gProgramName, (int)status, result);
     }
     
     return result;
index ab1071d40ac8a27388149f95f4be8116ef791a22..64895aba6e757201837335c58b2224655821c80c 100644 (file)
@@ -2,52 +2,27 @@
  *
  * 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: dnsextd.c,v $
-Revision 1.41  2005/09/24 01:10:54  cheshire
-Fix comment typos
-
-Revision 1.40  2005/09/07 21:54:37  ksekar
-<rdar://problem/4046465> dnsextd doesn't clean up on exit
-Close sockets before cleanup so clients can't make new requests
-
-Revision 1.39  2005/08/22 23:30:30  ksekar
-<rdar://problem/4158123> memory leak in dnsextd.c
-
-Revision 1.38  2005/06/29 10:03:56  cheshire
-Fix compile errors and warnings
-
-Revision 1.37  2005/06/27 22:12:17  ksekar
-<rdar://problem/4163315> dnsextd performance improvements
-
-Revision 1.36  2005/06/14 23:14:41  ksekar
-<rdar://problem/3934233> Unable to refresh LLQs
+Revision 1.33.2.2  2006/08/29 06:24:34  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
 
-Revision 1.35  2005/03/17 03:57:43  cheshire
-LEASE_OPT_SIZE is now LEASE_OPT_RDLEN; LLQ_OPT_SIZE is now LLQ_OPT_RDLEN
-
-Revision 1.34  2005/03/16 18:47:37  ksekar
-<rdar://problem/4046465> dnsextd doesn't clean up on exit
+Revision 1.33.2.1  2005/08/05 21:14:00  ksekar
+<rdar://problem/4012279> Long-lived queries not working on windows
+Change constant names
 
 Revision 1.33  2005/03/11 19:09:02  ksekar
 Fixed ZERO_LLQID macro
@@ -177,7 +152,6 @@ Revision 1.1  2004/08/11 00:43:26  ksekar
 #include <syslog.h>
 #include <string.h>
 #include <sys/time.h>
-#include <sys/resource.h>
 #include <time.h>
 #include <errno.h>
 
@@ -255,9 +229,7 @@ typedef struct AnswerListElem
     mDNSu16 type;
     CacheRecord *KnownAnswers;  // All valid answers delivered to client
     CacheRecord *EventList;     // New answers (adds/removes) to be sent to client
-    int refcount;
-    mDNSBool UseTCP;            // Use TCP if UDP would cause truncation
-    pthread_t tid;              // Allow parallel list updates
+    int refcount;          
        } AnswerListElem;
 
 // llq table entry
@@ -278,7 +250,7 @@ typedef struct LLQEntry
 typedef struct 
        {
     // server variables - read only after initialization (no locking)
-    struct sockaddr_in saddr;  // server address
+    struct in_addr saddr;      // server address
     domainname zone;           // zone being updated
     int tcpsd;                 // listening TCP socket
     int udpsd;                 // listening UDP socket
@@ -296,9 +268,8 @@ typedef struct
     // LLQ table variables
     LLQEntry *LLQTable[LLQ_TABLESIZE];  // !!!KRS change this and RRTable to use a common data structure
     AnswerListElem *AnswerTable[LLQ_TABLESIZE];
-    int AnswerTableCount;
-    int LLQEventNotifySock;          // Unix domain socket pair - update handling thread writes to EventNotifySock, which wakes
-    int LLQEventListenSock;          // the main thread listening on EventListenSock, indicating that the zone has changed
+    int LLQEventListenSock;       // Unix domain socket pair - polling thread writes to ServPollSock, which wakes
+    int LLQServPollSock;          // the main thread listening on EventListenSock, indicating that the zone has changed
        } DaemonInfo;
 
 // args passed to UDP request handler thread as void*
@@ -317,13 +288,6 @@ typedef struct
     DaemonInfo *d;
        } TCPRequestArgs;
 
-// args passed to UpdateAnswerList thread as void*
-typedef struct
-       {
-    DaemonInfo *d;
-    AnswerListElem *a;
-       } UpdateAnswerListArgs;
-
 //
 // Global Variables
 //
@@ -385,12 +349,11 @@ mDNSlocal void Log(const char *format, ...)
 
 // Error Logging
 // prints message "dnsextd <function>: <operation> - <error message>" 
-// must be compiled w/ -D_REENTRANT for thread-safe errno usage
+// must be compiled w/ -D_REENTRANT  for thread-safe errno usage
 mDNSlocal void LogErr(const char *fn, const char *operation)
        {
-       char buf[512], errbuf[256];
-       strerror_r(errno, errbuf, sizeof(errbuf));
-       snprintf(buf, sizeof(buf), "%s: %s - %s", fn, operation, errbuf);
+       char buf[512];
+       snprintf(buf, sizeof(buf), "%s: %s - %s", fn, operation, strerror(errno));
        PrintLog(buf);
        }
 
@@ -433,40 +396,30 @@ mDNSlocal void HdrHToN(PktMsg *pkt)
 // caller terminates connection via close()
 mDNSlocal int ConnectToServer(DaemonInfo *d)
        {
-       int ntries = 0, retry = 0;
-
-       while (1)
-               {
-           int sd = socket(AF_INET, SOCK_STREAM, 0);
-               if (sd < 0) { LogErr("ConnectToServer", "socket");  return -1; }
-               if (!connect(sd, (struct sockaddr *)&d->saddr, sizeof(d->saddr))) return sd;
-               close(sd);
-               if (++ntries < 10)
-                       {
-                       LogErr("ConnectToServer", "connect");
-                       Log("ConnectToServer - retrying connection");
-                       if (!retry) retry = 500000 + random() % 500000;
-                       usleep(retry);
-                       retry *= 2;
-                       }
-               else { Log("ConnectToServer - %d failed attempts.  Aborting.", ntries); return -1; }
-               }
+       struct sockaddr_in servaddr;
+       int sd;
+       
+       bzero(&servaddr, sizeof(servaddr));
+       if (d->saddr.s_addr) servaddr.sin_addr = d->saddr;
+       else                 inet_pton(AF_INET, LOOPBACK, &d->saddr);  // use loopback if server not explicitly specified                       
+       servaddr.sin_port = htons(NS_PORT);
+       servaddr.sin_family = AF_INET;
+#ifndef NOT_HAVE_SA_LEN
+       servaddr.sin_len = sizeof(servaddr); 
+#endif
+       sd = socket(AF_INET, SOCK_STREAM, 0);
+       if (sd < 0) { LogErr("ConnectToServer", "socket");  return -1; }
+       if (connect(sd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) { LogErr("ConnectToServer", "connect"); return -1; }
+       return sd;
        }
 
-// send an entire block of data over a connected socket
+// send an entire block of data over a connected socket, blocking if buffers are full
 mDNSlocal int MySend(int sd, const void *msg, int len)
        {
-       int selectval, n, nsent = 0;
-       fd_set wset;    
-       struct timeval timeout = { 3, 0 };  // until we remove all calls from main thread, keep timeout short
-       
+       int n, nsent = 0;
+
        while (nsent < len)
                {
-               FD_ZERO(&wset);
-               FD_SET(sd, &wset);
-               selectval = select(sd+1, NULL, &wset, NULL, &timeout);
-               if (selectval < 0) { LogErr("MySend", "select");  return -1; }
-               if (!selectval || !FD_ISSET(sd, &wset)) { Log("MySend - timeout"); return -1; }
                n = send(sd, (char *)msg + nsent, len - nsent, 0);
                if (n < 0) { LogErr("MySend", "send");  return -1; }
                nsent += n;
@@ -493,21 +446,11 @@ static int my_recv(const int sd, void *const buf, const int len)
     // use an explicit while() loop instead.
     // Also, don't try to do '+=' arithmetic on the original "void *" pointer --
     // arithmetic on "void *" pointers is compiler-dependent.
-
-       fd_set rset;    
-       struct timeval timeout = { 3, 0 };  // until we remove all calls from main thread, keep timeout short   
-    int selectval, remaining = len;
+    int remaining = len;
     char *ptr = (char *)buf;
-       ssize_t num_read;
-       
-       while (remaining)
+    while (remaining)
        {
-               FD_ZERO(&rset);
-               FD_SET(sd, &rset);
-               selectval = select(sd+1, &rset, NULL, NULL, &timeout);
-               if (selectval < 0) { LogErr("my_recv", "select");  return -1; }
-               if (!selectval || !FD_ISSET(sd, &rset)) { Log("my_recv - timeout"); return -1; }
-       num_read = recv(sd, ptr, remaining, 0);
+       ssize_t num_read = recv(sd, ptr, remaining, 0);
        if ((num_read == 0) || (num_read < 0) || (num_read > remaining)) return -1;
        ptr       += num_read;
        remaining -= num_read;
@@ -528,7 +471,7 @@ mDNSlocal PktMsg *ReadTCPMsg(int sd, PktMsg *storage)
        unsigned int srclen;
        
        nread = my_recv(sd, &msglen, sizeof(msglen));
-       if (nread < 0) { LogErr("ReadTCPMsg", "recv"); goto error; }
+       if (nread < 0) { LogErr("TCPRequestForkFn", "recv"); goto error; }
        msglen = ntohs(msglen);
        if (nread != sizeof(msglen)) { Log("Could not read length field of message"); goto error; }     
 
@@ -552,7 +495,7 @@ mDNSlocal PktMsg *ReadTCPMsg(int sd, PktMsg *storage)
        if (getpeername(sd, (struct sockaddr *)&pkt->src, &srclen) ||
                srclen != sizeof(pkt->src)) { LogErr("ReadTCPMsg", "getpeername"); bzero(&pkt->src, sizeof(pkt->src)); }
        nread = my_recv(sd, &pkt->msg, msglen);
-       if (nread < 0) { LogErr("ReadTCPMsg", "recv"); goto error; }
+       if (nread < 0) { LogErr("TCPRequestForkFn", "recv"); goto error; }
        if (nread != msglen) { Log("Could not read entire message"); goto error; }
        if (pkt->len < sizeof(DNSMessageHeader))
                { Log("ReadTCPMsg: Message too short (%d bytes)", pkt->len);  goto error; }     
@@ -564,33 +507,6 @@ mDNSlocal PktMsg *ReadTCPMsg(int sd, PktMsg *storage)
        return NULL;
        }
 
-mDNSlocal int UDPServerTransaction(const DaemonInfo *d, const PktMsg *request, PktMsg *reply, mDNSBool *trunc)
-       {
-       fd_set rset;    
-       struct timeval timeout = { 3, 0 };  // until we remove all calls from main thread, keep timeout short
-       int selectval, err = -1, sd = socket(AF_INET, SOCK_DGRAM, 0);
-
-       *trunc = mDNSfalse;
-       if (sd < 0) { LogErr("UDPServerTransaction", "socket"); goto end; }
-       if (sendto(sd, (char *)&request->msg, request->len, 0, (struct sockaddr *)&d->saddr, sizeof(d->saddr)) != (int)request->len)
-               { LogErr("UDPServerTransaction", "sendto"); goto end; }
-
-       FD_ZERO(&rset);
-       FD_SET(sd, &rset);
-       selectval = select(sd+1, &rset, NULL, NULL, &timeout);
-       if (selectval < 0) { LogErr("UDPServerTransaction", "select");  goto end; }
-       if (!selectval || !FD_ISSET(sd, &rset)) { Log("UDPServerTransaction - timeout"); goto end; }
-       reply->len = recvfrom(sd, &reply->msg, sizeof(reply->msg), 0, NULL, NULL);
-       if ((int)reply->len < 0) { LogErr("UDPServerTransaction", "recvfrom"); goto end; }
-       if (reply->len < sizeof(DNSMessageHeader)) { Log("UDPServerTransaction - Message too short (%d bytes)", reply->len); goto end; }
-       if (reply->msg.h.flags.b[0] & kDNSFlag0_TC) *trunc = mDNStrue;
-       err = 0;
-
-       end:
-       if (sd >= 0) close(sd);
-       return err;     
-       }
-
 //
 // Dynamic Update Utility Routines
 //
@@ -926,14 +842,10 @@ mDNSlocal void PrintHelp(void)
 mDNSlocal int ProcessArgs(int argc, char *argv[], DaemonInfo *d)
        {
        int opt;
-       struct in_addr server;
-       
+
        if (argc < 2) goto arg_error;
-       
-    // defaults, may be overriden by command option
-       d->port.NotAnInteger = htons(DAEMON_PORT);  
-       inet_pton(AF_INET, LOOPBACK, &server);  // use loopback if server not explicitly specified
 
+       d->port.NotAnInteger = htons(DAEMON_PORT);  // default, may be overriden by command option
        while ((opt = getopt(argc, argv, "z:p:hfvs:k:")) != -1)
                {
                switch(opt)
@@ -944,8 +856,8 @@ mDNSlocal int ProcessArgs(int argc, char *argv[], DaemonInfo *d)
                        case 'h': PrintHelp();    return -1;
                        case 'f': foreground = 1; break;
                        case 'v': verbose = 1;    break;
-                       case 's': if (!inet_pton(AF_INET, optarg, &server)) goto arg_error;
-                               break;
+                       case 's': if (!inet_pton(AF_INET, optarg, &d->saddr)) goto arg_error;
+                                     break;
                        case 'k': if (ReadAuthKey(argc, argv, d) < 0) goto arg_error;
                                      break;
                        case 'z': if (!MakeDomainNameFromDNSNameString(&d->zone, optarg))
@@ -960,16 +872,6 @@ mDNSlocal int ProcessArgs(int argc, char *argv[], DaemonInfo *d)
                
        if (!d->zone.c[0]) goto arg_error;  // zone is the only required argument
        if (d->AuthInfo) AssignDomainName(&d->AuthInfo->zone, &d->zone); // if we have a shared secret, use it for the entire zone
-
-       // setup server's sockaddr
-       bzero(&d->saddr, sizeof(d->saddr));
-       d->saddr.sin_addr = server;   
-       d->saddr.sin_port = htons(NS_PORT);
-       d->saddr.sin_family = AF_INET;
-#ifndef NOT_HAVE_SA_LEN
-       d->saddr.sin_len = sizeof(d->saddr); 
-#endif
-
        return 0;
        
        arg_error:
@@ -1018,7 +920,7 @@ mDNSlocal int SetupSockets(DaemonInfo *daemon)
        // set up Unix domain socket pair for LLQ polling thread to signal main thread that a change to the zone occurred
        if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockpair) < 0) { LogErr("SetupSockets", "socketpair"); return -1; }
        daemon->LLQEventListenSock = sockpair[0];
-       daemon->LLQEventNotifySock = sockpair[1];
+       daemon->LLQServPollSock = sockpair[1];
        return 0;
        }
 
@@ -1027,9 +929,9 @@ mDNSlocal int SetupSockets(DaemonInfo *daemon)
 //
 
 // Delete a resource record from the nameserver via a dynamic update
-// sd is a socket already connected to the server
-mDNSlocal void DeleteOneRecord(DaemonInfo *d, CacheRecord *rr, domainname *zone, int sd)
+mDNSlocal void DeleteRecord(DaemonInfo *d, CacheRecord *rr, domainname *zone)
        {
+       int sd = -1;
        mDNSOpaque16 id;
        PktMsg pkt;
        mDNSu8 *ptr = pkt.msg.data;
@@ -1039,6 +941,8 @@ mDNSlocal void DeleteOneRecord(DaemonInfo *d, CacheRecord *rr, domainname *zone,
        PktMsg *reply = NULL;
        
        VLog("Expiring record %s", GetRRDisplayString_rdb(&rr->resrec, &rr->resrec.rdata->u, buf));     
+       sd = ConnectToServer(d);
+       if (sd < 0) { Log("DeleteRecord: ConnectToServer failed"); goto end; }
        
        id.NotAnInteger = 0;
        InitializeDNSMessage(&pkt.msg.h, id, UpdateReqFlags);
@@ -1060,45 +964,51 @@ mDNSlocal void DeleteOneRecord(DaemonInfo *d, CacheRecord *rr, domainname *zone,
        pkt.len = ptr - (mDNSu8 *)&pkt.msg;
        pkt.src.sin_addr.s_addr = htonl(INADDR_ANY); // address field set solely for verbose logging in subroutines
        pkt.src.sin_family = AF_INET;
-       if (SendTCPMsg(sd, &pkt)) { Log("DeleteOneRecord: SendTCPMsg failed"); }
+       if (SendTCPMsg(sd, &pkt)) { Log("DeleteRecord: SendTCPMsg failed"); }
        reply = ReadTCPMsg(sd, NULL);
        if (!SuccessfulUpdateTransaction(&pkt, reply))
-               Log("Expiration update failed with rcode %d", reply ? reply->msg.h.flags.b[1] & kDNSFlag1_RC : -1);
+               Log("Expiration update failed with rcode %d", reply->msg.h.flags.b[1] & kDNSFlag1_RC);
                                          
        end:
-       if (!ptr) { Log("DeleteOneRecord: Error constructing lease expiration update"); }
+       if (!ptr) { Log("DeleteRecord: Error constructing lease expiration update"); }
+       if (sd >= 0) close(sd); 
        if (reply) free(reply);
        }
 
-// iterate over table, deleting expired records (or all records if DeleteAll is true)
-mDNSlocal void DeleteRecords(DaemonInfo *d, mDNSBool DeleteAll)
+// iterate over table, deleting expired records
+mDNSlocal void DeleteExpiredRecords(DaemonInfo *d)
        {
+       int i;
+       RRTableElem *ptr, *prev, *fptr; 
        struct timeval now;
-       int i, sd = ConnectToServer(d);
-       if (sd < 0) { Log("DeleteRecords: ConnectToServer failed"); return; }  
-       if (gettimeofday(&now, NULL)) { LogErr("DeleteRecords ", "gettimeofday"); return; }
-       if (pthread_mutex_lock(&d->tablelock)) { LogErr("DeleteRecords", "pthread_mutex_lock"); return; }
 
+       if (gettimeofday(&now, NULL)) { LogErr("DeleteExpiredRecords ", "gettimeofday"); return; }
+       if (pthread_mutex_lock(&d->tablelock)) { LogErr("DeleteExpiredRecords", "pthread_mutex_lock"); return; }
        for (i = 0; i < d->nbuckets; i++)
                {
-               RRTableElem **ptr = &d->table[i];
-               while (*ptr)
+               ptr = d->table[i];
+               prev = NULL;
+               while (ptr)
                        {
-                       if (DeleteAll || (*ptr)->expire - now.tv_sec < 0)
+                       if (ptr->expire - now.tv_sec < 0)
                                {
-                               RRTableElem *fptr;
                                // delete record from server
-                               DeleteOneRecord(d, &(*ptr)->rr, &(*ptr)->zone, sd);
-                               fptr = *ptr;
-                               *ptr = (*ptr)->next;
+                               DeleteRecord(d, &ptr->rr, &ptr->zone);
+                               if (prev) prev->next = ptr->next;
+                               else d->table[i] = ptr->next;
+                               fptr = ptr;
+                               ptr = ptr->next;
                                free(fptr);
                                d->nelems--;
                                }
-                       else ptr = &(*ptr)->next;
+                       else
+                               {
+                               prev = ptr;
+                               ptr = ptr->next;
+                               }
                        }
                }
        pthread_mutex_unlock(&d->tablelock);
-       close(sd);
        }
 
 //
@@ -1235,54 +1145,32 @@ mDNSlocal PktMsg *FormatLeaseReply(DaemonInfo *d, PktMsg *orig, mDNSu32 lease)
 mDNSlocal PktMsg *HandleRequest(PktMsg *pkt, DaemonInfo *d)
        {
        int sd = -1;
-       PktMsg *reply = NULL, *LeaseReply, buf;
+       PktMsg *reply = NULL, *LeaseReply;
        mDNSs32 lease;
-       char addrbuf[32], pingmsg[4];
+       char buf[32];
        
        // send msg to server, read reply
-
-       if (pkt->len <= 512)
-               {
-               mDNSBool trunc;
-               if (UDPServerTransaction(d, pkt, &buf, &trunc) < 0)
-                       Log("HandleRequest - UDPServerTransaction failed.  Trying TCP");
-               else if (trunc) VLog("HandleRequest - answer truncated.  Using TCP");
-               else reply = &buf; // success
-               }
-
-       if (!reply)
-               {
-               sd = ConnectToServer(d);
-               if (sd < 0)
-                       { Log("Discarding request from %s due to connection errors", inet_ntop(AF_INET, &pkt->src.sin_addr, addrbuf, 32)); goto cleanup; }
-               if (SendTCPMsg(sd, pkt) < 0)
-                       { Log("Couldn't relay message from %s to server.  Discarding.", inet_ntop(AF_INET, &pkt->src.sin_addr, addrbuf, 32)); goto cleanup; }           
-               reply = ReadTCPMsg(sd, &buf);
-               }
-               
+       sd = ConnectToServer(d);
+       if (sd < 0)
+               { Log("Discarding request from %s due to connection errors", inet_ntop(AF_INET, &pkt->src.sin_addr, buf, 32)); goto cleanup; }
+       if (SendTCPMsg(sd, pkt) < 0)
+               { Log("Couldn't relay message from %s to server.  Discarding.", inet_ntop(AF_INET, &pkt->src.sin_addr, buf, 32)); goto cleanup; }
+       reply = ReadTCPMsg(sd, NULL);
+       
        // process reply
        if (!SuccessfulUpdateTransaction(pkt, reply))
-               { VLog("Message from %s not a successful update.", inet_ntop(AF_INET, &pkt->src.sin_addr, addrbuf, 32));  goto cleanup; }       
+               { VLog("Message from %s not a successful update.", inet_ntop(AF_INET, &pkt->src.sin_addr, buf, 32));  goto cleanup; }   
        lease = GetPktLease(pkt);
        UpdateLeaseTable(pkt, d, lease);
        if (lease > 0)
                {
                LeaseReply = FormatLeaseReply(d, reply, lease);
                if (!LeaseReply) Log("HandleRequest - unable to format lease reply");
+               free(reply); 
                reply = LeaseReply;
                }
-
-       // tell the main thread there was an update so it can send LLQs
-       if (send(d->LLQEventNotifySock, pingmsg, sizeof(pingmsg), 0) != sizeof(pingmsg)) LogErr("HandleRequest", "send");
-
        cleanup:
        if (sd >= 0) close(sd);
-       if (reply == &buf)
-               {
-               reply = malloc(sizeof(*reply));
-               if (!reply) LogErr("HandleRequest", "malloc");
-               else { reply->len = buf.len; memcpy(&reply->msg, &buf.msg, buf.len); }
-               }
        return reply;
        }
 
@@ -1327,13 +1215,9 @@ mDNSlocal void DeleteLLQ(DaemonInfo *d, LLQEntry *e)
        inet_ntop(AF_INET, &e->cli.sin_addr, addr, 32);
        VLog("Deleting LLQ table entry for %##s client %s", e->qname.c, addr);
 
-       if (a && !(--a->refcount) && d->AnswerTableCount >= LLQ_TABLESIZE)
+       // free shared answer structure if ref count drops to zero
+       if (a && !(--a->refcount))
                {
-               // currently, generating initial answers blocks the main thread, so we keep the answer list
-               // even if the ref count drops to zero.  To prevent unbounded table growth, we free shared answers
-               // if the ref count drops to zero AND there are more table elements than buckets
-               // !!!KRS update this when we make the table dynamically growable
-
                CacheRecord *cr = a->KnownAnswers, *tmp;
                AnswerListElem **tbl = &d->AnswerTable[bucket];
 
@@ -1345,7 +1229,7 @@ mDNSlocal void DeleteLLQ(DaemonInfo *d, LLQEntry *e)
                        }
 
                while (*tbl && *tbl != a) tbl = &(*tbl)->next;
-               if (*tbl) { *tbl = (*tbl)->next; free(a); d->AnswerTableCount--; }
+               if (*tbl) { *tbl = (*tbl)->next; free(a); }
                else Log("Error: DeleteLLQ - AnswerList not found in table");
                }
 
@@ -1372,17 +1256,20 @@ mDNSlocal int SendLLQ(DaemonInfo *d, PktMsg *pkt, struct sockaddr_in dst)
        return err;
        }
 
-mDNSlocal CacheRecord *AnswerQuestion(DaemonInfo *d, AnswerListElem *e)
+// if non-negative, sd is a TCP socket connected to the nameserver
+// otherwise, this routine creates and closes its own socket
+mDNSlocal CacheRecord *AnswerQuestion(DaemonInfo *d, AnswerListElem *e, int sd)
        {
        PktMsg q;
-       int i, sd = -1;
+       int i;
        const mDNSu8 *ansptr;
        mDNSu8 *end = q.msg.data;
        mDNSOpaque16 id, flags = QueryFlags;
-       PktMsg buf, *reply = NULL;
+       PktMsg *reply = NULL;
        LargeCacheRecord lcr;
        CacheRecord *AnswerList = NULL;
        mDNSu8 rcode;
+       mDNSBool CloseSDOnExit = sd < 0;
        
        VLog("Querying server for %##s type %d", e->name.c, e->type);
        
@@ -1393,26 +1280,11 @@ mDNSlocal CacheRecord *AnswerQuestion(DaemonInfo *d, AnswerListElem *e)
        end = putQuestion(&q.msg, end, end + AbsoluteMaxDNSMessageData, &e->name, e->type, kDNSClass_IN);
        if (!end) { Log("Error: AnswerQuestion - putQuestion returned NULL"); goto end; }
        q.len = (int)(end - (mDNSu8 *)&q.msg);
-
-       if (!e->UseTCP)
-               {
-               mDNSBool trunc;
-
-               if (UDPServerTransaction(d, &q, &buf, &trunc) < 0)
-                       Log("AnswerQuestion %##s - UDPServerTransaction failed.  Trying TCP", e->name.c);
-               else if (trunc)
-                       { VLog("AnswerQuestion %##s - answer truncated.  Using TCP", e->name.c); e->UseTCP = mDNStrue; }
-               else reply = &buf;  // success
-               }
        
-       if (!reply)
-               {
-               sd = ConnectToServer(d);
-               if (sd < 0) { Log("AnswerQuestion: ConnectToServer failed"); goto end; }
-               if (SendTCPMsg(sd, &q)) { Log("AnswerQuestion: SendTCPMsg failed"); close(sd); goto end; }
-               reply = ReadTCPMsg(sd, NULL);
-               close(sd);
-               }
+       if (sd < 0) sd = ConnectToServer(d);
+       if (sd < 0) { Log("AnswerQuestion: ConnectToServer failed"); goto end; }
+       if (SendTCPMsg(sd, &q)) { Log("AnswerQuestion: SendTCPMsg failed"); close(sd); goto end; }
+       reply = ReadTCPMsg(sd, NULL);
 
        if ((reply->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask) != (kDNSFlag0_QR_Response | kDNSFlag0_OP_StdQuery))
                { Log("AnswerQuestion: %##s type %d - Invalid response flags from server"); goto end; }
@@ -1442,22 +1314,18 @@ mDNSlocal CacheRecord *AnswerQuestion(DaemonInfo *d, AnswerListElem *e)
                }
        
        end:
-       if (reply && reply != &buf) free(reply);
+       if (sd > -1 && CloseSDOnExit) close(sd);
+       if (reply) free(reply);
        return AnswerList;
        }
 
-// Routine forks a thread to set EventList to contain Add/Remove events, and deletes any removes from the KnownAnswer list
-mDNSlocal void *UpdateAnswerList(void *args)
+// Routine sets EventList to contain Add/Remove events, and deletes any removes from the KnownAnswer list
+mDNSlocal void UpdateAnswerList(DaemonInfo *d, AnswerListElem *a, int sd)
        {
        CacheRecord *cr, *NewAnswers, **na, **ka; // "new answer", "known answer"
-       DaemonInfo *d = ((UpdateAnswerListArgs *)args)->d;
-       AnswerListElem *a = ((UpdateAnswerListArgs *)args)->a;
 
-       free(args);
-       args = NULL;
-       
        // get up to date answers
-       NewAnswers = AnswerQuestion(d, a);
+       NewAnswers = AnswerQuestion(d, a, sd);
        
        // first pass - mark all answers for deletion
        for (ka = &a->KnownAnswers; *ka; ka = &(*ka)->next)
@@ -1511,9 +1379,7 @@ mDNSlocal void *UpdateAnswerList(void *args)
                cr = NewAnswers;
                NewAnswers = NewAnswers->next;
                free(cr);
-               }
-       
-       return NULL;
+               }       
        }
 
 mDNSlocal void SendEvents(DaemonInfo *d, LLQEntry *e)
@@ -1537,7 +1403,7 @@ mDNSlocal void SendEvents(DaemonInfo *d, LLQEntry *e)
                if (verbose) GetRRDisplayString_rdb(&cr->resrec, &cr->resrec.rdata->u, rrbuf);
                VLog("%s (%s): %s", addrbuf, (mDNSs32)cr->resrec.rroriginalttl < 0 ? "Remove": "Add", rrbuf);                            
                end = PutResourceRecordTTLJumbo(&response.msg, end, &response.msg.h.numAnswers, &cr->resrec, cr->resrec.rroriginalttl);
-               if (!end) { Log("Error: SendEvents - PutResourceRecordTTLJumbo returned NULL"); return; }
+               if (!end) { Log("Error: SendEvents - UpdateAnswerList returned NULL"); return; }
                }
                           
        FormatLLQOpt(&opt, kLLQOp_Event, e->id, LLQLease(e));
@@ -1548,28 +1414,6 @@ mDNSlocal void SendEvents(DaemonInfo *d, LLQEntry *e)
        if (SendLLQ(d, &response, e->cli) < 0) LogMsg("Error: SendEvents - SendLLQ");           
        }
 
-mDNSlocal void PrintLLQAnswers(DaemonInfo *d)
-       {
-       int i;
-       char rrbuf[80];
-       
-       Log("Printing LLQ Answer Table contents");
-
-       for (i = 0; i < LLQ_TABLESIZE; i++)
-               {
-               AnswerListElem *a = d->AnswerTable[i];
-               while(a)
-                       {
-                       int ancount = 0;
-                       const CacheRecord *rr = a->KnownAnswers;
-                       while (rr) { ancount++; rr = rr->next; }                
-                       Log("%p : Question %##s;  type %d;  referenced by %d LLQs; %d answers:", a, a->name.c, a->type, a->refcount, ancount);
-                       for (rr = a->KnownAnswers; rr; rr = rr->next) Log("\t%s", GetRRDisplayString_rdb(&rr->resrec, &rr->resrec.rdata->u, rrbuf));
-                       a = a->next;
-                       }
-               }
-       }
-
 mDNSlocal void PrintLLQTable(DaemonInfo *d)
        {
        LLQEntry *e;
@@ -1583,19 +1427,9 @@ mDNSlocal void PrintLLQTable(DaemonInfo *d)
                e = d->LLQTable[i];
                while(e)
                        {
-                       char *state;
-                       
-                       switch (e->state)
-                               {
-                               case RequestReceived: state = "RequestReceived"; break;
-                               case ChallengeSent:   state = "ChallengeSent";   break;
-                               case Established:     state = "Established";     break;
-                               default:              state = "unknown";                                        
-                               }
-                       inet_ntop(AF_INET, &e->cli.sin_addr, addr, 32);                         
-                       
-                       Log("LLQ from %s in state %s; %##s; type %d; orig lease %d; remaining lease %d; AnswerList %p)",
-                               addr, state, e->qname.c, e->qtype, e->lease, LLQLease(e), e->AnswerList);
+                       inet_ntop(AF_INET, &e->cli.sin_addr, addr, 32);
+                       Log("LLQ from %##s type %d lease %d (%d remaining)",
+                               addr, e->qname.c, e->qtype, e->lease, LLQLease(e));
                        e = e->next;
                        }
                }
@@ -1605,13 +1439,14 @@ mDNSlocal void PrintLLQTable(DaemonInfo *d)
 mDNSlocal void GenLLQEvents(DaemonInfo *d)
        {
        LLQEntry **e;
-       int i;
+       int i, sd;
        struct timeval t;
-       UpdateAnswerListArgs *args;
-       
+
        VLog("Generating LLQ Events");
 
        gettimeofday(&t, NULL);
+       sd = ConnectToServer(d);
+       if (sd < 0) { Log("GenLLQEvents: ConnectToServer failed"); return; }
 
        // get all answers up to date
        for (i = 0; i < LLQ_TABLESIZE; i++)
@@ -1619,26 +1454,11 @@ mDNSlocal void GenLLQEvents(DaemonInfo *d)
                AnswerListElem *a = d->AnswerTable[i];
                while(a)
                        {
-                       args = malloc(sizeof(*args));
-                       if (!args) { LogErr("GenLLQEvents", "malloc"); return; }                        
-                       args->d = d;
-                       args->a = a;
-                       if (pthread_create(&a->tid, NULL, UpdateAnswerList, args) < 0) { LogErr("GenLLQEvents", "pthread_create"); return; }
-                       usleep(1);
+                       UpdateAnswerList(d, a, sd);
                        a = a->next;
                        }
                }
 
-       for (i = 0; i < LLQ_TABLESIZE; i++)
-               {
-               AnswerListElem *a = d->AnswerTable[i];
-               while(a)
-                       {
-                       if (pthread_join(a->tid, NULL))  LogErr("GenLLQEvents", "pthread_join");
-                       a = a->next;
-                       }
-               }
-       
     // for each established LLQ, send events
        for (i = 0; i < LLQ_TABLESIZE; i++)
                {
@@ -1680,6 +1500,79 @@ mDNSlocal void GenLLQEvents(DaemonInfo *d)
                        a = a->next;
                        }
                }       
+               
+       close(sd);
+       }
+
+// Monitor zone for changes that may produce LLQ events
+mDNSlocal void *LLQEventMonitor(void *DInfoPtr)
+       {
+       DaemonInfo *d = DInfoPtr;
+       PktMsg q;
+       mDNSu8 *end = q.msg.data;
+       const mDNSu8 *ptr;
+       mDNSOpaque16 id, flags = QueryFlags;
+       PktMsg reply;
+       mDNSs32 serial = 0;
+       mDNSBool SerialInitialized = mDNSfalse;
+       int sd;
+    LargeCacheRecord lcr;
+       ResourceRecord *rr = &lcr.r.resrec;
+       int i, sleeptime = 0;
+       domainname zone;
+       char pingmsg[4];
+       
+       // create question
+       id.NotAnInteger = 0;
+       InitializeDNSMessage(&q.msg.h, id, flags);
+       AssignDomainName(&zone, &d->zone);
+       end = putQuestion(&q.msg, end, end + AbsoluteMaxDNSMessageData, &zone, kDNSType_SOA, kDNSClass_IN);
+       if (!end) { Log("Error: LLQEventMonitor - putQuestion returned NULL"); return NULL; }
+       q.len = (int)(end - (mDNSu8 *)&q.msg);
+
+       sd = ConnectToServer(d);
+       if (sd < 0) { Log("LLQEventMonitor: ConnectToServer failed"); return NULL; }
+
+       while(1)
+               {
+               usleep(sleeptime);
+               sleeptime = LLQ_MONITOR_ERR_INTERVAL;  // if we bail on error below, rate limit retry
+               
+               // send message, receive response
+               if (SendTCPMsg(sd, &q)) { Log("LLQEventMonitor: SendTCPMsg failed"); continue; }
+               if (!ReadTCPMsg(sd, &reply)) { Log("LLQEventMonitor: ReadTCPMsg failed"); continue; }
+               end = (mDNSu8 *)&reply.msg + reply.len;
+               if (reply.msg.h.flags.b[1] & kDNSFlag1_RC) { Log("LLQEventMonitor - received non-zero rcode"); continue; }
+
+               // find answer
+               ptr = LocateAnswers(&reply.msg, end);
+               if (!ptr) { Log("Error: LLQEventMonitor - LocateAnswers returned NULL"); continue; }
+               for (i = 0; i < reply.msg.h.numAnswers; i++)
+                       {
+                       ptr = GetLargeResourceRecord(NULL, &reply.msg, ptr, end, 0, kDNSRecordTypePacketAns, &lcr);
+                       if (!ptr) { Log("Error: LLQEventMonitor - GetLargeResourceRecord  returned NULL"); continue; }
+                       if (rr->rrtype != kDNSType_SOA || rr->rrclass != kDNSClass_IN || !SameDomainName(rr->name, &zone)) continue;
+                       if (!SerialInitialized)
+                               {
+                               // first time through loop
+                               SerialInitialized = mDNStrue;
+                               serial = rr->rdata->u.soa.serial;
+                               sleeptime = LLQ_MONITOR_INTERVAL;
+                               break;
+                               }
+                       else if (rr->rdata->u.soa.serial != serial)
+                               {
+                               // update serial, wake main thread
+                               serial = rr->rdata->u.soa.serial;
+                               VLog("LLQEventMonitor: zone changed. Signaling main thread.");
+                               if (send(d->LLQServPollSock, pingmsg, sizeof(pingmsg), 0) != sizeof(pingmsg))
+                                       { LogErr("LLQEventMonitor", "send"); break; }
+                               }
+                       sleeptime = LLQ_MONITOR_INTERVAL;
+                       break;                  
+                       }
+               if (!ptr) Log("LLQEventMonitor: response to query did not contain SOA");
+               }
        }
 
 mDNSlocal void SetAnswerList(DaemonInfo *d, LLQEntry *e)
@@ -1694,12 +1587,15 @@ mDNSlocal void SetAnswerList(DaemonInfo *d, LLQEntry *e)
                AssignDomainName(&a->name, &e->qname);
                a->type = e->qtype;
                a->refcount = 0;
+               a->KnownAnswers = NULL;
                a->EventList = NULL;
-               a->UseTCP = mDNSfalse;
                a->next = d->AnswerTable[bucket];
                d->AnswerTable[bucket] = a;
-               d->AnswerTableCount++;
-               a->KnownAnswers = AnswerQuestion(d, a);
+
+               // to get initial answer list, call UpdateAnswerList and move cache records from EventList to KnownAnswers
+               UpdateAnswerList(d, a, -1);
+               a->KnownAnswers = a->EventList;
+               a->EventList = NULL;
                }
        
        e->AnswerList = a;
@@ -1754,11 +1650,8 @@ mDNSlocal void LLQRefresh(DaemonInfo *d, LLQEntry *e, LLQOptData *llq, mDNSOpaqu
        
        if (llq->lease)
                {
-               struct timeval t;
                if (llq->lease < LLQ_MIN_LEASE) llq->lease = LLQ_MIN_LEASE;
                else if (llq->lease > LLQ_MAX_LEASE) llq->lease = LLQ_MIN_LEASE;
-               gettimeofday(&t, NULL);
-               e->expire = t.tv_sec + llq->lease;
                }
        
        ack.src.sin_addr.s_addr = 0; // unused 
@@ -2090,7 +1983,6 @@ mDNSlocal void *TCPRequestForkFn(void *vptr)
                }
                
        cleanup:
-       close(req->sd);
        free(req);
        if (in) free(in);
        if (out) free(out);
@@ -2099,34 +1991,31 @@ mDNSlocal void *TCPRequestForkFn(void *vptr)
 
 mDNSlocal int RecvTCPRequest(int sd, DaemonInfo *d)
        {
-       TCPRequestArgs *req = NULL;
+       TCPRequestArgs *req;
        pthread_t tid;
        unsigned int clilen = sizeof(req->cliaddr);
        
        req = malloc(sizeof(TCPRequestArgs));
-       if (!req) { LogErr("RecvTCPRequest", "malloc"); goto error; }
+       if (!req) { LogErr("RecvTCPRequest", "malloc"); return -1; }
        bzero(req, sizeof(*req));
        req->d = d;
        req->sd = accept(sd, (struct sockaddr *)&req->cliaddr, &clilen);
-       if (req->sd < 0) { LogErr("RecvTCPRequest", "accept"); goto error; }    
-       if (clilen != sizeof(req->cliaddr)) { Log("Client address of unknown size %d", clilen); goto error; }
-       if (pthread_create(&tid, NULL, TCPRequestForkFn, req)) { LogErr("RecvTCPRequest", "pthread_create"); goto error; }
+       if (req->sd < 0) { LogErr("RecvTCPRequest", "accept"); return -1; }     
+       if (clilen != sizeof(req->cliaddr)) { Log("Client address of unknown size %d", clilen); free(req); return -1; }
+       if (pthread_create(&tid, NULL, TCPRequestForkFn, req)) { LogErr("RecvTCPRequest", "pthread_create"); free(req); return -1; }
        pthread_detach(tid);
        return 0;
-
-       error:
-       if (req) free(req);
-       return -1;
        }
 
 // main event loop
 // listen for incoming requests, periodically check table for expired records, respond to signals
 mDNSlocal int ListenForUpdates(DaemonInfo *d)
        {
-       int maxfdp1, nfds;
+       int err;
+       int maxfdp1;
        fd_set rset;
-       struct timeval timenow, timeout, EventTS, tablecheck = { 0, 0 };
-       mDNSBool EventsPending = mDNSfalse;
+       struct timeval timenow, timeout = { 0, 0 };
+       long NextTableCheck = 0;
        
        VLog("Listening for requests...");
 
@@ -2137,72 +2026,42 @@ mDNSlocal int ListenForUpdates(DaemonInfo *d)
        
        while(1)
                {
-               // set timeout
-               timeout.tv_sec = timeout.tv_usec = 0;
+               // expire records if necessary, set timeout
                if (gettimeofday(&timenow, NULL)) { LogErr("ListenForUpdates", "gettimeofday"); return -1; }
-               if (EventsPending)
+               if (timenow.tv_sec >= NextTableCheck)
                        {
-                       if (timenow.tv_sec - EventTS.tv_sec >= 5)           // if we've been waiting 5 seconds for a "quiet" period to send
-                               { GenLLQEvents(d); EventsPending = mDNSfalse; } // events, we go ahead and do it now
-                       else timeout.tv_usec = 500000;                      // else do events after 1/2 second with no new events or LLQs
-                       }
-               if (!EventsPending)
-                       {
-                       // if no pending events, timeout when we need to check for expired records
-                       if (tablecheck.tv_sec && timenow.tv_sec - tablecheck.tv_sec >= 0)
-                               { DeleteRecords(d, mDNSfalse); tablecheck.tv_sec = 0; } // table check overdue                          
-                       if (!tablecheck.tv_sec) tablecheck.tv_sec = timenow.tv_sec + EXPIRATION_INTERVAL;
-                       timeout.tv_sec = tablecheck.tv_sec - timenow.tv_sec;
+                       DeleteExpiredRecords(d);
+                       NextTableCheck = timenow.tv_sec + EXPIRATION_INTERVAL;
                        }
+               timeout.tv_sec = NextTableCheck - timenow.tv_sec;
                
                FD_SET(d->tcpsd, &rset);
                FD_SET(d->udpsd, &rset);
                FD_SET(d->LLQEventListenSock, &rset);
                
-               nfds = select(maxfdp1, &rset, NULL, NULL, &timeout);            
-               if (nfds < 0)
+               err = select(maxfdp1, &rset, NULL, NULL, &timeout);             
+               if (err < 0)
                        {
                        if (errno == EINTR)
                                {
-                               if (terminate)
-                                       {
-                                       // close sockets to prevent clients from making new requests during shutdown
-                                       close(d->tcpsd);
-                                       close(d->udpsd);
-                                       d->tcpsd = d->udpsd = -1;
-                                       DeleteRecords(d, mDNStrue);
-                                       return 0;
-                                       }
-                               else if (dumptable) { PrintLeaseTable(d); PrintLLQTable(d); PrintLLQAnswers(d); dumptable = 0; }
+                               if (terminate) { DeleteExpiredRecords(d); return 0; }
+                               else if (dumptable) { PrintLeaseTable(d); PrintLLQTable(d); dumptable = 0; }
                                else Log("Received unhandled signal - continuing"); 
                                }
-                       else
-                               {
-                               LogErr("ListenForUpdates", "select"); return -1;
-                               }
+                       else { LogErr("ListenForUpdates", "select"); return -1; }
                        }
-               else if (nfds)
+               else
                        {
                        if (FD_ISSET(d->tcpsd, &rset)) RecvTCPRequest(d->tcpsd, d);
                        if (FD_ISSET(d->udpsd, &rset)) RecvUDPRequest(d->udpsd, d); 
                        if (FD_ISSET(d->LLQEventListenSock, &rset))
                                {
                                // clear signalling data off socket
-                               char buf[256];
-                               recv(d->LLQEventListenSock, buf, 256, 0);
-                               if (!EventsPending)
-                                       {
-                                       EventsPending = mDNStrue;
-                                       if (gettimeofday(&EventTS, NULL)) { LogErr("ListenForUpdates", "gettimeofday"); return -1; }                                    
-                                       }
+                               char buf[32];
+                               recv(d->LLQEventListenSock, buf, 32, 0);
+                               GenLLQEvents(d);
                                }
                        }
-               else
-                       {
-                       // timeout
-                       if (EventsPending) { GenLLQEvents(d); EventsPending = mDNSfalse; }
-                       else { DeleteRecords(d, mDNSfalse); tablecheck.tv_sec = 0; }
-                       }
                }
        return 0;
        }
@@ -2217,26 +2076,17 @@ mDNSlocal void HndlSignal(int sig)
 
 int main(int argc, char *argv[])
        {
+       pthread_t LLQtid;
        DaemonInfo *d;
-       struct rlimit rlim;
-       
+
        d = malloc(sizeof(*d));
        if (!d) { LogErr("main", "malloc"); exit(1); }
-       bzero(d, sizeof(DaemonInfo));   
+       bzero(d, sizeof(DaemonInfo));
        
        if (signal(SIGTERM,     HndlSignal) == SIG_ERR) perror("Can't catch SIGTERM");
        if (signal(INFO_SIGNAL, HndlSignal) == SIG_ERR) perror("Can't catch SIGINFO");
        if (signal(SIGINT,      HndlSignal) == SIG_ERR) perror("Can't catch SIGINT");
        if (signal(SIGPIPE,     SIG_IGN  )  == SIG_ERR) perror("Can't ignore SIGPIPE");
-
-       // remove open file limit
-       rlim.rlim_max = RLIM_INFINITY;
-       rlim.rlim_cur = RLIM_INFINITY;
-       if (setrlimit(RLIMIT_NOFILE, &rlim) < 0)
-               {
-               LogErr("main", "setrlimit");
-               Log("Using default file descriptor resource limit");
-               }
        
        if (ProcessArgs(argc, argv, d) < 0) exit(1);
 
@@ -2253,8 +2103,14 @@ int main(int argc, char *argv[])
        if (InitLeaseTable(d) < 0) exit(1);
        if (SetupSockets(d) < 0) exit(1); 
        if (SetUpdateSRV(d) < 0) exit(1);
-
-       ListenForUpdates(d);
+       
+       if (pthread_create(&LLQtid, NULL, LLQEventMonitor, d)) { LogErr("main", "pthread_create"); }    
+       else
+               {
+               pthread_detach(LLQtid);
+               ListenForUpdates(d);
+               }
+               
        if (ClearUpdateSRV(d) < 0) exit(1);  // clear update srv's even if ListenForUpdates or pthread_create returns an error
        free(d);
        exit(0);
index 4b0ab0b3d496417b01fed71721ba779eefb2287a..afa9a8003f5eb22dbff4fa9baf3e393811fe7c5d 100755 (executable)
@@ -2,24 +2,17 @@
  *
  * 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@
  *
  * Formatting notes:
  * This code follows the "Whitesmiths style" C indentation rules. Plenty of discussion
        Change History (most recent first):
 
 $Log: mDNSPosix.c,v $
+Revision 1.78.2.1  2006/08/29 06:24:34  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.78  2006/06/28 09:12:22  cheshire
+Added debugging message
+
+Revision 1.77  2006/03/19 02:00:11  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
+Revision 1.76  2006/01/09 19:29:16  cheshire
+<rdar://problem/4403128> Cap number of "sendto failed" messages we allow mDNSResponder to log
+
 Revision 1.75  2006/01/05 22:04:57  cheshire
 <rdar://problem/4399479> Log error message when send fails with "operation not permitted"
 
@@ -447,15 +452,20 @@ mDNSexport mStatus mDNSPlatformSendUDP(const mDNS *const m, const void *const ms
        if      (err > 0) err = 0;
        else if (err < 0)
                {
+               static int MessageCount = 0;
         // Don't report EHOSTDOWN (i.e. ARP failure), ENETDOWN, or no route to host for unicast destinations
                if (!mDNSAddressIsAllDNSLinkGroup(dst))
                        if (errno == EHOSTDOWN || errno == ENETDOWN || errno == EHOSTUNREACH || errno == ENETUNREACH) return(mStatus_TransientErr);
 
-               if (thisIntf)
-                       LogMsg("mDNSPlatformSendUDP got error %d (%s) sending packet to %#a on interface %#a/%s/%d",
-                                                 errno, strerror(errno), dst, &thisIntf->coreIntf.ip, thisIntf->intfName, thisIntf->index);
-               else
-                       LogMsg("mDNSPlatformSendUDP got error %d (%s) sending packet to %#a", errno, strerror(errno), dst);
+               if (MessageCount < 1000)
+                       {
+                       MessageCount++;
+                       if (thisIntf)
+                               LogMsg("mDNSPlatformSendUDP got error %d (%s) sending packet to %#a on interface %#a/%s/%d",
+                                                         errno, strerror(errno), dst, &thisIntf->coreIntf.ip, thisIntf->intfName, thisIntf->index);
+                       else
+                               LogMsg("mDNSPlatformSendUDP got error %d (%s) sending packet to %#a", errno, strerror(errno), dst);
+                       }
                }
 
        return PosixErrorToStatus(err);
@@ -681,7 +691,7 @@ mDNSlocal PosixNetworkInterface *SearchForInterfaceByName(mDNS *const m, const c
        return intf;
        }
 
-mDNSexport mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(const mDNS *const m, mDNSu32 index)
+mDNSexport mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(mDNS *const m, mDNSu32 index)
        {
        PosixNetworkInterface *intf;
 
@@ -696,7 +706,7 @@ mDNSexport mDNSInterfaceID mDNSPlatformInterfaceIDfromInterfaceIndex(const mDNS
        return (mDNSInterfaceID) intf;
        }
        
-mDNSexport mDNSu32 mDNSPlatformInterfaceIndexfromInterfaceID(const mDNS *const m, mDNSInterfaceID id)
+mDNSexport mDNSu32 mDNSPlatformInterfaceIndexfromInterfaceID(mDNS *const m, mDNSInterfaceID id)
        {
        PosixNetworkInterface *intf;
 
@@ -732,7 +742,7 @@ mDNSlocal void ClearInterfaceList(mDNS *const m)
        while (m->HostInterfaces)
                {
                PosixNetworkInterface *intf = (PosixNetworkInterface*)(m->HostInterfaces);
-               mDNS_DeregisterInterface(m, &intf->coreIntf);
+               mDNS_DeregisterInterface(m, &intf->coreIntf, mDNSfalse);
                if (gMDNSPlatformPosixVerboseLevel > 0) fprintf(stderr, "Deregistered interface %s\n", intf->intfName);
                FreePosixNetworkInterface(intf);
                }
@@ -884,6 +894,7 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
                        {
                        imr6.ipv6mr_multiaddr       = *(const struct in6_addr*)&AllDNSLinkGroupv6;
                        imr6.ipv6mr_interface       = interfaceIndex;
+                       //LogMsg("Joining %.16a on %d", &imr6.ipv6mr_multiaddr, imr6.ipv6mr_interface);
                        err = setsockopt(*sktPtr, IPPROTO_IPV6, IPV6_JOIN_GROUP, &imr6, sizeof(imr6));
                        if (err < 0)
                                {
@@ -1025,7 +1036,7 @@ mDNSlocal int SetupOneInterface(mDNS *const m, struct sockaddr *intfAddr, struct
 
        // The interface is all ready to go, let's register it with the mDNS core.
        if (err == 0)
-               err = mDNS_RegisterInterface(m, &intf->coreIntf, 0);
+               err = mDNS_RegisterInterface(m, &intf->coreIntf, mDNSfalse);
 
        // Clean up.
        if (err == 0)
index a5af557e543b7ad34e8cdb4ca0f4ada621545424..f62d9c30958bb9c0b5f0c636d52ac3991d33adc9 100755 (executable)
@@ -2,28 +2,24 @@
  *
  * 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: mDNSPosix.h,v $
+Revision 1.18  2006/08/14 23:24:47  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.17  2005/02/04 00:39:59  cheshire
 Move ParseDNSServers() from PosixDaemon.c to mDNSPosix.c so all Posix client layers can use it
 
index f9bd4a6e42304b21dfaf5eca7fae3847d1eab418..ad1821ca5b0ab5e832980e3b7838e5dcff664d3b 100755 (executable)
@@ -2,28 +2,28 @@
  *
  * 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: mDNSUNP.c,v $
+Revision 1.34  2006/08/14 23:24:47  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.33  2006/03/13 23:14:21  cheshire
+<rdar://problem/4427969> Compile problems on FreeBSD
+Use <netinet/in_var.h> instead of <netinet6/in6_var.h>
+
 Revision 1.32  2005/12/21 02:56:43  cheshire
 <rdar://problem/4243433> get_ifi_info() should fake ifi_index when SIOCGIFINDEX undefined
 
@@ -169,7 +169,9 @@ First checkin
 #endif
 
 #if defined(AF_INET6) && HAVE_IPV6 && !HAVE_LINUX
-#include <netinet6/in6_var.h>
+#include <net/if_var.h>
+#include <netinet/in_var.h>
+// NOTE: netinet/in_var.h implicitly includes netinet6/in6_var.h for us
 #endif
 
 #if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
@@ -186,8 +188,7 @@ void plen_to_mask(int plen, char *addr) {
                if(plen>bits_in_block) ones_in_block=bits_in_block;
                else                   ones_in_block=plen;
                block = ones & (ones << (bits_in_block-ones_in_block));
-               i==0 ? sprintf(addr, "%x", block) :
- sprintf(addr, "%s:%x", addr, block);
+               i==0 ? sprintf(addr, "%x", block) : sprintf(addr, "%s:%x", addr, block);
                plen -= ones_in_block;
                }
        }
index 912c9d8ff1a75c3ed7547b2114e1e4c2e693954b..d0d75c4e16d4ae30e402423d7f2d0ca8d5a64a1b 100755 (executable)
@@ -2,28 +2,24 @@
  *
  * 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: mDNSUNP.h,v $
+Revision 1.19  2006/08/14 23:24:47  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.18  2005/04/08 21:37:57  ksekar
 <rdar://problem/3792767> get_ifi_info doesn't return IPv6 interfaces on Linux
 
index ad06e0163a67b87f366392594493eb5f15c8906f..d8b8ef40a184b1a889ec1885225f7f5e5fdb6e15 100644 (file)
@@ -1,28 +1,32 @@
 #!/bin/sh
+# Emacs settings: -*- tab-width: 4 -*-
 #
-# Linux /etc/init.d script to start/stop the mdnsd daemon.
-# Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
+# Copyright (c) 2002-2006 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@
+#
+# Linux /etc/init.d script to start/stop the mdnsd daemon.
 #
 # $Log: mdnsd.sh,v $
+# Revision 1.9  2006/09/05 20:00:14  cheshire
+# Moved Emacs settings to second line of file
+#
+# Revision 1.8  2006/08/29 16:42:01  mkrochma
+# Fix POSIX startup script
+#
+# Revision 1.7  2006/08/14 23:24:47  cheshire
+# Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+#
 # Revision 1.6  2004/12/07 20:30:45  cheshire
 # Fix start-stop-daemon for Suse Linux (don't use -s TERM)
 #
index 35e02fccad407574602b2eba0570c2f97d0d4d53..651a30d001520cc80ac752170dec23bf37528cd2 100755 (executable)
@@ -155,7 +155,7 @@ format_reverse_addr_in (
 
 /*
        Format an address structure as a string appropriate for DNS reverse (PTR)
-       lookup for AF_INET6.  Output is in .ip6.int domain.
+       lookup for AF_INET6.  Output is in .ip6.arpa domain.
        
        Parameters
                prefixlen
@@ -491,22 +491,6 @@ const int MDNS_VERBOSE = 0;
 #define k_aliases_max 15
 #define k_addrs_max 15
 
-const int k_mdnsd_intfs_local = 0;
-       // Tell mdnsd to perform lookups only using link-local interfaces.
-       /*
-               Currently, this feature is buggy.  0 will actually cause mdnsd to
-               do what it thinks is best.  Unfortunately, this is to lookup 'local'
-               addresses locally and remote addresses via the DNS.  Thus, lookups
-               for non-"local" addresses via mdns will not work correctly.
-               
-               Apple is currently modifying mdnsd to allow a special interface id
-               (expected value -2) to mean "always lookup locally".  This constant
-               should be changed once the change is made.
-               
-               AW - 16 June 2004
-        */
-
-
 typedef struct buf_header
 {
        char hostname [k_hostname_maxlen + 1];
@@ -879,13 +863,13 @@ mdns_lookup_name (
        switch (af)
        {
          case AF_INET:
-               rrtype = T_A;
+               rrtype = kDNSServiceType_A;
                result->hostent->h_length = 4;
                        // Length of an A record
                break;
        
          case AF_INET6:
-               rrtype = T_AAAA;
+               rrtype = kDNSServiceType_AAAA;
                result->hostent->h_length = 16;
                        // Length of an AAAA record
                break;
@@ -902,11 +886,11 @@ mdns_lookup_name (
        errcode =
                DNSServiceQueryRecord (
                        &sdref,
-                       0,              // reserved flags field
-                       k_mdnsd_intfs_local,    // all local interfaces
+                       kDNSServiceFlagsForceMulticast,         // force multicast query
+                       kDNSServiceInterfaceIndexAny,   // all interfaces
                        fullname,       // full name to query for
                        rrtype,         // resource record type
-                       C_IN,   // internet class records
+                       kDNSServiceClass_IN,    // internet class records
                        mdns_lookup_callback,   // callback
                        result          // Context - result buffer
                );
@@ -977,11 +961,11 @@ mdns_lookup_addr (
        errcode =
                DNSServiceQueryRecord (
                        &sdref,
-                       0,              // reserved flags field
-                       k_mdnsd_intfs_local,    // all local interfaces
+                       kDNSServiceFlagsForceMulticast,         // force multicast query
+                       kDNSServiceInterfaceIndexAny,   // all interfaces
                        addr_str,       // address string to query for
-                       T_PTR,  // pointer RRs
-                       C_IN,   // internet class records
+                       kDNSServiceType_PTR,    // pointer RRs
+                       kDNSServiceClass_IN,    // internet class records
                        mdns_lookup_callback,   // callback
                        result          // Context - result buffer
                );
@@ -1121,7 +1105,7 @@ mdns_lookup_callback
                }
                
                // If a PTR
-               if (rrtype == T_PTR)
+               if (rrtype == kDNSServiceType_PTR)
                {
                        if (callback_body_ptr (fullname, result, rdlen, rdata) < 0)
                                return;
@@ -1711,8 +1695,14 @@ const char * k_default_domains [] =
        {
                "local",
                "254.169.in-addr.arpa",
-               "0.8.e.f.ip6.int",
-               "0.8.e.f.ip6.arpa",
+               "8.e.f.ip6.int",
+               "8.e.f.ip6.arpa",
+               "9.e.f.ip6.int",
+               "9.e.f.ip6.arpa",
+               "a.e.f.ip6.int",
+               "a.e.f.ip6.arpa",
+               "b.e.f.ip6.int",
+               "b.e.f.ip6.arpa",
                NULL
                        // Always null terminated
        };
@@ -2281,10 +2271,10 @@ rr_to_af (ns_type_t rrtype)
 {
        switch (rrtype)
        {
-         case T_A:
+         case kDNSServiceType_A:
                return AF_INET;
        
-         case T_AAAA:
+         case kDNSServiceType_AAAA:
                return AF_INET6;
        
          default:
@@ -2299,10 +2289,10 @@ af_to_rr (int af)
        switch (af)
        {
          case AF_INET:
-               return T_A;
+               return kDNSServiceType_A;
        
          case AF_INET6:
-               return T_AAAA;
+               return kDNSServiceType_AAAA;
        
          default:
                //return ns_t_invalid;
@@ -2423,9 +2413,9 @@ format_reverse_addr_in6 (
                // divide prefixlen into nibbles, rounding up
 
        // Special handling for first
-       if (i / 2)
+       if (i % 2)
        {
-               curr += sprintf (curr, "%d.", (in_addr_a [i] >> 4) & 0x0F);
+               curr += sprintf (curr, "%d.", (in_addr_a [i/2] >> 4) & 0x0F);
        }
        i >>= 1;
                // Convert i to bytes (divide by 2)
index 8f9b309fb73035f978953fbbcae244e5f5d1cc9b..bdcdad7c771b92ae8faf1d8b617ef51c1ffe57af 100755 (executable)
@@ -2,6 +2,12 @@
 
 # Applicable domains
 domain local
-domain 0.8.e.f.ip6.int
-domain 0.8.e.f.ip6.arpa
 domain 254.169.in-addr.arpa
+domain 8.e.f.ip6.int
+domain 9.e.f.ip6.int
+domain a.e.f.ip6.int
+domain b.e.f.ip6.int
+domain 8.e.f.ip6.arpa
+domain 9.e.f.ip6.arpa
+domain a.e.f.ip6.arpa
+domain b.e.f.ip6.arpa
index ac14fc57f08c200c92ddfce74fcfe22c8b1e2a80..b58289f30573100f143dba7597c3d65d7d5ef7bf 100755 (executable)
@@ -1,29 +1,23 @@
 #!/usr/bin/python
-
-# parselog.py, written and contributed by Kevin Marks
+# Emacs settings: -*- tab-width: 4 -*-
 #
 # Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
 #
-# @APPLE_LICENSE_HEADER_START@
-#
-# 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.
-#
-# 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
+# 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
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# 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@
+# parselog.py, written and contributed by Kevin Marks
 #
-# Requires OS X 10.3 Panther for Python and Core Graphics Python APIs
+# Requires OS X 10.3 Panther or later, for Python and Core Graphics Python APIs
 # Invoke from the command line with "parselog.py fname" where fname is a log file made by mDNSNetMonitor
 #
 # Caveats:
 # Filled green  circle: Normal answer             Hollow green  circle: Goodbye message (record going away)
 #                                                 Hollow blue   circle: Legacy query (from old client)
 # $Log: parselog.py,v $
+# Revision 1.4  2006/09/05 20:00:14  cheshire
+# Moved Emacs settings to second line of file
+#
+# Revision 1.3  2006/08/14 23:24:47  cheshire
+# Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+#
 # Revision 1.2  2003/12/01 21:47:44  cheshire
 # APSL
 #
diff --git a/mDNSShared/CommonServices.h b/mDNSShared/CommonServices.h
new file mode 100644 (file)
index 0000000..beaab56
--- /dev/null
@@ -0,0 +1,1504 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
+ *
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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.
+
+    Change History (most recent first):
+    
+$Log: CommonServices.h,v $
+Revision 1.3.4.1  2006/08/29 06:24:36  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.3  2004/04/08 09:27:12  bradley
+Added macro for portable specification of callback calling conventions.
+
+Revision 1.2  2004/03/07 05:53:39  bradley
+Fixed NumVersion extraction macros. Updated error code mappings to match latest internal version.
+
+Revision 1.1  2004/01/30 02:25:59  bradley
+Common Services and portability support for various platforms.
+
+*/
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @header         CommonServices
+       
+       Common Services for Mac OS X, Linux, Palm, VxWorks, Windows, and Windows CE.
+*/
+
+#ifndef        __COMMON_SERVICES__
+#define        __COMMON_SERVICES__
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+#if 0
+#pragma mark == Target ==
+#endif
+
+//===========================================================================================================================
+//      Target
+//===========================================================================================================================
+
+// Macintosh
+
+#if( !defined( TARGET_OS_MAC ) )
+       #if( ( macintosh || __MACH__ ) && !KERNEL )
+               // ConditionalMacros.h in CoreServices will define this TARGET_* flag.
+       #else
+               #define TARGET_OS_MAC                   0
+       #endif
+#endif
+
+#if( !defined( TARGET_API_MAC_OSX_KERNEL ) )
+       #if( __MACH__ && KERNEL )
+               #define TARGET_API_MAC_OSX_KERNEL               1
+       #else
+               #define TARGET_API_MAC_OSX_KERNEL               0
+       #endif
+#endif
+
+// Linux
+
+#if( !defined( TARGET_OS_LINUX ) )
+       #if( defined( __linux__ ) )
+               #define TARGET_OS_LINUX                 1
+       #else
+               #define TARGET_OS_LINUX                 0
+       #endif
+#endif
+
+// Palm
+
+#if( !defined( TARGET_OS_PALM ) )
+       #if( defined( __PALMOS_TRAPS__ ) || defined( __PALMOS_ARMLET__ ) )
+               #define TARGET_OS_PALM                  1
+       #else
+               #define TARGET_OS_PALM                  0
+       #endif
+#endif
+
+// VxWorks
+
+#if( !defined( TARGET_OS_VXWORKS ) )
+       
+       // No predefined macro for VxWorks so just assume VxWorks if nothing else is set.
+       
+       #if( !macintosh && !__MACH__  && !defined( __linux__ ) && !defined( __PALMOS_TRAPS__ ) && !defined( __PALMOS_ARMLET__ ) && !defined( _WIN32 ) )
+               #define TARGET_OS_VXWORKS               1
+       #else
+               #define TARGET_OS_VXWORKS               0
+       #endif
+#endif
+
+// Windows
+
+#if( !defined( TARGET_OS_WIN32 ) )
+       #if( macintosh || __MACH__ )
+               // ConditionalMacros.h in CoreServices will define this TARGET_* flag.
+       #else                   
+               #if( defined( _WIN32 ) )
+                       #define TARGET_OS_WIN32         1
+               #else
+                       #define TARGET_OS_WIN32         0
+               #endif
+       #endif
+#endif
+
+// Windows CE
+
+#if( !defined( TARGET_OS_WINDOWS_CE ) )
+       #if( defined( _WIN32_WCE ) )
+               #define TARGET_OS_WINDOWS_CE    1
+       #else
+               #define TARGET_OS_WINDOWS_CE    0
+       #endif
+#endif
+
+#if 0
+#pragma mark == Includes ==
+#endif
+
+//===========================================================================================================================
+//      Includes
+//===========================================================================================================================
+
+#if( !KERNEL )
+       #include        <stddef.h>
+#endif
+       
+#if( ( macintosh || __MACH__ ) && !KERNEL )
+               
+       #if( defined( __MWERKS__ ) )
+               #if( __option( c9x ) )
+                       #include        <stdbool.h>
+               #endif
+       #else
+               #include        <stdbool.h>
+       #endif
+       
+       #include        <stdint.h>
+       
+       #if( __MACH__ )
+               
+               // Mac OS X
+               
+               #include        <sys/types.h>
+               #include        <netinet/in.h>
+               #include        <arpa/inet.h>
+               #include        <fcntl.h>
+               #include        <pthread.h>
+               #include        <sys/ioctl.h>
+               #include        <sys/socket.h>
+               #include        <unistd.h>
+               
+               #include        <CoreServices/CoreServices.h>
+       
+       #else
+               
+               // Classic Mac OS
+               
+               #include        <ConditionalMacros.h>
+               #include        <MacTypes.h>
+       
+       #endif
+       
+#elif( KERNEL )
+       
+       // Mac OS X Kernel
+       
+       #include        <stdint.h>
+       
+       #include        <libkern/OSTypes.h>
+       #include        <sys/types.h>
+       
+#elif( TARGET_OS_LINUX )
+       
+       // Linux (no special includes yet).
+
+#elif( TARGET_OS_PALM )
+       
+       // Palm (no special includes yet).
+
+#elif( TARGET_OS_VXWORKS )
+       
+       // VxWorks
+       
+       #include        "vxWorks.h"
+       
+#elif( TARGET_OS_WIN32 )
+       
+       // Windows
+       
+       #if( !defined( WIN32_WINDOWS ) )
+               #define WIN32_WINDOWS           0x0401
+       #endif
+       
+       #if( !defined( _WIN32_WINDOWS ) )
+               #define _WIN32_WINDOWS          0x0401
+       #endif
+       
+       #if( !defined( WIN32_LEAN_AND_MEAN ) )
+               #define WIN32_LEAN_AND_MEAN                     // Needed to avoid redefinitions by Windows interfaces.
+       #endif
+       
+       #if( defined( __MWERKS__ ) )
+       
+               #if( __option( c9x ) )
+                       #include        <stdbool.h>
+               #endif
+               
+               #include        <stdint.h>
+               
+       #elif( defined( _MSC_VER ) )
+       
+               #pragma warning( disable:4127 )         // Disable "conditional expression is constant" warning for debug macros.
+               #pragma warning( disable:4706 )         // Disable "assignment within conditional expression" for Microsoft headers.
+               
+       #endif
+
+       #include        <windows.h>
+       #include        <winsock2.h>
+       #include        <Ws2tcpip.h>
+       
+       #if( defined( _MSC_VER ) )
+               #pragma warning( default:4706 )
+       #endif
+       
+#else
+       #error unknown OS - update this file to support your OS
+#endif
+
+#if( !defined( TARGET_BUILD_MAIN ) )
+       #if( !TARGET_OS_VXWORKS )
+               #define TARGET_BUILD_MAIN               1
+       #endif
+#endif
+
+#if( __GNUC__ || !TARGET_OS_VXWORKS )
+       #define TARGET_LANGUAGE_C_LIKE          1
+#else
+       #define TARGET_LANGUAGE_C_LIKE          0
+#endif
+
+#if 0
+#pragma mark == CPU ==
+#endif
+
+//===========================================================================================================================
+//     CPU
+//===========================================================================================================================
+
+// PowerPC
+
+#if( !defined( TARGET_CPU_PPC ) )
+       #if( defined( __ppc__ ) || defined( __PPC__ ) || defined( powerpc ) || defined( ppc ) || defined( _M_MPPC ) )
+               #define TARGET_CPU_PPC                          1
+       #else
+               #define TARGET_CPU_PPC                          0
+       #endif
+#endif
+
+// x86
+
+#if( !defined( TARGET_CPU_X86 ) )
+       #if( __INTEL__ || defined( __i386__ ) || defined( i386 ) || defined( intel ) || defined( _M_IX86 ) )
+               #define TARGET_CPU_X86                          1
+       #else
+               #define TARGET_CPU_X86                          0
+       #endif
+#endif
+
+// MIPS
+
+#if( !defined( TARGET_CPU_MIPS ) )
+       #if( __MIPS__ || defined( MIPS32 ) || defined( R3000 ) || defined( R4000 ) || defined( R4650 ) || defined( _M_MRX000 ) )
+               #define TARGET_CPU_MIPS                         1
+       #else
+               #define TARGET_CPU_MIPS                         0
+       #endif
+#endif
+
+#if( !defined( TARGET_CPU_PPC ) && !defined( TARGET_CPU_X86 ) && !defined( TARGET_CPU_MIPS ) )
+       #error unknown CPU - update this file to support your CPU
+#endif
+
+#if 0
+#pragma mark == Byte Order ==
+#endif
+
+//===========================================================================================================================
+//     Byte Order
+//===========================================================================================================================
+
+// TARGET_RT_LITTLE_ENDIAN
+
+#if( !defined( TARGET_RT_LITTLE_ENDIAN ) )
+       #if( MIPSEL || IL_LITTLE_ENDIAN || defined( __LITTLE_ENDIAN__ )                                                                                 || \
+                ( defined(   BYTE_ORDER ) && defined(   LITTLE_ENDIAN ) && (   BYTE_ORDER ==   LITTLE_ENDIAN ) )       || \
+                ( defined(  _BYTE_ORDER ) && defined(  _LITTLE_ENDIAN ) && (  _BYTE_ORDER ==  _LITTLE_ENDIAN ) )       || \
+                ( defined( __BYTE_ORDER ) && defined( __LITTLE_ENDIAN ) && ( __BYTE_ORDER == __LITTLE_ENDIAN ) )       || \
+                TARGET_CPU_X86 || ( defined( TARGET_RT_BIG_ENDIAN ) && !TARGET_RT_BIG_ENDIAN ) )
+               #define TARGET_RT_LITTLE_ENDIAN         1
+       #else
+               #define TARGET_RT_LITTLE_ENDIAN         0
+       #endif
+#endif
+
+// TARGET_RT_BIG_ENDIAN
+
+#if( !defined( TARGET_RT_BIG_ENDIAN ) )
+       #if( MIPSEB || IL_BIG_ENDIAN || defined( __BIG_ENDIAN__ )                                                                               || \
+                ( defined(   BYTE_ORDER ) && defined(   BIG_ENDIAN ) && (   BYTE_ORDER ==   BIG_ENDIAN ) )     || \
+                ( defined(  _BYTE_ORDER ) && defined(  _BIG_ENDIAN ) && (  _BYTE_ORDER ==  _BIG_ENDIAN ) )     || \
+                ( defined( __BYTE_ORDER ) && defined( __BIG_ENDIAN ) && ( __BYTE_ORDER == __BIG_ENDIAN ) )     || \
+               ( defined( TARGET_RT_LITTLE_ENDIAN ) && !TARGET_RT_LITTLE_ENDIAN ) )
+               #define TARGET_RT_BIG_ENDIAN            1
+       #else
+               #define TARGET_RT_BIG_ENDIAN            0
+       #endif
+#endif
+
+#if( defined( TARGET_RT_LITTLE_ENDIAN ) && !defined( TARGET_RT_BIG_ENDIAN ) )
+       #if( TARGET_RT_LITTLE_ENDIAN )
+               #define TARGET_RT_BIG_ENDIAN            0
+       #else
+               #define TARGET_RT_BIG_ENDIAN            1
+       #endif
+#endif
+
+#if( defined( TARGET_RT_BIG_ENDIAN ) && !defined( TARGET_RT_LITTLE_ENDIAN ) )
+       #if( TARGET_RT_BIG_ENDIAN )
+               #define TARGET_RT_LITTLE_ENDIAN         0
+       #else
+               #define TARGET_RT_LITTLE_ENDIAN         1
+       #endif
+#endif
+
+#if( !defined( TARGET_RT_LITTLE_ENDIAN ) || !defined( TARGET_RT_BIG_ENDIAN ) )
+       #error unknown byte order - update this file to support your byte order
+#endif
+
+// TARGET_RT_BYTE_ORDER
+
+#if( !defined( TARGET_RT_BYTE_ORDER_BIG_ENDIAN ) )
+       #define TARGET_RT_BYTE_ORDER_BIG_ENDIAN                 1234
+#endif
+
+#if( !defined( TARGET_RT_BYTE_ORDER_LITTLE_ENDIAN ) )
+       #define TARGET_RT_BYTE_ORDER_LITTLE_ENDIAN              4321
+#endif
+
+#if( !defined( TARGET_RT_BYTE_ORDER ) )
+       #if( TARGET_RT_LITTLE_ENDIAN )
+               #define TARGET_RT_BYTE_ORDER                            TARGET_RT_BYTE_ORDER_LITTLE_ENDIAN
+       #else
+               #define TARGET_RT_BYTE_ORDER                            TARGET_RT_BYTE_ORDER_BIG_ENDIAN
+       #endif
+#endif
+
+#if 0
+#pragma mark == Constants ==
+#endif
+
+//===========================================================================================================================
+//     Constants
+//===========================================================================================================================
+
+#if( !TARGET_OS_MAC )
+       #define CR              '\r'
+#endif
+
+#define LF                     '\n'
+#define        CRSTR           "\r"
+#define        LFSTR           "\n"
+#define CRLF           "\r\n"
+#define CRCR           "\r\r"
+
+#if 0
+#pragma mark == Compatibility ==
+#endif
+
+//===========================================================================================================================
+//     Compatibility
+//===========================================================================================================================
+
+// Macros to allow the same code to work on Windows and other sockets API-compatible platforms.
+
+#if( TARGET_OS_WIN32 )
+       #define close_compat( X )               closesocket( X )
+       #define errno_compat()                  (int) GetLastError()
+       #define set_errno_compat( X )   SetLastError( X )
+       #define EWOULDBLOCK_compat              WSAEWOULDBLOCK
+       #define ETIMEDOUT_compat                WSAETIMEDOUT
+       #define ENOTCONN_compat                 WSAENOTCONN
+       #define IsValidSocket( X )              ( ( X ) != INVALID_SOCKET )
+       #define kInvalidSocketRef               INVALID_SOCKET
+       #if( TARGET_LANGUAGE_C_LIKE )
+               typedef SOCKET                          SocketRef;
+       #endif
+#else
+       #define close_compat( X )               close( X )
+       #define errno_compat()                  errno
+       #define set_errno_compat( X )   do { errno = ( X ); } while( 0 )
+       #define EWOULDBLOCK_compat              EWOULDBLOCK
+       #define ETIMEDOUT_compat                ETIMEDOUT
+       #define ENOTCONN_compat                 ENOTCONN
+       #define IsValidSocket( X )              ( ( X ) >= 0 )
+       #define kInvalidSocketRef               -1
+       #if( TARGET_LANGUAGE_C_LIKE )
+               typedef int                                     SocketRef;
+       #endif
+#endif
+
+// socklen_t is not defined on the following platforms so emulate it if not defined:
+// 
+// - Pre-Panther Mac OS X. Panther defines SO_NOADDRERR so trigger off that.
+// - Windows SDK prior to 2003. 2003+ SDK's define EAI_AGAIN so trigger off that.
+// - VxWorks
+
+#if( TARGET_LANGUAGE_C_LIKE )
+       #if( ( TARGET_OS_MAC && !defined( SO_NOADDRERR ) ) || ( TARGET_OS_WIN32 && !defined( EAI_AGAIN ) ) || TARGET_OS_VXWORKS )
+               typedef int                                             socklen_t;
+       #endif
+#endif
+
+// ssize_t is not defined on the following platforms so emulate it if not defined:
+// 
+// - Mac OS X when not building with BSD headers
+// - Windows
+
+#if( TARGET_LANGUAGE_C_LIKE )
+       #if( ( TARGET_OS_WIN32 || !defined( _BSD_SSIZE_T_DEFINED_ ) ) && !TARGET_OS_VXWORKS )
+               typedef int                                             ssize_t;
+       #endif
+#endif
+
+// sockaddr_storage is not supported on non-IPv6 machines so alias it to an IPv4-compatible structure.
+
+#if( TARGET_LANGUAGE_C_LIKE )
+       #if( !defined( AF_INET6 ) )
+               #define sockaddr_storage                sockaddr_in
+               #define ss_family                               sin_family
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        SOCKADDR_IS_IP_LOOPBACK
+       
+       @abstract       Determines if a sockaddr is an IPv4 or IPv6 loopback address (if IPv6 is supported).
+*/
+
+#if( defined( AF_INET6 ) )
+       #define SOCKADDR_IS_IP_LOOPBACK( SA )                                                                                                                   \
+               ( ( (const struct sockaddr *)( SA ) )->sa_family == AF_INET )                                                           \
+               ? ( ( (const struct sockaddr_in *)( SA ) )->sin_addr.s_addr == htonl( INADDR_LOOPBACK ) )       \
+               : ( ( (const struct sockaddr *)( SA ) )->sa_family == AF_INET6 )                                                        \
+                       ? IN6_IS_ADDR_LOOPBACK( &( (const struct sockaddr_in6 *)( SA ) )->sin6_addr )                   \
+                       : 0
+#else
+       #define SOCKADDR_IS_IP_LOOPBACK( SA )                                                                                                                   \
+               ( ( (const struct sockaddr *)( SA ) )->sa_family == AF_INET )                                                           \
+               ? ( ( (const struct sockaddr_in *)( SA ) )->sin_addr.s_addr == htonl( INADDR_LOOPBACK ) )       \
+               : 0
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        SOCKADDR_IS_IP_LINK_LOCAL
+       
+       @abstract       Determines if a sockaddr is an IPv4 or IPv6 link-local address (if IPv6 is supported).
+*/
+
+#if( defined( AF_INET6 ) )
+       #define SOCKADDR_IS_IP_LINK_LOCAL( SA )                                                                                                                         \
+               ( ( ( (const struct sockaddr *)( SA ) )->sa_family == AF_INET )                                                                 \
+                 ? ( ( ( (uint8_t *)( &( (const struct sockaddr_in *)( SA ) )->sin_addr ) )[ 0 ] == 169 ) &&   \
+                         ( ( (uint8_t *)( &( (const struct sockaddr_in *)( SA ) )->sin_addr ) )[ 1 ] == 254 ) )        \
+                 : IN6_IS_ADDR_LOOPBACK( &( (const struct sockaddr_in6 *)( SA ) )->sin6_addr ) )
+#else
+       #define SOCKADDR_IS_IP_LINK_LOCAL( SA )                                                                                                                         \
+               ( ( ( (const struct sockaddr *)( SA ) )->sa_family == AF_INET )                                                                 \
+                 ? ( ( ( (uint8_t *)( &( (const struct sockaddr_in *)( SA ) )->sin_addr ) )[ 0 ] == 169 ) &&   \
+                         ( ( (uint8_t *)( &( (const struct sockaddr_in *)( SA ) )->sin_addr ) )[ 1 ] == 254 ) )        \
+                 : 0 )
+#endif
+
+// _beginthreadex and _endthreadex are not supported on Windows CE 2.1 or later (the C runtime issues with leaking 
+// resources have apparently been resolved and they seem to have just ripped out support for the API) so map it to 
+// CreateThread on Windows CE.
+
+#if( TARGET_OS_WINDOWS_CE )
+       #define _beginthreadex_compat( SECURITY_PTR, STACK_SIZE, START_ADDRESS, ARG_LIST, FLAGS, THREAD_ID_PTR )                        \
+               (uintptr_t) CreateThread( SECURITY_PTR, STACK_SIZE, (LPTHREAD_START_ROUTINE) START_ADDRESS, ARG_LIST, FLAGS,    \
+                                         (LPDWORD) THREAD_ID_PTR )
+       
+       #define _endthreadex_compat( RESULT )           ExitThread( (DWORD) RESULT )
+#elif( TARGET_OS_WIN32 )
+       #define _beginthreadex_compat                           _beginthreadex
+       #define _endthreadex_compat                                     _endthreadex
+#endif
+
+// The C99 "inline" keyword is not supported by Microsoft compilers, but they do support __inline so map it when needed.
+
+#if( defined( _MSC_VER ) )
+       #define inline_compat           __inline
+#else
+       #define inline_compat           inline
+#endif
+
+// Calling conventions 
+
+#if( !defined( CALLBACK_COMPAT ) )
+       #if( TARGET_OS_WIN32 || TARGET_OS_WINDOWS_CE )
+               #define CALLBACK_COMPAT         CALLBACK
+       #else
+               #define CALLBACK_COMPAT
+       #endif
+#endif
+
+#if 0
+#pragma mark == Macros ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        kSizeCString
+
+       @abstract       A meta-value to pass to supported routines to indicate the size should be calculated with strlen.
+*/
+
+#define        kSizeCString            ( (size_t) -1 )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        sizeof_array
+       
+       @abstract       Determines the number of elements in an array.
+*/
+
+#define        sizeof_array( X )               ( sizeof( X ) / sizeof( X[ 0 ] ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        sizeof_element
+       
+       @abstract       Determines the size of an array element.
+*/
+
+#define        sizeof_element( X )             sizeof( X[ 0 ] )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        sizeof_string
+       
+       @abstract       Determines the size of a constant C string, excluding the null terminator.
+*/
+
+#define        sizeof_string( X )              ( sizeof( ( X ) ) - 1 )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        sizeof_field
+       
+       @abstract       Determines the size of a field of a type.
+*/
+
+#define        sizeof_field( TYPE, FIELD )             sizeof( ( ( (TYPE *) 0 )->FIELD ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       RoundUp
+
+       @abstract       Rounds X up to a multiple of Y.
+*/
+
+#define        RoundUp( X, Y )         ( ( X ) + ( ( Y ) - ( ( X ) % ( Y ) ) ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       IsAligned
+
+       @abstract       Returns non-zero if X is aligned to a Y byte boundary and 0 if not. Y must be a power of 2.
+*/
+
+#define        IsAligned( X, Y )               ( ( ( X ) & ( ( Y ) - 1 ) ) == 0 )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       IsFieldAligned
+
+       @abstract       Returns non-zero if FIELD of type TYPE is aligned to a Y byte boundary and 0 if not. Y must be a power of 2.
+*/
+
+#define        IsFieldAligned( X, TYPE, FIELD, Y )             IsAligned( ( (uintptr_t)( X ) ) + offsetof( TYPE, FIELD ), ( Y ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       AlignDown
+
+       @abstract       Aligns X down to a Y byte boundary. Y must be a power of 2.
+*/
+
+#define        AlignDown( X, Y )               ( ( X ) & ~( ( Y ) - 1 ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       AlignUp
+
+       @abstract       Aligns X up to a Y byte boundary. Y must be a power of 2.
+*/
+
+#define        AlignUp( X, Y )         ( ( ( X ) + ( ( Y ) - 1 ) ) & ~( ( Y ) - 1 ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       Min
+
+       @abstract       Returns the lesser of X and Y.
+*/
+
+#if( !defined( Min ) )
+       #define Min( X, Y )             ( ( ( X ) < ( Y ) ) ? ( X ) : ( Y ) )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       Max
+
+       @abstract       Returns the greater of X and Y.
+*/
+
+#if( !defined( Max ) )
+       #define Max( X, Y )             ( ( ( X ) > ( Y ) ) ? ( X ) : ( Y ) )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       InsertBits
+
+       @abstract       Inserts BITS (both 0 and 1 bits) into X, controlled by MASK and SHIFT, and returns the result.
+       
+       @discussion
+       
+       MASK is the bitmask of the bits in the final position.
+       SHIFT is the number of bits to shift left for 1 to reach the first bit position of MASK.
+       
+       For example, if you wanted to insert 0x3 into the leftmost 4 bits of a 32-bit value:
+       
+       InsertBits( 0, 0x3, 0xF0000000U, 28 ) == 0x30000000
+*/
+
+#define        InsertBits( X, BITS, MASK, SHIFT )              ( ( ( X ) & ~( MASK ) ) | ( ( ( BITS ) << ( SHIFT ) ) & ( MASK ) ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       ExtractBits
+
+       @abstract       Extracts bits from X, controlled by MASK and SHIFT, and returns the result.
+       
+       @discussion
+       
+       MASK is the bitmask of the bits in the final position.
+       SHIFT is the number of bits to shift right to right justify MASK.
+       
+       For example, if you had a 32-bit value (e.g. 0x30000000) wanted the left-most 4 bits (e.g. 3 in this example):
+       
+       ExtractBits( 0x30000000U, 0xF0000000U, 28 ) == 0x3
+*/
+
+#define        ExtractBits( X, MASK, SHIFT )                   ( ( ( X ) >> ( SHIFT ) ) & ( ( MASK ) >> ( SHIFT ) ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       Stringify
+
+       @abstract       Stringify's an expression.
+       
+       @discussion
+       
+       Stringify macros to process raw text passed via -D options to C string constants. The double-wrapping is necessary 
+       because the C preprocessor doesn't perform its normal argument expansion pre-scan with stringified macros so the 
+       -D macro needs to be expanded once via the wrapper macro then stringified so the raw text is stringified. Otherwise, 
+       the replacement value would be used instead of the symbolic name (only for preprocessor symbols like #defines).
+       
+       For example:
+       
+               #define kMyConstant             1
+               
+               printf( "%s", Stringify( kMyConstant ) );                       // Prints "kMyConstant"
+               printf( "%s", StringifyExpansion( kMyConstant ) );      // Prints "1"
+               
+       Non-preprocessor symbols do not have this issue. For example:
+       
+               enum
+               {
+                       kMyConstant = 1
+               };
+               
+               printf( "%s", Stringify( kMyConstant ) );                       // Prints "kMyConstant"
+               printf( "%s", StringifyExpansion( kMyConstant ) );      // Prints "kMyConstant"
+       
+       See <http://gcc.gnu.org/onlinedocs/cpp/Argument-Prescan.html> for more info on C preprocessor pre-scanning.
+*/
+
+#define        Stringify( X )                          # X
+#define        StringifyExpansion( X )         Stringify( X )
+
+#if 0
+#pragma mark == Types ==
+#endif
+
+#if( TARGET_LANGUAGE_C_LIKE )
+//===========================================================================================================================
+//      Standard Types
+//===========================================================================================================================
+
+#if( !defined( INT8_MIN ) )
+       
+       #define INT8_MIN                                        SCHAR_MIN
+       
+       #if( defined( _MSC_VER ) )
+
+               // C99 stdint.h not supported in VC++/VS.NET yet.
+
+               typedef INT8                                    int8_t;
+               typedef UINT8                                   uint8_t;
+               typedef INT16                                   int16_t;
+               typedef UINT16                                  uint16_t;
+               typedef INT32                                   int32_t;
+               typedef UINT32                                  uint32_t;
+               typedef __int64                                 int64_t;
+               typedef unsigned __int64                uint64_t;
+               
+       #elif( TARGET_OS_VXWORKS && ( TORNADO_VERSION < 220 ) )
+               typedef long long                               int64_t;
+               typedef unsigned long long              uint64_t;
+       #endif
+       
+       typedef int8_t                                          int_least8_t;
+       typedef int16_t                                         int_least16_t;
+       typedef int32_t                                         int_least32_t;
+       typedef int64_t                                         int_least64_t;
+
+       typedef uint8_t                                         uint_least8_t;
+       typedef uint16_t                                        uint_least16_t;
+       typedef uint32_t                                        uint_least32_t;
+       typedef uint64_t                                        uint_least64_t;
+       
+       typedef int8_t                                          int_fast8_t;
+       typedef int16_t                                         int_fast16_t;
+       typedef int32_t                                         int_fast32_t;
+       typedef int64_t                                         int_fast64_t;
+       
+       typedef uint8_t                                         uint_fast8_t;
+       typedef uint16_t                                        uint_fast16_t;
+       typedef uint32_t                                        uint_fast32_t;
+       typedef uint64_t                                        uint_fast64_t;
+
+       #if( !defined( _MSC_VER ) || TARGET_OS_WINDOWS_CE )
+               typedef long int                                intptr_t;
+               typedef unsigned long int               uintptr_t;
+       #endif
+
+#endif
+
+// Macros for minimum-width integer constants
+
+#if( !defined( INT8_C ) )
+       #define INT8_C( value )                 value
+#endif
+
+#if( !defined( INT16_C ) )
+       #define INT16_C( value )                value
+#endif
+
+#if( !defined( INT32_C ) )
+       #define INT32_C( value )                value ## L
+#endif
+
+#if( !defined( INT64_C ) )
+       #if( defined( _MSC_VER ) )
+               #define INT64_C( value )        value ## i64
+       #else
+               #define INT64_C( value )        value ## LL
+       #endif
+#endif
+
+#if( !defined( UINT8_C ) )
+       #define UINT8_C( value )                value ## U
+#endif
+
+#if( !defined( UINT16_C ) )
+       #define UINT16_C( value )               value ## U
+#endif
+
+#if( !defined( UINT32_C ) )
+       #define UINT32_C( value )               value ## UL
+#endif
+
+#if( !defined( UINT64_C ) )
+       #if( defined( _MSC_VER ) )
+               #define UINT64_C( value )       value ## UI64
+       #else
+               #define UINT64_C( value )       value ## ULL
+       #endif
+#endif
+
+#if 0
+#pragma mark == bool ==
+#endif
+
+//===========================================================================================================================
+//      Boolean Constants and Types
+//===========================================================================================================================
+
+// C++ defines bool, true, and false. Metrowerks allows this to be controlled by the "bool" option though.
+// C99 defines __bool_true_false_are_defined when bool, true, and false are defined.
+// MacTypes.h defines true and false (Mac builds only).
+// 
+// Note: The Metrowerks has to be in its own block because Microsoft Visual Studio .NET does not completely 
+// short-circuit and gets confused by the option( bool ) portion of the conditional.
+
+#if( defined( __MWERKS__ ) )
+       
+       // Note: The following test is done on separate lines because CodeWarrior doesn't like it all on one line.
+       
+       #if( !__bool_true_false_are_defined && ( !defined( __cplusplus ) || !__option( bool ) ) )
+               #define COMMON_SERVICES_NEEDS_BOOL              1
+       #else
+               #define COMMON_SERVICES_NEEDS_BOOL              0
+       #endif
+       
+       // Workaround when building with CodeWarrior, but using the Apple stdbool.h header, which uses _Bool.
+       
+       #if( __bool_true_false_are_defined && !defined( __cplusplus ) && !__option( c9x ) )
+               #define _Bool   int
+       #endif
+       
+       // Workaround when building with CodeWarrior for C++ with bool disabled and using the Apple stdbool.h header, 
+       // which defines true and false to map to C++ true and false (which are not enabled). Serenity Now!
+       
+       #if( __bool_true_false_are_defined && defined( __cplusplus ) && !__option( bool ) )
+               #define true    1
+               #define false   0
+       #endif
+#else
+       #define COMMON_SERVICES_NEEDS_BOOL                      ( !defined( __cplusplus ) && !__bool_true_false_are_defined )
+#endif
+
+#if( COMMON_SERVICES_NEEDS_BOOL )
+       
+       typedef int             bool;
+       
+       #define bool    bool
+       
+       #if( !defined( __MACTYPES__ ) && !defined( true ) && !defined( false ) )
+               #define true    1
+               #define false   0
+       #endif
+       
+       #define __bool_true_false_are_defined           1
+#endif
+
+// IOKit IOTypes.h typedef's bool if TYPE_BOOL is not defined so define it here to prevent redefinition by IOTypes.h.
+
+#if( TARGET_API_MAC_OSX_KERNEL )
+       #define TYPE_BOOL               1
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @typedef        CStr255
+       
+       @abstract       255 character null-terminated (C-style) string.
+*/
+
+#if( TARGET_LANGUAGE_C_LIKE )
+       typedef char    CStr255[ 256 ];
+#endif
+
+#endif // TARGET_LANGUAGE_C_LIKE
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        TYPE_LONGLONG_NATIVE
+
+       @abstract       Defines whether long long (or its equivalent) is natively supported or requires special libraries.
+*/
+
+#if( !defined( TYPE_LONGLONG_NATIVE ) )
+       #if( !TARGET_OS_VXWORKS )
+               #define TYPE_LONGLONG_NATIVE                    1
+       #else
+               #define TYPE_LONGLONG_NATIVE                    0
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        long_long_compat
+
+       @abstract       Compatibility type to map to the closest thing to long long and unsigned long long.
+       
+       @discussion
+       
+       Neither long long nor unsigned long long are supported by Microsoft compilers, but they do support proprietary
+       "__int64" and "unsigned __int64" equivalents so map to those types if the real long long is not supported.
+*/
+
+#if( TARGET_LANGUAGE_C_LIKE )
+       #if( TARGET_OS_WIN32 )
+               typedef __int64                                 long_long_compat;
+               typedef unsigned __int64                unsigned_long_long_compat;
+       #else
+               typedef signed long long                long_long_compat;
+               typedef unsigned long long              unsigned_long_long_compat;
+       #endif
+#endif
+
+#if 0
+#pragma mark == Errors ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @enum           OSStatus
+
+       @abstract       Status Code
+       
+       @constant       kNoErr                                              0 No error occurred.
+       @constant       kInProgressErr                              1 Operation in progress.
+       @constant       kUnknownErr                                     -6700 Unknown error occurred.
+       @constant       kOptionErr                                      -6701 Option was not acceptable.
+       @constant       kSelectorErr                            -6702 Selector passed in is invalid or unknown.
+       @constant       kExecutionStateErr                      -6703 Call made in the wrong execution state (e.g. called at interrupt time).
+       @constant       kPathErr                                        -6704 Path is invalid, too long, or otherwise not usable.
+       @constant       kParamErr                                       -6705 Parameter is incorrect, missing, or not appropriate.
+       @constant       kParamCountErr                          -6706 Incorrect or unsupported number of parameters.
+       @constant       kCommandErr                                     -6707 Command invalid or not supported.
+       @constant       kIDErr                                          -6708 Unknown, invalid, or inappropriate identifier.
+       @constant       kStateErr                                       -6709 Not in appropriate state to perform operation.
+       @constant       kRangeErr                                       -6710 Index is out of range or not valid.
+       @constant       kRequestErr                                     -6711 Request was improperly formed or not appropriate.
+       @constant       kResponseErr                            -6712 Response was incorrect or out of sequence.
+       @constant       kChecksumErr                            -6713 Checksum does not match the actual data.
+       @constant       kNotHandledErr                          -6714 Operation was not handled (or not handled completely).
+       @constant       kVersionErr                                     -6715 Version is not incorrect or not compatibile.
+       @constant       kSignatureErr                           -6716 Signature did not match what was expected.
+       @constant       kFormatErr                                      -6717 Unknown, invalid, or inappropriate file/data format.
+       @constant       kNotInitializedErr                      -6718 Action request before needed services were initialized.
+       @constant       kAlreadyInitializedErr          -6719 Attempt made to initialize when already initialized.
+       @constant       kNotInUseErr                            -6720 Object not in use (e.g. cannot abort if not already in use).
+       @constant       kInUseErr                                       -6721 Object is in use (e.g. cannot reuse active param blocks).
+       @constant       kTimeoutErr                                     -6722 Timeout occurred.
+       @constant       kCanceledErr                            -6723 Operation canceled (successful cancel).
+       @constant       kAlreadyCanceledErr                     -6724 Operation has already been canceled.
+       @constant       kCannotCancelErr                        -6725 Operation could not be canceled (maybe already done or invalid).
+       @constant       kDeletedErr                                     -6726 Object has already been deleted.
+       @constant       kNotFoundErr                            -6727 Something was not found.
+       @constant       kNoMemoryErr                            -6728 Not enough memory was available to perform the operation.
+       @constant       kNoResourcesErr                         -6729 Resources unavailable to perform the operation.
+       @constant       kDuplicateErr                           -6730 Duplicate found or something is a duplicate.
+       @constant       kImmutableErr                           -6731 Entity is not changeable.
+       @constant       kUnsupportedDataErr                     -6732 Data is unknown or not supported.
+       @constant       kIntegrityErr                           -6733 Data is corrupt.
+       @constant       kIncompatibleErr                        -6734 Data is not compatible or it is in an incompatible format.
+       @constant       kUnsupportedErr                         -6735 Feature or option is not supported.
+       @constant       kUnexpectedErr                          -6736 Error occurred that was not expected.
+       @constant       kValueErr                                       -6737 Value is not appropriate.
+       @constant       kNotReadableErr                         -6738 Could not read or reading is not allowed.
+       @constant       kNotWritableErr                         -6739 Could not write or writing is not allowed.
+       @constant       kBadReferenceErr                        -6740 An invalid or inappropriate reference was specified.
+       @constant       kFlagErr                                        -6741 An invalid, inappropriate, or unsupported flag was specified.
+       @constant       kMalformedErr                           -6742 Something was not formed correctly.
+       @constant       kSizeErr                                        -6743 Size was too big, too small, or not appropriate.
+       @constant       kNameErr                                        -6744 Name was not correct, allowed, or appropriate.
+       @constant       kNotReadyErr                            -6745 Device or service is not ready.
+       @constant       kReadErr                                        -6746 Could not read.
+       @constant       kWriteErr                                       -6747 Could not write.
+       @constant       kMismatchErr                            -6748 Something does not match.
+       @constant       kDateErr                                        -6749 Date is invalid or out-of-range.
+       @constant       kUnderrunErr                            -6750 Less data than expected.
+       @constant       kOverrunErr                                     -6751 More data than expected.
+       @constant       kEndingErr                                      -6752 Connection, session, or something is ending.
+       @constant       kConnectionErr                          -6753 Connection failed or could not be established.
+       @constant       kAuthenticationErr                      -6754 Authentication failed or is not supported.
+       @constant       kOpenErr                                        -6755 Could not open file, pipe, device, etc.
+       @constant       kTypeErr                                        -6756 Incorrect or incompatible type (e.g. file, data, etc.).
+       @constant       kSkipErr                                        -6757 Items should be or was skipped.
+       @constant       kNoAckErr                                       -6758 No acknowledge.
+       @constant       kCollisionErr                           -6759 Collision occurred (e.g. two on bus at same time).
+       @constant       kBackoffErr                                     -6760 Backoff in progress and operation intentionally failed.
+       @constant       kNoAddressAckErr                        -6761 No acknowledge of address.
+       @constant       kBusyErr                                        -6762 Cannot perform because something is busy.
+       @constant       kNoSpaceErr                                     -6763 Not enough space to perform operation.
+*/
+
+#if( TARGET_LANGUAGE_C_LIKE )
+       #if( !TARGET_OS_MAC && !TARGET_API_MAC_OSX_KERNEL )
+               typedef int32_t         OSStatus;
+       #endif
+#endif
+
+#define kNoErr                                         0
+#define kInProgressErr                         1
+
+// Generic error codes are in the range -6700 to -6779.
+
+#define kGenericErrorBase                      -6700   // Starting error code for all generic errors.
+       
+#define kUnknownErr                                    -6700
+#define kOptionErr                                     -6701
+#define kSelectorErr                           -6702
+#define kExecutionStateErr                     -6703
+#define kPathErr                                       -6704
+#define kParamErr                                      -6705
+#define kParamCountErr                         -6706
+#define kCommandErr                                    -6707
+#define kIDErr                                         -6708
+#define kStateErr                                      -6709
+#define kRangeErr                                      -6710
+#define kRequestErr                                    -6711
+#define kResponseErr                           -6712
+#define kChecksumErr                           -6713
+#define kNotHandledErr                         -6714
+#define kVersionErr                                    -6715
+#define kSignatureErr                          -6716
+#define kFormatErr                                     -6717
+#define kNotInitializedErr                     -6718
+#define kAlreadyInitializedErr         -6719
+#define kNotInUseErr                           -6720
+#define kInUseErr                                      -6721
+#define kTimeoutErr                                    -6722
+#define kCanceledErr                           -6723
+#define kAlreadyCanceledErr                    -6724
+#define kCannotCancelErr                       -6725
+#define kDeletedErr                                    -6726
+#define kNotFoundErr                           -6727
+#define kNoMemoryErr                           -6728
+#define kNoResourcesErr                                -6729
+#define kDuplicateErr                          -6730
+#define kImmutableErr                          -6731
+#define kUnsupportedDataErr                    -6732
+#define kIntegrityErr                          -6733
+#define kIncompatibleErr                       -6734
+#define kUnsupportedErr                                -6735
+#define kUnexpectedErr                         -6736
+#define kValueErr                                      -6737
+#define kNotReadableErr                                -6738
+#define kNotWritableErr                                -6739
+#define        kBadReferenceErr                        -6740
+#define        kFlagErr                                        -6741
+#define        kMalformedErr                           -6742
+#define        kSizeErr                                        -6743
+#define        kNameErr                                        -6744
+#define        kNotReadyErr                            -6745
+#define        kReadErr                                        -6746
+#define        kWriteErr                                       -6747
+#define        kMismatchErr                            -6748
+#define        kDateErr                                        -6749
+#define        kUnderrunErr                            -6750
+#define        kOverrunErr                                     -6751
+#define        kEndingErr                                      -6752
+#define        kConnectionErr                          -6753
+#define        kAuthenticationErr                      -6754
+#define        kOpenErr                                        -6755
+#define        kTypeErr                                        -6756
+#define        kSkipErr                                        -6757
+#define        kNoAckErr                                       -6758
+#define        kCollisionErr                           -6759
+#define        kBackoffErr                                     -6760
+#define        kNoAddressAckErr                        -6761
+#define        kBusyErr                                        -6762
+#define        kNoSpaceErr                                     -6763
+
+#define kGenericErrorEnd                       -6779   // Last generic error code (inclusive)
+
+#if 0
+#pragma mark == Mac Compatibility ==
+#endif
+
+//===========================================================================================================================
+//     Mac Compatibility
+//===========================================================================================================================
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @enum           Duration
+       
+       @abstract       Type used to specify a duration of time.
+       
+       @constant       kDurationImmediate                      Indicates no delay/wait time.
+       @constant       kDurationMicrosecond            Microsecond units.
+       @constant       kDurationMillisecond            Millisecond units.
+       @constant       kDurationSecond                         Second units.
+       @constant       kDurationMinute                         Minute units.
+       @constant       kDurationHour                           Hour units.
+       @constant       kDurationDay                            Day units.
+       @constant       kDurationForever                        Infinite period of time (no timeout).
+
+       @discussion 
+       
+       Duration values are intended to be multiplied by the specific interval to achieve an actual duration. For example, 
+       to wait for 5 seconds you would use "5 * kDurationSecond".
+*/
+
+#if( TARGET_LANGUAGE_C_LIKE )
+       #if( !TARGET_OS_MAC )
+               typedef int32_t         Duration;
+       #endif
+#endif
+
+#define        kDurationImmediate                              0L
+#define        kDurationMicrosecond                    -1L
+#define        kDurationMillisecond                    1L
+#define        kDurationSecond                                 ( 1000L * kDurationMillisecond )
+#define        kDurationMinute                                 ( 60L * kDurationSecond )
+#define        kDurationHour                                   ( 60L * kDurationMinute )
+#define        kDurationDay                                    ( 24L * kDurationHour )
+#define        kDurationForever                                0x7FFFFFFFL
+
+// Seconds <-> Minutes <-> Hours <-> Days <-> Weeks <-> Months <-> Years conversions
+
+#define kNanosecondsPerMicrosecond             1000
+#define kNanosecondsPerMillisecond             1000000
+#define kNanosecondsPerSecond                  1000000000
+#define kMicrosecondsPerSecond                 1000000
+#define kMicrosecondsPerMillisecond            1000
+#define kMillisecondsPerSecond                 1000
+#define kSecondsPerMinute                              60
+#define kSecondsPerHour                                        ( 60 * 60 )                             // 3600
+#define kSecondsPerDay                                 ( 60 * 60 * 24 )                // 86400
+#define kSecondsPerWeek                                        ( 60 * 60 * 24 * 7 )    // 604800
+#define kMinutesPerHour                                        60
+#define kMinutesPerDay                                 ( 60 * 24 )                             // 1440
+#define kHoursPerDay                                   24
+#define kDaysPerWeek                                   7
+#define kWeeksPerYear                                  52
+#define kMonthsPerYear                                 12
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        VersionStages
+
+       @abstract       NumVersion-style version stages.
+*/
+
+#define        kVersionStageDevelopment                0x20
+#define        kVersionStageAlpha                              0x40
+#define        kVersionStageBeta                               0x60
+#define        kVersionStageFinal                              0x80
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       NumVersionBuild
+
+       @abstract       Builds a 32-bit Mac-style NumVersion value (e.g. NumVersionBuild( 1, 2, 3, kVersionStageBeta, 4 ) -> 1.2.3b4).
+*/
+
+#define        NumVersionBuild( MAJOR, MINOR, BUGFIX, STAGE, REV )     \
+       ( ( ( ( MAJOR )  & 0xFF ) << 24 ) |                                             \
+         ( ( ( MINOR )  & 0x0F ) << 20 ) |                                             \
+         ( ( ( BUGFIX ) & 0x0F ) << 16 ) |                                             \
+         ( ( ( STAGE )  & 0xFF ) <<  8 ) |                                             \
+         ( ( ( REV )    & 0xFF )       ) )
+
+#define        NumVersionExtractMajor( VERSION )                               ( (uint8_t)( ( ( VERSION ) >> 24 ) & 0xFF ) )
+#define        NumVersionExtractMinorAndBugFix( VERSION )              ( (uint8_t)( ( ( VERSION ) >> 16 ) & 0xFF ) )
+#define        NumVersionExtractMinor( VERSION )                               ( (uint8_t)( ( ( VERSION ) >> 20 ) & 0x0F ) )
+#define        NumVersionExtractBugFix( VERSION )                              ( (uint8_t)( ( ( VERSION ) >> 16 ) & 0x0F ) )
+#define        NumVersionExtractStage( VERSION )                               ( (uint8_t)( ( ( VERSION ) >>  8 ) & 0xFF ) )
+#define        NumVersionExtractRevision( VERSION )                    ( (uint8_t)(   ( VERSION )         & 0xFF ) )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       NumVersionCompare
+
+       @abstract       Compares two NumVersion values and returns the following values:
+       
+               left < right -> -1
+               left > right ->  1
+               left = right ->  0
+*/
+
+#if( TARGET_LANGUAGE_C_LIKE )
+       int     NumVersionCompare( uint32_t inLeft, uint32_t inRight );
+#endif
+
+#if 0
+#pragma mark == Binary Constants ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        binary_4
+       
+       @abstract       Macro to generate an 4-bit constant using binary notation (e.g. binary_4( 1010 ) == 0xA).
+*/
+
+#define        binary_4( a )                                           binary_4_hex_wrap( hex_digit4( a ) )
+#define binary_4_hex_wrap( a )                         binary_4_hex( a )
+#define binary_4_hex( a )                                      ( 0x ## a )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        binary_8
+       
+       @abstract       Macro to generate an 8-bit constant using binary notation (e.g. binary_8( 01111011 ) == 0x7B).
+*/
+
+#define        binary_8( a )                                           binary_8_hex_wrap( hex_digit8( a ) )
+#define binary_8_hex_wrap( a )                         binary_8_hex( a )
+#define binary_8_hex( a )                                      ( 0x ## a )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        binary_16
+       
+       @abstract       Macro to generate an 16-bit constant using binary notation (e.g. binary_16( 01111011, 01111011 ) == 0x7B7B).
+*/
+
+#define        binary_16( a, b )                                       binary_16_hex_wrap( hex_digit8( a ), hex_digit8( b ) )
+#define binary_16_hex_wrap( a, b )                     binary_16_hex( a, b )
+#define binary_16_hex( a, b )                          ( 0x ## a ## b )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        binary_32
+       
+       @abstract       Macro to generate an 32-bit constant using binary notation 
+                               (e.g. binary_32( 01111011, 01111011, 01111011, 01111011 ) == 0x7B7B7B7B).
+*/
+
+#define        binary_32( a, b, c, d )                         binary_32_hex_wrap( hex_digit8( a ), hex_digit8( b ), hex_digit8( c ), hex_digit8( d ) )
+#define binary_32_hex_wrap( a, b, c, d )       binary_32_hex( a, b, c, d )
+#define binary_32_hex( a, b, c, d )                    ( 0x ## a ## b ## c ## d )
+
+// Binary Constant Helpers
+
+#define hex_digit8( a )                                                HEX_DIGIT_ ## a
+#define hex_digit4( a )                                                HEX_DIGIT_ ## 0000 ## a
+
+#define HEX_DIGIT_00000000                                     00
+#define HEX_DIGIT_00000001                                     01
+#define HEX_DIGIT_00000010                                     02
+#define HEX_DIGIT_00000011                                     03
+#define HEX_DIGIT_00000100                                     04
+#define HEX_DIGIT_00000101                                     05
+#define HEX_DIGIT_00000110                                     06
+#define HEX_DIGIT_00000111                                     07
+#define HEX_DIGIT_00001000                                     08
+#define HEX_DIGIT_00001001                                     09
+#define HEX_DIGIT_00001010                                     0A
+#define HEX_DIGIT_00001011                                     0B
+#define HEX_DIGIT_00001100                                     0C
+#define HEX_DIGIT_00001101                                     0D
+#define HEX_DIGIT_00001110                                     0E
+#define HEX_DIGIT_00001111                                     0F
+#define HEX_DIGIT_00010000                                     10
+#define HEX_DIGIT_00010001                                     11
+#define HEX_DIGIT_00010010                                     12
+#define HEX_DIGIT_00010011                                     13
+#define HEX_DIGIT_00010100                                     14
+#define HEX_DIGIT_00010101                                     15
+#define HEX_DIGIT_00010110                                     16
+#define HEX_DIGIT_00010111                                     17
+#define HEX_DIGIT_00011000                                     18
+#define HEX_DIGIT_00011001                                     19
+#define HEX_DIGIT_00011010                                     1A
+#define HEX_DIGIT_00011011                                     1B
+#define HEX_DIGIT_00011100                                     1C
+#define HEX_DIGIT_00011101                                     1D
+#define HEX_DIGIT_00011110                                     1E
+#define HEX_DIGIT_00011111                                     1F
+#define HEX_DIGIT_00100000                                     20
+#define HEX_DIGIT_00100001                                     21
+#define HEX_DIGIT_00100010                                     22
+#define HEX_DIGIT_00100011                                     23
+#define HEX_DIGIT_00100100                                     24
+#define HEX_DIGIT_00100101                                     25
+#define HEX_DIGIT_00100110                                     26
+#define HEX_DIGIT_00100111                                     27
+#define HEX_DIGIT_00101000                                     28
+#define HEX_DIGIT_00101001                                     29
+#define HEX_DIGIT_00101010                                     2A
+#define HEX_DIGIT_00101011                                     2B
+#define HEX_DIGIT_00101100                                     2C
+#define HEX_DIGIT_00101101                                     2D
+#define HEX_DIGIT_00101110                                     2E
+#define HEX_DIGIT_00101111                                     2F
+#define HEX_DIGIT_00110000                                     30
+#define HEX_DIGIT_00110001                                     31
+#define HEX_DIGIT_00110010                                     32
+#define HEX_DIGIT_00110011                                     33
+#define HEX_DIGIT_00110100                                     34
+#define HEX_DIGIT_00110101                                     35
+#define HEX_DIGIT_00110110                                     36
+#define HEX_DIGIT_00110111                                     37
+#define HEX_DIGIT_00111000                                     38
+#define HEX_DIGIT_00111001                                     39
+#define HEX_DIGIT_00111010                                     3A
+#define HEX_DIGIT_00111011                                     3B
+#define HEX_DIGIT_00111100                                     3C
+#define HEX_DIGIT_00111101                                     3D
+#define HEX_DIGIT_00111110                                     3E
+#define HEX_DIGIT_00111111                                     3F
+#define HEX_DIGIT_01000000                                     40
+#define HEX_DIGIT_01000001                                     41
+#define HEX_DIGIT_01000010                                     42
+#define HEX_DIGIT_01000011                                     43
+#define HEX_DIGIT_01000100                                     44
+#define HEX_DIGIT_01000101                                     45
+#define HEX_DIGIT_01000110                                     46
+#define HEX_DIGIT_01000111                                     47
+#define HEX_DIGIT_01001000                                     48
+#define HEX_DIGIT_01001001                                     49
+#define HEX_DIGIT_01001010                                     4A
+#define HEX_DIGIT_01001011                                     4B
+#define HEX_DIGIT_01001100                                     4C
+#define HEX_DIGIT_01001101                                     4D
+#define HEX_DIGIT_01001110                                     4E
+#define HEX_DIGIT_01001111                                     4F
+#define HEX_DIGIT_01010000                                     50
+#define HEX_DIGIT_01010001                                     51
+#define HEX_DIGIT_01010010                                     52
+#define HEX_DIGIT_01010011                                     53
+#define HEX_DIGIT_01010100                                     54
+#define HEX_DIGIT_01010101                                     55
+#define HEX_DIGIT_01010110                                     56
+#define HEX_DIGIT_01010111                                     57
+#define HEX_DIGIT_01011000                                     58
+#define HEX_DIGIT_01011001                                     59
+#define HEX_DIGIT_01011010                                     5A
+#define HEX_DIGIT_01011011                                     5B
+#define HEX_DIGIT_01011100                                     5C
+#define HEX_DIGIT_01011101                                     5D
+#define HEX_DIGIT_01011110                                     5E
+#define HEX_DIGIT_01011111                                     5F
+#define HEX_DIGIT_01100000                                     60
+#define HEX_DIGIT_01100001                                     61
+#define HEX_DIGIT_01100010                                     62
+#define HEX_DIGIT_01100011                                     63
+#define HEX_DIGIT_01100100                                     64
+#define HEX_DIGIT_01100101                                     65
+#define HEX_DIGIT_01100110                                     66
+#define HEX_DIGIT_01100111                                     67
+#define HEX_DIGIT_01101000                                     68
+#define HEX_DIGIT_01101001                                     69
+#define HEX_DIGIT_01101010                                     6A
+#define HEX_DIGIT_01101011                                     6B
+#define HEX_DIGIT_01101100                                     6C
+#define HEX_DIGIT_01101101                                     6D
+#define HEX_DIGIT_01101110                                     6E
+#define HEX_DIGIT_01101111                                     6F
+#define HEX_DIGIT_01110000                                     70
+#define HEX_DIGIT_01110001                                     71
+#define HEX_DIGIT_01110010                                     72
+#define HEX_DIGIT_01110011                                     73
+#define HEX_DIGIT_01110100                                     74
+#define HEX_DIGIT_01110101                                     75
+#define HEX_DIGIT_01110110                                     76
+#define HEX_DIGIT_01110111                                     77
+#define HEX_DIGIT_01111000                                     78
+#define HEX_DIGIT_01111001                                     79
+#define HEX_DIGIT_01111010                                     7A
+#define HEX_DIGIT_01111011                                     7B
+#define HEX_DIGIT_01111100                                     7C
+#define HEX_DIGIT_01111101                                     7D
+#define HEX_DIGIT_01111110                                     7E
+#define HEX_DIGIT_01111111                                     7F
+#define HEX_DIGIT_10000000                                     80
+#define HEX_DIGIT_10000001                                     81
+#define HEX_DIGIT_10000010                                     82
+#define HEX_DIGIT_10000011                                     83
+#define HEX_DIGIT_10000100                                     84
+#define HEX_DIGIT_10000101                                     85
+#define HEX_DIGIT_10000110                                     86
+#define HEX_DIGIT_10000111                                     87
+#define HEX_DIGIT_10001000                                     88
+#define HEX_DIGIT_10001001                                     89
+#define HEX_DIGIT_10001010                                     8A
+#define HEX_DIGIT_10001011                                     8B
+#define HEX_DIGIT_10001100                                     8C
+#define HEX_DIGIT_10001101                                     8D
+#define HEX_DIGIT_10001110                                     8E
+#define HEX_DIGIT_10001111                                     8F
+#define HEX_DIGIT_10010000                                     90
+#define HEX_DIGIT_10010001                                     91
+#define HEX_DIGIT_10010010                                     92
+#define HEX_DIGIT_10010011                                     93
+#define HEX_DIGIT_10010100                                     94
+#define HEX_DIGIT_10010101                                     95
+#define HEX_DIGIT_10010110                                     96
+#define HEX_DIGIT_10010111                                     97
+#define HEX_DIGIT_10011000                                     98
+#define HEX_DIGIT_10011001                                     99
+#define HEX_DIGIT_10011010                                     9A
+#define HEX_DIGIT_10011011                                     9B
+#define HEX_DIGIT_10011100                                     9C
+#define HEX_DIGIT_10011101                                     9D
+#define HEX_DIGIT_10011110                                     9E
+#define HEX_DIGIT_10011111                                     9F
+#define HEX_DIGIT_10100000                                     A0
+#define HEX_DIGIT_10100001                                     A1
+#define HEX_DIGIT_10100010                                     A2
+#define HEX_DIGIT_10100011                                     A3
+#define HEX_DIGIT_10100100                                     A4
+#define HEX_DIGIT_10100101                                     A5
+#define HEX_DIGIT_10100110                                     A6
+#define HEX_DIGIT_10100111                                     A7
+#define HEX_DIGIT_10101000                                     A8
+#define HEX_DIGIT_10101001                                     A9
+#define HEX_DIGIT_10101010                                     AA
+#define HEX_DIGIT_10101011                                     AB
+#define HEX_DIGIT_10101100                                     AC
+#define HEX_DIGIT_10101101                                     AD
+#define HEX_DIGIT_10101110                                     AE
+#define HEX_DIGIT_10101111                                     AF
+#define HEX_DIGIT_10110000                                     B0
+#define HEX_DIGIT_10110001                                     B1
+#define HEX_DIGIT_10110010                                     B2
+#define HEX_DIGIT_10110011                                     B3
+#define HEX_DIGIT_10110100                                     B4
+#define HEX_DIGIT_10110101                                     B5
+#define HEX_DIGIT_10110110                                     B6
+#define HEX_DIGIT_10110111                                     B7
+#define HEX_DIGIT_10111000                                     B8
+#define HEX_DIGIT_10111001                                     B9
+#define HEX_DIGIT_10111010                                     BA
+#define HEX_DIGIT_10111011                                     BB
+#define HEX_DIGIT_10111100                                     BC
+#define HEX_DIGIT_10111101                                     BD
+#define HEX_DIGIT_10111110                                     BE
+#define HEX_DIGIT_10111111                                     BF
+#define HEX_DIGIT_11000000                                     C0
+#define HEX_DIGIT_11000001                                     C1
+#define HEX_DIGIT_11000010                                     C2
+#define HEX_DIGIT_11000011                                     C3
+#define HEX_DIGIT_11000100                                     C4
+#define HEX_DIGIT_11000101                                     C5
+#define HEX_DIGIT_11000110                                     C6
+#define HEX_DIGIT_11000111                                     C7
+#define HEX_DIGIT_11001000                                     C8
+#define HEX_DIGIT_11001001                                     C9
+#define HEX_DIGIT_11001010                                     CA
+#define HEX_DIGIT_11001011                                     CB
+#define HEX_DIGIT_11001100                                     CC
+#define HEX_DIGIT_11001101                                     CD
+#define HEX_DIGIT_11001110                                     CE
+#define HEX_DIGIT_11001111                                     CF
+#define HEX_DIGIT_11010000                                     D0
+#define HEX_DIGIT_11010001                                     D1
+#define HEX_DIGIT_11010010                                     D2
+#define HEX_DIGIT_11010011                                     D3
+#define HEX_DIGIT_11010100                                     D4
+#define HEX_DIGIT_11010101                                     D5
+#define HEX_DIGIT_11010110                                     D6
+#define HEX_DIGIT_11010111                                     D7
+#define HEX_DIGIT_11011000                                     D8
+#define HEX_DIGIT_11011001                                     D9
+#define HEX_DIGIT_11011010                                     DA
+#define HEX_DIGIT_11011011                                     DB
+#define HEX_DIGIT_11011100                                     DC
+#define HEX_DIGIT_11011101                                     DD
+#define HEX_DIGIT_11011110                                     DE
+#define HEX_DIGIT_11011111                                     DF
+#define HEX_DIGIT_11100000                                     E0
+#define HEX_DIGIT_11100001                                     E1
+#define HEX_DIGIT_11100010                                     E2
+#define HEX_DIGIT_11100011                                     E3
+#define HEX_DIGIT_11100100                                     E4
+#define HEX_DIGIT_11100101                                     E5
+#define HEX_DIGIT_11100110                                     E6
+#define HEX_DIGIT_11100111                                     E7
+#define HEX_DIGIT_11101000                                     E8
+#define HEX_DIGIT_11101001                                     E9
+#define HEX_DIGIT_11101010                                     EA
+#define HEX_DIGIT_11101011                                     EB
+#define HEX_DIGIT_11101100                                     EC
+#define HEX_DIGIT_11101101                                     ED
+#define HEX_DIGIT_11101110                                     EE
+#define HEX_DIGIT_11101111                                     EF
+#define HEX_DIGIT_11110000                                     F0
+#define HEX_DIGIT_11110001                                     F1
+#define HEX_DIGIT_11110010                                     F2
+#define HEX_DIGIT_11110011                                     F3
+#define HEX_DIGIT_11110100                                     F4
+#define HEX_DIGIT_11110101                                     F5
+#define HEX_DIGIT_11110110                                     F6
+#define HEX_DIGIT_11110111                                     F7
+#define HEX_DIGIT_11111000                                     F8
+#define HEX_DIGIT_11111001                                     F9
+#define HEX_DIGIT_11111010                                     FA
+#define HEX_DIGIT_11111011                                     FB
+#define HEX_DIGIT_11111100                                     FC
+#define HEX_DIGIT_11111101                                     FD
+#define HEX_DIGIT_11111110                                     FE
+#define HEX_DIGIT_11111111                                     FF
+
+#if 0
+#pragma mark == Debugging ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       CommonServicesTest
+
+       @abstract       Unit test.
+*/
+
+#if( DEBUG )
+       #if( TARGET_LANGUAGE_C_LIKE )
+               OSStatus        CommonServicesTest( void );
+       #endif
+#endif
+
+#ifdef __cplusplus
+       }
+#endif
+
+#endif // __COMMON_SERVICES__
diff --git a/mDNSShared/DebugServices.c b/mDNSShared/DebugServices.c
new file mode 100644 (file)
index 0000000..164310a
--- /dev/null
@@ -0,0 +1,3102 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
+ *
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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.
+
+    Change History (most recent first):
+    
+$Log: DebugServices.c,v $
+Revision 1.6  2006/08/14 23:24:56  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.5  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.4  2004/04/15 08:59:08  bradley
+Removed deprecated debug and log levels and replaced them with modern equivalents.
+
+Revision 1.3  2004/04/08 09:29:55  bradley
+Manually do host->network byte order conversion to avoid needing libraries for htons/htonl. Changed
+hex dumps to better separate hex and ASCII. Added support for %.8a syntax in DebugSNPrintF for Fibre
+Channel addresses (00:11:22:33:44:55:66:77). Fixed a few places where HeaderDoc was incorrect.
+
+Revision 1.2  2004/03/07 05:59:34  bradley
+Sync'd with internal version: Added expect macros, error codes, and CoreServices exclusion.
+
+Revision 1.1  2004/01/30 02:27:30  bradley
+Debugging support for various platforms.
+
+
+       To Do:
+       
+       - Use StackWalk on Windows to optionally print stack frames.
+*/
+
+#if 0
+#pragma mark == Includes ==
+#endif
+
+//===========================================================================================================================
+//     Includes
+//===========================================================================================================================
+
+#if( !KERNEL )
+       #include        <ctype.h>
+       #include        <stdio.h>
+       #include        <string.h>
+#endif
+
+#include       "CommonServices.h"
+
+#include       "DebugServices.h"
+
+#if( DEBUG )
+
+#if( TARGET_OS_VXWORKS )
+       #include        "intLib.h"
+#endif
+
+#if( TARGET_OS_WIN32 )
+       #include        <time.h>
+       
+       #if( !TARGET_OS_WINDOWS_CE )
+               #include        <fcntl.h>
+               #include        <io.h>
+       #endif
+#endif
+
+#if( DEBUG_IDEBUG_ENABLED && TARGET_API_MAC_OSX_KERNEL )
+       #include        <IOKit/IOLib.h>
+#endif
+
+// If MDNS_DEBUGMSGS is defined (even if defined 0), it is aware of mDNS and it is probably safe to include mDNSEmbeddedAPI.h.
+
+#if( defined( MDNS_DEBUGMSGS ) )
+       #include        "mDNSEmbeddedAPI.h"
+#endif
+
+#if 0
+#pragma mark == Macros ==
+#endif
+
+//===========================================================================================================================
+//     Macros
+//===========================================================================================================================
+
+#define DebugIsPrint( C )              ( ( ( C ) >= 0x20 ) && ( ( C ) <= 0x7E ) )
+
+#if 0
+#pragma mark == Prototypes ==
+#endif
+
+//===========================================================================================================================
+//     Prototypes
+//===========================================================================================================================
+
+static OSStatus        DebugPrint( DebugLevel inLevel, char *inData, size_t inSize );
+
+// fprintf
+
+#if( DEBUG_FPRINTF_ENABLED )
+       static OSStatus DebugFPrintFInit( DebugOutputTypeFlags inFlags, const char *inFilename );
+       static void             DebugFPrintFPrint( char *inData, size_t inSize );
+#endif
+
+// iDebug (Mac OS X user and kernel)
+
+#if( DEBUG_IDEBUG_ENABLED )
+       static OSStatus DebugiDebugInit( void );
+       static void             DebugiDebugPrint( char *inData, size_t inSize );
+#endif
+
+// kprintf (Mac OS X Kernel)
+
+#if( DEBUG_KPRINTF_ENABLED )
+       static void     DebugKPrintFPrint( char *inData, size_t inSize );
+#endif
+
+// Mac OS X IOLog (Mac OS X Kernel)
+
+#if( DEBUG_MAC_OS_X_IOLOG_ENABLED )
+       static void     DebugMacOSXIOLogPrint( char *inData, size_t inSize );
+#endif
+
+// Mac OS X Log
+
+#if( TARGET_OS_MAC )
+       static OSStatus DebugMacOSXLogInit( void );
+       static void             DebugMacOSXLogPrint( char *inData, size_t inSize );
+#endif
+
+// Windows Debugger
+
+#if( TARGET_OS_WIN32 )
+       static void     DebugWindowsDebuggerPrint( char *inData, size_t inSize );
+#endif
+
+// Windows Event Log
+
+#if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+       static OSStatus DebugWindowsEventLogInit( const char *inName, HMODULE inModule );
+       static void     DebugWindowsEventLogPrint( DebugLevel inLevel, char *inData, size_t inSize );
+#endif
+
+// DebugLib support
+
+#if( DEBUG_CORE_SERVICE_ASSERTS_ENABLED )
+       static pascal void      
+               DebugAssertOutputHandler( 
+                       OSType                          inComponentSignature, 
+                       UInt32                          inOptions, 
+                       const char *            inAssertionString, 
+                       const char *            inExceptionString, 
+                       const char *            inErrorString, 
+                       const char *            inFileName, 
+                       long                            inLineNumber, 
+                       void *                          inValue, 
+                       ConstStr255Param        inOutputMsg );
+#endif
+
+// Utilities
+
+static char *  DebugNumVersionToString( uint32_t inVersion, char *inString );
+
+#if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+       static void     DebugWinEnableConsole( void );
+#endif
+
+#if( TARGET_OS_WIN32 )
+       static TCHAR *
+               DebugWinCharToTCharString( 
+                       const char *    inCharString, 
+                       size_t                  inCharCount, 
+                       TCHAR *                 outTCharString, 
+                       size_t                  inTCharCountMax, 
+                       size_t *                outTCharCount );
+#endif
+
+#if 0
+#pragma mark == Globals ==
+#endif
+
+//===========================================================================================================================
+//     Private Globals
+//===========================================================================================================================
+
+#if( TARGET_OS_VXWORKS )
+       // TCP States for inetstatShow.
+
+       extern char **  pTcpstates;             // defined in tcpLib.c
+
+       const char *            kDebugTCPStates[] =
+       {
+               "(0)  TCPS_CLOSED", 
+               "(1)  TCPS_LISTEN", 
+               "(2)  TCPS_SYN_SENT", 
+               "(3)  TCPS_SYN_RECEIVED", 
+               "(4)  TCPS_ESTABLISHED", 
+               "(5)  TCPS_CLOSE_WAIT", 
+               "(6)  TCPS_FIN_WAIT_1", 
+               "(7)  TCPS_CLOSING", 
+               "(8)  TCPS_LAST_ACK", 
+               "(9)  TCPS_FIN_WAIT_2", 
+               "(10) TCPS_TIME_WAIT",
+       };
+#endif
+
+// General
+
+static bool                                                                    gDebugInitialized                               = false;
+static DebugOutputType                                         gDebugOutputType                                = kDebugOutputTypeNone;
+static DebugLevel                                                      gDebugPrintLevelMin                             = kDebugLevelInfo;
+static DebugLevel                                                      gDebugPrintLevelMax                             = kDebugLevelMax;
+static DebugLevel                                                      gDebugBreakLevel                                = kDebugLevelAssert;
+#if( DEBUG_CORE_SERVICE_ASSERTS_ENABLED )
+       static DebugAssertOutputHandlerUPP              gDebugAssertOutputHandlerUPP    = NULL;
+#endif
+
+// Custom
+
+static DebugOutputFunctionPtr                          gDebugCustomOutputFunction              = NULL;
+static void *                                                          gDebugCustomOutputContext               = NULL;
+
+// fprintf
+
+#if( DEBUG_FPRINTF_ENABLED )
+       static FILE *                                                   gDebugFPrintFFile                               = NULL;
+#endif
+
+// MacOSXLog
+
+#if( TARGET_OS_MAC )
+       typedef int     ( *DebugMacOSXLogFunctionPtr )( const char *inFormat, ... );
+       
+       static DebugMacOSXLogFunctionPtr                gDebugMacOSXLogFunction                 = NULL;
+#endif
+
+// WindowsEventLog
+
+
+#if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+       static HANDLE                                                   gDebugWindowsEventLogEventSource = NULL;
+#endif
+
+#if 0
+#pragma mark -
+#pragma mark == General ==
+#endif
+
+//===========================================================================================================================
+//     DebugInitialize
+//===========================================================================================================================
+
+DEBUG_EXPORT OSStatus  DebugInitialize( DebugOutputType inType, ... )
+{
+       OSStatus                        err;
+       DebugOutputType         type;
+       va_list                         args;
+       
+       va_start( args, inType );
+
+#if( TARGET_OS_VXWORKS )
+       // Set up the TCP state strings if they are not already set up by VxWorks (normally not set up for some reason).
+       
+       if( !pTcpstates )
+       {
+               pTcpstates = (char **) kDebugTCPStates;
+       }
+#endif
+       
+       // Set up DebugLib stuff (if building with Debugging.h).
+       
+#if( DEBUG_CORE_SERVICE_ASSERTS_ENABLED )
+       if( !gDebugAssertOutputHandlerUPP )
+       {
+               gDebugAssertOutputHandlerUPP = NewDebugAssertOutputHandlerUPP( DebugAssertOutputHandler );
+               check( gDebugAssertOutputHandlerUPP );
+               if( gDebugAssertOutputHandlerUPP )
+               {
+                       InstallDebugAssertOutputHandler( gDebugAssertOutputHandlerUPP );
+               }
+       }
+#endif
+       
+       // Pre-process meta-output kind to pick an appropriate output kind for the platform.
+       
+       type = inType;
+       if( type == kDebugOutputTypeMetaConsole )
+       {
+               #if( TARGET_OS_MAC )
+                       type = kDebugOutputTypeMacOSXLog;
+               #elif( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+                       #if( DEBUG_FPRINTF_ENABLED )
+                               type = kDebugOutputTypeFPrintF;
+                       #else
+                               type = kDebugOutputTypeWindowsDebugger;
+                       #endif
+               #elif( TARGET_API_MAC_OSX_KERNEL )
+                       #if( DEBUG_MAC_OS_X_IOLOG_ENABLED )
+                               type = kDebugOutputTypeMacOSXIOLog;
+                       #elif( DEBUG_IDEBUG_ENABLED )
+                               type = kDebugOutputTypeiDebug;
+                       #elif( DEBUG_KPRINTF_ENABLED )
+                               type = kDebugOutputTypeKPrintF;
+                       #endif
+               #elif( TARGET_OS_VXWORKS )
+                       #if( DEBUG_FPRINTF_ENABLED )
+                               type = kDebugOutputTypeFPrintF;
+                       #else
+                               #error target is VxWorks, but fprintf output is disabled
+                       #endif
+               #else
+                       #if( DEBUG_FPRINTF_ENABLED )
+                               type = kDebugOutputTypeFPrintF;
+                       #endif
+               #endif
+       }
+       
+       // Process output kind.
+       
+       gDebugOutputType = type;
+       switch( type )
+       {
+               case kDebugOutputTypeNone:
+                       err = kNoErr;
+                       break;
+
+               case kDebugOutputTypeCustom:
+                       gDebugCustomOutputFunction = va_arg( args, DebugOutputFunctionPtr );
+                       gDebugCustomOutputContext  = va_arg( args, void * );
+                       err = kNoErr;
+                       break;
+
+#if( DEBUG_FPRINTF_ENABLED )
+               case kDebugOutputTypeFPrintF:
+                       if( inType == kDebugOutputTypeMetaConsole )
+                       {
+                               err = DebugFPrintFInit( kDebugOutputTypeFlagsStdErr, NULL );
+                       }
+                       else
+                       {
+                               DebugOutputTypeFlags            flags;
+                               const char *                            filename;
+                               
+                               flags = (DebugOutputTypeFlags) va_arg( args, unsigned int );
+                               if( ( flags & kDebugOutputTypeFlagsTypeMask ) == kDebugOutputTypeFlagsFile )
+                               {
+                                       filename = va_arg( args, const char * );
+                               }
+                               else
+                               {
+                                       filename = NULL;
+                               }
+                               err = DebugFPrintFInit( flags, filename );
+                       }
+                       break;
+#endif
+
+#if( DEBUG_IDEBUG_ENABLED )
+               case kDebugOutputTypeiDebug:
+                       err = DebugiDebugInit();
+                       break;
+#endif
+
+#if( DEBUG_KPRINTF_ENABLED )
+               case kDebugOutputTypeKPrintF:
+                       err = kNoErr;
+                       break;
+#endif
+
+#if( DEBUG_MAC_OS_X_IOLOG_ENABLED )
+               case kDebugOutputTypeMacOSXIOLog:
+                       err = kNoErr;
+                       break;
+#endif
+
+#if( TARGET_OS_MAC )
+               case kDebugOutputTypeMacOSXLog:
+                       err = DebugMacOSXLogInit();
+                       break;
+#endif
+
+#if( TARGET_OS_WIN32 )
+               case kDebugOutputTypeWindowsDebugger:
+                       err = kNoErr;
+                       break;
+#endif
+
+#if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+               case kDebugOutputTypeWindowsEventLog:
+               {
+                       const char *            name;
+                       HMODULE                         module;
+                       
+                       name   = va_arg( args, const char * );
+                       module = va_arg( args, HMODULE );
+                       err = DebugWindowsEventLogInit( name, module );
+               }
+               break;
+#endif
+
+               default:
+                       err = kParamErr;
+                       goto exit;
+       }
+       gDebugInitialized = true;
+       
+exit:
+       va_end( args );
+       return( err );
+}
+
+//===========================================================================================================================
+//     DebugFinalize
+//===========================================================================================================================
+
+DEBUG_EXPORT void              DebugFinalize( void )
+{
+#if( DEBUG_CORE_SERVICE_ASSERTS_ENABLED )
+       check( gDebugAssertOutputHandlerUPP );
+       if( gDebugAssertOutputHandlerUPP )
+       {
+               InstallDebugAssertOutputHandler( NULL );
+               DisposeDebugAssertOutputHandlerUPP( gDebugAssertOutputHandlerUPP );
+               gDebugAssertOutputHandlerUPP = NULL;
+       }
+#endif
+}
+
+//===========================================================================================================================
+//     DebugGetProperty
+//===========================================================================================================================
+
+DEBUG_EXPORT OSStatus  DebugGetProperty( DebugPropertyTag inTag, ... )
+{
+       OSStatus                        err;
+       va_list                         args;
+       DebugLevel *            level;
+       
+       va_start( args, inTag );
+       switch( inTag )
+       {
+               case kDebugPropertyTagPrintLevelMin:
+                       level  = va_arg( args, DebugLevel * );
+                       *level = gDebugPrintLevelMin;
+                       err = kNoErr;
+                       break;
+               
+               case kDebugPropertyTagPrintLevelMax:
+                       level  = va_arg( args, DebugLevel * );
+                       *level = gDebugPrintLevelMax;
+                       err = kNoErr;
+                       break;
+               
+               case kDebugPropertyTagBreakLevel:
+                       level  = va_arg( args, DebugLevel * );
+                       *level = gDebugBreakLevel;
+                       err = kNoErr;
+                       break;          
+               
+               default:
+                       err = kUnsupportedErr;
+                       break;
+       }
+       va_end( args );
+       return( err );
+}
+
+//===========================================================================================================================
+//     DebugSetProperty
+//===========================================================================================================================
+
+DEBUG_EXPORT OSStatus  DebugSetProperty( DebugPropertyTag inTag, ... )
+{
+       OSStatus                err;
+       va_list                 args;
+       DebugLevel              level;
+       
+       va_start( args, inTag );
+       switch( inTag )
+       {
+               case kDebugPropertyTagPrintLevelMin:
+                       level  = va_arg( args, DebugLevel );
+                       gDebugPrintLevelMin = level;
+                       err = kNoErr;
+                       break;
+               
+               case kDebugPropertyTagPrintLevelMax:
+                       level  = va_arg( args, DebugLevel );
+                       gDebugPrintLevelMax = level;
+                       err = kNoErr;
+                       break;
+               
+               case kDebugPropertyTagBreakLevel:
+                       level  = va_arg( args, DebugLevel );
+                       gDebugBreakLevel = level;
+                       err = kNoErr;
+                       break;          
+               
+               default:
+                       err = kUnsupportedErr;
+                       break;
+       }
+       va_end( args );
+       return( err );
+}
+
+#if 0
+#pragma mark -
+#pragma mark == Output ==
+#endif
+
+//===========================================================================================================================
+//     DebugPrintF
+//===========================================================================================================================
+
+DEBUG_EXPORT size_t    DebugPrintF( DebugLevel inLevel, const char *inFormat, ... )
+{      
+       va_list         args;
+       size_t          n;
+       
+       // Skip if the level is not in the enabled range..
+       
+       if( ( inLevel < gDebugPrintLevelMin ) || ( inLevel > gDebugPrintLevelMax ) )
+       {
+               n = 0;
+               goto exit;
+       }
+       
+       va_start( args, inFormat );
+       n = DebugPrintFVAList( inLevel, inFormat, args );
+       va_end( args );
+
+exit:
+       return( n );
+}
+
+//===========================================================================================================================
+//     DebugPrintFVAList
+//===========================================================================================================================
+
+DEBUG_EXPORT size_t    DebugPrintFVAList( DebugLevel inLevel, const char *inFormat, va_list inArgs )
+{
+       size_t          n;
+       char            buffer[ 512 ];
+       
+       // Skip if the level is not in the enabled range..
+       
+       if( ( inLevel < gDebugPrintLevelMin ) || ( inLevel > gDebugPrintLevelMax ) )
+       {
+               n = 0;
+               goto exit;
+       }
+       
+       n = DebugSNPrintFVAList( buffer, sizeof( buffer ), inFormat, inArgs );
+       DebugPrint( inLevel, buffer, (size_t) n );
+
+exit:
+       return( n );
+}
+
+//===========================================================================================================================
+//     DebugPrint
+//===========================================================================================================================
+
+static OSStatus        DebugPrint( DebugLevel inLevel, char *inData, size_t inSize )
+{
+       OSStatus                err;
+       
+       // Skip if the level is not in the enabled range..
+       
+       if( ( inLevel < gDebugPrintLevelMin ) || ( inLevel > gDebugPrintLevelMax ) )
+       {
+               err = kRangeErr;
+               goto exit;
+       }
+       
+       // Printing is not safe at interrupt time so check for this and warn with an interrupt safe mechanism (if available).
+       
+       if( DebugTaskLevel() & kDebugInterruptLevelMask )
+       {
+               #if( TARGET_OS_VXWORKS )
+                       logMsg( "\ncannot print at interrupt time\n\n", 1, 2, 3, 4, 5, 6 );
+               #endif
+               
+               err = kExecutionStateErr;
+               goto exit;
+       }
+       
+       // Initialize the debugging library if it hasn't already been initialized (allows for zero-config usage).
+       
+       if( !gDebugInitialized )
+       {
+               debug_initialize( kDebugOutputTypeMetaConsole );
+       }
+       
+       // Print based on the current output type.
+       
+       switch( gDebugOutputType )
+       {
+               case kDebugOutputTypeNone:
+                       break;
+               
+               case kDebugOutputTypeCustom:
+                       if( gDebugCustomOutputFunction )
+                       {
+                               gDebugCustomOutputFunction( inData, inSize, gDebugCustomOutputContext );
+                       }
+                       break;
+
+#if( DEBUG_FPRINTF_ENABLED )
+               case kDebugOutputTypeFPrintF:
+                       DebugFPrintFPrint( inData, inSize );
+                       break;
+#endif
+
+#if( DEBUG_IDEBUG_ENABLED )
+               case kDebugOutputTypeiDebug:
+                       DebugiDebugPrint( inData, inSize );
+                       break;
+#endif
+
+#if( DEBUG_KPRINTF_ENABLED )
+               case kDebugOutputTypeKPrintF:
+                       DebugKPrintFPrint( inData, inSize );
+                       break;
+#endif
+
+#if( DEBUG_MAC_OS_X_IOLOG_ENABLED )
+               case kDebugOutputTypeMacOSXIOLog:
+                       DebugMacOSXIOLogPrint( inData, inSize );
+                       break;
+#endif
+
+#if( TARGET_OS_MAC )
+               case kDebugOutputTypeMacOSXLog:
+                       DebugMacOSXLogPrint( inData, inSize );
+                       break;
+#endif
+
+#if( TARGET_OS_WIN32 )
+               case kDebugOutputTypeWindowsDebugger:
+                       DebugWindowsDebuggerPrint( inData, inSize );
+                       break;
+#endif
+
+#if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+               case kDebugOutputTypeWindowsEventLog:
+                       DebugWindowsEventLogPrint( inLevel, inData, inSize );
+                       break;
+#endif
+
+               default:
+                       break;
+       }
+       err = kNoErr;
+       
+exit:
+       return( err );
+}
+
+//===========================================================================================================================
+//     DebugPrintAssert
+//
+//     Warning: This routine relies on several of the strings being string constants that will exist forever because the
+//           underlying logMsg API that does the printing is asynchronous so it cannot use temporary/stack-based 
+//           pointer variables (e.g. local strings). The debug macros that invoke this function only use constant 
+//           constant strings, but if this function is invoked directly from other places, it must use constant strings.
+//===========================================================================================================================
+
+DEBUG_EXPORT void
+       DebugPrintAssert( 
+               int_least32_t   inErrorCode, 
+               const char *    inAssertString, 
+               const char *    inMessage, 
+               const char *    inFilename, 
+               int_least32_t   inLineNumber, 
+               const char *    inFunction )
+{
+       // Skip if the level is not in the enabled range..
+       
+       if( ( kDebugLevelAssert < gDebugPrintLevelMin ) || ( kDebugLevelAssert > gDebugPrintLevelMax ) )
+       {
+               return;
+       }
+       
+       if( inErrorCode != 0 )
+       {
+               DebugPrintF( 
+                       kDebugLevelAssert, 
+                       "\n"
+                       "[ASSERT] error:  %ld (%m)\n"
+                       "[ASSERT] where:  \"%s\", line %ld, \"%s\"\n"
+                       "\n", 
+                       inErrorCode, inErrorCode, 
+                       inFilename ? inFilename : "", 
+                       inLineNumber, 
+                       inFunction ? inFunction : "" );
+       }
+       else
+       {
+               DebugPrintF( 
+                       kDebugLevelAssert, 
+                       "\n"
+                       "[ASSERT] assert: \"%s\" %s\n"
+                       "[ASSERT] where:  \"%s\", line %ld, \"%s\"\n"
+                       "\n", 
+                       inAssertString ? inAssertString : "", 
+                       inMessage ? inMessage : "", 
+                       inFilename ? inFilename : "", 
+                       inLineNumber, 
+                       inFunction ? inFunction : "" );
+       }
+       
+       // Break into the debugger if enabled.
+       
+       #if( TARGET_OS_WIN32 )
+               if( gDebugBreakLevel <= kDebugLevelAssert )
+               {
+                       if( IsDebuggerPresent() )
+                       {
+                               DebugBreak();
+                       }
+               }
+       #endif
+}
+
+#if 0
+#pragma mark -
+#endif
+
+#if( DEBUG_FPRINTF_ENABLED )
+//===========================================================================================================================
+//     DebugFPrintFInit
+//===========================================================================================================================
+
+static OSStatus        DebugFPrintFInit( DebugOutputTypeFlags inFlags, const char *inFilename )
+{
+       OSStatus                                        err;
+       DebugOutputTypeFlags            typeFlags;
+       
+       typeFlags = inFlags & kDebugOutputTypeFlagsTypeMask;
+       if( typeFlags == kDebugOutputTypeFlagsStdOut )
+       {
+               #if( TARGET_OS_WIN32 )
+                       DebugWinEnableConsole();
+               #endif
+
+               gDebugFPrintFFile = stdout;
+       }
+       else if( typeFlags == kDebugOutputTypeFlagsStdErr )
+       {
+               #if( TARGET_OS_WIN32 )
+                       DebugWinEnableConsole();
+               #endif
+               
+               gDebugFPrintFFile = stdout;
+       }
+       else if( typeFlags == kDebugOutputTypeFlagsFile )
+       {
+               require_action_quiet( inFilename && ( *inFilename != '\0' ), exit, err = kOpenErr );
+               
+               gDebugFPrintFFile = fopen( inFilename, "a" );
+               require_action_quiet( gDebugFPrintFFile, exit, err = kOpenErr );
+       }
+       else
+       {
+               err = kParamErr;
+               goto exit;
+       }
+       err = kNoErr;
+       
+exit:
+       return( err );
+}
+
+//===========================================================================================================================
+//     DebugFPrintFPrint
+//===========================================================================================================================
+
+static void    DebugFPrintFPrint( char *inData, size_t inSize )
+{
+       char *          p;
+       char *          q;
+       
+       // Convert \r to \n. fprintf will interpret \n and convert to whatever is appropriate for the platform.
+       
+       p = inData;
+       q = p + inSize;
+       while( p < q )
+       {
+               if( *p == '\r' )
+               {
+                       *p = '\n';
+               }
+               ++p;
+       }
+       
+       // Write the data and flush.
+       
+       if( gDebugFPrintFFile )
+       {
+               fprintf( gDebugFPrintFFile, "%.*s", (int) inSize, inData );
+               fflush( gDebugFPrintFFile );
+       }
+}
+#endif // DEBUG_FPRINTF_ENABLED
+
+#if( DEBUG_IDEBUG_ENABLED )
+//===========================================================================================================================
+//     DebugiDebugInit
+//===========================================================================================================================
+
+static OSStatus        DebugiDebugInit( void )
+{
+       OSStatus                err;
+       
+       #if( TARGET_API_MAC_OSX_KERNEL )
+               
+               extern uint32_t *               _giDebugReserved1;
+               
+               // Emulate the iDebugSetOutputType macro in iDebugServices.h.
+               // Note: This is not thread safe, but neither is iDebugServices.h nor iDebugKext.
+               
+               if( !_giDebugReserved1 )
+               {
+                       _giDebugReserved1 = (uint32_t *) IOMalloc( sizeof( uint32_t ) );
+                       require_action_quiet( _giDebugReserved1, exit, err = kNoMemoryErr );
+               }
+               *_giDebugReserved1 = 0x00010000U;
+               err = kNoErr;
+exit:
+       #else
+               
+               __private_extern__ void iDebugSetOutputTypeInternal( uint32_t inType );
+               
+               iDebugSetOutputTypeInternal( 0x00010000U );
+               err = kNoErr;
+               
+       #endif
+       
+       return( err );
+}
+
+//===========================================================================================================================
+//     DebugiDebugPrint
+//===========================================================================================================================
+
+static void    DebugiDebugPrint( char *inData, size_t inSize )
+{
+       #if( TARGET_API_MAC_OSX_KERNEL )
+               
+               // Locally declared here so we do not need to include iDebugKext.h.
+               // Note: IOKit uses a global namespace for all code and only a partial link occurs at build time. When the 
+               // KEXT is loaded, the runtime linker will link in this extern'd symbol (assuming iDebug is present).
+               // _giDebugLogInternal is actually part of IOKit proper so this should link even if iDebug is not present.
+               
+               typedef void ( *iDebugLogFunctionPtr )( uint32_t inLevel, uint32_t inTag, const char *inFormat, ... );
+               
+               extern iDebugLogFunctionPtr             _giDebugLogInternal;
+               
+               if( _giDebugLogInternal )
+               {
+                       _giDebugLogInternal( 0, 0, "%.*s", (int) inSize, inData );
+               }
+               
+       #else
+       
+               __private_extern__ void iDebugLogInternal( uint32_t inLevel, uint32_t inTag, const char *inFormat, ... );
+               
+               iDebugLogInternal( 0, 0, "%.*s", (int) inSize, inData );
+       
+       #endif
+}
+#endif
+
+#if( DEBUG_KPRINTF_ENABLED )
+//===========================================================================================================================
+//     DebugKPrintFPrint
+//===========================================================================================================================
+
+static void    DebugKPrintFPrint( char *inData, size_t inSize )
+{
+       extern void     kprintf( const char *inFormat, ... );
+       
+       kprintf( "%.*s", (int) inSize, inData );
+}
+#endif
+
+#if( DEBUG_MAC_OS_X_IOLOG_ENABLED )
+//===========================================================================================================================
+//     DebugMacOSXIOLogPrint
+//===========================================================================================================================
+
+static void    DebugMacOSXIOLogPrint( char *inData, size_t inSize )
+{
+       extern void     IOLog( const char *inFormat, ... );
+       
+       IOLog( "%.*s", (int) inSize, inData );
+}
+#endif
+
+#if( TARGET_OS_MAC )
+//===========================================================================================================================
+//     DebugMacOSXLogInit
+//===========================================================================================================================
+
+static OSStatus        DebugMacOSXLogInit( void )
+{
+       OSStatus                err;
+       CFStringRef             path;
+       CFURLRef                url;
+       CFBundleRef             bundle;
+       CFStringRef             functionName;
+       void *                  functionPtr;
+       
+       bundle = NULL;
+       
+       // Create a bundle reference for System.framework.
+       
+       path = CFSTR( "/System/Library/Frameworks/System.framework" );
+       url = CFURLCreateWithFileSystemPath( NULL, path, kCFURLPOSIXPathStyle, true );
+       require_action_quiet( url, exit, err = memFullErr );
+       
+       bundle = CFBundleCreate( NULL, url );
+       CFRelease( url );
+       require_action_quiet( bundle, exit, err = memFullErr );
+       
+       // Get a ptr to the system's "printf" function from System.framework.
+       
+       functionName = CFSTR( "printf" );
+       functionPtr = CFBundleGetFunctionPointerForName( bundle, functionName );
+       require_action_quiet( functionPtr, exit, err = memFullErr );    
+       
+       // Success! Note: The bundle cannot be released because it would invalidate the function ptr.
+       
+       gDebugMacOSXLogFunction = (DebugMacOSXLogFunctionPtr) functionPtr;
+       bundle = NULL;
+       err = noErr;
+       
+exit:
+       if( bundle )
+       {
+               CFRelease( bundle );
+       }
+       return( err );
+}
+
+//===========================================================================================================================
+//     DebugMacOSXLogPrint
+//===========================================================================================================================
+
+static void    DebugMacOSXLogPrint( char *inData, size_t inSize )
+{      
+       if( gDebugMacOSXLogFunction )
+       {
+               gDebugMacOSXLogFunction( "%.*s", (int) inSize, inData );
+       }
+}
+#endif
+
+#if( TARGET_OS_WIN32 )
+//===========================================================================================================================
+//     DebugWindowsDebuggerPrint
+//===========================================================================================================================
+
+void   DebugWindowsDebuggerPrint( char *inData, size_t inSize )
+{
+       TCHAR                           buffer[ 512 ];
+       const char *            src;
+       const char *            end;
+       TCHAR *                         dst;
+       char                            c;
+       
+       // Copy locally and null terminate the string. This also converts from char to TCHAR in case we are 
+       // building with UNICODE enabled since the input is always char. Also convert \r to \n in the process.
+
+       src = inData;
+       if( inSize >= sizeof_array( buffer ) )
+       {
+               inSize = sizeof_array( buffer ) - 1;
+       }
+       end = src + inSize;
+       dst = buffer;   
+       while( src < end )
+       {
+               c = *src++;
+               if( c == '\r' )
+               {
+                       c = '\n';
+               }
+               *dst++ = (TCHAR) c;
+       }
+       *dst = 0;
+       
+       // Print out the string to the debugger.
+       
+       OutputDebugString( buffer );
+}
+#endif
+
+#if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+//===========================================================================================================================
+//     DebugWindowsEventLogInit
+//===========================================================================================================================
+
+static OSStatus        DebugWindowsEventLogInit( const char *inName, HMODULE inModule )
+{
+       OSStatus                        err;
+       HKEY                            key;
+       TCHAR                           name[ 128 ];
+       const char *            src;
+       TCHAR                           path[ MAX_PATH ];
+       size_t                          size;
+       DWORD                           typesSupported;
+       DWORD                           n;
+       
+       key = NULL;
+
+       // Use a default name if needed then convert the name to TCHARs so it works on ANSI or Unicode builds.
+
+       if( !inName || ( *inName == '\0' ) )
+       {
+               inName = "DefaultApp";
+       }
+       DebugWinCharToTCharString( inName, kSizeCString, name, sizeof( name ), NULL );
+       
+       // Build the path string using the fixed registry path and app name.
+       
+       src = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\";
+       DebugWinCharToTCharString( src, kSizeCString, path, sizeof_array( path ), &size );
+       DebugWinCharToTCharString( inName, kSizeCString, path + size, sizeof_array( path ) - size, NULL );
+       
+       // Add/Open the source name as a sub-key under the Application key in the EventLog registry key.
+       
+       err = RegCreateKeyEx( HKEY_LOCAL_MACHINE, path, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, NULL );
+       require_noerr_quiet( err, exit );
+       
+       // Set the path in the EventMessageFile subkey. Add 1 to the TCHAR count to include the null terminator.
+       
+       n = GetModuleFileName( inModule, path, sizeof_array( path ) );
+       err = translate_errno( n > 0, (OSStatus) GetLastError(), kParamErr );
+       require_noerr_quiet( err, exit );
+       n += 1;
+       n *= sizeof( TCHAR );
+       
+       err = RegSetValueEx( key, TEXT( "EventMessageFile" ), 0, REG_EXPAND_SZ, (const LPBYTE) path, n );
+       require_noerr_quiet( err, exit );
+       
+       // Set the supported event types in the TypesSupported subkey.
+       
+       typesSupported = EVENTLOG_SUCCESS | EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE |
+                                        EVENTLOG_AUDIT_SUCCESS | EVENTLOG_AUDIT_FAILURE;
+       err = RegSetValueEx( key, TEXT( "TypesSupported" ), 0, REG_DWORD, (const LPBYTE) &typesSupported, sizeof( DWORD ) );
+       require_noerr_quiet( err, exit );
+       
+       // Set up the event source.
+       
+       gDebugWindowsEventLogEventSource = RegisterEventSource( NULL, name );
+       err = translate_errno( gDebugWindowsEventLogEventSource, (OSStatus) GetLastError(), kParamErr );
+       require_noerr_quiet( err, exit );
+       
+exit:
+       if( key )
+       {
+               RegCloseKey( key );
+       }
+       return( err );
+}
+
+//===========================================================================================================================
+//     DebugWindowsEventLogPrint
+//===========================================================================================================================
+
+static void    DebugWindowsEventLogPrint( DebugLevel inLevel, char *inData, size_t inSize )
+{
+       WORD                            type;
+       TCHAR                           buffer[ 512 ];
+       const char *            src;
+       const char *            end;
+       TCHAR *                         dst;
+       char                            c;
+       const TCHAR *           array[ 1 ];
+       
+       // Map the debug level to a Windows EventLog type.
+       
+       if( inLevel <= kDebugLevelNotice )
+       {
+               type = EVENTLOG_INFORMATION_TYPE;
+       }
+       else if( inLevel <= kDebugLevelWarning )
+       {
+               type = EVENTLOG_WARNING_TYPE;
+       }
+       else
+       {
+               type = EVENTLOG_ERROR_TYPE;
+       }
+       
+       // Copy locally and null terminate the string. This also converts from char to TCHAR in case we are 
+       // building with UNICODE enabled since the input is always char. Also convert \r to \n in the process.
+       
+       src = inData;
+       if( inSize >= sizeof_array( buffer ) )
+       {
+               inSize = sizeof_array( buffer ) - 1;
+       }
+       end = src + inSize;
+       dst = buffer;   
+       while( src < end )
+       {
+               c = *src++;
+               if( c == '\r' )
+               {
+                       c = '\n';
+               }
+               *dst++ = (TCHAR) c;
+       }
+       *dst = 0;
+       
+       // Add the the string to the event log.
+       
+       array[ 0 ] = buffer;
+       if( gDebugWindowsEventLogEventSource )
+       {
+               ReportEvent( gDebugWindowsEventLogEventSource, type, 0, 0x20000001L, NULL, 1, 0, array, NULL );
+       }
+}
+#endif // TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE
+
+#if( DEBUG_CORE_SERVICE_ASSERTS_ENABLED )
+//===========================================================================================================================
+//     DebugAssertOutputHandler
+//===========================================================================================================================
+
+static pascal void     
+       DebugAssertOutputHandler( 
+               OSType                          inComponentSignature, 
+               UInt32                          inOptions, 
+               const char *            inAssertString, 
+               const char *            inExceptionString, 
+               const char *            inErrorString, 
+               const char *            inFileName, 
+               long                            inLineNumber, 
+               void *                          inValue, 
+               ConstStr255Param        inOutputMsg )
+{
+       DEBUG_UNUSED( inComponentSignature );
+       DEBUG_UNUSED( inOptions );
+       DEBUG_UNUSED( inExceptionString );
+       DEBUG_UNUSED( inValue );
+       DEBUG_UNUSED( inOutputMsg );
+       
+       DebugPrintAssert( 0, inAssertString, inErrorString, inFileName, (int_least32_t) inLineNumber, "" );
+}
+#endif
+
+#if 0
+#pragma mark -
+#pragma mark == Utilities ==
+#endif
+
+//===========================================================================================================================
+//     DebugSNPrintF
+//
+//     Stolen from mDNS.c's mDNS_snprintf/mDNS_vsnprintf with the following changes:
+//
+//     Changed names to avoid name collisions with the mDNS versions.
+//     Changed types to standard C types since mDNSEmbeddedAPI.h may not be available.
+//     Conditionalized mDNS stuff so it can be used with or with mDNSEmbeddedAPI.h.
+//     Added 64-bit support for %d (%lld), %i (%lli), %u (%llu), %o (%llo), %x (%llx), and %b (%llb).
+//     Added %@   - Cocoa/CoreFoundation object. Param is the object. Strings are used directly. Others use CFCopyDescription.
+//     Added %.8a - FIbre Channel address. Arg=ptr to address.
+//     Added %##a - IPv4 (if AF_INET defined) or IPv6 (if AF_INET6 defined) sockaddr. Arg=ptr to sockaddr.
+//     Added %b   - Binary representation of integer (e.g. 01101011). Modifiers and arg=the same as %d, %x, etc.
+//     Added %C   - Mac-style FourCharCode (e.g. 'APPL'). Arg=32-bit value to print as a Mac-style FourCharCode.
+//     Added %H   - Hex Dump (e.g. "\x6b\xa7" -> "6B A7"). 1st arg=ptr, 2nd arg=size, 3rd arg=max size.
+//     Added %#H  - Hex Dump & ASCII (e.g. "\x41\x62" -> "6B A7 'Ab'"). 1st arg=ptr, 2nd arg=size, 3rd arg=max size.
+//     Added %m   - Error Message (e.g. 0 -> "kNoErr"). Modifiers and error code args are the same as %d, %x, etc.
+//     Added %S   - UTF-16 string. Host order if no BOM. Precision is UTF-16 char count. BOM counts in any precision. Arg=ptr.
+//     Added %#S  - Big Endian UTF-16 string (unless BOM overrides). Otherwise the same as %S.
+//     Added %##S - Little Endian UTF-16 string (unless BOM overrides). Otherwise the same as %S.
+//     Added %U   - Universally Unique Identifier (UUID) (e.g. 6ba7b810-9dad-11d1-80b4-00c04fd430c8). Arg=ptr to 16-byte UUID.
+//===========================================================================================================================
+
+DEBUG_EXPORT size_t DebugSNPrintF(char *sbuffer, size_t buflen, const char *fmt, ...)
+       {
+       size_t length;
+       
+       va_list ptr;
+       va_start(ptr,fmt);
+       length = DebugSNPrintFVAList(sbuffer, buflen, fmt, ptr);
+       va_end(ptr);
+       
+       return(length);
+       }
+
+//===========================================================================================================================
+//     DebugSNPrintFVAList     - va_list version of DebugSNPrintF. See DebugSNPrintF for more info.
+//===========================================================================================================================
+
+DEBUG_EXPORT size_t DebugSNPrintFVAList(char *sbuffer, size_t buflen, const char *fmt, va_list arg)
+       {
+       static const struct DebugSNPrintF_format
+               {
+               unsigned      leftJustify : 1;
+               unsigned      forceSign : 1;
+               unsigned      zeroPad : 1;
+               unsigned      havePrecision : 1;
+               unsigned      hSize : 1;
+               char          lSize;
+               char          altForm;
+               char          sign;             // +, - or space
+               unsigned int  fieldWidth;
+               unsigned int  precision;
+               } DebugSNPrintF_format_default = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+       size_t nwritten = 0;
+       int c;
+       if (buflen == 0) return(0);
+       buflen--;               // Pre-reserve one space in the buffer for the terminating nul
+       if (buflen == 0) goto exit;
+       
+       for (c = *fmt; c != 0; c = *++fmt)
+               {
+               if (c != '%')
+                       {
+                       *sbuffer++ = (char)c;
+                       if (++nwritten >= buflen) goto exit;
+                       }
+               else
+                       {
+                       size_t i=0, j;
+                       // The mDNS Vsprintf Argument Conversion Buffer is used as a temporary holding area for
+                       // generating decimal numbers, hexdecimal numbers, IP addresses, domain name strings, etc.
+                       // The size needs to be enough for a 256-byte domain name plus some error text.
+                       #define mDNS_VACB_Size 300
+                       char mDNS_VACB[mDNS_VACB_Size];
+                       #define mDNS_VACB_Lim (&mDNS_VACB[mDNS_VACB_Size])
+                       #define mDNS_VACB_Remain(s) ((size_t)(mDNS_VACB_Lim - s))
+                       char *s = mDNS_VACB_Lim;
+                       const char *digits = "0123456789ABCDEF";
+                       struct DebugSNPrintF_format F = DebugSNPrintF_format_default;
+       
+                       for(;;) //  decode flags
+                               {
+                               c = *++fmt;
+                               if      (c == '-') F.leftJustify = 1;
+                               else if (c == '+') F.forceSign = 1;
+                               else if (c == ' ') F.sign = ' ';
+                               else if (c == '#') F.altForm++;
+                               else if (c == '0') F.zeroPad = 1;
+                               else break;
+                               }
+       
+                       if (c == '*')   //  decode field width
+                               {
+                               int f = va_arg(arg, int);
+                               if (f < 0) { f = -f; F.leftJustify = 1; }
+                               F.fieldWidth = (unsigned int)f;
+                               c = *++fmt;
+                               }
+                       else
+                               {
+                               for (; c >= '0' && c <= '9'; c = *++fmt)
+                                       F.fieldWidth = (10 * F.fieldWidth) + (c - '0');
+                               }
+       
+                       if (c == '.')   //  decode precision
+                               {
+                               if ((c = *++fmt) == '*')
+                                       { F.precision = va_arg(arg, unsigned int); c = *++fmt; }
+                               else for (; c >= '0' && c <= '9'; c = *++fmt)
+                                               F.precision = (10 * F.precision) + (c - '0');
+                               F.havePrecision = 1;
+                               }
+       
+                       if (F.leftJustify) F.zeroPad = 0;
+       
+                       conv:
+                       switch (c)      //  perform appropriate conversion
+                               {
+                               #if TYPE_LONGLONG_NATIVE
+                                       unsigned_long_long_compat n;
+                                       unsigned_long_long_compat base;
+                               #else
+                                       unsigned long n;
+                                       unsigned long base;
+                               #endif
+                               case 'h' :      F.hSize = 1; c = *++fmt; goto conv;
+                               case 'l' :      // fall through
+                               case 'L' :      F.lSize++; c = *++fmt; goto conv;
+                               case 'd' :
+                               case 'i' :      base = 10;
+                                                       goto canBeSigned;
+                               case 'u' :      base = 10;
+                                                       goto notSigned;
+                               case 'o' :      base = 8;
+                                                       goto notSigned;
+                               case 'b' :      base = 2;
+                                                       goto notSigned;
+                               case 'p' :      n = va_arg(arg, uintptr_t);
+                                                       F.havePrecision = 1;
+                                                       F.precision = (sizeof(uintptr_t) == 4) ? 8 : 16;
+                                                       F.sign = 0;
+                                                       base = 16;
+                                                       c = 'x';
+                                                       goto number;
+                               case 'x' :      digits = "0123456789abcdef";
+                               case 'X' :      base = 16;
+                                                       goto notSigned;
+                               canBeSigned:
+                                                       #if TYPE_LONGLONG_NATIVE
+                                                               if (F.lSize == 1) n = (unsigned_long_long_compat)va_arg(arg, long);
+                                                               else if (F.lSize == 2) n = (unsigned_long_long_compat)va_arg(arg, long_long_compat);
+                                                               else n = (unsigned_long_long_compat)va_arg(arg, int);
+                                                       #else
+                                                               if (F.lSize == 1) n = (unsigned long)va_arg(arg, long);
+                                                               else if (F.lSize == 2) goto exit;
+                                                               else n = (unsigned long)va_arg(arg, int);
+                                                       #endif
+                                                       if (F.hSize) n = (short) n;
+                                                       #if TYPE_LONGLONG_NATIVE
+                                                               if ((long_long_compat) n < 0) { n = (unsigned_long_long_compat)-(long_long_compat)n; F.sign = '-'; }
+                                                       #else
+                                                               if ((long) n < 0) { n = (unsigned long)-(long)n; F.sign = '-'; }
+                                                       #endif
+                                                       else if (F.forceSign) F.sign = '+';
+                                                       goto number;
+                               
+                               notSigned:      if (F.lSize == 1) n = va_arg(arg, unsigned long);
+                                                       else if (F.lSize == 2)
+                                                               {
+                                                               #if TYPE_LONGLONG_NATIVE
+                                                                       n = va_arg(arg, unsigned_long_long_compat);
+                                                               #else
+                                                                       goto exit;
+                                                               #endif
+                                                               }
+                                                       else n = va_arg(arg, unsigned int);
+                                                       if (F.hSize) n = (unsigned short) n;
+                                                       F.sign = 0;
+                                                       goto number;
+                               
+                               number:         if (!F.havePrecision)
+                                                               {
+                                                               if (F.zeroPad)
+                                                                       {
+                                                                       F.precision = F.fieldWidth;
+                                                                       if (F.altForm) F.precision -= 2;
+                                                                       if (F.sign) --F.precision;
+                                                                       }
+                                                               if (F.precision < 1) F.precision = 1;
+                                                               }
+                                                       if (F.precision > mDNS_VACB_Size - 1)
+                                                               F.precision = mDNS_VACB_Size - 1;
+                                                       for (i = 0; n; n /= base, i++) *--s = (char)(digits[n % base]);
+                                                       for (; i < F.precision; i++) *--s = '0';
+                                                       if (F.altForm) { *--s = (char)c; *--s = '0'; i += 2; }
+                                                       if (F.sign) { *--s = F.sign; i++; }
+                                                       break;
+       
+                               case 'a' :      {
+                                                       unsigned char *a = va_arg(arg, unsigned char *);
+                                                       char pre[4] = "";
+                                                       char post[32] = "";
+                                                       if (!a) { static char emsg[] = "<<NULL>>"; s = emsg; i = sizeof(emsg)-1; }
+                                                       else
+                                                               {
+                                                               s = mDNS_VACB;  // Adjust s to point to the start of the buffer, not the end
+                                                               if (F.altForm == 1)
+                                                                       {
+                                                                       #if(defined(MDNS_DEBUGMSGS))
+                                                                               mDNSAddr *ip = (mDNSAddr*)a;
+                                                                               switch (ip->type)
+                                                                                       {
+                                                                                       case mDNSAddrType_IPv4: F.precision =  4; a = (unsigned char *)&ip->ip.v4; break;
+                                                                                       case mDNSAddrType_IPv6: F.precision = 16; a = (unsigned char *)&ip->ip.v6; break;
+                                                                                       default:                F.precision =  0; break;
+                                                                                       }
+                                                                       #else
+                                                                               F.precision = 0;        // mDNSEmbeddedAPI.h not included so no mDNSAddr support
+                                                                       #endif
+                                                                       }
+                                                               else if (F.altForm == 2)
+                                                                       {
+                                                                       #ifdef AF_INET
+                                                                               const struct sockaddr *sa;
+                                                                               unsigned char *port;
+                                                                               sa = (const struct sockaddr*)a;
+                                                                               switch (sa->sa_family)
+                                                                                       {
+                                                                                       case AF_INET:  F.precision =  4; a = (unsigned char*)&((const struct sockaddr_in *)a)->sin_addr;
+                                                                                                      port = (unsigned char*)&((const struct sockaddr_in *)sa)->sin_port;
+                                                                                                      DebugSNPrintF(post, sizeof(post), ":%d", (port[0] << 8) | port[1]); break;
+                                                                                       #ifdef AF_INET6
+                                                                                       case AF_INET6: F.precision = 16; a = (unsigned char*)&((const struct sockaddr_in6 *)a)->sin6_addr; 
+                                                                                                      pre[0] = '['; pre[1] = '\0';
+                                                                                                      port = (unsigned char*)&((const struct sockaddr_in6 *)sa)->sin6_port;
+                                                                                                      DebugSNPrintF(post, sizeof(post), "%%%d]:%d", 
+                                                                                                               (int)((const struct sockaddr_in6 *)sa)->sin6_scope_id,
+                                                                                                               (port[0] << 8) | port[1]); break;
+                                                                                       #endif
+                                                                                       default:       F.precision =  0; break;
+                                                                                       }
+                                                                       #else
+                                                                               F.precision = 0;        // socket interfaces not included so no sockaddr support
+                                                                       #endif
+                                                                       }
+                                                               switch (F.precision)
+                                                                       {
+                                                                       case  4: i = DebugSNPrintF(mDNS_VACB, sizeof(mDNS_VACB), "%d.%d.%d.%d%s",
+                                                                                                               a[0], a[1], a[2], a[3], post); break;
+                                                                       case  6: i = DebugSNPrintF(mDNS_VACB, sizeof(mDNS_VACB), "%02X:%02X:%02X:%02X:%02X:%02X",
+                                                                                                               a[0], a[1], a[2], a[3], a[4], a[5]); break;
+                                                                       case  8: i = DebugSNPrintF(mDNS_VACB, sizeof(mDNS_VACB), "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
+                                                                                                               a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); break;
+                                                                       case 16: i = DebugSNPrintF(mDNS_VACB, sizeof(mDNS_VACB), 
+                                                                                                               "%s%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X%s",
+                                                                                                               pre, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], 
+                                                                                                               a[9], a[10], a[11], a[12], a[13], a[14], a[15], post); break;           
+                                                                       default: i = DebugSNPrintF(mDNS_VACB, sizeof(mDNS_VACB), "%s", "<< ERROR: Must specify address size "
+                                                                                                               "(i.e. %.4a=IPv4, %.6a=Ethernet, %.8a=Fibre Channel %.16a=IPv6) >>"); break;
+                                                                       }
+                                                               }
+                                                       }
+                                                       break;
+
+                               case 'U' :      {
+                                                       unsigned char *a = va_arg(arg, unsigned char *);
+                                                       if (!a) { static char emsg[] = "<<NULL>>"; s = emsg; i = sizeof(emsg)-1; }
+                                                       else
+                                                               {
+                                                               s = mDNS_VACB;  // Adjust s to point to the start of the buffer, not the end
+                                                               i = DebugSNPrintF(mDNS_VACB, sizeof(mDNS_VACB), "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+                                                                               *((uint32_t*) &a[0]), *((uint16_t*) &a[4]), *((uint16_t*) &a[6]), 
+                                                                               a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]); break;
+                                                               }
+                                                       }
+                                                       break;
+
+                               case 'c' :      *--s = (char)va_arg(arg, int); i = 1; break;
+       
+                               case 'C' :      if (F.lSize) n = va_arg(arg, unsigned long);
+                                                       else n = va_arg(arg, unsigned int);
+                                                       if (F.hSize) n = (unsigned short) n;
+                                                       c = (int)( n        & 0xFF); *--s = (char)(DebugIsPrint(c) ? c : '^');
+                                                       c = (int)((n >>  8) & 0xFF); *--s = (char)(DebugIsPrint(c) ? c : '^');
+                                                       c = (int)((n >> 16) & 0xFF); *--s = (char)(DebugIsPrint(c) ? c : '^');
+                                                       c = (int)((n >> 24) & 0xFF); *--s = (char)(DebugIsPrint(c) ? c : '^');
+                                                       i = 4;
+                                                       break;
+       
+                               case 's' :      s = va_arg(arg, char *);
+                                                       if (!s) { static char emsg[] = "<<NULL>>"; s = emsg; i = sizeof(emsg)-1; }
+                                                       else switch (F.altForm)
+                                                               {
+                                                               case 0: i=0;
+                                                                               if (F.havePrecision)                            // C string
+                                                                                       {
+                                                                                       while((i < F.precision) && s[i]) i++;
+                                                                                       // Make sure we don't truncate in the middle of a UTF-8 character.
+                                                                                       // If the last character is part of a multi-byte UTF-8 character, back up to the start of it.
+                                                                                       j=0;
+                                                                                       while((i > 0) && ((c = s[i-1]) & 0x80)) { j++; i--; if((c & 0xC0) != 0x80) break; }
+                                                                                       // If the actual count of UTF-8 characters matches the encoded UTF-8 count, add it back.
+                                                                                       if((j > 1) && (j <= 6))
+                                                                                               {
+                                                                                               int test = (0xFF << (8-j)) & 0xFF;
+                                                                                               int mask = test | (1 << ((8-j)-1));
+                                                                                               if((c & mask) == test) i += j;
+                                                                                               }
+                                                                                       }
+                                                                               else
+                                                                                       while(s[i]) i++;
+                                                                               break;                                                          
+                                                               case 1: i = (unsigned char) *s++; break;        // Pascal string
+                                                               case 2: {                                                                       // DNS label-sequence name
+                                                                               unsigned char *a = (unsigned char *)s;
+                                                                               s = mDNS_VACB;  // Adjust s to point to the start of the buffer, not the end
+                                                                               if (*a == 0) *s++ = '.';        // Special case for root DNS name
+                                                                               while (*a)
+                                                                                       {
+                                                                                       if (*a > 63) { s += DebugSNPrintF(s, mDNS_VACB_Remain(s), "<<INVALID LABEL LENGTH %u>>", *a); break; }
+                                                                                       if (s + *a >= &mDNS_VACB[254]) { s += DebugSNPrintF(s, mDNS_VACB_Remain(s), "<<NAME TOO LONG>>"); break; }
+                                                                                       s += DebugSNPrintF(s, mDNS_VACB_Remain(s), "%#s.", a);
+                                                                                       a += 1 + *a;
+                                                                                       }
+                                                                               i = (size_t)(s - mDNS_VACB);
+                                                                               s = mDNS_VACB;  // Reset s back to the start of the buffer
+                                                                               break;
+                                                                               }
+                                                               }
+                                                       if (F.havePrecision && i > F.precision)         // Make sure we don't truncate in the middle of a UTF-8 character
+                                                               { i = F.precision; while (i>0 && (s[i] & 0xC0) == 0x80) i--; }
+                                                       break;
+                               
+                               case 'S':       {       // UTF-16 string
+                                                       unsigned char *a = va_arg(arg, unsigned char *);
+                                                       uint16_t      *u = (uint16_t*)a;
+                                                       if (!u) { static char emsg[] = "<<NULL>>"; s = emsg; i = sizeof(emsg)-1; }
+                                                       if ((!F.havePrecision || F.precision))
+                                                               {
+                                                               if      ((a[0] == 0xFE) && (a[1] == 0xFF)) { F.altForm = 1; u += 1; a += 2; F.precision--; }    // Big Endian
+                                                               else if ((a[0] == 0xFF) && (a[1] == 0xFE)) { F.altForm = 2; u += 1; a += 2; F.precision--; }    // Little Endian
+                                                               }
+                                                       s = mDNS_VACB;  // Adjust s to point to the start of the buffer, not the end
+                                                       switch (F.altForm)
+                                                               {
+                                                               case 0: while ((!F.havePrecision || (i < F.precision)) && u[i] && mDNS_VACB_Remain(s))  // Host Endian
+                                                                                       { c = u[i]; *s++ = (char)(DebugIsPrint(c) ? c : '^'); i++; }
+                                                                               break;
+                                                               case 1: while ((!F.havePrecision || (i < F.precision)) && u[i] && mDNS_VACB_Remain(s))  // Big Endian
+                                                                                       { c = ((a[0] << 8) | a[1]) & 0xFF; *s++ = (char)(DebugIsPrint(c) ? c : '^'); i++; a += 2; }
+                                                                               break;
+                                                               case 2: while ((!F.havePrecision || (i < F.precision)) && u[i] && mDNS_VACB_Remain(s))  // Little Endian
+                                                                                       { c = ((a[1] << 8) | a[0]) & 0xFF; *s++ = (char)(DebugIsPrint(c) ? c : '^'); i++; a += 2; }
+                                                                               break;
+                                                               }
+                                                       }
+                                                       s = mDNS_VACB;  // Reset s back to the start of the buffer
+                                                       break;
+                       
+                       #if TARGET_OS_MAC
+                               case '@':       {       // Cocoa/CoreFoundation object
+                                                       CFTypeRef cfObj;
+                                                       CFStringRef cfStr;
+                                                       cfObj = (CFTypeRef) va_arg(arg, void *);
+                                                       cfStr = (CFGetTypeID(cfObj) == CFStringGetTypeID()) ? (CFStringRef)CFRetain(cfObj) : CFCopyDescription(cfObj);
+                                                       s = mDNS_VACB;  // Adjust s to point to the start of the buffer, not the end
+                                                       if (cfStr)
+                                                               {
+                                                               CFRange range;
+                                                               CFIndex m;
+                                                               range = CFRangeMake(0, CFStringGetLength(cfStr));
+                                                               m = 0;
+                                                               CFStringGetBytes(cfStr, range, kCFStringEncodingUTF8, '^', false, (UInt8*)mDNS_VACB, (CFIndex)sizeof(mDNS_VACB), &m);
+                                                               CFRelease(cfStr);
+                                                               i = (size_t) m;
+                                                               }
+                                                       else
+                                                               {
+                                                               i = DebugSNPrintF(mDNS_VACB, sizeof(mDNS_VACB), "%s", "ERROR: <invalid CF object>" );
+                                                               }
+                                                       }
+                                                       if (F.havePrecision && i > F.precision)         // Make sure we don't truncate in the middle of a UTF-8 character
+                                                               { i = F.precision; while (i>0 && (s[i] & 0xC0) == 0x80) i--; }
+                                                       break;
+                       #endif
+
+                               case 'm' :      {       // Error Message
+                                                       long err;
+                                                       if (F.lSize) err = va_arg(arg, long);
+                                                       else err = va_arg(arg, int);
+                                                       if (F.hSize) err = (short)err;
+                                                       DebugGetErrorString(err, mDNS_VACB, sizeof(mDNS_VACB));
+                                                       s = mDNS_VACB;  // Adjust s to point to the start of the buffer, not the end
+                                                       for(i=0;s[i];i++) {}
+                                                       }
+                                                       break;
+
+                               case 'H' :      {       // Hex Dump
+                                                       void *a = va_arg(arg, void *);
+                                                       size_t size = (size_t)va_arg(arg, int);
+                                                       size_t max = (size_t)va_arg(arg, int);
+                                                       DebugFlags flags = 
+                                                               kDebugFlagsNoAddress | kDebugFlagsNoOffset | kDebugFlagsNoNewLine |
+                                                               kDebugFlags8BitSeparator | kDebugFlagsNo32BitSeparator |
+                                                               kDebugFlagsNo16ByteHexPad | kDebugFlagsNoByteCount;
+                                                       if (F.altForm == 0) flags |= kDebugFlagsNoASCII;
+                                                       size = (max < size) ? max : size;
+                                                       s = mDNS_VACB;  // Adjust s to point to the start of the buffer, not the end
+                                                       i = DebugHexDump(kDebugLevelMax, 0, NULL, 0, 0, NULL, 0, a, a, size, flags, mDNS_VACB, sizeof(mDNS_VACB));
+                                                       }
+                                                       break;
+                               
+                               case 'v' :      {       // Version
+                                                       uint32_t version;
+                                                       version = va_arg(arg, unsigned int);
+                                                       DebugNumVersionToString(version, mDNS_VACB);
+                                                       s = mDNS_VACB;  // Adjust s to point to the start of the buffer, not the end
+                                                       for(i=0;s[i];i++) {}
+                                                       }
+                                                       break;
+
+                               case 'n' :      s = va_arg(arg, char *);
+                                                       if      (F.hSize) * (short *) s = (short)nwritten;
+                                                       else if (F.lSize) * (long  *) s = (long)nwritten;
+                                                       else              * (int   *) s = (int)nwritten;
+                                                       continue;
+       
+                               default:        s = mDNS_VACB;
+                                                       i = DebugSNPrintF(mDNS_VACB, sizeof(mDNS_VACB), "<<UNKNOWN FORMAT CONVERSION CODE %%%c>>", c);
+
+                               case '%' :      *sbuffer++ = (char)c;
+                                                       if (++nwritten >= buflen) goto exit;
+                                                       break;
+                               }
+       
+                       if (i < F.fieldWidth && !F.leftJustify)                 // Pad on the left
+                               do      {
+                                       *sbuffer++ = ' ';
+                                       if (++nwritten >= buflen) goto exit;
+                                       } while (i < --F.fieldWidth);
+       
+                       if (i > buflen - nwritten)      // Make sure we don't truncate in the middle of a UTF-8 character
+                               { i = buflen - nwritten; while (i>0 && (s[i] & 0xC0) == 0x80) i--; }
+                       for (j=0; j<i; j++) *sbuffer++ = *s++;                  // Write the converted result
+                       nwritten += i;
+                       if (nwritten >= buflen) goto exit;
+       
+                       for (; i < F.fieldWidth; i++)                                   // Pad on the right
+                               {
+                               *sbuffer++ = ' ';
+                               if (++nwritten >= buflen) goto exit;
+                               }
+                       }
+               }
+       exit:
+       *sbuffer++ = 0;
+       return(nwritten);
+       }
+
+//===========================================================================================================================
+//     DebugGetErrorString
+//===========================================================================================================================
+
+DEBUG_EXPORT const char *      DebugGetErrorString( int_least32_t inErrorCode, char *inBuffer, size_t inBufferSize )
+{
+       const char *            s;
+       char *                          dst;
+       char *                          end;
+#if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+       char                            buffer[ 256 ];
+#endif
+       
+       switch( inErrorCode )
+       {
+               #define CaseErrorString( X, STR )                                       case X: s = STR; break
+               #define CaseErrorStringify( X )                                         case X: s = # X; break
+               #define CaseErrorStringifyHardCode( VALUE, X )          case VALUE: s = # X; break
+               
+               // General Errors
+               
+               CaseErrorString( 0,  "no error" );
+               CaseErrorString( 1,  "in-progress/waiting" );
+               CaseErrorString( -1, "catch-all unknown error" );
+                               
+               // ACP Errors
+               
+               CaseErrorStringifyHardCode( -2,  kACPBadRequestErr );
+               CaseErrorStringifyHardCode( -3,  kACPNoMemoryErr );
+               CaseErrorStringifyHardCode( -4,  kACPBadParamErr );
+               CaseErrorStringifyHardCode( -5,  kACPNotFoundErr );
+               CaseErrorStringifyHardCode( -6,  kACPBadChecksumErr );
+               CaseErrorStringifyHardCode( -7,  kACPCommandNotHandledErr );
+               CaseErrorStringifyHardCode( -8,  kACPNetworkErr );
+               CaseErrorStringifyHardCode( -9,  kACPDuplicateCommandHandlerErr );
+               CaseErrorStringifyHardCode( -10, kACPUnknownPropertyErr );
+               CaseErrorStringifyHardCode( -11, kACPImmutablePropertyErr );
+               CaseErrorStringifyHardCode( -12, kACPBadPropertyValueErr );
+               CaseErrorStringifyHardCode( -13, kACPNoResourcesErr );
+               CaseErrorStringifyHardCode( -14, kACPBadOptionErr );
+               CaseErrorStringifyHardCode( -15, kACPBadSizeErr );
+               CaseErrorStringifyHardCode( -16, kACPBadPasswordErr );
+               CaseErrorStringifyHardCode( -17, kACPNotInitializedErr );
+               CaseErrorStringifyHardCode( -18, kACPNonReadablePropertyErr );
+               CaseErrorStringifyHardCode( -19, kACPBadVersionErr );
+               CaseErrorStringifyHardCode( -20, kACPBadSignatureErr );
+               CaseErrorStringifyHardCode( -21, kACPBadIndexErr );
+               CaseErrorStringifyHardCode( -22, kACPUnsupportedErr );
+               CaseErrorStringifyHardCode( -23, kACPInUseErr );
+               CaseErrorStringifyHardCode( -24, kACPParamCountErr );
+               CaseErrorStringifyHardCode( -25, kACPIDErr );
+               CaseErrorStringifyHardCode( -26, kACPFormatErr );
+               CaseErrorStringifyHardCode( -27, kACPUnknownUserErr );
+               CaseErrorStringifyHardCode( -28, kACPAccessDeniedErr );
+               CaseErrorStringifyHardCode( -29, kACPIncorrectFWErr );
+               
+               // Common Services Errors
+               
+               CaseErrorStringify( kUnknownErr );
+               CaseErrorStringify( kOptionErr );
+               CaseErrorStringify( kSelectorErr );
+               CaseErrorStringify( kExecutionStateErr );
+               CaseErrorStringify( kPathErr );
+               CaseErrorStringify( kParamErr );
+               CaseErrorStringify( kParamCountErr );
+               CaseErrorStringify( kCommandErr );
+               CaseErrorStringify( kIDErr );
+               CaseErrorStringify( kStateErr );
+               CaseErrorStringify( kRangeErr );
+               CaseErrorStringify( kRequestErr );
+               CaseErrorStringify( kResponseErr );
+               CaseErrorStringify( kChecksumErr );
+               CaseErrorStringify( kNotHandledErr );
+               CaseErrorStringify( kVersionErr );
+               CaseErrorStringify( kSignatureErr );
+               CaseErrorStringify( kFormatErr );
+               CaseErrorStringify( kNotInitializedErr );
+               CaseErrorStringify( kAlreadyInitializedErr );
+               CaseErrorStringify( kNotInUseErr );
+               CaseErrorStringify( kInUseErr );
+               CaseErrorStringify( kTimeoutErr );
+               CaseErrorStringify( kCanceledErr );
+               CaseErrorStringify( kAlreadyCanceledErr );
+               CaseErrorStringify( kCannotCancelErr );
+               CaseErrorStringify( kDeletedErr );
+               CaseErrorStringify( kNotFoundErr );
+               CaseErrorStringify( kNoMemoryErr );
+               CaseErrorStringify( kNoResourcesErr );
+               CaseErrorStringify( kDuplicateErr );
+               CaseErrorStringify( kImmutableErr );
+               CaseErrorStringify( kUnsupportedDataErr );
+               CaseErrorStringify( kIntegrityErr );
+               CaseErrorStringify( kIncompatibleErr );
+               CaseErrorStringify( kUnsupportedErr );
+               CaseErrorStringify( kUnexpectedErr );
+               CaseErrorStringify( kValueErr );
+               CaseErrorStringify( kNotReadableErr );
+               CaseErrorStringify( kNotWritableErr );
+               CaseErrorStringify( kBadReferenceErr );
+               CaseErrorStringify( kFlagErr );
+               CaseErrorStringify( kMalformedErr );
+               CaseErrorStringify( kSizeErr );
+               CaseErrorStringify( kNameErr );
+               CaseErrorStringify( kNotReadyErr );
+               CaseErrorStringify( kReadErr );
+               CaseErrorStringify( kWriteErr );
+               CaseErrorStringify( kMismatchErr );
+               CaseErrorStringify( kDateErr );
+               CaseErrorStringify( kUnderrunErr );
+               CaseErrorStringify( kOverrunErr );
+               CaseErrorStringify( kEndingErr );
+               CaseErrorStringify( kConnectionErr );
+               CaseErrorStringify( kAuthenticationErr );
+               CaseErrorStringify( kOpenErr );
+               CaseErrorStringify( kTypeErr );
+               CaseErrorStringify( kSkipErr );
+               CaseErrorStringify( kNoAckErr );
+               CaseErrorStringify( kCollisionErr );
+               CaseErrorStringify( kBackoffErr );
+               CaseErrorStringify( kNoAddressAckErr );
+               CaseErrorStringify( kBusyErr );
+               CaseErrorStringify( kNoSpaceErr );
+               
+               // mDNS/DNS-SD Errors
+               
+               CaseErrorStringifyHardCode( -65537, mStatus_UnknownErr );
+               CaseErrorStringifyHardCode( -65538, mStatus_NoSuchNameErr );
+               CaseErrorStringifyHardCode( -65539, mStatus_NoMemoryErr );
+               CaseErrorStringifyHardCode( -65540, mStatus_BadParamErr );
+               CaseErrorStringifyHardCode( -65541, mStatus_BadReferenceErr );
+               CaseErrorStringifyHardCode( -65542, mStatus_BadStateErr );
+               CaseErrorStringifyHardCode( -65543, mStatus_BadFlagsErr );
+               CaseErrorStringifyHardCode( -65544, mStatus_UnsupportedErr );
+               CaseErrorStringifyHardCode( -65545, mStatus_NotInitializedErr );
+               CaseErrorStringifyHardCode( -65546, mStatus_NoCache );
+               CaseErrorStringifyHardCode( -65547, mStatus_AlreadyRegistered );
+               CaseErrorStringifyHardCode( -65548, mStatus_NameConflict );
+               CaseErrorStringifyHardCode( -65549, mStatus_Invalid );
+               CaseErrorStringifyHardCode( -65550, mStatus_GrowCache );
+               CaseErrorStringifyHardCode( -65551, mStatus_BadInterfaceErr );
+               CaseErrorStringifyHardCode( -65552, mStatus_Incompatible );
+               CaseErrorStringifyHardCode( -65791, mStatus_ConfigChanged );
+               CaseErrorStringifyHardCode( -65792, mStatus_MemFree );
+               
+               // RSP Errors
+               
+               CaseErrorStringifyHardCode( -400000, kRSPUnknownErr );
+               CaseErrorStringifyHardCode( -400050, kRSPParamErr );
+               CaseErrorStringifyHardCode( -400108, kRSPNoMemoryErr );
+               CaseErrorStringifyHardCode( -405246, kRSPRangeErr );
+               CaseErrorStringifyHardCode( -409057, kRSPSizeErr );
+               CaseErrorStringifyHardCode( -400200, kRSPHardwareErr );
+               CaseErrorStringifyHardCode( -401712, kRSPTimeoutErr );  
+               CaseErrorStringifyHardCode( -402053, kRSPUnsupportedErr );
+               CaseErrorStringifyHardCode( -402419, kRSPIDErr );
+               CaseErrorStringifyHardCode( -403165, kRSPFlagErr );
+               CaseErrorString(                        -200000, "kRSPControllerStatusBase - 0x50" );           
+               CaseErrorString(                        -200080, "kRSPCommandSucceededErr - 0x50" );
+               CaseErrorString(                        -200001, "kRSPCommandFailedErr - 0x01" );
+               CaseErrorString(                        -200051, "kRSPChecksumErr - 0x33" );
+               CaseErrorString(                        -200132, "kRSPCommandTimeoutErr - 0x84" );
+               CaseErrorString(                        -200034, "kRSPPasswordRequiredErr - 0x22 OBSOLETE" );
+               CaseErrorString(                        -200128, "kRSPCanceledErr - 0x02 Async" );
+               
+               // XML Errors
+               
+               CaseErrorStringifyHardCode( -100043, kXMLNotFoundErr );
+               CaseErrorStringifyHardCode( -100050, kXMLParamErr );
+               CaseErrorStringifyHardCode( -100108, kXMLNoMemoryErr );
+               CaseErrorStringifyHardCode( -100206, kXMLFormatErr );
+               CaseErrorStringifyHardCode( -100586, kXMLNoRootElementErr );
+               CaseErrorStringifyHardCode( -101703, kXMLWrongDataTypeErr );
+               CaseErrorStringifyHardCode( -101726, kXMLKeyErr );
+               CaseErrorStringifyHardCode( -102053, kXMLUnsupportedErr );
+               CaseErrorStringifyHardCode( -102063, kXMLMissingElementErr );
+               CaseErrorStringifyHardCode( -103026, kXMLParseErr );
+               CaseErrorStringifyHardCode( -103159, kXMLBadDataErr );
+               CaseErrorStringifyHardCode( -103170, kXMLBadNameErr );
+               CaseErrorStringifyHardCode( -105246, kXMLRangeErr );
+               CaseErrorStringifyHardCode( -105251, kXMLUnknownElementErr );
+               CaseErrorStringifyHardCode( -108739, kXMLMalformedInputErr );
+               CaseErrorStringifyHardCode( -109057, kXMLBadSizeErr );
+               CaseErrorStringifyHardCode( -101730, kXMLMissingChildElementErr );
+               CaseErrorStringifyHardCode( -102107, kXMLMissingParentElementErr );
+               CaseErrorStringifyHardCode( -130587, kXMLNonRootElementErr );
+               CaseErrorStringifyHardCode( -102015, kXMLDateErr );
+
+       #if( __MACH__ )
+       
+               // Mach Errors
+
+               CaseErrorStringifyHardCode( 0x00002000, MACH_MSG_IPC_SPACE );
+               CaseErrorStringifyHardCode( 0x00001000, MACH_MSG_VM_SPACE );
+               CaseErrorStringifyHardCode( 0x00000800, MACH_MSG_IPC_KERNEL );
+               CaseErrorStringifyHardCode( 0x00000400, MACH_MSG_VM_KERNEL );
+               CaseErrorStringifyHardCode( 0x10000001, MACH_SEND_IN_PROGRESS );
+               CaseErrorStringifyHardCode( 0x10000002, MACH_SEND_INVALID_DATA );
+               CaseErrorStringifyHardCode( 0x10000003, MACH_SEND_INVALID_DEST );
+               CaseErrorStringifyHardCode( 0x10000004, MACH_SEND_TIMED_OUT );
+               CaseErrorStringifyHardCode( 0x10000007, MACH_SEND_INTERRUPTED );
+               CaseErrorStringifyHardCode( 0x10000008, MACH_SEND_MSG_TOO_SMALL );
+               CaseErrorStringifyHardCode( 0x10000009, MACH_SEND_INVALID_REPLY );
+               CaseErrorStringifyHardCode( 0x1000000A, MACH_SEND_INVALID_RIGHT );
+               CaseErrorStringifyHardCode( 0x1000000B, MACH_SEND_INVALID_NOTIFY );
+               CaseErrorStringifyHardCode( 0x1000000C, MACH_SEND_INVALID_MEMORY );
+               CaseErrorStringifyHardCode( 0x1000000D, MACH_SEND_NO_BUFFER );
+               CaseErrorStringifyHardCode( 0x1000000E, MACH_SEND_TOO_LARGE );
+               CaseErrorStringifyHardCode( 0x1000000F, MACH_SEND_INVALID_TYPE );
+               CaseErrorStringifyHardCode( 0x10000010, MACH_SEND_INVALID_HEADER );
+               CaseErrorStringifyHardCode( 0x10000011, MACH_SEND_INVALID_TRAILER );
+               CaseErrorStringifyHardCode( 0x10000015, MACH_SEND_INVALID_RT_OOL_SIZE );
+               CaseErrorStringifyHardCode( 0x10004001, MACH_RCV_IN_PROGRESS );
+               CaseErrorStringifyHardCode( 0x10004002, MACH_RCV_INVALID_NAME );
+               CaseErrorStringifyHardCode( 0x10004003, MACH_RCV_TIMED_OUT );
+               CaseErrorStringifyHardCode( 0x10004004, MACH_RCV_TOO_LARGE );
+               CaseErrorStringifyHardCode( 0x10004005, MACH_RCV_INTERRUPTED );
+               CaseErrorStringifyHardCode( 0x10004006, MACH_RCV_PORT_CHANGED );
+               CaseErrorStringifyHardCode( 0x10004007, MACH_RCV_INVALID_NOTIFY );
+               CaseErrorStringifyHardCode( 0x10004008, MACH_RCV_INVALID_DATA );
+               CaseErrorStringifyHardCode( 0x10004009, MACH_RCV_PORT_DIED );
+               CaseErrorStringifyHardCode( 0x1000400A, MACH_RCV_IN_SET );
+               CaseErrorStringifyHardCode( 0x1000400B, MACH_RCV_HEADER_ERROR );
+               CaseErrorStringifyHardCode( 0x1000400C, MACH_RCV_BODY_ERROR );
+               CaseErrorStringifyHardCode( 0x1000400D, MACH_RCV_INVALID_TYPE );
+               CaseErrorStringifyHardCode( 0x1000400E, MACH_RCV_SCATTER_SMALL );
+               CaseErrorStringifyHardCode( 0x1000400F, MACH_RCV_INVALID_TRAILER );
+               CaseErrorStringifyHardCode( 0x10004011, MACH_RCV_IN_PROGRESS_TIMED );
+
+               // Mach OSReturn Errors
+
+               CaseErrorStringifyHardCode( 0xDC000001, kOSReturnError );
+               CaseErrorStringifyHardCode( 0xDC004001, kOSMetaClassInternal );
+               CaseErrorStringifyHardCode( 0xDC004002, kOSMetaClassHasInstances );
+               CaseErrorStringifyHardCode( 0xDC004003, kOSMetaClassNoInit );
+               CaseErrorStringifyHardCode( 0xDC004004, kOSMetaClassNoTempData );
+               CaseErrorStringifyHardCode( 0xDC004005, kOSMetaClassNoDicts );
+               CaseErrorStringifyHardCode( 0xDC004006, kOSMetaClassNoKModSet );
+               CaseErrorStringifyHardCode( 0xDC004007, kOSMetaClassNoInsKModSet );
+               CaseErrorStringifyHardCode( 0xDC004008, kOSMetaClassNoSuper );
+               CaseErrorStringifyHardCode( 0xDC004009, kOSMetaClassInstNoSuper );
+               CaseErrorStringifyHardCode( 0xDC00400A, kOSMetaClassDuplicateClass );
+
+               // IOKit Errors
+
+               CaseErrorStringifyHardCode( 0xE00002BC, kIOReturnError );
+               CaseErrorStringifyHardCode( 0xE00002BD, kIOReturnNoMemory );
+               CaseErrorStringifyHardCode( 0xE00002BE, kIOReturnNoResources );
+               CaseErrorStringifyHardCode( 0xE00002BF, kIOReturnIPCError );
+               CaseErrorStringifyHardCode( 0xE00002C0, kIOReturnNoDevice );
+               CaseErrorStringifyHardCode( 0xE00002C1, kIOReturnNotPrivileged );
+               CaseErrorStringifyHardCode( 0xE00002C2, kIOReturnBadArgument );
+               CaseErrorStringifyHardCode( 0xE00002C3, kIOReturnLockedRead );
+               CaseErrorStringifyHardCode( 0xE00002C4, kIOReturnLockedWrite );
+               CaseErrorStringifyHardCode( 0xE00002C5, kIOReturnExclusiveAccess );
+               CaseErrorStringifyHardCode( 0xE00002C6, kIOReturnBadMessageID );
+               CaseErrorStringifyHardCode( 0xE00002C7, kIOReturnUnsupported );
+               CaseErrorStringifyHardCode( 0xE00002C8, kIOReturnVMError );
+               CaseErrorStringifyHardCode( 0xE00002C9, kIOReturnInternalError );
+               CaseErrorStringifyHardCode( 0xE00002CA, kIOReturnIOError );
+               CaseErrorStringifyHardCode( 0xE00002CC, kIOReturnCannotLock );
+               CaseErrorStringifyHardCode( 0xE00002CD, kIOReturnNotOpen );
+               CaseErrorStringifyHardCode( 0xE00002CE, kIOReturnNotReadable );
+               CaseErrorStringifyHardCode( 0xE00002CF, kIOReturnNotWritable );
+               CaseErrorStringifyHardCode( 0xE00002D0, kIOReturnNotAligned );
+               CaseErrorStringifyHardCode( 0xE00002D1, kIOReturnBadMedia );
+               CaseErrorStringifyHardCode( 0xE00002D2, kIOReturnStillOpen );
+               CaseErrorStringifyHardCode( 0xE00002D3, kIOReturnRLDError );
+               CaseErrorStringifyHardCode( 0xE00002D4, kIOReturnDMAError );
+               CaseErrorStringifyHardCode( 0xE00002D5, kIOReturnBusy );
+               CaseErrorStringifyHardCode( 0xE00002D6, kIOReturnTimeout );
+               CaseErrorStringifyHardCode( 0xE00002D7, kIOReturnOffline );
+               CaseErrorStringifyHardCode( 0xE00002D8, kIOReturnNotReady );
+               CaseErrorStringifyHardCode( 0xE00002D9, kIOReturnNotAttached );
+               CaseErrorStringifyHardCode( 0xE00002DA, kIOReturnNoChannels );
+               CaseErrorStringifyHardCode( 0xE00002DB, kIOReturnNoSpace );
+               CaseErrorStringifyHardCode( 0xE00002DD, kIOReturnPortExists );
+               CaseErrorStringifyHardCode( 0xE00002DE, kIOReturnCannotWire );
+               CaseErrorStringifyHardCode( 0xE00002DF, kIOReturnNoInterrupt );
+               CaseErrorStringifyHardCode( 0xE00002E0, kIOReturnNoFrames );
+               CaseErrorStringifyHardCode( 0xE00002E1, kIOReturnMessageTooLarge );
+               CaseErrorStringifyHardCode( 0xE00002E2, kIOReturnNotPermitted );
+               CaseErrorStringifyHardCode( 0xE00002E3, kIOReturnNoPower );
+               CaseErrorStringifyHardCode( 0xE00002E4, kIOReturnNoMedia );
+               CaseErrorStringifyHardCode( 0xE00002E5, kIOReturnUnformattedMedia );
+               CaseErrorStringifyHardCode( 0xE00002E6, kIOReturnUnsupportedMode );
+               CaseErrorStringifyHardCode( 0xE00002E7, kIOReturnUnderrun );
+               CaseErrorStringifyHardCode( 0xE00002E8, kIOReturnOverrun );
+               CaseErrorStringifyHardCode( 0xE00002E9, kIOReturnDeviceError     );
+               CaseErrorStringifyHardCode( 0xE00002EA, kIOReturnNoCompletion    );
+               CaseErrorStringifyHardCode( 0xE00002EB, kIOReturnAborted         );
+               CaseErrorStringifyHardCode( 0xE00002EC, kIOReturnNoBandwidth     );
+               CaseErrorStringifyHardCode( 0xE00002ED, kIOReturnNotResponding   );
+               CaseErrorStringifyHardCode( 0xE00002EE, kIOReturnIsoTooOld       );
+               CaseErrorStringifyHardCode( 0xE00002EF, kIOReturnIsoTooNew       );
+               CaseErrorStringifyHardCode( 0xE00002F0, kIOReturnNotFound );
+               CaseErrorStringifyHardCode( 0xE0000001, kIOReturnInvalid );
+
+               // IOKit FireWire Errors
+
+               CaseErrorStringifyHardCode( 0xE0008010, kIOFireWireResponseBase );
+               CaseErrorStringifyHardCode( 0xE0008020, kIOFireWireBusReset );
+               CaseErrorStringifyHardCode( 0xE0008001, kIOConfigNoEntry );
+               CaseErrorStringifyHardCode( 0xE0008002, kIOFireWirePending );
+               CaseErrorStringifyHardCode( 0xE0008003, kIOFireWireLastDCLToken );
+               CaseErrorStringifyHardCode( 0xE0008004, kIOFireWireConfigROMInvalid );
+               CaseErrorStringifyHardCode( 0xE0008005, kIOFireWireAlreadyRegistered );
+               CaseErrorStringifyHardCode( 0xE0008006, kIOFireWireMultipleTalkers );
+               CaseErrorStringifyHardCode( 0xE0008007, kIOFireWireChannelActive );
+               CaseErrorStringifyHardCode( 0xE0008008, kIOFireWireNoListenerOrTalker );
+               CaseErrorStringifyHardCode( 0xE0008009, kIOFireWireNoChannels );
+               CaseErrorStringifyHardCode( 0xE000800A, kIOFireWireChannelNotAvailable );
+               CaseErrorStringifyHardCode( 0xE000800B, kIOFireWireSeparateBus );
+               CaseErrorStringifyHardCode( 0xE000800C, kIOFireWireBadSelfIDs );
+               CaseErrorStringifyHardCode( 0xE000800D, kIOFireWireLowCableVoltage );
+               CaseErrorStringifyHardCode( 0xE000800E, kIOFireWireInsufficientPower );
+               CaseErrorStringifyHardCode( 0xE000800F, kIOFireWireOutOfTLabels );
+               CaseErrorStringifyHardCode( 0xE0008101, kIOFireWireBogusDCLProgram );
+               CaseErrorStringifyHardCode( 0xE0008102, kIOFireWireTalkingAndListening );
+               CaseErrorStringifyHardCode( 0xE0008103, kIOFireWireHardwareSlept );
+               CaseErrorStringifyHardCode( 0xE00087D0, kIOFWMessageServiceIsRequestingClose );
+               CaseErrorStringifyHardCode( 0xE00087D1, kIOFWMessagePowerStateChanged );
+               CaseErrorStringifyHardCode( 0xE00087D2, kIOFWMessageTopologyChanged );
+
+               // IOKit USB Errors
+                               
+               CaseErrorStringifyHardCode( 0xE0004061, kIOUSBUnknownPipeErr );
+               CaseErrorStringifyHardCode( 0xE0004060, kIOUSBTooManyPipesErr );
+               CaseErrorStringifyHardCode( 0xE000405F, kIOUSBNoAsyncPortErr );
+               CaseErrorStringifyHardCode( 0xE000405E, kIOUSBNotEnoughPipesErr );
+               CaseErrorStringifyHardCode( 0xE000405D, kIOUSBNotEnoughPowerErr );
+               CaseErrorStringifyHardCode( 0xE0004057, kIOUSBEndpointNotFound );
+               CaseErrorStringifyHardCode( 0xE0004056, kIOUSBConfigNotFound );
+               CaseErrorStringifyHardCode( 0xE0004051, kIOUSBTransactionTimeout );
+               CaseErrorStringifyHardCode( 0xE0004050, kIOUSBTransactionReturned );
+               CaseErrorStringifyHardCode( 0xE000404F, kIOUSBPipeStalled );
+               CaseErrorStringifyHardCode( 0xE000404E, kIOUSBInterfaceNotFound );
+               CaseErrorStringifyHardCode( 0xE000404D, kIOUSBLowLatencyBufferNotPreviouslyAllocated );
+               CaseErrorStringifyHardCode( 0xE000404C, kIOUSBLowLatencyFrameListNotPreviouslyAllocated );
+               CaseErrorStringifyHardCode( 0xE000404B, kIOUSBHighSpeedSplitError );
+               CaseErrorStringifyHardCode( 0xE0004010, kIOUSBLinkErr );
+               CaseErrorStringifyHardCode( 0xE000400F, kIOUSBNotSent2Err );
+               CaseErrorStringifyHardCode( 0xE000400E, kIOUSBNotSent1Err );
+               CaseErrorStringifyHardCode( 0xE000400D, kIOUSBBufferUnderrunErr );
+               CaseErrorStringifyHardCode( 0xE000400C, kIOUSBBufferOverrunErr );
+               CaseErrorStringifyHardCode( 0xE000400B, kIOUSBReserved2Err );
+               CaseErrorStringifyHardCode( 0xE000400A, kIOUSBReserved1Err );
+               CaseErrorStringifyHardCode( 0xE0004007, kIOUSBWrongPIDErr );
+               CaseErrorStringifyHardCode( 0xE0004006, kIOUSBPIDCheckErr );
+               CaseErrorStringifyHardCode( 0xE0004003, kIOUSBDataToggleErr );
+               CaseErrorStringifyHardCode( 0xE0004002, kIOUSBBitstufErr );
+               CaseErrorStringifyHardCode( 0xE0004001, kIOUSBCRCErr );
+       
+       #endif  // __MACH__
+
+               // Other Errors
+               
+               default:
+                       s = NULL;
+                       #if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+                               if( inBuffer && ( inBufferSize > 0 ) )
+                               {
+                                       DWORD           n;
+                                       
+                                       n = FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD) inErrorCode, 
+                                               MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), buffer, sizeof( buffer ), NULL );
+                                       if( n > 0 )
+                                       {
+                                               // Remove any trailing CR's or LF's since some messages have them.
+                                               
+                                               while( ( n > 0 ) && isspace( ( (unsigned char *) buffer )[ n - 1 ] ) )
+                                               {
+                                                       buffer[ --n ] = '\0';
+                                               }
+                                               s = buffer;
+                                       }
+                               }
+                       #endif
+                       
+                       if( !s )
+                       {
+                               #if( !TARGET_API_MAC_OSX_KERNEL && !TARGET_OS_WINDOWS_CE )
+                                       s = strerror( inErrorCode );
+                               #endif
+                               if( !s )
+                               {
+                                       s = "<unknown error code>";
+                               }
+                       }
+                       break;
+       }
+       
+       // Copy the string to the output buffer. If no buffer is supplied or it is empty, return an empty string.
+       
+       if( inBuffer && ( inBufferSize > 0 ) )
+       {
+               dst = inBuffer;
+               end = dst + ( inBufferSize - 1 );
+               while( ( ( end - dst ) > 0 ) && ( *s != '\0' ) )
+               {
+                       *dst++ = *s++;
+               }
+               *dst = '\0';
+               s = inBuffer;
+       }
+       return( s );
+}
+
+//===========================================================================================================================
+//     DebugHexDump
+//===========================================================================================================================
+
+DEBUG_EXPORT size_t
+       DebugHexDump( 
+               DebugLevel              inLevel, 
+               int                             inIndent, 
+               const char *    inLabel, 
+               size_t                  inLabelSize, 
+               int                             inLabelMinWidth, 
+               const char *    inType, 
+               size_t                  inTypeSize, 
+               const void *    inDataStart, 
+               const void *    inData, 
+               size_t                  inDataSize, 
+               DebugFlags              inFlags, 
+               char *                  outBuffer, 
+               size_t                  inBufferSize )
+{
+       static const char               kHexChars[] = "0123456789ABCDEF";
+       const uint8_t *                 start;
+       const uint8_t *                 src;
+       char *                                  dst;
+       char *                                  end;
+       size_t                                  n;
+       int                                             offset;
+       int                                             width;
+       const char *                    newline;
+       char                                    separator[ 8 ];
+       char *                                  s;
+       
+       DEBUG_UNUSED( inType );
+       DEBUG_UNUSED( inTypeSize );
+       
+       // Set up the function-wide variables.
+       
+       if( inLabelSize == kSizeCString )
+       {
+               inLabelSize = strlen( inLabel );
+       }
+       start   = (const uint8_t *) inData;
+       src     = start;
+       dst             = outBuffer;
+       end             = dst + inBufferSize;
+       offset  = (int)( (intptr_t) inData - (intptr_t) inDataStart );
+       width   = ( (int) inLabelSize > inLabelMinWidth ) ? (int) inLabelSize : inLabelMinWidth;
+       newline = ( inFlags & kDebugFlagsNoNewLine ) ? "" : "\n";
+               
+       // Set up the separator string. This is used to insert spaces on subsequent "lines" when not using newlines.
+       
+       s = separator;
+       if( inFlags & kDebugFlagsNoNewLine )
+       {
+               if( inFlags & kDebugFlags8BitSeparator )
+               {
+                       *s++ = ' ';
+               }
+               if( inFlags & kDebugFlags16BitSeparator )
+               {
+                       *s++ = ' ';
+               }
+               if( !( inFlags & kDebugFlagsNo32BitSeparator ) )
+               {
+                       *s++ = ' ';
+               }
+               check( ( (size_t)( s - separator ) ) < sizeof( separator ) );
+       }
+       *s = '\0';
+       
+       for( ;; )
+       {
+               char            prefixString[ 32 ];
+               char            hexString[ 64 ];
+               char            asciiString[ 32 ];
+               char            byteCountString[ 32 ];
+               int                     c;
+               size_t          chunkSize;
+               size_t          i;
+               
+               // If this is a label-only item (i.e. no data), print the label (accounting for prefix string spacing) and exit.
+               
+               if( inDataSize == 0 )
+               {
+                       if( inLabel && ( inLabelSize > 0 ) )
+                       {
+                               width = 0;
+                               if( !( inFlags & kDebugFlagsNoAddress ) )
+                               {
+                                       width += 8;                     // "00000000"
+                                       if( !( inFlags & kDebugFlagsNoOffset ) )
+                                       {
+                                               width += 1;             // "+"
+                                       }
+                               }
+                               if( inFlags & kDebugFlags32BitOffset )
+                               {
+                                       width += 8;                     // "00000000"
+                               }
+                               else if( !( inFlags & kDebugFlagsNoOffset ) )
+                               {
+                                       width += 4;                     // "0000"
+                               }
+                               
+                               if( outBuffer )
+                               {
+                                       dst += DebugSNPrintF( dst, (size_t)( end - dst ), "%*s" "%-*.*s" "%.*s" "%s", 
+                                               width, "", 
+                                               ( width > 0 ) ? ": " : "", 
+                                               width, (int) inLabelSize, inLabel, 
+                                               newline );
+                               }
+                               else
+                               {
+                                       dst += DebugPrintF( inLevel, "%*s" "%-*.*s" "%.*s" "%s", 
+                                               width, "", 
+                                               ( width > 0 ) ? ": " : "", 
+                                               width, (int) inLabelSize, inLabel, 
+                                               newline );
+                               }
+                       }
+                       break;
+               }
+               
+               // Build the prefix string. It will be in one of the following formats:
+               //
+               // 1) "00000000+0000[0000]"     (address and offset)
+               // 2) "00000000"                        (address only)
+               // 3) "0000[0000]"                      (offset only)
+               // 4) ""                                        (no address or offset)
+               //
+               // Note: If we're printing multiple "lines", but not printing newlines, a space is used to separate.
+               
+               s = prefixString;
+               if( !( inFlags & kDebugFlagsNoAddress ) )
+               {
+                       *s++ = kHexChars[ ( ( (uintptr_t) src ) >> 28 ) & 0xF ];
+                       *s++ = kHexChars[ ( ( (uintptr_t) src ) >> 24 ) & 0xF ];
+                       *s++ = kHexChars[ ( ( (uintptr_t) src ) >> 20 ) & 0xF ];
+                       *s++ = kHexChars[ ( ( (uintptr_t) src ) >> 16 ) & 0xF ];
+                       *s++ = kHexChars[ ( ( (uintptr_t) src ) >> 12 ) & 0xF ];
+                       *s++ = kHexChars[ ( ( (uintptr_t) src ) >>  8 ) & 0xF ];
+                       *s++ = kHexChars[ ( ( (uintptr_t) src ) >>  4 ) & 0xF ];
+                       *s++ = kHexChars[   ( (uintptr_t) src )         & 0xF ];
+                       
+                       if( !( inFlags & kDebugFlagsNoOffset ) )
+                       {
+                               *s++ = '+';
+                       }
+               }
+               if( !( inFlags & kDebugFlagsNoOffset ) )
+               {
+                       if( inFlags & kDebugFlags32BitOffset )
+                       {
+                               *s++ = kHexChars[ ( offset >> 28 ) & 0xF ];
+                               *s++ = kHexChars[ ( offset >> 24 ) & 0xF ];
+                               *s++ = kHexChars[ ( offset >> 20 ) & 0xF ];
+                               *s++ = kHexChars[ ( offset >> 16 ) & 0xF ];
+                       }
+                       *s++ = kHexChars[ ( offset >> 12 ) & 0xF ];
+                       *s++ = kHexChars[ ( offset >>  8 ) & 0xF ];
+                       *s++ = kHexChars[ ( offset >>  4 ) & 0xF ];
+                       *s++ = kHexChars[   offset         & 0xF ];
+               }
+               if( s != prefixString )
+               {
+                       *s++ = ':';
+                       *s++ = ' ';
+               }
+               check( ( (size_t)( s - prefixString ) ) < sizeof( prefixString ) );
+               *s = '\0';
+               
+               // Build a hex string with a optional spaces after every 1, 2, and/or 4 bytes to make it easier to read.
+               // Optionally pads the hex string with space to fill the full 16 byte range (so it lines up).
+               
+               s = hexString;
+               chunkSize = ( inDataSize < 16 ) ? inDataSize : 16;
+               n = ( inFlags & kDebugFlagsNo16ByteHexPad ) ? chunkSize : 16;
+               for( i = 0; i < n; ++i )
+               {
+                       if( ( inFlags & kDebugFlags8BitSeparator ) && ( i > 0 ) )
+                       {
+                               *s++ = ' ';
+                       }
+                       if( ( inFlags & kDebugFlags16BitSeparator ) && ( i > 0 ) && ( ( i % 2 ) == 0 ) )
+                       {
+                               *s++ = ' ';
+                       }
+                       if( !( inFlags & kDebugFlagsNo32BitSeparator ) && ( i > 0 ) && ( ( i % 4 ) == 0 ) )
+                       {
+                               *s++ = ' ';
+                       }
+                       if( i < chunkSize )
+                       {
+                               *s++ = kHexChars[ src[ i ] >> 4   ];
+                               *s++ = kHexChars[ src[ i ] &  0xF ];
+                       }
+                       else
+                       {
+                               *s++ = ' ';
+                               *s++ = ' ';
+                       }
+               }
+               check( ( (size_t)( s - hexString ) ) < sizeof( hexString ) );
+               *s = '\0';
+               
+               // Build a string with the ASCII version of the data (replaces non-printable characters with '^').
+               // Optionally pads the string with '`' to fill the full 16 byte range (so it lines up).
+               
+               s = asciiString;
+               if( !( inFlags & kDebugFlagsNoASCII ) )
+               {
+                       *s++ = ' ';
+                       *s++ = '|';
+                       for( i = 0; i < n; ++i )
+                       {
+                               if( i < chunkSize )
+                               {
+                                       c = src[ i ];
+                                       if( !DebugIsPrint( c ) )
+                                       {
+                                               c = '^';
+                                       }
+                               }
+                               else
+                               {
+                                       c = '`';
+                               }
+                               *s++ = (char) c;
+                       }
+                       *s++ = '|';
+                       check( ( (size_t)( s - asciiString ) ) < sizeof( asciiString ) );
+               }
+               *s = '\0';
+               
+               // Build a string indicating how bytes are in the hex dump. Only printed on the first line.
+               
+               s = byteCountString;
+               if( !( inFlags & kDebugFlagsNoByteCount ) )
+               {
+                       if( src == start )
+                       {
+                               s += DebugSNPrintF( s, sizeof( byteCountString ), " (%d bytes)", (int) inDataSize );
+                       }
+               }
+               check( ( (size_t)( s - byteCountString ) ) < sizeof( byteCountString ) );
+               *s = '\0';
+               
+               // Build the entire line from all the pieces we've previously built.
+                       
+               if( outBuffer )
+               {
+                       if( src == start )
+                       {
+                               dst += DebugSNPrintF( dst, (size_t)( end - dst ), 
+                                       "%*s"           // Indention
+                                       "%s"            // Separator (only if needed)
+                                       "%s"            // Prefix
+                                       "%-*.*s"        // Label
+                                       "%s"            // Separator
+                                       "%s"            // Hex
+                                       "%s"            // ASCII
+                                       "%s"            // Byte Count
+                                       "%s",           // Newline
+                                       inIndent, "", 
+                                       ( src != start ) ? separator : "", 
+                                       prefixString, 
+                                       width, (int) inLabelSize, inLabel ? inLabel : "", 
+                                       ( width > 0 ) ? " " : "", 
+                                       hexString, 
+                                       asciiString, 
+                                       byteCountString, 
+                                       newline );
+                       }
+                       else
+                       {
+                               dst += DebugSNPrintF( dst, (size_t)( end - dst ), 
+                                       "%*s"           // Indention
+                                       "%s"            // Separator (only if needed)
+                                       "%s"            // Prefix
+                                       "%*s"           // Label Spacing
+                                       "%s"            // Separator
+                                       "%s"            // Hex
+                                       "%s"            // ASCII
+                                       "%s"            // Byte Count
+                                       "%s",           // Newline
+                                       inIndent, "", 
+                                       ( src != start ) ? separator : "", 
+                                       prefixString, 
+                                       width, "", 
+                                       ( width > 0 ) ? " " : "", 
+                                       hexString, 
+                                       asciiString, 
+                                       byteCountString, 
+                                       newline );
+                       }
+               }
+               else
+               {
+                       if( src == start )
+                       {
+                               dst += DebugPrintF( inLevel, 
+                                       "%*s"           // Indention
+                                       "%s"            // Separator (only if needed)
+                                       "%s"            // Prefix
+                                       "%-*.*s"        // Label
+                                       "%s"            // Separator
+                                       "%s"            // Hex
+                                       "%s"            // ASCII
+                                       "%s"            // Byte Count
+                                       "%s",           // Newline
+                                       inIndent, "", 
+                                       ( src != start ) ? separator : "", 
+                                       prefixString, 
+                                       width, (int) inLabelSize, inLabel, 
+                                       ( width > 0 ) ? " " : "", 
+                                       hexString, 
+                                       asciiString, 
+                                       byteCountString, 
+                                       newline );
+                       }
+                       else
+                       {
+                               dst += DebugPrintF( inLevel, 
+                                       "%*s"           // Indention
+                                       "%s"            // Separator (only if needed)
+                                       "%s"            // Prefix
+                                       "%*s"           // Label Spacing
+                                       "%s"            // Separator
+                                       "%s"            // Hex
+                                       "%s"            // ASCII
+                                       "%s"            // Byte Count
+                                       "%s",           // Newline
+                                       inIndent, "", 
+                                       ( src != start ) ? separator : "", 
+                                       prefixString, 
+                                       width, "", 
+                                       ( width > 0 ) ? " " : "", 
+                                       hexString, 
+                                       asciiString, 
+                                       byteCountString, 
+                                       newline );
+                       }
+               }
+               
+               // Move to the next chunk. Exit if there is no more data.
+               
+               offset          += (int) chunkSize;
+               src             += chunkSize;
+               inDataSize      -= chunkSize;
+               if( inDataSize == 0 )
+               {
+                       break;
+               }
+       }
+       
+       // Note: The "dst - outBuffer" size calculation works even if "outBuffer" is NULL because it's all relative.
+       
+       return( (size_t)( dst - outBuffer ) );
+}
+
+//===========================================================================================================================
+//     DebugNumVersionToString
+//===========================================================================================================================
+
+static char *  DebugNumVersionToString( uint32_t inVersion, char *inString )
+{
+       char *          s;
+       uint8_t         majorRev;
+       uint8_t         minor;
+       uint8_t         bugFix;
+       uint8_t         stage;
+       uint8_t         revision;
+       
+       check( inString );
+       
+       majorRev        = (uint8_t)( ( inVersion >> 24 ) & 0xFF );
+       minor           = (uint8_t)( ( inVersion >> 20 ) & 0x0F );
+       bugFix          = (uint8_t)( ( inVersion >> 16 ) & 0x0F );
+       stage           = (uint8_t)( ( inVersion >>  8 ) & 0xFF );
+       revision        = (uint8_t)(   inVersion         & 0xFF );
+       
+       // Convert the major, minor, and bugfix numbers.
+       
+       s  = inString;
+       s += sprintf( s, "%u", majorRev );
+       s += sprintf( s, ".%u", minor );
+       if( bugFix != 0 )
+       {
+               s += sprintf( s, ".%u", bugFix );
+       }
+       
+       // Convert the version stage and non-release revision number.
+       
+       switch( stage )
+       {
+               case kVersionStageDevelopment:
+                       s += sprintf( s, "d%u", revision );
+                       break;
+               
+               case kVersionStageAlpha:
+                       s += sprintf( s, "a%u", revision );
+                       break;
+               
+               case kVersionStageBeta:
+                       s += sprintf( s, "b%u", revision );
+                       break;
+               
+               case kVersionStageFinal:
+                       
+                       // A non-release revision of zero is a special case indicating the software is GM (at the golden master 
+                       // stage) and therefore, the non-release revision should not be added to the string.
+                       
+                       if( revision != 0 )
+                       {
+                               s += sprintf( s, "f%u", revision );
+                       }
+                       break;
+               
+               default:
+                       dlog( kDebugLevelError, "invalid NumVersion stage (0x%02X)\n", stage );
+                       break;
+       }
+       return( inString );
+}
+
+//===========================================================================================================================
+//     DebugTaskLevel
+//===========================================================================================================================
+
+DEBUG_EXPORT uint32_t  DebugTaskLevel( void )
+{
+       uint32_t                level;
+       
+       level = 0;
+       
+#if( TARGET_OS_VXWORKS )
+       if( intContext() )
+       {
+               level |= ( ( 1 << kDebugInterruptLevelShift ) & kDebugInterruptLevelMask );
+       }
+#endif
+       
+       return( level );
+}
+
+#if( TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE )
+//===========================================================================================================================
+//     DebugWinEnableConsole
+//===========================================================================================================================
+
+#pragma warning( disable:4311 )
+
+static void    DebugWinEnableConsole( void )
+{
+       static bool             sConsoleEnabled = false;
+       BOOL                    result;
+       int                             fileHandle;
+       FILE *                  file;
+       int                             err;
+       
+       if( sConsoleEnabled )
+       {
+               goto exit;
+       }
+       
+       // Create console window.
+       
+       result = AllocConsole();
+       require_quiet( result, exit );
+
+       // Redirect stdin to the console stdin.
+       
+       fileHandle = _open_osfhandle( (long) GetStdHandle( STD_INPUT_HANDLE ), _O_TEXT );
+       
+       #if( defined( __MWERKS__ ) )
+               file = __handle_reopen( (unsigned long) fileHandle, "r", stdin );
+               require_quiet( file, exit );
+       #else
+               file = _fdopen( fileHandle, "r" );
+               require_quiet( file, exit );
+       
+               *stdin = *file;
+       #endif
+       
+       err = setvbuf( stdin, NULL, _IONBF, 0 );
+       require_noerr_quiet( err, exit );
+       
+       // Redirect stdout to the console stdout.
+               
+       fileHandle = _open_osfhandle( (long) GetStdHandle( STD_OUTPUT_HANDLE ), _O_TEXT );
+       
+       #if( defined( __MWERKS__ ) )
+               file = __handle_reopen( (unsigned long) fileHandle, "w", stdout );
+               require_quiet( file, exit );
+       #else
+               file = _fdopen( fileHandle, "w" );
+               require_quiet( file, exit );
+               
+               *stdout = *file;
+       #endif
+       
+       err = setvbuf( stdout, NULL, _IONBF, 0 );
+       require_noerr_quiet( err, exit );
+       
+       // Redirect stderr to the console stdout.
+       
+       fileHandle = _open_osfhandle( (long) GetStdHandle( STD_OUTPUT_HANDLE ), _O_TEXT );
+       
+       #if( defined( __MWERKS__ ) )
+               file = __handle_reopen( (unsigned long) fileHandle, "w", stderr );
+               require_quiet( file, exit );
+       #else
+               file = _fdopen( fileHandle, "w" );
+               require_quiet( file, exit );
+       
+               *stderr = *file;
+       #endif
+       
+       err = setvbuf( stderr, NULL, _IONBF, 0 );
+       require_noerr_quiet( err, exit );
+       
+       sConsoleEnabled = true;
+       
+exit:
+       return;
+}
+
+#pragma warning( default:4311 )
+
+#endif // TARGET_OS_WIN32 && !TARGET_OS_WINDOWS_CE
+
+#if( TARGET_OS_WIN32 )
+//===========================================================================================================================
+//     DebugWinCharToTCharString
+//===========================================================================================================================
+
+static TCHAR *
+       DebugWinCharToTCharString( 
+               const char *    inCharString, 
+               size_t                  inCharCount, 
+               TCHAR *                 outTCharString, 
+               size_t                  inTCharCountMax, 
+               size_t *                outTCharCount )
+{
+       const char *            src;
+       TCHAR *                         dst;
+       TCHAR *                         end;
+       
+       if( inCharCount == kSizeCString )
+       {
+               inCharCount = strlen( inCharString );
+       }
+       src = inCharString;
+       dst = outTCharString;
+       if( inTCharCountMax > 0 )
+       {
+               inTCharCountMax -= 1;
+               if( inTCharCountMax > inCharCount )
+               {
+                       inTCharCountMax = inCharCount;
+               }
+               
+               end = dst + inTCharCountMax;
+               while( dst < end )
+               {
+                       *dst++ = (TCHAR) *src++;
+               }
+               *dst = 0;
+       }
+       if( outTCharCount )
+       {
+               *outTCharCount = (size_t)( dst - outTCharString );
+       }
+       return( outTCharString );
+}
+#endif
+
+#if 0
+#pragma mark -
+#pragma mark == Debugging ==
+#endif
+
+//===========================================================================================================================
+//     DebugServicesTest
+//===========================================================================================================================
+
+DEBUG_EXPORT OSStatus  DebugServicesTest( void )
+{
+       OSStatus                err;
+       char                    s[ 512 ];
+       uint8_t *               p;
+       uint8_t                 data[] = 
+       {
+               0x11, 0x22, 0x33, 0x44, 
+               0x55, 0x66, 
+               0x77, 0x88, 0x99, 0xAA, 
+               0xBB, 0xCC, 0xDD, 
+               0xEE,
+               0xFF, 
+               0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 
+               0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 
+               0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x81, 0x91, 0xA1 
+       };
+       
+       debug_initialize( kDebugOutputTypeMetaConsole );        
+       
+       // check's
+       
+       check( 0 && "SHOULD SEE: check" );
+       check( 1 && "SHOULD *NOT* SEE: check (valid)" );
+       check_string( 0, "SHOULD SEE: check_string" );
+       check_string( 1, "SHOULD *NOT* SEE: check_string (valid)" );
+       check_noerr( -123 );
+       check_noerr( 10038 );
+       check_noerr( 22 );
+       check_noerr( 0 );
+       check_noerr_string( -6712, "SHOULD SEE: check_noerr_string" );
+       check_noerr_string( 0, "SHOULD *NOT* SEE: check_noerr_string (valid)" );
+       check_translated_errno( 0 >= 0 && "SHOULD *NOT* SEE", -384, -999 );
+       check_translated_errno( -1 >= 0 && "SHOULD SEE", -384, -999 );
+       check_translated_errno( -1 >= 0 && "SHOULD SEE", 0, -999 );
+       check_ptr_overlap( "SHOULD *NOT* SEE" ? 10 : 0, 10, 22, 10 );
+       check_ptr_overlap( "SHOULD SEE" ? 10 : 0, 10,  5, 10 );
+       check_ptr_overlap( "SHOULD SEE" ? 10 : 0, 10, 12,  6 );
+       check_ptr_overlap( "SHOULD SEE" ? 12 : 0,  6, 10, 10 );
+       check_ptr_overlap( "SHOULD SEE" ? 12 : 0, 10, 10, 10 );
+       check_ptr_overlap( "SHOULD *NOT* SEE" ? 22 : 0, 10, 10, 10 );
+       check_ptr_overlap( "SHOULD *NOT* SEE" ? 10 : 0, 10, 20, 10 );
+       check_ptr_overlap( "SHOULD *NOT* SEE" ? 20 : 0, 10, 10, 10 );
+               
+       // require's
+       
+       require( 0 && "SHOULD SEE", require1 );
+       { err = kResponseErr; goto exit; }
+require1:
+       require( 1 && "SHOULD *NOT* SEE", require2 );
+       goto require2Good;
+require2:
+       { err = kResponseErr; goto exit; }
+require2Good:
+       require_string( 0 && "SHOULD SEE", require3, "SHOULD SEE: require_string" );
+       { err = kResponseErr; goto exit; }
+require3:
+       require_string( 1 && "SHOULD *NOT* SEE", require4, "SHOULD *NOT* SEE: require_string (valid)" );
+       goto require4Good;
+require4:
+       { err = kResponseErr; goto exit; }
+require4Good:
+       require_quiet( 0 && "SHOULD SEE", require5 );
+       { err = kResponseErr; goto exit; }
+require5:
+       require_quiet( 1 && "SHOULD *NOT* SEE", require6 );
+       goto require6Good;
+require6:
+       { err = kResponseErr; goto exit; }
+require6Good:
+       require_noerr( -1, require7 );
+       { err = kResponseErr; goto exit; }
+require7:
+       require_noerr( 0, require8 );
+       goto require8Good;
+require8:
+       { err = kResponseErr; goto exit; }
+require8Good:
+       require_noerr_string( -2, require9, "SHOULD SEE: require_noerr_string");
+       { err = kResponseErr; goto exit; }
+require9:
+       require_noerr_string( 0, require10, "SHOULD *NOT* SEE: require_noerr_string (valid)" );
+       goto require10Good;
+require10:
+       { err = kResponseErr; goto exit; }
+require10Good:
+       require_noerr_action_string( -3, require11, dlog( kDebugLevelMax, "action 1 (expected)\n" ), "require_noerr_action_string" );
+       { err = kResponseErr; goto exit; }
+require11:
+       require_noerr_action_string( 0, require12, dlog( kDebugLevelMax, "action 2\n" ), "require_noerr_action_string (valid)" );
+       goto require12Good;
+require12:
+       { err = kResponseErr; goto exit; }
+require12Good:
+       require_noerr_quiet( -4, require13 );
+       { err = kResponseErr; goto exit; }
+require13:
+       require_noerr_quiet( 0, require14 );
+       goto require14Good;
+require14:
+       { err = kResponseErr; goto exit; }
+require14Good:
+       require_noerr_action( -5, require15, dlog( kDebugLevelMax, "SHOULD SEE: action 3 (expected)\n" ) );
+       { err = kResponseErr; goto exit; }
+require15:
+       require_noerr_action( 0, require16, dlog( kDebugLevelMax, "SHOULD *NOT* SEE: action 4\n" ) );
+       goto require16Good;
+require16:
+       { err = kResponseErr; goto exit; }
+require16Good:
+       require_noerr_action_quiet( -4, require17, dlog( kDebugLevelMax, "SHOULD SEE: action 5 (expected)\n" ) );
+       { err = kResponseErr; goto exit; }
+require17:
+       require_noerr_action_quiet( 0, require18, dlog( kDebugLevelMax, "SHOULD *NOT* SEE: action 6\n" ) );
+       goto require18Good;
+require18:
+       { err = kResponseErr; goto exit; }
+require18Good:
+       require_action( 0 && "SHOULD SEE", require19, dlog( kDebugLevelMax, "SHOULD SEE: action 7 (expected)\n" ) );
+       { err = kResponseErr; goto exit; }
+require19:
+       require_action( 1 && "SHOULD *NOT* SEE", require20, dlog( kDebugLevelMax, "SHOULD *NOT* SEE: action 8\n" ) );
+       goto require20Good;
+require20:
+       { err = kResponseErr; goto exit; }
+require20Good:
+       require_action_quiet( 0, require21, dlog( kDebugLevelMax, "SHOULD SEE: action 9 (expected)\n" ) );
+       { err = kResponseErr; goto exit; }
+require21:
+       require_action_quiet( 1, require22, dlog( kDebugLevelMax, "SHOULD *NOT* SEE: action 10\n" ) );
+       goto require22Good;
+require22:
+       { err = kResponseErr; goto exit; }
+require22Good:
+       require_action_string( 0, require23, dlog( kDebugLevelMax, "SHOULD SEE: action 11 (expected)\n" ), "SHOULD SEE: require_action_string" );
+       { err = kResponseErr; goto exit; }
+require23:
+       require_action_string( 1, require24, dlog( kDebugLevelMax, "SHOULD *NOT* SEE: action 12\n" ), "SHOULD *NOT* SEE: require_action_string" );
+       goto require24Good;
+require24:
+       { err = kResponseErr; goto exit; }
+require24Good:
+
+#if( defined( __MWERKS__ )  )
+       #if( defined( __cplusplus ) && __option( exceptions ) )
+               #define COMPILER_HAS_EXCEPTIONS         1
+       #else
+               #define COMPILER_HAS_EXCEPTIONS         0
+       #endif
+#else
+       #if( defined( __cplusplus ) )
+               #define COMPILER_HAS_EXCEPTIONS         1
+       #else
+               #define COMPILER_HAS_EXCEPTIONS         0
+       #endif
+#endif
+
+#if( COMPILER_HAS_EXCEPTIONS )
+       try
+       {
+               require_throw( 1 && "SHOULD *NOT* SEE" );
+               require_throw( 0 && "SHOULD SEE" );
+       }
+       catch( ... )
+       {
+               goto require26Good;
+       }
+       { err = kResponseErr; goto exit; }
+require26Good:
+#endif
+
+       // translate_errno
+       
+       err = translate_errno( 1 != -1, -123, -567 );
+       require( ( err == 0 ) && "SHOULD *NOT* SEE", exit );
+       
+       err = translate_errno( -1 != -1, -123, -567 );
+       require( ( err == -123 ) && "SHOULD *NOT* SEE", exit );
+       
+       err = translate_errno( -1 != -1, 0, -567 );
+       require( ( err == -567 ) && "SHOULD *NOT* SEE", exit );
+
+       // debug_string
+       
+       debug_string( "debug_string" );
+       
+       // DebugSNPrintF
+       
+       DebugSNPrintF( s, sizeof( s ), "%d", 1234 );
+       require_action( strcmp( s, "1234" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%X", 0x2345 );
+       require_action( strcmp( s, "2345" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%#s", "\05test" );
+       require_action( strcmp( s, "test" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%##s", "\03www\05apple\03com" );
+       require_action( strcmp( s, "www.apple.com." ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%ld", (long) INT32_C( 2147483647 ) );
+       require_action( strcmp( s, "2147483647" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%lu", (unsigned long) UINT32_C( 4294967295 ) );
+       require_action( strcmp( s, "4294967295" ) == 0, exit, err = -1 );
+       
+       #if( TYPE_LONGLONG_NATIVE )
+               DebugSNPrintF( s, sizeof( s ), "%lld", (long_long_compat) INT64_C( 9223372036854775807 ) );
+               require_action( strcmp( s, "9223372036854775807" ) == 0, exit, err = -1 );
+               
+               DebugSNPrintF( s, sizeof( s ), "%lld", (long_long_compat) INT64_C( -9223372036854775807 ) );
+               require_action( strcmp( s, "-9223372036854775807" ) == 0, exit, err = -1 );
+               
+               DebugSNPrintF( s, sizeof( s ), "%llu", (unsigned_long_long_compat) UINT64_C( 18446744073709551615 ) );
+               require_action( strcmp( s, "18446744073709551615" ) == 0, exit, err = -1 );
+       #endif
+       
+       DebugSNPrintF( s, sizeof( s ), "%lb", (unsigned long) binary_32( 01111011, 01111011, 01111011, 01111011 ) );
+       require_action( strcmp( s, "1111011011110110111101101111011" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%C", 0x41624364 );      // 'AbCd'
+       require_action( strcmp( s, "AbCd" ) == 0, exit, err = -1 );
+       
+       #if( defined( MDNS_DEBUGMSGS ) )
+       {
+               mDNSAddr                maddr;
+               
+               memset( &maddr, 0, sizeof( maddr ) );
+               maddr.type = mDNSAddrType_IPv4;
+               maddr.ip.v4.b[ 0 ] = 127;
+               maddr.ip.v4.b[ 1 ] = 0;
+               maddr.ip.v4.b[ 2 ] = 0;
+               maddr.ip.v4.b[ 3 ] = 1;
+               DebugSNPrintF( s, sizeof( s ), "%#a", &maddr );
+               require_action( strcmp( s, "127.0.0.1" ) == 0, exit, err = -1 );
+               
+               memset( &maddr, 0, sizeof( maddr ) );
+               maddr.type = mDNSAddrType_IPv6;
+               maddr.ip.v6.b[  0 ]     = 0xFE;
+               maddr.ip.v6.b[  1 ]     = 0x80;
+               maddr.ip.v6.b[ 15 ]     = 0x01;
+               DebugSNPrintF( s, sizeof( s ), "%#a", &maddr );
+               require_action( strcmp( s, "FE80:0000:0000:0000:0000:0000:0000:0001" ) == 0, exit, err = -1 );
+       }
+       #endif
+       
+       #if( AF_INET )
+       {
+               struct sockaddr_in              sa4;
+               
+               memset( &sa4, 0, sizeof( sa4 ) );
+               sa4.sin_family          = AF_INET;
+               p                                       = (uint8_t *) &sa4.sin_port;
+               p[ 0 ]                          = (uint8_t)( ( 80 >> 8 ) & 0xFF );
+               p[ 1 ]                          = (uint8_t)(   80        & 0xFF );
+               p                                       = (uint8_t *) &sa4.sin_addr.s_addr;
+               p[ 0 ]                          = (uint8_t)( ( INADDR_LOOPBACK >> 24 ) & 0xFF );
+               p[ 1 ]                          = (uint8_t)( ( INADDR_LOOPBACK >> 16 ) & 0xFF );
+               p[ 2 ]                          = (uint8_t)( ( INADDR_LOOPBACK >>  8 ) & 0xFF );
+               p[ 3 ]                          = (uint8_t)(   INADDR_LOOPBACK         & 0xFF );
+               DebugSNPrintF( s, sizeof( s ), "%##a", &sa4 );
+               require_action( strcmp( s, "127.0.0.1:80" ) == 0, exit, err = -1 );
+       }
+       #endif
+       
+       #if( AF_INET6 )
+       {
+               struct sockaddr_in6             sa6;
+               
+               memset( &sa6, 0, sizeof( sa6 ) );
+               sa6.sin6_family                         = AF_INET6;
+               p                                                       = (uint8_t *) &sa6.sin6_port;
+               p[ 0 ]                                          = (uint8_t)( ( 80 >> 8 ) & 0xFF );
+               p[ 1 ]                                          = (uint8_t)(   80        & 0xFF );
+               sa6.sin6_addr.s6_addr[  0 ]     = 0xFE;
+               sa6.sin6_addr.s6_addr[  1 ]     = 0x80;
+               sa6.sin6_addr.s6_addr[ 15 ]     = 0x01;
+               sa6.sin6_scope_id                       = 2;
+               DebugSNPrintF( s, sizeof( s ), "%##a", &sa6 );
+               require_action( strcmp( s, "[FE80:0000:0000:0000:0000:0000:0000:0001%2]:80" ) == 0, exit, err = -1 );
+       }
+       #endif
+       
+       // Unicode
+
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "tes" );
+       require_action( strcmp( s, "tes" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "test" );
+       require_action( strcmp( s, "test" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "testing" );
+       require_action( strcmp( s, "test" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "te\xC3\xA9" );
+       require_action( strcmp( s, "te\xC3\xA9" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "te\xC3\xA9ing" );
+       require_action( strcmp( s, "te\xC3\xA9" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "tes\xC3\xA9ing" );
+       require_action( strcmp( s, "tes" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "t\xed\x9f\xbf" );
+       require_action( strcmp( s, "t\xed\x9f\xbf" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "t\xed\x9f\xbfing" );
+       require_action( strcmp( s, "t\xed\x9f\xbf" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "te\xed\x9f\xbf" );
+       require_action( strcmp( s, "te" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 4, "te\xed\x9f\xbfing" );
+       require_action( strcmp( s, "te" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 7, "te\xC3\xA9\xed\x9f\xbfing" );
+       require_action( strcmp( s, "te\xC3\xA9\xed\x9f\xbf" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 6, "te\xC3\xA9\xed\x9f\xbfing" );
+       require_action( strcmp( s, "te\xC3\xA9" ) == 0, exit, err = kResponseErr );
+       
+       DebugSNPrintF(s, sizeof(s), "%.*s", 5, "te\xC3\xA9\xed\x9f\xbfing" );
+       require_action( strcmp( s, "te\xC3\xA9" ) == 0, exit, err = kResponseErr );
+
+       #if( TARGET_RT_BIG_ENDIAN )
+               DebugSNPrintF( s, sizeof( s ), "%S", "\x00" "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" "\x00" );
+               require_action( strcmp( s, "abcd" ) == 0, exit, err = -1 );
+       #else
+               DebugSNPrintF( s, sizeof( s ), "%S", "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" "\x00" "\x00" );
+               require_action( strcmp( s, "abcd" ) == 0, exit, err = -1 );
+       #endif
+       
+       DebugSNPrintF( s, sizeof( s ), "%S", 
+               "\xFE\xFF" "\x00" "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" "\x00" ); // Big Endian BOM
+       require_action( strcmp( s, "abcd" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%S", 
+               "\xFF\xFE" "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" "\x00" "\x00" ); // Little Endian BOM
+       require_action( strcmp( s, "abcd" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%#S", "\x00" "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" "\x00" );      // Big Endian
+       require_action( strcmp( s, "abcd" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%##S", "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" "\x00" "\x00" );     // Little Endian
+       require_action( strcmp( s, "abcd" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%.*S", 
+               4, "\xFE\xFF" "\x00" "a" "\x00" "b" "\x00" "c" "\x00" "d" );    // Big Endian BOM
+       require_action( strcmp( s, "abc" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%.*S", 
+               4, "\xFF\xFE" "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" );    // Little Endian BOM
+       require_action( strcmp( s, "abc" ) == 0, exit, err = -1 );
+       
+       #if( TARGET_RT_BIG_ENDIAN )
+               DebugSNPrintF( s, sizeof( s ), "%.*S", 3, "\x00" "a" "\x00" "b" "\x00" "c" "\x00" "d" );
+               require_action( strcmp( s, "abc" ) == 0, exit, err = -1 );
+       #else
+               DebugSNPrintF( s, sizeof( s ), "%.*S", 3, "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" );
+               require_action( strcmp( s, "abc" ) == 0, exit, err = -1 );
+       #endif
+       
+       DebugSNPrintF( s, sizeof( s ), "%#.*S", 3, "\x00" "a" "\x00" "b" "\x00" "c" "\x00" "d" );       // Big Endian
+       require_action( strcmp( s, "abc" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%##.*S", 3, "a" "\x00" "b" "\x00" "c" "\x00" "d" "\x00" );      // Little Endian
+       require_action( strcmp( s, "abc" ) == 0, exit, err = -1 );
+       
+       // Misc
+       
+       DebugSNPrintF( s, sizeof( s ), "%U", "\x10\xb8\xa7\x6b" "\xad\x9d" "\xd1\x11" "\x80\xb4" "\x00\xc0\x4f\xd4\x30\xc8" );
+       require_action( strcmp( s, "6ba7b810-9dad-11d1-80b4-00c04fd430c8" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%m", 0 );
+       require_action( strcmp( s, "no error" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "%lm", (long) 0 );
+       require_action( strcmp( s, "no error" ) == 0, exit, err = -1 );
+       
+       DebugSNPrintF( s, sizeof( s ), "\"%H\"", "\x6b\xa7\xb8\x10\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8", 16, 16 );
+       DebugPrintF( kDebugLevelMax, "%s\n\n", s );
+       
+       DebugSNPrintF( s, sizeof( s ), "\"%H\"", 
+               "\x6b\xa7\xb8\x10\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8"
+               "\x6b\xa7\xb8\x10\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8", 
+               32, 32 );
+       DebugPrintF( kDebugLevelMax, "%s\n\n", s );
+       
+       DebugSNPrintF( s, sizeof( s ), "\"%H\"", "\x6b\xa7", 2, 2 );
+       DebugPrintF( kDebugLevelMax, "%s\n\n", s );
+       
+       // Hex Dumps
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, "My Label", kSizeCString, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNone, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, NULL, 0, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNoAddress | kDebugFlagsNoOffset, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, "My Label", kSizeCString, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNoAddress | kDebugFlagsNoOffset, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, "My Label", kSizeCString, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNoAddress, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, NULL, 0, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNoOffset, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, NULL, 0, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNoAddress, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, NULL, 0, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNoOffset, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, NULL, 0, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNoByteCount, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, NULL, 0, 0, NULL, 0, "\x41\x62\x43\x64", "\x41\x62\x43\x64", 4,        // 'AbCd'
+               kDebugFlagsNoAddress | kDebugFlagsNoOffset | kDebugFlagsNoNewLine |
+               kDebugFlagsNo32BitSeparator | kDebugFlagsNo16ByteHexPad | kDebugFlagsNoByteCount, 
+               s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 0, NULL, 0, 0, NULL, 0, data, data, sizeof( data ), 
+               kDebugFlagsNoAddress | kDebugFlagsNoOffset | kDebugFlagsNoASCII | kDebugFlagsNoNewLine |
+               kDebugFlags16BitSeparator | kDebugFlagsNo32BitSeparator |
+               kDebugFlagsNo16ByteHexPad | kDebugFlagsNoByteCount, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       s[ 0 ] = '\0';
+       DebugHexDump( kDebugLevelMax, 8, NULL, 0, 0, NULL, 0, data, data, sizeof( data ), kDebugFlagsNone, s, sizeof( s ) );
+       DebugPrintF( kDebugLevelMax, "%s\n", s );
+       
+       // dlog's
+       
+       dlog( kDebugLevelNotice, "dlog\n" );
+       dlog( kDebugLevelNotice, "dlog integer: %d\n", 123 );
+       dlog( kDebugLevelNotice, "dlog string:  \"%s\"\n", "test string" );
+       dlogmem( kDebugLevelNotice, data, sizeof( data ) );
+       
+       // Done
+       
+       DebugPrintF( kDebugLevelMax, "\n\nALL TESTS DONE\n\n" );
+       err = kNoErr;
+       
+exit:
+       if( err )
+       {
+               DebugPrintF( kDebugLevelMax, "\n\n### TEST FAILED ###\n\n" );
+       }
+       return( err );
+}
+
+#endif // DEBUG
diff --git a/mDNSShared/DebugServices.h b/mDNSShared/DebugServices.h
new file mode 100644 (file)
index 0000000..7111fa2
--- /dev/null
@@ -0,0 +1,1628 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
+ *
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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.
+
+    Change History (most recent first):
+    
+$Log: DebugServices.h,v $
+Revision 1.5  2006/08/14 23:24:56  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.4  2004/04/15 08:59:08  bradley
+Removed deprecated debug and log levels and replaced them with modern equivalents.
+
+Revision 1.3  2004/04/08 09:29:55  bradley
+Manually do host->network byte order conversion to avoid needing libraries for htons/htonl. Changed
+hex dumps to better separate hex and ASCII. Added support for %.8a syntax in DebugSNPrintF for Fibre
+Channel addresses (00:11:22:33:44:55:66:77). Fixed a few places where HeaderDoc was incorrect.
+
+Revision 1.2  2004/03/07 05:59:34  bradley
+Sync'd with internal version: Added expect macros, error codes, and CoreServices exclusion.
+
+Revision 1.1  2004/01/30 02:27:30  bradley
+Debugging support for various platforms.
+
+*/
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @header         DebugServices
+
+       Debugging Library
+*/
+
+#ifndef        __DEBUG_SERVICES__
+#define        __DEBUG_SERVICES__
+
+#include       <stdarg.h>
+
+#include       "CommonServices.h"
+
+#if( TARGET_OS_VXWORKS )
+       #include        "logLib.h"
+#endif
+
+#if 0
+#pragma mark == Settings ==
+#endif
+
+//===========================================================================================================================
+//     Settings
+//===========================================================================================================================
+
+// General
+
+#if( !defined( DEBUG ) )
+       #define DEBUG           0
+#endif
+
+#if( defined( NDEBUG ) && DEBUG )
+       #error NDEBUG defined and DEBUG is also enabled...they need to be in-sync
+#endif
+       
+// AssertMacros.h/Debugging.h overrides.
+
+#if( !defined( DEBUG_OVERRIDE_APPLE_MACROS ) )
+       #define DEBUG_OVERRIDE_APPLE_MACROS             1
+#endif
+
+// Routine name. Uses ISO __func__ where possible. Otherwise, uses the best thing that is available (if anything).
+
+#if( defined( __MWERKS__ ) || ( __GNUC__ > 2 ) || ( ( __GNUC__ == 2 ) && ( __GNUC_MINOR__ >= 9 ) ) )
+       #define __ROUTINE__                                     __func__
+#elif( defined( __GNUC__ ) )
+       #define __ROUTINE__                                     __PRETTY_FUNCTION__
+#elif( defined( _MSC_VER ) && !defined( _WIN32_WCE ) )
+       #define __ROUTINE__                                     __FUNCTION__
+#else
+       #define __ROUTINE__                                     ""
+#endif
+
+// Variable argument macro support. Use ANSI C99 __VA_ARGS__ where possible. Otherwise, use the next best thing.
+
+#if( defined( __GNUC__ ) )
+       #if( ( __GNUC__ > 3 ) || ( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 3) ) )
+               #define DEBUG_C99_VA_ARGS               1
+               #define DEBUG_GNU_VA_ARGS               0
+       #else
+               #define DEBUG_C99_VA_ARGS               0
+               #define DEBUG_GNU_VA_ARGS               1
+       #endif
+#elif( defined( __MWERKS__ ) )
+       #define DEBUG_C99_VA_ARGS                       1
+       #define DEBUG_GNU_VA_ARGS                       0
+#else
+       #define DEBUG_C99_VA_ARGS                       0
+       #define DEBUG_GNU_VA_ARGS                       0
+#endif
+
+#if 0
+#pragma mark == Output ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_FPRINTF_ENABLED
+       
+       @abstract       Enables ANSI C fprintf output.
+*/
+
+#if( !defined( DEBUG_FPRINTF_ENABLED ) )
+       #if( !TARGET_API_MAC_OSX_KERNEL && !TARGET_OS_WINDOWS_CE )
+               #define DEBUG_FPRINTF_ENABLED                   1
+       #else
+               #define DEBUG_FPRINTF_ENABLED                   0
+       #endif
+#else
+       #if( TARGET_API_MAC_OSX_KERNEL || TARGET_OS_WINDOWS_CE )
+               #error fprintf enabled, but not supported on Mac OS X kernel or Windows CE
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_MAC_OS_X_IOLOG_ENABLED
+       
+       @abstract       Enables IOLog (Mac OS X Kernel) output.
+*/
+
+#if( !defined( DEBUG_MAC_OS_X_IOLOG_ENABLED ) )
+       #define DEBUG_MAC_OS_X_IOLOG_ENABLED            TARGET_API_MAC_OSX_KERNEL
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_KPRINTF_ENABLED
+       
+       @abstract       Enables kprintf (Mac OS X Kernel) output.
+*/
+
+#if( !defined( DEBUG_KPRINTF_ENABLED ) )
+       #define DEBUG_KPRINTF_ENABLED                           TARGET_API_MAC_OSX_KERNEL
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_IDEBUG_ENABLED
+       
+       @abstract       Enables iDebug (Mac OS X user and Kernel) output.
+       
+       @discussion
+       
+       For Mac OS X kernel development, iDebug is enabled by default because we can dynamically check for the presence 
+       of iDebug via some exported IOKit symbols. Mac OS X app usage doesn't allow dynamic detection because it relies
+       on statically linking to the iDebugServices.cp file so for Mac OS X app usage, you have to manually enable iDebug.
+*/
+
+#if( !defined( DEBUG_IDEBUG_ENABLED ) )
+       #define DEBUG_IDEBUG_ENABLED                            TARGET_API_MAC_OSX_KERNEL
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_CORE_SERVICE_ASSERTS_ENABLED
+       
+       @abstract       Controls whether Core Services assert handling is enabled. Enabling requires CoreServices framework.
+*/
+
+#if( !defined( DEBUG_CORE_SERVICE_ASSERTS_ENABLED ) )
+       #if( defined( __DEBUGGING__ ) )
+               #define DEBUG_CORE_SERVICE_ASSERTS_ENABLED              1
+       #else
+               #define DEBUG_CORE_SERVICE_ASSERTS_ENABLED              0
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @typedef        DebugOutputType
+       
+       @abstract       Type of debug output (i.e. where the output goes).
+*/
+
+typedef uint32_t                       DebugOutputType;
+
+#define kDebugOutputTypeNone                           0x6E6F6E65U     // 'none' - no params
+#define kDebugOutputTypeCustom                         0x63757374U     // 'cust' - 1st param = function ptr, 2nd param = context
+#define kDebugOutputTypeFPrintF                                0x66707269U     // 'fpri' - 1st param = DebugOutputTypeFlags [, 2nd param = filename]
+#define kDebugOutputTypeiDebug                         0x69646267U     // 'idbg' - no params
+#define kDebugOutputTypeKPrintF                                0x6B707266U     // 'kprf' - no params
+#define kDebugOutputTypeMacOSXIOLog                    0x696C6F67U     // 'ilog' - no params 
+#define kDebugOutputTypeMacOSXLog                      0x786C6F67U     // 'xlog' - no params
+#define kDebugOutputTypeWindowsDebugger                0x77696E64U     // 'wind' - no params
+#define kDebugOutputTypeWindowsEventLog                0x7765766CU     // 'wevl' - 1st param = C-string name, 2nd param = HMODULE or NULL.
+
+// Console meta output kind - Any kind of Console output (in horizontal order of preference):
+// 
+// Mac OS X                    = ANSI printf (viewable in Console.app)
+// Mac OS X Kernel     = IOLog (/var/log/system.log) or kprintf (serial).
+// Windows                     = ANSI printf (Console window) or OutputDebugString (debugger).
+// Other                       = ANSI printf (viewer varies).
+
+#define kDebugOutputTypeMetaConsole                    0x434F4E53U     // 'CONS' - no params
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @typedef        DebugOutputTypeFlags
+       
+       @abstract       Flags controlling how the output type is configured.
+       
+       @constant       kDebugOutputTypeFlagsTypeMask   Bit mask for the output type (e.g. stdout, stderr, file, etc.).
+       @constant       kDebugOutputTypeFlagsStdOut             fprintf should go to stdout.
+       @constant       kDebugOutputTypeFlagsStdErr             fprintf should go to stderr.
+       @constant       kDebugOutputTypeFlagsFile               fprintf should go to a specific file (filename passed as va_arg).
+*/
+
+typedef unsigned int           DebugOutputTypeFlags;
+
+#define        kDebugOutputTypeFlagsTypeMask   0xF
+#define        kDebugOutputTypeFlagsStdOut             1
+#define        kDebugOutputTypeFlagsStdErr             2
+#define        kDebugOutputTypeFlagsFile               10
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @typedef        DebugOutputFunctionPtr
+       
+       @abstract       Function ptr for a custom callback to print debug output.
+*/
+
+typedef void ( *DebugOutputFunctionPtr )( char *inData, size_t inSize, void *inContext );
+
+//===========================================================================================================================
+//     Constants
+//===========================================================================================================================
+
+#if 0
+#pragma mark == Flags ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @typedef        DebugFlags
+       
+       @abstract       Flags controlling how output is printed.
+*/
+
+typedef uint32_t               DebugFlags;
+
+#define        kDebugFlagsNone                                 0
+#define        kDebugFlagsNoAddress                    ( 1 << 0 )
+#define        kDebugFlagsNoOffset                             ( 1 << 1 )
+#define        kDebugFlags32BitOffset                  ( 1 << 2 )
+#define        kDebugFlagsNoASCII                              ( 1 << 3 )
+#define        kDebugFlagsNoNewLine                    ( 1 << 4 )
+#define        kDebugFlags8BitSeparator                ( 1 << 5 )
+#define        kDebugFlags16BitSeparator               ( 1 << 6 )
+#define        kDebugFlagsNo32BitSeparator             ( 1 << 7 )
+#define        kDebugFlagsNo16ByteHexPad               ( 1 << 8 )
+#define        kDebugFlagsNoByteCount                  ( 1 << 9 )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @enum           DebugTaskLevelFlags
+       
+       @abstract       Flags indicating the task level.
+*/
+
+enum
+{
+       kDebugInterruptLevelShift                               = 0, 
+       kDebugInterruptLevelMask                                = 0x00000007,
+       kDebugInVBLTaskMask                                             = 0x00000010,
+       kDebugInDeferredTaskMask                                = 0x00000020,
+    kDebugInSecondaryInterruptHandlerMask      = 0x00000040, 
+       kDebugPageFaultFatalMask                                = 0x00000100,   // There should be a "kPageFaultFatalMask" in Debugging.h.
+       kDebugMPTaskLevelMask                                   = 0x00000200,   // There should be a "kMPTaskLevelMask" in Debugging.h.
+       kDebugInterruptDepthShift                               = 16, 
+       kDebugInterruptDepthMask                                = 0x00FF0000
+};
+
+#define        DebugExtractTaskLevelInterruptLevel( LEVEL )    \
+       ( ( ( LEVEL ) & kDebugInterruptLevelMask ) >> kDebugInterruptLevelShift )
+       
+#define        DebugExtractTaskLevelInterruptDepth( LEVEL )    \
+       ( ( ( LEVEL ) & kDebugInterruptDepthMask ) >> kDebugInterruptDepthShift )
+
+#if 0
+#pragma mark == Levels ==
+#endif
+
+//===========================================================================================================================
+//     Constants & Types - Levels
+//===========================================================================================================================
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @typedef        DebugLevel
+       
+       @abstract       Level used to control debug logging.
+*/
+
+typedef int32_t                        DebugLevel;
+
+// Levels
+
+#define kDebugLevelMask                                        0x0000FFFF
+#define kDebugLevelChatty                              100
+#define kDebugLevelVerbose                             500
+#define kDebugLevelTrace                               800
+#define kDebugLevelInfo                                1000
+#define kDebugLevelNotice                              3000
+#define kDebugLevelWarning                             5000
+#define kDebugLevelAssert                              6000
+#define kDebugLevelRequire                             7000
+#define kDebugLevelError                               8000
+#define kDebugLevelCritical                            9000
+#define kDebugLevelAlert                               10000
+#define kDebugLevelEmergency                   11000
+#define kDebugLevelTragic                              12000
+#define kDebugLevelMax                                 0x0000FFFF
+
+// Level Flags
+       
+#define kDebugLevelFlagMask                            0xFFFF0000
+#define kDebugLevelFlagStackTrace              0x00010000
+#define kDebugLevelFlagDebugBreak              0x00020000
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @typedef        LogLevel
+       
+       @abstract       Level used to control which events are logged.
+*/
+
+typedef int32_t                                                LogLevel;
+
+#define        kLogLevelUninitialized          -1L
+#define kLogLevelAll                           0L
+#define kLogLevelChatty                                100L
+#define kLogLevelVerbose                       500L
+#define kLogLevelTrace                                 800L
+#define kLogLevelInfo                          1000L
+#define kLogLevelNotice                                3000L
+#define kLogLevelWarning                       4000L
+#define kLogLevelAssert                        6000L
+#define kLogLevelRequire                       7000L
+#define kLogLevelError                         8000L
+#define kLogLevelCritical                      9000L
+#define kLogLevelAlert                         10000L
+#define kLogLevelEmergency                     11000L
+#define kLogLevelTragic                                12000L
+#define kLogLevelOff                           0x0000FFFEL
+
+#if 0
+#pragma mark == Properties ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @typedef        DebugPropertyTag
+       
+       @abstract       Tag for properties.
+*/
+
+typedef uint32_t               DebugPropertyTag;
+
+#define        kDebugPropertyTagPrintLevelMin          0x6D696E70U             // 'minp'       Get: 1st param = DebugLevel *
+                                                                                                                       //                      Set: 1st param = DebugLevel
+
+#define        kDebugPropertyTagPrintLevel                     kDebugPropertyTagPrintLevelMin
+
+#define        kDebugPropertyTagPrintLevelMax          0x706D786CU             // 'maxp'       Get: 1st param = DebugLevel *
+                                                                                                                       //                      Set: 1st param = DebugLevel
+
+#define        kDebugPropertyTagBreakLevel                     0x62726B6CU             // 'brkl'       Get: 1st param = DebugLevel *
+                                                                                                                       //                      Set: 1st param = DebugLevel
+#if 0
+#pragma mark == General macros ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_UNUSED
+       
+       @abstract       Macro to mark a paramter as unused to avoid unused parameter warnings.
+       
+       @discussion     
+       
+       There is no universally supported pragma/attribute for indicating a variable is unused. DEBUG_UNUSED lets us
+       indicate a variable is unused in a manner that is supported by most compilers.
+*/
+
+#define        DEBUG_UNUSED( X )                       (void)( X )
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_USE_ONLY
+       
+       @abstract       Macro to mark a variable as used only when debugging is enabled.
+       
+       @discussion     
+       
+       Variables are sometimes needed only for debugging. When debugging is turned off, these debug-only variables generate 
+       compiler warnings about unused variables. To eliminate these warnings, use these macros to indicate variables that 
+       are only used for debugging.
+*/
+
+#if( DEBUG )
+       #define DEBUG_USE_ONLY( X )
+#else
+       #define DEBUG_USE_ONLY( X )             (void)( X )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_LOCAL
+       
+       @abstract       Macros to make variables and functions static when debugging is off, but extern when debugging is on.
+       
+       @discussion     
+       
+       Rather than using "static" directly, using this macros allows you to access these variables external while 
+       debugging without being penalized for production builds.
+*/
+
+#if( DEBUG )
+       #define DEBUG_LOCAL
+#else
+       #define DEBUG_LOCAL                     static
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_STATIC
+       
+       @abstract       Macros to make variables and functions static when debugging is off, but extern when debugging is on.
+       
+       @discussion     
+       
+       Rather than using "static" directly, using this macros allows you to access these variables external while 
+       debugging without being penalized for production builds.
+*/
+
+#if( DEBUG )
+       #define DEBUG_STATIC
+#else
+       #define DEBUG_STATIC    static
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DEBUG_EXPORT
+       
+       @abstract       Macros to export variables.
+       
+       @discussion     
+       
+       "__private_extern__" is a hack for IOKit to allow symbols to be exported from compilation units, but 
+       // not exported outside a driver (IOKit uses a lame global namespace for symbols). This still does not 
+       // solve the problem of multiple drivers in the same dependency chain since they share symbols.
+*/
+
+#if( TARGET_API_MAC_OSX_KERNEL )
+       #define DEBUG_EXPORT            __private_extern__
+#else
+       #define DEBUG_EXPORT            extern
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        debug_add
+       
+       @abstract       Macro to add (or subtract if negative) a value when debugging is on. Does nothing if debugging is off.
+*/
+
+#if( DEBUG )
+       #define debug_add( A, B )               ( A ) += ( B )
+#else
+       #define debug_add( A, B )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        debug_perform
+       
+       @abstract       Macro to perform something in debug-only builds.
+*/
+
+#if( DEBUG )
+       #define debug_perform( X )              do { X; } while( 0 )
+#else
+       #define debug_perform( X )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       translate_errno
+
+       @abstract       Returns 0 if the test success. If the test fails, returns errno if non-zero and othewise the alternate error.
+*/
+
+#define translate_errno( TEST, ERRNO, ALTERNATE_ERROR )                ( ( TEST ) ? 0 : ( ERRNO ) ? ( ERRNO ) : ( ALTERNATE_ERROR ) )
+
+#if 0
+#pragma mark == Compile Time macros ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        check_compile_time
+       
+       @abstract       Performs a compile-time check of something such as the size of an int.
+       
+       @discussion     
+       
+       This declares an array with a size that is determined by a compile-time expression. If the expression evaluates 
+       to 0, the array has a size of -1, which is illegal and generates a compile-time error.
+       
+       For example:
+       
+       check_compile_time( sizeof( int ) == 4 );
+       
+       Note: This only works with compile-time expressions.
+       Note: This only works in places where extern declarations are allowed (e.g. global scope).
+       
+       References:
+       
+       <http://www.jaggersoft.com/pubs/CVu11_3.html>
+       <http://www.jaggersoft.com/pubs/CVu11_5.html>
+       
+       Note: The following macros differ from the macros on the www.jaggersoft.com web site because those versions do not
+       work with GCC due to GCC allow a zero-length array. Using a -1 condition turned out to be more portable.
+*/
+
+#define        check_compile_time( X )         extern int debug_compile_time_name[ ( X ) ? 1 : -1 ]
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        check_compile_time_code
+       
+       @abstract       Perform a compile-time check, suitable for placement in code, of something such as the size of an int.
+       
+       @discussion     
+       
+       This creates a switch statement with an existing case for 0 and an additional case using the result of a 
+       compile-time expression. A switch statement cannot have two case labels with the same constant so if the
+       compile-time expression evaluates to 0, it is illegal and generates a compile-time error. If the compile-time
+       expression does not evaluate to 0, the resulting value is used as the case label and it compiles without error.
+
+       For example:
+       
+       check_compile_time_code( sizeof( int ) == 4 );
+       
+       Note: This only works with compile-time expressions.
+       Note: This does not work in a global scope so it must be inside a function.
+       
+       References:
+       
+       <http://www.jaggersoft.com/pubs/CVu11_3.html>
+       <http://www.jaggersoft.com/pubs/CVu11_5.html>
+*/
+
+#define        check_compile_time_code( X )    switch( 0 ) { case 0: case X:; }
+
+#if 0
+#pragma mark == check macros ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        check
+       
+       @abstract       Check that an expression is true (non-zero).
+       
+       @discussion     
+       
+       If expression evalulates to false, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) using the default debugging output method.
+                               
+       Code inside check() statements is not compiled into production builds. 
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef check
+#endif
+#if( !defined( check ) )
+       #if( DEBUG )
+               #define check( X )                                                                                                                                                                      \
+                       do                                                                                                                                                                                              \
+                       {                                                                                                                                                                                               \
+                               if( !( X ) )                                                                                                                                                            \
+                               {                                                                                                                                                                                       \
+                                       debug_print_assert( 0, #X, NULL, __FILE__, __LINE__, __ROUTINE__ );                                             \
+                               }                                                                                                                                                                                       \
+                       } while( 0 )
+       #else
+               #define check( X )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        check_string
+       
+       @abstract       Check that an expression is true (non-zero) with an explanation.
+       
+       @discussion     
+       
+       If expression evalulates to false, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) and a custom explanation string using the default debugging output method.
+                               
+       Code inside check_string() statements is not compiled into production builds. 
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef check_string
+#endif
+#if( !defined( check_string ) )
+       #if( DEBUG )
+               #define check_string( X, STR )                                                                                                                                          \
+                       do                                                                                                                                                                                              \
+                       {                                                                                                                                                                                               \
+                               if( !( X ) )                                                                                                                                                            \
+                               {                                                                                                                                                                                       \
+                                       debug_print_assert( 0, #X, STR, __FILE__, __LINE__, __ROUTINE__ );                                              \
+                               }                                                                                                                                                                                       \
+                                                                                                                                                                                                                       \
+                       }       while( 0 )
+       #else
+               #define check_string( X, STR )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        check_noerr
+       
+       @abstract       Check that an error code is noErr (0).
+       
+       @discussion     
+       
+       If the error code is non-0, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) using the default debugging output method.
+                               
+       Code inside check_noerr() statements is not compiled into production builds. 
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef check_noerr
+#endif
+#if( !defined( check_noerr ) )
+       #if( DEBUG )
+               #define check_noerr( ERR )                                                                                                                                                      \
+                       do                                                                                                                                                                                              \
+                       {                                                                                                                                                                                               \
+                               int_least32_t           localErr;                                                                                                                               \
+                                                                                                                                                                                                                       \
+                               localErr = (int_least32_t)( ERR );                                                                                                                      \
+                               if( localErr != 0 )                                                                                                                                             \
+                               {                                                                                                                                                                                       \
+                                       debug_print_assert( localErr, NULL, NULL, __FILE__, __LINE__, __ROUTINE__ );                    \
+                               }                                                                                                                                                                                       \
+                                                                                                                                                                                                                       \
+                       }       while( 0 )
+       #else
+               #define check_noerr( ERR )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        check_noerr_string
+       
+       @abstract       Check that an error code is noErr (0) with an explanation.
+       
+       @discussion     
+       
+       If the error code is non-0, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) and a custom explanation string using the default debugging output method.
+                               
+       Code inside check_noerr_string() statements is not compiled into production builds. 
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef check_noerr_string
+#endif
+#if( !defined( check_noerr_string ) )
+       #if( DEBUG )
+               #define check_noerr_string( ERR, STR )                                                                                                                          \
+                       do                                                                                                                                                                                              \
+                       {                                                                                                                                                                                               \
+                               int_least32_t           localErr;                                                                                                                               \
+                                                                                                                                                                                                                       \
+                               localErr = (int_least32_t)( ERR );                                                                                                                      \
+                               if( localErr != 0 )                                                                                                                                             \
+                               {                                                                                                                                                                                       \
+                                       debug_print_assert( localErr, NULL, STR, __FILE__, __LINE__, __ROUTINE__ );                             \
+                               }                                                                                                                                                                                       \
+                                                                                                                                                                                                                       \
+                       }       while( 0 )
+       #else
+               #define check_noerr_string( ERR, STR )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        check_translated_errno
+       
+       @abstract       Check a condition and prints errno (if non-zero) to the log.
+       
+       @discussion     
+       
+       Code inside check_translated_errno() statements is not compiled into production builds.
+*/
+
+#if( !defined( check_translated_errno ) )
+       #if( DEBUG )
+               #define check_translated_errno( TEST, ERRNO, ALTERNATE_ERROR )                                                                          \
+                       do                                                                                                                                                                                              \
+                       {                                                                                                                                                                                               \
+                               if( !( TEST ) )                                                                                                                                                         \
+                               {                                                                                                                                                                                       \
+                                       int_least32_t           localErr;                                                                                                                       \
+                                                                                                                                                                                                                       \
+                                       localErr = (int_least32_t)( ERRNO );                                                                                                    \
+                                       localErr = ( localErr != 0 ) ? localErr : (int_least32_t)( ALTERNATE_ERROR );                   \
+                                       debug_print_assert( localErr, #TEST, NULL, __FILE__, __LINE__, __ROUTINE__ );                   \
+                               }                                                                                                                                                                                       \
+                                                                                                                                                                                                                       \
+                       }       while( 0 )
+       #else
+               #define check_translated_errno( TEST, ERRNO, ALTERNATE_ERROR )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        check_ptr_overlap
+       
+       @abstract       Checks that two ptrs do not overlap.
+*/
+
+#define        check_ptr_overlap( P1, P1_SIZE, P2, P2_SIZE )                                                                           \
+       do                                                                                                                                                                              \
+       {                                                                                                                                                                               \
+               check( !( ( (uintptr_t)( P1 ) >=     (uintptr_t)( P2 ) ) &&                                             \
+                                 ( (uintptr_t)( P1 ) <  ( ( (uintptr_t)( P2 ) ) + ( P2_SIZE ) ) ) ) );         \
+               check( !( ( (uintptr_t)( P2 ) >=     (uintptr_t)( P1 ) ) &&                                             \
+                                 ( (uintptr_t)( P2 ) <  ( ( (uintptr_t)( P1 ) ) + ( P1_SIZE ) ) ) ) );         \
+                                                                                                                                                                                       \
+       }       while( 0 )
+
+#if 0
+#pragma mark == require macros ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require
+       
+       @abstract       Requires that an expression evaluate to true.
+       
+       @discussion     
+       
+       If expression evalulates to false, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) using the default debugging output method then jumps to a label.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require
+#endif
+#if( !defined( require ) )
+       #define require( X, LABEL )                                                                                                                                                             \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( !( X ) )                                                                                                                                                                    \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( 0, #X, NULL, __FILE__, __LINE__, __ROUTINE__ );                                                     \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_string
+       
+       @abstract       Requires that an expression evaluate to true with an explanation.
+       
+       @discussion     
+       
+       If expression evalulates to false, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) and a custom explanation string using the default debugging output method then jumps to a label.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_string
+#endif
+#if( !defined( require_string ) )
+       #define require_string( X, LABEL, STR )                                                                                                                                 \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( !( X ) )                                                                                                                                                                    \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( 0, #X, STR, __FILE__, __LINE__, __ROUTINE__ );                                                      \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_quiet
+       
+       @abstract       Requires that an expression evaluate to true.
+       
+       @discussion     
+       
+       If expression evalulates to false, this jumps to a label. No debugging information is printed.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_quiet
+#endif
+#if( !defined( require_quiet ) )
+       #define require_quiet( X, LABEL )                                                                                                                                               \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( !( X ) )                                                                                                                                                                    \
+                       {                                                                                                                                                                                               \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_noerr
+       
+       @abstract       Require that an error code is noErr (0).
+       
+       @discussion     
+       
+       If the error code is non-0, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) using the default debugging output method then jumps to a label.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_noerr
+#endif
+#if( !defined( require_noerr ) )
+       #define require_noerr( ERR, LABEL )                                                                                                                                             \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       int_least32_t           localErr;                                                                                                                                       \
+                                                                                                                                                                                                                       \
+                       localErr = (int_least32_t)( ERR );                                                                                                                              \
+                       if( localErr != 0 )                                                                                                                                                     \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( localErr, NULL, NULL, __FILE__, __LINE__, __ROUTINE__ );                            \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_noerr_string
+       
+       @abstract       Require that an error code is noErr (0).
+       
+       @discussion     
+       
+       If the error code is non-0, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.), and a custom explanation string using the default debugging output method using the 
+       default debugging output method then jumps to a label.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_noerr_string
+#endif
+#if( !defined( require_noerr_string ) )
+       #define require_noerr_string( ERR, LABEL, STR )                                                                                                                 \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       int_least32_t           localErr;                                                                                                                                       \
+                                                                                                                                                                                                                       \
+                       localErr = (int_least32_t)( ERR );                                                                                                                              \
+                       if( localErr != 0 )                                                                                                                                                     \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( localErr, NULL, STR, __FILE__, __LINE__, __ROUTINE__ );                                     \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_noerr_action_string
+       
+       @abstract       Require that an error code is noErr (0).
+       
+       @discussion     
+       
+       If the error code is non-0, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.), and a custom explanation string using the default debugging output method using the 
+       default debugging output method then executes an action and jumps to a label.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_noerr_action_string
+#endif
+#if( !defined( require_noerr_action_string ) )
+       #define require_noerr_action_string( ERR, LABEL, ACTION, STR )                                                                                  \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       int_least32_t           localErr;                                                                                                                                       \
+                                                                                                                                                                                                                       \
+                       localErr = (int_least32_t)( ERR );                                                                                                                              \
+                       if( localErr != 0 )                                                                                                                                                     \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( localErr, NULL, STR, __FILE__, __LINE__, __ROUTINE__ );                                     \
+                               { ACTION; }                                                                                                                                                                     \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_noerr_quiet
+       
+       @abstract       Require that an error code is noErr (0).
+       
+       @discussion     
+       
+       If the error code is non-0, this jumps to a label. No debugging information is printed.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_noerr_quiet
+#endif
+#if( !defined( require_noerr_quiet ) )
+       #define require_noerr_quiet( ERR, LABEL )                                                                                                                               \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( ( ERR ) != 0 )                                                                                                                                                              \
+                       {                                                                                                                                                                                               \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_noerr_action
+       
+       @abstract       Require that an error code is noErr (0) with an action to execute otherwise.
+       
+       @discussion     
+       
+       If the error code is non-0, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) using the default debugging output method then executes an action and jumps to a label.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_noerr_action
+#endif
+#if( !defined( require_noerr_action ) )
+       #define require_noerr_action( ERR, LABEL, ACTION )                                                                                                              \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       int_least32_t           localErr;                                                                                                                                       \
+                                                                                                                                                                                                                       \
+                       localErr = (int_least32_t)( ERR );                                                                                                                              \
+                       if( localErr != 0 )                                                                                                                                                     \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( localErr, NULL, NULL, __FILE__, __LINE__, __ROUTINE__ );                            \
+                               { ACTION; }                                                                                                                                                                     \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_noerr_action_quiet
+       
+       @abstract       Require that an error code is noErr (0) with an action to execute otherwise.
+       
+       @discussion     
+       
+       If the error code is non-0, this executes an action and jumps to a label. No debugging information is printed.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_noerr_action_quiet
+#endif
+#if( !defined( require_noerr_action_quiet ) )
+       #define require_noerr_action_quiet( ERR, LABEL, ACTION )                                                                                                \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( ( ERR ) != 0 )                                                                                                                                                              \
+                       {                                                                                                                                                                                               \
+                               { ACTION; }                                                                                                                                                                     \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_action
+       
+       @abstract       Requires that an expression evaluate to true with an action to execute otherwise.
+       
+       @discussion     
+       
+       If expression evalulates to false, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) using the default debugging output method then executes an action and jumps to a label.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_action
+#endif
+#if( !defined( require_action ) )
+       #define require_action( X, LABEL, ACTION )                                                                                                                              \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( !( X ) )                                                                                                                                                                    \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( 0, #X, NULL, __FILE__, __LINE__, __ROUTINE__ );                                                     \
+                               { ACTION; }                                                                                                                                                                     \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_action_quiet
+       
+       @abstract       Requires that an expression evaluate to true with an action to execute otherwise.
+       
+       @discussion     
+       
+       If expression evalulates to false, this executes an action and jumps to a label. No debugging information is printed.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_action_quiet
+#endif
+#if( !defined( require_action_quiet ) )
+       #define require_action_quiet( X, LABEL, ACTION )                                                                                                                \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( !( X ) )                                                                                                                                                                    \
+                       {                                                                                                                                                                                               \
+                               { ACTION; }                                                                                                                                                                     \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_action_string
+       
+       @abstract       Requires that an expression evaluate to true with an explanation and action to execute otherwise.
+       
+       @discussion     
+       
+       If expression evalulates to false, this prints debugging information (actual expression string, file, line number, 
+       function name, etc.) and a custom explanation string using the default debugging output method then executes an
+       action and jumps to a label.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef require_action_string
+#endif
+#if( !defined( require_action_string ) )
+       #define require_action_string( X, LABEL, ACTION, STR )                                                                                                  \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( !( X ) )                                                                                                                                                                    \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( 0, #X, STR, __FILE__, __LINE__, __ROUTINE__ );                                              \
+                               { ACTION; }                                                                                                                                                                     \
+                               goto LABEL;                                                                                                                                                                     \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        require_throw
+       
+       @abstract       Requires that an expression evaluates to true or an exception is thrown.
+       
+       @discussion     
+       
+       If the expression evaluates to false, this prints debugging information (actual expression string, file, 
+       line number, function name, etc.) using the default debugging output method then throws an exception.
+*/
+
+#if( defined( __cplusplus ) )
+       #define require_throw( X )                                                                                                                                                              \
+               do                                                                                                                                                                                                      \
+               {                                                                                                                                                                                                       \
+                       if( !( X ) )                                                                                                                                                                    \
+                       {                                                                                                                                                                                               \
+                               debug_print_assert( 0, #X, NULL, __FILE__, __LINE__, __ROUTINE__ );                                                     \
+                               throw kUnknownErr;                                                                                                                                                      \
+                       }                                                                                                                                                                                               \
+                                                                                                                                                                                                                       \
+               }       while( 0 )
+#endif
+
+#if 0
+#pragma mark == Design-By-Contract macros ==
+#endif
+
+//===========================================================================================================================
+//     Design-By-Contract macros
+//===========================================================================================================================
+
+#define        ensure( X )                                                                                                     check( X )
+#define        ensure_string( X, STR )                                                                         check_string( X, STR )
+#define        ensure_noerr( ERR )                                                                                     check_noerr( ERR )
+#define        ensure_noerr_string( ERR, STR )                                                         check_noerr_string( ERR, STR )
+#define        ensure_translated_errno( TEST, ERRNO, ALTERNATE_ERROR )         check_translated_errno( TEST, ERRNO, ALTERNATE_ERROR )
+
+// Note: Design-By-Contract "require" macros are already defined elsewhere.
+
+#if 0
+#pragma mark == Expect macros ==
+#endif
+
+//===========================================================================================================================
+//     Expect macros
+//===========================================================================================================================
+
+// Expect macros allow code to include runtime checking of things that should not happen in shipping code (e.g. internal 
+// programmer errors, such as a NULL parameter where it is not allowed). Once the code has been verified to work correctly 
+// without asserting, the DEBUG_EXPECT_VERIFIED conditional can be set to eliminate the error checking entirely. It can 
+// also be useful to measure the cost of error checking code by profiling with it enable and with it disabled.
+
+#if( DEBUG_EXPECT_VERIFIED )
+       #define require_expect
+       #define require_string_expect
+       #define require_quiet_expect
+       #define require_noerr_expect
+       #define require_noerr_string_expect
+       #define require_noerr_action_string_expect
+       #define require_noerr_quiet_expect
+       #define require_noerr_action_expect
+       #define require_noerr_action_quiet_expect
+       #define require_action_expect
+       #define require_action_quiet_expect
+       #define require_action_string_expect
+#else
+       #define require_expect                                                  require
+       #define require_string_expect                                   require_string
+       #define require_quiet_expect                                    require_quiet
+       #define require_noerr_expect                                    require_noerr
+       #define require_noerr_string_expect                             require_noerr_string
+       #define require_noerr_action_string_expect              require_noerr_action_string
+       #define require_noerr_quiet_expect                              require_noerr_quiet
+       #define require_noerr_action_expect                             require_noerr_action
+       #define require_noerr_action_quiet_expect               require_noerr_action_quiet
+       #define require_action_expect                                   require_action
+       #define require_action_quiet_expect                             require_action_quiet
+       #define require_action_string_expect                    require_action_string
+#endif
+
+#if 0
+#pragma mark == Output macros ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        debug_string
+       
+       @abstract       Prints a debugging C string.
+*/
+
+#if( DEBUG_OVERRIDE_APPLE_MACROS )
+       #undef debug_string
+#endif
+#if( !defined( debug_string ) )
+       #if( DEBUG )
+               #define debug_string( STR )                                                                                                                                             \
+                       do                                                                                                                                                                                      \
+                       {                                                                                                                                                                                       \
+                               debug_print_assert( 0, NULL, STR, __FILE__, __LINE__, __ROUTINE__ );                                    \
+                                                                                                                                                                                                               \
+                       }       while( 0 )
+       #else
+               #define debug_string( STR )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        debug_print_assert
+       
+       @abstract       Prints an assertion.
+*/
+
+#if( DEBUG )
+       #define debug_print_assert( ERROR_CODE, ASSERT_STRING, MESSAGE, FILENAME, LINE_NUMBER, FUNCTION )       \
+               DebugPrintAssert( ERROR_CODE, ASSERT_STRING, MESSAGE, FILENAME, LINE_NUMBER, FUNCTION )
+#else
+       #define debug_print_assert( ERROR_CODE, ASSERT_STRING, MESSAGE, FILENAME, LINE_NUMBER, FUNCTION )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        dlog
+       
+       @abstract       Prints a debug-only message.
+*/
+
+#if( DEBUG )
+       #if( DEBUG_C99_VA_ARGS )
+               #define dlog( ... )                     DebugPrintF( __VA_ARGS__ )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define dlog( ARGS... )         DebugPrintF( ## ARGS )                  
+       #else
+               #define dlog                            DebugPrintF
+       #endif
+#else
+       #if( DEBUG_C99_VA_ARGS )
+               #define dlog( ... )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define dlog( ARGS... )
+       #else
+               #define dlog                            while( 0 )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        dlogv
+       
+       @abstract       Prints a debug-only message.
+*/
+
+#if( DEBUG )
+       #define dlogv( LEVEL, FORMAT, LIST )            DebugPrintFVAList( ( LEVEL ), ( FORMAT ), ( LIST ) )
+#else
+       #define dlogv( LEVEL, FORMAT, LIST )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        dlogmem
+       
+       @abstract       Prints a debug-only dump of memory.
+*/
+
+#if( DEBUG )
+       #define dlogmem( LEVEL, PTR, SIZE )             \
+               DebugHexDump( ( LEVEL ), 0, NULL, 0, 0, NULL, 0, ( PTR ), ( PTR ), ( SIZE ), kDebugFlagsNone, NULL, 0 )
+#else
+       #define dlogmem( LEVEL, PTR, SIZE )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DebugNSLog
+       
+       @abstract       Debug-only macro for the Cocoa NSLog function.
+*/
+
+#if( DEBUG )
+       #if( DEBUG_C99_VA_ARGS )
+               #define DebugNSLog( ... )                       NSLog( __VA_ARGS__ )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define DebugNSLog( ARGS... )           NSLog( ## ARGS )
+       #else
+               #define DebugNSLog                                      NSLog
+       #endif
+#else
+       #if( DEBUG_C99_VA_ARGS )
+               #define DebugNSLog( ... )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define DebugNSLog( ARGS... )
+       #else
+               #define DebugNSLog                                      while( 0 )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @defined        DebugLogMsg
+       
+       @abstract       Debug-only macro for the VxWorks logMsg function.
+*/
+
+#if( TARGET_OS_VXWORKS )
+       #if( DEBUG )
+               #define DebugLogMsg( LEVEL, FORMAT, P1, P2, P3, P4, P5, P6 )                                                    \
+                       do                                                                                                                                                                      \
+                       {                                                                                                                                                                       \
+                               if( ( inLevel >= gDebugPrintLevelMin ) || ( inLevel <= gDebugPrintLevelMax ) )  \
+                               {                                                                                                                                                               \
+                                       logMsg( ( FORMAT ), ( P1 ), ( P2 ), ( P3 ), ( P4 ), ( P5 ), ( P6 ) );           \
+                               }                                                                                                                                                               \
+                                                                                                                                                                                               \
+                       }       while( 0 )
+       #else
+               #define DebugLogMsg( LEVEL, FORMAT, P1, P2, P3, P4, P5, P6 )
+       #endif
+#else
+       #define DebugLogMsg             dlog
+#endif
+
+#if 0
+#pragma mark == Routines - General ==
+#endif
+
+#ifdef __cplusplus
+       extern "C" {
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugInitialize
+
+       @abstract       Initializes the debugging library for a specific kind of output.
+
+       @param          inType          
+       @param          varArg          Variable number parameters, controlled by the "inType" parameter.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT OSStatus   DebugInitialize( DebugOutputType inType, ... );
+#endif
+
+#if( DEBUG )
+       #if( DEBUG_C99_VA_ARGS )
+               #define debug_initialize( ... )                 DebugInitialize( __VA_ARGS__ )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define debug_initialize( ARGS... )             DebugInitialize( ## ARGS )
+       #else
+               #define debug_initialize                                DebugInitialize
+       #endif
+#else
+       #if( DEBUG_C99_VA_ARGS )
+               #define debug_initialize( ... )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define debug_initialize( ARGS... )
+       #else
+               #define debug_initialize                                while( 0 )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugFinalize
+
+       @abstract       Releases any resources used by the debugging library
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT void               DebugFinalize( void );
+#endif
+
+#if( DEBUG )                     
+       #define debug_terminate()       DebugFinalize()
+#else
+       #define debug_terminate()
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugGetProperty
+
+       @abstract       Gets the specified property from the debugging library.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT OSStatus   DebugGetProperty( DebugPropertyTag inTag, ... );
+#endif
+
+#if( DEBUG )
+       #if( DEBUG_C99_VA_ARGS )
+               #define debug_get_property( ... )                       DebugGetProperty( __VA_ARGS__ )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define debug_get_property( ARGS... )           DebugGetProperty( ## ARGS )
+       #else
+               #define debug_get_property                                      DebugGetProperty
+       #endif
+#else
+       #if( DEBUG_C99_VA_ARGS )
+               #define debug_get_property( ... )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define debug_get_property( ARGS... )
+       #else
+               #define debug_get_property                                      while( 0 )
+       #endif
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugSetProperty
+
+       @abstract       Sets the specified property from the debugging library.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT OSStatus   DebugSetProperty( DebugPropertyTag inTag, ... );
+#endif
+
+#if( DEBUG )
+       #if( DEBUG_C99_VA_ARGS )
+               #define debug_set_property( ... )                       DebugSetProperty( __VA_ARGS__ )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define debug_set_property( ARGS... )           DebugSetProperty( ## ARGS )
+       #else
+               #define debug_set_property                                      DebugSetProperty
+       #endif
+#else
+       #if( DEBUG_C99_VA_ARGS )
+               #define debug_set_property( ... )
+       #elif( DEBUG_GNU_VA_ARGS )
+               #define debug_set_property( ARGS... )
+       #else
+               #define debug_set_property                                      while( 0 )
+       #endif
+#endif
+
+#if 0
+#pragma mark == Routines - Debugging Output ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugPrintF
+
+       @abstract       Prints a debug message with printf-style formatting.
+       
+       @param          inLevel Error that generated this assert or noErr.
+       
+       @param          inFormatString
+                                       C string containing assertion text.
+
+       @param          VAR_ARG
+                                       Variable number of arguments depending on the format string.
+       
+       @result         Number of bytes printed or -1 on error.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT size_t             DebugPrintF( DebugLevel inLevel, const char *inFormat, ... );
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugPrintFVAList
+
+       @abstract       va_list version of DebugPrintF. See DebugPrintF for more info.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT size_t             DebugPrintFVAList( DebugLevel inLevel, const char *inFormat, va_list inArgs );
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugPrintAssert
+
+       @abstract       Prints a message describing the reason the (e.g. an assert failed), an optional error message, 
+                               an optional source filename, an optional source line number.
+
+       @param          inErrorCode                     Error that generated this assert or noErr.
+       @param          inAssertString          C string containing assertion text.
+       @param          inMessage                       C string containing a message about the assert.
+       @param          inFileName                      C string containing path of file where the error occurred.
+       @param          inLineNumber            Line number in source file where the error occurred.
+       @param          inFunction                      C string containing name of function where assert occurred.
+
+       @discussion
+       
+       Example output: 
+       
+       [ASSERT] assert: "dataPtr != NULL" allocate memory for object failed
+       [ASSERT] where:  "MyFile.c", line 123, ("MyFunction")
+       
+       OR
+       
+       [ASSERT] error:  -6728 (kNoMemoryErr)
+       [ASSERT] where:  "MyFile.c", line 123, ("MyFunction")
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT void
+               DebugPrintAssert( 
+                       int_least32_t   inErrorCode, 
+                       const char *    inAssertString, 
+                       const char *    inMessage, 
+                       const char *    inFilename, 
+                       int_least32_t   inLineNumber, 
+                       const char *    inFunction );
+#endif
+
+#if 0
+#pragma mark == Routines - Utilities ==
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugSNPrintF
+       
+       @abstract       Debugging versions of standard C snprintf with extra features.
+       
+       @param          sbuffer         Buffer to receive result. Null terminated unless the buffer size is 0.
+       @param          buflen          Size of the buffer including space for the null terminator.
+       @param          fmt                     printf-style format string.
+       @param          VAR_ARG         Variable number of arguments depending on the format string.
+
+       @result         Number of characters written (minus the null terminator).
+       
+       @discussion     
+       
+       Extra features over the standard C snprintf:
+       <pre>
+               64-bit support for %d (%lld), %i (%lli), %u (%llu), %o (%llo), %x (%llx), and %b (%llb).
+               %@   - Cocoa/CoreFoundation object. Param is the object. Strings are used directly. Others use CFCopyDescription.
+               %a   - Network Address: %.4a=IPv4, %.6a=Ethernet, %.8a Fibre Channel, %.16a=IPv6. Arg=ptr to network address.
+               %#a  - IPv4 or IPv6 mDNSAddr. Arg=ptr to mDNSAddr.
+               %##a - IPv4 (if AF_INET defined) or IPv6 (if AF_INET6 defined) sockaddr. Arg=ptr to sockaddr.
+               %b   - Binary representation of integer (e.g. 01101011). Modifiers and arg=the same as %d, %x, etc.
+               %C   - Mac-style FourCharCode (e.g. 'APPL'). Arg=32-bit value to print as a Mac-style FourCharCode.
+               %H   - Hex Dump (e.g. "\x6b\xa7" -> "6B A7"). 1st arg=ptr, 2nd arg=size, 3rd arg=max size.
+               %#H  - Hex Dump & ASCII (e.g. "\x41\x62" -> "6B A7 'Ab'"). 1st arg=ptr, 2nd arg=size, 3rd arg=max size.
+               %m   - Error Message (e.g. 0 -> "kNoErr"). Modifiers and error code arg=the same as %d, %x, etc.
+               %#s  - Pascal-style length-prefixed string. Arg=ptr to string.
+               %##s - DNS label-sequence name. Arg=ptr to name.
+               %S   - UTF-16 string, 0x0000 terminated. Host order if no BOM. Precision is UTF-16 count. Precision includes BOM.
+               %#S  - Big Endian UTF-16 string (unless BOM overrides). Otherwise, the same as %S.
+               %##S - Little Endian UTF-16 string (unless BOM overrides). Otherwise, the same as %S.
+               %U   - Universally Unique Identifier (UUID) (e.g. 6ba7b810-9dad-11d1-80b4-00c04fd430c8). Arg=ptr to 16-byte UUID.
+       </pre>
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT size_t DebugSNPrintF(char *sbuffer, size_t buflen, const char *fmt, ...);
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugSNPrintFVAList
+
+       @abstract       va_list version of DebugSNPrintF. See DebugSNPrintF for more info.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT size_t DebugSNPrintFVAList(char *sbuffer, size_t buflen, const char *fmt, va_list arg);
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugGetErrorString
+
+       @abstract       Gets an error string from an error code.
+
+       @param          inStatus                Error code to get the string for.
+       @param          inBuffer                Optional buffer to copy the string to for non-static strings. May be null.
+       @param          inBufferSize    Size of optional buffer. May be 0.
+       
+       @result         C string containing error string for the error code. Guaranteed to be a valid, static string. If a 
+                               buffer is supplied, the return value will always be a pointer to the supplied buffer, which will 
+                               contain the best available description of the error code. If a buffer is not supplied, the return
+                               value will be the best available description of the error code that can be represented as a static 
+                               string. This allows code that cannot use a temporary buffer to hold the result to still get a useful 
+                               error string in most cases, but also allows code that can use a temporary buffer to get the best 
+                               available description.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT const char *       DebugGetErrorString( int_least32_t inErrorCode, char *inBuffer, size_t inBufferSize );
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugHexDump
+
+       @abstract       Hex dumps data to a string or to the output device.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT size_t
+               DebugHexDump( 
+                       DebugLevel              inLevel, 
+                       int                             inIndent, 
+                       const char *    inLabel, 
+                       size_t                  inLabelSize, 
+                       int                             inLabelMinWidth, 
+                       const char *    inType, 
+                       size_t                  inTypeSize, 
+                       const void *    inDataStart, 
+                       const void *    inData, 
+                       size_t                  inDataSize, 
+                       DebugFlags              inFlags, 
+                       char *                  outBuffer, 
+                       size_t                  inBufferSize );
+#endif
+
+#if( DEBUG )
+       #define dloghex( LEVEL, INDENT, LABEL, LABEL_SIZE, LABEL_MIN_SIZE, TYPE, TYPE_SIZE, DATA_START, DATA, DATA_SIZE, FLAGS, BUFFER, BUFFER_SIZE )   \
+               DebugHexDump( ( LEVEL ), (INDENT), ( LABEL ), ( LABEL_SIZE ), ( LABEL_MIN_SIZE ), ( TYPE ), ( TYPE_SIZE ),                                                              \
+                       ( DATA_START ), ( DATA ), ( DATA_SIZE ), ( FLAGS ), ( BUFFER ), ( BUFFER_SIZE ) )
+#else
+       #define dloghex( LEVEL, INDENT, LABEL, LABEL_SIZE, LABEL_MIN_SIZE, TYPE, TYPE_SIZE, DATA_START, DATA, DATA_SIZE, FLAGS, BUFFER, BUFFER_SIZE )
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugTaskLevel
+
+       @abstract       Returns the current task level.
+
+       @result         Current task level
+       
+       @discussion     
+       
+       Bit masks to isolate portions of the result (note that some masks may also need bit shifts to right justify):
+       <pre>
+               kDebugInterruptLevelMask                                - Indicates the current interrupt level (> 0 means interrupt time).
+               kDebugInVBLTaskMask                                             - Indicates if a VBL task is currently being executed.
+               kDebugInDeferredTaskMask                                - Indicates if a Deferred Task is currently being executed.
+               kDebugInSecondaryInterruptHandlerMask   - Indicates if a Secondary Interrupt Handler is currently being executed.
+               kDebugPageFaultFatalMask                                - Indicates if it is unsafe to cause a page fault (worse than interrupt time).
+               kDebugMPTaskLevelMask                                   - Indicates if being called from an MP task.
+               kDebugInterruptDepthMask                                - 0 means task level, 1 means in interrupt, > 1 means in nested interrupt.
+       </pre>
+       
+       Helpers:
+       <pre>
+               DebugExtractTaskLevelInterruptDepth()   - Macro to extract interrupt depth from task level value.
+       </pre>
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT uint32_t   DebugTaskLevel( void );
+#endif
+
+//---------------------------------------------------------------------------------------------------------------------------
+/*!    @function       DebugServicesTest
+
+       @abstract       Unit test.
+*/
+
+#if( DEBUG )
+       DEBUG_EXPORT OSStatus   DebugServicesTest( void );
+#endif
+
+#ifdef __cplusplus
+       }
+#endif
+
+#endif // __DEBUG_SERVICES__
index 1d231f291171973a3a95ef1329aa3401d13af645..d9f9033425e1a05a10e2bcacb800e091d173db1d 100755 (executable)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003 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@
 
        File:           GenLinkedList.c
 
@@ -30,6 +24,9 @@
     Change History (most recent first):
 
 $Log: GenLinkedList.c,v $
+Revision 1.4  2006/08/14 23:24:56  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2004/04/22 21:14:42  cheshire
 Fix comment spelling mistake
 
index 5a7de91dd9227f2b04daa1284c05761b21e0dd51..4df6e67c47f15360ee7e2aadce3f772394849082 100755 (executable)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003 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@
 
        File:           GenLinkedList.c
 
@@ -30,6 +24,9 @@
     Change History (most recent first):
 
 $Log: GenLinkedList.h,v $
+Revision 1.3  2006/08/14 23:24:56  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/02/05 07:41:08  cheshire
 Add Log header
 
index 665263d3fbb329f874928c3e6b46dd27efd1f015..85e9d0297bae1aeda3e5b9fd37a01499e7196302 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: BaseListener.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/04/30 21:48:27  rpantos
 Change line endings for CVS.
 
index 5bda3ae8cede25ca0a60d377c6de381bf9dceba5..b254c9752e00a2efb0a3239345f37a9b75c9ceeb 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: BrowseListener.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/04/30 21:48:27  rpantos
 Change line endings for CVS.
 
index 73e1626358d3f971403cc08f93b9e5678d9deda3..5050a7a60ef9ac33d9d27c7b8c3886197638e5a3 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: DNSRecord.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/12/11 03:00:59  rpantos
 <rdar://problem/3907498> Java DNSRecord API should be cleaned up
 
index 50d29e411e7e2722ef69255afa867780652ffe4d..a431df17825e3447cf390bdbe66a3bcd8728bb59 100644 (file)
@@ -1,28 +1,28 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: DNSSD.java,v $
+Revision 1.11  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.10  2006/06/20 23:05:55  rpantos
+<rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
+
 Revision 1.9  2005/10/26 01:52:24  cheshire
 <rdar://problem/4316286> Race condition in Java code (doesn't work at all on Linux)
 
@@ -54,10 +54,6 @@ First checked in.
        This file declares and implements DNSSD, the central Java factory class
        for doing DNS Service Discovery. It includes the mostly-abstract public
        interface, as well as the Apple* implementation subclasses.
-
-       To do:
-       - implement network interface mappings
-       - RegisterRecord
  */
 
 
@@ -310,6 +306,18 @@ abstract public class      DNSSD
        throws DNSSDException
        { return register( 0, 0, serviceName, regType, null, null, port, null, listener); }
 
+       /** Create a {@link DNSSDRecordRegistrar} allowing efficient registration of 
+               multiple individual records.<P> 
+               <P>
+               @return         A {@link DNSSDRecordRegistrar} that can be used to register records.
+
+               @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
+               @see    RuntimePermission
+       */
+       public static DNSSDRecordRegistrar      createRecordRegistrar( RegisterRecordListener listener)
+       throws DNSSDException
+       { return getInstance()._createRecordRegistrar( listener); }
+
        /** Query for an arbitrary DNS record.<P> 
                @param  flags
                                        Possible values are: MORE_COMING.
@@ -474,6 +482,9 @@ abstract public class       DNSSD
                                                                        String domain, String host, int port, TXTRecord txtRecord, RegisterListener listener)
        throws DNSSDException;
 
+       abstract protected DNSSDRecordRegistrar _createRecordRegistrar( RegisterRecordListener listener)
+       throws DNSSDException;
+
        abstract protected DNSSDService _queryRecord( int flags, int ifIndex, String serviceName, int rrtype, 
                                                                                int rrclass, QueryListener listener)
        throws DNSSDException;
@@ -595,6 +606,12 @@ class      AppleDNSSD extends DNSSD
                                                                                ( txtRecord != null) ? txtRecord.getRawBytes() : null, client);
        }
 
+       protected DNSSDRecordRegistrar  _createRecordRegistrar( RegisterRecordListener listener)
+       throws DNSSDException
+       {
+               return new AppleRecordRegistrar( listener);
+       }
+
        protected DNSSDService          _queryRecord( int flags, int ifIndex, String serviceName, int rrtype, 
                                                                                int rrclass, QueryListener client)
        throws DNSSDException
@@ -797,7 +814,6 @@ class       AppleRegistration extends AppleService implements DNSSDRegistration
                AppleDNSRecord  newRecord = new AppleDNSRecord( this);
 
                this.ThrowOnErr( this.AddRecord( flags, rrType, rData, ttl, newRecord));
-
                return newRecord;
        }
 
@@ -815,6 +831,35 @@ class      AppleRegistration extends AppleService implements DNSSDRegistration
        protected native int    AddRecord( int flags, int rrType, byte[] rData, int ttl, AppleDNSRecord destObj);
 }
 
+class  AppleRecordRegistrar extends AppleService implements DNSSDRecordRegistrar
+{
+       public                  AppleRecordRegistrar( RegisterRecordListener listener) 
+       throws DNSSDException
+       { 
+               super(listener); 
+               this.ThrowOnErr( this.CreateConnection());
+               if ( !AppleDNSSD.hasAutoCallbacks)
+                       new Thread(this).start();
+       }
+
+       public DNSRecord        registerRecord( int flags, int ifIndex, String fullname, int rrtype, 
+                                                                       int rrclass, byte[] rdata, int ttl)
+       throws DNSSDException
+       {
+               AppleDNSRecord  newRecord = new AppleDNSRecord( this);
+
+               this.ThrowOnErr( this.RegisterRecord( flags, ifIndex, fullname, rrtype, rrclass, rdata, ttl, newRecord));
+               return newRecord;
+       }
+
+       // Sets fNativeContext. Returns non-zero on error.
+       protected native int    CreateConnection();
+
+       // Sets fNativeContext. Returns non-zero on error.
+       protected native int    RegisterRecord( int flags, int ifIndex, String fullname, int rrtype, 
+                                                                               int rrclass, byte[] rdata, int ttl, AppleDNSRecord destObj);
+}
+
 class  AppleQuery extends AppleService
 {
        public                  AppleQuery( int flags, int ifIndex, String serviceName, int rrtype, 
index 0ab05875d402b3322509d113234b52ea4494af91..f73afeadd0fb6de9daf24cd2a7a40ab29d3ee570 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: DNSSDException.java,v $
+Revision 1.4  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/07/10 22:19:01  cheshire
 Add missing error codes to list of public static final ints
 
diff --git a/mDNSShared/Java/DNSSDRecordRegistrar.java b/mDNSShared/Java/DNSSDRecordRegistrar.java
new file mode 100644 (file)
index 0000000..825634f
--- /dev/null
@@ -0,0 +1,77 @@
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
+ * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
+ *
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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.
+
+       This file declares the public interface to DNSSDRecordRegistrar, a DNSSDService
+       subclass that allows efficient registration of multiple individual records.
+
+    Change History (most recent first):
+
+$Log: DNSSDRecordRegistrar.java,v $
+Revision 1.2  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.1  2006/06/20 23:00:12  rpantos
+<rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
+
+ */
+
+
+package        com.apple.dnssd;
+
+
+/**    An object for registering records, created by {@link DNSSD#createRecordRegistrar}. */
+
+public interface       DNSSDRecordRegistrar extends DNSSDService
+{
+       /** Register an independent {@link DNSRecord}.<P> 
+               @param  flags
+                                       Possible values are SHARED or UNIQUE (see flag type definitions for details).
+               <P>
+               @param  ifIndex
+                                       If non-zero, specifies the interface on which to register the record
+                                       (the index for a given interface is determined via the if_nametoindex()
+                                       family of calls.)  Passing 0 causes the record to be registered on all interfaces.
+               <P>
+               @param  fullname
+                                       The full domain name of the resource record.
+               <P>
+               @param  rrtype
+                                       The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
+                                       as defined in nameser.h.
+               <P>
+               @param  rrclass
+                                       The class of the resource record, as defined in nameser.h 
+                                       (usually 1 for the Internet class).
+               <P>
+               @param  rData
+                                       The new rdata  as it is to appear in the DNS record.
+               <P>
+               @param  ttl
+                                       The time to live of the resource record, in seconds. Pass 0 to use a default value.
+               <P>
+               @param  listener
+                                       This object will get called when the service is registered.
+               <P>
+               @return         A {@link DNSSDService} that can be used to abort the record registration.
+
+               @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
+               @see    RuntimePermission
+       */
+       public DNSRecord        registerRecord( int flags, int ifIndex, String fullname, int rrtype, 
+                                                                       int rrclass, byte[] rdata, int ttl)
+       throws DNSSDException;
+} 
+
index 4a4942f9d93fb706a1270f83f3522120f88c8406..86f2d831cd702d06f0f5ed95d3b5d784b69a41fa 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: DNSSDRegistration.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/12/11 03:01:00  rpantos
 <rdar://problem/3907498> Java DNSRecord API should be cleaned up
 
index 98683720f1ad6e20d62009e3af85aac36887b613..d5a8a38825a7ef93d95ef44a06d4629db245009d 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: DNSSDService.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/04/30 21:48:27  rpantos
 Change line endings for CVS.
 
index bfb319af55d896b2605a2e4c67426c8f73b9d06a..233c188da00dbd05a5b2caec7f92c4397974044e 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: DomainListener.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/04/30 21:48:27  rpantos
 Change line endings for CVS.
 
index d7c6243eb1798fc11a9d6642610c24e48c74c985..bd40fb9d4ab856dfaecaa31518713fefc79c74e5 100644 (file)
@@ -1,28 +1,34 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: JNISupport.c,v $
+Revision 1.17  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.16  2006/07/14 02:35:47  cheshire
+Added (commented out) syslog debugging messages
+
+Revision 1.15  2006/06/27 19:34:43  cheshire
+<rdar://problem/4430023> txtRecord parameter of DNSServiceResolveReply() should be unsigned char *
+
+Revision 1.14  2006/06/20 23:03:35  rpantos
+<rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
+
 Revision 1.13  2005/10/26 01:52:24  cheshire
 <rdar://problem/4316286> Race condition in Java code (doesn't work at all on Linux)
 
@@ -108,6 +114,8 @@ static DWORD        if_nametoindex( const char * nameStr );
 
 #include "DNSSD.java.h"
 
+//#include <syslog.h>
+
 // convenience definition 
 #ifdef __GNUC__
 #define        _UNUSED __attribute__ ((unused))
@@ -416,7 +424,7 @@ JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleBrowser_CreateBrowser( JNIEnv *
 
 static void DNSSD_API  ServiceResolveReply( DNSServiceRef sdRef _UNUSED, DNSServiceFlags flags, uint32_t interfaceIndex,
                                                                DNSServiceErrorType errorCode, const char *fullname, const char *hosttarget,
-                                                               uint16_t port, uint16_t txtLen, const char *txtRecord, void *context)
+                                                               uint16_t port, uint16_t txtLen, const unsigned char *txtRecord, void *context)
 {
        OpContext               *pContext = (OpContext*) context;
        jclass                  txtCls;
@@ -527,6 +535,7 @@ JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleRegistration_BeginRegister( JNI
                                                        jint ifIndex, jint flags, jstring serviceName, jstring regType,
                                                        jstring domain, jstring host, jint port, jbyteArray txtRecord)
 {
+       //syslog(LOG_ERR, "BR");
        jclass                                  cls = (*pEnv)->GetObjectClass( pEnv, pThis);
        jfieldID                                contextField = (*pEnv)->GetFieldID( pEnv, cls, "fNativeContext", "I");
        OpContext                               *pContext = NULL;
@@ -534,6 +543,8 @@ JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleRegistration_BeginRegister( JNI
        jbyte                                   *pBytes;
        jsize                                   numBytes;
 
+       //syslog(LOG_ERR, "BR: contextField %d", contextField);
+
        if ( contextField != 0)
                pContext = NewContext( pEnv, pThis, "serviceRegistered",
                                                                "(Lcom/apple/dnssd/DNSSDRegistration;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
@@ -547,6 +558,8 @@ JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleRegistration_BeginRegister( JNI
                const char      *domainStr = SafeGetUTFChars( pEnv, domain);
                const char      *hostStr = SafeGetUTFChars( pEnv, host);
 
+               //syslog(LOG_ERR, "BR: regStr %s", regStr);
+
                // Since Java ints are defined to be big-endian, we de-canonicalize 'port' from a 
                // big-endian number into a 16-bit pattern here.
                uint16_t        portBits = port;
@@ -674,6 +687,119 @@ JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleDNSRecord_Remove( JNIEnv *pEnv,
 }
 
 
+JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleRecordRegistrar_CreateConnection( JNIEnv *pEnv, jobject pThis)
+{
+       jclass                                  cls = (*pEnv)->GetObjectClass( pEnv, pThis);
+       jfieldID                                contextField = (*pEnv)->GetFieldID( pEnv, cls, "fNativeContext", "I");
+       OpContext                               *pContext = NULL;
+       DNSServiceErrorType             err = kDNSServiceErr_NoError;
+
+       if ( contextField != 0)
+               pContext = NewContext( pEnv, pThis, "recordRegistered", "(Lcom/apple/dnssd/DNSRecord;I)V");
+       else
+               err = kDNSServiceErr_BadParam;
+
+       if ( pContext != NULL)
+       {
+               err = DNSServiceCreateConnection( &pContext->ServiceRef);
+               if ( err == kDNSServiceErr_NoError)
+               {
+                       (*pEnv)->SetIntField( pEnv, pThis, contextField, (jint) pContext);
+               }
+       }
+       else
+               err = kDNSServiceErr_NoMemory;
+
+       return err;
+}
+
+struct RecordRegistrationRef
+{
+       OpContext               *Context;
+       jobject                 RecordObj;
+};
+typedef struct RecordRegistrationRef   RecordRegistrationRef;
+
+static void DNSSD_API  RegisterRecordReply( DNSServiceRef sdRef _UNUSED, 
+                                                               DNSRecordRef recordRef _UNUSED, DNSServiceFlags flags, 
+                                                               DNSServiceErrorType errorCode, void *context)
+{
+       RecordRegistrationRef   *regEnvelope = (RecordRegistrationRef*) context;
+       OpContext               *pContext = regEnvelope->Context;
+
+       SetupCallbackState( &pContext->Env);
+
+       if ( pContext->ClientObj != NULL && pContext->Callback != NULL)
+       {       
+               if ( errorCode == kDNSServiceErr_NoError)
+               {       
+                       (*pContext->Env)->CallVoidMethod( pContext->Env, pContext->ClientObj, pContext->Callback, 
+                                                                                               regEnvelope->RecordObj, flags);
+               }
+               else
+                       ReportError( pContext->Env, pContext->ClientObj, pContext->JavaObj, errorCode);
+       }
+
+       (*pContext->Env)->DeleteWeakGlobalRef( pContext->Env, regEnvelope->RecordObj);
+       free( regEnvelope);
+
+       TeardownCallbackState();
+}
+
+JNIEXPORT jint JNICALL Java_com_apple_dnssd_AppleRecordRegistrar_RegisterRecord( JNIEnv *pEnv, jobject pThis, 
+                                                       jint flags, jint ifIndex, jstring fullname, jint rrType, jint rrClass, 
+                                                       jbyteArray rData, jint ttl, jobject destObj)
+{
+       jclass                                  cls = (*pEnv)->GetObjectClass( pEnv, pThis);
+       jfieldID                                contextField = (*pEnv)->GetFieldID( pEnv, cls, "fNativeContext", "I");
+       jclass                                  destCls = (*pEnv)->GetObjectClass( pEnv, destObj);
+       jfieldID                                recField = (*pEnv)->GetFieldID( pEnv, destCls, "fRecord", "I");
+       const char                              *nameStr = SafeGetUTFChars( pEnv, fullname);
+       OpContext                               *pContext = NULL;
+       DNSServiceErrorType             err = kDNSServiceErr_NoError;
+       jbyte                                   *pBytes;
+       jsize                                   numBytes;
+       DNSRecordRef                    recRef;
+       RecordRegistrationRef   *regEnvelope;
+
+       if ( contextField != 0)
+               pContext = (OpContext*) (*pEnv)->GetIntField( pEnv, pThis, contextField);
+       if ( pContext == NULL || pContext->ServiceRef == NULL || nameStr == NULL)
+               return kDNSServiceErr_BadParam;
+
+       regEnvelope = calloc( 1, sizeof *regEnvelope);
+       if ( regEnvelope == NULL)
+               return kDNSServiceErr_NoMemory;
+       regEnvelope->Context = pContext;
+       regEnvelope->RecordObj = (*pEnv)->NewWeakGlobalRef( pEnv, destObj);     // must convert local ref to global to cache
+
+       pBytes = (*pEnv)->GetByteArrayElements( pEnv, rData, NULL);
+       numBytes = (*pEnv)->GetArrayLength( pEnv, rData);
+
+       err = DNSServiceRegisterRecord( pContext->ServiceRef, &recRef, flags, ifIndex, 
+                                                                       nameStr, rrType, rrClass, numBytes, pBytes, ttl,
+                                                                       RegisterRecordReply, regEnvelope);
+
+       if ( err == kDNSServiceErr_NoError)
+       {
+               (*pEnv)->SetIntField( pEnv, destObj, recField, (jint) recRef);
+       }
+       else
+       {
+               if ( regEnvelope->RecordObj != NULL)
+                       (*pEnv)->DeleteWeakGlobalRef( pEnv, regEnvelope->RecordObj);
+               free( regEnvelope);
+       }
+
+       if ( pBytes != NULL)
+               (*pEnv)->ReleaseByteArrayElements( pEnv, rData, pBytes, 0);
+
+       SafeReleaseUTFChars( pEnv, fullname, nameStr);
+
+       return err;
+}
+
+
 static void DNSSD_API  ServiceQueryReply( DNSServiceRef sdRef _UNUSED, DNSServiceFlags flags, uint32_t interfaceIndex,
                                                                DNSServiceErrorType errorCode, const char *serviceName,
                                                                uint16_t rrtype, uint16_t rrclass, uint16_t rdlen,
@@ -846,7 +972,7 @@ JNIEXPORT jstring JNICALL Java_com_apple_dnssd_AppleDNSSD_GetNameForIfIndex( JNI
 {
        char                                    *p = LOCAL_ONLY_NAME, nameBuff[IF_NAMESIZE];
 
-       if (ifIndex != kDNSServiceInterfaceIndexLocalOnly)
+       if (ifIndex != (jint) kDNSServiceInterfaceIndexLocalOnly)
                p = if_indextoname( ifIndex, nameBuff );
 
        return (*pEnv)->NewStringUTF( pEnv, p);
index 7ece74cf449c67c60b9c279407a0a9ea8aa1a3ad..042798c339262c9b26f76adf99f875fa2073f657 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: QueryListener.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/04/30 21:48:27  rpantos
 Change line endings for CVS.
 
index a6cf33191dff1529f482dd3e79c446cab86a91ae..ea573f0152d626661f8e0670368e609cca5967c3 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: RegisterListener.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/04/30 21:48:27  rpantos
 Change line endings for CVS.
 
diff --git a/mDNSShared/Java/RegisterRecordListener.java b/mDNSShared/Java/RegisterRecordListener.java
new file mode 100644 (file)
index 0000000..247e5d5
--- /dev/null
@@ -0,0 +1,48 @@
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
+ * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ *
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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.
+
+    Change History (most recent first):
+
+$Log: RegisterRecordListener.java,v $
+Revision 1.2  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.1  2006/06/20 23:00:12  rpantos
+<rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
+
+
+ */
+
+
+package        com.apple.dnssd;
+
+
+/**    A listener that receives results from {@link DNSSDRecordRegistrar#registerRecord}. */
+
+public interface RegisterRecordListener extends BaseListener
+{
+       /** Called when a record registration succeeds.<P> 
+
+               @param  record
+                                       A {@link DNSRecord}. 
+               <P>
+               @param  flags
+                                       Currently ignored, reserved for future use.
+               <P>
+       */
+       void    recordRegistered( DNSRecord record, int flags);
+}
+
index 0e213531178d557789c6f31c2e3e89d2a4648df5..168edb21f29d5a6f58240c20ff6780935019275f 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: ResolveListener.java,v $
+Revision 1.3  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/04/30 21:48:27  rpantos
 Change line endings for CVS.
 
index 5eed93eb74b44179ab9313d6fa999bce13a7b3d9..9dbe14e021948c4a60cc2f36bdd9afa5e27948fd 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: Java; tab-width: 4 -*-
+ *
  * Copyright (c) 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: TXTRecord.java,v $
+Revision 1.6  2006/08/14 23:25:08  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  2004/08/25 21:54:36  rpantos
 <rdar://problem/3773973> Fix getValue() for values containing '='.
 
index 6ec40da052ad9c2a8856cb36a3e852db4e4f1d79..d6385b5989d3f6864d41029967b181aaca84654d 100644 (file)
@@ -2,28 +2,24 @@
  *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
- *
- * 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.
- *
- * 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
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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: PlatformCommon.c,v $
+Revision 1.7  2006/08/14 23:24:56  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.6  2005/04/08 21:30:16  ksekar
 <rdar://problem/4007457> Compiling problems with mDNSResponder-98 on Solaris/Sparc v9
 Patch submitted by Bernd Kuhls
index 46a672ad66b4b591347dd11f526fbabfc8c9a1b2..ed18d857d95de941c88882c94e8bf7fdb1f88094 100644 (file)
@@ -2,28 +2,24 @@
  *
  * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
- *
- * 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.
- *
- * 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
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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: PlatformCommon.h,v $
+Revision 1.4  2006/08/14 23:24:56  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/01/19 19:19:21  ksekar
 <rdar://problem/3960191> Need a way to turn off domain discovery
 
index 6089ae655a07bafec13b1b50efb9dff2618b4cc4..0e4e2b6ffe4fdf4be0b5c5c9ac36c5b7a2df4720 100644 (file)
@@ -1,25 +1,23 @@
+.\" -*- tab-width: 4 -*-
+.\" 
 .\" Copyright (c) 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@
 .\"
 .\" $Log: dns-sd.1,v $
+.\" Revision 1.6  2006/08/14 23:24:56  cheshire
+.\" Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+.\"
 .\" Revision 1.5  2005/07/04 23:12:35  cheshire
 .\" <rdar://problem/4103628> The dns-sd command first appeared in Mac OS X 10.4 (Tiger)
 .\"
index 3fd58ef309c7d51048fabd519f90f1829617224d..b7eb8a229a41ae3dc69691dbf2be2bc8cc3d5811 100755 (executable)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
@@ -42,7 +43,7 @@
 #endif
 
 /* stdint.h does not exist on FreeBSD 4.x; its types are defined in sys/types.h instead */
-#if defined(__FreeBSD_version) && (__FreeBSD_version < 500000)
+#if defined(__FreeBSD__) && (__FreeBSD__ < 5)
 #include <sys/types.h>
 
 /* Likewise, on Sun, standard integer types are in sys/types.h */
@@ -145,10 +146,15 @@ enum
      * (queries from hosts more than one hop away; hosts not directly connected to the local link).
      */
 
-    kDNSServiceFlagsForceMulticast      = 0x400
+    kDNSServiceFlagsForceMulticast      = 0x400,
     /* Flag for signifying that a query or registration should be performed exclusively via multicast DNS,
      * even for a name in a domain (e.g. foo.apple.com.) that would normally imply unicast DNS.
      */
+     
+    kDNSServiceFlagsReturnCNAME         = 0x800
+    /* Flag for returning CNAME records in the DNSServiceQueryRecord call. CNAME records are
+     * normally followed without indicating to the client that there was a CNAME record.
+     */
     };
 
 /*
@@ -196,7 +202,7 @@ enum
     kDNSServiceType_KEY       = 25,     /* Security key. */
     kDNSServiceType_PX        = 26,     /* X.400 mail mapping. */
     kDNSServiceType_GPOS      = 27,     /* Geographical position (withdrawn). */
-    kDNSServiceType_AAAA      = 28,     /* Ip6 Address. */
+    kDNSServiceType_AAAA      = 28,     /* IPv6 Address. */
     kDNSServiceType_LOC       = 29,     /* Location Information. */
     kDNSServiceType_NXT       = 30,     /* Next domain (security). */
     kDNSServiceType_EID       = 31,     /* Endpoint identifier. */
@@ -206,7 +212,7 @@ enum
     kDNSServiceType_NAPTR     = 35,     /* Naming Authority PoinTeR */
     kDNSServiceType_KX        = 36,     /* Key Exchange */
     kDNSServiceType_CERT      = 37,     /* Certification record */
-    kDNSServiceType_A6        = 38,     /* IPv6 address (deprecates AAAA) */
+    kDNSServiceType_A6        = 38,     /* IPv6 Address (deprecated) */
     kDNSServiceType_DNAME     = 39,     /* Non-terminal DNAME (for IPv6) */
     kDNSServiceType_SINK      = 40,     /* Kitchen sink (experimentatl) */
     kDNSServiceType_OPT       = 41,     /* EDNS0 option (meta-RR) */
@@ -318,7 +324,7 @@ enum
  * 
  * If the client passes 0 for interface index, that means "do the right thing",
  * which (at present) means, "if the name is in an mDNS local multicast domain
- * (e.g. 'local.', '254.169.in-addr.arpa.', '0.8.E.F.ip6.arpa.') then multicast
+ * (e.g. 'local.', '254.169.in-addr.arpa.', '{8,9,A,B}.E.F.ip6.arpa.') then multicast
  * on all applicable interfaces, otherwise send via unicast to the appropriate
  * DNS server." Normally, most clients will use 0 for interface index to
  * automatically get the default sensible behaviour.
@@ -623,6 +629,9 @@ typedef void (DNSSD_API *DNSServiceRegisterReply)
  *                  i.e. it creates a TXT record of length one containing a single empty string.
  *                  RFC 1035 doesn't allow a TXT record to contain *zero* strings, so a single empty
  *                  string is the smallest legal DNS TXT record.
+ *                  As with the other parameters, the DNSServiceRegister call copies the txtRecord
+ *                  data; e.g. if you allocated the storage for the txtRecord parameter with malloc()
+ *                  then you can safely free that memory right after the DNSServiceRegister call returns.
  *
  * callBack:        The function to be called when the registration completes or asynchronously
  *                  fails.  The client MAY pass NULL for the callback -  The client will NOT be notified
@@ -638,7 +647,6 @@ typedef void (DNSSD_API *DNSServiceRegisterReply)
  *                  errors are delivered to the callback), otherwise returns an error code indicating
  *                  the error that occurred (the callback is never invoked and the DNSServiceRef
  *                  is not initialized.)
- *
  */
 
 DNSServiceErrorType DNSSD_API DNSServiceRegister
@@ -665,6 +673,12 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister
  * The record can later be updated or deregistered by passing the RecordRef initialized
  * by this function to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
  *
+ * Note that the DNSServiceAddRecord/UpdateRecord/RemoveRecord are *NOT* thread-safe
+ * with respect to a single DNSServiceRef. If you plan to have multiple threads
+ * in your program simultaneously add, update, or remove records from the same
+ * DNSServiceRef, then it's the caller's responsibility to use a mutext lock
+ * or take similar appropriate precautions to serialize those calls.
+ *
  *
  * Parameters;
  *
@@ -914,9 +928,23 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse
  *
  * txtRecord:       The service's primary txt record, in standard txt record format.
  *
-
  * context:         The context pointer that was passed to the callout.
  *
+ * NOTE: In earlier versions of this header file, the txtRecord parameter was declared "const char *"
+ * This is incorrect, since it contains length bytes which are values in the range 0 to 255, not -128 to +127.
+ * Depending on your compiler settings, this change may cause signed/unsigned mismatch warnings.
+ * These should be fixed by updating your own callback function definition to match the corrected
+ * function signature using "const unsigned char *txtRecord". Making this change may also fix inadvertent
+ * bugs in your callback function, where it could have incorrectly interpreted a length byte with value 250
+ * as being -6 instead, with various bad consequences ranging from incorrect operation to software crashes.
+ * If you need to maintain portable code that will compile cleanly with both the old and new versions of
+ * this header file, you should update your callback function definition to use the correct unsigned value,
+ * and then in the place where you pass your callback function to DNSServiceResolve(), use a cast to eliminate
+ * the compiler warning, e.g.:
+ *   DNSServiceResolve(sd, flags, index, name, regtype, domain, (DNSServiceResolveReply)MyCallback, context);
+ * This will ensure that your code compiles cleanly without warnings (and more importantly, works correctly)
+ * with both the old header and with the new corrected version.
+ *
  */
 
 typedef void (DNSSD_API *DNSServiceResolveReply)
@@ -929,7 +957,7 @@ typedef void (DNSSD_API *DNSServiceResolveReply)
     const char                          *hosttarget,
     uint16_t                            port,
     uint16_t                            txtLen,
-    const char                          *txtRecord,
+    const unsigned char                 *txtRecord,
     void                                *context
     );
 
@@ -1022,7 +1050,7 @@ DNSServiceErrorType DNSSD_API DNSServiceCreateConnection(DNSServiceRef *sdRef);
  * DNSServiceRegisterRecordReply() parameters:
  *
  * sdRef:           The connected DNSServiceRef initialized by
- *                  DNSServiceDiscoveryConnect().
+ *                  DNSServiceCreateConnection().
  *
  * RecordRef:       The DNSRecordRef initialized by DNSServiceRegisterRecord().  If the above
  *                  DNSServiceRef is passed to DNSServiceRefDeallocate(), this DNSRecordRef is
@@ -1237,7 +1265,7 @@ DNSServiceErrorType DNSSD_API DNSServiceQueryRecord
  *
  */
 
-void DNSSD_API DNSServiceReconfirmRecord
+DNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord
     (
     DNSServiceFlags                    flags,
     uint32_t                           interfaceIndex,
@@ -1443,7 +1471,6 @@ DNSServiceErrorType DNSSD_API TXTRecordSetValue
  * return value:    Returns kDNSServiceErr_NoError on success.
  *                  Returns kDNSServiceErr_NoSuchKey if the "key" does not
  *                  exist in the TXTRecordRef.
- *
  */
 
 DNSServiceErrorType DNSSD_API TXTRecordRemoveValue
@@ -1463,7 +1490,6 @@ DNSServiceErrorType DNSSD_API TXTRecordRemoveValue
  *                  which you can pass directly to DNSServiceRegister() or
  *                  to DNSServiceUpdateRecord().
  *                  Returns 0 if the TXTRecordRef is empty.
- *
  */
 
 uint16_t DNSSD_API TXTRecordGetLength
@@ -1481,7 +1507,6 @@ uint16_t DNSSD_API TXTRecordGetLength
  * return value:    Returns a pointer to the raw bytes inside the TXTRecordRef
  *                  which you can pass directly to DNSServiceRegister() or
  *                  to DNSServiceUpdateRecord().
- *
  */
 
 const void * DNSSD_API TXTRecordGetBytesPtr
@@ -1536,7 +1561,6 @@ const void * DNSSD_API TXTRecordGetBytesPtr
  *
  * return value:    Returns 1 if the TXT Record contains the specified key.
  *                  Otherwise, it returns 0.
- *
  */
 
 int DNSSD_API TXTRecordContainsKey
index 12009f68574e9b0ff26586a818b102bb28afe7c6..796ca84ce56e632ea1ec6ae4ce98cb22d3fce30c 100644 (file)
@@ -1,25 +1,23 @@
+.\" -*- tab-width: 4 -*-
+.\" 
 .\" Copyright (c) 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@
 .\"
 .\" $Log: dnsextd.8,v $
+.\" Revision 1.2  2006/08/14 23:24:56  cheshire
+.\" Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+.\"
 .\" Revision 1.1  2004/08/15 18:49:18  cheshire
 .\" <rdar://problem/3763030> No man page for dnsextd
 .\"
diff --git a/mDNSShared/dnsextd.c b/mDNSShared/dnsextd.c
new file mode 100644 (file)
index 0000000..be795c5
--- /dev/null
@@ -0,0 +1,2118 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
+ *
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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.
+
+    Change History (most recent first):
+
+$Log: dnsextd.c,v $
+Revision 1.33.2.2  2006/08/29 06:24:36  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.33.2.1  2005/08/05 21:14:00  ksekar
+<rdar://problem/4012279> Long-lived queries not working on windows
+Change constant names
+
+Revision 1.33  2005/03/11 19:09:02  ksekar
+Fixed ZERO_LLQID macro
+
+Revision 1.32  2005/03/10 22:54:33  ksekar
+<rdar://problem/4046285> dnsextd leaks memory/ports
+
+Revision 1.31  2005/02/24 02:37:57  ksekar
+<rdar://problem/4021977> dnsextd memory management improvements
+
+Revision 1.30  2005/01/27 22:57:56  cheshire
+Fix compile errors on gcc4
+
+Revision 1.29  2004/12/22 00:13:50  ksekar
+<rdar://problem/3873993> Change version, port, and polling interval for LLQ
+
+Revision 1.28  2004/12/17 00:30:00  ksekar
+<rdar://problem/3924045> dnsextd memory leak
+
+Revision 1.27  2004/12/17 00:27:32  ksekar
+Ignore SIGPIPE
+
+Revision 1.26  2004/12/17 00:21:33  ksekar
+Fixes for new CacheRecord structure with indirect name pointer
+
+Revision 1.25  2004/12/16 20:13:02  cheshire
+<rdar://problem/3324626> Cache memory management improvements
+
+Revision 1.24  2004/12/14 17:09:06  ksekar
+fixed incorrect usage instructions
+
+Revision 1.23  2004/12/06 20:24:31  ksekar
+<rdar://problem/3907303> dnsextd leaks sockets
+
+Revision 1.22  2004/12/03 20:20:29  ksekar
+<rdar://problem/3904149> dnsextd: support delivery of large records via LLQ events
+
+Revision 1.21  2004/12/03 06:11:34  ksekar
+<rdar://problem/3885059> clean up dnsextd arguments
+
+Revision 1.20  2004/12/01 04:27:28  cheshire
+<rdar://problem/3872803> Darwin patches for Solaris and Suse
+Don't use uint32_t, etc. -- they require stdint.h, which doesn't exist on FreeBSD 4.x, Solaris, etc.
+
+Revision 1.19  2004/12/01 01:16:29  cheshire
+Solaris compatibility fixes
+
+Revision 1.18  2004/11/30 23:51:06  cheshire
+Remove double semicolons
+
+Revision 1.17  2004/11/30 22:37:01  cheshire
+Update copyright dates and add "Mode: C; tab-width: 4" headers
+
+Revision 1.16  2004/11/25 02:02:28  ksekar
+Fixed verbose log message argument
+
+Revision 1.15  2004/11/19 02:35:02  ksekar
+<rdar://problem/3886317> Wide Area Security: Add LLQ-ID to events
+
+Revision 1.14  2004/11/17 06:17:58  cheshire
+Update comments to show correct SRV names: _dns-update._udp.<zone>. and _dns-llq._udp.<zone>.
+
+Revision 1.13  2004/11/13 02:22:36  ksekar
+<rdar://problem/3878201> Refresh Acks from daemon malformatted
+
+Revision 1.12  2004/11/12 01:05:01  ksekar
+<rdar://problem/3876757> dnsextd: daemon registers the SRV same record
+twice at startup
+
+Revision 1.11  2004/11/12 01:03:31  ksekar
+<rdar://problem/3876776> dnsextd: KnownAnswers (CacheRecords) leaked
+
+Revision 1.10  2004/11/12 00:35:28  ksekar
+<rdar://problem/3876705> dnsextd: uninitialized pointer can cause crash
+
+Revision 1.9  2004/11/10 20:38:17  ksekar
+<rdar://problem/3874168> dnsextd: allow a "fudge" in LLQ lease echo
+
+Revision 1.8  2004/11/01 17:48:14  cheshire
+Changed SOA serial number back to signed. RFC 1035 may describe it as "unsigned", but
+it's wrong. The SOA serial is a modular counter, as explained in "DNS & BIND", page
+137. Since C doesn't have a modular type, we used signed, C's closest approximation.
+
+Revision 1.7  2004/10/30 00:06:58  ksekar
+<rdar://problem/3722535> Support Long Lived Queries in DNS Extension daemon
+
+Revision 1.6  2004/09/17 01:08:54  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.5  2004/09/16 00:50:54  cheshire
+Don't use MSG_WAITALL -- it returns "Invalid argument" on some Linux versions
+
+Revision 1.4  2004/09/14 23:27:48  cheshire
+Fix compile errors
+
+Revision 1.3  2004/09/02 01:39:40  cheshire
+For better readability, follow consistent convention that QR bit comes first, followed by OP bits
+
+Revision 1.2  2004/08/24 23:27:57  cheshire
+Fixes for Linux compatibility:
+Don't use strings.h
+Don't assume SIGINFO
+Don't try to set servaddr.sin_len on platforms that don't have sa_len
+
+Revision 1.1  2004/08/11 00:43:26  ksekar
+<rdar://problem/3722542>: DNS Extension daemon for DNS Update Lease
+
+*/
+
+#include "../mDNSCore/mDNSEmbeddedAPI.h"
+#include "../mDNSCore/DNSCommon.h"
+#include "../mDNSCore/mDNS.c"
+//!!!KRS we #include mDNS.c for the various constants defined there  - we should move these to DNSCommon.h
+
+#include <signal.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+#include <errno.h>
+
+// Compatibility workaround
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif
+
+//
+// Constants
+//
+
+#define LOOPBACK "127.0.0.1"
+#define NS_PORT 53
+#define DAEMON_PORT 5352                // default, may be overridden via command line argument
+#define LISTENQ 128                     // tcp connection backlog
+#define RECV_BUFLEN 9000                
+#define LEASETABLE_INIT_NBUCKETS 256    // initial hashtable size (doubles as table fills)
+#define LLQ_TABLESIZE 1024              // !!!KRS make this dynamically growable
+#define EXPIRATION_INTERVAL 300          // check for expired records every 5 minutes
+#define SRV_TTL 7200                    // TTL For _dns-update SRV records
+
+// LLQ Lease bounds (seconds)
+#define LLQ_MIN_LEASE (15 * 60)
+#define LLQ_MAX_LEASE (120 * 60)
+#define LLQ_LEASE_FUDGE 60
+
+// LLQ SOA poll interval (microseconds)
+#define LLQ_MONITOR_ERR_INTERVAL (60 * 1000000)
+#define LLQ_MONITOR_INTERVAL 250000
+#ifdef SIGINFO
+#define INFO_SIGNAL SIGINFO
+#else
+#define INFO_SIGNAL SIGUSR1
+#endif
+
+#define SAME_INADDR(x,y) (*((mDNSu32 *)&x) == *((mDNSu32 *)&y))
+#define ZERO_LLQID(x) (!memcmp(x, "\x0\x0\x0\x0\x0\x0\x0\x0", 8))
+
+//
+// Data Structures
+// Structs/fields that must be locked for thread safety are explicitly commented
+//
+
+typedef struct
+       {
+    struct sockaddr_in src;
+    size_t len;
+    DNSMessage msg;
+    // Note: extra storage for oversized (TCP) messages goes here
+       } PktMsg;
+
+// lease table entry
+typedef struct RRTableElem
+       {
+    struct RRTableElem *next;
+    struct sockaddr_in cli;   // client's source address
+    long expire;              // expiration time, in seconds since epoch
+    domainname zone;          // from zone field of update message
+    domainname name;          // name of the record
+    CacheRecord rr;           // last field in struct allows for allocation of oversized RRs
+       } RRTableElem;
+
+typedef enum
+       {
+       RequestReceived = 0,
+       ChallengeSent   = 1,
+       Established     = 2
+       } LLQState;
+
+typedef struct AnswerListElem
+       {
+    struct AnswerListElem *next;
+    domainname name;
+    mDNSu16 type;
+    CacheRecord *KnownAnswers;  // All valid answers delivered to client
+    CacheRecord *EventList;     // New answers (adds/removes) to be sent to client
+    int refcount;          
+       } AnswerListElem;
+
+// llq table entry
+typedef struct LLQEntry
+       {
+    struct LLQEntry *next;     
+    struct sockaddr_in cli;   // clien'ts source address 
+    domainname qname;
+    mDNSu16 qtype;
+    mDNSu8 id[8];
+    LLQState state;
+    mDNSu32 lease;            // original lease, in seconds
+    mDNSs32 expire;           // expiration, absolute, in seconds since epoch
+    AnswerListElem *AnswerList;
+       } LLQEntry;
+
+// daemon-wide information
+typedef struct 
+       {
+    // server variables - read only after initialization (no locking)
+    struct in_addr saddr;      // server address
+    domainname zone;           // zone being updated
+    int tcpsd;                 // listening TCP socket
+    int udpsd;                 // listening UDP socket
+
+    // daemon variables - read only after initialization (no locking)
+    uDNS_AuthInfo *AuthInfo;   // linked list of keys for signing deletion updates
+    mDNSIPPort port;           // listening port
+
+    // lease table variables (locked via mutex after initialization)
+    RRTableElem **table;       // hashtable for records with leases
+    pthread_mutex_t tablelock; // mutex for lease table
+    mDNSs32 nbuckets;          // buckets allocated
+    mDNSs32 nelems;            // elements in table
+
+    // LLQ table variables
+    LLQEntry *LLQTable[LLQ_TABLESIZE];  // !!!KRS change this and RRTable to use a common data structure
+    AnswerListElem *AnswerTable[LLQ_TABLESIZE];
+    int LLQEventListenSock;       // Unix domain socket pair - polling thread writes to ServPollSock, which wakes
+    int LLQServPollSock;          // the main thread listening on EventListenSock, indicating that the zone has changed
+       } DaemonInfo;
+
+// args passed to UDP request handler thread as void*
+typedef struct
+       {
+    PktMsg pkt;
+    struct sockaddr_in cliaddr;
+    DaemonInfo *d;
+       } UDPRequestArgs;
+
+// args passed to TCP request handler thread as void*
+typedef struct
+       {
+    int sd;                     // socket connected to client
+    struct sockaddr_in cliaddr; 
+    DaemonInfo *d;
+       } TCPRequestArgs;
+
+//
+// Global Variables
+//
+
+// booleans to determine runtime output
+// read-only after initialization (no mutex protection)
+static mDNSBool foreground = 0;
+static mDNSBool verbose = 0;
+
+// globals set via signal handler (accessed exclusively by main select loop and signal handler)
+static mDNSBool terminate = 0;
+static mDNSBool dumptable = 0;
+
+//
+// Logging Routines
+// Log messages are delivered to syslog unless -f option specified
+//
+
+// common message logging subroutine
+mDNSlocal void PrintLog(const char *buffer)
+       {
+       if (foreground) 
+               {
+               fprintf(stderr,"%s\n", buffer);
+               fflush(stderr);
+               }
+       else                            
+               {
+               openlog("dnsextd", LOG_CONS | LOG_PERROR, LOG_DAEMON);
+               syslog(LOG_ERR, "%s", buffer);
+               closelog();
+               }
+       }
+
+// Verbose Logging (conditional on -v option)
+mDNSlocal void VLog(const char *format, ...)
+       {
+       char buffer[512];
+       va_list ptr;
+
+       if (!verbose) return;
+       va_start(ptr,format);
+       buffer[mDNS_vsnprintf((char *)buffer, sizeof(buffer), format, ptr)] = 0;
+       va_end(ptr);
+       PrintLog(buffer);
+       }
+
+// Unconditional Logging
+mDNSlocal void Log(const char *format, ...)
+       {
+       char buffer[512];
+       va_list ptr;
+
+       va_start(ptr,format);
+       buffer[mDNS_vsnprintf((char *)buffer, sizeof(buffer), format, ptr)] = 0;
+       va_end(ptr);
+       PrintLog(buffer);
+       }
+
+// Error Logging
+// prints message "dnsextd <function>: <operation> - <error message>" 
+// must be compiled w/ -D_REENTRANT  for thread-safe errno usage
+mDNSlocal void LogErr(const char *fn, const char *operation)
+       {
+       char buf[512];
+       snprintf(buf, sizeof(buf), "%s: %s - %s", fn, operation, strerror(errno));
+       PrintLog(buf);
+       }
+
+//
+// Networking Utility Routines
+//
+
+// Convert DNS Message Header from Network to Host byte order
+mDNSlocal void HdrNToH(PktMsg *pkt)
+       {
+       // Read the integer parts which are in IETF byte-order (MSB first, LSB second)
+       mDNSu8 *ptr = (mDNSu8 *)&pkt->msg.h.numQuestions;
+       pkt->msg.h.numQuestions   = (mDNSu16)((mDNSu16)ptr[0] <<  8 | ptr[1]);
+       pkt->msg.h.numAnswers     = (mDNSu16)((mDNSu16)ptr[2] <<  8 | ptr[3]);
+       pkt->msg.h.numAuthorities = (mDNSu16)((mDNSu16)ptr[4] <<  8 | ptr[5]);
+       pkt->msg.h.numAdditionals = (mDNSu16)((mDNSu16)ptr[6] <<  8 | ptr[7]);
+       }
+
+// Convert DNS Message Header from Host to Network byte order
+mDNSlocal void HdrHToN(PktMsg *pkt)
+       {
+       mDNSu16 numQuestions   = pkt->msg.h.numQuestions;
+       mDNSu16 numAnswers     = pkt->msg.h.numAnswers;
+       mDNSu16 numAuthorities = pkt->msg.h.numAuthorities;
+       mDNSu16 numAdditionals = pkt->msg.h.numAdditionals;
+       mDNSu8 *ptr = (mDNSu8 *)&pkt->msg.h.numQuestions;
+
+       // Put all the integer values in IETF byte-order (MSB first, LSB second)
+       *ptr++ = (mDNSu8)(numQuestions   >> 8);
+       *ptr++ = (mDNSu8)(numQuestions   &  0xFF);
+       *ptr++ = (mDNSu8)(numAnswers     >> 8);
+       *ptr++ = (mDNSu8)(numAnswers     &  0xFF);
+       *ptr++ = (mDNSu8)(numAuthorities >> 8);
+       *ptr++ = (mDNSu8)(numAuthorities &  0xFF);
+       *ptr++ = (mDNSu8)(numAdditionals >> 8);
+       *ptr++ = (mDNSu8)(numAdditionals &  0xFF);
+       }
+
+// create a socket connected to nameserver
+// caller terminates connection via close()
+mDNSlocal int ConnectToServer(DaemonInfo *d)
+       {
+       struct sockaddr_in servaddr;
+       int sd;
+       
+       bzero(&servaddr, sizeof(servaddr));
+       if (d->saddr.s_addr) servaddr.sin_addr = d->saddr;
+       else                 inet_pton(AF_INET, LOOPBACK, &d->saddr);  // use loopback if server not explicitly specified                       
+       servaddr.sin_port = htons(NS_PORT);
+       servaddr.sin_family = AF_INET;
+#ifndef NOT_HAVE_SA_LEN
+       servaddr.sin_len = sizeof(servaddr); 
+#endif
+       sd = socket(AF_INET, SOCK_STREAM, 0);
+       if (sd < 0) { LogErr("ConnectToServer", "socket");  return -1; }
+       if (connect(sd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) { LogErr("ConnectToServer", "connect"); return -1; }
+       return sd;
+       }
+
+// send an entire block of data over a connected socket, blocking if buffers are full
+mDNSlocal int MySend(int sd, const void *msg, int len)
+       {
+       int n, nsent = 0;
+
+       while (nsent < len)
+               {
+               n = send(sd, (char *)msg + nsent, len - nsent, 0);
+               if (n < 0) { LogErr("MySend", "send");  return -1; }
+               nsent += n;
+               }
+       return 0;
+       }
+
+// Transmit a DNS message, prefixed by its length, over TCP, blocking if necessary
+mDNSlocal int SendTCPMsg(int sd, PktMsg *pkt)
+       {
+       // send the lenth, in network byte order
+       mDNSu16 len = htons((mDNSu16)pkt->len);
+       if (MySend(sd, &len, sizeof(len)) < 0) return -1;
+
+       // send the message
+       return MySend(sd, &pkt->msg, pkt->len);
+       }
+
+// Receive len bytes, waiting until we have all of them.
+// Returns number of bytes read (which should always be the number asked for).
+static int my_recv(const int sd, void *const buf, const int len)
+    {
+    // Don't use "MSG_WAITALL"; it returns "Invalid argument" on some Linux versions;
+    // use an explicit while() loop instead.
+    // Also, don't try to do '+=' arithmetic on the original "void *" pointer --
+    // arithmetic on "void *" pointers is compiler-dependent.
+    int remaining = len;
+    char *ptr = (char *)buf;
+    while (remaining)
+       {
+       ssize_t num_read = recv(sd, ptr, remaining, 0);
+       if ((num_read == 0) || (num_read < 0) || (num_read > remaining)) return -1;
+       ptr       += num_read;
+       remaining -= num_read;
+       }
+    return(len);
+    }
+
+// Return a DNS Message read off of a TCP socket, or NULL on failure
+// If storage is non-null, result is placed in that buffer.  Otherwise,
+// returned value is allocated with Malloc, and contains sufficient extra
+// storage for a Lease OPT RR
+
+mDNSlocal PktMsg *ReadTCPMsg(int sd, PktMsg *storage)
+       {       
+       int nread, allocsize;
+       mDNSu16 msglen = 0;     
+       PktMsg *pkt = NULL;
+       unsigned int srclen;
+       
+       nread = my_recv(sd, &msglen, sizeof(msglen));
+       if (nread < 0) { LogErr("TCPRequestForkFn", "recv"); goto error; }
+       msglen = ntohs(msglen);
+       if (nread != sizeof(msglen)) { Log("Could not read length field of message"); goto error; }     
+
+       if (storage)
+               {
+               if (msglen > sizeof(storage->msg)) { Log("ReadTCPMsg: provided buffer too small."); goto error; }
+               pkt = storage;
+               }
+       else
+               {
+               // buffer extra space to add an OPT RR
+               if (msglen > sizeof(DNSMessage)) allocsize = sizeof(PktMsg) - sizeof(DNSMessage) + msglen;
+               else                             allocsize = sizeof(PktMsg);            
+               pkt = malloc(allocsize);
+               if (!pkt) { LogErr("ReadTCPMsg", "malloc"); goto error; }
+               bzero(pkt, sizeof(*pkt));
+               }
+       
+       pkt->len = msglen;
+       srclen = sizeof(pkt->src);
+       if (getpeername(sd, (struct sockaddr *)&pkt->src, &srclen) ||
+               srclen != sizeof(pkt->src)) { LogErr("ReadTCPMsg", "getpeername"); bzero(&pkt->src, sizeof(pkt->src)); }
+       nread = my_recv(sd, &pkt->msg, msglen);
+       if (nread < 0) { LogErr("TCPRequestForkFn", "recv"); goto error; }
+       if (nread != msglen) { Log("Could not read entire message"); goto error; }
+       if (pkt->len < sizeof(DNSMessageHeader))
+               { Log("ReadTCPMsg: Message too short (%d bytes)", pkt->len);  goto error; }     
+       HdrNToH(pkt);
+       return pkt;
+       //!!!KRS convert to HBO here?
+       error:
+       if (pkt && pkt != storage) free(pkt);
+       return NULL;
+       }
+
+//
+// Dynamic Update Utility Routines
+//
+
+// Get the lease life of records in a dynamic update
+// returns -1 on error or if no lease present
+mDNSlocal mDNSs32 GetPktLease(PktMsg *pkt)
+       {
+       mDNSs32 lease = -1;
+       const mDNSu8 *ptr = NULL, *end = (mDNSu8 *)&pkt->msg + pkt->len;
+       LargeCacheRecord lcr;
+       int i;
+       
+       HdrNToH(pkt);
+       ptr = LocateAdditionals(&pkt->msg, end);
+       if (ptr) 
+               for (i = 0; i < pkt->msg.h.numAdditionals; i++)
+                       {
+                       ptr = GetLargeResourceRecord(NULL, &pkt->msg, ptr, end, 0, kDNSRecordTypePacketAdd, &lcr);
+                       if (!ptr) { Log("Unable to read additional record"); break; }
+                       if (lcr.r.resrec.rrtype == kDNSType_OPT)
+                               {
+                               if (lcr.r.resrec.rdlength < LEASE_OPT_RDLEN) continue;
+                               if (lcr.r.resrec.rdata->u.opt.opt != kDNSOpt_Lease) continue;
+                               lease = (mDNSs32)lcr.r.resrec.rdata->u.opt.OptData.lease;
+                               break;
+                               }
+                       }
+
+       HdrHToN(pkt);
+       return lease;
+       }
+
+// check if a request and server response complete a successful dynamic update
+mDNSlocal mDNSBool SuccessfulUpdateTransaction(PktMsg *request, PktMsg *reply)
+       {
+       char buf[32];
+       char *vlogmsg = NULL;
+       
+       // check messages
+       if (!request || !reply) { vlogmsg = "NULL message"; goto failure; }
+       if (request->len < sizeof(DNSMessageHeader) || reply->len < sizeof(DNSMessageHeader)) { vlogmsg = "Malformatted message"; goto failure; }
+
+       // check request operation
+       if ((request->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask) != (request->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask))
+               { vlogmsg = "Request opcode not an update"; goto failure; }
+
+       // check result
+       if ((reply->msg.h.flags.b[1] & kDNSFlag1_RC)) { vlogmsg = "Reply contains non-zero rcode";  goto failure; }
+       if ((reply->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask) != (kDNSFlag0_OP_Update | kDNSFlag0_QR_Response))
+               { vlogmsg = "Reply opcode not an update response"; goto failure; }
+
+       VLog("Successful update from %s", inet_ntop(AF_INET, &request->src.sin_addr, buf, 32));
+       return mDNStrue;                
+
+       failure:
+       VLog("Request %s: %s", inet_ntop(AF_INET, &request->src.sin_addr, buf, 32), vlogmsg);
+       return mDNSfalse;
+       }
+
+// Allocate an appropriately sized CacheRecord and copy data from original.
+// Name pointer in CacheRecord object is set to point to the name specified
+//
+mDNSlocal CacheRecord *CopyCacheRecord(const CacheRecord *orig, domainname *name)
+       {
+       CacheRecord *cr;
+       size_t size = sizeof(*cr);
+       if (orig->resrec.rdlength > InlineCacheRDSize) size += orig->resrec.rdlength - InlineCacheRDSize;
+       cr = malloc(size);
+       if (!cr) { LogErr("CopyCacheRecord", "malloc"); return NULL; }
+       memcpy(cr, orig, size);
+       cr->resrec.rdata = (RData*)&cr->rdatastorage;
+       cr->resrec.name = name;
+       
+       return cr;
+       }
+
+
+//
+// Lease Hashtable Utility Routines
+//
+
+// double hash table size
+// caller must lock table prior to invocation
+mDNSlocal void RehashTable(DaemonInfo *d)
+       {
+       RRTableElem *ptr, *tmp, **new;
+       int i, bucket, newnbuckets = d->nbuckets * 2;
+
+       VLog("Rehashing lease table (new size %d buckets)", newnbuckets);
+       new = malloc(sizeof(RRTableElem *) * newnbuckets);
+       if (!new) { LogErr("RehashTable", "malloc");  return; }
+       bzero(new, newnbuckets * sizeof(RRTableElem *));
+
+       for (i = 0; i < d->nbuckets; i++)
+               {
+               ptr = d->table[i];
+               while (ptr)
+                       {
+                       bucket = ptr->rr.resrec.namehash % newnbuckets;
+                       tmp = ptr;
+                       ptr = ptr->next;
+                       tmp->next = new[bucket];
+                       new[bucket] = tmp;
+                       }
+               }
+       d->nbuckets = newnbuckets;
+       free(d->table);
+       d->table = new;
+       }
+
+// print entire contents of hashtable, invoked via SIGINFO
+mDNSlocal void PrintLeaseTable(DaemonInfo *d)
+       {
+       int i;
+       RRTableElem *ptr;
+       char rrbuf[80], addrbuf[16];
+       struct timeval now;
+       int hr, min, sec;
+
+       if (gettimeofday(&now, NULL)) { LogErr("PrintTable", "gettimeofday"); return; }
+       if (pthread_mutex_lock(&d->tablelock)) { LogErr("PrintTable", "pthread_mutex_lock"); return; }
+       
+       Log("Dumping Lease Table Contents (table contains %d resource records)", d->nelems);
+       for (i = 0; i < d->nbuckets; i++)
+               {
+               for (ptr = d->table[i]; ptr; ptr = ptr->next)
+                       {
+                       hr = ((ptr->expire - now.tv_sec) / 60) / 60;
+                       min = ((ptr->expire - now.tv_sec) / 60) % 60;
+                       sec = (ptr->expire - now.tv_sec) % 60;
+                       Log("Update from %s, Expires in %d:%d:%d\n\t%s", inet_ntop(AF_INET, &ptr->cli.sin_addr, addrbuf, 16), hr, min, sec,
+                               GetRRDisplayString_rdb(&ptr->rr.resrec, &ptr->rr.resrec.rdata->u, rrbuf));
+                       }
+               }
+       pthread_mutex_unlock(&d->tablelock);
+       }
+
+//
+// Startup SRV Registration Routines 
+// Register _dns-update._udp/_tcp.<zone> SRV records indicating the port on which
+// the daemon accepts requests  
+//
+
+// delete all RRS of a given name/type
+mDNSlocal mDNSu8 *putRRSetDeletion(DNSMessage *msg, mDNSu8 *ptr, mDNSu8 *limit,  ResourceRecord *rr)
+       {
+       ptr = putDomainNameAsLabels(msg, ptr, limit, rr->name);
+       if (!ptr || ptr + 10 >= limit) return NULL;  // out of space
+       ptr[0] = (mDNSu8)(rr->rrtype  >> 8);
+       ptr[1] = (mDNSu8)(rr->rrtype  &  0xFF);
+       ptr[2] = (mDNSu8)((mDNSu16)kDNSQClass_ANY >> 8);
+       ptr[3] = (mDNSu8)((mDNSu16)kDNSQClass_ANY &  0xFF);
+       bzero(ptr+4, sizeof(rr->rroriginalttl) + sizeof(rr->rdlength)); // zero ttl/rdata
+       msg->h.mDNS_numUpdates++;
+       return ptr + 10;
+       }
+
+mDNSlocal mDNSu8 *PutUpdateSRV(DaemonInfo *d, PktMsg *pkt, mDNSu8 *ptr, char *regtype, mDNSBool registration)
+       {
+       AuthRecord rr;
+       char hostname[1024], buf[80];
+       mDNSu8 *end = (mDNSu8 *)&pkt->msg + sizeof(DNSMessage);
+       
+       mDNS_SetupResourceRecord(&rr, NULL, 0, kDNSType_SRV, SRV_TTL, kDNSRecordTypeUnique, NULL, NULL);
+       rr.resrec.rrclass = kDNSClass_IN;
+       rr.resrec.rdata->u.srv.priority = 0;
+       rr.resrec.rdata->u.srv.weight = 0;
+       rr.resrec.rdata->u.srv.port.NotAnInteger = d->port.NotAnInteger;
+       if (!gethostname(hostname, 1024) < 0 || MakeDomainNameFromDNSNameString(&rr.resrec.rdata->u.srv.target, hostname))
+               rr.resrec.rdata->u.srv.target.c[0] = '\0';
+       
+       MakeDomainNameFromDNSNameString(rr.resrec.name, regtype);
+       AppendDomainName(rr.resrec.name, &d->zone);
+       VLog("%s  %s", registration ? "Registering SRV record" : "Deleting existing RRSet",
+                GetRRDisplayString_rdb(&rr.resrec, &rr.resrec.rdata->u, buf));
+       if (registration) ptr = PutResourceRecord(&pkt->msg, ptr, &pkt->msg.h.mDNS_numUpdates, &rr.resrec);
+       else              ptr = putRRSetDeletion(&pkt->msg, ptr, end, &rr.resrec);
+       return ptr;
+       }
+
+
+// perform dynamic update.
+// specify deletion by passing false for the register parameter, otherwise register the records.
+mDNSlocal int UpdateSRV(DaemonInfo *d, mDNSBool registration)
+       {
+       int sd = -1;
+       mDNSOpaque16 id;
+       PktMsg pkt;
+       mDNSu8 *ptr = pkt.msg.data;
+       mDNSu8 *end = (mDNSu8 *)&pkt.msg + sizeof(DNSMessage);
+       mDNSu16 nAdditHBO;  // num additionas, in host byte order, required by message digest routine
+       PktMsg *reply = NULL;
+
+       int result = -1;        
+
+       // Initialize message
+       id.NotAnInteger = 0;
+       InitializeDNSMessage(&pkt.msg.h, id, UpdateReqFlags);
+       pkt.src.sin_addr.s_addr = htonl(INADDR_ANY); // address field set solely for verbose logging in subroutines
+       pkt.src.sin_family = AF_INET;
+       
+       // format message body
+       ptr = putZone(&pkt.msg, ptr, end, &d->zone, mDNSOpaque16fromIntVal(kDNSClass_IN));
+       if (!ptr) goto end;
+
+       ptr = PutUpdateSRV(d, &pkt, ptr, "_dns-update._udp.", registration); if (!ptr) goto end;
+       ptr = PutUpdateSRV(d, &pkt, ptr, "_dns-update._tcp.", registration); if (!ptr) goto end;
+       ptr = PutUpdateSRV(d, &pkt, ptr, "_dns-llq._udp.", registration);    if (!ptr) goto end;        
+       
+       nAdditHBO = pkt.msg.h.numAdditionals;
+       HdrHToN(&pkt);
+       if (d->AuthInfo)
+               {
+               ptr = DNSDigest_SignMessage(&pkt.msg, &ptr, &nAdditHBO, d->AuthInfo);
+               if (!ptr) goto end;
+               }
+       pkt.len = ptr - (mDNSu8 *)&pkt.msg;
+       
+       // send message, receive reply
+       sd = ConnectToServer(d);
+       if (sd < 0) { Log("UpdateSRV: ConnectToServer failed"); goto end; }  
+       if (SendTCPMsg(sd, &pkt)) { Log("UpdateSRV: SendTCPMsg failed"); }
+       reply = ReadTCPMsg(sd, NULL);
+       if (!SuccessfulUpdateTransaction(&pkt, reply))
+               Log("SRV record registration failed with rcode %d", reply->msg.h.flags.b[1] & kDNSFlag1_RC);
+       else result = 0;
+       
+       end:
+       if (!ptr) { Log("UpdateSRV: Error constructing lease expiration update"); }
+       if (sd >= 0) close(sd); 
+       if (reply) free(reply);
+       return result;
+       }
+
+// wrapper routines/macros
+#define ClearUpdateSRV(d) UpdateSRV(d, 0)
+
+// clear any existing records prior to registration
+mDNSlocal int SetUpdateSRV(DaemonInfo *d)
+       {
+       int err;
+
+       err = ClearUpdateSRV(d);         // clear any existing record
+       if (!err) err = UpdateSRV(d, 1);
+       return err;
+       }
+
+//
+// Argument Parsing and Configuration
+//
+
+// read authentication information for a zone from command line argument
+// global optind corresponds to keyname argument on entry
+mDNSlocal int ReadAuthKey(int argc, char *argv[], DaemonInfo *d)
+       {
+       uDNS_AuthInfo *auth = NULL;
+       unsigned char keybuf[512];
+       mDNSs32 keylen;
+       
+       auth = malloc(sizeof(*auth));
+       if (!auth) { perror("ReadAuthKey, malloc");  goto error; }
+       auth->next = NULL;
+       if (argc < optind + 1) return -1;  // keyname + secret 
+       if (!MakeDomainNameFromDNSNameString(&auth->keyname, optarg))
+               { fprintf(stderr, "Bad key name %s", optarg); goto error; }
+       keylen = DNSDigest_Base64ToBin(argv[optind++], keybuf, 512);
+       if (keylen < 0)
+               { fprintf(stderr, "Bad shared secret %s (must be base-64 encoded string)", argv[optind-1]); goto error; }
+       DNSDigest_ConstructHMACKey(auth, keybuf, (mDNSu32)keylen);
+       d->AuthInfo = auth;
+       return 0;
+
+       error:
+       if (auth) free(auth);
+       return -1;      
+       }
+
+mDNSlocal int SetPort(DaemonInfo *d, char *PortAsString)
+       {
+       long l;
+
+       l = strtol(PortAsString, NULL, 10);                    // convert string to long
+       if ((!l && errno == EINVAL) || l > 65535) return -1;   // error check conversion
+       d->port.NotAnInteger = htons((mDNSu16)l);              // set to network byte order
+       return 0;
+       }
+       
+mDNSlocal void PrintUsage(void)
+       {
+       fprintf(stderr, "Usage: dnsextd -z <zone> [-vf] [ -s server ] [-k keyname secret] ...\n"
+                       "Use \"dnsextd -h\" for help\n");
+       }
+
+mDNSlocal void PrintHelp(void)
+       {
+       fprintf(stderr, "\n\n");
+       PrintUsage();
+
+       fprintf(stderr, 
+                       "dnsextd is a daemon that implements DNS extensions supporting Dynamic DNS Update Leases\n"
+            "and Long Lived Queries, used in Wide-Area DNS Service Discovery, on behalf of name servers\n"
+                       "that do not natively support these extensions.  (See dns-sd.org for more info on DNS Service\n"
+                       "Discovery, Update Leases, and Long Lived Queries.)\n\n"
+
+            "dnsextd requires one argument,the zone, which is the domain for which Update Leases\n"
+            "and Long Lived Queries are to be administered.  dnsextd communicates directly with the\n"
+                       "primary master server for this zone.\n\n"
+
+                       "The options are as follows:\n\n"
+
+                       "-f    Run daemon in foreground.\n\n"
+
+                       "-h    Print help.\n\n"
+
+                       "-k    Specify TSIG authentication key for dynamic updates from daemon to name server.\n"
+                       "      -k option is followed by the name of the key, and the shared secret as a base-64\n"
+            "      encoded string.  This key/secret are used by the daemon to delete resource records\n"
+            "      from the server when leases expire.  Clients are responsible for signing their\n"
+            "      update requests.\n\n"
+                       
+                       "-s    Specify address (IPv4 address in dotted-decimal notation) of the Primary Master\n"
+                       "      name server.  Defaults to loopback (127.0.0.1), i.e. daemon and name server\n"
+                       "      running on the same machine.\n\n"
+
+                       "-v    Verbose output.\n\n"
+               );                 
+       }
+
+// Note: ProcessArgs called before process is daemonized, and therefore must open no descriptors
+// returns 0 (success) if program is to continue execution
+// output control arguments (-f, -v) do not affect this routine
+mDNSlocal int ProcessArgs(int argc, char *argv[], DaemonInfo *d)
+       {
+       int opt;
+
+       if (argc < 2) goto arg_error;
+
+       d->port.NotAnInteger = htons(DAEMON_PORT);  // default, may be overriden by command option
+       while ((opt = getopt(argc, argv, "z:p:hfvs:k:")) != -1)
+               {
+               switch(opt)
+                       {
+                       case 'p': if (SetPort(d, optarg) < 0) goto arg_error;
+                                 break;
+
+                       case 'h': PrintHelp();    return -1;
+                       case 'f': foreground = 1; break;
+                       case 'v': verbose = 1;    break;
+                       case 's': if (!inet_pton(AF_INET, optarg, &d->saddr)) goto arg_error;
+                                     break;
+                       case 'k': if (ReadAuthKey(argc, argv, d) < 0) goto arg_error;
+                                     break;
+                       case 'z': if (!MakeDomainNameFromDNSNameString(&d->zone, optarg))
+                                         {
+                                                 fprintf(stderr, "Bad zone %s", optarg);
+                                                 goto arg_error;
+                                                 }
+                                     break;
+                       default:  goto arg_error;                               
+                       }
+               }
+               
+       if (!d->zone.c[0]) goto arg_error;  // zone is the only required argument
+       if (d->AuthInfo) AssignDomainName(&d->AuthInfo->zone, &d->zone); // if we have a shared secret, use it for the entire zone
+       return 0;
+       
+       arg_error:
+       PrintUsage();
+       return -1;
+       }
+
+
+//
+// Initialization Routines
+//
+
+// Allocate memory, initialize locks and bookkeeping variables
+mDNSlocal int InitLeaseTable(DaemonInfo *d)
+       {
+       if (pthread_mutex_init(&d->tablelock, NULL)) { LogErr("InitLeaseTable", "pthread_mutex_init"); return -1; }
+       d->nbuckets = LEASETABLE_INIT_NBUCKETS;
+       d->nelems = 0;
+       d->table = malloc(sizeof(RRTableElem *) * LEASETABLE_INIT_NBUCKETS);
+       if (!d->table) { LogErr("InitLeaseTable", "malloc"); return -1; }
+       bzero(d->table, sizeof(RRTableElem *) * LEASETABLE_INIT_NBUCKETS);
+       return 0;
+       }
+mDNSlocal int SetupSockets(DaemonInfo *daemon)
+       {
+       struct sockaddr_in daddr;
+       int sockpair[2];
+       
+       // set up sockets on which we receive requests
+       bzero(&daddr, sizeof(daddr));
+       daddr.sin_family = AF_INET;
+       daddr.sin_addr.s_addr = htonl(INADDR_ANY);
+
+       if (daemon->port.NotAnInteger) daddr.sin_port = daemon->port.NotAnInteger;
+       else                           daddr.sin_port = htons(DAEMON_PORT);
+       
+       daemon->tcpsd = socket(AF_INET, SOCK_STREAM, 0);
+       if (!daemon->tcpsd) { LogErr("SetupSockets", "socket");  return -1; }
+       if (bind(daemon->tcpsd, (struct sockaddr *)&daddr, sizeof(daddr)) < 0) { LogErr("SetupSockets", "bind"); return -1; }
+       if (listen(daemon->tcpsd, LISTENQ) < 0) { LogErr("SetupSockets", "listen"); return -1; }
+
+       daemon->udpsd = socket(AF_INET, SOCK_DGRAM, 0);
+       if (!daemon->udpsd) { LogErr("SetupSockets", "socket");  return -1; }
+       if (bind(daemon->udpsd, (struct sockaddr *)&daddr, sizeof(daddr)) < 0) { LogErr("SetupSockets", "bind"); return -1; }
+
+       // set up Unix domain socket pair for LLQ polling thread to signal main thread that a change to the zone occurred
+       if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockpair) < 0) { LogErr("SetupSockets", "socketpair"); return -1; }
+       daemon->LLQEventListenSock = sockpair[0];
+       daemon->LLQServPollSock = sockpair[1];
+       return 0;
+       }
+
+//
+// periodic table updates
+//
+
+// Delete a resource record from the nameserver via a dynamic update
+mDNSlocal void DeleteRecord(DaemonInfo *d, CacheRecord *rr, domainname *zone)
+       {
+       int sd = -1;
+       mDNSOpaque16 id;
+       PktMsg pkt;
+       mDNSu8 *ptr = pkt.msg.data;
+       mDNSu8 *end = (mDNSu8 *)&pkt.msg + sizeof(DNSMessage);
+       mDNSu16 nAdditHBO;  // num additionas, in host byte order, required by message digest routine
+       char buf[80];
+       PktMsg *reply = NULL;
+       
+       VLog("Expiring record %s", GetRRDisplayString_rdb(&rr->resrec, &rr->resrec.rdata->u, buf));     
+       sd = ConnectToServer(d);
+       if (sd < 0) { Log("DeleteRecord: ConnectToServer failed"); goto end; }
+       
+       id.NotAnInteger = 0;
+       InitializeDNSMessage(&pkt.msg.h, id, UpdateReqFlags);
+       
+       ptr = putZone(&pkt.msg, ptr, end, zone, mDNSOpaque16fromIntVal(rr->resrec.rrclass));
+       if (!ptr) goto end;
+       ptr = putDeletionRecord(&pkt.msg, ptr, &rr->resrec);
+       if (!ptr) goto end;
+
+       nAdditHBO = pkt.msg.h.numAdditionals;
+       HdrHToN(&pkt);
+
+       if (d->AuthInfo)
+               {
+               ptr = DNSDigest_SignMessage(&pkt.msg, &ptr, &nAdditHBO, d->AuthInfo);
+               if (!ptr) goto end;
+               }
+
+       pkt.len = ptr - (mDNSu8 *)&pkt.msg;
+       pkt.src.sin_addr.s_addr = htonl(INADDR_ANY); // address field set solely for verbose logging in subroutines
+       pkt.src.sin_family = AF_INET;
+       if (SendTCPMsg(sd, &pkt)) { Log("DeleteRecord: SendTCPMsg failed"); }
+       reply = ReadTCPMsg(sd, NULL);
+       if (!SuccessfulUpdateTransaction(&pkt, reply))
+               Log("Expiration update failed with rcode %d", reply->msg.h.flags.b[1] & kDNSFlag1_RC);
+                                         
+       end:
+       if (!ptr) { Log("DeleteRecord: Error constructing lease expiration update"); }
+       if (sd >= 0) close(sd); 
+       if (reply) free(reply);
+       }
+
+// iterate over table, deleting expired records
+mDNSlocal void DeleteExpiredRecords(DaemonInfo *d)
+       {
+       int i;
+       RRTableElem *ptr, *prev, *fptr; 
+       struct timeval now;
+
+       if (gettimeofday(&now, NULL)) { LogErr("DeleteExpiredRecords ", "gettimeofday"); return; }
+       if (pthread_mutex_lock(&d->tablelock)) { LogErr("DeleteExpiredRecords", "pthread_mutex_lock"); return; }
+       for (i = 0; i < d->nbuckets; i++)
+               {
+               ptr = d->table[i];
+               prev = NULL;
+               while (ptr)
+                       {
+                       if (ptr->expire - now.tv_sec < 0)
+                               {
+                               // delete record from server
+                               DeleteRecord(d, &ptr->rr, &ptr->zone);
+                               if (prev) prev->next = ptr->next;
+                               else d->table[i] = ptr->next;
+                               fptr = ptr;
+                               ptr = ptr->next;
+                               free(fptr);
+                               d->nelems--;
+                               }
+                       else
+                               {
+                               prev = ptr;
+                               ptr = ptr->next;
+                               }
+                       }
+               }
+       pthread_mutex_unlock(&d->tablelock);
+       }
+
+//
+// main update request handling
+//
+
+// Add, delete, or refresh records in table based on contents of a successfully completed dynamic update
+mDNSlocal void UpdateLeaseTable(PktMsg *pkt, DaemonInfo *d, mDNSs32 lease)
+       {
+       RRTableElem **rptr, *tmp;
+       int i, allocsize, bucket;
+       LargeCacheRecord lcr;
+       ResourceRecord *rr = &lcr.r.resrec;
+       const mDNSu8 *ptr, *end;
+       struct timeval time;
+       DNSQuestion zone;
+       char buf[80];
+       
+       if (pthread_mutex_lock(&d->tablelock)) { LogErr("UpdateLeaseTable", "pthread_mutex_lock"); return; }
+       HdrNToH(pkt);
+       ptr = pkt->msg.data;
+       end = (mDNSu8 *)&pkt->msg + pkt->len;
+       ptr = getQuestion(&pkt->msg, ptr, end, 0, &zone);
+       if (!ptr) { Log("UpdateLeaseTable: cannot read zone");  goto cleanup; }
+       ptr = LocateAuthorities(&pkt->msg, end);
+       if (!ptr) { Log("UpdateLeaseTable: Format error");  goto cleanup; }
+       
+       for (i = 0; i < pkt->msg.h.mDNS_numUpdates; i++)
+               {
+               mDNSBool DeleteAllRRSets = mDNSfalse, DeleteOneRRSet = mDNSfalse, DeleteOneRR = mDNSfalse;
+               
+               ptr = GetLargeResourceRecord(NULL, &pkt->msg, ptr, end, 0, kDNSRecordTypePacketAns, &lcr);
+               if (!ptr) { Log("UpdateLeaseTable: GetLargeResourceRecord returned NULL"); goto cleanup; }
+               bucket = rr->namehash % d->nbuckets;
+               rptr = &d->table[bucket];
+
+               // handle deletions             
+               if (rr->rrtype == kDNSQType_ANY && !rr->rroriginalttl && rr->rrclass == kDNSQClass_ANY && !rr->rdlength)
+                       DeleteAllRRSets = mDNStrue; // delete all rrsets for a name
+               else if (!rr->rroriginalttl && rr->rrclass == kDNSQClass_ANY && !rr->rdlength)
+                       DeleteOneRRSet = mDNStrue;
+               else if (!rr->rroriginalttl && rr->rrclass == kDNSClass_NONE)
+                       DeleteOneRR = mDNStrue;
+
+               if (DeleteAllRRSets || DeleteOneRRSet || DeleteOneRR)
+                       {
+                       while (*rptr)
+                         {
+                         if (SameDomainName((*rptr)->rr.resrec.name, rr->name) &&
+                                (DeleteAllRRSets ||
+                                (DeleteOneRRSet && (*rptr)->rr.resrec.rrtype == rr->rrtype) ||
+                                 (DeleteOneRR && SameResourceRecord(&(*rptr)->rr.resrec, rr))))
+                                 {
+                                 tmp = *rptr;
+                                 VLog("Received deletion update for %s", GetRRDisplayString_rdb(&tmp->rr.resrec, &tmp->rr.resrec.rdata->u, buf));
+                                 *rptr = (*rptr)->next;
+                                 free(tmp);
+                                 d->nelems--;
+                                 }
+                         else rptr = &(*rptr)->next;
+                         }
+                       }
+               else if (lease > 0)
+                       {
+                       // see if add or refresh
+                       while (*rptr && !SameResourceRecord(&(*rptr)->rr.resrec, rr)) rptr = &(*rptr)->next;
+                       if (*rptr)
+                               {
+                               // refresh
+                               if (gettimeofday(&time, NULL)) { LogErr("UpdateLeaseTable", "gettimeofday"); goto cleanup; }
+                               (*rptr)->expire = time.tv_sec + (unsigned)lease;
+                               VLog("Refreshing lease for %s", GetRRDisplayString_rdb(&lcr.r.resrec, &lcr.r.resrec.rdata->u, buf));                                    
+                               }
+                       else
+                               {
+                               // New record - add to table
+                               if (d->nelems > d->nbuckets)
+                                       {
+                                       RehashTable(d);
+                                       bucket = rr->namehash % d->nbuckets;
+                                       rptr = &d->table[bucket];
+                                       }
+                               if (gettimeofday(&time, NULL)) { LogErr("UpdateLeaseTable", "gettimeofday"); goto cleanup; }
+                               allocsize = sizeof(RRTableElem);
+                               if (rr->rdlength > InlineCacheRDSize) allocsize += (rr->rdlength - InlineCacheRDSize);
+                               tmp = malloc(allocsize);
+                               if (!tmp) { LogErr("UpdateLeaseTable", "malloc"); goto cleanup; }
+                               memcpy(&tmp->rr, &lcr.r, sizeof(CacheRecord) + rr->rdlength - InlineCacheRDSize);
+                               tmp->rr.resrec.rdata = (RData *)&tmp->rr.rdatastorage;
+                               AssignDomainName(&tmp->name, rr->name);
+                               tmp->rr.resrec.name = &tmp->name;
+                               tmp->expire = time.tv_sec + (unsigned)lease;
+                               tmp->cli.sin_addr = pkt->src.sin_addr;
+                               AssignDomainName(&tmp->zone, &zone.qname);
+                               tmp->next = d->table[bucket];
+                               d->table[bucket] = tmp;
+                               d->nelems++;
+                               VLog("Adding update for %s to lease table", GetRRDisplayString_rdb(&lcr.r.resrec, &lcr.r.resrec.rdata->u, buf));
+                               }
+                       }
+               }
+                                       
+       cleanup:
+       pthread_mutex_unlock(&d->tablelock);
+       HdrHToN(pkt);
+       }
+
+// Given a successful reply from a server, create a new reply that contains lease information
+// Replies are currently not signed !!!KRS change this
+mDNSlocal PktMsg *FormatLeaseReply(DaemonInfo *d, PktMsg *orig, mDNSu32 lease)
+       {
+       PktMsg *reply;
+       mDNSu8 *ptr, *end;
+       mDNSOpaque16 flags;
+
+       (void)d;  //unused
+       reply = malloc(sizeof(*reply));
+       if (!reply) { LogErr("FormatLeaseReply", "malloc"); return NULL; }
+       flags.b[0] = kDNSFlag0_QR_Response | kDNSFlag0_OP_Update;
+       flags.b[1] = 0;
+       InitializeDNSMessage(&reply->msg.h, orig->msg.h.id, flags);
+       reply->src.sin_addr.s_addr = htonl(INADDR_ANY);            // unused except for log messages
+       reply->src.sin_family = AF_INET;
+       ptr = reply->msg.data;
+       end = (mDNSu8 *)&reply->msg + sizeof(DNSMessage);
+       ptr = putUpdateLease(&reply->msg, ptr, lease);
+       if (!ptr) { Log("FormatLeaseReply: putUpdateLease failed"); free(reply); return NULL; }                            
+       reply->len = ptr - (mDNSu8 *)&reply->msg;
+       return reply;
+       }
+
+// pkt is thread-local, not requiring locking
+mDNSlocal PktMsg *HandleRequest(PktMsg *pkt, DaemonInfo *d)
+       {
+       int sd = -1;
+       PktMsg *reply = NULL, *LeaseReply;
+       mDNSs32 lease;
+       char buf[32];
+       
+       // send msg to server, read reply
+       sd = ConnectToServer(d);
+       if (sd < 0)
+               { Log("Discarding request from %s due to connection errors", inet_ntop(AF_INET, &pkt->src.sin_addr, buf, 32)); goto cleanup; }
+       if (SendTCPMsg(sd, pkt) < 0)
+               { Log("Couldn't relay message from %s to server.  Discarding.", inet_ntop(AF_INET, &pkt->src.sin_addr, buf, 32)); goto cleanup; }
+       reply = ReadTCPMsg(sd, NULL);
+       
+       // process reply
+       if (!SuccessfulUpdateTransaction(pkt, reply))
+               { VLog("Message from %s not a successful update.", inet_ntop(AF_INET, &pkt->src.sin_addr, buf, 32));  goto cleanup; }   
+       lease = GetPktLease(pkt);
+       UpdateLeaseTable(pkt, d, lease);
+       if (lease > 0)
+               {
+               LeaseReply = FormatLeaseReply(d, reply, lease);
+               if (!LeaseReply) Log("HandleRequest - unable to format lease reply");
+               free(reply); 
+               reply = LeaseReply;
+               }
+       cleanup:
+       if (sd >= 0) close(sd);
+       return reply;
+       }
+
+
+//
+// LLQ Support Routines
+//
+
+// Set fields of an LLQ Opt Resource Record
+mDNSlocal void FormatLLQOpt(AuthRecord *opt, int opcode, mDNSu8 *id, mDNSs32 lease)
+       {
+       bzero(opt, sizeof(*opt));
+       mDNS_SetupResourceRecord(opt, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, mDNSNULL, mDNSNULL);
+       opt->resrec.rdlength = LLQ_OPT_RDLEN;
+       opt->resrec.rdestimate = LLQ_OPT_RDLEN;
+       opt->resrec.rdata->u.opt.opt = kDNSOpt_LLQ;
+       opt->resrec.rdata->u.opt.optlen = sizeof(LLQOptData);
+       opt->resrec.rdata->u.opt.OptData.llq.vers = kLLQ_Vers;
+       opt->resrec.rdata->u.opt.OptData.llq.llqOp = opcode;
+       opt->resrec.rdata->u.opt.OptData.llq.err = LLQErr_NoError;
+       memcpy(opt->resrec.rdata->u.opt.OptData.llq.id, id, 8);
+       opt->resrec.rdata->u.opt.OptData.llq.lease = lease;
+       }
+
+// Calculate effective remaining lease of an LLQ
+mDNSlocal mDNSu32 LLQLease(LLQEntry *e)
+       {
+       struct timeval t;
+       
+       gettimeofday(&t, NULL);
+       if (e->expire < t.tv_sec) return 0;
+       else return e->expire - t.tv_sec;
+       }
+
+mDNSlocal void DeleteLLQ(DaemonInfo *d, LLQEntry *e)
+       {
+       int  bucket = DomainNameHashValue(&e->qname) % LLQ_TABLESIZE;
+       LLQEntry **ptr = &d->LLQTable[bucket];
+       AnswerListElem *a = e->AnswerList;
+       char addr[32];
+       
+       inet_ntop(AF_INET, &e->cli.sin_addr, addr, 32);
+       VLog("Deleting LLQ table entry for %##s client %s", e->qname.c, addr);
+
+       // free shared answer structure if ref count drops to zero
+       if (a && !(--a->refcount))
+               {
+               CacheRecord *cr = a->KnownAnswers, *tmp;
+               AnswerListElem **tbl = &d->AnswerTable[bucket];
+
+               while (cr)
+                       {
+                       tmp = cr;
+                       cr = cr->next;
+                       free(tmp);
+                       }
+
+               while (*tbl && *tbl != a) tbl = &(*tbl)->next;
+               if (*tbl) { *tbl = (*tbl)->next; free(a); }
+               else Log("Error: DeleteLLQ - AnswerList not found in table");
+               }
+
+       // remove LLQ from table, free memory
+       while(*ptr && *ptr != e) ptr = &(*ptr)->next;
+       if (!*ptr) { Log("Error: DeleteLLQ - LLQ not in table"); return; }
+       *ptr = (*ptr)->next;
+       free(e);        
+       }
+
+mDNSlocal int SendLLQ(DaemonInfo *d, PktMsg *pkt, struct sockaddr_in dst)
+       {
+       char addr[32];
+       int err = -1;
+
+       HdrHToN(pkt);
+       if (sendto(d->udpsd, &pkt->msg, pkt->len, 0, (struct sockaddr *)&dst, sizeof(dst)) != (int)pkt->len)
+               {
+               LogErr("DaemonInfo", "sendto");
+               Log("Could not send response to client %s", inet_ntop(AF_INET, &dst.sin_addr, addr, 32));
+               }
+       else err = 0;
+       HdrNToH(pkt);
+       return err;
+       }
+
+// if non-negative, sd is a TCP socket connected to the nameserver
+// otherwise, this routine creates and closes its own socket
+mDNSlocal CacheRecord *AnswerQuestion(DaemonInfo *d, AnswerListElem *e, int sd)
+       {
+       PktMsg q;
+       int i;
+       const mDNSu8 *ansptr;
+       mDNSu8 *end = q.msg.data;
+       mDNSOpaque16 id, flags = QueryFlags;
+       PktMsg *reply = NULL;
+       LargeCacheRecord lcr;
+       CacheRecord *AnswerList = NULL;
+       mDNSu8 rcode;
+       mDNSBool CloseSDOnExit = sd < 0;
+       
+       VLog("Querying server for %##s type %d", e->name.c, e->type);
+       
+       flags.b[0] |= kDNSFlag0_RD;  // recursion desired
+       id.NotAnInteger = 0;
+       InitializeDNSMessage(&q.msg.h, id, flags);
+       
+       end = putQuestion(&q.msg, end, end + AbsoluteMaxDNSMessageData, &e->name, e->type, kDNSClass_IN);
+       if (!end) { Log("Error: AnswerQuestion - putQuestion returned NULL"); goto end; }
+       q.len = (int)(end - (mDNSu8 *)&q.msg);
+       
+       if (sd < 0) sd = ConnectToServer(d);
+       if (sd < 0) { Log("AnswerQuestion: ConnectToServer failed"); goto end; }
+       if (SendTCPMsg(sd, &q)) { Log("AnswerQuestion: SendTCPMsg failed"); close(sd); goto end; }
+       reply = ReadTCPMsg(sd, NULL);
+
+       if ((reply->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask) != (kDNSFlag0_QR_Response | kDNSFlag0_OP_StdQuery))
+               { Log("AnswerQuestion: %##s type %d - Invalid response flags from server"); goto end; }
+       rcode = (mDNSu8)(reply->msg.h.flags.b[1] & kDNSFlag1_RC);
+       if (rcode && rcode != kDNSFlag1_RC_NXDomain) { Log("AnswerQuestion: %##s type %d - non-zero rcode %d from server", e->name.c, e->type, rcode); goto end; }
+
+       end = (mDNSu8 *)&reply->msg + reply->len;
+       ansptr = LocateAnswers(&reply->msg, end);
+       if (!ansptr) { Log("Error: AnswerQuestion - LocateAnswers returned NULL"); goto end; }
+
+       for (i = 0; i < reply->msg.h.numAnswers; i++)
+               {
+               ansptr = GetLargeResourceRecord(NULL, &reply->msg, ansptr, end, 0, kDNSRecordTypePacketAns, &lcr);
+               if (!ansptr) { Log("AnswerQuestions: GetLargeResourceRecord returned NULL"); goto end; }
+               if (lcr.r.resrec.rrtype != e->type || lcr.r.resrec.rrclass != kDNSClass_IN || !SameDomainName(lcr.r.resrec.name, &e->name))
+                       {
+                       Log("AnswerQuestion: response %##s type #d does not answer question %##s type #d.  Discarding",
+                                 lcr.r.resrec.name->c, lcr.r.resrec.rrtype, e->name.c, e->type);
+                       }
+               else
+                       {
+                       CacheRecord *cr = CopyCacheRecord(&lcr.r, &e->name);
+                       if (!cr) { Log("Error: AnswerQuestion - CopyCacheRecord returned NULL"); goto end; }                                               
+                       cr->next = AnswerList;
+                       AnswerList = cr;
+                       }
+               }
+       
+       end:
+       if (sd > -1 && CloseSDOnExit) close(sd);
+       if (reply) free(reply);
+       return AnswerList;
+       }
+
+// Routine sets EventList to contain Add/Remove events, and deletes any removes from the KnownAnswer list
+mDNSlocal void UpdateAnswerList(DaemonInfo *d, AnswerListElem *a, int sd)
+       {
+       CacheRecord *cr, *NewAnswers, **na, **ka; // "new answer", "known answer"
+
+       // get up to date answers
+       NewAnswers = AnswerQuestion(d, a, sd);
+       
+       // first pass - mark all answers for deletion
+       for (ka = &a->KnownAnswers; *ka; ka = &(*ka)->next)
+               (*ka)->resrec.rroriginalttl = (unsigned)-1; // -1 means delete
+
+       // second pass - mark answers pre-existent
+       for (ka = &a->KnownAnswers; *ka; ka = &(*ka)->next)
+               {
+               for (na = &NewAnswers; *na; na = &(*na)->next)
+                       {
+                       if (SameResourceRecord(&(*ka)->resrec, &(*na)->resrec))
+                               { (*ka)->resrec.rroriginalttl = 0; break; } // 0 means no change
+                       }
+               }
+
+       // third pass - add new records to Event list
+       na = &NewAnswers;
+       while (*na)             
+               {
+               for (ka = &a->KnownAnswers; *ka; ka = &(*ka)->next)
+                       if (SameResourceRecord(&(*ka)->resrec, &(*na)->resrec)) break;
+               if (!*ka)
+                       {
+                       // answer is not in list - splice from NewAnswers list, add to Event list
+                       cr = *na;
+                       *na = (*na)->next;        // splice from list
+                       cr->next = a->EventList;  // add spliced record to event list
+                       a->EventList = cr;
+                       cr->resrec.rroriginalttl = 1; // 1 means add
+                       }
+               else na = &(*na)->next;
+               }
+       
+       // move all the removes from the answer list to the event list  
+       ka = &a->KnownAnswers;
+       while (*ka) 
+               {
+               if ((*ka)->resrec.rroriginalttl == (unsigned)-1)
+                       {
+                       cr = *ka;
+                       *ka = (*ka)->next;
+                       cr->next = a->EventList;
+                       a->EventList = cr;
+                       }
+               else ka = &(*ka)->next;
+               }
+       
+       // lastly, free the remaining records (known answers) in NewAnswers list
+       while (NewAnswers)
+               {
+               cr = NewAnswers;
+               NewAnswers = NewAnswers->next;
+               free(cr);
+               }       
+       }
+
+mDNSlocal void SendEvents(DaemonInfo *d, LLQEntry *e)
+       {
+       PktMsg  response;
+       CacheRecord *cr;
+       mDNSu8 *end = (mDNSu8 *)&response.msg.data;
+       mDNSOpaque16 msgID;
+       char rrbuf[80], addrbuf[32];
+       AuthRecord opt;
+       
+       msgID.NotAnInteger = random();
+       if (verbose) inet_ntop(AF_INET, &e->cli.sin_addr, addrbuf, 32);
+       InitializeDNSMessage(&response.msg.h, msgID, ResponseFlags);
+       end = putQuestion(&response.msg, end, end + AbsoluteMaxDNSMessageData, &e->qname, e->qtype, kDNSClass_IN);
+       if (!end) { Log("Error: SendEvents - putQuestion returned NULL"); return; }
+       
+       // put adds/removes in packet
+       for (cr = e->AnswerList->EventList; cr; cr = cr->next)
+               {
+               if (verbose) GetRRDisplayString_rdb(&cr->resrec, &cr->resrec.rdata->u, rrbuf);
+               VLog("%s (%s): %s", addrbuf, (mDNSs32)cr->resrec.rroriginalttl < 0 ? "Remove": "Add", rrbuf);                            
+               end = PutResourceRecordTTLJumbo(&response.msg, end, &response.msg.h.numAnswers, &cr->resrec, cr->resrec.rroriginalttl);
+               if (!end) { Log("Error: SendEvents - UpdateAnswerList returned NULL"); return; }
+               }
+                          
+       FormatLLQOpt(&opt, kLLQOp_Event, e->id, LLQLease(e));
+       end = PutResourceRecordTTLJumbo(&response.msg, end, &response.msg.h.numAdditionals, &opt.resrec, 0);
+       if (!end) { Log("Error: SendEvents - PutResourceRecordTTLJumbo"); return; }
+
+       response.len = (int)(end - (mDNSu8 *)&response.msg);
+       if (SendLLQ(d, &response, e->cli) < 0) LogMsg("Error: SendEvents - SendLLQ");           
+       }
+
+mDNSlocal void PrintLLQTable(DaemonInfo *d)
+       {
+       LLQEntry *e;
+       char addr[32];
+       int i;
+       
+       Log("Printing LLQ table contents");
+
+       for (i = 0; i < LLQ_TABLESIZE; i++)
+               {
+               e = d->LLQTable[i];
+               while(e)
+                       {
+                       inet_ntop(AF_INET, &e->cli.sin_addr, addr, 32);
+                       Log("LLQ from %##s type %d lease %d (%d remaining)",
+                               addr, e->qname.c, e->qtype, e->lease, LLQLease(e));
+                       e = e->next;
+                       }
+               }
+       }
+
+// Send events to clients as a result of a change in the zone
+mDNSlocal void GenLLQEvents(DaemonInfo *d)
+       {
+       LLQEntry **e;
+       int i, sd;
+       struct timeval t;
+
+       VLog("Generating LLQ Events");
+
+       gettimeofday(&t, NULL);
+       sd = ConnectToServer(d);
+       if (sd < 0) { Log("GenLLQEvents: ConnectToServer failed"); return; }
+
+       // get all answers up to date
+       for (i = 0; i < LLQ_TABLESIZE; i++)
+               {
+               AnswerListElem *a = d->AnswerTable[i];
+               while(a)
+                       {
+                       UpdateAnswerList(d, a, sd);
+                       a = a->next;
+                       }
+               }
+
+    // for each established LLQ, send events
+       for (i = 0; i < LLQ_TABLESIZE; i++)
+               {
+               e = &d->LLQTable[i];
+               while(*e)
+                       {
+                       if ((*e)->expire < t.tv_sec) DeleteLLQ(d, *e);
+                       else
+                               {
+                               if ((*e)->state == Established && (*e)->AnswerList->EventList) SendEvents(d, *e);
+                               e = &(*e)->next;
+                               }
+                       }
+               }
+       
+       // now that all LLQs are updated, we move Add events from the Event list to the Known Answer list, and free Removes
+       for (i = 0; i < LLQ_TABLESIZE; i++)
+               {
+               AnswerListElem *a = d->AnswerTable[i];
+               while(a)
+                       {
+                       if (a->EventList)
+                               {
+                               CacheRecord *cr = a->EventList, *tmp;
+                               while (cr)
+                                       {
+                                       tmp = cr;
+                                       cr = cr->next;
+                                       if ((signed)tmp->resrec.rroriginalttl < 0) free(tmp);
+                                       else
+                                               {
+                                               tmp->next = a->KnownAnswers;
+                                               a->KnownAnswers = tmp;  
+                                               tmp->resrec.rroriginalttl = 0;
+                                               }
+                                       }
+                               a->EventList = NULL;
+                               }
+                       a = a->next;
+                       }
+               }       
+               
+       close(sd);
+       }
+
+// Monitor zone for changes that may produce LLQ events
+mDNSlocal void *LLQEventMonitor(void *DInfoPtr)
+       {
+       DaemonInfo *d = DInfoPtr;
+       PktMsg q;
+       mDNSu8 *end = q.msg.data;
+       const mDNSu8 *ptr;
+       mDNSOpaque16 id, flags = QueryFlags;
+       PktMsg reply;
+       mDNSs32 serial = 0;
+       mDNSBool SerialInitialized = mDNSfalse;
+       int sd;
+    LargeCacheRecord lcr;
+       ResourceRecord *rr = &lcr.r.resrec;
+       int i, sleeptime = 0;
+       domainname zone;
+       char pingmsg[4];
+       
+       // create question
+       id.NotAnInteger = 0;
+       InitializeDNSMessage(&q.msg.h, id, flags);
+       AssignDomainName(&zone, &d->zone);
+       end = putQuestion(&q.msg, end, end + AbsoluteMaxDNSMessageData, &zone, kDNSType_SOA, kDNSClass_IN);
+       if (!end) { Log("Error: LLQEventMonitor - putQuestion returned NULL"); return NULL; }
+       q.len = (int)(end - (mDNSu8 *)&q.msg);
+
+       sd = ConnectToServer(d);
+       if (sd < 0) { Log("LLQEventMonitor: ConnectToServer failed"); return NULL; }
+
+       while(1)
+               {
+               usleep(sleeptime);
+               sleeptime = LLQ_MONITOR_ERR_INTERVAL;  // if we bail on error below, rate limit retry
+               
+               // send message, receive response
+               if (SendTCPMsg(sd, &q)) { Log("LLQEventMonitor: SendTCPMsg failed"); continue; }
+               if (!ReadTCPMsg(sd, &reply)) { Log("LLQEventMonitor: ReadTCPMsg failed"); continue; }
+               end = (mDNSu8 *)&reply.msg + reply.len;
+               if (reply.msg.h.flags.b[1] & kDNSFlag1_RC) { Log("LLQEventMonitor - received non-zero rcode"); continue; }
+
+               // find answer
+               ptr = LocateAnswers(&reply.msg, end);
+               if (!ptr) { Log("Error: LLQEventMonitor - LocateAnswers returned NULL"); continue; }
+               for (i = 0; i < reply.msg.h.numAnswers; i++)
+                       {
+                       ptr = GetLargeResourceRecord(NULL, &reply.msg, ptr, end, 0, kDNSRecordTypePacketAns, &lcr);
+                       if (!ptr) { Log("Error: LLQEventMonitor - GetLargeResourceRecord  returned NULL"); continue; }
+                       if (rr->rrtype != kDNSType_SOA || rr->rrclass != kDNSClass_IN || !SameDomainName(rr->name, &zone)) continue;
+                       if (!SerialInitialized)
+                               {
+                               // first time through loop
+                               SerialInitialized = mDNStrue;
+                               serial = rr->rdata->u.soa.serial;
+                               sleeptime = LLQ_MONITOR_INTERVAL;
+                               break;
+                               }
+                       else if (rr->rdata->u.soa.serial != serial)
+                               {
+                               // update serial, wake main thread
+                               serial = rr->rdata->u.soa.serial;
+                               VLog("LLQEventMonitor: zone changed. Signaling main thread.");
+                               if (send(d->LLQServPollSock, pingmsg, sizeof(pingmsg), 0) != sizeof(pingmsg))
+                                       { LogErr("LLQEventMonitor", "send"); break; }
+                               }
+                       sleeptime = LLQ_MONITOR_INTERVAL;
+                       break;                  
+                       }
+               if (!ptr) Log("LLQEventMonitor: response to query did not contain SOA");
+               }
+       }
+
+mDNSlocal void SetAnswerList(DaemonInfo *d, LLQEntry *e)
+       {
+       int bucket = DomainNameHashValue(&e->qname) % LLQ_TABLESIZE;
+       AnswerListElem *a = d->AnswerTable[bucket];
+       while (a && (a->type != e->qtype ||!SameDomainName(&a->name, &e->qname))) a = a->next;
+       if (!a)
+               {
+               a = malloc(sizeof(*a));
+               if (!a) { LogErr("SetAnswerList", "malloc"); return; }
+               AssignDomainName(&a->name, &e->qname);
+               a->type = e->qtype;
+               a->refcount = 0;
+               a->KnownAnswers = NULL;
+               a->EventList = NULL;
+               a->next = d->AnswerTable[bucket];
+               d->AnswerTable[bucket] = a;
+
+               // to get initial answer list, call UpdateAnswerList and move cache records from EventList to KnownAnswers
+               UpdateAnswerList(d, a, -1);
+               a->KnownAnswers = a->EventList;
+               a->EventList = NULL;
+               }
+       
+       e->AnswerList = a;
+       a->refcount ++;
+       }
+       
+ // Allocate LLQ entry, insert into table
+mDNSlocal LLQEntry *NewLLQ(DaemonInfo *d, struct sockaddr_in cli, domainname *qname, mDNSu16 qtype, mDNSu32 lease)
+       {
+       char addr[32];
+       struct timeval t;
+       int bucket = DomainNameHashValue(qname) % LLQ_TABLESIZE;
+       LLQEntry *e;
+
+       e = malloc(sizeof(*e));
+       if (!e) { LogErr("NewLLQ", "malloc"); return NULL; }
+
+       inet_ntop(AF_INET, &cli.sin_addr, addr, 32);
+       VLog("Allocating LLQ entry for client %s question %##s type %d", addr, qname->c, qtype);
+       
+       // initialize structure
+       e->cli = cli;
+       AssignDomainName(&e->qname, qname);
+       e->qtype = qtype;
+       memset(e->id, 0, 8);
+       e->state = RequestReceived;
+       e->AnswerList = NULL;
+       
+       if (lease < LLQ_MIN_LEASE) lease = LLQ_MIN_LEASE;
+       else if (lease > LLQ_MAX_LEASE) lease = LLQ_MIN_LEASE;
+       gettimeofday(&t, NULL);
+       e->expire = t.tv_sec + (int)lease;
+       e->lease = lease;
+       
+       // add to table
+       e->next = d->LLQTable[bucket];
+       d->LLQTable[bucket] = e;
+       
+       return e;
+       }
+
+// Handle a refresh request from client
+mDNSlocal void LLQRefresh(DaemonInfo *d, LLQEntry *e, LLQOptData *llq, mDNSOpaque16 msgID)
+       {
+       AuthRecord opt;
+       PktMsg ack;
+       mDNSu8 *end = (mDNSu8 *)&ack.msg.data;
+       char addr[32];
+
+       inet_ntop(AF_INET, &e->cli.sin_addr, addr, 32);
+       VLog("%s LLQ for %##s from %s", llq->lease ? "Refreshing" : "Deleting", e->qname.c, addr);
+       
+       if (llq->lease)
+               {
+               if (llq->lease < LLQ_MIN_LEASE) llq->lease = LLQ_MIN_LEASE;
+               else if (llq->lease > LLQ_MAX_LEASE) llq->lease = LLQ_MIN_LEASE;
+               }
+       
+       ack.src.sin_addr.s_addr = 0; // unused 
+       InitializeDNSMessage(&ack.msg.h, msgID, ResponseFlags);
+       end = putQuestion(&ack.msg, end, end + AbsoluteMaxDNSMessageData, &e->qname, e->qtype, kDNSClass_IN);
+       if (!end) { Log("Error: putQuestion"); return; }
+
+       FormatLLQOpt(&opt, kLLQOp_Refresh, e->id, llq->lease ? LLQLease(e) : 0);
+       end = PutResourceRecordTTLJumbo(&ack.msg, end, &ack.msg.h.numAdditionals, &opt.resrec, 0);
+       if (!end) { Log("Error: PutResourceRecordTTLJumbo"); return; }
+
+       ack.len = (int)(end - (mDNSu8 *)&ack.msg);
+       if (SendLLQ(d, &ack, e->cli)) Log("Error: LLQRefresh"); 
+
+       if (llq->lease) e->state = Established;
+       else DeleteLLQ(d, e);   
+       }
+
+// Complete handshake with Ack an initial answers
+mDNSlocal void LLQCompleteHandshake(DaemonInfo *d, LLQEntry *e, LLQOptData *llq, mDNSOpaque16 msgID)
+       {
+       char addr[32];
+       CacheRecord *ptr;
+       AuthRecord opt;
+       PktMsg ack;
+       mDNSu8 *end = (mDNSu8 *)&ack.msg.data;
+       char rrbuf[80], addrbuf[32];
+       
+       inet_ntop(AF_INET, &e->cli.sin_addr, addr, 32);
+
+       if (memcmp(llq->id, e->id, 8)           ||
+               llq->vers  != kLLQ_Vers             ||
+               llq->llqOp != kLLQOp_Setup          ||
+               llq->err   != LLQErr_NoError        ||
+               llq->lease > e->lease + LLQ_LEASE_FUDGE ||
+               llq->lease < e->lease - LLQ_LEASE_FUDGE)
+               { Log("Incorrect challenge response from %s", addr); return; }
+
+       if (e->state == Established) VLog("Retransmitting LLQ ack + answers for %##s", e->qname.c);
+       else                         VLog("Delivering LLQ ack + answers for %##s", e->qname.c);  
+       
+       // format ack + answers
+       ack.src.sin_addr.s_addr = 0; // unused 
+       InitializeDNSMessage(&ack.msg.h, msgID, ResponseFlags);
+       end = putQuestion(&ack.msg, end, end + AbsoluteMaxDNSMessageData, &e->qname, e->qtype, kDNSClass_IN);
+       if (!end) { Log("Error: putQuestion"); return; }
+       
+       if (e->state != Established) { SetAnswerList(d, e); e->state = Established; }
+       
+       if (verbose) inet_ntop(AF_INET, &e->cli.sin_addr, addrbuf, 32);
+       for (ptr = e->AnswerList->KnownAnswers; ptr; ptr = ptr->next)
+               {
+               if (verbose) GetRRDisplayString_rdb(&ptr->resrec, &ptr->resrec.rdata->u, rrbuf);
+               VLog("%s Intitial Answer - %s", addr, rrbuf);
+               end = PutResourceRecordTTLJumbo(&ack.msg, end, &ack.msg.h.numAnswers, &ptr->resrec, 1);
+               if (!end) { Log("Error: PutResourceRecordTTLJumbo"); return; }
+               }
+
+       FormatLLQOpt(&opt, kLLQOp_Setup, e->id, LLQLease(e));
+       end = PutResourceRecordTTLJumbo(&ack.msg, end, &ack.msg.h.numAdditionals, &opt.resrec, 0);
+       if (!end) { Log("Error: PutResourceRecordTTLJumbo"); return; }
+
+       ack.len = (int)(end - (mDNSu8 *)&ack.msg);
+       if (SendLLQ(d, &ack, e->cli)) Log("Error: LLQCompleteHandshake");
+       }
+
+mDNSlocal void LLQSetupChallenge(DaemonInfo *d, LLQEntry *e, LLQOptData *llq, mDNSOpaque16 msgID)
+       {
+       struct timeval t;
+       mDNSu32 randval;
+       PktMsg challenge;
+       mDNSu8 *end = challenge.msg.data;
+       AuthRecord opt;
+
+       if (e->state == ChallengeSent) VLog("Retransmitting LLQ setup challenge for %##s", e->qname.c);
+       else                           VLog("Sending LLQ setup challenge for %##s", e->qname.c);
+       
+       if (!ZERO_LLQID(llq->id)) { Log("Error: LLQSetupChallenge - nonzero ID"); return; } // server bug
+       if (llq->llqOp != kLLQOp_Setup) { Log("LLQSetupChallenge - incorrrect operation from client"); return; } // client error
+       
+       if (ZERO_LLQID(e->id)) // don't regenerate random ID for retransmissions
+               {
+               // construct ID <time><random>
+               gettimeofday(&t, NULL);
+               randval = random();
+               memcpy(e->id, &t.tv_sec, sizeof(t.tv_sec));
+               memcpy(e->id + sizeof(t.tv_sec), &randval, sizeof(randval));                       
+               }
+
+       // format response (query + LLQ opt rr)
+       challenge.src.sin_addr.s_addr = 0; // unused 
+       InitializeDNSMessage(&challenge.msg.h, msgID, ResponseFlags);
+       end = putQuestion(&challenge.msg, end, end + AbsoluteMaxDNSMessageData, &e->qname, e->qtype, kDNSClass_IN);
+       if (!end) { Log("Error: putQuestion"); return; }        
+       FormatLLQOpt(&opt, kLLQOp_Setup, e->id, LLQLease(e));
+       end = PutResourceRecordTTLJumbo(&challenge.msg, end, &challenge.msg.h.numAdditionals, &opt.resrec, 0);
+       if (!end) { Log("Error: PutResourceRecordTTLJumbo"); return; }
+       challenge.len = (int)(end - (mDNSu8 *)&challenge.msg);
+       if (SendLLQ(d, &challenge, e->cli)) { Log("Error: LLQSetupChallenge"); return; }
+       e->state = ChallengeSent;
+       }
+
+// Take action on an LLQ message from client.  Entry must be initialized and in table
+mDNSlocal void UpdateLLQ(DaemonInfo *d, LLQEntry *e, LLQOptData *llq, mDNSOpaque16 msgID)
+       {
+       switch(e->state)
+               {
+               case RequestReceived:
+                       LLQSetupChallenge(d, e, llq, msgID);
+                       return;
+               case ChallengeSent:
+                       if (ZERO_LLQID(llq->id)) LLQSetupChallenge(d, e, llq, msgID); // challenge sent and lost
+                       else LLQCompleteHandshake(d, e, llq, msgID);
+                       return;
+               case Established:
+                       if (ZERO_LLQID(llq->id))
+                               {
+                               // client started over.  reset state.
+                               LLQEntry *newe = NewLLQ(d, e->cli, &e->qname, e->qtype, llq->lease);
+                               if (!newe) return;
+                               DeleteLLQ(d, e);
+                               LLQSetupChallenge(d, newe, llq, msgID);
+                               return;
+                               }
+                       else if (llq->llqOp == kLLQOp_Setup)
+                               { LLQCompleteHandshake(d, e, llq, msgID); return; } // Ack lost                         
+                       else if (llq->llqOp == kLLQOp_Refresh)
+                               { LLQRefresh(d, e, llq, msgID); return; }
+                       else { Log("Unhandled message for established LLQ"); return; }
+               }       
+       }
+
+mDNSlocal LLQEntry *LookupLLQ(DaemonInfo *d, struct sockaddr_in cli, domainname *qname, mDNSu16 qtype, mDNSu8 *id)
+       {       
+       int bucket = bucket = DomainNameHashValue(qname) % LLQ_TABLESIZE;
+       LLQEntry *ptr = d->LLQTable[bucket];
+
+       while(ptr)
+               {
+               if (((ptr->state == ChallengeSent && ZERO_LLQID(id)) || // zero-id due to packet loss OK in state ChallengeSent
+                        !memcmp(id, ptr->id, 8)) &&                        // id match
+                       SAME_INADDR(cli, ptr->cli) && qtype == ptr->qtype && SameDomainName(&ptr->qname, qname)) // same source, type, qname
+                       return ptr;
+               ptr = ptr->next;
+               }
+       return NULL;
+       }
+
+mDNSlocal int RecvLLQ(DaemonInfo *d, PktMsg *pkt)
+       {
+       DNSQuestion q;
+       LargeCacheRecord opt;
+       int i, err = -1;
+       char addr[32];
+       const mDNSu8 *qptr = pkt->msg.data;
+    const mDNSu8 *end = (mDNSu8 *)&pkt->msg + pkt->len;
+       const mDNSu8 *aptr = LocateAdditionals(&pkt->msg, end);
+       LLQOptData *llq = NULL;
+       LLQEntry *e = NULL;
+       
+       HdrNToH(pkt);   
+       inet_ntop(AF_INET, &pkt->src.sin_addr, addr, 32);
+
+       VLog("Received LLQ msg from %s", addr);
+       // sanity-check packet
+       if (!pkt->msg.h.numQuestions || !pkt->msg.h.numAdditionals)
+               {
+               Log("Malformatted LLQ from %s with %d questions, %d additionals", addr, pkt->msg.h.numQuestions, pkt->msg.h.numAdditionals);                    
+               goto end;
+               }
+
+       // find the OPT RR - must be last in message
+       for (i = 0; i < pkt->msg.h.numAdditionals; i++)
+               {
+               aptr = GetLargeResourceRecord(NULL, &pkt->msg, aptr, end, 0, kDNSRecordTypePacketAdd, &opt); 
+               if (!aptr) { Log("Malformatted LLQ from %s: could not get Additional record %d", addr, i); goto end; }
+               }
+
+       // validate OPT
+       if (opt.r.resrec.rrtype != kDNSType_OPT) { Log("Malformatted LLQ from %s: last Additional not an Opt RR", addr); goto end; }
+       if (opt.r.resrec.rdlength < pkt->msg.h.numQuestions * LLQ_OPT_RDLEN) { Log("Malformatted LLQ from %s: Opt RR to small (%d bytes for %d questions)", addr, opt.r.resrec.rdlength, pkt->msg.h.numQuestions); }
+       
+       // dispatch each question
+       for (i = 0; i < pkt->msg.h.numQuestions; i++)
+               {
+               qptr = getQuestion(&pkt->msg, qptr, end, 0, &q);
+               if (!qptr) { Log("Malformatted LLQ from %s: cannot read question %d", addr, i); goto end; }
+               llq = (LLQOptData *)&opt.r.resrec.rdata->u.opt.OptData.llq + i; // point into OptData at index i
+               if (llq->vers != kLLQ_Vers) { Log("LLQ from %s contains bad version %d (expected %d)", addr, llq->vers, kLLQ_Vers); goto end; }
+               
+               e = LookupLLQ(d, pkt->src, &q.qname, q.qtype, llq->id);
+               if (!e)
+                       {
+                       // no entry - if zero ID, create new
+                       e = NewLLQ(d, pkt->src, &q.qname, q.qtype, llq->lease);
+                       if (!e) goto end;
+                       }
+               UpdateLLQ(d, e, llq, pkt->msg.h.id);
+               }
+       err = 0;
+       
+       end:
+       HdrHToN(pkt);
+       return err;
+       }
+
+mDNSlocal mDNSBool IsLLQRequest(PktMsg *pkt)
+       {
+       const mDNSu8 *ptr = NULL, *end = (mDNSu8 *)&pkt->msg + pkt->len;
+       LargeCacheRecord lcr;
+       int i;
+       mDNSBool result = mDNSfalse;
+       
+       HdrNToH(pkt);           
+       if ((mDNSu8)(pkt->msg.h.flags.b[0] & kDNSFlag0_QROP_Mask) != (mDNSu8)(kDNSFlag0_QR_Query | kDNSFlag0_OP_StdQuery)) goto end;
+
+       if (!pkt->msg.h.numAdditionals) goto end;
+       ptr = LocateAdditionals(&pkt->msg, end);
+       if (!ptr) goto end;
+
+       // find last Additional
+       for (i = 0; i < pkt->msg.h.numAdditionals; i++)
+               {
+               ptr = GetLargeResourceRecord(NULL, &pkt->msg, ptr, end, 0, kDNSRecordTypePacketAdd, &lcr);
+               if (!ptr) { Log("Unable to read additional record"); goto end; }
+               }
+       
+       if (lcr.r.resrec.rrtype == kDNSType_OPT &&
+               lcr.r.resrec.rdlength >= LLQ_OPT_RDLEN &&
+               lcr.r.resrec.rdata->u.opt.opt == kDNSOpt_LLQ)
+               { result = mDNStrue; goto end; }
+
+       end:
+       HdrHToN(pkt);
+       return result;
+       }
+
+// !!!KRS implement properly
+mDNSlocal mDNSBool IsLLQAck(PktMsg *pkt)
+       {
+       if (pkt->msg.h.flags.NotAnInteger == ResponseFlags.NotAnInteger &&
+               pkt->msg.h.numQuestions && !pkt->msg.h.numAnswers && !pkt->msg.h.numAuthorities) return mDNStrue;
+       return mDNSfalse;
+       }
+
+
+// request handler wrappers for TCP and UDP requests
+// (read message off socket, fork thread that invokes main processing routine and handles cleanup)
+mDNSlocal void *UDPUpdateRequestForkFn(void *vptr)
+       {
+       char buf[32];
+       UDPRequestArgs *req = vptr;
+       PktMsg *reply = NULL;
+       
+       VLog("Received UDP request: %d bytes from %s", req->pkt.len, inet_ntop(AF_INET, &req->pkt.src.sin_addr, buf, 32));  
+       //!!!KRS strictly speaking, we shouldn't use TCP for a UDP request because the server may give us a long answer that would require truncation for UDP delivery to client
+       reply = HandleRequest(&req->pkt, req->d);
+       if (reply)
+               {
+               if (sendto(req->d->udpsd, &reply->msg, reply->len, 0, (struct sockaddr *)&req->pkt.src, sizeof(req->pkt.src)) != (int)reply->len)
+                       LogErr("UDPUpdateRequestForkFn", "sendto");             
+               }
+
+       if (reply) free(reply);         
+       free(req);
+       pthread_exit(NULL);
+       }
+
+//!!!KRS this needs to be changed to use non-blocking sockets
+mDNSlocal int RecvUDPRequest(int sd, DaemonInfo *d)
+       {
+       UDPRequestArgs *req;
+       pthread_t tid;
+       unsigned int clisize = sizeof(req->cliaddr);
+       
+       req = malloc(sizeof(UDPRequestArgs));
+       if (!req) { LogErr("RecvUDPRequest", "malloc"); return -1; }
+       bzero(req, sizeof(*req));
+       req->d = d;
+       req->pkt.len = recvfrom(sd, &req->pkt.msg, sizeof(req->pkt.msg), 0, (struct sockaddr *)&req->cliaddr, &clisize);
+       if ((int)req->pkt.len < 0) { LogErr("RecvUDPRequest", "recvfrom"); free(req); return -1; }
+       if (clisize != sizeof(req->cliaddr)) { Log("Client address of unknown size %d", clisize); free(req); return -1; }
+       req->pkt.src = req->cliaddr;
+
+       if (IsLLQRequest(&req->pkt))
+               {
+               // LLQ messages handled by main thread
+               int err = RecvLLQ(d, &req->pkt);
+               free(req);
+               return err;
+               }
+
+       if (IsLLQAck(&req->pkt)) { free(req); return 0; } // !!!KRS need to do acks + retrans
+       
+       if (pthread_create(&tid, NULL, UDPUpdateRequestForkFn, req)) { LogErr("RecvUDPRequest", "pthread_create"); free(req); return -1; }
+       pthread_detach(tid);
+       return 0;
+       }
+
+mDNSlocal void *TCPRequestForkFn(void *vptr)
+       {
+       TCPRequestArgs *req = vptr;
+       PktMsg *in = NULL, *out = NULL;
+       char buf[32];
+       
+    //!!!KRS if this read blocks indefinitely, we can run out of threads
+       // read the request
+       in = ReadTCPMsg(req->sd, NULL);
+       if (!in)
+               {
+               LogMsg("TCPRequestForkFn: Could not read message from %s", inet_ntop(AF_INET, &req->cliaddr.sin_addr, buf, 32));
+               goto cleanup;
+               }
+
+       VLog("Received TCP request: %d bytes from %s", in->len, inet_ntop(AF_INET, &req->cliaddr.sin_addr, buf, 32));   
+       // create the reply
+       out = HandleRequest(in, req->d);
+       if (!out)
+               {
+               LogMsg("TCPRequestForkFn: No reply for client %s", inet_ntop(AF_INET, &req->cliaddr.sin_addr, buf, 32));
+               goto cleanup;
+               }
+
+       // deliver reply to client
+       if (SendTCPMsg(req->sd, out) < 0) 
+               {
+               LogMsg("TCPRequestForkFn: Unable to send reply to client %s", inet_ntop(AF_INET, &req->cliaddr.sin_addr, buf, 32));
+               goto cleanup;
+               }
+               
+       cleanup:
+       free(req);
+       if (in) free(in);
+       if (out) free(out);
+       pthread_exit(NULL);
+       }
+
+mDNSlocal int RecvTCPRequest(int sd, DaemonInfo *d)
+       {
+       TCPRequestArgs *req;
+       pthread_t tid;
+       unsigned int clilen = sizeof(req->cliaddr);
+       
+       req = malloc(sizeof(TCPRequestArgs));
+       if (!req) { LogErr("RecvTCPRequest", "malloc"); return -1; }
+       bzero(req, sizeof(*req));
+       req->d = d;
+       req->sd = accept(sd, (struct sockaddr *)&req->cliaddr, &clilen);
+       if (req->sd < 0) { LogErr("RecvTCPRequest", "accept"); return -1; }     
+       if (clilen != sizeof(req->cliaddr)) { Log("Client address of unknown size %d", clilen); free(req); return -1; }
+       if (pthread_create(&tid, NULL, TCPRequestForkFn, req)) { LogErr("RecvTCPRequest", "pthread_create"); free(req); return -1; }
+       pthread_detach(tid);
+       return 0;
+       }
+
+// main event loop
+// listen for incoming requests, periodically check table for expired records, respond to signals
+mDNSlocal int ListenForUpdates(DaemonInfo *d)
+       {
+       int err;
+       int maxfdp1;
+       fd_set rset;
+       struct timeval timenow, timeout = { 0, 0 };
+       long NextTableCheck = 0;
+       
+       VLog("Listening for requests...");
+
+       FD_ZERO(&rset);
+       maxfdp1 = d->tcpsd + 1;
+       if (d->udpsd + 1 > maxfdp1) maxfdp1 = d->udpsd + 1;
+       if (d->LLQEventListenSock + 1 > maxfdp1) maxfdp1 = d->LLQEventListenSock + 1;
+       
+       while(1)
+               {
+               // expire records if necessary, set timeout
+               if (gettimeofday(&timenow, NULL)) { LogErr("ListenForUpdates", "gettimeofday"); return -1; }
+               if (timenow.tv_sec >= NextTableCheck)
+                       {
+                       DeleteExpiredRecords(d);
+                       NextTableCheck = timenow.tv_sec + EXPIRATION_INTERVAL;
+                       }
+               timeout.tv_sec = NextTableCheck - timenow.tv_sec;
+               
+               FD_SET(d->tcpsd, &rset);
+               FD_SET(d->udpsd, &rset);
+               FD_SET(d->LLQEventListenSock, &rset);
+               
+               err = select(maxfdp1, &rset, NULL, NULL, &timeout);             
+               if (err < 0)
+                       {
+                       if (errno == EINTR)
+                               {
+                               if (terminate) { DeleteExpiredRecords(d); return 0; }
+                               else if (dumptable) { PrintLeaseTable(d); PrintLLQTable(d); dumptable = 0; }
+                               else Log("Received unhandled signal - continuing"); 
+                               }
+                       else { LogErr("ListenForUpdates", "select"); return -1; }
+                       }
+               else
+                       {
+                       if (FD_ISSET(d->tcpsd, &rset)) RecvTCPRequest(d->tcpsd, d);
+                       if (FD_ISSET(d->udpsd, &rset)) RecvUDPRequest(d->udpsd, d); 
+                       if (FD_ISSET(d->LLQEventListenSock, &rset))
+                               {
+                               // clear signalling data off socket
+                               char buf[32];
+                               recv(d->LLQEventListenSock, buf, 32, 0);
+                               GenLLQEvents(d);
+                               }
+                       }
+               }
+       return 0;
+       }
+
+// signal handler sets global variables, which are inspected by main event loop
+// (select automatically returns due to the handled signal)
+mDNSlocal void HndlSignal(int sig)
+       {
+       if (sig == SIGTERM || sig == SIGINT ) { terminate = 1; return; }
+       if (sig == INFO_SIGNAL)               { dumptable = 1; return; }
+       }
+
+int main(int argc, char *argv[])
+       {
+       pthread_t LLQtid;
+       DaemonInfo *d;
+
+       d = malloc(sizeof(*d));
+       if (!d) { LogErr("main", "malloc"); exit(1); }
+       bzero(d, sizeof(DaemonInfo));
+       
+       if (signal(SIGTERM,     HndlSignal) == SIG_ERR) perror("Can't catch SIGTERM");
+       if (signal(INFO_SIGNAL, HndlSignal) == SIG_ERR) perror("Can't catch SIGINFO");
+       if (signal(SIGINT,      HndlSignal) == SIG_ERR) perror("Can't catch SIGINT");
+       if (signal(SIGPIPE,     SIG_IGN  )  == SIG_ERR) perror("Can't ignore SIGPIPE");
+       
+       if (ProcessArgs(argc, argv, d) < 0) exit(1);
+
+       if (!foreground)
+               {
+               if (daemon(0,0))
+                       {
+                       LogErr("main", "daemon");
+                       fprintf(stderr, "Could not daemonize process, running in foreground");
+                       foreground = 1;
+                       }       
+               }
+
+       if (InitLeaseTable(d) < 0) exit(1);
+       if (SetupSockets(d) < 0) exit(1); 
+       if (SetUpdateSRV(d) < 0) exit(1);
+       
+       if (pthread_create(&LLQtid, NULL, LLQEventMonitor, d)) { LogErr("main", "pthread_create"); }    
+       else
+               {
+               pthread_detach(LLQtid);
+               ListenForUpdates(d);
+               }
+               
+       if (ClearUpdateSRV(d) < 0) exit(1);  // clear update srv's even if ListenForUpdates or pthread_create returns an error
+       free(d);
+       exit(0);
+       }
index 6284b1e388170b1666fed01d5d72147fdea12b03..e080dda478fefcb66838187b3d9c8b865f83f52c 100755 (executable)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2004, Apple Computer, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
@@ -27,6 +28,9 @@
    Change History (most recent first):
 
 $Log: dnssd_clientlib.c,v $
+Revision 1.11  2006/08/14 23:05:53  cheshire
+Added "tab-width" emacs header line
+
 Revision 1.10  2005/04/06 02:06:56  shersche
 Add DNSSD_API macro to TXTRecord API calls
 
index 7259a9c71173c701e3a01d36a7e8635770da00b8..9cff8246cb5ee324d768c8a7a1d595881445c641 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003 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@
 
  * This file defines a simple shim layer between a client calling the "/usr/include/dns_sd.h" APIs
  * and an implementation of mDNSCore ("mDNSEmbeddedAPI.h" APIs) in the same address space.
        Change History (most recent first):
 
 $Log: dnssd_clientshim.c,v $
+Revision 1.10  2006/08/14 23:24:56  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.9  2006/07/24 23:45:55  cheshire
+<rdar://problem/4605276> DNSServiceReconfirmRecord() should return error code
+
 Revision 1.8  2004/12/16 20:47:34  cheshire
 <rdar://problem/3324626> Cache memory management improvements
 
@@ -704,7 +704,7 @@ fail:
 // is run against this Extension, it will get a reasonable error code instead of just
 // failing to launch (Strong Link) or calling an unresolved symbol and crashing (Weak Link)
 #if !MDNS_BUILDINGSTUBLIBRARY
-void DNSServiceReconfirmRecord
+DNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord
        (
        DNSServiceFlags                    flags,
        uint32_t                           interfaceIndex,
@@ -722,5 +722,6 @@ void DNSServiceReconfirmRecord
        (void)rrclass;                  // Unused
        (void)rdlen;                    // Unused
        (void)rdata;                    // Unused
+       return(kDNSServiceErr_Unsupported);
        }
 #endif
index b5582592127c18ebcddff69a11d2332397becce4..97732b0f2d4e6e2f9b5ba63e1b4f69c6484cc035 100755 (executable)
     Change History (most recent first):
 
 $Log: dnssd_clientstub.c,v $
+Revision 1.53  2006/09/07 04:43:12  herscher
+Fix compile error on Win32 platform by moving inclusion of syslog.h
+
+Revision 1.52  2006/08/15 23:04:21  mkrochma
+<rdar://problem/4090354> Client should be able to specify service name w/o callback
+
+Revision 1.51  2006/07/24 23:45:55  cheshire
+<rdar://problem/4605276> DNSServiceReconfirmRecord() should return error code
+
+Revision 1.50  2006/06/28 08:22:27  cheshire
+<rdar://problem/4605264> dnssd_clientstub.c needs to report unlink failures in syslog
+
+Revision 1.49  2006/06/28 07:58:59  cheshire
+Minor textual tidying
+
 Revision 1.48  2005/06/30 18:01:00  shersche
 <rdar://problem/4096913> Clients shouldn't wait ten seconds to connect to mDNSResponder
 
@@ -106,7 +121,7 @@ Revision 1.25  2004/07/26 05:54:02  shersche
 DNSServiceProcessResult() returns NoError if socket read returns EWOULDBLOCK
 
 Revision 1.24  2004/07/20 06:46:21  shersche
-<rdar://problem/3730123> fix endless loop in my_read() if recv returns 0
+<rdar://problem/3730123> fix endless loop in read_all() if recv returns 0
 Bug #: 3730123
 
 Revision 1.23  2004/06/29 00:48:38  cheshire
@@ -176,41 +191,44 @@ Update to APSL 2.0
 
 #include <errno.h>
 #include <stdlib.h>
+
+#include "dnssd_ipc.h"
+
 #if defined(_WIN32)
+
 #include <winsock2.h>
 #include <windows.h>
+
 #define sockaddr_mdns sockaddr_in
 #define AF_MDNS AF_INET
-extern BOOL
-IsSystemServiceDisabled();
-#else
-#include <sys/time.h>
-#include <sys/socket.h>
-#define sockaddr_mdns sockaddr_un
-#define AF_MDNS AF_LOCAL
-#endif
-
-#include "dnssd_ipc.h"
 
-#if defined(_WIN32)
-// disable warning: "'type cast' : from data pointer 'void *' to
-// function pointer"
+// disable warning: "'type cast' : from data pointer 'void *' to function pointer"
 #pragma warning(disable:4055)
 
-// disable warning: "nonstandard extension, function/data pointer
-// conversion in expression"
+// disable warning: "nonstandard extension, function/data pointer conversion in expression"
 #pragma warning(disable:4152)
 
+extern BOOL IsSystemServiceDisabled();
+
 #define sleep(X) Sleep((X) * 1000)
 
 static int g_initWinsock = 0;
-#endif
 
+#else
+
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <syslog.h>
+
+#define sockaddr_mdns sockaddr_un
+#define AF_MDNS AF_LOCAL
+
+#endif
 
 // <rdar://problem/4096913> Specifies how many times we'll try and connect to the
 // server.
 
-#define DNSSD_CLIENT_MAXTRIES  4
+#define DNSSD_CLIENT_MAXTRIES 4
 
 #define CTL_PATH_PREFIX "/tmp/dnssd_clippath."
 // error socket (if needed) is named "dnssd_clipath.[pid].xxx:n" where xxx are the
@@ -239,7 +257,7 @@ typedef struct _DNSRecordRef_t
 // exported functions
 
 // write len bytes.  return 0 on success, -1 on error
-static int my_write(dnssd_sock_t sd, char *buf, int len)
+static int write_all(dnssd_sock_t sd, char *buf, int len)
     {
     // Don't use "MSG_WAITALL"; it returns "Invalid argument" on some Linux versions; use an explicit while() loop instead.
     //if (send(sd, buf, len, MSG_WAITALL) != len)   return -1;
@@ -254,7 +272,7 @@ static int my_write(dnssd_sock_t sd, char *buf, int len)
     }
 
 // read len bytes.  return 0 on success, -1 on error
-static int my_read(dnssd_sock_t sd, char *buf, int len)
+static int read_all(dnssd_sock_t sd, char *buf, int len)
     {
     // Don't use "MSG_WAITALL"; it returns "Invalid argument" on some Linux versions; use an explicit while() loop instead.
     //if (recv(sd, buf, len, MSG_WAITALL) != len)  return -1;
@@ -290,7 +308,7 @@ static ipc_msg_hdr *create_hdr(uint32_t op, size_t *len, char **data_start, int
     if (!reuse_socket)
         {
 #if defined(USE_TCP_LOOPBACK)
-               *len += 2;      // Allocate space for two-byte port number
+               *len += 2;  // Allocate space for two-byte port number
 #else
                struct timeval time;
                if (gettimeofday(&time, NULL) < 0) return NULL;
@@ -318,7 +336,7 @@ static ipc_msg_hdr *create_hdr(uint32_t op, size_t *len, char **data_start, int
        // Put dummy data in for the port, since we don't know what
        // it is yet.  The data will get filled in before we
        // send the message. This happens in deliver_request().
-       if (!reuse_socket)      put_short(0, data_start);
+       if (!reuse_socket)  put_short(0, data_start);
 #else
     if (!reuse_socket)  put_string(ctrl_path, data_start);
 #endif
@@ -360,9 +378,9 @@ static DNSServiceRef connect_to_server(void)
        sdr->sockfd = socket(AF_DNSSD, SOCK_STREAM, 0);
        if (sdr->sockfd == dnssd_InvalidSocket) { free(sdr); return NULL; }
 #if defined(USE_TCP_LOOPBACK)
-       saddr.sin_family                =       AF_INET;
-       saddr.sin_addr.s_addr   =       inet_addr(MDNS_TCP_SERVERADDR);
-       saddr.sin_port                  =       htons(MDNS_TCP_SERVERPORT);
+       saddr.sin_family      = AF_INET;
+       saddr.sin_addr.s_addr = inet_addr(MDNS_TCP_SERVERADDR);
+       saddr.sin_port        = htons(MDNS_TCP_SERVERPORT);
 #else
        saddr.sun_family = AF_LOCAL;
        strcpy(saddr.sun_path, MDNS_UDS_SERVERPATH);
@@ -370,14 +388,14 @@ static DNSServiceRef connect_to_server(void)
        while (1)
                {
                int err = connect(sdr->sockfd, (struct sockaddr *) &saddr, sizeof(saddr));
-               if (!err) break;                // If we succeeded, return sdr
+               if (!err) break; // If we succeeded, return sdr
                // If we failed, then it may be because the daemon is still launching.
                // This can happen for processes that launch early in the boot process, while the
                // daemon is still coming up. Rather than fail here, we'll wait a bit and try again.
                // If, after four seconds, we still can't connect to the daemon,
                // then we give up and return a failure code.
                if (++NumTries < DNSSD_CLIENT_MAXTRIES)
-                       sleep(1);               // Sleep a bit, then try again
+                       sleep(1); // Sleep a bit, then try again
                else
                        {
                        dnssd_close(sdr->sockfd);
@@ -394,7 +412,7 @@ static DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reu
     ipc_msg_hdr *hdr = msg;
     uint32_t datalen = hdr->datalen;
     dnssd_sockaddr_t caddr, daddr;  // (client and daemon address structs)
-    char *data = (char *)msg + sizeof(ipc_msg_hdr);
+    char *const data = (char *)msg + sizeof(ipc_msg_hdr);
     dnssd_sock_t listenfd = dnssd_InvalidSocket, errsd = dnssd_InvalidSocket;
        int ret;
        dnssd_socklen_t len = (dnssd_socklen_t) sizeof(caddr);
@@ -420,17 +438,19 @@ static DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reu
                        if (getsockname(listenfd, (struct sockaddr*) &caddr, &len) < 0) goto cleanup;
                        listen(listenfd, 1);
                        port.s = caddr.sin_port;
-                       data[0] = port.b[0];    // don't switch the byte order, as the
-                       data[1] = port.b[1];    // daemon expects it in network byte order
+                       data[0] = port.b[0];  // don't switch the byte order, as the
+                       data[1] = port.b[1];  // daemon expects it in network byte order
                        }
 #else
                        {
                        mode_t mask = umask(0);
                        caddr.sun_family = AF_LOCAL;
-#ifndef NOT_HAVE_SA_LEN                // According to Stevens (section 3.2), there is no portable way to
-                                                               // determine whether sa_len is defined on a particular platform.
+// According to Stevens (section 3.2), there is no portable way to
+// determine whether sa_len is defined on a particular platform.
+#ifndef NOT_HAVE_SA_LEN
                        caddr.sun_len = sizeof(struct sockaddr_un);
 #endif
+                       //syslog(LOG_WARNING, "deliver_request: creating UDS: %s\n", data);
                        strcpy(caddr.sun_path, data);
                        ret = bind(listenfd, (struct sockaddr *)&caddr, sizeof(caddr));
                        umask(mask);
@@ -441,7 +461,9 @@ static DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reu
                }
 
        ConvertHeaderBytes(hdr);
-    if (my_write(sdr->sockfd, msg, datalen + sizeof(ipc_msg_hdr)) < 0)
+       //syslog(LOG_WARNING, "deliver_request writing %ld bytes\n", datalen + sizeof(ipc_msg_hdr));
+       //syslog(LOG_WARNING, "deliver_request name is %s\n", (char *)msg + sizeof(ipc_msg_hdr));
+    if (write_all(sdr->sockfd, msg, datalen + sizeof(ipc_msg_hdr)) < 0)
         goto cleanup;
     free(msg);
     msg = NULL;
@@ -449,22 +471,32 @@ static DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reu
     if (reuse_sd) errsd = sdr->sockfd;
     else
         {
+               //syslog(LOG_WARNING, "deliver_request: accept\n");
         len = sizeof(daddr);
         errsd = accept(listenfd, (struct sockaddr *)&daddr, &len);
+               //syslog(LOG_WARNING, "deliver_request: accept returned %d\n", errsd);
         if (errsd < 0)  goto cleanup;
         }
 
-    if (my_read(errsd, (char*)&err, (int)sizeof(err)) < 0)
+    if (read_all(errsd, (char*)&err, (int)sizeof(err)) < 0)
         err = kDNSServiceErr_Unknown;
     else
        err = ntohl(err);
 
+       //syslog(LOG_WARNING, "deliver_request: retrieved error code %d\n", err);
+
 cleanup:
-    if (!reuse_sd && listenfd > 0) dnssd_close(listenfd);
-    if (!reuse_sd && errsd > 0) dnssd_close(errsd);
+       if (!reuse_sd)
+               {
+               if (listenfd > 0) dnssd_close(listenfd);
+               if (errsd    > 0) dnssd_close(errsd);
 #if !defined(USE_TCP_LOOPBACK)
-    if (!reuse_sd && data) unlink(data);
+               // syslog(LOG_WARNING, "deliver_request: removing UDS: %s\n", data);
+               if (unlink(data) != 0)
+                       syslog(LOG_WARNING, "WARNING: unlink(\"%s\") failed errno %d (%s)", data, errno, strerror(errno));
+               // else syslog(LOG_WARNING, "deliver_request: removed UDS: %s\n", data);
 #endif
+               }
     if (msg) free(msg);
     return err;
     }
@@ -485,7 +517,7 @@ DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdRef)
     if (!sdRef || sdRef->sockfd < 0 || !sdRef->process_reply)
         return kDNSServiceErr_BadReference;
 
-    if (my_read(sdRef->sockfd, (void *)&hdr, sizeof(hdr)) < 0)
+    if (read_all(sdRef->sockfd, (void *)&hdr, sizeof(hdr)) < 0)
                // return NoError on EWOULDBLOCK. This will handle the case
                // where a non-blocking socket is told there is data, but
                // it was a false positive.
@@ -495,7 +527,7 @@ DNSServiceErrorType DNSSD_API DNSServiceProcessResult(DNSServiceRef sdRef)
         return kDNSServiceErr_Incompatible;
     data = malloc(hdr.datalen);
     if (!data) return kDNSServiceErr_NoMemory;
-    if (my_read(sdRef->sockfd, data, hdr.datalen) < 0)
+    if (read_all(sdRef->sockfd, data, hdr.datalen) < 0)
         return kDNSServiceErr_Unknown;
     sdRef->process_reply(sdRef, &hdr, data);
     free(data);
@@ -518,7 +550,7 @@ static void handle_resolve_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *d
     union { uint16_t s; u_char b[2]; } port;
     uint32_t ifi;
     DNSServiceErrorType err;
-    char *txtrecord;
+    unsigned char *txtrecord;
     int str_error = 0;
     (void)hdr;                 //unused
 
@@ -530,7 +562,7 @@ static void handle_resolve_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *d
     port.b[0] = *data++;
     port.b[1] = *data++;
     txtlen = get_short(&data);
-    txtrecord = get_rdata(&data, txtlen);
+    txtrecord = (unsigned char *)get_rdata(&data, txtlen);
 
        if (!err && str_error) err = kDNSServiceErr_Unknown;
     ((DNSServiceResolveReply)sdr->app_callback)(sdr, flags, ifi, err, fullname, target, port.s, txtlen, txtrecord, sdr->app_context);
@@ -626,16 +658,16 @@ static void handle_query_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *dat
     }
 
 DNSServiceErrorType DNSSD_API DNSServiceQueryRecord
-(
DNSServiceRef                         *sdRef,
DNSServiceFlags                        flags,
uint32_t                              interfaceIndex,
const char                            *name,
uint16_t                              rrtype,
uint16_t                              rrclass,
DNSServiceQueryRecordReply            callBack,
void                                  *context
- )
+    (
   DNSServiceRef              *sdRef,
   DNSServiceFlags             flags,
   uint32_t                    interfaceIndex,
   const char                 *name,
   uint16_t                    rrtype,
   uint16_t                    rrclass,
   DNSServiceQueryRecordReply  callBack,
   void                       *context
   )
     {
     char *msg = NULL, *ptr;
     size_t len;
@@ -707,15 +739,15 @@ static void handle_browse_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *da
     }
 
 DNSServiceErrorType DNSSD_API DNSServiceBrowse
-(
DNSServiceRef                      *sdRef,
DNSServiceFlags              flags,
uint32_t                     interfaceIndex,
const char                         *regtype,
const char                         *domain,
DNSServiceBrowseReply        callBack,
void                               *context
- )
+       (
      DNSServiceRef         *sdRef,
      DNSServiceFlags        flags,
      uint32_t               interfaceIndex,
      const char            *regtype,
      const char            *domain,
      DNSServiceBrowseReply  callBack,
      void                  *context
      )
     {
     char *msg = NULL, *ptr;
     size_t len;
@@ -763,10 +795,10 @@ error:
     }
 
 DNSServiceErrorType DNSSD_API DNSServiceSetDefaultDomainForUser
-(
DNSServiceFlags                    flags,
const char                         *domain
- )
+       (
      DNSServiceFlags  flags,
      const char      *domain
      )
     {
     DNSServiceRef sdr;
     DNSServiceErrorType err;
@@ -780,7 +812,7 @@ DNSServiceErrorType DNSSD_API DNSServiceSetDefaultDomainForUser
 
     sdr = connect_to_server();
     if (!sdr) { free(hdr); return kDNSServiceErr_Unknown; }
-    err = deliver_request((char *)hdr, sdr, 1);                // deliver_request frees the message for us
+    err = deliver_request((char *)hdr, sdr, 1); // deliver_request frees the message for us
        DNSServiceRefDeallocate(sdr);
        return err;
     }
@@ -841,8 +873,8 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister
     if (!name[0]  && (flags & kDNSServiceFlagsNoAutoRename))
         return kDNSServiceErr_BadParam;
 
-    // no callback must have auto-name
-    if (!callBack && name[0]) return kDNSServiceErr_BadParam;
+    // no callback must have auto-rename
+    if (!callBack && (flags & kDNSServiceFlagsNoAutoRename)) return kDNSServiceErr_BadParam;
 
     len = sizeof(DNSServiceFlags);
     len += sizeof(uint32_t);  // interfaceIndex
@@ -906,13 +938,13 @@ static void handle_enumeration_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, cha
     }
 
 DNSServiceErrorType DNSSD_API DNSServiceEnumerateDomains
-(
DNSServiceRef                    *sdRef,
- DNSServiceFlags            flags,
- uint32_t                   interfaceIndex,
- DNSServiceDomainEnumReply  callBack,
void                             *context
- )
+       (
      DNSServiceRef             *sdRef,
      DNSServiceFlags            flags,
      uint32_t                   interfaceIndex,
      DNSServiceDomainEnumReply  callBack,
      void                      *context
      )
     {
     char *msg = NULL, *ptr;
     size_t len;
@@ -989,20 +1021,20 @@ DNSServiceErrorType DNSSD_API DNSServiceCreateConnection(DNSServiceRef *sdRef)
     }
 
 DNSServiceErrorType DNSSD_API DNSServiceRegisterRecord
-(
DNSServiceRef                 sdRef,
DNSRecordRef                          *RecordRef,
DNSServiceFlags               flags,
uint32_t                              interfaceIndex,
const char                            *fullname,
uint16_t                              rrtype,
uint16_t                              rrclass,
uint16_t                              rdlen,
const void                            *rdata,
uint32_t                              ttl,
DNSServiceRegisterRecordReply         callBack,
void                                  *context
- )
+    (
   DNSServiceRef                  sdRef,
   DNSRecordRef                  *RecordRef,
   DNSServiceFlags                flags,
   uint32_t                       interfaceIndex,
   const char                    *fullname,
   uint16_t                       rrtype,
   uint16_t                       rrclass,
   uint16_t                       rdlen,
   const void                    *rdata,
   uint32_t                       ttl,
   DNSServiceRegisterRecordReply  callBack,
   void                          *context
   )
     {
     char *msg = NULL, *ptr;
     size_t len;
@@ -1057,13 +1089,13 @@ error:
 //sdRef returned by DNSServiceRegister()
 DNSServiceErrorType DNSSD_API DNSServiceAddRecord
     (
-    DNSServiceRef                      sdRef,
-    DNSRecordRef                       *RecordRef,
-    DNSServiceFlags               flags,
-    uint16_t                   rrtype,
-    uint16_t                   rdlen,
-    const void                         *rdata,
-    uint32_t                   ttl
+    DNSServiceRef    sdRef,
+    DNSRecordRef    *RecordRef,
+    DNSServiceFlags  flags,
+    uint16_t         rrtype,
+    uint16_t         rdlen,
+    const void      *rdata,
+    uint32_t         ttl
     )
     {
     ipc_msg_hdr *hdr;
@@ -1109,12 +1141,12 @@ error:
 //DNSRecordRef returned by DNSServiceRegisterRecord or DNSServiceAddRecord
 DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord
     (
-    DNSServiceRef              sdRef,
-    DNSRecordRef                       RecordRef,
-    DNSServiceFlags               flags,
-    uint16_t                   rdlen,
-    const void                         *rdata,
-    uint32_t                   ttl
+    DNSServiceRef    sdRef,
+    DNSRecordRef     RecordRef,
+    DNSServiceFlags  flags,
+    uint16_t         rdlen,
+    const void      *rdata,
+    uint32_t         ttl
     )
     {
     ipc_msg_hdr *hdr;
@@ -1139,11 +1171,11 @@ DNSServiceErrorType DNSSD_API DNSServiceUpdateRecord
     }
 
 DNSServiceErrorType DNSSD_API DNSServiceRemoveRecord
-(
DNSServiceRef            sdRef,
DNSRecordRef                  RecordRef,
DNSServiceFlags          flags
- )
+       (
      DNSServiceRef    sdRef,
      DNSRecordRef     RecordRef,
      DNSServiceFlags  flags
      )
     {
     ipc_msg_hdr *hdr;
     size_t len = 0;
@@ -1163,16 +1195,16 @@ DNSServiceErrorType DNSSD_API DNSServiceRemoveRecord
     return err;
     }
 
-void DNSSD_API DNSServiceReconfirmRecord
-(
DNSServiceFlags              flags,
uint32_t                     interfaceIndex,
const char                         *fullname,
uint16_t                     rrtype,
uint16_t                     rrclass,
uint16_t                     rdlen,
const void                         *rdata
- )
+DNSServiceErrorType DNSSD_API DNSServiceReconfirmRecord
+       (
      DNSServiceFlags  flags,
      uint32_t         interfaceIndex,
      const char      *fullname,
      uint16_t         rrtype,
      uint16_t         rrclass,
      uint16_t         rdlen,
      const void      *rdata
      )
     {
     char *ptr;
     size_t len;
@@ -1185,9 +1217,9 @@ void DNSSD_API DNSServiceReconfirmRecord
     len += 3 * sizeof(uint16_t);
     len += rdlen;
     tmp = connect_to_server();
-    if (!tmp) return;
+    if (!tmp) return(kDNSServiceErr_Unknown);
     hdr = create_hdr(reconfirm_record_request, &len, &ptr, 1);
-    if (!hdr) return;
+    if (!hdr) return(kDNSServiceErr_Unknown);
 
     put_flags(flags, &ptr);
     put_long(interfaceIndex, &ptr);
@@ -1197,8 +1229,9 @@ void DNSSD_API DNSServiceReconfirmRecord
     put_short(rdlen, &ptr);
     put_rdata(rdlen, rdata, &ptr);
        ConvertHeaderBytes(hdr);
-    my_write(tmp->sockfd, (char *)hdr, (int) len);
+    write_all(tmp->sockfd, (char *)hdr, (int) len);
     free(hdr);
     DNSServiceRefDeallocate(tmp);
+    return(kDNSServiceErr_NoError);
     }
 
index 6a0236df98a2c982bdc18d7ba2aa3aa815b6659a..460cfa93b9e1169ad95d9727a03000dff10b95e1 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
@@ -27,6 +28,9 @@
        Change History (most recent first):
 
 $Log: dnssd_ipc.c,v $
+Revision 1.16  2006/08/14 23:05:53  cheshire
+Added "tab-width" emacs header line
+
 Revision 1.15  2005/01/27 22:57:56  cheshire
 Fix compile errors on gcc4
 
index 32d7872e1c420ef71f4b427acd3c2fdb439514ce..53d324f966b5350fe43e11a1a05cee327940036d 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-2004, Apple Computer, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
     Change History (most recent first):
 
 $Log: dnssd_ipc.h,v $
+Revision 1.23  2006/08/14 23:05:53  cheshire
+Added "tab-width" emacs header line
+
+Revision 1.22  2006/06/28 08:56:26  cheshire
+Added "_op" to the end of the operation code enum values,
+to differentiate them from the routines with the same names
+
 Revision 1.21  2005/09/29 06:38:13  herscher
 Remove #define MSG_WAITALL on Windows.  We don't use this macro anymore, and it's presence causes warnings to be emitted when compiling against the latest Microsoft Platform SDK.
 
@@ -173,12 +181,12 @@ typedef enum
 
 typedef enum
     {
-    enumeration_reply = 64,
-    reg_service_reply,
-    browse_reply,
-    resolve_reply,
-    query_reply,
-    reg_record_reply
+    enumeration_reply_op = 64,
+    reg_service_reply_op,
+    browse_reply_op,
+    resolve_reply_op,
+    query_reply_op,
+    reg_record_reply_op
     } reply_op_t;
 
 typedef struct ipc_msg_hdr_struct ipc_msg_hdr;
index b02dd17c0ba28b771d64f2076d89a071f1c2f3ab..38ae2db0a1c1e972e568da1b8bb57be53e350e3a 100644 (file)
@@ -1,25 +1,23 @@
+.\" -*- tab-width: 4 -*-
+.\" 
 .\" Copyright (c) 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@
 .\"
 .\" $Log: mDNS.1,v $
+.\" Revision 1.8  2006/08/14 23:24:56  cheshire
+.\" Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+.\"
 .\" Revision 1.7  2005/02/16 02:29:32  cheshire
 .\" Update terminology
 .\"
index fcf16ffbbb9fe3f92b2d7f3a400c636a806bbc85..d7b19f0b7a711c7c56036f36d089293caf65bbb8 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003 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@
 
        File:           mDNSDebug.c
 
@@ -29,6 +23,9 @@
     Change History (most recent first):
 
 $Log: mDNSDebug.c,v $
+Revision 1.7  2006/08/14 23:24:56  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.6  2005/01/27 22:57:56  cheshire
 Fix compile errors on gcc4
 
index 352ad6de970edcdc30cf652ad434969322f92d36..11f81689166e32d8138bb8a422c31ebc1723ff29 100644 (file)
@@ -1,25 +1,23 @@
+.\" -*- tab-width: 4 -*-
+.\" 
 .\" Copyright (c) 2003-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@
 .\"
 .\" $Log: mDNSResponder.8,v $
+.\" Revision 1.7  2006/08/14 23:24:56  cheshire
+.\" Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+.\"
 .\" Revision 1.6  2005/02/10 22:35:28  cheshire
 .\" <rdar://problem/3727944> Update name
 .\"
index 9ba0ccc53e57e495cd17491680dc57941f7efcc2..67302620a6850e43fc0cab2f0fdc45ea30604c09 100644 (file)
@@ -1,29 +1,67 @@
 /* -*- Mode: C; tab-width: 4 -*-
  *
- * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003-2006 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: uds_daemon.c,v $
+Revision 1.201.2.1  2006/08/29 06:24:36  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.201  2006/06/29 03:02:47  cheshire
+<rdar://problem/4607042> mDNSResponder NXDOMAIN and CNAME support
+
+Revision 1.200  2006/06/28 08:56:26  cheshire
+Added "_op" to the end of the operation code enum values,
+to differentiate them from the routines with the same names
+
+Revision 1.199  2006/06/28 08:53:39  cheshire
+Added (commented out) debugging messages
+
+Revision 1.198  2006/06/27 20:16:07  cheshire
+Fix code layout
+
+Revision 1.197  2006/05/18 01:32:35  cheshire
+<rdar://problem/4472706> iChat: Lost connection with Bonjour
+(mDNSResponder insufficiently defensive against malformed browsing PTR responses)
+
+Revision 1.196  2006/05/05 07:07:13  cheshire
+<rdar://problem/4538206> mDNSResponder fails when UDS reads deliver partial data
+
+Revision 1.195  2006/04/25 20:56:28  mkrochma
+Added comment about previous checkin
+
+Revision 1.194  2006/04/25 18:29:36  mkrochma
+Workaround for warning: unused variable 'status' when building mDNSPosix
+
+Revision 1.193  2006/03/19 17:14:38  cheshire
+<rdar://problem/4483117> Need faster purging of stale records
+read_rr_from_ipc_msg was not setting namehash and rdatahash
+
+Revision 1.192  2006/03/18 20:58:32  cheshire
+Misplaced curly brace
+
+Revision 1.191  2006/03/10 22:19:43  cheshire
+Update debugging message in resolve_result_callback() to indicate whether event is ADD or RMV
+
+Revision 1.190  2006/03/10 21:56:12  cheshire
+<rdar://problem/4111464> After record update, old record sometimes remains in cache
+When service TXT and SRV record both change, clients with active resolve calls get *two* callbacks, one
+when the TXT data changes, and then immediately afterwards a second callback with the new port number
+This change suppresses the first unneccessary (and confusing) callback
+
 Revision 1.189  2006/01/06 00:56:31  cheshire
 <rdar://problem/4400573> Should remove PID file on exit
 
@@ -565,7 +603,7 @@ Revision 1.25  2003/10/22 23:37:49  ksekar
 <rdar://problem/3459141>: crash/hang in abort_client
 
 Revision 1.24  2003/10/21 20:59:40  ksekar
-<rdar://problem/3335216>: handle blocked clients moreefficiently
+<rdar://problem/3335216>: handle blocked clients more efficiently
 
 Revision 1.23  2003/09/23 02:12:43  cheshire
 Also include port number in list of services registered via new UDS API
@@ -814,8 +852,7 @@ typedef struct
     // const ResourceRecord *srv;
     mDNSBool   srv;
     mDNSBool   txt;
-    domainname target;
-    mDNSIPPort port;
+    rdataSRV   srvdata;
     mDNSu16    txtlen;
     mDNSu8     txtdata[AbsoluteMaxDNSMessageData];
     } resolve_termination_t;
@@ -853,14 +890,11 @@ mDNSlocal void question_result_callback(mDNS *const m, DNSQuestion *question, co
 mDNSlocal void question_termination_callback(void *context);
 mDNSlocal void handle_browse_request(request_state *request);
 mDNSlocal void browse_termination_callback(void *context);
-mDNSlocal void browse_result_callback(mDNS *const m, DNSQuestion *question, const ResourceRecord *const answer, mDNSBool AddRecord);
 mDNSlocal void handle_regservice_request(request_state *request);
 mDNSlocal void regservice_termination_callback(void *context);
-mDNSlocal void process_service_registration(ServiceRecordSet *const srs, mDNSBool SuppressError);
 mDNSlocal void regservice_callback(mDNS *const m, ServiceRecordSet *const srs, mStatus result);
 mDNSlocal mStatus handle_add_request(request_state *rstate);
 mDNSlocal mStatus handle_update_request(request_state *rstate);
-mDNSlocal mStatus gen_rr_response(domainname *servicename, mDNSInterfaceID id, request_state *request, reply_state **rep);
 mDNSlocal void append_reply(request_state *req, reply_state *rep);
 mDNSlocal int build_domainname_from_strings(domainname *srv, char *name, char *regtype, char *domain);
 mDNSlocal void enum_termination_callback(void *context);
@@ -1142,6 +1176,7 @@ mDNSexport void udsserver_info(mDNS *const m)
 
     LogMsgNoIdent("Timenow 0x%08lX (%ld)", (mDNSu32)now, now);
 
+    LogMsgNoIdent("Slt Q   TTL U Type  if     len rdata");
        for (slot = 0; slot < CACHE_HASH_SLOTS; slot++)
                for(cg = m->rrcache_hash[slot]; cg; cg=cg->next)
                        {
@@ -1151,10 +1186,14 @@ mDNSexport void udsserver_info(mDNS *const m)
                                mDNSs32 remain = rr->resrec.rroriginalttl - (now - rr->TimeRcvd) / mDNSPlatformOneSecond;
                                CacheUsed++;
                                if (rr->CRActiveQuestion) CacheActive++;
-                               LogMsgNoIdent("%s%6ld %s%-6s%-6s%s",
-                                       rr->CRActiveQuestion ? "*" : " ", remain,
-                                       (rr->resrec.RecordType & kDNSRecordTypePacketUniqueMask) ? "-" : " ", DNSTypeName(rr->resrec.rrtype),
-                                       ((NetworkInterfaceInfo *)rr->resrec.InterfaceID)->ifname, CRDisplayString(m, rr));
+                               LogMsgNoIdent("%3d %s%6ld %s %-6s%-6s%s",
+                                       slot,
+                                       rr->CRActiveQuestion ? "*" : " ",
+                                       remain,
+                                       (rr->resrec.RecordType & kDNSRecordTypePacketUniqueMask) ? "-" : " ",
+                                       DNSTypeName(rr->resrec.rrtype),
+                                       ((NetworkInterfaceInfo *)rr->resrec.InterfaceID)->ifname,
+                                       CRDisplayString(m, rr));
                                usleep(1000);   // Limit rate a little so we don't flood syslog too fast
                                }
                        }
@@ -1334,6 +1373,8 @@ mDNSlocal void request_callback(void *info)
                        return;
                        }
 
+               //LogOperation("request_callback: Opened dedicated errfd %d", errfd);
+
                #if defined(USE_TCP_LOOPBACK)
                        {
                        mDNSOpaque16 port;
@@ -1353,8 +1394,10 @@ mDNSlocal void request_callback(void *info)
                        strcpy(cliaddr.sun_path, ctrl_path);
                        }
                #endif
+               //LogOperation("request_callback: Connecting to “%s”", cliaddr.sun_path);
                if (connect(errfd, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0)
                        {
+                       //LogOperation("request_callback: Couldn't connect to “%s”", cliaddr.sun_path);
                        my_perror("ERROR: connect");
                        abort_request(rstate);
                        unlink_request(rstate);
@@ -1381,6 +1424,7 @@ mDNSlocal void request_callback(void *info)
                        default: LogMsg("%3d: ERROR: udsserver_recv_request - unsupported request type: %d", rstate->sd, rstate->hdr.op);
                        }
 
+               //LogOperation("request_callback: Returning error code %d on socket %d", err, errfd);
                err = dnssd_htonl(err);
                nwritten = send(errfd, (dnssd_sockbuf_t) &err, sizeof(err), 0);
                // On a freshly-created Unix Domain Socket, the kernel should *never* fail to buffer a four-byte write for us.
@@ -1388,7 +1432,9 @@ mDNSlocal void request_callback(void *info)
                if (nwritten < (int)sizeof(err))
                        LogMsg("ERROR: failed to write error response back to caller: %d %d %s",
                                nwritten, dnssd_errno(), dnssd_strerror(dnssd_errno()));
+               //else LogOperation("request_callback: Returned  error code %d on socket %d", err, errfd);
                dnssd_close(errfd);
+               //LogOperation("request_callback: Closed errfd %d", errfd);
                reset_connected_rstate(rstate);         // Reset ready to accept the next request on this pipe
                }
        else
@@ -1459,6 +1505,7 @@ mDNSlocal void handle_query_request(request_state *rstate)
     q->LongLived        = (flags & kDNSServiceFlagsLongLivedQuery) != 0;
     q->ExpectUnique     = mDNSfalse;
     q->ForceMCast       = (flags & kDNSServiceFlagsForceMulticast) != 0;
+    q->ReturnCNAME      = (flags & kDNSServiceFlagsReturnCNAME) != 0;
     q->QuestionCallback = question_result_callback;
     q->QuestionContext  = rstate;
 
@@ -1603,7 +1650,7 @@ mDNSlocal void resolve_termination_callback(void *context)
     }
 
 mDNSlocal void resolve_result_callback(mDNS *const m, DNSQuestion *question, const ResourceRecord *const answer, mDNSBool AddRecord)
-{
+       {
     size_t len = 0;
     char fullname[MAX_ESCAPED_DOMAIN_NAME], target[MAX_ESCAPED_DOMAIN_NAME];
     char *data;
@@ -1613,7 +1660,8 @@ mDNSlocal void resolve_result_callback(mDNS *const m, DNSQuestion *question, con
     resolve_termination_t *res = rs->termination_context;
     (void)m; // Unused
 
-       LogOperation("%3d: DNSServiceResolve(%##s, %s) RESULT %s", rs->sd, question->qname.c, DNSTypeName(question->qtype), RRDisplayString(m, answer));
+       LogOperation("%3d: DNSServiceResolve(%##s, %s) %s %s",
+               rs->sd, question->qname.c, DNSTypeName(question->qtype), AddRecord ? "ADD" : "RMV", RRDisplayString(m, answer));
     
     // This code used to do this trick of just keeping a copy of the pointer to
     // the answer record in the cache, but the unicast query code doesn't currently
@@ -1621,18 +1669,24 @@ mDNSlocal void resolve_result_callback(mDNS *const m, DNSQuestion *question, con
     
        if (!AddRecord)
                {
-               // if (answer->rrtype == kDNSType_TXT && res->txt == answer) res->txt = mDNSNULL;
+               // After unicast query code is updated to store its records in the common cache, use this...
                // if (answer->rrtype == kDNSType_SRV && res->srv == answer) res->srv = mDNSNULL;
+               // if (answer->rrtype == kDNSType_TXT && res->txt == answer) res->txt = mDNSNULL;
+               // intead of this...
+               if (answer->rrtype == kDNSType_SRV && res->srv &&                                    SameRDataBody(answer, (RDataBody *)&res->srvdata))
+                       res->srv = mDNSfalse;
+               if (answer->rrtype == kDNSType_TXT && res->txt && answer->rdlength == res->txtlen && SameRDataBody(answer, (RDataBody *)&res->txtdata))
+                       res->txt = mDNSfalse;
                return;
                }
 
-    // if (answer->rrtype == kDNSType_TXT) res->txt = answer;
+       // After unicast query code is updated to store its records in the common cache, use this...
     // if (answer->rrtype == kDNSType_SRV) res->srv = answer;
-
+    // if (answer->rrtype == kDNSType_TXT) res->txt = answer;
+       // intead of this...
     if (answer->rrtype == kDNSType_SRV)
        {
-       AssignDomainName(&res->target, &answer->rdata->u.srv.target);
-       res->port = answer->rdata->u.srv.port;
+       res->srvdata = answer->rdata->u.srv;
        res->srv = mDNStrue;
        }
     if (answer->rrtype == kDNSType_TXT)
@@ -1646,7 +1700,7 @@ mDNSlocal void resolve_result_callback(mDNS *const m, DNSQuestion *question, con
     if (!res->txt || !res->srv) return;                // only deliver result to client if we have both answers
     
     ConvertDomainNameToCString(answer->name, fullname);
-    ConvertDomainNameToCString(&res->target, target);
+    ConvertDomainNameToCString(&res->srvdata.target, target);
 
     // calculate reply length
     len += sizeof(DNSServiceFlags);
@@ -1658,7 +1712,7 @@ mDNSlocal void resolve_result_callback(mDNS *const m, DNSQuestion *question, con
     len += res->txtlen;
     
     // allocate/init reply header
-    rep =  create_reply(resolve_reply, len, rs);
+    rep =  create_reply(resolve_reply_op, len, rs);
     rep->rhdr->flags = dnssd_htonl(0);
     rep->rhdr->ifi   = dnssd_htonl(mDNSPlatformInterfaceIndexfromInterfaceID(gmDNS, answer->InterfaceID));
     rep->rhdr->error = dnssd_htonl(kDNSServiceErr_NoError);
@@ -1668,8 +1722,8 @@ mDNSlocal void resolve_result_callback(mDNS *const m, DNSQuestion *question, con
     // write reply data to message
     put_string(fullname, &data);
     put_string(target, &data);
-       *data++ = res->port.b[0];
-       *data++ = res->port.b[1];
+       *data++ = res->srvdata.port.b[0];
+       *data++ = res->srvdata.port.b[1];
     put_short(res->txtlen, &data);
     put_rdata(res->txtlen, res->txtdata, &data);
     
@@ -1697,6 +1751,12 @@ mDNSlocal void question_result_callback(mDNS *const m, DNSQuestion *question, co
        LogOperation("%3d: DNSServiceQueryRecord(%##s, %s) RESULT %s", req->sd, question->qname.c, DNSTypeName(question->qtype), RRDisplayString(m, answer));
     //mDNS_StopQuery(m, question);
     
+       if (answer->rdlength == 0)
+               {
+               deliver_async_error(req, query_reply_op, kDNSServiceErr_NoSuchRecord);
+               return;
+               }
+    
     // calculate reply data length
     len = sizeof(DNSServiceFlags);
     len += 2 * sizeof(uint32_t);  // if index + ttl
@@ -1706,10 +1766,10 @@ mDNSlocal void question_result_callback(mDNS *const m, DNSQuestion *question, co
     ConvertDomainNameToCString(answer->name, name);
     len += strlen(name) + 1;
     
-    rep =  create_reply(query_reply, len, req);
+    rep =  create_reply(query_reply_op, len, req);
 
     rep->rhdr->flags = dnssd_htonl(AddRecord ? kDNSServiceFlagsAdd : 0);
-    rep->rhdr->ifi  dnssd_htonl(mDNSPlatformInterfaceIndexfromInterfaceID(gmDNS, answer->InterfaceID));
+    rep->rhdr->ifi   = dnssd_htonl(mDNSPlatformInterfaceIndexfromInterfaceID(gmDNS, answer->InterfaceID));
     rep->rhdr->error = dnssd_htonl(kDNSServiceErr_NoError);
 
     data = rep->sdata;
@@ -1901,11 +1961,80 @@ mDNSlocal void handle_setdomain_request(request_state *request)
     unlink_request(request);
     }
 
+// Generates a response message giving name, type, domain, plus interface index,
+// suitable for a browse result or service registration result.
+// On successful completion rep is set to point to a malloc'd reply_state struct
+mDNSlocal mStatus GenerateNTDResponse(domainname *servicename, mDNSInterfaceID id, request_state *request, reply_state **rep)
+       {
+       domainlabel name;
+       domainname type, dom;
+       *rep = NULL;
+       if (!DeconstructServiceName(servicename, &name, &type, &dom))
+               return kDNSServiceErr_Invalid;
+       else
+               {
+               char namestr[MAX_DOMAIN_LABEL+1];
+               char typestr[MAX_ESCAPED_DOMAIN_NAME];
+               char domstr [MAX_ESCAPED_DOMAIN_NAME];
+               int len;
+               char *data;
+       
+               ConvertDomainLabelToCString_unescaped(&name, namestr);
+               ConvertDomainNameToCString(&type, typestr);
+               ConvertDomainNameToCString(&dom, domstr);
+               
+               // Calculate reply data length
+               len = sizeof(DNSServiceFlags);
+               len += sizeof(uint32_t);  // if index
+               len += sizeof(DNSServiceErrorType);
+               len += (int) (strlen(namestr) + 1);
+               len += (int) (strlen(typestr) + 1);
+               len += (int) (strlen(domstr) + 1);
+               
+               // Build reply header
+               *rep = create_reply(query_reply_op, len, request);
+               (*rep)->rhdr->flags = dnssd_htonl(0);
+               (*rep)->rhdr->ifi   = dnssd_htonl(mDNSPlatformInterfaceIndexfromInterfaceID(gmDNS, id));
+               (*rep)->rhdr->error = dnssd_htonl(kDNSServiceErr_NoError);
+               
+               // Build reply body
+               data = (*rep)->sdata;
+               put_string(namestr, &data);
+               put_string(typestr, &data);
+               put_string(domstr, &data);
+
+               return mStatus_NoError;
+               }
+       }
+
+mDNSlocal void FoundInstance(mDNS *const m, DNSQuestion *question, const ResourceRecord *const answer, mDNSBool AddRecord)
+       {
+       request_state *req = question->QuestionContext;
+       reply_state *rep;
+       (void)m; // Unused
+
+       if (answer->rrtype != kDNSType_PTR)
+               { LogMsg("%3d: FoundInstance: Should not be called with rrtype %d (not a PTR record)", req->sd, answer->rrtype); return; }
+
+       if (GenerateNTDResponse(&answer->rdata->u.name, answer->InterfaceID, req, &rep) != mStatus_NoError)
+               {
+               LogMsg("%3d: FoundInstance: %##s PTR %##s received from network is not valid DNS-SD service pointer",
+                       req->sd, answer->name->c, answer->rdata->u.name.c);
+               return;
+               }
+
+       LogOperation("%3d: DNSServiceBrowse(%##s, %s) RESULT %s %s",
+               req->sd, question->qname.c, DNSTypeName(question->qtype), AddRecord ? "Add" : "Rmv", RRDisplayString(m, answer));
+
+       if (AddRecord) rep->rhdr->flags |= dnssd_htonl(kDNSServiceFlagsAdd);
+       append_reply(req, rep);
+       }
+
 mDNSlocal mStatus add_domain_to_browser(browser_info_t *info, const domainname *d)
        {
        browser_t *b, *p;
        mStatus err;
-   
+
        for (p = info->browsers; p; p = p->next)
                {
                if (SameDomainName(&p->domain, d))
@@ -1915,7 +2044,7 @@ mDNSlocal mStatus add_domain_to_browser(browser_info_t *info, const domainname *
        b = mallocL("browser_t", sizeof(*b));
        if (!b) return mStatus_NoMemoryErr;
        AssignDomainName(&b->domain, d);
-       err = mDNS_StartBrowse(gmDNS, &b->q, &info->regtype, d, info->interface_id, info->ForceMCast, browse_result_callback, info->rstate);
+       err = mDNS_StartBrowse(gmDNS, &b->q, &info->regtype, d, info->interface_id, info->ForceMCast, FoundInstance, info->rstate);
        if (err)
                {
                LogMsg("mDNS_StartBrowse returned %d for type %##s domain %##s", err, info->regtype.c, d->c);
@@ -2031,30 +2160,6 @@ error:
     unlink_request(request);
     }
 
-mDNSlocal void browse_result_callback(mDNS *const m, DNSQuestion *question, const ResourceRecord *const answer, mDNSBool AddRecord)
-    {
-    request_state *req = question->QuestionContext;
-    reply_state *rep;
-    mStatus err;
-    (void)m; // Unused
-       LogOperation("%3d: DNSServiceBrowse(%##s, %s) RESULT %s %s",
-               req->sd, question->qname.c, DNSTypeName(question->qtype), AddRecord ? "Add" : "Rmv", RRDisplayString(m, answer));
-
-    err = gen_rr_response(&answer->rdata->u.name, answer->InterfaceID, req, &rep);
-    if (err)
-        {
-        if (deliver_async_error(req, browse_reply, err) < 0)
-            {
-            abort_request(req);
-            unlink_request(req);
-            }
-        return;
-        }
-    if (AddRecord) rep->rhdr->flags |= dnssd_htonl(kDNSServiceFlagsAdd);  // non-zero TTL indicates add
-    append_reply(req, rep);
-    return;
-    }
-
 mDNSlocal void browse_termination_callback(void *context)
     {
        browser_info_t *info = context;
@@ -2096,8 +2201,10 @@ mDNSexport void udsserver_default_browse_domain_changed(const domainname *d, mDN
                                        *ptr = (*ptr)->next;
                                        if (remove->q.LongLived)
                                                {
-                                               // give goodbyes for known answers.
-                                               // note that since events are sent to client via udsserver_idle(), we don't need to worry about the question being cancelled mid-loop
+                                               // Give goodbyes for known answers.
+                                               // Note that this a special case where we know that the QuestionCallback function is our own
+                                               // code (it's FoundInstance), and that callback routine doesn't ever cancel its operation, so we
+                                               // don't need to guard against the question being cancelled mid-loop the way the mDNSCore routines do.
                                                CacheRecord *ka = remove->q.uDNS_info.knownAnswers;
                                                while (ka) { remove->q.QuestionCallback(gmDNS, &remove->q, &ka->resrec, mDNSfalse); ka = ka->next; }
                                                }
@@ -2411,6 +2518,7 @@ mDNSlocal void regservice_callback(mDNS *const m, ServiceRecordSet *const srs, m
 
     if (result == mStatus_NoError)
                {
+               request_state *req = instance->request;
                if (instance->allowremotequery)
                        {
                        ExtraResourceRecord *e;
@@ -2420,7 +2528,22 @@ mDNSlocal void regservice_callback(mDNS *const m, ServiceRecordSet *const srs, m
                        srs->RR_TXT.AllowRemoteQuery = mDNStrue;
                        for (e = instance->srs.Extras; e; e = e->next) e->r.AllowRemoteQuery = mDNStrue;
                        }
-        process_service_registration(srs, SuppressError);
+        
+               if (!req) LogMsg("ERROR: regservice_callback - null request object");
+               else
+                       {
+                       reply_state *rep;
+                       if (GenerateNTDResponse(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, req, &rep) != mStatus_NoError)
+                               LogMsg("%3d: regservice_callback: %##s is not valid DNS-SD SRV name", req->sd, srs->RR_SRV.resrec.name->c);
+                       else
+                               {
+                               transfer_state send_result = send_msg(rep);
+                               if (send_result == t_error || send_result == t_terminated)
+                                       { abort_request(req); unlink_request(req); freeL("reply_state", rep); }
+                               else if (send_result == t_complete) freeL("regservice_callback", rep);
+                               else append_reply(req, rep);
+                               }
+                       }
         if (instance->autoname && CountPeerRegistrations(m, srs) == 0)
                RecordUpdatedNiceLabel(m, 0);   // Successfully got new name, tell user immediately
                return;
@@ -2459,7 +2582,7 @@ mDNSlocal void regservice_callback(mDNS *const m, ServiceRecordSet *const srs, m
                    request_state *rs = instance->request;
                        if (!rs) { LogMsg("ERROR: regservice_callback: received result %ld with a NULL request pointer", result); return; }
                        free_service_instance(instance);
-                       if (!SuppressError && deliver_async_error(rs, reg_service_reply, result) < 0)
+                       if (!SuppressError && deliver_async_error(rs, reg_service_reply_op, result) < 0)
                 {
                 abort_request(rs);
                 unlink_request(rs);
@@ -2473,7 +2596,7 @@ mDNSlocal void regservice_callback(mDNS *const m, ServiceRecordSet *const srs, m
                if (!rs) { LogMsg("ERROR: regservice_callback: received result %ld with a NULL request pointer", result); return; }
         if (result != mStatus_NATTraversal) LogMsg("ERROR: unknown result in regservice_callback: %ld", result);
                free_service_instance(instance);
-        if (!SuppressError && deliver_async_error(rs, reg_service_reply, result) < 0)
+        if (!SuppressError && deliver_async_error(rs, reg_service_reply_op, result) < 0)
             {
             abort_request(rs);
             unlink_request(rs);
@@ -2646,36 +2769,6 @@ mDNSlocal void update_callback(mDNS *const m, AuthRecord *const rr, RData *oldrd
     (void)m; // Unused
     if (oldrd != &rr->rdatastorage) freeL("update_callback", oldrd);
     }
-    
-mDNSlocal void process_service_registration(ServiceRecordSet *const srs, mDNSBool SuppressError)
-    {
-    reply_state *rep;
-    transfer_state send_result;
-    mStatus err;
-    service_instance *instance = srs->ServiceContext;
-    request_state *req = instance->request;
-
-       if (!req) { LogMsg("ERROR: process_service_registration - null request object"); return; }
-    err = gen_rr_response(srs->RR_SRV.resrec.name, srs->RR_SRV.resrec.InterfaceID, req, &rep);
-    if (err)
-        {
-        if (SuppressError && deliver_async_error(req, reg_service_reply, err) < 0)
-            {
-            abort_request(req);
-            unlink_request(req);
-            }
-        return;
-        }
-    send_result = send_msg(rep);
-    if (send_result == t_error || send_result == t_terminated)
-        {
-        abort_request(req);
-        unlink_request(req);
-        freeL("process_service_registration", rep);
-        }
-    else if (send_result == t_complete) freeL("process_service_registration", rep);
-    else append_reply(req, rep);
-    }
 
 mDNSlocal void free_service_instance(service_instance *srv)
        {
@@ -2801,7 +2894,7 @@ mDNSlocal void regrecord_callback(mDNS *const m, AuthRecord * rr, mStatus result
     len += sizeof(uint32_t);                //interfaceIndex
     len += sizeof(DNSServiceErrorType);
     
-    reply = create_reply(reg_record_reply, len, rstate);
+    reply = create_reply(reg_record_reply_op, len, rstate);
     reply->mhdr->client_context = re->client_context;
     reply->rhdr->flags = dnssd_htonl(0);
     reply->rhdr->ifi = dnssd_htonl(mDNSPlatformInterfaceIndexfromInterfaceID(gmDNS, rr->resrec.InterfaceID));
@@ -3027,7 +3120,7 @@ mDNSlocal reply_state *format_enumeration_reply(request_state *rstate, const cha
     len += sizeof(DNSServiceErrorType);
     len += strlen(domain) + 1;
 
-    reply = create_reply(enumeration_reply, len, rstate);
+    reply = create_reply(enumeration_reply_op, len, rstate);
     reply->rhdr->flags = dnssd_htonl(flags);
     reply->rhdr->ifi = dnssd_htonl(ifi);
     reply->rhdr->error = dnssd_htonl(err);
@@ -3051,16 +3144,22 @@ mDNSlocal void enum_termination_callback(void *context)
 
 mDNSlocal void handle_reconfirm_request(request_state *rstate)
     {
-    AuthRecord *rr;
-
-    rr = read_rr_from_ipc_msg(rstate->msgdata, 0, 1);
-    if (!rr) return;
-       LogOperation("%3d: DNSServiceReconfirmRecord(%##s) %s", rstate->sd, RRDisplayString(gmDNS, &rr->resrec));
-    mDNS_ReconfirmByValue(gmDNS, &rr->resrec);
-    abort_request(rstate);
-    unlink_request(rstate);
-    freeL("handle_reconfirm_request", rr);
-    }
+    AuthRecord *rr = read_rr_from_ipc_msg(rstate->msgdata, 0, 0);
+    if (rr)
+               {
+               mStatus status = mDNS_ReconfirmByValue(gmDNS, &rr->resrec);
+               LogOperation(
+                       (status == mStatus_NoError) ?
+                       "%3d: DNSServiceReconfirmRecord(%s) interface %d initiated" :
+                       "%3d: DNSServiceReconfirmRecord(%s) interface %d failed: %d",
+                       rstate->sd, RRDisplayString(gmDNS, &rr->resrec),
+                       mDNSPlatformInterfaceIndexfromInterfaceID(gmDNS, rr->resrec.InterfaceID), status);
+               status = 0;  // Adding this line eliminates a build failure when building mDNSPosix on Tiger
+               }
+       abort_request(rstate);
+       unlink_request(rstate);
+       freeL("handle_reconfirm_request", rr);
+       }
 
 // setup rstate to accept new reg/dereg requests
 mDNSlocal void reset_connected_rstate(request_state *rstate)
@@ -3120,64 +3219,19 @@ mDNSlocal AuthRecord *read_rr_from_ipc_msg(char *msgbuf, int GetTTL, int validat
         freeL("read_rr_from_ipc_msg", rr);
         return NULL;
        }
+    
     if (flags & kDNSServiceFlagsAllowRemoteQuery) rr->AllowRemoteQuery  = mDNStrue;
     rr->resrec.rrclass = class;
     rr->resrec.rdlength = rdlen;
     rr->resrec.rdata->MaxRDLength = rdlen;
     rdata = get_rdata(&msgbuf, rdlen);
     memcpy(rr->resrec.rdata->u.data, rdata, rdlen);
-    if (GetTTL)
-       {
-        rr->resrec.rroriginalttl = get_long(&msgbuf);
-       }
+    if (GetTTL) rr->resrec.rroriginalttl = get_long(&msgbuf);
+    rr->resrec.namehash = DomainNameHashValue(rr->resrec.name);
+    SetNewRData(&rr->resrec, mDNSNULL, 0);     // Sets rr->rdatahash for us
     return rr;
     }
 
-// generate a response message for a browse result, service registration result, or any other call with the
-// identical callback signature.  on successful completion rep is set to point to a malloc'd reply_state struct,
-// and mStatus_NoError is returned.  otherwise the appropriate error is returned.
-
-mDNSlocal mStatus gen_rr_response(domainname *servicename, mDNSInterfaceID id, request_state *request, reply_state **rep)
-    {
-    char *data;
-    int len;
-    domainlabel name;
-    domainname type, dom;
-       char namestr[MAX_DOMAIN_LABEL+1];               // Unescaped name: up to 63 bytes plus C-string terminating NULL.
-       char typestr[MAX_ESCAPED_DOMAIN_NAME];
-       char domstr [MAX_ESCAPED_DOMAIN_NAME];
-
-    *rep = NULL;
-    
-    if (!DeconstructServiceName(servicename, &name, &type, &dom))
-        return kDNSServiceErr_Unknown;
-
-    ConvertDomainLabelToCString_unescaped(&name, namestr);
-    ConvertDomainNameToCString(&type, typestr);
-    ConvertDomainNameToCString(&dom, domstr);
-
-    // calculate reply data length
-    len = sizeof(DNSServiceFlags);
-    len += sizeof(uint32_t);  // if index
-    len += sizeof(DNSServiceErrorType);
-    len += (int) (strlen(namestr) + 1);
-    len += (int) (strlen(typestr) + 1);
-    len += (int) (strlen(domstr) + 1);
-    
-    *rep = create_reply(query_reply, len, request);
-
-    (*rep)->rhdr->flags = dnssd_htonl(0);
-    (*rep)->rhdr->ifi = dnssd_htonl(mDNSPlatformInterfaceIndexfromInterfaceID(gmDNS, id));
-    (*rep)->rhdr->error = dnssd_htonl(kDNSServiceErr_NoError);
-
-    data = (*rep)->sdata;
-    
-    put_string(namestr, &data);
-    put_string(typestr, &data);
-    put_string(domstr, &data);
-    return mStatus_NoError;
-    }
-
 mDNSlocal int build_domainname_from_strings(domainname *srv, char *name, char *regtype, char *domain)
     {
     domainlabel n;
@@ -3283,8 +3337,8 @@ mDNSlocal int read_msg(request_state *rs)
                 return t_error;
                }
             rs->msgdata = rs->msgbuf;
-            }
             bzero(rs->msgbuf, rs->hdr.datalen + MSG_PAD_BYTES);
+            }
         nleft = rs->hdr.datalen - rs->data_bytes;
         nread = recv(rs->sd, rs->msgbuf + rs->data_bytes, nleft, 0);
         if (nread == 0)        { rs->ts = t_terminated;  return t_terminated;  }
@@ -3364,7 +3418,7 @@ mDNSlocal int send_msg(reply_state *rs)
     }
 
 mDNSlocal reply_state *create_reply(reply_op_t op, size_t datalen, request_state *request)
-{
+       {
     reply_state *reply;
     int totallen;
 
index 55688b75b35dae4021ce784790dced48659298de..358e121fd4ecb6a0a9d88c675fcbb5f70dce39b3 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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@
 
        File:           uds_daemon.h
 
@@ -29,6 +23,9 @@
     Change History (most recent first):
 
 $Log: uds_daemon.h,v $
+Revision 1.15  2006/08/14 23:24:57  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.14  2005/01/27 17:48:39  cheshire
 Added comment about CFSocketInvalidate closing the underlying socket
 
index 988a41cfe7f731a37247a2f76c11de83684bdb31..70670c89042d7a9b3858d4f4edd86f9cd793a8bc 100644 (file)
@@ -1,28 +1,28 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2005 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: mDNSVxWorks.c,v $
+Revision 1.30  2006/08/14 23:25:18  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.29  2006/03/19 02:00:12  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
 Revision 1.28  2005/05/30 07:36:38  bradley
 New implementation of the mDNS platform plugin for VxWorks 5.5 or later with IPv6 support.
 
@@ -609,7 +609,7 @@ mDNSexport mDNSs32  mDNSPlatformUTC( void )
 //     mDNSPlatformInterfaceIDfromInterfaceIndex
 //===========================================================================================================================
 
-mDNSexport mDNSInterfaceID     mDNSPlatformInterfaceIDfromInterfaceIndex( const mDNS *const inMDNS, mDNSu32 inIndex )
+mDNSexport mDNSInterfaceID     mDNSPlatformInterfaceIDfromInterfaceIndex( mDNS *const inMDNS, mDNSu32 inIndex )
 {
        NetworkInterfaceInfoVxWorks *           i;
        
@@ -630,7 +630,7 @@ mDNSexport mDNSInterfaceID  mDNSPlatformInterfaceIDfromInterfaceIndex( const mDNS
 //     mDNSPlatformInterfaceIndexfromInterfaceID
 //===========================================================================================================================
 
-mDNSexport mDNSu32     mDNSPlatformInterfaceIndexfromInterfaceID( const mDNS *const inMDNS, mDNSInterfaceID inID )
+mDNSexport mDNSu32     mDNSPlatformInterfaceIndexfromInterfaceID( mDNS *const inMDNS, mDNSInterfaceID inID )
 {
        NetworkInterfaceInfoVxWorks *           i;
        
@@ -1106,7 +1106,7 @@ mDNSlocal int     SetupActiveInterfaces( mDNS *const inMDNS, mDNSs32 inUTC )
                        // If it's is an old one that went away and came back in less than a minute, we're in a flapping scenario.
                        
                        flapping = ( ( inUTC - i->lastSeen ) > 0 ) && ( ( inUTC - i->lastSeen ) < 60 );
-                       mDNS_RegisterInterface( inMDNS, n, flapping ? mDNSPlatformOneSecond * 5 : 0 );
+                       mDNS_RegisterInterface( inMDNS, n, flapping );
                        if( mDNSAddressIsNonLinkLocalIPv4( &i->ifinfo.ip ) ) ++count;
                        
                        dmsg( kDebugLevelInfo, DEBUG_NAME "%s:   Registered    %8s(%u) InterfaceID %#p %#a%s%s\n", __ROUTINE__, 
@@ -1189,7 +1189,7 @@ mDNSlocal int     ClearInactiveInterfaces( mDNS *const inMDNS, mDNSs32 inUTC, mDNSBo
                                i->ifinfo.ifname, i->scopeID, i->ifinfo.InterfaceID, &i->ifinfo.ip, 
                                i->ifinfo.InterfaceActive ? " (Primary)" : "" );
                        
-                       mDNS_DeregisterInterface( inMDNS, &i->ifinfo );
+                       mDNS_DeregisterInterface( inMDNS, &i->ifinfo, mDNSfalse );
                        i->ifinfo.InterfaceID = NULL;
                        if( mDNSAddressIsNonLinkLocalIPv4( &i->ifinfo.ip ) ) ++count;
                }
index 50552f3962aa519577b0856889127592501da875..eb62b4877ece633877a74aa87f343383a280218c 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2005 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: mDNSVxWorks.h,v $
+Revision 1.5  2006/08/14 23:25:18  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2005/05/30 07:36:38  bradley
 New implementation of the mDNS platform plugin for VxWorks 5.5 or later with IPv6 support.
 
index d8c2824f792e850dbfb7e3aa5ac36db4ab2dcd51..0a041ce29905c48debb4c55c98e2b72fb86a17fb 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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@
 
        Contains:       mDNS platform plugin for VxWorks.
 
        Change History (most recent first):
 
 $Log: mDNSVxWorksIPv4Only.c,v $
+Revision 1.29  2006/08/14 23:25:18  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.28  2006/03/19 02:00:12  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
 Revision 1.27  2004/12/17 23:37:49  cheshire
 <rdar://problem/3485365> Guard against repeating wireless dissociation/re-association
 (and other repetitive configuration changes)
@@ -1104,7 +1104,7 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inA
        item->hostSet.Advertise               = inMDNS->AdvertiseLocalAddresses;
        item->hostSet.McastTxRx               = mDNStrue;
 
-       err = mDNS_RegisterInterface( inMDNS, &item->hostSet, 0 );
+       err = mDNS_RegisterInterface( inMDNS, &item->hostSet, mDNSfalse );
        require_noerr( err, exit );
        item->hostRegistered = mDNStrue;
        
@@ -1146,7 +1146,7 @@ mDNSlocal mStatus TearDownInterface( mDNS * const inMDNS, MDNSInterfaceItem *inI
        if( inItem->hostRegistered )
        {
                inItem->hostRegistered = mDNSfalse;
-               mDNS_DeregisterInterface( inMDNS, &inItem->hostSet );
+               mDNS_DeregisterInterface( inMDNS, &inItem->hostSet, mDNSfalse );
        }
        
        // Close the multicast socket.
index 3c3cdf574eb666c09c6fda16101a551a9c2612ce..9b24f19577fa06ddfd1a741b5689f546964e4c67 100644 (file)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2002-2003 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@
 
        Contains:       mDNS platform plugin for VxWorks.
 
@@ -27,6 +21,9 @@
        Change History (most recent first):
 
 $Log: mDNSVxWorksIPv4Only.h,v $
+Revision 1.4  2006/08/14 23:25:18  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  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
index 75eaa2dbe14a67bea1cf597605da24d52a89239f..16a1001cc3d4e0422c9b35da3ca6b0af7820ac0d 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: CommonServices.h,v $
+Revision 1.3.4.1  2006/08/29 06:24:39  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2004/04/08 09:27:12  bradley
 Added macro for portable specification of callback calling conventions.
 
index 092331a1f7716dd7374ce839ae78af74dcbfaa3b..3b280a4cfcd9c7d22f5b9653a70c261c97ba752e 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ConfigDialog.cpp,v $
+Revision 1.3  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/03/03 19:55:21  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
index 2d361a8024fe3836b88d45baa66eec387430c7bc..0a38b16d5dff324e789520300e68cae953a954db 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ConfigDialog.h,v $
+Revision 1.3  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/03/03 19:55:21  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
index c9a41238160ac76aaf1bb7c4148670e2e53ad33d..bcf0f7a0cd0ba07edc01b11d00f153d01071f5eb 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ConfigPropertySheet.cpp,v $
+Revision 1.5  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2005/10/05 20:46:50  herscher
 <rdar://problem/4192011> Move Wide-Area preferences to another part of the registry so they don't removed during an update-install.
 
index a954f18578abc39d734c2a27ec3be779968503fb..b92fc1fce994f2e1f0e5ad613fb2082e6728c6a3 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ConfigPropertySheet.h,v $
+Revision 1.5  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2005/03/03 19:55:21  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
@@ -74,9 +71,12 @@ protected:
        DECLARE_MESSAGE_MAP()
 
        afx_msg BOOL    OnInitDialog();
-       afx_msg BOOL    OnCommand( WPARAM wParam, LPARAM lParam );\r
-       afx_msg LONG    OnDataReady( WPARAM inWParam, LPARAM inLParam );\r
-       afx_msg LONG    OnRegistryChanged( WPARAM inWParam, LPARAM inLParam );\r
+       afx_msg BOOL    OnCommand( WPARAM wParam, LPARAM lParam );
+
+       afx_msg LONG    OnDataReady( WPARAM inWParam, LPARAM inLParam );
+
+       afx_msg LONG    OnRegistryChanged( WPARAM inWParam, LPARAM inLParam );
+
        void                    OnEndDialog();
 
 private:
index 03db2cb72dd1b116c121c9337478c1343b50c7a4..ea0321e8df11f016bb4b1d4bb00713e12b4c1190 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ControlPanel.cpp,v $
+Revision 1.3  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/03/03 19:55:22  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
index 04491d09115a98a2e94cd65b8d40e4b20e803d67..efb5c3b2fb79766f0d5e15e84e92ad5d41628f89 100644 (file)
@@ -1,28 +1,25 @@
+; -*- 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: ControlPanel.def,v $
+;  Revision 1.4  2006/08/14 23:25:28  cheshire
+;  Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+;
 ;  Revision 1.3  2005/03/03 19:55:22  shersche
 ;  <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 ;
index 847639e1f4b53ff43d8dc45dfaac6eb2bf2b9925..926ba94d0e946a4da9764b3c5537da47d5359295 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ControlPanel.h,v $
+Revision 1.3  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/03/03 19:55:21  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
index 375d0f44167a8293013ce17b391e7b78a27813e9..5d6c90afec817c491e808578833b883c598934ed 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: FirstPage.cpp,v $
+Revision 1.6  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  2005/10/05 20:46:50  herscher
 <rdar://problem/4192011> Move Wide-Area preferences to another part of the registry so they don't removed during an update-install.
 
index 6d875e1376afc08d7a670712182bd57f460885b3..b990f3d43145ebeb6690755469c82184618ab1d3 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: FirstPage.h,v $
+Revision 1.4  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/03/07 18:27:42  shersche
 <rdar://problem/4037940> Fix problem when ControlPanel commits changes to the browse domain list
 
index 83058b3fc2aa9232c16be2507d95f284c97ee324..eb830df113d35365d5954f919a0e19f495bed20e 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: SecondPage.cpp,v $
+Revision 1.7  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.6  2005/10/05 20:46:50  herscher
 <rdar://problem/4192011> Move Wide-Area preferences to another part of the registry so they don't removed during an update-install.
 
index 917608edad7806ae6aec3b1c84fd8df12b4c9427..f60612ecfa381f65851857933b588177eadf1c09 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: SecondPage.h,v $
+Revision 1.5  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2005/04/05 03:52:14  shersche
 <rdar://problem/4066485> Registering with shared secret key doesn't work. Additionally, mDNSResponder wasn't dynamically re-reading it's DynDNS setup after setting a shared secret key.
 
index 7ba6a2a63464e3f676518865944be14639cc4962..066fa98767e0242786af1eb224fc7037f88fc86b 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: SharedSecret.cpp,v $
+Revision 1.5  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2005/10/18 06:13:41  herscher
 <rdar://problem/4192119> Prepend "$" to key name to ensure that secure updates work if the domain name and key name are the same
 
index c757df9c0f84ac97cfe4c74616d0d046b3873af7..f5f64351c597599c7d584e892f932593ba85aa2a 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: SharedSecret.h,v $
+Revision 1.4  2006/08/14 23:25:28  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/04/06 02:04:49  shersche
 <rdar://problem/4066485> Registering with shared secret doesn't work
 
index b8cef51e9072df63812ac44ba368663955306c99..a4834185065ea365f6f86821516913e8e664f7ca 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ThirdPage.cpp,v $
+Revision 1.5  2006/08/14 23:25:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2005/10/05 20:46:50  herscher
 <rdar://problem/4192011> Move Wide-Area preferences to another part of the registry so they don't removed during an update-install.
 
index 9fe742038706758451be7e94edb90e72012aac3e..6c1146c86e1b8efbdb8477c55ce19b1c9979eaa2 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ThirdPage.h,v $
+Revision 1.3  2006/08/14 23:25:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/03/03 19:55:21  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
@@ -36,10 +33,13 @@ Revision 1.2  2005/03/03 19:55:21  shersche
 
 #include <DebugServices.h>
 #include <list>
-#include "afxcmn.h"\r
-#include "afxwin.h"\r
+#include "afxcmn.h"
+
+#include "afxwin.h"
+
+
+
 
-\r
 
 //---------------------------------------------------------------------------------------------------------------------------
 //     CThirdPage
@@ -86,44 +86,82 @@ private:
        BOOL                    m_modified;
 
 public:
-private:\r
-       static int CALLBACK \r
-       SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);\r
-\r
-       CListCtrl       m_browseListCtrl;\r
-       bool            m_initialized;\r
-       bool            m_firstTime;\r
-\r
-public:\r
-\r
-       afx_msg void OnBnClickedAddBrowseDomain();\r
-       afx_msg void OnBnClickedRemoveBrowseDomain();\r
-       afx_msg void OnLvnItemchangedBrowseList(NMHDR *pNMHDR, LRESULT *pResult);\r
-       CButton m_removeButton;\r
-};\r
-\r
-\r
+private:
+
+       static int CALLBACK 
+
+       SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
+
+
+
+       CListCtrl       m_browseListCtrl;
+
+       bool            m_initialized;
+
+       bool            m_firstTime;
+
+
+
+public:
+
+
+
+       afx_msg void OnBnClickedAddBrowseDomain();
+
+       afx_msg void OnBnClickedRemoveBrowseDomain();
+
+       afx_msg void OnLvnItemchangedBrowseList(NMHDR *pNMHDR, LRESULT *pResult);
+
+       CButton m_removeButton;
+
+};
+
+
+
+
+
 //---------------------------------------------------------------------------------------------------------------------------
 //     CAddBrowseDomain
 //---------------------------------------------------------------------------------------------------------------------------
-\r
-class CAddBrowseDomain : public CDialog\r
-{\r
-       DECLARE_DYNAMIC(CAddBrowseDomain)\r
-\r
-public:\r
-       CAddBrowseDomain(CWnd* pParent = NULL);   // standard constructor\r
-       virtual ~CAddBrowseDomain();\r
-\r
-// Dialog Data\r
-       enum { IDD = IDR_ADD_BROWSE_DOMAIN };\r
-\r
-protected:\r
-       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
-       virtual BOOL OnInitDialog();\r
-       virtual void OnOK();\r
-       DECLARE_MESSAGE_MAP()\r
-public:\r
-       CComboBox       m_comboBox;\r
-       CString         m_text;\r
-};\r
+
+
+class CAddBrowseDomain : public CDialog
+
+{
+
+       DECLARE_DYNAMIC(CAddBrowseDomain)
+
+
+
+public:
+
+       CAddBrowseDomain(CWnd* pParent = NULL);   // standard constructor
+
+       virtual ~CAddBrowseDomain();
+
+
+
+// Dialog Data
+
+       enum { IDD = IDR_ADD_BROWSE_DOMAIN };
+
+
+
+protected:
+
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+
+       virtual BOOL OnInitDialog();
+
+       virtual void OnOK();
+
+       DECLARE_MESSAGE_MAP()
+
+public:
+
+       CComboBox       m_comboBox;
+
+       CString         m_text;
+
+};
+
index ad80318a0e34460fbba1302fd88c44e2790af02c..4bab622206c2b3ccb2aea0c6b846f465cc580b7c 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: stdafx.cpp,v $
+Revision 1.3  2006/08/14 23:25:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/03/03 19:55:22  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
index 7e63ac4c495712b330bc7a21004cf8f09c0a352a..1a04b6c72a058c5bafaeb397b1d475e6538d63cc 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: stdafx.h,v $
+Revision 1.4  2006/08/14 23:25:29  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/10/19 19:50:35  herscher
 Workaround a bug in the latest Microsoft Platform SDK when compiling C++ files that include (directly or indirectly) <WspiApi.h>
 
@@ -74,6 +71,8 @@ Revision 1.2  2005/03/03 19:55:21  shersche
 #ifndef _AFX_NO_AFXCMN_SUPPORT
 #include <afxcmn.h>                    // MFC support for Windows Common Controls
 #endif // _AFX_NO_AFXCMN_SUPPORT
-#include <afxdlgs.h>\r
-#include <cpl.h>            // Control Panel Applet functions and defines\r
+#include <afxdlgs.h>
+
+#include <cpl.h>            // Control Panel Applet functions and defines
+
 #include <afxtempl.h>       // MFC Template support
index c32676cd859eb474e92fe6f9b1d17278da3d4b85..4a71579c8e453da58986c5c86837e2cb818c23eb 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: AssemblyInfo.cpp,v $
+Revision 1.5  2006/08/14 23:25:43  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2004/07/26 21:03:00  shersche
 enable strong naming for dnssd.NET assembly
 
index f64b951bc833f42b120c26045eeead40c409993a..1886c4475f12eb05ff60ac6aa627502cb14c5293 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: PString.h,v $
+Revision 1.3  2006/08/14 23:25:43  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/19 16:08:56  shersche
 fix problems in UTF8/Unicode string translations
 
@@ -49,7 +46,8 @@ namespace Apple
                        {
                                Byte unicodeBytes[] = Encoding::Unicode->GetBytes(string);
                                Byte utf8Bytes[] = Encoding::Convert(Encoding::Unicode, Encoding::UTF8, unicodeBytes);
-                               m_p = Marshal::AllocHGlobal(utf8Bytes->Length + 1);\r
+                               m_p = Marshal::AllocHGlobal(utf8Bytes->Length + 1);
+
                                Byte __pin * p = &utf8Bytes[0];
                                char * hBytes = static_cast<char*>(m_p.ToPointer());
                                memcpy(hBytes, p, utf8Bytes->Length);
index b09cb841fa43e912d2e7f4e575e3728f8bed4762..54ff68e5b429947c59a6039730c89b2c88d34606 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: Stdafx.cpp,v $
+Revision 1.3  2006/08/14 23:25:43  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/02/05 02:37:01  cheshire
 Convert newlines to Unix-style (ASCII 10)
 
index 00a0820544383b61015937943b20addac4875f89..7fbc319892d74c8c7f21aa68a0be81f7c43d6cc3 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: Stdafx.h,v $
+Revision 1.5  2006/08/14 23:25:43  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2005/10/19 19:50:35  herscher
 Workaround a bug in the latest Microsoft Platform SDK when compiling C++ files that include (directly or indirectly) <WspiApi.h>
 
index 36a5452fd820c84c17468ddbff975a2780ed64d1..f5ba48623a146145a17665c82cd1645d66de588c 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: dnssd_NET.cpp,v $
+Revision 1.10  2006/08/14 23:25:43  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.9  2004/09/16 18:17:13  shersche
 Use background threads, cleanup to parameter names.
 Submitted by: prepin@gmail.com
index 6faeb3dcdfdc4fd6563dece9cdb2716712935250..999e6898af3b620b0a18a55baee92498f19e5e59 100755 (executable)
@@ -1,24 +1,18 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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@
 
  * 
  * NOTE:
@@ -40,6 +34,9 @@
     Change History (most recent first):
 
 $Log: dnssd_NET.h,v $
+Revision 1.9  2006/08/14 23:25:43  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.8  2005/02/10 22:35:33  cheshire
 <rdar://problem/3727944> Update name
 
index 6dd9e97f7cd3def5481a060165f972fda098a3dc..0e3ea786a4cfcb353261343c1dc019a8bb232f77 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: dllmain.c,v $
+Revision 1.4  2006/08/14 23:25:41  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/07/07 19:18:29  shersche
 Fix error in previous checkin, change SystemServiceIsDisabled() to IsSystemServiceDisabled()
 
index 624904634ef993868bef82e493b3b0b5d5760345..52ba5b3a94f1e0ff2cf7934ae98640dcd9b1b321 100644 (file)
@@ -1,28 +1,25 @@
+; -*- tab-width: 4 -*-
 ;
 ; Copyright (c) 2003-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: dnssd.def,v $
+; Revision 1.3  2006/08/14 23:25:41  cheshire
+; Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+;
 ; Revision 1.2  2004/07/19 07:43:59  shersche
 ; export TXTRecord APIs
 ;
index ce71791318819b8355cc0b5d44586d360c68ed07..82e9c9e20a57199ee6a6a7cdc48b62f1bc83774d 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: Application.rc2,v $
+Revision 1.3  2006/08/14 23:25:48  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:26  rpantos
 Fix for <rdar://problem/3701120>.
 
index 5984f335e56b1a1106de421fa84b25a3caf2c696..641349dda8ed8ea4b68625129914135d1e1e14ff 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: AboutDialog.cpp,v $
+Revision 1.3  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:26  rpantos
 Fix for <rdar://problem/3701120>.
 
index 82634323d9fb392c1be7097377667a17606340bc..98f4103349c29a9b21a8c3857e24fef7bee728a4 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: AboutDialog.h,v $
+Revision 1.3  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:26  rpantos
 Fix for <rdar://problem/3701120>.
 
index 8d1dcfdf4f0d7c6fb6f7a8eb46f663e75dc9c163..b3a377e404a35c78b0e1383d282b3e02915b62ff 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: Application.cpp,v $
+Revision 1.3  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:26  rpantos
 Fix for <rdar://problem/3701120>.
 
index 498dd07559e53fc00c79cdac903bf30be4af0df5..b21deda5ff8ccf34a744946d246e591eb9d3b94b 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: Application.h,v $
+Revision 1.3  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:26  rpantos
 Fix for <rdar://problem/3701120>.
 
index ab5f1002e571c171fc5e0985f2a6fa63f5206f1a..f917ce8a062d1f97056e8216f6b27d1de9cbc430 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ChooserDialog.cpp,v $
+Revision 1.4  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/02/10 22:35:35  cheshire
 <rdar://problem/3727944> Update name
 
index 8bda96cda02df1f4749d0b8aeb8e6e647ee873d6..833661009ccefccb808e3af3e270005848670493 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ChooserDialog.h,v $
+Revision 1.3  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:26  rpantos
 Fix for <rdar://problem/3701120>.
 
index c3869e7f1fbed1b1a9d45e7ecc19dd16ddf6d3c9..b4209d08614cf0e00221f1193c2dce499dfea7fa 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: LoginDialog.cpp,v $
+Revision 1.2  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 04:04:36  rpantos
 Move up one level
 
index caf641a578f6b6f43d58a079ae8eb7ed45fc7505..4149fc8bfd8fee9455f542f7dba14388b94c487f 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: LoginDialog.h,v $
+Revision 1.2  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 04:04:36  rpantos
 Move up one level
 
index 1ccc754dd894f11fb0c2153f69fc9072bae01bbc..7c4030536c6870715daba62f78990fe7b7bb117c 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: StdAfx.cpp,v $
+Revision 1.3  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:26  rpantos
 Fix for <rdar://problem/3701120>.
 
index cb8031ecb0995fb23235efc9cbe8d75997c708d7..958c12e53fa97438c2dda293c5d285155cb6416a 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: StdAfx.h,v $
+Revision 1.3  2006/08/14 23:25:49  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:26  rpantos
 Fix for <rdar://problem/3701120>.
 
index 39bb5294ca8045909ef1f8f3079821674ec5daa7..257197622e3b569014385d275e85da3332a84dd9 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: Application.cpp,v $
+Revision 1.3  2006/08/14 23:25:55  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:27  rpantos
 Fix for <rdar://problem/3701120>.
 
index 08409b154478900af7c9b5a4de1fd8f120c69c8f..76e80983ed3a536a01fbba68594848885380745a 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: Application.h,v $
+Revision 1.3  2006/08/14 23:25:55  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:27  rpantos
 Fix for <rdar://problem/3701120>.
 
index 2bdd05b38f48b0d3f4cf4d98bcb1dede254c346d..01fa3a003342fba98e69ce161276dc733438c81d 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: BrowserDialog.cpp,v $
+Revision 1.3  2006/08/14 23:25:55  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:27  rpantos
 Fix for <rdar://problem/3701120>.
 
index e0a77239331c93dc0c8dc0ee92d7b9472f71b63a..206ca91f315e2a2e2a33a41707c494850a3bdfb2 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: BrowserDialog.h,v $
+Revision 1.3  2006/08/14 23:25:55  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:27  rpantos
 Fix for <rdar://problem/3701120>.
 
index 919256eed57e8ffc6b618404df4fd145e17451c8..dbbcc18800968f9022982a35d3e4ef3df99858b6 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: StdAfx.cpp,v $
+Revision 1.3  2006/08/14 23:25:55  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:27  rpantos
 Fix for <rdar://problem/3701120>.
 
index f598c267b754b4d38d98f0e8a8c41d0193b20f1f..4cdcef7bbbe769ca7d3f50dfd20d986a35a89c1c 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: StdAfx.h,v $
+Revision 1.3  2006/08/14 23:25:55  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2004/07/13 21:24:27  rpantos
 Fix for <rdar://problem/3701120>.
 
index 258363eb1221d9ba0d81e4ded7b52ae8cb4c618f..015690f5214d4155fa437097b8d60bb4bc229f0a 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: Tool.c,v $
+Revision 1.4  2006/08/14 23:25:59  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2004/09/16 01:58:25  cheshire
 Fix compiler warnings
 
index 64697489e3d5a99428991fe0cbe0bbadfc562771..9d6829a6a97a3268955a53864c3c979a1610170d 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ToolPrefixWindows.h,v $
+Revision 1.2  2006/08/14 23:25:59  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 04:07:54  rpantos
 Move up one level
 
index 7b73d2e837521ac1bb7c3174f75d74b60da2f07c..85015ed7b778c7a00395f48ea010aaafe67d09cb 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: ToolPrefixWindowsDebug.h,v $
+Revision 1.2  2006/08/14 23:25:59  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 04:07:54  rpantos
 Move up one level
 
index 94e2d0218138ebc8e894eb2c474684bd99bb82bc..7a7f99f8751cf82347c660e3c3f0cc8fd051d500 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: DNSServiceDiscovery.c,v $
+Revision 1.9  2006/08/14 23:26:01  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.8  2004/09/17 01:08:58  cheshire
 Renamed mDNSClientAPI.h to mDNSEmbeddedAPI.h
   The name "mDNSClientAPI.h" is misleading to new developers looking at this code. The interfaces
index 084b0b811d1b1137ffc484b3cc434eb12a161d03..460bb13d327d9abce7d62ef7dfe11d0cd0bcb870 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: DNSServiceDiscovery.h,v $
+Revision 1.5  2006/08/14 23:26:01  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2004/05/06 18:42:58  ksekar
 General dns_sd.h API cleanup, including the following radars:
 <rdar://problem/3592068>: Remove flags with zero value
index c32ebb01d3acdd25b1637c379ae162db01017619..e5d6d0d08e0dd9e3c40fcc03799386729572d135 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: DNSServices.c,v $
+Revision 1.33  2006/08/14 23:26:01  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.32  2004/12/16 20:13:02  cheshire
 <rdar://problem/3324626> Cache memory management improvements
 
index 8e16a8c3c6300bb8967435a74d6fddf35004188c..3e4c005fba22158e136c4a2ab9e75bb53f9605b0 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: DNSServices.h,v $
+Revision 1.12  2006/08/14 23:26:01  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.11  2004/07/13 21:24:28  rpantos
 Fix for <rdar://problem/3701120>.
 
index 7562c2e741615329bf6de158f0598488fa06e12b..ffbb1f69230eb3b665b7ab42f23846b3ffa29fe4 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: DebugServices.c,v $
+Revision 1.5.2.1  2006/08/29 06:24:39  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.5  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
index e6874067f97b381e37b455e06a360e42a3323164..ee2c1af57defd175aed48a56a5575e8b15d7da39 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: DebugServices.h,v $
+Revision 1.4.4.1  2006/08/29 06:24:39  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.4  2004/04/15 08:59:08  bradley
 Removed deprecated debug and log levels and replaced them with modern equivalents.
 
index 42511a31c47ed841cf3320727cc766e72200bdaa..c47a9c4b8a039aa6d5467ac4af76eeeefb0da585 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: jdns_sd.rc,v $
+Revision 1.4  2006/08/14 23:26:04  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2004/10/19 03:41:42  shersche
 <rdar://problem/3843396> Include "afxres.h" to resource script so it gets compiled correctly
 Bug #: 3843396
index 8a115ee238c5812a6ac824500c5cee12231b505a..99a79877d696c18a97240ef989e58fc6bd37c45c 100644 (file)
@@ -1,25 +1,26 @@
+# -*- 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@
 #
 # $Log: makefile,v $
+# Revision 1.9  2006/08/14 23:26:04  cheshire
+# Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+#
+# Revision 1.8  2006/07/05 20:57:22  cheshire
+# <rdar://problem/3839132> Java needs to implement DNSServiceRegisterRecord equivalent
+#
 # Revision 1.7  2005/10/19 17:19:56  herscher
 # Change JDK to use JAVA_HOME environment variable
 #
@@ -142,6 +143,8 @@ JARCONTENTS =       $(OBJDIR)\com\apple\dnssd\DNSSDService.class \
                                $(OBJDIR)\com\apple\dnssd\RegisterListener.class \
                                $(OBJDIR)\com\apple\dnssd\QueryListener.class \
                                $(OBJDIR)\com\apple\dnssd\DomainListener.class \
+                               $(OBJDIR)\com\apple\dnssd\DNSSDRecordRegistrar.class \
+                               $(OBJDIR)\com\apple\dnssd\RegisterRecordListener.class \
                                $(OBJDIR)\com\apple\dnssd\DNSSD.class
 
 $(BUILDDIR)\dns_sd.jar: $(JARCONTENTS)
index 364865596e1bc2c0ed9f502693c69da4288bdab3..63a7df1d795dd91ca9b634aa227519fae73ae6cb 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: NSPTool.c,v $
+Revision 1.4  2006/08/14 23:26:06  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2004/08/26 04:46:49  shersche
 Add -q switch for silent operation
 
index af06d929e83c58a2ebd2b9846e6b7146f02b80a5..4ae504fda5e0dd91468a39cf0036d807228b236f 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: Prefix.h,v $
+Revision 1.2  2006/08/14 23:26:06  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 04:14:26  rpantos
 Move up one level.
 
index dc94ba9a2f26974e671af40c2a386b1a3d896c91..c86b7ec2175d9abef046147405de312292933715 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: RegNames.h,v $
+Revision 1.3  2006/08/14 23:25:20  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.2  2005/10/05 18:05:28  herscher
 <rdar://problem/4192011> Save Wide-Area preferences in a different spot in the registry so they don't get removed when doing an update install.
 
index ba235c8ebe861da768f476f7fc0491801b9edca8..79019daceff5b1abd1b5a80c22bf65abe8191941 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: Firewall.cpp,v $
+Revision 1.4  2006/08/14 23:26:07  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.3  2005/09/29 06:33:54  herscher
 <rdar://problem/4278931> Fix compilation error when using latest Microsoft Platform SDK.
 
index ac2dfad870dc7b2c4deb66d820982ba70ea853cc..e84a93044affd62722a81c7198c9ef0e707e6cdf 100755 (executable)
@@ -1,59 +1,88 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: Firewall.h,v $
+Revision 1.2  2006/08/14 23:26:07  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/09/13 07:32:31  shersche
 Wrapper for Windows Firewall API code
-\r
-\r
-*/\r
-\r
-#ifndef _Firewall_h\r
-#define _Firewall_h\r
-\r
-\r
-#include "CommonServices.h"\r
-#include "DebugServices.h"\r
-\r
-\r
-#if defined(__cplusplus)\r
-extern "C"\r
-{\r
-#endif\r
-\r
-\r
-OSStatus\r
-mDNSAddToFirewall\r
-               (\r
-               LPWSTR  executable,\r
-               LPWSTR  name\r
-               );\r
-\r
-\r
-#if defined(__cplusplus)\r
-}\r
-#endif\r
-\r
-\r
-#endif\r
+
+
+
+
+*/
+
+
+
+#ifndef _Firewall_h
+
+#define _Firewall_h
+
+
+
+
+
+#include "CommonServices.h"
+
+#include "DebugServices.h"
+
+
+
+
+
+#if defined(__cplusplus)
+
+extern "C"
+
+{
+
+#endif
+
+
+
+
+
+OSStatus
+
+mDNSAddToFirewall
+
+               (
+
+               LPWSTR  executable,
+
+               LPWSTR  name
+
+               );
+
+
+
+
+
+#if defined(__cplusplus)
+
+}
+
+#endif
+
+
+
+
+
+#endif
+
index 150aa3bb73506001da002c3ae039bf28b934539f..a64b0e419a3bd5de647e207b85a85390c6f8ffd0 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: Prefix.h,v $
+Revision 1.2  2006/08/14 23:26:07  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 04:16:41  rpantos
 Move up one level.
 
index 768b589ab8a06ce83c537a1b7c4cea38dfe247d2..c14288fbe61643a367727f596cb6dce96fad6e19 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: Service.c,v $
+Revision 1.39  2006/08/14 23:26:07  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.38  2005/10/05 20:55:15  herscher
 <rdar://problem/4096464> Don't call SetLLRoute on loopback interface
 
index a5723063e5ff21d70bcf6b1445b6f671390af896..c0f4d01c4fdc0d600169f7ed280287f8a9063c5d 100755 (executable)
@@ -1,28 +1,28 @@
-/*
+/* -*- 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: VPCDetect.cpp,v $
+Revision 1.3  2006/08/14 23:25:20  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.2  2006/02/26 19:31:05  herscher
+<rdar://problem/4455038> Bonjour For Windows takes 90 seconds to start. This was caused by a bad interaction between the VirtualPC check, and the removal of the WMI dependency.  The problem was fixed by: 1) checking to see if WMI is running before trying to talk to it.  2) Retrying the VirtualPC check every 10 seconds upon failure, stopping after 10 unsuccessful tries.
+
 Revision 1.1  2005/11/27 20:21:16  herscher
 <rdar://problem/4210580> Workaround Virtual PC bug that incorrectly modifies incoming mDNS packets
 
@@ -40,55 +40,75 @@ static BOOL g_doneCheck = FALSE;
 static BOOL g_isVPC            = FALSE;
 
 
-BOOL
-IsVPCRunning()
+mStatus
+IsVPCRunning( BOOL * inVirtualPC )
 {
        IWbemLocator                    *       pLoc            = 0;
        IWbemServices                   *       pSvc            = 0;
     IEnumWbemClassObject       *       pEnumerator = NULL;
        bool                                            coInit          = false;
        HRESULT                                         hres;
-
-       // Short circuit if we've already done this
-
-       require_action_quiet( !g_doneCheck, exit, g_doneCheck = TRUE );
-
+       SC_HANDLE                                       scm                     = NULL;
+       SC_HANDLE                                       service         = NULL;
+       SERVICE_STATUS                          status;
+       mStatus                                         err;
+       BOOL                                            ok          = TRUE;
+
+       // Initialize flag
+
+       *inVirtualPC = FALSE;
+
+       // Find out if WMI is running
+
+       scm = OpenSCManager( 0, 0, SC_MANAGER_CONNECT );
+       err = translate_errno( scm, (OSStatus) GetLastError(), kOpenErr );
+       require_noerr( err, exit );
+
+       service = OpenService( scm, TEXT( "winmgmt" ), SERVICE_QUERY_STATUS );
+       err = translate_errno( service, (OSStatus) GetLastError(), kNotFoundErr );
+       require_noerr( err, exit );
+       
+       ok = QueryServiceStatus( service, &status );
+       err = translate_errno( ok, (OSStatus) GetLastError(), kAuthenticationErr );
+       require_noerr( err, exit );
+       require_action( status.dwCurrentState == SERVICE_RUNNING, exit, err = kUnknownErr );
+       
     // Initialize COM.
 
        hres = CoInitializeEx(0, COINIT_MULTITHREADED);
-       require_action( SUCCEEDED( hres ), exit, g_isVPC = false );
+       require_action( SUCCEEDED( hres ), exit, err = kUnknownErr );
        coInit = true;
 
        // Initialize Security
 
        hres =  CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL );
-       require_action( SUCCEEDED( hres ), exit, g_isVPC = false );
+       require_action( SUCCEEDED( hres ), exit, err = kUnknownErr );
 
                       
     // Obtain the initial locator to Windows Management on a particular host computer.
 
     hres = CoCreateInstance( CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc );
-       require_action( SUCCEEDED( hres ), exit, g_isVPC = false );
+       require_action( SUCCEEDED( hres ), exit, err = kUnknownErr );
  
     // Connect to the root\cimv2 namespace with the
     // current user and obtain pointer pSvc
     // to make IWbemServices calls.
 
-       hres = pLoc->ConnectServer( _bstr_t(L"ROOT\\CIMV2"), NULL, NULL, 0, NULL, 0, 0, &pSvc );
-       require_action( SUCCEEDED( hres ), exit, g_isVPC = false );
+       hres = pLoc->ConnectServer( _bstr_t(L"ROOT\\CIMV2"), NULL, NULL, 0, WBEM_FLAG_CONNECT_USE_MAX_WAIT, 0, 0, &pSvc );
+       require_action( SUCCEEDED( hres ), exit, err = kUnknownErr );
     
     // Set the IWbemServices proxy so that impersonation
     // of the user (client) occurs.
 
        hres = CoSetProxyBlanket( pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE );
-       require_action( SUCCEEDED( hres ), exit, g_isVPC = false );
+       require_action( SUCCEEDED( hres ), exit, err = kUnknownErr );
 
     // Use the IWbemServices pointer to make requests of WMI. 
     // Make requests here:
 
        hres = pSvc->ExecQuery( bstr_t("WQL"), bstr_t("SELECT * from Win32_BaseBoard"), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
     
-       require_action( SUCCEEDED( hres ), exit, g_isVPC = false );
+       require_action( SUCCEEDED( hres ), exit, err = kUnknownErr );
 
        do
        {
@@ -114,7 +134,7 @@ IsVPCRunning()
 
                                if (wcscmp( wstring, L"microsoft corporation" ) == 0 )
                                {
-                                       g_isVPC = true;
+                                       *inVirtualPC = TRUE;
                                }
                        }
                
@@ -139,15 +159,20 @@ exit:
        CoUninitialize();
        }
 
-       if ( !g_doneCheck )
+       if ( service )
        {
-               g_doneCheck = TRUE;
+               CloseServiceHandle( service );
+       }
 
-               if ( g_isVPC )
-               {
-                       dlog( kDebugLevelTrace, "Virtual PC detected" );
-               }
+       if ( scm )
+       {
+               CloseServiceHandle( scm );
+       }
+
+       if ( *inVirtualPC )
+       {
+               dlog( kDebugLevelTrace, "Virtual PC detected" );
        }
 
-       return g_isVPC;
+       return err;
 }
index ed709acb626260cd40f2a527f66eb9a4b91fa966..0b7ce19efb48c1ca8b0e268545aedac31d045fea 100644 (file)
@@ -1,28 +1,28 @@
-/*
+/* -*- 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: VPCDetect.h,v $
+Revision 1.3  2006/08/14 23:25:20  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.2  2006/02/26 19:31:05  herscher
+<rdar://problem/4455038> Bonjour For Windows takes 90 seconds to start. This was caused by a bad interaction between the VirtualPC check, and the removal of the WMI dependency.  The problem was fixed by: 1) checking to see if WMI is running before trying to talk to it.  2) Retrying the VirtualPC check every 10 seconds upon failure, stopping after 10 unsuccessful tries.
+
 Revision 1.1  2005/11/27 20:21:16  herscher
 <rdar://problem/4210580> Workaround Virtual PC bug that incorrectly modifies incoming mDNS packets
 
@@ -31,6 +31,7 @@ Revision 1.1  2005/11/27 20:21:16  herscher
 #pragma once
 
 #include <windows.h>
+#include <mDNSEmbeddedAPI.h>
 
 
 #if defined(__cplusplus)
@@ -39,8 +40,8 @@ extern "C"
 #endif
 
 
-extern BOOL
-IsVPCRunning();
+extern mStatus
+IsVPCRunning( BOOL * inVirtualPC );
 
 
 #if defined(__cplusplus)
index ca20ae00d53057d8c1f3cc732266e6bf5b5be646..654b07a5b074e8ad8f1081a7c137a950b657b30c 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: WinServices.cpp,v $
+Revision 1.2  2006/08/14 23:25:20  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 05:23:33  rpantos
 First checked in
 
index 9700cd47311d60d8345782a5b41ce81d0681af50..9d9db91d4bba5059893a66938eaaaf5dc6edd770 100644 (file)
@@ -1,28 +1,25 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 1997-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: WinServices.h,v $
+Revision 1.2  2006/08/14 23:25:21  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.1  2004/06/18 05:23:33  rpantos
 First checked in
 
index 8256ddf7c38adecc54aad5a360702f03b8741a2f..4bb081bdf5e4c65d6dc856f9acc303cdc95109fe 100644 (file)
@@ -1,28 +1,31 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 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: WinVersRes.h,v $
+Revision 1.54  2006/08/14 23:25:21  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.53  2006/02/28 20:07:53  herscher
+Bump to 1.0.3.1
+
+Revision 1.52  2006/01/09 20:45:29  cheshire
+Update copyright date to 2006
+
 Revision 1.51  2005/11/28 19:49:56  herscher
 Bump to 1.0.2.9
 
@@ -184,12 +187,12 @@ First checked in.
 #define MASTER_PROD_NAME       "Bonjour"
 
 // Define the product version for mDNSResponder on Windows
-#define MASTER_PROD_VERS               1,0,2,9
-#define MASTER_PROD_VERS_STR   "1,0,2,9"
-#define MASTER_PROD_VERS_STR2  "1.0.2.9"
-#define MASTER_PROD_VERS_STR3 "Explorer Plugin 1.0.2.9"
+#define MASTER_PROD_VERS               1,0,3,1
+#define MASTER_PROD_VERS_STR   "1,0,3,1"
+#define MASTER_PROD_VERS_STR2  "1.0.3.1"
+#define MASTER_PROD_VERS_STR3 "Explorer Plugin 1.0.3.1"
 
 // Define the legal copyright
-#define MASTER_LEGAL_COPYRIGHT "Copyright (C) 2003-2005 Apple Computer, Inc."
+#define MASTER_LEGAL_COPYRIGHT "Copyright (C) 2003-2006 Apple Computer, Inc."
 
 #endif // WINRESVERS_H
index 0435517fb7d74c53e807628942681f614a20f7b3..0e24e0bc3311a02597b30b299b8df78cbebe546b 100755 (executable)
@@ -1,28 +1,25 @@
-/*
+/* -*- 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: dDNS.c,v $
+Revision 1.8.2.1  2006/08/29 06:24:39  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
 Revision 1.8  2005/09/12 07:13:33  herscher
 <rdar://problem/4248878> Workaround for router crash.  Lazily call RegisterSearchDomains rather than call it always at startup.
 
index 12c56da3930761ca9d9cdb509ab5d36a124b2e9b..f3e6c887c740dcaefe9ee0e513b89dc1547ab696 100755 (executable)
@@ -1,24 +1,18 @@
-/*
+/* -*- 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):
 
 #pragma mark - DynDNS structures
 #endif
 
-#if WIN32
-// named type definition in parentheses \r
-#      pragma warning( disable: 4115 ) \r
-#endif\r
-
 typedef struct IPAddrListElem
        {
        mDNSAddr addr;
index 19f8570f4b07ee59629c6f681e2e5be912c4dd09..953ef202f9821faeebd0fa584139750e85c15623 100755 (executable)
@@ -1,24 +1,18 @@
-/*
+/* -*- 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):
     
index 7084d16b2a0dc1e86bc27e534a2d78c5d405cbfe..2f5d46cd62a870ffc270fbc00eb701b3f8966802 100755 (executable)
@@ -1,24 +1,18 @@
-/*
+/* -*- 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):
 
index 952dc44ca808e8fc0ad537337d594ce57cc75a7e..9b081be4f44c7fc3e5b54dfe6494b1b6a5d7abd6 100755 (executable)
@@ -1,24 +1,18 @@
-/*
+/* -*- 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):
 
index 93a14a71eb991e3888d4de3d788262f13fc590a0..41ddc4db3dc152e8ee8170c3ecc49612b93d1c92 100755 (executable)
@@ -1,28 +1,31 @@
-/*
+/* -*- 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.c,v $
+Revision 1.107.2.1  2006/08/29 06:24:39  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.107  2006/03/19 02:00:13  cheshire
+<rdar://problem/4073825> Improve logic for delaying packets after repeated interface transitions
+
+Revision 1.106  2006/02/26 19:31:05  herscher
+<rdar://problem/4455038> Bonjour For Windows takes 90 seconds to start. This was caused by a bad interaction between the VirtualPC check, and the removal of the WMI dependency.  The problem was fixed by: 1) checking to see if WMI is running before trying to talk to it.  2) Retrying the VirtualPC check every 10 seconds upon failure, stopping after 10 unsuccessful tries.
+
 Revision 1.105  2005/11/27 20:21:16  herscher
 <rdar://problem/4210580> Workaround Virtual PC bug that incorrectly modifies incoming mDNS packets
 
@@ -452,6 +455,9 @@ Multicast DNS platform plugin for Win32
 
 #define kIPv6IfIndexBase                                                       (10000000L)
 
+#define kRetryVPCRate                                                          (-100000000)
+#define kRetryVPCMax                                                           (10)
+
 
 #if 0
 #pragma mark == Prototypes ==
@@ -474,6 +480,8 @@ mDNSlocal mStatus                   SetupSocket( mDNS * const inMDNS, const struct sockaddr *inA
 mDNSlocal mStatus                      SockAddrToMDNSAddr( const struct sockaddr * const inSA, mDNSAddr *outIP, mDNSIPPort *outPort );
 mDNSlocal mStatus                      SetupNotifications( mDNS * const inMDNS );
 mDNSlocal mStatus                      TearDownNotifications( mDNS * const inMDNS );
+mDNSlocal mStatus           SetupRetryVPCCheck( mDNS * const inMDNS );
+mDNSlocal mStatus           TearDownRetryVPCCheck( mDNS * const inMDNS );
 
 mDNSlocal mStatus                      SetupThread( mDNS * const inMDNS );
 mDNSlocal mStatus                      TearDownThread( const mDNS * const inMDNS );
@@ -485,6 +493,7 @@ mDNSlocal void                              ProcessingThreadInterfaceListChanged( mDNS *inMDNS );
 mDNSlocal void                         ProcessingThreadComputerDescriptionChanged( mDNS * inMDNS );
 mDNSlocal void                         ProcessingThreadTCPIPConfigChanged( mDNS * inMDNS );
 mDNSlocal void                         ProcessingThreadDynDNSConfigChanged( mDNS * inMDNS );
+mDNSlocal void              ProcessingThreadRetryVPCCheck( mDNS * inMDNS );
 
 
 // Platform Accessors
@@ -640,6 +649,12 @@ mStatus    mDNSPlatformInit( mDNS * const inMDNS )
        inMDNS->HISoftware.c[ 0 ] = (mDNSu8) mDNSPlatformStrLen( &inMDNS->HISoftware.c[ 1 ] );
        dlog( kDebugLevelInfo, DEBUG_NAME "HISoftware: %#s\n", inMDNS->HISoftware.c );
 #endif
+
+       // Bookkeeping
+
+       inMDNS->p->vpcCheckCount                        = 0;
+       inMDNS->p->vpcCheckEvent                        = NULL;
+       inMDNS->p->timersCount                          = 0;
        
        // Set up the IPv4 unicast socket
 
@@ -666,16 +681,8 @@ mStatus    mDNSPlatformInit( mDNS * const inMDNS )
        {
                DWORD size;
 
-               // If we are running inside VPC, then we won't use WSARecvMsg because it will give us bogus information due to
-               // a bug in VPC itself.
-
-               err = IsVPCRunning();
-
-               if ( !err )
-               {
-                       err = WSAIoctl( inMDNS->p->unicastSock4, SIO_GET_EXTENSION_FUNCTION_POINTER, &kWSARecvMsgGUID, 
+               err = WSAIoctl( inMDNS->p->unicastSock4, SIO_GET_EXTENSION_FUNCTION_POINTER, &kWSARecvMsgGUID, 
                                                        sizeof( kWSARecvMsgGUID ), &inMDNS->p->unicastSock4RecvMsgPtr, sizeof( inMDNS->p->unicastSock4RecvMsgPtr ), &size, NULL, NULL );
-               }
                
                if ( err )
                {
@@ -776,6 +783,9 @@ void        mDNSPlatformClose( mDNS * const inMDNS )
        err = TearDownInterfaceList( inMDNS );
        check_noerr( err );
        check( !inMDNS->p->inactiveInterfaceList );
+
+       err = TearDownRetryVPCCheck( inMDNS );
+       check_noerr( err );
                
        err = TearDownSynchronizationObjects( inMDNS );
        check_noerr( err );
@@ -1146,7 +1156,7 @@ exit:
 //     mDNSPlatformInterfaceIDfromInterfaceIndex
 //===========================================================================================================================
 
-mDNSInterfaceID        mDNSPlatformInterfaceIDfromInterfaceIndex( const mDNS * const inMDNS, mDNSu32 inIndex )
+mDNSInterfaceID        mDNSPlatformInterfaceIDfromInterfaceIndex( mDNS * const inMDNS, mDNSu32 inIndex )
 {
        mDNSInterfaceID         id;
        
@@ -1176,7 +1186,7 @@ mDNSInterfaceID   mDNSPlatformInterfaceIDfromInterfaceIndex( const mDNS * const in
 //     mDNSPlatformInterfaceIndexfromInterfaceID
 //===========================================================================================================================
        
-mDNSu32        mDNSPlatformInterfaceIndexfromInterfaceID( const mDNS * const inMDNS, mDNSInterfaceID inID )
+mDNSu32        mDNSPlatformInterfaceIndexfromInterfaceID( mDNS * const inMDNS, mDNSInterfaceID inID )
 {
        mDNSu32         index;
        
@@ -2797,12 +2807,12 @@ mDNSlocal mStatus       SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inI
 
                #if( !TARGET_OS_WINDOWS_CE )
                {
-                       DWORD           size;
+                       DWORD size;
 
                        // If we are running inside VPC, then we won't use WSARecvMsg because it will give us bogus information due to
                        // a bug in VPC itself.
                        
-                       err = IsVPCRunning();
+                       err = inMDNS->p->inVirtualPC;
 
                        if ( !err )
                        {
@@ -2845,7 +2855,7 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inI
        
        ifd->interfaceInfo.Advertise = inMDNS->AdvertiseLocalAddresses;
        
-       err = mDNS_RegisterInterface( inMDNS, &ifd->interfaceInfo, 0 );
+       err = mDNS_RegisterInterface( inMDNS, &ifd->interfaceInfo, mDNSfalse );
        require_noerr( err, exit );
        ifd->hostRegistered = mDNStrue;
        
@@ -2883,7 +2893,7 @@ mDNSlocal mStatus TearDownInterface( mDNS * const inMDNS, mDNSInterfaceData *inI
        if( inIFD->hostRegistered )
        {
                inIFD->hostRegistered = mDNSfalse;
-               mDNS_DeregisterInterface( inMDNS, &inIFD->interfaceInfo );
+               mDNS_DeregisterInterface( inMDNS, &inIFD->interfaceInfo, mDNSfalse );
        }
        
        // Tear down the multicast socket.
@@ -3275,6 +3285,64 @@ mDNSlocal mStatus        TearDownNotifications( mDNS * const inMDNS )
        return( mStatus_NoError );
 }
 
+
+//===========================================================================================================================
+//     SetupRetryVPCCheck
+//===========================================================================================================================
+
+mDNSlocal mStatus
+SetupRetryVPCCheck( mDNS * const inMDNS )
+{
+    LARGE_INTEGER      liDueTime;
+       BOOL                    ok;
+       mStatus                 err;
+
+       dlog( kDebugLevelTrace, DEBUG_NAME "setting up retry VirtualPC check\n" );
+    
+       liDueTime.QuadPart = kRetryVPCRate;
+
+    // Create a waitable timer.
+    
+       inMDNS->p->vpcCheckEvent = CreateWaitableTimer( NULL, TRUE, TEXT( "VPCCheckTimer" ) );
+       err = translate_errno( inMDNS->p->vpcCheckEvent, (mStatus) GetLastError(), kUnknownErr );
+       require_noerr( err, exit );
+
+    // Set a timer to wait for 10 seconds.
+    
+       ok = SetWaitableTimer( inMDNS->p->vpcCheckEvent, &liDueTime, 0, NULL, NULL, 0 );
+       err = translate_errno( ok, (OSStatus) GetLastError(), kUnknownErr );
+       require_noerr( err, exit );
+
+       inMDNS->p->timersCount++;
+
+exit:
+
+       return err;
+}
+
+
+//===========================================================================================================================
+//     TearDownRetryVPCCheck
+//===========================================================================================================================
+
+mDNSlocal mStatus
+TearDownRetryVPCCheck( mDNS * const inMDNS )
+{
+       dlog( kDebugLevelTrace, DEBUG_NAME "tearing down retry VirtualPC check\n" );
+
+       if ( inMDNS->p->vpcCheckEvent )
+       {
+               CancelWaitableTimer( inMDNS->p->vpcCheckEvent );
+               CloseHandle( inMDNS->p->vpcCheckEvent );
+
+               inMDNS->p->vpcCheckEvent = NULL;
+               inMDNS->p->timersCount--;
+       }
+
+       return ( mStatus_NoError );
+}
+
+
 #if 0
 #pragma mark -
 #endif
@@ -3481,6 +3549,13 @@ mDNSlocal unsigned WINAPI        ProcessingThread( LPVOID inParam )
                                                
                                                signaledObject = waitList[ waitItemIndex ];
        
+                                               if ( m->p->vpcCheckEvent == signaledObject )
+                                               {
+                                                       ProcessingThreadRetryVPCCheck( m );
+                                                       ++n;
+
+                                                       break;
+                                               }
 #if ( MDNS_WINDOWS_ENABLE_IPV4 )
                                                if ( m->p->unicastSock4ReadEvent == signaledObject )
                                                {
@@ -3578,7 +3653,15 @@ mDNSlocal mStatus ProcessingThreadInitialize( mDNS * const inMDNS )
        BOOL            wasSet;
        
        inMDNS->p->threadID = GetCurrentThreadId();
-       
+
+       err = IsVPCRunning( &inMDNS->p->inVirtualPC );
+
+       if ( err )
+       {
+               TearDownRetryVPCCheck( inMDNS );
+               SetupRetryVPCCheck( inMDNS );
+       }
+
        err = SetupInterfaceList( inMDNS );
        require_noerr( err, exit );
 
@@ -3593,6 +3676,7 @@ exit:
        if( err )
        {
                TearDownInterfaceList( inMDNS );
+               TearDownRetryVPCCheck( inMDNS );
        }
        inMDNS->p->initStatus = err;
        
@@ -3622,7 +3706,7 @@ mDNSlocal mStatus ProcessingThreadSetupWaitList( mDNS * const inMDNS, HANDLE **o
        
        // Allocate an array to hold all the objects to wait on.
        
-       waitListCount = kWaitListFixedItemCount + inMDNS->p->interfaceCount + gTCPConnections;
+       waitListCount = kWaitListFixedItemCount + inMDNS->p->timersCount + inMDNS->p->interfaceCount + gTCPConnections;
        waitList = (HANDLE *) malloc( waitListCount * sizeof( *waitList ) );
        require_action( waitList, exit, err = mStatus_NoMemoryErr );
        waitItemPtr = waitList;
@@ -3635,6 +3719,13 @@ mDNSlocal mStatus        ProcessingThreadSetupWaitList( mDNS * const inMDNS, HANDLE **o
        *waitItemPtr++ = inMDNS->p->descChangedEvent;
        *waitItemPtr++ = inMDNS->p->tcpipChangedEvent;
        *waitItemPtr++ = inMDNS->p->ddnsChangedEvent;
+
+       // Add timers
+
+       if ( inMDNS->p->vpcCheckEvent )
+       {
+               *waitItemPtr++ = inMDNS->p->vpcCheckEvent;
+       }
        
        // Append all the dynamic wait items to the list.
 #if ( MDNS_WINDOWS_ENABLE_IPV4 )
@@ -3956,6 +4047,44 @@ mDNSlocal void   ProcessingThreadDynDNSConfigChanged( mDNS *inMDNS )
 }
 
 
+//===========================================================================================================================
+//     ProcessingThreadRetryVPCCheck
+//===========================================================================================================================
+
+mDNSlocal void
+ProcessingThreadRetryVPCCheck( mDNS * inMDNS )
+{
+       mStatus err = mStatus_NoError;
+
+       dlog( kDebugLevelTrace, DEBUG_NAME "in ProcessingThreadRetryVPCCheck\n" );
+       
+       TearDownRetryVPCCheck( inMDNS );
+       
+       if ( inMDNS->p->vpcCheckCount < kRetryVPCMax )
+       {
+               inMDNS->p->vpcCheckCount++;
+
+               err = IsVPCRunning( &inMDNS->p->inVirtualPC );
+               require_noerr( err, exit );
+       
+               if ( inMDNS->p->inVirtualPC )
+               {
+                       ProcessingThreadInterfaceListChanged( inMDNS );
+               }
+       }
+
+exit:
+
+       if ( err )
+       {
+               SetupRetryVPCCheck( inMDNS );
+       }
+
+       return; 
+}
+
+
+
 #if 0
 #pragma mark -
 #pragma mark == Utilities ==
index 1a9755debfac1546e647f73ee795cba4c133c381..d5c59c889c13fadc6648e6faf561725e3a92089f 100755 (executable)
@@ -1,28 +1,28 @@
-/*
+/* -*- 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.24.2.1  2006/08/29 06:24:39  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.24  2006/02/26 19:31:04  herscher
+<rdar://problem/4455038> Bonjour For Windows takes 90 seconds to start. This was caused by a bad interaction between the VirtualPC check, and the removal of the WMI dependency.  The problem was fixed by: 1) checking to see if WMI is running before trying to talk to it.  2) Retrying the VirtualPC check every 10 seconds upon failure, stopping after 10 unsuccessful tries.
+
 Revision 1.23  2005/10/05 20:55:14  herscher
 <rdar://problem/4096464> Don't call SetLLRoute on loopback interface
 
@@ -198,10 +198,14 @@ struct    mDNS_PlatformSupport_struct
        HANDLE                                          ddnsChangedEvent;       // DynDNS config changed
        HANDLE                                          wakeupEvent;
        HANDLE                                          initEvent;
+       HANDLE                                          vpcCheckEvent;          // Timer handle to check if we're running in Virtual PC
+       int                                                     vpcCheckCount;
        HKEY                                            descKey;
        HKEY                                            tcpipKey;
        HKEY                                            ddnsKey;
        mStatus                                         initStatus;
+       mDNSBool                                        inVirtualPC;
+       int                                                     timersCount;
        mDNSBool                                        registeredLoopback4;
        SocketRef                                       interfaceListChangedSocket;
        int                                                     interfaceCount;
index f0937f5e1429c054dabd8e347106236e2f12dacc..db0d802f9188411cb586f0329514c80b62ed895e 100644 (file)
@@ -1,28 +1,29 @@
-/*
+/* -*- Mode: C; tab-width: 4 -*-
+ *
  * Copyright (c) 2003-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: mdnsNSP.c,v $
+Revision 1.20  2006/08/14 23:26:10  cheshire
+Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+
+Revision 1.19  2006/06/08 23:09:37  cheshire
+Updated comment: Correct IPv6LL reverse-mapping domains are '{8,9,A,B}.E.F.ip6.arpa.',
+not only '0.8.E.F.ip6.arpa.' (Actual code still needs to be fixed.)
+
 Revision 1.18  2005/10/17 05:45:36  herscher
 Fix typo in previous checkin
 
@@ -681,7 +682,7 @@ DEBUG_LOCAL int WSPAPI
                require_action( InHostsTable( translated ) == FALSE, exit, err = WSASERVICE_NOT_FOUND );
        }
 
-       // The name ends in .local ( and isn't in the hosts table ), .0.8.e.f.ip6.arpa, or .254.169.in-addr.arpa so start the resolve operation. Lazy initialize DNS-SD if needed.
+       // The name ends in .local ( and isn't in the hosts table ), {8,9,A,B}.E.F.ip6.arpa, or .254.169.in-addr.arpa so start the resolve operation. Lazy initialize DNS-SD if needed.
                
        NSPLock();
        
index 338e5a5428fe727b484ae83e7416f61788562e77..7c24bae20f59518bc2c2d25751b5a0c546a1d57f 100644 (file)
@@ -1,28 +1,25 @@
+; -*- tab-width: 4 -*-
 ;
 ; Copyright (c) 2003-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: mdnsNSP.def,v $
+; Revision 1.4  2006/08/14 23:26:10  cheshire
+; Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
+;
 ; Revision 1.3  2005/01/28 23:48:46  shersche
 ; <rdar://problem/3942551> Export DllRegisterServer, DllUnregisterServer which can be called from the Installer or regsvr32
 ; Bug #: 3942551