- update makefile
[oweals/gnunet.git] / src / include / gnunet_multicast_service.h
index 7a2421b4b26450d4ba496c15f07b3d567cdde781..50dcf7aefcebf275ebe4a37517a07c0e051b2890 100644 (file)
@@ -44,11 +44,6 @@ extern "C"
  */
 #define GNUNET_MULTICAST_VERSION 0x00000000
 
-/**
- * Maximum size of a multicast message fragment.
- */
-#define GNUNET_MULTICAST_FRAGMENT_MAX_SIZE 63 * 1024
-
 /**
  * Opaque handle for a multicast group member.
  */
@@ -77,7 +72,14 @@ enum GNUNET_MULTICAST_MessageFlags
    */
   GNUNET_MULTICAST_MESSAGE_NOT_FRAGMENTED
     = GNUNET_MULTICAST_MESSAGE_FIRST_FRAGMENT
-    | GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT
+  | GNUNET_MULTICAST_MESSAGE_LAST_FRAGMENT,
+
+  /**
+   * Historic message, used only locally when replaying messages from local
+   * storage.
+   */
+  GNUNET_MULTICAST_MESSAGE_HISTORIC = 1 << 30
+
 };
 
 
@@ -112,7 +114,7 @@ struct GNUNET_MULTICAST_MessageHeader
    *
    * Signature must match the public key of the multicast group.
    */
-  struct GNUNET_CRYPTO_EccSignature signature;
+  struct GNUNET_CRYPTO_EddsaSignature signature;
 
   /**
    * Purpose for the signature and size of the signed data.
@@ -120,7 +122,7 @@ struct GNUNET_MULTICAST_MessageHeader
   struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
 
   /**
-   * Number of the message fragment, monotonically increasing.
+   * Number of the message fragment, monotonically increasing starting from 1.
    */
   uint64_t fragment_id GNUNET_PACKED;
 
@@ -150,15 +152,81 @@ struct GNUNET_MULTICAST_MessageHeader
 
   /**
    * Flags for this message fragment.
+   *
+   * @see enum GNUNET_MULTICAST_MessageFlags
    */
   uint32_t flags GNUNET_PACKED;
 
   /* Followed by message body. */
 };
 
+
+/**
+ * Header of a request from a member to the origin.
+ */
+struct GNUNET_MULTICAST_RequestHeader
+{
+  /**
+   * Header for all requests from a member to the origin.
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Public key of the sending member.
+   */
+  struct GNUNET_CRYPTO_EddsaPublicKey member_key;
+
+  /**
+   * ECC signature of the request fragment.
+   *
+   * Signature must match the public key of the multicast group.
+   */
+  struct GNUNET_CRYPTO_EddsaSignature signature;
+
+  /**
+   * Purpose for the signature and size of the signed data.
+   */
+  struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+  /**
+   * Number of the request fragment.
+   * Monotonically increasing from 1.
+   */
+  uint64_t fragment_id GNUNET_PACKED;
+
+  /**
+   * Byte offset of this @e fragment of the @e request.
+   */
+  uint64_t fragment_offset GNUNET_PACKED;
+
+  /**
+   * Number of the request this fragment belongs to.
+   *
+   * Set in GNUNET_MULTICAST_origin_to_all().
+   */
+  uint64_t request_id GNUNET_PACKED;
+
+  /**
+   * Flags for this request.
+   */
+  enum GNUNET_MULTICAST_MessageFlags flags GNUNET_PACKED;
+
+  /* Followed by request body. */
+};
+
 GNUNET_NETWORK_STRUCT_END
 
 
+/**
+ * Maximum size of a multicast message fragment.
+ */
+#define GNUNET_MULTICAST_FRAGMENT_MAX_SIZE 63 * 1024
+
+#define GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD           \
+  GNUNET_MULTICAST_FRAGMENT_MAX_SIZE                    \
+  - sizeof (struct GNUNET_MULTICAST_MessageHeader)
+
+
 /**
  * Handle that identifies a join request.
  *
@@ -214,7 +282,7 @@ GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *jh,
  */
 typedef void
 (*GNUNET_MULTICAST_JoinCallback) (void *cls,
-                                  const struct GNUNET_CRYPTO_EccPublicSignKey *member_key,
+                                  const struct GNUNET_CRYPTO_EddsaPublicKey *member_key,
                                   const struct GNUNET_MessageHeader *join_req,
                                   struct GNUNET_MULTICAST_JoinHandle *jh);
 
