#include <source/ariba/communication/BaseCommunication.h>
Inherits ariba::communication::NetworkChangeInterface, ariba::utility::SystemEventListener, and ariba::transport::transport_listener.
Classes | |
class | endpoint_reference |
list of all remote addresses of links to end-points More... | |
class | LinkDescriptor |
Public Member Functions | |
BaseCommunication () | |
Default ctor that just creates an non-functional base communication. | |
virtual | ~BaseCommunication () |
Default dtor that does nothing. | |
void | start () |
Startup the base communication, start modules etc. | |
void | stop () |
Stops the base communication, stop modules etc. | |
void | setEndpoints (string &endpoints) |
Sets the endpoints. | |
bool | isStarted () |
Check whether the base communication has been started up. | |
const LinkID | establishLink (const EndpointDescriptor &descriptor, const LinkID &linkid=LinkID::UNSPECIFIED, const QoSParameterSet &qos=QoSParameterSet::DEFAULT, const SecurityParameterSet &sec=SecurityParameterSet::DEFAULT) |
Establishes a link to another end-point. | |
void | dropLink (const LinkID link) |
Drops a link. | |
seqnum_t | sendMessage (const LinkID lid, const Message *message) |
const EndpointDescriptor & | getEndpointDescriptor (const LinkID link=LinkID::UNSPECIFIED) const |
LinkIDs | getLocalLinks (const address_v *addr) const |
void | registerMessageReceiver (MessageReceiver *receiver) |
void | unregisterMessageReceiver (MessageReceiver *receiver) |
void | registerEventListener (CommunicationEvents *_events) |
void | unregisterEventListener (CommunicationEvents *_events) |
virtual void | handleSystemEvent (const SystemEvent &event) |
called when a system event is emitted by system queue | |
virtual void | receive_message (transport_protocol *transport, const address_vf local, const address_vf remote, const uint8_t *data, size_t size) |
called when a message is received form transport_peer | |
Protected Member Functions | |
void | receiveMessage (const Message *message, const address_v *local, const address_v *remote) |
handle received message from a transport module | |
virtual void | onNetworkChange (const NetworkChangeInterface::NetworkChangeInfo &info) |
called when a network interface change happens | |
Private Types | |
typedef vector< LinkDescriptor * > | LinkSet |
Link management: list of links. | |
typedef set < CommunicationEvents * > | EventListenerSet |
event listener | |
Private Member Functions | |
use_logging_h (BaseCommunication) | |
void | addLink (LinkDescriptor *link) |
Link management: add a link. | |
void | removeLink (const LinkID &localLink) |
Link management: remove a link. | |
LinkDescriptor & | queryLocalLink (const LinkID &localLink) const |
Link management: get link information using the local link. | |
LinkDescriptor & | queryRemoteLink (const LinkID &remoteLink) const |
Link management: get link information using the remote link. | |
void | add_endpoint (const address_v *endpoint) |
adds an end-point to the list | |
void | remove_endpoint (const address_v *endpoint) |
removes an end-point from the list | |
void | send (Message *message, const EndpointDescriptor &endpoint) |
convenience: send message to peer | |
void | send (Message *message, const LinkDescriptor &descriptor) |
sends a message to the remote locator inside the link descriptor | |
Private Attributes | |
LinkSet | linkSet |
Link management: the set of currently managed links. | |
EndpointDescriptor | localDescriptor |
The local end-point descriptor. | |
NetworkChangeDetection | networkMonitor |
network change detector | |
vector< endpoint_reference > | remote_endpoints |
EventListenerSet | eventListener |
seqnum_t | currentSeqnum |
sequence numbers | |
transport_peer * | transport |
transport peer | |
MessageReceiver * | messageReceiver |
the base overlay message receiver | |
bool | started |
state of the base communication | |
Friends | |
class | ariba::SideportListener |
Its primary task is to provide an abstraction to existing protocols and addressing schemes.
Definition at line 105 of file BaseCommunication.h.
typedef set<CommunicationEvents*> ariba::communication::BaseCommunication::EventListenerSet [private] |
typedef vector<LinkDescriptor*> ariba::communication::BaseCommunication::LinkSet [private] |
ariba::communication::BaseCommunication::BaseCommunication | ( | ) |
Default ctor that just creates an non-functional base communication.
Definition at line 90 of file BaseCommunication.cpp.
ariba::communication::BaseCommunication::~BaseCommunication | ( | ) | [virtual] |
void ariba::communication::BaseCommunication::add_endpoint | ( | const address_v * | endpoint | ) | [private] |
adds an end-point to the list
adds an endpoint to the list
Definition at line 58 of file BaseCommunication.cpp.
References ariba::addressing::address_v::clone(), ariba::communication::BaseCommunication::BaseCommunication::endpoint_reference::count, ariba::communication::BaseCommunication::BaseCommunication::endpoint_reference::endpoint, remote_endpoints, and ariba::addressing::address_v::type_id().
Referenced by receiveMessage().
void ariba::communication::BaseCommunication::addLink | ( | LinkDescriptor * | link | ) | [private] |
Link management: add a link.
add a newly allocated link to the set of links
Definition at line 518 of file BaseCommunication.cpp.
References linkSet.
Referenced by establishLink(), and receiveMessage().
void ariba::communication::BaseCommunication::dropLink | ( | const LinkID | link | ) |
Drops a link.
Definition at line 185 of file BaseCommunication.cpp.
References eventListener, logging_debug, logging_error, ariba::communication::CommunicationEvents::onLinkDown(), queryLocalLink(), removeLink(), send(), ariba::utility::Identifier::toString(), and ariba::communication::AribaBaseMsg::typeLinkClose.
Referenced by ariba::overlay::BaseOverlay::dropLink(), ariba::overlay::BaseOverlay::handleJoinReply(), and ariba::overlay::BaseOverlay::leaveSpoVNet().
const LinkID ariba::communication::BaseCommunication::establishLink | ( | const EndpointDescriptor & | descriptor, | |
const LinkID & | linkid = LinkID::UNSPECIFIED , |
|||
const QoSParameterSet & | qos = QoSParameterSet::DEFAULT , |
|||
const SecurityParameterSet & | sec = SecurityParameterSet::DEFAULT | |||
) |
Establishes a link to another end-point.
Definition at line 153 of file BaseCommunication.cpp.
References addLink(), ariba::utility::LinkID::create(), ariba::utility::Identifier::isUnspecified(), localDescriptor, logging_debug, send(), ariba::communication::EndpointDescriptor::toString(), ariba::utility::Identifier::toString(), and ariba::communication::AribaBaseMsg::typeLinkRequest.
Referenced by ariba::overlay::BaseOverlay::establishDirectLink(), ariba::overlay::BaseOverlay::handleLinkReply(), and ariba::overlay::BaseOverlay::joinSpoVNet().
const EndpointDescriptor & ariba::communication::BaseCommunication::getEndpointDescriptor | ( | const LinkID | link = LinkID::UNSPECIFIED |
) | const |
Returns the end-point descriptor
link | the link id of the requested end-point |
Definition at line 242 of file BaseCommunication.cpp.
References ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::isUnspecified(), localDescriptor, queryLocalLink(), ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::remoteEndpoint, ariba::communication::EndpointDescriptor::UNSPECIFIED(), and ariba::utility::LinkID::UNSPECIFIED.
Referenced by ariba::overlay::BaseOverlay::getEndpointDescriptor(), ariba::AribaModule::getLocalEndpoints(), ariba::overlay::BaseOverlay::handleLinkRequest(), and ariba::overlay::BaseOverlay::joinSpoVNet().
Get local links to the given endpoint of all local link using the default parameter EndpointDescriptor::UNSPECIFIED
ep | The remote endpoint to get all links to. |
Definition at line 549 of file BaseCommunication.cpp.
References linkSet.
void ariba::communication::BaseCommunication::handleSystemEvent | ( | const SystemEvent & | event | ) | [virtual] |
called when a system event is emitted by system queue
Implements ariba::utility::SystemEventListener.
Definition at line 274 of file BaseCommunication.cpp.
References ariba::utility::SystemEvent::getType(), ariba::communication::DispatchMsg::local, logging_debug, ariba::communication::DispatchMsg::message, ariba::communication::MessageDispatchEvent, receiveMessage(), and ariba::communication::DispatchMsg::remote.
bool ariba::communication::BaseCommunication::isStarted | ( | ) |
Check whether the base communication has been started up.
Definition at line 142 of file BaseCommunication.cpp.
References started.
Referenced by ariba::Node::initiate(), and ariba::Node::join().
void ariba::communication::BaseCommunication::onNetworkChange | ( | const NetworkChangeInterface::NetworkChangeInfo & | info | ) | [protected, virtual] |
called when a network interface change happens
Implements ariba::communication::NetworkChangeInterface.
Definition at line 562 of file BaseCommunication.cpp.
BaseCommunication::LinkDescriptor & ariba::communication::BaseCommunication::queryLocalLink | ( | const LinkID & | localLink | ) | const [private] |
Link management: get link information using the local link.
query a descriptor by local link id
Definition at line 534 of file BaseCommunication.cpp.
References linkSet, and ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::UNSPECIFIED().
Referenced by dropLink(), getEndpointDescriptor(), ariba::SideportListener::getReachabilityProtocol(), receiveMessage(), and sendMessage().
BaseCommunication::LinkDescriptor & ariba::communication::BaseCommunication::queryRemoteLink | ( | const LinkID & | remoteLink | ) | const [private] |
Link management: get link information using the remote link.
query a descriptor by remote link id
Definition at line 542 of file BaseCommunication.cpp.
References linkSet, and ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::UNSPECIFIED().
Referenced by receiveMessage().
void ariba::communication::BaseCommunication::receive_message | ( | transport_protocol * | transport, | |
const address_vf | local, | |||
const address_vf | remote, | |||
const uint8_t * | data, | |||
size_t | size | |||
) | [virtual] |
called when a message is received form transport_peer
called when a message is received from transport_peer
Reimplemented from ariba::transport::transport_listener.
Definition at line 289 of file BaseCommunication.cpp.
References ariba::utility::SystemQueue::instance(), ariba::communication::DispatchMsg::local, ariba::communication::DispatchMsg::message, ariba::communication::MessageDispatchEvent, ariba::communication::DispatchMsg::remote, and ariba::utility::SystemQueue::scheduleEvent().
void ariba::communication::BaseCommunication::receiveMessage | ( | const Message * | message, | |
const address_v * | local, | |||
const address_v * | remote | |||
) | [protected] |
handle received message from a transport module
handles a message from the underlay transport
decapsulate message
only answer the first request
create link ids
Definition at line 310 of file BaseCommunication.cpp.
References ariba::addressing::endpoint_set::add(), add_endpoint(), addLink(), ariba::addressing::address_v::clone(), ariba::utility::LinkID::create(), eventListener, ariba::communication::EndpointDescriptor::getEndpoints(), ariba::communication::AribaBaseMsg::getLocalDescriptor(), ariba::communication::AribaBaseMsg::getLocalLink(), ariba::communication::AribaBaseMsg::getRemoteDescriptor(), ariba::communication::AribaBaseMsg::getRemoteLink(), ariba::communication::AribaBaseMsg::getType(), ariba::communication::AribaBaseMsg::getTypeString(), ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::isUnspecified(), ariba::addressing::endpoint_set::Layer1_3, localDescriptor, ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::localLink, ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::localLocator, logging_debug, logging_warn, messageReceiver, ariba::communication::CommunicationEvents::onLinkChanged(), ariba::communication::CommunicationEvents::onLinkDown(), ariba::communication::CommunicationEvents::onLinkRequest(), ariba::communication::CommunicationEvents::onLinkUp(), queryLocalLink(), queryRemoteLink(), ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::remoteEndpoint, ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::remoteLink, ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::remoteLocator, removeLink(), send(), ariba::addressing::address_v::to_string(), ariba::utility::Identifier::toString(), ariba::communication::AribaBaseMsg::typeData, ariba::communication::AribaBaseMsg::typeLinkClose, ariba::communication::AribaBaseMsg::typeLinkReply, ariba::communication::AribaBaseMsg::typeLinkRequest, ariba::communication::AribaBaseMsg::typeLinkUpdate, ariba::utility::NodeID::UNSPECIFIED, and ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::up.
Referenced by handleSystemEvent().
void ariba::communication::BaseCommunication::registerEventListener | ( | CommunicationEvents * | _events | ) |
Definition at line 252 of file BaseCommunication.cpp.
References eventListener.
Referenced by ariba::overlay::BaseOverlay::start().
void ariba::communication::BaseCommunication::registerMessageReceiver | ( | MessageReceiver * | receiver | ) | [inline] |
Registers a receiver.
_receiver | The receiving side |
Definition at line 172 of file BaseCommunication.h.
References messageReceiver.
Referenced by ariba::overlay::BaseOverlay::start().
void ariba::communication::BaseCommunication::remove_endpoint | ( | const address_v * | endpoint | ) | [private] |
removes an end-point from the list
removes an endpoint from the list
Definition at line 73 of file BaseCommunication.cpp.
References logging_info, remote_endpoints, ariba::transport::transport_peer::terminate(), transport, and ariba::addressing::address_v::type_id().
Referenced by removeLink().
void ariba::communication::BaseCommunication::removeLink | ( | const LinkID & | localLink | ) | [private] |
Link management: remove a link.
remove a link from set
Definition at line 523 of file BaseCommunication.cpp.
References linkSet, and remove_endpoint().
Referenced by dropLink(), and receiveMessage().
void ariba::communication::BaseCommunication::send | ( | Message * | message, | |
const LinkDescriptor & | descriptor | |||
) | [private] |
sends a message to the remote locator inside the link descriptor
Definition at line 713 of file BaseCommunication.cpp.
References data_serialize(), DEFAULT_V, DataTpl< T, DataModel >::getBuffer(), DataTpl< T, DataModel >::getLength(), ariba::communication::BaseCommunication::BaseCommunication::LinkDescriptor::remoteLocator, ariba::transport::transport_peer::send(), and transport.
void ariba::communication::BaseCommunication::send | ( | Message * | message, | |
const EndpointDescriptor & | endpoint | |||
) | [private] |
convenience: send message to peer
sends a message to all end-points in the end-point descriptor
Definition at line 707 of file BaseCommunication.cpp.
References data_serialize(), DEFAULT_V, DataTpl< T, DataModel >::getBuffer(), ariba::communication::EndpointDescriptor::getEndpoints(), DataTpl< T, DataModel >::getLength(), ariba::transport::transport_peer::send(), and transport.
Referenced by dropLink(), establishLink(), receiveMessage(), and sendMessage().
seqnum_t ariba::communication::BaseCommunication::sendMessage | ( | const LinkID | lid, | |
const Message * | message | |||
) |
Sends a message though an existing link to an end-point.
lid | The link identifier | |
message | The message to be sent |
Definition at line 212 of file BaseCommunication.cpp.
References currentSeqnum, logging_debug, logging_error, queryLocalLink(), send(), ariba::utility::Identifier::toString(), and ariba::communication::AribaBaseMsg::typeData.
Referenced by ariba::overlay::BaseOverlay::handleJoinRequest(), ariba::overlay::BaseOverlay::onLinkUp(), and ariba::overlay::BaseOverlay::send().
void ariba::communication::BaseCommunication::setEndpoints | ( | string & | endpoints | ) |
Sets the endpoints.
Definition at line 147 of file BaseCommunication.cpp.
References ariba::addressing::endpoint_set::assign(), ariba::communication::EndpointDescriptor::getEndpoints(), localDescriptor, logging_info, and ariba::addressing::endpoint_set::to_string().
Referenced by ariba::AribaModule::start().
void ariba::communication::BaseCommunication::start | ( | ) |
Startup the base communication, start modules etc.
Definition at line 98 of file BaseCommunication.cpp.
References currentSeqnum, ariba::communication::AddressDiscovery::discover_endpoints(), ariba::communication::EndpointDescriptor::getEndpoints(), localDescriptor, logging_info, networkMonitor, ariba::transport::transport_peer::register_listener(), ariba::communication::NetworkChangeDetection::registerNotification(), ariba::transport::transport_peer::start(), started, ariba::communication::EndpointDescriptor::toString(), and transport.
Referenced by ariba::Node::initiate(), and ariba::Node::join().
void ariba::communication::BaseCommunication::stop | ( | ) |
Stops the base communication, stop modules etc.
Definition at line 132 of file BaseCommunication.cpp.
References logging_info, started, ariba::transport::transport_peer::stop(), and transport.
Referenced by ariba::Node::leave().
void ariba::communication::BaseCommunication::unregisterEventListener | ( | CommunicationEvents * | _events | ) |
Definition at line 257 of file BaseCommunication.cpp.
References eventListener.
Referenced by ariba::overlay::BaseOverlay::stop().
void ariba::communication::BaseCommunication::unregisterMessageReceiver | ( | MessageReceiver * | receiver | ) | [inline] |
Unregister a receiver.
_receiver | The receiving side |
Definition at line 181 of file BaseCommunication.h.
References messageReceiver.
Referenced by ariba::overlay::BaseOverlay::stop().
ariba::communication::BaseCommunication::use_logging_h | ( | BaseCommunication | ) | [private] |
friend class ariba::SideportListener [friend] |
Definition at line 111 of file BaseCommunication.h.
sequence numbers
Definition at line 298 of file BaseCommunication.h.
Referenced by sendMessage(), and start().
Definition at line 295 of file BaseCommunication.h.
Referenced by dropLink(), receiveMessage(), registerEventListener(), and unregisterEventListener().
Link management: the set of currently managed links.
Definition at line 258 of file BaseCommunication.h.
Referenced by addLink(), getLocalLinks(), queryLocalLink(), queryRemoteLink(), and removeLink().
The local end-point descriptor.
Definition at line 273 of file BaseCommunication.h.
Referenced by establishLink(), getEndpointDescriptor(), receiveMessage(), setEndpoints(), and start().
MessageReceiver* ariba::communication::BaseCommunication::messageReceiver [private] |
the base overlay message receiver
Definition at line 304 of file BaseCommunication.h.
Referenced by receiveMessage(), registerMessageReceiver(), and unregisterMessageReceiver().
vector<endpoint_reference> ariba::communication::BaseCommunication::remote_endpoints [private] |
Definition at line 285 of file BaseCommunication.h.
Referenced by add_endpoint(), and remove_endpoint().
bool ariba::communication::BaseCommunication::started [private] |
state of the base communication
Definition at line 313 of file BaseCommunication.h.
Referenced by BaseCommunication(), isStarted(), start(), and stop().
transport peer
Definition at line 301 of file BaseCommunication.h.
Referenced by BaseCommunication(), remove_endpoint(), send(), start(), and stop().