Index: source/ariba/AribaModule.cpp
===================================================================
--- source/ariba/AribaModule.cpp	(revision 2995)
+++ source/ariba/AribaModule.cpp	(revision 3037)
@@ -46,12 +46,10 @@
 #include "ariba/utility/misc/Helper.h"
 #include "ariba/utility/misc/StringFormat.h"
-
-// hack includes
-#include "ariba/interface/UnderlayAbstraction.h"
+#include "ariba/communication/BaseCommunication.h"
 #include "ariba/communication/EndpointDescriptor.h"
 #include "ariba/communication/modules/network/NetworkLocator.h"
 
 using namespace ariba::utility::Helper;
-using ariba::interface::UnderlayAbstraction;
+using ariba::communication::BaseCommunication;
 using ariba::communication::EndpointDescriptor;
 
@@ -61,5 +59,5 @@
 
 	// init with default values
-	this->underlay_abs = NULL;
+	this->base_comm = NULL;
 	this->ip_addr = NULL;
 	this->tcp_port = 41402;
@@ -132,5 +130,5 @@
 	}
 
-	//std::cout << "added bootstrap info: " << getBootstrapHints() << std::endl;
+	//logging_debug( "added bootstrap info: " << getBootstrapHints() );
 }
 
@@ -154,5 +152,5 @@
 
 	// init variables
-	underlay_abs = NULL;
+	base_comm = NULL;
 }
 
@@ -161,10 +159,10 @@
 
 	// preconditions
-	assert(underlay_abs == NULL);
+	assert(base_comm == NULL);
 	assert(!started);
 
 	// create the base communication component
 	started = true;
-	underlay_abs = new interface::UnderlayAbstraction();
+	base_comm = new BaseCommunication();
 }
 
@@ -173,10 +171,10 @@
 
 	// preconditions
-	assert(underlay_abs != NULL);
+	assert(base_comm != NULL);
 	assert(started);
 
 	// delete base communication component
 	started = false;
-	delete underlay_abs;
+	delete base_comm;
 }
 
Index: source/ariba/AribaModule.h
===================================================================
--- source/ariba/AribaModule.h	(revision 2995)
+++ source/ariba/AribaModule.h	(revision 3037)
@@ -64,6 +64,6 @@
 class NetworkLocator;
 }
-namespace interface {
-class UnderlayAbstraction;
+namespace communication {
+class BaseCommunication;
 }
 
@@ -185,6 +185,5 @@
 			const Name& spovnet) const;
 
-	// TODO: merge with old interface
-	interface::UnderlayAbstraction* underlay_abs;
+	communication::BaseCommunication* base_comm;
 
 	// TODO: use "abstract" representations here!
Index: source/ariba/LinkProperties.cpp
===================================================================
--- source/ariba/LinkProperties.cpp	(revision 2995)
+++ source/ariba/LinkProperties.cpp	(revision 3037)
@@ -52,3 +52,9 @@
 }
 
+string LinkProperties::toString() const {
+	std::ostringstream buf;
+	buf << "[reliable=" << (reliable ? "yes" : "no") << "]";
+	return buf.str();
+}
+
 } // namespace ariba
Index: source/ariba/LinkProperties.h
===================================================================
--- source/ariba/LinkProperties.h	(revision 2995)
+++ source/ariba/LinkProperties.h	(revision 3037)
@@ -40,4 +40,10 @@
 #define LINKPROPERTIES_H_
 
