mirror of
https://github.com/mangosfour/server.git
synced 2025-12-20 07:37:02 +00:00
Merge remote branch 'origin/master' into 335
This commit is contained in:
commit
299ac66fdb
334 changed files with 9130 additions and 22112 deletions
|
|
@ -54,4 +54,3 @@ EXTRA_DIST += \
|
||||||
win/VC100/g3dlite.vcxproj
|
win/VC100/g3dlite.vcxproj
|
||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
|
|
|
||||||
1
NEWS
1
NEWS
|
|
@ -16,6 +16,7 @@ http://mangos.lighthouseapp.com/
|
||||||
Version 0.16
|
Version 0.16
|
||||||
* Under discussion.
|
* Under discussion.
|
||||||
* OpenSSL lib upgrade to OpenSSL 1.0.0.
|
* OpenSSL lib upgrade to OpenSSL 1.0.0.
|
||||||
|
* Sockets lib use dropped.
|
||||||
* Upgrade to client version 3.3.3a (build 11723).
|
* Upgrade to client version 3.3.3a (build 11723).
|
||||||
|
|
||||||
Version 0.15
|
Version 0.15
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,6 @@ AC_CONFIG_FILES([
|
||||||
dep/lib/Makefile
|
dep/lib/Makefile
|
||||||
dep/src/Makefile
|
dep/src/Makefile
|
||||||
dep/src/g3dlite/Makefile
|
dep/src/g3dlite/Makefile
|
||||||
dep/src/sockets/Makefile
|
|
||||||
dep/src/zlib/Makefile
|
dep/src/zlib/Makefile
|
||||||
dep/src/gsoap/Makefile
|
dep/src/gsoap/Makefile
|
||||||
dep/Makefile
|
dep/Makefile
|
||||||
|
|
|
||||||
2
contrib/extractor/.gitignore
vendored
2
contrib/extractor/.gitignore
vendored
|
|
@ -14,8 +14,10 @@
|
||||||
*.ncb
|
*.ncb
|
||||||
*.pdb
|
*.pdb
|
||||||
*.suo
|
*.suo
|
||||||
|
*.sdf
|
||||||
debug
|
debug
|
||||||
release
|
release
|
||||||
|
ipch
|
||||||
*.user
|
*.user
|
||||||
*.ilk
|
*.ilk
|
||||||
ad_debug.exe
|
ad_debug.exe
|
||||||
19
contrib/extractor/VC100_AD.sln
Normal file
19
contrib/extractor/VC100_AD.sln
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ad", "VC100_ad.vcxproj", "{D7552D4F-408F-4F8E-859B-366659150CF4}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{D7552D4F-408F-4F8E-859B-366659150CF4}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{D7552D4F-408F-4F8E-859B-366659150CF4}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{D7552D4F-408F-4F8E-859B-366659150CF4}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{D7552D4F-408F-4F8E-859B-366659150CF4}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
185
contrib/extractor/VC100_ad.vcxproj
Normal file
185
contrib/extractor/VC100_ad.vcxproj
Normal file
|
|
@ -0,0 +1,185 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectName>ad</ProjectName>
|
||||||
|
<ProjectGuid>{D7552D4F-408F-4F8E-859B-366659150CF4}</ProjectGuid>
|
||||||
|
<RootNamespace>ad</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseOfMfc>false</UseOfMfc>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||||
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\</OutDir>
|
||||||
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\debug\</IntDir>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
|
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir>
|
||||||
|
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\release\</IntDir>
|
||||||
|
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||||
|
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
|
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||||
|
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||||
|
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<TargetEnvironment>Win32</TargetEnvironment>
|
||||||
|
<TypeLibraryName>./ad.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName>
|
||||||
|
</HeaderFileName>
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>libmpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderOutputFile>$(IntDir)ad.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||||
|
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||||
|
<ProgramDataBaseFileName>$(IntDir)</ProgramDataBaseFileName>
|
||||||
|
<XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
|
||||||
|
<BrowseInformation>true</BrowseInformation>
|
||||||
|
<BrowseInformationFile>$(IntDir)</BrowseInformationFile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0419</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<OutputFile>ad_debug.exe</OutputFile>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<AdditionalLibraryDirectories>./debug/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<IgnoreSpecificDefaultLibraries>LIBCD.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<ProgramDatabaseFile>./ad_debug.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention>
|
||||||
|
</DataExecutionPrevention>
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Midl>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<TargetEnvironment>Win32</TargetEnvironment>
|
||||||
|
<TypeLibraryName>./ad.tlb</TypeLibraryName>
|
||||||
|
<HeaderFileName>
|
||||||
|
</HeaderFileName>
|
||||||
|
</Midl>
|
||||||
|
<ClCompile>
|
||||||
|
<Optimization>Full</Optimization>
|
||||||
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
|
<AdditionalIncludeDirectories>libmpq;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderOutputFile>$(IntDir)ad.pch</PrecompiledHeaderOutputFile>
|
||||||
|
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||||
|
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||||
|
<ProgramDataBaseFileName>$(IntDir)</ProgramDataBaseFileName>
|
||||||
|
<XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
</ClCompile>
|
||||||
|
<ResourceCompile>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<Culture>0x0419</Culture>
|
||||||
|
</ResourceCompile>
|
||||||
|
<Link>
|
||||||
|
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<OutputFile>./ad.exe</OutputFile>
|
||||||
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
<AdditionalLibraryDirectories>./release/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<IgnoreSpecificDefaultLibraries>LIBC.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||||
|
<ProgramDatabaseFile>./ad.pdb</ProgramDatabaseFile>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||||
|
<DataExecutionPrevention>
|
||||||
|
</DataExecutionPrevention>
|
||||||
|
<TargetMachine>MachineX86</TargetMachine>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="loadlib\adt.cpp" />
|
||||||
|
<ClCompile Include="libmpq\common.cpp" />
|
||||||
|
<ClCompile Include="dbcfile.cpp" />
|
||||||
|
<ClCompile Include="libmpq\explode.cpp" />
|
||||||
|
<ClCompile Include="libmpq\extract.cpp" />
|
||||||
|
<ClCompile Include="libmpq\huffman.cpp" />
|
||||||
|
<ClCompile Include="loadlib\loadlib.cpp" />
|
||||||
|
<ClCompile Include="libmpq\mpq.cpp" />
|
||||||
|
<ClCompile Include="mpq_libmpq.cpp" />
|
||||||
|
<ClCompile Include="libmpq\parser.cpp" />
|
||||||
|
<ClCompile Include="system.cpp">
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||||
|
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||||
|
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Full</Optimization>
|
||||||
|
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="libmpq\wave.cpp" />
|
||||||
|
<ClCompile Include="loadlib\wdt.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="loadlib\adt.h" />
|
||||||
|
<ClInclude Include="libmpq\common.h" />
|
||||||
|
<ClInclude Include="dbcfile.h" />
|
||||||
|
<ClInclude Include="libmpq\explode.h" />
|
||||||
|
<ClInclude Include="libmpq\huffman.h" />
|
||||||
|
<ClInclude Include="loadlib\loadlib.h" />
|
||||||
|
<ClInclude Include="libmpq\mpq.h" />
|
||||||
|
<ClInclude Include="mpq_libmpq.h" />
|
||||||
|
<ClInclude Include="libmpq\wave.h" />
|
||||||
|
<ClInclude Include="loadlib\wdt.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
86
contrib/extractor/VC100_ad.vcxproj.filters
Normal file
86
contrib/extractor/VC100_ad.vcxproj.filters
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?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>{7748a821-40c1-4432-a07e-ff4da1273091}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{bd48cc48-7a79-4088-9e3f-8bf123692891}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hpp;hxx;hm;inl</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="loadlib\adt.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="libmpq\common.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dbcfile.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="libmpq\explode.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="libmpq\extract.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="libmpq\huffman.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="loadlib\loadlib.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="libmpq\mpq.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="mpq_libmpq.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="libmpq\parser.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="system.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="libmpq\wave.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="loadlib\wdt.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="loadlib\adt.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="libmpq\common.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="dbcfile.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="libmpq\explode.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="libmpq\huffman.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="loadlib\loadlib.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="libmpq\mpq.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="mpq_libmpq.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="libmpq\wave.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="loadlib\wdt.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
@ -160,34 +160,6 @@ EXTRA_DIST += \
|
||||||
postgre/pg_type.h \
|
postgre/pg_type.h \
|
||||||
postgre/postgres_ext.h
|
postgre/postgres_ext.h
|
||||||
|
|
||||||
# Sockets header files for Win32 builds
|
|
||||||
EXTRA_DIST += \
|
|
||||||
sockets\Base64.h \
|
|
||||||
sockets\CircularBuffer.h \
|
|
||||||
sockets\IFile.h \
|
|
||||||
sockets\Ipv4Address.h \
|
|
||||||
sockets\Ipv6Address.h \
|
|
||||||
sockets\ISocketHandler.h \
|
|
||||||
sockets\ListenSocket.h \
|
|
||||||
sockets\Mutex.h \
|
|
||||||
sockets\Parse.h \
|
|
||||||
sockets\RandomNumber.h \
|
|
||||||
sockets\ResolvServer.h \
|
|
||||||
sockets\ResolvSocket.h \
|
|
||||||
sockets\SctpSocket.h \
|
|
||||||
sockets\Socket.h \
|
|
||||||
sockets\socket_include.h \
|
|
||||||
sockets\SocketAddress.h \
|
|
||||||
sockets\SocketHandler.h \
|
|
||||||
sockets\sockets-config.h \
|
|
||||||
sockets\StdLog.h \
|
|
||||||
sockets\StdoutLog.h \
|
|
||||||
sockets\TcpSocket.h \
|
|
||||||
sockets\Thread.h \
|
|
||||||
sockets\UdpSocket.h \
|
|
||||||
sockets\Uid.h \
|
|
||||||
sockets\Utility.h
|
|
||||||
|
|
||||||
# VLD header files for Win32 builds
|
# VLD header files for Win32 builds
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
vld/vld.h
|
vld/vld.h
|
||||||
|
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
/** \file Base64.h
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_Base64_H
|
|
||||||
#define _SOCKETS_Base64_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4514)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \defgroup util Utilities */
|
|
||||||
|
|
||||||
/** Base64 encode/decode.
|
|
||||||
\ingroup util */
|
|
||||||
class Base64
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Base64();
|
|
||||||
|
|
||||||
void encode(FILE *, std::string& , bool add_crlf = true);
|
|
||||||
void encode(const std::string&, std::string& , bool add_crlf = true);
|
|
||||||
void encode(const char *, size_t, std::string& , bool add_crlf = true);
|
|
||||||
void encode(const unsigned char *, size_t, std::string& , bool add_crlf = true);
|
|
||||||
|
|
||||||
void decode(const std::string&, std::string& );
|
|
||||||
void decode(const std::string&, unsigned char *, size_t&);
|
|
||||||
|
|
||||||
size_t decode_length(const std::string& );
|
|
||||||
|
|
||||||
private:
|
|
||||||
Base64(const Base64& ) {}
|
|
||||||
Base64& operator=(const Base64& ) { return *this; }
|
|
||||||
static const char *bstr;
|
|
||||||
static const char rstr[128];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_Base64_H
|
|
||||||
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
/**
|
|
||||||
** \file Exception.h
|
|
||||||
** \date 2007-09-28
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _Sockets_Exception_H
|
|
||||||
#define _Sockets_Exception_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Exception
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Exception(const std::string& description);
|
|
||||||
virtual ~Exception() {}
|
|
||||||
|
|
||||||
virtual const std::string ToString() const;
|
|
||||||
|
|
||||||
Exception(const Exception& ) {} // copy constructor
|
|
||||||
|
|
||||||
Exception& operator=(const Exception& ) { return *this; } // assignment operator
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_description;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _Sockets_Exception_H
|
|
||||||
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
/** \file File.h
|
|
||||||
** \date 2005-04-25
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_File_H
|
|
||||||
#define _SOCKETS_File_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include "IFile.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/** IFile implementation of a disk file.
|
|
||||||
\ingroup file */
|
|
||||||
class File : public IFile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
File();
|
|
||||||
~File();
|
|
||||||
|
|
||||||
bool fopen(const std::string&, const std::string&);
|
|
||||||
void fclose();
|
|
||||||
|
|
||||||
size_t fread(char *, size_t, size_t) const;
|
|
||||||
size_t fwrite(const char *, size_t, size_t);
|
|
||||||
|
|
||||||
char *fgets(char *, int) const;
|
|
||||||
void fprintf(const char *format, ...);
|
|
||||||
|
|
||||||
off_t size() const;
|
|
||||||
bool eof() const;
|
|
||||||
|
|
||||||
void reset_read() const;
|
|
||||||
void reset_write();
|
|
||||||
|
|
||||||
private:
|
|
||||||
File(const File& ) {} // copy constructor
|
|
||||||
File& operator=(const File& ) { return *this; } // assignment operator
|
|
||||||
|
|
||||||
std::string m_path;
|
|
||||||
std::string m_mode;
|
|
||||||
FILE *m_fil;
|
|
||||||
mutable long m_rptr;
|
|
||||||
long m_wptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_File_H
|
|
||||||
|
|
||||||
|
|
@ -1,71 +0,0 @@
|
||||||
/** \file IFile.h
|
|
||||||
** \date 2005-04-25
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_IFile_H
|
|
||||||
#define _SOCKETS_IFile_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \defgroup file File handling */
|
|
||||||
/** Pure virtual file I/O interface.
|
|
||||||
\ingroup file */
|
|
||||||
class IFile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IFile() {}
|
|
||||||
|
|
||||||
virtual bool fopen(const std::string&, const std::string&) = 0;
|
|
||||||
virtual void fclose() = 0;
|
|
||||||
|
|
||||||
virtual size_t fread(char *, size_t, size_t) const = 0;
|
|
||||||
virtual size_t fwrite(const char *, size_t, size_t) = 0;
|
|
||||||
|
|
||||||
virtual char *fgets(char *, int) const = 0;
|
|
||||||
virtual void fprintf(const char *format, ...) = 0;
|
|
||||||
|
|
||||||
virtual off_t size() const = 0;
|
|
||||||
virtual bool eof() const = 0;
|
|
||||||
|
|
||||||
virtual void reset_read() const = 0;
|
|
||||||
virtual void reset_write() = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_IFile_H
|
|
||||||
|
|
||||||
|
|
@ -1,232 +0,0 @@
|
||||||
/** \file ISocketHandler.h
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_ISocketHandler_H
|
|
||||||
#define _SOCKETS_ISocketHandler_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include "socket_include.h"
|
|
||||||
#include "Socket.h"
|
|
||||||
#include "StdLog.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
LIST_CALLONCONNECT = 0,
|
|
||||||
#ifdef ENABLE_DETACH
|
|
||||||
LIST_DETACH,
|
|
||||||
#endif
|
|
||||||
LIST_TIMEOUT,
|
|
||||||
LIST_RETRY,
|
|
||||||
LIST_CLOSE
|
|
||||||
} list_t;
|
|
||||||
|
|
||||||
class SocketAddress;
|
|
||||||
class Mutex;
|
|
||||||
|
|
||||||
|
|
||||||
/** Socket container class, event generator.
|
|
||||||
\ingroup basic */
|
|
||||||
class ISocketHandler
|
|
||||||
{
|
|
||||||
friend class Socket;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** Connection pool class for internal use by the ISocketHandler.
|
|
||||||
\ingroup internal */
|
|
||||||
#ifdef ENABLE_POOL
|
|
||||||
class PoolSocket : public Socket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PoolSocket(ISocketHandler& h,Socket *src) : Socket(h) {
|
|
||||||
CopyConnection( src );
|
|
||||||
SetIsClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnRead() {
|
|
||||||
Handler().LogError(this, "OnRead", 0, "data on hibernating socket", LOG_LEVEL_FATAL);
|
|
||||||
SetCloseAndDelete();
|
|
||||||
}
|
|
||||||
void OnOptions(int,int,int,SOCKET) {}
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ~ISocketHandler() {}
|
|
||||||
|
|
||||||
/** Get mutex reference for threadsafe operations. */
|
|
||||||
virtual Mutex& GetMutex() const = 0;
|
|
||||||
|
|
||||||
/** Register StdLog object for error callback.
|
|
||||||
\param log Pointer to log class */
|
|
||||||
virtual void RegStdLog(StdLog *log) = 0;
|
|
||||||
|
|
||||||
/** Log error to log class for print out / storage. */
|
|
||||||
virtual void LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t = LOG_LEVEL_WARNING) = 0;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Socket stuff
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
/** Add socket instance to socket map. Removal is always automatic. */
|
|
||||||
virtual void Add(Socket *) = 0;
|
|
||||||
private:
|
|
||||||
/** Remove socket from socket map, used by Socket class. */
|
|
||||||
virtual void Remove(Socket *) = 0;
|
|
||||||
public:
|
|
||||||
/** Get status of read/write/exception file descriptor set for a socket. */
|
|
||||||
virtual void Get(SOCKET s,bool& r,bool& w,bool& e) = 0;
|
|
||||||
/** Set read/write/exception file descriptor sets (fd_set). */
|
|
||||||
virtual void Set(SOCKET s,bool bRead,bool bWrite,bool bException = true) = 0;
|
|
||||||
|
|
||||||
/** Wait for events, generate callbacks. */
|
|
||||||
virtual int Select(long sec,long usec) = 0;
|
|
||||||
/** This method will not return until an event has been detected. */
|
|
||||||
virtual int Select() = 0;
|
|
||||||
/** Wait for events, generate callbacks. */
|
|
||||||
virtual int Select(struct timeval *tsel) = 0;
|
|
||||||
|
|
||||||
/** Check that a socket really is handled by this socket handler. */
|
|
||||||
virtual bool Valid(Socket *) = 0;
|
|
||||||
/** Return number of sockets handled by this handler. */
|
|
||||||
virtual size_t GetCount() = 0;
|
|
||||||
|
|
||||||
/** Override and return false to deny all incoming connections.
|
|
||||||
\param p ListenSocket class pointer (use GetPort to identify which one) */
|
|
||||||
virtual bool OkToAccept(Socket *p) = 0;
|
|
||||||
|
|
||||||
/** Called by Socket when a socket changes state. */
|
|
||||||
virtual void AddList(SOCKET s,list_t which_one,bool add) = 0;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Connection pool
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
#ifdef ENABLE_POOL
|
|
||||||
/** Find available open connection (used by connection pool). */
|
|
||||||
virtual ISocketHandler::PoolSocket *FindConnection(int type,const std::string& protocol,SocketAddress&) = 0;
|
|
||||||
/** Enable connection pool (by default disabled). */
|
|
||||||
virtual void EnablePool(bool = true) = 0;
|
|
||||||
/** Check pool status.
|
|
||||||
\return true if connection pool is enabled */
|
|
||||||
virtual bool PoolEnabled() = 0;
|
|
||||||
#endif // ENABLE_POOL
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Socks4
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
#ifdef ENABLE_SOCKS4
|
|
||||||
/** Set socks4 server ip that all new tcp sockets should use. */
|
|
||||||
virtual void SetSocks4Host(ipaddr_t) = 0;
|
|
||||||
/** Set socks4 server hostname that all new tcp sockets should use. */
|
|
||||||
virtual void SetSocks4Host(const std::string& ) = 0;
|
|
||||||
/** Set socks4 server port number that all new tcp sockets should use. */
|
|
||||||
virtual void SetSocks4Port(port_t) = 0;
|
|
||||||
/** Set optional socks4 userid. */
|
|
||||||
virtual void SetSocks4Userid(const std::string& ) = 0;
|
|
||||||
/** If connection to socks4 server fails, immediately try direct connection to final host. */
|
|
||||||
virtual void SetSocks4TryDirect(bool = true) = 0;
|
|
||||||
/** Get socks4 server ip.
|
|
||||||
\return socks4 server ip */
|
|
||||||
virtual ipaddr_t GetSocks4Host() = 0;
|
|
||||||
/** Get socks4 port number.
|
|
||||||
\return socks4 port number */
|
|
||||||
virtual port_t GetSocks4Port() = 0;
|
|
||||||
/** Get socks4 userid (optional).
|
|
||||||
\return socks4 userid */
|
|
||||||
virtual const std::string& GetSocks4Userid() = 0;
|
|
||||||
/** Check status of socks4 try direct flag.
|
|
||||||
\return true if direct connection should be tried if connection to socks4 server fails */
|
|
||||||
virtual bool Socks4TryDirect() = 0;
|
|
||||||
#endif // ENABLE_SOCKS4
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// DNS resolve server
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
/** Enable asynchronous DNS.
|
|
||||||
\param port Listen port of asynchronous dns server */
|
|
||||||
virtual void EnableResolver(port_t = 16667) = 0;
|
|
||||||
/** Check resolver status.
|
|
||||||
\return true if resolver is enabled */
|
|
||||||
virtual bool ResolverEnabled() = 0;
|
|
||||||
/** Queue a dns request.
|
|
||||||
\param host Hostname to be resolved
|
|
||||||
\param port Port number will be echoed in Socket::OnResolved callback */
|
|
||||||
virtual int Resolve(Socket *,const std::string& host,port_t port) = 0;
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
virtual int Resolve6(Socket *,const std::string& host,port_t port) = 0;
|
|
||||||
#endif
|
|
||||||
/** Do a reverse dns lookup. */
|
|
||||||
virtual int Resolve(Socket *,ipaddr_t a) = 0;
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
virtual int Resolve(Socket *,in6_addr& a) = 0;
|
|
||||||
#endif
|
|
||||||
/** Get listen port of asynchronous dns server. */
|
|
||||||
virtual port_t GetResolverPort() = 0;
|
|
||||||
/** Resolver thread ready for queries. */
|
|
||||||
virtual bool ResolverReady() = 0;
|
|
||||||
/** Returns true if socket waiting for a resolve event. */
|
|
||||||
virtual bool Resolving(Socket *) = 0;
|
|
||||||
#endif // ENABLE_RESOLVER
|
|
||||||
|
|
||||||
#ifdef ENABLE_TRIGGERS
|
|
||||||
/** Fetch unique trigger id. */
|
|
||||||
virtual int TriggerID(Socket *src) = 0;
|
|
||||||
/** Subscribe socket to trigger id. */
|
|
||||||
virtual bool Subscribe(int id, Socket *dst) = 0;
|
|
||||||
/** Unsubscribe socket from trigger id. */
|
|
||||||
virtual bool Unsubscribe(int id, Socket *dst) = 0;
|
|
||||||
/** Execute OnTrigger for subscribed sockets.
|
|
||||||
\param id Trigger ID
|
|
||||||
\param data Data passed from source to destination
|
|
||||||
\param erase Empty trigger id source and destination maps if 'true',
|
|
||||||
Leave them in place if 'false' - if a trigger should be called many times */
|
|
||||||
virtual void Trigger(int id, Socket::TriggerData& data, bool erase = true) = 0;
|
|
||||||
#endif // ENABLE_TRIGGERS
|
|
||||||
|
|
||||||
#ifdef ENABLE_DETACH
|
|
||||||
/** Indicates that the handler runs under SocketThread. */
|
|
||||||
virtual void SetSlave(bool x = true) = 0;
|
|
||||||
/** Indicates that the handler runs under SocketThread. */
|
|
||||||
virtual bool IsSlave() = 0;
|
|
||||||
#endif // ENABLE_DETACH
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_ISocketHandler_H
|
|
||||||
|
|
||||||
|
|
@ -1,98 +0,0 @@
|
||||||
/**
|
|
||||||
** \file Ipv4Address.h
|
|
||||||
** \date 2006-09-21
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_Ipv4Address_H
|
|
||||||
#define _SOCKETS_Ipv4Address_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include "SocketAddress.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Ipv4 address implementation.
|
|
||||||
\ingroup basic */
|
|
||||||
class Ipv4Address : public SocketAddress
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** Create empty Ipv4 address structure.
|
|
||||||
\param port Port number */
|
|
||||||
Ipv4Address(port_t port = 0);
|
|
||||||
/** Create Ipv4 address structure.
|
|
||||||
\param a Socket address in network byte order (as returned by Utility::u2ip)
|
|
||||||
\param port Port number in host byte order */
|
|
||||||
Ipv4Address(ipaddr_t a,port_t port);
|
|
||||||
/** Create Ipv4 address structure.
|
|
||||||
\param a Socket address in network byte order
|
|
||||||
\param port Port number in host byte order */
|
|
||||||
Ipv4Address(struct in_addr& a,port_t port);
|
|
||||||
/** Create Ipv4 address structure.
|
|
||||||
\param host Hostname to be resolved
|
|
||||||
\param port Port number in host byte order */
|
|
||||||
Ipv4Address(const std::string& host,port_t port);
|
|
||||||
Ipv4Address(struct sockaddr_in&);
|
|
||||||
~Ipv4Address();
|
|
||||||
|
|
||||||
// SocketAddress implementation
|
|
||||||
|
|
||||||
operator struct sockaddr *();
|
|
||||||
operator socklen_t();
|
|
||||||
bool operator==(SocketAddress&);
|
|
||||||
|
|
||||||
void SetPort(port_t port);
|
|
||||||
port_t GetPort();
|
|
||||||
|
|
||||||
void SetAddress(struct sockaddr *sa);
|
|
||||||
int GetFamily();
|
|
||||||
|
|
||||||
bool IsValid();
|
|
||||||
std::auto_ptr<SocketAddress> GetCopy();
|
|
||||||
|
|
||||||
/** Convert address struct to text. */
|
|
||||||
std::string Convert(bool include_port = false);
|
|
||||||
std::string Reverse();
|
|
||||||
|
|
||||||
/** Resolve hostname. */
|
|
||||||
static bool Resolve(const std::string& hostname,struct in_addr& a);
|
|
||||||
/** Reverse resolve (IP to hostname). */
|
|
||||||
static bool Reverse(struct in_addr& a,std::string& name);
|
|
||||||
/** Convert address struct to text. */
|
|
||||||
static std::string Convert(struct in_addr& a);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ipv4Address(const Ipv4Address& ) {} // copy constructor
|
|
||||||
Ipv4Address& operator=(const Ipv4Address& ) { return *this; } // assignment operator
|
|
||||||
struct sockaddr_in m_addr;
|
|
||||||
bool m_valid;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
#endif // _SOCKETS_Ipv4Address_H
|
|
||||||
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
/**
|
|
||||||
** \file Ipv6Address.h
|
|
||||||
** \date 2006-09-21
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_Ipv6Address_H
|
|
||||||
#define _SOCKETS_Ipv6Address_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
|
|
||||||
#include "SocketAddress.h"
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
#if defined( _WIN32) && !defined(__CYGWIN__)
|
|
||||||
typedef unsigned __int32 uint32_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/** Ipv6 address implementation.
|
|
||||||
\ingroup basic */
|
|
||||||
class Ipv6Address : public SocketAddress
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** Create empty Ipv6 address structure.
|
|
||||||
\param port Port number */
|
|
||||||
Ipv6Address(port_t port = 0);
|
|
||||||
/** Create Ipv6 address structure.
|
|
||||||
\param a Socket address in network byte order
|
|
||||||
\param port Port number in host byte order */
|
|
||||||
Ipv6Address(struct in6_addr& a,port_t port);
|
|
||||||
/** Create Ipv6 address structure.
|
|
||||||
\param host Hostname to be resolved
|
|
||||||
\param port Port number in host byte order */
|
|
||||||
Ipv6Address(const std::string& host,port_t port);
|
|
||||||
Ipv6Address(struct sockaddr_in6&);
|
|
||||||
~Ipv6Address();
|
|
||||||
|
|
||||||
// SocketAddress implementation
|
|
||||||
|
|
||||||
operator struct sockaddr *();
|
|
||||||
operator socklen_t();
|
|
||||||
bool operator==(SocketAddress&);
|
|
||||||
|
|
||||||
void SetPort(port_t port);
|
|
||||||
port_t GetPort();
|
|
||||||
|
|
||||||
void SetAddress(struct sockaddr *sa);
|
|
||||||
int GetFamily();
|
|
||||||
|
|
||||||
bool IsValid();
|
|
||||||
std::auto_ptr<SocketAddress> GetCopy();
|
|
||||||
|
|
||||||
/** Convert address struct to text. */
|
|
||||||
std::string Convert(bool include_port = false);
|
|
||||||
std::string Reverse();
|
|
||||||
|
|
||||||
/** Resolve hostname. */
|
|
||||||
static bool Resolve(const std::string& hostname,struct in6_addr& a);
|
|
||||||
/** Reverse resolve (IP to hostname). */
|
|
||||||
static bool Reverse(struct in6_addr& a,std::string& name);
|
|
||||||
/** Convert address struct to text. */
|
|
||||||
static std::string Convert(struct in6_addr& a,bool mixed = false);
|
|
||||||
|
|
||||||
void SetFlowinfo(uint32_t);
|
|
||||||
uint32_t GetFlowinfo();
|
|
||||||
#ifndef _WIN32
|
|
||||||
void SetScopeId(uint32_t);
|
|
||||||
uint32_t GetScopeId();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ipv6Address(const Ipv6Address& ) {} // copy constructor
|
|
||||||
Ipv6Address& operator=(const Ipv6Address& ) { return *this; } // assignment operator
|
|
||||||
struct sockaddr_in6 m_addr;
|
|
||||||
bool m_valid;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
#endif // IPPROTO_IPV6
|
|
||||||
#endif // ENABLE_IPV6
|
|
||||||
#endif // _SOCKETS_Ipv6Address_H
|
|
||||||
|
|
||||||
|
|
@ -1,420 +0,0 @@
|
||||||
/** \file ListenSocket.h
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_ListenSocket_H
|
|
||||||
#define _SOCKETS_ListenSocket_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <stdlib.h>
|
|
||||||
#else
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ISocketHandler.h"
|
|
||||||
#include "Socket.h"
|
|
||||||
#include "Utility.h"
|
|
||||||
#include "SctpSocket.h"
|
|
||||||
#include "Ipv4Address.h"
|
|
||||||
#include "Ipv6Address.h"
|
|
||||||
#ifdef ENABLE_EXCEPTIONS
|
|
||||||
#include "Exception.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/** Binds incoming port number to new Socket class X.
|
|
||||||
\ingroup basic */
|
|
||||||
template <class X>
|
|
||||||
class ListenSocket : public Socket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** Constructor.
|
|
||||||
\param h ISocketHandler reference
|
|
||||||
\param use_creator Optional use of creator (default true) */
|
|
||||||
ListenSocket(ISocketHandler& h,bool use_creator = true) : Socket(h), m_depth(0), m_creator(NULL)
|
|
||||||
,m_bHasCreate(false)
|
|
||||||
{
|
|
||||||
if (use_creator)
|
|
||||||
{
|
|
||||||
m_creator = new X(h);
|
|
||||||
Socket *tmp = m_creator -> Create();
|
|
||||||
if (tmp && dynamic_cast<X *>(tmp))
|
|
||||||
{
|
|
||||||
m_bHasCreate = true;
|
|
||||||
}
|
|
||||||
if (tmp)
|
|
||||||
{
|
|
||||||
delete tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~ListenSocket() {
|
|
||||||
if (m_creator)
|
|
||||||
{
|
|
||||||
delete m_creator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Close file descriptor. */
|
|
||||||
int Close() {
|
|
||||||
if (GetSocket() != INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
closesocket(GetSocket());
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Bind and listen to any interface.
|
|
||||||
\param port Port (0 is random)
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(port_t port,int depth = 20) {
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
Ipv6Address ad(port);
|
|
||||||
return Bind(ad, depth);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Ipv4Address ad(port);
|
|
||||||
return Bind(ad, depth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int Bind(SocketAddress& ad,int depth) {
|
|
||||||
#ifdef USE_SCTP
|
|
||||||
if (dynamic_cast<SctpSocket *>(m_creator))
|
|
||||||
{
|
|
||||||
return Bind(ad, "sctp", depth);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return Bind(ad, "tcp", depth);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Bind and listen to any interface, with optional protocol.
|
|
||||||
\param port Port (0 is random)
|
|
||||||
\param protocol Network protocol
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(port_t port,const std::string& protocol,int depth = 20) {
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
Ipv6Address ad(port);
|
|
||||||
return Bind(ad, protocol, depth);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Ipv4Address ad(port);
|
|
||||||
return Bind(ad, protocol, depth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Bind and listen to specific interface.
|
|
||||||
\param intf Interface hostname
|
|
||||||
\param port Port (0 is random)
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(const std::string& intf,port_t port,int depth = 20) {
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
Ipv6Address ad(intf, port);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
return Bind(ad, depth);
|
|
||||||
}
|
|
||||||
Handler().LogError(this, "Bind", 0, "name resolution of interface name failed", LOG_LEVEL_FATAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Ipv4Address ad(intf, port);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
return Bind(ad, depth);
|
|
||||||
}
|
|
||||||
Handler().LogError(this, "Bind", 0, "name resolution of interface name failed", LOG_LEVEL_FATAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Bind and listen to specific interface.
|
|
||||||
\param intf Interface hostname
|
|
||||||
\param port Port (0 is random)
|
|
||||||
\param protocol Network protocol
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(const std::string& intf,port_t port,const std::string& protocol,int depth = 20) {
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
Ipv6Address ad(intf, port);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
return Bind(ad, protocol, depth);
|
|
||||||
}
|
|
||||||
Handler().LogError(this, "Bind", 0, "name resolution of interface name failed", LOG_LEVEL_FATAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Ipv4Address ad(intf, port);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
return Bind(ad, protocol, depth);
|
|
||||||
}
|
|
||||||
Handler().LogError(this, "Bind", 0, "name resolution of interface name failed", LOG_LEVEL_FATAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Bind and listen to ipv4 interface.
|
|
||||||
\param a Ipv4 interface address
|
|
||||||
\param port Port (0 is random)
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(ipaddr_t a,port_t port,int depth = 20) {
|
|
||||||
Ipv4Address ad(a, port);
|
|
||||||
#ifdef USE_SCTP
|
|
||||||
if (dynamic_cast<SctpSocket *>(m_creator))
|
|
||||||
{
|
|
||||||
return Bind(ad, "sctp", depth);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return Bind(ad, "tcp", depth);
|
|
||||||
}
|
|
||||||
/** Bind and listen to ipv4 interface.
|
|
||||||
\param a Ipv4 interface address
|
|
||||||
\param port Port (0 is random)
|
|
||||||
\param protocol Network protocol
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(ipaddr_t a,port_t port,const std::string& protocol,int depth) {
|
|
||||||
Ipv4Address ad(a, port);
|
|
||||||
return Bind(ad, protocol, depth);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Bind and listen to ipv6 interface.
|
|
||||||
\param a Ipv6 interface address
|
|
||||||
\param port Port (0 is random)
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(in6_addr a,port_t port,int depth = 20) {
|
|
||||||
Ipv6Address ad(a, port);
|
|
||||||
#ifdef USE_SCTP
|
|
||||||
if (dynamic_cast<SctpSocket *>(m_creator))
|
|
||||||
{
|
|
||||||
return Bind(ad, "sctp", depth);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return Bind(ad, "tcp", depth);
|
|
||||||
}
|
|
||||||
/** Bind and listen to ipv6 interface.
|
|
||||||
\param a Ipv6 interface address
|
|
||||||
\param port Port (0 is random)
|
|
||||||
\param protocol Network protocol
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(in6_addr a,port_t port,const std::string& protocol,int depth) {
|
|
||||||
Ipv6Address ad(a, port);
|
|
||||||
return Bind(ad, protocol, depth);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Bind and listen to network interface.
|
|
||||||
\param ad Interface address
|
|
||||||
\param protocol Network protocol
|
|
||||||
\param depth Listen queue depth */
|
|
||||||
int Bind(SocketAddress& ad,const std::string& protocol,int depth) {
|
|
||||||
SOCKET s;
|
|
||||||
if ( (s = CreateSocket(ad.GetFamily(), SOCK_STREAM, protocol)) == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (bind(s, ad, ad) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "bind", Errno, StrError(Errno), LOG_LEVEL_FATAL);
|
|
||||||
closesocket(s);
|
|
||||||
#ifdef ENABLE_EXCEPTIONS
|
|
||||||
throw Exception("bind() failed for port " + Utility::l2string(ad.GetPort()) + ": " + StrError(Errno));
|
|
||||||
#endif
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (listen(s, depth) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "listen", Errno, StrError(Errno), LOG_LEVEL_FATAL);
|
|
||||||
closesocket(s);
|
|
||||||
#ifdef ENABLE_EXCEPTIONS
|
|
||||||
throw Exception("listen() failed for port " + Utility::l2string(ad.GetPort()) + ": " + StrError(Errno));
|
|
||||||
#endif
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
m_depth = depth;
|
|
||||||
Attach(s);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return assigned port number. */
|
|
||||||
port_t GetPort()
|
|
||||||
{
|
|
||||||
return GetSockPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return listen queue depth. */
|
|
||||||
int GetDepth()
|
|
||||||
{
|
|
||||||
return m_depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** OnRead on a ListenSocket receives an incoming connection. */
|
|
||||||
void OnRead()
|
|
||||||
{
|
|
||||||
struct sockaddr sa;
|
|
||||||
socklen_t sa_len = sizeof(struct sockaddr);
|
|
||||||
SOCKET a_s = accept(GetSocket(), &sa, &sa_len);
|
|
||||||
|
|
||||||
if (a_s == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "accept", Errno, StrError(Errno), LOG_LEVEL_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!Handler().OkToAccept(this))
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "accept", -1, "Not OK to accept", LOG_LEVEL_WARNING);
|
|
||||||
closesocket(a_s);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Handler().GetCount() >= FD_SETSIZE)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "accept", (int)Handler().GetCount(), "ISocketHandler fd_set limit reached", LOG_LEVEL_FATAL);
|
|
||||||
closesocket(a_s);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Socket *tmp = m_bHasCreate ? m_creator -> Create() : new X(Handler());
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
tmp -> SetIpv6( IsIpv6() );
|
|
||||||
#endif
|
|
||||||
tmp -> SetParent(this);
|
|
||||||
tmp -> Attach(a_s);
|
|
||||||
tmp -> SetNonblocking(true);
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (sa_len == sizeof(struct sockaddr_in6))
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 *p = (struct sockaddr_in6 *)&sa;
|
|
||||||
if (p -> sin6_family == AF_INET6)
|
|
||||||
{
|
|
||||||
Ipv6Address ad(p -> sin6_addr,ntohs(p -> sin6_port));
|
|
||||||
ad.SetFlowinfo(p -> sin6_flowinfo);
|
|
||||||
#ifndef _WIN32
|
|
||||||
ad.SetScopeId(p -> sin6_scope_id);
|
|
||||||
#endif
|
|
||||||
tmp -> SetRemoteAddress(ad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
if (sa_len == sizeof(struct sockaddr_in))
|
|
||||||
{
|
|
||||||
struct sockaddr_in *p = (struct sockaddr_in *)&sa;
|
|
||||||
if (p -> sin_family == AF_INET)
|
|
||||||
{
|
|
||||||
Ipv4Address ad(p -> sin_addr,ntohs(p -> sin_port));
|
|
||||||
tmp -> SetRemoteAddress(ad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmp -> SetConnected(true);
|
|
||||||
tmp -> Init();
|
|
||||||
tmp -> SetDeleteByHandler(true);
|
|
||||||
Handler().Add(tmp);
|
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
if (tmp -> IsSSL()) // SSL Enabled socket
|
|
||||||
{
|
|
||||||
// %! OnSSLAccept calls SSLNegotiate that can finish in this one call.
|
|
||||||
// %! If that happens and negotiation fails, the 'tmp' instance is
|
|
||||||
// %! still added to the list of active sockets in the sockethandler.
|
|
||||||
// %! See bugfix for this in SocketHandler::Select - don't Set rwx
|
|
||||||
// %! flags if CloseAndDelete() flag is true.
|
|
||||||
// %! An even better fugbix (see TcpSocket::OnSSLAccept) now avoids
|
|
||||||
// %! the Add problem altogether, so ignore the above.
|
|
||||||
// %! (OnSSLAccept does no longer call SSLNegotiate().)
|
|
||||||
tmp -> OnSSLAccept();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
tmp -> OnAccept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Please don't use this method.
|
|
||||||
"accept()" is handled automatically in the OnRead() method. */
|
|
||||||
virtual SOCKET Accept(SOCKET socket, struct sockaddr *saptr, socklen_t *lenptr)
|
|
||||||
{
|
|
||||||
return accept(socket, saptr, lenptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HasCreator() { return m_bHasCreate; }
|
|
||||||
|
|
||||||
void OnOptions(int,int,int,SOCKET) {
|
|
||||||
SetSoReuseaddr(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ListenSocket(const ListenSocket& s) : Socket(s) {}
|
|
||||||
private:
|
|
||||||
ListenSocket& operator=(const ListenSocket& ) { return *this; }
|
|
||||||
int m_depth;
|
|
||||||
X *m_creator;
|
|
||||||
bool m_bHasCreate;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_ListenSocket_H
|
|
||||||
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
/** \file Lock.h
|
|
||||||
** \date 2005-08-22
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2005,2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_Lock_H
|
|
||||||
#define _SOCKETS_Lock_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Mutex;
|
|
||||||
|
|
||||||
/** Mutex encapsulation class.
|
|
||||||
\ingroup threading */
|
|
||||||
class Lock
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Lock(Mutex&);
|
|
||||||
~Lock();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Mutex& m_mutex;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif // _SOCKETS_Lock_H
|
|
||||||
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
/** \file Mutex.h
|
|
||||||
** \date 2004-10-30
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_Mutex_H
|
|
||||||
#define _SOCKETS_Mutex_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#ifndef _WIN32
|
|
||||||
#include <pthread.h>
|
|
||||||
#else
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Mutex container class, used by Lock.
|
|
||||||
\ingroup threading */
|
|
||||||
class Mutex
|
|
||||||
{
|
|
||||||
friend class Lock;
|
|
||||||
public:
|
|
||||||
Mutex();
|
|
||||||
~Mutex();
|
|
||||||
|
|
||||||
void Lock();
|
|
||||||
void Unlock();
|
|
||||||
private:
|
|
||||||
#ifdef _WIN32
|
|
||||||
HANDLE m_mutex;
|
|
||||||
#else
|
|
||||||
pthread_mutex_t m_mutex;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif // _SOCKETS_Mutex_H
|
|
||||||
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
/** \file Parse.h - parse a string
|
|
||||||
**
|
|
||||||
** Written: 1999-Feb-10 grymse@alhem.net
|
|
||||||
**/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Copyright (C) 1999-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SOCKETS_Parse_H
|
|
||||||
#define _SOCKETS_Parse_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4514)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************/
|
|
||||||
/* interface of class Parse */
|
|
||||||
|
|
||||||
/** Splits a string whatever way you want.
|
|
||||||
\ingroup util */
|
|
||||||
class Parse
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Parse();
|
|
||||||
Parse(const std::string&);
|
|
||||||
Parse(const std::string&,const std::string&);
|
|
||||||
Parse(const std::string&,const std::string&,short);
|
|
||||||
~Parse();
|
|
||||||
short issplit(const char);
|
|
||||||
void getsplit();
|
|
||||||
void getsplit(std::string&);
|
|
||||||
std::string getword();
|
|
||||||
void getword(std::string&);
|
|
||||||
void getword(std::string&,std::string&,int);
|
|
||||||
std::string getrest();
|
|
||||||
void getrest(std::string&);
|
|
||||||
long getvalue();
|
|
||||||
void setbreak(const char);
|
|
||||||
int getwordlen();
|
|
||||||
int getrestlen();
|
|
||||||
void enablebreak(const char c) {
|
|
||||||
pa_enable = c;
|
|
||||||
}
|
|
||||||
void disablebreak(const char c) {
|
|
||||||
pa_disable = c;
|
|
||||||
}
|
|
||||||
void getline();
|
|
||||||
void getline(std::string&);
|
|
||||||
size_t getptr() { return pa_the_ptr; }
|
|
||||||
void EnableQuote(bool b) { pa_quote = b; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string pa_the_str;
|
|
||||||
std::string pa_splits;
|
|
||||||
std::string pa_ord;
|
|
||||||
size_t pa_the_ptr;
|
|
||||||
char pa_breakchar;
|
|
||||||
char pa_enable;
|
|
||||||
char pa_disable;
|
|
||||||
short pa_nospace;
|
|
||||||
bool pa_quote;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_Parse_H
|
|
||||||
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
/** \file ResolvServer.h
|
|
||||||
** \date 2005-03-24
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_ResolvServer_H
|
|
||||||
#define _SOCKETS_ResolvServer_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
#include "socket_include.h"
|
|
||||||
#include "Thread.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \defgroup async Asynchronous DNS */
|
|
||||||
/** Async DNS resolver thread.
|
|
||||||
\ingroup async */
|
|
||||||
class ResolvServer : public Thread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ResolvServer(port_t);
|
|
||||||
~ResolvServer();
|
|
||||||
|
|
||||||
void Run();
|
|
||||||
void Quit();
|
|
||||||
|
|
||||||
bool Ready();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ResolvServer(const ResolvServer& ) {} // copy constructor
|
|
||||||
ResolvServer& operator=(const ResolvServer& ) { return *this; } // assignment operator
|
|
||||||
|
|
||||||
bool m_quit;
|
|
||||||
port_t m_port;
|
|
||||||
bool m_ready;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // ENABLE_RESOLVER
|
|
||||||
#endif // _SOCKETS_ResolvServer_H
|
|
||||||
|
|
||||||
|
|
@ -1,106 +0,0 @@
|
||||||
/** \file ResolvSocket.h
|
|
||||||
** \date 2005-03-24
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_ResolvSocket_H
|
|
||||||
#define _SOCKETS_ResolvSocket_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
#include "TcpSocket.h"
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Mutex;
|
|
||||||
|
|
||||||
/** Async DNS resolver socket.
|
|
||||||
\ingroup async */
|
|
||||||
class ResolvSocket : public TcpSocket
|
|
||||||
{
|
|
||||||
typedef std::map<std::string, /* type */
|
|
||||||
std::map<std::string, std::string> > cache_t; /* host, result */
|
|
||||||
typedef std::map<std::string, /* type */
|
|
||||||
std::map<std::string, time_t> > timeout_t; /* host, time */
|
|
||||||
|
|
||||||
public:
|
|
||||||
ResolvSocket(ISocketHandler&);
|
|
||||||
ResolvSocket(ISocketHandler&, Socket *parent, const std::string& host, port_t port, bool ipv6 = false);
|
|
||||||
ResolvSocket(ISocketHandler&, Socket *parent, ipaddr_t);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
ResolvSocket(ISocketHandler&, Socket *parent, in6_addr&);
|
|
||||||
#endif
|
|
||||||
~ResolvSocket();
|
|
||||||
|
|
||||||
void OnAccept() { m_bServer = true; }
|
|
||||||
void OnLine(const std::string& line);
|
|
||||||
void OnDetached();
|
|
||||||
void OnDelete();
|
|
||||||
|
|
||||||
void SetId(int x) { m_resolv_id = x; }
|
|
||||||
int GetId() { return m_resolv_id; }
|
|
||||||
|
|
||||||
void OnConnect();
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
void SetResolveIpv6(bool x = true) { m_resolve_ipv6 = x; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
ResolvSocket(const ResolvSocket& s) : TcpSocket(s) {} // copy constructor
|
|
||||||
ResolvSocket& operator=(const ResolvSocket& ) { return *this; } // assignment operator
|
|
||||||
|
|
||||||
std::string m_query;
|
|
||||||
std::string m_data;
|
|
||||||
bool m_bServer;
|
|
||||||
Socket *m_parent;
|
|
||||||
int m_resolv_id;
|
|
||||||
std::string m_resolv_host;
|
|
||||||
port_t m_resolv_port;
|
|
||||||
ipaddr_t m_resolv_address;
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
bool m_resolve_ipv6;
|
|
||||||
in6_addr m_resolv_address6;
|
|
||||||
#endif
|
|
||||||
static cache_t m_cache;
|
|
||||||
static timeout_t m_cache_to;
|
|
||||||
static Mutex m_cache_mutex;
|
|
||||||
bool m_cached;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // ENABLE_RESOLVER
|
|
||||||
#endif // _SOCKETS_ResolvSocket_H
|
|
||||||
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
/**
|
|
||||||
** \file SctpSocket.h
|
|
||||||
** \date 2006-09-04
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_SctpSocket_H
|
|
||||||
#define _SOCKETS_SctpSocket_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
|
|
||||||
#include "StreamSocket.h"
|
|
||||||
#ifdef USE_SCTP
|
|
||||||
#include <netinet/sctp.h>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SCTP_BUFSIZE_READ 16400
|
|
||||||
|
|
||||||
class SocketAddress;
|
|
||||||
|
|
||||||
|
|
||||||
class SctpSocket : public StreamSocket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** SctpSocket constructor.
|
|
||||||
\param h Owner
|
|
||||||
\param type SCTP_STREAM or SCTP_SEQPACKET */
|
|
||||||
SctpSocket(ISocketHandler& h,int type);
|
|
||||||
~SctpSocket();
|
|
||||||
|
|
||||||
/** bind() */
|
|
||||||
int Bind(const std::string&,port_t);
|
|
||||||
int Bind(SocketAddress&);
|
|
||||||
/** sctp_bindx() */
|
|
||||||
int AddAddress(const std::string&,port_t);
|
|
||||||
int AddAddress(SocketAddress&);
|
|
||||||
/** sctp_bindx() */
|
|
||||||
int RemoveAddress(const std::string&,port_t);
|
|
||||||
int RemoveAddress(SocketAddress&);
|
|
||||||
|
|
||||||
/** connect() */
|
|
||||||
int Open(const std::string&,port_t);
|
|
||||||
int Open(SocketAddress&);
|
|
||||||
|
|
||||||
/** Connect timeout callback. */
|
|
||||||
void OnConnectTimeout();
|
|
||||||
#ifdef _WIN32
|
|
||||||
/** Connection failed reported as exception on win32 */
|
|
||||||
void OnException();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SOLARIS
|
|
||||||
/** sctp_connectx() */
|
|
||||||
int AddConnection(const std::string&,port_t);
|
|
||||||
int AddConnection(SocketAddress&);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Get peer addresses of an association. */
|
|
||||||
int getpaddrs(sctp_assoc_t id,std::list<std::string>&);
|
|
||||||
/** Get all bound addresses of an association. */
|
|
||||||
int getladdrs(sctp_assoc_t id,std::list<std::string>&);
|
|
||||||
|
|
||||||
/** sctp_peeloff */
|
|
||||||
int PeelOff(sctp_assoc_t id);
|
|
||||||
|
|
||||||
/** recvmsg callback */
|
|
||||||
virtual void OnReceiveMessage(const char *buf,size_t sz,struct sockaddr *sa,socklen_t sa_len,struct sctp_sndrcvinfo *sinfo,int msg_flags) = 0;
|
|
||||||
|
|
||||||
void OnOptions(int,int,int,SOCKET) {}
|
|
||||||
|
|
||||||
virtual int Protocol();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
SctpSocket(const SctpSocket& s) : StreamSocket(s) {}
|
|
||||||
void OnRead();
|
|
||||||
void OnWrite();
|
|
||||||
|
|
||||||
private:
|
|
||||||
SctpSocket& operator=(const SctpSocket& s) { return *this; }
|
|
||||||
int m_type; ///< SCTP_STREAM or SCTP_SEQPACKET
|
|
||||||
char *m_buf; ///< Temporary receive buffer
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // USE_SCTP
|
|
||||||
#endif // _SOCKETS_SctpSocket_H
|
|
||||||
|
|
||||||
|
|
@ -1,739 +0,0 @@
|
||||||
/** \file Socket.h
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This software is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_Socket_H
|
|
||||||
#define _SOCKETS_Socket_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <list>
|
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "socket_include.h"
|
|
||||||
#include <time.h>
|
|
||||||
#include "SocketAddress.h"
|
|
||||||
#include "Thread.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class ISocketHandler;
|
|
||||||
class SocketAddress;
|
|
||||||
class IFile;
|
|
||||||
|
|
||||||
|
|
||||||
/** \defgroup basic Basic sockets */
|
|
||||||
/** Socket base class.
|
|
||||||
\ingroup basic */
|
|
||||||
class Socket
|
|
||||||
{
|
|
||||||
friend class ISocketHandler;
|
|
||||||
#ifdef ENABLE_DETACH
|
|
||||||
/** Detached socket run thread.
|
|
||||||
\ingroup internal */
|
|
||||||
class SocketThread : public Thread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SocketThread(Socket *p);
|
|
||||||
~SocketThread();
|
|
||||||
|
|
||||||
void Run();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Socket *GetSocket() const { return m_socket; }
|
|
||||||
SocketThread(const SocketThread& s) : m_socket(s.GetSocket()) {}
|
|
||||||
SocketThread& operator=(const SocketThread& ) { return *this; }
|
|
||||||
Socket *m_socket;
|
|
||||||
};
|
|
||||||
#endif // ENABLE_DETACH
|
|
||||||
|
|
||||||
#ifdef ENABLE_TRIGGERS
|
|
||||||
public:
|
|
||||||
/** Data pass class from source to destination. */
|
|
||||||
class TriggerData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TriggerData() : m_src(NULL) {}
|
|
||||||
virtual ~TriggerData() {}
|
|
||||||
|
|
||||||
Socket *GetSource() const { return m_src; }
|
|
||||||
void SetSource(Socket *x) { m_src = x; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Socket *m_src;
|
|
||||||
};
|
|
||||||
#endif // ENABLE_TRIGGERS
|
|
||||||
|
|
||||||
/** Socket mode flags. */
|
|
||||||
/*
|
|
||||||
enum {
|
|
||||||
// Socket
|
|
||||||
SOCK_DEL = 0x01, ///< Delete by handler flag
|
|
||||||
SOCK_CLOSE = 0x02, ///< Close and delete flag
|
|
||||||
SOCK_DISABLE_READ = 0x04, ///< Disable checking for read events
|
|
||||||
SOCK_CONNECTED = 0x08, ///< Socket is connected (tcp/udp)
|
|
||||||
|
|
||||||
SOCK_ERASED_BY_HANDLER = 0x10, ///< Set by handler before delete
|
|
||||||
// HAVE_OPENSSL
|
|
||||||
SOCK_ENABLE_SSL = 0x20, ///< Enable SSL for this TcpSocket
|
|
||||||
SOCK_SSL = 0x40, ///< ssl negotiation mode (TcpSocket)
|
|
||||||
SOCK_SSL_SERVER = 0x80, ///< True if this is an incoming ssl TcpSocket connection
|
|
||||||
|
|
||||||
// ENABLE_IPV6
|
|
||||||
SOCK_IPV6 = 0x0100, ///< This is an ipv6 socket if this one is true
|
|
||||||
// ENABLE_POOL
|
|
||||||
SOCK_CLIENT = 0x0200, ///< only client connections are pooled
|
|
||||||
SOCK_RETAIN = 0x0400, ///< keep connection on close
|
|
||||||
SOCK_LOST = 0x0800, ///< connection lost
|
|
||||||
|
|
||||||
// ENABLE_SOCKS4
|
|
||||||
SOCK_SOCKS4 = 0x1000, ///< socks4 negotiation mode (TcpSocket)
|
|
||||||
// ENABLE_DETACH
|
|
||||||
SOCK_DETACH = 0x2000, ///< Socket ordered to detach flag
|
|
||||||
SOCK_DETACHED = 0x4000, ///< Socket has been detached
|
|
||||||
// StreamSocket
|
|
||||||
STREAMSOCK_CONNECTING = 0x8000, ///< Flag indicating connection in progress
|
|
||||||
|
|
||||||
STREAMSOCK_FLUSH_BEFORE_CLOSE = 0x010000L, ///< Send all data before closing (default true)
|
|
||||||
STREAMSOCK_CALL_ON_CONNECT = 0x020000L, ///< OnConnect will be called next ISocketHandler cycle if true
|
|
||||||
STREAMSOCK_RETRY_CONNECT = 0x040000L, ///< Try another connection attempt next ISocketHandler cycle
|
|
||||||
STREAMSOCK_LINE_PROTOCOL = 0x080000L, ///< Line protocol mode flag
|
|
||||||
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** "Default" constructor */
|
|
||||||
Socket(ISocketHandler&);
|
|
||||||
|
|
||||||
virtual ~Socket();
|
|
||||||
|
|
||||||
/** Socket class instantiation method. Used when a "non-standard" constructor
|
|
||||||
* needs to be used for the socket class. Note: the socket class still needs
|
|
||||||
* the "default" constructor with one ISocketHandler& as input parameter.
|
|
||||||
*/
|
|
||||||
virtual Socket *Create() { return NULL; }
|
|
||||||
|
|
||||||
/** Returns reference to sockethandler that owns the socket.
|
|
||||||
If the socket is detached, this is a reference to the slave sockethandler.
|
|
||||||
*/
|
|
||||||
ISocketHandler& Handler() const;
|
|
||||||
|
|
||||||
/** Returns reference to sockethandler that owns the socket.
|
|
||||||
This one always returns the reference to the original sockethandler,
|
|
||||||
even if the socket is detached.
|
|
||||||
*/
|
|
||||||
ISocketHandler& MasterHandler() const;
|
|
||||||
|
|
||||||
/** Called by ListenSocket after accept but before socket is added to handler.
|
|
||||||
* CTcpSocket uses this to create its ICrypt member variable.
|
|
||||||
* The ICrypt member variable is created by a virtual method, therefore
|
|
||||||
* it can't be called directly from the CTcpSocket constructor.
|
|
||||||
* Also used to determine if incoming HTTP connection is normal (port 80)
|
|
||||||
* or ssl (port 443).
|
|
||||||
*/
|
|
||||||
virtual void Init();
|
|
||||||
|
|
||||||
/** Create a socket file descriptor.
|
|
||||||
\param af Address family AF_INET / AF_INET6 / ...
|
|
||||||
\param type SOCK_STREAM / SOCK_DGRAM / ...
|
|
||||||
\param protocol "tcp" / "udp" / ... */
|
|
||||||
SOCKET CreateSocket(int af,int type,const std::string& protocol = "");
|
|
||||||
|
|
||||||
/** Assign this socket a file descriptor created
|
|
||||||
by a call to socket() or otherwise. */
|
|
||||||
void Attach(SOCKET s);
|
|
||||||
|
|
||||||
/** Return file descriptor assigned to this socket. */
|
|
||||||
SOCKET GetSocket();
|
|
||||||
|
|
||||||
/** Close connection immediately - internal use.
|
|
||||||
\sa SetCloseAndDelete */
|
|
||||||
virtual int Close();
|
|
||||||
|
|
||||||
/** Add file descriptor to sockethandler fd_set's. */
|
|
||||||
void Set(bool bRead,bool bWrite,bool bException = true);
|
|
||||||
|
|
||||||
/** Returns true when socket file descriptor is valid
|
|
||||||
and socket is not about to be closed. */
|
|
||||||
virtual bool Ready();
|
|
||||||
|
|
||||||
/** Returns pointer to ListenSocket that created this instance
|
|
||||||
* on an incoming connection. */
|
|
||||||
Socket *GetParent();
|
|
||||||
|
|
||||||
/** Used by ListenSocket to set parent pointer of newly created
|
|
||||||
* socket instance. */
|
|
||||||
void SetParent(Socket *);
|
|
||||||
|
|
||||||
/** Get listening port from ListenSocket<>. */
|
|
||||||
virtual port_t GetPort();
|
|
||||||
|
|
||||||
/** Set socket non-block operation. */
|
|
||||||
bool SetNonblocking(bool);
|
|
||||||
|
|
||||||
/** Set socket non-block operation. */
|
|
||||||
bool SetNonblocking(bool, SOCKET);
|
|
||||||
|
|
||||||
/** Total lifetime of instance. */
|
|
||||||
time_t Uptime();
|
|
||||||
|
|
||||||
/** Set address/port of last connect() call. */
|
|
||||||
void SetClientRemoteAddress(SocketAddress&);
|
|
||||||
|
|
||||||
/** Get address/port of last connect() call. */
|
|
||||||
std::auto_ptr<SocketAddress> GetClientRemoteAddress();
|
|
||||||
|
|
||||||
/** Common interface for SendBuf used by Tcp and Udp sockets. */
|
|
||||||
virtual void SendBuf(const char *,size_t,int = 0);
|
|
||||||
|
|
||||||
/** Common interface for Send used by Tcp and Udp sockets. */
|
|
||||||
virtual void Send(const std::string&,int = 0);
|
|
||||||
|
|
||||||
/** Outgoing traffic counter. */
|
|
||||||
virtual uint64_t GetBytesSent(bool clear = false);
|
|
||||||
|
|
||||||
/** Incoming traffic counter. */
|
|
||||||
virtual uint64_t GetBytesReceived(bool clear = false);
|
|
||||||
|
|
||||||
// LIST_TIMEOUT
|
|
||||||
|
|
||||||
/** Enable timeout control. 0=disable timeout check. */
|
|
||||||
void SetTimeout(time_t secs);
|
|
||||||
|
|
||||||
/** Check timeout. \return true if time limit reached */
|
|
||||||
bool Timeout(time_t tnow);
|
|
||||||
|
|
||||||
/** Used by ListenSocket. ipv4 and ipv6 */
|
|
||||||
void SetRemoteAddress(SocketAddress&);
|
|
||||||
|
|
||||||
/** \name Event callbacks */
|
|
||||||
//@{
|
|
||||||
|
|
||||||
/** Called when there is something to be read from the file descriptor. */
|
|
||||||
virtual void OnRead();
|
|
||||||
/** Called when there is room for another write on the file descriptor. */
|
|
||||||
virtual void OnWrite();
|
|
||||||
/** Called on socket exception. */
|
|
||||||
virtual void OnException();
|
|
||||||
/** Called before a socket class is deleted by the ISocketHandler. */
|
|
||||||
virtual void OnDelete();
|
|
||||||
/** Called when a connection has completed. */
|
|
||||||
virtual void OnConnect();
|
|
||||||
/** Called when an incoming connection has been completed. */
|
|
||||||
virtual void OnAccept();
|
|
||||||
/** Called when a complete line has been read and the socket is in
|
|
||||||
* line protocol mode. */
|
|
||||||
virtual void OnLine(const std::string& );
|
|
||||||
/** Called on connect timeout (5s). */
|
|
||||||
virtual void OnConnectFailed();
|
|
||||||
/** Called when a client socket is created, to set socket options.
|
|
||||||
\param family AF_INET, AF_INET6, etc
|
|
||||||
\param type SOCK_STREAM, SOCK_DGRAM, etc
|
|
||||||
\param protocol Protocol number (tcp, udp, sctp, etc)
|
|
||||||
\param s Socket file descriptor
|
|
||||||
*/
|
|
||||||
virtual void OnOptions(int family,int type,int protocol,SOCKET s) = 0;
|
|
||||||
/** Connection retry callback - return false to abort connection attempts */
|
|
||||||
virtual bool OnConnectRetry();
|
|
||||||
#ifdef ENABLE_RECONNECT
|
|
||||||
/** a reconnect has been made */
|
|
||||||
virtual void OnReconnect();
|
|
||||||
#endif
|
|
||||||
/** TcpSocket: When a disconnect has been detected (recv/SSL_read returns 0 bytes). */
|
|
||||||
virtual void OnDisconnect();
|
|
||||||
/** Timeout callback. */
|
|
||||||
virtual void OnTimeout();
|
|
||||||
/** Connection timeout. */
|
|
||||||
virtual void OnConnectTimeout();
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/** \name Socket mode flags, set/reset */
|
|
||||||
//@{
|
|
||||||
/** Set delete by handler true when you want the sockethandler to
|
|
||||||
delete the socket instance after use. */
|
|
||||||
void SetDeleteByHandler(bool = true);
|
|
||||||
/** Check delete by handler flag.
|
|
||||||
\return true if this instance should be deleted by the sockethandler */
|
|
||||||
bool DeleteByHandler();
|
|
||||||
|
|
||||||
// LIST_CLOSE - conditional event queue
|
|
||||||
|
|
||||||
/** Set close and delete to terminate the connection. */
|
|
||||||
void SetCloseAndDelete(bool = true);
|
|
||||||
/** Check close and delete flag.
|
|
||||||
\return true if this socket should be closed and the instance removed */
|
|
||||||
bool CloseAndDelete();
|
|
||||||
|
|
||||||
/** Return number of seconds since socket was ordered to close. \sa SetCloseAndDelete */
|
|
||||||
time_t TimeSinceClose();
|
|
||||||
|
|
||||||
/** Ignore read events for an output only socket. */
|
|
||||||
void DisableRead(bool x = true);
|
|
||||||
/** Check ignore read events flag.
|
|
||||||
\return true if read events should be ignored */
|
|
||||||
bool IsDisableRead();
|
|
||||||
|
|
||||||
/** Set connected status. */
|
|
||||||
void SetConnected(bool = true);
|
|
||||||
/** Check connected status.
|
|
||||||
\return true if connected */
|
|
||||||
bool IsConnected();
|
|
||||||
|
|
||||||
/** Connection lost - error while reading/writing from a socket - TcpSocket only. */
|
|
||||||
void SetLost();
|
|
||||||
/** Check connection lost status flag, used by TcpSocket only.
|
|
||||||
\return true if there was an error while r/w causing the socket to close */
|
|
||||||
bool Lost();
|
|
||||||
|
|
||||||
/** Set flag indicating the socket is being actively deleted by the sockethandler. */
|
|
||||||
void SetErasedByHandler(bool x = true);
|
|
||||||
/** Get value of flag indicating socket is deleted by sockethandler. */
|
|
||||||
bool ErasedByHandler();
|
|
||||||
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/** \name Information about remote connection */
|
|
||||||
//@{
|
|
||||||
/** Returns address of remote end. */
|
|
||||||
std::auto_ptr<SocketAddress> GetRemoteSocketAddress();
|
|
||||||
/** Returns address of remote end: ipv4. */
|
|
||||||
ipaddr_t GetRemoteIP4();
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
/** Returns address of remote end: ipv6. */
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
struct in6_addr GetRemoteIP6();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** Returns remote port number: ipv4 and ipv6. */
|
|
||||||
port_t GetRemotePort();
|
|
||||||
/** Returns remote ip as string? ipv4 and ipv6. */
|
|
||||||
std::string GetRemoteAddress();
|
|
||||||
/** ipv4 and ipv6(not implemented) */
|
|
||||||
std::string GetRemoteHostname();
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/** Returns local port number for bound socket file descriptor. */
|
|
||||||
port_t GetSockPort();
|
|
||||||
/** Returns local ipv4 address for bound socket file descriptor. */
|
|
||||||
ipaddr_t GetSockIP4();
|
|
||||||
/** Returns local ipv4 address as text for bound socket file descriptor. */
|
|
||||||
std::string GetSockAddress();
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Returns local ipv6 address for bound socket file descriptor. */
|
|
||||||
struct in6_addr GetSockIP6();
|
|
||||||
/** Returns local ipv6 address as text for bound socket file descriptor. */
|
|
||||||
std::string GetSockAddress6();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
/** @name IP options
|
|
||||||
When an ip or socket option is available on all of the operating systems
|
|
||||||
I'm testing on (linux 2.4.x, _win32, macosx, solaris9 intel) they are not
|
|
||||||
checked with an #ifdef below.
|
|
||||||
This might cause a compile error on other operating systems. */
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// IP options
|
|
||||||
//@{
|
|
||||||
|
|
||||||
bool SetIpOptions(const void *p, socklen_t len);
|
|
||||||
bool SetIpTOS(unsigned char tos);
|
|
||||||
unsigned char IpTOS();
|
|
||||||
bool SetIpTTL(int ttl);
|
|
||||||
int IpTTL();
|
|
||||||
bool SetIpHdrincl(bool x = true);
|
|
||||||
bool SetIpMulticastTTL(int);
|
|
||||||
int IpMulticastTTL();
|
|
||||||
bool SetMulticastLoop(bool x = true);
|
|
||||||
bool IpAddMembership(struct ip_mreq&);
|
|
||||||
bool IpDropMembership(struct ip_mreq&);
|
|
||||||
|
|
||||||
#ifdef IP_PKTINFO
|
|
||||||
bool SetIpPktinfo(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef IP_RECVTOS
|
|
||||||
bool SetIpRecvTOS(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef IP_RECVTTL
|
|
||||||
bool SetIpRecvTTL(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef IP_RECVOPTS
|
|
||||||
bool SetIpRecvopts(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef IP_RETOPTS
|
|
||||||
bool SetIpRetopts(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef IP_RECVERR
|
|
||||||
bool SetIpRecverr(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef IP_MTU_DISCOVER
|
|
||||||
bool SetIpMtudiscover(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef IP_MTU
|
|
||||||
int IpMtu();
|
|
||||||
#endif
|
|
||||||
#ifdef IP_ROUTER_ALERT
|
|
||||||
bool SetIpRouterAlert(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef LINUX
|
|
||||||
bool IpAddMembership(struct ip_mreqn&);
|
|
||||||
#endif
|
|
||||||
#ifdef LINUX
|
|
||||||
bool IpDropMembership(struct ip_mreqn&);
|
|
||||||
#endif
|
|
||||||
//@}
|
|
||||||
|
|
||||||
// SOCKET options
|
|
||||||
/** @name Socket Options */
|
|
||||||
//@{
|
|
||||||
|
|
||||||
bool SoAcceptconn();
|
|
||||||
bool SetSoBroadcast(bool x = true);
|
|
||||||
bool SetSoDebug(bool x = true);
|
|
||||||
int SoError();
|
|
||||||
bool SetSoDontroute(bool x = true);
|
|
||||||
bool SetSoLinger(int onoff, int linger);
|
|
||||||
bool SetSoOobinline(bool x = true);
|
|
||||||
bool SetSoRcvlowat(int);
|
|
||||||
bool SetSoSndlowat(int);
|
|
||||||
bool SetSoRcvtimeo(struct timeval&);
|
|
||||||
bool SetSoSndtimeo(struct timeval&);
|
|
||||||
bool SetSoRcvbuf(int);
|
|
||||||
int SoRcvbuf();
|
|
||||||
bool SetSoSndbuf(int);
|
|
||||||
int SoSndbuf();
|
|
||||||
int SoType();
|
|
||||||
bool SetSoReuseaddr(bool x = true);
|
|
||||||
bool SetSoKeepalive(bool x = true);
|
|
||||||
|
|
||||||
#ifdef SO_BSDCOMPAT
|
|
||||||
bool SetSoBsdcompat(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef SO_BINDTODEVICE
|
|
||||||
bool SetSoBindtodevice(const std::string& intf);
|
|
||||||
#endif
|
|
||||||
#ifdef SO_PASSCRED
|
|
||||||
bool SetSoPasscred(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef SO_PEERCRED
|
|
||||||
bool SoPeercred(struct ucred& );
|
|
||||||
#endif
|
|
||||||
#ifdef SO_PRIORITY
|
|
||||||
bool SetSoPriority(int);
|
|
||||||
#endif
|
|
||||||
#ifdef SO_RCVBUFFORCE
|
|
||||||
bool SetSoRcvbufforce(int);
|
|
||||||
#endif
|
|
||||||
#ifdef SO_SNDBUFFORCE
|
|
||||||
bool SetSoSndbufforce(int);
|
|
||||||
#endif
|
|
||||||
#ifdef SO_TIMESTAMP
|
|
||||||
bool SetSoTimestamp(bool x = true);
|
|
||||||
#endif
|
|
||||||
#ifdef SO_NOSIGPIPE
|
|
||||||
bool SetSoNosigpipe(bool x = true);
|
|
||||||
#endif
|
|
||||||
//@}
|
|
||||||
|
|
||||||
// TCP options in TcpSocket.h/TcpSocket.cpp
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
/** @name SSL Support */
|
|
||||||
//@{
|
|
||||||
/** SSL client/server support - internal use. \sa TcpSocket */
|
|
||||||
virtual void OnSSLConnect();
|
|
||||||
/** SSL client/server support - internal use. \sa TcpSocket */
|
|
||||||
virtual void OnSSLAccept();
|
|
||||||
/** SSL negotiation failed for client connect. */
|
|
||||||
virtual void OnSSLConnectFailed();
|
|
||||||
/** SSL negotiation failed for server accept. */
|
|
||||||
virtual void OnSSLAcceptFailed();
|
|
||||||
/** new SSL support */
|
|
||||||
virtual bool SSLNegotiate();
|
|
||||||
/** Check if SSL is Enabled for this TcpSocket.
|
|
||||||
\return true if this is a TcpSocket with SSL enabled */
|
|
||||||
bool IsSSL();
|
|
||||||
/** Enable SSL operation for a TcpSocket. */
|
|
||||||
void EnableSSL(bool x = true);
|
|
||||||
/** Still negotiating ssl connection.
|
|
||||||
\return true if ssl negotiating is still in progress */
|
|
||||||
bool IsSSLNegotiate();
|
|
||||||
/** Set flag indicating ssl handshaking still in progress. */
|
|
||||||
void SetSSLNegotiate(bool x = true);
|
|
||||||
/** OnAccept called with SSL Enabled.
|
|
||||||
\return true if this is a TcpSocket with an incoming SSL connection */
|
|
||||||
bool IsSSLServer();
|
|
||||||
/** Set flag indicating that this is a TcpSocket with incoming SSL connection. */
|
|
||||||
void SetSSLServer(bool x = true);
|
|
||||||
/** SSL; Get pointer to ssl context structure. */
|
|
||||||
virtual SSL_CTX *GetSslContext() { return NULL; }
|
|
||||||
/** SSL; Get pointer to ssl structure. */
|
|
||||||
virtual SSL *GetSsl() { return NULL; }
|
|
||||||
//@}
|
|
||||||
#endif // HAVE_OPENSSL
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
/** Enable ipv6 for this socket. */
|
|
||||||
void SetIpv6(bool x = true);
|
|
||||||
/** Check ipv6 socket.
|
|
||||||
\return true if this is an ipv6 socket */
|
|
||||||
bool IsIpv6();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_POOL
|
|
||||||
/** @name Connection Pool */
|
|
||||||
//@{
|
|
||||||
/** Client = connecting TcpSocket. */
|
|
||||||
void SetIsClient();
|
|
||||||
/** Socket type from socket() call. */
|
|
||||||
void SetSocketType(int x);
|
|
||||||
/** Socket type from socket() call. */
|
|
||||||
int GetSocketType();
|
|
||||||
/** Protocol type from socket() call. */
|
|
||||||
void SetSocketProtocol(const std::string& x);
|
|
||||||
/** Protocol type from socket() call. */
|
|
||||||
const std::string& GetSocketProtocol();
|
|
||||||
/** Instruct a client socket to stay open in the connection pool after use.
|
|
||||||
If you have connected to a server using tcp, you can call SetRetain
|
|
||||||
to leave the connection open after your socket instance has been deleted.
|
|
||||||
The next connection you make to the same server will reuse the already
|
|
||||||
opened connection, if it is still available.
|
|
||||||
*/
|
|
||||||
void SetRetain();
|
|
||||||
/** Check retain flag.
|
|
||||||
\return true if the socket should be moved to connection pool after use */
|
|
||||||
bool Retain();
|
|
||||||
/** Copy connection parameters from sock. */
|
|
||||||
void CopyConnection(Socket *sock);
|
|
||||||
//@}
|
|
||||||
#endif // ENABLE_POOL
|
|
||||||
|
|
||||||
#ifdef ENABLE_SOCKS4
|
|
||||||
/** \name Socks4 support */
|
|
||||||
//@{
|
|
||||||
/** Socks4 client support internal use. \sa TcpSocket */
|
|
||||||
virtual void OnSocks4Connect();
|
|
||||||
/** Socks4 client support internal use. \sa TcpSocket */
|
|
||||||
virtual void OnSocks4ConnectFailed();
|
|
||||||
/** Socks4 client support internal use. \sa TcpSocket */
|
|
||||||
virtual bool OnSocks4Read();
|
|
||||||
/** Called when the last write caused the tcp output buffer to
|
|
||||||
* become empty. */
|
|
||||||
/** socket still in socks4 negotiation mode */
|
|
||||||
bool Socks4();
|
|
||||||
/** Set flag indicating Socks4 handshaking in progress */
|
|
||||||
void SetSocks4(bool x = true);
|
|
||||||
|
|
||||||
/** Set socks4 server host address to use */
|
|
||||||
void SetSocks4Host(ipaddr_t a);
|
|
||||||
/** Set socks4 server hostname to use. */
|
|
||||||
void SetSocks4Host(const std::string& );
|
|
||||||
/** Socks4 server port to use. */
|
|
||||||
void SetSocks4Port(port_t p);
|
|
||||||
/** Provide a socks4 userid if required by the socks4 server. */
|
|
||||||
void SetSocks4Userid(const std::string& x);
|
|
||||||
/** Get the ip address of socks4 server to use.
|
|
||||||
\return socks4 server host address */
|
|
||||||
ipaddr_t GetSocks4Host();
|
|
||||||
/** Get the socks4 server port to use.
|
|
||||||
\return socks4 server port */
|
|
||||||
port_t GetSocks4Port();
|
|
||||||
/** Get socks4 userid.
|
|
||||||
\return Socks4 userid */
|
|
||||||
const std::string& GetSocks4Userid();
|
|
||||||
//@}
|
|
||||||
#endif // ENABLE_SOCKS4
|
|
||||||
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
/** \name Asynchronous Resolver */
|
|
||||||
//@{
|
|
||||||
/** Request an asynchronous dns resolution.
|
|
||||||
\param host hostname to be resolved
|
|
||||||
\param port port number passed along for the ride
|
|
||||||
\return Resolve ID */
|
|
||||||
int Resolve(const std::string& host,port_t port = 0);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
int Resolve6(const std::string& host, port_t port = 0);
|
|
||||||
#endif
|
|
||||||
/** Callback returning a resolved address.
|
|
||||||
\param id Resolve ID from Resolve call
|
|
||||||
\param a resolved ip address
|
|
||||||
\param port port number passed to Resolve */
|
|
||||||
virtual void OnResolved(int id,ipaddr_t a,port_t port);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
virtual void OnResolved(int id,in6_addr& a,port_t port);
|
|
||||||
#endif
|
|
||||||
/** Request asynchronous reverse dns lookup.
|
|
||||||
\param a in_addr to be translated */
|
|
||||||
int Resolve(ipaddr_t a);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
int Resolve(in6_addr& a);
|
|
||||||
#endif
|
|
||||||
/** Callback returning reverse resolve results.
|
|
||||||
\param id Resolve ID
|
|
||||||
\param name Resolved hostname */
|
|
||||||
virtual void OnReverseResolved(int id,const std::string& name);
|
|
||||||
/** Callback indicating failed dns lookup.
|
|
||||||
\param id Resolve ID */
|
|
||||||
virtual void OnResolveFailed(int id);
|
|
||||||
//@}
|
|
||||||
#endif // ENABLE_RESOLVER
|
|
||||||
|
|
||||||
#ifdef ENABLE_DETACH
|
|
||||||
/** \name Thread Support */
|
|
||||||
//@{
|
|
||||||
/** Callback fires when a new socket thread has started and this
|
|
||||||
socket is ready for operation again.
|
|
||||||
\sa ResolvSocket */
|
|
||||||
virtual void OnDetached();
|
|
||||||
|
|
||||||
// LIST_DETACH
|
|
||||||
|
|
||||||
/** Internal use. */
|
|
||||||
void SetDetach(bool x = true);
|
|
||||||
/** Check detach flag.
|
|
||||||
\return true if the socket should detach to its own thread */
|
|
||||||
bool IsDetach();
|
|
||||||
|
|
||||||
/** Internal use. */
|
|
||||||
void SetDetached(bool x = true);
|
|
||||||
/** Check detached flag.
|
|
||||||
\return true if the socket runs in its own thread. */
|
|
||||||
const bool IsDetached() const;
|
|
||||||
/** Order this socket to start its own thread and call OnDetached
|
|
||||||
when ready for operation. */
|
|
||||||
bool Detach();
|
|
||||||
/** Store the slave sockethandler pointer. */
|
|
||||||
void SetSlaveHandler(ISocketHandler *);
|
|
||||||
/** Create new thread for this socket to run detached in. */
|
|
||||||
void DetachSocket();
|
|
||||||
//@}
|
|
||||||
#endif // ENABLE_DETACH
|
|
||||||
|
|
||||||
/** Write traffic to an IFile. Socket will not delete this object. */
|
|
||||||
void SetTrafficMonitor(IFile *p) { m_traffic_monitor = p; }
|
|
||||||
|
|
||||||
#ifdef ENABLE_TRIGGERS
|
|
||||||
/** \name Triggers */
|
|
||||||
//@{
|
|
||||||
/** Subscribe to trigger id. */
|
|
||||||
void Subscribe(int id);
|
|
||||||
/** Unsubscribe from trigger id. */
|
|
||||||
void Unsubscribe(int id);
|
|
||||||
/** Trigger callback, with data passed from source to destination. */
|
|
||||||
virtual void OnTrigger(int id, const TriggerData& data);
|
|
||||||
/** Trigger cancelled because source has been deleted (as in delete). */
|
|
||||||
virtual void OnCancelled(int id);
|
|
||||||
//@}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/** default constructor not available */
|
|
||||||
Socket() : m_handler(m_handler) {}
|
|
||||||
/** copy constructor not available */
|
|
||||||
Socket(const Socket& s) : m_handler(s.m_handler) {}
|
|
||||||
|
|
||||||
/** assignment operator not available. */
|
|
||||||
Socket& operator=(const Socket& ) { return *this; }
|
|
||||||
|
|
||||||
/** All traffic will be written to this IFile, if set. */
|
|
||||||
IFile *GetTrafficMonitor() { return m_traffic_monitor; }
|
|
||||||
|
|
||||||
// unsigned long m_flags; ///< boolean flags, replacing old 'bool' members
|
|
||||||
|
|
||||||
private:
|
|
||||||
ISocketHandler& m_handler; ///< Reference of ISocketHandler in control of this socket
|
|
||||||
SOCKET m_socket; ///< File descriptor
|
|
||||||
bool m_bDel; ///< Delete by handler flag
|
|
||||||
bool m_bClose; ///< Close and delete flag
|
|
||||||
time_t m_tCreate; ///< Time in seconds when this socket was created
|
|
||||||
Socket *m_parent; ///< Pointer to ListenSocket class, valid for incoming sockets
|
|
||||||
bool m_b_disable_read; ///< Disable checking for read events
|
|
||||||
bool m_connected; ///< Socket is connected (tcp/udp)
|
|
||||||
bool m_b_erased_by_handler; ///< Set by handler before delete
|
|
||||||
time_t m_tClose; ///< Time in seconds when ordered to close
|
|
||||||
std::auto_ptr<SocketAddress> m_client_remote_address; ///< Address of last connect()
|
|
||||||
std::auto_ptr<SocketAddress> m_remote_address; ///< Remote end address
|
|
||||||
IFile *m_traffic_monitor;
|
|
||||||
time_t m_timeout_start; ///< Set by SetTimeout
|
|
||||||
time_t m_timeout_limit; ///< Defined by SetTimeout
|
|
||||||
bool m_bLost; ///< connection lost
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
static WSAInitializer m_winsock_init; ///< Winsock initialization singleton class
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
bool m_b_enable_ssl; ///< Enable SSL for this TcpSocket
|
|
||||||
bool m_b_ssl; ///< ssl negotiation mode (TcpSocket)
|
|
||||||
bool m_b_ssl_server; ///< True if this is an incoming ssl TcpSocket connection
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
bool m_ipv6; ///< This is an ipv6 socket if this one is true
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_POOL
|
|
||||||
int m_socket_type; ///< Type of socket, from socket() call
|
|
||||||
std::string m_socket_protocol; ///< Protocol, from socket() call
|
|
||||||
bool m_bClient; ///< only client connections are pooled
|
|
||||||
bool m_bRetain; ///< keep connection on close
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_SOCKS4
|
|
||||||
bool m_bSocks4; ///< socks4 negotiation mode (TcpSocket)
|
|
||||||
ipaddr_t m_socks4_host; ///< socks4 server address
|
|
||||||
port_t m_socks4_port; ///< socks4 server port number
|
|
||||||
std::string m_socks4_userid; ///< socks4 server usedid
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_DETACH
|
|
||||||
bool m_detach; ///< Socket ordered to detach flag
|
|
||||||
bool m_detached; ///< Socket has been detached
|
|
||||||
SocketThread *m_pThread; ///< Detach socket thread class pointer
|
|
||||||
ISocketHandler *m_slave_handler; ///< Actual sockethandler while detached
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _SOCKETS_Socket_H
|
|
||||||
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
/**
|
|
||||||
** \file SocketAddress.h
|
|
||||||
** \date 2006-09-21
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_SocketAddress_H
|
|
||||||
#define _SOCKETS_SocketAddress_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include <string>
|
|
||||||
#include <memory>
|
|
||||||
#include "socket_include.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
This class and its subclasses is intended to be used as replacement
|
|
||||||
for the internal data type 'ipaddr_t' and various implementations of
|
|
||||||
IPv6 addressing found throughout the library.
|
|
||||||
'ipaddr_t' is an IPv4 address in network byte order.
|
|
||||||
'port_t' is the portnumber in host byte order.
|
|
||||||
'struct in6_addr' is an IPv6 address.
|
|
||||||
'struct in_addr' is an IPv4 address.
|
|
||||||
\ingroup basic
|
|
||||||
*/
|
|
||||||
class SocketAddress
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~SocketAddress() {}
|
|
||||||
|
|
||||||
/** Get a pointer to the address struct. */
|
|
||||||
virtual operator struct sockaddr *() = 0;
|
|
||||||
|
|
||||||
/** Get length of address struct. */
|
|
||||||
virtual operator socklen_t() = 0;
|
|
||||||
|
|
||||||
/** Compare two addresses. */
|
|
||||||
virtual bool operator==(SocketAddress&) = 0;
|
|
||||||
|
|
||||||
/** Set port number.
|
|
||||||
\param port Port number in host byte order */
|
|
||||||
virtual void SetPort(port_t port) = 0;
|
|
||||||
|
|
||||||
/** Get port number.
|
|
||||||
\return Port number in host byte order. */
|
|
||||||
virtual port_t GetPort() = 0;
|
|
||||||
|
|
||||||
/** Set socket address.
|
|
||||||
\param sa Pointer to either 'struct sockaddr_in' or 'struct sockaddr_in6'. */
|
|
||||||
virtual void SetAddress(struct sockaddr *sa) = 0;
|
|
||||||
|
|
||||||
/** Convert address to text. */
|
|
||||||
virtual std::string Convert(bool include_port) = 0;
|
|
||||||
|
|
||||||
/** Reverse lookup of address. */
|
|
||||||
virtual std::string Reverse() = 0;
|
|
||||||
|
|
||||||
/** Get address family. */
|
|
||||||
virtual int GetFamily() = 0;
|
|
||||||
|
|
||||||
/** Address structure is valid. */
|
|
||||||
virtual bool IsValid() = 0;
|
|
||||||
|
|
||||||
/** Get a copy of this SocketAddress object. */
|
|
||||||
virtual std::auto_ptr<SocketAddress> GetCopy() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
#endif // _SOCKETS_SocketAddress_H
|
|
||||||
|
|
||||||
|
|
@ -1,266 +0,0 @@
|
||||||
/** \file SocketHandler.h
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_SocketHandler_H
|
|
||||||
#define _SOCKETS_SocketHandler_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include <map>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include "socket_include.h"
|
|
||||||
#include "ISocketHandler.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class Socket;
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
class ResolvServer;
|
|
||||||
#endif
|
|
||||||
class Mutex;
|
|
||||||
|
|
||||||
/** Socket container class, event generator.
|
|
||||||
\ingroup basic */
|
|
||||||
class SocketHandler : public ISocketHandler
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
/** Map type for holding file descriptors/socket object pointers. */
|
|
||||||
typedef std::map<SOCKET,Socket *> socket_m;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** SocketHandler constructor.
|
|
||||||
\param log Optional log class pointer */
|
|
||||||
SocketHandler(StdLog *log = NULL);
|
|
||||||
|
|
||||||
/** SocketHandler threadsafe constructor.
|
|
||||||
\param mutex Externally declared mutex variable
|
|
||||||
\param log Optional log class pointer */
|
|
||||||
SocketHandler(Mutex& mutex,StdLog *log = NULL);
|
|
||||||
|
|
||||||
~SocketHandler();
|
|
||||||
|
|
||||||
/** Get mutex reference for threadsafe operations. */
|
|
||||||
Mutex& GetMutex() const;
|
|
||||||
|
|
||||||
/** Register StdLog object for error callback.
|
|
||||||
\param log Pointer to log class */
|
|
||||||
void RegStdLog(StdLog *log);
|
|
||||||
|
|
||||||
/** Log error to log class for print out / storage. */
|
|
||||||
void LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t = LOG_LEVEL_WARNING);
|
|
||||||
|
|
||||||
/** Add socket instance to socket map. Removal is always automatic. */
|
|
||||||
void Add(Socket *);
|
|
||||||
|
|
||||||
/** Get status of read/write/exception file descriptor set for a socket. */
|
|
||||||
void Get(SOCKET s,bool& r,bool& w,bool& e);
|
|
||||||
|
|
||||||
/** Set read/write/exception file descriptor sets (fd_set). */
|
|
||||||
void Set(SOCKET s,bool bRead,bool bWrite,bool bException = true);
|
|
||||||
|
|
||||||
/** Wait for events, generate callbacks. */
|
|
||||||
int Select(long sec,long usec);
|
|
||||||
|
|
||||||
/** This method will not return until an event has been detected. */
|
|
||||||
int Select();
|
|
||||||
|
|
||||||
/** Wait for events, generate callbacks. */
|
|
||||||
int Select(struct timeval *tsel);
|
|
||||||
|
|
||||||
/** Check that a socket really is handled by this socket handler. */
|
|
||||||
bool Valid(Socket *);
|
|
||||||
|
|
||||||
/** Return number of sockets handled by this handler. */
|
|
||||||
size_t GetCount();
|
|
||||||
|
|
||||||
/** Override and return false to deny all incoming connections.
|
|
||||||
\param p ListenSocket class pointer (use GetPort to identify which one) */
|
|
||||||
bool OkToAccept(Socket *p);
|
|
||||||
|
|
||||||
/** Called by Socket when a socket changes state. */
|
|
||||||
void AddList(SOCKET s,list_t which_one,bool add);
|
|
||||||
|
|
||||||
// Connection pool
|
|
||||||
#ifdef ENABLE_POOL
|
|
||||||
/** Find available open connection (used by connection pool). */
|
|
||||||
ISocketHandler::PoolSocket *FindConnection(int type,const std::string& protocol,SocketAddress&);
|
|
||||||
/** Enable connection pool (by default disabled). */
|
|
||||||
void EnablePool(bool x = true);
|
|
||||||
/** Check pool status.
|
|
||||||
\return true if connection pool is enabled */
|
|
||||||
bool PoolEnabled();
|
|
||||||
#endif // ENABLE_POOL
|
|
||||||
|
|
||||||
// Socks4
|
|
||||||
#ifdef ENABLE_SOCKS4
|
|
||||||
/** Set socks4 server ip that all new tcp sockets should use. */
|
|
||||||
void SetSocks4Host(ipaddr_t);
|
|
||||||
/** Set socks4 server hostname that all new tcp sockets should use. */
|
|
||||||
void SetSocks4Host(const std::string& );
|
|
||||||
/** Set socks4 server port number that all new tcp sockets should use. */
|
|
||||||
void SetSocks4Port(port_t);
|
|
||||||
/** Set optional socks4 userid. */
|
|
||||||
void SetSocks4Userid(const std::string& );
|
|
||||||
/** If connection to socks4 server fails, immediately try direct connection to final host. */
|
|
||||||
void SetSocks4TryDirect(bool x = true);
|
|
||||||
/** Get socks4 server ip.
|
|
||||||
\return socks4 server ip */
|
|
||||||
ipaddr_t GetSocks4Host();
|
|
||||||
/** Get socks4 port number.
|
|
||||||
\return socks4 port number */
|
|
||||||
port_t GetSocks4Port();
|
|
||||||
/** Get socks4 userid (optional).
|
|
||||||
\return socks4 userid */
|
|
||||||
const std::string& GetSocks4Userid();
|
|
||||||
/** Check status of socks4 try direct flag.
|
|
||||||
\return true if direct connection should be tried if connection to socks4 server fails */
|
|
||||||
bool Socks4TryDirect();
|
|
||||||
#endif // ENABLE_SOCKS4
|
|
||||||
|
|
||||||
// DNS resolve server
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
/** Enable asynchronous DNS.
|
|
||||||
\param port Listen port of asynchronous dns server */
|
|
||||||
void EnableResolver(port_t port = 16667);
|
|
||||||
/** Check resolver status.
|
|
||||||
\return true if resolver is enabled */
|
|
||||||
bool ResolverEnabled();
|
|
||||||
/** Queue a dns request.
|
|
||||||
\param host Hostname to be resolved
|
|
||||||
\param port Port number will be echoed in Socket::OnResolved callback */
|
|
||||||
int Resolve(Socket *,const std::string& host,port_t port);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
int Resolve6(Socket *,const std::string& host,port_t port);
|
|
||||||
#endif
|
|
||||||
/** Do a reverse dns lookup. */
|
|
||||||
int Resolve(Socket *,ipaddr_t a);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
int Resolve(Socket *,in6_addr& a);
|
|
||||||
#endif
|
|
||||||
/** Get listen port of asynchronous dns server. */
|
|
||||||
port_t GetResolverPort();
|
|
||||||
/** Resolver thread ready for queries. */
|
|
||||||
bool ResolverReady();
|
|
||||||
/** Returns true if the socket is waiting for a resolve event. */
|
|
||||||
bool Resolving(Socket *);
|
|
||||||
#endif // ENABLE_RESOLVER
|
|
||||||
|
|
||||||
#ifdef ENABLE_TRIGGERS
|
|
||||||
/** Fetch unique trigger id. */
|
|
||||||
int TriggerID(Socket *src);
|
|
||||||
/** Subscribe socket to trigger id. */
|
|
||||||
bool Subscribe(int id, Socket *dst);
|
|
||||||
/** Unsubscribe socket from trigger id. */
|
|
||||||
bool Unsubscribe(int id, Socket *dst);
|
|
||||||
/** Execute OnTrigger for subscribed sockets.
|
|
||||||
\param id Trigger ID
|
|
||||||
\param data Data passed from source to destination
|
|
||||||
\param erase Empty trigger id source and destination maps if 'true',
|
|
||||||
Leave them in place if 'false' - if a trigger should be called many times */
|
|
||||||
void Trigger(int id, Socket::TriggerData& data, bool erase = true);
|
|
||||||
#endif // ENABLE_TRIGGERS
|
|
||||||
|
|
||||||
#ifdef ENABLE_DETACH
|
|
||||||
/** Indicates that the handler runs under SocketThread. */
|
|
||||||
void SetSlave(bool x = true);
|
|
||||||
/** Indicates that the handler runs under SocketThread. */
|
|
||||||
bool IsSlave();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Sanity check of those accursed lists. */
|
|
||||||
void CheckSanity();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
socket_m m_sockets; ///< Active sockets map
|
|
||||||
socket_m m_add; ///< Sockets to be added to sockets map
|
|
||||||
std::list<Socket *> m_delete; ///< Sockets to be deleted (failed when Add)
|
|
||||||
|
|
||||||
protected:
|
|
||||||
StdLog *m_stdlog; ///< Registered log class, or NULL
|
|
||||||
Mutex& m_mutex; ///< Thread safety mutex
|
|
||||||
bool m_b_use_mutex; ///< Mutex correctly initialized
|
|
||||||
|
|
||||||
private:
|
|
||||||
void CheckList(socket_v&,const std::string&); ///< Used by CheckSanity
|
|
||||||
/** Remove socket from socket map, used by Socket class. */
|
|
||||||
void Remove(Socket *);
|
|
||||||
SOCKET m_maxsock; ///< Highest file descriptor + 1 in active sockets list
|
|
||||||
fd_set m_rfds; ///< file descriptor set monitored for read events
|
|
||||||
fd_set m_wfds; ///< file descriptor set monitored for write events
|
|
||||||
fd_set m_efds; ///< file descriptor set monitored for exceptions
|
|
||||||
int m_preverror; ///< debug select() error
|
|
||||||
int m_errcnt; ///< debug select() error
|
|
||||||
time_t m_tlast; ///< timeout control
|
|
||||||
|
|
||||||
// state lists
|
|
||||||
socket_v m_fds; ///< Active file descriptor list
|
|
||||||
socket_v m_fds_erase; ///< File descriptors that are to be erased from m_sockets
|
|
||||||
socket_v m_fds_callonconnect; ///< checklist CallOnConnect
|
|
||||||
#ifdef ENABLE_DETACH
|
|
||||||
socket_v m_fds_detach; ///< checklist Detach
|
|
||||||
#endif
|
|
||||||
socket_v m_fds_timeout; ///< checklist timeout
|
|
||||||
socket_v m_fds_retry; ///< checklist retry client connect
|
|
||||||
socket_v m_fds_close; ///< checklist close and delete
|
|
||||||
|
|
||||||
#ifdef ENABLE_SOCKS4
|
|
||||||
ipaddr_t m_socks4_host; ///< Socks4 server host ip
|
|
||||||
port_t m_socks4_port; ///< Socks4 server port number
|
|
||||||
std::string m_socks4_userid; ///< Socks4 userid
|
|
||||||
bool m_bTryDirect; ///< Try direct connection if socks4 server fails
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
int m_resolv_id; ///< Resolver id counter
|
|
||||||
ResolvServer *m_resolver; ///< Resolver thread pointer
|
|
||||||
port_t m_resolver_port; ///< Resolver listen port
|
|
||||||
std::map<Socket *, bool> m_resolve_q; ///< resolve queue
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_POOL
|
|
||||||
bool m_b_enable_pool; ///< Connection pool enabled if true
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_TRIGGERS
|
|
||||||
int m_next_trigger_id; ///< Unique trigger id counter
|
|
||||||
std::map<int, Socket *> m_trigger_src; ///< mapping trigger id to source socket
|
|
||||||
std::map<int, std::map<Socket *, bool> > m_trigger_dst; ///< mapping trigger id to destination sockets
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_DETACH
|
|
||||||
bool m_slave; ///< Indicates that this is a ISocketHandler run in SocketThread
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_SocketHandler_H
|
|
||||||
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
/** \file StdLog.h
|
|
||||||
** \date 2004-06-01
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_StdLog_H
|
|
||||||
#define _SOCKETS_StdLog_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** error level enum. */
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
LOG_LEVEL_WARNING = 0,
|
|
||||||
LOG_LEVEL_ERROR,
|
|
||||||
LOG_LEVEL_FATAL,
|
|
||||||
LOG_LEVEL_INFO
|
|
||||||
} loglevel_t;
|
|
||||||
|
|
||||||
|
|
||||||
class ISocketHandler;
|
|
||||||
class Socket;
|
|
||||||
|
|
||||||
/** \defgroup logging Log help classes */
|
|
||||||
/** Log class interface.
|
|
||||||
\ingroup logging */
|
|
||||||
class StdLog
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~StdLog() {}
|
|
||||||
|
|
||||||
virtual void error(ISocketHandler *,Socket *,
|
|
||||||
const std::string& user_text,
|
|
||||||
int err,
|
|
||||||
const std::string& sys_err,
|
|
||||||
loglevel_t = LOG_LEVEL_WARNING) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_StdLog_H
|
|
||||||
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
/** \file StdoutLog.h
|
|
||||||
** \date 2004-06-01
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_StdoutLog_H
|
|
||||||
#define _SOCKETS_StdoutLog_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include "StdLog.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/** StdLog implementation, logs to stdout.
|
|
||||||
\ingroup logging */
|
|
||||||
class StdoutLog : public StdLog
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void error(ISocketHandler *,Socket *,const std::string& call,int err,const std::string& sys_err,loglevel_t);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_StdoutLog_H
|
|
||||||
|
|
||||||
|
|
@ -1,127 +0,0 @@
|
||||||
#ifndef _StreamSocket_H
|
|
||||||
#define _StreamSocket_H
|
|
||||||
|
|
||||||
#include "Socket.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/** SOCK_STREAM Socket base class.
|
|
||||||
\ingroup basic */
|
|
||||||
class StreamSocket : public Socket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
StreamSocket(ISocketHandler& );
|
|
||||||
~StreamSocket();
|
|
||||||
|
|
||||||
/** Socket should Check Connect on next write event from select(). */
|
|
||||||
void SetConnecting(bool = true);
|
|
||||||
|
|
||||||
/** Check connecting flag.
|
|
||||||
\return true if the socket is still trying to connect */
|
|
||||||
bool Connecting();
|
|
||||||
|
|
||||||
/** Returns true when socket file descriptor is valid,
|
|
||||||
socket connection is established, and socket is not about to
|
|
||||||
be closed. */
|
|
||||||
bool Ready();
|
|
||||||
|
|
||||||
/** Set timeout to use for connection attempt.
|
|
||||||
\param x Timeout in seconds */
|
|
||||||
void SetConnectTimeout(int x);
|
|
||||||
|
|
||||||
/** Return number of seconds to wait for a connection.
|
|
||||||
\return Connection timeout (seconds) */
|
|
||||||
int GetConnectTimeout();
|
|
||||||
|
|
||||||
/** Set flush before close to make a tcp socket completely empty its
|
|
||||||
output buffer before closing the connection. */
|
|
||||||
void SetFlushBeforeClose(bool = true);
|
|
||||||
|
|
||||||
/** Check flush before status.
|
|
||||||
\return true if the socket should send all data before closing */
|
|
||||||
bool GetFlushBeforeClose();
|
|
||||||
|
|
||||||
/** Define number of connection retries (tcp only).
|
|
||||||
n = 0 - no retry
|
|
||||||
n > 0 - number of retries
|
|
||||||
n = -1 - unlimited retries */
|
|
||||||
void SetConnectionRetry(int n);
|
|
||||||
|
|
||||||
/** Get number of maximum connection retries (tcp only). */
|
|
||||||
int GetConnectionRetry();
|
|
||||||
|
|
||||||
/** Increase number of actual connection retries (tcp only). */
|
|
||||||
void IncreaseConnectionRetries();
|
|
||||||
|
|
||||||
/** Get number of actual connection retries (tcp only). */
|
|
||||||
int GetConnectionRetries();
|
|
||||||
|
|
||||||
/** Reset actual connection retries (tcp only). */
|
|
||||||
void ResetConnectionRetries();
|
|
||||||
|
|
||||||
// LIST_CALLONCONNECT
|
|
||||||
|
|
||||||
/** Instruct socket to call OnConnect callback next sockethandler cycle. */
|
|
||||||
void SetCallOnConnect(bool x = true);
|
|
||||||
|
|
||||||
/** Check call on connect flag.
|
|
||||||
\return true if OnConnect() should be called a.s.a.p */
|
|
||||||
bool CallOnConnect();
|
|
||||||
|
|
||||||
// LIST_RETRY
|
|
||||||
|
|
||||||
/** Set flag to initiate a connection attempt after a connection timeout. */
|
|
||||||
void SetRetryClientConnect(bool x = true);
|
|
||||||
|
|
||||||
/** Check if a connection attempt should be made.
|
|
||||||
\return true when another attempt should be made */
|
|
||||||
bool RetryClientConnect();
|
|
||||||
|
|
||||||
/** Called after OnRead if socket is in line protocol mode.
|
|
||||||
\sa SetLineProtocol */
|
|
||||||
/** Enable the OnLine callback. Do not create your own OnRead
|
|
||||||
* callback when using this. */
|
|
||||||
virtual void SetLineProtocol(bool = true);
|
|
||||||
|
|
||||||
/** Check line protocol mode.
|
|
||||||
\return true if socket is in line protocol mode */
|
|
||||||
bool LineProtocol();
|
|
||||||
|
|
||||||
/** Set shutdown status. */
|
|
||||||
void SetShutdown(int);
|
|
||||||
|
|
||||||
/** Get shutdown status. */
|
|
||||||
int GetShutdown();
|
|
||||||
|
|
||||||
/** Returns IPPROTO_TCP or IPPROTO_SCTP */
|
|
||||||
virtual int Protocol() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
StreamSocket(const StreamSocket& ) {} // copy constructor
|
|
||||||
|
|
||||||
private:
|
|
||||||
StreamSocket& operator=(const StreamSocket& ) { return *this; } // assignment operator
|
|
||||||
|
|
||||||
bool m_bConnecting; ///< Flag indicating connection in progress
|
|
||||||
int m_connect_timeout; ///< Connection timeout (seconds)
|
|
||||||
bool m_flush_before_close; ///< Send all data before closing (default true)
|
|
||||||
int m_connection_retry; ///< Maximum connection retries (tcp)
|
|
||||||
int m_retries; ///< Actual number of connection retries (tcp)
|
|
||||||
bool m_call_on_connect; ///< OnConnect will be called next ISocketHandler cycle if true
|
|
||||||
bool m_b_retry_connect; ///< Try another connection attempt next ISocketHandler cycle
|
|
||||||
bool m_line_protocol; ///< Line protocol mode flag
|
|
||||||
int m_shutdown; ///< Shutdown status
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _StreamSocket_H
|
|
||||||
|
|
||||||
|
|
@ -1,358 +0,0 @@
|
||||||
/** \file TcpSocket.h
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_TcpSocket_H
|
|
||||||
#define _SOCKETS_TcpSocket_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include "StreamSocket.h"
|
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
#include "SSLInitializer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define TCP_BUFSIZE_READ 16400
|
|
||||||
#define TCP_OUTPUT_CAPACITY 1024000
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class SocketAddress;
|
|
||||||
|
|
||||||
|
|
||||||
/** Socket implementation for TCP.
|
|
||||||
\ingroup basic */
|
|
||||||
class TcpSocket : public StreamSocket
|
|
||||||
{
|
|
||||||
/** \defgroup internal Internal utility */
|
|
||||||
protected:
|
|
||||||
/** Buffer class containing one read/write circular buffer.
|
|
||||||
\ingroup internal */
|
|
||||||
class CircularBuffer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CircularBuffer(size_t size);
|
|
||||||
~CircularBuffer();
|
|
||||||
|
|
||||||
/** append l bytes from p to buffer */
|
|
||||||
bool Write(const char *p,size_t l);
|
|
||||||
/** copy l bytes from buffer to dest */
|
|
||||||
bool Read(char *dest,size_t l);
|
|
||||||
/** copy l bytes from buffer to dest, dont touch buffer pointers */
|
|
||||||
bool SoftRead(char *dest, size_t l);
|
|
||||||
/** skip l bytes from buffer */
|
|
||||||
bool Remove(size_t l);
|
|
||||||
/** read l bytes from buffer, returns as string. */
|
|
||||||
std::string ReadString(size_t l);
|
|
||||||
|
|
||||||
/** total buffer length */
|
|
||||||
size_t GetLength();
|
|
||||||
/** pointer to circular buffer beginning */
|
|
||||||
const char *GetStart();
|
|
||||||
/** return number of bytes from circular buffer beginning to buffer physical end */
|
|
||||||
size_t GetL();
|
|
||||||
/** return free space in buffer, number of bytes until buffer overrun */
|
|
||||||
size_t Space();
|
|
||||||
|
|
||||||
/** return total number of bytes written to this buffer, ever */
|
|
||||||
unsigned long ByteCounter(bool clear = false);
|
|
||||||
|
|
||||||
private:
|
|
||||||
CircularBuffer(const CircularBuffer& /*s*/) {}
|
|
||||||
CircularBuffer& operator=(const CircularBuffer& ) { return *this; }
|
|
||||||
char *buf;
|
|
||||||
size_t m_max;
|
|
||||||
size_t m_q;
|
|
||||||
size_t m_b;
|
|
||||||
size_t m_t;
|
|
||||||
unsigned long m_count;
|
|
||||||
};
|
|
||||||
/** Output buffer struct.
|
|
||||||
\ingroup internal */
|
|
||||||
struct OUTPUT {
|
|
||||||
OUTPUT() : _b(0), _t(0), _q(0) {}
|
|
||||||
OUTPUT(const char *buf, size_t len) : _b(0), _t(len), _q(len) {
|
|
||||||
memcpy(_buf, buf, len);
|
|
||||||
}
|
|
||||||
size_t Space() {
|
|
||||||
return TCP_OUTPUT_CAPACITY - _t;
|
|
||||||
}
|
|
||||||
void Add(const char *buf, size_t len) {
|
|
||||||
memcpy(_buf + _t, buf, len);
|
|
||||||
_t += len;
|
|
||||||
_q += len;
|
|
||||||
}
|
|
||||||
size_t Remove(size_t len) {
|
|
||||||
_b += len;
|
|
||||||
_q -= len;
|
|
||||||
return _q;
|
|
||||||
}
|
|
||||||
const char *Buf() {
|
|
||||||
return _buf + _b;
|
|
||||||
}
|
|
||||||
size_t Len() {
|
|
||||||
return _q;
|
|
||||||
}
|
|
||||||
size_t _b;
|
|
||||||
size_t _t;
|
|
||||||
size_t _q;
|
|
||||||
char _buf[TCP_OUTPUT_CAPACITY];
|
|
||||||
};
|
|
||||||
typedef std::list<OUTPUT *> output_l;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** Constructor with standard values on input/output buffers. */
|
|
||||||
TcpSocket(ISocketHandler& );
|
|
||||||
/** Constructor with custom values for i/o buffer.
|
|
||||||
\param h ISocketHandler reference
|
|
||||||
\param isize Input buffer size
|
|
||||||
\param osize Output buffer size */
|
|
||||||
TcpSocket(ISocketHandler& h,size_t isize,size_t osize);
|
|
||||||
~TcpSocket();
|
|
||||||
|
|
||||||
/** Open a connection to a remote server.
|
|
||||||
If you want your socket to connect to a server,
|
|
||||||
always call Open before Add'ing a socket to the sockethandler.
|
|
||||||
If not, the connection attempt will not be monitored by the
|
|
||||||
socket handler...
|
|
||||||
\param ip IP address
|
|
||||||
\param port Port number
|
|
||||||
\param skip_socks Do not use socks4 even if configured */
|
|
||||||
bool Open(ipaddr_t ip,port_t port,bool skip_socks = false);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Open connection.
|
|
||||||
\param ip Ipv6 address
|
|
||||||
\param port Port number
|
|
||||||
\param skip_socks Do not use socks4 even if configured */
|
|
||||||
bool Open(in6_addr ip,port_t port,bool skip_socks = false);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
bool Open(SocketAddress&,bool skip_socks = false);
|
|
||||||
bool Open(SocketAddress&,SocketAddress& bind_address,bool skip_socks = false);
|
|
||||||
/** Open connection.
|
|
||||||
\param host Hostname
|
|
||||||
\param port Port number */
|
|
||||||
bool Open(const std::string &host,port_t port);
|
|
||||||
|
|
||||||
/** Connect timeout callback. */
|
|
||||||
void OnConnectTimeout();
|
|
||||||
#ifdef _WIN32
|
|
||||||
/** Connection failed reported as exception on win32 */
|
|
||||||
void OnException();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Close file descriptor - internal use only.
|
|
||||||
\sa SetCloseAndDelete */
|
|
||||||
int Close();
|
|
||||||
|
|
||||||
/** Send a string.
|
|
||||||
\param s String to send
|
|
||||||
\param f Dummy flags -- not used */
|
|
||||||
void Send(const std::string &s,int f = 0);
|
|
||||||
/** Send string using printf formatting. */
|
|
||||||
void Sendf(const char *format, ...);
|
|
||||||
/** Send buffer of bytes.
|
|
||||||
\param buf Buffer pointer
|
|
||||||
\param len Length of data
|
|
||||||
\param f Dummy flags -- not used */
|
|
||||||
void SendBuf(const char *buf,size_t len,int f = 0);
|
|
||||||
/** This callback is executed after a successful read from the socket.
|
|
||||||
\param buf Pointer to the data
|
|
||||||
\param len Length of the data */
|
|
||||||
virtual void OnRawData(const char *buf,size_t len);
|
|
||||||
|
|
||||||
/** Called when output buffer has been sent.
|
|
||||||
Note: Will only be called IF the output buffer has been used.
|
|
||||||
Send's that was successful without needing the output buffer
|
|
||||||
will not generate a call to this method. */
|
|
||||||
virtual void OnWriteComplete();
|
|
||||||
/** Number of bytes in input buffer. */
|
|
||||||
size_t GetInputLength();
|
|
||||||
/** Number of bytes in output buffer. */
|
|
||||||
size_t GetOutputLength();
|
|
||||||
|
|
||||||
/** Callback fires when a socket in line protocol has read one full line.
|
|
||||||
\param line Line read */
|
|
||||||
void OnLine(const std::string& line);
|
|
||||||
/** Get counter of number of bytes received. */
|
|
||||||
uint64_t GetBytesReceived(bool clear = false);
|
|
||||||
/** Get counter of number of bytes sent. */
|
|
||||||
uint64_t GetBytesSent(bool clear = false);
|
|
||||||
|
|
||||||
/** Socks4 specific callback. */
|
|
||||||
void OnSocks4Connect();
|
|
||||||
/** Socks4 specific callback. */
|
|
||||||
void OnSocks4ConnectFailed();
|
|
||||||
/** Socks4 specific callback.
|
|
||||||
\return 'need_more' */
|
|
||||||
bool OnSocks4Read();
|
|
||||||
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
/** Callback executed when resolver thread has finished a resolve request. */
|
|
||||||
void OnResolved(int id,ipaddr_t a,port_t port);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
void OnResolved(int id,in6_addr& a,port_t port);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
/** Callback for 'New' ssl support - replaces SSLSocket. Internal use. */
|
|
||||||
void OnSSLConnect();
|
|
||||||
/** Callback for 'New' ssl support - replaces SSLSocket. Internal use. */
|
|
||||||
void OnSSLAccept();
|
|
||||||
/** This method must be implemented to initialize
|
|
||||||
the ssl context for an outgoing connection. */
|
|
||||||
virtual void InitSSLClient();
|
|
||||||
/** This method must be implemented to initialize
|
|
||||||
the ssl context for an incoming connection. */
|
|
||||||
virtual void InitSSLServer();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_RECONNECT
|
|
||||||
/** Flag that says a broken connection will try to reconnect. */
|
|
||||||
void SetReconnect(bool = true);
|
|
||||||
/** Check reconnect on lost connection flag status. */
|
|
||||||
bool Reconnect();
|
|
||||||
/** Flag to determine if a reconnect is in progress. */
|
|
||||||
void SetIsReconnect(bool x = true);
|
|
||||||
/** Socket is reconnecting. */
|
|
||||||
bool IsReconnect();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void DisableInputBuffer(bool = true);
|
|
||||||
|
|
||||||
void OnOptions(int,int,int,SOCKET);
|
|
||||||
|
|
||||||
void SetLineProtocol(bool = true);
|
|
||||||
|
|
||||||
// TCP options
|
|
||||||
bool SetTcpNodelay(bool = true);
|
|
||||||
|
|
||||||
virtual int Protocol();
|
|
||||||
|
|
||||||
/** Trigger limit for callback OnTransferLimit. */
|
|
||||||
void SetTransferLimit(size_t sz);
|
|
||||||
/** This callback fires when the output buffer drops below the value
|
|
||||||
set by SetTransferLimit. Default: 0 (disabled). */
|
|
||||||
virtual void OnTransferLimit();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TcpSocket(const TcpSocket& );
|
|
||||||
void OnRead();
|
|
||||||
void OnRead( char *buf, size_t n );
|
|
||||||
void OnWrite();
|
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
/** SSL; Initialize ssl context for a client socket.
|
|
||||||
\param meth_in SSL method */
|
|
||||||
void InitializeContext(const std::string& context, SSL_METHOD *meth_in = NULL);
|
|
||||||
/** SSL; Initialize ssl context for a server socket.
|
|
||||||
\param keyfile Combined private key/certificate file
|
|
||||||
\param password Password for private key
|
|
||||||
\param meth_in SSL method */
|
|
||||||
void InitializeContext(const std::string& context, const std::string& keyfile, const std::string& password, SSL_METHOD *meth_in = NULL);
|
|
||||||
/** SSL; Initialize ssl context for a server socket.
|
|
||||||
\param certfile Separate certificate file
|
|
||||||
\param keyfile Combined private key/certificate file
|
|
||||||
\param password Password for private key
|
|
||||||
\param meth_in SSL method */
|
|
||||||
void InitializeContext(const std::string& context, const std::string& certfile, const std::string& keyfile, const std::string& password, SSL_METHOD *meth_in = NULL);
|
|
||||||
/** SSL; Password callback method. */
|
|
||||||
static int SSL_password_cb(char *buf,int num,int rwflag,void *userdata);
|
|
||||||
/** SSL; Get pointer to ssl context structure. */
|
|
||||||
virtual SSL_CTX *GetSslContext();
|
|
||||||
/** SSL; Get pointer to ssl structure. */
|
|
||||||
virtual SSL *GetSsl();
|
|
||||||
/** ssl; still negotiating connection. */
|
|
||||||
bool SSLNegotiate();
|
|
||||||
/** SSL; Get ssl password. */
|
|
||||||
const std::string& GetPassword();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CircularBuffer ibuf; ///< Circular input buffer
|
|
||||||
|
|
||||||
private:
|
|
||||||
TcpSocket& operator=(const TcpSocket& ) { return *this; }
|
|
||||||
|
|
||||||
/** the actual send() */
|
|
||||||
int TryWrite(const char *buf, size_t len);
|
|
||||||
/** add data to output buffer top */
|
|
||||||
void Buffer(const char *buf, size_t len);
|
|
||||||
|
|
||||||
//
|
|
||||||
bool m_b_input_buffer_disabled;
|
|
||||||
uint64_t m_bytes_sent;
|
|
||||||
uint64_t m_bytes_received;
|
|
||||||
bool m_skip_c; ///< Skip second char of CRLF or LFCR sequence in OnRead
|
|
||||||
char m_c; ///< First char in CRLF or LFCR sequence
|
|
||||||
std::string m_line; ///< Current line in line protocol mode
|
|
||||||
#ifdef SOCKETS_DYNAMIC_TEMP
|
|
||||||
char *m_buf; ///< temporary read buffer
|
|
||||||
#endif
|
|
||||||
output_l m_obuf; ///< output buffer
|
|
||||||
OUTPUT *m_obuf_top; ///< output buffer on top
|
|
||||||
size_t m_transfer_limit;
|
|
||||||
size_t m_output_length;
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
static SSLInitializer m_ssl_init;
|
|
||||||
SSL_CTX *m_ssl_ctx; ///< ssl context
|
|
||||||
SSL *m_ssl; ///< ssl 'socket'
|
|
||||||
BIO *m_sbio; ///< ssl bio
|
|
||||||
std::string m_password; ///< ssl password
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_SOCKS4
|
|
||||||
int m_socks4_state; ///< socks4 support
|
|
||||||
char m_socks4_vn; ///< socks4 support, temporary variable
|
|
||||||
char m_socks4_cd; ///< socks4 support, temporary variable
|
|
||||||
unsigned short m_socks4_dstport; ///< socks4 support
|
|
||||||
unsigned long m_socks4_dstip; ///< socks4 support
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
int m_resolver_id; ///< Resolver id (if any) for current Open call
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_RECONNECT
|
|
||||||
bool m_b_reconnect; ///< Reconnect on lost connection flag
|
|
||||||
bool m_b_is_reconnect; ///< Trying to reconnect
|
|
||||||
#endif
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_TcpSocket_H
|
|
||||||
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
/** \file Thread.h
|
|
||||||
** \date 2004-10-30
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_Thread_H
|
|
||||||
#define _SOCKETS_Thread_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
// to be
|
|
||||||
//typedef DWORD threadfunc_t;
|
|
||||||
//typedef LPVOID threadparam_t;
|
|
||||||
//#define STDPREFIX WINAPI
|
|
||||||
typedef unsigned threadfunc_t;
|
|
||||||
typedef void * threadparam_t;
|
|
||||||
#define STDPREFIX __stdcall
|
|
||||||
#else
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
typedef void * threadfunc_t;
|
|
||||||
typedef void * threadparam_t;
|
|
||||||
#define STDPREFIX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** \defgroup threading Threading */
|
|
||||||
/** Thread base class.
|
|
||||||
The Thread class is used by the resolver (ResolvServer) and running a detached socket (SocketThread).
|
|
||||||
When you know some processing will take a long time and will freeze up a socket, there is always the
|
|
||||||
possibility to call Detach() on that socket before starting the processing.
|
|
||||||
When the OnDetached() callback is later called the processing can continue, now in its own thread.
|
|
||||||
\ingroup threading */
|
|
||||||
class Thread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Thread(bool release = true);
|
|
||||||
virtual ~Thread();
|
|
||||||
|
|
||||||
static threadfunc_t STDPREFIX StartThread(threadparam_t);
|
|
||||||
|
|
||||||
virtual void Run() = 0;
|
|
||||||
|
|
||||||
bool IsRunning();
|
|
||||||
void SetRunning(bool x);
|
|
||||||
bool IsReleased();
|
|
||||||
void SetRelease(bool x);
|
|
||||||
bool DeleteOnExit();
|
|
||||||
void SetDeleteOnExit(bool x = true);
|
|
||||||
bool IsDestructor();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Thread(const Thread& ) {}
|
|
||||||
Thread& operator=(const Thread& ) { return *this; }
|
|
||||||
#ifdef _WIN32
|
|
||||||
HANDLE m_thread;
|
|
||||||
unsigned m_dwThreadId;
|
|
||||||
#else
|
|
||||||
pthread_t m_thread;
|
|
||||||
#endif
|
|
||||||
bool m_running;
|
|
||||||
bool m_release;
|
|
||||||
bool m_b_delete_on_exit;
|
|
||||||
bool m_b_destructor;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_Thread_H
|
|
||||||
|
|
||||||
|
|
@ -1,215 +0,0 @@
|
||||||
/** \file UdpSocket.h
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_UdpSocket_H
|
|
||||||
#define _SOCKETS_UdpSocket_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include "Socket.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Socket implementation for UDP.
|
|
||||||
\ingroup basic */
|
|
||||||
class UdpSocket : public Socket
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** Constructor.
|
|
||||||
\param h ISocketHandler reference
|
|
||||||
\param ibufsz Maximum size of receive message (extra bytes will be truncated)
|
|
||||||
\param ipv6 'true' if this is an ipv6 socket */
|
|
||||||
UdpSocket(ISocketHandler& h,int ibufsz = 16384,bool ipv6 = false, int retries = 0);
|
|
||||||
~UdpSocket();
|
|
||||||
|
|
||||||
/** Called when incoming data has been received.
|
|
||||||
\param buf Pointer to data
|
|
||||||
\param len Length of data
|
|
||||||
\param sa Pointer to sockaddr struct of sender
|
|
||||||
\param sa_len Length of sockaddr struct */
|
|
||||||
virtual void OnRawData(const char *buf,size_t len,struct sockaddr *sa,socklen_t sa_len);
|
|
||||||
|
|
||||||
/** Called when incoming data has been received and read timestamp is enabled.
|
|
||||||
\param buf Pointer to data
|
|
||||||
\param len Length of data
|
|
||||||
\param sa Pointer to sockaddr struct of sender
|
|
||||||
\param sa_len Length of sockaddr struct
|
|
||||||
\param ts Timestamp from message */
|
|
||||||
virtual void OnRawData(const char *buf,size_t len,struct sockaddr *sa,socklen_t sa_len,struct timeval *ts);
|
|
||||||
|
|
||||||
/** To receive incoming data, call Bind to setup an incoming port.
|
|
||||||
\param port Incoming port number
|
|
||||||
\param range Port range to try if ports already in use
|
|
||||||
\return 0 if bind succeeded */
|
|
||||||
int Bind(port_t& port,int range = 1);
|
|
||||||
/** To receive data on a specific interface:port, use this.
|
|
||||||
\param intf Interface ip/hostname
|
|
||||||
\param port Port number
|
|
||||||
\param range Port range
|
|
||||||
\return 0 if bind succeeded */
|
|
||||||
int Bind(const std::string& intf,port_t& port,int range = 1);
|
|
||||||
/** To receive data on a specific interface:port, use this.
|
|
||||||
\param a Ip address
|
|
||||||
\param port Port number
|
|
||||||
\param range Port range
|
|
||||||
\return 0 if bind succeeded */
|
|
||||||
int Bind(ipaddr_t a,port_t& port,int range = 1);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** To receive data on a specific interface:port, use this.
|
|
||||||
\param a Ipv6 address
|
|
||||||
\param port Port number
|
|
||||||
\param range Port range
|
|
||||||
\return 0 if bind succeeded */
|
|
||||||
int Bind(in6_addr a,port_t& port,int range = 1);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** To receive data on a specific interface:port, use this.
|
|
||||||
\param ad Socket address
|
|
||||||
\param range Port range
|
|
||||||
\return 0 if bind succeeded */
|
|
||||||
int Bind(SocketAddress& ad,int range = 1);
|
|
||||||
|
|
||||||
/** Define remote host.
|
|
||||||
\param l Address of remote host
|
|
||||||
\param port Port of remote host
|
|
||||||
\return true if successful */
|
|
||||||
bool Open(ipaddr_t l,port_t port);
|
|
||||||
/** Define remote host.
|
|
||||||
\param host Hostname
|
|
||||||
\param port Port number
|
|
||||||
\return true if successful */
|
|
||||||
bool Open(const std::string& host,port_t port);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Define remote host.
|
|
||||||
\param a Address of remote host, ipv6
|
|
||||||
\param port Port of remote host
|
|
||||||
\return true if successful */
|
|
||||||
bool Open(struct in6_addr& a,port_t port);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** Define remote host.
|
|
||||||
\param ad Socket address
|
|
||||||
\return true if successful */
|
|
||||||
bool Open(SocketAddress& ad);
|
|
||||||
|
|
||||||
/** Send to specified host */
|
|
||||||
void SendToBuf(const std::string& ,port_t,const char *data,int len,int flags = 0);
|
|
||||||
/** Send to specified address */
|
|
||||||
void SendToBuf(ipaddr_t,port_t,const char *data,int len,int flags = 0);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Send to specified ipv6 address */
|
|
||||||
void SendToBuf(in6_addr,port_t,const char *data,int len,int flags = 0);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** Send to specified socket address */
|
|
||||||
void SendToBuf(SocketAddress& ad,const char *data,int len,int flags = 0);
|
|
||||||
|
|
||||||
/** Send string to specified host */
|
|
||||||
void SendTo(const std::string&,port_t,const std::string&,int flags = 0);
|
|
||||||
/** Send string to specified address */
|
|
||||||
void SendTo(ipaddr_t,port_t,const std::string&,int flags = 0);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Send string to specified ipv6 address */
|
|
||||||
void SendTo(in6_addr,port_t,const std::string&,int flags = 0);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** Send string to specified socket address */
|
|
||||||
void SendTo(SocketAddress& ad,const std::string&,int flags = 0);
|
|
||||||
|
|
||||||
/** Send to connected address */
|
|
||||||
void SendBuf(const char *data,size_t,int flags = 0);
|
|
||||||
/** Send string to connected address. */
|
|
||||||
void Send(const std::string& ,int flags = 0);
|
|
||||||
|
|
||||||
/** Set broadcast */
|
|
||||||
void SetBroadcast(bool b = true);
|
|
||||||
/** Check broadcast flag.
|
|
||||||
\return true broadcast is enabled. */
|
|
||||||
bool IsBroadcast();
|
|
||||||
|
|
||||||
/** multicast */
|
|
||||||
void SetMulticastTTL(int ttl = 1);
|
|
||||||
int GetMulticastTTL();
|
|
||||||
void SetMulticastLoop(bool = true);
|
|
||||||
bool IsMulticastLoop();
|
|
||||||
void AddMulticastMembership(const std::string& group,const std::string& intf = "0.0.0.0",int if_index = 0);
|
|
||||||
void DropMulticastMembership(const std::string& group,const std::string& intf = "0.0.0.0",int if_index = 0);
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** multicast, ipv6 only */
|
|
||||||
void SetMulticastHops(int = -1);
|
|
||||||
/** multicast, ipv6 only */
|
|
||||||
int GetMulticastHops();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** Returns true if Bind succeeded. */
|
|
||||||
bool IsBound();
|
|
||||||
/** Return Bind port number */
|
|
||||||
port_t GetPort();
|
|
||||||
|
|
||||||
void OnOptions(int,int,int,SOCKET) {}
|
|
||||||
|
|
||||||
int GetLastSizeWritten();
|
|
||||||
|
|
||||||
/** Also read timestamp information from incoming message */
|
|
||||||
void SetTimestamp(bool = true);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
UdpSocket(const UdpSocket& s) : Socket(s) {}
|
|
||||||
void OnRead();
|
|
||||||
#if defined(LINUX) || defined(MACOSX)
|
|
||||||
/** This method emulates socket recvfrom, but uses messages so we can get the timestamp */
|
|
||||||
int ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen_t fromlen, struct timeval *ts);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
UdpSocket& operator=(const UdpSocket& ) { return *this; }
|
|
||||||
/** create before using sendto methods */
|
|
||||||
void CreateConnection();
|
|
||||||
char *m_ibuf; ///< Input buffer
|
|
||||||
int m_ibufsz; ///< Size of input buffer
|
|
||||||
bool m_bind_ok; ///< Bind completed successfully
|
|
||||||
port_t m_port; ///< Bind port number
|
|
||||||
int m_last_size_written;
|
|
||||||
int m_retries;
|
|
||||||
bool m_b_read_ts;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_UdpSocket_H
|
|
||||||
|
|
||||||
|
|
@ -1,186 +0,0 @@
|
||||||
/** \file Utility.h
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_Utility_H
|
|
||||||
#define _SOCKETS_Utility_H
|
|
||||||
|
|
||||||
#include "sockets-config.h"
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <memory>
|
|
||||||
#include "socket_include.h"
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TWIST_LEN 624
|
|
||||||
|
|
||||||
class SocketAddress;
|
|
||||||
|
|
||||||
/** Conversion utilities.
|
|
||||||
\ingroup util */
|
|
||||||
class Utility
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
The Mersenne Twister
|
|
||||||
http://www.math.keio.ac.jp/~matumoto/emt.html
|
|
||||||
*/
|
|
||||||
class Rng {
|
|
||||||
public:
|
|
||||||
Rng(unsigned long seed);
|
|
||||||
|
|
||||||
unsigned long Get();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_value;
|
|
||||||
unsigned long m_tmp[TWIST_LEN];
|
|
||||||
};
|
|
||||||
class ncmap_compare {
|
|
||||||
public:
|
|
||||||
bool operator()(const std::string& x, const std::string& y) const {
|
|
||||||
return strcasecmp(x.c_str(), y.c_str()) < 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
template<typename Y> class ncmap : public std::map<std::string, Y, ncmap_compare> {
|
|
||||||
public:
|
|
||||||
ncmap() {}
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
static std::string base64(const std::string& str_in);
|
|
||||||
static std::string base64d(const std::string& str_in);
|
|
||||||
static std::string l2string(long l);
|
|
||||||
static std::string bigint2string(uint64_t l);
|
|
||||||
static uint64_t atoi64(const std::string& str);
|
|
||||||
static unsigned int hex2unsigned(const std::string& str);
|
|
||||||
static std::string rfc1738_encode(const std::string& src);
|
|
||||||
static std::string rfc1738_decode(const std::string& src);
|
|
||||||
|
|
||||||
/** Checks whether a string is a valid ipv4/ipv6 ip number. */
|
|
||||||
static bool isipv4(const std::string&);
|
|
||||||
/** Checks whether a string is a valid ipv4/ipv6 ip number. */
|
|
||||||
static bool isipv6(const std::string&);
|
|
||||||
|
|
||||||
/** Hostname to ip resolution ipv4, not asynchronous. */
|
|
||||||
static bool u2ip(const std::string&, ipaddr_t&);
|
|
||||||
static bool u2ip(const std::string&, struct sockaddr_in& sa, int ai_flags = 0);
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Hostname to ip resolution ipv6, not asynchronous. */
|
|
||||||
static bool u2ip(const std::string&, struct in6_addr&);
|
|
||||||
static bool u2ip(const std::string&, struct sockaddr_in6& sa, int ai_flags = 0);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Reverse lookup of address to hostname */
|
|
||||||
static bool reverse(struct sockaddr *sa, socklen_t sa_len, std::string&, int flags = 0);
|
|
||||||
static bool reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, std::string& service, int flags = 0);
|
|
||||||
|
|
||||||
static bool u2service(const std::string& name, int& service, int ai_flags = 0);
|
|
||||||
|
|
||||||
/** Convert binary ip address to string: ipv4. */
|
|
||||||
static void l2ip(const ipaddr_t,std::string& );
|
|
||||||
static void l2ip(const in_addr&,std::string& );
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Convert binary ip address to string: ipv6. */
|
|
||||||
static void l2ip(const struct in6_addr&,std::string& ,bool mixed = false);
|
|
||||||
|
|
||||||
/** ipv6 address compare. */
|
|
||||||
static int in6_addr_compare(in6_addr,in6_addr);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** ResolveLocal (hostname) - call once before calling any GetLocal method. */
|
|
||||||
static void ResolveLocal();
|
|
||||||
/** Returns local hostname, ResolveLocal must be called once before using.
|
|
||||||
\sa ResolveLocal */
|
|
||||||
static const std::string& GetLocalHostname();
|
|
||||||
/** Returns local ip, ResolveLocal must be called once before using.
|
|
||||||
\sa ResolveLocal */
|
|
||||||
static ipaddr_t GetLocalIP();
|
|
||||||
/** Returns local ip number as string.
|
|
||||||
\sa ResolveLocal */
|
|
||||||
static const std::string& GetLocalAddress();
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
/** Returns local ipv6 ip.
|
|
||||||
\sa ResolveLocal */
|
|
||||||
static const struct in6_addr& GetLocalIP6();
|
|
||||||
/** Returns local ipv6 address.
|
|
||||||
\sa ResolveLocal */
|
|
||||||
static const std::string& GetLocalAddress6();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/** Set environment variable.
|
|
||||||
\param var Name of variable to set
|
|
||||||
\param value Value */
|
|
||||||
static void SetEnv(const std::string& var,const std::string& value);
|
|
||||||
/** Convert sockaddr struct to human readable string.
|
|
||||||
\param sa Ptr to sockaddr struct */
|
|
||||||
static std::string Sa2String(struct sockaddr *sa);
|
|
||||||
|
|
||||||
/** Get current time in sec/microseconds. */
|
|
||||||
static void GetTime(struct timeval *);
|
|
||||||
|
|
||||||
static std::auto_ptr<SocketAddress> CreateAddress(struct sockaddr *,socklen_t);
|
|
||||||
|
|
||||||
static unsigned long ThreadID();
|
|
||||||
|
|
||||||
static std::string ToLower(const std::string& str);
|
|
||||||
static std::string ToUpper(const std::string& str);
|
|
||||||
|
|
||||||
static std::string ToString(double d);
|
|
||||||
|
|
||||||
/** Returns a random 32-bit integer */
|
|
||||||
static unsigned long Rnd();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static std::string m_host; ///< local hostname
|
|
||||||
static ipaddr_t m_ip; ///< local ip address
|
|
||||||
static std::string m_addr; ///< local ip address in string format
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
static struct in6_addr m_local_ip6; ///< local ipv6 address
|
|
||||||
#endif
|
|
||||||
static std::string m_local_addr6; ///< local ipv6 address in string format
|
|
||||||
#endif
|
|
||||||
static bool m_local_resolved; ///< ResolveLocal has been called if true
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // _SOCKETS_Utility_H
|
|
||||||
|
|
||||||
|
|
@ -1,306 +0,0 @@
|
||||||
/** \file socket_include.h
|
|
||||||
** \date 2005-04-12
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_socket_include_H
|
|
||||||
#define _SOCKETS_socket_include_H
|
|
||||||
#include "sockets-config.h"
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4514)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// common defines affecting library and applications using library
|
|
||||||
|
|
||||||
/* Define SOCKETS_DYNAMIC_TEMP to use dynamically allocated buffers
|
|
||||||
in read operations - helps on ECOS */
|
|
||||||
#define SOCKETS_DYNAMIC_TEMP
|
|
||||||
|
|
||||||
|
|
||||||
// platform specific stuff
|
|
||||||
#if (defined(__unix__) || defined(unix)) && !defined(USG)
|
|
||||||
#include <sys/param.h>
|
|
||||||
#endif
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
// int64
|
|
||||||
#ifdef _WIN32
|
|
||||||
typedef unsigned __int64 uint64_t;
|
|
||||||
#else
|
|
||||||
#include <stdlib.h>
|
|
||||||
#ifdef SOLARIS
|
|
||||||
# include <sys/types.h>
|
|
||||||
#else
|
|
||||||
# include <stdint.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
// ----------------------------------------
|
|
||||||
// common unix includes / defines
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
//#include <netdb.h>
|
|
||||||
|
|
||||||
// all typedefs in this file will be declared outside the sockets namespace,
|
|
||||||
// because some os's will already have one or more of the type defined.
|
|
||||||
typedef int SOCKET;
|
|
||||||
#define Errno errno
|
|
||||||
#define StrError strerror
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// WIN32 adapt
|
|
||||||
#define closesocket close
|
|
||||||
#define INVALID_SOCKET -1
|
|
||||||
#define SOCKET_ERROR -1
|
|
||||||
|
|
||||||
#ifndef INADDR_NONE
|
|
||||||
#define INADDR_NONE ((unsigned long) -1)
|
|
||||||
#endif // INADDR_NONE
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // !_WIN32
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------
|
|
||||||
// Generic
|
|
||||||
#ifndef SOL_IP
|
|
||||||
#define SOL_IP IPPROTO_IP
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------
|
|
||||||
// OS specific adaptions
|
|
||||||
|
|
||||||
#ifdef SOLARIS
|
|
||||||
// ----------------------------------------
|
|
||||||
// Solaris
|
|
||||||
typedef unsigned short port_t;
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
// no defs
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define s6_addr16 _S6_un._S6_u8
|
|
||||||
#define MSG_NOSIGNAL 0
|
|
||||||
|
|
||||||
#elif defined __FreeBSD__
|
|
||||||
// ----------------------------------------
|
|
||||||
// FreeBSD
|
|
||||||
# if __FreeBSD_version >= 400014
|
|
||||||
# define s6_addr16 __u6_addr.__u6_addr16
|
|
||||||
# if !defined(MSG_NOSIGNAL)
|
|
||||||
# define MSG_NOSIGNAL 0
|
|
||||||
# endif
|
|
||||||
# include <netinet/in.h>
|
|
||||||
typedef in_addr_t ipaddr_t;
|
|
||||||
typedef in_port_t port_t;
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
// no defs
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
|
|
||||||
# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
|
|
||||||
# else
|
|
||||||
# error FreeBSD versions prior to 400014 does not support ipv6
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#elif defined (__NetBSD__) || defined (__OpenBSD__)
|
|
||||||
# if !defined(MSG_NOSIGNAL)
|
|
||||||
# define MSG_NOSIGNAL 0
|
|
||||||
# endif
|
|
||||||
# include <netinet/in.h>
|
|
||||||
typedef in_addr_t ipaddr_t;
|
|
||||||
typedef in_port_t port_t;
|
|
||||||
#elif defined MACOSX
|
|
||||||
// ----------------------------------------
|
|
||||||
// Mac OS X
|
|
||||||
#include <string.h>
|
|
||||||
#ifdef __DARWIN_UNIX03
|
|
||||||
typedef unsigned short port_t;
|
|
||||||
#else
|
|
||||||
#include <mach/port.h>
|
|
||||||
#endif // __DARWIN_UNIX03
|
|
||||||
typedef unsigned long ipaddr_t;
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
// no defs
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define s6_addr16 __u6_addr.__u6_addr16
|
|
||||||
#define MSG_NOSIGNAL 0 // oops - thanks Derek
|
|
||||||
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
|
|
||||||
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
|
|
||||||
|
|
||||||
#elif defined _WIN32
|
|
||||||
// ----------------------------------------
|
|
||||||
// Win32
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma comment(lib, "wsock32.lib")
|
|
||||||
#endif
|
|
||||||
#define strcasecmp _stricmp
|
|
||||||
|
|
||||||
typedef unsigned long ipaddr_t;
|
|
||||||
typedef unsigned short port_t;
|
|
||||||
typedef int socklen_t;
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
// no defs
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 1.8.6: define FD_SETSIZE to something bigger than 64 if there are a lot of
|
|
||||||
// simultaneous connections (must be done before including winsock.h)
|
|
||||||
#ifndef FD_SETSIZE
|
|
||||||
#define FD_SETSIZE 1024
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// windows 2000 with ipv6 preview installed:
|
|
||||||
// http://msdn.microsoft.com/downloads/sdks/platform/tpipv6.asp
|
|
||||||
// see the FAQ on how to install
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#if _MSC_VER < 1200
|
|
||||||
#ifndef __CYGWIN__
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#include <tpipv6.h> // For IPv6 Tech Preview.
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif // _MSC_VER < 1200
|
|
||||||
|
|
||||||
|
|
||||||
#define MSG_NOSIGNAL 0
|
|
||||||
//#define SHUT_RDWR 2
|
|
||||||
#define SHUT_WR 1
|
|
||||||
|
|
||||||
#define Errno WSAGetLastError()
|
|
||||||
const char *StrError(int x);
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// class WSAInitializer is a part of the Socket class (on win32)
|
|
||||||
// as a static instance - so whenever an application uses a Socket,
|
|
||||||
// winsock is initialized
|
|
||||||
class WSAInitializer // Winsock Initializer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WSAInitializer() {
|
|
||||||
if (WSAStartup(0x101,&m_wsadata))
|
|
||||||
{
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~WSAInitializer() {
|
|
||||||
WSACleanup();
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
WSADATA m_wsadata;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(sun) || defined(__sun__)
|
|
||||||
|
|
||||||
#define MSG_NOSIGNAL 0
|
|
||||||
typedef unsigned short port_t;
|
|
||||||
|
|
||||||
#else
|
|
||||||
// ----------------------------------------
|
|
||||||
// LINUX
|
|
||||||
typedef unsigned long ipaddr_t;
|
|
||||||
typedef unsigned short port_t;
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
// no defs
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
/** List type containing file descriptors. */
|
|
||||||
typedef std::list<SOCKET> socket_v;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// getaddrinfo / getnameinfo replacements
|
|
||||||
#ifdef NO_GETADDRINFO
|
|
||||||
#ifndef AI_NUMERICHOST
|
|
||||||
#define AI_NUMERICHOST 1
|
|
||||||
#endif
|
|
||||||
#ifndef NI_NUMERICHOST
|
|
||||||
#define NI_NUMERICHOST 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _SOCKETS_socket_include_H
|
|
||||||
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
/**
|
|
||||||
** \file sockets-config.h
|
|
||||||
** \date 2007-04-14
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifndef _SOCKETS_CONFIG_H
|
|
||||||
#define _SOCKETS_CONFIG_H
|
|
||||||
|
|
||||||
#ifndef _RUN_DP
|
|
||||||
/* First undefine symbols if already defined. */
|
|
||||||
#undef HAVE_OPENSSL
|
|
||||||
#undef ENABLE_IPV6
|
|
||||||
#undef USE_SCTP
|
|
||||||
#undef NO_GETADDRINFO
|
|
||||||
#undef ENABLE_POOL
|
|
||||||
#undef ENABLE_SOCKS4
|
|
||||||
#undef ENABLE_RESOLVER
|
|
||||||
#undef ENABLE_RECONNECT
|
|
||||||
#undef ENABLE_DETACH
|
|
||||||
#undef ENABLE_TRIGGERS
|
|
||||||
#undef ENABLE_EXCEPTIONS
|
|
||||||
#endif // _RUN_DP
|
|
||||||
|
|
||||||
// define MACOSX for internal socket library checks
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__) && !defined(MACOSX)
|
|
||||||
#define MACOSX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* OpenSSL support. */
|
|
||||||
//#define HAVE_OPENSSL
|
|
||||||
|
|
||||||
|
|
||||||
/* Ipv6 support. */
|
|
||||||
//#define ENABLE_IPV6
|
|
||||||
|
|
||||||
|
|
||||||
/* SCTP support. */
|
|
||||||
//#define USE_SCTP
|
|
||||||
|
|
||||||
|
|
||||||
/* Define NO_GETADDRINFO if your operating system does not support
|
|
||||||
the "getaddrinfo" and "getnameinfo" function calls. */
|
|
||||||
#define NO_GETADDRINFO
|
|
||||||
|
|
||||||
|
|
||||||
/* Connection pool support. */
|
|
||||||
#define ENABLE_POOL
|
|
||||||
|
|
||||||
|
|
||||||
/* Socks4 client support. */
|
|
||||||
//#define ENABLE_SOCKS4
|
|
||||||
|
|
||||||
|
|
||||||
/* Asynchronous resolver. */
|
|
||||||
#define ENABLE_RESOLVER
|
|
||||||
|
|
||||||
|
|
||||||
/* Enable TCP reconnect on lost connection.
|
|
||||||
Socket::OnReconnect
|
|
||||||
Socket::OnDisconnect
|
|
||||||
*/
|
|
||||||
#define ENABLE_RECONNECT
|
|
||||||
|
|
||||||
|
|
||||||
/* Enable socket thread detach functionality. */
|
|
||||||
#define ENABLE_DETACH
|
|
||||||
|
|
||||||
|
|
||||||
/* Enable socket to socket triggers. Not yet in use. */
|
|
||||||
//#define ENABLE_TRIGGERS
|
|
||||||
|
|
||||||
|
|
||||||
/* Enabled exceptions. */
|
|
||||||
//#define ENABLE_EXCEPTIONS
|
|
||||||
|
|
||||||
|
|
||||||
/* Resolver uses the detach function so either enable both or disable both. */
|
|
||||||
#ifndef ENABLE_DETACH
|
|
||||||
#undef ENABLE_RESOLVER
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _SOCKETS_CONFIG_H
|
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
## Sub-directories to parse
|
## Sub-directories to parse
|
||||||
SUBDIRS = g3dlite sockets gsoap zlib
|
SUBDIRS = g3dlite gsoap zlib
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
# Nothing yet.
|
# Nothing yet.
|
||||||
|
|
|
||||||
|
|
@ -1,272 +0,0 @@
|
||||||
/** \file Base64.cpp
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include "Base64.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
const char *Base64::bstr =
|
|
||||||
"ABCDEFGHIJKLMNOPQ"
|
|
||||||
"RSTUVWXYZabcdefgh"
|
|
||||||
"ijklmnopqrstuvwxy"
|
|
||||||
"z0123456789+/";
|
|
||||||
|
|
||||||
const char Base64::rstr[] = {
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63,
|
|
||||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
|
||||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
|
|
||||||
0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
|
||||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
|
|
||||||
Base64::Base64()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Base64::encode(FILE *fil, std::string& output, bool add_crlf)
|
|
||||||
{
|
|
||||||
size_t remain;
|
|
||||||
size_t i = 0;
|
|
||||||
size_t o = 0;
|
|
||||||
char input[4];
|
|
||||||
|
|
||||||
output = "";
|
|
||||||
remain = fread(input,1,3,fil);
|
|
||||||
while (remain > 0)
|
|
||||||
{
|
|
||||||
if (add_crlf && o && o % 76 == 0)
|
|
||||||
output += "\n";
|
|
||||||
switch (remain)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
|
||||||
output += "==";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
|
||||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
|
||||||
output += "=";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
|
||||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
|
||||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
|
||||||
}
|
|
||||||
o += 4;
|
|
||||||
//
|
|
||||||
remain = fread(input,1,3,fil);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Base64::encode(const std::string& str_in, std::string& str_out, bool add_crlf)
|
|
||||||
{
|
|
||||||
encode(str_in.c_str(), str_in.size(), str_out, add_crlf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Base64::encode(const char* input,size_t l,std::string& output, bool add_crlf)
|
|
||||||
{
|
|
||||||
size_t i = 0;
|
|
||||||
size_t o = 0;
|
|
||||||
|
|
||||||
output = "";
|
|
||||||
while (i < l)
|
|
||||||
{
|
|
||||||
size_t remain = l - i;
|
|
||||||
if (add_crlf && o && o % 76 == 0)
|
|
||||||
output += "\n";
|
|
||||||
switch (remain)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
|
||||||
output += "==";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
|
||||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
|
||||||
output += "=";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
|
||||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
|
||||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
|
||||||
}
|
|
||||||
o += 4;
|
|
||||||
i += 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Base64::encode(const unsigned char* input,size_t l,std::string& output,bool add_crlf)
|
|
||||||
{
|
|
||||||
size_t i = 0;
|
|
||||||
size_t o = 0;
|
|
||||||
|
|
||||||
output = "";
|
|
||||||
while (i < l)
|
|
||||||
{
|
|
||||||
size_t remain = l - i;
|
|
||||||
if (add_crlf && o && o % 76 == 0)
|
|
||||||
output += "\n";
|
|
||||||
switch (remain)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
|
||||||
output += "==";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
|
||||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
|
||||||
output += "=";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
|
||||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
|
||||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
|
||||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
|
||||||
}
|
|
||||||
o += 4;
|
|
||||||
i += 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Base64::decode(const std::string& input,std::string& output)
|
|
||||||
{
|
|
||||||
size_t i = 0;
|
|
||||||
size_t l = input.size();
|
|
||||||
|
|
||||||
output = "";
|
|
||||||
while (i < l)
|
|
||||||
{
|
|
||||||
while (i < l && (input[i] == 13 || input[i] == 10))
|
|
||||||
i++;
|
|
||||||
if (i < l)
|
|
||||||
{
|
|
||||||
char b1 = (char)((rstr[(int)input[i]] << 2 & 0xfc) +
|
|
||||||
(rstr[(int)input[i + 1]] >> 4 & 0x03));
|
|
||||||
output += b1;
|
|
||||||
if (input[i + 2] != '=')
|
|
||||||
{
|
|
||||||
char b2 = (char)((rstr[(int)input[i + 1]] << 4 & 0xf0) +
|
|
||||||
(rstr[(int)input[i + 2]] >> 2 & 0x0f));
|
|
||||||
output += b2;
|
|
||||||
}
|
|
||||||
if (input[i + 3] != '=')
|
|
||||||
{
|
|
||||||
char b3 = (char)((rstr[(int)input[i + 2]] << 6 & 0xc0) +
|
|
||||||
rstr[(int)input[i + 3]]);
|
|
||||||
output += b3;
|
|
||||||
}
|
|
||||||
i += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Base64::decode(const std::string& input, unsigned char *output, size_t& sz)
|
|
||||||
{
|
|
||||||
size_t i = 0;
|
|
||||||
size_t l = input.size();
|
|
||||||
size_t j = 0;
|
|
||||||
|
|
||||||
while (i < l)
|
|
||||||
{
|
|
||||||
while (i < l && (input[i] == 13 || input[i] == 10))
|
|
||||||
i++;
|
|
||||||
if (i < l)
|
|
||||||
{
|
|
||||||
unsigned char b1 = (unsigned char)((rstr[(int)input[i]] << 2 & 0xfc) +
|
|
||||||
(rstr[(int)input[i + 1]] >> 4 & 0x03));
|
|
||||||
if (output)
|
|
||||||
{
|
|
||||||
output[j] = b1;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
if (input[i + 2] != '=')
|
|
||||||
{
|
|
||||||
unsigned char b2 = (unsigned char)((rstr[(int)input[i + 1]] << 4 & 0xf0) +
|
|
||||||
(rstr[(int)input[i + 2]] >> 2 & 0x0f));
|
|
||||||
if (output)
|
|
||||||
{
|
|
||||||
output[j] = b2;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
if (input[i + 3] != '=')
|
|
||||||
{
|
|
||||||
unsigned char b3 = (unsigned char)((rstr[(int)input[i + 2]] << 6 & 0xc0) +
|
|
||||||
rstr[(int)input[i + 3]]);
|
|
||||||
if (output)
|
|
||||||
{
|
|
||||||
output[j] = b3;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
i += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sz = j;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
size_t Base64::decode_length(const std::string& str64)
|
|
||||||
{
|
|
||||||
if (str64.empty() || str64.size() % 4)
|
|
||||||
return 0;
|
|
||||||
size_t l = 3 * (str64.size() / 4 - 1) + 1;
|
|
||||||
if (str64[str64.size() - 2] != '=')
|
|
||||||
l++;
|
|
||||||
if (str64[str64.size() - 1] != '=')
|
|
||||||
l++;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
** \file Exception.cpp
|
|
||||||
** \date 2007-09-28
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4786)
|
|
||||||
#endif
|
|
||||||
#include "Exception.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Exception::Exception(const std::string& description) : m_description(description)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const std::string Exception::ToString() const
|
|
||||||
{
|
|
||||||
return m_description;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,214 +0,0 @@
|
||||||
/**
|
|
||||||
** \file Ipv4Address.cpp
|
|
||||||
** \date 2006-09-21
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include "Ipv4Address.h"
|
|
||||||
#include "Utility.h"
|
|
||||||
#include "Parse.h"
|
|
||||||
#ifndef _WIN32
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ipv4Address::Ipv4Address(port_t port) : m_valid(true)
|
|
||||||
{
|
|
||||||
memset(&m_addr, 0, sizeof(m_addr));
|
|
||||||
m_addr.sin_family = AF_INET;
|
|
||||||
m_addr.sin_port = htons( port );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv4Address::Ipv4Address(ipaddr_t a,port_t port) : m_valid(true)
|
|
||||||
{
|
|
||||||
memset(&m_addr, 0, sizeof(m_addr));
|
|
||||||
m_addr.sin_family = AF_INET;
|
|
||||||
m_addr.sin_port = htons( port );
|
|
||||||
memcpy(&m_addr.sin_addr, &a, sizeof(struct in_addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv4Address::Ipv4Address(struct in_addr& a,port_t port) : m_valid(true)
|
|
||||||
{
|
|
||||||
memset(&m_addr, 0, sizeof(m_addr));
|
|
||||||
m_addr.sin_family = AF_INET;
|
|
||||||
m_addr.sin_port = htons( port );
|
|
||||||
m_addr.sin_addr = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv4Address::Ipv4Address(const std::string& host,port_t port) : m_valid(false)
|
|
||||||
{
|
|
||||||
memset(&m_addr, 0, sizeof(m_addr));
|
|
||||||
m_addr.sin_family = AF_INET;
|
|
||||||
m_addr.sin_port = htons( port );
|
|
||||||
{
|
|
||||||
ipaddr_t a;
|
|
||||||
if (Utility::u2ip(host, a))
|
|
||||||
{
|
|
||||||
memcpy(&m_addr.sin_addr, &a, sizeof(struct in_addr));
|
|
||||||
m_valid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv4Address::Ipv4Address(struct sockaddr_in& sa)
|
|
||||||
{
|
|
||||||
m_addr = sa;
|
|
||||||
m_valid = sa.sin_family == AF_INET;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv4Address::~Ipv4Address()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv4Address::operator struct sockaddr *()
|
|
||||||
{
|
|
||||||
return (struct sockaddr *)&m_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv4Address::operator socklen_t()
|
|
||||||
{
|
|
||||||
return sizeof(struct sockaddr_in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Ipv4Address::SetPort(port_t port)
|
|
||||||
{
|
|
||||||
m_addr.sin_port = htons( port );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
port_t Ipv4Address::GetPort()
|
|
||||||
{
|
|
||||||
return ntohs( m_addr.sin_port );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Ipv4Address::Resolve(const std::string& hostname,struct in_addr& a)
|
|
||||||
{
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
memset(&a, 0, sizeof(a));
|
|
||||||
if (Utility::isipv4(hostname))
|
|
||||||
{
|
|
||||||
if (!Utility::u2ip(hostname, sa, AI_NUMERICHOST))
|
|
||||||
return false;
|
|
||||||
a = sa.sin_addr;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!Utility::u2ip(hostname, sa))
|
|
||||||
return false;
|
|
||||||
a = sa.sin_addr;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Ipv4Address::Reverse(struct in_addr& a,std::string& name)
|
|
||||||
{
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin_family = AF_INET;
|
|
||||||
sa.sin_addr = a;
|
|
||||||
return Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Ipv4Address::Convert(bool include_port)
|
|
||||||
{
|
|
||||||
if (include_port)
|
|
||||||
return Convert(m_addr.sin_addr) + ":" + Utility::l2string(GetPort());
|
|
||||||
return Convert(m_addr.sin_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Ipv4Address::Convert(struct in_addr& a)
|
|
||||||
{
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin_family = AF_INET;
|
|
||||||
sa.sin_addr = a;
|
|
||||||
std::string name;
|
|
||||||
Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name, NI_NUMERICHOST);
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Ipv4Address::SetAddress(struct sockaddr *sa)
|
|
||||||
{
|
|
||||||
memcpy(&m_addr, sa, sizeof(struct sockaddr_in));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int Ipv4Address::GetFamily()
|
|
||||||
{
|
|
||||||
return m_addr.sin_family;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Ipv4Address::IsValid()
|
|
||||||
{
|
|
||||||
return m_valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Ipv4Address::operator==(SocketAddress& a)
|
|
||||||
{
|
|
||||||
if (a.GetFamily() != GetFamily())
|
|
||||||
return false;
|
|
||||||
if ((socklen_t)a != sizeof(m_addr))
|
|
||||||
return false;
|
|
||||||
struct sockaddr *sa = a;
|
|
||||||
struct sockaddr_in *p = (struct sockaddr_in *)sa;
|
|
||||||
if (p -> sin_port != m_addr.sin_port)
|
|
||||||
return false;
|
|
||||||
if (memcmp(&p -> sin_addr, &m_addr.sin_addr, 4))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::auto_ptr<SocketAddress> Ipv4Address::GetCopy()
|
|
||||||
{
|
|
||||||
return std::auto_ptr<SocketAddress>(new Ipv4Address(m_addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Ipv4Address::Reverse()
|
|
||||||
{
|
|
||||||
std::string tmp;
|
|
||||||
Reverse(m_addr.sin_addr, tmp);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,270 +0,0 @@
|
||||||
/**
|
|
||||||
** \file Ipv6Address.cpp
|
|
||||||
** \date 2006-09-21
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include "Ipv6Address.h"
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
|
|
||||||
#include "Utility.h"
|
|
||||||
#include "Parse.h"
|
|
||||||
#ifndef _WIN32
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
Ipv6Address::Ipv6Address(port_t port) : m_valid(true)
|
|
||||||
{
|
|
||||||
memset(&m_addr, 0, sizeof(m_addr));
|
|
||||||
m_addr.sin6_family = AF_INET6;
|
|
||||||
m_addr.sin6_port = htons( port );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv6Address::Ipv6Address(struct in6_addr& a,port_t port) : m_valid(true)
|
|
||||||
{
|
|
||||||
memset(&m_addr, 0, sizeof(m_addr));
|
|
||||||
m_addr.sin6_family = AF_INET6;
|
|
||||||
m_addr.sin6_port = htons( port );
|
|
||||||
m_addr.sin6_addr = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv6Address::Ipv6Address(const std::string& host,port_t port) : m_valid(false)
|
|
||||||
{
|
|
||||||
memset(&m_addr, 0, sizeof(m_addr));
|
|
||||||
m_addr.sin6_family = AF_INET6;
|
|
||||||
m_addr.sin6_port = htons( port );
|
|
||||||
{
|
|
||||||
struct in6_addr a;
|
|
||||||
if (Utility::u2ip(host, a))
|
|
||||||
{
|
|
||||||
m_addr.sin6_addr = a;
|
|
||||||
m_valid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv6Address::Ipv6Address(struct sockaddr_in6& sa)
|
|
||||||
{
|
|
||||||
m_addr = sa;
|
|
||||||
m_valid = sa.sin6_family == AF_INET6;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv6Address::~Ipv6Address()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv6Address::operator struct sockaddr *()
|
|
||||||
{
|
|
||||||
return (struct sockaddr *)&m_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Ipv6Address::operator socklen_t()
|
|
||||||
{
|
|
||||||
return sizeof(struct sockaddr_in6);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Ipv6Address::SetPort(port_t port)
|
|
||||||
{
|
|
||||||
m_addr.sin6_port = htons( port );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
port_t Ipv6Address::GetPort()
|
|
||||||
{
|
|
||||||
return ntohs( m_addr.sin6_port );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Ipv6Address::Resolve(const std::string& hostname,struct in6_addr& a)
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 sa;
|
|
||||||
memset(&a, 0, sizeof(a));
|
|
||||||
if (Utility::isipv6(hostname))
|
|
||||||
{
|
|
||||||
if (!Utility::u2ip(hostname, sa, AI_NUMERICHOST))
|
|
||||||
return false;
|
|
||||||
a = sa.sin6_addr;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!Utility::u2ip(hostname, sa))
|
|
||||||
return false;
|
|
||||||
a = sa.sin6_addr;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Ipv6Address::Reverse(struct in6_addr& a,std::string& name)
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 sa;
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin6_family = AF_INET6;
|
|
||||||
sa.sin6_addr = a;
|
|
||||||
return Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Ipv6Address::Convert(bool include_port)
|
|
||||||
{
|
|
||||||
if (include_port)
|
|
||||||
return Convert(m_addr.sin6_addr) + ":" + Utility::l2string(GetPort());
|
|
||||||
return Convert(m_addr.sin6_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Ipv6Address::Convert(struct in6_addr& a,bool mixed)
|
|
||||||
{
|
|
||||||
char slask[100]; // l2ip temporary
|
|
||||||
*slask = 0;
|
|
||||||
unsigned int prev = 0;
|
|
||||||
bool skipped = false;
|
|
||||||
bool ok_to_skip = true;
|
|
||||||
if (mixed)
|
|
||||||
{
|
|
||||||
unsigned short x;
|
|
||||||
unsigned short addr16[8];
|
|
||||||
memcpy(addr16, &a, sizeof(addr16));
|
|
||||||
for (size_t i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
x = ntohs(addr16[i]);
|
|
||||||
if (*slask && (x || !ok_to_skip || prev))
|
|
||||||
strcat(slask,":");
|
|
||||||
if (x || !ok_to_skip)
|
|
||||||
{
|
|
||||||
sprintf(slask + strlen(slask),"%x", x);
|
|
||||||
if (x && skipped)
|
|
||||||
ok_to_skip = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
skipped = true;
|
|
||||||
}
|
|
||||||
prev = x;
|
|
||||||
}
|
|
||||||
x = ntohs(addr16[6]);
|
|
||||||
sprintf(slask + strlen(slask),":%u.%u",x / 256,x & 255);
|
|
||||||
x = ntohs(addr16[7]);
|
|
||||||
sprintf(slask + strlen(slask),".%u.%u",x / 256,x & 255);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 sa;
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin6_family = AF_INET6;
|
|
||||||
sa.sin6_addr = a;
|
|
||||||
std::string name;
|
|
||||||
Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name, NI_NUMERICHOST);
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
return slask;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Ipv6Address::SetAddress(struct sockaddr *sa)
|
|
||||||
{
|
|
||||||
memcpy(&m_addr, sa, sizeof(struct sockaddr_in6));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int Ipv6Address::GetFamily()
|
|
||||||
{
|
|
||||||
return m_addr.sin6_family;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Ipv6Address::SetFlowinfo(uint32_t x)
|
|
||||||
{
|
|
||||||
m_addr.sin6_flowinfo = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t Ipv6Address::GetFlowinfo()
|
|
||||||
{
|
|
||||||
return m_addr.sin6_flowinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
void Ipv6Address::SetScopeId(uint32_t x)
|
|
||||||
{
|
|
||||||
m_addr.sin6_scope_id = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t Ipv6Address::GetScopeId()
|
|
||||||
{
|
|
||||||
return m_addr.sin6_scope_id;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
bool Ipv6Address::IsValid()
|
|
||||||
{
|
|
||||||
return m_valid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Ipv6Address::operator==(SocketAddress& a)
|
|
||||||
{
|
|
||||||
if (a.GetFamily() != GetFamily())
|
|
||||||
return false;
|
|
||||||
if ((socklen_t)a != sizeof(m_addr))
|
|
||||||
return false;
|
|
||||||
struct sockaddr *sa = a;
|
|
||||||
struct sockaddr_in6 *p = (struct sockaddr_in6 *)sa;
|
|
||||||
if (p -> sin6_port != m_addr.sin6_port)
|
|
||||||
return false;
|
|
||||||
if (memcmp(&p -> sin6_addr, &m_addr.sin6_addr, sizeof(struct in6_addr)))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::auto_ptr<SocketAddress> Ipv6Address::GetCopy()
|
|
||||||
{
|
|
||||||
return std::auto_ptr<SocketAddress>(new Ipv6Address(m_addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Ipv6Address::Reverse()
|
|
||||||
{
|
|
||||||
std::string tmp;
|
|
||||||
Reverse(m_addr.sin6_addr, tmp);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
#endif // IPPROTO_IPV6
|
|
||||||
#endif // ENABLE_IPV6
|
|
||||||
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
/** \file Lock.cpp
|
|
||||||
** \date 2005-08-22
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2005,2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include "Mutex.h"
|
|
||||||
#include "Lock.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
Lock::Lock(Mutex& m) : m_mutex(m)
|
|
||||||
{
|
|
||||||
m_mutex.Lock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Lock::~Lock()
|
|
||||||
{
|
|
||||||
m_mutex.Unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
# Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program; if not, write to the Free Software
|
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
## Process this file with automake to produce Makefile.in
|
|
||||||
|
|
||||||
## Sub-directories to parse
|
|
||||||
|
|
||||||
## CPP flags for includes, defines, etc.
|
|
||||||
AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../../include/sockets
|
|
||||||
|
|
||||||
## Build MaNGOS shared library and its parts as convenience library.
|
|
||||||
# All libraries will be convenience libraries. Might be changed to shared
|
|
||||||
# later.
|
|
||||||
noinst_LIBRARIES = libmangossockets.a
|
|
||||||
|
|
||||||
libmangossockets_a_SOURCES = \
|
|
||||||
Base64.cpp \
|
|
||||||
Exception.cpp \
|
|
||||||
Ipv4Address.cpp \
|
|
||||||
Ipv6Address.cpp \
|
|
||||||
Lock.cpp \
|
|
||||||
Mutex.cpp \
|
|
||||||
Parse.cpp \
|
|
||||||
ResolvServer.cpp \
|
|
||||||
ResolvSocket.cpp \
|
|
||||||
Socket.cpp \
|
|
||||||
SocketHandler.cpp \
|
|
||||||
StdoutLog.cpp \
|
|
||||||
StreamSocket.cpp \
|
|
||||||
TcpSocket.cpp \
|
|
||||||
Thread.cpp \
|
|
||||||
UdpSocket.cpp \
|
|
||||||
Utility.cpp \
|
|
||||||
socket_include.cpp
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
/** \file Mutex.cpp
|
|
||||||
** \date 2004-10-30
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include "Mutex.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
Mutex::Mutex()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
m_mutex = ::CreateMutex(NULL, FALSE, NULL);
|
|
||||||
#else
|
|
||||||
pthread_mutex_init(&m_mutex, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Mutex::~Mutex()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
::CloseHandle(m_mutex);
|
|
||||||
#else
|
|
||||||
pthread_mutex_destroy(&m_mutex);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Mutex::Lock()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
/*DWORD d =*/ WaitForSingleObject(m_mutex, INFINITE);
|
|
||||||
/// \todo check 'd' for result
|
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&m_mutex);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Mutex::Unlock()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
::ReleaseMutex(m_mutex);
|
|
||||||
#else
|
|
||||||
pthread_mutex_unlock(&m_mutex);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,321 +0,0 @@
|
||||||
/** \file Parse.cpp - parse a string
|
|
||||||
**
|
|
||||||
** Written: 1999-Feb-10 grymse@alhem.net
|
|
||||||
**/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Copyright (C) 1999-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "Parse.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* implementation of class Parse */
|
|
||||||
|
|
||||||
Parse::Parse()
|
|
||||||
:pa_the_str("")
|
|
||||||
,pa_splits("")
|
|
||||||
,pa_ord("")
|
|
||||||
,pa_the_ptr(0)
|
|
||||||
,pa_breakchar(0)
|
|
||||||
,pa_enable(0)
|
|
||||||
,pa_disable(0)
|
|
||||||
,pa_nospace(0)
|
|
||||||
,pa_quote(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Parse::Parse(const std::string&s)
|
|
||||||
:pa_the_str(s)
|
|
||||||
,pa_splits("")
|
|
||||||
,pa_ord("")
|
|
||||||
,pa_the_ptr(0)
|
|
||||||
,pa_breakchar(0)
|
|
||||||
,pa_enable(0)
|
|
||||||
,pa_disable(0)
|
|
||||||
,pa_nospace(0)
|
|
||||||
,pa_quote(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Parse::Parse(const std::string&s,const std::string&sp)
|
|
||||||
:pa_the_str(s)
|
|
||||||
,pa_splits(sp)
|
|
||||||
,pa_ord("")
|
|
||||||
,pa_the_ptr(0)
|
|
||||||
,pa_breakchar(0)
|
|
||||||
,pa_enable(0)
|
|
||||||
,pa_disable(0)
|
|
||||||
,pa_nospace(0)
|
|
||||||
,pa_quote(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Parse::Parse(const std::string&s,const std::string&sp,short /*nospace*/)
|
|
||||||
:pa_the_str(s)
|
|
||||||
,pa_splits(sp)
|
|
||||||
,pa_ord("")
|
|
||||||
,pa_the_ptr(0)
|
|
||||||
,pa_breakchar(0)
|
|
||||||
,pa_enable(0)
|
|
||||||
,pa_disable(0)
|
|
||||||
,pa_nospace(1)
|
|
||||||
,pa_quote(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Parse::~Parse()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#define C ((pa_the_ptr<pa_the_str.size()) ? pa_the_str[pa_the_ptr] : 0)
|
|
||||||
|
|
||||||
short Parse::issplit(const char c)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < pa_splits.size(); i++)
|
|
||||||
if (pa_splits[i] == c)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parse::getsplit()
|
|
||||||
{
|
|
||||||
size_t x;
|
|
||||||
|
|
||||||
if (C == '=')
|
|
||||||
{
|
|
||||||
x = pa_the_ptr++;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
while (C && (issplit(C)))
|
|
||||||
pa_the_ptr++;
|
|
||||||
x = pa_the_ptr;
|
|
||||||
while (C && !issplit(C) && C != '=')
|
|
||||||
pa_the_ptr++;
|
|
||||||
}
|
|
||||||
if (x == pa_the_ptr && C == '=')
|
|
||||||
pa_the_ptr++;
|
|
||||||
pa_ord = (x < pa_the_str.size()) ? pa_the_str.substr(x,pa_the_ptr - x) : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Parse::getword()
|
|
||||||
{
|
|
||||||
size_t x;
|
|
||||||
int disabled = 0;
|
|
||||||
int quote = 0;
|
|
||||||
int rem = 0;
|
|
||||||
|
|
||||||
if (pa_nospace)
|
|
||||||
{
|
|
||||||
while (C && issplit(C))
|
|
||||||
pa_the_ptr++;
|
|
||||||
x = pa_the_ptr;
|
|
||||||
while (C && !issplit(C) && (C != pa_breakchar || !pa_breakchar || disabled))
|
|
||||||
{
|
|
||||||
if (pa_breakchar && C == pa_disable)
|
|
||||||
disabled = 1;
|
|
||||||
if (pa_breakchar && C == pa_enable)
|
|
||||||
disabled = 0;
|
|
||||||
if (pa_quote && C == '"')
|
|
||||||
quote = 1;
|
|
||||||
pa_the_ptr++;
|
|
||||||
while (quote && C && C != '"')
|
|
||||||
{
|
|
||||||
pa_the_ptr++;
|
|
||||||
}
|
|
||||||
if (pa_quote && C == '"')
|
|
||||||
{
|
|
||||||
pa_the_ptr++;
|
|
||||||
}
|
|
||||||
quote = 0;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
if (C == pa_breakchar && pa_breakchar)
|
|
||||||
{
|
|
||||||
x = pa_the_ptr++;
|
|
||||||
rem = 1;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C)))
|
|
||||||
pa_the_ptr++;
|
|
||||||
x = pa_the_ptr;
|
|
||||||
while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) &&
|
|
||||||
(C != pa_breakchar || !pa_breakchar || disabled))
|
|
||||||
{
|
|
||||||
if (pa_breakchar && C == pa_disable)
|
|
||||||
disabled = 1;
|
|
||||||
if (pa_breakchar && C == pa_enable)
|
|
||||||
disabled = 0;
|
|
||||||
if (pa_quote && C == '"')
|
|
||||||
{
|
|
||||||
quote = 1;
|
|
||||||
pa_the_ptr++;
|
|
||||||
while (quote && C && C != '"')
|
|
||||||
{
|
|
||||||
pa_the_ptr++;
|
|
||||||
}
|
|
||||||
if (pa_quote && C == '"')
|
|
||||||
{
|
|
||||||
pa_the_ptr++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pa_the_ptr++;
|
|
||||||
quote = 0;
|
|
||||||
}
|
|
||||||
pa_the_ptr++;
|
|
||||||
rem = 1;
|
|
||||||
}
|
|
||||||
if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar)
|
|
||||||
pa_the_ptr++;
|
|
||||||
}
|
|
||||||
if (x < pa_the_str.size())
|
|
||||||
{
|
|
||||||
pa_ord = pa_the_str.substr(x,pa_the_ptr - x - rem);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pa_ord = "";
|
|
||||||
}
|
|
||||||
return pa_ord;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parse::getword(std::string&s)
|
|
||||||
{
|
|
||||||
s = Parse::getword();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parse::getsplit(std::string&s)
|
|
||||||
{
|
|
||||||
Parse::getsplit();
|
|
||||||
s = pa_ord;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parse::getword(std::string&s,std::string&fill,int l)
|
|
||||||
{
|
|
||||||
Parse::getword();
|
|
||||||
s = "";
|
|
||||||
while (s.size() + pa_ord.size() < (size_t)l)
|
|
||||||
s += fill;
|
|
||||||
s += pa_ord;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Parse::getrest()
|
|
||||||
{
|
|
||||||
std::string s;
|
|
||||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
|
||||||
pa_the_ptr++;
|
|
||||||
s = (pa_the_ptr < pa_the_str.size()) ? pa_the_str.substr(pa_the_ptr) : "";
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parse::getrest(std::string&s)
|
|
||||||
{
|
|
||||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
|
||||||
pa_the_ptr++;
|
|
||||||
s = (pa_the_ptr < pa_the_str.size()) ? pa_the_str.substr(pa_the_ptr) : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
long Parse::getvalue()
|
|
||||||
{
|
|
||||||
Parse::getword();
|
|
||||||
return atol(pa_ord.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parse::setbreak(const char c)
|
|
||||||
{
|
|
||||||
pa_breakchar = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Parse::getwordlen()
|
|
||||||
{
|
|
||||||
size_t x,y = pa_the_ptr,len;
|
|
||||||
|
|
||||||
if (C == pa_breakchar && pa_breakchar)
|
|
||||||
{
|
|
||||||
x = pa_the_ptr++;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C)))
|
|
||||||
pa_the_ptr++;
|
|
||||||
x = pa_the_ptr;
|
|
||||||
while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) && (C != pa_breakchar || !pa_breakchar))
|
|
||||||
pa_the_ptr++;
|
|
||||||
}
|
|
||||||
if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar)
|
|
||||||
pa_the_ptr++;
|
|
||||||
len = pa_the_ptr - x;
|
|
||||||
pa_the_ptr = y;
|
|
||||||
return (int)len;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Parse::getrestlen()
|
|
||||||
{
|
|
||||||
size_t y = pa_the_ptr;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
|
||||||
pa_the_ptr++;
|
|
||||||
len = strlen(pa_the_str.c_str() + pa_the_ptr);
|
|
||||||
pa_the_ptr = y;
|
|
||||||
return (int)len;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parse::getline()
|
|
||||||
{
|
|
||||||
size_t x;
|
|
||||||
|
|
||||||
x = pa_the_ptr;
|
|
||||||
while (C && C != 13 && C != 10)
|
|
||||||
pa_the_ptr++;
|
|
||||||
pa_ord = (x < pa_the_str.size()) ? pa_the_str.substr(x,pa_the_ptr - x) : "";
|
|
||||||
if (C == 13)
|
|
||||||
pa_the_ptr++;
|
|
||||||
if (C == 10)
|
|
||||||
pa_the_ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Parse::getline(std::string&s)
|
|
||||||
{
|
|
||||||
getline();
|
|
||||||
s = pa_ord;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* end of implementation of class Parse */
|
|
||||||
/***************************************************/
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
||||||
/** \file ResolvServer.cpp
|
|
||||||
** \date 2005-03-24
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4786)
|
|
||||||
#endif
|
|
||||||
#include "ResolvServer.h"
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
#include "StdoutLog.h"
|
|
||||||
#include "ListenSocket.h"
|
|
||||||
#include "ResolvSocket.h"
|
|
||||||
#include "SocketHandler.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
ResolvServer::ResolvServer(port_t port)
|
|
||||||
:Thread()
|
|
||||||
,m_quit(false)
|
|
||||||
,m_port(port)
|
|
||||||
,m_ready(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ResolvServer::~ResolvServer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ResolvServer::Run()
|
|
||||||
{
|
|
||||||
// StdoutLog log;
|
|
||||||
SocketHandler h;
|
|
||||||
ListenSocket<ResolvSocket> l(h);
|
|
||||||
|
|
||||||
if (l.Bind("127.0.0.1", m_port))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
h.Add(&l);
|
|
||||||
|
|
||||||
m_ready = true;
|
|
||||||
while (!m_quit && IsRunning() )
|
|
||||||
{
|
|
||||||
h.Select(0, 500000);
|
|
||||||
}
|
|
||||||
SetRunning(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ResolvServer::Quit()
|
|
||||||
{
|
|
||||||
m_quit = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool ResolvServer::Ready()
|
|
||||||
{
|
|
||||||
return m_ready;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // ENABLE_RESOLVER
|
|
||||||
|
|
||||||
|
|
@ -1,436 +0,0 @@
|
||||||
/** \file ResolvSocket.cpp
|
|
||||||
** \date 2005-03-24
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifdef _WIN32
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4786)
|
|
||||||
#pragma warning(disable:4503)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#include <netdb.h>
|
|
||||||
#endif
|
|
||||||
#include "ResolvSocket.h"
|
|
||||||
#ifdef ENABLE_RESOLVER
|
|
||||||
#include "Utility.h"
|
|
||||||
#include "Parse.h"
|
|
||||||
#include "ISocketHandler.h"
|
|
||||||
#include "Lock.h"
|
|
||||||
#include "Mutex.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#ifdef _DEBUG
|
|
||||||
//#define DEB(x) x
|
|
||||||
//#else
|
|
||||||
#define DEB(x)
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
|
|
||||||
// static
|
|
||||||
ResolvSocket::cache_t ResolvSocket::m_cache;
|
|
||||||
ResolvSocket::timeout_t ResolvSocket::m_cache_to;
|
|
||||||
Mutex ResolvSocket::m_cache_mutex;
|
|
||||||
|
|
||||||
|
|
||||||
ResolvSocket::ResolvSocket(ISocketHandler& h)
|
|
||||||
:TcpSocket(h)
|
|
||||||
,m_bServer(false)
|
|
||||||
,m_parent(NULL)
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
,m_resolve_ipv6(false)
|
|
||||||
#endif
|
|
||||||
,m_cached(false)
|
|
||||||
{
|
|
||||||
SetLineProtocol();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, const std::string& host, port_t port, bool ipv6)
|
|
||||||
:TcpSocket(h)
|
|
||||||
,m_bServer(false)
|
|
||||||
,m_parent(parent)
|
|
||||||
,m_resolv_host(host)
|
|
||||||
,m_resolv_port(port)
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
,m_resolve_ipv6(ipv6)
|
|
||||||
#endif
|
|
||||||
,m_cached(false)
|
|
||||||
{
|
|
||||||
SetLineProtocol();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, ipaddr_t a)
|
|
||||||
:TcpSocket(h)
|
|
||||||
,m_bServer(false)
|
|
||||||
,m_parent(parent)
|
|
||||||
,m_resolv_port(0)
|
|
||||||
,m_resolv_address(a)
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
,m_resolve_ipv6(false)
|
|
||||||
#endif
|
|
||||||
,m_cached(false)
|
|
||||||
{
|
|
||||||
SetLineProtocol();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, in6_addr& a)
|
|
||||||
:TcpSocket(h)
|
|
||||||
,m_bServer(false)
|
|
||||||
,m_parent(parent)
|
|
||||||
,m_resolv_port(0)
|
|
||||||
,m_resolve_ipv6(true)
|
|
||||||
,m_resolv_address6(a)
|
|
||||||
,m_cached(false)
|
|
||||||
{
|
|
||||||
SetLineProtocol();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
ResolvSocket::~ResolvSocket()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ResolvSocket::OnLine(const std::string& line)
|
|
||||||
{
|
|
||||||
Parse pa(line, ":");
|
|
||||||
if (m_bServer)
|
|
||||||
{
|
|
||||||
m_query = pa.getword();
|
|
||||||
m_data = pa.getrest();
|
|
||||||
DEB( fprintf(stderr, " *** ResolvSocket server; query=%s, data=%s\n", m_query.c_str(), m_data.c_str());)
|
|
||||||
// %! check cache
|
|
||||||
{
|
|
||||||
Lock lock(m_cache_mutex);
|
|
||||||
if (m_cache[m_query].find(m_data) != m_cache[m_query].end())
|
|
||||||
{
|
|
||||||
if (time(NULL) - m_cache_to[m_query][m_data] < 3600) // ttl
|
|
||||||
{
|
|
||||||
std::string result = m_cache[m_query][m_data];
|
|
||||||
DEB(fprintf(stderr, " *** Returning cache for [%s][%s] = '%s'\n", m_query.c_str(), m_data.c_str(), result.c_str());)
|
|
||||||
Send("Cached\n");
|
|
||||||
if (!result.size()) /* failed */
|
|
||||||
{
|
|
||||||
Send("Failed\n\n");
|
|
||||||
SetCloseAndDelete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (m_query == "gethostbyname")
|
|
||||||
{
|
|
||||||
Send("A: " + result + "\n\n");
|
|
||||||
SetCloseAndDelete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (m_query == "gethostbyname2")
|
|
||||||
{
|
|
||||||
Send("AAAA: " + result + "\n\n");
|
|
||||||
SetCloseAndDelete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
if (m_query == "gethostbyaddr")
|
|
||||||
{
|
|
||||||
Send("Name: " + result + "\n\n");
|
|
||||||
SetCloseAndDelete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!Detach()) // detach failed?
|
|
||||||
{
|
|
||||||
SetCloseAndDelete();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::string key = pa.getword();
|
|
||||||
std::string value = pa.getrest();
|
|
||||||
DEB( fprintf(stderr, " *** ResolvSocket response; %s: %s\n", key.c_str(), value.c_str());)
|
|
||||||
|
|
||||||
if (key == "Cached")
|
|
||||||
{
|
|
||||||
m_cached = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (key == "Failed" && m_parent)
|
|
||||||
{
|
|
||||||
DEB( fprintf(stderr, " ************ Resolve failed\n");)
|
|
||||||
if (Handler().Resolving(m_parent) || Handler().Valid(m_parent))
|
|
||||||
{
|
|
||||||
m_parent -> OnResolveFailed(m_resolv_id);
|
|
||||||
}
|
|
||||||
// update cache
|
|
||||||
if (!m_cached)
|
|
||||||
{
|
|
||||||
Lock lock(m_cache_mutex);
|
|
||||||
DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(), m_data.c_str(), value.c_str());)
|
|
||||||
m_cache[m_query][m_data] = value;
|
|
||||||
m_cache_to[m_query][m_data] = time(NULL);
|
|
||||||
}
|
|
||||||
m_parent = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (key == "Name" && !m_resolv_host.size() && m_parent)
|
|
||||||
{
|
|
||||||
if (Handler().Resolving(m_parent) || Handler().Valid(m_parent))
|
|
||||||
{
|
|
||||||
m_parent -> OnReverseResolved(m_resolv_id, value);
|
|
||||||
}
|
|
||||||
// update cache
|
|
||||||
if (!m_cached)
|
|
||||||
{
|
|
||||||
Lock lock(m_cache_mutex);
|
|
||||||
DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(), m_data.c_str(), value.c_str());)
|
|
||||||
m_cache[m_query][m_data] = value;
|
|
||||||
m_cache_to[m_query][m_data] = time(NULL);
|
|
||||||
}
|
|
||||||
m_parent = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (key == "A" && m_parent)
|
|
||||||
{
|
|
||||||
if (Handler().Resolving(m_parent) || Handler().Valid(m_parent))
|
|
||||||
{
|
|
||||||
ipaddr_t l;
|
|
||||||
Utility::u2ip(value, l); // ip2ipaddr_t
|
|
||||||
m_parent -> OnResolved(m_resolv_id, l, m_resolv_port);
|
|
||||||
}
|
|
||||||
// update cache
|
|
||||||
if (!m_cached)
|
|
||||||
{
|
|
||||||
Lock lock(m_cache_mutex);
|
|
||||||
DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(), m_data.c_str(), value.c_str());)
|
|
||||||
m_cache[m_query][m_data] = value;
|
|
||||||
m_cache_to[m_query][m_data] = time(NULL);
|
|
||||||
}
|
|
||||||
m_parent = NULL; // always use first ip in case there are several
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
else
|
|
||||||
if (key == "AAAA" && m_parent)
|
|
||||||
{
|
|
||||||
if (Handler().Resolving(m_parent) || Handler().Valid(m_parent))
|
|
||||||
{
|
|
||||||
in6_addr a;
|
|
||||||
Utility::u2ip(value, a);
|
|
||||||
m_parent -> OnResolved(m_resolv_id, a, m_resolv_port);
|
|
||||||
}
|
|
||||||
// update cache
|
|
||||||
if (!m_cached)
|
|
||||||
{
|
|
||||||
Lock lock(m_cache_mutex);
|
|
||||||
DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(), m_data.c_str(), value.c_str());)
|
|
||||||
m_cache[m_query][m_data] = value;
|
|
||||||
m_cache_to[m_query][m_data] = time(NULL);
|
|
||||||
}
|
|
||||||
m_parent = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ResolvSocket::OnDetached()
|
|
||||||
{
|
|
||||||
DEB( fprintf(stderr, " *** ResolvSocket::OnDetached(); query=%s, data=%s\n", m_query.c_str(), m_data.c_str());)
|
|
||||||
if (m_query == "gethostbyname")
|
|
||||||
{
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
if (Utility::u2ip(m_data, sa))
|
|
||||||
{
|
|
||||||
std::string ip;
|
|
||||||
Utility::l2ip(sa.sin_addr, ip);
|
|
||||||
Send("A: " + ip + "\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Send("Failed\n");
|
|
||||||
}
|
|
||||||
Send("\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (m_query == "gethostbyname2")
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 sa;
|
|
||||||
if (Utility::u2ip(m_data, sa))
|
|
||||||
{
|
|
||||||
std::string ip;
|
|
||||||
Utility::l2ip(sa.sin6_addr, ip);
|
|
||||||
Send("AAAA: " + ip + "\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Send("Failed\n");
|
|
||||||
}
|
|
||||||
Send("\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
if (m_query == "gethostbyaddr")
|
|
||||||
{
|
|
||||||
if (Utility::isipv4( m_data ))
|
|
||||||
{
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
if (!Utility::u2ip(m_data, sa, AI_NUMERICHOST))
|
|
||||||
{
|
|
||||||
Send("Failed: convert to sockaddr_in failed\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string name;
|
|
||||||
if (!Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), name))
|
|
||||||
{
|
|
||||||
Send("Failed: ipv4 reverse lookup of " + m_data + "\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Send("Name: " + name + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (Utility::isipv6( m_data ))
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 sa;
|
|
||||||
if (!Utility::u2ip(m_data, sa, AI_NUMERICHOST))
|
|
||||||
{
|
|
||||||
Send("Failed: convert to sockaddr_in6 failed\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string name;
|
|
||||||
if (!Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), name))
|
|
||||||
{
|
|
||||||
Send("Failed: ipv6 reverse lookup of " + m_data + "\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Send("Name: " + name + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Send("Failed: malformed address\n");
|
|
||||||
}
|
|
||||||
Send("\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string msg = "Unknown query type: " + m_query;
|
|
||||||
Handler().LogError(this, "OnDetached", 0, msg);
|
|
||||||
Send("Unknown\n\n");
|
|
||||||
}
|
|
||||||
SetCloseAndDelete();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ResolvSocket::OnConnect()
|
|
||||||
{
|
|
||||||
if (!m_resolv_host.empty())
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
std::string msg = (m_resolve_ipv6 ? "gethostbyname2 " : "gethostbyname ") + m_resolv_host + "\n";
|
|
||||||
m_query = m_resolve_ipv6 ? "gethostbyname2" : "gethostbyname";
|
|
||||||
#else
|
|
||||||
std::string msg = "gethostbyname " + m_resolv_host + "\n";
|
|
||||||
m_query = "gethostbyname";
|
|
||||||
#endif
|
|
||||||
m_data = m_resolv_host;
|
|
||||||
Send( msg );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
if (m_resolve_ipv6)
|
|
||||||
{
|
|
||||||
std::string tmp;
|
|
||||||
Utility::l2ip(m_resolv_address6, tmp);
|
|
||||||
m_query = "gethostbyaddr";
|
|
||||||
m_data = tmp;
|
|
||||||
std::string msg = "gethostbyaddr " + tmp + "\n";
|
|
||||||
Send( msg );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
std::string tmp;
|
|
||||||
Utility::l2ip(m_resolv_address, tmp);
|
|
||||||
m_query = "gethostbyaddr";
|
|
||||||
m_data = tmp;
|
|
||||||
std::string msg = "gethostbyaddr " + tmp + "\n";
|
|
||||||
Send( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ResolvSocket::OnDelete()
|
|
||||||
{
|
|
||||||
if (m_parent)
|
|
||||||
{
|
|
||||||
if (Handler().Resolving(m_parent) || Handler().Valid(m_parent))
|
|
||||||
{
|
|
||||||
m_parent -> OnResolveFailed(m_resolv_id);
|
|
||||||
}
|
|
||||||
// update cache
|
|
||||||
if (!m_cached)
|
|
||||||
{
|
|
||||||
Lock lock(m_cache_mutex);
|
|
||||||
std::string value;
|
|
||||||
DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(), m_data.c_str(), value.c_str());)
|
|
||||||
m_cache[m_query][m_data] = value;
|
|
||||||
m_cache_to[m_query][m_data] = time(NULL);
|
|
||||||
}
|
|
||||||
m_parent = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // ENABLE_RESOLVER
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,98 +0,0 @@
|
||||||
/** \file StdoutLog.cpp
|
|
||||||
** \date 2004-06-01
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4786)
|
|
||||||
#endif
|
|
||||||
#include "ISocketHandler.h"
|
|
||||||
#include "Socket.h"
|
|
||||||
#include "StdoutLog.h"
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void StdoutLog::error(ISocketHandler *,Socket *sock,const std::string& call,int err,const std::string& sys_err,loglevel_t lvl)
|
|
||||||
{
|
|
||||||
time_t t = time(NULL);
|
|
||||||
struct tm tp;
|
|
||||||
#ifdef _WIN32
|
|
||||||
memcpy(&tp, localtime(&t), sizeof(tp));
|
|
||||||
#else
|
|
||||||
localtime_r(&t, &tp);
|
|
||||||
#endif
|
|
||||||
std::string level;
|
|
||||||
|
|
||||||
switch (lvl)
|
|
||||||
{
|
|
||||||
case LOG_LEVEL_WARNING:
|
|
||||||
level = "Warning";
|
|
||||||
break;
|
|
||||||
case LOG_LEVEL_ERROR:
|
|
||||||
level = "Error";
|
|
||||||
break;
|
|
||||||
case LOG_LEVEL_FATAL:
|
|
||||||
level = "Fatal";
|
|
||||||
break;
|
|
||||||
case LOG_LEVEL_INFO:
|
|
||||||
level = "Info";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (sock)
|
|
||||||
{
|
|
||||||
printf("%d-%02d-%02d %02d:%02d:%02d :: fd %d :: %s: %d %s (%s)\n",
|
|
||||||
tp.tm_year + 1900,
|
|
||||||
tp.tm_mon + 1,
|
|
||||||
tp.tm_mday,
|
|
||||||
tp.tm_hour,tp.tm_min,tp.tm_sec,
|
|
||||||
sock -> GetSocket(),
|
|
||||||
call.c_str(),err,sys_err.c_str(),level.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("%d-%02d-%02d %02d:%02d:%02d :: %s: %d %s (%s)\n",
|
|
||||||
tp.tm_year + 1900,
|
|
||||||
tp.tm_mon + 1,
|
|
||||||
tp.tm_mday,
|
|
||||||
tp.tm_hour,tp.tm_min,tp.tm_sec,
|
|
||||||
call.c_str(),err,sys_err.c_str(),level.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,169 +0,0 @@
|
||||||
#include "StreamSocket.h"
|
|
||||||
#include "ISocketHandler.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
StreamSocket::StreamSocket(ISocketHandler& h) : Socket(h)
|
|
||||||
,m_bConnecting(false)
|
|
||||||
,m_connect_timeout(5)
|
|
||||||
,m_flush_before_close(true)
|
|
||||||
,m_connection_retry(0)
|
|
||||||
,m_retries(0)
|
|
||||||
,m_call_on_connect(false)
|
|
||||||
,m_b_retry_connect(false)
|
|
||||||
,m_line_protocol(false)
|
|
||||||
,m_shutdown(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
StreamSocket::~StreamSocket()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::SetConnecting(bool x)
|
|
||||||
{
|
|
||||||
if (x != m_bConnecting)
|
|
||||||
{
|
|
||||||
m_bConnecting = x;
|
|
||||||
if (x)
|
|
||||||
{
|
|
||||||
SetTimeout( GetConnectTimeout() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetTimeout( 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool StreamSocket::Connecting()
|
|
||||||
{
|
|
||||||
return m_bConnecting;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool StreamSocket::Ready()
|
|
||||||
{
|
|
||||||
if (GetSocket() != INVALID_SOCKET && !Connecting() && !CloseAndDelete())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::SetConnectTimeout(int x)
|
|
||||||
{
|
|
||||||
m_connect_timeout = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int StreamSocket::GetConnectTimeout()
|
|
||||||
{
|
|
||||||
return m_connect_timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::SetFlushBeforeClose(bool x)
|
|
||||||
{
|
|
||||||
m_flush_before_close = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool StreamSocket::GetFlushBeforeClose()
|
|
||||||
{
|
|
||||||
return m_flush_before_close;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int StreamSocket::GetConnectionRetry()
|
|
||||||
{
|
|
||||||
return m_connection_retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::SetConnectionRetry(int x)
|
|
||||||
{
|
|
||||||
m_connection_retry = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int StreamSocket::GetConnectionRetries()
|
|
||||||
{
|
|
||||||
return m_retries;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::IncreaseConnectionRetries()
|
|
||||||
{
|
|
||||||
m_retries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::ResetConnectionRetries()
|
|
||||||
{
|
|
||||||
m_retries = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::SetCallOnConnect(bool x)
|
|
||||||
{
|
|
||||||
Handler().AddList(GetSocket(), LIST_CALLONCONNECT, x);
|
|
||||||
m_call_on_connect = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool StreamSocket::CallOnConnect()
|
|
||||||
{
|
|
||||||
return m_call_on_connect;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::SetRetryClientConnect(bool x)
|
|
||||||
{
|
|
||||||
Handler().AddList(GetSocket(), LIST_RETRY, x);
|
|
||||||
m_b_retry_connect = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool StreamSocket::RetryClientConnect()
|
|
||||||
{
|
|
||||||
return m_b_retry_connect;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::SetLineProtocol(bool x)
|
|
||||||
{
|
|
||||||
m_line_protocol = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool StreamSocket::LineProtocol()
|
|
||||||
{
|
|
||||||
return m_line_protocol;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void StreamSocket::SetShutdown(int x)
|
|
||||||
{
|
|
||||||
m_shutdown = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int StreamSocket::GetShutdown()
|
|
||||||
{
|
|
||||||
return m_shutdown;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
} // namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,166 +0,0 @@
|
||||||
/** \file Thread.cpp
|
|
||||||
** \date 2004-10-30
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <process.h>
|
|
||||||
#include "socket_include.h"
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Thread.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
Thread::Thread(bool release)
|
|
||||||
:m_thread(0)
|
|
||||||
,m_running(true)
|
|
||||||
,m_release(false)
|
|
||||||
,m_b_delete_on_exit(false)
|
|
||||||
,m_b_destructor(false)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
// m_thread = ::CreateThread(NULL, 0, StartThread, this, 0, &m_dwThreadId);
|
|
||||||
m_thread = (HANDLE)_beginthreadex(NULL, 0, &StartThread, this, 0, &m_dwThreadId);
|
|
||||||
#else
|
|
||||||
pthread_attr_t attr;
|
|
||||||
|
|
||||||
pthread_attr_init(&attr);
|
|
||||||
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
|
|
||||||
if (pthread_create(&m_thread,&attr, StartThread,this) == -1)
|
|
||||||
{
|
|
||||||
perror("Thread: create failed");
|
|
||||||
SetRunning(false);
|
|
||||||
}
|
|
||||||
// pthread_attr_destroy(&attr);
|
|
||||||
#endif
|
|
||||||
m_release = release;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Thread::~Thread()
|
|
||||||
{
|
|
||||||
m_b_destructor = true;
|
|
||||||
if (m_running)
|
|
||||||
{
|
|
||||||
SetRelease(true);
|
|
||||||
SetRunning(false);
|
|
||||||
#ifdef _WIN32
|
|
||||||
Sleep(1000);
|
|
||||||
#else
|
|
||||||
sleep(1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (m_thread)
|
|
||||||
::CloseHandle(m_thread);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
threadfunc_t STDPREFIX Thread::StartThread(threadparam_t zz)
|
|
||||||
{
|
|
||||||
Thread *p = (Thread *)zz;
|
|
||||||
|
|
||||||
while (p -> m_running && !p -> m_release)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
Sleep(1000);
|
|
||||||
#else
|
|
||||||
sleep(1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (p -> m_running)
|
|
||||||
{
|
|
||||||
p -> Run();
|
|
||||||
}
|
|
||||||
p -> SetRunning(false); // if return
|
|
||||||
if (p -> DeleteOnExit() && !p -> IsDestructor())
|
|
||||||
{
|
|
||||||
delete p;
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
_endthreadex(0);
|
|
||||||
#endif
|
|
||||||
return (threadfunc_t)NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Thread::IsRunning()
|
|
||||||
{
|
|
||||||
return m_running;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Thread::SetRunning(bool x)
|
|
||||||
{
|
|
||||||
m_running = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Thread::IsReleased()
|
|
||||||
{
|
|
||||||
return m_release;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Thread::SetRelease(bool x)
|
|
||||||
{
|
|
||||||
m_release = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Thread::DeleteOnExit()
|
|
||||||
{
|
|
||||||
return m_b_delete_on_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Thread::SetDeleteOnExit(bool x)
|
|
||||||
{
|
|
||||||
m_b_delete_on_exit = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Thread::IsDestructor()
|
|
||||||
{
|
|
||||||
return m_b_destructor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,852 +0,0 @@
|
||||||
/** \file UdpSocket.cpp
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#ifdef _WIN32
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4786)
|
|
||||||
#endif
|
|
||||||
#include <stdlib.h>
|
|
||||||
#else
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ISocketHandler.h"
|
|
||||||
#include "UdpSocket.h"
|
|
||||||
#include "Utility.h"
|
|
||||||
#include "Ipv4Address.h"
|
|
||||||
#include "Ipv6Address.h"
|
|
||||||
#ifdef ENABLE_EXCEPTIONS
|
|
||||||
#include "Exception.h"
|
|
||||||
#endif
|
|
||||||
// include this to see strange sights
|
|
||||||
//#include <linux/in6.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
UdpSocket::UdpSocket(ISocketHandler& h, int ibufsz, bool ipv6, int retries) : Socket(h)
|
|
||||||
, m_ibuf(new char[ibufsz])
|
|
||||||
, m_ibufsz(ibufsz)
|
|
||||||
, m_bind_ok(false)
|
|
||||||
, m_port(0)
|
|
||||||
, m_last_size_written(-1)
|
|
||||||
, m_retries(retries)
|
|
||||||
, m_b_read_ts(false)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
SetIpv6(ipv6);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
UdpSocket::~UdpSocket()
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
delete[] m_ibuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int UdpSocket::Bind(port_t &port, int range)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
Ipv6Address ad(port);
|
|
||||||
return Bind(ad, range);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Ipv4Address ad(port);
|
|
||||||
return Bind(ad, range);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int UdpSocket::Bind(const std::string& intf, port_t &port, int range)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
Ipv6Address ad(intf, port);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
return Bind(ad, range);
|
|
||||||
}
|
|
||||||
SetCloseAndDelete();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Ipv4Address ad(intf, port);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
return Bind(ad, range);
|
|
||||||
}
|
|
||||||
SetCloseAndDelete();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int UdpSocket::Bind(ipaddr_t a, port_t &port, int range)
|
|
||||||
{
|
|
||||||
Ipv4Address ad(a, port);
|
|
||||||
return Bind(ad, range);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
int UdpSocket::Bind(in6_addr a, port_t &port, int range)
|
|
||||||
{
|
|
||||||
Ipv6Address ad(a, port);
|
|
||||||
return Bind(ad, range);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int UdpSocket::Bind(SocketAddress& ad, int range)
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
Attach(CreateSocket(ad.GetFamily(), SOCK_DGRAM, "udp"));
|
|
||||||
}
|
|
||||||
if (GetSocket() != INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
SetNonblocking(true);
|
|
||||||
int n = bind(GetSocket(), ad, ad);
|
|
||||||
int tries = range;
|
|
||||||
while (n == -1 && tries--)
|
|
||||||
{
|
|
||||||
ad.SetPort(ad.GetPort() + 1);
|
|
||||||
n = bind(GetSocket(), ad, ad);
|
|
||||||
}
|
|
||||||
if (n == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "bind", Errno, StrError(Errno), LOG_LEVEL_FATAL);
|
|
||||||
SetCloseAndDelete();
|
|
||||||
#ifdef ENABLE_EXCEPTIONS
|
|
||||||
throw Exception("bind() failed for UdpSocket, port:range: " + Utility::l2string(ad.GetPort()) + ":" + Utility::l2string(range));
|
|
||||||
#endif
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
m_bind_ok = true;
|
|
||||||
m_port = ad.GetPort();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** if you wish to use Send, first Open a connection */
|
|
||||||
bool UdpSocket::Open(ipaddr_t l, port_t port)
|
|
||||||
{
|
|
||||||
Ipv4Address ad(l, port);
|
|
||||||
return Open(ad);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool UdpSocket::Open(const std::string& host, port_t port)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
Ipv6Address ad(host, port);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
return Open(ad);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Ipv4Address ad(host, port);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
return Open(ad);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
bool UdpSocket::Open(struct in6_addr& a, port_t port)
|
|
||||||
{
|
|
||||||
Ipv6Address ad(a, port);
|
|
||||||
return Open(ad);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
bool UdpSocket::Open(SocketAddress& ad)
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
Attach(CreateSocket(ad.GetFamily(), SOCK_DGRAM, "udp"));
|
|
||||||
}
|
|
||||||
if (GetSocket() != INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
SetNonblocking(true);
|
|
||||||
if (connect(GetSocket(), ad, ad) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "connect", Errno, StrError(Errno), LOG_LEVEL_FATAL);
|
|
||||||
SetCloseAndDelete();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SetConnected();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::CreateConnection()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
SOCKET s = CreateSocket(AF_INET6, SOCK_DGRAM, "udp");
|
|
||||||
if (s == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SetNonblocking(true, s);
|
|
||||||
Attach(s);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
SOCKET s = CreateSocket(AF_INET, SOCK_DGRAM, "udp");
|
|
||||||
if (s == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SetNonblocking(true, s);
|
|
||||||
Attach(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** send to specified address */
|
|
||||||
void UdpSocket::SendToBuf(const std::string& h, port_t p, const char *data, int len, int flags)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
Ipv6Address ad(h, p);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
SendToBuf(ad, data, len, flags);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
Ipv4Address ad(h, p);
|
|
||||||
if (ad.IsValid())
|
|
||||||
{
|
|
||||||
SendToBuf(ad, data, len, flags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** send to specified address */
|
|
||||||
void UdpSocket::SendToBuf(ipaddr_t a, port_t p, const char *data, int len, int flags)
|
|
||||||
{
|
|
||||||
Ipv4Address ad(a, p);
|
|
||||||
SendToBuf(ad, data, len, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
void UdpSocket::SendToBuf(in6_addr a, port_t p, const char *data, int len, int flags)
|
|
||||||
{
|
|
||||||
Ipv6Address ad(a, p);
|
|
||||||
SendToBuf(ad, data, len, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::SendToBuf(SocketAddress& ad, const char *data, int len, int flags)
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
Attach(CreateSocket(ad.GetFamily(), SOCK_DGRAM, "udp"));
|
|
||||||
}
|
|
||||||
if (GetSocket() != INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
SetNonblocking(true);
|
|
||||||
if ((m_last_size_written = sendto(GetSocket(), data, len, flags, ad, ad)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "sendto", Errno, StrError(Errno), LOG_LEVEL_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::SendTo(const std::string& a, port_t p, const std::string& str, int flags)
|
|
||||||
{
|
|
||||||
SendToBuf(a, p, str.c_str(), (int)str.size(), flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::SendTo(ipaddr_t a, port_t p, const std::string& str, int flags)
|
|
||||||
{
|
|
||||||
SendToBuf(a, p, str.c_str(), (int)str.size(), flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
void UdpSocket::SendTo(in6_addr a, port_t p, const std::string& str, int flags)
|
|
||||||
{
|
|
||||||
SendToBuf(a, p, str.c_str(), (int)str.size(), flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::SendTo(SocketAddress& ad, const std::string& str, int flags)
|
|
||||||
{
|
|
||||||
SendToBuf(ad, str.c_str(), (int)str.size(), flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** send to connected address */
|
|
||||||
void UdpSocket::SendBuf(const char *data, size_t len, int flags)
|
|
||||||
{
|
|
||||||
if (!IsConnected())
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SendBuf", 0, "not connected", LOG_LEVEL_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((m_last_size_written = send(GetSocket(), data, (int)len, flags)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "send", Errno, StrError(Errno), LOG_LEVEL_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::Send(const std::string& str, int flags)
|
|
||||||
{
|
|
||||||
SendBuf(str.c_str(), (int)str.size(), flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(LINUX) || defined(MACOSX)
|
|
||||||
int UdpSocket::ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen_t fromlen, struct timeval *ts)
|
|
||||||
{
|
|
||||||
struct msghdr msg;
|
|
||||||
struct iovec vec[1];
|
|
||||||
union {
|
|
||||||
struct cmsghdr cm;
|
|
||||||
#ifdef MACOSX
|
|
||||||
#ifdef __DARWIN_UNIX03
|
|
||||||
#define ALIGNBYTES __DARWIN_ALIGNBYTES
|
|
||||||
#endif
|
|
||||||
#define myALIGN(p) (((unsigned int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
|
|
||||||
#define myCMSG_SPACE(l) (myALIGN(sizeof(struct cmsghdr)) + myALIGN(l))
|
|
||||||
char data[ myCMSG_SPACE(sizeof(struct timeval)) ];
|
|
||||||
#else
|
|
||||||
char data[ CMSG_SPACE(sizeof(struct timeval)) ];
|
|
||||||
#endif
|
|
||||||
} cmsg_un;
|
|
||||||
struct cmsghdr *cmsg;
|
|
||||||
struct timeval *tv;
|
|
||||||
|
|
||||||
vec[0].iov_base = ioBuf;
|
|
||||||
vec[0].iov_len = inBufSize;
|
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
|
||||||
memset(from, 0, fromlen);
|
|
||||||
memset(ioBuf, 0, inBufSize);
|
|
||||||
memset(&cmsg_un, 0, sizeof(cmsg_un));
|
|
||||||
|
|
||||||
msg.msg_name = (caddr_t)from;
|
|
||||||
msg.msg_namelen = fromlen;
|
|
||||||
msg.msg_iov = vec;
|
|
||||||
msg.msg_iovlen = 1;
|
|
||||||
msg.msg_control = cmsg_un.data;
|
|
||||||
msg.msg_controllen = sizeof(cmsg_un.data);
|
|
||||||
msg.msg_flags = 0;
|
|
||||||
|
|
||||||
// Original version - for reference only
|
|
||||||
//int n = recvfrom(GetSocket(), m_ibuf, m_ibufsz, 0, (struct sockaddr *)&sa, &sa_len);
|
|
||||||
|
|
||||||
int n = recvmsg(GetSocket(), &msg, MSG_DONTWAIT);
|
|
||||||
|
|
||||||
// now ioBuf will contain the data, as if we used recvfrom
|
|
||||||
|
|
||||||
// Now get the time
|
|
||||||
if(n != -1 && msg.msg_controllen >= sizeof(struct cmsghdr) && !(msg.msg_flags & MSG_CTRUNC))
|
|
||||||
{
|
|
||||||
tv = 0;
|
|
||||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg))
|
|
||||||
{
|
|
||||||
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMP)
|
|
||||||
{
|
|
||||||
tv = (struct timeval *)CMSG_DATA(cmsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tv)
|
|
||||||
{
|
|
||||||
memcpy(ts, tv, sizeof(struct timeval));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// The address is in network order, but that's OK right now
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::OnRead()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 sa;
|
|
||||||
socklen_t sa_len = sizeof(sa);
|
|
||||||
if (m_b_read_ts)
|
|
||||||
{
|
|
||||||
struct timeval ts;
|
|
||||||
Utility::GetTime(&ts);
|
|
||||||
#if !defined(LINUX) && !defined(MACOSX)
|
|
||||||
int n = recvfrom(GetSocket(), m_ibuf, m_ibufsz, 0, (struct sockaddr *)&sa, &sa_len);
|
|
||||||
#else
|
|
||||||
int n = ReadTS(m_ibuf, m_ibufsz, (struct sockaddr *)&sa, sa_len, &ts);
|
|
||||||
#endif
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
this -> OnRawData(m_ibuf, n, (struct sockaddr *)&sa, sa_len, &ts);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (n == -1)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (Errno != WSAEWOULDBLOCK)
|
|
||||||
#else
|
|
||||||
if (Errno != EWOULDBLOCK)
|
|
||||||
#endif
|
|
||||||
Handler().LogError(this, "recvfrom", Errno, StrError(Errno), LOG_LEVEL_ERROR);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int n = recvfrom(GetSocket(), m_ibuf, m_ibufsz, 0, (struct sockaddr *)&sa, &sa_len);
|
|
||||||
int q = m_retries; // receive max 10 at one cycle
|
|
||||||
while (n > 0)
|
|
||||||
{
|
|
||||||
if (sa_len != sizeof(sa))
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "recvfrom", 0, "unexpected address struct size", LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
this -> OnRawData(m_ibuf, n, (struct sockaddr *)&sa, sa_len);
|
|
||||||
if (!q--)
|
|
||||||
break;
|
|
||||||
//
|
|
||||||
n = recvfrom(GetSocket(), m_ibuf, m_ibufsz, 0, (struct sockaddr *)&sa, &sa_len);
|
|
||||||
}
|
|
||||||
if (n == -1)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (Errno != WSAEWOULDBLOCK)
|
|
||||||
#else
|
|
||||||
if (Errno != EWOULDBLOCK)
|
|
||||||
#endif
|
|
||||||
Handler().LogError(this, "recvfrom", Errno, StrError(Errno), LOG_LEVEL_ERROR);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
socklen_t sa_len = sizeof(sa);
|
|
||||||
if (m_b_read_ts)
|
|
||||||
{
|
|
||||||
struct timeval ts;
|
|
||||||
Utility::GetTime(&ts);
|
|
||||||
#if !defined(LINUX) && !defined(MACOSX)
|
|
||||||
int n = recvfrom(GetSocket(), m_ibuf, m_ibufsz, 0, (struct sockaddr *)&sa, &sa_len);
|
|
||||||
#else
|
|
||||||
int n = ReadTS(m_ibuf, m_ibufsz, (struct sockaddr *)&sa, sa_len, &ts);
|
|
||||||
#endif
|
|
||||||
if (n > 0)
|
|
||||||
{
|
|
||||||
this -> OnRawData(m_ibuf, n, (struct sockaddr *)&sa, sa_len, &ts);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (n == -1)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (Errno != WSAEWOULDBLOCK)
|
|
||||||
#else
|
|
||||||
if (Errno != EWOULDBLOCK)
|
|
||||||
#endif
|
|
||||||
Handler().LogError(this, "recvfrom", Errno, StrError(Errno), LOG_LEVEL_ERROR);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int n = recvfrom(GetSocket(), m_ibuf, m_ibufsz, 0, (struct sockaddr *)&sa, &sa_len);
|
|
||||||
int q = m_retries;
|
|
||||||
while (n > 0)
|
|
||||||
{
|
|
||||||
if (sa_len != sizeof(sa))
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "recvfrom", 0, "unexpected address struct size", LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
this -> OnRawData(m_ibuf, n, (struct sockaddr *)&sa, sa_len);
|
|
||||||
if (!q--)
|
|
||||||
break;
|
|
||||||
//
|
|
||||||
n = recvfrom(GetSocket(), m_ibuf, m_ibufsz, 0, (struct sockaddr *)&sa, &sa_len);
|
|
||||||
}
|
|
||||||
if (n == -1)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (Errno != WSAEWOULDBLOCK)
|
|
||||||
#else
|
|
||||||
if (Errno != EWOULDBLOCK)
|
|
||||||
#endif
|
|
||||||
Handler().LogError(this, "recvfrom", Errno, StrError(Errno), LOG_LEVEL_ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::SetBroadcast(bool b)
|
|
||||||
{
|
|
||||||
int one = 1;
|
|
||||||
int zero = 0;
|
|
||||||
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
if (b)
|
|
||||||
{
|
|
||||||
if (setsockopt(GetSocket(), SOL_SOCKET, SO_BROADCAST, (char *) &one, sizeof(one)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SetBroadcast", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (setsockopt(GetSocket(), SOL_SOCKET, SO_BROADCAST, (char *) &zero, sizeof(zero)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SetBroadcast", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool UdpSocket::IsBroadcast()
|
|
||||||
{
|
|
||||||
int is_broadcast = 0;
|
|
||||||
socklen_t size;
|
|
||||||
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
if (getsockopt(GetSocket(), SOL_SOCKET, SO_BROADCAST, (char *)&is_broadcast, &size) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "IsBroadcast", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
return is_broadcast != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::SetMulticastTTL(int ttl)
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
if (setsockopt(GetSocket(), SOL_IP, IP_MULTICAST_TTL, (char *)&ttl, sizeof(int)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SetMulticastTTL", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int UdpSocket::GetMulticastTTL()
|
|
||||||
{
|
|
||||||
int ttl = 0;
|
|
||||||
socklen_t size = sizeof(int);
|
|
||||||
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
if (getsockopt(GetSocket(), SOL_IP, IP_MULTICAST_TTL, (char *)&ttl, &size) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "GetMulticastTTL", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
return ttl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::SetMulticastLoop(bool x)
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
int val = x ? 1 : 0;
|
|
||||||
if (setsockopt(GetSocket(), IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (char *)&val, sizeof(int)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SetMulticastLoop", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
int val = x ? 1 : 0;
|
|
||||||
if (setsockopt(GetSocket(), SOL_IP, IP_MULTICAST_LOOP, (char *)&val, sizeof(int)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SetMulticastLoop", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool UdpSocket::IsMulticastLoop()
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
int is_loop = 0;
|
|
||||||
socklen_t size = sizeof(int);
|
|
||||||
if (getsockopt(GetSocket(), IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (char *)&is_loop, &size) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "IsMulticastLoop", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
return is_loop ? true : false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
int is_loop = 0;
|
|
||||||
socklen_t size = sizeof(int);
|
|
||||||
if (getsockopt(GetSocket(), SOL_IP, IP_MULTICAST_LOOP, (char *)&is_loop, &size) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "IsMulticastLoop", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
return is_loop ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::AddMulticastMembership(const std::string& group, const std::string& local_if, int if_index)
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
struct ipv6_mreq x;
|
|
||||||
struct in6_addr addr;
|
|
||||||
if (Utility::u2ip( group, addr ))
|
|
||||||
{
|
|
||||||
x.ipv6mr_multiaddr = addr;
|
|
||||||
x.ipv6mr_interface = if_index;
|
|
||||||
if (setsockopt(GetSocket(), IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&x, sizeof(struct ipv6_mreq)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "AddMulticastMembership", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
struct ip_mreq x; // ip_mreqn
|
|
||||||
ipaddr_t addr;
|
|
||||||
if (Utility::u2ip( group, addr ))
|
|
||||||
{
|
|
||||||
memcpy(&x.imr_multiaddr.s_addr, &addr, sizeof(addr));
|
|
||||||
Utility::u2ip( local_if, addr);
|
|
||||||
memcpy(&x.imr_interface.s_addr, &addr, sizeof(addr));
|
|
||||||
// x.imr_ifindex = if_index;
|
|
||||||
if (setsockopt(GetSocket(), SOL_IP, IP_ADD_MEMBERSHIP, (char *)&x, sizeof(struct ip_mreq)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "AddMulticastMembership", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::DropMulticastMembership(const std::string& group, const std::string& local_if, int if_index)
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (IsIpv6())
|
|
||||||
{
|
|
||||||
struct ipv6_mreq x;
|
|
||||||
struct in6_addr addr;
|
|
||||||
if (Utility::u2ip( group, addr ))
|
|
||||||
{
|
|
||||||
x.ipv6mr_multiaddr = addr;
|
|
||||||
x.ipv6mr_interface = if_index;
|
|
||||||
if (setsockopt(GetSocket(), IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, (char *)&x, sizeof(struct ipv6_mreq)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "DropMulticastMembership", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
struct ip_mreq x; // ip_mreqn
|
|
||||||
ipaddr_t addr;
|
|
||||||
if (Utility::u2ip( group, addr ))
|
|
||||||
{
|
|
||||||
memcpy(&x.imr_multiaddr.s_addr, &addr, sizeof(addr));
|
|
||||||
Utility::u2ip( local_if, addr);
|
|
||||||
memcpy(&x.imr_interface.s_addr, &addr, sizeof(addr));
|
|
||||||
// x.imr_ifindex = if_index;
|
|
||||||
if (setsockopt(GetSocket(), SOL_IP, IP_DROP_MEMBERSHIP, (char *)&x, sizeof(struct ip_mreq)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "DropMulticastMembership", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
void UdpSocket::SetMulticastHops(int hops)
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
if (!IsIpv6())
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SetMulticastHops", 0, "Ipv6 only", LOG_LEVEL_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (setsockopt(GetSocket(), IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *)&hops, sizeof(int)) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SetMulticastHops", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int UdpSocket::GetMulticastHops()
|
|
||||||
{
|
|
||||||
if (GetSocket() == INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
CreateConnection();
|
|
||||||
}
|
|
||||||
if (!IsIpv6())
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "SetMulticastHops", 0, "Ipv6 only", LOG_LEVEL_ERROR);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int hops = 0;
|
|
||||||
socklen_t size = sizeof(int);
|
|
||||||
if (getsockopt(GetSocket(), IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *)&hops, &size) == -1)
|
|
||||||
{
|
|
||||||
Handler().LogError(this, "GetMulticastHops", Errno, StrError(Errno), LOG_LEVEL_WARNING);
|
|
||||||
}
|
|
||||||
return hops;
|
|
||||||
}
|
|
||||||
#endif // IPPROTO_IPV6
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
bool UdpSocket::IsBound()
|
|
||||||
{
|
|
||||||
return m_bind_ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::OnRawData(const char *buf, size_t len, struct sockaddr *sa, socklen_t sa_len)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::OnRawData(const char *buf, size_t len, struct sockaddr *sa, socklen_t sa_len, struct timeval *ts)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
port_t UdpSocket::GetPort()
|
|
||||||
{
|
|
||||||
return m_port;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int UdpSocket::GetLastSizeWritten()
|
|
||||||
{
|
|
||||||
return m_last_size_written;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void UdpSocket::SetTimestamp(bool x)
|
|
||||||
{
|
|
||||||
m_b_read_ts = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,999 +0,0 @@
|
||||||
/** \file Utility.cpp
|
|
||||||
** \date 2004-02-13
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include "Utility.h"
|
|
||||||
#include "Parse.h"
|
|
||||||
#include "Ipv4Address.h"
|
|
||||||
#include "Ipv6Address.h"
|
|
||||||
#include "Base64.h"
|
|
||||||
#include <vector>
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <time.h>
|
|
||||||
#else
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#endif
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
namespace SOCKETS_NAMESPACE {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// defines for the random number generator
|
|
||||||
#define TWIST_IA 397
|
|
||||||
#define TWIST_IB (TWIST_LEN - TWIST_IA)
|
|
||||||
#define UMASK 0x80000000
|
|
||||||
#define LMASK 0x7FFFFFFF
|
|
||||||
#define MATRIX_A 0x9908B0DF
|
|
||||||
#define TWIST(b,i,j) ((b)[i] & UMASK) | ((b)[j] & LMASK)
|
|
||||||
#define MAGIC_TWIST(s) (((s) & 1) * MATRIX_A)
|
|
||||||
|
|
||||||
|
|
||||||
// statics
|
|
||||||
std::string Utility::m_host;
|
|
||||||
bool Utility::m_local_resolved = false;
|
|
||||||
ipaddr_t Utility::m_ip = 0;
|
|
||||||
std::string Utility::m_addr;
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
struct in6_addr Utility::m_local_ip6;
|
|
||||||
std::string Utility::m_local_addr6;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::base64(const std::string& str_in)
|
|
||||||
{
|
|
||||||
std::string str;
|
|
||||||
Base64 m_b;
|
|
||||||
m_b.encode(str_in, str, false); // , false == do not add cr/lf
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::base64d(const std::string& str_in)
|
|
||||||
{
|
|
||||||
std::string str;
|
|
||||||
Base64 m_b;
|
|
||||||
m_b.decode(str_in, str);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::l2string(long l)
|
|
||||||
{
|
|
||||||
std::string str;
|
|
||||||
char tmp[100];
|
|
||||||
sprintf(tmp,"%ld",l);
|
|
||||||
str = tmp;
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::bigint2string(uint64_t l)
|
|
||||||
{
|
|
||||||
std::string str;
|
|
||||||
uint64_t tmp = l;
|
|
||||||
while (tmp)
|
|
||||||
{
|
|
||||||
uint64_t a = tmp % 10;
|
|
||||||
str = (char)(a + 48) + str;
|
|
||||||
tmp /= 10;
|
|
||||||
}
|
|
||||||
if (str.empty())
|
|
||||||
{
|
|
||||||
str = "0";
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint64_t Utility::atoi64(const std::string& str)
|
|
||||||
{
|
|
||||||
uint64_t l = 0;
|
|
||||||
for (size_t i = 0; i < str.size(); i++)
|
|
||||||
{
|
|
||||||
l = l * 10 + str[i] - 48;
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int Utility::hex2unsigned(const std::string& str)
|
|
||||||
{
|
|
||||||
unsigned int r = 0;
|
|
||||||
for (size_t i = 0; i < str.size(); i++)
|
|
||||||
{
|
|
||||||
r = r * 16 + str[i] - 48 - ((str[i] >= 'A') ? 7 : 0) - ((str[i] >= 'a') ? 32 : 0);
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Encode string per RFC1738 URL encoding rules
|
|
||||||
* tnx rstaveley
|
|
||||||
*/
|
|
||||||
std::string Utility::rfc1738_encode(const std::string& src)
|
|
||||||
{
|
|
||||||
static char hex[] = "0123456789ABCDEF";
|
|
||||||
std::string dst;
|
|
||||||
for (size_t i = 0; i < src.size(); i++)
|
|
||||||
{
|
|
||||||
if (isalnum(src[i]))
|
|
||||||
{
|
|
||||||
dst += src[i];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (src[i] == ' ')
|
|
||||||
{
|
|
||||||
dst += '+';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned char c = static_cast<unsigned char>(src[i]);
|
|
||||||
dst += '%';
|
|
||||||
dst += hex[c / 16];
|
|
||||||
dst += hex[c % 16];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dst;
|
|
||||||
} // rfc1738_encode
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Decode string per RFC1738 URL encoding rules
|
|
||||||
* tnx rstaveley
|
|
||||||
*/
|
|
||||||
std::string Utility::rfc1738_decode(const std::string& src)
|
|
||||||
{
|
|
||||||
std::string dst;
|
|
||||||
for (size_t i = 0; i < src.size(); i++)
|
|
||||||
{
|
|
||||||
if (src[i] == '%' && isxdigit(src[i + 1]) && isxdigit(src[i + 2]))
|
|
||||||
{
|
|
||||||
char c1 = src[++i];
|
|
||||||
char c2 = src[++i];
|
|
||||||
c1 = c1 - 48 - ((c1 >= 'A') ? 7 : 0) - ((c1 >= 'a') ? 32 : 0);
|
|
||||||
c2 = c2 - 48 - ((c2 >= 'A') ? 7 : 0) - ((c2 >= 'a') ? 32 : 0);
|
|
||||||
dst += (char)(c1 * 16 + c2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (src[i] == '+')
|
|
||||||
{
|
|
||||||
dst += ' ';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dst += src[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dst;
|
|
||||||
} // rfc1738_decode
|
|
||||||
|
|
||||||
|
|
||||||
bool Utility::isipv4(const std::string& str)
|
|
||||||
{
|
|
||||||
int dots = 0;
|
|
||||||
// %! ignore :port?
|
|
||||||
for (size_t i = 0; i < str.size(); i++)
|
|
||||||
{
|
|
||||||
if (str[i] == '.')
|
|
||||||
dots++;
|
|
||||||
else
|
|
||||||
if (!isdigit(str[i]))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (dots != 3)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Utility::isipv6(const std::string& str)
|
|
||||||
{
|
|
||||||
size_t qc = 0;
|
|
||||||
size_t qd = 0;
|
|
||||||
for (size_t i = 0; i < str.size(); i++)
|
|
||||||
{
|
|
||||||
qc += (str[i] == ':') ? 1 : 0;
|
|
||||||
qd += (str[i] == '.') ? 1 : 0;
|
|
||||||
}
|
|
||||||
if (qc > 7)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (qd && qd != 3)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Parse pa(str,":.");
|
|
||||||
std::string tmp = pa.getword();
|
|
||||||
while (!tmp.empty())
|
|
||||||
{
|
|
||||||
if (tmp.size() > 4)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (size_t i = 0; i < tmp.size(); i++)
|
|
||||||
{
|
|
||||||
if (tmp[i] < '0' || (tmp[i] > '9' && tmp[i] < 'A') ||
|
|
||||||
(tmp[i] > 'F' && tmp[i] < 'a') || tmp[i] > 'f')
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
tmp = pa.getword();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Utility::u2ip(const std::string& str, ipaddr_t& l)
|
|
||||||
{
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
bool r = Utility::u2ip(str, sa);
|
|
||||||
memcpy(&l, &sa.sin_addr, sizeof(l));
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
bool Utility::u2ip(const std::string& str, struct in6_addr& l)
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 sa;
|
|
||||||
bool r = Utility::u2ip(str, sa);
|
|
||||||
l = sa.sin6_addr;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void Utility::l2ip(const ipaddr_t ip, std::string& str)
|
|
||||||
{
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin_family = AF_INET;
|
|
||||||
memcpy(&sa.sin_addr, &ip, sizeof(sa.sin_addr));
|
|
||||||
Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), str, NI_NUMERICHOST);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Utility::l2ip(const in_addr& ip, std::string& str)
|
|
||||||
{
|
|
||||||
struct sockaddr_in sa;
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin_family = AF_INET;
|
|
||||||
sa.sin_addr = ip;
|
|
||||||
Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), str, NI_NUMERICHOST);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
void Utility::l2ip(const struct in6_addr& ip, std::string& str,bool mixed)
|
|
||||||
{
|
|
||||||
char slask[100]; // l2ip temporary
|
|
||||||
*slask = 0;
|
|
||||||
unsigned int prev = 0;
|
|
||||||
bool skipped = false;
|
|
||||||
bool ok_to_skip = true;
|
|
||||||
if (mixed)
|
|
||||||
{
|
|
||||||
unsigned short x;
|
|
||||||
unsigned short addr16[8];
|
|
||||||
memcpy(addr16, &ip, sizeof(addr16));
|
|
||||||
for (size_t i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
x = ntohs(addr16[i]);
|
|
||||||
if (*slask && (x || !ok_to_skip || prev))
|
|
||||||
strcat(slask,":");
|
|
||||||
if (x || !ok_to_skip)
|
|
||||||
{
|
|
||||||
sprintf(slask + strlen(slask),"%x", x);
|
|
||||||
if (x && skipped)
|
|
||||||
ok_to_skip = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
skipped = true;
|
|
||||||
}
|
|
||||||
prev = x;
|
|
||||||
}
|
|
||||||
x = ntohs(addr16[6]);
|
|
||||||
sprintf(slask + strlen(slask),":%u.%u",x / 256,x & 255);
|
|
||||||
x = ntohs(addr16[7]);
|
|
||||||
sprintf(slask + strlen(slask),".%u.%u",x / 256,x & 255);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 sa;
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin6_family = AF_INET6;
|
|
||||||
sa.sin6_addr = ip;
|
|
||||||
Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), str, NI_NUMERICHOST);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
str = slask;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int Utility::in6_addr_compare(in6_addr a,in6_addr b)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
if (a.s6_addr[i] < b.s6_addr[i])
|
|
||||||
return -1;
|
|
||||||
if (a.s6_addr[i] > b.s6_addr[i])
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void Utility::ResolveLocal()
|
|
||||||
{
|
|
||||||
char h[256];
|
|
||||||
|
|
||||||
// get local hostname and translate into ip-address
|
|
||||||
*h = 0;
|
|
||||||
gethostname(h,255);
|
|
||||||
{
|
|
||||||
if (Utility::u2ip(h, m_ip))
|
|
||||||
{
|
|
||||||
Utility::l2ip(m_ip, m_addr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
memset(&m_local_ip6, 0, sizeof(m_local_ip6));
|
|
||||||
{
|
|
||||||
if (Utility::u2ip(h, m_local_ip6))
|
|
||||||
{
|
|
||||||
Utility::l2ip(m_local_ip6, m_local_addr6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
m_host = h;
|
|
||||||
m_local_resolved = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const std::string& Utility::GetLocalHostname()
|
|
||||||
{
|
|
||||||
if (!m_local_resolved)
|
|
||||||
{
|
|
||||||
ResolveLocal();
|
|
||||||
}
|
|
||||||
return m_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ipaddr_t Utility::GetLocalIP()
|
|
||||||
{
|
|
||||||
if (!m_local_resolved)
|
|
||||||
{
|
|
||||||
ResolveLocal();
|
|
||||||
}
|
|
||||||
return m_ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const std::string& Utility::GetLocalAddress()
|
|
||||||
{
|
|
||||||
if (!m_local_resolved)
|
|
||||||
{
|
|
||||||
ResolveLocal();
|
|
||||||
}
|
|
||||||
return m_addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
const struct in6_addr& Utility::GetLocalIP6()
|
|
||||||
{
|
|
||||||
if (!m_local_resolved)
|
|
||||||
{
|
|
||||||
ResolveLocal();
|
|
||||||
}
|
|
||||||
return m_local_ip6;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const std::string& Utility::GetLocalAddress6()
|
|
||||||
{
|
|
||||||
if (!m_local_resolved)
|
|
||||||
{
|
|
||||||
ResolveLocal();
|
|
||||||
}
|
|
||||||
return m_local_addr6;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void Utility::SetEnv(const std::string& var,const std::string& value)
|
|
||||||
{
|
|
||||||
#if (defined(SOLARIS8) || defined(SOLARIS))
|
|
||||||
{
|
|
||||||
static std::map<std::string, char *> vmap;
|
|
||||||
if (vmap.find(var) != vmap.end())
|
|
||||||
{
|
|
||||||
delete[] vmap[var];
|
|
||||||
}
|
|
||||||
vmap[var] = new char[var.size() + 1 + value.size() + 1];
|
|
||||||
sprintf(vmap[var], "%s=%s", var.c_str(), value.c_str());
|
|
||||||
putenv( vmap[var] );
|
|
||||||
}
|
|
||||||
#elif defined _WIN32
|
|
||||||
{
|
|
||||||
std::string slask = var + "=" + value;
|
|
||||||
_putenv( (char *)slask.c_str());
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
setenv(var.c_str(), value.c_str(), 1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::Sa2String(struct sockaddr *sa)
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
if (sa -> sa_family == AF_INET6)
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa;
|
|
||||||
std::string tmp;
|
|
||||||
Utility::l2ip(sa6 -> sin6_addr, tmp);
|
|
||||||
return tmp + ":" + Utility::l2string(ntohs(sa6 -> sin6_port));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
if (sa -> sa_family == AF_INET)
|
|
||||||
{
|
|
||||||
struct sockaddr_in *sa4 = (struct sockaddr_in *)sa;
|
|
||||||
ipaddr_t a;
|
|
||||||
memcpy(&a, &sa4 -> sin_addr, 4);
|
|
||||||
std::string tmp;
|
|
||||||
Utility::l2ip(a, tmp);
|
|
||||||
return tmp + ":" + Utility::l2string(ntohs(sa4 -> sin_port));
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Utility::GetTime(struct timeval *p)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
FILETIME ft; // Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
|
|
||||||
GetSystemTimeAsFileTime(&ft);
|
|
||||||
uint64_t tt;
|
|
||||||
memcpy(&tt, &ft, sizeof(tt));
|
|
||||||
tt /= 10; // make it usecs
|
|
||||||
p->tv_sec = (long)tt / 1000000;
|
|
||||||
p->tv_usec = (long)tt % 1000000;
|
|
||||||
#else
|
|
||||||
gettimeofday(p, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::auto_ptr<SocketAddress> Utility::CreateAddress(struct sockaddr *sa,socklen_t sa_len)
|
|
||||||
{
|
|
||||||
switch (sa -> sa_family)
|
|
||||||
{
|
|
||||||
case AF_INET:
|
|
||||||
if (sa_len == sizeof(struct sockaddr_in))
|
|
||||||
{
|
|
||||||
struct sockaddr_in *p = (struct sockaddr_in *)sa;
|
|
||||||
return std::auto_ptr<SocketAddress>(new Ipv4Address(*p));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
case AF_INET6:
|
|
||||||
if (sa_len == sizeof(struct sockaddr_in6))
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 *p = (struct sockaddr_in6 *)sa;
|
|
||||||
return std::auto_ptr<SocketAddress>(new Ipv6Address(*p));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return std::auto_ptr<SocketAddress>(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Utility::u2ip(const std::string& host, struct sockaddr_in& sa, int ai_flags)
|
|
||||||
{
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin_family = AF_INET;
|
|
||||||
#ifdef NO_GETADDRINFO
|
|
||||||
if ((ai_flags & AI_NUMERICHOST) != 0 || isipv4(host))
|
|
||||||
{
|
|
||||||
Parse pa((char *)host.c_str(), ".");
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
unsigned char b1;
|
|
||||||
unsigned char b2;
|
|
||||||
unsigned char b3;
|
|
||||||
unsigned char b4;
|
|
||||||
} a;
|
|
||||||
ipaddr_t l;
|
|
||||||
} u;
|
|
||||||
u.a.b1 = static_cast<unsigned char>(pa.getvalue());
|
|
||||||
u.a.b2 = static_cast<unsigned char>(pa.getvalue());
|
|
||||||
u.a.b3 = static_cast<unsigned char>(pa.getvalue());
|
|
||||||
u.a.b4 = static_cast<unsigned char>(pa.getvalue());
|
|
||||||
memcpy(&sa.sin_addr, &u.l, sizeof(sa.sin_addr));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#ifndef LINUX
|
|
||||||
struct hostent *he = gethostbyname( host.c_str() );
|
|
||||||
if (!he)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(&sa.sin_addr, he -> h_addr, sizeof(sa.sin_addr));
|
|
||||||
#else
|
|
||||||
struct hostent he;
|
|
||||||
struct hostent *result = NULL;
|
|
||||||
int myerrno = 0;
|
|
||||||
char buf[2000];
|
|
||||||
int n = gethostbyname_r(host.c_str(), &he, buf, sizeof(buf), &result, &myerrno);
|
|
||||||
if (n || !result)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (he.h_addr_list && he.h_addr_list[0])
|
|
||||||
memcpy(&sa.sin_addr, he.h_addr, 4);
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
struct addrinfo hints;
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
|
||||||
// AI_NUMERICHOST
|
|
||||||
// AI_CANONNAME
|
|
||||||
// AI_PASSIVE - server
|
|
||||||
// AI_ADDRCONFIG
|
|
||||||
// AI_V4MAPPED
|
|
||||||
// AI_ALL
|
|
||||||
// AI_NUMERICSERV
|
|
||||||
hints.ai_flags = ai_flags;
|
|
||||||
hints.ai_family = AF_INET;
|
|
||||||
hints.ai_socktype = 0;
|
|
||||||
hints.ai_protocol = 0;
|
|
||||||
struct addrinfo *res;
|
|
||||||
if (Utility::isipv4(host))
|
|
||||||
hints.ai_flags |= AI_NUMERICHOST;
|
|
||||||
int n = getaddrinfo(host.c_str(), NULL, &hints, &res);
|
|
||||||
if (!n)
|
|
||||||
{
|
|
||||||
std::vector<struct addrinfo *> vec;
|
|
||||||
struct addrinfo *ai = res;
|
|
||||||
while (ai)
|
|
||||||
{
|
|
||||||
if (ai -> ai_addrlen == sizeof(sa))
|
|
||||||
vec.push_back( ai );
|
|
||||||
ai = ai -> ai_next;
|
|
||||||
}
|
|
||||||
if (vec.empty())
|
|
||||||
return false;
|
|
||||||
ai = vec[Utility::Rnd() % vec.size()];
|
|
||||||
{
|
|
||||||
memcpy(&sa, ai -> ai_addr, ai -> ai_addrlen);
|
|
||||||
}
|
|
||||||
freeaddrinfo(res);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
std::string error = "Error: ";
|
|
||||||
#ifndef __CYGWIN__
|
|
||||||
error += gai_strerror(n);
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
#endif // NO_GETADDRINFO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
#ifdef IPPROTO_IPV6
|
|
||||||
bool Utility::u2ip(const std::string& host, struct sockaddr_in6& sa, int ai_flags)
|
|
||||||
{
|
|
||||||
memset(&sa, 0, sizeof(sa));
|
|
||||||
sa.sin6_family = AF_INET6;
|
|
||||||
#ifdef NO_GETADDRINFO
|
|
||||||
if ((ai_flags & AI_NUMERICHOST) != 0 || isipv6(host))
|
|
||||||
{
|
|
||||||
std::list<std::string> vec;
|
|
||||||
size_t x = 0;
|
|
||||||
for (size_t i = 0; i <= host.size(); i++)
|
|
||||||
{
|
|
||||||
if (i == host.size() || host[i] == ':')
|
|
||||||
{
|
|
||||||
std::string s = host.substr(x, i - x);
|
|
||||||
//
|
|
||||||
if (strstr(s.c_str(),".")) // x.x.x.x
|
|
||||||
{
|
|
||||||
Parse pa(s,".");
|
|
||||||
char slask[100]; // u2ip temporary hex2string conversion
|
|
||||||
unsigned long b0 = static_cast<unsigned long>(pa.getvalue());
|
|
||||||
unsigned long b1 = static_cast<unsigned long>(pa.getvalue());
|
|
||||||
unsigned long b2 = static_cast<unsigned long>(pa.getvalue());
|
|
||||||
unsigned long b3 = static_cast<unsigned long>(pa.getvalue());
|
|
||||||
sprintf(slask,"%lx",b0 * 256 + b1);
|
|
||||||
vec.push_back(slask);
|
|
||||||
sprintf(slask,"%lx",b2 * 256 + b3);
|
|
||||||
vec.push_back(slask);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vec.push_back(s);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
x = i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
size_t sz = vec.size(); // number of byte pairs
|
|
||||||
size_t i = 0; // index in in6_addr.in6_u.u6_addr16[] ( 0 .. 7 )
|
|
||||||
unsigned short addr16[8];
|
|
||||||
for (std::list<std::string>::iterator it = vec.begin(); it != vec.end(); it++)
|
|
||||||
{
|
|
||||||
std::string bytepair = *it;
|
|
||||||
if (!bytepair.empty())
|
|
||||||
{
|
|
||||||
addr16[i++] = htons(Utility::hex2unsigned(bytepair));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
addr16[i++] = 0;
|
|
||||||
while (sz++ < 8)
|
|
||||||
{
|
|
||||||
addr16[i++] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memcpy(&sa.sin6_addr, addr16, sizeof(addr16));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#ifdef SOLARIS
|
|
||||||
int errnum = 0;
|
|
||||||
struct hostent *he = getipnodebyname( host.c_str(), AF_INET6, 0, &errnum );
|
|
||||||
#else
|
|
||||||
struct hostent *he = gethostbyname2( host.c_str(), AF_INET6 );
|
|
||||||
#endif
|
|
||||||
if (!he)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
memcpy(&sa.sin6_addr,he -> h_addr_list[0],he -> h_length);
|
|
||||||
#ifdef SOLARIS
|
|
||||||
free(he);
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
struct addrinfo hints;
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
|
||||||
hints.ai_flags = ai_flags;
|
|
||||||
hints.ai_family = AF_INET6;
|
|
||||||
hints.ai_socktype = 0;
|
|
||||||
hints.ai_protocol = 0;
|
|
||||||
struct addrinfo *res;
|
|
||||||
if (Utility::isipv6(host))
|
|
||||||
hints.ai_flags |= AI_NUMERICHOST;
|
|
||||||
int n = getaddrinfo(host.c_str(), NULL, &hints, &res);
|
|
||||||
if (!n)
|
|
||||||
{
|
|
||||||
std::vector<struct addrinfo *> vec;
|
|
||||||
struct addrinfo *ai = res;
|
|
||||||
while (ai)
|
|
||||||
{
|
|
||||||
if (ai -> ai_addrlen == sizeof(sa))
|
|
||||||
vec.push_back( ai );
|
|
||||||
ai = ai -> ai_next;
|
|
||||||
}
|
|
||||||
if (vec.empty())
|
|
||||||
return false;
|
|
||||||
ai = vec[Utility::Rnd() % vec.size()];
|
|
||||||
{
|
|
||||||
memcpy(&sa, ai -> ai_addr, ai -> ai_addrlen);
|
|
||||||
}
|
|
||||||
freeaddrinfo(res);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
std::string error = "Error: ";
|
|
||||||
#ifndef __CYGWIN__
|
|
||||||
error += gai_strerror(n);
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
#endif // NO_GETADDRINFO
|
|
||||||
}
|
|
||||||
#endif // IPPROTO_IPV6
|
|
||||||
#endif // ENABLE_IPV6
|
|
||||||
|
|
||||||
|
|
||||||
bool Utility::reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, int flags)
|
|
||||||
{
|
|
||||||
std::string service;
|
|
||||||
return Utility::reverse(sa, sa_len, hostname, service, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Utility::reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, std::string& service, int flags)
|
|
||||||
{
|
|
||||||
hostname = "";
|
|
||||||
service = "";
|
|
||||||
#ifdef NO_GETADDRINFO
|
|
||||||
switch (sa -> sa_family)
|
|
||||||
{
|
|
||||||
case AF_INET:
|
|
||||||
if (flags & NI_NUMERICHOST)
|
|
||||||
{
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
unsigned char b1;
|
|
||||||
unsigned char b2;
|
|
||||||
unsigned char b3;
|
|
||||||
unsigned char b4;
|
|
||||||
} a;
|
|
||||||
ipaddr_t l;
|
|
||||||
} u;
|
|
||||||
struct sockaddr_in *sa_in = (struct sockaddr_in *)sa;
|
|
||||||
memcpy(&u.l, &sa_in -> sin_addr, sizeof(u.l));
|
|
||||||
char tmp[100];
|
|
||||||
sprintf(tmp, "%u.%u.%u.%u", u.a.b1, u.a.b2, u.a.b3, u.a.b4);
|
|
||||||
hostname = tmp;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct sockaddr_in *sa_in = (struct sockaddr_in *)sa;
|
|
||||||
struct hostent *h = gethostbyaddr( (const char *)&sa_in -> sin_addr, sizeof(sa_in -> sin_addr), AF_INET);
|
|
||||||
if (h)
|
|
||||||
{
|
|
||||||
hostname = h -> h_name;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
case AF_INET6:
|
|
||||||
if (flags & NI_NUMERICHOST)
|
|
||||||
{
|
|
||||||
char slask[100]; // l2ip temporary
|
|
||||||
*slask = 0;
|
|
||||||
unsigned int prev = 0;
|
|
||||||
bool skipped = false;
|
|
||||||
bool ok_to_skip = true;
|
|
||||||
{
|
|
||||||
unsigned short addr16[8];
|
|
||||||
struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)sa;
|
|
||||||
memcpy(addr16, &sa_in6 -> sin6_addr, sizeof(addr16));
|
|
||||||
for (size_t i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
unsigned short x = ntohs(addr16[i]);
|
|
||||||
if (*slask && (x || !ok_to_skip || prev))
|
|
||||||
strcat(slask,":");
|
|
||||||
if (x || !ok_to_skip)
|
|
||||||
{
|
|
||||||
sprintf(slask + strlen(slask),"%x", x);
|
|
||||||
if (x && skipped)
|
|
||||||
ok_to_skip = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
skipped = true;
|
|
||||||
}
|
|
||||||
prev = x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!*slask)
|
|
||||||
strcpy(slask, "::");
|
|
||||||
hostname = slask;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// %! TODO: ipv6 reverse lookup
|
|
||||||
struct sockaddr_in6 *sa_in = (struct sockaddr_in6 *)sa;
|
|
||||||
struct hostent *h = gethostbyaddr( (const char *)&sa_in -> sin6_addr, sizeof(sa_in -> sin6_addr), AF_INET6);
|
|
||||||
if (h)
|
|
||||||
{
|
|
||||||
hostname = h -> h_name;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
char host[NI_MAXHOST];
|
|
||||||
char serv[NI_MAXSERV];
|
|
||||||
// NI_NOFQDN
|
|
||||||
// NI_NUMERICHOST
|
|
||||||
// NI_NAMEREQD
|
|
||||||
// NI_NUMERICSERV
|
|
||||||
// NI_DGRAM
|
|
||||||
int n = getnameinfo(sa, sa_len, host, sizeof(host), serv, sizeof(serv), flags);
|
|
||||||
if (n)
|
|
||||||
{
|
|
||||||
// EAI_AGAIN
|
|
||||||
// EAI_BADFLAGS
|
|
||||||
// EAI_FAIL
|
|
||||||
// EAI_FAMILY
|
|
||||||
// EAI_MEMORY
|
|
||||||
// EAI_NONAME
|
|
||||||
// EAI_OVERFLOW
|
|
||||||
// EAI_SYSTEM
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
hostname = host;
|
|
||||||
service = serv;
|
|
||||||
return true;
|
|
||||||
#endif // NO_GETADDRINFO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Utility::u2service(const std::string& name, int& service, int ai_flags)
|
|
||||||
{
|
|
||||||
#ifdef NO_GETADDRINFO
|
|
||||||
// %!
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
struct addrinfo hints;
|
|
||||||
service = 0;
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
|
||||||
// AI_NUMERICHOST
|
|
||||||
// AI_CANONNAME
|
|
||||||
// AI_PASSIVE - server
|
|
||||||
// AI_ADDRCONFIG
|
|
||||||
// AI_V4MAPPED
|
|
||||||
// AI_ALL
|
|
||||||
// AI_NUMERICSERV
|
|
||||||
hints.ai_flags = ai_flags;
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
|
||||||
hints.ai_socktype = 0;
|
|
||||||
hints.ai_protocol = 0;
|
|
||||||
struct addrinfo *res;
|
|
||||||
int n = getaddrinfo(NULL, name.c_str(), &hints, &res);
|
|
||||||
if (!n)
|
|
||||||
{
|
|
||||||
service = res -> ai_protocol;
|
|
||||||
freeaddrinfo(res);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
#endif // NO_GETADDRINFO
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long Utility::ThreadID()
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
return GetCurrentThreadId();
|
|
||||||
#else
|
|
||||||
return (unsigned long)pthread_self();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::ToLower(const std::string& str)
|
|
||||||
{
|
|
||||||
std::string r;
|
|
||||||
for (size_t i = 0; i < str.size(); i++)
|
|
||||||
{
|
|
||||||
if (str[i] >= 'A' && str[i] <= 'Z')
|
|
||||||
r += str[i] | 32;
|
|
||||||
else
|
|
||||||
r += str[i];
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::ToUpper(const std::string& str)
|
|
||||||
{
|
|
||||||
std::string r;
|
|
||||||
for (size_t i = 0; i < str.size(); i++)
|
|
||||||
{
|
|
||||||
if (str[i] >= 'a' && str[i] <= 'z')
|
|
||||||
r += (char)(str[i] - 32);
|
|
||||||
else
|
|
||||||
r += str[i];
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string Utility::ToString(double d)
|
|
||||||
{
|
|
||||||
char tmp[100];
|
|
||||||
sprintf(tmp, "%f", d);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long Utility::Rnd()
|
|
||||||
{
|
|
||||||
static Utility::Rng generator( (unsigned long)time(NULL) );
|
|
||||||
return generator.Get();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Utility::Rng::Rng(unsigned long seed) : m_value( 0 )
|
|
||||||
{
|
|
||||||
m_tmp[0]= seed & 0xffffffffUL;
|
|
||||||
for (int i = 1; i < TWIST_LEN; i++)
|
|
||||||
{
|
|
||||||
m_tmp[i] = (1812433253UL * (m_tmp[i - 1] ^ (m_tmp[i - 1] >> 30)) + i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long Utility::Rng::Get()
|
|
||||||
{
|
|
||||||
unsigned long val = m_tmp[m_value];
|
|
||||||
++m_value;
|
|
||||||
if (m_value == TWIST_LEN)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < TWIST_IB; ++i)
|
|
||||||
{
|
|
||||||
unsigned long s = TWIST(m_tmp, i, i + 1);
|
|
||||||
m_tmp[i] = m_tmp[i + TWIST_IA] ^ (s >> 1) ^ MAGIC_TWIST(s);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
for (int i = 0; i < TWIST_LEN - 1; ++i)
|
|
||||||
{
|
|
||||||
unsigned long s = TWIST(m_tmp, i, i + 1);
|
|
||||||
m_tmp[i] = m_tmp[i - TWIST_IB] ^ (s >> 1) ^ MAGIC_TWIST(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsigned long s = TWIST(m_tmp, TWIST_LEN - 1, 0);
|
|
||||||
m_tmp[TWIST_LEN - 1] = m_tmp[TWIST_IA - 1] ^ (s >> 1) ^ MAGIC_TWIST(s);
|
|
||||||
|
|
||||||
m_value = 0;
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SOCKETS_NAMESPACE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
The following are the only .cpp files used from the new network library (v2.2.8) This file is just for future reference.
|
|
||||||
|
|
||||||
Base64.cpp
|
|
||||||
Exception.cpp
|
|
||||||
Ipv4Address.cpp
|
|
||||||
Ipv6Address.cpp
|
|
||||||
Lock.cpp
|
|
||||||
Mutex.cpp
|
|
||||||
Parse.cpp
|
|
||||||
ResolvServer.cpp
|
|
||||||
ResolvSocket.cpp
|
|
||||||
Socket.cpp
|
|
||||||
SocketHandler.cpp
|
|
||||||
socket_include.cpp
|
|
||||||
StdoutLog.cpp
|
|
||||||
StreamSocket.cpp
|
|
||||||
TcpSocket.cpp
|
|
||||||
Thread.cpp
|
|
||||||
UdpSocket.cpp
|
|
||||||
Utility.cpp
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
/** \file socket_include.cpp
|
|
||||||
** \date 2004-11-28
|
|
||||||
** \author grymse@alhem.net
|
|
||||||
**/
|
|
||||||
/*
|
|
||||||
Copyright (C) 2004-2007 Anders Hedstrom
|
|
||||||
|
|
||||||
This library is made available under the terms of the GNU GPL.
|
|
||||||
|
|
||||||
If you would like to use this library in a closed-source application,
|
|
||||||
a separate license agreement is available. For information about
|
|
||||||
the closed-source license agreement for the C++ sockets library,
|
|
||||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
|
||||||
email license@alhem.net.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// only to be included in win32 projects
|
|
||||||
const char *StrError(int x)
|
|
||||||
{
|
|
||||||
static char tmp[100];
|
|
||||||
switch (x)
|
|
||||||
{
|
|
||||||
case 10004: return "Interrupted function call.";
|
|
||||||
case 10013: return "Permission denied.";
|
|
||||||
case 10014: return "Bad address.";
|
|
||||||
case 10022: return "Invalid argument.";
|
|
||||||
case 10024: return "Too many open files.";
|
|
||||||
case 10035: return "Resource temporarily unavailable.";
|
|
||||||
case 10036: return "Operation now in progress.";
|
|
||||||
case 10037: return "Operation already in progress.";
|
|
||||||
case 10038: return "Socket operation on nonsocket.";
|
|
||||||
case 10039: return "Destination address required.";
|
|
||||||
case 10040: return "Message too long.";
|
|
||||||
case 10041: return "Protocol wrong type for socket.";
|
|
||||||
case 10042: return "Bad protocol option.";
|
|
||||||
case 10043: return "Protocol not supported.";
|
|
||||||
case 10044: return "Socket type not supported.";
|
|
||||||
case 10045: return "Operation not supported.";
|
|
||||||
case 10046: return "Protocol family not supported.";
|
|
||||||
case 10047: return "Address family not supported by protocol family.";
|
|
||||||
case 10048: return "Address already in use.";
|
|
||||||
case 10049: return "Cannot assign requested address.";
|
|
||||||
case 10050: return "Network is down.";
|
|
||||||
case 10051: return "Network is unreachable.";
|
|
||||||
case 10052: return "Network dropped connection on reset.";
|
|
||||||
case 10053: return "Software caused connection abort.";
|
|
||||||
case 10054: return "Connection reset by peer.";
|
|
||||||
case 10055: return "No buffer space available.";
|
|
||||||
case 10056: return "Socket is already connected.";
|
|
||||||
case 10057: return "Socket is not connected.";
|
|
||||||
case 10058: return "Cannot send after socket shutdown.";
|
|
||||||
case 10060: return "Connection timed out.";
|
|
||||||
case 10061: return "Connection refused.";
|
|
||||||
case 10064: return "Host is down.";
|
|
||||||
case 10065: return "No route to host.";
|
|
||||||
case 10067: return "Too many processes.";
|
|
||||||
case 10091: return "Network subsystem is unavailable.";
|
|
||||||
case 10092: return "Winsock.dll version out of range.";
|
|
||||||
case 10093: return "Successful WSAStartup not yet performed.";
|
|
||||||
case 10101: return "Graceful shutdown in progress.";
|
|
||||||
case 10109: return "Class type not found.";
|
|
||||||
case 11001: return "Host not found.";
|
|
||||||
case 11002: return "Nonauthoritative host not found.";
|
|
||||||
case 11003: return "This is a nonrecoverable error.";
|
|
||||||
case 11004: return "Valid name, no data record of requested type.";
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sprintf(tmp, "Winsock error code: %d", x);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `character_db_version`;
|
DROP TABLE IF EXISTS `character_db_version`;
|
||||||
CREATE TABLE `character_db_version` (
|
CREATE TABLE `character_db_version` (
|
||||||
`required_9849_01_characters_saved_variables` bit(1) default NULL
|
`required_10007_01_characters_pet_aura` bit(1) default NULL
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
@ -1033,7 +1033,7 @@ CREATE TABLE `groups` (
|
||||||
`icon6` int(11) unsigned NOT NULL,
|
`icon6` int(11) unsigned NOT NULL,
|
||||||
`icon7` int(11) unsigned NOT NULL,
|
`icon7` int(11) unsigned NOT NULL,
|
||||||
`icon8` int(11) unsigned NOT NULL,
|
`icon8` int(11) unsigned NOT NULL,
|
||||||
`isRaid` tinyint(1) unsigned NOT NULL,
|
`groupType` tinyint(1) unsigned NOT NULL,
|
||||||
`difficulty` tinyint(3) unsigned NOT NULL default '0',
|
`difficulty` tinyint(3) unsigned NOT NULL default '0',
|
||||||
`raiddifficulty` int(11) UNSIGNED NOT NULL default '0',
|
`raiddifficulty` int(11) UNSIGNED NOT NULL default '0',
|
||||||
PRIMARY KEY (`groupId`),
|
PRIMARY KEY (`groupId`),
|
||||||
|
|
|
||||||
1670
sql/mangos.sql
1670
sql/mangos.sql
File diff suppressed because it is too large
Load diff
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
/* Current table fill progress state: */
|
/* Current table fill progress state: */
|
||||||
/* SpellEffect.cpp from start until end of Spell::EffectTameCreature */
|
/* SpellEffect.cpp from start until end of Spell::EffectTameCreature */
|
||||||
/* at 9ba5ff723a68e397a53b3ffe5ec8d749e8ba3eab [9690] state */
|
/* Spell.cpp */
|
||||||
|
/* at 6ee669d1d52581d4707c6475b512e6cc53844121 [9944] state */
|
||||||
|
|
||||||
DROP TABLE IF EXISTS spell_check;
|
DROP TABLE IF EXISTS spell_check;
|
||||||
CREATE TABLE `spell_check` (
|
CREATE TABLE `spell_check` (
|
||||||
|
|
@ -39,11 +40,13 @@ CREATE TABLE `spell_check` (
|
||||||
INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMaskB,SpellIcon,SpellVisual,SpellCategory,EffectType,EffectAura,EffectIdx,Name,Code) VALUES
|
INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMaskB,SpellIcon,SpellVisual,SpellCategory,EffectType,EffectAura,EffectIdx,Name,Code) VALUES
|
||||||
/* sorted by spell ids */
|
/* sorted by spell ids */
|
||||||
/*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */
|
/*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */
|
||||||
(1454, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
|
||||||
(1455, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
|
||||||
(1456, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
|
||||||
(1535, 11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(1535, 11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
|
(1784, 8, -1, -1, -1, -1, -1, -1, -1,-1,'Stealth', 'Spell::EffectTriggerSpell'),
|
||||||
(2584, -1, -1, -1, -1, -1, -1, -1, 4,-1,'Waiting to Resurrect', 'Spell::EffectSpiritHeal'),
|
(2584, -1, -1, -1, -1, -1, -1, -1, 4,-1,'Waiting to Resurrect', 'Spell::EffectSpiritHeal'),
|
||||||
|
(2641, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Dismiss Pet', 'Spell::CheckTargetCreatureType'),
|
||||||
|
(2764, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Throw', 'Spell::CheckCast'),
|
||||||
|
(2825, 11, -1, -1, -1, -1, -1, -1, -1,-1,'Bloodlust', 'Spell::cast'),
|
||||||
|
(6788, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Weakened Soul', 'Spell::cast'),
|
||||||
(9512, -1, -1, -1, -1, -1, -1, 30, -1,-1,'Restore Energy', 'Spell::EffectEnergize'),
|
(9512, -1, -1, -1, -1, -1, -1, 30, -1,-1,'Restore Energy', 'Spell::EffectEnergize'),
|
||||||
(4073, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Mechanical Dragonling', 'Spell::EffectDummy'),
|
(4073, -1, -1, -1, -1, -1, -1, -1, -1,-1,'Mechanical Dragonling', 'Spell::EffectDummy'),
|
||||||
(5938, 8, -1, -1, -1, -1, -1, 3, -1,-1,'Shiv', 'Spell::EffectDummy'),
|
(5938, 8, -1, -1, -1, -1, -1, 3, -1,-1,'Shiv', 'Spell::EffectDummy'),
|
||||||
|
|
@ -73,9 +76,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(11307,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(11307,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(11314,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(11314,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(11315,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(11315,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(11687, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
(11196,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Recently Bandaged', 'Spell::cast'),
|
||||||
(11688, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
|
||||||
(11689, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
|
||||||
(11958, 3, -1, -1, -1, -1, -1, 3, -1,-1,'Cold Snap', 'Spell::EffectDummy'),
|
(11958, 3, -1, -1, -1, -1, -1, 3, -1,-1,'Cold Snap', 'Spell::EffectDummy'),
|
||||||
(12749,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mithril Mechanical Dragonling', 'Spell::EffectDummy'),
|
(12749,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mithril Mechanical Dragonling', 'Spell::EffectDummy'),
|
||||||
(12975, 4, -1, -1, -1, -1, -1, 3, -1,-1,'Last Stand', 'Spell::EffectDummy'),
|
(12975, 4, -1, -1, -1, -1, -1, 3, -1,-1,'Last Stand', 'Spell::EffectDummy'),
|
||||||
|
|
@ -86,30 +87,34 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(13166,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Gnomish Battle Chicken', 'Spell::EffectDummy'),
|
(13166,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Gnomish Battle Chicken', 'Spell::EffectDummy'),
|
||||||
(13567, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Dummy Trigger', 'Spell::EffectDummy'),
|
(13567, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Dummy Trigger', 'Spell::EffectDummy'),
|
||||||
(14185, 8, -1, -1, -1, -1, -1, 3, -1,-1,'Preparation', 'Spell::EffectDummy'),
|
(14185, 8, -1, -1, -1, -1, -1, 3, -1,-1,'Preparation', 'Spell::EffectDummy'),
|
||||||
|
(14278, 8, -1, -1, -1, -1, -1, -1, -1,-1,'Ghostly Strike', 'Spell::EffectWeaponDmg'),
|
||||||
|
(15237, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(15430, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(15431, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
(15998, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Capture Worg Pup', 'Spell::EffectDummy'),
|
(15998, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Capture Worg Pup', 'Spell::EffectDummy'),
|
||||||
(16566,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Net-o-Matic', 'Spell::EffectDummy'),
|
(16566,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Net-o-Matic', 'Spell::EffectDummy'),
|
||||||
(16589, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Noggenfogger Elixir', 'Spell::EffectDummy'),
|
(16589, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Noggenfogger Elixir', 'Spell::EffectDummy'),
|
||||||
(16591,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Noggenfogger Elixir', 'Spell::EffectDummy'),
|
(16591,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Noggenfogger Elixir', 'Spell::EffectDummy'),
|
||||||
(16593,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Noggenfogger Elixir', 'Spell::EffectDummy'),
|
(16593,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Noggenfogger Elixir', 'Spell::EffectDummy'),
|
||||||
(16595,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Noggenfogger Elixir', 'Spell::EffectDummy'),
|
(16595,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Noggenfogger Elixir', 'Spell::EffectDummy'),
|
||||||
|
(16857, 7, -1, -1, -1, -1, -1, -1, -1,-1,'Faerie Fire', 'Spell::cast'),
|
||||||
(17251, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Spirit Healer Res', 'Spell::EffectDummy'),
|
(17251, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Spirit Healer Res', 'Spell::EffectDummy'),
|
||||||
(17269,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Create Resonating Skull', 'Spell::EffectDummy'),
|
(17269,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Create Resonating Skull', 'Spell::EffectDummy'),
|
||||||
(17270,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Create Bone Dust', 'Spell::EffectDummy'),
|
(17270,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Create Bone Dust', 'Spell::EffectDummy'),
|
||||||
(17271, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Test Fetid Skull', 'Spell::EffectDummy'),
|
(17271, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Test Fetid Skull', 'Spell::EffectDummy'),
|
||||||
(18788,-1, -1, -1, -1, -1, -1, 1, -1,-1,'Demonic Sacrifice', 'Spell::EffectInstaKill'),
|
|
||||||
(18789,-1, -1, -1, -1, -1, -1, -1, -1,-1,'', 'Spell::EffectInstaKill'),
|
|
||||||
(18790,-1, -1, -1, -1, -1, -1, -1, -1,-1,'', 'Spell::EffectInstaKill'),
|
|
||||||
(18791,-1, -1, -1, -1, -1, -1, -1, -1,-1,'', 'Spell::EffectInstaKill'),
|
|
||||||
(18792,-1, -1, -1, -1, -1, -1, -1, -1,-1,'', 'Spell::EffectInstaKill'),
|
|
||||||
(19658,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Devour Magic Effect', 'Spell::EffectDispel'),
|
(19658,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Devour Magic Effect', 'Spell::EffectDispel'),
|
||||||
(19804,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Arcanite Dragonling', 'Spell::EffectDummy'),
|
(19804,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Arcanite Dragonling', 'Spell::EffectDummy'),
|
||||||
(19823,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova Visual', 'Spell::EffectDummy'),
|
(19823,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova Visual', 'Spell::EffectDummy'),
|
||||||
(20167,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Seal of Light', 'Spell::EffectHeal'),
|
(20167,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Seal of Light', 'Spell::EffectHeal'),
|
||||||
(20187,10, -1, -1, -1, -1, -1, 2, -1,-1,'Judgement of Righteousness', 'Spell::EffectSchoolDMG'),
|
(20187,10, -1, -1, -1, -1, -1, 2, -1,-1,'Judgement of Righteousness', 'Spell::EffectSchoolDMG'),
|
||||||
(20253, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Intercept', 'Spell::EffectSchoolDMG'),
|
(20253, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Intercept', 'Spell::EffectSchoolDMG'),
|
||||||
|
(20424,10, -1, -1, -1, -1, -1, -1, -1,-1,'Seal of Command', 'Spell::SetTargetMap'),
|
||||||
(20473,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(20473,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
|
(20577,-1, -1, -1, -1, -1, -1, 3, -1,-1,'Cannibalize', 'Spell::CheckTarget'),
|
||||||
(20577, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Cannibalize', 'Spell::EffectDummy'),
|
(20577, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Cannibalize', 'Spell::EffectDummy'),
|
||||||
|
(20577,-1, -1, -1, -1, -1, -1, 3, -1,-1,'Cannibalize', 'Spell::SetTargetMap'),
|
||||||
(20578,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cannibalize', 'Spell::EffectDummy'),
|
(20578,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cannibalize', 'Spell::EffectDummy'),
|
||||||
|
(20594, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Stoneskin', 'Spell::cast'),
|
||||||
(20647,-1, -1, -1, -1, -1, -1, 2, -1, 0,'Execute', 'Spell::EffectDummy'),
|
(20647,-1, -1, -1, -1, -1, -1, 2, -1, 0,'Execute', 'Spell::EffectDummy'),
|
||||||
(20929,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(20929,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(20930,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(20930,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
|
|
@ -122,6 +127,9 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(23076, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Mechanical Dragonling', 'Spell::EffectDummy'),
|
(23076, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Mechanical Dragonling', 'Spell::EffectDummy'),
|
||||||
(23133, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Gnomish Battle Chicken', 'Spell::EffectDummy'),
|
(23133, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Gnomish Battle Chicken', 'Spell::EffectDummy'),
|
||||||
(23170,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Brood Affliction: Bronze', 'Spell::EffectDummy'),
|
(23170,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Brood Affliction: Bronze', 'Spell::EffectDummy'),
|
||||||
|
(23334,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Horde Flag Drop', 'Spell::CheckCasterAuras'),
|
||||||
|
(23336,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Alliance Flag Drop', 'Spell::CheckCasterAuras'),
|
||||||
|
(23356,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Taming Lesson', 'Spell::CheckTargetCreatureType'),
|
||||||
(23441,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Gadgetzan Transporter', 'Spell::EffectDummy'),
|
(23441,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Gadgetzan Transporter', 'Spell::EffectDummy'),
|
||||||
(23442,-1, -1, -1, -1, -1, -1, 5, -1,-1,'Everlook Transporter', 'Spell::EffectTeleportUnits'),
|
(23442,-1, -1, -1, -1, -1, -1, 5, -1,-1,'Everlook Transporter', 'Spell::EffectTeleportUnits'),
|
||||||
(23444,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Transporter Malfunction', 'Spell::EffectDummy'),
|
(23444,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Transporter Malfunction', 'Spell::EffectDummy'),
|
||||||
|
|
@ -131,6 +139,9 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(23448, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Transporter Arrival', 'Spell::EffectDummy'),
|
(23448, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Transporter Arrival', 'Spell::EffectDummy'),
|
||||||
(23449,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Transporter Malfunction', 'Spell::EffectTeleportUnits'),
|
(23449,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Transporter Malfunction', 'Spell::EffectTeleportUnits'),
|
||||||
(23453, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Gnomish Transporter', 'Spell::EffectDummy'),
|
(23453, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Gnomish Transporter', 'Spell::EffectDummy'),
|
||||||
|
(23455,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(23458,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(23459,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
(23645, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Hourglass Sand', 'Spell::EffectDummy'),
|
(23645, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Hourglass Sand', 'Spell::EffectDummy'),
|
||||||
(23725, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Gift of Life', 'Spell::EffectDummy'),
|
(23725, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Gift of Life', 'Spell::EffectDummy'),
|
||||||
(23782,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Gift of Life', 'Spell::EffectDummy'),
|
(23782,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Gift of Life', 'Spell::EffectDummy'),
|
||||||
|
|
@ -142,11 +153,15 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(24532,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Burst of Energy', 'Spell::EffectEnergize'),
|
(24532,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Burst of Energy', 'Spell::EffectEnergize'),
|
||||||
(24571,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Blood Fury', 'Spell::EffectEnergize'),
|
(24571,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Blood Fury', 'Spell::EffectEnergize'),
|
||||||
(24575,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Brittle Armor', 'Spell::EffectTriggerSpell'),
|
(24575,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Brittle Armor', 'Spell::EffectTriggerSpell'),
|
||||||
|
(25329,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(25331, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
(25535,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(25535,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(25537,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(25537,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(25546,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(25546,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(25547,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(25547,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(25599, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Thundercrash', 'Spell::EffectSchoolDMG'),
|
(25599, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Thundercrash', 'Spell::EffectSchoolDMG'),
|
||||||
|
(25771,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Forbearance', 'Spell::cast'),
|
||||||
|
(25771,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Forbearance', 'Spell::CheckCast'),
|
||||||
(25858,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Reindeer', 'Spell::EffectDummy'),
|
(25858,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Reindeer', 'Spell::EffectDummy'),
|
||||||
(25859,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Reindeer', 'Spell::EffectDummy'),
|
(25859,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Reindeer', 'Spell::EffectDummy'),
|
||||||
(25860, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Reindeer Transformation', 'Spell::EffectDummy'),
|
(25860, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Reindeer Transformation', 'Spell::EffectDummy'),
|
||||||
|
|
@ -156,6 +171,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(25912,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(25912,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(25913,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(25913,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(25914,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(25914,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
|
(25991, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Poison Bolt Volley (Pincess Huhuran)','Spell::SetTargetMap'),
|
||||||
(26074, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Holiday Cheer', 'Spell::EffectDummy'),
|
(26074, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Holiday Cheer', 'Spell::EffectDummy'),
|
||||||
(26464,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mercurial Shield', 'Spell::EffectTriggerSpell'),
|
(26464,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mercurial Shield', 'Spell::EffectTriggerSpell'),
|
||||||
(26467,-1, -1, -1, -1, -1, -1, 6, 42, 0,'Persistent Shield', 'Spell::EffectDummy'),
|
(26467,-1, -1, -1, -1, -1, -1, 6, 42, 0,'Persistent Shield', 'Spell::EffectDummy'),
|
||||||
|
|
@ -164,11 +180,19 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(27174,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(27174,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(27175,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(27175,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(27176,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(27176,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(27222, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
(27799, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(27800, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(27801, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(27803,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(27804,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(27805,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
(28006, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Arcane Cloaking', 'Spell::EffectDummy'),
|
(28006, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Arcane Cloaking', 'Spell::EffectDummy'),
|
||||||
(28305,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mana Leech', 'Spell::EffectTriggerSpell'),
|
(28305,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mana Leech', 'Spell::EffectTriggerSpell'),
|
||||||
|
(28542, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Life Drain', 'Spell::SetTargetMap'),
|
||||||
|
(28796, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Poison Bolt Volley', 'Spell::SetTargetMap'),
|
||||||
(28884, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'),
|
(28884, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'),
|
||||||
(29142, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Eyesore Blaster', 'Spell::EffectSchoolDMG'),
|
(29142, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Eyesore Blaster', 'Spell::EffectSchoolDMG'),
|
||||||
|
(29213, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Curse of the Plaguebringer', 'Spell::SetTargetMap'),
|
||||||
(29294,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Naxxramas Entry Flag Effect DND', 'Spell::EffectDummy'),
|
(29294,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Naxxramas Entry Flag Effect DND', 'Spell::EffectDummy'),
|
||||||
(29200, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Purify Helboar Meat', 'Spell::EffectDummy'),
|
(29200, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Purify Helboar Meat', 'Spell::EffectDummy'),
|
||||||
(29277,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Purified Helboar Meat', 'Spell::EffectDummy'),
|
(29277,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Purified Helboar Meat', 'Spell::EffectDummy'),
|
||||||
|
|
@ -183,8 +207,12 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(30501,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Poultryized!', 'Spell::EffectDummy'),
|
(30501,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Poultryized!', 'Spell::EffectDummy'),
|
||||||
(30504,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Poultryized!', 'Spell::EffectDummy'),
|
(30504,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Poultryized!', 'Spell::EffectDummy'),
|
||||||
(30507, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Poultryizer', 'Spell::EffectDummy'),
|
(30507, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Poultryizer', 'Spell::EffectDummy'),
|
||||||
|
(30708,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Totem of Wrath', 'Spell::cast'),
|
||||||
|
(30843, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Enfeeble', 'Spell::SetTargetMap'),
|
||||||
(31225, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Shimmering Vessel', 'Spell::EffectDummy'),
|
(31225, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Shimmering Vessel', 'Spell::EffectDummy'),
|
||||||
(31231, 8, -1, -1, -1, -1, -1, 3, -1,-1,'Cheat Death', 'Spell::EffectDummy'),
|
(31231, 8, -1, -1, -1, -1, -1, 3, -1,-1,'Cheat Death', 'Spell::EffectDummy'),
|
||||||
|
(31298, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Sleep', 'Spell::SetTargetMap'),
|
||||||
|
(31347, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Doom', 'Spell::SetTargetMap'),
|
||||||
(31436, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Malevolent Cleave', 'Spell::EffectSchoolDMG'),
|
(31436, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Malevolent Cleave', 'Spell::EffectSchoolDMG'),
|
||||||
(31687, 3, -1, -1, -1, -1, -1, 3, -1,-1,'Summon Water Elemental', 'Spell::EffectDummy'),
|
(31687, 3, -1, -1, -1, -1, -1, 3, -1,-1,'Summon Water Elemental', 'Spell::EffectDummy'),
|
||||||
(31789,10, -1, -1, -1, -1, -1, 3, -1, 0,'Righteous Defense', 'Spell::EffectDummy'),
|
(31789,10, -1, -1, -1, -1, -1, 3, -1, 0,'Righteous Defense', 'Spell::EffectDummy'),
|
||||||
|
|
@ -192,8 +220,10 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(31803,-1, -1, -1, -1, -1, -1, 6, 3,-1,'Holy Vengeance', 'Spell::EffectSchoolDMG'),
|
(31803,-1, -1, -1, -1, -1, -1, 6, 3,-1,'Holy Vengeance', 'Spell::EffectSchoolDMG'),
|
||||||
(31818,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Life Tap', 'Spell::EffectDummy'),
|
(31818,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Life Tap', 'Spell::EffectDummy'),
|
||||||
(31930,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Judgements of the Wise', 'Spell::EffectEnergize'),
|
(31930,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Judgements of the Wise', 'Spell::EffectEnergize'),
|
||||||
|
(32182,11, -1, -1, -1, -1, -1, -1, -1,-1,'Heroism', 'Spell::cast'),
|
||||||
(32409,-1, -1, -1, -1, -1, -1, 6, 3,-1,'Shadow Word: Death', 'Spell::EffectSchoolDMG'),
|
(32409,-1, -1, -1, -1, -1, -1, 6, 3,-1,'Shadow Word: Death', 'Spell::EffectSchoolDMG'),
|
||||||
(32553,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Life Tap', 'Spell::EffectDummy'),
|
(32553,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Life Tap', 'Spell::EffectDummy'),
|
||||||
|
(32752,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Summoning Disorientation', 'Spell::CheckCast'),
|
||||||
(32813,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Squirrel Form', 'Spell::EffectDummy'),
|
(32813,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Squirrel Form', 'Spell::EffectDummy'),
|
||||||
(32816,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Giraffe Form', 'Spell::EffectDummy'),
|
(32816,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Giraffe Form', 'Spell::EffectDummy'),
|
||||||
(32817,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Serpent Form', 'Spell::EffectDummy'),
|
(32817,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Serpent Form', 'Spell::EffectDummy'),
|
||||||
|
|
@ -211,10 +241,11 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(33072,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(33072,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(33073,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(33073,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(33074,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(33074,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
|
(33711, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Murmur\'s Touch', 'Spell::SetTargetMap'),
|
||||||
(34846,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Charge', 'Spell::EffectDummy'),
|
(34846,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Charge', 'Spell::EffectDummy'),
|
||||||
|
(34991,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Netherstorm Flag', 'Spell::CheckCasterAuras'),
|
||||||
(35139, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Throw Boom\'s Doom', 'Spell::EffectSchoolDMG'),
|
(35139, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Throw Boom\'s Doom', 'Spell::EffectSchoolDMG'),
|
||||||
(35181, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Dive Bomb', 'Spell::EffectSchoolDMG'),
|
(35181, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Dive Bomb', 'Spell::EffectSchoolDMG'),
|
||||||
(35701,-1, -1, -1, -1, -1, -1, -1, -1,-1,'', 'Spell::EffectInstaKill'),
|
|
||||||
(35743,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Socrethar Portal', 'Spell::EffectDummy'),
|
(35743,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Socrethar Portal', 'Spell::EffectDummy'),
|
||||||
(35744,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Socrethar Portal', 'Spell::EffectDummy'),
|
(35744,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Socrethar Portal', 'Spell::EffectDummy'),
|
||||||
(35745, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Socrethar\'s Stone', 'Spell::EffectDummy'),
|
(35745, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Socrethar\'s Stone', 'Spell::EffectDummy'),
|
||||||
|
|
@ -250,16 +281,24 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(37881,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Blessing of Lower City', 'Spell::EffectDummy'),
|
(37881,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Blessing of Lower City', 'Spell::EffectDummy'),
|
||||||
(38441, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Cataclysmic Bolt', 'Spell::EffectSchoolDMG'),
|
(38441, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Cataclysmic Bolt', 'Spell::EffectSchoolDMG'),
|
||||||
(38615,-1, -1, -1, -1, -1, -1, 54, -1,-1,'Poison', 'Spell::EffectEnchantItemTmp'),
|
(38615,-1, -1, -1, -1, -1, -1, 54, -1,-1,'Poison', 'Spell::EffectEnchantItemTmp'),
|
||||||
|
(38794, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Murmur\'s Touch (h)', 'Spell::SetTargetMap'),
|
||||||
(38903, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'),
|
(38903, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'),
|
||||||
(39609,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Mana Tide Totem', 'Spell::EffectDummy'),
|
(39609,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Mana Tide Totem', 'Spell::EffectDummy'),
|
||||||
(39610,11, -1, -1, -1, -1, -1, 3, -1,-1,'Mana Tide Totem effect', 'Spell::EffectDummy'),
|
(39610,11, -1, -1, -1, -1, -1, 3, -1,-1,'Mana Tide Totem effect', 'Spell::EffectDummy'),
|
||||||
(40802, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Mingo\'s Fortune Generator', 'Spell::EffectDummy'),
|
(40802, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Mingo\'s Fortune Generator', 'Spell::EffectDummy'),
|
||||||
(40810, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Saber Lash', 'Spell::EffectSchoolDMG'),
|
(40810, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Saber Lash', 'Spell::EffectSchoolDMG'),
|
||||||
(41276, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'),
|
(41276, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'),
|
||||||
|
(41425,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Hypothermia', 'Spell::cast'),
|
||||||
|
(41617,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cenarion Mana Salve', 'Spell::SendCastResult'),
|
||||||
|
(41618,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Bottled Nethergon Energy', 'Spell::SendCastResult'),
|
||||||
|
(41619,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cenarion Healing Salve', 'Spell::SendCastResult'),
|
||||||
|
(41620,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Bottled Nethergon Vapor', 'Spell::SendCastResult'),
|
||||||
(41637,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Prayer of Mending', 'Spell::cast'),
|
(41637,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Prayer of Mending', 'Spell::cast'),
|
||||||
|
(42005, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Bloodboil', 'Spell::SetTargetMap'),
|
||||||
(42287, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Salvage Wreckage', 'Spell::EffectDummy'),
|
(42287, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Salvage Wreckage', 'Spell::EffectDummy'),
|
||||||
(42288,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Salvage Wreckage', 'Spell::EffectDummy'),
|
(42288,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Salvage Wreckage', 'Spell::EffectDummy'),
|
||||||
(42289,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Salvage Wreckage', 'Spell::EffectDummy'),
|
(42289,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Salvage Wreckage', 'Spell::EffectDummy'),
|
||||||
|
(42292,-1, -1, -1, -1, -1, -1, -1, -1,-1,'PvP Trinket', 'Spell::CheckCasterAuras'),
|
||||||
(42337,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Raptor Capture Credit', 'Spell::EffectDummy'),
|
(42337,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Raptor Capture Credit', 'Spell::EffectDummy'),
|
||||||
(42384, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Brutal Swipe', 'Spell::EffectSchoolDMG'),
|
(42384, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Brutal Swipe', 'Spell::EffectSchoolDMG'),
|
||||||
(43036, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Dismembering Corpse', 'Spell::EffectDummy'),
|
(43036, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Dismembering Corpse', 'Spell::EffectDummy'),
|
||||||
|
|
@ -277,6 +316,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(43900,-1, -1, -1, -1, -1, -1, -1, 78,-1,'Swift Brewfest Ram', 'Spell::EffectDummy'),
|
(43900,-1, -1, -1, -1, -1, -1, -1, 78,-1,'Swift Brewfest Ram', 'Spell::EffectDummy'),
|
||||||
(44454, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Tasty Reef Fish', 'Spell::EffectDummy'),
|
(44454, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Tasty Reef Fish', 'Spell::EffectDummy'),
|
||||||
(44455,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Tasty Reef Fish', 'Spell::EffectDummy'),
|
(44455,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Tasty Reef Fish', 'Spell::EffectDummy'),
|
||||||
|
(44462, 0, -1, -1, -1, -1, -1, 77, -1,-1,'The Way to His Heart...: Cast Quest Complete on Master','Spell::EffectScriptEffect'),
|
||||||
(44824,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flying Reindeer', 'Spell::EffectDummy'),
|
(44824,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flying Reindeer', 'Spell::EffectDummy'),
|
||||||
(44825,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flying Reindeer', 'Spell::EffectDummy'),
|
(44825,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flying Reindeer', 'Spell::EffectDummy'),
|
||||||
(44827,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flying Reindeer', 'Spell::EffectDummy'),
|
(44827,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flying Reindeer', 'Spell::EffectDummy'),
|
||||||
|
|
@ -289,6 +329,7 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(45088,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Emissary of Hate Credit', 'Spell::EffectDummy'),
|
(45088,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Emissary of Hate Credit', 'Spell::EffectDummy'),
|
||||||
(45150, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor Slash', 'Spell::EffectSchoolDMG'),
|
(45150, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor Slash', 'Spell::EffectSchoolDMG'),
|
||||||
(45182,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cheat Death', 'Spell::EffectDummy'),
|
(45182,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cheat Death', 'Spell::EffectDummy'),
|
||||||
|
(45373,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Bloodberry Elixir', 'Spell::SendCastResult'),
|
||||||
(45470,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Intercept', 'Spell::EffectDummy'),
|
(45470,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Intercept', 'Spell::EffectDummy'),
|
||||||
(45672,-1, -1, -1, -1, -1, -1, -1, 61,-1,'Shrunk', 'Spell::EffectDummy'),
|
(45672,-1, -1, -1, -1, -1, -1, -1, 61,-1,'Shrunk', 'Spell::EffectDummy'),
|
||||||
(45673,-1, -1, -1, -1, -1, -1, -1, 61,-1,'Bigger!', 'Spell::EffectDummy'),
|
(45673,-1, -1, -1, -1, -1, -1, -1, 61,-1,'Bigger!', 'Spell::EffectDummy'),
|
||||||
|
|
@ -304,20 +345,39 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(46167, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Planning for the Future: Create Snowfall Glade Pup Cover','Spell::EffectDummy'),
|
(46167, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Planning for the Future: Create Snowfall Glade Pup Cover','Spell::EffectDummy'),
|
||||||
(46485, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Greatmother\'s Soulcatcher', 'Spell::EffectDummy'),
|
(46485, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Greatmother\'s Soulcatcher', 'Spell::EffectDummy'),
|
||||||
(46486,-1, -1, -1, -1, -1, -1, -1, -1, 0,'Greatmother\'s Soulcatcher', 'Spell::EffectDummy'),
|
(46486,-1, -1, -1, -1, -1, -1, -1, -1, 0,'Greatmother\'s Soulcatcher', 'Spell::EffectDummy'),
|
||||||
|
(46699,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Requires No Ammo', 'Spell::CheckItems'),
|
||||||
(46606, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Plague Canister Dummy', 'Spell::EffectDummy'),
|
(46606, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Plague Canister Dummy', 'Spell::EffectDummy'),
|
||||||
(46773,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Planning for the Future: Create Snowfall Glade Pup Cover','Spell::EffectDummy'),
|
(46773,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Planning for the Future: Create Snowfall Glade Pup Cover','Spell::EffectDummy'),
|
||||||
(46797, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Quest - Borean Tundra - Set Explosives Cart','Spell::EffectDummy'),
|
(46797, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Quest - Borean Tundra - Set Explosives Cart','Spell::EffectDummy'),
|
||||||
(46798,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Quest - Borean Tundra - Summon Explosives Cart','Spell::EffectDummy'),
|
(46798,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Quest - Borean Tundra - Summon Explosives Cart','Spell::EffectDummy'),
|
||||||
|
(47390,-1, -1, -1, -1, -1, -1, -1, -1,-1,'The Focus on the Beach: Ley Line Focus Bunny Beam','Spell::EffectDummy'),
|
||||||
|
(47391, 0, -1, -1, -1, -1, -1, -1, 4,-1,'Ley Line Information', 'Spell::EffectScriptEffect'),
|
||||||
|
(47393, 0, -1, -1, -1, -1, -1, 77, -1,-1,'The Focus on the Beach: Ley Line Focus Bunny Beam','Spell::EffectScriptEffect'),
|
||||||
|
(47472,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Atop the Woodlands: Ley Line Focus Bunny Beam','Spell::EffectDummy'),
|
||||||
|
(47473, 0, -1, -1, -1, -1, -1, -1, 4,-1,'Ley Line Information', 'Spell::EffectScriptEffect'),
|
||||||
(47540, 6,0x0080000000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Penance', 'Spell::EffectDummy'),
|
(47540, 6,0x0080000000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Penance', 'Spell::EffectDummy'),
|
||||||
|
(47615, 0, -1, -1, -1, -1, -1, 77, -1,-1,'The End of the Line: Ley Line Focus Bunny Beam','Spell::EffectScriptEffect'),
|
||||||
|
(47635,-1, -1, -1, -1, -1, -1, -1, -1,-1,'The End of the Line: Ley Line Focus Bunny Beam','Spell::EffectDummy'),
|
||||||
|
(47636, 0, -1, -1, -1, -1, -1, -1, 4,-1,'Ley Line Information', 'Spell::EffectScriptEffect'),
|
||||||
|
(47638, 0, -1, -1, -1, -1, -1, 77, -1,-1,'Atop the Woodlands: Ley Line Focus Bunny Beam','Spell::EffectScriptEffect'),
|
||||||
(47632,-1, -1, -1, -1, -1, -1, 2, -1, 0,'Death Coil', 'Spell::EffectDummy'),
|
(47632,-1, -1, -1, -1, -1, -1, 2, -1, 0,'Death Coil', 'Spell::EffectDummy'),
|
||||||
(47633,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Death Coil', 'Spell::EffectDummy'),
|
(47633,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Death Coil', 'Spell::EffectDummy'),
|
||||||
(47757,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
(47757,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
||||||
(47758,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
(47758,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
||||||
(47897, 5,0x0001000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'),
|
(47897, 5,0x0001000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'),
|
||||||
(47960,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'),
|
(47960,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'),
|
||||||
|
(48023,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'),
|
||||||
|
(48024,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'),
|
||||||
|
(48025,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'),
|
||||||
|
(48075,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(48076,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(48077, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
|
(48078, 6, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Nova', 'Spell::cast'),
|
||||||
(48301,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mind Trauma', 'Spell::EffectSchoolDMG'),
|
(48301,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mind Trauma', 'Spell::EffectSchoolDMG'),
|
||||||
(48542,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Revitalize', 'Spell::EffectEnergize'),
|
(48542,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Revitalize', 'Spell::EffectEnergize'),
|
||||||
|
(48743,-1, -1, -1, -1, -1, -1, 1, -1,-1,'Death Pact', 'Spell::CheckCast'),
|
||||||
(48743,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Death Pact', 'Spell::EffectHeal'),
|
(48743,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Death Pact', 'Spell::EffectHeal'),
|
||||||
|
(48743,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Death Pact', 'Spell::SetTargetMap'),
|
||||||
(48820,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(48820,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(48821,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(48821,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
(48822,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
(48822,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
|
|
@ -334,6 +394,9 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(50246,-1, -1, -1, -1, -1, -1, -1, -1,-1,'01001000', 'Spell::EffectDummy'),
|
(50246,-1, -1, -1, -1, -1, -1, -1, -1,-1,'01001000', 'Spell::EffectDummy'),
|
||||||
(50286, 7,0x0000000000000000,0x00000100, -1, -1, -1, 3, -1,-1,'Starfall', 'Spell::EffectDummy'),
|
(50286, 7,0x0000000000000000,0x00000100, -1, -1, -1, 3, -1,-1,'Starfall', 'Spell::EffectDummy'),
|
||||||
(50288,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Starfall', 'Spell::EffectDummy'),
|
(50288,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Starfall', 'Spell::EffectDummy'),
|
||||||
|
(50546, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Ley Line Focus Control Ring Effect', 'Spell::EffectDummy'),
|
||||||
|
(50547, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Ley Line Focus Control Amulet Effect','Spell::EffectDummy'),
|
||||||
|
(50548, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Ley Line Focus Control Talisman Effect','Spell::EffectDummy'),
|
||||||
(50737,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Create Drakkari Medallion Cover', 'Spell::EffectDummy'),
|
(50737,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Create Drakkari Medallion Cover', 'Spell::EffectDummy'),
|
||||||
(50782,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Slam', 'Spell::EffectDummy'),
|
(50782,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Slam', 'Spell::EffectDummy'),
|
||||||
(50926, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Gluttonous Lurkers: Create Zul\'Drak Rat Cover','Spell::EffectDummy'),
|
(50926, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Gluttonous Lurkers: Create Zul\'Drak Rat Cover','Spell::EffectDummy'),
|
||||||
|
|
@ -353,18 +416,39 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(51366,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Shoot RJR', 'Spell::EffectDummy'),
|
(51366,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Shoot RJR', 'Spell::EffectDummy'),
|
||||||
(51370,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Dig For Treasure', 'Spell::EffectDummy'),
|
(51370,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Dig For Treasure', 'Spell::EffectDummy'),
|
||||||
(51582, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Rocket Boots Engaged', 'Spell::EffectDummy'),
|
(51582, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Rocket Boots Engaged', 'Spell::EffectDummy'),
|
||||||
|
(51582,-1, -1, -1, -1, -1, -1, 3, -1,-1,'Rocket Boots Engaged', 'Spell::CheckCast'),
|
||||||
(51592, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Pickup Primordial Hatchling', 'Spell::EffectDummy'),
|
(51592, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Pickup Primordial Hatchling', 'Spell::EffectDummy'),
|
||||||
(51593,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Pickup Primordial Hatchling', 'Spell::EffectDummy'),
|
(51593,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Pickup Primordial Hatchling', 'Spell::EffectDummy'),
|
||||||
|
(51617,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'),
|
||||||
|
(51621,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'),
|
||||||
|
(51723, 8, -1, -1, -1, -1, -1, -1, -1,-1,'Fan of Knives', 'Spell::cast'),
|
||||||
|
(51836,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Bananas Fall to Ground', 'Spell::EffectDummy'),
|
||||||
|
(51837,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Orange Falls to Ground', 'Spell::EffectDummy'),
|
||||||
|
(51839,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Papaya Falls to Ground', 'Spell::EffectDummy'),
|
||||||
|
(51840, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Despawn Fruit Tosser', 'Spell::EffectDummy'),
|
||||||
|
(51866, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Kick Nass', 'Spell::EffectDummy'),
|
||||||
|
(51870,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Collect Hair Sample', 'Spell::EffectDummy'),
|
||||||
|
(51871,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Nass Kill Credit', 'Spell::EffectDummy'),
|
||||||
|
(51872, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Hair Sample Collected', 'Spell::EffectDummy'),
|
||||||
(51961, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Captured Chicken Cover', 'Spell::EffectDummy'),
|
(51961, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Captured Chicken Cover', 'Spell::EffectDummy'),
|
||||||
|
(51964, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Tormentor\'s Incense', 'Spell::EffectDummy'),
|
||||||
|
(51967, 0, -1, -1, -1, -1, -1, -1,168,-1,'Mojo of Rhunok', 'Spell::EffectScriptEffect'),
|
||||||
(52025,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cleansing Totem Effect', 'Spell::EffectDummy'),
|
(52025,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cleansing Totem Effect', 'Spell::EffectDummy'),
|
||||||
(52032,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Mana Spring Totem', 'Spell::EffectDummy'),
|
(52032,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Mana Spring Totem', 'Spell::EffectDummy'),
|
||||||
(52042,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Healing Stream Totem', 'Spell::EffectDummy'),
|
(52042,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Healing Stream Totem', 'Spell::EffectDummy'),
|
||||||
|
(52070,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Adventurous Dwarf', 'Spell::EffectDummy'),
|
||||||
(52308, 0, -1, -1, -1, -1, -1, 3, -1, 0,'Take Sputum Sample', 'Spell::EffectDummy'),
|
(52308, 0, -1, -1, -1, -1, -1, 3, -1, 0,'Take Sputum Sample', 'Spell::EffectDummy'),
|
||||||
(52308, 0, -1, -1, -1, -1, -1, 3, -1, 1,'Take Sputum Sample', 'Spell::EffectDummy'),
|
(52308, 0, -1, -1, -1, -1, -1, 3, -1, 1,'Take Sputum Sample', 'Spell::EffectDummy'),
|
||||||
(52437,-1, -1, -1, -1, -1, -1, 6, -1, 0,'Sudden Death', 'Spell::EffectDummy'),
|
(52437,-1, -1, -1, -1, -1, -1, 6, -1, 0,'Sudden Death', 'Spell::EffectDummy'),
|
||||||
(52752,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Ancestral Awakening', 'Spell::EffectDummy'),
|
(52752,-1, -1, -1, -1, -1, -1, 10, -1, 0,'Ancestral Awakening', 'Spell::EffectDummy'),
|
||||||
(52759, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Ancestral Awakening', 'Spell::EffectDummy'),
|
(52759, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Ancestral Awakening', 'Spell::EffectDummy'),
|
||||||
|
(52759,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Ancestral Awakening', 'Spell::SetTargetMap'),
|
||||||
(52845,-1, -1, -1, -1, -1, -1, 3, -1,-1,'Brewfest Mount Transformation (Faction Swap)','Spell::EffectDummy'),
|
(52845,-1, -1, -1, -1, -1, -1, 3, -1,-1,'Brewfest Mount Transformation (Faction Swap)','Spell::EffectDummy'),
|
||||||
|
(52874,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fan of Knives', 'Spell::cast'),
|
||||||
|
(52941, 0, -1, -1, -1, -1, -1, 77, -1,-1,'Song of Cleansing', 'Spell::EffectScriptEffect'),
|
||||||
|
(52954, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Spirit', 'Spell::EffectScriptEffect'),
|
||||||
|
(52958, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Spirit', 'Spell::EffectScriptEffect'),
|
||||||
|
(52959, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Spirit', 'Spell::EffectScriptEffect'),
|
||||||
(52986,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
(52986,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
||||||
(52987,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
(52987,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
||||||
(52988,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
(52988,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'),
|
||||||
|
|
@ -386,14 +470,23 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(53343, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Rune of Razorice', 'Spell::EffectDummy'),
|
(53343, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Rune of Razorice', 'Spell::EffectDummy'),
|
||||||
(53478, 9, -1, -1, -1, -1, -1, 3, -1,-1,'Last Stand', 'Spell::EffectDummy'),
|
(53478, 9, -1, -1, -1, -1, -1, 3, -1,-1,'Last Stand', 'Spell::EffectDummy'),
|
||||||
(53479,-1, -1, -1, -1, -1, -1, -1, 34, 0,'Last Stand', 'Spell::EffectDummy'),
|
(53479,-1, -1, -1, -1, -1, -1, -1, 34, 0,'Last Stand', 'Spell::EffectDummy'),
|
||||||
|
(53563,-1, -1, -1, -1, -1, -1, -1, 23,-1,'Beacon of Light', 'Aura::HandlePeriodicTriggerSpell'),
|
||||||
|
(53563,-1, -1, -1, -1, -1, -1, -1, 23,-1,'Beacon of Light', 'Unit::HandleDummyAuraProc'),
|
||||||
|
(53805, 0, -1, -1, -1, -1, -1, -1,239,-1,'Pygmy Oil', 'Spell::EffectDummy'),
|
||||||
|
(53806,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Pygmy Oil', 'Spell::EffectDummy'),
|
||||||
|
(53808,-1, -1, -1, -1, -1, -1, 3, -1,-1,'Pygmy Oil', 'Spell::EffectDummy'),
|
||||||
(54049, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
(54049, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
||||||
(54050, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
(54050, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
||||||
(54051, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
(54051, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
||||||
(54052, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
(54052, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
||||||
(54053, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
(54053, 5,0x0040000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadow Bite', 'Spell::EffectSchoolDMG'),
|
||||||
|
(54098, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Poison Bolt Volley (h)', 'Spell::SetTargetMap'),
|
||||||
|
(54182, 0, -1, -1, -1, -1, -1, 77, -1,-1,'An End to the Suffering: Quest Completion Script','Spell::EffectScriptEffect'),
|
||||||
(54216,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Master''s Call', 'Spell::EffectDummy'),
|
(54216,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Master''s Call', 'Spell::EffectDummy'),
|
||||||
(54586,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Runeforging Credit', 'Spell::EffectDummy'),
|
(54586,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Runeforging Credit', 'Spell::EffectDummy'),
|
||||||
|
(54646,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Focus Magic', 'Spell::CheckCast'),
|
||||||
(54824,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Swiftmend', 'Spell::EffectHeal'),
|
(54824,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Swiftmend', 'Spell::EffectHeal'),
|
||||||
|
(54835, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Curse of the Plaguebringer (h)', 'Spell::SetTargetMap'),
|
||||||
(54861,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Nitro Boosts', 'Spell::EffectDummy'),
|
(54861,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Nitro Boosts', 'Spell::EffectDummy'),
|
||||||
(55004, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Nitro Boosts', 'Spell::EffectDummy'),
|
(55004, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Nitro Boosts', 'Spell::EffectDummy'),
|
||||||
(55078,-1, -1, -1, -1, -1, -1, -1, 3,-1,'Blood Plague', 'Spell::EffectScriptEffect'),
|
(55078,-1, -1, -1, -1, -1, -1, -1, 3,-1,'Blood Plague', 'Spell::EffectScriptEffect'),
|
||||||
|
|
@ -407,28 +500,47 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(55441,11, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Mana Tide', 'Spell::EffectDummy'),
|
(55441,11, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Mana Tide', 'Spell::EffectDummy'),
|
||||||
(55456,11, -1, -1, -1, -1, -1, -1, -1,-1,'Glyph of Healing Stream Totem', 'Spell::EffectDummy'),
|
(55456,11, -1, -1, -1, -1, -1, -1, -1,-1,'Glyph of Healing Stream Totem', 'Spell::EffectDummy'),
|
||||||
(55528,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Hurl Boulder', 'Spell::EffectDummy'),
|
(55528,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Hurl Boulder', 'Spell::EffectDummy'),
|
||||||
|
(55665, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Life Drain (h)', 'Spell::SetTargetMap'),
|
||||||
|
(55675,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Circle of Healing', 'Spell::SetTargetMap'),
|
||||||
(55818, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Hurl Boulder', 'Spell::EffectDummy'),
|
(55818, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Hurl Boulder', 'Spell::EffectDummy'),
|
||||||
|
(56153,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Guardian Aura - Ahn\'Kahet', 'Spell::SetTargetMap'),
|
||||||
(56235,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Glyph of Conflagrate', 'Spell::EffectSchoolDMG'),
|
(56235,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Glyph of Conflagrate', 'Spell::EffectSchoolDMG'),
|
||||||
(56446,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
(56446,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
||||||
|
(57085,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Refreshment', 'Spell::EffectScriptEffect'),
|
||||||
|
(57292,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Refreshment', 'Spell::EffectScriptEffect'),
|
||||||
|
(57337, 0, -1, -1, -1, -1, -1, 77, -1,-1,'Great Feast', 'Spell::EffectScriptEffect'),
|
||||||
|
(57397, 0, -1, -1, -1, -1, -1, 77, -1,-1,'Fish Feast', 'Spell::EffectScriptEffect'),
|
||||||
|
(57467, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor', 'Spell::EffectSchoolDMG'),
|
||||||
(57627,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Charge', 'Spell::EffectSchoolDMG'),
|
(57627,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Charge', 'Spell::EffectSchoolDMG'),
|
||||||
(57635, 9, -1, -1, -1, -1, -1, 3, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
(57635, 9, -1, -1, -1, -1, -1, 3, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
||||||
(57636,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
(57636,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
||||||
(57946, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
(57669,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Replenishment', 'Spell::SetTargetMap'),
|
||||||
|
(57723,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Exhaustion', 'Spell::cast'),
|
||||||
|
(57724,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Sated', 'Spell::cast'),
|
||||||
|
(57908, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Stain Cloth', 'Spell::EffectDummy'),
|
||||||
|
(57915,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Create Cloth', 'Spell::EffectDummy'),
|
||||||
|
(58067,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Refreshment', 'Spell::EffectScriptEffect'),
|
||||||
(58367,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Execution', 'Spell::EffectDummy'),
|
(58367,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Execution', 'Spell::EffectDummy'),
|
||||||
(58418, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Portal to Orgrimmar', 'Spell::EffectDummy'),
|
(58418, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Portal to Orgrimmar', 'Spell::EffectDummy'),
|
||||||
(58420, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Portal to Stormwind', 'Spell::EffectDummy'),
|
(58420, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Portal to Stormwind', 'Spell::EffectDummy'),
|
||||||
|
(58466, 0, -1, -1, -1, -1, -1, 77, -1,-1,'Gigantic Feast', 'Spell::EffectScriptEffect'),
|
||||||
|
(58475, 0, -1, -1, -1, -1, -1, 77, -1,-1,'Small Feast', 'Spell::EffectScriptEffect'),
|
||||||
(58601, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Remove Flight Auras', 'Spell::EffectDummy'),
|
(58601, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Remove Flight Auras', 'Spell::EffectDummy'),
|
||||||
(58657,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Plague Strike', 'Spell::EffectWeaponDmg'),
|
(58657,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Plague Strike', 'Spell::EffectWeaponDmg'),
|
||||||
|
(58875,11, -1, -1, -1, -1, -1, -1, -1,-1,'Spirit Walk', 'Spell::cast'),
|
||||||
|
(58876,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Spirit Walk', 'Spell::cast'),
|
||||||
(59336,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Death Strike', 'Spell::EffectWeaponDmg'),
|
(59336,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Death Strike', 'Spell::EffectWeaponDmg'),
|
||||||
(59332,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Blood Strike', 'Spell::EffectWeaponDmg'),
|
(59332,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Blood Strike', 'Spell::EffectWeaponDmg'),
|
||||||
(59640, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Underbelly Elixir', 'Spell::EffectDummy'),
|
(59640, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Underbelly Elixir', 'Spell::EffectDummy'),
|
||||||
(59645,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Underbelly Elixir', 'Spell::EffectDummy'),
|
(59645,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Underbelly Elixir', 'Spell::EffectDummy'),
|
||||||
(59831,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Underbelly Elixir', 'Spell::EffectDummy'),
|
(59831,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Underbelly Elixir', 'Spell::EffectDummy'),
|
||||||
(59843,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Underbelly Elixir', 'Spell::EffectDummy'),
|
(59843,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Underbelly Elixir', 'Spell::EffectDummy'),
|
||||||
|
(60089,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Faerie Fire', 'Spell::cast'),
|
||||||
(60932, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
(60932, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
||||||
(60934,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
(60934,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
||||||
(61290, 5,0x0001000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'),
|
(61290, 5,0x0001000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'),
|
||||||
(61291,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'),
|
(61291,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'),
|
||||||
|
(61336,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Survival Instincts', 'Spell::CheckCast'),
|
||||||
(61491, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Intercept', 'Spell::EffectSchoolDMG'),
|
(61491, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Intercept', 'Spell::EffectSchoolDMG'),
|
||||||
(61507, 9, -1, -1, -1, -1, -1, 3, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
(61507, 9, -1, -1, -1, -1, -1, 3, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
||||||
(61508,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
(61508,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
||||||
|
|
@ -436,6 +548,10 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(61650,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(61650,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(61654,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(61654,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
(61657,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
(61657,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::EffectDummy'),
|
||||||
|
(61832, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Rifle the Bodies: Create Magehunter Personal Effects Cover','Spell::EffectDummy'),
|
||||||
|
(61987,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Avenging Wrath Marker', 'Spell::cast'),
|
||||||
|
(61987,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Avenging Wrath Marker', 'Spell::CheckCast'),
|
||||||
|
(62124,10, -1, -1, -1, -1, -1, -1, -1,-1,'Hand of Reckoning', 'Spell::cast'),
|
||||||
(62305,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Master''s Call', 'Spell::EffectScriptEffect'),
|
(62305,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Master''s Call', 'Spell::EffectScriptEffect'),
|
||||||
(62775, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Tympanic Tantrum', 'Spell::EffectSchoolDMG'),
|
(62775, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Tympanic Tantrum', 'Spell::EffectSchoolDMG'),
|
||||||
(63334,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Disease', 'Spell::EffectScriptEffect'),
|
(63334,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Disease', 'Spell::EffectScriptEffect'),
|
||||||
|
|
@ -444,6 +560,13 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(64688, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor Slash', 'Spell::EffectSchoolDMG'),
|
(64688, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Meteor Slash', 'Spell::EffectSchoolDMG'),
|
||||||
(66765,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Meteor Fists', 'Spell::EffectWeaponDmg'),
|
(66765,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Meteor Fists', 'Spell::EffectWeaponDmg'),
|
||||||
(66809,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Meteor Fists', 'Spell::EffectWeaponDmg'),
|
(66809,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Meteor Fists', 'Spell::EffectWeaponDmg'),
|
||||||
|
(64844,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Divine Hymn', 'Spell::SetTargetMap'),
|
||||||
|
(64904,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Hymn of Hope', 'Spell::SetTargetMap'),
|
||||||
|
(65116,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Stoneskin', 'Spell::cast'),
|
||||||
|
(65422,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Food', 'Spell::EffectScriptEffect'),
|
||||||
|
(66013, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Penetrating Cold', 'Spell::SetTargetMap'),
|
||||||
|
(66477, 0, -1, -1, -1, -1, -1, 77, -1,-1,'Bountiful Feast', 'Spell::EffectScriptEffect'),
|
||||||
|
(66622,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Refreshment', 'Spell::EffectScriptEffect'),
|
||||||
(67016,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flask of the North', 'Spell::EffectDummy'),
|
(67016,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flask of the North', 'Spell::EffectDummy'),
|
||||||
(67017,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flask of the North', 'Spell::EffectDummy'),
|
(67017,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flask of the North', 'Spell::EffectDummy'),
|
||||||
(67018,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flask of the North', 'Spell::EffectDummy'),
|
(67018,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Flask of the North', 'Spell::EffectDummy'),
|
||||||
|
|
@ -451,7 +574,11 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(67331,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Meteor Fists', 'Spell::EffectWeaponDmg'),
|
(67331,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Meteor Fists', 'Spell::EffectWeaponDmg'),
|
||||||
(67333,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Meteor Fists', 'Spell::EffectWeaponDmg'),
|
(67333,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Meteor Fists', 'Spell::EffectWeaponDmg'),
|
||||||
(67485, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Hand of Rekoning', 'Spell::EffectSchoolDMG'),
|
(67485, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Hand of Rekoning', 'Spell::EffectSchoolDMG'),
|
||||||
|
(67485,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Hand of Rekoning', 'Spell::cast'),
|
||||||
|
(67700, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Penetrating Cold', 'Spell::SetTargetMap'),
|
||||||
(68082,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Glyph of Seal of Command', 'Spell::EffectEnergize'),
|
(68082,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Glyph of Seal of Command', 'Spell::EffectEnergize'),
|
||||||
|
(68509, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Penetrating Cold', 'Spell::SetTargetMap'),
|
||||||
|
(68510, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Penetrating Cold', 'Spell::SetTargetMap'),
|
||||||
(69055,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Bone Slice', 'Spell::EffectWeaponDmg'),
|
(69055,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Bone Slice', 'Spell::EffectWeaponDmg'),
|
||||||
(70492, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'),
|
(70492, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'),
|
||||||
(70907,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Water Elemental', 'Spell::EffectDummy'),
|
(70907,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Summon Water Elemental', 'Spell::EffectDummy'),
|
||||||
|
|
@ -459,17 +586,34 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
(70937,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Eternal Water', 'Spell::EffectDummy'),
|
(70937,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Eternal Water', 'Spell::EffectDummy'),
|
||||||
(71021,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Saber Lash', 'Spell::EffectWeaponDmg'),
|
(71021,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Saber Lash', 'Spell::EffectWeaponDmg'),
|
||||||
(71904, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Chaos Bane', 'Spell::EffectSchoolDMG'),
|
(71904, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Chaos Bane', 'Spell::EffectSchoolDMG'),
|
||||||
|
(71904, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Chaos Bane', 'Spell::cast'),
|
||||||
|
(72281, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'),
|
||||||
|
(72282, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'),
|
||||||
|
(72283, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'),
|
||||||
|
(72284, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'),
|
||||||
|
(72286, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'),
|
||||||
(72505, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'),
|
(72505, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'),
|
||||||
(72624, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'),
|
(72624, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'),
|
||||||
(72625, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'),
|
(72625, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'),
|
||||||
(73422, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Chaos Bane', 'Spell::cast'),
|
(73422, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Chaos Bane', 'Spell::cast'),
|
||||||
|
(73422,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Chaos Bane', 'Spell::cast'),
|
||||||
|
(74854, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Blazing Hippogryph', 'Aura::HandleAuraDummy'),
|
||||||
|
(74855, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Blazing Hippogryph', 'Aura::HandleAuraDummy'),
|
||||||
|
(74856, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Blazing Hippogryph', 'Aura::HandleAuraDummy'),
|
||||||
|
(75614, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'),
|
||||||
|
(75617, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'),
|
||||||
|
(75618, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'),
|
||||||
|
(75619, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'),
|
||||||
|
(75620, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'),
|
||||||
|
(76153, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'),
|
||||||
/*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */
|
/*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */
|
||||||
|
|
||||||
/* sorted by spell names */
|
/* sorted by spell names */
|
||||||
/*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */
|
/*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */
|
||||||
( 0, 3,0x0000000020000000,0x00000000, -1, -1, -1, 2, -1,-1,'Arcane Blast', 'Spell::EffectSchoolDMG'),
|
( 0, 3,0x0000000020000000,0x00000000, -1, -1, -1, 2, -1,-1,'Arcane Blast', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0, 3,0x0000000000200080,0x00000000, -1, -1, -1, -1, -1,-1,'Arcane Missles / Blizzard', 'Spell::prepareDataForTriggerSystem'),
|
||||||
( 0, 9,0x0000000000000800,0x00000000, -1, -1, -1, 2, -1,-1,'Arcane Shot', 'Spell::EffectSchoolDMG'),
|
( 0, 9,0x0000000000000800,0x00000000, -1, -1, -1, 2, -1,-1,'Arcane Shot', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0,10,0x0000200000000000,0x00000000, -1, -1, -1, -1, -1,-1,'Avenging Wrath', 'Spell::cast'),
|
||||||
( 0,15,0x0000000000400000,0x00000000, -1, -1, -1, 31, -1,-1,'Blood Strike', 'Spell::EffectWeaponDmg'),
|
( 0,15,0x0000000000400000,0x00000000, -1, -1, -1, 31, -1,-1,'Blood Strike', 'Spell::EffectWeaponDmg'),
|
||||||
( 0,15, -1, -1,1736, -1, -1, 31, -1,-1,'Blood-Caked Strike', 'Spell::EffectWeaponDmg'),
|
( 0,15, -1, -1,1736, -1, -1, 31, -1,-1,'Blood-Caked Strike', 'Spell::EffectWeaponDmg'),
|
||||||
( 0, 5,0x0000000000004000,0x00000000, -1, -1, -1, -1, -1,-1,'Drain Soul', 'Unit::SpellDamageBonus'),
|
( 0, 5,0x0000000000004000,0x00000000, -1, -1, -1, -1, -1,-1,'Drain Soul', 'Unit::SpellDamageBonus'),
|
||||||
|
|
@ -477,32 +621,48 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
( 0, 4,0x0000040000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Bloodthirst', 'Spell::EffectSchoolDMG'),
|
( 0, 4,0x0000040000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Bloodthirst', 'Spell::EffectSchoolDMG'),
|
||||||
( 0,11,0x0000000000000100,0x00000000, -1, -1, -1, 10, -1,-1,'Chain Healing', 'Spell::EffectHeal'),
|
( 0,11,0x0000000000000100,0x00000000, -1, -1, -1, 10, -1,-1,'Chain Healing', 'Spell::EffectHeal'),
|
||||||
( 0, 4,0x0000000000000001,0x00000000, -1, 867, -1, 3, -1,-1,'Charge', 'Spell::EffectDummy'),
|
( 0, 4,0x0000000000000001,0x00000000, -1, 867, -1, 3, -1,-1,'Charge', 'Spell::EffectDummy'),
|
||||||
|
( 0, 6, -1, -1, -1,8253, -1, -1, -1,-1,'Circle of Healing', 'Spell::SetTargetMap'),
|
||||||
( 0,11,0x0000000004000000,0x00000000,1673, -1, -1, 3, -1,-1,'Cleansing Totem', 'Spell::EffectDummy'),
|
( 0,11,0x0000000004000000,0x00000000,1673, -1, -1, 3, -1,-1,'Cleansing Totem', 'Spell::EffectDummy'),
|
||||||
|
( 0, 3,0x0000000200000000,0x00000008, -1, -1, -1, -1, -1,-1,'Clearcasting', 'Spell::prepareDataForTriggerSystem'),
|
||||||
( 0, 4,0x0000000004000000,0x00000000, -1, -1, -1, 3, -1,-1,'Concussion Blow', 'Spell::EffectDummy'),
|
( 0, 4,0x0000000004000000,0x00000000, -1, -1, -1, 3, -1,-1,'Concussion Blow', 'Spell::EffectDummy'),
|
||||||
( 0, 3, -1, -1, -1, -1, -1, 3, -1, 1,'Conjure Mana Gem', 'Spell::EffectDummy'), /*part 1*/
|
( 0, 3, -1, -1, -1, -1, -1, 3, -1, 1,'Conjure Mana Gem', 'Spell::EffectDummy'), /*part 1*/
|
||||||
( 0, 3, -1, -1, -1, -1, -1, 24, -1, 0,'Conjure Mana Gem', 'Spell::EffectDummy'), /*part 2*/
|
( 0, 3, -1, -1, -1, -1, -1, 24, -1, 0,'Conjure Mana Gem', 'Spell::EffectDummy'), /*part 2*/
|
||||||
|
( 0, 3, -1, -1, -1, -1, -1, 24, -1, 0,'Conjure Mana Gem', 'Spell::CheckItems'),
|
||||||
( 0, 9,0x0008000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Counterattack', 'Spell::EffectSchoolDMG'),
|
( 0, 9,0x0008000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Counterattack', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0, 5, -1, -1, -1, -1,1179, -1, -1,-1,'Curse of Doom', 'Spell::CheckTargetCreatureType'),
|
||||||
( 0, 8,0x0000000000010000,0x00000000, -1, -1, -1, -1, 3,-1,'Deadly poison', 'Spell::EffectSchoolDMG'),
|
( 0, 8,0x0000000000010000,0x00000000, -1, -1, -1, -1, 3,-1,'Deadly poison', 'Spell::EffectSchoolDMG'),
|
||||||
( 0,15,0x0000000000002000,0x00000000, -1, -1, -1, 3, -1,-1,'Death Coil', 'Spell::EffectDummy'),
|
( 0,15,0x0000000000002000,0x00000000, -1, -1, -1, 3, -1,-1,'Death Coil', 'Spell::EffectDummy'),
|
||||||
( 0,15,0x0000000000000010,0x00000000, -1, -1, -1, 31, -1, 1,'Death Strike', 'Spell::EffectWeaponDmg'),
|
( 0,15,0x0000000000000010,0x00000000, -1, -1, -1, 31, -1, 1,'Death Strike', 'Spell::EffectWeaponDmg'),
|
||||||
( 0,15,0x0000000000000010,0x00000000, -1, -1, -1, 3, -1, 2,'Death Strike', 'Spell::EffectDummy'),
|
( 0,15,0x0000000000000010,0x00000000, -1, -1, -1, 3, -1, 2,'Death Strike', 'Spell::EffectDummy'),
|
||||||
( 0, 5, -1, -1, -1, -1, 12, 38, -1,-1,'Devour Magic', 'Spell::EffectDispel'),
|
( 0, 5, -1, -1, -1, -1, 12, 38, -1,-1,'Devour Magic', 'Spell::EffectDispel'),
|
||||||
( 0, 9,0x0000400000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
( 0, 9,0x0000400000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Disengage', 'Spell::EffectDummy'),
|
||||||
|
( 0,10,0x0000000000400080,0x00000000, -1, -1, -1, -1, -1,-1,'Divine Shield, Divine Protection or Hand of Protection','Spell::cast'),
|
||||||
( 0, 8,0x0000000800000000,0x00000000, -1, -1, -1, 2, -1,-1,'Envenom', 'Spell::EffectSchoolDMG'),
|
( 0, 8,0x0000000800000000,0x00000000, -1, -1, -1, 2, -1,-1,'Envenom', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 8,0x0000000000020000,0x00000000, -1, -1, -1, 2, -1,-1,'Eviscerate', 'Spell::EffectSchoolDMG'),
|
( 0, 8,0x0000000000020000,0x00000000, -1, -1, -1, 2, -1,-1,'Eviscerate', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 4,0x0000000020000000,0x00000000, -1, -1, -1, 3, -1,-1,'Execute', 'Spell::EffectDummy'),
|
( 0, 4,0x0000000020000000,0x00000000, -1, -1, -1, 3, -1,-1,'Execute', 'Spell::EffectDummy'),
|
||||||
|
( 0,-1, -1, -1,1648, -1, -1, 3, -1,-1,'Execute', 'Spell::CheckCast'),
|
||||||
( 0, 9,0x0000000000000004,0x00000000, -1, -1, -1, 2, -1,-1,'Explosive Trap Effect', 'Spell::EffectSchoolDMG'),
|
( 0, 9,0x0000000000000004,0x00000000, -1, -1, -1, 2, -1,-1,'Explosive Trap Effect', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 7,0x0000000000800000,0x00000000, -1,6587, -1, 2, -1,-1,'Ferocious Bite', 'Spell::EffectSchoolDMG'),
|
( 0, 7,0x0000000000800000,0x00000000, -1,6587, -1, 2, -1,-1,'Ferocious Bite', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0,11, -1, -1, 33, -1, -1, 3, -1,-1,'Fire Nova', 'Spell::CheckCast'),
|
||||||
|
( 0, 5, -1, -1, 16, -1, -1, -1, -1,-1,'Fire Shield', 'Spell::CheckCast'),
|
||||||
( 0,11,0x0000000000200000,0x00000000, -1, -1, -1, -1, -1,-1,'Flametongue', 'Spell::EffectDummy'),
|
( 0,11,0x0000000000200000,0x00000000, -1, -1, -1, -1, -1,-1,'Flametongue', 'Spell::EffectDummy'),
|
||||||
( 0, 9, -1, -1,1578, -1, -1, 2, -1,-1,'Gore', 'Spell::EffectSchoolDMG'),
|
( 0, 9, -1, -1,1578, -1, -1, 2, -1,-1,'Gore', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 8,0x0000000000000008,0x00000000, -1, -1, -1, 2, -1,-1,'Gouge', 'Spell::EffectSchoolDMG'),
|
( 0, 8,0x0000000000000008,0x00000000, -1, -1, -1, 2, -1,-1,'Gouge', 'Spell::EffectSchoolDMG'),
|
||||||
( 0,10,0x0000008000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Hammer of Wrath', 'Spell::EffectSchoolDMG'),
|
( 0,10,0x0000008000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Hammer of Wrath', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0,-1, -1, -1, -1,7250, -1, 2, -1,-1,'Hammer of Wrath', 'Spell::CheckCast'),
|
||||||
( 0,10,0x0004000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Hammer of the Righteous', 'Spell::EffectSchoolDMG'),
|
( 0,10,0x0004000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Hammer of the Righteous', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0, 5,0x0004000000000000,0x00000000,3172, -1, -1, -1, 4,-1,'Haunt', 'Spell::DoAllEffectOnTarget'),
|
||||||
( 0,11,0x0000000000002000,0x00000000, -1, -1, -1, 3, -1,-1,'Healing Stream Totem', 'Spell::EffectDummy'),
|
( 0,11,0x0000000000002000,0x00000000, -1, -1, -1, 3, -1,-1,'Healing Stream Totem', 'Spell::EffectDummy'),
|
||||||
|
( 0, 4,0x0000800000000060,0x00000000, -1, -1, -1, -1, -1,-1,'Hellfire Effect / Rain of Fire / Seed of Corruption','Spell::prepareDataForTriggerSystem'),
|
||||||
|
( 0, 8,0x0000000002800000,0x00000000, -1, -1, -1, -1, -1,-1,'Hemorrhage', 'Spell::EffectWeaponDmg'),
|
||||||
( 0, 4,0x0000000100000000,0x00000000, -1, -1, -1, 2, -1,-1,'Heroic Throw', 'Spell::EffectSchoolDMG'),
|
( 0, 4,0x0000000100000000,0x00000000, -1, -1, -1, 2, -1,-1,'Heroic Throw', 'Spell::EffectSchoolDMG'),
|
||||||
( 0,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
( 0,10, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::EffectDummy'),
|
||||||
|
( 0,-1, -1, -1, 156, -1, -1, 3, -1,-1,'Holy Shock', 'Spell::CheckCast'),
|
||||||
( 0,15,0x0000100000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Hungering Cold', 'Spell::EffectDummy'),
|
( 0,15,0x0000100000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Hungering Cold', 'Spell::EffectDummy'),
|
||||||
|
( 0, 9,0x0100200000000214,0x00000200, -1, -1, -1, -1, -1,-1,'Hunter Rapid Killing/Explosive Trap Effect/Immolation Trap Effect/Frost Trap Aura/Snake Trap Effect/Explosive Shot', 'Spell::prepareDataForTriggerSystem'),
|
||||||
|
( 0, 3,0x0000008000000000,0x00000000, -1, -1, -1, -1, -1,-1,'Ice Block', 'Spell::cast'),
|
||||||
( 0, 5,0x0000000000000004,0x00000000, -1, -1, -1, -1, 3,-1,'Immolate', 'Spell::EffectSchoolDMG'),
|
( 0, 5,0x0000000000000004,0x00000000, -1, -1, -1, -1, 3,-1,'Immolate', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0, 9,0x000020000000001C,0x00000000, -1, -1, -1, -1, -1,-1,'Immolation Trap, Frost Trap, Explosive Trap, and Snake Trap','Spell::prepareDataForTriggerSystem'),
|
||||||
( 0,15, -1, -1,2751, -1, -1, -1,107, 1,'Improved Death Strike', 'Spell::EffectDummy'),
|
( 0,15, -1, -1,2751, -1, -1, -1,107, 1,'Improved Death Strike', 'Spell::EffectDummy'),
|
||||||
( 0,15, -1, -1,2751, -1, -1, 0, 0, 2,'Improved Death Strike', 'Spell::EffectDummy'),
|
( 0,15, -1, -1,2751, -1, -1, 0, 0, 2,'Improved Death Strike', 'Spell::EffectDummy'),
|
||||||
( 0, 5, -1, -1, 208, -1, -1, -1, 4,-1,'Improved Life Tap', 'Spell::EffectDummy'),
|
( 0, 5, -1, -1, 208, -1, -1, -1, 4,-1,'Improved Life Tap', 'Spell::EffectDummy'),
|
||||||
|
|
@ -511,8 +671,11 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
( 0, 8,0x0000000000002000,0x00000000, -1, -1, -1, 2, -1,-1,'Instant Poison', 'Spell::EffectSchoolDMG'),
|
( 0, 8,0x0000000000002000,0x00000000, -1, -1, -1, 2, -1,-1,'Instant Poison', 'Spell::EffectSchoolDMG'),
|
||||||
( 0,10, -1, -1, 561, -1, -1, 3, -1,-1,'Judgement of command', 'Spell::EffectDummy'),
|
( 0,10, -1, -1, 561, -1, -1, 3, -1,-1,'Judgement of command', 'Spell::EffectDummy'),
|
||||||
( 0,10,0x0000000800000000,0x00000000,2292, -1, -1, 2, -1,-1,'Judgement of Vengeance', 'Spell::EffectSchoolDMG'),
|
( 0,10,0x0000000800000000,0x00000000,2292, -1, -1, 2, -1,-1,'Judgement of Vengeance', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0,10,0x0001000900B80400,0x00000000, -1, -1, -1, -1, -1,-1,'Judgements (all) / Holy Shock', 'Spell::prepareDataForTriggerSystem'),
|
||||||
( 0, 7,0x0000010000000000,0x00000000,2246, -1, -1, 2, -1,-1,'Lacerate', 'Spell::EffectSchoolDMG'),
|
( 0, 7,0x0000010000000000,0x00000000,2246, -1, -1, 2, -1,-1,'Lacerate', 'Spell::EffectSchoolDMG'),
|
||||||
( 0,11,0x0000000000000000,0x00000004, -1, -1, -1, 3, -1,-1,'Lava Lash', 'Spell::EffectDummy'),
|
( 0,11,0x0000000000000000,0x00000004, -1, -1, -1, 3, -1,-1,'Lava Lash', 'Spell::EffectDummy'),
|
||||||
|
( 0,10,0x0000000000008000,0x00000000, -1, -1, -1, -1, -1,-1,'Lay on Hands', 'Spell::cast'),
|
||||||
|
( 0,10,0x0000000000008000,0x00000000, -1, -1, -1, -1, -1,-1,'Lay on Hands', 'Spell::CheckCast'),
|
||||||
( 0, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
( 0, 5,0x0000000000040000,0x00000000, -1, -1, -1, 3, -1,-1,'Life Tap', 'Spell::EffectDummy'),
|
||||||
( 0, 5, -1, -1,1982, -1, -1, -1,107,-1,'Mana Feed', 'Spell::EffectDummy'),
|
( 0, 5, -1, -1,1982, -1, -1, -1,107,-1,'Mana Feed', 'Spell::EffectDummy'),
|
||||||
( 0,11,0x0000000000004000,0x00000000, -1, -1, -1, 3, -1,-1,'Mana Spring Totem', 'Spell::EffectDummy'),
|
( 0,11,0x0000000000004000,0x00000000, -1, -1, -1, 3, -1,-1,'Mana Spring Totem', 'Spell::EffectDummy'),
|
||||||
|
|
@ -520,16 +683,23 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
( 0, 8, -1, -1,1960, -1, -1, 0,246,-1,'Master Poisoner', 'Spell::EffectSchoolDMG'),
|
( 0, 8, -1, -1,1960, -1, -1, 0,246,-1,'Master Poisoner', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 6,0x0000000000002000,0x00000000, -1, -1, -1, 2, -1,-1,'Mind Blast', 'Spell::EffectSchoolDMG'),
|
( 0, 6,0x0000000000002000,0x00000000, -1, -1, -1, 2, -1,-1,'Mind Blast', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 9,0x0000000000000002,0x00000000, -1, 342, -1, 2, -1,-1,'Mongoose Bite', 'Spell::EffectSchoolDMG'),
|
( 0, 9,0x0000000000000002,0x00000000, -1, 342, -1, 2, -1,-1,'Mongoose Bite', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0, 8,0x0020000000000000,0x00000000, -1, -1, -1, -1, -1,-1,'Mutilate', 'Spell::CheckCast'),
|
||||||
( 0, 6,0x0080000000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Penance', 'Spell::EffectDummy'),
|
( 0, 6,0x0080000000000000,0x00000000, -1, -1, -1, 3, -1,-1,'Penance', 'Spell::EffectDummy'),
|
||||||
|
( 0, 6,0x0001800000800000,0x00000040, -1, -1, -1, -1, -1,-1,'Penance,Mind Sear,Mind Flay', 'Spell::prepareDataForTriggerSystem'),
|
||||||
( 0,15,0x0000000000000001,0x00000000, -1, -1, -1, 31, -1,-1,'Plague Strike', 'Spell::EffectWeaponDmg'),
|
( 0,15,0x0000000000000001,0x00000000, -1, -1, -1, 31, -1,-1,'Plague Strike', 'Spell::EffectWeaponDmg'),
|
||||||
|
( 0, 8,0x000000101001E000,0x00000000, -1, -1, -1, -1, -1,-1,'poisons', 'Spell::prepareDataForTriggerSystem'),
|
||||||
|
( 0, 7,0x0000000000020000,0x00000000, -1, -1, -1, -1, -1,-1,'Pounce', 'Spell::CheckCast'),
|
||||||
|
( 0, 6,0x0000000000000001,0x00000000, -1, -1, -1, -1, -1,-1,'Power Word: Shield', 'Spell::cast'),
|
||||||
|
( 0, 6,0x0000002000000000,0x00000000, -1, -1, -1, -1, -1,-1,'Prayer of Mending', 'Spell::cast'),
|
||||||
( 0, 6,0x0000002000000000,0x00000000, -1, -1, -1, 6, -1,-1,'Prayer of Mending', 'Spell::cast'),
|
( 0, 6,0x0000002000000000,0x00000000, -1, -1, -1, 6, -1,-1,'Prayer of Mending', 'Spell::cast'),
|
||||||
( 0, 8,0x0000024000000860,0x00000000, -1, -1, -1, -1, -1,-1,'Preparation (affected spells)', 'Spell::EffectDummy'),
|
( 0, 8,0x0000024000000860,0x00000000, -1, -1, -1, -1, -1,-1,'Preparation (affected spells)', 'Spell::EffectDummy'),
|
||||||
( 0, 7,0x0000000000000040,0x00000000, -1, -1, -1, -1, 8,-1,'Regrowth', 'Spell::EffectHeal'),
|
|
||||||
( 0, 7,0x0000000000000010,0x00000000, -1, -1, -1, -1, 8,-1,'Rejuvenation', 'Spell::EffectHeal'),
|
|
||||||
( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, 2, -1,-1,'Rake', 'Spell::EffectSchoolDMG'), /* used in */
|
( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, 2, -1,-1,'Rake', 'Spell::EffectSchoolDMG'), /* used in */
|
||||||
( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, 80, -1, 2,'Rake', 'Spell::EffectSchoolDMG'), /* exactly selected */
|
( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, 80, -1, 2,'Rake', 'Spell::EffectSchoolDMG'), /* exactly selected */
|
||||||
( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, -1, 3,-1,'Rake', 'Aura::HandlePeriodicDamage'), /* used in */
|
( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, -1, 3,-1,'Rake', 'Aura::HandlePeriodicDamage'), /* used in */
|
||||||
( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, 80, -1, 2,'Rake', 'Aura::HandlePeriodicDamage'), /* exactly selected */
|
( 0, 7,0x0000000000001000,0x00000000, -1, -1, -1, 80, -1, 2,'Rake', 'Aura::HandlePeriodicDamage'), /* exactly selected */
|
||||||
|
( 0, 7,0x0000000000000040,0x00000000, -1, -1, -1, -1, 8,-1,'Regrowth', 'Spell::EffectHeal'),
|
||||||
|
( 0, 7,0x0000000000000010,0x00000000, -1, -1, -1, -1, 8,-1,'Rejuvenation', 'Spell::EffectHeal'),
|
||||||
|
( 0, 3,0x0000010000000000,0x00000000, -1, -1, -1, -1, -1,-1,'Replenish Mana', 'Spell::prepareDataForTriggerSystem'),
|
||||||
( 0,11,0x0000000000000000,0x00000010, -1, -1, -1, -1, 8,-1,'Riptide', 'Spell::EffectHeal'),
|
( 0,11,0x0000000000000000,0x00000010, -1, -1, -1, -1, 8,-1,'Riptide', 'Spell::EffectHeal'),
|
||||||
( 0,11, -1, -1, 338, -1, -1, -1, 4, 1,'Restorative Totems', 'Spell::EffectSchoolDMG'), /*part 1*/
|
( 0,11, -1, -1, 338, -1, -1, -1, 4, 1,'Restorative Totems', 'Spell::EffectSchoolDMG'), /*part 1*/
|
||||||
( 0, 4,0x0000000000000400,0x00000000, -1, -1, -1, 2, -1,-1,'Revenge', 'Spell::EffectSchoolDMG'),
|
( 0, 4,0x0000000000000400,0x00000000, -1, -1, -1, 2, -1,-1,'Revenge', 'Spell::EffectSchoolDMG'),
|
||||||
|
|
@ -546,16 +716,14 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas
|
||||||
( 0, 7,0x0000000000008000,0x00000000, -1, -1, -1, -1, -1,-1,'Shred', 'Unit::MeleeDamageBonus'),
|
( 0, 7,0x0000000000008000,0x00000000, -1, -1, -1, -1, -1,-1,'Shred', 'Unit::MeleeDamageBonus'),
|
||||||
( 0, 4,0x0000000000200000,0x00000000, -1, -1, -1, 3, -1,-1,'Slam', 'Spell::EffectDummy'),
|
( 0, 4,0x0000000000200000,0x00000000, -1, -1, -1, 3, -1,-1,'Slam', 'Spell::EffectDummy'),
|
||||||
( 0, 7,0x0000000000000000,0x00000100, -1, -1, -1, 3, -1,-1,'Starfall', 'Spell::EffectDummy'),
|
( 0, 7,0x0000000000000000,0x00000100, -1, -1, -1, 3, -1,-1,'Starfall', 'Spell::EffectDummy'),
|
||||||
|
( 0, 7,0x0000000000000000,0x00000100, -1, -1, -1, -1, -1,-1,'Starfall', 'Spell::SetTargetMap'),
|
||||||
( 0, 9,0x0000000100000000,0x00000000, -1, -1, -1, 2, -1,-1,'Steady Shot', 'Spell::EffectSchoolDMG'),
|
( 0, 9,0x0000000100000000,0x00000000, -1, -1, -1, 2, -1,-1,'Steady Shot', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 9,0x0000000100000000,0x00000000, -1, -1, -1, 3, -1,-1,'Steady Shot', 'Spell::EffectDummy'),
|
( 0, 9,0x0000000100000000,0x00000000, -1, -1, -1, 3, -1,-1,'Steady Shot', 'Spell::EffectDummy'),
|
||||||
( 0, 8,0x0000000000400000,0x00000000, -1, -1, -1, -1, -1,-1,'Stealth', 'Spell::EffectTriggerSpell'),
|
|
||||||
( 0,-1, -1, -1,1989, -1, -1, -1, 42, 0,'Sudden Death', 'Spell::EffectDummy'),
|
( 0,-1, -1, -1,1989, -1, -1, -1, 42, 0,'Sudden Death', 'Spell::EffectDummy'),
|
||||||
( 0, 7,0x0010000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Swipe', 'Spell::EffectSchoolDMG'),
|
( 0, 7,0x0010000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Swipe', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 4,0x0000000000000080,0x00000000, -1, -1, -1, 2, -1,-1,'Thunder Clap', 'Spell::EffectSchoolDMG'),
|
( 0, 4,0x0000000000000080,0x00000000, -1, -1, -1, 2, -1,-1,'Thunder Clap', 'Spell::EffectSchoolDMG'),
|
||||||
|
( 0,11,0x0000000004000000,0x00000000, -1, -1, -1, -1, -1,-1,'Totem of Wrath', 'Spell::cast'),
|
||||||
( 0, 4,0x0000010000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Victory Rush', 'Spell::EffectSchoolDMG'),
|
( 0, 4,0x0000010000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Victory Rush', 'Spell::EffectSchoolDMG'),
|
||||||
( 0, 8,0x0000000010000000,0x00000000, -1, -1, -1, 2, -1,-1,'Wound Poison', 'Spell::EffectSchoolDMG'),
|
( 0, 7, -1, -1,2864, -1, -1, 0, -1, 2,'Wild Growth', 'Spell::SetTargetMap'),
|
||||||
|
( 0, 8,0x0000000010000000,0x00000000, -1, -1, -1, 2, -1,-1,'Wound Poison', 'Spell::EffectSchoolDMG');
|
||||||
/* some random spells from not proccessed files sorted by spell ids */
|
|
||||||
/*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */
|
/*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */
|
||||||
(53563,-1, -1, -1, -1, -1, -1, -1, 23,-1,'Beacon of Light', 'Aura::HandlePeriodicTriggerSpell'),
|
|
||||||
(53563,-1, -1, -1, -1, -1, -1, -1, 23,-1,'Beacon of Light', 'Unit::HandleDummyAuraProc');
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `realmd_db_version`;
|
DROP TABLE IF EXISTS `realmd_db_version`;
|
||||||
CREATE TABLE `realmd_db_version` (
|
CREATE TABLE `realmd_db_version` (
|
||||||
`required_9748_01_realmd_realmlist` bit(1) default NULL
|
`required_10008_01_realmd_realmd_db_version` bit(1) default NULL
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue