Index: source/ariba/overlay/modules/OverlayFactory.cpp
===================================================================
--- source/ariba/overlay/modules/OverlayFactory.cpp	(revision 3067)
+++ source/ariba/overlay/modules/OverlayFactory.cpp	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,7 +35,11 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #include "OverlayFactory.h"
+
+// structured overlays
+#include "chord/Chord.h"
+#include "onehop/OneHop.h"
 
 namespace ariba {
@@ -53,5 +57,5 @@
 
 		case OverlayParameterSet::OverlayStructureChord:
-			return NULL;
+			return new Chord( baseoverlay, nodeid, routeReceiver );
 
 		case OverlayParameterSet::OverlayStructureKademlia:
Index: source/ariba/overlay/modules/OverlayFactory.h
===================================================================
--- source/ariba/overlay/modules/OverlayFactory.h	(revision 3067)
+++ source/ariba/overlay/modules/OverlayFactory.h	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #ifndef __OVERLAY_FACTORY_H
@@ -41,10 +41,8 @@
 
 #include "ariba/utility/types/OverlayParameterSet.h"
-#include "ariba/overlay/modules/OverlayInterface.h"
-#include "ariba/overlay/modules/onehop/OneHop.h"
+
+#include "OverlayInterface.h"
 
 using ariba::utility::OverlayParameterSet;
-using ariba::overlay::OverlayInterface;
-using ariba::overlay::OneHop;
 
 namespace ariba {
Index: source/ariba/overlay/modules/OverlayInterface.cpp
===================================================================
--- source/ariba/overlay/modules/OverlayInterface.cpp	(revision 3067)
+++ source/ariba/overlay/modules/OverlayInterface.cpp	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,48 +35,48 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #include "OverlayInterface.h"
 #include "ariba/overlay/BaseOverlay.h"
 
+// namespace ariba::overlay
 namespace ariba {
 namespace overlay {
 
-ServiceID OverlayInterface::OVERLAY_SERVICE_ID (0);
+ServiceID OverlayInterface::OVERLAY_SERVICE_ID(0);
 
-OverlayInterface::OverlayInterface(
-	BaseOverlay& _baseoverlay,
-	const NodeID& _nodeid,
-	OverlayStructureEvents* _eventsReceiver )
-	: 	baseoverlay( _baseoverlay ),
-		nodeid( _nodeid ),
-		eventsReceiver( _eventsReceiver ) {
+OverlayInterface::OverlayInterface(BaseOverlay& _baseoverlay,
+		const NodeID& _nodeid, OverlayStructureEvents* _eventsReceiver) :
+	baseoverlay(_baseoverlay), nodeid(_nodeid), eventsReceiver(_eventsReceiver) {
 
-	_baseoverlay.bind( this, OVERLAY_SERVICE_ID );
+	_baseoverlay.bind(this, OVERLAY_SERVICE_ID);
 }
 
-OverlayInterface::~OverlayInterface(){
-	baseoverlay.unbind( this, OVERLAY_SERVICE_ID );
+OverlayInterface::~OverlayInterface() {
+	baseoverlay.unbind(this, OVERLAY_SERVICE_ID);
 }
 
-void OverlayInterface::onLinkUp(const LinkID& lnk, const NodeID& remote){
+void OverlayInterface::onLinkUp(const LinkID& lnk, const NodeID& remote) {
 }
 
-void OverlayInterface::onLinkDown(const LinkID& lnk, const NodeID& remote){
+void OverlayInterface::onLinkDown(const LinkID& lnk, const NodeID& remote) {
 }
 
-void OverlayInterface::onLinkChanged(const LinkID& lnk, const NodeID& remote){
+void OverlayInterface::onLinkChanged(const LinkID& lnk, const NodeID& remote) {
 }
 
-void OverlayInterface::onLinkFail(const LinkID& lnk, const NodeID& remote){
+void OverlayInterface::onLinkFail(const LinkID& lnk, const NodeID& remote) {
 }
 
-void OverlayInterface::onLinkQoSChanged(const LinkID& lnk, const NodeID& remote, const LinkProperties& prop){
+void OverlayInterface::onLinkQoSChanged(const LinkID& lnk,
+		const NodeID& remote, const LinkProperties& prop) {
 }
 
-bool OverlayInterface::onLinkRequest(const NodeID& remote, const DataMessage& msg){
+bool OverlayInterface::onLinkRequest(const NodeID& remote,
+		const DataMessage& msg) {
 }
 
-void OverlayInterface::onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk){
+void OverlayInterface::onMessage(const DataMessage& msg, const NodeID& remote,
+		const LinkID& lnk) {
 }
 
Index: source/ariba/overlay/modules/OverlayInterface.h
===================================================================
--- source/ariba/overlay/modules/OverlayInterface.h	(revision 3067)
+++ source/ariba/overlay/modules/OverlayInterface.h	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #ifndef __OVERLAY_INTERFACE_H
@@ -57,41 +57,113 @@
 class BaseOverlay;
 
-class OverlayInterface : public CommunicationListener {
+/**
+ * This class declares an interface for an structured overlay.
+ */
+class OverlayInterface: public CommunicationListener {
 	friend class BaseOverlay;
+
 public:
+	/**
+	 * A node list
+	 */
+	typedef vector<NodeID> NodeList;
+
+	/**
+	 * Constructs a new overlay.
+	 */
 	OverlayInterface(
-		BaseOverlay& _baseoverlay,
-		const NodeID& _nodeid,
-		OverlayStructureEvents* _eventsReceiver
-	);
+			BaseOverlay& _baseoverlay,
+			const NodeID& _nodeid,
+			OverlayStructureEvents* _eventsReceiver );
 
+	/**
+	 * Destrcuts the overlay.
+	 */
 	virtual ~OverlayInterface();
 
-	typedef vector<NodeID> NodeList;
+	/**
+	 * Creates the overlay.
+	 */
+	virtual void createOverlay() = 0;
 
-	virtual void createOverlay() = 0;
+	/**
+	 * Destroys the overlay.
+	 */
 	virtual void deleteOverlay() = 0;
 
-	virtual void joinOverlay( const EndpointDescriptor& bootstrapEp = EndpointDescriptor::UNSPECIFIED) = 0;
+	/**
+	 * Joins the overlay. Starts integration and stabilization of the overlay
+	 * Node.
+	 *
+	 * @param bootstrap The bootstrap end-point descriptor or the default
+	 *    end-point, if this node is the initiator
+	 */
+	virtual void joinOverlay(const EndpointDescriptor& bootstrap =
+		EndpointDescriptor::UNSPECIFIED ) = 0;
+
+	/**
+	 * Leaves the overlay gracefully.
+	 */
 	virtual void leaveOverlay() = 0;
 
-	virtual const EndpointDescriptor& resolveNode( const NodeID& node ) = 0;
-	virtual void routeMessage( const NodeID& destnode, Message* msg ) = 0;
+	/**
+	 * Resolves a overlay neighbor.
+	 *
+	 * @param node The node to resolve
+	 * @return Endpoint descriptor of local neighbor or UNSPECIFIED
+	 */
+	virtual const EndpointDescriptor& resolveNode(const NodeID& node) = 0;
 
+	/**
+	 * Routes a message to a given node by using overlay routing.
+	 *
+	 * @param destnode The destination node.
+	 * @param msg The message to be routed.
+	 */
+	virtual void routeMessage(const NodeID& destnode, Message* msg) = 0;
+
+	/**
+	 * Returns the nodes known to this overlay.
+	 *
+	 * Usually this are the direct neighbors in the overlay structure.
+	 * For instance, Chord would return his predecessor, successor and finger
+	 * nodes. On the other hand OneHop would likely return all participating
+	 * nodes in the overlay.
+	 *
+	 * @return The list of all known nodes
+	 */
 	virtual NodeList getKnownNodes() const = 0;
 
-	// functions from CommunicationListener that we _can_ use as overlay
+	//--- 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);
-	virtual void onLinkQoSChanged(const LinkID& lnk, const NodeID& remote, const LinkProperties& prop);
+	/// @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);
-	virtual void onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk = LinkID::UNSPECIFIED);
+	/// @see CommunicationListener
+	virtual void onMessage(const DataMessage& msg, const NodeID& remote,
+			const LinkID& lnk = LinkID::UNSPECIFIED);
 
 protected:
+
+	/// Reference to an active base overlay
 	BaseOverlay& baseoverlay;
+
+	/// The node identifier to use with this overlay
 	const NodeID& nodeid;
+
+	/// The listener used to inform about overlay structure changes
 	OverlayStructureEvents* eventsReceiver;
+
+	/// The service identifer of this overlay
 	static ServiceID OVERLAY_SERVICE_ID;
 };
Index: source/ariba/overlay/modules/OverlayStructureEvents.cpp
===================================================================
--- source/ariba/overlay/modules/OverlayStructureEvents.cpp	(revision 3067)
+++ source/ariba/overlay/modules/OverlayStructureEvents.cpp	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 #include "OverlayStructureEvents.h"
 
Index: source/ariba/overlay/modules/OverlayStructureEvents.h
===================================================================
--- source/ariba/overlay/modules/OverlayStructureEvents.h	(revision 3067)
+++ source/ariba/overlay/modules/OverlayStructureEvents.h	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #ifndef __OVERLAY_STRUCTURE_EVENTS_H
@@ -55,4 +55,5 @@
 	friend class ariba::overlay::OverlayInterface;
 	friend class ariba::overlay::OneHop;
+
 public:
 	OverlayStructureEvents();
Index: source/ariba/overlay/modules/chord/Chord.cpp
===================================================================
--- source/ariba/overlay/modules/chord/Chord.cpp	(revision 3067)
+++ source/ariba/overlay/modules/chord/Chord.cpp	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,23 +35,67 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
+
+#include "ariba/overlay/BaseOverlay.h"
 
 #include "Chord.h"
+#include "messages/ChordMessage.h"
+#include "messages/Discovery.h"
+
+#include "detail/chord_routing_table.hpp"
 
 namespace ariba {
 namespace overlay {
 
-use_logging_cpp( OneHop );
+typedef chord_routing_table::item route_item;
+use_logging_cpp( Chord )
+;
 
 Chord::Chord(BaseOverlay& _baseoverlay, const NodeID& _nodeid,
 		OverlayStructureEvents* _eventsReceiver) :
-	OverlayInterface( _baseoverlay, _nodeid, _eventsReceiver ) {
+	OverlayInterface(_baseoverlay, _nodeid, _eventsReceiver) {
+
+	// create routing table
+	this->table = new chord_routing_table(_nodeid, 2);
+	orphan_removal_counter = 0;
+	stabilize_counter = 0;
+	stabilize_finger = 0;
+	bootstrapLink = LinkID::UNSPECIFIED;
 }
 
 Chord::~Chord() {
+
+	// delete routing table
+	delete table;
+}
+
+// helper: sets up a link using the base overlay
+LinkID Chord::setup(const EndpointDescriptor& endp) {
+
+	logging_debug("request to setup link to " << endp.toString() );
+	// establish link via base overlay
+	return baseoverlay.establishLink(endp, OverlayInterface::OVERLAY_SERVICE_ID);
+}
+
+// helper: sends a message using the "base overlay"
+seqnum_t Chord::send(Message* msg, const LinkID& link) {
+	return baseoverlay.sendMessage(msg, link);
+}
+
+void Chord::send_discovery_to(const NodeID& destination, int ttl) {
+	logging_debug("Initiating discovery of " << destination.toString() );
+	Message msg;
+	ChordMessage cmsg(ChordMessage::discovery, nodeid, destination);
+	Discovery dmsg;
+	dmsg.setSourceEndpoint(&baseoverlay.getEndpointDescriptor());
+	dmsg.setFollowType(Discovery::normal);
+	dmsg.setTTL((uint8_t) ttl);
+	cmsg.encapsulate(&dmsg);
+	msg.encapsulate(&cmsg);
+	logging_debug("" << (int)cmsg.getType());
+	this->onMessage(&msg, NodeID::UNSPECIFIED, LinkID::UNSPECIFIED);
 }
 
 void Chord::createOverlay() {
-
 }
 
@@ -60,26 +104,240 @@
 }
 
-void Chord::joinOverlay(
-	const EndpointDescriptor& bootstrapEp = EndpointDescriptor::UNSPECIFIED
-) {
-
+void Chord::joinOverlay(const EndpointDescriptor& boot) {
+	logging_info( "joining Chord overlay structure through end-point " <<
+			(boot == EndpointDescriptor::UNSPECIFIED ?
+					"local" : boot.toString()) );
+
+	// initiator? no->setup first link
+	if (!(boot == EndpointDescriptor::UNSPECIFIED)) bootstrapLink = setup(boot);
+
+	// timer for stabilization management
+	Timer::setInterval(2500);
+	Timer::start();
 }
 
 void Chord::leaveOverlay() {
-
-}
-
-const EndpointDescriptor& Chord::resolveNode( const NodeID& node ) {
-
-}
-
-void Chord::routeMessage( const NodeID& destnode, Message* msg ) {
-
-}
-
-NodeList Chord::getKnownNodes() const {
-
-}
-
-
-}} // namespace ariba, overlay
+	Timer::stop();
+	for (size_t i = 0; i < table->size(); i++) {
+		route_item* it = (*table)[i];
+		ChordMessage msg(ChordMessage::leave, nodeid, it->id);
+		send(&msg,it->info);
+	}
+}
+
+const EndpointDescriptor& Chord::resolveNode(const NodeID& node) {
+	const route_item* item = table->get(node);
+	if (item == NULL || item->info.isUnspecified()) return EndpointDescriptor::UNSPECIFIED;
+	return baseoverlay.getEndpointDescriptor(item->info);
+}
+
+void Chord::routeMessage(const NodeID& destnode, Message* msg) {
+	// get next hop
+	const route_item* item = table->get_next_hop(destnode);
+
+	// message for this node? yes-> delegate to base overlay
+	if (item->id == nodeid) baseoverlay.incomingRouteMessage(msg);
+	else { // no-> send to next hop
+		ChordMessage cmsg(ChordMessage::route, nodeid, destnode);
+		cmsg.encapsulate(msg);
+		send(&cmsg, item->info);
+	}
+}
+
+OverlayInterface::NodeList Chord::getKnownNodes() const {
+	OverlayInterface::NodeList nodelist;
+	for (size_t i = 0; i < table->size(); i++)
+		if ((*table)[i]->ref_count != 0) nodelist.push_back((*table)[i]->id);
+	return nodelist;
+}
+
+/// @see CommunicationListener.h
+/// @see OverlayInterface.h
+void Chord::onLinkUp(const LinkID& lnk, const NodeID& remote) {
+	logging_debug("link_up: link=" << lnk.toString() << " remote=" <<
+			remote.toString() );
+	route_item* item = table->insert(remote);
+
+	if (!bootstrapLink.isUnspecified() && lnk == bootstrapLink) {
+		send_discovery_to(nodeid);
+		bootstrapLink = LinkID::UNSPECIFIED;
+	}
+
+	// item added to routing table?
+	if (item != NULL) { // yes-> add to routing table
+		logging_debug("new routing neighbor: " << remote.toString() );
+		item->info = lnk;
+	} else { // no-> add orphan entry to routing table
+		logging_debug("new orphan: " << remote.toString() );
+		table->insert_orphan(remote)->info = lnk;
+	}
+}
+
+/// @see CommunicationListener.h or @see OverlayInterface.h
+void Chord::onLinkDown(const LinkID& lnk, const NodeID& remote) {
+	logging_debug("link_down: link=" << lnk.toString() << " remote=" <<
+			remote.toString() );
+
+	// remove link from routing table
+	table->remove(remote);
+}
+
+/// @see CommunicationListener.h
+/// @see OverlayInterface.h
+void Chord::onMessage(const DataMessage& msg, const NodeID& remote,
+		const LinkID& link) {
+
+	// decode message
+	typedef ChordMessage M;
+	M* m = msg.getMessage()->convert<ChordMessage> ();
+	if (m == NULL) return;
+
+	logging_debug("onMessage: type=" << (int)m->getType() );
+
+	// handle messages
+	switch (m->getType()) {
+
+	// invalid message
+	case M::invalid:
+		break;
+
+		// route message with payload
+	case M::route: {
+		// find next hop
+		const route_item* item = table->get_next_hop(m->getDestination());
+
+		// next hop == myself?
+		if (m->getDestination() == nodeid) { // yes-> route to base overlay
+			logging_debug("send message to baseoverlay");
+			baseoverlay.incomingRouteMessage(m);
+		}
+		// no-> route to next hop
+		else {
+			logging_debug("route chord message to " << item->id.toString() );
+			send(m, item->info);
+		}
+		break;
+	}
+
+		// discovery request
+	case M::discovery: {
+		// decapsulate message
+		Discovery* dmsg = m->decapsulate<Discovery> ();
+		logging_debug("received discovery message with"
+				<< " dest=" << m->getDestination().toString()
+				<< " ttl=" << (int)dmsg->getTTL()
+				<< " type=" << (int)dmsg->getFollowType()
+		);
+
+		// 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());
+
+		// delegate discovery message
+		switch (dmsg->getFollowType()) {
+
+		// normal: route discovery message like every other message
+		case Discovery::normal:
+			// closest node? yes-> split to follow successor and predecessor
+			if (table->is_closest_to(m->getDestination())) {
+
+				if (table->get_successor() != NULL) {
+					// send successor message
+					ChordMessage cmsg_s(*m);
+					Discovery dmsg_s(*dmsg);
+					dmsg_s.setFollowType(Discovery::successor);
+					cmsg_s.encapsulate(&dmsg_s);
+					route_item* succ_item = table->get(*table->get_successor());
+					logging_debug("split: routing discovery message to successor "
+							<< succ_item->id.toString() );
+					send(&cmsg_s, succ_item->info);
+				}
+
+				// send predecessor message
+				if (table->get_predesessor() != NULL) {
+					ChordMessage cmsg_p(*m);
+					Discovery dmsg_p(*dmsg);
+					dmsg_p.setFollowType(Discovery::predecessor);
+					cmsg_p.encapsulate(&dmsg_p);
+					route_item* pred_item = table->get(
+							*table->get_predesessor());
+					logging_debug("split: routing discovery message to predecessor "
+							<< pred_item->id.toString() );
+					send(&cmsg_p, pred_item->info);
+				}
+			}
+			// no-> route message
+			else {
+				// find next hop
+				const route_item* item = table->get_next_hop(
+						m->getDestination());
+				if (item->id == nodeid) break;
+				logging_debug("routing discovery message to " <<
+						item->id.toString() );
+				send(m, item->info);
+			}
+			break;
+
+			// successor mode: follow the successor until TTL is zero
+		case Discovery::successor:
+		case Discovery::predecessor: {
+			// time to live ended? yes-> stop routing
+			if (dmsg->getTTL() == 0) break;
+
+			// decrease time-to-live
+			dmsg->setTTL(dmsg->getTTL() - 1);
+
+			const route_item* item;
+			if (dmsg->getFollowType() == Discovery::successor) item
+					= table->get(*table->get_successor());
+			else item = table->get(*table->get_predesessor());
+			logging_debug("routing discovery message to succ/pred "
+					<< item->id.toString() );
+			ChordMessage cmsg(*m);
+			cmsg.encapsulate(dmsg);
+			send(&cmsg, item->info);
+			break;
+		}
+		}
+		break;
+	}
+
+		// leave
+	case M::leave: {
+		baseoverlay.dropLink(link);
+		break;
+	}
+	}
+}
+
+void Chord::eventFunction() {
+	stabilize_counter++;
+	if (stabilize_counter == 3) {
+		stabilize_counter = 0;
+		stabilize_finger = ((stabilize_finger+1) % table->get_finger_table_size() );
+		logging_debug("sending discovery message to my neighbors");
+		send_discovery_to(nodeid);
+		send_discovery_to(
+			table->get_finger_table(stabilize_finger).get_compare().get_center()
+		);
+		orphan_removal_counter++;
+		if (orphan_removal_counter == 2) {
+			orphan_removal_counter = 0;
+			for (size_t i = 0; i < table->size(); i++) {
+				route_item* it = (*table)[i];
+				if (it->ref_count == 0) {
+					baseoverlay.dropLink(it->info);
+					logging_debug("dropping orphaned link " << it->info.toString() << " to " << it->id.toString());
+				}
+			}
+		}
+	}
+	logging_debug("--- chord routing information ----------------------------------");
+	logging_debug("predecessor: " << (table->get_predesessor()==NULL? "<none>" : table->get_predesessor()->toString()) );
+	logging_debug("node_id    : " << nodeid.toString() );
+	logging_debug("successor  : " << (table->get_successor()==NULL? "<none>" : table->get_successor()->toString()));
+	logging_debug("----------------------------------------------------------------");
+}
+
+}
+} // namespace ariba, overlay
Index: source/ariba/overlay/modules/chord/Chord.h
===================================================================
--- source/ariba/overlay/modules/chord/Chord.h	(revision 3067)
+++ source/ariba/overlay/modules/chord/Chord.h	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,42 +35,96 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #ifndef CHORD_H_
 #define CHORD_H_
 
+#include "ariba/utility/system/Timer.h"
 #include "ariba/utility/logging/Logging.h"
 #include "ariba/communication/EndpointDescriptor.h"
+#include "../OverlayInterface.h"
+#include <vector>
+
+class chord_routing_table;
 
 namespace ariba {
 namespace overlay {
 
-using ariba::overlay::OverlayInterface;
 using ariba::communication::EndpointDescriptor;
+using ariba::utility::Timer;
 
-class Chord : public OverlayInterface {
+using namespace std;
+
+/**
+ * This class implements a structured overlay inspired by chord.
+ * It differs to the original form of chord in the following manner:
+ *
+ * (1) The graph is bidirectional
+ * (2) Stabilization is done in a reactive manner
+ *
+ * It therefore can be considered as a kind of Chorded-Kademlia :)
+ *
+ * The resulting overlay graph has a diameter of O(log N).
+ *
+ * @author Sebastian Mies <mies@tm.uka.de>
+ */
+class Chord : public OverlayInterface, protected Timer {
 	use_logging_h( Chord );
 private:
+	chord_routing_table* table;
+	int orphan_removal_counter;
+	int stabilize_counter;
+	int stabilize_finger;
+	LinkID bootstrapLink;
+
+	// helper: sets up a link using the "base overlay"
+	LinkID setup( const EndpointDescriptor& endp );
+
+	// helper: sends a message using the "base overlay"
+	seqnum_t send( Message* msg, const LinkID& link );
+
+	// stabilization: sends a discovery message to the specified neighborhood
+	void send_discovery_to( const NodeID& destination, int ttl = 4 );
 
 public:
 	Chord(BaseOverlay& _baseoverlay, const NodeID& _nodeid,
 			OverlayStructureEvents* _eventsReceiver);
-	~Chord();
+	virtual ~Chord();
 
-	void createOverlay();
+	/// @see OverlayInterface.h
+	virtual void createOverlay();
 
-	void deleteOverlay();
+	/// @see OverlayInterface.h
+	virtual void deleteOverlay();
 
-	void joinOverlay(
-		const EndpointDescriptor& bootstrapEp = EndpointDescriptor::UNSPECIFIED
+	/// @see OverlayInterface.h
+	virtual void joinOverlay(
+		const EndpointDescriptor& boot = EndpointDescriptor::UNSPECIFIED
 	);
 
-	void leaveOverlay();
+	/// @see OverlayInterface.h
+	virtual void leaveOverlay();
 
-	const EndpointDescriptor& resolveNode( const NodeID& node );
+	/// @see OverlayInterface.h
+	virtual const EndpointDescriptor& resolveNode( const NodeID& node );
 
-	void routeMessage( const NodeID& destnode, Message* msg );
+	/// @see OverlayInterface.h
+	virtual void routeMessage( const NodeID& destnode, Message* msg );
 
-	NodeList getKnownNodes() const;
+	/// @see OverlayInterface.h
+	virtual NodeList getKnownNodes() const;
+
+	/// @see CommunicationListener.h or @see OverlayInterface.h
+	virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
+
+	/// @see CommunicationListener.h or @see OverlayInterface.h
+	virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
+
+	/// @see CommunicationListener.h or @see OverlayInterface.h
+	virtual void onMessage(const DataMessage& msg, const NodeID& remote,
+			const LinkID& lnk = LinkID::UNSPECIFIED);
+
+	/// @see Timer.h
+	virtual void eventFunction();
 };
 
Index: source/ariba/overlay/modules/chord/detail/chord_routing_table.hpp
===================================================================
--- source/ariba/overlay/modules/chord/detail/chord_routing_table.hpp	(revision 3690)
+++ source/ariba/overlay/modules/chord/detail/chord_routing_table.hpp	(revision 3690)
@@ -0,0 +1,329 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+#ifndef CHORD_ROUTING_TABLE_HPP_
+#define CHORD_ROUTING_TABLE_HPP_
+
+#include <vector>
+#include <iostream>
+
+#include <boost/foreach.hpp>
+
+#include "distances.hpp"
+#include "comparators.hpp"
+#include "minimizer_table.hpp"
+
+#include "ariba/Identifiers.h"
+
+using namespace ariba;
+
+using namespace distances;
+using namespace comparators;
+using namespace std;
+
+// placeholders for route info and nodeid type
+typedef ariba::NodeID nodeid_t;
+typedef ariba::LinkID routeinfo_t;
+
+/**
+ * Implementation of a chord routing table.
+*
+ * @author Sebastian Mies <mies@tm.uka.de>
+ */
+class chord_routing_table {
+private:
+	typedef chord_routing_table self;
+	typedef distance_compare<nodeid_t&, nodeid_t, ring_succ_distance>
+			succ_compare_type;
+	typedef distance_compare<nodeid_t&, nodeid_t, ring_pred_distance>
+			pred_compare_type;
+	typedef distance_compare<nodeid_t, nodeid_t, ring_distance>
+			finger_compare_type;
+
+public:
+	typedef minimizer_table<nodeid_t, succ_compare_type, self> succ_table;
+	typedef minimizer_table<nodeid_t, pred_compare_type, self> pred_table;
+	typedef minimizer_table<nodeid_t, finger_compare_type, self> finger_table;
+
+	// a routing table entry
+	class item {
+	public:
+		uint8_t ref_count;
+		nodeid_t id;
+		routeinfo_t info;
+	};
+	typedef vector<item> route_table;
+
+
+private:
+	// maximum number of fingers
+	static const int max_fingers = 32;
+
+	// the own node id
+	nodeid_t id;
+
+	// successor and predecessor tables
+	succ_table succ;
+	pred_table pred;
+	finger_table* finger[max_fingers*2];
+
+	// main routing table
+	route_table table;
+
+	// some internal flags
+	item* item_added;
+	item item_removed;
+	bool item_removed_flag;
+	bool simulate;
+
+	// finds an item inside the routing table
+	item* find_item(const nodeid_t& id) {
+		BOOST_FOREACH( item& i, table )
+			if ( i.id == id ) return &i;
+		return NULL;
+	}
+
+	/// Adds a item to the routing table
+	item* add_item( const nodeid_t& id ) {
+		item i;
+		i.id = id;
+		i.ref_count = 1;
+		table.push_back(i);
+		item_added = &table.back();
+		return item_added;
+	}
+
+	/// Removes an item from the routing table
+	bool remove_item( const nodeid_t& id ) {
+		for (route_table::iterator i = table.begin(); i!=table.end(); i++) {
+			if ( (*i).id == id ) {
+				(*i).ref_count--;
+				if ((*i).ref_count == 0) {
+					item_removed = *i;
+					item_removed_flag = true;
+					return true;
+				}
+				break;
+			}
+		}
+		return false;
+	}
+
+public:
+
+	// handles events from minimizers
+	template<class Table>
+	void on_table( table_listener::type_ type, const Table& tab, typename Table::iterator pos ) {
+		switch (type) {
+		case table_listener::insert: {
+			item* i = find_item( *pos );
+			if (i == NULL) i = add_item( *pos ); else i->ref_count++;
+			break;
+		}
+		case table_listener::remove: {
+			remove_item(*pos);
+			break;
+		}
+		case table_listener::update:
+			break;
+		}
+	}
+
+
+public:
+	/// constructs the reactive chord routing table
+	explicit chord_routing_table( const nodeid_t& id, int redundancy = 2 ) :
+		id(id),	succ( redundancy, succ_compare_type(this->id), *this ),
+		pred( redundancy, pred_compare_type(this->id), *this ) {
+
+		// create finger tables
+		nodeid_t nid = Identifier(2);
+		for (size_t i=0; i<max_fingers; i++) {
+			finger[i*2+0] =
+				new finger_table( redundancy,
+						finger_compare_type(this->id - nid), *this);
+			finger[i*2+1] =
+				new finger_table( redundancy,
+						finger_compare_type(this->id + nid), *this);
+			nid = nid << 1;
+		}
+	}
+
+	/// check whether a node could fit the routing table
+	bool is_insertable( const nodeid_t& value ) {
+		if (find_item(value)!=NULL) return false;
+		bool is_insertable_ = false;
+		is_insertable_ |= succ.insertable(value);
+		is_insertable_ |= pred.insertable(value);
+		for (size_t i=0; i<max_fingers*2; i++)
+			is_insertable_ |= finger[i]->insertable(value);
+		return is_insertable_;
+	}
+
+	/// searches an item
+	item* get( const nodeid_t& value ) {
+		return find_item(value);
+	}
+
+	inline item* operator[] ( size_t index ) {
+		return &table[index];
+	}
+
+	inline size_t size() const {
+		return table.size();
+	}
+
+	/// adds a node
+	item* insert( const nodeid_t& value ) {
+		if (value==id) return NULL;
+		item_added = NULL;
+		item_removed_flag = false;
+		succ.insert(value);
+		pred.insert(value);
+		for (size_t i=0; i<max_fingers*2; i++) finger[i]->insert(value);
+		return item_added;
+	}
+
+	/// adds an orphan
+	item* insert_orphan( const nodeid_t& value ) {
+		item* it = find_item(value);
+		if (it!=NULL) return it;
+		item i;
+		i.id = id;
+		i.ref_count = 0;
+		table.push_back(i);
+		return &table.back();
+	}
+
+	/// removes an node
+	const item* remove( const nodeid_t& value ) {
+		item_removed_flag = false;
+		succ.remove(value);
+		pred.remove(value);
+		for (size_t i=0; i<max_fingers*2; i++) finger[i]->remove(value);
+		if (!item_removed_flag) remove_orphan(value);
+		return item_removed_flag ? &item_removed : NULL;
+	}
+
+	/// removes an orphan
+	item* remove_orphan( const nodeid_t& value ) {
+		item_removed_flag = false;
+		remove_item(value);
+		return item_removed_flag ? &item_removed : NULL;
+	}
+
+	/// returns the next hop
+	const item* get_next_hop( const nodeid_t& value ) {
+		ring_distance distance;
+		item* best_item = NULL;
+		for (size_t i=0; i<table.size(); i++) {
+			item* curr = &table[i];
+			// not not include orphans into routing!
+			if (curr->ref_count==0) continue;
+
+			// check if we found a better item
+			if (best_item==NULL) {
+				best_item = curr;
+				continue;
+			} else {
+				if (distance(value, curr->id)<distance(value, best_item->id))
+					best_item = curr;
+			}
+		}
+		return best_item;
+	}
+
+	const nodeid_t* get_successor() {
+		if (succ.size()==NULL) return NULL;
+		return &succ.front();
+	}
+
+	const nodeid_t* get_predesessor() {
+		if (pred.size()==NULL) return NULL;
+		return &pred.front();
+	}
+
+
+	bool is_closest_to( const nodeid_t& value ) {
+		ring_distance distance;
+		nodeid_t delta = distance(value, id);
+		if (get_successor() != NULL &&
+				delta > distance(value, *get_successor() ) ) return false;
+		if (get_predesessor() != NULL &&
+				delta > distance(value, *get_predesessor() ) ) return false;
+		return true;
+	}
+
+	/// returns the whole routing table
+	vector<item>& get_table() {
+		return table;
+	}
+
+	/// returns the last removed item
+	const item* get_removed_item() const {
+		return item_removed_flag ? &item_removed : NULL;
+	}
+
+	/// return successor table
+	const succ_table& get_succ_table() const {
+		return succ;
+	}
+
+	/// return predecessor table
+	const pred_table& get_pred_table() const {
+		return pred;
+	}
+
+	/// return finger table
+	finger_table& get_finger_table( size_t index ) {
+		return *finger[index];
+	}
+
+	/// return number of finger tables
+	size_t get_finger_table_size() const {
+		return max_fingers*2;
+	}
+};
+
+/// output routing table
+std::ostream& operator<<(std::ostream& s, const chord_routing_table& t) {
+	s << "[pred=" << t.get_pred_table() << " succ=" << t.get_succ_table()
+			<< "]";
+	return s;
+}
+
+#endif /* CHORD_ROUTING_TABLE_HPP_ */
Index: source/ariba/overlay/modules/chord/detail/comparators.hpp
===================================================================
--- source/ariba/overlay/modules/chord/detail/comparators.hpp	(revision 3690)
+++ source/ariba/overlay/modules/chord/detail/comparators.hpp	(revision 3690)
@@ -0,0 +1,86 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+#ifndef COMPARATORS_HPP_
+#define COMPARATORS_HPP_
+
+/**
+ * TODO: Doc
+ *
+ * @author Sebastian Mies <mies@tm.uka.de>
+ */
+#include "distances.hpp"
+
+namespace comparators {
+
+using namespace distances;
+
+/// default compare operation
+struct default_compare {
+	template<typename T>
+	int operator ()(const T& x, const T& y) {
+		return x == y ? 0 : (x < y ? -1 : 1);
+	}
+};
+
+/// compares distances to a given center point
+template<class CenterType, class T, class Distance = default_distance,
+		class Compare = default_compare>
+class distance_compare {
+private:
+	CenterType center;
+	Distance distance;
+	Compare compare;
+
+public:
+	explicit distance_compare(CenterType center,
+			Distance distance = Distance(), Compare compare = Compare()) :
+		center(center), distance(distance), compare(compare) {
+	}
+
+	const CenterType get_center() const {
+		return center;
+	}
+
+	int operator ()(const T& x, const T& y) {
+		return compare(distance(center, x), distance(center, y));
+	}
+};
+
+}
+
+#endif /* COMPARATORS_HPP_ */
Index: source/ariba/overlay/modules/chord/detail/distances.hpp
===================================================================
--- source/ariba/overlay/modules/chord/detail/distances.hpp	(revision 3690)
+++ source/ariba/overlay/modules/chord/detail/distances.hpp	(revision 3690)
@@ -0,0 +1,109 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+#ifndef DISTANCES_HPP_
+#define DISTANCES_HPP_
+
+/**
+ * TODO: Doc
+ *
+ * @author Sebastian Mies <mies@tm.uka.de>
+ */
+namespace distances {
+
+/// returns the maximum value of a type
+template<class T>
+T max_value() {
+	return ~(T)0;
+}
+
+/// returns the maximum value of a type
+template<class T>
+T min_value() {
+	return 0;
+}
+
+/// euclidean distance between two points (metric)
+struct default_distance {
+	template<typename T>
+	T operator ()(const T& x, const T& y) {
+		return abs(x - y);
+	}
+};
+
+/// xor distance (metric)
+struct xor_distance {
+	template<typename T>
+	T operator()(const T& x, const T& y) {
+		return x ^ y;
+	}
+};
+
+/// distance between two points on a ring (metric)
+struct ring_distance {
+	template<typename T>
+	T operator()(const T& x, const T& y) {
+		const T m = max_value<T>();
+		T d_nor = (x >= y) ? (x-y) : (y-x);
+		T d_inv = m - d_nor;
+		return d_nor < d_inv ? d_nor : d_inv;
+	}
+};
+
+/// distance from x to a predecessor y on a ring (not a metric!)
+struct ring_pred_distance {
+	template<typename T>
+	T operator ()(const T& x, const T& y) {
+		const T m = max_value<T>();
+		if (x >= y) return x - y;
+		else return m - y + x;
+	}
+};
+
+/// distance from x to a successor y on a ring (not a metric!)
+struct ring_succ_distance {
+	template<typename T>
+	T operator ()(const T& y, const T& x) {
+		const T m = max_value<T>();
+		if (x >= y) return x - y;
+		else return m - y + x;
+	}
+};
+
+}
+
+#endif /* DISTANCES_HPP_ */
Index: source/ariba/overlay/modules/chord/detail/minimizer_table.hpp
===================================================================
--- source/ariba/overlay/modules/chord/detail/minimizer_table.hpp	(revision 3690)
+++ source/ariba/overlay/modules/chord/detail/minimizer_table.hpp	(revision 3690)
@@ -0,0 +1,163 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+#ifndef MINIMIZER_TABLE_HPP_
+#define MINIMIZER_TABLE_HPP_
+
+#include <vector>
+#include <iostream>
+#include "table_listener.hpp"
+
+using std::vector;
+using std::ostream;
+
+/**
+ * TODO: Doc
+ *
+ * @author Sebastian Mies <mies@tm.uka.de>
+ */
+template<class Value, class Comparator, typename Listener = table_listener>
+class minimizer_table: public vector<Value> {
+private:
+	// define table type
+	typedef vector<Value> super;
+
+	// members
+	size_t max_size;
+	Comparator compare;
+
+	// listener
+	Listener& listener;
+
+public:
+
+	/// delegates from vector<Value>
+	typedef	typename super::iterator iterator;
+
+	/// delegates from vector<Value>
+	typedef typename super::const_iterator const_iterator;
+
+	/// explicitly construct a minimizer table
+	explicit minimizer_table(size_t max_size, Comparator compare = Comparator(),
+			Listener& listener = Listener::DEFAULT) :
+			super(), max_size(max_size), compare(compare), listener(listener) {
+	}
+
+	/// returns true, if the value would fit into the table
+	bool insertable( const Value& value ) {
+		return insert(value,true) != super::end();
+	}
+
+	/// inserts a value into an ordered list
+	iterator insert(const Value& value, bool simulate = false ) {
+		iterator iter = super::end();
+
+		// table empty? -> just add entry
+		if (super::size() == 0) {
+			if (!simulate) super::push_back(value);
+			iter = super::end()-1;
+			if (!simulate) listener.on_table( table_listener::insert, *this, iter );
+		} else
+
+		// add at correct position
+		for (iterator i = super::begin(); i != super::end(); i++) {
+			int cmp = compare(value, *i);
+			if (cmp < 0) {
+				if (!simulate) {
+					iter = super::insert(i, value);
+				} else
+					iter = i;
+				if (!simulate)
+					listener.on_table( table_listener::insert, *this, iter );
+				break;
+			} else
+			if (cmp == 0) return iter;
+		}
+
+		// no item smaller than item and table not full? -> append
+		if (iter == super::end() && super::size() != max_size) {
+			if (!simulate)
+			super::push_back(value);
+			iter = super::end()-1;
+			if (!simulate) listener.on_table( table_listener::insert, *this, iter );
+
+		} else
+
+		// drop entries
+		if (super::size() > max_size) {
+			if (!simulate) {
+				listener.on_table( table_listener::remove, *this, super::end()-1 );
+				super::pop_back();
+			}
+		}
+		return iter;
+	}
+
+	/// remove value from ordered list
+	bool remove(const Value& value) {
+		for (iterator i = super::begin(); i != super::end(); i++)
+		if (*i == value) {
+			super::erase(i);
+			return true;
+		}
+		return false;
+	}
+
+	/// check whether this list contains a specific value
+	bool contains(const Value& value) const {
+		for (const_iterator i = super::begin(); i != super::end(); i++)
+		if (*i == value) return true;
+		return false;
+	}
+
+	Comparator& get_compare() {
+		return compare;
+	}
+};
+
+/// prints a list of items
+template<class V, class C, class L>
+std::ostream& operator<<(std::ostream& s, const minimizer_table<V, C, L>& v) {
+	typedef minimizer_table<V, C, L> t;
+	for (typename t::const_iterator i = v.begin(); i != v.end(); i++) {
+		if (i != v.begin()) s << ",";
+		s << *i;
+	}
+	return s;
+}
+
+#endif /* MINIMIZER_TABLE_HPP_ */
Index: source/ariba/overlay/modules/chord/detail/table_listener.hpp
===================================================================
--- source/ariba/overlay/modules/chord/detail/table_listener.hpp	(revision 3690)
+++ source/ariba/overlay/modules/chord/detail/table_listener.hpp	(revision 3690)
@@ -0,0 +1,75 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OF TELEMATICS OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+
+#ifndef TABLE_LISTENER_HPP_
+#define TABLE_LISTENER_HPP_
+
+#include<iostream>
+
+using namespace std;
+
+/// a table listener prototype
+/**
+ * TODO: Doc
+ *
+ * @author Sebastian Mies <mies@tm.uka.de>
+ */
+class table_listener {
+public:
+	/// default listener
+	static table_listener DEFAULT;
+
+	/// event types
+	enum type_ { insert, remove, update };
+
+	/// event function
+	template<class Table>
+	void on_table(type_ type, const Table& tab, typename Table::iterator pos ) {
+		cout << "on_table: ";
+		switch (type) {
+		case insert: cout << "insert"; break;
+		case remove: cout << "remove"; break;
+		case update: cout << "update"; break;
+		}
+		cout << "= " << *pos << endl;
+	}
+};
+
+table_listener table_listener::DEFAULT;
+
+#endif /* TABLE_LISTENER_HPP_ */
Index: source/ariba/overlay/modules/chord/messages/ChordMessage.cpp
===================================================================
--- source/ariba/overlay/modules/chord/messages/ChordMessage.cpp	(revision 3690)
+++ source/ariba/overlay/modules/chord/messages/ChordMessage.cpp	(revision 3690)
@@ -0,0 +1,49 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+
+#include "ChordMessage.h"
+
+namespace ariba {
+namespace overlay {
+
+vsznDefault( ChordMessage );
+
+ChordMessage::~ChordMessage(){
+}
+
+}} // ariba::overlay
Index: source/ariba/overlay/modules/chord/messages/ChordMessage.h
===================================================================
--- source/ariba/overlay/modules/chord/messages/ChordMessage.h	(revision 3690)
+++ source/ariba/overlay/modules/chord/messages/ChordMessage.h	(revision 3690)
@@ -0,0 +1,110 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+
+#ifndef __CHORD_MESSAGE_H
+#define __CHORD_MESSAGE_H
+
+#include "ariba/utility/messages.h"
+#include "ariba/utility/serialization.h"
+#include "ariba/Identifiers.h"
+
+using ariba::utility::Message;
+
+namespace ariba {
+namespace overlay {
+
+using_serialization
+;
+
+class ChordMessage: public Message { VSERIALIZEABLE
+public:
+	enum type_ {
+		invalid = 0, ///< invalid message
+		route = 1, ///< route message with payload
+		discovery = 2, ///< discover neighbors of a destination node
+		leave = 3, ///< leave message
+	};
+
+	inline ChordMessage( const ChordMessage& msg ) {
+		this->type = msg.type;
+		this->hop_count = msg.hop_count;
+		this->source = msg.source;
+		this->destination = msg.destination;
+	}
+
+	inline explicit ChordMessage(type_ type = invalid,
+			const NodeID& source = NodeID::UNSPECIFIED,
+			const NodeID& destination = NodeID::UNSPECIFIED) :
+		type((uint8_t) type), source(source), destination(destination) {
+	}
+
+	virtual ~ChordMessage();
+
+	inline uint8_t getHopCount() const {
+		return hop_count;
+	}
+
+	inline void setHopCount( uint8_t hop_count ) {
+		this->hop_count = hop_count;
+	}
+
+	inline type_ getType() const {
+		return (type_) this->type;
+	}
+
+	const NodeID& getSource() const {
+		return source;
+	}
+
+	inline const NodeID& getDestination() const {
+		return destination;
+	}
+
+private:
+	uint8_t type;
+	uint8_t hop_count;
+	NodeID source, destination;
+};
+
+}} // ariba::overlay
+
+sznBeginDefault( ariba::overlay::ChordMessage, X ){
+	X && type && hop_count && &source && &destination && Payload();
+}sznEnd();
+
+#endif // __CHORD_MESSAGE_H
Index: source/ariba/overlay/modules/chord/messages/Discovery.cpp
===================================================================
--- source/ariba/overlay/modules/chord/messages/Discovery.cpp	(revision 3690)
+++ source/ariba/overlay/modules/chord/messages/Discovery.cpp	(revision 3690)
@@ -0,0 +1,52 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+
+#include "Discovery.h"
+
+namespace ariba {
+namespace overlay {
+
+vsznDefault(Discovery);
+
+Discovery::Discovery(){
+}
+
+Discovery::~Discovery(){
+}
+
+}} // ariba::overlay
Index: source/ariba/overlay/modules/chord/messages/Discovery.h
===================================================================
--- source/ariba/overlay/modules/chord/messages/Discovery.h	(revision 3690)
+++ source/ariba/overlay/modules/chord/messages/Discovery.h	(revision 3690)
@@ -0,0 +1,140 @@
+// [License]
+// The Ariba-Underlay Copyright
+//
+// Copyright (c) 2008-2009, Institute of Telematics, UniversitÃ€t Karlsruhe (TH)
+//
+// Institute of Telematics
+// UniversitÃ€t Karlsruhe (TH)
+// Zirkel 2, 76128 Karlsruhe
+// Germany
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// The views and conclusions contained in the software and documentation
+// are those of the authors and should not be interpreted as representing
+// official policies, either expressed or implied, of the Institute of
+// Telematics.
+// [License]
+
+#ifndef DISCOVERY_H__
+#define DISCOVERY_H__
+
+#include <vector>
+#include "ariba/utility/messages.h"
+#include "ariba/utility/serialization.h"
+#include "ariba/utility/types/NodeID.h"
+#include "ariba/communication/EndpointDescriptor.h"
+
+using std::pair;
+using std::make_pair;
+using std::vector;
+using ariba::utility::Message;
+using ariba::utility::NodeID;
+using ariba::communication::EndpointDescriptor;
+
+namespace ariba {
+namespace overlay {
+
+using_serialization;
+
+class Discovery : public Message {
+	VSERIALIZEABLE;
+public:
+	enum follow_type_ {
+		normal = 0,
+		successor = 1,
+		predecessor = 2
+	};
+
+	Discovery( const Discovery& msg ) {
+		this->follow_type = msg.follow_type;
+		this->ttl = msg.ttl;
+		this->source_endpoint = new EndpointDescriptor( *msg.source_endpoint );
+	}
+	explicit Discovery();
+	virtual ~Discovery();
+/*
+	typedef pair<NodeID,EndpointDescriptor*> NodeEndpoint;
+	typedef vector<NodeEndpoint> NodeEndpointList;
+
+	void add(const NodeID& node, EndpointDescriptor* endp);
+
+	const NodeEndpointList& getList();
+*/
+
+	EndpointDescriptor* getSourceEndpoint() const {
+		return source_endpoint;
+	}
+
+	void setSourceEndpoint( const EndpointDescriptor* endpoint ) {
+		source_endpoint = const_cast<EndpointDescriptor*>(endpoint);
+	}
+
+	inline uint8_t getTTL() const {
+		return ttl;
+	}
+
+	inline void setTTL( uint8_t ttl ) {
+		this->ttl = ttl;
+	}
+
+	inline follow_type_ getFollowType() const {
+		return (follow_type_)follow_type;
+	}
+
+	inline void setFollowType( follow_type_ type ) {
+		follow_type = (uint8_t)type;
+	}
+
+private:
+	uint8_t follow_type;
+	uint8_t ttl;
+	EndpointDescriptor* source_endpoint;
+//	NodeEndpointList descriptors;
+};
+
+}} // ariba::overlay
+
+sznBeginDefault( ariba::overlay::Discovery, X ) {
+
+	/// serialize follow-type and time-to-live
+	X && follow_type && ttl;
+
+	// serialize end-point
+	X && VO(source_endpoint);
+/*
+	// serialize length of descriptor list
+	uint16_t len = descriptors.size();
+	X && len;
+	if (X.isDeserializer()) descriptors.resize(len);
+
+	// serialize descriptors
+	for (int i=0; i<len; i++)
+		X && &descriptors[i].first && VO(descriptors[i].second);
+
+	// serialize payload
+	X && Payload();
+*/
+} sznEnd();
+
+#endif // DISCOVERY_H__
Index: source/ariba/overlay/modules/onehop/OneHop.cpp
===================================================================
--- source/ariba/overlay/modules/onehop/OneHop.cpp	(revision 3067)
+++ source/ariba/overlay/modules/onehop/OneHop.cpp	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,8 +35,12 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #include "OneHop.h"
 #include "ariba/overlay/BaseOverlay.h"
+
+#include "ariba/overlay/modules/onehop/messages/OneHopMessage.h"
+#include "ariba/overlay/modules/onehop/messages/NodeListingRequest.h"
+#include "ariba/overlay/modules/onehop/messages/NodeListingReply.h"
 
 namespace ariba {
@@ -84,13 +88,13 @@
 		return;
 	}
-
-	baseoverlay.sendMessage( msg, i->second );
-}
-
-void OneHop::createOverlay(){
-
+	OneHopMessage onehopRoute( OneHopMessage::OneHopMessageTypeRoute );
+	onehopRoute.encapsulate(msg);
+
+	baseoverlay.sendMessage( &onehopRoute, i->second );
+}
+
+void OneHop::createOverlay() {
 	// don't need to bootstrap against ourselfs.
 	// the create and join process is completed now.
-
 	logging_info( "creating onehop overlay structure" );
 	state = OneHopStateCompleted;
@@ -119,5 +123,5 @@
 void OneHop::joinOverlay(const EndpointDescriptor& bootstrapEp){
 
-	logging_info( "joining onehop overlay structure through endpoint " <<
+	logging_info( "joining onehop overlay structure through end-point " <<
 			(bootstrapEp == EndpointDescriptor::UNSPECIFIED ?
 					"local" : bootstrapEp.toString()) );
@@ -133,8 +137,5 @@
 
 		state = OneHopStateCompleted;
-
-
 	} else {
-
 		bootstrapLink = baseoverlay.establishLink( bootstrapEp,
 					OverlayInterface::OVERLAY_SERVICE_ID );
@@ -175,8 +176,5 @@
 	if( state == OneHopStateInvalid ) return;
 
-	//
 	// node went down, remove from overlay mapping
-	//
-
 	logging_debug( "node " << remote.toString() << " left overlay structure" );
 
@@ -223,5 +221,5 @@
 	//
 
-	if( onemsg->isType( OneHopMessage::OneHopMessageTypeListingRequest) ){
+	if( onemsg->isType( OneHopMessage::OneHopMessageTypeListingRequest ) ){
 
 		NodeListingRequest* request = onemsg->decapsulate<NodeListingRequest>();
@@ -316,4 +314,10 @@
 	} // if( reply != NULL )
 
+	if( onemsg->isType( OneHopMessage::OneHopMessageTypeRoute) ){
+		logging_debug( "Route message arrived at destination node -> delegate to BaseOverlay" );
+		baseoverlay.incomingRouteMessage( onemsg );
+	}
+
+
 }
 
Index: source/ariba/overlay/modules/onehop/OneHop.h
===================================================================
--- source/ariba/overlay/modules/onehop/OneHop.h	(revision 3067)
+++ source/ariba/overlay/modules/onehop/OneHop.h	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #ifndef _ONE_HOP_H
@@ -42,77 +42,68 @@
 #include <map>
 #include "ariba/overlay/modules/OverlayInterface.h"
-#include "ariba/overlay/modules/onehop/messages/OneHopMessage.h"
-#include "ariba/overlay/modules/onehop/messages/NodeListingRequest.h"
-#include "ariba/overlay/modules/onehop/messages/NodeListingReply.h"
 #include "ariba/utility/logging/Logging.h"
 
 using std::map;
-using ariba::overlay::OverlayInterface;
-using ariba::overlay::OneHopMessage;
-using ariba::overlay::NodeListingRequest;
-using ariba::overlay::NodeListingReply;
 
 namespace ariba {
 namespace overlay {
 
-class OneHop : public OverlayInterface {
+class OneHop: public OverlayInterface {
 	use_logging_h( OneHop );
 public:
-	OneHop(
-		BaseOverlay& _overlay,
-		const NodeID& _nodeid,
-		OverlayStructureEvents* _eventsReceiver
-	);
+	OneHop(BaseOverlay& _overlay, const NodeID& _nodeid,
+			OverlayStructureEvents* _eventsReceiver);
 
 	virtual ~OneHop();
 
 protected:
+	/// @see OverlayInterface.h
+	virtual void createOverlay();
 
-	//
-	// OverlayInterface.h
-	//
-
-	virtual void createOverlay();
+	/// @see OverlayInterface.h
 	virtual void deleteOverlay();
 
-	virtual void joinOverlay(const EndpointDescriptor& bootstrapEp = EndpointDescriptor::UNSPECIFIED);
+	/// @see OverlayInterface.h
+	virtual void joinOverlay(const EndpointDescriptor& boot =
+			EndpointDescriptor::UNSPECIFIED);
+
+	/// @see OverlayInterface.h
 	virtual void leaveOverlay();
 
-	virtual const EndpointDescriptor& resolveNode( const NodeID& node );
-	virtual void routeMessage( const NodeID& destnode, Message* msg );
+	/// @see OverlayInterface.h
+	virtual const EndpointDescriptor& resolveNode(const NodeID& node);
 
+	/// @see OverlayInterface.h
+	virtual void routeMessage(const NodeID& destnode, Message* msg);
+
+	/// @see OverlayInterface.h
 	virtual NodeList getKnownNodes() const;
 
-	//
-	// see CommunicationListener.h or OverlayInterface.h
-	//
+	/// @see CommunicationListener.h or @see OverlayInterface.h
+	virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
 
-	virtual void onLinkUp(const LinkID& lnk, const NodeID& remote);
+	/// @see CommunicationListener.h or @see OverlayInterface.h
 	virtual void onLinkDown(const LinkID& lnk, const NodeID& remote);
-	virtual void onMessage(const DataMessage& msg, const NodeID& remote, const LinkID& lnk = LinkID::UNSPECIFIED);
+
+	/// @see CommunicationListener.h or @see OverlayInterface.h
+	virtual void onMessage(const DataMessage& msg, const NodeID& remote,
+			const LinkID& lnk = LinkID::UNSPECIFIED);
 
 private:
-
-	/**
-	 * The other nodes in the overlay
-	 */
-	typedef map<const NodeID,const LinkID> OverlayNodeMapping;
+	/// The other nodes in the overlay
+	typedef map<const NodeID, const LinkID> OverlayNodeMapping;
 	OverlayNodeMapping overlayNodes;
 
-	/**
-	 * The current state of the overlay
-	 */
+	/// The current state of the overlay
 	typedef enum _OneHopState {
-		OneHopStateInvalid                = 0,
-		OneHopStateJoinInitiated          = 1,
-		OneHopStateJoinListingRequested   = 2,
-		OneHopStateCompleted              = 3,
+		OneHopStateInvalid = 0,
+		OneHopStateJoinInitiated = 1,
+		OneHopStateJoinListingRequested = 2,
+		OneHopStateCompleted = 3,
 	} OneHopState;
 
 	OneHopState state;
-
 	uint16_t pendingLinks;
 	LinkID bootstrapLink;
-
 };
 
Index: source/ariba/overlay/modules/onehop/messages/NodeListingReply.cpp
===================================================================
--- source/ariba/overlay/modules/onehop/messages/NodeListingReply.cpp	(revision 3067)
+++ source/ariba/overlay/modules/onehop/messages/NodeListingReply.cpp	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #include "NodeListingReply.h"
Index: source/ariba/overlay/modules/onehop/messages/NodeListingReply.h
===================================================================
--- source/ariba/overlay/modules/onehop/messages/NodeListingReply.h	(revision 3067)
+++ source/ariba/overlay/modules/onehop/messages/NodeListingReply.h	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #ifndef NODE_LISTING_REPLY_H__
@@ -77,13 +77,9 @@
 
 sznBeginDefault( ariba::overlay::NodeListingReply, X ) {
-	uint16_t len = X.isSerializer() ? descriptors.size() : 0;
+	uint16_t len = descriptors.size();
 	X && len;
-	if (X.isDeserializer()) {
-		descriptors.resize(len);
-	}
-	for (int i=0; i<len; i++) {
-		if (X.isDeserializer()) descriptors[i].second = new EndpointDescriptor();
-		X && &descriptors[i].first && reinterpret_cast<VSerializeable*>(descriptors[i].second);
-	}
+	if (X.isDeserializer())	descriptors.resize(len);
+	for (int i=0; i<len; i++)
+		X && &descriptors[i].first && VO(descriptors[i].second);
 } sznEnd();
 
Index: source/ariba/overlay/modules/onehop/messages/NodeListingRequest.cpp
===================================================================
--- source/ariba/overlay/modules/onehop/messages/NodeListingRequest.cpp	(revision 3067)
+++ source/ariba/overlay/modules/onehop/messages/NodeListingRequest.cpp	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #include "NodeListingRequest.h"
Index: source/ariba/overlay/modules/onehop/messages/NodeListingRequest.h
===================================================================
--- source/ariba/overlay/modules/onehop/messages/NodeListingRequest.h	(revision 3067)
+++ source/ariba/overlay/modules/onehop/messages/NodeListingRequest.h	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #ifndef NODE_LISTING_REQUEST_H__
Index: source/ariba/overlay/modules/onehop/messages/OneHopMessage.cpp
===================================================================
--- source/ariba/overlay/modules/onehop/messages/OneHopMessage.cpp	(revision 3067)
+++ source/ariba/overlay/modules/onehop/messages/OneHopMessage.cpp	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #include "OneHopMessage.h"
Index: source/ariba/overlay/modules/onehop/messages/OneHopMessage.h
===================================================================
--- source/ariba/overlay/modules/onehop/messages/OneHopMessage.h	(revision 3067)
+++ source/ariba/overlay/modules/onehop/messages/OneHopMessage.h	(revision 3690)
@@ -1,3 +1,3 @@
-// [Licence]
+// [License]
 // The Ariba-Underlay Copyright
 //
@@ -35,5 +35,5 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [Licence]
+// [License]
 
 #ifndef __ONE_HOP_MESSAGE_H
@@ -57,4 +57,5 @@
 		OneHopMessageTypeListingRequest = 1,
 		OneHopMessageTypeListingReply   = 2,
+		OneHopMessageTypeRoute	        = 3,
 	} OneHopMessageType;
 
