-remove trailing whitespace
[oweals/gnunet.git] / src / testbed / testbed.h
index 3c096399a394b9ebb66a080061c28277b90a21bf..cb39cc993534028d44ae9145ffe21f8e1f16448c 100644 (file)
@@ -1,6 +1,6 @@
 /*
       This file is part of GNUnet
-      (C) 2012 Christian Grothoff (and other contributing authors)
+      (C) 2008--2013 Christian Grothoff (and other contributing authors)
 
       GNUnet is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
  * @author Christian Grothoff
  */
 
-#ifndef NEW_TESTING_H
-#define NEW_TESTING_H
+#ifndef TESTBED_H
+#define TESTBED_H
 
 #include "gnunet_util_lib.h"
 
-
+GNUNET_NETWORK_STRUCT_BEGIN
 /**
  * Initial message from a client to a testing control service.
  */
-struct GNUNET_TESTBED_Message
+struct GNUNET_TESTBED_InitMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_INIT
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_INIT
    */
   struct GNUNET_MessageHeader header;
 
   /**
    * Host ID that the controller is either given (if this is the
    * dominating client) or assumed to have (for peer-connections
-   * between controllers).  A controller must check that all 
+   * between controllers).  A controller must check that all
    * connections make consistent claims...
    */
   uint32_t host_id GNUNET_PACKED;
@@ -55,6 +55,7 @@ struct GNUNET_TESTBED_Message
    */
   uint64_t event_mask GNUNET_PACKED;
 
+  /* Followed by 0-terminated hostname of the controller */
 };
 
 
@@ -65,7 +66,7 @@ struct GNUNET_TESTBED_AddHostMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST
    */
   struct GNUNET_MessageHeader header;
 
@@ -84,11 +85,26 @@ struct GNUNET_TESTBED_AddHostMessage
    * 0 to use no user name; otherwise 'strlen (username)',
    * excluding 0-termination!
    */
-  uint16_t user_name_length GNUNET_PACKED;
+  uint16_t username_length GNUNET_PACKED;
+
+  /**
+   * Number of bytes in the host name (excluding 0-termination) that follows the
+   * user name; cannot be 0
+   */
+  uint16_t hostname_length GNUNET_PACKED;
+
+  /**
+   * The length of the uncompressed configuration
+   */
+  uint16_t config_size GNUNET_PACKED;
+
+  /* followed by non 0-terminated user name */
 
-  /* followed by 0-terminated user name */
+  /* followed by non 0-terminated host name */
 
-  /* followed by 0-terminated host name */
+  /* followed by gzip compressed configuration to start or connect to a
+     controller on this host.  While starting the controller this configration
+     is used as a template */
 
 };
 
@@ -96,12 +112,13 @@ struct GNUNET_TESTBED_AddHostMessage
 /**
  * Confirmation from the service that adding a host
  * worked (or failed).
+ * FIXME: Where is this required?
  */
 struct GNUNET_TESTBED_HostConfirmedMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTSUCCESS
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_ADD_HOST_SUCCESS
    */
   struct GNUNET_MessageHeader header;
 
@@ -110,85 +127,94 @@ struct GNUNET_TESTBED_HostConfirmedMessage
    */
   uint32_t host_id GNUNET_PACKED;
 
-  /* followed by the 0-terminated error message (on failure) 
-   (typical errors include failure to login and 
-   host-id already in use) */
+  /* followed by the 0-terminated error message (on failure)
+   * (typical errors include host-id already in use) */
 
 };
 
 
 /**
- * Message to testing service: configure service sharing
- * at a host.
+ * Client notifies controller that it should delegate
+ * requests for a particular client to a particular
+ * sub-controller.
  */
-struct GNUNET_TESTBED_ConfigureSharedServiceMessage
+struct GNUNET_TESTBED_ControllerLinkRequest
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * Host that is being configured.
+   * For which host should requests be delegated? NBO.
    */
-  uint32_t host_id GNUNET_PACKED;
+  uint32_t delegated_host_id GNUNET_PACKED;
 
   /**
-   * Number of peers that should share a service instance;
-   * 1 for no sharing, 0 to forcefully disable the service.
+   * The id of the operation which created this message
    */
-  uint32_t num_peers GNUNET_PACKED;
+  uint64_t operation_id GNUNET_PACKED;
 
