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);
 }
 
Index: source/ariba/communication/BaseCommunication.h
===================================================================
--- source/ariba/communication/BaseCommunication.h	(revision 5151)
+++ source/ariba/communication/BaseCommunication.h	(revision 5284)
@@ -40,4 +40,5 @@
 #define BASECOMMUNICATION_H_
 
+// boost & std includes
 #include <ext/hash_map>
 #include <ext/hash_set>
@@ -49,65 +50,59 @@
 #include <boost/foreach.hpp>
 
+// utilities
 #include "ariba/utility/types.h"
 #include "ariba/utility/messages.h"
 #include "ariba/utility/logging/Logging.h"
 #include "ariba/utility/misc/Demultiplexer.hpp"
-
+#include "ariba/utility/system/SystemEventListener.h"
+
+// new transport and addressing
+#include "ariba/utility/addressing/addressing.hpp"
+#include "ariba/utility/transport/transport.hpp"
+
+// communication
 #include "ariba/communication/CommunicationEvents.h"
 #include "ariba/communication/EndpointDescriptor.h"
+#include "ariba/communication/messages/AribaBaseMsg.h"
+
+// network changes
 #include "ariba/communication/networkinfo/NetworkChangeInterface.h"
 #include "ariba/communication/networkinfo/NetworkChangeDetection.h"
 #include "ariba/communication/networkinfo/NetworkInformation.h"
 #include "ariba/communication/networkinfo/AddressInformation.h"
