Index: source/ariba/overlay/modules/chord/Chord.cpp
===================================================================
--- source/ariba/overlay/modules/chord/Chord.cpp	(revision 5803)
+++ source/ariba/overlay/modules/chord/Chord.cpp	(revision 5870)
@@ -38,13 +38,18 @@
 
 #include "ariba/overlay/BaseOverlay.h"
+#include "ariba/overlay/messages/OverlayMsg.h"
 
 #include "Chord.h"
-#include "messages/ChordMessage.h"
+#include "detail/chord_routing_table.hpp"
+
 #include "messages/Discovery.h"
-
-#include "detail/chord_routing_table.hpp"
 
 namespace ariba {
 namespace overlay {
+
+enum signalMessageTypes {
+	typeDiscovery = OverlayMsg::typeSignalingStart + 0x01,
+	typeLeave = OverlayMsg::typeSignalingStart + 0x02,
+};
 
 typedef chord_routing_table::item route_item;
@@ -57,5 +62,9 @@
 
 	// create routing table
+<<<<<<< .working
 	this->table = new chord_routing_table(_nodeid, 2);
+=======
+	this->table = new chord_routing_table(_nodeid, 4);
+>>>>>>> .merge-rechts.r5869
 	orphan_removal_counter = 0;
 	discovery_count = 0;
@@ -71,71 +80,81 @@
 
 /// helper: sets up a link using the base overlay
-LinkID Chord::setup(const EndpointDescriptor& endp, const NodeID& node, const NodeID& remoteRelay ) {
-	logging_debug("Request to setup link to " << endp.toString() );
+LinkID Chord::setup(const EndpointDescriptor& endpoint, const NodeID& remote ) {
 
 	// check if we already have a connection
 	for (int i=0; i<table->size(); i++)
-		if ((*table)[i]->id == node && !((*table)[i]->info.isUnspecified()))
+		if ((*table)[i]->ref_count > 0 && (*table)[i]->id == remote && !((*table)[i]->info.isUnspecified()))
 			return LinkID::UNSPECIFIED;
 
 	// check if we are already trying to establish a link
 	for (size_t i=0; i<pending.size(); i++)
-		if ( pending[i] == node ) {
-			logging_debug("Already trying to establish a link to node " << node.toString() );
+		if ( pending[i] == remote ) {
+			logging_debug("Already trying to establish a link to node "
+				<< remote.toString() );
 			return LinkID::UNSPECIFIED;
 		}
 
 	// adding node to list of pending connections
-	pending.push_back( node );
+	pending.push_back( remote );
+
+	logging_info("Request to setup link to " << endpoint.toString() );
 
 	// establish link via base overlay
+<<<<<<< .working
 	return baseoverlay.establishLink(endp, node, OverlayInterface::OVERLAY_SERVICE_ID, remoteRelay );
+=======
+	return baseoverlay.establishLink( endpoint, remote,
+			OverlayInterface::OVERLAY_SERVICE_ID );
+>>>>>>> .merge-rechts.r5869
 }
 
 /// helper: sends a message using the "base overlay"
-seqnum_t Chord::send(Message* msg, const LinkID& link) {
+seqnum_t Chord::send( OverlayMsg* msg, const LinkID& link ) {
 	if (link.isUnspecified()) return 0;
-	return baseoverlay.sendMessage(msg, link);
+	msg->setRelayed(true);
+	return baseoverlay.send_link( msg, link );
 }
 
 /// sends a discovery message
-void Chord::send_discovery_to(const NodeID& destination, int ttl) {
+void Chord::send_discovery_to(const NodeID& remote, int ttl) {
+	LinkID link = getNextLinkId(remote);
+	if ( remote == nodeid || link.isUnspecified()) return;
 	if ( table->size() == 0 ) return;
 
-	ChordMessage cmsg(ChordMessage::discovery, nodeid, destination);
-	Discovery dmsg;
-	dmsg.setSourceEndpoint(&baseoverlay.getEndpointDescriptor());
-	dmsg.setSourceRelay(baseoverlay.getRelayNode(destination));
-	dmsg.setFollowType(Discovery::normal);
-	dmsg.setTTL((uint8_t) ttl);
-	cmsg.encapsulate(&dmsg);
-
+	OverlayMsg msg( typeDiscovery );
+	msg.setRelayed(true);
+	Discovery dmsg( Discovery::normal, (uint8_t)2, baseoverlay.getEndpointDescriptor() );
+	msg.encapsulate(&dmsg);
+
+<<<<<<< .working
 	// get next hop
 	const route_item* item = table->get_next_hop(destination);
 	if (item!=NULL && !item->info.isUnspecified()) send(&cmsg, item->info);
-}
-
-void Chord::discover_neighbors( const LinkID& lnk ) {
+=======
+	// send to node
+	baseoverlay.send_node( &msg, remote );
+>>>>>>> .merge-rechts.r5869
+}
+
+void Chord::discover_neighbors( const LinkID& link ) {
+	uint8_t ttl = 2;
+	{
+		// send predecessor discovery
+		OverlayMsg msg( typeDiscovery );
+		msg.setRelayed(true);
+		Discovery dmsg( Discovery::predecessor, ttl,
+			baseoverlay.getEndpointDescriptor() );
+		msg.encapsulate(&dmsg);
+		send(&msg, link);
+	}
 	{
 		// send successor discovery
-		ChordMessage cmsg(ChordMessage::discovery, nodeid, nodeid);
-		Discovery dmsg;
-		dmsg.setSourceEndpoint(&baseoverlay.getEndpointDescriptor());
-		dmsg.setSourceRelay(baseoverlay.getRelayNode(nodeid));
-		dmsg.setFollowType(Discovery::successor);
-		dmsg.setTTL((uint8_t)4);
-		cmsg.encapsulate(&dmsg);
-		send(&cmsg, lnk);
-	}
-	{
-		// send predecessor discovery
-		ChordMessage cmsg(ChordMessage::discovery, nodeid, nodeid);
-		Discovery dmsg;
-		dmsg.setSourceEndpoint(&baseoverlay.getEndpointDescriptor());
-		dmsg.setSourceRelay(baseoverlay.getRelayNode(nodeid));
-		dmsg.setFollowType(Discovery::predecessor);
-		dmsg.setTTL((uint8_t)4);
-		cmsg.encapsulate(&dmsg);
-		send(&cmsg, lnk);
+		OverlayMsg msg( typeDiscovery );
+		msg.setSourceEndpoint( baseoverlay.getEndpointDescriptor() );
+		msg.setRelayed(true);
+		Discovery dmsg( Discovery::successor, ttl,
+			baseoverlay.getEndpointDescriptor() );
+		msg.encapsulate(&dmsg);
+		send(&msg, link);
 	}
 }
@@ -166,9 +185,10 @@
 	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);
-	}
-}
-
+		OverlayMsg msg( typeLeave );
+		send( &msg, it->info );
+	}
+}
+
+/// @see OverlayInterface.h
 const EndpointDescriptor& Chord::resolveNode(const NodeID& node) {
 	const route_item* item = table->get(node);
@@ -177,12 +197,24 @@
 }
 
-void Chord::routeMessage(const NodeID& destnode, Message* msg) {
+/// @see OverlayInterface.h
+const LinkID& Chord::getNextLinkId( const NodeID& id ) const {
 	// get next hop
+<<<<<<< .working
 	const route_item* item = table->get_next_hop(destnode);
-
+=======
+	const route_item* item = table->get_next_hop(id);
+>>>>>>> .merge-rechts.r5869
+
+<<<<<<< .working
 	// message for this node? yes-> delegate to base overlay
 	if (item->id == nodeid || destnode == nodeid)
 		baseoverlay.incomingRouteMessage( msg, LinkID::UNSPECIFIED, nodeid );
-
+=======
+	// returns a unspecified id when this is itself
+	if (item == NULL || item->id == nodeid)
+		return LinkID::UNSPECIFIED;
+>>>>>>> .merge-rechts.r5869
+
+<<<<<<< .working
 	else { // no-> send to next hop
 		ChordMessage cmsg(ChordMessage::route, nodeid, destnode);
@@ -190,6 +222,11 @@
 		send(&cmsg, item->info);
 	}
-}
-
+=======
+	/// return routing info
+	return item->info;
+>>>>>>> .merge-rechts.r5869
+}
+
+<<<<<<< .working
 /// @see OverlayInterface.h
 void Chord::routeMessage(const NodeID& node, const LinkID& link, Message* msg) {
@@ -214,4 +251,6 @@
 }
 
+=======
+>>>>>>> .merge-rechts.r5869
 OverlayInterface::NodeList Chord::getKnownNodes(bool deep) const {
 	OverlayInterface::NodeList nodelist;
@@ -243,5 +282,5 @@
 /// @see OverlayInterface.h
 void Chord::onLinkUp(const LinkID& lnk, const NodeID& remote) {
-	logging_debug("link_up: link=" << lnk.toString() << " remote=" <<
+	logging_info("link_up: link=" << lnk.toString() << " remote=" <<
 			remote.toString() );
 	for (vector<NodeID>::iterator i=pending.begin(); i!=pending.end(); i++)
@@ -250,4 +289,17 @@
 			break;
 		}
+/*
+	// check if we already have a connection, yes-> do not handle duplicate!
+	for (int i=0; i<table->size(); i++)
+		if ((*table)[i]->id == remote && !((*table)[i]->info.isUnspecified()) && (*table)[i]->info != lnk) {
+
+			return;
+		}
+*/
+	if (remote==nodeid) {
+		baseoverlay.dropLink(lnk);
+		return;
+	}
+
 	route_item* item = table->insert(remote);
 
@@ -257,7 +309,10 @@
 				<< " with link " << lnk.toString());
 		// replace with new link
-		if (!item->info.isUnspecified())
+		if (!item->info.isUnspecified() || item->info!=lnk)
 			baseoverlay.dropLink(item->info);
 		item->info = lnk;
+		// discover neighbors of new overlay neighbor
+		discover_neighbors( lnk );
+		showLinks();
 	} else { // no-> add orphan entry to routing table
 		logging_info("new orphan: " << remote.toString()
@@ -266,11 +321,7 @@
 	}
 
-	discover_neighbors( lnk );
-
+	// erase bootstrap link
 	vector<LinkID>::iterator it = std::find(bootstrapLinks.begin(), bootstrapLinks.end(), lnk);
-	if( it != bootstrapLinks.end() ) {
-		discover_neighbors( lnk );
-		bootstrapLinks.erase( it );
-	}
+	if( it != bootstrapLinks.end() ) bootstrapLinks.erase( it );
 }
 
@@ -282,6 +333,8 @@
 	// remove link from routing table
 	route_item* item = table->get(remote);
-	if (item!=NULL) item->info = LinkID::UNSPECIFIED;
-	table->remove(remote);
+	if (item!=NULL && item->info==lnk) {
+		item->info = LinkID::UNSPECIFIED;
+		table->remove(remote);
+	}
 }
 
