Index: source/ariba/Node.h
===================================================================
--- source/ariba/Node.h	(revision 10653)
+++ source/ariba/Node.h	(revision 12060)
@@ -43,12 +43,16 @@
 namespace ariba {
 	class Node;
-	namespace overlay {
-		class BaseOverlay;
-	}
+    namespace communication {
+        class BaseCommunication;
+    }
+    namespace overlay {
+        class BaseOverlay;
+    }
 }
 
 #include <vector>
 #include <iostream>
-#include <boost/foreach.hpp>
+#include <exception>
+
 #include "Module.h"
 #include "Identifiers.h"
@@ -56,8 +60,14 @@
 #include "NodeListener.h"
 #include "Name.h"
-#include "AribaModule.h"
+//#include "AribaModule.h"
 #include "CommunicationListener.h"
 #include "DataMessage.h"
 #include "SideportListener.h"
+#include "ariba/overlay/SequenceNumber.h"
+
+// reboost messages
+#include "ariba/utility/transport/messages/message.hpp"
+
+#include <boost/property_tree/ptree.hpp>
 
 using std::vector;
@@ -65,4 +75,23 @@
 
 namespace ariba {
+
+// typedef ariba::overlay::SequenceNumber SequenceNumber; // XXX see CommunicationListener
+
+using boost::property_tree::ptree;
+
+// sendMessage-Priorities
+struct send_priority
+{
+    enum SEND_PRIORITY
+    {
+        HIGHEST = 2,
+        HIGHER = 3,
+        NORMAL = 4,
+        LOWER = 5,
+        LOWEST = 6
+    };
+};
+
+
 
 /**
@@ -75,6 +104,8 @@
  * @author Christoph Mayer <mayer@tm.uka.de>
  */
+// TODO do we really want to inherit from Module.. ?
 class Node: public Module {
 public:
+    
 	/**
 	 * Constructs a new node using a given ariba module
@@ -86,5 +117,8 @@
 	 *   is a zero-terminated char-string.
 	 */
-	Node(AribaModule& ariba_mod, const Name& node_name = Name::UNSPECIFIED);
+//	Node(AribaModule& ariba_mod, const Name& node_name = Name::UNSPECIFIED);
+	
+	// XXX EXPERIMENTAL
+	Node();
 
 	/**
@@ -100,4 +134,12 @@
 	//--- node control ---
 
+    /**
+     * XXX EXPERIMENTAL
+     * 
+     * Replaces initialte & join
+     */
+    void connect(const ptree& config);
+
+    // XXX DEPRECATED
 	/**
 	 * This method instructs the node to join a particular spovnet.
@@ -107,5 +149,5 @@
 	 * @param vnetId The SpoVNet name
 	 */
-	void join(const Name& name);
+//	void join(const Name& name);
 
 	/**
@@ -116,6 +158,6 @@
 	 * @param param The SpoVNet properties
 	 */
-	void initiate(const Name& name, const SpoVNetProperties& parm =
-			SpoVNetProperties::DEFAULT);
+//	void initiate(const Name& name, const SpoVNetProperties& parm =
+//			SpoVNetProperties::DEFAULT);
 
 	/**
@@ -221,51 +263,108 @@
 	void dropLink(const LinkID& lnk);
 
-	// message sending
-
-	/**
-	 * Sends a one-shot message to a service. If link properties are specified,
-	 * the node tries to fulfill those requirements. This may cause the node
-	 * to first establish a temporary link, second sending the message and last
-	 * dropping the link. This would result in a small amount of extra latency
-	 * until the message is delivered. If reliable transport was selected,
-	 * the method returns a sequence number and a communication event is
-	 * triggered on message delivery or loss.
-	 *
-	 * @param msg The message to be sent
-	 * @param nid The remote node identifier
-	 * @param sid The remote service identifier
-	 * @param req The requirements associated with the message
-	 * @return A sequence number
-	 */
+	/**
+	 * Returns whether a link is direct or relayed over other nodes
+	 * @param lnk LinkID of the link
+	 * @return true if link is direct; false otherwise
+	 */
+	bool isLinkDirect(const ariba::LinkID& lnk) const;
+	
+	/**
+	 * Returns the latest measured hop count on this link.
+	 * NOTE: This is not guaranteed to be up to date.
+	 * 
+	 * @param lnk LinkID of the link
+	 * @return overlay hop count on this link 
+	 */
+	int getHopCount(const ariba::LinkID& lnk) const;
+	
+	
+	/* +++++ Message sending +++++ */
+
+	
+    /**
+     * Sends a message via an established link. If reliable transport was
+     * selected, the method returns a sequence number and a communication event
+     * is triggered on message delivery or loss.
+     * 
+     * +++ New interface, using efficient zero-copy reboost messages. +++
+     *
+     * @param msg The message to be sent
+     * @param lnk The link to be used for sending the message
+     */
+    const SequenceNumber& sendMessage(reboost::message_t msg, const LinkID& lnk, uint8_t priority=send_priority::NORMAL);
+
+    /**
+     * +++ Legacy interface, converts old ariba messages into new reboost messages. +++
+     */    
+    seqnum_t sendMessage(const DataMessage& msg, const LinkID& lnk);
+
+    
+    /**
+     * Sends a one-shot message to a service. If link properties are specified,
+     * the node tries to fulfill those requirements. This may cause the node
+     * to first establish a temporary link, second sending the message and last
+     * dropping the link. This would result in a small amount of extra latency
+     * until the message is delivered. If reliable transport was selected,
+     * the method returns a sequence number and a communication event is
+     * triggered on message delivery or loss.
+     * 
+     * +++ New interface, using efficient zero-copy reboost messages. +++
+     *
+     * @param msg The message to be sent
+     * @param nid The remote node identifier
+     * @param sid The remote service identifier
+     * @param req The requirements associated with the message
+     * @return A sequence number
+     */
+    const SequenceNumber& sendMessage(reboost::message_t msg, const NodeID& nid, const ServiceID& sid,
+            uint8_t priority=send_priority::NORMAL, const LinkProperties& req = LinkProperties::DEFAULT);
+
+    /**
+     * +++ Legacy interface, converts old ariba messages into new reboost messages. +++
+     */
 	seqnum_t sendMessage(const DataMessage& msg, const NodeID& nid, const ServiceID& sid,
 			const LinkProperties& req = LinkProperties::DEFAULT);
 
-	/**
-	 * like the above function, but sends the message to the closest directly known node
-	 * to the specified address
-	 */
+    
+    /**
+     * like the above function, but sends the message to the closest directly known node
+     * to the specified address
+     * 
+     * +++ New interface, using efficient zero-copy reboost messages. +++
+     * 
+     */
+    NodeID sendMessageCloserToNodeID(reboost::message_t msg, const NodeID& nid, const ServiceID& sid,
+            uint8_t priority=send_priority::NORMAL, const LinkProperties& req = LinkProperties::DEFAULT);
+
+    /**
+     * +++ Legacy interface, converts old ariba messages into new reboost messages. +++
+     */
     NodeID sendMessageCloserToNodeID(const DataMessage& msg, const NodeID& nid, const ServiceID& sid,
             const LinkProperties& req = LinkProperties::DEFAULT);
 
-	/**
-	 * Sends a message via an established link. If reliable transport was
-	 * selected, the method returns a sequence number and a communication event
-	 * is triggered on message delivery or loss.
-	 *
-	 * @param msg The message to be sent
-	 * @param lnk The link to be used for sending the message
-	 */
-	seqnum_t sendMessage(const DataMessage& msg, const LinkID& lnk);
-
-	/**
-	 * Sends a message to all known hosts in the overlay structure
-	 * the nodes that are reached here depend on the overlay structure.
-	 *
-	 * @param msg The message to be send
-	 * @param sid The id of the service that should receive the message
-	 * @see getNeighborNodes
-	 */
+	
+    /**
+     * Sends a message to all known hosts in the overlay structure
+     * the nodes that are reached here depend on the overlay structure.
+     *
+     * +++ New interface, using efficient zero-copy reboost messages. +++
+     *
+     * @param msg The message to be send
+     * @param sid The id of the service that should receive the message
+     * @see getNeighborNodes
+     */
+	void sendBroadcastMessage(reboost::message_t msg, const ServiceID& sid, uint8_t priority=send_priority::NORMAL);
+
+    /**
+     * +++ Legacy interface, converts old ariba messages into new reboost messages. +++
+     */
 	void sendBroadcastMessage(const DataMessage& msg, const ServiceID& sid);
 
+	
+	/* +++++ [Message sending] +++++ */
+	
+	
+	
 	// --- communication listeners ---
 
@@ -313,5 +412,10 @@
 	/** @see Module.h */
 	string getName() const;
-
+	
+	
+private:
+	inline void check_send_priority(uint8_t priority);
+
+	
 protected:
 	// friends
@@ -320,7 +424,8 @@
 	// member variables
 	Name name;                             //< node name
-	AribaModule& ariba_mod;	               //< ariba module
+//	AribaModule* ariba_mod;	               //< ariba module
 	SpoVNetID spovnetId; 	               //< current spovnet id
 	NodeID nodeId; 		              	   //< current node id
+	communication::BaseCommunication* base_communication;
 	overlay::BaseOverlay* base_overlay;    //< the base overlay
 
