rippled
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 <ripple/beast/net/IPAddressConversion.h>
21 
22 namespace beast {
23 namespace IP {
24 
26 from_asio(boost::asio::ip::address const& address)
27 {
28  return Endpoint{address};
29 }
30 
31 Endpoint
32 from_asio(boost::asio::ip::tcp::endpoint const& endpoint)
33 {
34  return Endpoint{endpoint.address(), endpoint.port()};
35 }
36 
37 boost::asio::ip::address
38 to_asio_address(Endpoint const& endpoint)
39 {
40  return endpoint.address();
41 }
42 
43 boost::asio::ip::tcp::endpoint
44 to_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
beast::IP::Endpoint::address
Address const & address() const
Returns the address portion of this endpoint.
Definition: IPEndpoint.h:76
beast::IP::to_asio_endpoint
boost::asio::ip::tcp::endpoint to_asio_endpoint(Endpoint const &endpoint)
Convert to asio::ip::tcp::endpoint.
Definition: IPAddressConversion.cpp:44
beast::IP::Endpoint::port
Port port() const
Returns the port number on the endpoint.
Definition: IPEndpoint.h:62
beast::IP::from_asio
Endpoint from_asio(boost::asio::ip::address const &address)
Convert to Endpoint.
Definition: IPAddressConversion.cpp:26
beast::IP::to_asio_address
boost::asio::ip::address to_asio_address(Endpoint const &endpoint)
Convert to asio::ip::address.
Definition: IPAddressConversion.cpp:38
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
beast
Definition: base_uint.h:641