Index: source/ariba/overlay/modules/OverlayInterface.h
===================================================================
--- source/ariba/overlay/modules/OverlayInterface.h	(revision 4625)
+++ source/ariba/overlay/modules/OverlayInterface.h	(revision 5151)
@@ -128,4 +128,16 @@
 
 	/**
+	 * Routes a message to a given node by using an existing link.
+	 *
+	 * TODO: This is a hack. This method allows the BaseOverlay class to
+	 * use overlay signaling links to transfer data for relaying
+	 *
+	 * @param node The destination node.
+	 * @param link An established link
+	 * @param msg The message to be sent.
+	 */
+	virtual void routeMessage(const NodeID& node, const LinkID& link, Message* msg) = 0;
+
+	/**
 	 * Returns the nodes known to this overlay.
 	 *
@@ -139,19 +151,33 @@
 	virtual NodeList getKnownNodes() const = 0;
 
+	/**
+	 * Returns the link id of the next hop a route message would take.
+	 *
+	 * @param id The destination node id
+	 * @return The link id of the next hop
+	 */
+	virtual const LinkID& getNextLinkId( const NodeID& id ) const = 0;
+
 	//--- functions from CommunicationListener that we _can_ use as overlay ---
 
 	/// @see CommunicationListener
 	virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
+
 	/// @see CommunicationListener
 	virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
+
 	/// @see CommunicationListener
 	virtual void onLinkChanged(const LinkID& lnk, const NodeID& remote);
+
 	/// @see CommunicationListener
 	virtual void onLinkFail(const LinkID& lnk, const NodeID& remote);
+
 	/// @see CommunicationListener
 	virtual void onLinkQoSChanged(const LinkID& lnk, const NodeID& remote,
 			const LinkProperties& prop);
+
 	/// @see CommunicationListener
 	virtual bool onLinkRequest(const NodeID& remote, const DataMessage& msg);
+
 	/// @see CommunicationListener
 	virtual void onMessage(const DataMessage& msg, const NodeID& remote,
@@ -162,5 +188,4 @@
 
 protected:
-
 	/// Reference to an active base overlay
 	BaseOverlay& baseoverlay;
Index: source/ariba/overlay/modules/OverlayStructureEvents.cpp
===================================================================
--- source/ariba/overlay/modules/OverlayStructureEvents.cpp	(revision 4625)
+++ source/ariba/overlay/modules/OverlayStructureEvents.cpp	(revision 5151)
@@ -47,5 +47,5 @@
 }
 
-void OverlayStructureEvents::incomingRouteMessage(Message* msg){
+void OverlayStructureEvents::incomingRouteMessage(Message* msg, const LinkID& link, const NodeID& source ){
 }
 
Index: source/ariba/overlay/modules/OverlayStructureEvents.h
===================================================================
--- source/ariba/overlay/modules/OverlayStructureEvents.h	(revision 4625)
+++ source/ariba/overlay/modules/OverlayStructureEvents.h	(revision 5151)
@@ -61,5 +61,5 @@
 
 protected:
-	virtual void incomingRouteMessage( Message* msg );
+	virtual void incomingRouteMessage( Message* msg, const LinkID& link = LinkID::UNSPECIFIED, const NodeID& source = NodeID::UNSPECIFIED );
 	virtual void onNodeJoin( const NodeID& node );
 };
Index: source/ariba/overlay/modules/chord/Chord.cpp
===================================================================
--- source/ariba/overlay/modules/chord/Chord.cpp	(revision 4625)
+++ source/ariba/overlay/modules/chord/Chord.cpp	(revision 5151)
@@ -71,9 +71,14 @@
 
 /// helper: sets up a link using the base overlay
