diff options
Diffstat (limited to '')
-rw-r--r-- | lib/irs/win32/DLLMain.c | 49 | ||||
-rw-r--r-- | lib/irs/win32/Makefile.in | 19 | ||||
l--------- | lib/irs/win32/include/.clang-format | 1 | ||||
-rw-r--r-- | lib/irs/win32/include/Makefile.in | 19 | ||||
-rw-r--r-- | lib/irs/win32/include/irs/Makefile.in | 28 | ||||
-rw-r--r-- | lib/irs/win32/include/irs/netdb.h | 207 | ||||
-rw-r--r-- | lib/irs/win32/include/irs/platform.h | 34 | ||||
-rw-r--r-- | lib/irs/win32/libirs.def | 27 | ||||
-rw-r--r-- | lib/irs/win32/libirs.vcxproj.filters.in | 69 | ||||
-rw-r--r-- | lib/irs/win32/libirs.vcxproj.in | 142 | ||||
-rw-r--r-- | lib/irs/win32/libirs.vcxproj.user | 3 | ||||
-rw-r--r-- | lib/irs/win32/resconf.c | 130 | ||||
-rw-r--r-- | lib/irs/win32/version.c | 18 |
13 files changed, 746 insertions, 0 deletions
diff --git a/lib/irs/win32/DLLMain.c b/lib/irs/win32/DLLMain.c new file mode 100644 index 0000000..62c6e53 --- /dev/null +++ b/lib/irs/win32/DLLMain.c @@ -0,0 +1,49 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#include <signal.h> +#include <windows.h> + +/* + * Called when we enter the DLL + */ +__declspec(dllexport) BOOL WINAPI + DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { + switch (fdwReason) { + /* + * The DLL is loading due to process + * initialization or a call to LoadLibrary. + */ + case DLL_PROCESS_ATTACH: + break; + + /* The attached process creates a new thread. */ + case DLL_THREAD_ATTACH: + break; + + /* The thread of the attached process terminates. */ + case DLL_THREAD_DETACH: + break; + + /* + * The DLL is unloading from a process due to + * process termination or a call to FreeLibrary. + */ + case DLL_PROCESS_DETACH: + break; + + default: + break; + } + return (TRUE); +} diff --git a/lib/irs/win32/Makefile.in b/lib/irs/win32/Makefile.in new file mode 100644 index 0000000..5641e1a --- /dev/null +++ b/lib/irs/win32/Makefile.in @@ -0,0 +1,19 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +SUBDIRS = include +TARGETS = + +@BIND9_MAKE_RULES@ diff --git a/lib/irs/win32/include/.clang-format b/lib/irs/win32/include/.clang-format new file mode 120000 index 0000000..e919bba --- /dev/null +++ b/lib/irs/win32/include/.clang-format @@ -0,0 +1 @@ +../../../../.clang-format.headers
\ No newline at end of file diff --git a/lib/irs/win32/include/Makefile.in b/lib/irs/win32/include/Makefile.in new file mode 100644 index 0000000..53a5348 --- /dev/null +++ b/lib/irs/win32/include/Makefile.in @@ -0,0 +1,19 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +SUBDIRS = irs +TARGETS = + +@BIND9_MAKE_RULES@ diff --git a/lib/irs/win32/include/irs/Makefile.in b/lib/irs/win32/include/irs/Makefile.in new file mode 100644 index 0000000..6d87432 --- /dev/null +++ b/lib/irs/win32/include/irs/Makefile.in @@ -0,0 +1,28 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +HEADERS = +SUBDIRS = +TARGETS = + +@BIND9_MAKE_RULES@ + +installdirs: + $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/irs + +install:: installdirs + for i in ${HEADERS}; do \ + ${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}/irs || exit 1; \ + done diff --git a/lib/irs/win32/include/irs/netdb.h b/lib/irs/win32/include/irs/netdb.h new file mode 100644 index 0000000..3e3e5d3 --- /dev/null +++ b/lib/irs/win32/include/irs/netdb.h @@ -0,0 +1,207 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +/*! \file */ + +#ifndef IRS_NETDB_H +#define IRS_NETDB_H 1 + +#include <stddef.h> /* Required on FreeBSD (and others?) for size_t. */ + +/* + * Define if <netdb.h> does not declare struct addrinfo. + */ +#undef ISC_IRS_NEEDADDRINFO + +#ifdef ISC_IRS_NEEDADDRINFO +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and + * IPv6 */ + size_t ai_addrlen; /* Length of ai_addr */ + char *ai_canonname; /* Canonical name for hostname */ + struct sockaddr *ai_addr; /* Binary address */ + struct addrinfo *ai_next; /* Next structure in linked list */ +}; +#endif /* ifdef ISC_IRS_NEEDADDRINFO */ + +/* + * Undefine all #defines we are interested in as <netdb.h> may or may not have + * defined them. + */ + +/* + * Error return codes from gethostbyname() and gethostbyaddr() + * (left in extern int h_errno). + */ + +#undef NETDB_INTERNAL +#undef NETDB_SUCCESS +#undef HOST_NOT_FOUND +#undef TRY_AGAIN +#undef NO_RECOVERY +#undef NO_DATA +#undef NO_ADDRESS + +#define NETDB_INTERNAL -1 /* see errno */ +#define NETDB_SUCCESS 0 /* no problem */ +#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ +#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */ +#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ +#define NO_DATA 4 /* Valid name, no data record of requested type */ +#define NO_ADDRESS NO_DATA /* no address, look for MX record */ + +/* + * Error return codes from getaddrinfo(). EAI_INSECUREDATA is our own extension + * and it's very unlikely to be already defined, but undef it just in case; it + * at least doesn't do any harm. + */ + +#undef EAI_ADDRFAMILY +#undef EAI_AGAIN +#undef EAI_BADFLAGS +#undef EAI_FAIL +#undef EAI_FAMILY +#undef EAI_MEMORY +#undef EAI_NODATA +#undef EAI_NONAME +#undef EAI_SERVICE +#undef EAI_SOCKTYPE +#undef EAI_SYSTEM +#undef EAI_BADHINTS +#undef EAI_PROTOCOL +#undef EAI_OVERFLOW +#undef EAI_INSECUREDATA +#undef EAI_MAX + +#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ +#define EAI_AGAIN 2 /* temporary failure in name resolution */ +#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ +#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ +#define EAI_FAMILY 5 /* ai_family not supported */ +#define EAI_MEMORY 6 /* memory allocation failure */ +#define EAI_NODATA 7 /* no address associated with hostname */ +#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ +#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ +#define EAI_SYSTEM 11 /* system error returned in errno */ +#define EAI_BADHINTS 12 +#define EAI_PROTOCOL 13 +#define EAI_OVERFLOW 14 +#define EAI_INSECUREDATA 15 +#define EAI_MAX 16 + +/* + * Flag values for getaddrinfo() + */ +#undef AI_PASSIVE +#undef AI_CANONNAME +#undef AI_NUMERICHOST + +#define AI_PASSIVE 0x00000001 +#define AI_CANONNAME 0x00000002 +#define AI_NUMERICHOST 0x00000004 + +/* + * Flag values for getipnodebyname() + */ +#undef AI_V4MAPPED +#undef AI_ALL +#undef AI_ADDRCONFIG +#undef AI_DEFAULT + +#define AI_V4MAPPED 0x00000008 +#define AI_ALL 0x00000010 +#define AI_ADDRCONFIG 0x00000020 +#define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG) + +/* + * Constants for getnameinfo() + */ +#undef NI_MAXHOST +#undef NI_MAXSERV + +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 + +/* + * Flag values for getnameinfo() + */ +#undef NI_NOFQDN +#undef NI_NUMERICHOST +#undef NI_NAMEREQD +#undef NI_NUMERICSERV +#undef NI_DGRAM +#undef NI_NUMERICSCOPE + +#define NI_NOFQDN 0x00000001 +#define NI_NUMERICHOST 0x00000002 +#define NI_NAMEREQD 0x00000004 +#define NI_NUMERICSERV 0x00000008 +#define NI_DGRAM 0x00000010 + +/* + * Define to map into irs_ namespace. + */ + +#define IRS_NAMESPACE + +#ifdef IRS_NAMESPACE + +/* + * Use our versions not the ones from the C library. + */ + +#ifdef getnameinfo +#undef getnameinfo +#endif /* ifdef getnameinfo */ +#define getnameinfo irs_getnameinfo + +#ifdef getaddrinfo +#undef getaddrinfo +#endif /* ifdef getaddrinfo */ +#define getaddrinfo irs_getaddrinfo + +#ifdef freeaddrinfo +#undef freeaddrinfo +#endif /* ifdef freeaddrinfo */ +#define freeaddrinfo irs_freeaddrinfo + +#ifdef gai_strerror +#undef gai_strerror +#endif /* ifdef gai_strerror */ +#define gai_strerror irs_gai_strerror + +#endif /* ifdef IRS_NAMESPACE */ + +int +getaddrinfo(const char *, const char *, const struct addrinfo *, + struct addrinfo **); +int +getnameinfo(const struct sockaddr *, socklen_t, char *, DWORD, char *, DWORD, + int); +void +freeaddrinfo(struct addrinfo *); +char * +gai_strerror(int); + +/* + * Tell Emacs to use C mode on this file. + * Local variables: + * mode: c + * End: + */ + +#endif /* IRS_NETDB_H */ diff --git a/lib/irs/win32/include/irs/platform.h b/lib/irs/win32/include/irs/platform.h new file mode 100644 index 0000000..2f0cced --- /dev/null +++ b/lib/irs/win32/include/irs/platform.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +/*! \file */ + +#ifndef IRS_PLATFORM_H +#define IRS_PLATFORM_H 1 + +/***** +***** Platform-dependent defines. +*****/ + +#ifdef LIBIRS_EXPORTS +#define LIBIRS_EXTERNAL_DATA __declspec(dllexport) +#else /* ifdef LIBIRS_EXPORTS */ +#define LIBIRS_EXTERNAL_DATA __declspec(dllimport) +#endif /* ifdef LIBIRS_EXPORTS */ + +/* + * Tell Emacs to use C mode on this file. + * Local Variables: + * mode: c + * End: + */ + +#endif /* IRS_PLATFORM_H */ diff --git a/lib/irs/win32/libirs.def b/lib/irs/win32/libirs.def new file mode 100644 index 0000000..d4e9f6f --- /dev/null +++ b/lib/irs/win32/libirs.def @@ -0,0 +1,27 @@ +LIBRARY libirs + +; Exported Functions +EXPORTS +irs_context_create +irs_context_destroy +irs_context_get +irs_context_getappctx +irs_context_getdnsclient +irs_context_getdnsconf +irs_context_getmctx +irs_context_getresconf +irs_context_gettask +irs_context_gettaskmgr +irs_context_gettimermgr +irs_dnsconf_destroy +irs_dnsconf_gettrustedkeys +irs_dnsconf_load +irs_freeaddrinfo +irs_gai_strerror +irs_getaddrinfo +irs_getnameinfo +irs_resconf_destroy +irs_resconf_getnameservers +irs_resconf_getndots +irs_resconf_getsearchlist +irs_resconf_load diff --git a/lib/irs/win32/libirs.vcxproj.filters.in b/lib/irs/win32/libirs.vcxproj.filters.in new file mode 100644 index 0000000..0ffbc07 --- /dev/null +++ b/lib/irs/win32/libirs.vcxproj.filters.in @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <None Include="libirs.def" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="DLLMain.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="version.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\context.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\dnsconf.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\gai_strerror.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\getaddrinfo.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\getnameinfo.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="resconf.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\include\irs\context.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\include\irs\dnsconf.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\include\irs\netdb.h.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\include\irs\platform.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\include\irs\resconf.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\include\irs\types.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\include\irs\version.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> +</Project> diff --git a/lib/irs/win32/libirs.vcxproj.in b/lib/irs/win32/libirs.vcxproj.in new file mode 100644 index 0000000..078ec92 --- /dev/null +++ b/lib/irs/win32/libirs.vcxproj.in @@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="@TOOLS_VERSION@" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|@PLATFORM@"> + <Configuration>Debug</Configuration> + <Platform>@PLATFORM@</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|@PLATFORM@"> + <Configuration>Release</Configuration> + <Platform>@PLATFORM@</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{A4F29CEB-7644-4A7F-BE9E-02B6A90E4919}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>libirs</RootNamespace> + @WINDOWS_TARGET_PLATFORM_VERSION@ + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>MultiByte</CharacterSet> + @PLATFORM_TOOLSET@ + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + @PLATFORM_TOOLSET@ + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>..\..\..\Build\$(Configuration)\</OutDir> + <IntDir>.\$(Configuration)\</IntDir> + <IntDirSharingDetected>None</IntDirSharingDetected> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>..\..\..\Build\$(Configuration)\</OutDir> + <IntDir>.\$(Configuration)\</IntDir> + <IntDirSharingDetected>None</IntDirSharingDetected> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|@PLATFORM@'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <TreatWarningAsError>false</TreatWarningAsError> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBIRS_EXPORTS;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles> + <AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\isccfg\include;..\..\dns\include;@LIBXML2_INC@@OPENSSL_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <FunctionLevelLinking>true</FunctionLevelLinking> + <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation> + <ObjectFileName>.\$(Configuration)\</ObjectFileName> + <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName> + <BrowseInformation>true</BrowseInformation> + <CompileAs>CompileAsC</CompileAs> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies> + <ModuleDefinitionFile>.\libirs.def</ModuleDefinitionFile> + <ImportLibrary>.\$(Configuration)\$(ProjectName).lib</ImportLibrary> + <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|@PLATFORM@'"> + <ClCompile> + <WarningLevel>Level1</WarningLevel> + <TreatWarningAsError>true</TreatWarningAsError> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBIRS_EXPORTS;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles> + <AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\isccfg\include;..\..\dns\include;@LIBXML2_INC@@OPENSSL_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <WholeProgramOptimization>false</WholeProgramOptimization> + <StringPooling>true</StringPooling> + <PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation> + <ObjectFileName>.\$(Configuration)\</ObjectFileName> + <ProgramDataBaseFileName>$(OutDir)$(TargetName).pdb</ProgramDataBaseFileName> + <CompileAs>CompileAsC</CompileAs> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>false</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\dns\win32\$(Configuration);..\..\isccfg\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <AdditionalDependencies>@OPENSSL_LIBCRYPTO@@OPENSSL_LIBSSL@libisc.lib;libdns.lib;libisccfg.lib;ws2_32.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies> + <ModuleDefinitionFile>.\libirs.def</ModuleDefinitionFile> + <ImportLibrary>.\$(Configuration)\$(ProjectName).lib</ImportLibrary> + <LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration> + <OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <None Include="libirs.def" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\context.c" /> + <ClCompile Include="..\dnsconf.c" /> + <ClCompile Include="..\gai_strerror.c" /> + <ClCompile Include="..\getaddrinfo.c" /> + <ClCompile Include="..\getnameinfo.c" /> + <ClCompile Include="DLLMain.c" /> + <ClCompile Include="resconf.c" /> + <ClCompile Include="version.c" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\include\irs\context.h" /> + <ClInclude Include="..\include\irs\dnsconf.h" /> + <ClInclude Include="..\include\irs\netdb.h" /> + <ClInclude Include="..\include\irs\platform.h" /> + <ClInclude Include="..\include\irs\resconf.h" /> + <ClInclude Include="..\include\irs\types.h" /> + <ClInclude Include="..\include\irs\version.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> diff --git a/lib/irs/win32/libirs.vcxproj.user b/lib/irs/win32/libirs.vcxproj.user new file mode 100644 index 0000000..ace9a86 --- /dev/null +++ b/lib/irs/win32/libirs.vcxproj.user @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +</Project>
\ No newline at end of file diff --git a/lib/irs/win32/resconf.c b/lib/irs/win32/resconf.c new file mode 100644 index 0000000..3b46b8e --- /dev/null +++ b/lib/irs/win32/resconf.c @@ -0,0 +1,130 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +/* + * Note that on Win32 there is normally no resolv.conf since all information + * is stored in the registry. Therefore there is no ordering like the + * contents of resolv.conf. Since the "search" or "domain" keyword, on + * Win32 if a search list is found it is used, otherwise the domain name + * is used since they are mutually exclusive. The search list can be entered + * in the DNS tab of the "Advanced TCP/IP settings" window under the same place + * that you add your nameserver list. + */ + +#define HAVE_GET_WIN32_NAMESERVERS 1 + +#include "../resconf.c" +#include <iphlpapi.h> + +#define TCPIP_SUBKEY "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters" + +isc_result_t +get_win32_searchlist(irs_resconf_t *conf) { + isc_result_t result = ISC_R_SUCCESS; + HKEY hKey; + char searchlist[MAX_PATH]; + DWORD searchlen = MAX_PATH; + LSTATUS status; + char *cp; + + REQUIRE(conf != NULL); + + memset(searchlist, 0, MAX_PATH); + status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TCPIP_SUBKEY, 0, KEY_READ, + &hKey); + if (status != ERROR_SUCCESS) { + return (ISC_R_SUCCESS); + } + + status = RegQueryValueEx(hKey, "SearchList", NULL, NULL, + (LPBYTE)searchlist, &searchlen); + RegCloseKey(hKey); + if (status != ERROR_SUCCESS) { + return (ISC_R_SUCCESS); + } + + cp = strtok((char *)searchlist, ", \0"); + while (cp != NULL) { + result = add_search(conf, cp); + if (result != ISC_R_SUCCESS) { + break; + } + cp = strtok(NULL, ", \0"); + } + return (result); +} + +isc_result_t +get_win32_nameservers(irs_resconf_t *conf) { + isc_result_t result; + FIXED_INFO *FixedInfo; + ULONG BufLen = sizeof(FIXED_INFO); + DWORD dwRetVal; + IP_ADDR_STRING *pIPAddr; + + REQUIRE(conf != NULL); + + FixedInfo = (FIXED_INFO *)GlobalAlloc(GPTR, BufLen); + if (FixedInfo == NULL) { + return (ISC_R_NOMEMORY); + } + dwRetVal = GetNetworkParams(FixedInfo, &BufLen); + if (dwRetVal == ERROR_BUFFER_OVERFLOW) { + GlobalFree(FixedInfo); + FixedInfo = GlobalAlloc(GPTR, BufLen); + if (FixedInfo == NULL) { + return (ISC_R_NOMEMORY); + } + dwRetVal = GetNetworkParams(FixedInfo, &BufLen); + } + if (dwRetVal != ERROR_SUCCESS) { + GlobalFree(FixedInfo); + return (ISC_R_FAILURE); + } + + result = get_win32_searchlist(conf); + if (result != ISC_R_SUCCESS) { + goto cleanup; + } + + if (ISC_LIST_EMPTY(conf->searchlist) && + strlen(FixedInfo->DomainName) > 0) + { + result = add_search(conf, FixedInfo->DomainName); + if (result != ISC_R_SUCCESS) { + goto cleanup; + } + } + + /* Get the list of nameservers */ + pIPAddr = &FixedInfo->DnsServerList; + while (pIPAddr) { + if (conf->numns >= RESCONFMAXNAMESERVERS) { + break; + } + + result = add_server(conf->mctx, pIPAddr->IpAddress.String, + &conf->nameservers); + if (result != ISC_R_SUCCESS) { + break; + } + conf->numns++; + pIPAddr = pIPAddr->Next; + } + +cleanup: + if (FixedInfo != NULL) { + GlobalFree(FixedInfo); + } + return (result); +} diff --git a/lib/irs/win32/version.c b/lib/irs/win32/version.c new file mode 100644 index 0000000..3c635ad --- /dev/null +++ b/lib/irs/win32/version.c @@ -0,0 +1,18 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#include <versions.h> + +#include <irs/version.h> + +LIBIRS_EXTERNAL_DATA const char irs_version[] = VERSION; |