File Common/BaseOverlayMessage.msg

Contains:

//
// Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//

cplusplus {{
#include <OverlayKey.h>
#include <NodeHandle.h>

#define KEY_L OverlayKey::getLength()

static const int TYPE_L = 8;
static const int IPADDR_L = 32;
static const int UDPPORT_L = 16;
static const int HOPCOUNT_L = 16;
static const int NONCE_L = 32;
static const int NEIGHBORSFLAG_L = 8;
#define NODEHANDLE_L (IPADDR_L + UDPPORT_L + KEY_L)

#define BASEOVERLAY_L(msg) TYPE_L
#define BASEROUTE_L(msg) (BASEOVERLAY_L(msg) + NODEHANDLE_L + KEY_L + \
                          HOPCOUNT_L)
#define BASEAPPDATA_L(msg) BASEOVERLAY_L(msg)

#define BASERPC_L(msg) (BASEOVERLAY_L(msg) + NONCE_L + NODEHANDLE_L)
#define BASECALL_L(msg) BASERPC_L(msg)
#define BASERESPONSE_L(msg) BASERPC_L(msg)
#define FINDNODECALL_L(msg) (BASECALL_L(msg) + KEY_L)
#define FINDNODERESPONSE_L(msg) (BASERESPONSE_L(msg) + NEIGHBORSFLAG_L + \
                  (msg->getClosestNodesArraySize() * NODEHANDLE_L))
#define FAILEDNODECALL_L(msg) (BASECALL_L(msg) + IPADDR_L + UDPPORT_L)
#define FAILEDNODERESPONSE_L(msg) (BASERESPONSE_L(msg) + 8 * sizeof(bool))
#define PINGCALL_L(msg) BASECALL_L(msg)
#define PINGRESPONSE_L(msg) BASERESPONSE_L(msg)
}};

class noncobject OverlayKey;
class noncobject TransportAddress;
class noncobject NodeHandle;

enum BaseOverlayMessageType
{
	OVERLAYSIGNALING = 0;
	RPC = 1;
	APPDATA = 2;
	OVERLAYROUTE = 3;
};


//
// Base class for all messages handled by overlay modules
//
// @author Bernhard Heep
// @see ChordMessage
//
message BaseOverlayMessage {
  fields:
    int type enum(BaseOverlayMessageType) = OVERLAYSIGNALING;  // message type
    bool signaling = true;  // true if this is a signaling message
};

message BaseRouteMessage extends BaseOverlayMessage {
  fields:
    OverlayKey destKey;     // destination key
    NodeHandle srcNode;     // source node
    int hopCount = 0;       // hop count, increased by BaseOverlay
};

message BaseAppDataMessage extends BaseOverlayMessage {
};

//
// A basic Remote-Procedure-Call message used for calls and return values
//
message BaseRpcMessage extends BaseOverlayMessage {
  fields:
    unsigned int nonce;  // nonce to match RPC responses to corresponding calls
    NodeHandle srcNode;  // source node	   
};

//
// A basic Remote-Procedure-Call message
//
message BaseCallMessage extends BaseRpcMessage {
};

//
// A basic Remote-Procedure-Response message
//
message BaseResponseMessage extends BaseRpcMessage {
};

//
// The RPC Timeout self-message
//
message RpcTimeoutMessage extends BaseRpcMessage {
};

//
// A basic find node rpc response
//
message FindNodeCall extends BaseCallMessage {
  fields:
    OverlayKey lookupKey;   // request nextHops for this key
    int numRedundantNodes;  // number of redundant nodes to return
    int numSiblings;        // number of siblings to return
};

//
// A basic find node rpc call
//
message FindNodeResponse extends BaseResponseMessage {
  fields:
    // the closestNodes[] vector contains all sibling for the lookup key
    bool siblings; 
    NodeHandle closestNodes[];  // vector of known next hops to the lookup key
};

//
// A basic failed node notification
//
message FailedNodeCall extends BaseCallMessage {
fields:
    TransportAddress failedNode;
};

//
// A basic failed node response
//
message FailedNodeResponse extends BaseResponseMessage {
fields:
    bool tryAgain;
};

//
// A basic ping rpc call
//
message PingCall extends BaseCallMessage {
};

//
// A basic ping response
//
message PingResponse extends BaseResponseMessage {
};