]> git.saurik.com Git - apple/mdnsresponder.git/commitdiff
mDNSResponder-107.1.tar.gz v107.1
authorApple <opensource@apple.com>
Thu, 5 May 2005 00:06:58 +0000 (00:06 +0000)
committerApple <opensource@apple.com>
Thu, 5 May 2005 00:06:58 +0000 (00:06 +0000)
68 files changed:
Clients/ExplorerPlugin/ExplorerBarWindow.cpp
Clients/ExplorerPlugin/ExplorerPluginLocRes.rc
Clients/ExplorerPlugin/ExplorerPluginLocRes.vcproj
Clients/ExplorerPlugin/ExplorerPluginRes.rc
Clients/ExplorerPlugin/ExplorerPluginRes.vcproj
Clients/ExplorerPlugin/res/globe.bmp [deleted file]
Clients/ExplorerPlugin/resource_res.h
Clients/PrinterSetupWizard/FirstPage.cpp
Clients/PrinterSetupWizard/PrinterSetupWizardApp.cpp
Clients/PrinterSetupWizard/PrinterSetupWizardLocRes.rc
Clients/PrinterSetupWizard/PrinterSetupWizardLocRes.vcproj
Clients/PrinterSetupWizard/PrinterSetupWizardRes.vcproj
Clients/PrinterSetupWizard/PrinterSetupWizardSheet.cpp
Clients/PrinterSetupWizard/PrinterSetupWizardSheet.h
Clients/PrinterSetupWizard/SecondPage.cpp
Clients/PrinterSetupWizard/SecondPage.h
Clients/PrinterSetupWizard/ThirdPage.cpp
Clients/PrinterSetupWizard/UtilTypes.h
Clients/PrinterSetupWizard/res/NetworkPrinter.ico
Clients/PrinterSetupWizard/res/Print.ico
Clients/dns-sd.c
Makefile
mDNSCore/DNSCommon.c
mDNSCore/DNSCommon.h
mDNSCore/mDNS.c
mDNSCore/mDNSEmbeddedAPI.h
mDNSCore/uDNS.c
mDNSCore/uDNS.h
mDNSMacOS9/mDNSLibraryResources.r
mDNSMacOSX/PreferencePane/BonjourPref.icns [new file with mode: 0644]
mDNSMacOSX/PreferencePane/BonjourPref.tiff [new file with mode: 0644]
mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.icns [deleted file]
mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.tiff [deleted file]
mDNSMacOSX/daemon.c
mDNSMacOSX/mDNSMacOSX.c
mDNSMacOSX/mDNSResponder.pbproj/project.pbxproj
mDNSPosix/Makefile
mDNSPosix/dnsextd.c
mDNSPosix/mDNSUNP.c
mDNSPosix/mDNSUNP.h
mDNSResponder.sln
mDNSShared/PlatformCommon.c
mDNSShared/dns_sd.h
mDNSShared/dnssd_clientlib.c
mDNSShared/dnssd_clientstub.c
mDNSShared/dnssd_ipc.h
mDNSShared/uds_daemon.c
mDNSWindows/ControlPanel/ControlPanel.rc
mDNSWindows/ControlPanel/FirstPage.cpp
mDNSWindows/ControlPanel/SecondPage.cpp
mDNSWindows/ControlPanel/SecondPage.h
mDNSWindows/ControlPanel/SharedSecret.cpp
mDNSWindows/ControlPanel/SharedSecret.h
mDNSWindows/ControlPanel/resource.h
mDNSWindows/DLL/dnssd.vcproj
mDNSWindows/Installer/Main.ism [deleted file]
mDNSWindows/Installer/SDK.ism [deleted file]
mDNSWindows/SystemService/Service.c
mDNSWindows/SystemServiceTest/Prefix.h [deleted file]
mDNSWindows/SystemServiceTest/Tool.c [deleted file]
mDNSWindows/SystemServiceTest/Tool.mcp [deleted file]
mDNSWindows/SystemServiceTest/Tool2002.vcproj [deleted file]
mDNSWindows/WinVersRes.h
mDNSWindows/dDNS.c
mDNSWindows/dDNS.h
mDNSWindows/loclibrary.c
mDNSWindows/mDNSWin32.c
mDNSWindows/mdnsNSP/mdnsNSP.c

index a68880b2a643aae03584be98f22dd215f1973832..d4ea5c1d6849c8b6a3465f7d7f2b74ca7e151170 100644 (file)
     Change History (most recent first):
     
 $Log: ExplorerBarWindow.cpp,v $
+Revision 1.21  2005/04/06 01:13:07  shersche
+<rdar://problem/4066195> Use the product icon instead of globe icon for 'About' link.
+
+Revision 1.20  2005/03/18 02:43:02  shersche
+<rdar://problem/4046443> Use standard IE website icon for 'About Bonjour', only using globe icon if standard icon cannot be loaded
+
+Revision 1.19  2005/03/16 03:46:27  shersche
+<rdar://problem/4045657> Use Bonjour icon for all discovered sites
+
 Revision 1.18  2005/02/26 01:24:05  shersche
 Remove display lines in tree control
 
@@ -143,6 +152,10 @@ static char THIS_FILE[] = __FILE__;
 
 #define        kTXTRecordKeyPath                               "path"
 
+// IE Icon resource
+
+#define kIEIconResource                                        32529
+
 
 #if 0
 #pragma mark == Prototypes ==