@@ -292,6 +345,5 @@
 
 	// decode message
-	typedef ChordMessage M;
-	M* m = msg.getMessage()->convert<ChordMessage> ();
+	OverlayMsg* m = dynamic_cast<OverlayMsg*>(msg.getMessage());
 	if (m == NULL) return;
 
@@ -299,4 +351,5 @@
 	switch (m->getType()) {
 
+<<<<<<< .working
 	// invalid message
 	case M::invalid:
@@ -324,55 +377,63 @@
 		// discovery request
 	case M::discovery: {
+=======
+	// discovery request
+	case typeDiscovery: {
+>>>>>>> .merge-rechts.r5869
 		// decapsulate message
 		Discovery* dmsg = m->decapsulate<Discovery> ();
-		logging_debug("received discovery message with"
-			    << " src=" << m->getSource().toString()
-				<< " dst=" << m->getDestination().toString()
+		logging_debug("Received discovery message with"
+			    << " src=" << m->getSourceNode().toString()
+				<< " dst=" << m->getDestinationNode().toString()
 				<< " ttl=" << (int)dmsg->getTTL()
-				<< " type=" << (int)dmsg->getFollowType()
+				<< " type=" << (int)dmsg->getType()
 		);
 
 		// 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(), m->getSource(), dmsg->getSourceRelay() );
+		if (m->getSourceNode() != nodeid
+			&& table->is_insertable(m->getSourceNode()))
+			setup( dmsg->getEndpoint(), m->getSourceNode() );
 
 		// delegate discovery message
-		switch (dmsg->getFollowType()) {
+		switch (dmsg->getType()) {
 
 		// 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())
-				|| (table->get_successor()!=NULL && *table->get_successor() == m->getDestination())
-				|| (table->get_predesessor()!=NULL && *table->get_predesessor() == m->getDestination())
-			) {
+			if ( table->is_closest_to(m->getDestinationNode()) ) {
 
 				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);
+					OverlayMsg omsg(*m);
+					dmsg->setType(Discovery::successor);
+					omsg.encapsulate(dmsg);
 					route_item* succ_item = table->get(*table->get_successor());
 					logging_debug("Discovery split: routing discovery message to successor "
 							<< succ_item->id.toString() );
+<<<<<<< .working
 					send(&cmsg_s, succ_item->info);
+=======
+					send(&omsg, succ_item->info);
+>>>>>>> .merge-rechts.r5869
 				}
 
 				// 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);
+					OverlayMsg omsg(*m);
+					dmsg->setType(Discovery::predecessor);
+					omsg.encapsulate(dmsg);
 					route_item* pred_item = table->get(
 							*table->get_predesessor());
 					logging_debug("Discovery split: routing discovery message to predecessor "
 							<< pred_item->id.toString() );
+<<<<<<< .working
 					send(&cmsg_p, pred_item->info);
+=======
+					send( &omsg, pred_item->info);
+>>>>>>> .merge-rechts.r5869
 				}
 			}
 			// no-> route message
 			else {
+<<<<<<< .working
 				// find next hop
 				const route_item* item = table->get_next_hop(m->getDestination());
@@ -381,4 +442,7 @@
 						item->id.toString() );
 				send(m, item->info);
+=======
+				baseoverlay.send( m, m->getDestinationNode() );
+>>>>>>> .merge-rechts.r5869
 			}
 			break;
@@ -395,5 +459,5 @@
 
 			const route_item* item = NULL;
-			if (dmsg->getFollowType() == Discovery::successor &&
+			if (dmsg->getType() == Discovery::successor &&
 					table->get_successor() != NULL) {
 				item = table->get(*table->get_successor());
@@ -405,8 +469,8 @@
 			logging_debug("routing discovery message to succ/pred "
 				<< item->id.toString() );
-			ChordMessage cmsg(*m);
-			Discovery dmsg_p(*dmsg);
-			cmsg.encapsulate(&dmsg_p);
-			send(&cmsg, item->info);
+			OverlayMsg omsg(*m);
+			omsg.encapsulate(dmsg);
+			omsg.setDestinationNode(item->id);
+			baseoverlay.send(&omsg, omsg.getDestinationNode());
 			break;
 		}}
@@ -415,6 +479,6 @@
 	}
 
-		// leave
-	case M::leave: {
+	// leave
+	case typeLeave: {
 		if (link!=LinkID::UNSPECIFIED) {
 			route_item* item = table->get(remote);
@@ -424,7 +488,5 @@
 		}
 		break;
-	}
-	}
-	delete m;
+	}}
 }
 
