rippled
Loading...
Searching...
No Matches
IPAddressConversion.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of Beast: https://github.com/vinniefalco/Beast
4 Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <xrpl/beast/net/IPAddressConversion.h>
21
22namespace beast {
23namespace IP {
24
25Endpoint
26from_asio(boost::asio::ip::address const& address)
27{
28 return Endpoint{address};
29}
30
31Endpoint
32from_asio(boost::asio::ip::tcp::endpoint const& endpoint)
33{
34 return Endpoint{endpoint.address(), endpoint.port()};
35}
36
37boost::asio::ip::address
38to_asio_address(Endpoint const& endpoint)
39{
40 return endpoint.address();
41}
42
43boost::asio::ip::tcp::endpoint
44to_asio_endpoint(Endpoint const& endpoint)
45{
46 return boost::asio::ip::tcp::endpoint{endpoint.address(), endpoint.port()};
47}
48
49} // namespace IP
50} // namespace beast
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
Address const & address() const
Returns the address portion of this endpoint.
Definition: IPEndpoint.h:76
Port port() const
Returns the port number on the endpoint.
Definition: IPEndpoint.h:62
boost::asio::ip::address to_asio_address(Endpoint const &endpoint)
Convert to asio::ip::address.
boost::asio::ip::tcp::endpoint to_asio_endpoint(Endpoint const &endpoint)
Convert to asio::ip::tcp::endpoint.
Endpoint from_asio(boost::asio::ip::address const &address)
Convert to Endpoint.