Index: source/ariba/overlay/messages/OverlayMsg.h
===================================================================
--- source/ariba/overlay/messages/OverlayMsg.h	(revision 10653)
+++ source/ariba/overlay/messages/OverlayMsg.h	(revision 12060)
@@ -47,6 +47,6 @@
 #include "ariba/utility/types/NodeID.h"
 #include "ariba/utility/types/LinkID.h"
-#include "ariba/communication/EndpointDescriptor.h"
-
+// #include <ariba/utility/misc/sha1.h>
+#include "ariba/overlay/SequenceNumber.h"
 
 namespace ariba {
@@ -57,5 +57,5 @@
 using ariba::utility::ServiceID;
 using ariba::utility::Message;
-using ariba::communication::EndpointDescriptor;
+//using ariba::communication::EndpointDescriptor;
 using_serialization;
 
@@ -64,5 +64,5 @@
  * between nodes.
  *
- * @author Sebastian Mies <mies@tm.uka.de>
+ * @author Sebastian Mies <mies@tm.uka.de>, Mario Hock
  */
 class OverlayMsg: public Message { VSERIALIZEABLE;
@@ -75,4 +75,5 @@
 		maskTransfer    = 0x10, ///< bit mask for transfer messages
 		typeData        = 0x11, ///< message contains data for higher layers
+		typeMessageLost = 0x12, ///< message contains info about a dropped message
 
 		// join signaling
@@ -87,5 +88,7 @@
 		typeLinkUpdate  = 0x33, ///< update message for link association
 		typeLinkDirect  = 0x34, ///< direct connection has been established
-		typeLinkAlive   = 0x35, ///< keep-alive message
+		typeKeepAlive   = 0x35, ///< keep-alive message
+		typeKeepAliveReply   = 0x36, ///< keep-alive message (replay)
+		typeLinkClose   = 0x37,
 
 		/// DHT routed messages
@@ -100,4 +103,8 @@
 		maskDHTResponse = 0x50, ///< bit mask for dht responses
 		typeDHTData     = 0x51, ///< DHT get data
+        
+        /// misc message types
+        typePing        = 0x44,
+        typePong        = 0x45,
 
 		// topology signaling
@@ -105,4 +112,17 @@
 		typeSignalingEnd = 0xFF    ///< end of the signaling types
 	};
+    
+    /// message flags (uint8_t)
+    enum flags_
+    {
+        flagRelayed         = 1 << 0,
+        flagRegisterRelay   = 1 << 1,
+        flagRouteRecord     = 1 << 2,
+        flagSeqNum1         = 1 << 3,
+        flagSeqNum2         = 1 << 4,
+        flagAutoLink        = 1 << 5,
+        flagLinkMessage     = 1 << 6,
+        flagHasMoreFlags    = 1 << 7
+    };
 
 	/// default constructor
@@ -114,5 +134,5 @@
 		const LinkID& _sourceLink      = LinkID::UNSPECIFIED,
 		const LinkID& _destinationLink = LinkID::UNSPECIFIED )
-	:	type(type), flags(0), hops(0), ttl(10),
+    :	type(type), flags(0), extended_flags(0), hops(0), ttl(10), priority(0),
 		service(_service),
 		sourceNode(_sourceNode), destinationNode(_destinationNode),
@@ -125,6 +145,7 @@
 	// copy constructor
 	OverlayMsg(const OverlayMsg& rhs)
-	:	type(rhs.type), flags(rhs.flags), hops(rhs.hops), ttl(rhs.ttl),
-		service(rhs.service),
+    :	type(rhs.type), flags(rhs.flags), extended_flags(rhs.extended_flags), 
+        hops(rhs.hops), ttl(rhs.ttl),
+		priority(rhs.priority), service(rhs.service),
 		sourceNode(rhs.sourceNode), destinationNode(rhs.destinationNode),
 		sourceLink(rhs.sourceLink), destinationLink(rhs.destinationLink),
@@ -149,53 +170,59 @@
 	}
 
+	/// priority ------------------------------------------------------------------
+	
+	uint8_t getPriority() const {
+	    return priority;
+	}
+	
+	void setPriority(uint8_t priority) {
+	    this->priority = priority;
+	}
+	
 	/// flags ------------------------------------------------------------------
 
 	bool isRelayed() const {
-		return (flags & 0x01)!=0;
+        return (flags & flagRelayed)!=0;
 	}
 
 	void setRelayed( bool relayed = true ) {
-		if (relayed) flags |= 1; else flags &= ~1;
+        if (relayed) flags |= flagRelayed; else flags &= ~flagRelayed;
 	}
 
 	bool isRegisterRelay() const {
-		return (flags & 0x02)!=0;
+		return (flags & flagRegisterRelay)!=0;
 	}
 
 	void setRegisterRelay( bool relayed = true ) {
-		if (relayed) flags |= 0x02; else flags &= ~0x02;
+        if (relayed) flags |= flagRegisterRelay; else flags &= ~flagRegisterRelay;
 	}
 
 	bool isRouteRecord() const {
-		return (flags & 0x04)!=0;
+		return (flags & flagRouteRecord)!=0;
 	}
 
 	void setRouteRecord( bool route_record = true ) {
-		if (route_record) flags |= 0x04; else flags &= ~0x04;
+        if (route_record) flags |= flagRouteRecord; else flags &= ~flagRouteRecord;
 	}
 
 	bool isAutoLink() const {
-		return (flags & 0x80) == 0x80;
+        return (flags & flagAutoLink) == flagAutoLink;
 	}
 
 	void setAutoLink(bool auto_link = true ) {
-		if (auto_link) flags |= 0x80; else flags &= ~0x80;
+        if (auto_link) flags |= flagAutoLink; else flags &= ~flagAutoLink;
 	}
 
 	bool isLinkMessage() const {
-		return (flags & 0x40)!=0;
+		return (flags & flagLinkMessage)!=0;
 	}
 
 	void setLinkMessage(bool link_info = true ) {
-		if (link_info) flags |= 0x40; else flags &= ~0x40;
-	}
-
-	bool containsSourceEndpoint() const {
-		return (flags & 0x20)!=0;
-	}
-
-	void setContainsSourceEndpoint(bool contains_endpoint) {
-		if (contains_endpoint) flags |= 0x20; else flags &= ~0x20;
-	}
+        if (link_info) flags |= flagLinkMessage; else flags &= ~flagLinkMessage;
+	}
+	
+	bool hasExtendedFlags() const {
+        return (flags & flagHasMoreFlags) == flagHasMoreFlags;
+    }
 
 	/// number of hops and time to live ----------------------------------------