-  /* followed by 0-terminated name of the service */
+  /**
+   * Which host is responsible for managing the delegation? NBO
+   */
+  uint32_t slave_host_id GNUNET_PACKED;
+
+  /**
+   * Set to 1 if the receiving controller is the master controller for
+   * the slave host (and thus responsible for starting it?). 0 if not
+   */
+  uint8_t is_subordinate;
 
 };
 
 
 /**
- * Client notifies controller that it should delegate
- * requests for a particular client to a particular
- * sub-controller.
+ * Response message for ControllerLinkRequest message
  */
-struct GNUNET_TESTBED_ControllerLinkMessage
+struct GNUNET_TESTBED_ControllerLinkResponse
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_LINK_CONTROLLERS_RESULT
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * For which host should requests be delegated? NBO.
+   * The size of the compressed configuration. Can be ZERO if the controller is
+   * not started (depends on the ControllerLinkRequest). NBO.
    */
-  uint32_t delegated_host_id GNUNET_PACKED;
+  uint16_t config_size GNUNET_PACKED;
 
   /**
-   * Which host is responsible for managing the delegation? NBO
+   * Set to GNUNET_YES to signify SUCCESS; GNUNET_NO to signify failure
    */
-  uint32_t slave_host_id GNUNET_PACKED;
+  uint16_t success GNUNET_PACKED;
 
   /**
-   * Is the receiving controller the master controller for
-   * the slave host (and thus responsible for starting it?). NBO.
+   * The id of the operation which created this message. NBO
    */
-  int32_t is_subordinate GNUNET_PACKED;
+  uint64_t operation_id GNUNET_PACKED;
+
+  /* If controller linking is successful and configuration is present, then here
+   * comes the serialized gzip configuration with which the controller is
+   * running at the delegate host */
 
-  /* followed by serialized slave configuration;
-     gzip'ed configuration file in INI format */
+  /* In case of failure, here comes the error message (without \0 termination)*/
 
 };
 
 
 /**
- * Message sent from client to testing service to 
+ * Message sent from client to testing service to
  * create (configure, but not start) a peer.
  */
 struct GNUNET_TESTBED_PeerCreateMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER
    */
   struct GNUNET_MessageHeader header;
 
@@ -197,26 +223,36 @@ struct GNUNET_TESTBED_PeerCreateMessage
    */
   uint32_t host_id GNUNET_PACKED;
 
+  /**
+   * Unique operation id
+   */
+  uint64_t operation_id GNUNET_PACKED;
+
   /**
    * Unique ID for the peer.
    */
   uint32_t peer_id GNUNET_PACKED;
 
+  /**
+   * Size of the uncompressed configuration
+   */
+  uint16_t config_size GNUNET_PACKED;
+
   /* followed by serialized peer configuration;
-     gzip'ed configuration file in INI format */
-  
+   * gzip'ed configuration file in INI format */
+
 };
 
 
 /**
- * Message sent from client to testing service to 
+ * Message sent from client to testing service to
  * reconfigure a (stopped) a peer.
  */
 struct GNUNET_TESTBED_PeerReconfigureMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPDE_TESTBED_PEERRECONF
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER
    */
   struct GNUNET_MessageHeader header;
 
@@ -230,9 +266,14 @@ struct GNUNET_TESTBED_PeerReconfigureMessage
    */
   uint64_t operation_id GNUNET_PACKED;
 
+  /**
+   * The length of the serialized configuration when uncompressed
+   */
+  uint16_t config_size GNUNET_PACKED;
+
   /* followed by serialized peer configuration;
-     gzip'ed configuration file in INI format */
-  
+   * gzip'ed configuration file in INI format */
+
 };
 
 
@@ -244,7 +285,7 @@ struct GNUNET_TESTBED_PeerStartMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_STARTPEER
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_START_PEER
    */
   struct GNUNET_MessageHeader header;
 
@@ -269,7 +310,7 @@ struct GNUNET_TESTBED_PeerStopMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER
    */
   struct GNUNET_MessageHeader header;
 
@@ -294,7 +335,7 @@ struct GNUNET_TESTBED_PeerDestroyMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER
    */
   struct GNUNET_MessageHeader header;
 
@@ -319,7 +360,7 @@ struct GNUNET_TESTBED_ConfigureUnderlayLinkMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_CONFIGULLINK
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_CONFIGURE_UNDERLAY_LINK
    */
   struct GNUNET_MessageHeader header;
 
@@ -356,7 +397,7 @@ struct GNUNET_TESTBED_OverlayConnectMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT
    */
   struct GNUNET_MessageHeader header;
 