+#include <string>
+#include <iostream>
+#include <sstream>
+
+using std::string;
+
 namespace ariba {
 // forward declaration
@@ -52,4 +58,5 @@
 	~LinkProperties();
 
+	string toString() const;
 	static const LinkProperties DEFAULT;
 
Index: source/ariba/Makefile.am
===================================================================
--- source/ariba/Makefile.am	(revision 2995)
+++ source/ariba/Makefile.am	(revision 3037)
@@ -256,6 +256,4 @@
 
 libariba_la_SOURCES += \
-  interface/UnderlayAbstraction.cpp \
-  interface/AribaContext.cpp \
   interface/ServiceInterface.cpp
 
Index: source/ariba/Node.cpp
===================================================================
--- source/ariba/Node.cpp	(revision 2995)
+++ source/ariba/Node.cpp	(revision 3037)
@@ -41,11 +41,8 @@
 #include "ariba/overlay/BaseOverlay.h"
 #include "ariba/utility/types/OverlayParameterSet.h"
-#include "ariba/interface/AribaContext.h"
 #include "ariba/interface/ServiceInterface.h"
-#include "ariba/interface/UnderlayAbstraction.h"
 #include "ariba/communication/EndpointDescriptor.h"
 
 using ariba::communication::EndpointDescriptor;
-using ariba::interface::UnderlayAbstraction;
 
 namespace ariba {
@@ -64,16 +61,9 @@
 		nodeListener(NULL), commListener(listener) {
 	}
-	
+
 	~ServiceInterfaceWrapper() {
 	}
 
 protected:
-	void onOverlayCreate(const SpoVNetID& id) {
-
-	}
-
-	void onOverlayDestroy(const SpoVNetID& id) {
-
-	}
 
 	bool isJoinAllowed(const NodeID& nodeid, const SpoVNetID& spovnetid) {
@@ -95,4 +85,12 @@
 	void onJoinFail(const SpoVNetID& spovnetid) {
 		if (nodeListener != NULL) nodeListener->onJoinFailed(spovnetid);
+	}
+
+	void onLeaveSuccess( const SpoVNetID& spovnetid ){
+		if (nodeListener != NULL) nodeListener->onLeaveCompleted(spovnetid);
+	}
+
+	void onLeaveFail( const SpoVNetID& spovnetid ){
+		if (nodeListener != NULL) nodeListener->onLeaveFailed(spovnetid);
 	}
 
@@ -131,5 +129,5 @@
 
 Node::Node(AribaModule& ariba_mod, const Name& node_name) :
-	ariba_mod(ariba_mod), name(node_name), context(NULL) {
+	ariba_mod(ariba_mod), name(node_name), base_overlay(NULL) {
 }
 
@@ -137,16 +135,29 @@
 }
 
+//TODO: Implement error handling: no bootstrap node available
 void Node::join(const Name& vnetname) {
 	spovnetId = vnetname.toSpoVNetId();
 	nodeId = generateNodeId(name);
-	this->context = ariba_mod.underlay_abs->joinSpoVNet(spovnetId,
-				*ariba_mod.getBootstrapNode(vnetname), nodeId, 
-				ariba_mod.ip_addr, ariba_mod.tcp_port);
-}
-
-//TODO: Implement error handling: no bootstrap node available
+
+	//logging("joining spovnet on"
+	//		<< " [spovnetid=]" << spovnetId.toString()
+	//		<< " [nodeid=]" << nodeId.toString() );
+
+	//logging_info("starting base communication...");
+	ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
+
+	//logging_info("starting base overlay...");
+	base_overlay = new BaseOverlay( *ariba_mod.base_comm, nodeId );
+
+	const communication::EndpointDescriptor* ep =
+			ariba_mod.getBootstrapNode(vnetname);
+	if( ep == NULL ) return;
+
+	base_overlay->joinSpoVNet( spovnetId, *ep);
+}
+
 void Node::initiate(const Name& vnetname, const SpoVNetProperties& parm) {
 	utility::OverlayParameterSet ovrpset =
-			(utility::OverlayParameterSet::_OverlayStructure) 
+			(utility::OverlayParameterSet::_OverlayStructure)
 			parm.getBaseOverlayType();
 
@@ -154,16 +165,25 @@
 	nodeId = generateNodeId(name);
 
-	this->context = ariba_mod.underlay_abs->createSpoVNet(
-				spovnetId, nodeId, ariba_mod.ip_addr,
-				ariba_mod.tcp_port);
+	//logging("joining spovnet on"
+	//			<< " [spovnetid=]" << spovnetId.toString()
+	//			<< " [nodeid=]" << nodeId.toString() );
+
+	//logging_info("starting base communication...");
+	ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
+
+	//logging_info("starting base overlay...");
+	base_overlay = new BaseOverlay( *ariba_mod.base_comm, nodeId );
+	base_overlay->createSpoVNet( spovnetId );
 
 	ariba_mod.addBootstrapNode(vnetname,
-		new EndpointDescriptor(this->context->
-		getBaseCommunication().getEndpointDescriptor()));
+		new EndpointDescriptor(ariba_mod.base_comm->getEndpointDescriptor()));
 }
 
 void Node::leave() {
-	ariba_mod.underlay_abs->leaveSpoVNet( context );
-	context = NULL;
+	base_overlay->leaveSpoVNet();
+	ariba_mod.base_comm->stop();
+
+	delete base_overlay;
+	base_overlay = NULL;
 }
 
@@ -177,5 +197,6 @@
 
 const NodeID& Node::getNodeId(const LinkID& lid) const {
-	return nodeId;
+	if( lid == LinkID::UNSPECIFIED ) return nodeId;
+	else return base_overlay->getNodeID( lid );
 }
 
@@ -185,41 +206,45 @@
 }
 
