rippled
Slot.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
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 #ifndef RIPPLE_PEERFINDER_SLOT_H_INCLUDED
21 #define RIPPLE_PEERFINDER_SLOT_H_INCLUDED
22 
23 #include <ripple/protocol/PublicKey.h>
24 #include <ripple/beast/net/IPEndpoint.h>
25 #include <boost/optional.hpp>
26 #include <memory>
27 
28 namespace ripple {
29 namespace PeerFinder {
30 
32 class Slot
33 {
34 public:
36 
37  enum State
38  {
44  };
45 
46  virtual ~Slot () = 0;
47 
49  virtual bool inbound () const = 0;
50 
55  virtual bool fixed () const = 0;
56 
61  virtual bool reserved () const = 0;
62 
64  virtual State state () const = 0;
65 
67  virtual beast::IP::Endpoint const& remote_endpoint () const = 0;
68 
70  virtual boost::optional <beast::IP::Endpoint> const& local_endpoint () const = 0;
71 
72  virtual boost::optional<std::uint16_t> listening_port () const = 0;
73 
77  virtual boost::optional <PublicKey> const& public_key () const = 0;
78 };
79 
80 }
81 }
82 
83 #endif
ripple::PeerFinder::Slot::state
virtual State state() const =0
Returns the state of the connection.
std::shared_ptr
STL class.
ripple::PeerFinder::Slot::accept
@ accept
Definition: Slot.h:39
ripple::PeerFinder::Slot::fixed
virtual bool fixed() const =0
Returns true if this is a fixed connection.
ripple::PeerFinder::Slot::public_key
virtual boost::optional< PublicKey > const & public_key() const =0
The peer's public key, when known.
ripple::PeerFinder::Slot::active
@ active
Definition: Slot.h:42
ripple::PeerFinder::Slot::reserved
virtual bool reserved() const =0
Returns true if this is a reserved connection.
ripple::PeerFinder::Slot::remote_endpoint
virtual beast::IP::Endpoint const & remote_endpoint() const =0
The remote endpoint of socket.
ripple::PeerFinder::Slot::listening_port
virtual boost::optional< std::uint16_t > listening_port() const =0
ripple::PeerFinder::Slot::connected
@ connected
Definition: Slot.h:41
ripple::PeerFinder::Slot::local_endpoint
virtual boost::optional< beast::IP::Endpoint > const & local_endpoint() const =0
The local endpoint of the socket, when known.
ripple::PeerFinder::Slot::closing
@ closing
Definition: Slot.h:43
ripple::PeerFinder::Slot::State
State
Definition: Slot.h:37
memory
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::PeerFinder::Slot::inbound
virtual bool inbound() const =0
Returns true if this is an inbound connection.
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
ripple::PeerFinder::Slot::~Slot
virtual ~Slot()=0
ripple::PeerFinder::Slot::connect
@ connect
Definition: Slot.h:40
ripple::PeerFinder::Slot
Properties and state associated with a peer to peer overlay connection.
Definition: Slot.h:32