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
#define kTXTRecordKeyPath "path"
+// IE Icon resource
+
+#define kIEIconResource 32529
+
#if 0
#pragma mark == Prototypes ==
{
AFX_MANAGE_STATE( AfxGetStaticModuleState() );
+ HINSTANCE module = NULL;
OSStatus err;
CRect rect;
CBitmap bitmap;
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 );
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 )
{
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
<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
<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
</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
CommandLine="if not exist Release\Root mkdir Release\Root\r
if not exist "Release\Root\Program Files" mkdir "Release\Root\Program Files"\r
if not exist "Release\Root\Program Files\Bonjour" mkdir "Release\Root\Program Files\Bonjour"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources" mkdir "Release\Root\Program Files\Bonjour\Resources"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources" mkdir "Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources\en.lproj" mkdir "Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources\en.lproj""/>\r
+if not exist "Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources" mkdir "Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources"\r
+if not exist "Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources\en.lproj" mkdir "Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources\en.lproj""/>\r
<Tool\r
Name="VCResourceCompilerTool"\r
PreprocessorDefinitions="NDEBUG"\r
\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
<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
<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
</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
CommandLine="if not exist Release\Root mkdir Release\Root\r
if not exist "Release\Root\Program Files" mkdir "Release\Root\Program Files"\r
if not exist "Release\Root\Program Files\Bonjour" mkdir "Release\Root\Program Files\Bonjour"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources" mkdir "Release\Root\Program Files\Bonjour\Resources"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources" mkdir "Release\Root\Program Files\Bonjour\Resources\ExplorerPlugin.dll.Resources""/>\r
+if not exist "Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources" mkdir "Release\Root\Program Files\Bonjour\ExplorerPlugin.Resources""/>\r
<Tool\r
Name="VCResourceCompilerTool"\r
PreprocessorDefinitions="NDEBUG"\r
#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
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
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);
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
// 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 );
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
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
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
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
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
\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
<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
<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
</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
CommandLine="if not exist Release\Root mkdir Release\Root\r
if not exist "Release\Root\Program Files" mkdir "Release\Root\Program Files"\r
if not exist "Release\Root\Program Files\Bonjour" mkdir "Release\Root\Program Files\Bonjour"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources" mkdir "Release\Root\Program Files\Bonjour\Resources"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources" mkdir "Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources\en.lproj" mkdir "Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources\en.lproj""/>\r
+if not exist "Release\Root\Program Files\Bonjour\PrinterWizard.Resources" mkdir "Release\Root\Program Files\Bonjour\PrinterWizard.Resources"\r
+if not exist "Release\Root\Program Files\Bonjour\PrinterWizard.Resources\en.lproj" mkdir "Release\Root\Program Files\Bonjour\PrinterWizard.Resources\en.lproj""/>\r
<Tool\r
Name="VCResourceCompilerTool"\r
PreprocessorDefinitions="NDEBUG"\r
<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
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
<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
</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
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
CommandLine="if not exist Release\Root mkdir Release\Root\r
if not exist "Release\Root\Program Files" mkdir "Release\Root\Program Files"\r
if not exist "Release\Root\Program Files\Bonjour" mkdir "Release\Root\Program Files\Bonjour"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources" mkdir "Release\Root\Program Files\Bonjour\Resources"\r
-if not exist "Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources" mkdir "Release\Root\Program Files\Bonjour\Resources\PrinterWizard.exe.Resources""/>\r
+if not exist "Release\Root\Program Files\Bonjour\PrinterWizard.Resources" mkdir "Release\Root\Program Files\Bonjour\PrinterWizard.Resources""/>\r
<Tool\r
Name="VCResourceCompilerTool"\r
PreprocessorDefinitions="NDEBUG"\r
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"
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"";
{
DEBUG_UNUSED( service );
+ Queue * q = service->SelectedQueue();
HANDLE hPrinter = NULL;
PRINTER_INFO_2 pInfo;
OSStatus err;
+
+ check( q );
//
// add the printer
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;
CPrinterSetupWizardSheet * self;
Service * service;
Queue * q;
- uint32_t qpriority = kDefaultPriority;
- CString qname;
int idx;
OSStatus err;
//
service->portNumber = ntohs(inPort);
- //
- // parse the text record.
- //
-
- err = self->ParseTextRecord( service, inTXTSize, inTXT, qname, qpriority );
- require_noerr( err, exit );
-
if ( service->qtotal == 1 )
{
//
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 );
//
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 );
//
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;
// <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 )
{
memcpy( buf, val, len );
buf[len] = '\0';
- err = UTF8StringToStringObject( buf, qname );
+ err = UTF8StringToStringObject( buf, q->name );
require_noerr( err, exit );
}
memcpy( buf, val, len );
buf[len] = '\0';
- err = UTF8StringToStringObject( buf, service->pdl );
+ err = UTF8StringToStringObject( buf, q->pdl );
require_noerr( err, exit );
}
memcpy( buf, val, len );
buf[len] = '\0';
- err = UTF8StringToStringObject( buf, service->usb_MFG );
+ err = UTF8StringToStringObject( buf, q->usb_MFG );
require_noerr( err, exit );
}
memcpy( buf, val, len );
buf[len] = '\0';
- err = UTF8StringToStringObject( buf, service->usb_MDL );
+ err = UTF8StringToStringObject( buf, q->usb_MDL );
require_noerr( err, exit );
}
memcpy( buf, val, len );
buf[len] = '\0';
- err = UTF8StringToStringObject( buf, service->description );
+ err = UTF8StringToStringObject( buf, q->description );
require_noerr( err, exit );
}
memcpy( buf, val, len );
buf[len] = '\0';
- err = UTF8StringToStringObject( buf, service->product );
+ err = UTF8StringToStringObject( buf, q->product );
require_noerr( err, exit );
}
memcpy( buf, val, len );
buf[len] = '\0';
- err = UTF8StringToStringObject( buf, service->location );
+ err = UTF8StringToStringObject( buf, q->location );
require_noerr( err, exit );
}
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;
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()
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();
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
// 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:
Printer * printer;
Printers::iterator it;
OSStatus err = kNoErr;
+ BOOL b;
+
+ b = CPropertyPage::OnSetActive();
psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
require_action( psheet, exit, err = kUnknownErr );
exit:
- return CPropertyPage::OnSetActive();
+ return b;
}
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()
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
{
CPrinterSetupWizardSheet * psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent());
require_quiet( psheet, exit );
-
+
check( service );
+ Queue * q = service->SelectedQueue();
+
+ check( q );
+
+
//
// and set it to selected
//
//
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
{
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 );
}
+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 )
{
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.
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(
CStatic m_descriptionField;\r
CStatic m_locationLabel;\r
CStatic m_locationField;\r
+
+ bool m_gotChoice;
};
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
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 ) );
}
//
//
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 )
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 )
// 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);
nIndex = m_manufacturerListCtrl.InsertItem(0, manufacturer->name);
m_manufacturerListCtrl.SetItemData(nIndex, (DWORD_PTR) manufacturer);
+
+ m_manufacturerListCtrl.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER );
}
return 0;
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);
printer = psheet->GetSelectedPrinter();
require_quiet( printer, exit );
- printer->deflt = m_defaultPrinterCtrl.GetState() ? true : false;
+ printer->deflt = ( m_defaultPrinterCtrl.GetCheck() == BST_CHECKED ) ? true : false;
exit:
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
~Service();
+ Queue*
+ SelectedQueue();
+
void
EmptyQueues();
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;
CString name;
uint32_t priority;
+ CString pdl;
+ CString usb_MFG;
+ CString usb_MDL;
+ CString description;
+ CString location;
+ CString product;
};
EmptyQueues();
}
+ inline Queue*
+ Service::SelectedQueue()
+ {
+ return queues.front();
+ }
+
inline void
Service::EmptyQueues()
{
{
Model * model = *it;
- if ( model->name = name )
+ if ( model->name == name )
{
return model;
}
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;
}
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)
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;
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)
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
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]] = '-'; }
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)
{
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);
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);
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)
{
nread += sizeof(mDNSs32);
}
else { LogMsg("ERROR: getOptRdata - unknown opt %d", opt->opt); return mDNSNULL; }
+ opt++; // increment pointer into rdatabody
}
rr->rdlength = pktRDLen;
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;
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
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);
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
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;
}
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
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
{
#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
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
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;
// 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; }
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;
}
AuthRecord *srv = &srs->RR_SRV;
mDNSu32 i;
+ privport = zeroIPPort;
+
if (!rInfo->ns.ip.v4.NotAnInteger) { LogMsg("SendServiceRegistration - NS not set!"); return; }
id = newMessageID(u);
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);
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
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
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
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/"
};
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
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;
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;
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);
}
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; }
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
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;
+ }
}
}
}
{
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;
{
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);
}
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);
}
}
<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 = {
# 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
#
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
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
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 \
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
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;
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);
{
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;
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;
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;
}
}
// 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++)
}
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; }
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;
{
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; }
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
#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;
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;
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);
#ifdef NOT_HAVE_DAEMON
#include <fcntl.h>
#include <sys/stat.h>
+#include <signal.h>
+
int daemon(int nochdir, int noclose)
{
switch (fork())
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
#include <net/if.h>
#include <netinet/in.h>
+#ifdef HAVE_LINUX
+#include <linux/socket.h>
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
#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 ? \
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): */
{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
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
#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
#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
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)"
char assert0[(sizeof(TXTRecordRefRealType) <= 16) ? 1 : -1];
};
-void TXTRecordCreate
+void DNSSD_API TXTRecordCreate
(
TXTRecordRef *txtRecord,
uint16_t bufferLen,
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,
return(kDNSServiceErr_NoError);
}
-DNSServiceErrorType TXTRecordRemoveValue
+DNSServiceErrorType DNSSD_API TXTRecordRemoveValue
(
TXTRecordRef *txtRecord,
const char *key
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); }
/*********************************************************************************************
*
*
*********************************************************************************************/
-int TXTRecordContainsKey
+int DNSSD_API TXTRecordContainsKey
(
uint16_t txtLen,
const void *txtRecord,
return (InternalTXTRecordSearch(txtLen, txtRecord, key, &keylen) ? 1 : 0);
}
-const void * TXTRecordGetValuePtr
+const void * DNSSD_API TXTRecordGetValuePtr
(
uint16_t txtLen,
const void *txtRecord,
return (item + 1 + keylen + 1);
}
-uint16_t TXTRecordGetCount
+uint16_t DNSSD_API TXTRecordGetCount
(
uint16_t txtLen,
const void *txtRecord
return((p>e) ? (uint16_t)0 : count);
}
-DNSServiceErrorType TXTRecordGetItemAtIndex
+DNSServiceErrorType DNSSD_API TXTRecordGetItemAtIndex
(
uint16_t txtLen,
const void *txtRecord,
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
char *msg = NULL;
ipc_msg_hdr *hdr;
int datalen;
+#if !defined(USE_TCP_LOOPBACK)
char ctrl_path[256];
+#endif
if (!reuse_socket)
{
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;
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
# 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
# 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
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,
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;
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);
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);
{
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");
}
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))
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;
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))
{
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)
END\r
END\r
\r
-\r
#ifdef APSTUDIO_INVOKED\r
/////////////////////////////////////////////////////////////////////////////\r
//\r
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
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
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
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
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
:
CPropertyPage(CFirstPage::IDD),
m_ignoreHostnameChange( false ),
- m_statusKey( NULL )
+ m_statusKey( NULL ),
+ m_setupKey( NULL )
{
//{{AFX_DATA_INIT(CFirstPage)
//}}AFX_DATA_INIT
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;
}
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
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 );
}
CSecondPage::~CSecondPage()
{
+ if ( m_setupKey )
+ {
+ RegCloseKey( m_setupKey );
+ m_setupKey = NULL;
+ }
}
CSecondPage::OnSetActive()
{
CConfigPropertySheet * psheet;
- HKEY key = NULL;
DWORD dwSize;
DWORD enabled;
DWORD err;
// 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;
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 );
}
}
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;
}
string = (TCHAR*) malloc( stringLen );
require_action( string, exit, err = kUnknownErr );
+ *string = '\0';
err = RegQueryValueEx( key, valueName, 0, NULL, (LPBYTE) string, &stringLen );
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
CButton m_advertiseServicesButton;
CButton m_sharedSecretButton;
BOOL m_modified;
+ HKEY m_setupKey;
public:
afx_msg void OnCbnSelChange();
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
\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
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
//---------------------------------------------------------------------------------------------------------------------------\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
\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
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
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
DECLARE_MESSAGE_MAP()\r
\r
public:\r
+\r
+ CString m_key;\r
CString m_secret;\r
- CString m_secretName;\r
};\r
#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
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
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
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
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)
// 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 );
//
if (gServiceManageLLRouting == true)
{
- SetLLRoute();
+ SetLLRoute( &gMDNSRecord );
}
exit:
static void
CoreCallback(mDNS * const inMDNS, mStatus status)
{
- DEBUG_UNUSED( inMDNS );
-
if (status == mStatus_ConfigChanged)
{
if (gServiceManageLLRouting == true)
{
- SetLLRoute();
+ SetLLRoute( inMDNS );
}
}
}
//===========================================================================================================================
-// HaveLLRoute
+// HaveRoute
//===========================================================================================================================
static bool
-HaveLLRoute(PMIB_IPFORWARDROW rowExtant)
+HaveRoute( PMIB_IPFORWARDROW rowExtant, unsigned long addr )
{
PMIB_IPFORWARDTABLE pIpForwardTable = NULL;
DWORD dwSize = 0;
//
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;
}
+//===========================================================================================================================
+// 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;
//
// 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.
}
//
- // 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;
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 );
IP_ADAPTER_INFO * pAdapterInfo = NULL;
IP_ADAPTER_INFO * pAdapter = NULL;
ULONG bufLen;
+ mDNSBool done = mDNSfalse;
OSStatus err;
//
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:
return( err );
}
-
+++ /dev/null
-/*
- * 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__
+++ /dev/null
-/*
- * 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
- }
+++ /dev/null
-<?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>
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
#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."
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>
{
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;
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);
}
}
{
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);
}
{
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
{
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)
#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;
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]);
if ( !strcmp( appPathNameA, "" ) )
{
char folder[MAX_PATH];
+ char * ext;
char * app;
GetModuleFileNameA( module, folder, MAX_PATH );
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);
{
wchar_t folder[MAX_PATH];
wchar_t * app;
+ wchar_t * ext;
GetModuleFileNameW( module, folder, MAX_PATH);
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);
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
static GUID kWSARecvMsgGUID = WSAID_WSARECVMSG;
#endif
+#define kIPv6IfIndexBase (10000000L)
+
#if 0
#pragma mark == Prototypes ==
// 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
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
{
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:
mDNSexport mDNSs32 mDNSPlatformUTC( void )
{
- return( -1 );
+ return ( mDNSs32 ) time( NULL );
}
//===========================================================================================================================
//===========================================================================================================================
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
// 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 )
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;
exit:
+ if ( pAdapterInfo )
+ {
+ free( pAdapterInfo );
+ }
+
if ( fixedInfo )
{
GlobalFree( fixedInfo );
DWORD bufLen = sizeof( IP_ADAPTER_INFO );
int i;
BOOL found;
+ DWORD index;
mStatus err = mStatus_NoError;
DEBUG_UNUSED( m );
}
}
- // 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 )
{
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
}
}
- 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 )
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.
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 )
}
if( p->ifa_flags & IFF_LOOPBACK )
{
- if( !loopback )
+ if( !loopbackv4 )
{
- loopback = p;
+ loopbackv4 = p;
}
continue;
}
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
*next = ifd;
next = &ifd->next;
++inMDNS->p->interfaceCount;
-
-
}
#endif
}
if( p->ifa_flags & IFF_LOOPBACK )
{
- if( !loopback )
+ if( !loopbackv6 )
{
- loopback = p;
+ loopbackv6 = p;
}
continue;
}
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
{
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 )
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';
// 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 )
{
if (!ifd->interfaceInfo.InterfaceID)
{
- p->scopeID = ifd->scopeID;
ifd->interfaceInfo.InterfaceID = (mDNSInterfaceID) p;
}
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;
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;
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.
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 ) )
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))
// 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( ;; )
{
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;
}
{
case AF_INET:
{
- struct sockaddr_in * sa4;
+ struct sockaddr_in * sa4;
require_action( prefixLength <= 32, exit, err = ERROR_INVALID_DATA );
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;
}
// 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!
}
}
+
+//===========================================================================================================================
+// 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
//===========================================================================================================================
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
//===========================================================================================================================
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 );
//===========================================================================================================================
mDNSlocal OSStatus
-ConvertUTF8ToLsaString( const char * input, PLSA_UNICODE_STRING output )
+MakeLsaStringFromUTF8String( PLSA_UNICODE_STRING output, const char * input )
{
int size;
OSStatus err;
//===========================================================================================================================
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;
}
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
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
( ( 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 );
}
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