@@ -264,13 +291,4 @@
 		this->destinationLink = link;
 		setLinkMessage();
-	}
-
-	void setSourceEndpoint( const EndpointDescriptor& endpoint ) {
-		sourceEndpoint = endpoint;
-		setContainsSourceEndpoint(true);
-	}
-
-	const EndpointDescriptor& getSourceEndpoint() const {
-		return sourceEndpoint;
 	}
 
@@ -284,4 +302,5 @@
 		destinationLink = dummyLink;
 		hops = 0;
+		routeRecord.clear();
 	}
 
@@ -294,7 +313,48 @@
 			routeRecord.push_back(node);
 	}
+	
+	/// sequence numbers
+	bool hasShortSeqNum() const
+    {
+        return (flags & (flagSeqNum1 | flagSeqNum2)) == flagSeqNum1;
+    }
+    
+    bool hasLongSeqNum() const
+    {
+        return (flags & (flagSeqNum1 | flagSeqNum2)) == flagSeqNum2;
+    }
+    
+    void setSeqNum(const SequenceNumber& sequence_number)
+    {
+        this->seqnum = sequence_number;
+        
+        // short seqnum
+        if ( sequence_number.isShortSeqNum() )
+        {
+            flags |= flagSeqNum1;
+            flags &= ~flagSeqNum2;
+        }
+        // longseqnum
+        else if ( sequence_number.isShortSeqNum() )
+        {
+            flags &= ~flagSeqNum1;
+            flags |= flagSeqNum2;
+        }
+        // no seqnum
+        else
+        {
+            flags &= ~flagSeqNum1;
+            flags &= ~flagSeqNum2;
+        }
+    }
+    
+    const SequenceNumber& getSeqNum() const
+    {
+        return seqnum;
+    }
+    
 
 private:
-	uint8_t type, flags, hops, ttl;
+	uint8_t type, flags, extended_flags, hops, ttl, priority;
 	ServiceID service;
 	NodeID sourceNode;
@@ -302,6 +362,7 @@
 	LinkID sourceLink;
 	LinkID destinationLink;
-	EndpointDescriptor sourceEndpoint;
+//	EndpointDescriptor sourceEndpoint;
 	vector<NodeID> routeRecord;
+    SequenceNumber seqnum;
 };
 
@@ -311,8 +372,16 @@
 sznBeginDefault( ariba::overlay::OverlayMsg, X ){
 	// header
-	X && type && flags && hops && ttl;
+	X && type && flags;
+    
+    if ( hasExtendedFlags() )
+        X && extended_flags;
+    
+    X && hops && ttl;
 
 	// addresses
 	X && &service && &sourceNode && &destinationNode;
+	
+	// priority
+	X && priority;
 
 	// message is associated with a end-to-end link
@@ -320,8 +389,40 @@
 		X && &sourceLink && &destinationLink;
 
-	// message is associated with a source end-point
-	if (containsSourceEndpoint())
-		X && sourceEndpoint;
-
+    
+    /* seqnum */
+    // serialize
+    if ( X.isSerializer() )
+    {
+        if ( hasShortSeqNum() )
+        {
+            uint32_t short_seqnum;
+            short_seqnum = seqnum.getShortSeqNum();
+            X && short_seqnum;
+        }
+        if ( hasLongSeqNum() )
+        {
+            uint64_t long_seqnum;
+            long_seqnum = seqnum.getLongSeqNum();
+            X && long_seqnum;
+        }
+    }
+    // deserialize
+    else
+    {
+        if ( hasShortSeqNum() )
+        {
+            uint32_t short_seqnum;
+            X && short_seqnum;
+            seqnum = ariba::overlay::SequenceNumber(short_seqnum);
+        }
+        if ( hasLongSeqNum() )
+        {
+            uint64_t long_seqnum;
+            X && long_seqnum;
+            seqnum = ariba::overlay::SequenceNumber(long_seqnum);
+        }        
+    }
+    
+    
 	// message should record its route
 	if (isRouteRecord()) {
@@ -333,5 +434,5 @@
 
 	// payload
-	X && Payload();
+//	X && Payload();
 } sznEnd();
 