@@ -253,7 +321,7 @@ GNUNET_MULTICAST_membership_test_result (struct GNUNET_MULTICAST_MembershipTestH
  */
 typedef void
 (*GNUNET_MULTICAST_MembershipTestCallback) (void *cls,
-                                            const struct GNUNET_CRYPTO_EccPublicSignKey *member_key,
+                                            const struct GNUNET_CRYPTO_EddsaPublicKey *member_key,
                                             uint64_t message_id,
                                             uint64_t group_generation,
                                             struct GNUNET_MULTICAST_MembershipTestHandle *mth);
@@ -277,7 +345,7 @@ typedef void
  */
 typedef void
 (*GNUNET_MULTICAST_RequestCallback) (void *cls,
-                                     const struct GNUNET_CRYPTO_EccPublicSignKey *member_key,
+                                     const struct GNUNET_CRYPTO_EddsaPublicKey *member_key,
                                      const struct GNUNET_MessageHeader *req,
                                      enum GNUNET_MULTICAST_MessageFlags flags);
 
@@ -341,7 +409,7 @@ struct GNUNET_MULTICAST_ReplayHandle;
  */
 typedef void
 (*GNUNET_MULTICAST_ReplayFragmentCallback) (void *cls,
-                                            const struct GNUNET_CRYPTO_EccPublicSignKey *member_key,
+                                            const struct GNUNET_CRYPTO_EddsaPublicKey *member_key,
                                             uint64_t fragment_id,
                                             uint64_t flags,
                                             struct GNUNET_MULTICAST_ReplayHandle *rh);
@@ -364,7 +432,7 @@ typedef void
  */
 typedef void
 (*GNUNET_MULTICAST_ReplayMessageCallback) (void *cls,
-                                           const struct GNUNET_CRYPTO_EccPublicSignKey *member_key,
+                                           const struct GNUNET_CRYPTO_EddsaPublicKey *member_key,
                                            uint64_t message_id,
                                            uint64_t fragment_offset,
                                            uint64_t flags,
@@ -479,7 +547,7 @@ GNUNET_MULTICAST_replay_response2 (struct GNUNET_MULTICAST_ReplayHandle *rh,
  * @param next_fragment_id Next fragment ID to continue counting fragments from
  *        when restarting the origin.  1 for a new group.
  * @param join_cb Function called to approve / disapprove joining of a peer.
- * @param mem_test_cb Function multicast can use to test group membership.
+ * @param member_test_cb Function multicast can use to test group membership.
  * @param replay_frag_cb Function that can be called to replay a message fragment.
  * @param replay_msg_cb Function that can be called to replay a message.
  * @param request_cb Function called with message fragments from group members.
@@ -491,10 +559,10 @@ GNUNET_MULTICAST_replay_response2 (struct GNUNET_MULTICAST_ReplayHandle *rh,
  */
 struct GNUNET_MULTICAST_Origin *
 GNUNET_MULTICAST_origin_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                               const struct GNUNET_CRYPTO_EccPrivateKey *priv_key,
+                               const struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key,
                                uint64_t next_fragment_id,
                                GNUNET_MULTICAST_JoinCallback join_cb,
-                               GNUNET_MULTICAST_MembershipTestCallback mem_test_cb,
+                               GNUNET_MULTICAST_MembershipTestCallback member_test_cb,
                                GNUNET_MULTICAST_ReplayFragmentCallback replay_frag_cb,
                                GNUNET_MULTICAST_ReplayMessageCallback replay_msg_cb,
                                GNUNET_MULTICAST_RequestCallback request_cb,
@@ -623,8 +691,8 @@ GNUNET_MULTICAST_origin_stop (struct GNUNET_MULTICAST_Origin *origin);
  */
 struct GNUNET_MULTICAST_Member *
 GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                              const struct GNUNET_CRYPTO_EccPublicSignKey *group_key,
-                              const struct GNUNET_CRYPTO_EccPrivateKey *member_key,
+                              const struct GNUNET_CRYPTO_EddsaPublicKey *group_key,
+                              const struct GNUNET_CRYPTO_EddsaPrivateKey *member_key,
                               const struct GNUNET_PeerIdentity *origin,
                               uint32_t relay_count,
                               const struct GNUNET_PeerIdentity *relays,
@@ -743,14 +811,14 @@ struct GNUNET_MULTICAST_MemberRequestHandle;
  * Send a message to the origin of the multicast group.
  *
  * @param member Membership handle.
- * @param message_id Application layer ID for the message.  Opaque to multicast.
+ * @param request_id Application layer ID for the request.  Opaque to multicast.
  * @param notify Callback to call to get the message.
  * @param notify_cls Closure for @a notify.
  * @return Handle to cancel request, NULL on error (i.e. request already pending).
  */
 struct GNUNET_MULTICAST_MemberRequestHandle *
 GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member,
-                                   uint64_t message_id,
+                                   uint64_t request_id,
                                    GNUNET_MULTICAST_MemberTransmitNotify notify,
                                    void *notify_cls);