plugin datastore mysql
[oweals/gnunet.git] / src / rps / rps.h
index 46c8ab0bb67d05091f75128808fc593f71d44900..3037e219035e6847d6ec2409f1b2e8ce26c9bfe0 100644 (file)
@@ -1,6 +1,6 @@
 /*
       This file is part of GNUnet
-      (C) 2012-2013 Christian Grothoff (and other contributing authors)
+      Copyright (C) 2012-2013 GNUnet e.V.
 
       GNUnet is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
       You should have received a copy of the GNU General Public License
       along with GNUnet; see the file COPYING.  If not, write to the
-      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-      Boston, MA 02111-1307, USA.
+      Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+      Boston, MA 02110-1301, USA.
  */
 /**
  * @file rps/rps.h
@@ -38,64 +38,77 @@ GNUNET_NETWORK_STRUCT_BEGIN
 ***********************************************************************/
 
 /**
- * P2P Message to push own ID to other peer.
+ * P2P Message to send PeerIDs to other peer.
  */
-struct GNUNET_RPS_P2P_PushMessage
+struct GNUNET_RPS_P2P_PullReplyMessage
 {
   /**
    * Header including size and type in NBO
    */
   struct GNUNET_MessageHeader header;
 
-  /** 
-   * TODO Proof of work
+  /**
+   * Number of PeerIDs sent
    */
-  uint64_t placeholder;
+  uint32_t num_peers GNUNET_PACKED;
+
+  /* Followed by num_peers * GNUNET_PeerIdentity */
 };
 
+
+
+/***********************************************************************
+ * Client-Service Messages
+***********************************************************************/
+
 /**
- * P2P Message to request PeerIDs from other peer.
+ * Message from client to RPS service to request random peer(s).
  */
-struct GNUNET_RPS_P2P_PullRequestMessage
+struct GNUNET_RPS_CS_RequestMessage
 {
   /**
    * Header including size and type in NBO
    */
   struct GNUNET_MessageHeader header;
 
-  /* This probably stays empty as we just
-   * infrom the peer of our existence */
-  uint64_t placeholder;
+  /**
+   * Identifyer of the message.
+   */
+  uint32_t id GNUNET_PACKED;
+
+  /**
+   * Number of random peer requested
+   */
+  uint32_t num_peers GNUNET_PACKED;
 };
 
 /**
- * P2P Message to send PeerIDs to other peer.
+ * Message from RPS service to client to reply with random peer(s).
  */
-struct GNUNET_RPS_P2P_PullReplyMessage
+struct GNUNET_RPS_CS_ReplyMessage
 {
   /**
-   * Header including size and type in NBO
+   * Type is #GNUNET_MESSAGE_TYPE_RPS_CS_REPLY.
    */
   struct GNUNET_MessageHeader header;
 
   /**
-   * Number of PeerIDs sent
+   * Identifyer of the message.
+   */
+  uint32_t id GNUNET_PACKED;
+
+  /**
+   * Number of random peer replied
    */
-  uint64_t num_peers GNUNET_PACKED;
+  uint32_t num_peers GNUNET_PACKED;
 
   /* Followed by num_peers * GNUNET_PeerIdentity */
 };
 
-
-
-/***********************************************************************
- * Client-Service Messages
-***********************************************************************/
-
 /**
- * Message from client to RPS service to request random peer(s).
+ * Message from client to RPS service to cancel request.
  */
-struct GNUNET_RPS_CS_RequestMessage
+struct GNUNET_RPS_CS_RequestCancelMessage
 {
   /**
    * Header including size and type in NBO
@@ -105,18 +118,32 @@ struct GNUNET_RPS_CS_RequestMessage
   /**
    * Identifyer of the message.
    */
-  uint64_t n;
+  uint32_t id GNUNET_PACKED;
+};
 
+/**
+ * Message from client to service with seed of peers.
+ */
+struct GNUNET_RPS_CS_SeedMessage
+{
   /**
-   * Number of random peer requested
+   * Header including size and type in NBO
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Number of peers
    */
-  uint64_t num_peers GNUNET_PACKED;
+  uint32_t num_peers GNUNET_PACKED;
+
+  /* Followed by num_peers * GNUNET_PeerIdentity */
 };
 
+#ifdef ENABLE_MALICIOUS
 /**
- * Message from RPS service to client to reply with random peer(s).
+ * Message from client to service to turn service malicious.
  */
-struct GNUNET_RPS_CS_ReplyMessage
+struct GNUNET_RPS_CS_ActMaliciousMessage
 {
   /**
    * Header including size and type in NBO
@@ -124,16 +151,28 @@ struct GNUNET_RPS_CS_ReplyMessage
   struct GNUNET_MessageHeader header;
 
   /**
-   * Identifyer of the message.
+   * If the type is 2 this is the attacked peer,
+   * empty otherwise.
    */
-  uint64_t n;
+  struct GNUNET_PeerIdentity attacked_peer;
 
   /**
-   * Number of random peer replied
+   * Type of malicious behaviour.
+   *
+   * 0 No malicious bahaviour at all
+   * 1 Try to maximise representation
+   * 2 Try to partition the network
    */
-  uint64_t num_peers GNUNET_PACKED;
+  uint32_t type GNUNET_PACKED;
 
-  /* Followed by num_peers * GNUNET_PeerIdentity */
+  /**
+   * Number of peers
+   */
+  uint32_t num_peers GNUNET_PACKED;
+
+  /* Followed by num_peers * GNUNET_PeerIdentity when the type of malicious
+     behaviour is 1 */
 };
+#endif /* ENABLE_MALICIOUS */
 
 GNUNET_NETWORK_STRUCT_END