+vector<NodeID> Node::getNeighborNodes() const {
+	return base_overlay->getOverlayNeighbors();
+}
+
 LinkID Node::establishLink(const NodeID& nid, const ServiceID& sid,
 		const LinkProperties& req, const DataMessage& msg) {
-	return context->getOverlay().establishLink(nid, sid);
+	return base_overlay->establishLink(nid, sid);
 }
 
 void Node::dropLink(const LinkID& lnk) {
-	context->getOverlay().dropLink(lnk);
+	base_overlay->dropLink(lnk);
 }
 
 seqnum_t Node::sendMessage(const DataMessage& msg, const NodeID& nid,
 		const ServiceID& sid, const LinkProperties& req) {
-	return context->getOverlay().sendMessage((Message*) msg, nid, sid);
+	return base_overlay->sendMessage((Message*) msg, nid, sid);
 }
 
 seqnum_t Node::sendMessage(const DataMessage& msg, const LinkID& lnk) {
-	return context->getOverlay().sendMessage((Message*) msg, lnk);
+	return base_overlay->sendMessage((Message*) msg, lnk);
 }
 
 void Node::sendBroadcastMessage(const DataMessage& msg, const ServiceID& sid) {
-	return context->getOverlay().broadcastMessage((Message*)msg, sid);
+	return base_overlay->broadcastMessage((Message*)msg, sid);
 }
 
 void Node::bind(NodeListener* listener) {
-	context->getOverlay().bind(new ServiceInterfaceWrapper(listener),
+	base_overlay->bind(new ServiceInterfaceWrapper(listener),
 			Node::anonymousService);
 }
 
 void Node::unbind(NodeListener* listener) {
-	delete context->getOverlay().unbind(Node::anonymousService);
+	delete base_overlay->unbind(Node::anonymousService);
 }
 
 void Node::bind(CommunicationListener* listener, const ServiceID& sid) {
-	context->getOverlay().bind(new ServiceInterfaceWrapper(listener), sid);
+	base_overlay->bind(new ServiceInterfaceWrapper(listener), sid);
 }
 
 void Node::unbind(CommunicationListener* listener, const ServiceID& sid) {
-	delete context->getOverlay().unbind(sid);
+	delete base_overlay->unbind(sid);
 }
 
Index: source/ariba/Node.h
===================================================================
--- source/ariba/Node.h	(revision 2995)
+++ source/ariba/Node.h	(revision 3037)
@@ -45,4 +45,5 @@
 }
 
+#include <vector>
 #include "Module.h"
 #include "Identifiers.h"
@@ -54,10 +55,15 @@
 #include "DataMessage.h"
 