-LinkID Chord::setup(const EndpointDescriptor& endp) {
+LinkID Chord::setup(const EndpointDescriptor& endp, const NodeID& node) {
 
 	logging_debug("request to setup link to " << endp.toString() );
+
+	for (size_t i=0; i<pending.size(); i++)
+		if (pending[i]==node) return LinkID::UNSPECIFIED;
+	pending.push_back(node);
+
 	// establish link via base overlay
-	return baseoverlay.establishLink(endp, OverlayInterface::OVERLAY_SERVICE_ID);
+	return baseoverlay.establishLink(endp, node, OverlayInterface::OVERLAY_SERVICE_ID);
 }
 
@@ -86,5 +91,5 @@
 /// sends a discovery message
 void Chord::send_discovery_to(const NodeID& destination, int ttl) {
-	logging_debug("Initiating discovery of " << destination.toString() );
+//	logging_debug("Initiating discovery of " << destination.toString() );
 	Message msg;
 	ChordMessage cmsg(ChordMessage::discovery, nodeid, destination);
@@ -111,5 +116,6 @@
 
 	// initiator? no->setup first link
-	if (!(boot == EndpointDescriptor::UNSPECIFIED)) bootstrapLink = setup(boot);
+	if (!(boot == EndpointDescriptor::UNSPECIFIED))
+		bootstrapLink = setup(boot);
 
 	// timer for stabilization management
@@ -138,5 +144,7 @@
 
 	// message for this node? yes-> delegate to base overlay
-	if (item->id == nodeid) baseoverlay.incomingRouteMessage(msg);
+	if (item->id == nodeid || destnode == nodeid)
+		baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid );
+
 	else { // no-> send to next hop
 		ChordMessage cmsg(ChordMessage::route, nodeid, destnode);
@@ -144,4 +152,26 @@
 		send(&cmsg, item->info);
 	}
+}
+
+/// @see OverlayInterface.h
+void Chord::routeMessage(const NodeID& node, const LinkID& link, Message* msg) {
+	logging_debug("Redirect over Chord to node id=" << node.toString()
+			<< " link id=" << link.toString() );
+	ChordMessage cmsg(ChordMessage::route, nodeid, node);
+	cmsg.encapsulate(msg);
+	send(&cmsg, link);
+}
+
+/// @see OverlayInterface.h
+const LinkID& Chord::getNextLinkId( const NodeID& id ) const {
+	// get next hop
+	const route_item* item = table->get_next_hop(id);
+
+	// returns a unspecified id when this is itself
+	if (item == NULL || item->id == nodeid)
+		return LinkID::UNSPECIFIED;
+
+	/// return routing info
+	return item->info;
 }
 
@@ -160,4 +190,9 @@
 	logging_debug("link_up: link=" << lnk.toString() << " remote=" <<
 			remote.toString() );
+	for (vector<NodeID>::iterator i=pending.begin(); i!=pending.end(); i++)
+		if (*i == remote) {
+			pending.erase(i);
+			break;
+		}
 	route_item* item = table->insert(remote);
 
@@ -207,5 +242,5 @@
 		break;
 
-		// route message with payload
+	// route message with payload
 	case M::route: {
 		// find next hop
@@ -214,10 +249,11 @@
 		// next hop == myself?
 		if (m->getDestination() == nodeid) { // yes-> route to base overlay
-			logging_debug("send message to baseoverlay");
-			baseoverlay.incomingRouteMessage(m);
+			logging_debug("Send message to baseoverlay");
+			baseoverlay.incomingRouteMessage( m, item->info, remote );
 		}
 		// no-> route to next hop
 		else {
-			logging_debug("route chord message to " << item->id.toString() );
+			logging_debug("Route chord message to "
+				<< item->id.toString() << " (destination=" << m->getDestination() << ")");
 			send(m, item->info);
 		}
@@ -236,6 +272,6 @@
 
 		// check if source node can be added to routing table and setup link
-		if (m->getSource() != nodeid && table->is_insertable(m->getSource())) setup(
-				*dmsg->getSourceEndpoint());
+		if (m->getSource() != nodeid && table->is_insertable(m->getSource()))
+			setup(*dmsg->getSourceEndpoint(), m->getSource() );
 
 		// delegate discovery message
@@ -302,5 +338,5 @@
 			}
 			if (item == NULL) break;
