Index: source/ariba/communication/BaseCommunication.cpp
===================================================================
--- source/ariba/communication/BaseCommunication.cpp	(revision 5151)
+++ source/ariba/communication/BaseCommunication.cpp	(revision 5284)
@@ -52,9 +52,13 @@
 namespace communication {
 
+#include "networkinfo/AddressDiscovery.hpp"
+
 use_logging_cpp(BaseCommunication);
-const BaseCommunication::LinkDescriptor BaseCommunication::LinkDescriptor::UNSPECIFIED;
-
-BaseCommunication::BaseCommunication()
-	: messageReceiver(NULL), network(NULL), transport(NULL), basecommStarted(false){
+const BaseCommunication::LinkDescriptor
+	BaseCommunication::LinkDescriptor::UNSPECIFIED;
+
+BaseCommunication::BaseCommunication() {
+	this->transport = NULL;
+	this->started = false;
 }
 
@@ -62,11 +66,10 @@
 }
 
-void BaseCommunication::start(const NetworkLocator* _locallocator, const uint16_t _listenport){
-
+void BaseCommunication::start() {
+	logging_info( "Starting up ..." );
 	currentSeqnum = 0;
-	listenport = _listenport;
-
-	logging_info( "starting up base communication and creating transports ..." );
-	logging_info( "using port " << listenport );
+
+	// creating transports
+	logging_info( "Creating transports ..." );
 
 #ifdef UNDERLAY_OMNET
@@ -77,90 +80,43 @@
 	network = new OmnetNetworkProtocol( module );
 #else
-	transport = new TCPTransport( listenport );
-	network = new IPv4NetworkProtocol();
+	transport = new transport_peer( localDescriptor.getEndpoints() );
 #endif
 
-	logging_debug( "searching for local locators ..." );
-
-	NetworkProtocol::NetworkLocatorSet locators = network->getAddresses();
-	NetworkProtocol::NetworkLocatorSet::iterator i = locators.begin();
-	NetworkProtocol::NetworkLocatorSet::iterator iend = locators.end();
-
-	//
-	// choose the first locator that is not localhost
-	//
-
-	bool foundLocator = false;
-
-	for( ; i != iend; i++){
-		logging_debug( "local locator found " << (*i)->toString() );
-		IPv4Locator* ipv4locator = dynamic_cast<IPv4Locator*>(*i);
-
-		// TODO: which locators are find to bind to?
-		// localhost is not too bad, works when testing locally
-		// with several instances. the manual override currently
-		// enables to use an arbitrary address, guess this is fine.
-		// so the manual override also can use ANY, LOCALHOST, BROADCAST
-
-		if( *ipv4locator != IPv4Locator::LOCALHOST &&
-		    *ipv4locator != IPv4Locator::ANY       &&
-		    *ipv4locator != IPv4Locator::BROADCAST  ){
-
-			ipv4locator->setPort(listenport);
-			localDescriptor.locator = ipv4locator;
-			localDescriptor.isUnspec = false;
-			logging_info( "binding to addr = " << ipv4locator->toString() );
-			foundLocator = true;
-			break;
-		}
-	} // for( ; i != iend; i++)
-
-
-	if( _locallocator != NULL ) {
-		if( localDescriptor.locator != NULL) delete localDescriptor.locator;
-		localDescriptor.locator = new IPv4Locator( IPv4Locator::fromString( _locallocator->toString()) );
-		localDescriptor.isUnspec = false;
-		logging_debug( "manual locator override, using locator=" <<
-					localDescriptor.locator->toString() );
-		foundLocator = true;
-	}
-
-	// if we found no local locator, exit using logging fatal
-	if( !foundLocator )
-		logging_fatal( "did not find a useable local locator!" );
-
-	transport->addMessageReceiver( this );
+	logging_info( "Searching for local locators ..." );
+	discoverEndpoints(localDescriptor.getEndpoints());
+	logging_info( "Done. Local endpoints = " << localDescriptor.toString() );
+
+	transport->register_listener( this );
 	transport->start();
 
 #ifndef UNDERLAY_OMNET
-	//
 	// bind to the network change detection
-	//
-
 	networkMonitor.registerNotification( this );
 #endif
 
-	//
 	// base comm startup done
-	//
-
-	basecommStarted = true;
-	logging_info( "base communication started up" );
+	started = true;
+	logging_info( "Started up." );
 }
 
 void BaseCommunication::stop() {
-
-	logging_info( "stopping base communication and transport ..." );
+	logging_info( "Stopping transports ..." );
 
 	transport->stop();
 	delete transport;
-	delete network;
-
-	basecommStarted = false;
-	logging_info( "base communication stopped" );
+	started = false;
+
+	logging_info( "Stopped." );
 }
 
 bool BaseCommunication::isStarted(){
-	return basecommStarted;
+	return started;
+}
+
+/// Sets the endpoints
+void BaseCommunication::setEndpoints( string& _endpoints ) {
+	localDescriptor.getEndpoints().assign(_endpoints);
+	logging_info("Setting local end-points: "
+		<< localDescriptor.getEndpoints().to_string());
 }
 
@@ -175,45 +131,23 @@
 
 	// debug
-	logging_debug( "request to establish link" );
-
-	//
-	// just use the first locator in the endp descriptors
-	//
-	if( descriptor.locator == NULL ){
-		logging_error( "invalid destination endpoint" );
-		return LinkID::UNSPECIFIED;
-	}
-
-	if( localDescriptor.locator == NULL ){
-		logging_error( "invalid local endpoint" );
-		return LinkID::UNSPECIFIED;
-	}
-
-	const NetworkLocator* remote = descriptor.locator;
-	const NetworkLocator* local =  localDescriptor.locator;
-
-	// create link identifier and link descriptor
-	if (linkid.isUnspecified()){
-		linkid = LinkID::create();
-		assert(!linkid.isUnspecified());
-	}
-
-	logging_debug( "creating new local descriptor entry with local link id " << linkid.toString() );
-	LinkDescriptor linkDescriptor( linkid, local, LinkID::UNSPECIFIED, remote, descriptor, false );
-	addLink( linkDescriptor );
-
-	//
-	// create a base msg with our link id and
-	// a request to open a link on the other side
-	//
-
-	logging_debug( "sending out base messages with request to open link to " << remote->toString() );
-	AribaBaseMsg baseMsg(
-			remote,
-			AribaBaseMsg::LINK_STATE_OPEN_REQUEST,
-			linkid,
-			LinkID::UNSPECIFIED );
-
-	transport->sendMessage(&baseMsg);
+	logging_debug( "Request to establish link" );
+
+	// create link identifier
+	if (linkid.isUnspecified())	linkid = LinkID::create();
+
+	// create link descriptor
+	logging_debug( "Creating new descriptor entry with local link id=" << linkid.toString() );
+	LinkDescriptor* ld = new LinkDescriptor();
+	ld->localLink = linkid;
+	addLink( ld );
+
+	// send a message to request new link to remote
+	logging_debug( "Send messages with request to open link to " << descriptor.toString() );
+	AribaBaseMsg baseMsg( AribaBaseMsg::typeLinkRequest, linkid );
+	baseMsg.getLocalDescriptor() = localDescriptor;
+
+	// serialize and send message
+	send( &baseMsg, descriptor );
+
 	return linkid;
 }
@@ -221,29 +155,24 @@
 void BaseCommunication::dropLink(const LinkID link) {
 
-	logging_debug( "starting to drop link " + link.toString() );
+	logging_debug( "Starting to drop link " + link.toString() );
 
 	// see if we have the link
-	LinkDescriptor& descriptor = queryLocalLink( link );
-	if( descriptor.isUnspecified() ){
-		logging_error( "don't know the link you want to drop "+ link.toString() );
+	LinkDescriptor& ld = queryLocalLink( link );
+	if( ld.isUnspecified() ) {
+		logging_error( "Don't know the link you want to drop "+ link.toString() );
 		return;
 	}
 
+	// tell the registered listeners
+	BOOST_FOREACH( CommunicationEvents* i, eventListener ) {
+		i->onLinkDown( link, ld.localLocator, ld.remoteLocator );
+	}
+
 	// create message to drop the link
-	logging_debug( "sending out link close request. for us, the link is closed now" );
-	AribaBaseMsg msg(
-		descriptor.remoteLocator,
-		AribaBaseMsg::LINK_STATE_CLOSE_REQUEST,
-		descriptor.localLink,
-		descriptor.remoteLink
-	);
+	logging_debug( "Sending out link close request. for us, the link is closed now" );
+	AribaBaseMsg msg( AribaBaseMsg::typeLinkClose, ld.localLink, ld.remoteLink );
 
 	// send message to drop the link
-	transport->sendMessage( &msg );
-
-	// tell the registered listeners
-	BOOST_FOREACH( CommunicationEvents* i, eventListener ){
-		i->onLinkDown( link, descriptor.localLocator, descriptor.remoteLocator );
-	}
+	send( &msg, ld );
 
 	// remove from map
@@ -253,36 +182,33 @@
 seqnum_t BaseCommunication::sendMessage( const LinkID lid, const Message* message) {
 
-	logging_debug( "sending out message to link " << lid.toString() );
+	logging_debug( "Sending out message to link " << lid.toString() );
 
 	// query local link info
-	LinkDescriptor& linkDesc = queryLocalLink(lid);
-	if( linkDesc.isUnspecified() ){
-		logging_error( "don't know the link with id " << lid.toString() );
+	LinkDescriptor& ld = queryLocalLink(lid);
+	if( ld.isUnspecified() ){
+		logging_error( "Don't know the link with id " << lid.toString() );
 		return -1;
 	}
 
+	// link not up-> error
+	if( !ld.up ) {
+		logging_error("Can not send on link " << lid.toString() << ": link not up");
+		return -1;
+	}
+
 	// create message
-	AribaBaseMsg msg(
-		linkDesc.remoteLocator,
-		AribaBaseMsg::LINK_STATE_DATA,
-		linkDesc.localLink,
-		linkDesc.remoteLink
-	);
+	AribaBaseMsg msg( AribaBaseMsg::typeData, ld.localLink, ld.remoteLink );
 
 	// encapsulate the payload message
 	msg.encapsulate( const_cast<Message*>(message) );
 
-	if( !linkDesc.linkup ){
-		logging_error("cant send message on link " << lid.toString() << ", link not up");
-		return -1;
-	}
-
 	// send message
-	transport->sendMessage( &msg );
+	send( &msg, ld );
+
+	// return sequence number
 	return ++currentSeqnum;
 }
 
 const EndpointDescriptor& BaseCommunication::getEndpointDescriptor(const LinkID link) const {
-
 	if( link == LinkID::UNSPECIFIED){
 		return localDescriptor;
@@ -294,14 +220,5 @@
 }
 
-void BaseCommunication::registerMessageReceiver(MessageReceiver* _receiver) {
-	messageReceiver = _receiver;
-}
-
-void BaseCommunication::unregisterMessageReceiver(MessageReceiver* _receiver) {
-	messageReceiver = NULL;
-}
-
 void BaseCommunication::registerEventListener(CommunicationEvents* _events){
-
 	if( eventListener.find( _events ) == eventListener.end() )
 		eventListener.insert( _events );
@@ -309,5 +226,4 @@
 
 void BaseCommunication::unregisterEventListener(CommunicationEvents* _events){
-
 	EventListenerSet::iterator i = eventListener.find( _events );
 	if( i != eventListener.end() )
@@ -315,257 +231,265 @@
 }
 
-
-bool BaseCommunication::receiveMessage(const Message* message, const LinkID& /*invalid*/, const NodeID& ){
-
-	//
-	// these messages arrive from the Transport module
-	// and are incoming network messages. Unpack the
-	// AribaBaseMsg and handle control packets,
-	// deliver data packets to the overlay
-	//
-
-	AribaBaseMsg* spovmsg = ((Message*)message)->decapsulate<AribaBaseMsg>();
-	logging_debug( "receiving base comm message of type " << spovmsg->getTypeString() );
-
-	//
-	// deliver data to the overlays. we just give the
-	// inner packet to every registered overlay ...
-	//
-
-	if( spovmsg->getType() == AribaBaseMsg::LINK_STATE_DATA ){
-
-		logging_debug( "received data message, forwarding to overlay" );
-
-		//
-		// put the linkid as address into the message
-		// and sent it to the receiver
-		//
-
-		if( messageReceiver != NULL ) {
-			messageReceiver->receiveMessage(
-				spovmsg,
-				spovmsg->getRemoteLink(),
-				NodeID::UNSPECIFIED
+SystemEventType TransportEvent("Transport");
+SystemEventType MessageDispatchEvent("MessageDispatchEvent", TransportEvent );
+
+class DispatchMsg {
+public:
+	address_v* local;
+	address_v* remote;
+	Message* message;
+};
+
+/// called when a system event is emitted by system queue
+void BaseCommunication::handleSystemEvent(const SystemEvent& event) {
+
+	// dispatch received messages
+	if ( event.getType() == MessageDispatchEvent ){
+		logging_debug( "Forwarding message receiver" );
+		DispatchMsg* dmsg = event.getData<DispatchMsg>();
+		Message* msg = dmsg->message;
+		receiveMessage(msg, dmsg->local, dmsg->remote);
+		msg->dropPayload();
+		delete dmsg;
+		delete msg;
+	}
+}
+
+/// called when a message is received form transport_peer
+void BaseCommunication::receive_message(transport_protocol* transport,
+	const address_vf local, const address_vf remote, const uint8_t* data,
+	size_t size) {
+
+//	logging_debug( "Dispatching message" );
+
+	// convert data
+	Data data_( const_cast<uint8_t*>(data), size * 8 );
+	DispatchMsg* dmsg = new DispatchMsg();
+
+	Message* msg = new Message(data_);
+	dmsg->local = local->clone();
+	dmsg->remote = remote->clone();
+	dmsg->message = msg;
+
+	SystemQueue::instance().scheduleEvent(
+		SystemEvent( this, MessageDispatchEvent, dmsg )
+	);
+}
+
+/// handles a message from the underlay transport
+void BaseCommunication::receiveMessage(const Message* message,
+	const address_v* local, const address_v* remote ){
+
+	/// decapsulate message
+	AribaBaseMsg* msg = ((Message*)message)->decapsulate<AribaBaseMsg>();
+	logging_debug( "Receiving message of type " << msg->getTypeString() );
+
+	// handle message
+	switch (msg->getType()) {
+
+		// ---------------------------------------------------------------------
+		// data message
+		// ---------------------------------------------------------------------
+		case AribaBaseMsg::typeData: {
+			logging_debug( "Received data message, forwarding to overlay" );
+			if( messageReceiver != NULL ) {
+				messageReceiver->receiveMessage(
+					msg, msg->getRemoteLink(), NodeID::UNSPECIFIED
+				);
+			}
+			break;
+		}
+
+		// ---------------------------------------------------------------------
+		// handle link request from remote
+		// ---------------------------------------------------------------------
+		case AribaBaseMsg::typeLinkRequest: {
+			logging_debug( "Received link open request" );
+
+			/// only answer the first request
+			if (!queryRemoteLink(msg->getLocalLink()).isUnspecified()) {
+				logging_debug("Link request already received. Ignore!");
+				break;
+			}
+
+			/// create link ids
+			LinkID localLink  = LinkID::create();
+			LinkID remoteLink = msg->getLocalLink();
+			logging_debug( "local=" << local->to_string()
+				<< " remote=" << remote->to_string()
 			);
+
+			// check if link creation is allowed by ALL listeners
+			bool allowlink = true;
+			BOOST_FOREACH( CommunicationEvents* i, eventListener ){
+				allowlink &= i->onLinkRequest( localLink, local, remote );
+			}
+
+			// not allowed-> warn
+			if( !allowlink ){
+				logging_warn( "Overlay denied creation of link" );
+				return;
+			}
+
+			// create descriptor
+			LinkDescriptor* ld = new LinkDescriptor();
+			ld->localLink = localLink;
+			ld->remoteLink = remoteLink;
+			ld->localLocator = local->clone();
+			ld->remoteLocator = remote->clone();
+			ld->remoteEndpoint = msg->getLocalDescriptor();
+
+			// add layer 1-3 addresses
+			ld->remoteEndpoint.getEndpoints().add(
+				ld->remoteLocator, endpoint_set::Layer1_3);
+			localDescriptor.getEndpoints().add(
+				local, endpoint_set::Layer1_3
+			);
+
+			// link is now up-> add it
+			ld->up = true;
+			addLink(ld);
+
+			// link is up!
+			logging_debug( "Link (initiated from remote) is up with "
+				<< "local(id=" << ld->localLink.toString() << ","
+				<< "locator=" << ld->localLocator->to_string() << ") "
+				<< "remote(id=" << ld->remoteLink.toString() << ", "
+				<< "locator=" << ld->remoteLocator->to_string() << ")"
+			);
+
+			// sending link request reply
+			logging_debug( "Sending link request reply with ids "
+				<< "local=" << localLink.toString() << ", "
+				<< "remote=" << remoteLink.toString() );
+			AribaBaseMsg reply( AribaBaseMsg::typeLinkReply, localLink, remoteLink );
+			reply.getLocalDescriptor() = localDescriptor;
+			reply.getRemoteDescriptor() = ld->remoteEndpoint;
+
+			send( &reply, *ld );
+
+			// inform listeners about new open link
+			BOOST_FOREACH( CommunicationEvents* i, eventListener ) {
+				i->onLinkUp( localLink, ld->localLocator, ld->remoteLocator);
+			}
+
+			// done
+			break;
 		}
 
-	} // LINK_STATE_DATA
-
-	//
-	// handle link open requests
-	//
-
-	else if( spovmsg->getType() == AribaBaseMsg::LINK_STATE_OPEN_REQUEST ){
-
-		logging_debug( "received link open request" );
-
-		//
-		// create a link context
-		//
-
-		//  in an incoming packet the localLink is from
-		// the sender perspective local and from our
-		// perspective remote
-
-		logging_debug( "creating local link" );
-
-		LinkID localLink  = LinkID::create();
-		LinkID remoteLink = spovmsg->getLocalLink();
-
-		if(localLink.isUnspecified()){
-			logging_error("local link is unspecified");
-			return false;
+		// ---------------------------------------------------------------------
+		// handle link request reply
+		// ---------------------------------------------------------------------
+		case AribaBaseMsg::typeLinkReply: {
+			logging_debug( "Received link open reply for a link we initiated" );
+
+			// this is a reply to a link open request, so we have already
+			// a link mapping and can now set the remote link to valid
+			LinkDescriptor& ld = queryLocalLink( msg->getRemoteLink() );
+
+			// no link found-> warn!
+			if (ld.isUnspecified()) {
+				logging_warn("Failed to find local link " << msg->getRemoteLink().toString());
+				return;
+			}
+
+			// set remote locator and link id
+			ld.remoteLink = msg->getLocalLink();
+			ld.remoteLocator = remote->clone();
+			localDescriptor.getEndpoints().add(
+				msg->getRemoteDescriptor().getEndpoints(),
+				endpoint_set::Layer1_3
+			);
+			ld.up = true;
+
+			logging_debug( "Link is now up with local id "
+				<< ld.localLink.toString() << " and remote id "
+				<< ld.remoteLink.toString() );
+
+
+			// inform lisneters about link up event
+			BOOST_FOREACH( CommunicationEvents* i, eventListener ){
+				i->onLinkUp( ld.localLink, ld.localLocator, ld.remoteLocator );
+			}
+
+			// done
+			break;
 		}
 
-		if(remoteLink.isUnspecified()){
-			logging_error("remote link is unspecified");
-			return false;
+		// ---------------------------------------------------------------------
+		// handle link close requests
+		// ---------------------------------------------------------------------
+		case AribaBaseMsg::typeLinkClose: {
+			// get remote link
+			const LinkID& localLink = msg->getRemoteLink();
+			logging_debug( "Received link close request for link " << localLink.toString() );
+
+			// searching for link, not found-> warn
+			LinkDescriptor& linkDesc = queryLocalLink( localLink );
+			if (linkDesc.isUnspecified()) {
+				logging_warn("Failed to find local link " << localLink.toString());
+				return;
+			}
+
+			// inform listeners
+			BOOST_FOREACH( CommunicationEvents* i, eventListener ){
+				i->onLinkDown( linkDesc.localLink,
+						linkDesc.localLocator, linkDesc.remoteLocator );
+			}
+
+			// remove the link descriptor
+			removeLink( localLink );
+
+			// done
+			break;
 		}
 
-		const NetworkLocator* localLocator  = dynamic_cast<const NetworkLocator*>(localDescriptor.locator);
-		const NetworkLocator* remoteLocator = dynamic_cast<const NetworkLocator*>(message->getSourceAddress());
-
-		logging_debug( "localLocator=" << localLocator->toString()
-				<< " remoteLocator=" << remoteLocator->toString());
-
-		// ask the registered listeners if this link
-		// creation is fine. we will only allow the
-		// link if all of them agree
-
-		bool allowlink = true;
-		BOOST_FOREACH( CommunicationEvents* i, eventListener ){
-			allowlink &= i->onLinkRequest( localLink, localLocator, remoteLocator );
+		// ---------------------------------------------------------------------
+		// handle link locator changes
+		// ---------------------------------------------------------------------
+		case AribaBaseMsg::typeLinkUpdate: {
+			const LinkID& localLink = msg->getRemoteLink();
+			logging_debug( "Received link update for link "
+				<< localLink.toString() );
+
+			// find the link description
+			LinkDescriptor& linkDesc = queryLocalLink( localLink );
+			if (linkDesc.isUnspecified()) {
+				logging_warn("Failed to update local link "
+					<< localLink.toString());
+				return;
+			}
+
+			// update the remote locator
+			const address_v* oldremote = linkDesc.remoteLocator;
+			linkDesc.remoteLocator = remote->clone();
+
+			// inform the listeners (local link has _not_ changed!)
+			BOOST_FOREACH( CommunicationEvents* i, eventListener ){
+				i->onLinkChanged(
+					linkDesc.localLink,	// linkid
+					linkDesc.localLocator,	// old local
+					linkDesc.localLocator,	// new local
+					oldremote,		// old remote
+					linkDesc.remoteLocator	// new remote
+				);
+			}
+
+			// done
+			break;
 		}
-
-		if( !allowlink ){
-			logging_warn( "overlay denied creation of link" );
-			return true;
-		}
-
-		//
-		// create and save the descriptor for the link
-		//
-
-		LinkDescriptor linkDescriptor(localLink, localLocator, remoteLink,
-					remoteLocator, EndpointDescriptor(remoteLocator), true);
-
-		logging_debug( "saving new link descriptor with " <<
-				"[local link " << localLink.toString() << "] " <<
-				"[local locator " << localLocator->toString() << "] " <<
-				"[remote link " << remoteLink.toString() << "] " <<
-				"[remote locator " << remoteLocator->toString() << "]" <<
-				"[link up true]" );
-
-		addLink( linkDescriptor );
-
-		//
-		// send out a link reply
-		//
-
-		logging_debug( "sending back link open reply for " <<
-					"[local link " << localLink.toString() << "] " <<
-					"[remote link " << remoteLink.toString() << "]" );
-
-		AribaBaseMsg reply(remoteLocator,
-				     AribaBaseMsg::LINK_STATE_OPEN_REPLY,
-				     localLink,
-				     remoteLink);
-
-		transport->sendMessage( &reply );
-
-		//
-		// the link is now open
-		//
-
-		BOOST_FOREACH( CommunicationEvents* i, eventListener ){
-			i->onLinkUp( localLink, localLocator, remoteLocator );
-		}
-
-	} // LINK_STATE_OPEN_REQUEST
-
-	//
-	// handle link open replies
-	//
-
-	else if( spovmsg->getType() == AribaBaseMsg::LINK_STATE_OPEN_REPLY ){
-
-		logging_debug( "received link open reply for a link we initiated" );
-
-		// this is a reply to a link open request, so we have already
-		// a link mapping and can now set the remote link to valid
-		LinkDescriptor& linkDesc = queryLocalLink( spovmsg->getRemoteLink() );
-
-		if (linkDesc.isUnspecified()) {
-			logging_warn("failed to find local link " << spovmsg->getRemoteLink().toString());
-			return false;
-		}
-
-		linkDesc.remoteLink = spovmsg->getLocalLink();
-		linkDesc.linkup = true;
-
-		logging_debug( "the link is now up with local link id " << linkDesc.localLink.toString() <<
-											" and remote link id " << linkDesc.remoteLink.toString() );
-
-		// notify the baseoverlay that the link is up, so
-		// it can exchange nodeids over this link. then we
-		// can send the queued messages, as both nodes have
-		// to know their nodeids first
-
-		BOOST_FOREACH( CommunicationEvents* i, eventListener ){
-			i->onLinkUp( linkDesc.localLink, linkDesc.localLocator, linkDesc.remoteLocator );
-		}
-
-	} // LINK_STATE_OPEN_REPLY
-
-	//
-	// handle link close requests
-	//
-
-	else if( spovmsg->getType() == AribaBaseMsg::LINK_STATE_CLOSE_REQUEST ){
-
-		const LinkID& localLink = spovmsg->getRemoteLink();
-		logging_debug( "received link close request for link " << localLink.toString() );
-
-		//
-		// the link is closed immediately, we
-		// don't need to send out a reply, so we
-		// delete the mapping and inform
-		//
-
-		LinkDescriptor& linkDesc = queryLocalLink( localLink );
-		if (linkDesc.isUnspecified()) {
-			logging_warn("Failed to find local link " << localLink.toString());
-			return false;
-		}
-
-		BOOST_FOREACH( CommunicationEvents* i, eventListener ){
-			i->onLinkDown( linkDesc.localLink, linkDesc.localLocator, linkDesc.remoteLocator );
-		}
-
-		//
-		// remove the link descriptor
-		//
-
-		removeLink( localLink );
-
-	} // LINK_STATE_CLOSE_REQUEST
-
-	//
-	// handle locator updates
-	//
-
-	else if( spovmsg->getType() == AribaBaseMsg::LINK_STATE_UPDATE ){
-
-		const LinkID& localLink = spovmsg->getRemoteLink();
-		logging_debug( "received link update for link " << localLink.toString() );
-
-		//
-		// find the link description
-		//
-
-		LinkDescriptor& linkDesc = queryLocalLink( localLink );
-		if (linkDesc.isUnspecified()) {
-			logging_warn("Failed to update local link " << localLink.toString());
-			return false;
-		}
-
-		//
-		// update the remote locator
-		//
-
-		const NetworkLocator* oldremote = linkDesc.remoteLocator;
-		linkDesc.remoteLocator = dynamic_cast<const NetworkLocator*>(message->getSourceAddress());
-
-		//
-		// inform the listeners (local link has _not_ changed!)
-		//
-
-		BOOST_FOREACH( CommunicationEvents* i, eventListener ){
-			i->onLinkChanged(
-				linkDesc.localLink,	// linkid
-				linkDesc.localLocator,	// old local
-				linkDesc.localLocator,	// new local
-				oldremote,		// old remote
-				linkDesc.remoteLocator	// new remote
-			);
-		}
-
-	} // LINK_STATE_UPDATE
-
-	return true;
-}
-
-void BaseCommunication::addLink( const LinkDescriptor& link ) {
+	}
+}
+
+/// add a newly allocated link to the set of links
+void BaseCommunication::addLink( LinkDescriptor* link ) {
 	linkSet.push_back( link );
 }
 
+/// remove a link from set
 void BaseCommunication::removeLink( const LinkID& localLink ) {
-
-	LinkSet::iterator i = linkSet.begin();
-	LinkSet::iterator iend = linkSet.end();
-
-	for( ; i != iend; i++){
-		if( (*i).localLink != localLink) continue;
-
+	for(LinkSet::iterator i=linkSet.begin(); i != linkSet.end(); i++){
+		if( (*i)->localLink != localLink) continue;
+		delete *i;
 		linkSet.erase( i );
 		break;
@@ -573,28 +497,28 @@
 }
 
+/// query a descriptor by local link id
 BaseCommunication::LinkDescriptor& BaseCommunication::queryLocalLink( const LinkID& link ) const {
 	for (int i=0; i<linkSet.size();i++)
-		if (linkSet[i].localLink == link) return (LinkDescriptor&)linkSet[i];
+		if (linkSet[i]->localLink == link) return (LinkDescriptor&)*linkSet[i];
 	return (LinkDescriptor&)LinkDescriptor::UNSPECIFIED;
 }
 
+/// query a descriptor by remote link id
 BaseCommunication::LinkDescriptor& BaseCommunication::queryRemoteLink( const LinkID& link ) const {
 	for (int i=0; i<linkSet.size();i++)
-		if (linkSet[i].remoteLink == link) return (LinkDescriptor&)linkSet[i];
+		if (linkSet[i]->remoteLink == link) return (LinkDescriptor&)*linkSet[i];
 	return (LinkDescriptor&)LinkDescriptor::UNSPECIFIED;
 }
 
-LinkIDs BaseCommunication::getLocalLinks( const EndpointDescriptor& ep ) const {
+LinkIDs BaseCommunication::getLocalLinks( const address_v* addr ) const {
 	LinkIDs ids;
-
 	for (int i=0; i<linkSet.size(); i++){
-		if( ep == EndpointDescriptor::UNSPECIFIED ){
-			ids.push_back( linkSet[i].localLink );
+		if( addr == NULL ){
+			ids.push_back( linkSet[i]->localLink );
 		} else {
-			if ( linkSet[i].remoteLocator == ep.locator )
-				ids.push_back( linkSet[i].localLink );
+			if ( *linkSet[i]->remoteLocator == *addr )
+				ids.push_back( linkSet[i]->localLink );
 		}
 	}
-
 	return ids;
 }
@@ -609,9 +533,8 @@
 #endif // UNDERLAY_OMNET
 
-	//
+/*- disabled!
+
 	// we only care about address changes, not about interface changes
 	// as address changes are triggered by interface changes, we are safe here
-	//
-
 	if( info.type != NetworkChangeInterface::EventTypeAddressNew &&
 		info.type != NetworkChangeInterface::EventTypeAddressDelete ) return;
@@ -619,8 +542,5 @@
 	logging_info( "base communication is handling network address changes" );
 
-	//
 	// get all now available addresses
-	//
-
 	NetworkInformation networkInformation;
 	AddressInformation addressInformation;
@@ -745,4 +665,17 @@
 		transport->sendMessage( &updateMsg );
 	}
+*/
+}
+
+/// sends a message to all end-points in the end-point descriptor
+void BaseCommunication::send(Message* message, const EndpointDescriptor& endpoint) {
+	Data data = data_serialize( message, DEFAULT_V );
+	transport->send( endpoint.getEndpoints(), data.getBuffer(), data.getLength() / 8);
+}
+
+/// sends a message to the remote locator inside the link descriptor
+void BaseCommunication::send(Message* message, const LinkDescriptor& desc) {
+	Data data = data_serialize( message, DEFAULT_V );
+	transport->send( desc.remoteLocator, data.getBuffer(), data.getLength() / 8);
 }
 