@@ -464,5 +526,9 @@
 		// remove orphan links
 		orphan_removal_counter++;
+<<<<<<< .working
 		if (orphan_removal_counter <0 || orphan_removal_counter >= 4) {
+=======
+		if (orphan_removal_counter <0 || orphan_removal_counter >= 2) {
+>>>>>>> .merge-rechts.r5869
 			logging_info("Running orphan removal");
 			orphan_removal_counter = 0;
@@ -473,6 +539,7 @@
 					table->insert(it->id);
 					if (it->ref_count==0) {
-						baseoverlay.dropLink(it->info);
+						LinkID id = it->info;
 						it->info = LinkID::UNSPECIFIED;
+						baseoverlay.dropLink(id);
 					}
 				}
@@ -480,4 +547,7 @@
 		}
 	}
+}
+
+void Chord::showLinks() {
 	logging_info("--- chord routing information ----------------------------------");
 	logging_info("predecessor: " << (table->get_predesessor()==NULL? "<none>" :
Index: source/ariba/overlay/modules/chord/Chord.h
===================================================================
--- source/ariba/overlay/modules/chord/Chord.h	(revision 5803)
+++ source/ariba/overlay/modules/chord/Chord.h	(revision 5870)
@@ -51,4 +51,6 @@
 namespace overlay {
 
+class OverlayMsg;
+
 using ariba::communication::EndpointDescriptor;
 using ariba::utility::Timer;
@@ -82,9 +84,8 @@
 	// helper: sets up a link using the "base overlay"
 	LinkID setup( const EndpointDescriptor& endp,
-		const NodeID& node = NodeID::UNSPECIFIED,
-		const NodeID& remoteRelay = NodeID::UNSPECIFIED );
+		const NodeID& node = NodeID::UNSPECIFIED );
 
 	// helper: sends a message using the "base overlay"
-	seqnum_t send( Message* msg, const LinkID& link );
+	seqnum_t send( OverlayMsg* msg, const LinkID& link );
 
 	// stabilization: sends a discovery message to the specified neighborhood
@@ -92,4 +93,6 @@
 
 	void discover_neighbors( const LinkID& lnk );
+
+	void showLinks();
 
 public:
@@ -119,10 +122,4 @@
 
 	/// @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
 	virtual NodeList getKnownNodes(bool deep = true) const;
 
@@ -137,8 +134,7 @@
 			const LinkID& lnk = LinkID::UNSPECIFIED);
 
-
-
 	/// @see Timer.h
 	virtual void eventFunction();
+
 };
 
Index: source/ariba/overlay/modules/chord/messages/ChordMessage.cpp
===================================================================
--- source/ariba/overlay/modules/chord/messages/ChordMessage.cpp	(revision 5803)
+++ 	(revision )
@@ -1,49 +1,0 @@
-// [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 5803)
+++ 	(revision )
@@ -1,110 +1,0 @@
-// [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 5803)
+++ source/ariba/overlay/modules/chord/messages/Discovery.cpp	(revision 5870)
@@ -44,7 +44,4 @@
 vsznDefault(Discovery);
 
-Discovery::Discovery(){
-}
-
 Discovery::~Discovery(){
 }
Index: source/ariba/overlay/modules/chord/messages/Discovery.h
===================================================================
--- source/ariba/overlay/modules/chord/messages/Discovery.h	(revision 5803)
+++ source/ariba/overlay/modules/chord/messages/Discovery.h	(revision 5870)
@@ -41,4 +41,5 @@
 
 #include <vector>
+
 #include "ariba/utility/messages.h"
 #include "ariba/utility/serialization.h"
@@ -61,25 +62,26 @@
 	VSERIALIZEABLE;
 public:
-	enum follow_type_ {
-		normal = 0,
-		successor = 1,
-		predecessor = 2
+	enum type_ {
+		invalid = 0,
+		normal = 1,
+		successor = 2,
+		predecessor = 3
 	};
 
-	Discovery( const Discovery& msg ) {
-		this->follow_type = msg.follow_type;
-		this->ttl = msg.ttl;
-		this->source_relay = msg.source_relay;
-		this->source_endpoint = msg.source_endpoint;
+	Discovery( const Discovery& msg ) : type(msg.type), ttl(msg.ttl),
+		endpoint(msg.endpoint) {
 	}
-	explicit Discovery();
+	Discovery( type_ type = invalid, uint8_t ttl = 4,
+		const EndpointDescriptor& endpoint = EndpointDescriptor::UNSPECIFIED() )
+	: type(type),  ttl(ttl), endpoint(endpoint) {
+	}
 	virtual ~Discovery();
 
-	const EndpointDescriptor* getSourceEndpoint() const {
-		return &source_endpoint;
+	inline type_ getType() const {
+		return (type_)type;
 	}
 
-	void setSourceEndpoint( const EndpointDescriptor* endpoint ) {
-		source_endpoint = *endpoint;
+	inline void setType( type_ type ) {
+		this->type = type;
 	}
 
@@ -92,24 +94,16 @@
 	}
 
-	inline follow_type_ getFollowType() const {
-		return (follow_type_)follow_type;
+	inline const EndpointDescriptor& getEndpoint() const {
+		return endpoint;
 	}
 
-	inline void setFollowType( follow_type_ type ) {
-		follow_type = (uint8_t)type;
+	inline void setEndpoint( const EndpointDescriptor& endpoint ) {
+		this->endpoint = endpoint;
 	}
 
-	inline void setSourceRelay( const NodeID& relay ) {
-		source_relay = relay;
-	}
-
-	inline const NodeID& getSourceRelay() const {
-		return source_relay;
-	}
 private:
-	uint8_t follow_type;
+	uint8_t type;
 	uint8_t ttl;
-	EndpointDescriptor source_endpoint;
-	NodeID source_relay;
+	EndpointDescriptor endpoint;
 };
 
@@ -117,9 +111,5 @@
 
 sznBeginDefault( ariba::overlay::Discovery, X ) {
-	/// serialize follow-type and time-to-live
-	X && follow_type && ttl;
-
-	// serialize end-point
-	X && &source_relay && source_endpoint;
+	X && type && ttl && endpoint;
 } sznEnd();
 