+using std::vector;
+
 namespace ariba {
 
 // forward declaration
 namespace interface {
-class AribaContext;
 class ServiceInterface;
+}
+
+namespace overlay {
+class BaseOverlay;
 }
 
@@ -66,4 +72,5 @@
  *
  * @author Sebastian Mies <mies@tm.uka.de>
+ * @author Christoph Mayer <mayer@tm.uka.de>
  */
 class Node: public Module {
@@ -181,4 +188,14 @@
 	 */
 	const Name getNodeName(const LinkID& lid = LinkID::UNSPECIFIED) const;
+
+	/**
+	 * Get a list of neighboring nodes in the overlay structure.
+	 * The number and identities of nodes depends highly on the
+	 * used overlay structure.
+	 *
+	 * @return a list of NodeIDs that are neighbors in the overlay structure
+	 * @see sendBroadcastMessage
+	 */
+	vector<NodeID> getNeighborNodes() const;
 
 	//--- communication ---
@@ -241,4 +258,5 @@
 	 * @param msg The message to be send
 	 * @param sid The id of the service that should receive the message
+	 * @see getNeighborNodes
 	 */
 	void sendBroadcastMessage(const DataMessage& msg, const ServiceID& sid);
@@ -317,11 +335,11 @@
 
 	// member variables
-	Name name;		//< node name
-	AribaModule& ariba_mod;	//< ariba module
-	SpoVNetID spovnetId; 	//< current spovnet id
-	NodeID nodeId; 		//< current node id
+	Name name;                             //< node name
+	AribaModule& ariba_mod;	               //< ariba module
+	SpoVNetID spovnetId; 	               //< current spovnet id
+	NodeID nodeId; 		                   //< current node id
+	overlay::BaseOverlay* base_overlay;    //< the base overlay
 
 	// delegates
-	interface::AribaContext* context;
 	static ServiceID anonymousService;
 };
Index: source/ariba/NodeListener.cpp
===================================================================
--- source/ariba/NodeListener.cpp	(revision 2995)
+++ source/ariba/NodeListener.cpp	(revision 3037)
@@ -42,25 +42,19 @@
 namespace ariba {
 
-// dummy
 NodeListener::NodeListener() {
 }
 
-// dummy
 NodeListener::~NodeListener() {
 }
 
-// dummy
 void NodeListener::onJoinCompleted(const SpoVNetID& vid ) {
 }
 
-// dummy
 void NodeListener::onJoinFailed(const SpoVNetID& vid ) {
 }
 
-// dummy
 void NodeListener::onLeaveCompleted(const SpoVNetID& vid ) {
 }
 
-// dummy
 void NodeListener::onLeaveFailed(const SpoVNetID& vid ) {
 }
Index: source/ariba/communication/BaseCommunication.cpp
===================================================================
--- source/ariba/communication/BaseCommunication.cpp	(revision 2995)
+++ source/ariba/communication/BaseCommunication.cpp	(revision 3037)
@@ -55,6 +55,15 @@
 const BaseCommunication::LinkDescriptor BaseCommunication::LinkDescriptor::UNSPECIFIED;
 
-BaseCommunication::BaseCommunication(const NetworkLocator* _locallocator, const uint16_t _listenport)
-	: messageReceiver( NULL ), currentSeqnum( 0 ), listenport( _listenport ) {
+BaseCommunication::BaseCommunication()
+	: messageReceiver(NULL), network(NULL), transport(NULL){
+}
+
+BaseCommunication::~BaseCommunication(){
+}
+
+void BaseCommunication::start(const NetworkLocator* _locallocator, const uint16_t _listenport){
+
+	currentSeqnum = 0;
+	listenport = _listenport;
 
 	logging_info( "starting up base communication and creating transports ..." );
@@ -139,5 +148,5 @@
 }
 
-BaseCommunication::~BaseCommunication() {
+void BaseCommunication::stop() {
 
 	logging_info( "stopping base communication and transport ..." );
@@ -210,5 +219,5 @@
 	// warn if this link has some queued messages attached
 	if( descriptor.waitingmsg.size() > 0 ){
-		logging_warn( "dropping link " << link.toString() << 
+		logging_warn( "dropping link " << link.toString() <<
 			" that has " << descriptor.waitingmsg.size() << " waiting messages" );
 	}
@@ -368,5 +377,5 @@
 		const NetworkLocator* remoteLocator = dynamic_cast<const NetworkLocator*>(message->getSourceAddress());
 
-		logging_debug( "localLocator=" << localLocator->toString() 
+		logging_debug( "localLocator=" << localLocator->toString()
 				<< " remoteLocator=" << remoteLocator->toString());
 
@@ -419,5 +428,5 @@
 		// the link is now open
 		//
-		
+
 		BOOST_FOREACH( CommunicationEvents* i, eventListener ){
 			i->onLinkUp( localLink, localLocator, remoteLocator );
@@ -444,6 +453,6 @@
 
 		linkDesc.remoteLink = spovmsg->getLocalLink();
-		linkDesc.linkup = true;	
-	
+		linkDesc.linkup = true;
+
 		logging_debug( "the link is now up with local link id " << spovmsg->getRemoteLink().toString() );
 
@@ -452,5 +461,5 @@
 		}
 
-		if( linkDesc.waitingmsg.size() > 0 ){ 
+		if( linkDesc.waitingmsg.size() > 0 ){
 			logging_info( "sending out queued messages on link " << linkDesc.localLink.toString() );
 
@@ -564,5 +573,5 @@
 	for( ; i != iend; i++){
 		if( (*i).localLink != localLink) continue;
-		
+
 		BOOST_FOREACH( Message* msg, i->waitingmsg ){
 			delete msg;
Index: source/ariba/communication/BaseCommunication.h
===================================================================
--- source/ariba/communication/BaseCommunication.h	(revision 2995)
+++ source/ariba/communication/BaseCommunication.h	(revision 3037)
@@ -122,18 +122,27 @@
  */
 class BaseCommunication : public MessageReceiver, NetworkChangeInterface {
-
 	use_logging_h(BaseCommunication);
-
 public:
-	/**
-	 * Constructs a Base Communication instance.
-	 * Listens default on port number 41402
-	 */
-	BaseCommunication(const NetworkLocator* _locallocator, const uint16_t _listenport);
-
-	/**
-	 * Destructs a Base Communication instance
+
+	/**
+	 * Default ctor that just creates an empty
+	 * non functional base communication
+	 */
+	BaseCommunication();
+
+	/**
+	 * Default dtor that does nothing
 	 */
 	virtual ~BaseCommunication();
+
+	/**
+	 * Startup the base communication, start modules etc.
+	 */
+	void start(const NetworkLocator* _locallocator, const uint16_t _listenport);
+
+	/**
+	 * stop the base communication, stop modules etc.
+	 */
+	void stop();
 
 	/**
Index: source/ariba/communication/EndpointDescriptor.cpp
===================================================================
--- source/ariba/communication/EndpointDescriptor.cpp	(revision 2995)
+++ source/ariba/communication/EndpointDescriptor.cpp	(revision 3037)
@@ -57,4 +57,6 @@
 
 EndpointDescriptor::EndpointDescriptor(const Locator* _locator){
+	if( _locator == NULL ) return;
+
 	locator = new IPv4Locator(*dynamic_cast<IPv4Locator*>((Locator*)_locator));
 	isUnspec = false;
Index: source/ariba/communication/EndpointDescriptor.h
===================================================================
--- source/ariba/communication/EndpointDescriptor.h	(revision 2995)
+++ source/ariba/communication/EndpointDescriptor.h	(revision 3037)
@@ -51,11 +51,4 @@
 using ariba::communication::IPv4Locator;
 
-// needed for friend decleration
-// in different namespace
-namespace ariba {
-namespace interface {
-	class UnderlayAbstraction;
-}}
-
 namespace ariba {
 namespace communication {
@@ -67,5 +60,4 @@
 
 	friend class BaseCommunication;
-	friend class ariba::interface::UnderlayAbstraction;
 
 public:
Index: source/ariba/interface/AribaContext.cpp
===================================================================
--- source/ariba/interface/AribaContext.cpp	(revision 2995)
+++ 	(revision )
@@ -1,68 +1,0 @@
-// [Licence]
-// 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.
-// [Licence]
-
-#include "AribaContext.h"
-
-namespace ariba {
-namespace interface {
-
-AribaContext::AribaContext(BaseCommunication& _basecomm, BaseOverlay& _overlay,
-		const SpoVNetID& _spovnetid, const NodeID& _nodeid)
-	: basecomm( _basecomm ), overlay( _overlay ), spovnetid( _spovnetid ), nodeid( _nodeid ) {
-}
-
-AribaContext::~AribaContext() {
-}
-
-const SpoVNetID& AribaContext::getSpoVNetID() const {
-	return spovnetid;
-}
-
-const NodeID& AribaContext::getNodeID(void) const {
-	return nodeid;
-}
-
-BaseOverlay& AribaContext::getOverlay(){
-	return overlay;
-}
-
-BaseCommunication& AribaContext::getBaseCommunication() {
-	return basecomm;
-}
-
-}} // ariba, interface
Index: source/ariba/interface/AribaContext.h
===================================================================
--- source/ariba/interface/AribaContext.h	(revision 2995)
+++ 	(revision )
@@ -1,77 +1,0 @@
-// [Licence]
-// 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.
-// [Licence]
-
-#ifndef __ARIBA_CONTEXT_H
-#define __ARIBA_CONTEXT_H
-
-#include "ariba/utility/types/SpoVNetID.h"
-#include "ariba/utility/types/NodeID.h"
-#include "ariba/communication/BaseCommunication.h"
-#include "ariba/overlay/BaseOverlay.h"
-
-using ariba::utility::SpoVNetID;
-using ariba::utility::NodeID;
-using ariba::communication::BaseCommunication;
-using ariba::overlay::BaseOverlay;
-
-namespace ariba {
-namespace interface {
-
-class AribaContext {
-public:
-	AribaContext(BaseCommunication& _basecomm, BaseOverlay& _overlay,
-			const SpoVNetID& _spovnetid, const NodeID& _nodeid);
-	~AribaContext();
-
-	const SpoVNetID& getSpoVNetID() const;
-	const NodeID& getNodeID() const;
-
-	BaseOverlay& getOverlay();
-	BaseCommunication& getBaseCommunication();
-
-private:
-	SpoVNetID spovnetid;
-	NodeID nodeid;
-
-	BaseCommunication& basecomm;
-	BaseOverlay& overlay;
-};
-
-}} // ariba, interface
-
-#endif //__ARIBA_CONTEXT_H
Index: source/ariba/interface/ServiceInterface.cpp
===================================================================
--- source/ariba/interface/ServiceInterface.cpp	(revision 2995)
+++ source/ariba/interface/ServiceInterface.cpp	(revision 3037)
@@ -48,10 +48,4 @@
 }
 
-void ServiceInterface::onOverlayCreate( const SpoVNetID& id ){
-}
-
-void ServiceInterface::onOverlayDestroy( const SpoVNetID& id ){
-}
-
 bool ServiceInterface::isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ){
 	// default: allow all nodes to join
@@ -71,4 +65,10 @@
 }
 
+void ServiceInterface::onLeaveSuccess( const SpoVNetID& spovnetid ){
+}
+
+void ServiceInterface::onLeaveFail( const SpoVNetID& spovnetid ){
+}
+	
 void ServiceInterface::onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote ){
 }
Index: source/ariba/interface/ServiceInterface.h
===================================================================
--- source/ariba/interface/ServiceInterface.h	(revision 2995)
+++ source/ariba/interface/ServiceInterface.h	(revision 3037)
@@ -74,7 +74,4 @@
 
 protected:
-	virtual void onOverlayCreate( const SpoVNetID& id );
-	virtual void onOverlayDestroy( const SpoVNetID& id );
-
 	virtual bool isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid );
 	virtual void onNodeJoin( const NodeID& nodeid, const SpoVNetID& spovnetid );
@@ -83,4 +80,6 @@
 	virtual void onJoinSuccess( const SpoVNetID& spovnetid );
 	virtual void onJoinFail( const SpoVNetID& spovnetid );
+	virtual void onLeaveSuccess( const SpoVNetID& spovnetid );
+	virtual void onLeaveFail( const SpoVNetID& spovnetid );
 
 	virtual void onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote );
Index: source/ariba/interface/UnderlayAbstraction.cpp
===================================================================
--- source/ariba/interface/UnderlayAbstraction.cpp	(revision 2995)
+++ 	(revision )
@@ -1,108 +1,0 @@
-// [Licence]
-// 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.
-// [Licence]
-
-#include "UnderlayAbstraction.h"
-
-namespace ariba {
-namespace interface {
-
-use_logging_cpp(UnderlayAbstraction);
-
-UnderlayAbstraction::UnderlayAbstraction() : basecomm( NULL ) {
-}
-
-UnderlayAbstraction::~UnderlayAbstraction() {
-}
-
-AribaContext* UnderlayAbstraction::createNode(const SpoVNetID& spovnetid, const NodeID& nodeid, const NetworkLocator* locallocator, const uint16_t localport) {
-
-	logging_info( "creating node ...");
-
-	NodeID newid = nodeid;
-
-	if( nodeid == NodeID::UNSPECIFIED ){
-		logging_debug( "nodeid is unspecified, creating random ..." );
-		newid = NodeID( Identifier::random() );
-		logging_info( "local nodeid is " << newid.toString() );
-	}
-
-	basecomm = new BaseCommunication( locallocator, localport );
-
-	BaseOverlay* baseoverlay = new BaseOverlay( *basecomm, newid );
-	AribaContext* ctx = new AribaContext( *basecomm, *baseoverlay, spovnetid, newid );
-
-	logging_info( "spovnetid = " << ctx->getSpoVNetID().toString() <<
-			", nodeid = " << ctx->getNodeID().toString() );
-
-	return ctx;
-}
-
-AribaContext* UnderlayAbstraction::createSpoVNet(const SpoVNetID& spovnetid, const NodeID& nodeid, const NetworkLocator* locallocator, const uint16_t localport, const OverlayParameterSet& param, const SecurityParameterSet& sec, const QoSParameterSet& qos) {
-
-	// create new node
-	AribaContext* ctx = createNode( spovnetid, nodeid, locallocator, localport );
-
-	// create new base overlay (initiator)
-	logging_info("creating new spovnet...");
-	ctx->getOverlay().createSpoVNet( spovnetid, param, sec, qos );
-	logging_info("node created");
-
-	return ctx;
-}
-
-AribaContext* UnderlayAbstraction::joinSpoVNet(const SpoVNetID& spovnetid, const EndpointDescriptor& bootstrapnode, const NodeID& nodeid, const NetworkLocator* locallocator, const uint16_t localport) {
-
-	// create new node
-	AribaContext* ctx = createNode( spovnetid, nodeid, locallocator, localport );
-
-	// join spovnet
-	logging_info("joining existing spovnet...");
-	ctx->getOverlay().joinSpoVNet( spovnetid, bootstrapnode );
-	logging_info("node created");
-
-	return ctx;
-}
-
-void UnderlayAbstraction::leaveSpoVNet(AribaContext* ctx) {
-	ctx->getOverlay().leaveSpoVNet();
-	delete &ctx->getOverlay();
-	delete &ctx->getBaseCommunication();
-	delete ctx;
-}
-
-}} // namespace ariba, interface
Index: source/ariba/interface/UnderlayAbstraction.h
===================================================================
--- source/ariba/interface/UnderlayAbstraction.h	(revision 2995)
+++ 	(revision )
@@ -1,106 +1,0 @@
-// [Licence]
-// 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.
-// [Licence]
-
-#ifndef UNDERLAYABSTRACTION_H_
-#define UNDERLAYABSTRACTION_H_
-
-#include <string>
-#include "ariba/utility/types/OverlayParameterSet.h"
-#include "ariba/utility/types/SecurityParameterSet.h"
-#include "ariba/utility/types/QoSParameterSet.h"
-#include "ariba/utility/types/SpoVNetID.h"
-#include "ariba/interface/AribaContext.h"
-#include "ariba/communication/BaseCommunication.h"
-#include "ariba/overlay/BaseOverlay.h"
-
-using std::string;
-using ariba::utility::OverlayParameterSet;
-using ariba::utility::SecurityParameterSet;
-using ariba::utility::QoSParameterSet;
-using ariba::utility::SpoVNetID;
-using ariba::interface::AribaContext;
-using ariba::communication::BaseCommunication;
-using ariba::overlay::BaseOverlay;
-
-namespace ariba {
-namespace interface {
-
-#define ARIBA_DEFAULT_PORT 0xa1ba
-
-class UnderlayAbstraction {
-	use_logging_h( UnderlayAbstraction );
-public:
-	UnderlayAbstraction();
-	virtual ~UnderlayAbstraction();
-
-	AribaContext* createSpoVNet(
-		const SpoVNetID& spovnetid,
-		const NodeID& nodeid = NodeID::UNSPECIFIED,
-		const NetworkLocator* locallocator = NULL,
-		const uint16_t localport = ARIBA_DEFAULT_PORT,
-		const OverlayParameterSet& param = OverlayParameterSet::DEFAULT,
-		const SecurityParameterSet& sec  = SecurityParameterSet::DEFAULT,
-		const QoSParameterSet& qos = QoSParameterSet::DEFAULT
-	);
-
-	AribaContext* joinSpoVNet(
-		const SpoVNetID& spovnetid,
-		const EndpointDescriptor& bootstrapnode,
-		const NodeID& nodeid = NodeID::UNSPECIFIED,
-		const NetworkLocator* locallocator = NULL,
-		const uint16_t localport = ARIBA_DEFAULT_PORT
-	);
-
-	void leaveSpoVNet( AribaContext* ctx );
-
-protected:
-	AribaContext* createNode(
-		const SpoVNetID& spovnetid,
-		const NodeID& nodeid,
-		const NetworkLocator* locallocator,
-		const uint16_t localport
-	);
-
-private:
-	BaseCommunication* basecomm;
-
-};
-
-}} //namespace ariba, interface
-
-#endif //UNDERLAYABSTRACTION_H_
Index: source/ariba/overlay/BaseOverlay.cpp
===================================================================
--- source/ariba/overlay/BaseOverlay.cpp	(revision 2995)
+++ source/ariba/overlay/BaseOverlay.cpp	(revision 3037)
@@ -107,9 +107,10 @@
 
 	logging_info( "leaving spovnet " << spovnetId );
+	bool ret = ( state != this->BaseOverlayStateInvalid );
 
 	logging_debug( "dropping all auto-links ..." );
-	
+
 	BOOST_FOREACH( LinkPair item, linkMapping ){
-		if( item.second.autolink ) 
+		if( item.second.autolink )
 			dropLink( item.first );
 	}
@@ -135,5 +136,6 @@
 	// inform all registered services of the event
 	BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
-		i->onOverlayDestroy( spovnetId );
+		if( ret ) i->onLeaveSuccess( spovnetId );
+		else      i->onLeaveFail( spovnetId );
 	}
 }
@@ -159,13 +161,4 @@
 
 	//
-	// create the overlay
-	//
-
-	overlayInterface->createOverlay();
-	BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
-		i->onOverlayCreate( spovnetId );
-	}
-
-	//
 	// bootstrap against ourselfs
 	//
@@ -286,5 +279,5 @@
 				node.toString() << " for service " << service.toString() <<
 				". creating auto link ...");
-		
+
 		const LinkID link = establishLink( node, service );
 		LinkMapping::iterator i = linkMapping.find( link );
@@ -328,5 +321,5 @@
 	ServiceInterface* iface = listenerMux.get( sid );
 	listenerMux.unregisterItem( sid );
-	
+
 	return NULL; //iface;
 }
@@ -385,8 +378,8 @@
 				" on link " << id.toString() );
 
-		OverlayMsg overMsg( 
-			OverlayMsg::OverlayMessageTypeUpdate, 
-			i->second.service, 
-			nodeId 
+		OverlayMsg overMsg(
+			OverlayMsg::OverlayMessageTypeUpdate,
+			i->second.service,
+			nodeId
 			);
 
@@ -655,10 +648,4 @@
 
 		overlayInterface->createOverlay();
-
-		// inform all registered services of the event
-		BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
-			i->onOverlayCreate( spovnetId );
-		}
-
 		overlayInterface->joinOverlay( replyMsg->getBootstrapEndpoint() );
 
@@ -765,5 +752,5 @@
 			// inform all registered services of the event
 			BOOST_FOREACH( ServiceInterface* i, listenerMux.getOneList() ){
-				i->onOverlayDestroy( spovnetId );
+				i->onLeaveFail( spovnetId );
 			}
 
@@ -815,4 +802,15 @@
 		sendMessage( message, *i, service ); // TODO: sollte auto links aufbauen fÃŒr sowas
 	}
+}
+
+vector<NodeID> BaseOverlay::getOverlayNeighbors() const {
+	// the known nodes _can_ also include our
+	// node, so we remove ourselfs
+
+	vector<NodeID> nodes = overlayInterface->getKnownNodes();
+	vector<NodeID>::iterator i = find( nodes.begin(), nodes.end(), this->nodeId );
+	if( i != nodes.end() ) nodes.erase( i );
+
+	return nodes;
 }
 
Index: source/ariba/overlay/BaseOverlay.h
===================================================================
--- source/ariba/overlay/BaseOverlay.h	(revision 2995)
+++ source/ariba/overlay/BaseOverlay.h	(revision 3037)
@@ -44,4 +44,6 @@
 #include <algorithm>
 #include <ctime>
+#include <list>
+#include <vector>
 #include <boost/foreach.hpp>
 
@@ -66,8 +68,11 @@
 #include "ariba/overlay/messages/JoinReply.h"
 
+using std::vector;
+using std::list;
 using std::cout;
 using std::map;
 using std::make_pair;
 using std::pair;
+using std::find;
 
 using ariba::communication::EndpointDescriptor;
@@ -103,7 +108,6 @@
 // in different namespace
 namespace ariba {
-namespace interface {
-	class UnderlayAbstraction;
-}}
+	class Node;
+}
 
 namespace ariba {
@@ -117,5 +121,5 @@
 
 	use_logging_h( BaseOverlay );
-	friend class ariba::interface::UnderlayAbstraction;
+	friend class ariba::Node;
 
 public:
@@ -166,4 +170,9 @@
 		const ServiceID& service
 	);
+
+	/**
+	 * Get a list of overlay neighboring nodes.
+	 */
+	vector<NodeID> getOverlayNeighbors() const;
 
 	/**
@@ -324,7 +333,7 @@
 		static const LinkItem UNSPECIFIED;
 
-		LinkItem( const LinkID& _link, const NodeID& _node, 
+		LinkItem( const LinkID& _link, const NodeID& _node,
 				const ServiceID& _service, ServiceInterface* _interface )
-			: link( _link ), node( _node ), service( _service ), interface( _interface ), 
+			: link( _link ), node( _node ), service( _service ), interface( _interface ),
 				autolink( false ), lastuse( time(NULL) ) {
 		}
@@ -350,5 +359,5 @@
 	typedef pair<const LinkID,LinkItem> LinkPair;
 	LinkMapping linkMapping;
-	
+
 	// nodes with pending joines. TODO: should be cleaned every some seconds
 	// add timestamps to each, and check on occasion
Index: source/ariba/overlay/OverlayEvents.cpp
===================================================================
--- source/ariba/overlay/OverlayEvents.cpp	(revision 2995)
+++ source/ariba/overlay/OverlayEvents.cpp	(revision 3037)
@@ -48,10 +48,4 @@
 }
 
-void OverlayEvents::onOverlayCreate( const SpoVNetID& id ){
-}
-
-void OverlayEvents::onOverlayDestroy( const SpoVNetID& id ){
-}
-
 bool OverlayEvents::isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid ){
 	// default: allow all nodes to join
@@ -71,4 +65,10 @@
 }
 
+void OverlayEvents::onLeaveSuccess( const SpoVNetID& spovnetid ){
+}
+
+void OverlayEvents::onLeaveFail( const SpoVNetID& spovnetid ){
+}
+
 void OverlayEvents::onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote ){
 }
Index: source/ariba/overlay/OverlayEvents.h
===================================================================
--- source/ariba/overlay/OverlayEvents.h	(revision 2995)
+++ source/ariba/overlay/OverlayEvents.h	(revision 3037)
@@ -58,8 +58,4 @@
 
 protected:
-
-	virtual void onOverlayCreate( const SpoVNetID& id );
-	virtual void onOverlayDestroy( const SpoVNetID& id );
-
 	/// for initiator about remote nodes
 	virtual bool isJoinAllowed( const NodeID& nodeid, const SpoVNetID& spovnetid );
@@ -70,4 +66,6 @@
 	virtual void onJoinSuccess( const SpoVNetID& spovnetid );
 	virtual void onJoinFail( const SpoVNetID& spovnetid );
+	virtual void onLeaveSuccess( const SpoVNetID& spovnetid );
+	virtual void onLeaveFail( const SpoVNetID& spovnetid );
 
 	virtual void onLinkUp( const LinkID& link, const NodeID& local, const NodeID& remote );
Index: source/ariba/utility/messages/Message.h
===================================================================
--- source/ariba/utility/messages/Message.h	(revision 2995)
+++ source/ariba/utility/messages/Message.h	(revision 3037)
@@ -235,4 +235,16 @@
 		}
 		return NULL;
+	}
+	
+	/**
+	 * The same as decapsulate, but this function
+	 * is used in the samples to make the semantics easier
+	 * to understand. The semantics is shown to be: you get 
+	 * a message and convert it to your type. Not as: you 
+	 * get a message and have to extract your message from it.
+	 */  
+	template<class T>
+	inline T* convert() {
+		return decapsulate<T>();	
 	}
 
Index: source/ariba/utility/misc/Helper.cpp
===================================================================
--- source/ariba/utility/misc/Helper.cpp	(revision 2995)
+++ source/ariba/utility/misc/Helper.cpp	(revision 3037)
@@ -49,5 +49,5 @@
 	_ultoa_s (val, buf, 16, 10);
 #else
-	sprintf (buf, "%u", val);
+	sprintf (buf, "%lu", val);
 #endif
 
@@ -62,5 +62,5 @@
 	_ltoa_s (val, buf, 16, 10);
 #else
-	sprintf (buf, "%i", val);
+	sprintf (buf, "%li", val);
 #endif
 
@@ -75,5 +75,5 @@
 	_ultoa_s (val, buf, 16, 16);
 #else
-	sprintf (buf, "%x", val);
+	sprintf (buf, "%lx", val);
 #endif
 
@@ -93,5 +93,5 @@
 	_ltoa_s (val, buf, 16, 16);
 #else
-	sprintf (buf, "%x", val);
+	sprintf (buf, "%lx", val);
 #endif
 
Index: source/ariba/utility/system/StartupInterface.h
===================================================================
--- source/ariba/utility/system/StartupInterface.h	(revision 2995)
+++ source/ariba/utility/system/StartupInterface.h	(revision 3037)
@@ -45,11 +45,4 @@
 
 namespace ariba {
-namespace interface {
-	class UnderlayAbstraction;
-}}
-
-using ariba::interface::UnderlayAbstraction;
-
-namespace ariba {
 namespace utility {
 