@@ -375,6 +416,47 @@ struct GNUNET_TESTBED_OverlayConnectMessage
    */
   uint32_t peer2 GNUNET_PACKED;
 
+  /**
+   * The ID of the host which runs peer2
+   */
+  uint32_t peer2_host_id GNUNET_PACKED;
+
+};
+
+
+/**
+ * Message sent from host controller of a peer(A) to the host controller of
+ * another peer(B) to request B to connect to A
+ */
+struct GNUNET_TESTBED_RemoteOverlayConnectMessage
+{
+  /**
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * The Unique ID of B
+   */
+  uint32_t peer GNUNET_PACKED;
+
+  /**
+   * The Operation ID that is used to identify this operation
+   */
+  uint64_t operation_id GNUNET_PACKED;
+
+  /**
+   * Identity of A
+   */
+  struct GNUNET_PeerIdentity peer_identity;
+
+  /**
+   * To be followed by the HELLO message of A
+   */
+  struct GNUNET_MessageHeader hello[0];
+  // FIXME: we usually do not use this gcc-hack as some
+  // compilers / tools really get messed up by it...
+
 };
 
 
@@ -385,16 +467,16 @@ struct GNUNET_TESTBED_PeerEventMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_PEER_EVENT
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * 'enum GNUNET_TESTBED_EventType' (in NBO);
-   * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP.
+   * `enum GNUNET_TESTBED_EventType` (in NBO);
+   * either #GNUNET_TESTBED_ET_PEER_START or #GNUNET_TESTBED_ET_PEER_STOP.
    */
   int32_t event_type GNUNET_PACKED;
-  
+
   /**
    * Host where the peer is running.
    */
@@ -420,16 +502,16 @@ struct GNUNET_TESTBED_ConnectionEventMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT
    */
   struct GNUNET_MessageHeader header;
 
   /**
    * 'enum GNUNET_TESTBED_EventType' (in NBO);
-   * either GNUNET_TESTBED_ET_PEER_CONNECT or GNUNET_TESTBED_ET_PEER_DISCONNECT.
+   * either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCONNECT.
    */
   int32_t event_type GNUNET_PACKED;
-  
+
   /**
    * First peer.
    */
@@ -455,7 +537,7 @@ struct GNUNET_TESTBED_OperationFailureEventMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONEVENT
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT
    */
   struct GNUNET_MessageHeader header;
 
@@ -464,7 +546,7 @@ struct GNUNET_TESTBED_OperationFailureEventMessage
    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
    */
   int32_t event_type GNUNET_PACKED;
-  
+
   /**
    * Operation ID of the operation that created this event.
    */
@@ -482,7 +564,7 @@ struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER_SUCCESS
    */
   struct GNUNET_MessageHeader header;
 
@@ -490,7 +572,7 @@ struct GNUNET_TESTBED_PeerCreateSuccessEventMessage
    * Peer identity of the peer that was created.
    */
   uint32_t peer_id GNUNET_PACKED;
-  
+
   /**
    * Operation ID of the operation that created this event.
    */
@@ -508,7 +590,7 @@ struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_GENERIC_OPERATION_SUCCESS
    */
   struct GNUNET_MessageHeader header;
 
@@ -517,7 +599,7 @@ struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
    * GNUNET_TESTBED_ET_OPERATION_FINISHED.
    */
   int32_t event_type GNUNET_PACKED;
-  
+
   /**
    * Operation ID of the operation that created this event.
    */
@@ -526,17 +608,15 @@ struct GNUNET_TESTBED_GenericOperationSuccessEventMessage
 };
 
 
-
-
 /**
- * Message sent from client to testing service to 
+ * Message sent from client to testing service to
  * obtain the configuration of a peer.
  */
 struct GNUNET_TESTBED_PeerGetConfigurationMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION
    */
   struct GNUNET_MessageHeader header;
 
@@ -553,23 +633,22 @@ struct GNUNET_TESTBED_PeerGetConfigurationMessage
 };
 
 
