mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 17:35:51 +00:00
Add IPAddressConversion and asio module
This commit is contained in:
@@ -82,6 +82,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\beast\Arithmetic.h" />
|
<ClInclude Include="..\..\beast\Arithmetic.h" />
|
||||||
|
<ClInclude Include="..\..\beast\Asio.h" />
|
||||||
|
<ClInclude Include="..\..\beast\asio\IPAddressConversion.h" />
|
||||||
<ClInclude Include="..\..\beast\Atomic.h" />
|
<ClInclude Include="..\..\beast\Atomic.h" />
|
||||||
<ClInclude Include="..\..\beast\Boost.h" />
|
<ClInclude Include="..\..\beast\Boost.h" />
|
||||||
<ClInclude Include="..\..\beast\boost\ErrorCode.h" />
|
<ClInclude Include="..\..\beast\boost\ErrorCode.h" />
|
||||||
@@ -401,6 +403,13 @@
|
|||||||
<ClInclude Include="..\..\modules\beast_sqlite\sqlite\sqlite3ext.h" />
|
<ClInclude Include="..\..\modules\beast_sqlite\sqlite\sqlite3ext.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\beast\asio\Asio.cpp" />
|
||||||
|
<ClCompile Include="..\..\beast\asio\impl\IPAddressConversion.cpp">
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\beast\boost\Boost.cpp" />
|
<ClCompile Include="..\..\beast\boost\Boost.cpp" />
|
||||||
<ClCompile Include="..\..\beast\chrono\Chrono.cpp" />
|
<ClCompile Include="..\..\beast\chrono\Chrono.cpp" />
|
||||||
<ClCompile Include="..\..\beast\chrono\impl\CPUMeter.cpp">
|
<ClCompile Include="..\..\beast\chrono\impl\CPUMeter.cpp">
|
||||||
|
|||||||
@@ -297,6 +297,12 @@
|
|||||||
<Filter Include="beast\boost">
|
<Filter Include="beast\boost">
|
||||||
<UniqueIdentifier>{d7ec873a-d1e7-4341-9d20-a1be8f8ddd88}</UniqueIdentifier>
|
<UniqueIdentifier>{d7ec873a-d1e7-4341-9d20-a1be8f8ddd88}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="beast\asio">
|
||||||
|
<UniqueIdentifier>{f73fedee-2efb-431b-9f4f-d2fd405454f6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="beast\asio\impl">
|
||||||
|
<UniqueIdentifier>{30b0fdfb-02b6-47dd-bdd9-ffc1f57e1f2c}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\modules\beast_core\beast_core.h">
|
<ClInclude Include="..\..\modules\beast_core\beast_core.h">
|
||||||
@@ -1251,6 +1257,12 @@
|
|||||||
<ClInclude Include="..\..\beast\net\IPAddress.h">
|
<ClInclude Include="..\..\beast\net\IPAddress.h">
|
||||||
<Filter>beast\net</Filter>
|
<Filter>beast\net</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\beast\Asio.h">
|
||||||
|
<Filter>beast</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\beast\asio\IPAddressConversion.h">
|
||||||
|
<Filter>beast\asio</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
<ClCompile Include="..\..\modules\beast_core\containers\AbstractFifo.cpp">
|
||||||
@@ -1799,6 +1811,12 @@
|
|||||||
<ClCompile Include="..\..\beast\net\impl\IPAddress.cpp">
|
<ClCompile Include="..\..\beast\net\impl\IPAddress.cpp">
|
||||||
<Filter>beast\net\impl</Filter>
|
<Filter>beast\net\impl</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\beast\asio\Asio.cpp">
|
||||||
|
<Filter>beast\asio</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\beast\asio\impl\IPAddressConversion.cpp">
|
||||||
|
<Filter>beast\asio\impl</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="..\..\TODO.txt">
|
<Text Include="..\..\TODO.txt">
|
||||||
|
|||||||
25
beast/Asio.h
Normal file
25
beast/Asio.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||||
|
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
#ifndef BEAST_ASIO_H_INCLUDED
|
||||||
|
#define BEAST_ASIO_H_INCLUDED
|
||||||
|
|
||||||
|
#include "asio/IPAddressConversion.h"
|
||||||
|
|
||||||
|
#endif
|
||||||
22
beast/asio/Asio.cpp
Normal file
22
beast/asio/Asio.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||||
|
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
#include "BeastConfig.h"
|
||||||
|
|
||||||
|
#include "impl/IPAddressConversion.cpp"
|
||||||
50
beast/asio/IPAddressConversion.h
Normal file
50
beast/asio/IPAddressConversion.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||||
|
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
#ifndef BEAST_ASIO_IPADDRESSCONVERSION_H_INCLUDED
|
||||||
|
#define BEAST_ASIO_IPADDRESSCONVERSION_H_INCLUDED
|
||||||
|
|
||||||
|
#include "../net/IPAddress.h"
|
||||||
|
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
|
||||||
|
namespace beast {
|
||||||
|
|
||||||
|
struct IPAddressConversion
|
||||||
|
{
|
||||||
|
/** Convert to IPAddress.
|
||||||
|
The port is set to zero.
|
||||||
|
*/
|
||||||
|
static IPAddress from_asio (boost::asio::ip::address const& address);
|
||||||
|
|
||||||
|
/** Convert to IPAddress, including port. */
|
||||||
|
static IPAddress from_asio (boost::asio::ip::tcp::endpoint const& endpoint);
|
||||||
|
|
||||||
|
/** Convert to asio::ip::address.
|
||||||
|
The port is ignored.
|
||||||
|
*/
|
||||||
|
static boost::asio::ip::address to_asio_address (IPAddress const& address);
|
||||||
|
|
||||||
|
/** Convert to asio::ip::tcp::endpoint. */
|
||||||
|
static boost::asio::ip::tcp::endpoint to_asio_endpoint (IPAddress const& address);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
65
beast/asio/impl/IPAddressConversion.cpp
Normal file
65
beast/asio/impl/IPAddressConversion.cpp
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||||
|
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
#include "../IPAddressConversion.h"
|
||||||
|
|
||||||
|
namespace beast {
|
||||||
|
|
||||||
|
IPAddress IPAddressConversion::from_asio (boost::asio::ip::address const& address)
|
||||||
|
{
|
||||||
|
if (address.is_v4 ())
|
||||||
|
{
|
||||||
|
boost::asio::ip::address_v4::bytes_type const bytes (
|
||||||
|
address.to_v4().to_bytes());
|
||||||
|
return IPAddress (IPAddress::V4 (
|
||||||
|
bytes [0], bytes [1], bytes [2], bytes [3]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// VFALCO TODO IPv6 support
|
||||||
|
bassertfalse;
|
||||||
|
return IPAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
IPAddress IPAddressConversion::from_asio (boost::asio::ip::tcp::endpoint const& endpoint)
|
||||||
|
{
|
||||||
|
return from_asio (endpoint.address()).withPort (endpoint.port());
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::asio::ip::address IPAddressConversion::to_asio_address (IPAddress const& address)
|
||||||
|
{
|
||||||
|
if (address.isV4 ())
|
||||||
|
{
|
||||||
|
return boost::asio::ip::address (
|
||||||
|
boost::asio::ip::address_v4 (
|
||||||
|
address.v4().value));
|
||||||
|
}
|
||||||
|
|
||||||
|
// VFALCO TODO IPv6 support
|
||||||
|
bassertfalse;
|
||||||
|
return boost::asio::ip::address (
|
||||||
|
boost::asio::ip::address_v6 ());
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::asio::ip::tcp::endpoint IPAddressConversion::to_asio_endpoint (IPAddress const& address)
|
||||||
|
{
|
||||||
|
return boost::asio::ip::tcp::endpoint (
|
||||||
|
to_asio_address (address), address.port());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef BEAST_ASIO_H_INCLUDED
|
#ifndef BEAST_ASIO_MODULE_H_INCLUDED
|
||||||
#define BEAST_ASIO_H_INCLUDED
|
#define BEAST_ASIO_MODULE_H_INCLUDED
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
# define BEAST_SOCKET_VIRTUAL
|
# define BEAST_SOCKET_VIRTUAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../../beast/Asio.h"
|
||||||
#include "../../beast/MPL.h"
|
#include "../../beast/MPL.h"
|
||||||
#include "../../beast/Utility.h"
|
#include "../../beast/Utility.h"
|
||||||
#include "../../beast/HTTP.h"
|
#include "../../beast/HTTP.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user