@@ -205,6 +218,7 @@ int ExplorerBarWindow::OnCreate( LPCREATESTRUCT inCreateStruct )
 {
        AFX_MANAGE_STATE( AfxGetStaticModuleState() );
        
+       HINSTANCE               module = NULL;
        OSStatus                err;
        CRect                   rect;
        CBitmap                 bitmap;
@@ -231,7 +245,7 @@ int ExplorerBarWindow::OnCreate( LPCREATESTRUCT inCreateStruct )
        mServiceHandlers.Add( e );
 
        s.LoadString( IDS_ABOUT );
-       m_about = mTree.InsertItem( s, 1, 1 );
+       m_about = mTree.InsertItem( s, 0, 0 );
 
        err = DNSServiceBrowse( &e->ref, 0, 0, e->type, NULL, BrowseCallBack, e );
        require_noerr( err, exit );
@@ -241,17 +255,22 @@ int       ExplorerBarWindow::OnCreate( LPCREATESTRUCT inCreateStruct )
 
        m_serviceRefs.push_back(e->ref);
 
-       m_imageList.Create( 16, 16, ILC_COLORDDB, 2, 0);
-       bitmap.Attach( ::LoadBitmap( GetNonLocalizedResources(), MAKEINTRESOURCE( IDB_GLOBE ) ) );
-       m_imageList.Add( &bitmap, (CBitmap*) NULL );
-       bitmap.Detach();
+       m_imageList.Create( 16, 16, ILC_MASK | ILC_COLOR16, 2, 0);
+
        bitmap.Attach( ::LoadBitmap( GetNonLocalizedResources(), MAKEINTRESOURCE( IDB_LOGO ) ) );
        m_imageList.Add( &bitmap, (CBitmap*) NULL );
+       bitmap.Detach();
 
        mTree.SetImageList(&m_imageList, TVSIL_NORMAL);
        
 exit:
 
+       if ( module )
+       {
+               FreeLibrary( module );
+               module = NULL;
+       }
+
        // Cannot talk to the mDNSResponder service. Show the error message and exit (with kNoErr so they can see it).
        if ( err )
        {
index 7e025f271d645f34e9eb079174bfdb696d7fd697..34cf048a51f320cba9408d144ece006524978f1d 100755 (executable)
@@ -177,7 +177,7 @@ END
 STRINGTABLE \r
 BEGIN\r
     IDS_ABOUT               "About Bonjour"\r
-    IDS_ABOUT_URL           "http://www.apple.com/macosx/features/rendezvous"\r
+    IDS_ABOUT_URL           "http://www.apple.com/macosx/features/bonjour"\r
     IDS_NAME                "Bonjour"\r
     IDS_WEB_SITES           "Web Sites"\r
     IDS_PRINTERS            "Printers"\r
index bcb02693eae341813f5c3694b103db93aaed4517..35f32be4f2cfc85bdde0ab9c377c33c3e779d364 100755 (executable)
@@ -13,7 +13,7 @@
        <Configurations>\r
                <Configuration\r
                        Name="Debug|Win32"\r
-                       OutputDirectory=".\Debug\Resources\ExplorerPlugin.dll.Resources\en.lproj"\r
+                       OutputDirectory=".\Debug\ExplorerPlugin.Resources\en.lproj"\r
                        IntermediateDirectory=".\Debug"\r
                        ConfigurationType="2"\r
                        UseOfMFC="1"\r
@@ -71,9 +71,8 @@
                        <Tool\r
                                Name="VCPreLinkEventTool"\r
                                Description="Building Output Directories"\r
-                               CommandLine="if not exist Debug\Resources mkdir Debug\Resources\r
-if not exist Debug\Resources\ExplorerPlugin.dll.Resources mkdir Debug\Resources\ExplorerPlugin.dll.Resources\r
-if not exist Debug\Resources\ExplorerPlugin.dll.Resources\en.lproj mkdir Debug\Resources\ExplorerPlugin.dll.Resources\en.lproj"/>\r
+                               CommandLine="if not exist Debug\ExplorerPlugin.Resources mkdir Debug\ExplorerPlugin.Resources\r
+if not exist Debug\ExplorerPlugin.Resources\en.lproj mkdir Debug\ExplorerPlugin.Resources\en.lproj"/>\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
                                PreprocessorDefinitions="_DEBUG"\r
@@ -86,7 +85,7 @@ if not exist Debug\Resources\ExplorerPlugin.dll.Resources\en.lproj mkdir Debug\R
                </Configuration>\r
                <Configuration\r
                        Name="Release|Win32"\r
-                       OutputDirectory=".\Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources\en.lproj"\r
+                       OutputDirectory=".\Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources\en.lproj"\r
                        IntermediateDirectory=".\Release"\r
                        ConfigurationType="2"\r
                        UseOfMFC="1"\r
@@ -151,9 +150,8 @@ if not exist Debug\Resources\ExplorerPlugin.dll.Resources\en.lproj mkdir Debug\R
                                CommandLine="if not exist Release\Root mkdir Release\Root\r
 if not exist &quot;Release\Root\Program Files&quot; mkdir &quot;Release\Root\Program Files&quot;\r
 if not exist &quot;Release\Root\Program Files\Bonjour&quot; mkdir &quot;Release\Root\Program Files\Bonjour&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources\en.lproj&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources\en.lproj&quot;"/>\r
+if not exist &quot;Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources&quot;\r
+if not exist &quot;Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources\en.lproj&quot; mkdir &quot;Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources\en.lproj&quot;"/>\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
                                PreprocessorDefinitions="NDEBUG"\r
index d97ab2039ff502ffe359068f2609a788a9b85dae..5ed5f4e20e270d8993c2baf32a981f566579010b 100755 (executable)
@@ -104,7 +104,6 @@ END
 \r
 IDB_LOGO                BITMAP                  "res\\logo.bmp"\r
 IDB_ABOUT               BITMAP                  "res\\about.bmp"\r
-IDB_GLOBE                                      BITMAP                                          "res\\globe.bmp"\r
 \r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r
index 0949120516428fcb676bdf3cb5a8b23635dd8f28..1429c246e8a62bf646e481e5c39d1b7c80891460 100755 (executable)
@@ -13,7 +13,7 @@
        <Configurations>\r
                <Configuration\r
                        Name="Debug|Win32"\r
-                       OutputDirectory=".\Debug\Resources\ExplorerPlugin.dll.Resources"\r
+                       OutputDirectory=".\Debug\ExplorerPlugin.Resources"\r
                        IntermediateDirectory=".\Debug"\r
                        ConfigurationType="2"\r
                        UseOfMFC="1"\r
@@ -70,8 +70,7 @@
                        <Tool\r
                                Name="VCPreLinkEventTool"\r
                                Description="Building Output Directories"\r
-                               CommandLine="if not exist Debug\Resources mkdir Debug\Resources\r
-if not exist Debug\Resources\ExplorerPlugin.dll.Resources mkdir Debug\Resources\ExplorerPlugin.dll.Resources"/>\r
+                               CommandLine="if not exist Debug\ExplorerPlugin.Resources mkdir Debug\ExplorerPlugin.Resources"/>\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
                                PreprocessorDefinitions="_DEBUG"\r
@@ -84,7 +83,7 @@ if not exist Debug\Resources\ExplorerPlugin.dll.Resources mkdir Debug\Resources\
                </Configuration>\r
                <Configuration\r
                        Name="Release|Win32"\r
-                       OutputDirectory=".\Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources"\r
+                       OutputDirectory=".\Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources"\r
                        IntermediateDirectory=".\Release"\r
                        ConfigurationType="2"\r
                        UseOfMFC="1"\r
@@ -148,8 +147,7 @@ if not exist Debug\Resources\ExplorerPlugin.dll.Resources mkdir Debug\Resources\
                                CommandLine="if not exist Release\Root mkdir Release\Root\r
 if not exist &quot;Release\Root\Program Files&quot; mkdir &quot;Release\Root\Program Files&quot;\r
 if not exist &quot;Release\Root\Program Files\Bonjour&quot; mkdir &quot;Release\Root\Program Files\Bonjour&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources&quot;"/>\r
+if not exist &quot;Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources&quot;"/>\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
                                PreprocessorDefinitions="NDEBUG"\r
diff --git a/Clients/ExplorerPlugin/res/globe.bmp b/Clients/ExplorerPlugin/res/globe.bmp
deleted file mode 100755 (executable)
index af43b4e..0000000
Binary files a/Clients/ExplorerPlugin/res/globe.bmp and /dev/null differ
index 4f66a0cc966d16f34ef7f3bcbb18a6ed4743e831..c4aae0a10a7a0d598f9b94b4cc724b44fb209d40 100755 (executable)
@@ -11,7 +11,6 @@
 #define IDI_BUTTON_2K                   115\r
 #define IDI_BUTTON_XP                   118\r
 #define IDB_ABOUT                       119\r
-#define IDB_GLOBE                       149\r
 #define IDC_COMPONENT                   1001\r
 #define IDC_LEGAL                       1002\r
 #define IDC_LOGIN_USERNAME_TEXT         1182\r
index 530b26cf8520670fda0a3d7863f136f8c2e9adbf..f8c4adae333533d7a2067b3559b2dae8c06285d5 100644 (file)
@@ -23,6 +23,9 @@
     Change History (most recent first):
     
 $Log: FirstPage.cpp,v $
+Revision 1.4  2005/03/16 01:41:29  shersche
+<rdar://problem/3989644> Remove info icon from first page
+
 Revision 1.3  2005/01/25 08:58:08  shersche
 <rdar://problem/3911084> Load icons at run-time from resource DLLs
 Bug #: 3911084
@@ -77,18 +80,6 @@ void CFirstPage::DoDataExchange(CDataExchange* pDX)
 BOOL
 CFirstPage::OnSetActive()
 {
-       static bool firstTime = true;
-
-       if ( firstTime )
-       {
-               CStatic * image = (CStatic*) GetDlgItem( IDC_INFO );
-               check( image );
-
-               image->SetIcon( LoadIcon( GetNonLocalizedResources(), MAKEINTRESOURCE( IDI_INFO ) ) );
-
-               firstTime = false;
-       }
-
        CPropertySheet* psheet = (CPropertySheet*) GetParent();   
    
        psheet->SetWizardButtons(PSWIZB_NEXT);
index 08a0505ae4e6a05bf549a2c4af044bd975ff36fb..7b6544313604e74af47fcd109d2d7de20ca8349a 100644 (file)
@@ -23,6 +23,9 @@
     Change History (most recent first):
     
 $Log: PrinterSetupWizardApp.cpp,v $
+Revision 1.8  2005/04/13 17:43:39  shersche
+<rdar://problem/4081448> Change "PrinterWizard.dll" to "PrinterWizardResources.dll"
+
 Revision 1.7  2005/02/15 07:50:09  shersche
 <rdar://problem/4007151> Update name
 
@@ -123,7 +126,7 @@ BOOL CPrinterSetupWizardApp::InitInstance()
 
        // Load Resources
 
-       res = PathForResource( NULL, L"PrinterWizard.dll", resource, MAX_PATH );
+       res = PathForResource( NULL, L"PrinterWizardResources.dll", resource, MAX_PATH );
        err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
        require_noerr( err, exit );
 
index 7a2842fc498dd6c7626756245c29afb2fdc9e36b..56319c3b24a768e0ca6869bd5d89c1e5f7d92e23 100755 (executable)
@@ -79,11 +79,11 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55\r
 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | \r
     WS_SYSMENU\r
-CAPTION "About Printer Setup Wizard"\r
+CAPTION "About Printer Wizard"\r
 FONT 8, "MS Shell Dlg", 0, 0, 0x1\r
 BEGIN\r
     ICON            128,IDC_STATIC,11,17,20,20\r
-    LTEXT           "Printer Setup Wizard Version 1.0",IDC_STATIC,40,10,119,\r
+    LTEXT           "Printer Wizard Version 1.0",IDC_STATIC,40,10,119,\r
                     8,SS_NOPREFIX\r
     LTEXT           "Copyright (C) 2002",IDC_STATIC,40,25,119,8\r
     DEFPUSHBUTTON   "OK",IDOK,178,7,50,16,WS_GROUP\r
@@ -93,7 +93,7 @@ IDD_PRINTERSETUPWIZARD_DIALOG DIALOGEX 0, 0, 320, 200
 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | \r
     WS_CAPTION | WS_SYSMENU\r
 EXSTYLE WS_EX_APPWINDOW\r
-CAPTION "Printer Setup Wizard"\r
+CAPTION "Bonjour Printer Wizard"\r
 FONT 8, "MS Shell Dlg", 0, 0, 0x1\r
 BEGIN\r
     DEFPUSHBUTTON   "OK",IDOK,263,7,50,16\r
@@ -123,12 +123,11 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION
 CAPTION "Bonjour Printer Wizard"\r
 FONT 8, "MS Shell Dlg", 0, 0, 0x0\r
 BEGIN\r
-    LTEXT           "Welcome to the Bonjour Printer Setup Wizard",\r
+    LTEXT           "Welcome to the Bonjour Printer Wizard",\r
                     IDC_GREETING,114,7,171,46\r
-    LTEXT           "Click next to continue.",IDC_STATIC,115,188,143,8\r
+    LTEXT           "To continue, click Next.",IDC_STATIC,115,188,143,8\r
     LTEXT           "This wizard helps you connect to a shared printer using Bonjour.  Make sure your printer is turned on and connected to your network.",\r
-                    IDC_STATIC,146,60,139,62\r
-    ICON            "",IDC_INFO,118,60,20,20,SS_REALSIZEIMAGE\r
+                    IDC_STATIC,114,60,171,62\r
 END\r
 \r
 IDD_THIRD_PAGE DIALOGEX 0, 0, 290, 154\r
@@ -143,9 +142,9 @@ BEGIN
     CONTROL         "",IDC_PRINTER_MANUFACTURER,"SysListView32",LVS_REPORT | \r
                     LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | \r
                     LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,2,58,105,76\r
-    ICON            1017,1,0,0,20,27\r
+    ICON            1017,1,3,5,20,27\r
     LTEXT           "",IDC_PRINTER_NAME,40,5,173,8\r
-    LTEXT           "The Bonjour Printer Wizard has auto-selected the following printer settings.  Click 'Next' to continue installing this printer.",\r
+    LTEXT           "The Bonjour Printer Wizard has auto-selected the following printer settings.  To continue installing this printer, click Next.",\r
                     IDC_PRINTER_SELECTION_TEXT,40,18,243,33\r
     CONTROL         "Use this printer as the default printer",\r
                     IDC_DEFAULT_PRINTER,"Button",BS_AUTOCHECKBOX | \r
@@ -160,20 +159,20 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN\r
     LTEXT           "Completing the Bonjour Printer Wizard",IDC_GOODBYE,\r
                     116,7,171,27\r
-    LTEXT           "You have successfully completed the Bonjour Printer Wizard.  The printer has the following settings:",\r
-                    IDC_STATIC,116,42,158,31\r
+    LTEXT           "You are ready to complete the Bonjour Printer Wizard.  The printer has the following settings:",\r
+                    IDC_STATIC,116,42,171,31\r
     LTEXT           "Name:",IDC_STATIC,116,78,22,8\r
     LTEXT           "Manufacturer:",IDC_STATIC,116,91,47,8\r
     LTEXT           "Model:",IDC_STATIC,116,104,22,8\r
     LTEXT           "Protocol:",IDC_STATIC,116,117,38,8\r
     LTEXT           "Default:",IDC_STATIC,116,130,27,8\r
-    LTEXT           "",IDC_PRINTER_NAME,172,78,113,8\r
+    LTEXT           "",IDC_PRINTER_NAME,172,78,113,8,SS_ENDELLIPSIS\r
     LTEXT           "",IDC_PRINTER_MANUFACTURER,172,91,113,8\r
     LTEXT           "",IDC_PRINTER_MODEL,172,104,113,8\r
     LTEXT           "",IDC_PRINTER_PROTOCOL,172,117,113,8\r
     LTEXT           "",IDC_PRINTER_DEFAULT,172,130,113,8\r
-    LTEXT           "To close this wizard, click Finish.",IDC_STATIC,116,187,\r
-                    103,8\r
+    LTEXT           "To complete the installation, click Finish.",IDC_STATIC,116,187,\r
+                    171,8\r
 END\r
 \r
 IDD_DIALOG1 DIALOGEX 0, 0, 265, 130\r
@@ -236,15 +235,15 @@ END
 \r
 STRINGTABLE \r
 BEGIN\r
-    IDS_ABOUTBOX            "&About Printer Setup Wizard..."\r
-    IDS_GOODBYE             "Completing the Bonjour Printer Setup Wizard."\r
-    IDS_GREETING            "Welcome to the Bonjour Printer Setup Wizard"\r
+    IDS_ABOUTBOX            "&About Bonjour Printer Wizard..."\r
+    IDS_GOODBYE             "Completing the Bonjour Printer Wizard."\r
+    IDS_GREETING            "Welcome to the Bonjour Printer Wizard"\r
     IDS_BROWSE_TITLE        "Browse for Bonjour Printers"\r
     IDS_BROWSE_SUBTITLE     "Select the printer you want to use from the list below."\r
     IDS_CAPTION             "Bonjour Printer Wizard"\r
-    IDS_GOODBYE_GOOD1       "You have successfully completed the Bonjour Printer Wizard.  The printer has the following settings:"\r
+    IDS_GOODBYE_GOOD1       "You are ready to complete the Bonjour Printer Wizard.  The printer has the following settings:"\r
     IDS_SEARCHING           "Searching for printers..."\r
-    IDS_GOODBYTE_GOOD2      "To close this wizard, click Finish."\r
+    IDS_GOODBYTE_GOOD2      "To complete the installation, click Finish."\r
     IDS_INSTALL_TITLE       "Install Bonjour Printer"\r
     IDS_INSTALL_SUBTITLE    "The manufacturer and model determine which printer software to use."\r
 END\r
index c97e842287839ddad98870a7c1a412a758168118..c8ea960e58161de109e899c00fe9500e587ee4d2 100755 (executable)
@@ -12,7 +12,7 @@
        <Configurations>\r
                <Configuration\r
                        Name="Debug|Win32"\r
-                       OutputDirectory=".\Debug\Resources\PrinterWizard.exe.Resources\en.lproj"\r
+                       OutputDirectory=".\Debug\PrinterWizard.Resources\en.lproj"\r
                        IntermediateDirectory=".\Debug"\r
                        ConfigurationType="2"\r
                        UseOfMFC="1"\r
@@ -57,9 +57,8 @@
                        <Tool\r
                                Name="VCPreLinkEventTool"\r
                                Description="Building Output Directories"\r
-                               CommandLine="if not exist Debug\Resources mkdir Debug\Resources\r
-if not exist Debug\Resources\PrinterWizard.exe.Resources mkdir Debug\Resources\PrinterWizard.exe.Resources\r
-if not exist Debug\Resources\PrinterWizard.exe.Resources\en.lproj mkdir Debug\Resources\PrinterWizard.exe.Resources\en.lproj\r
+                               CommandLine="if not exist Debug\PrinterWizard.Resources mkdir Debug\PrinterWizard.Resources\r
+if not exist Debug\PrinterWizard.Resources\en.lproj mkdir Debug\PrinterWizard.Resources\en.lproj\r
 "/>\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
@@ -73,7 +72,7 @@ if not exist Debug\Resources\PrinterWizard.exe.Resources\en.lproj mkdir Debug\Re
                </Configuration>\r
                <Configuration\r
                        Name="Release|Win32"\r
-                       OutputDirectory=".\Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources\en.lproj"\r
+                       OutputDirectory=".\Release\Root\Program Files\Bonjour\PrinterWizard.Resources\en.lproj"\r
                        IntermediateDirectory=".\Release"\r
                        ConfigurationType="2"\r
                        UseOfMFC="1"\r
@@ -123,9 +122,8 @@ if not exist Debug\Resources\PrinterWizard.exe.Resources\en.lproj mkdir Debug\Re
                                CommandLine="if not exist Release\Root mkdir Release\Root\r
 if not exist &quot;Release\Root\Program Files&quot; mkdir &quot;Release\Root\Program Files&quot;\r
 if not exist &quot;Release\Root\Program Files\Bonjour&quot; mkdir &quot;Release\Root\Program Files\Bonjour&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources\en.lproj&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources\en.lproj&quot;"/>\r
+if not exist &quot;Release\Root\Program Files\Bonjour\PrinterWizard.Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\PrinterWizard.Resources&quot;\r
+if not exist &quot;Release\Root\Program Files\Bonjour\PrinterWizard.Resources\en.lproj&quot; mkdir &quot;Release\Root\Program Files\Bonjour\PrinterWizard.Resources\en.lproj&quot;"/>\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
                                PreprocessorDefinitions="NDEBUG"\r
index 79424ffad9c085e18a4775c576f1e4f615209d28..33b9fe8ed30945f63404a8fb6bdaa4b666484463 100755 (executable)
@@ -12,7 +12,7 @@
        <Configurations>\r
                <Configuration\r
                        Name="Debug|Win32"\r
-                       OutputDirectory=".\Debug\Resources\PrinterWizard.exe.Resources"\r
+                       OutputDirectory=".\Debug\PrinterWizard.Resources"\r
                        IntermediateDirectory=".\Debug"\r
                        ConfigurationType="2"\r
                        UseOfMFC="1"\r
@@ -38,7 +38,7 @@
                                Name="VCCustomBuildTool"/>\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               OutputFile="$(OutDir)/PrinterWizard.dll"\r
+                               OutputFile="$(OutDir)/PrinterWizardResources.dll"\r
                                LinkIncremental="2"\r
                                GenerateDebugInformation="TRUE"\r
                                SubSystem="2"\r
@@ -57,8 +57,7 @@
                        <Tool\r
                                Name="VCPreLinkEventTool"\r
                                Description="Building Output Directories"\r
-                               CommandLine="if not exist Debug\Resources mkdir Debug\Resources\r
-if not exist Debug\Resources\PrinterWizard.exe.Resources mkdir Debug\Resources\PrinterWizard.exe.Resources"/>\r
+                               CommandLine="if not exist Debug\PrinterWizard.Resources mkdir Debug\PrinterWizard.Resources"/>\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
                                PreprocessorDefinitions="_DEBUG"\r
@@ -71,7 +70,7 @@ if not exist Debug\Resources\PrinterWizard.exe.Resources mkdir Debug\Resources\P
                </Configuration>\r
                <Configuration\r
                        Name="Release|Win32"\r
-                       OutputDirectory=".\Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources"\r
+                       OutputDirectory=".\Release\Root\Program Files\Bonjour\PrinterWizard.Resources"\r
                        IntermediateDirectory=".\Release"\r
                        ConfigurationType="2"\r
                        UseOfMFC="1"\r
@@ -97,7 +96,7 @@ if not exist Debug\Resources\PrinterWizard.exe.Resources mkdir Debug\Resources\P
                                Name="VCCustomBuildTool"/>\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               OutputFile="$(OutDir)/PrinterWizard.dll"\r
+                               OutputFile="$(OutDir)/PrinterWizardResources.dll"\r
                                LinkIncremental="1"\r
                                GenerateDebugInformation="FALSE"\r
                                SubSystem="2"\r
@@ -121,8 +120,7 @@ if not exist Debug\Resources\PrinterWizard.exe.Resources mkdir Debug\Resources\P
                                CommandLine="if not exist Release\Root mkdir Release\Root\r
 if not exist &quot;Release\Root\Program Files&quot; mkdir &quot;Release\Root\Program Files&quot;\r
 if not exist &quot;Release\Root\Program Files\Bonjour&quot; mkdir &quot;Release\Root\Program Files\Bonjour&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources&quot;\r
-if not exist &quot;Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources&quot;"/>\r
+if not exist &quot;Release\Root\Program Files\Bonjour\PrinterWizard.Resources&quot; mkdir &quot;Release\Root\Program Files\Bonjour\PrinterWizard.Resources&quot;"/>\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
                                PreprocessorDefinitions="NDEBUG"\r
index 75cda89d51ec2a8a856a6023b0fbcb7aece14b1b..378e56ce06071ee487f8049e20551c54ac1d0e24 100644 (file)
@@ -23,6 +23,9 @@
     Change History (most recent first):
     
 $Log: PrinterSetupWizardSheet.cpp,v $
+Revision 1.30  2005/04/13 17:46:22  shersche
+<rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
+
 Revision 1.29  2005/02/14 20:48:37  shersche
 <rdar://problem/4003710> Default pdl key to "application/postscript"
 
@@ -445,7 +448,7 @@ CPrinterSetupWizardSheet::InstallPrinterPDLAndLPR(Printer * printer, Service * s
        pInfo.pPortName                         =       printer->portName.GetBuffer();
        pInfo.pDriverName                       =       printer->modelName.GetBuffer();
        pInfo.pComment                          =       printer->displayModelName.GetBuffer();
-       pInfo.pLocation                         =       service->location.GetBuffer();
+       pInfo.pLocation                         =       q->location.GetBuffer();
        pInfo.pDevMode                          =       NULL;
        pInfo.pDevMode                          =       NULL;
        pInfo.pSepFile                          =       L"";
@@ -489,9 +492,12 @@ CPrinterSetupWizardSheet::InstallPrinterIPP(Printer * printer, Service * service
 {
        DEBUG_UNUSED( service );
 
+       Queue           *       q                = service->SelectedQueue();
        HANDLE                  hPrinter = NULL;
        PRINTER_INFO_2  pInfo;
        OSStatus                err;
+
+       check( q );
        
        //
        // add the printer
@@ -502,7 +508,7 @@ CPrinterSetupWizardSheet::InstallPrinterIPP(Printer * printer, Service * service
        pInfo.pPortName                 = printer->portName.GetBuffer();
        pInfo.pDriverName               = printer->modelName.GetBuffer();
        pInfo.pPrintProcessor   = L"winprint";
-       pInfo.pLocation                 = service->location.GetBuffer();
+       pInfo.pLocation                 = q->location.GetBuffer();
        pInfo.pComment                  = printer->displayModelName.GetBuffer();
        pInfo.Attributes                = PRINTER_ATTRIBUTE_NETWORK | PRINTER_ATTRIBUTE_LOCAL;
        
@@ -886,8 +892,6 @@ CPrinterSetupWizardSheet::OnResolve(
        CPrinterSetupWizardSheet        *       self;
        Service                                         *       service;
        Queue                                           *       q;
-       uint32_t                                                qpriority = kDefaultPriority;
-       CString                                                 qname;
        int                                                             idx;
        OSStatus                                                err;
 
@@ -925,13 +929,6 @@ CPrinterSetupWizardSheet::OnResolve(
        //
        service->portNumber = ntohs(inPort);
 
-       //
-       // parse the text record.
-       //
-
-       err = self->ParseTextRecord( service, inTXTSize, inTXT, qname, qpriority );
-       require_noerr( err, exit );
-
        if ( service->qtotal == 1 )
        {       
                //
@@ -948,10 +945,13 @@ CPrinterSetupWizardSheet::OnResolve(
 
                require_action( q, exit, err = E_OUTOFMEMORY );
 
+               //
+               // parse the text record.
+               //
+
+               err = self->ParseTextRecord( service, q, inTXTSize, inTXT );
+               require_noerr( err, exit );
 
-               q->name         = qname;
-               q->priority = qpriority;
-               
                service->queues.push_back( q );
 
                //
@@ -1033,7 +1033,7 @@ CPrinterSetupWizardSheet::OnQuery(
 
                require_action( q, exit, err = E_OUTOFMEMORY );
 
-               err = service->printer->window->ParseTextRecord( service, inRDLen, inTXT, q->name, q->priority );
+               err = service->printer->window->ParseTextRecord( service, q, inRDLen, inTXT );
                require_noerr( err, exit );
 
                //
@@ -1512,8 +1512,11 @@ exit:
 
 
 OSStatus
-CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize, const char * inTXT, CString & qname, uint32_t & qpriority )
+CPrinterSetupWizardSheet::ParseTextRecord( Service * service, Queue * q, uint16_t inTXTSize, const char * inTXT )
 {
+       check( service );
+       check( q );
+
        // <rdar://problem/3946587> Use TXTRecord APIs declared in dns_sd.h
        
        bool                    qtotalDefined   = false;
@@ -1524,11 +1527,11 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
 
        // <rdar://problem/3987680> Default to queue "lp"
 
-       qname = L"lp";
+       q->name = L"lp";
 
        // <rdar://problem/4003710> Default pdl key to be "application/postscript"
 
-       service->pdl = L"application/postscript";
+       q->pdl = L"application/postscript";
 
        if ( ( val = TXTRecordGetValuePtr( inTXTSize, inTXT, "rp", &len ) ) != NULL )
        {
@@ -1537,7 +1540,7 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
                memcpy( buf, val, len );
                buf[len] = '\0';
 
-               err = UTF8StringToStringObject( buf, qname );
+               err = UTF8StringToStringObject( buf, q->name );
                require_noerr( err, exit );
        }
        
@@ -1548,7 +1551,7 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
                memcpy( buf, val, len );
                buf[len] = '\0';
 
-               err = UTF8StringToStringObject( buf, service->pdl );
+               err = UTF8StringToStringObject( buf, q->pdl );
                require_noerr( err, exit );
        }
        
@@ -1560,7 +1563,7 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
                memcpy( buf, val, len );
                buf[len] = '\0';
 
-               err = UTF8StringToStringObject( buf, service->usb_MFG );
+               err = UTF8StringToStringObject( buf, q->usb_MFG );
                require_noerr( err, exit );
        }
        
@@ -1572,7 +1575,7 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
                memcpy( buf, val, len );
                buf[len] = '\0';
 
-               err = UTF8StringToStringObject( buf, service->usb_MDL );
+               err = UTF8StringToStringObject( buf, q->usb_MDL );
                require_noerr( err, exit );
        }
 
@@ -1583,7 +1586,7 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
                memcpy( buf, val, len );
                buf[len] = '\0';
 
-               err = UTF8StringToStringObject( buf, service->description );
+               err = UTF8StringToStringObject( buf, q->description );
                require_noerr( err, exit );
        }
                
@@ -1594,7 +1597,7 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
                memcpy( buf, val, len );
                buf[len] = '\0';
 
-               err = UTF8StringToStringObject( buf, service->product );
+               err = UTF8StringToStringObject( buf, q->product );
                require_noerr( err, exit );
        }
 
@@ -1605,7 +1608,7 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
                memcpy( buf, val, len );
                buf[len] = '\0';
 
-               err = UTF8StringToStringObject( buf, service->location );
+               err = UTF8StringToStringObject( buf, q->location );
                require_noerr( err, exit );
        }
 
@@ -1627,20 +1630,20 @@ CPrinterSetupWizardSheet::ParseTextRecord( Service * service, uint16_t inTXTSize
                memcpy( buf, val, len );
                buf[len] = '\0';
 
-               qpriority = atoi( buf );
+               q->priority = atoi( buf );
        }
 
 exit:
 
        // The following code is to fix a problem with older HP 
        // printers that don't include "qtotal" in their text
-       // record.  We'll check to see if the qname is "TEXT"
+       // record.  We'll check to see if the q->name is "TEXT"
        // and if so, we're going to modify it to be "lp" so
        // that we don't use the wrong queue
 
-       if ( !err && !qtotalDefined && ( qname == L"TEXT" ) )
+       if ( !err && !qtotalDefined && ( q->name == L"TEXT" ) )
        {
-               qname = "lp";
+               q->name = "lp";
        }
 
        return err;
index cf7f096f76b84b8b628efdcb3ddddc34d67d3746..3bf77a61462608fa66c137e8a88ea1acd5c7fbf5 100644 (file)
@@ -23,6 +23,9 @@
     Change History (most recent first):
     
 $Log: PrinterSetupWizardSheet.h,v $
+Revision 1.9  2005/04/13 17:46:22  shersche
+<rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
+
 Revision 1.8  2005/02/08 18:53:33  shersche
 Remove qtotalDefined parameter from ParseTextRecord()
 
@@ -241,7 +244,7 @@ private:
        StopResolve( Service * service );
 
        OSStatus
-       ParseTextRecord( Service * service, uint16_t inTXTSize, const char * inTXT, CString & qname, uint32_t & qpriority );
+       ParseTextRecord( Service * service, Queue * q, uint16_t inTXTSize, const char * inTXT );
 
        OSStatus
        LoadPrinterNames();
index 63665ee8f1f9e6bf05b10d4127b5711b32b18cc9..f5647a61a19073898e873f06ee7263a3a26869f3 100644 (file)
     Change History (most recent first):
     
 $Log: SecondPage.cpp,v $
+Revision 1.15  2005/04/13 17:46:22  shersche
+<rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
+
+Revision 1.14  2005/03/20 20:08:37  shersche
+<rdar://problem/4055670> Second screen should not select a printer by default
+
 Revision 1.13  2005/02/15 07:50:10  shersche
 <rdar://problem/4007151> Update name
 
@@ -131,6 +137,13 @@ CSecondPage::InitBrowseList()
        // disable the printer information box
        //
        SetPrinterInformationState( FALSE );
+       m_descriptionField.SetWindowText( L"" );
+       m_locationField.SetWindowText( L"" );
+
+       //
+       // and wait for the user to either hit the mouse or keyboard before selecting an item
+       //
+       m_gotChoice = false;
 
 exit:
 
@@ -182,6 +195,9 @@ CSecondPage::OnSetActive()
        Printer                                         *       printer;
        Printers::iterator                              it;
        OSStatus                                                err = kNoErr;
+       BOOL                                                    b;
+
+       b = CPropertyPage::OnSetActive();
 
        psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
        require_action( psheet, exit, err = kUnknownErr );
@@ -207,7 +223,7 @@ CSecondPage::OnSetActive()
 
 exit:
 
-       return CPropertyPage::OnSetActive();
+       return b;
 }
 
 
@@ -220,6 +236,8 @@ CSecondPage::OnKillActive()
 
 BEGIN_MESSAGE_MAP(CSecondPage, CPropertyPage)
        ON_NOTIFY(TVN_SELCHANGED, IDC_BROWSE_LIST, OnTvnSelchangedBrowseList)
+       ON_NOTIFY(NM_CLICK, IDC_BROWSE_LIST, OnNmClickBrowseList)
+       ON_NOTIFY(TVN_KEYDOWN, IDC_BROWSE_LIST, OnTvnKeyDownBrowseList)
        ON_WM_SETCURSOR()
 END_MESSAGE_MAP()
 
@@ -245,11 +263,6 @@ CSecondPage::OnAddPrinter(
        m_browseList.SetItemData( printer->item, (DWORD_PTR) printer );
 
        m_browseList.SortChildren(TVI_ROOT);
-               
-       if ( printer->name == m_selectedName )
-       {
-               m_browseList.SelectItem( printer->item );
-       }
 
        //
        // if the searching item is still in the list
@@ -333,9 +346,14 @@ CSecondPage::OnResolveService( Service * service )
 {
        CPrinterSetupWizardSheet * psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
        require_quiet( psheet, exit );
-       
+
        check( service );
 
+       Queue * q = service->SelectedQueue();
+
+       check( q );
+       
+
        //
        // and set it to selected
        //
@@ -347,8 +365,8 @@ CSecondPage::OnResolveService( Service * service )
        //
        SetPrinterInformationState( TRUE );
 
-       m_descriptionField.SetWindowText( service->description );
-       m_locationField.SetWindowText( service->location );
+       m_descriptionField.SetWindowText( q->description );
+       m_locationField.SetWindowText( q->location );
 
        //
        // reset the cursor
@@ -366,15 +384,43 @@ void CSecondPage::OnTvnSelchangedBrowseList(NMHDR *pNMHDR, LRESULT *pResult)
 {
        LPNMTREEVIEW                                    pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
        CPrinterSetupWizardSheet        *       psheet;
+       Printer                                         *       printer;
        int                                                             err = 0;
 
-       HTREEITEM item = m_browseList.GetSelectedItem();
-       require_quiet( item, exit );
-
        psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
-       require_action( psheet, exit, err = kUnknownErr );      
+       require_action( psheet, exit, err = kUnknownErr );
+
+       // The strange code here is to workaround a bug in the CTreeCtrl, whereupon the item
+       // we selected isn't passed through correctly to this callback routine.
+
+       if ( !m_gotChoice )
+       {
+               printer = psheet->GetSelectedPrinter();
+
+               // If we really haven't selected a printer, then re-select NULL and exit
+
+               if ( !printer )
+               {
+                       m_browseList.SelectItem( NULL );
 
-       Printer * printer;
+                       goto exit;
+               }
+
+               // If we already have selected a printer, fake like we've clicked on it, but only
+               // if the CTreeCtrl hasn't already selected it
+               
+               else if ( printer->item != m_browseList.GetSelectedItem() )
+               {
+                       m_gotChoice = true;
+
+                       m_browseList.SelectItem( printer->item );
+
+                       goto exit;
+               }
+       }
+
+       HTREEITEM item = m_browseList.GetSelectedItem();
+       require_quiet( item, exit );
 
        printer = reinterpret_cast<Printer*>(m_browseList.GetItemData( item ) );
        require_quiet( printer, exit );
@@ -410,6 +456,26 @@ exit:
 }
 
 
+void CSecondPage::OnNmClickBrowseList(NMHDR *pNMHDR, LRESULT *pResult)
+{
+       DEBUG_UNUSED( pNMHDR );
+
+       m_gotChoice = true;
+
+       *pResult = 0;
+}
+
+
+void CSecondPage::OnTvnKeyDownBrowseList( NMHDR * pNMHDR, LRESULT * pResult)
+{
+       DEBUG_UNUSED( pNMHDR );
+
+       m_gotChoice = true;
+
+       *pResult = 0;
+}
+
+
 void
 CSecondPage::LoadTextAndDisableWindow( CString & text )
 {
index aa0826083f910da34319936e6f2bf1ca53639569..5cf1852aa8093a5b0c5b0a75bd20fe31bf7405f7 100644 (file)
@@ -23,6 +23,9 @@
     Change History (most recent first):
     
 $Log: SecondPage.h,v $
+Revision 1.8  2005/03/20 20:08:37  shersche
+<rdar://problem/4055670> Second screen should not select a printer by default
+
 Revision 1.7  2005/01/31 23:54:30  shersche
 <rdar://problem/3947508> Start browsing when printer wizard starts. Move browsing logic from CSecondPage object to CPrinterSetupWizardSheet object.
 
@@ -95,6 +98,8 @@ public:
        bool                    m_waiting;
 
        afx_msg void    OnTvnSelchangedBrowseList(NMHDR *pNMHDR, LRESULT *pResult);
+       afx_msg void    OnNmClickBrowseList(NMHDR * pNMHDR, LRESULT * pResult);
+       afx_msg void    OnTvnKeyDownBrowseList(NMHDR * pNMHDR, LRESULT * pResult );
 
        OSStatus
        OnAddPrinter(
@@ -126,4 +131,6 @@ private:
        CStatic m_descriptionField;\r
        CStatic m_locationLabel;\r
        CStatic m_locationField;\r
+
+       bool    m_gotChoice;
 };
index acd8d3c5374d4ece89560516cf26577f7ac8b033..8da4d40e8a7edd7d172a8cb1a49f6fa7815c92dc 100644 (file)
     Change History (most recent first):
     
 $Log: ThirdPage.cpp,v $
+Revision 1.23  2005/04/18 02:33:47  shersche
+<rdar://problem/4091216> Default printer option cannot be deselected
+
+Revision 1.22  2005/04/13 17:46:22  shersche
+<rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
+
+Revision 1.21  2005/03/30 02:09:55  shersche
+Auto-resize the column width to account for differing fonts and font sizes
+
 Revision 1.20  2005/03/05 02:27:45  shersche
 <rdar://problem/4030388> Generic drivers don't do color
 
@@ -1039,20 +1048,27 @@ OSStatus CThirdPage::MatchPrinter(Manufacturers & manufacturers, Printer * print
        CString                                 text;
        OSStatus                                err                                     =       kNoErr;
 
+       check( printer );
+       check( service );
+
+       Queue * q = service->SelectedQueue();
+
+       check( q );
+
        //
        // first look to see if we have a usb_MFG descriptor
        //
-       if (service->usb_MFG.GetLength() > 0)
+       if ( q->usb_MFG.GetLength() > 0)
        {
-               manufacturer = MatchManufacturer( manufacturers, ConvertToManufacturerName ( service->usb_MFG ) );
+               manufacturer = MatchManufacturer( manufacturers, ConvertToManufacturerName ( q->usb_MFG ) );
        }
 
        if ( manufacturer == NULL )
        {
-               service->product.Remove('(');
-               service->product.Remove(')');
+               q->product.Remove('(');
+               q->product.Remove(')');
 
-               manufacturer = MatchManufacturer( manufacturers, ConvertToManufacturerName ( service->product ) );
+               manufacturer = MatchManufacturer( manufacturers, ConvertToManufacturerName ( q->product ) );
        }
        
        //
@@ -1060,17 +1076,17 @@ OSStatus CThirdPage::MatchPrinter(Manufacturers & manufacturers, Printer * print
        //
        if ( manufacturer != NULL )
        {
-               if (service->usb_MDL.GetLength() > 0)
+               if ( q->usb_MDL.GetLength() > 0 )
                {
-                       model = MatchModel ( manufacturer, ConvertToModelName ( service->usb_MDL ) );
+                       model = MatchModel ( manufacturer, ConvertToModelName ( q->usb_MDL ) );
                }
 
-               if ( ( model == NULL ) && ( service->product.GetLength() > 0 ) )
+               if ( ( model == NULL ) && ( q->product.GetLength() > 0 ) )
                {
-                       service->product.Remove('(');
-                       service->product.Remove(')');
+                       q->product.Remove('(');
+                       q->product.Remove(')');
 
-                       model = MatchModel ( manufacturer, ConvertToModelName ( service->product ) );
+                       model = MatchModel ( manufacturer, ConvertToModelName ( q->product ) );
                }
 
                if ( model != NULL )
@@ -1254,12 +1270,18 @@ CThirdPage::MatchGeneric( Printer * printer, Service * service, Manufacturer **
 
        DEBUG_UNUSED( printer );
 
+       check( service );
+
+       Queue * q = service->SelectedQueue();
+
+       check( q );
+
        Manufacturers::iterator iter = m_manufacturers.find( kGenericManufacturer );
        require_action_quiet( iter != m_manufacturers.end(), exit, ok = FALSE );
 
        *manufacturer = iter->second;
 
-       pdl = service->pdl;
+       pdl = q->pdl;
        pdl.MakeLower();
 
        if ( pdl.Find( kPDLPCLKey ) != -1 )
@@ -1323,11 +1345,11 @@ OSStatus CThirdPage::OnInitPage()
        // selection notice
        //
        header.LoadString(IDS_MANUFACTURER_HEADING);
-       m_manufacturerListCtrl.InsertColumn(0, header, LVCFMT_LEFT, 138);
+       m_manufacturerListCtrl.InsertColumn(0, header, LVCFMT_LEFT, -1 );
        m_manufacturerSelected = NULL;
 
        header.LoadString(IDS_MODEL_HEADING);
-       m_modelListCtrl.InsertColumn(0, header, LVCFMT_LEFT, 247);
+       m_modelListCtrl.InsertColumn(0, header, LVCFMT_LEFT, -1 );
        m_modelSelected = NULL;
 
        return (err);
@@ -1431,6 +1453,8 @@ CThirdPage::PopulateUI(Manufacturers & manufacturers)
                nIndex = m_manufacturerListCtrl.InsertItem(0, manufacturer->name);
 
                m_manufacturerListCtrl.SetItemData(nIndex, (DWORD_PTR) manufacturer);
+
+               m_manufacturerListCtrl.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER );
        }
 
        return 0;
@@ -1471,6 +1495,8 @@ void CThirdPage::OnLvnItemchangedManufacturer(NMHDR *pNMHDR, LRESULT *pResult)
                        int nItem = m_modelListCtrl.InsertItem( 0, model->displayName );
 
                        m_modelListCtrl.SetItemData(nItem, (DWORD_PTR) model);
+
+                       m_modelListCtrl.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER );
                }
 
                m_modelListCtrl.SetRedraw(TRUE);
@@ -1531,7 +1557,7 @@ void CThirdPage::OnBnClickedDefaultPrinter()
        printer = psheet->GetSelectedPrinter();
        require_quiet( printer, exit );
 
-       printer->deflt = m_defaultPrinterCtrl.GetState() ? true : false;
+       printer->deflt = ( m_defaultPrinterCtrl.GetCheck() == BST_CHECKED ) ? true : false;
 
 exit:
 
index 5e2fe196ef91357c12bc4e211281a1b83ce7ac21..4496e0cc8acc98d6aa1a3c4a0ef4a9ec19c6c9de 100644 (file)
     Change History (most recent first):
     
 $Log: UtilTypes.h,v $
+Revision 1.13  2005/04/13 17:46:22  shersche
+<rdar://problem/4082122> Generic PCL not selected when printers advertise multiple text records
+
+Revision 1.12  2005/03/16 03:12:28  shersche
+<rdar://problem/4050504> Generic PCL driver isn't selected correctly on Win2K
+
 Revision 1.11  2005/03/05 02:27:46  shersche
 <rdar://problem/4030388> Generic drivers don't do color
 
@@ -149,6 +155,9 @@ namespace PrinterSetupWizard
 
                ~Service();
 
+               Queue*
+               SelectedQueue();
+
                void
                EmptyQueues();
 
@@ -163,12 +172,6 @@ namespace PrinterSetupWizard
                DNSServiceRef   serviceRef;
                CString                 hostname;
                unsigned short  portNumber;
-               CString                 pdl;
-               CString                 usb_MFG;
-               CString                 usb_MDL;
-               CString                 description;
-               CString                 location;
-               CString                 product;
                CString                 protocol;
                unsigned short  qtotal;
 
@@ -194,6 +197,12 @@ namespace PrinterSetupWizard
 
                CString         name;
                uint32_t        priority;
+               CString         pdl;
+               CString         usb_MFG;
+               CString         usb_MDL;
+               CString         description;
+               CString         location;
+               CString         product;
        };
 
 
@@ -269,6 +278,12 @@ namespace PrinterSetupWizard
                EmptyQueues();
        }
 
+       inline Queue*
+       Service::SelectedQueue()
+       {
+               return queues.front();
+       }
+
        inline void
        Service::EmptyQueues()
        {
@@ -301,7 +316,7 @@ namespace PrinterSetupWizard
                {
                        Model * model = *it;
 
-                       if ( model->name = name )
+                       if ( model->name == name )
                        {
                                return model;
                        }
index 22130b3de3ee242e78b347bc07d177cf3cd44a10..b737f473253cde006f562cdca30f025db8646439 100644 (file)
Binary files a/Clients/PrinterSetupWizard/res/NetworkPrinter.ico and b/Clients/PrinterSetupWizard/res/NetworkPrinter.ico differ
index 22130b3de3ee242e78b347bc07d177cf3cd44a10..b737f473253cde006f562cdca30f025db8646439 100644 (file)
Binary files a/Clients/PrinterSetupWizard/res/Print.ico and b/Clients/PrinterSetupWizard/res/Print.ico differ
index 699a93286da4ad51aa85c27cf8f944ddc1a808cc..2fdc66f8b77e8627960938266212893d6e5621bf 100644 (file)
@@ -550,7 +550,7 @@ static DNSServiceErrorType RegisterService(DNSServiceRef *sdRef,
        for (i = 0; i < argc; i++)
                {
                unsigned char *len = ptr++;
-               *len = strlen(argv[i]);
+               *len = (unsigned char) strlen(argv[i]);
                strcpy((char*)ptr, argv[i]);
                ptr += *len;
                }
@@ -558,7 +558,7 @@ static DNSServiceErrorType RegisterService(DNSServiceRef *sdRef,
        printf("Registering Service %s.%s%s", nam, typ, dom);
        if (host && *host) printf(" host %s", host);
        printf(" port %s %s\n", port, txt);
-       return(DNSServiceRegister(sdRef, /* kDNSServiceFlagsAllowRemoteQuery */ 0, opinterface, nam, typ, dom, host, registerPort.NotAnInteger, ptr-txt, txt, reg_reply, NULL));
+       return(DNSServiceRegister(sdRef, /* kDNSServiceFlagsAllowRemoteQuery */ 0, opinterface, nam, typ, dom, host, registerPort.NotAnInteger, (uint16_t) (ptr-txt), txt, reg_reply, NULL));
        }
 
 int main(int argc, char **argv)
@@ -584,6 +584,14 @@ int main(int argc, char **argv)
                printf("Using LocalOnly\n");
                }
 
+       if (argc > 2 && !strcmp(argv[1], "-i") && atoi(argv[2]))
+               {
+               opinterface = atoi(argv[2]);
+               argc -= 2;
+               argv += 2;
+               printf("Using interface %d\n", opinterface);
+               }
+
        if (argc < 2) goto Fail;        // Minimum command line is the command name and one argument
        operation = getfirstoption( argc, argv, "EFBLQRPAUNTMI", &optind);
        if (operation == -1) goto Fail;
index 049754259ed09395919aa4c917fdaad9005cff12..924853bfc4c4302208834b80edb9a7d95565fec2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
 
 include /Developer/Makefiles/pb_makefiles/platform.make
 
-MVERS = "mDNSResponder-107"
+MVERS = "mDNSResponder-107.1"
 
 install:
        cd "$(SRCROOT)/mDNSMacOSX"; xcodebuild install     OBJROOT=$(OBJROOT) SYMROOT=$(SYMROOT) DSTROOT=$(DSTROOT) MVERS=$(MVERS)
index a2039b91936b2ba81dc3cec181ae6ef93fd2f338..2ce24894e8665cb9216b3c06239340b2449742ad 100644 (file)
     Change History (most recent first):
 
 $Log: DNSCommon.c,v $
+Revision 1.90  2005/03/21 00:33:51  shersche
+<rdar://problem/4021486> Fix build warnings on Win32 platform
+
+Revision 1.89  2005/03/17 18:59:38  ksekar
+<rdar://problem/4012279> Properly parse multiple LLQ Options per packet on Windows
+
+Revision 1.88  2005/03/16 00:42:32  ksekar
+<rdar://problem/4012279> Long-lived queries not working on Windows
+
 Revision 1.87  2005/02/25 04:21:00  cheshire
 <rdar://problem/4015377> mDNS -F returns the same domain multiple times with different casing
 
@@ -1028,7 +1037,7 @@ mDNSexport void AppendLabelSuffix(domainlabel *name, mDNSu32 val, mDNSBool RichT
 
        while (val >= divisor * 10) { divisor *= 10; chars++; }
 
-       name->c[0] = TruncateUTF8ToLength(name->c+1, name->c[0], MAX_DOMAIN_LABEL - chars);
+       name->c[0] = (mDNSu8) TruncateUTF8ToLength(name->c+1, name->c[0], MAX_DOMAIN_LABEL - chars);
 
        if (RichText) { name->c[++name->c[0]] = ' '; name->c[++name->c[0]] = '('; }
        else          { name->c[++name->c[0]] = '-'; }
@@ -1342,14 +1351,14 @@ mDNSlocal mDNSu8 *putOptRData(mDNSu8 *ptr, const mDNSu8 *limit, ResourceRecord *
                nput += 2 * sizeof(mDNSu16);
                if (opt->opt == kDNSOpt_LLQ)
                        {
-                       if (ptr + sizeof(LLQOptData) > limit) goto space_err;
+                       if (ptr + LLQ_OPTLEN > limit) goto space_err;
                        ptr = putVal16(ptr, opt->OptData.llq.vers);
                        ptr = putVal16(ptr, opt->OptData.llq.llqOp);
                        ptr = putVal16(ptr, opt->OptData.llq.err);
                        mDNSPlatformMemCopy(opt->OptData.llq.id, ptr, 8);  // 8-byte id
                        ptr += 8;
                        ptr = putVal32(ptr, opt->OptData.llq.lease);
-                       nput += sizeof(LLQOptData);
+                       nput += LLQ_OPTLEN;
                        }
                else if (opt->opt == kDNSOpt_Lease)
                        {
@@ -1377,11 +1386,10 @@ mDNSlocal mDNSu16 getVal16(const mDNSu8 **ptr)
 mDNSlocal const mDNSu8 *getOptRdata(const mDNSu8 *ptr, const mDNSu8 *limit, ResourceRecord *rr, mDNSu16 pktRDLen)
        {
        int nread = 0;
-       rdataOpt *opt;
-       
-       while (nread < pktRDLen)
+       rdataOpt *opt = (rdataOpt *)rr->rdata->u.data;
+
+       while (nread < pktRDLen && (mDNSu8 *)opt < rr->rdata->u.data + MaximumRDSize - sizeof(rdataOpt))
                {
-               opt = (rdataOpt *)(rr->rdata->u.data + nread);
                // space for opt + optlen
                if (nread + (2 * sizeof(mDNSu16)) > rr->rdata->MaxRDLength) goto space_err;
                opt->opt = getVal16(&ptr);
@@ -1389,7 +1397,7 @@ mDNSlocal const mDNSu8 *getOptRdata(const mDNSu8 *ptr, const mDNSu8 *limit, Reso
                nread += 2 * sizeof(mDNSu16);
                if (opt->opt == kDNSOpt_LLQ)
                        {
-                       if ((unsigned)(limit - ptr) < sizeof(LLQOptData)) goto space_err;
+                       if ((unsigned)(limit - ptr) < LLQ_OPTLEN) goto space_err;
                        opt->OptData.llq.vers = getVal16(&ptr);
                        opt->OptData.llq.llqOp = getVal16(&ptr);
                        opt->OptData.llq.err = getVal16(&ptr);
@@ -1399,7 +1407,7 @@ mDNSlocal const mDNSu8 *getOptRdata(const mDNSu8 *ptr, const mDNSu8 *limit, Reso
                        if (opt->OptData.llq.lease > 0x70000000UL / mDNSPlatformOneSecond)
                                opt->OptData.llq.lease = 0x70000000UL / mDNSPlatformOneSecond;
                        ptr += sizeof(mDNSOpaque32);
-                       nread += sizeof(LLQOptData);
+                       nread += LLQ_OPTLEN;
                        }
                else if (opt->opt == kDNSOpt_Lease)
                        {
@@ -1412,6 +1420,7 @@ mDNSlocal const mDNSu8 *getOptRdata(const mDNSu8 *ptr, const mDNSu8 *limit, Reso
                        nread += sizeof(mDNSs32);
                        }
                else { LogMsg("ERROR: getOptRdata - unknown opt %d", opt->opt); return mDNSNULL; }
+               opt++;  // increment pointer into rdatabody
                }
        
        rr->rdlength = pktRDLen;
@@ -1629,8 +1638,8 @@ mDNSexport mDNSu8 *putUpdateLease(DNSMessage *msg, mDNSu8 *end, mDNSu32 lease)
        
        opt->RecordType = kDNSRecordTypeKnownUnique;  // to avoid warnings in other layers
        opt->rrtype = kDNSType_OPT;
-       opt->rdlength = LEASE_OPT_SIZE;
-       opt->rdestimate = LEASE_OPT_SIZE;
+       opt->rdlength = LEASE_OPT_RDLEN;
+       opt->rdestimate = LEASE_OPT_RDLEN;
 
        optRD = &rr.resrec.rdata->u.opt;
        optRD->opt = kDNSOpt_Lease;
index 1b11e11993444bcfeccb2208b293aa526224c227..13b7ca80f2bc64dbbd1cf8d41316b63559e986c6 100644 (file)
@@ -23,6 +23,9 @@
     Change History (most recent first):
 
 $Log: DNSCommon.h,v $
+Revision 1.32  2005/03/21 00:33:51  shersche
+<rdar://problem/4021486> Fix build warnings on Win32 platform
+
 Revision 1.31  2005/02/18 00:43:11  cheshire
 <rdar://problem/4010245> mDNSResponder should auto-truncate service names that are too long
 
@@ -314,7 +317,7 @@ extern const mDNSu8 *getDomainName(const DNSMessage *const msg, const mDNSu8 *pt
 extern const mDNSu8 *skipResourceRecord(const DNSMessage *msg, const mDNSu8 *ptr, const mDNSu8 *end);
 
 extern const mDNSu8 *GetLargeResourceRecord(mDNS *const m, const DNSMessage * const msg, const mDNSu8 *ptr, 
-    const mDNSu8 * const end, const mDNSInterfaceID InterfaceID, mDNSu8 RecordType, LargeCacheRecord *largecr);
+    const mDNSu8 * end, const mDNSInterfaceID InterfaceID, mDNSu8 RecordType, LargeCacheRecord *largecr);
 
 extern const mDNSu8 *skipQuestion(const DNSMessage *msg, const mDNSu8 *ptr, const mDNSu8 *end);
 
index d89a42bce2ab23fb9f50f5dc44f45aec1b2a9aa8..e68c865ab07a6abe99fcdc92224a7cd0324f015d 100755 (executable)
@@ -45,6 +45,9 @@
     Change History (most recent first):
 
 $Log: mDNS.c,v $
+Revision 1.523  2005/03/21 00:33:51  shersche
+<rdar://problem/4021486> Fix build warnings on Win32 platform
+
 Revision 1.522  2005/03/04 21:48:12  cheshire
 <rdar://problem/4037283> Fractional time rounded down instead of up on platforms with coarse clock granularity
 
@@ -3136,7 +3139,7 @@ mDNSlocal void SendResponses(mDNS *const m)
                                        newptr = PutResourceRecordTTL(&m->omsg, responseptr, &m->omsg.h.numAnswers, &rr->resrec, m->SleepState ? 0 : rr->resrec.rroriginalttl);
                                        rr->resrec.rrclass &= ~kDNSClass_UniqueRRSet;                   // Make sure to clear cache flush bit back to normal state
                                        if (!newptr && m->omsg.h.numAnswers) break;
-                                       rr->RequireGoodbye = !m->SleepState;
+                                       rr->RequireGoodbye = (mDNSu8) (!m->SleepState);
                                        if (rr->LastAPTime == m->timenow) numAnnounce++; else numAnswer++;
                                        responseptr = newptr;
                                        }
index 852322fc5e0b1531b7618739e3d908977db6ee97..70439f312d64f8b26cabaa288770d739016d9901 100755 (executable)
@@ -60,6 +60,9 @@
     Change History (most recent first):
 
 $Log: mDNSEmbeddedAPI.h,v $
+Revision 1.282  2005/03/16 00:42:32  ksekar
+<rdar://problem/4012279> Long-lived queries not working on Windows
+
 Revision 1.281  2005/02/25 17:47:44  ksekar
 <rdar://problem/4021868> SendServiceRegistration fails on wake from sleep
 
@@ -1367,6 +1370,11 @@ typedef packedstruct
        mDNSu32 lease;
        } LLQOptData;
 
+#define LLQ_OPTLEN ((3 * sizeof(mDNSu16)) + 8 + sizeof(mDNSu32))
+// Windows adds pad bytes to sizeof(LLQOptData).  Use this macro when setting length fields or validating option rdata from
+// off the wire.  Use sizeof(LLQOptData) when dealing with structures (e.g. memcpy).  Never memcpy between on-the-wire
+// representation and a structure
+       
 // NOTE: rdataOpt format may be repeated an arbitrary number of times in a single resource record
 typedef packedstruct
        {
@@ -1773,8 +1781,8 @@ typedef struct
 #define kLLQOp_Refresh   2
 #define kLLQOp_Event     3
 
-#define LLQ_OPT_SIZE (2 * sizeof(mDNSu16)) + sizeof(LLQOptData)
-#define LEASE_OPT_SIZE (2 * sizeof(mDNSu16)) + sizeof(mDNSs32)
+#define LLQ_OPT_RDLEN ((2 * sizeof(mDNSu16)) + LLQ_OPTLEN)
+#define LEASE_OPT_RDLEN (2 * sizeof(mDNSu16)) + sizeof(mDNSs32)
 
 // LLQ Errror Codes
 enum
index e9d0991119e79ebdefed692e2b50098b9f96e36d..f4ca81817c4c882f729adf647f3a85a84791582a 100755 (executable)
     Change History (most recent first):
 
 $Log: uDNS.c,v $
+Revision 1.206  2005/03/31 02:19:55  cheshire
+<rdar://problem/4021486> Fix build warnings
+Reviewed by: Scott Herscher
+
+Revision 1.205  2005/03/21 00:33:51  shersche
+<rdar://problem/4021486> Fix build warnings on Win32 platform
+
+Revision 1.204  2005/03/16 00:42:32  ksekar
+<rdar://problem/4012279> Long-lived queries not working on Windows
+
 Revision 1.203  2005/03/04 03:00:03  ksekar
 <rdar://problem/4026546> Retransmissions happen too early, causing registrations to conflict with themselves
 
@@ -2425,7 +2435,7 @@ mDNSlocal void SetUpdateExpiration(mDNS *m, DNSMessage *msg, const mDNSu8 *end,
                        if (!ptr) break;
                        if (lcr.r.resrec.rrtype == kDNSType_OPT)
                                {
-                               if (lcr.r.resrec.rdlength < LEASE_OPT_SIZE) continue;
+                               if (lcr.r.resrec.rdlength < LEASE_OPT_RDLEN) continue;
                                if (lcr.r.resrec.rdata->u.opt.opt != kDNSOpt_Lease) continue;
                                lease = lcr.r.resrec.rdata->u.opt.OptData.lease;
                                break;
@@ -2616,13 +2626,13 @@ mDNSlocal mDNSu8 *putLLQ(DNSMessage *const msg, mDNSu8 *ptr, DNSQuestion *questi
        // format opt rr (fields not specified are zero-valued)
        ubzero(&rr, sizeof(AuthRecord));
        mDNS_SetupResourceRecord(&rr, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, mDNSNULL, mDNSNULL);
-       opt->rdlength = LLQ_OPT_SIZE;
-       opt->rdestimate = LLQ_OPT_SIZE;
+       opt->rdlength = LLQ_OPT_RDLEN;
+       opt->rdestimate = LLQ_OPT_RDLEN;
 
        optRD = &rr.resrec.rdata->u.opt;
        optRD->opt = kDNSOpt_LLQ;
-       optRD->optlen = sizeof(LLQOptData);
-       umemcpy(&optRD->OptData.llq, data, sizeof(LLQOptData));
+       optRD->optlen = LLQ_OPTLEN;
+       umemcpy(&optRD->OptData.llq, data, sizeof(*data));
        ptr = PutResourceRecordTTLJumbo(msg, ptr, &msg->h.numAdditionals, opt, 0);
        if (!ptr) { LogMsg("ERROR: putLLQ - PutResourceRecordTTLJumbo"); return mDNSNULL; }
 
@@ -2636,17 +2646,19 @@ mDNSlocal mDNSBool getLLQAtIndex(mDNS *m, DNSMessage *msg, const mDNSu8 *end, LL
        int i;
        const mDNSu8 *ptr;
        
+       ubzero(&lcr, sizeof(lcr));
+       
        ptr = LocateAdditionals(msg, end);
        if (!ptr) return mDNSfalse;
-
+       
        // find the last additional
        for (i = 0; i < msg->h.numAdditionals; i++)
 //             { ptr = GetLargeResourceRecord(m, msg, ptr, end, 0, kDNSRecordTypePacketAdd, &lcr); if (!ptr) return mDNSfalse; }
 //!!!KRS workaround for LH server bug, which puts OPT as first additional
                { ptr = GetLargeResourceRecord(m, msg, ptr, end, 0, kDNSRecordTypePacketAdd, &lcr); if (!ptr) return mDNSfalse; if (lcr.r.resrec.rrtype == kDNSType_OPT) break; }
        if (lcr.r.resrec.rrtype != kDNSType_OPT) return mDNSfalse;
-       if (lcr.r.resrec.rdlength < (index + 1) * LLQ_OPT_SIZE) return mDNSfalse;  // rdata too small
-       umemcpy(llq, (mDNSu8 *)&lcr.r.resrec.rdata->u.opt.OptData.llq + (index * sizeof(LLQOptData)), sizeof(LLQOptData));      // !!! Should convert to host byte order?
+       if (lcr.r.resrec.rdlength < (index + 1) * LLQ_OPT_RDLEN) return mDNSfalse;  // rdata too small
+       umemcpy(llq, (mDNSu8 *)&lcr.r.resrec.rdata->u.opt.OptData.llq + (index * sizeof(*llq)), sizeof(*llq));
        return mDNStrue;
        }
 
@@ -3949,6 +3961,8 @@ mDNSlocal void SendServiceRegistration(mDNS *m, ServiceRecordSet *srs)
        AuthRecord *srv = &srs->RR_SRV;
        mDNSu32 i;
        
+       privport = zeroIPPort;
+       
        if (!rInfo->ns.ip.v4.NotAnInteger) { LogMsg("SendServiceRegistration - NS not set!"); return; }
 
        id = newMessageID(u);
@@ -4950,14 +4964,14 @@ mDNSexport void uDNS_Init(mDNS *const m)
        m->uDNS_info.nextevent = m->timenow_last + 0x78000000;
        }
 
-mDNSexport void uDNS_Sleep(mDNS *m)
+mDNSexport void uDNS_Sleep(mDNS *const m)
        {
        SuspendLLQs(m, mDNStrue);
        SleepServiceRegistrations(m);
        SleepRecordRegistrations(m);
        }
 
-mDNSexport void uDNS_Wake(mDNS *m)
+mDNSexport void uDNS_Wake(mDNS *const m)
        {
        RestartQueries(m);
        WakeServiceRegistrations(m);
index 85b68d577cce8955cd63c250a87c5579f22bc152..616d7122f7bd9171548ff7162261c3bb9e1ef94b 100755 (executable)
     Change History (most recent first):
 
 $Log: uDNS.h,v $
+Revision 1.31  2005/03/31 02:19:56  cheshire
+<rdar://problem/4021486> Fix build warnings
+Reviewed by: Scott Herscher
+
 Revision 1.30  2005/03/04 03:00:03  ksekar
 <rdar://problem/4026546> Retransmissions happen too early, causing registrations to conflict with themselves
 
@@ -147,9 +151,9 @@ extern mStatus uDNS_StartQuery(mDNS *const m, DNSQuestion *const question);
 extern mDNSBool uDNS_IsActiveQuery(DNSQuestion *const question, uDNS_GlobalInfo *u);  // returns true if OK to call StopQuery
 extern mStatus uDNS_StopQuery(mDNS *const m, DNSQuestion *const question);
        
-extern void uDNS_Init(mDNS *m);
-extern void uDNS_Sleep(mDNS *m);
-extern void uDNS_Wake(mDNS *m);
+extern void uDNS_Init(mDNS *const m);
+extern void uDNS_Sleep(mDNS *const m);
+extern void uDNS_Wake(mDNS *const m);
 #define uDNS_Close uDNS_Sleep
        
 // uDNS_UpdateRecord
index a518d9de105ba1b477be90789e04664bf81410ac..ab3b3453539d348c0a062eaf1da99f2c6daa6eea 100644 (file)
@@ -23,6 +23,9 @@
     Change History (most recent first):
 
 $Log: mDNSLibraryResources.r,v $
+Revision 1.32  2005/05/05 00:06:58  ksekar
+Update version string to 1.0a107.1
+
 Revision 1.31  2005/03/15 02:14:14  cheshire
 mDNSResponder-107
 
@@ -134,15 +137,15 @@ like Muse Research who want to be able to use mDNS/DNS-SD from GPL-licensed code
 
 resource 'vers' (1, purgeable)
        {
-   0x01, 0x00, alpha, 107, verUS,
-   "1.0a107",
-   "Multicast DNS & DNS Service Discovery 1.0a107"
+   0x01, 0x00, alpha, 107.1, verUS,
+   "1.0a107.1",
+   "Multicast DNS & DNS Service Discovery 1.0a107.1"
        };
 
 resource 'vers' (2, purgeable)
        {
-   0x01, 0x00, alpha, 107, verUS,
-   "1.0a107",
+   0x01, 0x00, alpha, 107.1, verUS,
+   "1.0a107.1",
    "developer.apple.com/darwin/projects/bonjour/"
        };
 
diff --git a/mDNSMacOSX/PreferencePane/BonjourPref.icns b/mDNSMacOSX/PreferencePane/BonjourPref.icns
new file mode 100644 (file)
index 0000000..97b560f
Binary files /dev/null and b/mDNSMacOSX/PreferencePane/BonjourPref.icns differ
diff --git a/mDNSMacOSX/PreferencePane/BonjourPref.tiff b/mDNSMacOSX/PreferencePane/BonjourPref.tiff
new file mode 100644 (file)
index 0000000..55cb212
Binary files /dev/null and b/mDNSMacOSX/PreferencePane/BonjourPref.tiff differ
diff --git a/mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.icns b/mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.icns
deleted file mode 100644 (file)
index 028a3a2..0000000
Binary files a/mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.icns and /dev/null differ
diff --git a/mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.tiff b/mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.tiff
deleted file mode 100644 (file)
index 985ae19..0000000
Binary files a/mDNSMacOSX/PreferencePane/DNSServiceDiscoveryPref.tiff and /dev/null differ
index 97ef5604d04c373de864085d3708404596892984..de12870102e51913e7a328edece68366422654a2 100644 (file)
     Change History (most recent first):
 
 $Log: daemon.c,v $
+Revision 1.257  2005/03/28 19:28:55  cheshire
+Fix minor typos in LogOperation() messages
+
+Revision 1.256  2005/03/17 22:01:22  cheshire
+Tidy up alignment of lines to make code more readable
+
 Revision 1.255  2005/03/09 00:48:43  cheshire
 <rdar://problem/4015157> QU packets getting sent too early on wake from sleep
 Move "m->p->NetworkChanged = 0;" line from caller to callee
@@ -899,8 +905,8 @@ mDNSlocal void AbortClient(mach_port_t ClientMachPort, void *m)
                while (qptr)
                        {
                        if (m && m != x)
-                               LogMsg("%5d: DNSServiceBrowser(%##s) STOP; WARNING m %p != x %p", ClientMachPort, qptr->q.qname.c, m, x);
-                       else LogOperation("%5d: DNSServiceBrowser(%##s) STOP", ClientMachPort, qptr->q.qname.c);
+                               LogMsg("%5d: DNSServiceBrowse(%##s) STOP; WARNING m %p != x %p", ClientMachPort, qptr->q.qname.c, m, x);
+                       else LogOperation("%5d: DNSServiceBrowse(%##s) STOP", ClientMachPort, qptr->q.qname.c);
                        mDNS_StopBrowse(&mDNSStorage, &qptr->q);
                        freePtr = qptr;
                        qptr = qptr->next;
@@ -922,8 +928,8 @@ mDNSlocal void AbortClient(mach_port_t ClientMachPort, void *m)
                DNSServiceResolver *x = *l;
                *l = (*l)->next;
                if (m && m != x)
-                       LogMsg("%5d: DNSServiceResolver(%##s) STOP; WARNING m %p != x %p", ClientMachPort, x->i.name.c, m, x);
-               else LogOperation("%5d: DNSServiceResolver(%##s) STOP", ClientMachPort, x->i.name.c);
+                       LogMsg("%5d: DNSServiceResolve(%##s) STOP; WARNING m %p != x %p", ClientMachPort, x->i.name.c, m, x);
+               else LogOperation("%5d: DNSServiceResolve(%##s) STOP", ClientMachPort, x->i.name.c);
                mDNS_StopResolveService(&mDNSStorage, &x->q);
                freeL("DNSServiceResolver", x);
                return;
@@ -973,19 +979,21 @@ mDNSlocal void AbortClientWithLogMessage(mach_port_t c, char *reason, char *msg,
        while (b && b->ClientMachPort != c) b = b->next;
        while (l && l->ClientMachPort != c) l = l->next;
        while (r && r->ClientMachPort != c) r = r->next;
-       if      (e)     LogMsg("%5d: DomainEnumeration(%##s) %s%s",                   c, e->dom.qname.c,            reason, msg);
+
+       if      (e) LogMsg("%5d: DomainEnumeration(%##s) %s%s",                   c, e->dom.qname.c,                reason, msg);
        else if (b)
-               {
-               for (qptr = b->qlist; qptr; qptr = qptr->next)
-                               LogMsg("%5d: Browser(%##s) %s%s",                             c, qptr->q.qname.c,              reason, msg);
-               }
-       else if (l)     LogMsg("%5d: Resolver(%##s) %s%s",                            c, l->i.name.c,               reason, msg);
+                       {
+                       for (qptr = b->qlist; qptr; qptr = qptr->next)
+                               LogMsg("%5d: Browser(%##s) %s%s",                             c, qptr->q.qname.c,               reason, msg);
+                       }
+       else if (l) LogMsg("%5d: Resolver(%##s) %s%s",                            c, l->i.name.c,                   reason, msg);
        else if (r)
-               {
-               ServiceInstance *si;
-               for (si = r->regs; si; si = si->next) LogMsg("%5d: Registration(%##s) %s%s", c, si->srs.RR_SRV.resrec.name->c, reason, msg);
-               }
-       else            LogMsg("%5d: (%s) %s, but no record of client can be found!", c,                            reason, msg);
+                       {
+                       ServiceInstance *si;
+                       for (si = r->regs; si; si = si->next)
+                               LogMsg("%5d: Registration(%##s) %s%s",                        c, si->srs.RR_SRV.resrec.name->c, reason, msg);
+                       }
+       else        LogMsg("%5d: (%s) %s, but no record of client can be found!", c,                                reason, msg);
 
        AbortClient(c, m);
        }
@@ -1407,7 +1415,7 @@ mDNSexport kern_return_t provide_DNSServiceResolverResolve_rpc(mach_port_t unuse
        DNSServiceResolverList = x;
 
        // Do the operation
-       LogOperation("%5d: DNSServiceResolver(%##s) START", client, x->i.name.c);
+       LogOperation("%5d: DNSServiceResolve(%##s) START", client, x->i.name.c);
        err = mDNS_StartResolveService(&mDNSStorage, &x->q, &x->i, FoundInstanceInfo, x);
        if (err) { AbortClient(client, x); errormsg = "mDNS_StartResolveService"; goto fail; }
 
index 8d553caf09daa9187db031bcf060f5294da97470..2b3e4eaf017d646ea70b961e4cb73327c9cd7c05 100644 (file)
     Change History (most recent first):
 
 $Log: mDNSMacOSX.c,v $
+Revision 1.310  2005/04/07 00:49:58  cheshire
+<rdar://problem/4080074> PPP connection disables Bonjour ".local" lookups
+
+Revision 1.309  2005/03/23 05:53:29  cheshire
+Fix %s where it should have been %##s in debugf & LogMsg calls
+
 Revision 1.308  2005/03/09 00:48:44  cheshire
 <rdar://problem/4015157> QU packets getting sent too early on wake from sleep
 Move "m->p->NetworkChanged = 0;" line from caller to callee
@@ -2141,9 +2147,12 @@ mDNSlocal mStatus UpdateInterfaceList(mDNS *const m, mDNSs32 utc)
                                                        else                                     v6Loopback = ifa;
                                                else
                                                        {
-                                                       AddInterfaceToList(m, ifa, utc);
-                                                       if (ifa->ifa_addr->sa_family == AF_INET) foundav4 = mDNStrue;
-                                                       else                                     foundav6 = mDNStrue;
+                                                       NetworkInterfaceInfoOSX *i = AddInterfaceToList(m, ifa, utc);
+                                                       if (i && i->Multicast)
+                                                               {
+                                                               if (ifa->ifa_addr->sa_family == AF_INET) foundav4 = mDNStrue;
+                                                               else                                     foundav6 = mDNStrue;
+                                                               }
                                                        }
                                                }
                                        }
@@ -2588,7 +2597,7 @@ mDNSlocal void FoundDomain(mDNS *const m, DNSQuestion *question, const ResourceR
                        {
                        if (SameDomainName(&ptr->ar.resrec.rdata->u.name, &answer->rdata->u.name))
                                {
-                               debugf("Deregistering PTR %s -> %s", ptr->ar.resrec.name->c, ptr->ar.resrec.rdata->u.name.c);
+                               debugf("Deregistering PTR %##s -> %##s", ptr->ar.resrec.name->c, ptr->ar.resrec.rdata->u.name.c);
                 dereg = &ptr->ar;
                                if (prev) prev->next = ptr->next;
                                else slElem->AuthRecs = ptr->next;
@@ -2755,7 +2764,7 @@ mDNSlocal mStatus RegisterSearchDomains(mDNS *const m, CFDictionaryRef dict)
                                {
                                AuthRecord *dereg = &arList->ar;
                                arList = arList->next;
-                               debugf("Deregistering PTR %s -> %s", dereg->resrec.name->c, dereg->resrec.rdata->u.name.c);
+                               debugf("Deregistering PTR %##s -> %##s", dereg->resrec.name->c, dereg->resrec.rdata->u.name.c);
                                err = mDNS_Deregister(m, dereg);
                                if (err) LogMsg("ERROR: RegisterSearchDomains mDNS_Deregister returned %d", err);
                                }
@@ -3304,7 +3313,7 @@ mDNSlocal void FoundLegacyBrowseDomain(mDNS *const m, DNSQuestion *question, con
                        prev = ptr;
                        ptr = ptr->next;
                        }
-               LogMsg("FoundLegacyBrowseDomain: Got remove event for domain %s not in list", answer->rdata->u.name.c);
+               LogMsg("FoundLegacyBrowseDomain: Got remove event for domain %##s not in list", answer->rdata->u.name.c);
                }
        }
 
index 3fe2b31063f896c1baedc39b4174c215c67bfe7f..37d071d1bc2f9e9765df5e4fa094f15a3b62bf36 100644 (file)
        <key>CFBundleGetInfoString</key>
        <string></string>
        <key>CFBundleIconFile</key>
-       <string>DNSServiceDiscoveryPref</string>
+       <string>BonjourPref</string>
        <key>CFBundleIdentifier</key>
        <string>com.apple.preference.bonjour</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <key>NSMainNibFile</key>
        <string>DNSServiceDiscoveryPref</string>
        <key>NSPrefPaneIconFile</key>
-       <string>DNSServiceDiscoveryPref.tiff</string>
+       <string>BonjourPref.tiff</string>
        <key>NSPrefPaneIconLabel</key>
        <string>Bonjour</string>
        <key>NSPrincipalClass</key>
                };
                FF260A3207B4466900CE10E5 = {
                        isa = PBXFileReference;
-                       name = DNSServiceDiscoveryPref.icns;
-                       path = PreferencePane/DNSServiceDiscoveryPref.icns;
+                       name = BonjourPref.icns;
+                       path = PreferencePane/BonjourPref.icns;
                        refType = 2;
                };
                FF260A3307B4466900CE10E5 = {
                        isa = PBXFileReference;
-                       name = DNSServiceDiscoveryPref.tiff;
-                       path = PreferencePane/DNSServiceDiscoveryPref.tiff;
+                       name = BonjourPref.tiff;
+                       path = PreferencePane/BonjourPref.tiff;
                        refType = 2;
                };
                FF260A3407B4466900CE10E5 = {
index 638b56d36ad4e7194113d793512b351b22c0768b..4ef7ccfb55635624adf270173baf13c2b14337b1 100755 (executable)
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # $Log: Makefile,v $
+# Revision 1.59  2005/04/14 21:07:10  rpantos
+# Bug #: 4089257, Clean build broken for Java support on POSIX
+# Submitted by: Roger Pantos
+# Reviewed by: Kiren Sekar
+#
+# Revision 1.58  2005/04/08 21:37:57  ksekar
+# <rdar://problem/3792767> get_ifi_info doesn't return IPv6 interfaces on Linux
+#
+# Revision 1.57  2005/03/17 04:02:28  cheshire
+# <rdar://problem/3986419> mDNSResponder won't compile with gcc4 on Tiger
+# Changed Makefile to link using gcc instead of libtool
+#
 # Revision 1.56  2005/02/02 02:25:21  cheshire
 # <rdar://problem/3980388> /var/run/mDNSResponder should be /var/run/mdnsd on Linux
 #
@@ -253,7 +265,7 @@ endif
 else
 
 ifeq ($(os),linux)
-CFLAGS_OS = -DNOT_HAVE_SA_LEN -DUSES_NETLINK
+CFLAGS_OS = -DNOT_HAVE_SA_LEN -DUSES_NETLINK -DHAVE_LINUX
 JAVACFLAGS_OS += -I$(JDK)/include/linux
 OPTIONALTARG = nss_mdns
 OPTINSTALL   = InstalledNSS
@@ -301,7 +313,7 @@ else
 ifeq ($(os),tiger)
 CFLAGS_OS = -DHAVE_IPV6 -no-cpp-precomp -Wdeclaration-after-statement
 CC = @gcc-4.0
-LD = libtool -dynamic
+LD = $(CC) -dynamiclib
 LIBFLAGS = -lSystem
 LDSUFFIX = dylib
 JDK = /System/Library/Frameworks/JavaVM.framework/Home
@@ -509,8 +521,8 @@ Java: setup $(BUILDDIR)/dns_sd.jar $(BUILDDIR)/libjdns_sd.$(LDSUFFIX)
 
 JAVASRC        = $(SHAREDDIR)/Java
 JARCONTENTS =  $(OBJDIR)/com/apple/dnssd/DNSSDService.class \
-                               $(OBJDIR)/com/apple/dnssd/DNSRecord.class \
                                $(OBJDIR)/com/apple/dnssd/DNSSDException.class \
+                               $(OBJDIR)/com/apple/dnssd/DNSRecord.class \
                                $(OBJDIR)/com/apple/dnssd/TXTRecord.class \
                                $(OBJDIR)/com/apple/dnssd/DNSSDRegistration.class \
                                $(OBJDIR)/com/apple/dnssd/BaseListener.class \
index 687507ebda1af75f4313d9587b6a784d40d21394..8903d8184a4ec90ccfcfbd8146669784978dbf91 100644 (file)
     Change History (most recent first):
 
 $Log: dnsextd.c,v $
+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  2005/03/11 19:09:02  ksekar
 Fixed ZERO_LLQID macro
 
@@ -529,7 +535,7 @@ mDNSlocal mDNSs32 GetPktLease(PktMsg *pkt)
                        if (!ptr) { Log("Unable to read additional record"); break; }
                        if (lcr.r.resrec.rrtype == kDNSType_OPT)
                                {
-                               if (lcr.r.resrec.rdlength < LEASE_OPT_SIZE) continue;
+                               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;
@@ -975,37 +981,30 @@ mDNSlocal void DeleteRecord(DaemonInfo *d, CacheRecord *rr, domainname *zone)
        if (reply) free(reply);
        }
 
-// iterate over table, deleting expired records
-mDNSlocal void DeleteExpiredRecords(DaemonInfo *d)
+// iterate over table, deleting expired records (or all records if DeleteAll is true)
+mDNSlocal void DeleteRecords(DaemonInfo *d, mDNSBool DeleteAll)
        {
        int i;
-       RRTableElem *ptr, *prev, *fptr; 
+       RRTableElem **ptr, *fptr;       
        struct timeval now;
 
-       if (gettimeofday(&now, NULL)) { LogErr("DeleteExpiredRecords ", "gettimeofday"); return; }
-       if (pthread_mutex_lock(&d->tablelock)) { LogErr("DeleteExpiredRecords", "pthread_mutex_lock"); return; }
+       if (gettimeofday(&now, NULL)) { LogErr("DeleteRecords ", "gettimeofday"); return; }
+       if (pthread_mutex_lock(&d->tablelock)) { LogErr("DeleteRecords", "pthread_mutex_lock"); return; }
        for (i = 0; i < d->nbuckets; i++)
                {
-               ptr = d->table[i];
-               prev = NULL;
-               while (ptr)
+               ptr = &d->table[i];
+               while (*ptr)
                        {
-                       if (ptr->expire - now.tv_sec < 0)
+                       if (DeleteAll || (*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;
+                               DeleteRecord(d, &(*ptr)->rr, &(*ptr)->zone);
+                               fptr = *ptr;
+                               *ptr = (*ptr)->next;
                                free(fptr);
                                d->nelems--;
                                }
-                       else
-                               {
-                               prev = ptr;
-                               ptr = ptr->next;
-                               }
+                       else ptr = &(*ptr)->next;
                        }
                }
        pthread_mutex_unlock(&d->tablelock);
@@ -1184,8 +1183,8 @@ mDNSlocal void FormatLLQOpt(AuthRecord *opt, int opcode, mDNSu8 *id, mDNSs32 lea
        {
        bzero(opt, sizeof(*opt));
        mDNS_SetupResourceRecord(opt, mDNSNULL, mDNSInterface_Any, kDNSType_OPT, kStandardTTL, kDNSRecordTypeKnownUnique, mDNSNULL, mDNSNULL);
-       opt->resrec.rdlength = LLQ_OPT_SIZE;
-       opt->resrec.rdestimate = LLQ_OPT_SIZE;
+       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;
@@ -1414,6 +1413,28 @@ 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;
@@ -1427,9 +1448,19 @@ mDNSlocal void PrintLLQTable(DaemonInfo *d)
                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));
+                       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);
                        e = e->next;
                        }
                }
@@ -1832,7 +1863,7 @@ mDNSlocal int RecvLLQ(DaemonInfo *d, PktMsg *pkt)
 
        // 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_SIZE) { Log("Malformatted LLQ from %s: Opt RR to small (%d bytes for %d questions)", addr, opt.r.resrec.rdlength, pkt->msg.h.numQuestions); }
+       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++)
@@ -1880,7 +1911,7 @@ mDNSlocal mDNSBool IsLLQRequest(PktMsg *pkt)
                }
        
        if (lcr.r.resrec.rrtype == kDNSType_OPT &&
-               lcr.r.resrec.rdlength >= LLQ_OPT_SIZE &&
+               lcr.r.resrec.rdlength >= LLQ_OPT_RDLEN &&
                lcr.r.resrec.rdata->u.opt.opt == kDNSOpt_LLQ)
                { result = mDNStrue; goto end; }
 
@@ -2030,7 +2061,7 @@ mDNSlocal int ListenForUpdates(DaemonInfo *d)
                if (gettimeofday(&timenow, NULL)) { LogErr("ListenForUpdates", "gettimeofday"); return -1; }
                if (timenow.tv_sec >= NextTableCheck)
                        {
-                       DeleteExpiredRecords(d);
+                       DeleteRecords(d, mDNSfalse);
                        NextTableCheck = timenow.tv_sec + EXPIRATION_INTERVAL;
                        }
                timeout.tv_sec = NextTableCheck - timenow.tv_sec;
@@ -2044,8 +2075,8 @@ mDNSlocal int ListenForUpdates(DaemonInfo *d)
                        {
                        if (errno == EINTR)
                                {
-                               if (terminate) { DeleteExpiredRecords(d); return 0; }
-                               else if (dumptable) { PrintLeaseTable(d); PrintLLQTable(d); dumptable = 0; }
+                               if (terminate) { DeleteRecords(d, mDNStrue); return 0; }
+                               else if (dumptable) { PrintLeaseTable(d); PrintLLQTable(d); PrintLLQAnswers(d); dumptable = 0; }
                                else Log("Received unhandled signal - continuing"); 
                                }
                        else { LogErr("ListenForUpdates", "select"); return -1; }
index 32a016cdd2ba15f13fdc2638afe196667db856aa..a0491386854647f844018a5a58b51d692ff3a45b 100755 (executable)
     Change History (most recent first):
 
 $Log: mDNSUNP.c,v $
+Revision 1.26  2005/04/08 21:43:59  ksekar
+<rdar://problem/4083426>  mDNSPosix (v98) retrieve interface list bug on AMD64 architecture
+Submitted by Andrew de Quincey
+
+Revision 1.25  2005/04/08 21:37:57  ksekar
+<rdar://problem/3792767> get_ifi_info doesn't return IPv6 interfaces on Linux
+
+Revision 1.24  2005/04/08 21:30:16  ksekar
+<rdar://problem/4007457> Compiling problems with mDNSResponder-98 on Solaris/Sparc v9
+Patch submitted by Bernd Kuhls
+
 Revision 1.23  2004/12/01 04:25:05  cheshire
 <rdar://problem/3872803> Darwin patches for Solaris and Suse
 Provide daemon() for platforms that don't have it
@@ -129,10 +140,135 @@ First checkin
     #include <net/if_dl.h>
 #endif
 
-#if defined(AF_INET6) && HAVE_IPV6
+#if defined(AF_INET6) && HAVE_IPV6 && !HAVE_LINUX
 #include <netinet6/in6_var.h>
 #endif
 
+#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
+#include <netdb.h>
+#include <arpa/inet.h>
+
+/* Converts a prefix length to IPv6 network mask */
+void plen_to_mask(int plen, char *addr) {
+       int i;
+       int colons=7; /* Number of colons in IPv6 address */
+       int bits_in_block=16; /* Bits per IPv6 block */
+       for(i=0;i<=colons;i++) {
+               int block, ones=0xffff, ones_in_block;
+               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);
+               plen -= ones_in_block;
+               }
+       }
+
+/* Gets IPv6 interface information from the /proc filesystem in linux*/
+struct ifi_info *get_ifi_info_linuxv6(int family, int doaliases)
+       {
+       struct ifi_info *ifi, *ifihead, **ifipnext;
+       FILE *fp;
+       char addr[8][5];
+       int flags, myflags, index, plen, scope;
+       char ifname[8], lastname[IFNAMSIZ];
+       char addr6[33];
+       struct addrinfo hints, *res0;
+       struct sockaddr_in6 *sin6;
+       struct in6_addr *addrptr;
+       int err;
+
+       res0=NULL;
+       ifihead = NULL;
+       ifipnext = &ifihead;
+       lastname[0] = 0;
+
+       if ((fp = fopen(PROC_IFINET6_PATH, "r")) != NULL) {
+               while (fscanf(fp,
+                                         "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %8s\n",
+                                         addr[0],addr[1],addr[2],addr[3],
+                                         addr[4],addr[5],addr[6],addr[7],
+                                         &index, &plen, &scope, &flags, ifname) != EOF) {
+
+                       myflags = 0;
+                       if (strncmp(lastname, ifname, IFNAMSIZ) == 0) {
+                               if (doaliases == 0)
+                                       continue;   /* already processed this interface */
+                               myflags = IFI_ALIAS;
+                               }
+                       memcpy(lastname, ifname, IFNAMSIZ);
+                       ifi = (struct ifi_info*)calloc(1, sizeof(struct ifi_info));
+                       if (ifi == NULL) {
+                               goto gotError;
+                               }
+
+                       *ifipnext = ifi;            /* prev points to this new one */
+                       ifipnext = &ifi->ifi_next;  /* pointer to next one goes here */
+
+                       sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",
+                                       addr[0],addr[1],addr[2],addr[3],
+                                       addr[4],addr[5],addr[6],addr[7]);
+
+                       /* Add address of the interface */
+                       memset(&hints, 0, sizeof(hints));
+                       hints.ai_family = AF_INET6;
+                       hints.ai_flags = AI_NUMERICHOST;
+                       err = getaddrinfo(addr6, NULL, &hints, &res0);
+                       if (err) {
+                               goto gotError;
+                               }
+                       ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in6));
+                       if (ifi->ifi_addr == NULL) {
+                               goto gotError;
+                               }
+                       memcpy(ifi->ifi_addr, res0->ai_addr, sizeof(struct sockaddr_in6));
+
+                       /* Add netmask of the interface */
+                       char ipv6addr[INET6_ADDRSTRLEN];
+                       plen_to_mask(plen, ipv6addr);
+                       ifi->ifi_netmask = calloc(1, sizeof(struct sockaddr_in6));
+                       if (ifi->ifi_addr == NULL) {
+                               goto gotError;
+                               }
+                       sin6=calloc(1, sizeof(struct sockaddr_in6));
+                       addrptr=calloc(1, sizeof(struct in6_addr));
+                       inet_pton(family, ipv6addr, addrptr);
+                       sin6->sin6_family=family;
+                       sin6->sin6_addr=*addrptr;
+                       sin6->sin6_scope_id=scope;
+                       memcpy(ifi->ifi_netmask, sin6, sizeof(struct sockaddr_in6));
+                       free(sin6);
+
+
+                       /* Add interface name */
+                       memcpy(ifi->ifi_name, ifname, IFI_NAME);
+
+                       /* Add interface index */
+                       ifi->ifi_index = index;
+
+                       /* If interface is in /proc then it is up*/
+                       ifi->ifi_flags = IFF_UP;
+
+                       freeaddrinfo(res0);
+                       res0=NULL;
+                       }
+               }
+       goto done;
+
+       gotError:
+       if (ifihead != NULL) {
+               free_ifi_info(ifihead);
+               ifihead = NULL;
+               }
+       if (res0 != NULL) {
+               freeaddrinfo(res0);
+               res0=NULL;
+               }
+       done:
+       return(ifihead);    /* pointer to first structure in linked list */
+       }
+#endif // defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
+
 struct ifi_info *get_ifi_info(int family, int doaliases)
 {
     int                 junk;
@@ -150,7 +286,11 @@ struct ifi_info *get_ifi_info(int family, int doaliases)
     struct sockaddr_in6 *sinptr6;
 #endif
 
-    sockfd = -1;
+#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
+ if(family == AF_INET6) return get_ifi_info_linuxv6(family, doaliases);
+#endif
+
+       sockfd = -1;
     sockf6 = -1;
     buf = NULL;
     ifihead = NULL;
@@ -191,7 +331,7 @@ struct ifi_info *get_ifi_info(int family, int doaliases)
         ifr = (struct ifreq *) ptr;
 
                len = GET_SA_LEN(ifr->ifr_addr);
-        ptr += sizeof(ifr->ifr_name) + len; /* for next one in buffer */
+               ptr += sizeof(struct ifreq); /* for next one in buffer */
     
 //        fprintf(stderr, "intf %d name=%s AF=%d\n", index, ifr->ifr_name, ifr->ifr_addr.sa_family);
         
@@ -534,6 +674,8 @@ struct in_pktinfo
 #ifdef NOT_HAVE_DAEMON
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <signal.h>
+
 int daemon(int nochdir, int noclose)
     {
        switch (fork())
index 786fef7e50a42940d444d7d4f95af61569defac5..912c9d8ff1a75c3ed7547b2114e1e4c2e693954b 100755 (executable)
@@ -24,6 +24,9 @@
     Change History (most recent first):
 
 $Log: mDNSUNP.h,v $
+Revision 1.18  2005/04/08 21:37:57  ksekar
+<rdar://problem/3792767> get_ifi_info doesn't return IPv6 interfaces on Linux
+
 Revision 1.17  2004/12/17 19:32:43  cheshire
 Add missing semicolon
 
@@ -90,6 +93,10 @@ First checkin
 #include <net/if.h>
 #include <netinet/in.h>
 
+#ifdef HAVE_LINUX
+#include <linux/socket.h>
+#endif
+
 #ifdef  __cplusplus
     extern "C" {
 #endif
@@ -99,8 +106,12 @@ First checkin
 #endif
 
 #if !defined(_SS_MAXSIZE)
-    #define sockaddr_storage sockaddr
-#endif
+#if HAVE_IPV6
+#define sockaddr_storage sockaddr_in6
+#else
+#define sockaddr_storage sockaddr
+#endif // HAVE_IPV6    
+#endif // !defined(_SS_MAXSIZE)
 
 #ifndef NOT_HAVE_SA_LEN
 #define GET_SA_LEN(X) (sizeof(struct sockaddr) > ((struct sockaddr*)&(X))->sa_len ? \
@@ -146,6 +157,17 @@ struct ifi_info {
   struct ifi_info  *ifi_next;   /* next of these structures */
 };
 
+#if defined(AF_INET6) && HAVE_IPV6 && HAVE_LINUX
+#define PROC_IFINET6_PATH "/proc/net/if_inet6"
+extern struct ifi_info  *get_ifi_info_linuxv6(int family, int doaliases);
+#endif
+       
+#if defined(AF_INET6) && HAVE_IPV6
+#define INET6_ADDRSTRLEN 46 /*Maximum length of IPv6 address */
+#endif
+       
+
+       
 #define IFI_ALIAS   1           /* ifi_addr is an alias */
 
 /* From the text (Stevens, section 16.6): */
index 423805fa990269c2ba755e1c3bc6f0a5c9f98ee5..a034e3e82b36562f3d50827f30ca2c46a6a82abf 100755 (executable)
@@ -34,6 +34,7 @@ Global
                {F4F15529-F0EB-402F-8662-73C5797EE557}.0 = {AB581101-18F0-46F6-B56A-83A6B1EA657E}\r
                {BB8AC1B5-6587-4163-BDC6-788B157705CA}.0 = {AB581101-18F0-46F6-B56A-83A6B1EA657E}\r
                {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.0 = {AB581101-18F0-46F6-B56A-83A6B1EA657E}\r
+               {F5D703B6-5612-4381-8BE2-2B7AEBAE58FC}.0 = {AB581101-18F0-46F6-B56A-83A6B1EA657E}\r
                {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.0 = {AB581101-18F0-46F6-B56A-83A6B1EA657E}\r
                {B1D2CDA2-CC8F-45D5-A694-2EE45B0308CF}.0 = {AB581101-18F0-46F6-B56A-83A6B1EA657E}\r
                {BB8AC1B5-6587-4163-BDC6-788B157705CA}.0 = {AB581101-18F0-46F6-B56A-83A6B1EA657E}\r
index 3baee26c699bb4c746625fd3f1c303c5b2bc9240..6ec40da052ad9c2a8856cb36a3e852db4e4f1d79 100644 (file)
     Change History (most recent first):
 
 $Log: PlatformCommon.c,v $
+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
+
 Revision 1.5  2005/02/01 19:33:30  ksekar
 <rdar://problem/3985239> Keychain format too restrictive
 
@@ -44,7 +48,7 @@ Move ReadDDNSSettingsFromConfFile() from mDNSMacOSX.c to PlatformCommon.c
 #include <stdio.h>                             // Needed for fopen() etc.
 #include <unistd.h>                            // Needed for close()
 #include <string.h>                            // Needed for strlen() etc.
-#include <sys/errno.h>                 // Needed for errno etc.
+#include <errno.h>                     // Needed for errno etc.
 #include <sys/socket.h>                        // Needed for socket() etc.
 #include <netinet/in.h>                        // Needed for sockaddr_in
 
index 81e0856d9a42f76856ec5e51563804b1a440ea33..fa18cce743257ce9dac49ffc5ec66af445fa04d1 100755 (executable)
 #include <windows.h>
 #define _UNUSED
 #define bzero(a, b) memset(a, 0, b)
+#ifndef _MSL_STDINT_H
 typedef UINT8       uint8_t;
 typedef INT8        int8_t;
 typedef UINT16      uint16_t;
 typedef INT16       int16_t;
 typedef UINT32      uint32_t;
 typedef INT32       int32_t;
+#endif
 #else
 #include <stdint.h>
 #endif
index 40ab0d0edbdbbf4a9c067e4e5f2c0bfcfe4f5fd4..6284b1e388170b1666fed01d5d72147fdea12b03 100755 (executable)
@@ -27,6 +27,9 @@
    Change History (most recent first):
 
 $Log: dnssd_clientlib.c,v $
+Revision 1.10  2005/04/06 02:06:56  shersche
+Add DNSSD_API macro to TXTRecord API calls
+
 Revision 1.9  2004/10/06 02:22:19  cheshire
 Changed MacRoman copyright symbol (should have been UTF-8 in any case :-) to ASCII-compatible "(c)"
 
@@ -196,7 +199,7 @@ struct dnssd_clientlib_CompileTimeAssertionCheck
        char assert0[(sizeof(TXTRecordRefRealType) <= 16) ? 1 : -1];
        };
 
-void TXTRecordCreate
+void DNSSD_API TXTRecordCreate
        (
        TXTRecordRef     *txtRecord,
        uint16_t         bufferLen,
@@ -209,12 +212,12 @@ void TXTRecordCreate
        txtRec->malloced = 0;
        }
 
-void TXTRecordDeallocate(TXTRecordRef *txtRecord)
+void DNSSD_API TXTRecordDeallocate(TXTRecordRef *txtRecord)
        {
        if (txtRec->malloced) free(txtRec->buffer);
        }
 
-DNSServiceErrorType TXTRecordSetValue
+DNSServiceErrorType DNSSD_API TXTRecordSetValue
        (
        TXTRecordRef     *txtRecord,
        const char       *key,
@@ -259,7 +262,7 @@ DNSServiceErrorType TXTRecordSetValue
        return(kDNSServiceErr_NoError);
        }
 
-DNSServiceErrorType TXTRecordRemoveValue
+DNSServiceErrorType DNSSD_API TXTRecordRemoveValue
        (
        TXTRecordRef     *txtRecord,
        const char       *key
@@ -276,8 +279,8 @@ DNSServiceErrorType TXTRecordRemoveValue
        return(kDNSServiceErr_NoError);
        }
 
-uint16_t       TXTRecordGetLength  (const TXTRecordRef *txtRecord) { return(txtRec->datalen); }
-const void *   TXTRecordGetBytesPtr(const TXTRecordRef *txtRecord) { return(txtRec->buffer); }
+uint16_t DNSSD_API TXTRecordGetLength  (const TXTRecordRef *txtRecord) { return(txtRec->datalen); }
+const void * DNSSD_API TXTRecordGetBytesPtr(const TXTRecordRef *txtRecord) { return(txtRec->buffer); }
 
 /*********************************************************************************************
  *
@@ -285,7 +288,7 @@ const void *   TXTRecordGetBytesPtr(const TXTRecordRef *txtRecord) { return(txtR
  *
  *********************************************************************************************/
 
-int TXTRecordContainsKey
+int DNSSD_API TXTRecordContainsKey
        (
        uint16_t         txtLen,
        const void       *txtRecord,
@@ -296,7 +299,7 @@ int TXTRecordContainsKey
        return (InternalTXTRecordSearch(txtLen, txtRecord, key, &keylen) ? 1 : 0);
        }
 
-const void * TXTRecordGetValuePtr
+const void * DNSSD_API TXTRecordGetValuePtr
        (
        uint16_t         txtLen,
        const void       *txtRecord,
@@ -311,7 +314,7 @@ const void * TXTRecordGetValuePtr
        return (item + 1 + keylen + 1);
        }
 
-uint16_t TXTRecordGetCount
+uint16_t DNSSD_API TXTRecordGetCount
        (
        uint16_t         txtLen,
        const void       *txtRecord
@@ -324,7 +327,7 @@ uint16_t TXTRecordGetCount
        return((p>e) ? (uint16_t)0 : count);
        }
 
-DNSServiceErrorType TXTRecordGetItemAtIndex
+DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex
        (
        uint16_t         txtLen,
        const void       *txtRecord,
index 8cf98d32bae83e344404bf7c1ad0715f625f45fc..ffc7111588707f7e614c8ff4b981139ee76d078e 100755 (executable)
     Change History (most recent first):
 
 $Log: dnssd_clientstub.c,v $
+Revision 1.47  2005/03/31 02:19:56  cheshire
+<rdar://problem/4021486> Fix build warnings
+Reviewed by: Scott Herscher
+
+Revision 1.46  2005/03/21 00:39:31  shersche
+<rdar://problem/4021486> Fix build warnings on Win32 platform
+
 Revision 1.45  2005/02/01 01:25:06  shersche
 Define sleep() to be Sleep() for Windows compatibility
 
@@ -266,7 +273,9 @@ static ipc_msg_hdr *create_hdr(uint32_t op, size_t *len, char **data_start, int
     char *msg = NULL;
     ipc_msg_hdr *hdr;
     int datalen;
+#if !defined(USE_TCP_LOOPBACK)
     char ctrl_path[256];
+#endif
 
     if (!reuse_socket)
         {
@@ -369,7 +378,7 @@ static DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reu
     char *data = (char *)msg + sizeof(ipc_msg_hdr);
     dnssd_sock_t listenfd = dnssd_InvalidSocket, errsd = dnssd_InvalidSocket;
        int ret;
-       unsigned int len = sizeof(caddr);
+       dnssd_socklen_t len = (dnssd_socklen_t) sizeof(caddr);
     DNSServiceErrorType err = kDNSServiceErr_Unknown;
 
     if (!hdr || sdr->sockfd < 0) return kDNSServiceErr_Unknown;
index 58c0ec391e50cdfbc67fc556c76a3e143a46a5d0..a04eaccc3096f2827ac99fadd3b8cb0b5c6d7d89 100644 (file)
@@ -27,6 +27,9 @@
     Change History (most recent first):
 
 $Log: dnssd_ipc.h,v $
+Revision 1.20  2005/03/21 00:39:31  shersche
+<rdar://problem/4021486> Fix build warnings on Win32 platform
+
 Revision 1.19  2005/02/02 02:25:22  cheshire
 <rdar://problem/3980388> /var/run/mDNSResponder should be /var/run/mdnsd on Linux
 
@@ -89,7 +92,8 @@ Update to APSL 2.0
 #      define dnssd_EINTR                      WSAEINTR
 #      define MSG_WAITALL                      0
 #      define dnssd_sock_t                     SOCKET
-#      define dnssd_sockbuf_t          
+#      define dnssd_socklen_t          int
+#      define dnssd_sockbuf_t          const char*
 #      define dnssd_close(sock)        closesocket(sock)
 #      define dnssd_errno()            WSAGetLastError()
 #      define ssize_t                          int
@@ -109,6 +113,8 @@ Update to APSL 2.0
 #      define dnssd_EINTR                      EINTR
 #      define dnssd_EPIPE                      EPIPE
 #      define dnssd_sock_t                     int
+#      define dnssd_socklen_t          unsigned int
+#      define dnssd_sockbuf_t          const char*
 #      define dnssd_close(sock)        close(sock)
 #      define dnssd_errno()            errno
 #endif
index 964d2fc1c2cbc9b162875fdb2f73129f00b4175f..9dc98e44e153140436a830b8ff50595498dc4f49 100644 (file)
     Change History (most recent first):
 
 $Log: uds_daemon.c,v $
+Revision 1.182  2005/03/21 00:39:31  shersche
+<rdar://problem/4021486> Fix build warnings on Win32 platform
+
+Revision 1.181  2005/03/20 20:21:32  shersche
+<rdar://problem/4056827> mDNSResponder crashes when incorrect interface index is passed to DNSServiceRegister()
+Text record length and data parameters must be initialized to 0 and NULL to ensure that the service request
+object is cleaned up correctly when encountering an interface index error.
+
 Revision 1.180  2005/03/10 00:13:12  cheshire
 <rdar://problem/4043098> DNSServiceBrowse no longer returning error codes for invalid types
 In handle_browse_request(), mStatus err was being set correctly if an error occurred,
@@ -645,7 +653,7 @@ typedef struct service_instance
     domainname domain;
     mDNSBool default_local;                    // is this the "local." from an empty-string registration?
     struct request_state *request;
-    int sd;
+    dnssd_sock_t sd;
     AuthRecord *subtypes;
     ServiceRecordSet srs; // note - must be last field in struct
     } service_instance;
@@ -834,7 +842,7 @@ static void handle_query_request(request_state *rstate);
 static reply_state *format_enumeration_reply(request_state *rstate, const char *domain, DNSServiceFlags flags, uint32_t ifi, DNSServiceErrorType err);
 static void handle_enum_request(request_state *rstate);
 static mStatus handle_regrecord_request(request_state *rstate);
-static void regrecord_callback(mDNS *const m, AuthRecord *const rr, mStatus result);
+static void regrecord_callback(mDNS *const m, AuthRecord * rr, mStatus result);
 static void connected_registration_termination(void *context);
 static void handle_reconfirm_request(request_state *rstate);
 static AuthRecord *read_rr_from_ipc_msg(char *msgbuf, int ttl, int validate_flags);
@@ -1164,13 +1172,13 @@ void udsserver_handle_configchange(void)
 static void connect_callback(void *info)
     {
     dnssd_sock_t sd;
-       unsigned int len;
+       dnssd_socklen_t len;
        unsigned long optval;
     dnssd_sockaddr_t cliaddr;
     request_state *rstate;
     (void)info; // Unused
 
-       len = (int) sizeof(cliaddr);
+       len = (dnssd_socklen_t) sizeof(cliaddr);
     
        sd = accept(listenfd, (struct sockaddr*) &cliaddr, &len);
 
@@ -1279,7 +1287,7 @@ static void request_callback(void *info)
                {
                mStatus err = 0;
                int nwritten;
-               int errfd = socket(AF_DNSSD, SOCK_STREAM, 0);
+               dnssd_sock_t errfd = socket(AF_DNSSD, SOCK_STREAM, 0);
                if (errfd == dnssd_InvalidSocket)
                        {
                        my_perror("ERROR: socket");
@@ -1336,7 +1344,7 @@ static void request_callback(void *info)
                        }
 
                err = dnssd_htonl(err);
-               nwritten = send(errfd, &err, sizeof(err), 0);
+               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.
                // If not, we don't attempt to handle this failure, but we do log it.
                if (nwritten < (int)sizeof(err))
@@ -2206,6 +2214,8 @@ static void handle_regservice_request(request_state *request)
 
        service->instances = NULL;
        service->request = request;
+       service->txtlen  = 0;
+       service->txtdata = NULL;
        request->service_registration = service;
     request->termination_context = request->service_registration;
     request->terminate = regservice_termination_callback;
@@ -3053,7 +3063,7 @@ static AuthRecord *read_rr_from_ipc_msg(char *msgbuf, int GetTTL, int validate_f
     bzero(rr, sizeof(AuthRecord));  // ok if oversized rdata not zero'd
     
     mDNS_SetupResourceRecord(rr, mDNSNULL, mDNSPlatformInterfaceIDfromInterfaceIndex(gmDNS, interfaceIndex),
-               type, 0, (flags & kDNSServiceFlagsShared) ? kDNSRecordTypeShared : kDNSRecordTypeUnique, mDNSNULL, mDNSNULL);
+               type, 0, (mDNSu8) ((flags & kDNSServiceFlagsShared) ? kDNSRecordTypeShared : kDNSRecordTypeUnique), mDNSNULL, mDNSNULL);
     
     if (!MakeDomainNameFromDNSNameString(rr->resrec.name, name))
        {
@@ -3342,7 +3352,7 @@ static int deliver_error(request_state *rstate, mStatus err)
        undelivered_error_t *undeliv;
        
        err = dnssd_htonl(err);
-       nwritten = send(rstate->sd, &err, sizeof(mStatus), 0);
+       nwritten = send(rstate->sd, (dnssd_sockbuf_t) &err, sizeof(mStatus), 0);
        if (nwritten < (int)sizeof(mStatus))
                {
                if (dnssd_errno() == dnssd_EINTR || dnssd_errno() == dnssd_EWOULDBLOCK)
index db16d913bbc8bd0f79d33f745524093af6a92464..51dbb7782eb4300dad5a1b2ae030a43aae7f3577 100755 (executable)
@@ -60,7 +60,6 @@ BEGIN
     END\r
 END\r
 \r
-\r
 #ifdef APSTUDIO_INVOKED\r
 /////////////////////////////////////////////////////////////////////////////\r
 //\r
@@ -120,13 +119,13 @@ CAPTION "Hostname"
 FONT 8, "MS Sans Serif", 0, 0, 0x0\r
 BEGIN\r
     LTEXT           "Enter a hostname for this computer. Other computers on the Internet will be able to reach your computer using this hostname.",\r
-                    IDC_STATIC,7,19,248,28\r
-    LTEXT           "Hostname:",IDC_STATIC,15,55,35,8\r
-    EDITTEXT        IDC_EDIT1,52,53,187,14,ES_AUTOHSCROLL\r
-    PUSHBUTTON      "Password...",IDC_BUTTON1,52,72,67,14\r
-    ICON            IDI_FAILURE,IDC_FAILURE,240,50,21,20,SS_CENTERIMAGE | \r
+                    IDC_STATIC,10,19,245,28\r
+    LTEXT           "Hostname:",IDC_STATIC,13,55,35,8\r
+    EDITTEXT        IDC_EDIT1,55,53,184,14,ES_AUTOHSCROLL\r
+    PUSHBUTTON      "Password...",IDC_BUTTON1,55,72,65,14\r
+    ICON            IDI_FAILURE,IDC_FAILURE,240,50,20,20,SS_CENTERIMAGE | \r
                     SS_REALSIZEIMAGE\r
-    ICON            IDI_SUCCESS,IDC_SUCCESS,240,50,21,20,SS_CENTERIMAGE | \r
+    ICON            IDI_SUCCESS,IDC_SUCCESS,240,50,20,20,SS_CENTERIMAGE | \r
                     SS_REALSIZEIMAGE | NOT WS_VISIBLE\r
 END\r
 \r
@@ -136,12 +135,12 @@ CAPTION "Registration"
 FONT 8, "MS Sans Serif", 0, 0, 0x0\r
 BEGIN\r
     CONTROL         "Domain:",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | \r
-                    WS_TABSTOP,13,54,42,10\r
-    COMBOBOX        IDC_COMBO2,59,53,189,46,CBS_DROPDOWN | CBS_SORT | \r
+                    WS_TABSTOP,13,54,41,10\r
+    COMBOBOX        IDC_COMBO2,55,53,193,46,CBS_DROPDOWN | CBS_SORT | \r
                     WS_DISABLED | WS_VSCROLL | WS_TABSTOP\r
-    PUSHBUTTON      "Password...",IDC_BUTTON1,59,72,65,14\r
+    PUSHBUTTON      "Password...",IDC_BUTTON1,55,72,65,14\r
     LTEXT           "Check the box and enter a registration domain to enable Bonjour advertising beyond the local subnet. ",\r
-                    IDC_STATIC,14,20,233,23\r
+                    IDC_STATIC,10,19,233,23\r
 END\r
 \r
 IDR_SECRET DIALOGEX 0, 0, 251, 90\r
@@ -153,7 +152,7 @@ BEGIN
     DEFPUSHBUTTON   "OK",IDOK,139,69,50,14\r
     PUSHBUTTON      "Cancel",IDCANCEL,194,69,50,14\r
     LTEXT           "Name:",IDC_STATIC,9,28,22,8\r
-    EDITTEXT        IDC_SECRET_NAME,36,26,208,14,ES_AUTOHSCROLL\r
+    EDITTEXT        IDC_KEY,36,26,208,14,ES_AUTOHSCROLL\r
     LTEXT           "Secret:",IDC_STATIC,9,44,24,8\r
     EDITTEXT        IDC_SECRET,36,42,208,14,ES_PASSWORD | ES_AUTOHSCROLL\r
     LTEXT           "Enter a Password if your DNS server requires authentication.",\r
@@ -182,7 +181,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
 BEGIN\r
     DEFPUSHBUTTON   "OK",IDOK,117,74,50,14\r
     PUSHBUTTON      "Cancel",IDCANCEL,173,74,50,14\r
-    COMBOBOX        IDC_COMBO1,35,42,188,30,CBS_DROPDOWN | CBS_SORT | \r
+    COMBOBOX        IDC_COMBO1,35,42,188,100,CBS_DROPDOWN | CBS_SORT | \r
                     WS_VSCROLL | WS_TABSTOP\r
     LTEXT           "Domain:",IDC_STATIC,7,43,27,8\r
     LTEXT           "The following domain will be added to your list of Bonjour browse domains.",\r
index 9dfe4017c8ec20a17e9f18cbf2012ba57d2b51ca..48cf1ffa4f58c2ee7e4a76c543f8e7e0a15e9775 100755 (executable)
@@ -23,6 +23,9 @@
     Change History (most recent first):
 
 $Log: FirstPage.cpp,v $
+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.
+
 Revision 1.3  2005/03/07 18:27:42  shersche
 <rdar://problem/4037940> Fix problem when ControlPanel commits changes to the browse domain list
 
@@ -51,7 +54,8 @@ CFirstPage::CFirstPage()
 :
        CPropertyPage(CFirstPage::IDD),
        m_ignoreHostnameChange( false ),
-       m_statusKey( NULL )
+       m_statusKey( NULL ),
+       m_setupKey( NULL )
 {
        //{{AFX_DATA_INIT(CFirstPage)
        //}}AFX_DATA_INIT
@@ -128,12 +132,33 @@ void CFirstPage::OnBnClickedSharedSecret()
 
        CSharedSecret dlg;
 
-       dlg.m_secretName = name;
+       dlg.m_key = name;
 
        if ( dlg.DoModal() == IDOK )
        {
-               dlg.Commit();
+               DWORD           wakeup = 0;
+               DWORD           dwSize = sizeof( DWORD );
+               OSStatus        err;
+
+               dlg.Commit( name );
+
+               // We have now updated the secret, however the system service
+               // doesn't know about it yet.  So we're going to update the
+               // registry with a dummy value which will cause the system
+               // service to re-initialize it's DynDNS setup
+               //
+
+               RegQueryValueEx( m_setupKey, L"Wakeup", NULL, NULL, (LPBYTE) &wakeup, &dwSize );      
+
+               wakeup++;
+               
+               err = RegSetValueEx( m_setupKey, L"Wakeup", 0, REG_DWORD, (LPBYTE) &wakeup, sizeof( DWORD ) );
+               require_noerr( err, exit );
        }
+
+exit:
+
+       return;
 }
 
 
index a330e84f4287104110c2f806a2e4e7c840d9227b..b14c7697472ae4f0381401a76f33113d71076f09 100755 (executable)
     Change History (most recent first):
 
 $Log: SecondPage.cpp,v $
+Revision 1.5  2005/04/05 04:15:46  shersche
+RegQueryString was returning uninitialized strings if the registry key couldn't be found, so always initialize strings before checking the registry key.
+
+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.
+
 Revision 1.3  2005/03/03 19:55:22  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
@@ -46,10 +52,16 @@ IMPLEMENT_DYNCREATE(CSecondPage, CPropertyPage)
 
 CSecondPage::CSecondPage()
 :
-       CPropertyPage(CSecondPage::IDD)
+       CPropertyPage(CSecondPage::IDD),
+       m_setupKey( NULL )
 {
        //{{AFX_DATA_INIT(CSecondPage)
        //}}AFX_DATA_INIT
+
+       OSStatus err;
+
+       err = RegCreateKey( HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L"\\Parameters\\DynDNS\\Setup\\" kServiceDynDNSRegistrationDomains, &m_setupKey );
+       check_noerr( err );
 }
 
 
@@ -59,6 +71,11 @@ CSecondPage::CSecondPage()
 
 CSecondPage::~CSecondPage()
 {
+       if ( m_setupKey )
+       {
+               RegCloseKey( m_setupKey );
+               m_setupKey = NULL;
+       }
 }
 
 
@@ -109,7 +126,6 @@ BOOL
 CSecondPage::OnSetActive()
 {
        CConfigPropertySheet    *       psheet;
-       HKEY                                            key = NULL;
        DWORD                                           dwSize;
        DWORD                                           enabled;
        DWORD                                           err;
@@ -126,20 +142,15 @@ CSecondPage::OnSetActive()
 
        // Now populate the registration domain box
 
-       err = RegCreateKey( HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L"\\Parameters\\DynDNS\\Setup\\" kServiceDynDNSRegistrationDomains, &key );
-       require_noerr( err, exit );
-
-       err = Populate( m_regDomainsBox, key, psheet->m_regDomains );
+       err = Populate( m_regDomainsBox, m_setupKey, psheet->m_regDomains );
        check_noerr( err );
 
        dwSize = sizeof( DWORD );
-       err = RegQueryValueEx( key, L"Enabled", NULL, NULL, (LPBYTE) &enabled, &dwSize );
+       err = RegQueryValueEx( m_setupKey, L"Enabled", NULL, NULL, (LPBYTE) &enabled, &dwSize );
        m_advertiseServicesButton.SetCheck( ( !err && enabled ) ? BST_CHECKED : BST_UNCHECKED );
        m_regDomainsBox.EnableWindow( ( !err && enabled ) );
        m_sharedSecretButton.EnableWindow( (!err && enabled ) );
 
-       RegCloseKey( key );
-
 exit:
 
        return b;
@@ -168,20 +179,12 @@ CSecondPage::OnOK()
 void
 CSecondPage::Commit()
 {
-       HKEY            key = NULL;
-       DWORD           err;
+       DWORD err;
 
-       err = RegCreateKey( HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L"\\Parameters\\DynDNS\\Setup\\" kServiceDynDNSRegistrationDomains, &key );
-       require_noerr( err, exit );
-
-       err = Commit( m_regDomainsBox, key, m_advertiseServicesButton.GetCheck() == BST_CHECKED );
-       check_noerr( err );
-       
-exit:
-
-       if ( key )
+       if ( m_setupKey != NULL )
        {
-               RegCloseKey( key );
+               err = Commit( m_regDomainsBox, m_setupKey, m_advertiseServicesButton.GetCheck() == BST_CHECKED );
+               check_noerr( err );
        }
 }
 
@@ -244,15 +247,39 @@ CSecondPage::Commit( CComboBox & box, HKEY key, DWORD enabled )
 
 void CSecondPage::OnBnClickedSharedSecret()
 {
-       CString string;
+       CString name;
 
-       m_regDomainsBox.GetWindowText( string );
+       m_regDomainsBox.GetWindowText( name );
 
        CSharedSecret dlg;
 
-       dlg.m_secretName = string;
+       dlg.m_key = name;
+
+       if ( dlg.DoModal() == IDOK )
+       {
+               DWORD           wakeup = 0;
+               DWORD           dwSize = sizeof( DWORD );
+               OSStatus        err;
+
+               dlg.Commit( name );
+
+               // We have now updated the secret, however the system service
+               // doesn't know about it yet.  So we're going to update the
+               // registry with a dummy value which will cause the system
+               // service to re-initialize it's DynDNS setup
+               //
+
+               RegQueryValueEx( m_setupKey, L"Wakeup", NULL, NULL, (LPBYTE) &wakeup, &dwSize );      
+
+               wakeup++;
+               
+               err = RegSetValueEx( m_setupKey, L"Wakeup", 0, REG_DWORD, (LPBYTE) &wakeup, sizeof( DWORD ) );
+               require_noerr( err, exit );
+       }
+
+exit:
 
-       dlg.DoModal();
+       return;
 }
 
 
@@ -470,6 +497,7 @@ CSecondPage::RegQueryString( HKEY key, CString valueName, CString & value )
 
                string = (TCHAR*) malloc( stringLen );
                require_action( string, exit, err = kUnknownErr );
+               *string = '\0';
 
                err = RegQueryValueEx( key, valueName, 0, NULL, (LPBYTE) string, &stringLen );
 
index a8d1f09a0a866c63bd22eaed670bd1b1da312bf0..917608edad7806ae6aec3b1c84fd8df12b4c9427 100755 (executable)
@@ -23,6 +23,9 @@
     Change History (most recent first):
 
 $Log: SecondPage.h,v $
+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.
+
 Revision 1.3  2005/03/03 19:55:21  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 
@@ -113,6 +116,7 @@ private:
        CButton                 m_advertiseServicesButton;
        CButton                 m_sharedSecretButton;
        BOOL                    m_modified;
+       HKEY                    m_setupKey;
 
 public:
        afx_msg void OnCbnSelChange();
index 6c42aca11a0ae1f44d4b1d3e3f4530f67628cad7..29636df0b5f6d1b786a35f9d7f5daccf14e2df61 100755 (executable)
@@ -23,6 +23,9 @@
     Change History (most recent first):\r
 \r
 $Log: SharedSecret.cpp,v $
+Revision 1.3  2005/04/06 02:04:49  shersche
+<rdar://problem/4066485> Registering with shared secret doesn't work
+
 Revision 1.2  2005/03/03 19:55:22  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 \r
@@ -61,8 +64,8 @@ IMPLEMENT_DYNAMIC(CSharedSecret, CDialog)
 \r
 CSharedSecret::CSharedSecret(CWnd* pParent /*=NULL*/)\r
        : CDialog(CSharedSecret::IDD, pParent)\r
+       , m_key(_T(""))\r
        , m_secret(_T(""))\r
-       , m_secretName(_T(""))\r
 {\r
 }\r
 \r
@@ -83,8 +86,8 @@ CSharedSecret::~CSharedSecret()
 void CSharedSecret::DoDataExchange(CDataExchange* pDX)\r
 {\r
        CDialog::DoDataExchange(pDX);\r
-       DDX_Text(pDX, IDC_SECRET, m_secret);\r
-       DDX_Text(pDX, IDC_SECRET_NAME, m_secretName);\r
+       DDX_Text(pDX, IDC_KEY, m_key );\r
+       DDX_Text(pDX, IDC_SECRET, m_secret );\r
 }\r
 \r
 \r
@@ -98,27 +101,33 @@ END_MESSAGE_MAP()
 //---------------------------------------------------------------------------------------------------------------------------\r
 \r
 void\r
-CSharedSecret::Commit()\r
+CSharedSecret::Commit( CString zone )\r
 {\r
        LSA_OBJECT_ATTRIBUTES   attrs;\r
        LSA_HANDLE                              handle = NULL;\r
        NTSTATUS                                res;\r
+       LSA_UNICODE_STRING              lucZoneName;\r
        LSA_UNICODE_STRING              lucKeyName;\r
-       LSA_UNICODE_STRING              lucPrivateData;\r
+       LSA_UNICODE_STRING              lucSecretName;\r
        BOOL                                    ok;\r
        OSStatus                                err;\r
 \r
        // If there isn't a trailing dot, add one because the mDNSResponder\r
        // presents names with the trailing dot.\r
 \r
-       if ( m_secretName.ReverseFind( '.' ) != m_secretName.GetLength() )\r
+       if ( zone.ReverseFind( '.' ) != zone.GetLength() )\r
        {\r
-               m_secretName += '.';\r
+               zone += '.';\r
+       }\r
+\r
+       if ( m_key.ReverseFind( '.' ) != m_key.GetLength() )\r
+       {\r
+               m_key += '.';\r
        }\r
 \r
        // attrs are reserved, so initialize to zeroes.\r
 \r
-       ZeroMemory(&attrs, sizeof( attrs ) );\r
+       ZeroMemory( &attrs, sizeof( attrs ) );\r
 \r
        // Get a handle to the Policy object on the local system\r
 \r
@@ -128,17 +137,25 @@ CSharedSecret::Commit()
 \r
        // Intializing PLSA_UNICODE_STRING structures\r
 \r
-       ok = InitLsaString( &lucKeyName, m_secretName );\r
+       ok = InitLsaString( &lucZoneName, zone );\r
+       err = translate_errno( ok, errno_compat(), kUnknownErr );\r
+       require_noerr( err, exit );\r
\r
+       ok = InitLsaString( &lucKeyName, m_key );\r
        err = translate_errno( ok, errno_compat(), kUnknownErr );\r
        require_noerr( err, exit );\r
 \r
-       ok = InitLsaString( &lucPrivateData, m_secret );\r
+       ok = InitLsaString( &lucSecretName, m_secret );\r
        err = translate_errno( ok, errno_compat(), kUnknownErr );\r
        require_noerr( err, exit );\r
 \r
        // Store the private data.\r
 \r
-       res = LsaStorePrivateData( handle, &lucKeyName, &lucPrivateData );\r
+       res = LsaStorePrivateData( handle, &lucZoneName, &lucKeyName );\r
+       err = translate_errno( res == 0, LsaNtStatusToWinError( res ), kUnknownErr );\r
+       require_noerr( err, exit );\r
+\r
+       res = LsaStorePrivateData( handle, &lucKeyName, &lucSecretName );\r
        err = translate_errno( res == 0, LsaNtStatusToWinError( res ), kUnknownErr );\r
        require_noerr( err, exit );\r
 \r
index 07e79e11d8b4c6bd22eeb423a5394873f8c46fde..804f6b408a87b9faaaed6dee5b2cdc213d2e1044 100755 (executable)
@@ -23,6 +23,9 @@
     Change History (most recent first):\r
 \r
 $Log: SharedSecret.h,v $
+Revision 1.3  2005/04/06 02:04:49  shersche
+<rdar://problem/4066485> Registering with shared secret doesn't work
+
 Revision 1.2  2005/03/03 19:55:21  shersche
 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
 \r
@@ -51,7 +54,7 @@ public:
        enum { IDD = IDR_SECRET };\r
 \r
        void\r
-       Commit();\r
+       Commit( CString zone );\r
 \r
 protected:\r
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
@@ -59,6 +62,7 @@ protected:
        DECLARE_MESSAGE_MAP()\r
 \r
 public:\r
+\r
+       CString m_key;\r
        CString m_secret;\r
-       CString m_secretName;\r
 };\r
index 1fbf6a552997a4ce7cdf9cedf5a1335111153302..a4e401472ed404bf694783518bff6ca8c5d78e76 100755 (executable)
@@ -23,6 +23,8 @@
 #define IDC_FAILURE                     1008\r
 #define IDC_SUCCESS                     1009\r
 #define IDC_SECRET_NAME                 1010\r
+#define IDC_NAME                        1010\r
+#define IDC_KEY                         1010\r
 #define IDC_LIST1                       1011\r
 #define IDC_BROWSE_LIST                 1011\r
 #define IDC_BUTTON2                     1012\r
index 39750483b70ec739f0b909c6de49b10890c6e080..e048c02d99700157036ef84dcf41d5cae74916b1 100644 (file)
@@ -33,7 +33,8 @@
                                Detect64BitPortabilityProblems="TRUE"\r
                                DebugInformationFormat="4"\r
                                CallingConvention="2"\r
-                               CompileAs="0"/>\r
+                               CompileAs="0"\r
+                               DisableSpecificWarnings="4127;4204"/>\r
                        <Tool\r
                                Name="VCCustomBuildTool"/>\r
                        <Tool\r
@@ -79,7 +80,8 @@
                                Detect64BitPortabilityProblems="TRUE"\r
                                DebugInformationFormat="3"\r
                                CallingConvention="2"\r
-                               CompileAs="0"/>\r
+                               CompileAs="0"\r
+                               DisableSpecificWarnings="4127;4204"/>\r
                        <Tool\r
                                Name="VCCustomBuildTool"/>\r
                        <Tool\r
diff --git a/mDNSWindows/Installer/Main.ism b/mDNSWindows/Installer/Main.ism
deleted file mode 100644 (file)
index c430d40..0000000
Binary files a/mDNSWindows/Installer/Main.ism and /dev/null differ
diff --git a/mDNSWindows/Installer/SDK.ism b/mDNSWindows/Installer/SDK.ism
deleted file mode 100644 (file)
index e63bde7..0000000
Binary files a/mDNSWindows/Installer/SDK.ism and /dev/null differ
index 451c239ce0b7b8b2eb348eeef9445d348d9b7727..0ab2dbf14d730a8b829894af9d2e5c24bc4994ad 100644 (file)
     Change History (most recent first):
     
 $Log: Service.c,v $
+Revision 1.34  2005/04/22 07:34:23  shersche
+Check an interface's address and make sure it's valid before using it to set link-local routes.
+
+Revision 1.33  2005/04/13 17:48:23  shersche
+<rdar://problem/4079667> Make sure there is only one default route for link-local addresses.
+
+Revision 1.32  2005/04/06 01:32:05  shersche
+Remove default route for link-local addressing when another interface comes up with a routable IPv4 address
+
+Revision 1.31  2005/04/06 01:00:11  shersche
+<rdar://problem/4080127> GetFullPathName() should be passed the number of TCHARs in the path buffer, not the size in bytes of the path buffer.
+
+Revision 1.30  2005/04/06 00:52:43  shersche
+<rdar://problem/4079667> Only add default route if there are no other routable IPv4 addresses on any of the other interfaces. More work needs to be done to correctly configure the routing table when multiple interfaces are extant and none of them have routable IPv4 addresses.
+
 Revision 1.29  2005/03/06 05:21:56  shersche
 <rdar://problem/4037635> Fix corrupt UTF-8 name when non-ASCII system name used, enabled unicode support
 
@@ -257,8 +272,9 @@ static mDNSs32              udsIdle(mDNS * const inMDNS, mDNSs32 interval);
 static void                    CoreCallback(mDNS * const inMDNS, mStatus result);
 static void                    HostDescriptionChanged(mDNS * const inMDNS);
 static OSStatus                GetRouteDestination(DWORD * ifIndex, DWORD * address);
-static bool                    HaveLLRoute(PMIB_IPFORWARDROW rowExtant);
-static OSStatus                SetLLRoute();
+static OSStatus                SetLLRoute( mDNS * const inMDNS );
+static bool                    HaveRoute( PMIB_IPFORWARDROW rowExtant, unsigned long addr );
+static bool                    IsValidAddress( const char * addr );
 
 #if defined(UNICODE)
 #      define StrLen(X)        wcslen(X)
@@ -478,7 +494,7 @@ static OSStatus     InstallService( LPCTSTR inName, LPCTSTR inDisplayName, LPCTSTR i
        
        // Get a full path to the executable since a relative path may have been specified.
        
-       size = GetFullPathName( inPath, sizeof( fullPath ), fullPath, &namePtr );
+       size = GetFullPathName( inPath, MAX_PATH, fullPath, &namePtr );
        err = translate_errno( size > 0, (OSStatus) GetLastError(), kPathErr );
        require_noerr( err, exit );
        
@@ -1162,7 +1178,7 @@ static OSStatus   ServiceSpecificInitialize( int argc, LPTSTR argv[] )
        //
        if (gServiceManageLLRouting == true)
        {
-               SetLLRoute();
+               SetLLRoute( &gMDNSRecord );
        }
 
 exit:
@@ -1246,13 +1262,11 @@ static void     ServiceSpecificFinalize( int argc, LPTSTR argv[] )
 static void
 CoreCallback(mDNS * const inMDNS, mStatus status)
 {
-       DEBUG_UNUSED( inMDNS );
-
        if (status == mStatus_ConfigChanged)
        {
                if (gServiceManageLLRouting == true)
                {
-                       SetLLRoute();
+                       SetLLRoute( inMDNS );
                }
        }
 }
@@ -1658,11 +1672,11 @@ EventSourceUnlock()
 
 
 //===========================================================================================================================
-//     HaveLLRoute
+//     HaveRoute
 //===========================================================================================================================
 
 static bool
-HaveLLRoute(PMIB_IPFORWARDROW rowExtant)
+HaveRoute( PMIB_IPFORWARDROW rowExtant, unsigned long addr )
 {
        PMIB_IPFORWARDTABLE     pIpForwardTable = NULL;
        DWORD                           dwSize                  = 0;
@@ -1694,7 +1708,7 @@ HaveLLRoute(PMIB_IPFORWARDROW rowExtant)
        //
        for ( i = 0; i < pIpForwardTable->dwNumEntries; i++)
        {
-               if (pIpForwardTable->table[i].dwForwardDest == inet_addr(kLLNetworkAddr))
+               if ( pIpForwardTable->table[i].dwForwardDest == addr )
                {
                        memcpy( rowExtant, &(pIpForwardTable->table[i]), sizeof(*rowExtant) );
                        found = true;
@@ -1713,12 +1727,23 @@ exit:
 }
 
 
+//===========================================================================================================================
+//     IsValidAddress
+//===========================================================================================================================
+
+static bool
+IsValidAddress( const char * addr )
+{
+       return ( addr && ( strcmp( addr, "0.0.0.0" ) != 0 ) ) ? true : false;
+}      
+
+
 //===========================================================================================================================
 //     SetLLRoute
 //===========================================================================================================================
 
 static OSStatus
-SetLLRoute()
+SetLLRoute( mDNS * const inMDNS )
 {
        DWORD                           ifIndex;
        MIB_IPFORWARDROW        rowExtant;
@@ -1748,7 +1773,7 @@ SetLLRoute()
        //
        // check to make sure we don't already have a route
        //
-       if (HaveLLRoute(&rowExtant))
+       if ( HaveRoute( &rowExtant, inet_addr( kLLNetworkAddr ) ) )
        {
                //
                // set the age to 0 so that we can do a memcmp.
@@ -1782,13 +1807,32 @@ SetLLRoute()
        }
 
        //
-       // see if this address is a link local address
+       // Now we want to see if we should install a default route for this interface.
+       // We want to do this if the following are true:
        //
-       if ((row.dwForwardNextHop & 0xFFFF) == row.dwForwardDest)
+       // 1. This interface has a link-local address
+       // 2. This is the only IPv4 interface
+       //
+
+       if ( ( row.dwForwardNextHop & 0xFFFF ) == row.dwForwardDest )
        {
-               //
-               // if so, set up a route to ARP everything
-               //
+               mDNSInterfaceData       *       ifd;
+               int                                             numLinkLocalInterfaces  = 0;
+               int                                             numInterfaces                   = 0;
+       
+               for ( ifd = inMDNS->p->interfaceList; ifd; ifd = ifd->next )
+               {
+                       if ( ifd->defaultAddr.type == mDNSAddrType_IPv4 )
+                       {
+                               numInterfaces++;
+
+                               if ( ( ifd->interfaceInfo.ip.ip.v4.b[0] == 169 ) && ( ifd->interfaceInfo.ip.ip.v4.b[1] == 254 ) )
+                               {
+                                       numLinkLocalInterfaces++;
+                               }
+                       }
+               }
+
                row.dwForwardDest               = 0;
                row.dwForwardIfIndex    = ifIndex;
                row.dwForwardMask               = 0;
@@ -1796,16 +1840,26 @@ SetLLRoute()
                row.dwForwardProto              = MIB_IPPROTO_NETMGMT;
                row.dwForwardAge                = 0;
                row.dwForwardPolicy             = 0;
-               row.dwForwardMetric1    = 1;
+               row.dwForwardMetric1    = 20;
                row.dwForwardMetric2    = (DWORD) - 1;
                row.dwForwardMetric3    = (DWORD) - 1;
                row.dwForwardMetric4    = (DWORD) - 1;
                row.dwForwardMetric5    = (DWORD) - 1;
-
-               err = CreateIpForwardEntry(&row);
-
-               require_noerr( err, exit );
+               
+               if ( numInterfaces == numLinkLocalInterfaces )
+               {
+                       if ( !HaveRoute( &row, 0 ) )
+                       {
+                               err = CreateIpForwardEntry(&row);
+                               require_noerr( err, exit );
+                       }
+               }
+               else
+               {
+                       DeleteIpForwardEntry( &row );
+               }
        }
+
 exit:
 
        return ( err );
@@ -1823,6 +1877,7 @@ GetRouteDestination(DWORD * ifIndex, DWORD * address)
        IP_ADAPTER_INFO *       pAdapterInfo    =       NULL;
        IP_ADAPTER_INFO *       pAdapter                =       NULL;
        ULONG                           bufLen;
+       mDNSBool                        done                    =       mDNSfalse;
        OSStatus                        err;
 
        //
@@ -1882,24 +1937,41 @@ GetRouteDestination(DWORD * ifIndex, DWORD * address)
                pAdapter = pAdapter->Next;
        }
 
-       pAdapter        =       pAdapterInfo;
-       err                     =       kUnknownErr;
-
-       while (pAdapter)
+       while ( !done )
        {
-               //
-               // if we don't have an interface selected, choose the first one
-               //
-               if ((pAdapter->Type == MIB_IF_TYPE_ETHERNET) && (!(*ifIndex) || (pAdapter->Index == (*ifIndex))))
+               pAdapter        =       pAdapterInfo;
+               err                     =       kUnknownErr;
+
+               while (pAdapter)
                {
-                       *address =      inet_addr( pAdapter->IpAddressList.IpAddress.String );
-                       *ifIndex =  pAdapter->Index;
-                       err              =      kNoErr;
-                       break;
+                       // If we don't have an interface selected, choose the first one that is of type ethernet and
+                       // has a valid IP Address
+
+                       if ((pAdapter->Type == MIB_IF_TYPE_ETHERNET) && ( IsValidAddress( pAdapter->IpAddressList.IpAddress.String ) ) && (!(*ifIndex) || (pAdapter->Index == (*ifIndex))))
+                       {
+                               *address =      inet_addr( pAdapter->IpAddressList.IpAddress.String );
+                               *ifIndex =  pAdapter->Index;
+                               err              =      kNoErr;
+                               break;
+                       }
+               
+                       pAdapter = pAdapter->Next;
                }
-       
-               pAdapter = pAdapter->Next;
-       }
+
+               // If we found the right interface, or we weren't trying to find a specific interface then we're done
+
+               if ( !err || !( *ifIndex) )
+               {
+                       done = mDNStrue;
+               }
+
+               // Otherwise, try again by wildcarding the interface
+
+               else
+               {
+                       *ifIndex = 0;
+               }
+       } 
 
 exit:
 
@@ -1910,4 +1982,3 @@ exit:
 
        return( err );
 }
-
diff --git a/mDNSWindows/SystemServiceTest/Prefix.h b/mDNSWindows/SystemServiceTest/Prefix.h
deleted file mode 100644 (file)
index 53fb893..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2003-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
- * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
-
-    Change History (most recent first):
-
-$Log: Prefix.h,v $
-Revision 1.1  2004/06/18 04:17:43  rpantos
-Move up one level.
-
-Revision 1.1  2004/01/30 02:58:57  bradley
-Test tool for the mDNSResponder Windows service.
-                                       
-*/
-
-#ifndef __PREFIX__
-#define __PREFIX__
-
-#if( defined( _DEBUG ) )
-       #define DEBUG                                   1
-       #define MDNS_DEBUGMSGS                  1
-#else
-       #define DEBUG                                   0
-#endif
-
-#define        DNS_SD_DIRECT_ENABLED           0
-#define        DNS_SD_CLIENT_ENABLED           1
-
-#endif // __PREFIX__
diff --git a/mDNSWindows/SystemServiceTest/Tool.c b/mDNSWindows/SystemServiceTest/Tool.c
deleted file mode 100644 (file)
index f4d675a..0000000
+++ /dev/null
@@ -1,851 +0,0 @@
-/*
- * Copyright (c) 2003-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
- * limitations under the License.
- * 
- * @APPLE_LICENSE_HEADER_END@
-
-    Change History (most recent first):
-       
-$Log: Tool.c,v $
-Revision 1.2  2004/07/13 21:24:28  rpantos
-Fix for <rdar://problem/3701120>.
-
-Revision 1.1  2004/06/18 04:17:43  rpantos
-Move up one level.
-
-Revision 1.3  2004/04/09 21:03:15  bradley
-Changed port numbers to use network byte order for consistency with other platforms.
-
-Revision 1.2  2004/04/08 09:43:43  bradley
-Changed callback calling conventions to __stdcall so they can be used with C# delegates.
-
-Revision 1.1  2004/01/30 02:58:57  bradley
-Test tool for the mDNSResponder Windows service.
-
-*/
-
-#include       <stdio.h>
-#include       <stdlib.h>
-
-#include       "CommonServices.h"
-#include       "DebugServices.h"
-#include       "DNSSD.h"
-
-//===========================================================================================================================
-//     Structures
-//===========================================================================================================================
-
-#define MAX_DOMAIN_LABEL 63
-#define MAX_DOMAIN_NAME 255
-
-typedef union { unsigned char b[2]; unsigned short NotAnInteger; } Opaque16;
-
-typedef struct { u_char c[ 64]; } domainlabel;
-typedef struct { u_char c[256]; } domainname;
-
-typedef struct 
-    { 
-    uint16_t priority; 
-    uint16_t weight; 
-    uint16_t port; 
-    domainname target;
-    } srv_rdata;
-
-//===========================================================================================================================
-//     Prototypes
-//===========================================================================================================================
-
-int                            main( int argc, char* argv[] );
-static void                    Usage( void );
-static int                     ProcessArgs( int argc, char* argv[] );
-
-#if( defined( WINVER ) )
-       static BOOL WINAPI      ConsoleControlHandler( DWORD inControlEvent );
-#endif
-
-static void CALLBACK_COMPAT
-       EnumerateDomainsCallBack(
-               DNSServiceRef           inRef,
-               DNSServiceFlags         inFlags,
-               uint32_t                        inInterfaceIndex,
-               DNSServiceErrorType     inErrorCode,
-               const char *            inDomain,  
-               void *                          inContext );
-
-static void CALLBACK_COMPAT
-       BrowseCallBack(
-               DNSServiceRef           inRef,
-               DNSServiceFlags         inFlags,
-               uint32_t                        inInterfaceIndex,
-               DNSServiceErrorType     inErrorCode,
-               const char *            inName,  
-               const char *            inType,  
-               const char *            inDomain,  
-               void *                          inContext );
-
-static void CALLBACK_COMPAT
-       ResolveCallBack(
-               DNSServiceRef           inRef,
-               DNSServiceFlags         inFlags,
-               uint32_t                        inInterfaceIndex,
-               DNSServiceErrorType     inErrorCode,
-               const char *            inFullName,  
-               const char *            inHostName,  
-               uint16_t                        inPort, 
-               uint16_t                        inTXTSize, 
-               const char *            inTXT, 
-               void *                          inContext );
-
-static void CALLBACK_COMPAT
-       RegisterCallBack(
-               DNSServiceRef           inRef,
-               DNSServiceFlags         inFlags,
-               DNSServiceErrorType     inErrorCode,
-               const char *            inName,  
-               const char *            inType,  
-               const char *            inDomain,  
-               void *                          inContext );
-
-static void CALLBACK_COMPAT
-       RecordCallBack( 
-               DNSServiceRef                   inRef, 
-               DNSRecordRef                    inRecordRef, 
-               DNSServiceFlags                 inFlags, 
-               DNSServiceErrorType     inErrorCode, 
-               void *                                  inContext );
-
-static void CALLBACK_COMPAT
-       QueryCallBack( 
-               const DNSServiceRef             inRef, 
-               const DNSServiceFlags           inFlags, 
-               const uint32_t                          inInterfaceIndex, 
-               const DNSServiceErrorType       inErrorCode, 
-               const char *                            inName, 
-               const uint16_t                          inRRType, 
-               const uint16_t                          inRRClass, 
-               const uint16_t                          inRDataSize, 
-               const void *                            inRData, 
-               const uint32_t                          inTTL, 
-               void *                                          inContext );
-
-static void    PrintRData( uint16_t inRRType, size_t inRDataSize, const uint8_t *inRData );
-
-static char *ConvertDomainLabelToCString_withescape(const domainlabel *const label, char *ptr, char esc);
-static char *ConvertDomainNameToCString_withescape(const domainname *const name, char *ptr, char esc);
-
-//===========================================================================================================================
-//     Globals
-//===========================================================================================================================
-
-#if( defined( WINVER ) )
-       static volatile int             gQuit = 0;
-#endif
-
-//===========================================================================================================================
-//     main
-//===========================================================================================================================
-
-int main( int argc, char *argv[] )
-{
-       OSStatus                err;
-       
-       debug_initialize( kDebugOutputTypeMetaConsole );
-       debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace );
-
-       SetConsoleCtrlHandler( ConsoleControlHandler, TRUE );
-       err = ProcessArgs( argc, argv );
-       return( (int) err );
-}
-
-//===========================================================================================================================
-//     Usage
-//===========================================================================================================================
-
-static void    Usage( void )
-{
-       fprintf( stderr, "\n" );
-       fprintf( stderr, "DNSServiceTest 1.0d1\n" );
-       fprintf( stderr, "\n" );
-       fprintf( stderr, "  -server <IP>                                      Set Remote Server\n" );
-       fprintf( stderr, "  -cv                                               Check Version\n" );
-       fprintf( stderr, "  -bd                                               Browse for Browse Domains\n" );
-       fprintf( stderr, "  -bs <type> <domain>                               Browse for Services\n" );
-       fprintf( stderr, "  -rsi <name> <type> <domain>                       Resolve Service Instance\n" );
-       fprintf( stderr, "  -rs <name> <type> <domain> <host> <port> <txt>    Register Service\n" );
-       fprintf( stderr, "  -rr                                               Register Records\n" );
-       fprintf( stderr, "  -qr <name> <type> <domain> <rrType>               Query Record\n" );
-       fprintf( stderr, "  -cr <name> <type> <domain> <rrType>               Reconfirm Record\n" );
-       fprintf( stderr, "  -cp <code>                                        Copy Property\n" );
-       fprintf( stderr, "  -h[elp]                                           Help\n" );
-       fprintf( stderr, "\n" );
-}
-
-DEBUG_LOCAL DNSServiceRef              gRef            = NULL;
-DEBUG_LOCAL DNSRecordRef               gRecordRef      = NULL;
-DEBUG_LOCAL const char *               gServer         = NULL;
-
-//===========================================================================================================================
-//     ProcessArgs
-//===========================================================================================================================
-
-static int ProcessArgs( int argc, char* argv[] )
-{      
-       OSStatus                        err;
-       int                                     i;
-       const char *            name;
-       const char *            type;
-       const char *            domain;
-       uint16_t                        port;
-       const char *            host;
-       const char *            txt;
-       uint16_t                        txtSize;
-       uint8_t                         txtStorage[ 256 ];
-       uint32_t                        ipv4;
-       char                            s[ 256 ];
-       DNSRecordRef            records[ 10 ];
-       char                            fullName[ kDNSServiceMaxDomainName ];
-       uint16_t                        rrType;
-       
-       err = DNSServiceInitialize( kDNSServiceInitializeFlagsNoServerCheck, 0 );
-       require_noerr( err, exit );
-       
-       // Parse the command line arguments (ignore first argument since it's just the program name).
-       
-       if( argc <= 1 )
-       {
-               Usage();
-               err = 0;
-               goto exit;
-       }
-       for( i = 1; i < argc; ++i )
-       {
-               if( strcmp( argv[ i ], "-server" ) == 0 )
-               {
-                       require_action( argc > ( i + 1 ), exit, err = kParamErr );
-                       gServer = argv[ ++i ];
-                       
-                       printf( "Server set to \"%s\"\n", gServer );
-               }
-               else if( strcmp( argv[ i ], "-cv" ) == 0 )
-               {
-                       // Check Version
-                                               
-                       err = DNSServiceCheckVersion();
-                       printf( "CheckVersion: %ld\n", err );
-                       err = kNoErr;
-                       goto exit;
-               }
-               else if( strcmp( argv[ i ], "-bd" ) == 0 )
-               {
-                       err = DNSServiceEnumerateDomains( &gRef, kDNSServiceFlagsBrowseDomains, 0, 
-                               EnumerateDomainsCallBack, NULL );
-                       require_noerr( err, exit );
-               }
-               else if( strcmp( argv[ i ], "-bs" ) == 0 )
-               {
-                       // Browse service <type> <domain>
-                                               
-                       if( argc > ( i + 2 ) )
-                       {
-                               type    = argv[ ++i ];
-                               domain  = argv[ ++i ];
-                       }
-                       else
-                       {
-                               type    = "_http._tcp";
-                               domain  = "";
-                       }
-                       if( ( domain[ 0 ] == '\0' ) || ( ( domain[ 0 ] == '.' ) && ( domain[ 1 ] == '\0' ) ) )
-                       {
-                               domain = "local.";
-                       }
-                       
-                       err = DNSServiceBrowse( &gRef, 0, 0, type, domain, BrowseCallBack, NULL );
-                       require_noerr( err, exit );
-               }
-               else if( strcmp( argv[ i ], "-rsi" ) == 0 )
-               {
-                       // Resolve Service Instance <name> <type> <domain>
-                                               
-                       if( argc > ( i + 3 ) )
-                       {
-                               name    = argv[ ++i ];
-                               type    = argv[ ++i ];
-                               domain  = argv[ ++i ];
-                       }
-                       else
-                       {
-                               name    = "test service";
-                               type    = "_http._tcp";
-                               domain  = "";
-                       }
-                       if( ( domain[ 0 ] == '\0' ) || ( ( domain[ 0 ] == '.' ) && ( domain[ 1 ] == '\0' ) ) )
-                       {
-                               domain = "local.";
-                       }
-                       
-                       err = DNSServiceResolve( &gRef, 0, 0, name, type, domain, ResolveCallBack, NULL );
-                       require_noerr( err, exit );
-               }
-               else if( strcmp( argv[ i ], "-rs" ) == 0 )
-               {
-                       // Register Service <name> <type> <domain> <host> <port> <txt>
-                       
-                       if( argc > ( i + 6 ) )
-                       {
-                               name    = argv[ ++i ];
-                               type    = argv[ ++i ];
-                               domain  = argv[ ++i ];
-                               host    = argv[ ++i ];
-                               port    = (uint16_t) atoi( argv[ ++i ] );
-                               txt     = argv[ ++i ];
-                       }
-                       else
-                       {
-                               name    = "test service";
-                               type    = "_http._tcp";
-                               domain  = "";
-                               host    = "";
-                               port    = 80;
-                               txt             = "My TXT Record";
-                       }
-                       if( *txt != '\0' )
-                       {
-                               txtStorage[ 0 ] = (uint8_t) strlen( txt );
-                               memcpy( &txtStorage[ 1 ], txt, txtStorage[ 0 ] );
-                               txtSize = (uint16_t)( 1 + txtStorage[ 0 ] );
-                               txt = (const char *) txtStorage;
-                       }
-                       else
-                       {
-                               txt = NULL;
-                               txtSize = 0;
-                       }
-                       if( ( domain[ 0 ] == '\0' ) || ( ( domain[ 0 ] == '.' ) && ( domain[ 1 ] == '\0' ) ) )
-                       {
-                               domain = "local.";
-                       }
-                       
-                       err = DNSServiceRegister( &gRef, 0, 0, name, type, domain, host, htons( port ), txtSize, txt, 
-                               RegisterCallBack, NULL );
-                       require_noerr( err, exit );
-                       
-                       #if( TEST_SERVICE_RECORDS )
-                               ipv4 = 0x11223344;
-                               err = DNSServiceAddRecord( gRef, &gRecordRef, 0, kDNSServiceDNSType_A, kDNSServiceDNSClass_IN, &ipv4, 60 );
-                               require_noerr( err, exit );
-                               
-                               Sleep( 10000 );
-                               
-                               ipv4 = 0x22334455;
-                               err = DNSServiceUpdateRecord( gRef, gRecordRef, 0, 4, &ipv4, 60 );
-                               require_noerr( err, exit );
-                               
-                               Sleep( 10000 );
-                               
-                               err = DNSServiceRemoveRecord( gRef, gRecordRef, 0 );
-                               require_noerr( err, exit );
-                               gRecordRef = NULL;
-                               
-                               Sleep( 10000 );
-                       #endif
-               }
-               else if( strcmp( argv[ i ], "-rr" ) == 0 )
-               {
-                       // Register Records
-                       
-                       err = DNSServiceCreateConnection( &gRef );
-                       require_noerr( err, exit );
-                                               
-                       printf( "registering 10 address records...\n" );
-                       ipv4 = 0x11223310;
-                       for( i = 0; i < 10; ++i )
-                       {
-                               sprintf( s, "testhost-%d.local.", i );
-                               ++ipv4;
-                               err = DNSServiceRegisterRecord( gRef, &records[ i ], kDNSServiceFlagsUnique, 0, s, 
-                                       kDNSServiceDNSType_A, kDNSServiceDNSClass_IN, 4, &ipv4, 60, RecordCallBack, NULL );
-                               check_noerr( err );
-                       }
-                       Sleep( 10000 );
-                       
-                       printf( "deregistering half of the records\n" );
-                       for( i = 0; i < 10; ++i )
-                       {
-                               if( i % 2 )
-                               {
-                                       err = DNSServiceRemoveRecord( gRef, records[ i ], 0 );
-                                       check_noerr( err );
-                                       records[ i ] = NULL;
-                               }
-                       }
-                       Sleep( 10000 );
-                       
-                       printf( "updating the remaining records\n" );
-                       for( i = 0; i < 10; ++i )
-                       {
-                               if( records[ i ] )
-                               {
-                                       ++ipv4;
-                                       err = DNSServiceUpdateRecord( gRef, records[ i ], 0, 4, &ipv4, 60 );
-                                       check_noerr( err );
-                               }
-                       }
-                       Sleep( 10000 );
-                       
-                       printf( "deregistering all remaining records\n" );
-               DNSServiceRefDeallocate( gRef );
-               
-               Sleep( 5000 );
-               }
-               else if( strcmp( argv[ i ], "-qr" ) == 0 )
-               {
-                       // Query Record <name> <type> <domain> <rrType>
-                                               
-                       if( argc > ( i + 4 ) )
-                       {
-                               name    = argv[ ++i ];
-                               type    = argv[ ++i ];
-                               domain  = argv[ ++i ];
-                               rrType  = (uint16_t) atoi( argv[ ++i ] );
-                       }
-                       else
-                       {
-                               name    = "test";
-                               type    = "";
-                               domain  = "";
-                               rrType  = 1;    // Address
-                       }
-                       if( ( domain[ 0 ] == '\0' ) || ( ( domain[ 0 ] == '.' ) && ( domain[ 1 ] == '\0' ) ) )
-                       {
-                               domain = "local.";
-                       }
-                       err = DNSServiceConstructFullName( fullName, name, type, domain );
-                       require_noerr( err, exit );
-                       
-                       printf( "resolving fullname %s type %d\n", fullName, rrType );
-                       err = DNSServiceQueryRecord( &gRef, 0, 0, fullName, rrType, kDNSServiceDNSClass_IN, QueryCallBack, NULL );
-                       require_noerr( err, exit );
-               }
-               else if( strcmp( argv[ i ], "-cr" ) == 0 )
-               {
-                       // Reconfirm Record <name> <type> <domain> <rrType>
-                       
-                       if( argc > ( i + 4 ) )
-                       {
-                               name    = argv[ ++i ];
-                               type    = argv[ ++i ];
-                               domain  = argv[ ++i ];
-                               rrType  = (uint16_t) atoi( argv[ ++i ] );
-                       }
-                       else
-                       {
-                               name    = "test";
-                               type    = "";
-                               domain  = "";
-                               rrType  = 1;    // Address
-                       }
-                       if( ( domain[ 0 ] == '\0' ) || ( ( domain[ 0 ] == '.' ) && ( domain[ 1 ] == '\0' ) ) )
-                       {
-                               domain = "local.";
-                       }
-                       err = DNSServiceConstructFullName( fullName, name, type, domain );
-                       require_noerr( err, exit );
-                       
-                       printf( "reconfirming record fullname %s type %d\n", fullName, rrType );
-                       ipv4 = 0x11223310;
-                       DNSServiceReconfirmRecord( 0, 0, fullName, rrType, kDNSServiceDNSClass_IN, 4, &ipv4 );
-               }
-               else if( strcmp( argv[ i ], "-cp" ) == 0 )
-               {
-                       DNSPropertyCode         code;
-                       DNSPropertyData         data;
-                       
-                       // Copy Property <code>
-                                               
-                       if( argc > ( i + 1 ) )
-                       {
-                               name = argv[ ++i ];
-                               require_action( strlen( name ) == 4, exit, err = kParamErr );
-                               
-                               code  = (DNSPropertyCode)( name[ 0 ] << 24 );
-                               code |= (DNSPropertyCode)( name[ 1 ] << 16 );
-                               code |= (DNSPropertyCode)( name[ 2 ] <<  8 );
-                               code |= (DNSPropertyCode)  name[ 3 ];
-                       }
-                       else
-                       {
-                               code = kDNSPropertyCodeVersion;
-                               name = "vers";
-                       }
-                       
-                       err = DNSServiceCopyProperty( code, &data );
-                       require_noerr( err, exit );
-                       
-                       printf( "'%s' property:\n", name );
-                       if( code == kDNSPropertyCodeVersion )
-                       {
-                               printf( "    clientCurrentVersion:      0x%08X\n", data.u.version.clientCurrentVersion );
-                               printf( "    clientOldestServerVersion: 0x%08X\n", data.u.version.clientOldestServerVersion );
-                               printf( "    serverCurrentVersion:      0x%08X\n", data.u.version.serverCurrentVersion );
-                               printf( "    serverOldestClientVersion: 0x%08X\n", data.u.version.serverOldestClientVersion );
-                       }
-               }
-               else if( ( strcmp( argv[ i ], "-help" ) == 0 ) || ( strcmp( argv[ i ], "-h" ) == 0 ) )
-               {
-                       // Help
-                       
-                       Usage();
-                       err = 0;
-                       goto exit;
-               }
-               else
-               {
-                       // Unknown parameter.
-                       
-                       dlog( kDebugLevelError, "unknown parameter (%s)\n", argv[ i ] );
-                       err = kParamErr;
-                       goto exit;
-               }
-       }
-       
-       // Run until control-C'd.
-       
-       while( !gQuit )
-       {
-               Sleep( 100 );
-       }
-       err = kNoErr;
-       
-exit:
-       DNSServiceFinalize();
-       if( err )
-       {
-               Usage();
-       }
-       return( err );
-}
-
-//===========================================================================================================================
-//     ConsoleControlHandler
-//===========================================================================================================================
-
-static BOOL WINAPI     ConsoleControlHandler( DWORD inControlEvent )
-{
-       BOOL            handled;
-       
-       handled = 0;
-       switch( inControlEvent )
-       {
-               case CTRL_C_EVENT:
-               case CTRL_BREAK_EVENT:
-               case CTRL_CLOSE_EVENT:
-               case CTRL_LOGOFF_EVENT:
-               case CTRL_SHUTDOWN_EVENT:
-                       gQuit = 1;
-                       handled = 1;
-                       break;
-               
-               default:
-                       break;
-       }
-       return( handled );
-}
-
-//===========================================================================================================================
-//     EnumerateDomainsCallBack
-//===========================================================================================================================
-
-static void CALLBACK_COMPAT
-       EnumerateDomainsCallBack(
-               DNSServiceRef           inRef,
-               DNSServiceFlags         inFlags,
-               uint32_t                        inInterfaceIndex,
-               DNSServiceErrorType     inErrorCode,
-               const char *            inDomain,  
-               void *                          inContext )
-{
-       printf( "inRef:            0x%08X\n", (uintptr_t) inRef );
-       printf( "inFlags:          0x%08X\n", (int) inFlags );
-       printf( "inInterfaceIndex: 0x%08X\n", (int) inInterfaceIndex );
-       printf( "inErrorCode:      %ld\n", inErrorCode );
-       printf( "inDomain:         \"%s\"\n", inDomain ? inDomain : "<null>" );
-       printf( "inContext:        0x%08X\n", (uintptr_t) inContext );
-       printf( "\n" );
-}
-
-//===========================================================================================================================
-//     BrowseCallBack
-//===========================================================================================================================
-
-static void CALLBACK_COMPAT
-       BrowseCallBack(
-               DNSServiceRef           inRef,
-               DNSServiceFlags         inFlags,
-               uint32_t                        inInterfaceIndex,
-               DNSServiceErrorType     inErrorCode,
-               const char *            inName,  
-               const char *            inType,  
-               const char *            inDomain,  
-               void *                          inContext )
-{
-       printf( "inRef:            0x%08X\n", (uintptr_t) inRef );
-       printf( "inFlags:          0x%08X\n", (int) inFlags );
-       printf( "inInterfaceIndex: 0x%08X\n", (int) inInterfaceIndex );
-       printf( "inErrorCode:      %ld\n", inErrorCode );
-       printf( "inName:           \"%s\"\n", inName ? inName : "<null>" );
-       printf( "inType:           \"%s\"\n", inType ? inType : "<null>" );
-       printf( "inDomain:         \"%s\"\n", inDomain ? inDomain : "<null>" );
-       printf( "inContext:        0x%08X\n", (uintptr_t) inContext );
-       printf( "\n" );
-}
-
-//===========================================================================================================================
-//     ResolveCallBack
-//===========================================================================================================================
-
-static void CALLBACK_COMPAT
-       ResolveCallBack(
-               DNSServiceRef           inRef,
-               DNSServiceFlags         inFlags,
-               uint32_t                        inInterfaceIndex,
-               DNSServiceErrorType     inErrorCode,
-               const char *            inFullName,  
-               const char *            inHostName,  
-               uint16_t                        inPort, 
-               uint16_t                        inTXTSize, 
-               const char *            inTXT, 
-               void *                          inContext )
-{
-       printf( "inRef:            0x%08X\n", (uintptr_t) inRef );
-       printf( "inFlags:          0x%08X\n", (int) inFlags );
-       printf( "inInterfaceIndex: 0x%08X\n", (int) inInterfaceIndex );
-       printf( "inErrorCode:      %ld\n", inErrorCode );
-       printf( "inFullName:       \"%s\"\n", inFullName ? inFullName : "<null>" );
-       printf( "inHostName:       \"%s\"\n", inHostName ? inHostName : "<null>" );
-       printf( "inPort:           %d\n", ntohs( inPort ) );
-       printf( "inTXTSize:        %ld\n", inTXTSize );
-       printf( "inTXT:            0x%08X\n", (uintptr_t) inTXT );
-       printf( "inContext:        0x%08X\n", (uintptr_t) inContext );
-       printf( "\n" );
-}
-
-//===========================================================================================================================
-//     RegisterCallBack
-//===========================================================================================================================
-
-static void CALLBACK_COMPAT
-       RegisterCallBack(
-               DNSServiceRef           inRef,
-               DNSServiceFlags         inFlags,
-               DNSServiceErrorType     inErrorCode,
-               const char *            inName,  
-               const char *            inType,  
-               const char *            inDomain,  
-               void *                          inContext )
-{
-       printf( "inRef:            0x%08X\n", (uintptr_t) inRef );
-       printf( "inFlags:          0x%08X\n", (int) inFlags );
-       printf( "inErrorCode:      %ld\n", inErrorCode );
-       printf( "inName:           \"%s\"\n", inName ? inName : "<null>" );
-       printf( "inType:           \"%s\"\n", inType ? inType : "<null>" );
-       printf( "inDomain:         \"%s\"\n", inDomain ? inDomain : "<null>" );
-       printf( "inContext:        0x%08X\n", (uintptr_t) inContext );
-       printf( "\n" );
-}
-
-//===========================================================================================================================
-//     RecordCallBack
-//===========================================================================================================================
-
-static void CALLBACK_COMPAT
-       RecordCallBack( 
-               DNSServiceRef                   inRef, 
-               DNSRecordRef                    inRecordRef, 
-               DNSServiceFlags                 inFlags, 
-               DNSServiceErrorType     inErrorCode, 
-               void *                                  inContext )
-{
-       DEBUG_UNUSED( inRef );
-       DEBUG_UNUSED( inRecordRef );
-       DEBUG_UNUSED( inFlags );
-       DEBUG_UNUSED( inContext );
-       
-       if( inErrorCode == kDNSServiceErr_NoError )
-       {
-               printf( "RecordCallBack: no errors\n" );
-       }
-       else
-       {
-               printf( "RecordCallBack: %ld error\n", inErrorCode );
-       }
-}
-
-//===========================================================================================================================
-//     QueryCallBack
-//===========================================================================================================================
-
-static void CALLBACK_COMPAT
-       QueryCallBack( 
-               const DNSServiceRef             inRef, 
-               const DNSServiceFlags           inFlags, 
-               const uint32_t                          inInterfaceIndex, 
-               const DNSServiceErrorType       inErrorCode, 
-               const char *                            inName, 
-               const uint16_t                          inRRType, 
-               const uint16_t                          inRRClass, 
-               const uint16_t                          inRDataSize, 
-               const void *                            inRData, 
-               const uint32_t                          inTTL, 
-               void *                                          inContext )
-{
-       DEBUG_UNUSED( inRef );
-       DEBUG_UNUSED( inRRClass );
-       DEBUG_UNUSED( inTTL );
-       DEBUG_UNUSED( inContext );
-       
-       if( inErrorCode == kDNSServiceErr_NoError )
-       {
-               if( inFlags & kDNSServiceFlagsAdd )
-               {
-                       printf( "Add" );
-               }
-               else
-               {
-                       printf( "Rmv" );
-               }
-               if( inFlags & kDNSServiceFlagsMoreComing )
-               {
-                       printf( "+" );
-               }
-               else
-               {
-                       printf( " " );
-               }
-               printf(" 0x%04X %d %s rdata ", inFlags, inInterfaceIndex, inName );
-               PrintRData( inRRType, (size_t) inRDataSize, (const uint8_t *) inRData );
-       }
-       else
-       {
-               printf( "QueryCallback: %ld error\n", inErrorCode );
-       }
-}
-
-//===========================================================================================================================
-//     PrintRData
-//===========================================================================================================================
-
-static void    PrintRData( uint16_t inRRType, size_t inRDataSize, const uint8_t *inRData )
-{
-       size_t                          i;
-       srv_rdata *                     srv;
-       char                            s[ 1005 ];
-       struct in_addr          in;
-       
-       switch( inRRType )
-       {
-               case kDNSServiceDNSType_TXT:
-                       
-                       // Print all the alphanumeric and punctuation characters
-                       
-                       for( i = 0; i < inRDataSize; ++i )
-                       {
-                               if( ( inRData[ i ] >= 32 ) && ( inRData[ i ] <= 127 ) )
-                               {
-                                       printf( "%c", inRData[ i ] );
-                               }
-                       }
-                       printf( "\n" );
-                       break;
-                       
-               case kDNSServiceDNSType_SRV:
-                       srv = (srv_rdata *)inRData;
-                       ConvertDomainNameToCString_withescape(&srv->target, s, 0);
-                       printf("pri=%d, w=%d, port=%d, target=%s\n", srv->priority, srv->weight, srv->port, s);
-                       break;
-                       
-               case kDNSServiceDNSType_A:
-                       check( inRDataSize == 4 );
-                       memcpy( &in, inRData, sizeof( in ) );
-                       printf( "%s\n", inet_ntoa( in ) );
-                       break;
-                       
-               case kDNSServiceDNSType_PTR:
-                       ConvertDomainNameToCString_withescape( (domainname *) inRData, s, 0 );
-                       break;
-               
-               case kDNSServiceDNSType_AAAA:
-                       check( inRDataSize == 16 );
-                       printf( "%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X\n",
-                                       inRData[0], inRData[1], inRData[2], inRData[3], inRData[4], inRData[5], inRData[6], inRData[7], inRData[8], 
-                                       inRData[9], inRData[10], inRData[11], inRData[12], inRData[13], inRData[14], inRData[15] );
-                       break;
-               
-               default:
-                       printf( "ERROR: I dont know how to print inRData of type %d\n", inRRType );
-                       return;
-       }
-}
-
-static char *ConvertDomainLabelToCString_withescape(const domainlabel *const label, char *ptr, char esc)
-    {
-    const unsigned char *      src = label->c;                         // Domain label we're reading
-    const unsigned char        len = *src++;                           // Read length of this (non-null) label
-    const unsigned char *const end = src + len;                        // Work out where the label ends
-    if (len > 63) return(NULL);           // If illegal label, abort
-    while (src < end)                                           // While we have characters in the label
-        {
-        unsigned char c = *src++;
-        if (esc)
-            {
-            if (c == '.')                                       // If character is a dot,
-                *ptr++ = esc;                                   // Output escape character
-            else if (c <= ' ')                                  // If non-printing ascii,
-                {                                                   // Output decimal escape sequence
-                *ptr++ = esc;
-                *ptr++ = (char)  ('0' + (c / 100)     );
-                *ptr++ = (char)  ('0' + (c /  10) % 10);
-                c      = (unsigned char)('0' + (c      ) % 10);
-                }
-            }
-        *ptr++ = (char)c;                                       // Copy the character
-        }
-    *ptr = 0;                                                   // Null-terminate the string
-    return(ptr);                                                // and return
-    }
-
-static char *ConvertDomainNameToCString_withescape(const domainname *const name, char *ptr, char esc)
-    {
-    const unsigned char *src         = name->c;                        // Domain name we're reading
-    const unsigned char *const max   = name->c + MAX_DOMAIN_NAME;      // Maximum that's valid
-
-    if (*src == 0) *ptr++ = '.';                                // Special case: For root, just write a dot
-
-    while (*src)                                                                                                        // While more characters in the domain name
-        {
-        if (src + 1 + *src >= max) return(NULL);
-        ptr = ConvertDomainLabelToCString_withescape((const domainlabel *)src, ptr, esc);
-        if (!ptr) return(NULL);
-        src += 1 + *src;
-        *ptr++ = '.';                                           // Write the dot after the label
-        }
-
-    *ptr++ = 0;                                                 // Null-terminate the string
-    return(ptr);                                                // and return
-    }
diff --git a/mDNSWindows/SystemServiceTest/Tool.mcp b/mDNSWindows/SystemServiceTest/Tool.mcp
deleted file mode 100644 (file)
index 2f38283..0000000
Binary files a/mDNSWindows/SystemServiceTest/Tool.mcp and /dev/null differ
diff --git a/mDNSWindows/SystemServiceTest/Tool2002.vcproj b/mDNSWindows/SystemServiceTest/Tool2002.vcproj
deleted file mode 100644 (file)
index 0afc4b3..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
-<VisualStudioProject
-       ProjectType="Visual C++"
-       Version="7.00"
-       Name="mDNSResponderTest"
-       ProjectGUID="{F66EFE7E-50A6-44D4-87C7-742B303BA852}"
-       Keyword="Win32Proj">
-       <Platforms>
-               <Platform
-                       Name="Win32"/>
-       </Platforms>
-       <Configurations>
-               <Configuration
-                       Name="Debug|Win32"
-                       OutputDirectory="Debug"
-                       IntermediateDirectory="Debug"
-                       ConfigurationType="1"
-                       CharacterSet="2">
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="0"
-                               AdditionalIncludeDirectories="..\..\..\mDNSCore;..\..\..\mDNSWindows"
-                               PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEBUG=1"
-                               StringPooling="TRUE"
-                               MinimalRebuild="TRUE"
-                               ExceptionHandling="FALSE"
-                               BasicRuntimeChecks="3"
-                               SmallerTypeCheck="FALSE"
-                               RuntimeLibrary="1"
-                               BufferSecurityCheck="TRUE"
-                               ForceConformanceInForLoopScope="TRUE"
-                               UsePrecompiledHeader="2"
-                               BrowseInformation="1"
-                               WarningLevel="4"
-                               WarnAsError="TRUE"
-                               Detect64BitPortabilityProblems="TRUE"
-                               DebugInformationFormat="3"/>
-                       <Tool
-                               Name="VCCustomBuildTool"/>
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="ws2_32.lib"
-                               OutputFile="$(ProjectName)Debug.exe"
-                               LinkIncremental="1"
-                               SuppressStartupBanner="TRUE"
-                               GenerateDebugInformation="TRUE"
-                               SubSystem="1"
-                               TargetMachine="1"/>
-                       <Tool
-                               Name="VCMIDLTool"/>
-                       <Tool
-                               Name="VCPostBuildEventTool"/>
-                       <Tool
-                               Name="VCPreBuildEventTool"/>
-                       <Tool
-                               Name="VCPreLinkEventTool"/>
-                       <Tool
-                               Name="VCResourceCompilerTool"/>
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"/>
-                       <Tool
-                               Name="VCWebDeploymentTool"/>
-               </Configuration>
-               <Configuration
-                       Name="Release|Win32"
-                       OutputDirectory="Release"
-                       IntermediateDirectory="Release"
-                       ConfigurationType="1"
-                       CharacterSet="2"
-                       WholeProgramOptimization="FALSE">
-                       <Tool
-                               Name="VCCLCompilerTool"
-                               Optimization="2"
-                               InlineFunctionExpansion="2"
-                               FavorSizeOrSpeed="2"
-                               OmitFramePointers="TRUE"
-                               AdditionalIncludeDirectories="..\..\..\mDNSCore;..\..\..\mDNSWindows"
-                               PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
-                               StringPooling="TRUE"
-                               ExceptionHandling="FALSE"
-                               RuntimeLibrary="0"
-                               BufferSecurityCheck="FALSE"
-                               EnableFunctionLevelLinking="FALSE"
-                               DisableLanguageExtensions="FALSE"
-                               ForceConformanceInForLoopScope="TRUE"
-                               UsePrecompiledHeader="2"
-                               WarningLevel="4"
-                               WarnAsError="TRUE"
-                               Detect64BitPortabilityProblems="TRUE"
-                               DebugInformationFormat="3"
-                               CompileAs="1"/>
-                       <Tool
-                               Name="VCCustomBuildTool"/>
-                       <Tool
-                               Name="VCLinkerTool"
-                               AdditionalDependencies="ws2_32.lib"
-                               OutputFile="$(ProjectName).exe"
-                               LinkIncremental="1"
-                               SuppressStartupBanner="TRUE"
-                               GenerateDebugInformation="TRUE"
-                               SubSystem="1"
-                               OptimizeReferences="2"
-                               EnableCOMDATFolding="2"
-                               TargetMachine="1"/>
-                       <Tool
-                               Name="VCMIDLTool"/>
-                       <Tool
-                               Name="VCPostBuildEventTool"/>
-                       <Tool
-                               Name="VCPreBuildEventTool"/>
-                       <Tool
-                               Name="VCPreLinkEventTool"/>
-                       <Tool
-                               Name="VCResourceCompilerTool"/>
-                       <Tool
-                               Name="VCWebServiceProxyGeneratorTool"/>
-                       <Tool
-                               Name="VCWebDeploymentTool"/>
-               </Configuration>
-       </Configurations>
-       <Files>
-               <File
-                       RelativePath="..\..\CommonServices.h">
-               </File>
-               <File
-                       RelativePath="..\..\..\mDNSCore\DNSCommon.c">
-               </File>
-               <File
-                       RelativePath="..\..\..\mDNSCore\DNSCommon.h">
-               </File>
-               <File
-                       RelativePath="..\..\..\mDNSCore\DNSDigest.c">
-               </File>
-               <File
-                       RelativePath="..\..\DNSSD.c">
-               </File>
-               <File
-                       RelativePath="..\..\DNSSD.h">
-               </File>
-               <File
-                       RelativePath="..\..\DNSSDDirect.c">
-               </File>
-               <File
-                       RelativePath="..\..\DNSSDDirect.h">
-               </File>
-               <File
-                       RelativePath="..\..\DebugServices.c">
-               </File>
-               <File
-                       RelativePath="..\..\DebugServices.h">
-               </File>
-               <File
-                       RelativePath="..\..\RMxClient.c">
-               </File>
-               <File
-                       RelativePath="..\..\RMxClient.h">
-               </File>
-               <File
-                       RelativePath="..\..\RMxCommon.c">
-               </File>
-               <File
-                       RelativePath="..\..\RMxCommon.h">
-               </File>
-               <File
-                       RelativePath="Tool.c">
-               </File>
-               <File
-                       RelativePath="..\..\..\mDNSCore\mDNS.c">
-               </File>
-               <File
-                       RelativePath="..\..\..\mDNSCore\mDNSClientAPI.h">
-               </File>
-               <File
-                       RelativePath="..\..\..\mDNSCore\mDNSDebug.h">
-               </File>
-               <File
-                       RelativePath="..\..\mDNSWin32.c">
-               </File>
-               <File
-                       RelativePath="..\..\mDNSWin32.h">
-               </File>
-               <File
-                       RelativePath="..\..\..\mDNSCore\uDNS.c">
-               </File>
-               <File
-                       RelativePath="..\..\..\mDNSCore\uDNS.h">
-               </File>
-       </Files>
-       <Globals>
-       </Globals>
-</VisualStudioProject>
index 884d661f10b7956767aa35e4367e4be7ef466cbe..a115258eb8f4bb242419585cd7663f6de51a9250 100644 (file)
     Change History (most recent first):
 
 $Log: WinVersRes.h,v $
+Revision 1.38  2005/04/25 21:59:42  shersche
+Bump to 1.0.0.66
+
+Revision 1.37  2005/04/22 07:39:48  shersche
+Bump to 1.0.0.65
+
+Revision 1.36  2005/04/19 07:25:56  shersche
+Bump version to 1.0.0.64
+
+Revision 1.35  2005/04/13 17:48:58  shersche
+Bump to 1.0.0.63
+
+Revision 1.34  2005/04/06 01:00:55  shersche
+Bump to 1.0.0.62
+
+Revision 1.33  2005/03/30 07:37:41  shersche
+Bump to 1.0.0.61
+
+Revision 1.32  2005/03/23 00:39:46  shersche
+Bump to version 1.0.0.60
+
+Revision 1.31  2005/03/16 03:52:06  shersche
+Bump to 1.0.0.59
+
 Revision 1.30  2005/03/07 19:18:18  shersche
 <rdar://problem/4039831> Update Windows build to 1.0.0.58
 
@@ -121,10 +145,10 @@ First checked in.
 #define MASTER_PROD_NAME       "Bonjour"
 
 // Define the product version for mDNSResponder on Windows
-#define MASTER_PROD_VERS               1,0,0,58
-#define MASTER_PROD_VERS_STR   "1,0,0,58"
-#define MASTER_PROD_VERS_STR2  "1.0.0.58"
-#define MASTER_PROD_VERS_STR3 "Explorer Plugin 1.0.0.58"
+#define MASTER_PROD_VERS               1,0,0,66
+#define MASTER_PROD_VERS_STR   "1,0,0,66"
+#define MASTER_PROD_VERS_STR2  "1.0.0.66"
+#define MASTER_PROD_VERS_STR3 "Explorer Plugin 1.0.0.66"
 
 // Define the legal copyright
 #define MASTER_LEGAL_COPYRIGHT "Copyright (C) 2003-2005 Apple Computer, Inc."
index 08cbc886949ddb99b82645964fa04d83c8ca413a..850a2d45e66b06ba113dd1c79bc7b38ede60197e 100755 (executable)
 
     Change History (most recent first):
 
+$Log: dDNS.c,v $
+Revision 1.6  2005/03/23 05:54:48  cheshire
+<rdar://problem/4021486> Fix build warnings
+Fix %s where it should be %##s in debugf & LogMsg calls
+
 */
 
 #include "dDNS.h"
 #include "DNSCommon.h"
+#include "uds_daemon.h"
 #include <winsock2.h>
 #include <iphlpapi.h>
 #include <ws2tcpip.h>
@@ -166,7 +172,7 @@ mDNSlocal void FoundDomain(mDNS *const m, DNSQuestion *question, const ResourceR
                        {
                        if (SameDomainName(&ptr->ar.resrec.rdata->u.name, &answer->rdata->u.name))
                                {
-                               debugf("Deregistering PTR %s -> %s", ptr->ar.resrec.name->c, ptr->ar.resrec.rdata->u.name.c);
+                               debugf("Deregistering PTR %##s -> %##s", ptr->ar.resrec.name->c, ptr->ar.resrec.rdata->u.name.c);
                 dereg = &ptr->ar;
                                if (prev) prev->next = ptr->next;
                                else slElem->AuthRecs = ptr->next;
@@ -271,7 +277,7 @@ mDNSlocal void FoundDefBrowseDomain(mDNS *const m, DNSQuestion *question, const
                        prev = ptr;
                        ptr = ptr->next;
                        }
-               LogMsg("FoundDefBrowseDomain: Got remove event for domain %s not in list", answer->rdata->u.name.c);
+               LogMsg("FoundDefBrowseDomain: Got remove event for domain %##s not in list", answer->rdata->u.name.c);
                }
        }
 
@@ -359,7 +365,7 @@ mDNSlocal mStatus RegisterSearchDomains( mDNS *const m )
                                {
                                AuthRecord *dereg = &arList->ar;
                                arList = arList->next;
-                               debugf("Deregistering PTR %s -> %s", dereg->resrec.name->c, dereg->resrec.rdata->u.name.c);
+                               debugf("Deregistering PTR %##s -> %##s", dereg->resrec.name->c, dereg->resrec.rdata->u.name.c);
                                err = mDNS_Deregister(m, dereg);
                                if (err) LogMsg("ERROR: RegisterSearchDomains mDNS_Deregister returned %d", err);
                                }
@@ -471,7 +477,7 @@ mDNSlocal void SetSCPrefsBrowseDomains(mDNS *m, DNameListElem * browseDomains, m
                {
                        if ( !browseDomain->name.c[0] )
                                {
-                               LogMsg("SetSCPrefsBrowseDomains bad DDNS browse domain: %s", browseDomain->name.c[0] ? browseDomain->name.c : "(unknown)");
+                               LogMsg("SetSCPrefsBrowseDomains bad DDNS browse domain: %##s", browseDomain->name.c[0] ? (char*) browseDomain->name.c : "(unknown)");
                                }
                        else
                                {
@@ -608,14 +614,28 @@ mStatus dDNS_Setup( mDNS *const m )
 mStatus dDNS_InitDNSConfig(mDNS *const m)
        {
        mStatus err;
+       static AuthRecord LocalRegPTR;
 
        // start query for domains to be used in default (empty string domain) browses
        err = mDNS_GetDomains(m, &LegacyBrowseDomainQ, mDNS_DomainTypeBrowseLegacy, NULL, mDNSInterface_LocalOnly, FoundDefBrowseDomain, NULL);
 
        // provide .local automatically
        SetSCPrefsBrowseDomain(m, &localdomain, mDNStrue);
+
+       // <rdar://problem/4055653> dns-sd -E does not return "local."
+       // register registration domain "local"
+       mDNS_SetupResourceRecord(&LocalRegPTR, mDNSNULL, mDNSInterface_LocalOnly, kDNSType_PTR, 7200, kDNSRecordTypeShared, NULL, NULL);
+       MakeDomainNameFromDNSNameString(LocalRegPTR.resrec.name, mDNS_DomainTypeNames[mDNS_DomainTypeRegistration]);
+       AppendDNSNameString            (LocalRegPTR.resrec.name, "local");
+       AssignDomainName(&LocalRegPTR.resrec.rdata->u.name, &localdomain);
+       err = mDNS_Register(m, &LocalRegPTR);
+       if (err)
+               {
+               LogMsg("ERROR: dDNS_InitDNSConfig - mDNS_Register returned error %d", err);
+               }
+
     return mStatus_NoError;
-}
+       }
 
 void
 dDNS_FreeIPAddrList(IPAddrListElem * list)
index e1b148e5d8569ce916c27a060c2bcf4702f20807..12c56da3930761ca9d9cdb509ab5d36a124b2e9b 100755 (executable)
 #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 7a90e66bca5cc4fac1b12cbe2da4efa632d938f2..7084d16b2a0dc1e86bc27e534a2d78c5d405cbfe 100755 (executable)
@@ -72,7 +72,7 @@ static int _getISOCode(LANGID wLangID, char *isoLangCode, int codeLen) {
                int startIndex = i * MODULO_ISOCODES;
                
                langCode = (ISOCODES[startIndex] << 8);
-               langCode += ( (unsigned short) (ISOCODES[startIndex + 1]) );
+               langCode = langCode + ( (unsigned short) (ISOCODES[startIndex + 1]) );
 
                if (langCode == wLangID) {
                        char *langStr = (char *)&(ISOCODES[startIndex+2]);
@@ -118,6 +118,7 @@ int PathForResourceA ( HMODULE module, const char *name, char *locFile, int locF
        if ( !strcmp( appPathNameA, "" ) )
        {
                char   folder[MAX_PATH];
+               char * ext;
                char * app;
 
                GetModuleFileNameA( module, folder, MAX_PATH );
@@ -126,10 +127,16 @@ int PathForResourceA ( HMODULE module, const char *name, char *locFile, int locF
                
                app = strrchr( folder, '\\' );
                require_action( app, exit, ret = 0 );
-
                *app++ = '\0';
 
-               snprintf( appPathNameA, MAX_PATH, "%s\\Resources\\%s", folder, app );
+               // Strip the extension
+
+               if ( ( ( ext = strstr( app, ".exe" ) ) != NULL ) || ( ( ext = strstr( app, ".dll" ) ) != NULL ) )
+               {
+                       *ext = '\0';
+               }
+
+               snprintf( appPathNameA, MAX_PATH, "%s\\%s", folder, app );
        }
 
        ret = PathForResourceWithPathA (appPathNameA, name, locFile, locFileLen);
@@ -149,6 +156,7 @@ int PathForResourceW ( HMODULE module, const wchar_t *name, wchar_t *locFile, in
        {
                wchar_t   folder[MAX_PATH];
                wchar_t * app;
+               wchar_t * ext;
 
                GetModuleFileNameW( module, folder, MAX_PATH);
 
@@ -156,10 +164,16 @@ int PathForResourceW ( HMODULE module, const wchar_t *name, wchar_t *locFile, in
                
                app = wcsrchr( folder, '\\' );
                require_action( app, exit, ret = 0 );
-
                *app++ = '\0';
 
-               swprintf( appPathNameW, MAX_PATH, L"%ls\\Resources\\%ls", folder, app );
+               // Strip the extension
+
+               if ( ( ( ext = wcsstr( app, L".exe" ) ) != NULL ) || ( ( ext = wcsstr( app, L".dll" ) ) != NULL ) )
+               {
+                       *ext = '\0';
+               }
+
+               swprintf( appPathNameW, MAX_PATH, L"%ls\\%ls", folder, app );
        }
 
        ret = PathForResourceWithPathW (appPathNameW, name, locFile, locFileLen);
index 6e7bb361389c072d68ab8155142b0994c62bd8d5..656b6e581a824477e002e0f1a62a7c1df4928329 100755 (executable)
     Change History (most recent first):
     
 $Log: mDNSWin32.c,v $
+Revision 1.91  2005/04/25 21:34:28  shersche
+<rdar://problem/4096465> Wide-Area services don't disappear when interface goes away
+
+Revision 1.90  2005/04/25 21:18:08  shersche
+<rdar://problem/4097314> mDNSResponder crash when interface goes away.  This error seems to be caused by the Windows platform code not returning mStatus_TransientErr when there is a problem with a udp unicast send.
+
+Revision 1.89  2005/04/22 07:32:24  shersche
+<rdar://problem/4092108> PPP connection disables Bonjour .local lookups
+<rdar://problem/4093944> mDNSResponder ignores Point-to-Point interfaces
+
+Revision 1.88  2005/04/05 03:53:03  shersche
+<rdar://problem/4066485> Registering with shared secret key doesn't work.
+
+Revision 1.87  2005/04/03 08:03:12  shersche
+<rdar://problem/4076478> mDNSResponder won't start on Windows 2000.
+
+Revision 1.86  2005/03/30 07:37:14  shersche
+Use prefix to compute IPv4 subnet mask, falling back to calling AddressToIndexAndMask only if prefix is zero.
+
+Revision 1.85  2005/03/30 07:34:52  shersche
+<rdar://problem/4045657> Interface index being returned is 512
+
+Revision 1.84  2005/03/29 19:19:47  shersche
+<rdar://problem/4055599> Windows is not accepting unicast responses.  This bug was a result of an error in obtaining the subnet mask for IPv4 interfaces.
+
 Revision 1.83  2005/03/07 18:27:42  shersche
 <rdar://problem/4037940> Fix problem when ControlPanel commits changes to the browse domain list
 
@@ -381,6 +406,8 @@ Multicast DNS platform plugin for Win32
        static GUID                                                                             kWSARecvMsgGUID = WSAID_WSARECVMSG;
 #endif
 
+#define kIPv6IfIndexBase                                                       (10000000L)
+
 
 #if 0
 #pragma mark == Prototypes ==
@@ -446,6 +473,16 @@ mDNSexport mStatus mDNSPlatformInterfaceIDToInfo( mDNS * const inMDNS, mDNSInter
 
 // Utilities
 
+typedef struct PolyString PolyString;
+
+struct PolyString
+{
+       domainname                      m_dname;
+       char                            m_utf8[256];
+       PLSA_UNICODE_STRING     m_lsa;
+};
+
+
 #if( MDNS_WINDOWS_USE_IPV6_IF_ADDRS )
        mDNSlocal int   getifaddrs_ipv6( struct ifaddrs **outAddrs );
 #endif
@@ -458,15 +495,18 @@ mDNSexport mStatus        mDNSPlatformInterfaceIDToInfo( mDNS * const inMDNS, mDNSInter
        mDNSlocal int   getifaddrs_ce( struct ifaddrs **outAddrs );
 #endif
 
-mDNSlocal mDNSBool     CanReceiveUnicast( void );
+mDNSlocal DWORD                                GetPrimaryInterface();
+mDNSlocal mStatus                      AddressToIndexAndMask( struct sockaddr * address, uint32_t * index, struct sockaddr * mask );
+mDNSlocal mDNSBool                     CanReceiveUnicast( void );
+mDNSlocal mDNSBool                     IsPointToPoint( IP_ADAPTER_UNICAST_ADDRESS * addr );
 
 mDNSlocal mStatus                      StringToAddress( mDNSAddr * ip, LPSTR string );
 mDNSlocal mStatus                      RegQueryString( HKEY key, LPCSTR param, LPSTR * string, DWORD * stringLen, DWORD * enabled );
 mDNSlocal struct ifaddrs*      myGetIfAddrs(int refresh);
 mDNSlocal OSStatus                     TCHARtoUTF8( const TCHAR *inString, char *inBuffer, size_t inBufferSize );
 mDNSlocal OSStatus                     WindowsLatin1toUTF8( const char *inString, char *inBuffer, size_t inBufferSize );
-mDNSlocal OSStatus                     ConvertUTF8ToLsaString( const char * input, PLSA_UNICODE_STRING output );
-mDNSlocal OSStatus                     ConvertLsaStringToUTF8( PLSA_UNICODE_STRING input, char ** output );
+mDNSlocal OSStatus                     MakeLsaStringFromUTF8String( PLSA_UNICODE_STRING output, const char * input );
+mDNSlocal OSStatus                     MakeUTF8StringFromLsaString( char * output, size_t len, PLSA_UNICODE_STRING input );
 mDNSlocal void                         FreeTCPConnectionData( mDNSTCPConnectionData * data );
 
 #ifdef __cplusplus
@@ -793,7 +833,20 @@ mStatus
        {
                n = sendto( sendingsocket, (char *) inMsg, n, 0, (struct sockaddr *) &addr, sizeof( addr ) );
                err = translate_errno( n > 0, errno_compat(), kWriteErr );
-               require_noerr( err, exit );
+
+               if ( err )
+               {
+                       // Don't report EHOSTDOWN (i.e. ARP failure), ENETDOWN, or no route to host for unicast destinations
+
+                       if ( !mDNSAddressIsAllDNSLinkGroup( inDstIP ) && ( WSAGetLastError() == WSAEHOSTDOWN || WSAGetLastError() == WSAENETDOWN || WSAGetLastError() == WSAEHOSTUNREACH || WSAGetLastError() == WSAENETUNREACH ) )
+                       {
+                               err = mStatus_TransientErr;
+                       }
+                       else
+                       {
+                               require_noerr( err, exit );
+                       }
+               }
        }
        
 exit:
@@ -960,7 +1013,7 @@ mDNSs32    mDNSPlatformRawTime( void )
 
 mDNSexport mDNSs32     mDNSPlatformUTC( void )
 {
-       return( -1 );
+       return ( mDNSs32 ) time( NULL );
 }
 
 //===========================================================================================================================
@@ -1462,36 +1515,38 @@ exit:
 //===========================================================================================================================
 
 void
-dDNSPlatformSetSecretForDomain( mDNS *m, const domainname * domain )
+dDNSPlatformSetSecretForDomain( mDNS *m, const domainname * inDomain )
 {
-       char                                    dstring[MAX_ESCAPED_DOMAIN_NAME];
-       domainname                      *       d;
-       domainname                              canon;
+       PolyString                              domain;
+       PolyString                              key;
+       PolyString                              secret;
        size_t                                  i;
        size_t                                  dlen;
        LSA_OBJECT_ATTRIBUTES   attrs;
        LSA_HANDLE                              handle = NULL;
-       LSA_UNICODE_STRING              keyName = { 0, 0, NULL };
-       LSA_UNICODE_STRING      *       secret = NULL;
-       char                            *       converted = NULL;
        NTSTATUS                                res;
        OSStatus                                err;
 
+       // Initialize PolyStrings
+
+       domain.m_lsa    = NULL;
+       key.m_lsa               = NULL;
+       secret.m_lsa    = NULL;
+
        // canonicalize name by converting to lower case (keychain and some name servers are case sensitive)
        
-       ConvertDomainNameToCString(domain, dstring);
-       dlen = strlen(dstring);
-       for (i = 0; i < dlen; i++)
+       ConvertDomainNameToCString( inDomain, domain.m_utf8 );
+       dlen = strlen( domain.m_utf8 );
+       for ( i = 0; i < dlen; i++ )
        {
-               dstring[i] = (char) tolower(dstring[i]);  // canonicalize -> lower case
+               domain.m_utf8[i] = (char) tolower( domain.m_utf8[i] );  // canonicalize -> lower case
        }
 
-       MakeDomainNameFromDNSNameString(&canon, dstring);
-       d = &canon;
+       MakeDomainNameFromDNSNameString( &domain.m_dname, domain.m_utf8 );
 
        // attrs are reserved, so initialize to zeroes.
 
-       ZeroMemory(&attrs, sizeof( attrs ) );
+       ZeroMemory( &attrs, sizeof( attrs ) );
 
        // Get a handle to the Policy object on the local system
 
@@ -1501,38 +1556,59 @@ dDNSPlatformSetSecretForDomain( mDNS *m, const domainname * domain )
 
        // Get the encrypted data
 
-       err = ConvertUTF8ToLsaString( dstring, &keyName );
+       domain.m_lsa = ( PLSA_UNICODE_STRING) malloc( sizeof( LSA_UNICODE_STRING ) );
+       require_action( domain.m_lsa != NULL, exit, err = mStatus_NoMemoryErr );
+       err = MakeLsaStringFromUTF8String( domain.m_lsa, domain.m_utf8 );
        require_noerr( err, exit );
 
-       res = LsaRetrievePrivateData( handle, &keyName, &secret );
+       // Retrieve the key
+
+       res = LsaRetrievePrivateData( handle, domain.m_lsa, &key.m_lsa );
        err = translate_errno( res == 0, LsaNtStatusToWinError( res ), kUnknownErr );
        require_noerr_quiet( err, exit );
 
-       // Convert the unicode to string to 8 bit
+       // Convert the key to a domainname
 
-       err = ConvertLsaStringToUTF8( secret, &converted );
+       err = MakeUTF8StringFromLsaString( key.m_utf8, sizeof( key.m_utf8 ), key.m_lsa );
        require_noerr( err, exit );
+       MakeDomainNameFromDNSNameString( &key.m_dname, key.m_utf8 );
 
-       mDNS_SetSecretForZone( m, d, d, converted );
+       // Retrieve the secret
+
+       res = LsaRetrievePrivateData( handle, key.m_lsa, &secret.m_lsa );
+       err = translate_errno( res == 0, LsaNtStatusToWinError( res ), kUnknownErr );
+       require_noerr_quiet( err, exit );
+       
+       // Convert the secret to UTF8 string
+
+       err = MakeUTF8StringFromLsaString( secret.m_utf8, sizeof( secret.m_utf8 ), secret.m_lsa );
+       require_noerr( err, exit );
+
+       // And finally, tell the core about this secret
+
+       debugf("Setting shared secret for zone %s with key %##s", domain.m_utf8, key.m_dname.c);
+       mDNS_SetSecretForZone( m, &domain.m_dname, &key.m_dname, secret.m_utf8 );
 
 exit:
 
-       if ( converted )
+       if ( domain.m_lsa != NULL )
        {
-               free( converted );
-               converted = NULL;
+               if ( domain.m_lsa->Buffer != NULL )
+               {
+                       free( domain.m_lsa->Buffer );
+               }
+
+               free( domain.m_lsa );
        }
 
-       if ( secret )
+       if ( key.m_lsa != NULL )
        {
-               LsaFreeMemory( secret );
-               secret = NULL;
+               LsaFreeMemory( key.m_lsa );
        }
 
-       if ( keyName.Buffer )
+       if ( secret.m_lsa != NULL )
        {
-               free( keyName.Buffer );
-               keyName.Buffer = NULL;
+               LsaFreeMemory( secret.m_lsa );
        }
 
        if ( handle )
@@ -1680,35 +1756,64 @@ exit:
 IPAddrListElem*
 dDNSPlatformGetDNSServers( void )
 {
-       FIXED_INFO              *       fixedInfo       = NULL;
-       ULONG                           bufLen          = sizeof( FIXED_INFO ); 
-       IP_ADDR_STRING  *       ipAddr;
-       IPAddrListElem  *       head            = NULL;
-       IPAddrListElem  *       current         = NULL;
+       PIP_PER_ADAPTER_INFO    pAdapterInfo    =       NULL;
+       FIXED_INFO                      *       fixedInfo       = NULL;
+       ULONG                                   bufLen          = 0;    
+       IP_ADDR_STRING          *       dnsServerList;
+       IP_ADDR_STRING          *       ipAddr;
+       IPAddrListElem          *       head            = NULL;
+       IPAddrListElem          *       current         = NULL;
+       DWORD                                   index;
        int                                     i                       = 0;
        mStatus                         err;
 
-       while ( 1 )
+       // Get the primary interface.
+
+       index = GetPrimaryInterface();
+
+       // This should have the interface index of the primary index.  Fall back in cases where
+       // it can't be determined.
+
+       if ( index )
        {
-               if ( fixedInfo )
+               bufLen = 0;
+
+               while ( GetPerAdapterInfo( index, pAdapterInfo, &bufLen ) == ERROR_BUFFER_OVERFLOW )
                {
-                       GlobalFree( fixedInfo );
-                       fixedInfo = NULL;
+                       pAdapterInfo = (PIP_PER_ADAPTER_INFO) realloc( pAdapterInfo, bufLen );
+                       require_action( pAdapterInfo, exit, err = mStatus_NoMemoryErr );
                }
 
-               fixedInfo = (FIXED_INFO*) GlobalAlloc( GPTR, bufLen );
-   
-               err = GetNetworkParams( fixedInfo, &bufLen );
+               dnsServerList = &pAdapterInfo->DnsServerList;
+       }
+       else
+       {
+               bufLen = sizeof( FIXED_INFO );
 
-               if ( ( err != ERROR_BUFFER_OVERFLOW ) || ( i++ == 100 ) )
+               while ( 1 )
                {
-                       break;
+                       if ( fixedInfo )
+                       {
+                               GlobalFree( fixedInfo );
+                               fixedInfo = NULL;
+                       }
+
+                       fixedInfo = (FIXED_INFO*) GlobalAlloc( GPTR, bufLen );
+          
+                       err = GetNetworkParams( fixedInfo, &bufLen );
+
+                       if ( ( err != ERROR_BUFFER_OVERFLOW ) || ( i++ == 100 ) )
+                       {
+                               break;
+                       }
                }
-       }
 
-       require_noerr( err, exit );
+               require_noerr( err, exit );
+
+               dnsServerList = &fixedInfo->DnsServerList;
+       }
 
-       for ( ipAddr = &fixedInfo->DnsServerList; ipAddr; ipAddr = ipAddr->Next )
+       for ( ipAddr = dnsServerList; ipAddr; ipAddr = ipAddr->Next )
        {
                mDNSAddr                        addr;
                IPAddrListElem  *       last = current;
@@ -1739,6 +1844,11 @@ dDNSPlatformGetDNSServers( void )
 
 exit:
 
+       if ( pAdapterInfo )
+       {
+               free( pAdapterInfo );
+       }
+
        if ( fixedInfo )
        {
                GlobalFree( fixedInfo );
@@ -1835,6 +1945,7 @@ dDNSPlatformGetPrimaryInterface( mDNS * m, mDNSAddr * primary, mDNSAddr * router
        DWORD                           bufLen          = sizeof( IP_ADAPTER_INFO );
        int                                     i;
        BOOL                            found;
+       DWORD                           index;
        mStatus                         err = mStatus_NoError;
 
        DEBUG_UNUSED( m );
@@ -1861,10 +1972,7 @@ dDNSPlatformGetPrimaryInterface( mDNS * m, mDNSAddr * primary, mDNSAddr * router
                }
        }
 
-       // Windows doesn't really have a concept of a primary adapter,
-       // so we're just going to iterate through all the adapters and
-       // pick the first one that has an IP address assigned and
-       // a gateway assigned
+       index = GetPrimaryInterface();
 
        for ( pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next )
        {
@@ -1873,7 +1981,8 @@ dDNSPlatformGetPrimaryInterface( mDNS * m, mDNSAddr * primary, mDNSAddr * router
                     pAdapter->GatewayList.IpAddress.String &&
                     pAdapter->GatewayList.IpAddress.String[0] &&
                     ( StringToAddress( primary, pAdapter->IpAddressList.IpAddress.String ) == mStatus_NoError ) &&
-                    ( StringToAddress( router, pAdapter->GatewayList.IpAddress.String ) == mStatus_NoError ) )
+                    ( StringToAddress( router, pAdapter->GatewayList.IpAddress.String ) == mStatus_NoError ) &&
+                    ( !index || ( pAdapter->Index == index ) ) )
                {
                        // Found one that will work
 
@@ -1882,16 +1991,6 @@ dDNSPlatformGetPrimaryInterface( mDNS * m, mDNSAddr * primary, mDNSAddr * router
                }
        }
 
-       if ( !found )
-       {
-               // If we couldn't find one, then let's try the first one in the list
-
-               err = StringToAddress( primary, pAdapter->IpAddressList.IpAddress.String );
-               require_noerr( err, exit );
-
-               found = TRUE;
-       }
-
 exit:
 
        if ( pAdapterInfo )
@@ -2232,19 +2331,24 @@ mDNSlocal mStatus       SetupInterfaceList( mDNS * const inMDNS )
        mDNSInterfaceData *                     ifd;
        struct ifaddrs *                        addrs;
        struct ifaddrs *                        p;
-       struct ifaddrs *                        loopback;
+       struct ifaddrs *                        loopbackv4;
+       struct ifaddrs *                        loopbackv6;
        u_int                                           flagMask;
        u_int                                           flagTest;
-       BOOL                                            foundUnicastSock4DestAddr;
-       BOOL                                            foundUnicastSock6DestAddr;
+       mDNSBool                                        foundv4;
+       mDNSBool                                        foundv6;
+       mDNSBool                                        foundUnicastSock4DestAddr;
+       mDNSBool                                        foundUnicastSock6DestAddr;
        
        dlog( kDebugLevelTrace, DEBUG_NAME "setting up interface list\n" );
        check( inMDNS );
        check( inMDNS->p );
        
        addrs                                           = NULL;
-       foundUnicastSock4DestAddr       = FALSE;
-       foundUnicastSock6DestAddr       = FALSE;
+       foundv4                                         = mDNSfalse;
+       foundv6                                         = mDNSfalse;
+       foundUnicastSock4DestAddr       = mDNSfalse;
+       foundUnicastSock6DestAddr       = mDNSfalse;
        
        // Tear down any existing interfaces that may be set up.
        
@@ -2266,10 +2370,11 @@ mDNSlocal mStatus       SetupInterfaceList( mDNS * const inMDNS )
        err = getifaddrs( &addrs );
        require_noerr( err, exit );
        
-       loopback        = NULL;
+       loopbackv4      = NULL;
+       loopbackv6      = NULL;
        next            = &inMDNS->p->interfaceList;
-       
-       flagMask = IFF_UP | IFF_MULTICAST | IFF_POINTTOPOINT;
+
+       flagMask = IFF_UP | IFF_MULTICAST;
        flagTest = IFF_UP | IFF_MULTICAST;
        
 #if( MDNS_WINDOWS_ENABLE_IPV4 )
@@ -2281,9 +2386,9 @@ mDNSlocal mStatus SetupInterfaceList( mDNS * const inMDNS )
                }
                if( p->ifa_flags & IFF_LOOPBACK )
                {
-                       if( !loopback )
+                       if( !loopbackv4 )
                        {
-                               loopback = p;
+                               loopbackv4 = p;
                        }
                        continue;
                }
@@ -2292,7 +2397,16 @@ mDNSlocal mStatus        SetupInterfaceList( mDNS * const inMDNS )
                
                err = SetupInterface( inMDNS, p, &ifd );
                require_noerr( err, exit );
-               
+
+               // If this guy is point-to-point (ifd->interfaceInfo.McastTxRx == 0 ) we still want to
+               // register him, but we also want to note that we haven't found a v4 interface
+               // so that we register loopback so same host operations work
+               
+               if ( ifd->interfaceInfo.McastTxRx == mDNStrue )
+               {
+                       foundv4 = mDNStrue;
+               }
+
                // If we're on a platform that doesn't have WSARecvMsg(), there's no way
                // of determing the destination address of a packet that is sent to us.
                // For multicast packets, that's easy to determine.  But for the unicast
@@ -2308,8 +2422,6 @@ mDNSlocal mStatus SetupInterfaceList( mDNS * const inMDNS )
                *next = ifd;
                next  = &ifd->next;
                ++inMDNS->p->interfaceCount;
-
-               
        }
 #endif
        
@@ -2324,9 +2436,9 @@ mDNSlocal mStatus SetupInterfaceList( mDNS * const inMDNS )
                }
                if( p->ifa_flags & IFF_LOOPBACK )
                {
-                       if( !loopback )
+                       if( !loopbackv6 )
                        {
-                               loopback = p;
+                               loopbackv6 = p;
                        }
                        continue;
                }
@@ -2336,6 +2448,15 @@ mDNSlocal mStatus        SetupInterfaceList( mDNS * const inMDNS )
                err = SetupInterface( inMDNS, p, &ifd );
                require_noerr( err, exit );
                                
+               // If this guy is point-to-point (ifd->interfaceInfo.McastTxRx == 0 ) we still want to
+               // register him, but we also want to note that we haven't found a v4 interface
+               // so that we register loopback so same host operations work
+               
+               if ( ifd->interfaceInfo.McastTxRx == mDNStrue )
+               {
+                       foundv6 = mDNStrue;
+               }
+
                // If we're on a platform that doesn't have WSARecvMsg(), there's no way
                // of determing the destination address of a packet that is sent to us.
                // For multicast packets, that's easy to determine.  But for the unicast
@@ -2371,18 +2492,19 @@ mDNSlocal mStatus       SetupInterfaceList( mDNS * const inMDNS )
                {
                        continue;
                }
-               loopback = p;
+               
+               v4loopback = p;
                break;
        }
        
 #endif
        
-       if( !inMDNS->p->interfaceList && loopback )
+       if ( !foundv4 && loopbackv4 )
        {
                dlog( kDebugLevelVerbose, DEBUG_NAME "Interface %40s (0x%08X) %##a\n", 
-                       loopback->ifa_name ? loopback->ifa_name : "<null>", loopback->ifa_extra.index, loopback->ifa_addr );
+                       loopbackv4->ifa_name ? loopbackv4->ifa_name : "<null>", loopbackv4->ifa_extra.index, loopbackv4->ifa_addr );
                
-               err = SetupInterface( inMDNS, loopback, &ifd );
+               err = SetupInterface( inMDNS, loopbackv4, &ifd );
                require_noerr( err, exit );
                
 #if( MDNS_WINDOWS_ENABLE_IPV4 )
@@ -2497,7 +2619,6 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inI
        ifd->sock               = kInvalidSocketRef;
        ifd->index              = inIFA->ifa_extra.index;
        ifd->scopeID    = inIFA->ifa_extra.index;
-       
        check( strlen( inIFA->ifa_name ) < sizeof( ifd->name ) );
        strncpy( ifd->name, inIFA->ifa_name, sizeof( ifd->name ) - 1 );
        ifd->name[ sizeof( ifd->name ) - 1 ] = '\0';
@@ -2512,7 +2633,7 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inI
        // but we cut the packet rate in half. At this time, reducing the packet rate is more important than v6-only 
        // devices on a large configured network, so we are willing to make that sacrifice.
        
-       ifd->interfaceInfo.McastTxRx   = mDNStrue;
+       ifd->interfaceInfo.McastTxRx   = ( ( inIFA->ifa_flags & IFF_MULTICAST ) && !( inIFA->ifa_flags & IFF_POINTTOPOINT ) ) ? mDNStrue : mDNSfalse;
        ifd->interfaceInfo.InterfaceID = NULL;
 
        for( p = inMDNS->p->interfaceList; p; p = p->next )
@@ -2521,7 +2642,6 @@ mDNSlocal mStatus SetupInterface( mDNS * const inMDNS, const struct ifaddrs *inI
                {
                        if (!ifd->interfaceInfo.InterfaceID)
                        {
-                               p->scopeID                                              = ifd->scopeID;
                                ifd->interfaceInfo.InterfaceID  = (mDNSInterfaceID) p;
                        }
 
@@ -3496,7 +3616,7 @@ mDNSlocal void    ProcessingThreadProcessPacket( mDNS *inMDNS, mDNSInterfaceData *i
 
                                if ( inIFD )
                                {
-                                       require_action( ipv4PacketInfo->ipi_ifindex == ( inIFD->index >> 8 ), exit, err = kMismatchErr );
+                                       require_action( ipv4PacketInfo->ipi_ifindex == inIFD->index, exit, err = kMismatchErr );
                                }
 
                                dstAddr.type                            = mDNSAddrType_IPv4;
@@ -3510,7 +3630,7 @@ mDNSlocal void    ProcessingThreadProcessPacket( mDNS *inMDNS, mDNSInterfaceData *i
 
                                if ( inIFD )
                                {
-                                       require_action( ipv6PacketInfo->ipi6_ifindex == inIFD->index, exit, err = kMismatchErr );
+                                       require_action( ipv6PacketInfo->ipi6_ifindex == ( inIFD->index - kIPv6IfIndexBase), exit, err = kMismatchErr );
                                }
 
                                dstAddr.type    = mDNSAddrType_IPv6;
@@ -3577,6 +3697,13 @@ mDNSlocal void   ProcessingThreadInterfaceListChanged( mDNS *inMDNS )
        err = SetupInterfaceList( inMDNS );
        check_noerr( err );
                
+       err = dDNS_Setup( inMDNS );
+       check_noerr( err );
+
+       // so that LLQs are restarted against the up to date name servers
+
+       mDNS_UpdateLLQs( inMDNS );
+
        mDNSPlatformUnlock( inMDNS );
        
        // Inform clients of the change.
@@ -3638,6 +3765,10 @@ mDNSlocal void ProcessingThreadTCPIPConfigChanged( mDNS * inMDNS )
        err = dDNS_Setup( inMDNS );
        check_noerr( err );
 
+       // so that LLQs are restarted against the up to date name servers
+
+       mDNS_UpdateLLQs( inMDNS );
+
        // and reset the event handler
 
        if ( ( inMDNS->p->tcpipKey != NULL ) && ( inMDNS->p->tcpipChangedEvent ) )
@@ -3665,6 +3796,10 @@ mDNSlocal void   ProcessingThreadDynDNSConfigChanged( mDNS *inMDNS )
        err = dDNS_Setup( inMDNS );
        check_noerr( err );
 
+       // so that LLQs are restarted against the up to date name servers
+
+       mDNS_UpdateLLQs( inMDNS );
+
        // and reset the event handler
 
        if ((inMDNS->p->ddnsKey != NULL) && (inMDNS->p->ddnsChangedEvent))
@@ -3770,7 +3905,7 @@ mDNSlocal int     getifaddrs_ipv6( struct ifaddrs **outAddrs )
        // This loops to handle the case where the interface changes in the window after getting the size, but before the
        // second call completes. A limit of 100 retries is enforced to prevent infinite loops if something else is wrong.
        
-       flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME;
+       flags = GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME;
        i = 0;
        for( ;; )
        {
@@ -3868,16 +4003,27 @@ mDNSlocal int   getifaddrs_ipv6( struct ifaddrs **outAddrs )
                        ifa->ifa_flags = 0;
                        if( iaa->OperStatus == IfOperStatusUp )                 ifa->ifa_flags |= IFF_UP;
                        if( iaa->IfType == IF_TYPE_SOFTWARE_LOOPBACK )  ifa->ifa_flags |= IFF_LOOPBACK;
+                       else if ( IsPointToPoint( addr ) )                              ifa->ifa_flags |= IFF_POINTTOPOINT;
                        if( !( iaa->Flags & IP_ADAPTER_NO_MULTICAST ) ) ifa->ifa_flags |= IFF_MULTICAST;
+
                        
-                       // Get the interface index. Windows does not have a uniform scheme for IPv4 and IPv6 interface indexes
-                       // so the following is a hack to put IPv4 interface indexes in the upper 24-bits and IPv6 interface indexes
-                       // in the lower 8-bits. This allows the IPv6 interface index to be usable as an IPv6 scope ID directly.
+                       // <rdar://problem/4045657> Interface index being returned is 512
+                       //
+                       // Windows does not have a uniform scheme for IPv4 and IPv6 interface indexes.
+                       // This code used to shift the IPv4 index up to ensure uniqueness between
+                       // it and IPv6 indexes.  Although this worked, it was somewhat confusing to developers, who
+                       // then see interface indexes passed back that don't correspond to anything
+                       // that is seen in Win32 APIs or command line tools like "route".  As a relatively
+                       // small percentage of developers are actively using IPv6, it seems to 
+                       // make sense to make our use of IPv4 as confusion free as possible.
+                       // So now, IPv6 interface indexes will be shifted up by a
+                       // constant value which will serve to uniquely identify them, and we will
+                       // leave IPv4 interface indexes unmodified.
                        
                        switch( family )
                        {
-                               case AF_INET:  ifa->ifa_extra.index = iaa->IfIndex << 8; break;
-                               case AF_INET6: ifa->ifa_extra.index = ipv6IfIndex;       break;
+                               case AF_INET:  ifa->ifa_extra.index = iaa->IfIndex; break;
+                               case AF_INET6: ifa->ifa_extra.index = ipv6IfIndex + kIPv6IfIndexBase;    break;
                                default: break;
                        }
                        
@@ -3913,7 +4059,7 @@ mDNSlocal int     getifaddrs_ipv6( struct ifaddrs **outAddrs )
                        {
                                case AF_INET:
                                {
-                                       struct sockaddr_in *            sa4;
+                                       struct sockaddr_in * sa4;
                                        
                                        require_action( prefixLength <= 32, exit, err = ERROR_INVALID_DATA );
                                        
@@ -3921,12 +4067,21 @@ mDNSlocal int   getifaddrs_ipv6( struct ifaddrs **outAddrs )
                                        require_action( sa4, exit, err = WSAENOBUFS );
                                        
                                        sa4->sin_family = AF_INET;
-                                       if( prefixLength == 0 )
+                                       
+                                       if ( prefixLength != 0 )
+                                       {
+                                               sa4->sin_addr.s_addr = htonl( 0xFFFFFFFFU << ( 32 - prefixLength ) );
+                                       }
+                                       else
                                        {
-                                               dlog( kDebugLevelWarning, DEBUG_NAME "%s: IPv4 netmask 0, defaulting to 255.255.255.255\n", __ROUTINE__ );
-                                               prefixLength = 32;
+                                               uint32_t index;
+
+                                               dlog( kDebugLevelWarning, DEBUG_NAME "%s: IPv4 prefixLength is 0\n", __ROUTINE__ );
+                                               err = AddressToIndexAndMask( ifa->ifa_addr, &index, (struct sockaddr*) sa4 );
+                                               require_noerr( err, exit );
                                        }
-                                       sa4->sin_addr.s_addr = htonl( 0xFFFFFFFFU << ( 32 - prefixLength ) );
+
+                                       dlog( kDebugLevelInfo, DEBUG_NAME "%s: IPv4 mask = %s\n", __ROUTINE__, inet_ntoa( sa4->sin_addr ) );
                                        ifa->ifa_netmask = (struct sockaddr *) sa4;
                                        break;
                                }
@@ -4073,32 +4228,31 @@ mDNSlocal int   getifaddrs_ipv4( struct ifaddrs **outAddrs )
                
                // Get addresses.
                
-               switch( ifInfo->iiAddress.Address.sa_family )
+               if ( ifInfo->iiAddress.Address.sa_family == AF_INET )
                {
-                       case AF_INET:
-                       {
-                               struct sockaddr_in *            sa4;
-                               
-                               sa4 = &ifInfo->iiAddress.AddressIn;
-                               ifa->ifa_addr = (struct sockaddr *) calloc( 1, sizeof( *sa4 ) );
-                               require_action( ifa->ifa_addr, exit, err = WSAENOBUFS );
-                               memcpy( ifa->ifa_addr, sa4, sizeof( *sa4 ) );
+                       struct sockaddr_in *            sa4;
+                       
+                       sa4 = &ifInfo->iiAddress.AddressIn;
+                       ifa->ifa_addr = (struct sockaddr *) calloc( 1, sizeof( *sa4 ) );
+                       require_action( ifa->ifa_addr, exit, err = WSAENOBUFS );
+                       memcpy( ifa->ifa_addr, sa4, sizeof( *sa4 ) );
 
-                               sa4 = &ifInfo->iiNetmask.AddressIn;
-                               ifa->ifa_netmask = (struct sockaddr*) calloc(1, sizeof( *sa4 ) );
-                               require_action( ifa->ifa_netmask, exit, err = WSAENOBUFS );
-                               memcpy( ifa->ifa_netmask, sa4, sizeof( *sa4 ) );
+                       ifa->ifa_netmask = (struct sockaddr*) calloc(1, sizeof( *sa4 ) );
 
-                               break;
-                       }
-                       
-                       default:
-                               break;
+                       // <rdar://problem/4076478> Service won't start on Win2K. The address
+                       // family field was not being initialized.
+
+                       ifa->ifa_netmask->sa_family = AF_INET;
+                       require_action( ifa->ifa_netmask, exit, err = WSAENOBUFS );
+                       err = AddressToIndexAndMask( ifa->ifa_addr, &ifa->ifa_extra.index, ifa->ifa_netmask );
+                       require_noerr( err, exit );
                }
+               else
+               {
+                       // Emulate an interface index.
                
-               // Emulate an interface index.
-               
-               ifa->ifa_extra.index = (uint32_t)( i + 1 );
+                       ifa->ifa_extra.index = (uint32_t)( i + 1 );
+               }
        }
        
        // Success!
@@ -4297,6 +4451,118 @@ void    freeifaddrs( struct ifaddrs *inIFAs )
        }
 }
 
+
+//===========================================================================================================================
+//     GetPrimaryInterface
+//===========================================================================================================================
+
+mDNSlocal DWORD
+GetPrimaryInterface()
+{
+       PMIB_IPFORWARDTABLE     pIpForwardTable = NULL;
+       DWORD                           dwSize                  = 0;
+       BOOL                            bOrder                  = FALSE;
+       OSStatus                        err;
+       DWORD                           index                   = 0;
+       DWORD                           metric                  = 0;
+       unsigned long int       i;
+
+       // Find out how big our buffer needs to be.
+
+       err = GetIpForwardTable(NULL, &dwSize, bOrder);
+       require_action( err == ERROR_INSUFFICIENT_BUFFER, exit, err = kUnknownErr );
+
+       // Allocate the memory for the table
+
+       pIpForwardTable = (PMIB_IPFORWARDTABLE) malloc( dwSize );
+       require_action( pIpForwardTable, exit, err = kNoMemoryErr );
+  
+       // Now get the table.
+
+       err = GetIpForwardTable(pIpForwardTable, &dwSize, bOrder);
+       require_noerr( err, exit );
+
+
+       // Search for the row in the table we want.
+
+       for ( i = 0; i < pIpForwardTable->dwNumEntries; i++)
+       {
+               // Look for a default route
+
+               if ( pIpForwardTable->table[i].dwForwardDest == 0 )
+               {
+                       if ( index && ( pIpForwardTable->table[i].dwForwardMetric1 >= metric ) )
+                       {
+                               continue;
+                       }
+
+                       index   = pIpForwardTable->table[i].dwForwardIfIndex;
+                       metric  = pIpForwardTable->table[i].dwForwardMetric1;
+               }
+       }
+
+exit:
+
+       if ( pIpForwardTable != NULL )
+       {
+               free( pIpForwardTable );
+       }
+
+       return index;
+}
+
+
+//===========================================================================================================================
+//     AddressToIndexAndMask
+//===========================================================================================================================
+
+mDNSlocal mStatus
+AddressToIndexAndMask( struct sockaddr * addr, uint32_t * ifIndex, struct sockaddr * mask  )
+{
+       // Before calling AddIPAddress we use GetIpAddrTable to get
+       // an adapter to which we can add the IP.
+       
+       PMIB_IPADDRTABLE        pIPAddrTable    = NULL;
+       DWORD                           dwSize                  = 0;
+       mStatus                         err                             = mStatus_UnknownErr;
+       DWORD                           i;
+
+       // For now, this is only for IPv4 addresses.  That is why we can safely cast
+       // addr's to sockaddr_in.
+
+       require_action( addr->sa_family == AF_INET, exit, err = mStatus_UnknownErr );
+
+       // Make an initial call to GetIpAddrTable to get the
+       // necessary size into the dwSize variable
+
+       while ( GetIpAddrTable( pIPAddrTable, &dwSize, 0 ) == ERROR_INSUFFICIENT_BUFFER )
+       {
+               pIPAddrTable = (MIB_IPADDRTABLE *) realloc( pIPAddrTable, dwSize );
+               require_action( pIPAddrTable, exit, err = WSAENOBUFS );
+       }
+
+       for ( i = 0; i < pIPAddrTable->dwNumEntries; i++ )
+       {
+               if ( ( ( struct sockaddr_in* ) addr )->sin_addr.s_addr == pIPAddrTable->table[i].dwAddr )
+               {
+                       *ifIndex                                                                                        = pIPAddrTable->table[i].dwIndex;
+                       ( ( struct sockaddr_in*) mask )->sin_addr.s_addr        = pIPAddrTable->table[i].dwMask;
+                       err                                                                                                     = mStatus_NoError;
+                       break;
+               }
+       }
+
+exit:
+
+       if ( pIPAddrTable )
+       {
+               free( pIPAddrTable );
+       }
+
+       return err;
+}
+
+
 //===========================================================================================================================
 //     CanReceiveUnicast
 //===========================================================================================================================
@@ -4327,6 +4593,49 @@ mDNSlocal mDNSBool       CanReceiveUnicast( void )
        return( ok );
 }
 
+
+//===========================================================================================================================
+//     IsPointToPoint
+//===========================================================================================================================
+
+mDNSlocal mDNSBool IsPointToPoint( IP_ADAPTER_UNICAST_ADDRESS * addr )
+{
+       struct ifaddrs  *       addrs   =       NULL;
+       struct ifaddrs  *       p               =       NULL;
+       OSStatus                        err;
+       mDNSBool                        ret             =       mDNSfalse;
+
+       // For now, only works for IPv4 interfaces
+
+       if ( addr->Address.lpSockaddr->sa_family == AF_INET )
+       {
+               // The getifaddrs_ipv4 call will give us correct information regarding IFF_POINTTOPOINT flags.
+
+               err = getifaddrs_ipv4( &addrs );
+               require_noerr( err, exit );
+
+               for ( p = addrs; p; p = p->ifa_next )
+               {
+                       if ( ( addr->Address.lpSockaddr->sa_family == p->ifa_addr->sa_family ) &&
+                            ( ( ( struct sockaddr_in* ) addr->Address.lpSockaddr )->sin_addr.s_addr == ( ( struct sockaddr_in* ) p->ifa_addr )->sin_addr.s_addr ) )
+                       {
+                               ret = ( p->ifa_flags & IFF_POINTTOPOINT ) ? mDNStrue : mDNSfalse;
+                               break;
+                       }
+               }
+       }
+
+exit:
+
+       if ( addrs )
+       {
+               freeifaddrs( addrs );
+       }
+
+       return ret;
+}
+
+
 //===========================================================================================================================
 //     GetWindowsVersionString
 //===========================================================================================================================
@@ -4504,6 +4813,7 @@ static mStatus StringToAddress( mDNSAddr * ip, LPSTR string )
                dwSize = sizeof( sa4 );
 
                err = WSAStringToAddressA( string, AF_INET, NULL, (struct sockaddr*) &sa4, &dwSize );
+               err = translate_errno( err == 0, WSAGetLastError(), kUnknownErr );
                require_noerr( err, exit );
                        
                err = dDNS_SetupAddr( ip, (struct sockaddr*) &sa4 );
@@ -4606,7 +4916,7 @@ exit:
 //===========================================================================================================================
 
 mDNSlocal OSStatus
-ConvertUTF8ToLsaString( const char * input, PLSA_UNICODE_STRING output )
+MakeLsaStringFromUTF8String( PLSA_UNICODE_STRING output, const char * input )
 {
        int                     size;
        OSStatus        err;
@@ -4650,41 +4960,36 @@ exit:
 //===========================================================================================================================
 
 static OSStatus
-ConvertLsaStringToUTF8( PLSA_UNICODE_STRING input, char ** output )
+MakeUTF8StringFromLsaString( char * output, size_t len, PLSA_UNICODE_STRING input )
 {
-       int                     size;
+       size_t          size;
        OSStatus        err = kNoErr;
 
        // The Length field of this structure holds the number of bytes,
        // but WideCharToMultiByte expects the number of wchar_t's. So
        // we divide by sizeof(wchar_t) to get the correct number.
 
-       size = WideCharToMultiByte(CP_UTF8, 0, input->Buffer, ( input->Length / sizeof( wchar_t ) ), NULL, 0, NULL, NULL);
+       size = (size_t) WideCharToMultiByte(CP_UTF8, 0, input->Buffer, ( input->Length / sizeof( wchar_t ) ), NULL, 0, NULL, NULL);
        err = translate_errno( size != 0, GetLastError(), kUnknownErr );
        require_noerr( err, exit );
        
-       // Add one for trailing '\0'
+       // Ensure that we have enough space (Add one for trailing '\0')
+
+       require_action( ( size + 1 ) <= len, exit, err = mStatus_NoMemoryErr );
 
-       *output = (char*) malloc( size + 1 );
-       require_action( *output, exit, err = mStatus_NoMemoryErr );
+       // Convert the string
 
-       size = WideCharToMultiByte(CP_UTF8, 0, input->Buffer, ( input->Length / sizeof( wchar_t ) ), *output, size, NULL, NULL);        
+       size = (size_t) WideCharToMultiByte( CP_UTF8, 0, input->Buffer, ( input->Length / sizeof( wchar_t ) ), output, (int) size, NULL, NULL); 
        err = translate_errno( size != 0, GetLastError(), kUnknownErr );
        require_noerr( err, exit );
 
        // have to add the trailing 0 because WideCharToMultiByte doesn't do it,
        // although it does return the correct size
 
-       (*output)[size] = '\0';
+       output[size] = '\0';
 
 exit:
 
-       if ( err && *output )
-       {
-               free( *output );
-               *output = NULL;
-       }
-
        return err;
 }
 
index c690459adcf8b1f708ae50ae0230e0c97849471f..d19254395cfb163b637b7eb554ab037be06b1f52 100644 (file)
     Change History (most recent first):
     
 $Log: mdnsNSP.c,v $
+Revision 1.14  2005/03/29 20:35:28  shersche
+<rdar://problem/4053899> Remove reverse lookup implementation due to NSP framework limitation
+
+Revision 1.13  2005/03/29 19:42:47  shersche
+Do label check before checking etc/hosts file
+
+Revision 1.12  2005/03/21 00:42:45  shersche
+<rdar://problem/4021486> Fix build warnings on Win32 platform
+
+Revision 1.11  2005/03/16 03:04:51  shersche
+<rdar://problem/4050633> Don't issue multicast query multilabel dot-local names
+
 Revision 1.10  2005/02/23 22:16:07  shersche
 Unregister the NSP before registering to workaround an installer problem during upgrade installs
 
@@ -227,6 +239,11 @@ DEBUG_LOCAL OSStatus       HostsFileOpen( HostsFile ** self, const char * fname );
 DEBUG_LOCAL OSStatus   HostsFileClose( HostsFile * self );
 DEBUG_LOCAL void               HostsFileInfoFree( HostsFileInfo * info );
 DEBUG_LOCAL OSStatus   HostsFileNext( HostsFile * self, HostsFileInfo ** hInfo );
+DEBUG_LOCAL const char * GetNextLabel( const char *cstr, char label[64] );
+
+#ifdef ENABLE_REVERSE_LOOKUP
+DEBUG_LOCAL OSStatus   IsReverseLookup( LPCWSTR name, size_t size );
+#endif
 
 
 #if 0
@@ -545,70 +562,49 @@ DEBUG_LOCAL int WSPAPI
                ( ( p[ 4 ] != 'A' ) && ( p[ 4 ] != 'a' ) )      ||
                ( ( p[ 5 ] != 'L' ) && ( p[ 5 ] != 'l' ) ) ) )
        {
-               require_action_quiet( size > sizeof_string( ".0.8.e.f.ip6.arpa" ), exit, err = WSASERVICE_NOT_FOUND );
-               p = name + ( size - 1 );
-               p = ( *p == '.' ) ? ( p - sizeof_string( ".0.8.e.f.ip6.arpa" ) ) : ( ( p - sizeof_string( ".0.8.e.f.ip6.arpa" ) ) + 1 );
-       
-               if      ( ( ( p[ 0 ] != '.' )                                                   ||
-                       ( ( p[ 1 ] != '0' ) )                                                   ||
-                       ( ( p[ 2 ] != '.' ) )                                                   ||
-                       ( ( p[ 3 ] != '8' ) )                                                   ||
-                       ( ( p[ 4 ] != '.' ) )                                                   ||
-                       ( ( p[ 5 ] != 'E' ) && ( p[ 5 ] != 'e' ) )              ||
-                       ( ( p[ 6 ] != '.' ) )                                                   ||
-                       ( ( p[ 7 ] != 'F' ) && ( p[ 7 ] != 'f' ) )              ||
-                       ( ( p[ 8 ] != '.' ) )                                                   ||
-                       ( ( p[ 9 ] != 'I' ) && ( p[ 9 ] != 'i' ) )              ||
-                       ( ( p[ 10 ] != 'P' ) && ( p[ 10 ] != 'p' ) )    ||      
-                       ( ( p[ 11 ] != '6' ) )                                                  ||
-                       ( ( p[ 12 ] != '.' ) )                                                  ||
-                       ( ( p[ 13 ] != 'A' ) && ( p[ 13 ] != 'a' ) )    ||
-                       ( ( p[ 14 ] != 'R' ) && ( p[ 14 ] != 'r' ) )    ||
-                       ( ( p[ 15 ] != 'P' ) && ( p[ 15 ] != 'p' ) )    ||
-                       ( ( p[ 16 ] != 'A' ) && ( p[ 16 ] != 'a' ) ) ) )
-               {
-                       require_action_quiet( size > sizeof_string( ".254.169.in-addr.arpa" ), exit, err = WSASERVICE_NOT_FOUND );
-                       p = name + ( size - 1 );
-                       p = ( *p == '.' ) ? ( p - sizeof_string( ".254.169.in-addr.arpa" ) ) : ( ( p - sizeof_string( ".254.169.in-addr.arpa" ) ) + 1 );
-       
-       require_action_quiet( ( ( p[ 0 ] == '.' )                                                &&
-                                                                       ( ( p[ 1 ] == '2' ) )                                                   &&
-                                                                       ( ( p[ 2 ] == '5' ) )                                                   &&
-                                                                       ( ( p[ 3 ] == '4' ) )                                                   &&
-                                                                       ( ( p[ 4 ] == '.' ) )                                                   &&
-                                                                       ( ( p[ 5 ] == '1' ) )                                                   &&
-                                                                       ( ( p[ 6 ] == '6' ) )                                                   &&
-                                                                       ( ( p[ 7 ] == '9' ) )                                                   &&
-                                                                       ( ( p[ 8 ] == '.' ) )                                                   &&
-                                                                       ( ( p[ 9 ] == 'I' ) || ( p[ 9 ] == 'i' ) )              &&
-                                                                       ( ( p[ 10 ] == 'N' ) || ( p[ 10 ] == 'n' ) )    &&      
-                                                                       ( ( p[ 11 ] == '-' ) )                                                  &&
-                                                                       ( ( p[ 12 ] == 'A' ) || ( p[ 12 ] == 'a' ) )    &&
-                                                                       ( ( p[ 13 ] == 'D' ) || ( p[ 13 ] == 'd' ) )    &&
-                                                                       ( ( p[ 14 ] == 'D' ) || ( p[ 14 ] == 'd' ) )    &&
-                                                                       ( ( p[ 15 ] == 'R' ) || ( p[ 15 ] == 'r' ) )    &&
-                                                                       ( ( p[ 16 ] == '.' ) )                                                  &&
-                                                                       ( ( p[ 17 ] == 'A' ) || ( p[ 17 ] == 'a' ) )    &&
-                                                                       ( ( p[ 18 ] == 'R' ) || ( p[ 18 ] == 'r' ) )    &&
-                                                                       ( ( p[ 19 ] == 'P' ) || ( p[ 19 ] == 'p' ) )    &&
-                                                                       ( ( p[ 20 ] == 'A' ) || ( p[ 20 ] == 'a' ) ) ),
-                                                                       exit, err = WSASERVICE_NOT_FOUND );
-               }
+#ifdef ENABLE_REVERSE_LOOKUP
+
+               err = IsReverseLookup( name, size );
+
+#else
+
+               err = WSASERVICE_NOT_FOUND;
+
+#endif
+
+               require_noerr( err, exit );
        }
        else
        {
+               const char      *       replyDomain;
+               char                    translated[ kDNSServiceMaxDomainName ];
+               int                             n;
+               int                             labels          = 0;
+               const char      *       label[128];
+               char                    text[64];
+
+               n = WideCharToMultiByte( CP_UTF8, 0, name, -1, translated, sizeof( translated ), NULL, NULL );
+               require_action( n > 0, exit, err = WSASERVICE_NOT_FOUND );
+
+               // <rdar://problem/4050633>
+
+               // Don't resolve multi-label name
+
+               replyDomain = translated;
+
+               while ( *replyDomain )
+               {
+                       label[labels++] = replyDomain;
+                       replyDomain             = GetNextLabel(replyDomain, text);
+               }
+
+               require_action( labels == 2, exit, err = WSASERVICE_NOT_FOUND );
+
                // <rdar://problem/3936771>
                //
                // Check to see if the name of this host is in the hosts table. If so,
                // don't try and resolve it
                
-               char    translated[ kDNSServiceMaxDomainName ];
-               int             n;
-
-               n = WideCharToMultiByte( CP_UTF8, 0, name, -1, translated, sizeof( translated ), NULL, NULL );
-               require_action( n > 0, exit, err = WSASERVICE_NOT_FOUND );
                require_action( InHostsTable( translated ) == FALSE, exit, err = WSASERVICE_NOT_FOUND );
        }
 
@@ -1984,3 +1980,108 @@ exit:
 
        return err;
 }
+
+
+//===========================================================================================================================
+//     GetNextLabel
+//===========================================================================================================================
+DEBUG_LOCAL const char*
+GetNextLabel(const char *cstr, char label[64])
+{
+       char *ptr = label;
+       while (*cstr && *cstr != '.')                                                           // While we have characters in the label...
+               {
+               char c = *cstr++;
+               if (c == '\\')
+                       {
+                       c = *cstr++;
+                       if (isdigit(cstr[-1]) && isdigit(cstr[0]) && isdigit(cstr[1]))
+                               {
+                               int v0 = cstr[-1] - '0';                                                // then interpret as three-digit decimal
+                               int v1 = cstr[ 0] - '0';
+                               int v2 = cstr[ 1] - '0';
+                               int val = v0 * 100 + v1 * 10 + v2;
+                               if (val <= 255) { c = (char)val; cstr += 2; }   // If valid three-digit decimal value, use it
+                               }
+                       }
+               *ptr++ = c;
+               if (ptr >= label+64) return(NULL);
+               }
+       if (*cstr) cstr++;                                                                                      // Skip over the trailing dot (if present)
+       *ptr++ = 0;
+       return(cstr);
+}
+
+
+#ifdef ENABLE_REVERSE_LOOKUP
+//===========================================================================================================================
+//     IsReverseLookup
+//===========================================================================================================================
+
+DEBUG_LOCAL OSStatus
+IsReverseLookup( LPCWSTR name, size_t size )
+{
+       LPCWSTR         p;
+       OSStatus        err = kNoErr;
+
+       require_action_quiet( size > sizeof_string( ".0.8.e.f.ip6.arpa" ), exit, err = WSASERVICE_NOT_FOUND );
+       p = name + ( size - 1 );
+       p = ( *p == '.' ) ? ( p - sizeof_string( ".0.8.e.f.ip6.arpa" ) ) : ( ( p - sizeof_string( ".0.8.e.f.ip6.arpa" ) ) + 1 );
+       
+       if      ( ( ( p[ 0 ] != '.' )                                                   ||
+               ( ( p[ 1 ] != '0' ) )                                                   ||
+               ( ( p[ 2 ] != '.' ) )                                                   ||
+               ( ( p[ 3 ] != '8' ) )                                                   ||
+               ( ( p[ 4 ] != '.' ) )                                                   ||
+               ( ( p[ 5 ] != 'E' ) && ( p[ 5 ] != 'e' ) )              ||
+               ( ( p[ 6 ] != '.' ) )                                                   ||
+               ( ( p[ 7 ] != 'F' ) && ( p[ 7 ] != 'f' ) )              ||
+               ( ( p[ 8 ] != '.' ) )                                                   ||
+               ( ( p[ 9 ] != 'I' ) && ( p[ 9 ] != 'i' ) )              ||
+               ( ( p[ 10 ] != 'P' ) && ( p[ 10 ] != 'p' ) )    ||      
+               ( ( p[ 11 ] != '6' ) )                                                  ||
+               ( ( p[ 12 ] != '.' ) )                                                  ||
+               ( ( p[ 13 ] != 'A' ) && ( p[ 13 ] != 'a' ) )    ||
+               ( ( p[ 14 ] != 'R' ) && ( p[ 14 ] != 'r' ) )    ||
+               ( ( p[ 15 ] != 'P' ) && ( p[ 15 ] != 'p' ) )    ||
+               ( ( p[ 16 ] != 'A' ) && ( p[ 16 ] != 'a' ) ) ) )
+       {
+               require_action_quiet( size > sizeof_string( ".254.169.in-addr.arpa" ), exit, err = WSASERVICE_NOT_FOUND );
+               p = name + ( size - 1 );
+               p = ( *p == '.' ) ? ( p - sizeof_string( ".254.169.in-addr.arpa" ) ) : ( ( p - sizeof_string( ".254.169.in-addr.arpa" ) ) + 1 );
+       
+               require_action_quiet( ( ( p[ 0 ] == '.' )                                                &&
+                                                               ( ( p[ 1 ] == '2' ) )                                                   &&
+                                                               ( ( p[ 2 ] == '5' ) )                                                   &&
+                                                               ( ( p[ 3 ] == '4' ) )                                                   &&
+                                                               ( ( p[ 4 ] == '.' ) )                                                   &&
+                                                               ( ( p[ 5 ] == '1' ) )                                                   &&
+                                                               ( ( p[ 6 ] == '6' ) )                                                   &&
+                                                               ( ( p[ 7 ] == '9' ) )                                                   &&
+                                                               ( ( p[ 8 ] == '.' ) )                                                   &&
+                                                               ( ( p[ 9 ] == 'I' ) || ( p[ 9 ] == 'i' ) )              &&
+                                                               ( ( p[ 10 ] == 'N' ) || ( p[ 10 ] == 'n' ) )    &&      
+                                                               ( ( p[ 11 ] == '-' ) )                                                  &&
+                                                               ( ( p[ 12 ] == 'A' ) || ( p[ 12 ] == 'a' ) )    &&
+                                                               ( ( p[ 13 ] == 'D' ) || ( p[ 13 ] == 'd' ) )    &&
+                                                               ( ( p[ 14 ] == 'D' ) || ( p[ 14 ] == 'd' ) )    &&
+                                                               ( ( p[ 15 ] == 'R' ) || ( p[ 15 ] == 'r' ) )    &&
+                                                               ( ( p[ 16 ] == '.' ) )                                                  &&
+                                                               ( ( p[ 17 ] == 'A' ) || ( p[ 17 ] == 'a' ) )    &&
+                                                               ( ( p[ 18 ] == 'R' ) || ( p[ 18 ] == 'r' ) )    &&
+                                                               ( ( p[ 19 ] == 'P' ) || ( p[ 19 ] == 'p' ) )    &&
+                                                               ( ( p[ 20 ] == 'A' ) || ( p[ 20 ] == 'a' ) ) ),
+                                                               exit, err = WSASERVICE_NOT_FOUND );
+       }
+
+       // It's a reverse lookup
+
+       check( err == kNoErr );
+
+exit:
+
+       return err;
+}
+#endif