-#include "ariba/communication/messages/AribaBaseMsg.h"
-#include "ariba/communication/modules/transport/TransportProtocol.h"
-#include "ariba/communication/modules/network/NetworkProtocol.h"
-#include "ariba/communication/modules/network/NetworkLocator.h"
-
-#ifndef UNDERLAY_OMNET
-  #include "ariba/communication/modules/transport/tcp/TCPTransport.h"
-  #include "ariba/communication/modules/network/ip/IPv4NetworkProtocol.h"
-#endif
-
-using __gnu_cxx::hash_set;
-using __gnu_cxx::hash_map;
-
-using std::cout;
-using std::set;
-using std::map;
-using std::vector;
-using std::pair;
-using std::make_pair;
-using std::find;
-
-using ariba::communication::NetworkChangeDetection;
-using ariba::communication::NetworkChangeInterface;
-using ariba::communication::NetworkInterfaceList;
-using ariba::communication::NetworkInformation;
-using ariba::communication::AddressInformation;
-using ariba::communication::AddressList;
-using ariba::communication::AribaBaseMsg;
-using ariba::communication::CommunicationEvents;
-
-using ariba::utility::Demultiplexer;
-using ariba::utility::QoSParameterSet;
-using ariba::utility::SecurityParameterSet;
-using ariba::utility::Address;
-using ariba::utility::LinkID;
-using ariba::utility::LinkIDs;
-using ariba::utility::Message;
-using ariba::utility::MessageReceiver;
-using ariba::utility::seqnum_t;
-
-using ariba::communication::TransportProtocol;
-using ariba::communication::NetworkProtocol;
-using ariba::communication::NetworkLocator;
-#ifndef UNDERLAY_OMNET
-  using ariba::communication::IPv4NetworkProtocol;
-  using ariba::communication::TCPTransport;
-#endif
+
+// deprecated
+//#include "ariba/communication/modules/transport/TransportProtocol.h"
+//#include "ariba/communication/modules/network/NetworkProtocol.h"
+//#include "ariba/communication/modules/network/NetworkLocator.h"
+
+// disabled
+//#ifndef UNDERLAY_OMNET
+//  #include "ariba/communication/modules/transport/tcp/TCPTransport.h"
+//  #include "ariba/communication/modules/network/ip/IPv4NetworkProtocol.h"
+//#endif
+
+// deprecated
+//using ariba::communication::TransportProtocol;
+//using ariba::communication::NetworkProtocol;
+//using ariba::communication::NetworkLocator;
+
+// disabled
+//#ifndef UNDERLAY_OMNET
+//  using ariba::communication::IPv4NetworkProtocol;
+//  using ariba::communication::TCPTransport;
+//#endif
 
 namespace ariba {
 namespace communication {
+
+using namespace std;
+using namespace ariba::addressing;
+using namespace ariba::transport;
+using namespace ariba::utility;
+
+// use base ariba types (clarifies multiple definitions)
+using ariba::utility::Message;
+using ariba::utility::seqnum_t;
 
 /**
@@ -119,50 +114,34 @@
  * @author Sebastian Mies, Christoph Mayer
  */
-class BaseCommunication : public MessageReceiver, NetworkChangeInterface {
+class BaseCommunication: public NetworkChangeInterface,
+	public SystemEventListener, public transport_listener {
 	use_logging_h(BaseCommunication);
+
 public:
-
-	/**
-	 * Default ctor that just creates an empty
-	 * non functional base communication
-	 */
+	/// Default ctor that just creates an non-functional base communication
 	BaseCommunication();
 
-	/**
-	 * Default dtor that does nothing
-	 */
+	/// Default dtor that does nothing
 	virtual ~BaseCommunication();
 
-	/**
-	 * Startup the base communication, start modules etc.
-	 */
-	void start(const NetworkLocator* _locallocator, const uint16_t _listenport);
-
-	/**
-	 * stop the base communication, stop modules etc.
-	 */
+	/// Startup the base communication, start modules etc.
+	void start();
+
+	/// Stops the base communication, stop modules etc.
 	void stop();
 
-	/*
-	 * Check whether the base communication has been started up
-	 */
+	/// Sets the endpoints
+	void setEndpoints( string& endpoints );
+
+	/// Check whether the base communication has been started up
 	bool isStarted();
 
-
-	/**
-	 * Establishes a link to another end-point.
-	 */
-	const LinkID establishLink(
-		const EndpointDescriptor& descriptor,
-		const LinkID& linkid = LinkID::UNSPECIFIED,
-		const QoSParameterSet& qos = QoSParameterSet::DEFAULT,
-		const SecurityParameterSet& sec = SecurityParameterSet::DEFAULT
-	);
-
-	/**
-	 * Drops a link.
-	 *
-	 * @param The link id of the link that should be dropped
-	 */
+	/// Establishes a link to another end-point.
+	const LinkID establishLink(const EndpointDescriptor& descriptor,
+		const LinkID& linkid = LinkID::UNSPECIFIED, const QoSParameterSet& qos =
+				QoSParameterSet::DEFAULT, const SecurityParameterSet& sec =
+				SecurityParameterSet::DEFAULT);
+
+	/// Drops a link
 	void dropLink(const LinkID link);
 
@@ -182,5 +161,6 @@
 	 * @return The end-point descriptor of the link's end-point
 	 */
-	const EndpointDescriptor& getEndpointDescriptor( const LinkID link = LinkID::UNSPECIFIED ) const;
+	const EndpointDescriptor& getEndpointDescriptor(const LinkID link =
+			LinkID::UNSPECIFIED) const;
 
 	/**
@@ -190,5 +170,5 @@
 	 * @return List of LinkID
 	 */
-	LinkIDs getLocalLinks( const EndpointDescriptor& ep = EndpointDescriptor::UNSPECIFIED ) const;
+	LinkIDs getLocalLinks(const address_v* addr) const;
 
 	/**
@@ -197,5 +177,7 @@
 	 * @param _receiver The receiving side
 	 */
-	void registerMessageReceiver( MessageReceiver* _receiver );
+	void registerMessageReceiver(MessageReceiver* receiver) {
+		messageReceiver = receiver;
+	}
 
 	/**
@@ -204,28 +186,36 @@
 	 * @param _receiver The receiving side
 	 */
-	void unregisterMessageReceiver( MessageReceiver* _receiver );
-
-	void registerEventListener( CommunicationEvents* _events );
-	void unregisterEventListener( CommunicationEvents* _events );
+	void unregisterMessageReceiver(MessageReceiver* receiver) {
+		messageReceiver = NULL;
+	}
+
+	void registerEventListener(CommunicationEvents* _events);
+
+	void unregisterEventListener(CommunicationEvents* _events);
+
+public:
+
+	/// called when a system event is emitted by system queue
+	virtual void handleSystemEvent(const SystemEvent& event);
+
+	/// called when a message is received form transport_peer
+	virtual void receive_message(transport_protocol* transport,
+		const address_vf local, const address_vf remote, const uint8_t* data,
+		size_t size);
 
 protected:
 
-	/**
-	 * Called from the Transport when async items
-	 * from the SystemQueue are delivered
-	 */
-	virtual bool receiveMessage( const Message* message, const LinkID& link, const NodeID& node );
-
-	/**
-	 * Called when a network interface change happens
-	 */
-	virtual void onNetworkChange( const NetworkChangeInterface::NetworkChangeInfo& info );
+	/// handle received message from a transport module
+	void receiveMessage(const Message* message,
+		const address_v* local, const address_v* remote );
+
+	/// called when a network interface change happens
+	virtual void onNetworkChange(
+		const NetworkChangeInterface::NetworkChangeInfo& info);
 
 private:
-
-	/**
-	 * A link descriptor consisting of the
-	 * end-point descriptor and currently used locator and
-	 * message receiver
+	/**
+	 * A link descriptor consisting of the end-point descriptor and currently
+	 * used underlay address.
 	 */
 	class LinkDescriptor {
@@ -233,118 +223,80 @@
 		static const LinkDescriptor UNSPECIFIED;
 
+		/// default constructor
 		LinkDescriptor() :
-			localLink(LinkID::UNSPECIFIED),
-			localLocator(NULL),
-			remoteLink(LinkID::UNSPECIFIED),
-			remoteLocator(NULL),
-			remoteEndpoint(EndpointDescriptor::UNSPECIFIED),
-			linkup(false) {
+			localLink(LinkID::UNSPECIFIED), localLocator(NULL),
+			remoteLink(LinkID::UNSPECIFIED), remoteLocator(NULL),
+			remoteEndpoint(EndpointDescriptor::UNSPECIFIED), up(false) {
 		}
 
-		LinkDescriptor(const LinkID& _localLink, const NetworkLocator*& _localLocator,
-				const LinkID& _remoteLink, const NetworkLocator*& _remoteLocator,
-				const EndpointDescriptor& _remoteEndpoint, bool _linkup ) :
-			localLink(_localLink),
-			localLocator(_localLocator),
-			remoteLink(_remoteLink),
-			remoteLocator(_remoteLocator),
-			remoteEndpoint(_remoteEndpoint),
-			linkup(_linkup) {
+		~LinkDescriptor() {
+			if (localLocator!=NULL)  delete localLocator;
+			if (remoteLocator!=NULL) delete remoteLocator;
 		}
 
-		LinkDescriptor( const LinkDescriptor& desc ) :
-			localLink(desc.localLink),
-			localLocator(desc.localLocator),
-			remoteLink(desc.remoteLink),
-			remoteLocator(desc.remoteLocator),
-			remoteEndpoint(desc.remoteEndpoint),
-			linkup(desc.linkup) {
+		/// returns true if this is the UNSPECIFIED object
+		bool isUnspecified() const {
+			return this == &UNSPECIFIED;
 		}
 
-		bool isUnspecified() const {
-			return (this == &UNSPECIFIED);
-		}
-
-		LinkID 					localLink;
-		const NetworkLocator* 	localLocator;
-		LinkID 					remoteLink;
-		const NetworkLocator* 	remoteLocator;
-		EndpointDescriptor 		remoteEndpoint;
-
-		bool 					linkup;
+		/// link identifiers
+		LinkID localLink;
+		LinkID remoteLink;
+
+		/// used underlay addresses for the link
+		const address_v* localLocator;
+		const address_v* remoteLocator;
+
+		/// the remote end-point descriptor
+		EndpointDescriptor remoteEndpoint;
+
+		/// flag, whether this link is up
+		bool up;
 	};
 
-	/**
-	 * Link management: add a link
-	 */
-	void addLink( const LinkDescriptor& link );
-
-	/**
-	 * Link management: remove alink
-	 */
-	void removeLink( const LinkID& localLink );
-
-	/**
-	 * Link management: get link information using the local link
-	 */
-	LinkDescriptor& queryLocalLink( const LinkID& localLink ) const;
-
-	/**
-	 * Link management: get link information using the remote link
-	 */
-	LinkDescriptor& queryRemoteLink( const LinkID& remoteLink ) const;
-
-	/**
-	 * Link management: list of links
-	 */
-	typedef vector<LinkDescriptor> LinkSet;
-
-	/**
-	 * Link management: the set of currently managed links
-	 */
+	/// Link management: list of links
+	typedef vector<LinkDescriptor*> LinkSet;
+
+	/// Link management: the set of currently managed links
 	LinkSet linkSet;
 
-	/**
-	 * The message receiver
-	 */
-	MessageReceiver* messageReceiver;
-
-	/**
-	 * The local end-point descriptor
-	 */
+	/// Link management: add a link
+	void addLink( LinkDescriptor* link );
+
+	/// Link management: remove a link
+	void removeLink(const LinkID& localLink);
+
+	/// Link management: get link information using the local link
+	LinkDescriptor& queryLocalLink(const LinkID& localLink) const;
+
+	/// Link management: get link information using the remote link
+	LinkDescriptor& queryRemoteLink(const LinkID& remoteLink) const;
+
+	/// The local end-point descriptor
 	EndpointDescriptor localDescriptor;
 
-	/**
-	 * Network information and protocol
-	 */
-	NetworkProtocol* network;
-
-	/**
-	 * Transport information and protocol
-	 */
-	TransportProtocol* transport;
-
 #ifndef UNDERLAY_OMNET
-	/**
-	 * Detect changes in the routing/interface, etc.
-	 * stuff needed for mobility detection
-	 */
+	/// network change detector
 	NetworkChangeDetection networkMonitor;
 #endif
-
-	/**
-	 * The local listen port
-	 */
-	uint16_t listenport;
-
+	/// event listener
 	typedef set<CommunicationEvents*> EventListenerSet;
 	EventListenerSet eventListener;
 
+	/// sequence numbers
 	seqnum_t currentSeqnum;
 
-	/**
-	 * state of the base communication
-	 */
-	bool basecommStarted;
+	/// transport peer
+	transport_peer* transport;
+
+	/// the base overlay message receiver
+	MessageReceiver* messageReceiver;
+
+	/// convenience: send message to peer
+	void send( Message* message, const EndpointDescriptor& endpoint );
+	void send( Message* message, const LinkDescriptor& descriptor );
+
+	/// state of the base communication
+	bool started;
 
 };
@@ -352,3 +304,3 @@
 }} // namespace ariba, communication
 
-#endif /*BASECOMMUNICATION_H_*/
+#endif /* BASECOMMUNICATION_H_ */
Index: source/ariba/communication/CommunicationEvents.cpp
===================================================================
--- source/ariba/communication/CommunicationEvents.cpp	(revision 5151)
+++ source/ariba/communication/CommunicationEvents.cpp	(revision 5284)
@@ -48,22 +48,28 @@
 }
 
-bool CommunicationEvents::onLinkRequest( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote ) {
+bool CommunicationEvents::onLinkRequest(const LinkID& id,
+	const address_v* local, const address_v* remote) {
 	return true;
 }
 
-void CommunicationEvents::onLinkUp( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote ) {
+void CommunicationEvents::onLinkUp(const LinkID& id, const address_v* local,
+	const address_v* remote) {
 }
 
-void CommunicationEvents::onLinkDown( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote ) {
+void CommunicationEvents::onLinkDown(const LinkID& id, const address_v* local,
+	const address_v* remote) {
 }
 
-
-void CommunicationEvents::onLinkChanged( const LinkID& id, const NetworkLocator* oldlocal, const NetworkLocator* newlocal, const NetworkLocator* oldremote, const NetworkLocator* newremote ) {
+void CommunicationEvents::onLinkChanged(const LinkID& id,
+	const address_v* oldlocal, const address_v* newlocal,
+	const address_v* oldremote, const address_v* newremote) {
 }
 
-void CommunicationEvents::onLinkFail( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote ){
+void CommunicationEvents::onLinkFail(const LinkID& id, const address_v* local,
+	const address_v* remote) {
 }
 
-void CommunicationEvents::onLinkQoSChanged( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote, const QoSParameterSet& qos ){
+void CommunicationEvents::onLinkQoSChanged(const LinkID& id,
+	const address_v* local, const address_v* remote, const QoSParameterSet& qos) {
 }
 
Index: source/ariba/communication/CommunicationEvents.h
===================================================================
--- source/ariba/communication/CommunicationEvents.h	(revision 5151)
+++ source/ariba/communication/CommunicationEvents.h	(revision 5284)
@@ -41,16 +41,15 @@
 
 #include "ariba/utility/types/LinkID.h"
-#include "ariba/communication/modules/network/NetworkLocator.h"
 #include "ariba/utility/types/QoSParameterSet.h"
-
-using ariba::utility::LinkID;
-using ariba::utility::QoSParameterSet;
-using ariba::communication::NetworkLocator;
+#include "ariba/utility/addressing/addressing.hpp"
 
 namespace ariba {
 namespace communication {
 
+using ariba::utility::LinkID;
+using ariba::utility::QoSParameterSet;
+using namespace ariba::addressing;
+
 class CommunicationEvents {
-
 	friend class BaseCommunication;
 
@@ -69,5 +68,6 @@
 	 * @return True, if the link should be established
 	 */
-	virtual bool onLinkRequest( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
+	virtual bool onLinkRequest(const LinkID& id, const address_v* local,
+		const address_v* remote);
 
 	/**
@@ -77,5 +77,6 @@
 	 * @param id The link id of the established link
 	 */
-	virtual void onLinkUp( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
+	virtual void onLinkUp(const LinkID& id, const address_v* local,
+		const address_v* remote);
 
 	/**
@@ -84,5 +85,6 @@
 	 * @param id The link identifier of the dropped link
 	 */
-	virtual void onLinkDown( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
+	virtual void onLinkDown(const LinkID& id, const address_v* local,
+		const address_v* remote);
 
 	/**
@@ -94,9 +96,14 @@
 	 * @param id The link identifier of the changed link
 	 */
-	virtual void onLinkChanged( const LinkID& id, const NetworkLocator* oldlocal, const NetworkLocator* newlocal, const NetworkLocator* oldremote, const NetworkLocator* newremote );
+	virtual void onLinkChanged(const LinkID& id,
+		const address_v* oldlocal,  const address_v* newlocal,
+		const address_v* oldremote, const address_v* newremote
+	);
 
-	virtual void onLinkFail( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
+	virtual void onLinkFail(const LinkID& id, const address_v* local,
+		const address_v* remote);
 
-	virtual void onLinkQoSChanged( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote, const QoSParameterSet& qos );
+	virtual void onLinkQoSChanged(const LinkID& id, const address_v* local,
+		const address_v* remote, const QoSParameterSet& qos);
 };
 
Index: source/ariba/communication/EndpointDescriptor.cpp
===================================================================
--- source/ariba/communication/EndpointDescriptor.cpp	(revision 5151)
+++ source/ariba/communication/EndpointDescriptor.cpp	(revision 5284)
@@ -48,113 +48,9 @@
 const EndpointDescriptor EndpointDescriptor::UNSPECIFIED;
 
-EndpointDescriptor::EndpointDescriptor() : locator( NULL ), isUnspec( true ){
-}
-
-EndpointDescriptor::EndpointDescriptor(const EndpointDescriptor& rh){
-	locator = (rh.locator != NULL) ? new IPv4Locator(*rh.locator) : NULL;
-	isUnspec = rh.isUnspec;
-}
-
-EndpointDescriptor::EndpointDescriptor(const Locator* _locator){
-	if( _locator == NULL ) return;
-
-	locator = new IPv4Locator(*dynamic_cast<IPv4Locator*>((Locator*)_locator));
-	isUnspec = false;
-}
-
-EndpointDescriptor::EndpointDescriptor(const string str) {
-	using namespace boost::xpressive;
-	using namespace ariba::utility::string_format;
-	using namespace ariba::utility::Helper;
-	using namespace std;
-
-	locator = NULL;
-	isUnspec = true;
-
-	smatch match;
-	if (regex_search(str, match, robjects)) {
-		regex_nav nav = match;
-		for (int i=0; i<nav.size(); i++) {
-			string type = nav[i][robject_id].str();
-			if (type=="ip") {
-				string ip = nav[i][robject_data].str();
-				ip = ip.substr(1,ip.size()-2);
-				this->locator = new IPv4Locator();
-				this->locator->setIP(ip);
-				this->isUnspec = false;
-			} else
-			if (type=="tcp") {
-				string port = nav[i][robject_data][rfields][1].str();
-				port = port.substr(1,port.size()-2);
-				this->locator->setPort(stoi(port));
-			}
-		}
-	}
-}
-
+/// destructor.
 EndpointDescriptor::~EndpointDescriptor() {
-}
-
-bool EndpointDescriptor::isUnspecified() const {
-	return isUnspec;
-}
-
-string EndpointDescriptor::toString() const {
-	if( locator == NULL ) return "<undefined locator>";
-	std::ostringstream o;
-	o << "ip{" << locator->getIP() << "}";
-	o << ",";
-	o << "tcp(ip,{" << locator->getPort() << "})";
-	return o.str();
-}
-
-EndpointDescriptor* EndpointDescriptor::fromString( string str ) {
-	return new EndpointDescriptor( str );
-}
-
-bool EndpointDescriptor::operator!=( const EndpointDescriptor& rh ) const {
-	return !operator==(rh);
-}
-
-bool EndpointDescriptor::operator==(const EndpointDescriptor& rh) const {
-
-	if( isUnspecified() && rh.isUnspecified() ) {
-
-		// both unspec bit set
-		return true;
-
-	} else if( (!isUnspecified()) && (!rh.isUnspecified()) ) {
-
-		//
-		// both are valid, check locators
-		//
-
-		if( locator == NULL && rh.locator == NULL ){
-
-			// both locators are invalid, ok true
-			return true;
-
-		} else if( locator == NULL ^ rh.locator == NULL ) {
-
-			// one locator is invalid, the other not, false
-			return false;
-
-		} else {
-
-			// both locators are valid, compare
-			assert( locator != NULL && rh.locator != NULL );
-			return ( locator->operator==(*rh.locator) );
-
-		}
-
-	} else {
-
-		// one is unspec, the other not
-		assert( isUnspecified() ^ rh.isUnspecified() );
-		return false;
-
-	}
 
 }
 
+
 }} // namespace ariba, communication
Index: source/ariba/communication/EndpointDescriptor.h
===================================================================
--- source/ariba/communication/EndpointDescriptor.h	(revision 5151)
+++ source/ariba/communication/EndpointDescriptor.h	(revision 5284)
@@ -40,14 +40,22 @@
 #define ENDPOINTDESCRIPTOR_H_
 
+// deprecated
+//#include "ariba/communication/modules/network/ip/IPv4Locator.h"
+
+// deprecated
+//using ariba::utility::Locator;
+//using ariba::communication::IPv4Locator;
+
+// typical types
 #include "ariba/utility/types.h"
 #include "ariba/utility/serialization.h"
-#include "ariba/communication/modules/network/ip/IPv4Locator.h"
+
+// new addressing and transport
+#include "ariba/utility/addressing/addressing.hpp"
+#include "ariba/utility/transport/transport.hpp"
+
+// stdlibc++
 #include <string>
 #include <set>
-
-using std::string;
-using std::set;
-using ariba::utility::Locator;
-using ariba::communication::IPv4Locator;
 
 namespace ariba {
@@ -55,58 +63,90 @@
 
 using_serialization;
+using namespace std;
+using namespace ariba::addressing;
 
-class EndpointDescriptor : public VSerializeable {
-	VSERIALIZEABLE;
-
+class EndpointDescriptor: public VSerializeable { VSERIALIZEABLE
 	friend class BaseCommunication;
 
 public:
-	/**
-	 * The default constructor.
-	 */
-	EndpointDescriptor();
+	/// the unspecified endpoint descriptor
+	static const EndpointDescriptor UNSPECIFIED;
 
-	EndpointDescriptor(const EndpointDescriptor& rh);
-	EndpointDescriptor(const Locator* _locator);
-	EndpointDescriptor(const string str);
+	/// creates an empty endpoint descriptor with zero endpoints
+	EndpointDescriptor() : endpoints() {
+	}
 
-	/**
-	 * The destructor.
-	 */
+	/// destructor.
 	virtual ~EndpointDescriptor();
 
-	/**
-	 * An unspecified end-point
-	 */
-	static const EndpointDescriptor UNSPECIFIED;
+	/// copy constructor
+	EndpointDescriptor(const EndpointDescriptor& rh) :
+		endpoints(rh.endpoints) {
+	}
 
-	/**
-	 * Returns true, if the descriptor is unspecified.
-	 *
-	 * @return True, if the descriptor is unspecified.
-	 */
-	bool isUnspecified() const;
+	/// construct end-points from an endpoint set
+	EndpointDescriptor(const endpoint_set& endpoints ) :
+		endpoints(endpoints) {
+	}
 
-	virtual string toString() const;
-	static EndpointDescriptor* fromString( string str );
+	/// construct end-points from a string
+	EndpointDescriptor(const string& str) : endpoints(str) {
+	}
 
-	bool operator==( const EndpointDescriptor& rh ) const;
-	bool operator!=( const EndpointDescriptor& rh ) const;
+	/// convert end-points to string
+	string toString() const {
+		return endpoints.to_string();
+	}
+
+	/// returns true, if this object is the unspecified object
+	bool isUnspecified() const {
+		return this == &UNSPECIFIED;
+	}
+
+	/// create endpoint
+	static EndpointDescriptor* fromString(string str) {
+		return new EndpointDescriptor(str);
+	}
+
+	bool operator==(const EndpointDescriptor& rh) const {
+		if (rh.isUnspecified() && isUnspecified()) return true;
+		return false;
+	}
+
+	bool operator!=(const EndpointDescriptor& rh) const {
+		if (!rh.isUnspecified() && !isUnspecified()) return true;
+		return false;
+	}
+
+	EndpointDescriptor& operator=( const EndpointDescriptor& rhs) {
+		endpoints = rhs.endpoints;
+	}
+
+	/// returns the end-points of this descriptor
+	endpoint_set& getEndpoints() {
+		return endpoints;
+	}
+
+	/// returns the end-points of this descriptor
+	const endpoint_set& getEndpoints() const {
+		return endpoints;
+	}
 
 private:
-	bool isUnspec;
-	IPv4Locator* locator;
+	endpoint_set endpoints;
 };
 
 }} // namespace ariba, communication
 
-sznBeginDefault( ariba::communication::EndpointDescriptor, X ) {
-	uint8_t unspec = isUnspec;
-
-	X && unspec && VO(locator);
-
-	// when deserializing reset unspec flag
-	if (X.isDeserializer()) isUnspec = unspec;
-} sznEnd();
+sznBeginDefault( ariba::communication::EndpointDescriptor, X ){
+	// serialize endpoints
+	uint16_t len = endpoints.to_bytes_size();
+	X && len;
+	uint8_t* buffer = X.bytes( len );
+	if (buffer!=NULL) {
+		if (X.isDeserializer()) endpoints.assign(buffer,len);
+		else endpoints.to_bytes(buffer);
+	}
+}sznEnd();
 
 #endif /*ENDPOINTDESCRIPTOR_H_*/
Index: source/ariba/communication/messages/AribaBaseMsg.cpp
===================================================================
--- source/ariba/communication/messages/AribaBaseMsg.cpp	(revision 5151)
+++ source/ariba/communication/messages/AribaBaseMsg.cpp	(revision 5284)
@@ -44,42 +44,28 @@
 vsznDefault(AribaBaseMsg);
 
-AribaBaseMsg::AribaBaseMsg(
-	const Address* address,
-	LINK_STATE _state,
-	const LinkID& _localLink,
-	const LinkID& _remoteLink )
-		: state( (uint8_t)_state ),
-		  localLink( _localLink ),
-		  remoteLink( _remoteLink ){
-
-	Message::setDestinationAddress( address );
+AribaBaseMsg::AribaBaseMsg( type_ _type,
+	const LinkID& localLink, const LinkID& remoteLink ) :
+	type((uint8_t)_type),
+	localLink(localLink),remoteLink(remoteLink) {
 }
 
-AribaBaseMsg::~AribaBaseMsg(){
+AribaBaseMsg::~AribaBaseMsg() {
 }
 
-const AribaBaseMsg::LINK_STATE AribaBaseMsg::getType(){
-	return (LINK_STATE)state;
-}
-
-const LinkID& AribaBaseMsg::getLocalLink(){
-	return localLink;
-}
-
-const LinkID& AribaBaseMsg::getRemoteLink(){
-	return remoteLink;
-}
-
-const string AribaBaseMsg::getTypeString(){
-
-	switch( getType() ){
-		case LINK_STATE_DATA: 			return "LINK_STATE_DATA";
-		case LINK_STATE_OPEN_REQUEST: 	return "LINK_STATE_OPEN_REQUEST";
-		case LINK_STATE_OPEN_REPLY: 	return "LINK_STATE_OPEN_REPLY";
-		case LINK_STATE_CLOSE_REQUEST: 	return "LINK_STATE_CLOSE_REQUEST";
-		case LINK_STATE_UPDATE:			return "LINK_STATE_UPDATE";
-		default:						"unknown";
+const string AribaBaseMsg::getTypeString() const {
+	switch (getType()) {
+		case typeData:
+			return "typeData";
+		case typeLinkRequest:
+			return "typeLinkRequest";
+		case typeLinkReply:
+			return "typeLinkReply";
+		case typeLinkClose:
+			return "typeLinkClose";
+		case typeLinkUpdate:
+			return "typeLinkUpdate";
+		default:
+			"unknown";
 	}
-
 	return "unknown";
 }
Index: source/ariba/communication/messages/AribaBaseMsg.h
===================================================================
--- source/ariba/communication/messages/AribaBaseMsg.h	(revision 5151)
+++ source/ariba/communication/messages/AribaBaseMsg.h	(revision 5284)
@@ -48,4 +48,6 @@
 #include "ariba/utility/types/ServiceID.h"
 
+#include "../EndpointDescriptor.h"
+
 using std::string;
 using ariba::utility::Address;
@@ -62,31 +64,50 @@
 	VSERIALIZEABLE;
 public:
+	enum type_ {
+		typeData = 0,
+		typeLinkRequest = 1,
+		typeLinkReply = 2,
+		typeLinkClose = 3,
+		typeLinkUpdate = 4
+	};
 
-	typedef enum _LINK_STATE {
-		LINK_STATE_DATA          = 0,
-		LINK_STATE_OPEN_REQUEST  = 1,
-		LINK_STATE_OPEN_REPLY    = 2,
-		LINK_STATE_CLOSE_REQUEST = 3, // there is no close reply. send request and local link is closed
-		LINK_STATE_UPDATE        = 4,
-	} LINK_STATE;
-
-	AribaBaseMsg(
-			const Address* address    = NULL,
-			LINK_STATE _state         = LINK_STATE_DATA,
-			const LinkID& _localLink  = LinkID::UNSPECIFIED,
-			const LinkID& _remoteLink = LinkID::UNSPECIFIED );
+	AribaBaseMsg( type_ type = typeData,
+			const LinkID& localLink = LinkID::UNSPECIFIED,
+			const LinkID& remoteLink = LinkID::UNSPECIFIED );
 
 	virtual ~AribaBaseMsg();
 
-	const LINK_STATE getType();
-	const string getTypeString();
-	const LinkID& getLocalLink();
-	const LinkID& getRemoteLink();
+	const string getTypeString() const;
+
+	const type_ getType() const {
+		return (type_)type;
+	}
+
+	const LinkID& getLocalLink() const {
+		return localLink;
+	}
+
+	const LinkID& getRemoteLink() const {
+		return remoteLink;
+	}
+
+	EndpointDescriptor& getLocalDescriptor() {
+		return localDescriptor;
+	}
+
+	EndpointDescriptor& getRemoteDescriptor() {
+		return remoteDescriptor;
+	}
 
 private:
-	uint8_t state;		// the link message type
+	uint8_t type;		// the link message type
+
+	// remote and local link ids
 	LinkID localLink;	// the local link id
 	LinkID remoteLink;	// the remote link id
 
+	// remote and local endpoint descriptors
+	EndpointDescriptor localDescriptor;
+	EndpointDescriptor remoteDescriptor;
 };
 
@@ -94,5 +115,8 @@
 
 sznBeginDefault( ariba::communication::AribaBaseMsg, X ) {
-	X && state && &localLink && &remoteLink && Payload();
+	X && type && &localLink && &remoteLink;
+	if (type == typeLinkReply || type == typeLinkRequest)
+		X && localDescriptor && remoteDescriptor;
+	X && Payload();
 } sznEnd();
 
Index: source/ariba/communication/networkinfo/AddressDiscovery.hpp
===================================================================
--- source/ariba/communication/networkinfo/AddressDiscovery.hpp	(revision 5284)
+++ source/ariba/communication/networkinfo/AddressDiscovery.hpp	(revision 5284)
@@ -0,0 +1,70 @@
+#ifndef ADDRESSDISCOVERY_HPP_
+#define ADDRESSDISCOVERY_HPP_
+
+#include "ariba/utility/addressing/addressing.hpp"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#include <ifaddrs.h>
+
+using namespace ariba::addressing;
+
+mac_address getMacFromIF( const char* name ) {
+	int s;
+	struct ifreq buffer;
+	s = socket(PF_INET, SOCK_DGRAM, 0);
+	memset(&buffer, 0x00, sizeof(buffer));
+	strcpy(buffer.ifr_name, name);
+	ioctl(s, SIOCGIFHWADDR, &buffer);
+	close(s);
+	mac_address addr;
+	addr.assign( (uint8_t*)buffer.ifr_hwaddr.sa_data, 6 );
+	return addr;
+}
+
+void discoverEndpoints( endpoint_set& endpoints ) {
+	struct ifaddrs* ifaceBuffer = NULL;
+	struct ifaddrs* tmpAddr     = NULL;
+	void*           tmpAddrPtr  = NULL;
+	char            straddr     [INET_ADDRSTRLEN];
+
+	int ret = getifaddrs( &ifaceBuffer );
+	if( ret != 0 ) return;
+
+	for( struct ifaddrs* i=ifaceBuffer; i != NULL; i=i->ifa_next ) {
+
+		// ignore devices that are disabled or have no ip
+		if(i == NULL) continue;
+		struct sockaddr* addr = i->ifa_addr;
+
+		// only look at IPv4, not IPv6 addresses
+		if (addr->sa_family == AF_INET) {
+			if (addr==NULL) continue;
+			tmpAddrPtr= &((struct sockaddr_in*)addr)->sin_addr;
+			inet_ntop( i->ifa_addr->sa_family, tmpAddrPtr, straddr, sizeof(straddr) );
+			ip_address ip = straddr;
+			if (ip.is_loopback()) continue;
+			address_vf vf = ip;
+			endpoints.add( vf );
+		} else
+		if (addr->sa_family == AF_INET6) {
+			if (addr==NULL) continue;
+			tmpAddrPtr= &((struct sockaddr_in6*)addr)->sin6_addr;
+			inet_ntop( i->ifa_addr->sa_family, tmpAddrPtr, straddr, sizeof(straddr) );
+			ip_address ip = straddr;
+			if (ip.is_loopback()) continue;
+			address_vf vf = ip;
+			endpoints.add( vf );
+		} else
+		if (i->ifa_name[0]=='p' && i->ifa_name[1]=='a' && i->ifa_name[2]=='n') {
+			mac_address mac = getMacFromIF(i->ifa_name);
+			address_vf vf = mac;
+			endpoints.add( vf );
+		}
+	}
+}
+
+#endif /* ADDRESSDISCOVERY_HPP_ */
Index: source/ariba/communication/networkinfo/AddressInformation.cpp
===================================================================
--- source/ariba/communication/networkinfo/AddressInformation.cpp	(revision 5151)
+++ source/ariba/communication/networkinfo/AddressInformation.cpp	(revision 5284)
@@ -39,6 +39,13 @@
 #include "AddressInformation.h"
 
+#include <ifaddrs.h>
+
+#include <boost/asio/ip/address.hpp>
+#include <boost/asio/ip/address_v4.hpp>
+
 namespace ariba {
 namespace communication {
+
+using namespace ariba::addressing;
 
 AddressInformation::AddressInformation(){
@@ -52,32 +59,29 @@
 	AddressList retlist;
 
-	//
 	// gather transport addresses
-	//
-
 	struct ifaddrs* ifap;
 	getifaddrs( &ifap );
 
 	for( struct ifaddrs* p = ifap; p != NULL; p=p->ifa_next ){
+
+		// no name set? ->continue
 		if( interface.name.compare(string(p->ifa_name)) != 0 ) continue;
 
-		// TODO: currently only handle IPv4
+		// handle IPv4 entry
 		struct sockaddr* addr = p->ifa_addr;
-		if( addr->sa_family != AF_INET ) continue;
+		if( addr->sa_family == AF_INET ) {
+			// get address
+			const struct sockaddr_in& ipv4 = (const struct sockaddr_in&)*addr;
+			boost::asio::ip::address_v4::bytes_type bytes;
+			for( int i=0; i<4; i++ )
+				bytes[i] = (ipv4.sin_addr.s_addr >> (24-i*8)) & 0xff;
 
-		const struct sockaddr_in& ipv4 = (const struct sockaddr_in&)*addr;
-		boost::asio::ip::address_v4::bytes_type bytes;
-		for( int i=0; i<4; i++ )
-			bytes[i] = (ipv4.sin_addr.s_addr >> (24-i*8)) & 0xff;
-
-		boost::asio::ip::address boost_addr = boost::asio::ip::address_v4( bytes );
-		retlist.push_back( IPv4Locator::fromString(boost_addr.to_string()) );
+			// add ipv4 address
+			boost::asio::ip::address boost_addr = boost::asio::ip::address_v4( bytes );
+			retlist.push_back( vcapsule<address_v>( ip_address(boost_addr) ) );
+		}
 	}
 
 	freeifaddrs( ifap );
-
-	//
-	// TODO: gather further addresses like MAC etc.
-	//
 
 	return retlist;
Index: source/ariba/communication/networkinfo/AddressInformation.h
===================================================================
--- source/ariba/communication/networkinfo/AddressInformation.h	(revision 5151)
+++ source/ariba/communication/networkinfo/AddressInformation.h	(revision 5284)
@@ -40,19 +40,17 @@
 #define __ADDRESS_INFORMATION_H
 
-#include <ifaddrs.h>
 #include <vector>
-#include <boost/asio/ip/address.hpp>
-#include <boost/asio/ip/address_v4.hpp>
+
 #include "ariba/communication/networkinfo/NetworkInterface.h"
-#include "ariba/communication/modules/network/ip/IPv4Locator.h"
-
-using std::vector;
-using ariba::communication::NetworkInterface;
-using ariba::communication::IPv4Locator;
+#include "ariba/utility/addressing/addressing.hpp"
 
 namespace ariba {
 namespace communication {
 
-typedef vector<IPv4Locator> AddressList; // TODO: make more general, not only ipv4
+using namespace std;
+using namespace ariba::addressing;
+
+/// a list of addresses
+typedef vector<address_v*> AddressList;
 
 class AddressInformation {
@@ -62,5 +60,4 @@
 
 	AddressList getAddresses(const NetworkInterface& interface);
-
 };
 