-			logging_debug("routing discovery message to succ/pred "
+				logging_debug("routing discovery message to succ/pred "
 					<< item->id.toString() );
 			ChordMessage cmsg(*m);
@@ -327,8 +363,7 @@
 
 void Chord::eventFunction() {
-	if (!LinkID::UNSPECIFIED.isUnspecified())
-		logging_error("LinkID::UNSPECIFIED not unspecified!!!!");
 	stabilize_counter++;
 	if (stabilize_counter == 3) {
+		pending.clear();
 		size_t numNeighbors = 0;
 		for (size_t i = 0; i < table->size(); i++) {
@@ -368,4 +403,3 @@
 }
 
-}
-} // namespace ariba, overlay
+}} // namespace ariba, overlay
Index: source/ariba/overlay/modules/chord/Chord.h
===================================================================
--- source/ariba/overlay/modules/chord/Chord.h	(revision 4625)
+++ source/ariba/overlay/modules/chord/Chord.h	(revision 5151)
@@ -77,7 +77,8 @@
 	int stabilize_finger;
 	LinkID bootstrapLink;
+	vector<NodeID> pending;
 
 	// helper: sets up a link using the "base overlay"
-	LinkID setup( const EndpointDescriptor& endp );
+	LinkID setup( const EndpointDescriptor& endp, const NodeID& node = NodeID::UNSPECIFIED );
 
 	// helper: sends a message using the "base overlay"
@@ -91,4 +92,7 @@
 			OverlayStructureEvents* _eventsReceiver, const OverlayParameterSet& param);
 	virtual ~Chord();
+
+	/// @see OverlayInterface.h
+	virtual const LinkID& getNextLinkId( const NodeID& id ) const;
 
 	/// @see OverlayInterface.h
@@ -113,4 +117,7 @@
 
 	/// @see OverlayInterface.h
+	virtual void routeMessage(const NodeID& node, const LinkID& link, Message* msg);
+
+	/// @see OverlayInterface.h
 	virtual NodeList getKnownNodes() const;
 
Index: source/ariba/overlay/modules/onehop/OneHop.cpp
===================================================================
--- source/ariba/overlay/modules/onehop/OneHop.cpp	(revision 4625)
+++ source/ariba/overlay/modules/onehop/OneHop.cpp	(revision 5151)
@@ -99,4 +99,17 @@
 }
 
+void OneHop::routeMessage(const NodeID& node, const LinkID& link, Message* msg) {
+	OneHopMessage onehopRoute( OneHopMessage::OneHopMessageTypeRoute );
+	onehopRoute.encapsulate(msg);
+	baseoverlay.sendMessage( &onehopRoute, link );
+}
+
+/// @see OverlayInterface.h
+const LinkID& OneHop::getNextLinkId( const NodeID& id ) const {
+	OverlayNodeMapping::const_iterator i = overlayNodes.find( id );
+	if (i == overlayNodes.end()) return LinkID::UNSPECIFIED;
+	return i->second;
+}
+
 void OneHop::createOverlay() {
 	// don't need to bootstrap against ourselfs.
Index: source/ariba/overlay/modules/onehop/OneHop.h
===================================================================
--- source/ariba/overlay/modules/onehop/OneHop.h	(revision 4625)
+++ source/ariba/overlay/modules/onehop/OneHop.h	(revision 5151)
@@ -81,5 +81,11 @@
 
 	/// @see OverlayInterface.h
+	virtual const LinkID& getNextLinkId( const NodeID& id ) const;
+
+	/// @see OverlayInterface.h
 	virtual void routeMessage(const NodeID& destnode, Message* msg);
+
+	/// @see OverlayInterface.h
+	virtual void routeMessage(const NodeID& node, const LinkID& link, Message* msg);
 
 	/// @see OverlayInterface.h
