Index: source/ariba/overlay/BaseOverlay.cpp
===================================================================
--- source/ariba/overlay/BaseOverlay.cpp	(revision 2473)
+++ source/ariba/overlay/BaseOverlay.cpp	(revision 2483)
@@ -69,4 +69,8 @@
 // 		ovl.visChangeNodeIcon(ovlId, nodeId, OvlVis::ICON_ID_CHARACTER_W);
 // 	}
+
+	// timer for auto link management
+	Timer::setInterval( 5000 );
+	Timer::start();
 }
 
@@ -75,4 +79,5 @@
 	logging_info("deleting base overlay");
 
+	Timer::stop();
 	bc.unregisterMessageReceiver( this );
 	bc.unregisterEventListener( this );
@@ -147,17 +152,22 @@
 	//
 	// create the overlay
-	// and bootstrap against ourselfs
 	//
 
 	overlayInterface->createOverlay();
+	BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
+		i->onOverlayCreate( spovnetId );
+	}
+
+	//
+	// bootstrap against ourselfs
+	//
+
 	overlayInterface->joinOverlay();
+	BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
+		i->onJoinSuccess( spovnetId );
+	}
 
 	ovl.visChangeNodeIcon ( ovlId, nodeId, OvlVis::ICON_ID_CAMERA );
 	ovl.visChangeNodeColor( ovlId, nodeId, OvlVis::NODE_COLORS_GREEN);
-
-	// inform all registered services of the event
-	BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
-		i->onOverlayCreate( spovnetId );
-	}
 }
 
@@ -245,4 +255,5 @@
 	overmsg.encapsulate( const_cast<Message*>(message) );
 
+	i->second.markused();
 	return bc.sendMessage( link, &overmsg );
 }
@@ -263,9 +274,23 @@
 
 	if( link == LinkID::UNSPECIFIED ){
-		logging_error( "no link could be found to send message to node " <<
-				node.toString() << " for service " << service.toString() );
-		return -1;
-	}
-
+
+		logging_info( "no link could be found to send message to node " <<
+				node.toString() << " for service " << service.toString() <<
+				". creating auto link ...");
+		
+		const LinkID link = establishLink( node, service );
+		LinkMapping::iterator i = linkMapping.find( link );
+
+		if( i == linkMapping.end() ){
+			logging_error( "failed to establish auto link to node " << node.toString() <<
+					" for service " << service.toString() );
+			return -1;
+		}
+
+		i->second.autolink = true;
+
+	} // if( link != LinkID::UNSPECIFIED )
+
+	i->second.markused();
 	return sendMessage( message, link );
 }
@@ -352,6 +377,12 @@
 				" on link " << id.toString() );
 
-		OverlayMsg overMsg( OverlayMsg::OverlayMessageTypeUpdate, i->second.service, nodeId );
+		OverlayMsg overMsg( 
+			OverlayMsg::OverlayMessageTypeUpdate, 
+			i->second.service, 
+			nodeId 
+			);
+
 		bc.sendMessage( id, &overMsg );
+		i->second.markused();
 
 	} // if( i == linkMapping.end() )
@@ -397,4 +428,6 @@
 	if( i->second.interface != NULL )
 		i->second.interface->onLinkChanged( id, nodeId, i->second.node );
+
+	i->second.markused();
 }
 
@@ -412,4 +445,6 @@
 	if( i->second.interface != NULL )
 		i->second.interface->onLinkFail( id, nodeId, i->second.node );
+
+	i->second.markused();
 }
 
@@ -427,4 +462,6 @@
 	if( i->second.interface != NULL )
 		i->second.interface->onLinkQoSChanged( id, nodeId, i->second.node, qos );
+
+	i->second.markused();
 }
 
@@ -434,4 +471,8 @@
 	OverlayMsg* overlayMsg = ((Message*)message)->decapsulate<OverlayMsg>();
 	if( overlayMsg == NULL ) return false;
+
+	// mark the link as in action
+	LinkMapping::iterator item = linkMapping.find( link );
+	if( item != linkMapping.end() ) item->second.markused();
 
 	//
@@ -683,4 +724,5 @@
 		i->second.interface = iface;
 		iface->onLinkUp( link, nodeId, sourcenode );
+		i->second.markused();
 
 		return true ;
@@ -828,3 +870,27 @@
 }
 
+void BaseOverlay::eventFunction(){
+
+	list<LinkID> oldlinks;
+	time_t now = time(NULL);
+
+	// first gather all the links from linkMapping that need droppin
+	// don't directly drop, as the dropLink function affects the
+	// linkMapping structure that we are traversing here.
+	// drop links after a timeout of 30s
+
+	// the macro gets confused if type is passed directly
+	// because of the comma in the pair definition
+	typedef pair<LinkID,LinkItem> pairitem; 
+
+	BOOST_FOREACH( pairitem item, linkMapping ){
+		if( item.second.autolink && difftime(now, item.second.lastuse) > 30)
+			oldlinks.push_back( item.first );
+	}
+
+	BOOST_FOREACH( const LinkID lnk, oldlinks ){
+		dropLink( lnk );
+	}
+}
+
 }} // namespace ariba, overlay
Index: source/ariba/overlay/BaseOverlay.h
===================================================================
--- source/ariba/overlay/BaseOverlay.h	(revision 2473)
+++ source/ariba/overlay/BaseOverlay.h	(revision 2483)
@@ -43,4 +43,5 @@
 #include <iostream>
 #include <algorithm>
+#include <ctime>
 #include <boost/foreach.hpp>
 
@@ -50,4 +51,5 @@
 #include "ariba/utility/misc/Demultiplexer.hpp"
 #include "ariba/utility/logging/Logging.h"
+#include "ariba/utility/system/Timer.h"
 
 #include "ariba/communication/EndpointDescriptor.h"
@@ -67,4 +69,5 @@
 using std::map;
 using std::make_pair;
+using std::pair;
 
 using ariba::communication::EndpointDescriptor;
@@ -92,4 +95,5 @@
 using ariba::utility::MessageSender;
 using ariba::utility::seqnum_t;
+using ariba::utility::Timer;
 
 #define ovl OvlVis::instance()
@@ -109,5 +113,6 @@
 	public MessageReceiver,
 	public CommunicationEvents,
-	public OverlayStructureEvents {
+	public OverlayStructureEvents,
+	protected Timer {
 
 	use_logging_h( BaseOverlay );
@@ -248,4 +253,7 @@
 	virtual void onNodeJoin( const NodeID& node );
 
+	// for timer events
+	virtual void eventFunction();
+
 private:
 
@@ -316,8 +324,11 @@
 		static const LinkItem UNSPECIFIED;
 
-		LinkItem( const LinkID& _link, const NodeID& _node,
+		LinkItem( const LinkID& _link, const NodeID& _node, 
 				const ServiceID& _service, ServiceInterface* _interface )
-			: link( _link ), node( _node ), service( _service ), interface( _interface ){
+			: link( _link ), node( _node ), service( _service ), interface( _interface ), 
+				autolink( false ), lastuse( time(NULL) ) {
 		}
+
+		// general information about the link
 
 		const LinkID link;
@@ -325,4 +336,13 @@
 		ServiceID service;
 		ServiceInterface* interface;
+
+		// information needed for auto links
+
+		void markused(){
+			lastuse = time(NULL);
+		}
+
+		bool autolink;
+		time_t lastuse;
 	};
 