-
 /**
- * Event notification from a controller to a client.
+ * Peer configuration and identity reply from controller to a client.
  */
 struct GNUNET_TESTBED_PeerConfigurationInformationMessage
 {
 
   /**
-   * Type is GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG
+   * Type is #GNUNET_MESSAGE_TYPE_TESTBED_PEER_INFORMATION
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * Peer number of the peer that was created.
+   * The id of the peer relevant to this information
    */
-  uint32_t peer_number GNUNET_PACKED;
-  
+  uint32_t peer_id GNUNET_PACKED;
+
   /**
    * Operation ID of the operation that created this event.
    */
@@ -578,10 +657,216 @@ struct GNUNET_TESTBED_PeerConfigurationInformationMessage
   /**
    * Identity of the peer.
    */
-  struct GNUNET_PeerIdentity peer_id;
+  struct GNUNET_PeerIdentity peer_identity;
+
+  /**
+   * The size of configuration when uncompressed
+   */
+  uint16_t config_size GNUNET_PACKED;
+
+  /* followed by gzip-compressed configuration of the peer */
+
+};
+
+
+/**
+ * Message to request configuration of a slave controller
+ */
+struct GNUNET_TESTBED_SlaveGetConfigurationMessage
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIGURATION
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * The id of the slave host
+   */
+  uint32_t slave_id GNUNET_PACKED;
+
+  /**
+   * Operation ID
+   */
+  uint64_t operation_id GNUNET_PACKED;
+
+};
+
+
+/**
+ * Reply to #GNUNET_MESSAGE_TYPE_TESTBED_GET_SLAVE_CONFIG message
+ */
+struct GNUNET_TESTBED_SlaveConfiguration
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_SLAVE_CONFIGURATION
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * The id of the host where the slave is running
+   */
+  uint32_t slave_id GNUNET_PACKED;
+
+  /**
+   * Operation ID
+   */
+  uint64_t operation_id GNUNET_PACKED;
+
+  /**
+   * The size of the configuration when uncompressed
+   */
+  uint16_t config_size GNUNET_PACKED;
 
   /* followed by gzip-compressed configuration of the peer */
 
 };
 
+
+/**
+ * Shutdown peers message
+ */
+struct GNUNET_TESTBED_ShutdownPeersMessage
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Operation ID
+   */
+  uint64_t operation_id GNUNET_PACKED;
+};
+
+
+/**
+ * Message to start/stop services of a peer
+ */
+struct GNUNET_TESTBED_ManagePeerServiceMessage
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Unique ID of the peer whose service has to be managed.
+   */
+  uint32_t peer_id GNUNET_PACKED;
+
+  /**
+   * Operation ID
+   */
+  uint64_t operation_id GNUNET_PACKED;
+
+  /**
+   * set this to 1 to start the service; 0 to stop the service
+   */
+  uint8_t start;
+
+  /**
+   * The NULL-terminated name of the service to start/stop follows here
+   */
+};
+
+
+/**************************************/
+/* Barriers IPC messages and protocol */
+/**************************************/
+
+
+/**
+ * The environmental variable which when available refers to the configuration
+ * file the local testbed controller is using
+ */
+#define ENV_TESTBED_CONFIG "GNUNET_TESTBED_CONTROLLER_CONFIG"
+
+
+/**
+ * Message to initialise a barrier
+ */
+struct GNUNET_TESTBED_BarrierInit
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * The quorum percentage needed for crossing the barrier
+   */
+  uint8_t quorum;
+
+  /**
+   * name of the barrier.  Non NULL-terminated.
+   */
+  char name[0];
+};
+
+
+/**
+ * Message to cancel a barrier
+ */
+struct GNUNET_TESTBED_BarrierCancel
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * The barrier name.  Non NULL terminated
+   */
+  char name[0];
+};
+
+
+/**
+ * Message for signalling status changes of a barrier
+ */
+struct GNUNET_TESTBED_BarrierStatusMsg
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_STATUS
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * status.  Use enumerated values of enum BarrierStatus
+   */
+  uint16_t status GNUNET_PACKED;
+
+  /**
+   * strlen of the barrier name
+   */
+  uint16_t name_len GNUNET_PACKED;
+
+  /**
+   * the barrier name (NULL terminated) concatenated with an error message (NULL
+   * terminated) if the status were to indicate an error
+   */
+  char data[0];
+};
+
+
+/**
+ * Message sent from peers to the testbed-barrier service to indicate that they
+ * have reached a barrier and are waiting for it to be crossed
+ */
+struct GNUNET_TESTBED_BarrierWait
+{
+  /**
+   * Type is GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_WAIT
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * The name of the barrier they have reached.  Non-NULL terminated.
+   */
+  char name[0];
+};
+
+
+GNUNET_NETWORK_STRUCT_END
 #endif
+/* end of testbed.h */