friend is a reserved work in C++. Rename to friend_id.
[oweals/gnunet.git] / src / include / gnunet_psyc_service.h
index eb17c93510afc19fbb527ed0a13c6abd6bdac0d4..018f012f490b7ef12f86fc1f79341fa12782ad6f 100644 (file)
@@ -110,9 +110,10 @@ enum GNUNET_PSYC_ChannelFlags
    * Past messages are only available to slaves who were admitted at the time
    * they were sent to the channel.
    */
-  GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1,
+  GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY = 1 << 1
 };
 
+
 /**
  * PSYC channel policies.
  */
@@ -132,7 +133,7 @@ enum GNUNET_PSYC_Policy
    */
   GNUNET_PSYC_CHANNEL_PRIVATE
     = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL
-    | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY,
+    | GNUNET_PSYC_CHANNEL_RESTRICTED_HISTORY
 
 #if IDEAS_FOR_FUTURE
   /**
@@ -152,9 +153,7 @@ enum GNUNET_PSYC_Policy
    */
   GNUNET_PSYC_CHANNEL_CLOSED
     = GNUNET_PSYC_CHANNEL_ADMISSION_CONTROL,
-,
 #endif
-
 };
 
 
@@ -163,9 +162,15 @@ enum GNUNET_PSYC_MessageFlags
   /**
    * Historic message, retrieved from PSYCstore.
    */
-  GNUNET_PSYC_MESSAGE_HISTORIC = 1
+  GNUNET_PSYC_MESSAGE_HISTORIC = 1 << 0,
+
+  /**
+   * Request from slave to master.
+   */
+  GNUNET_PSYC_MESSAGE_REQUEST = 1 << 1
 };
 
+
 GNUNET_NETWORK_STRUCT_BEGIN
 
 /**
@@ -187,6 +192,7 @@ struct GNUNET_PSYC_MessageHeader
 
   /**
    * Number of the message this message part belongs to.
+   * Monotonically increasing from 1.
    */
   uint64_t message_id GNUNET_PACKED;
 
@@ -251,6 +257,7 @@ struct GNUNET_PSYC_MessageModifier
 
 GNUNET_NETWORK_STRUCT_END
 
+
 #define GNUNET_PSYC_MODIFIER_MAX_PAYLOAD        \
   GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD         \
   - sizeof (struct GNUNET_PSYC_MessageModifier)
@@ -263,6 +270,7 @@ GNUNET_NETWORK_STRUCT_END
   GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD         \
   - sizeof (struct GNUNET_MessageHeader)
 
+
 /**
  * Handle that identifies a join request.
  *
@@ -359,7 +367,7 @@ struct GNUNET_PSYC_Master;
  * Function called after the channel master started.
  *
  * @param cls Closure.
- * @param last_message_id Last message ID sent to the channel.
+ * @param max_message_id Last message ID sent to the channel.
  */
 typedef void
 (*GNUNET_PSYC_MasterStartCallback) (void *cls, uint64_t max_message_id);
@@ -406,7 +414,7 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
 /**
  * Function called to provide data for a transmission via PSYC.
  *
- * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
+ * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO)
  * invalidates the respective transmission handle.
  *
  * @param cls Closure.
@@ -422,10 +430,48 @@ GNUNET_PSYC_master_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
  *         #GNUNET_YES if this completes the transmission (all data supplied)
  */
 typedef int
-(*GNUNET_PSYC_MasterTransmitNotify) (void *cls,
-                                     uint16_t *data_size,
-                                     void *data);
+(*GNUNET_PSYC_TransmitNotifyData) (void *cls,
+                                   uint16_t *data_size,
+                                   void *data);
 
+/**
+ * Function called to provide a modifier for a transmission via PSYC.
+ *
+ * Note that returning #GNUNET_YES or #GNUNET_SYSERR (but not #GNUNET_NO)
+ * invalidates the respective transmission handle.
+ *
+ * @param cls Closure.
+ * @param[in,out] data_size  Initially set to the number of bytes available in
+ *         @a data, should be set to the number of bytes written to data.
+ * @param[out] data  Where to write the modifier's name and value.
+ *         The function must copy at most @a data_size bytes to @a data.
+ *         When this callback is first called for a modifier, @a data should
+ *         contain: "name\0value".  If the whole value does not fit, subsequent
+ *         calls to this function should write continuations of the value to
+ *         @a data.
+ * @param[out] oper  Where to write the operator of the modifier.
+ *         Only needed during the first call to this callback at the beginning
+ *         of the modifier.  In case of subsequent calls asking for value
+ *         continuations @a oper is set to #NULL.
+ * @param[out] value_size  Where to write the full size of the value.
+ *         Only needed during the first call to this callback at the beginning
+ *         of the modifier.  In case of subsequent calls asking for value
+ *         continuations @a value_size is set to #NULL.
+ * @return #GNUNET_SYSERR on error (fatal, aborts transmission)
+ *         #GNUNET_NO on success, if more data is to be transmitted later.
+ *         Should be used if @a data_size was not big enough to take all the
+ *         data for the modifier's value (the name must be always returned
+ *         during the first call to this callback).
+ *         If 0 is returned in @a data_size the transmission is paused,
+ *         and can be resumed with GNUNET_PSYC_master_transmit_resume().
+ *         #GNUNET_YES if this completes the modifier (the whole value is supplied).
+ */
+typedef int
+(*GNUNET_PSYC_TransmitNotifyModifier) (void *cls,
+                                       uint16_t *data_size,
+                                       void *data,
+                                       uint8_t *oper,
+                                       uint32_t *value_size);
 
 /**
  * Flags for transmitting messages to a channel by the master.
@@ -472,8 +518,8 @@ struct GNUNET_PSYC_MasterTransmitHandle;
 struct GNUNET_PSYC_MasterTransmitHandle *
 GNUNET_PSYC_master_transmit (struct GNUNET_PSYC_Master *master,
                              const char *method_name,
-                             GNUNET_PSYC_MasterTransmitNotify notify_mod,
-                             GNUNET_PSYC_MasterTransmitNotify notify_data,
+                             GNUNET_PSYC_TransmitNotifyModifier notify_mod,
+                             GNUNET_PSYC_TransmitNotifyData notify_data,
                              void *notify_cls,
                              enum GNUNET_PSYC_MasterTransmitFlags flags);
 
@@ -582,29 +628,6 @@ void
 GNUNET_PSYC_slave_part (struct GNUNET_PSYC_Slave *slave);
 
 
-/**
- * Function called to provide data for a transmission to the channel master
- * (a.k.a. the @e host of the channel).
- *
- * Note that returning #GNUNET_OK or #GNUNET_SYSERR (but not #GNUNET_NO)
- * invalidates the respective transmission handle.
- *
- * @param cls Closure.
- * @param[in,out] data_size Initially set to the number of bytes available in
- *        @a data, should be set to the number of bytes written to data
- *        (IN/OUT).
- * @param[out] data Where to write the body of the message to give to the method;
- *        function must copy at most @a *data_size bytes to @a data.
- * @return #GNUNET_SYSERR on error (fatal, aborts transmission).
- *         #GNUNET_NO on success, if more data is to be transmitted later.
- *         #GNUNET_YES if this completes the transmission (all data supplied).
- */
-typedef int
-(*GNUNET_PSYC_SlaveTransmitNotify) (void *cls,
-                                    size_t *data_size,
-                                    char *data);
-
-
 /**
  * Flags for transmitting messages to the channel master by a slave.
  */
@@ -625,8 +648,8 @@ struct GNUNET_PSYC_SlaveTransmitHandle;
  *
  * @param slave Slave handle.
  * @param method_name Which (PSYC) method should be invoked (on host).
- * @param env Environment containing transient variables for the message, or NULL.
- * @param notify Function to call when we are allowed to transmit (to get data).
+ * @param notify_mod Function to call to obtain modifiers.
+ * @param notify_data Function to call to obtain fragments of the data.
  * @param notify_cls Closure for @a notify.
  * @param flags Flags for the message being transmitted.
  * @return Transmission handle, NULL on error (i.e. more than one request queued).
@@ -634,8 +657,8 @@ struct GNUNET_PSYC_SlaveTransmitHandle;
 struct GNUNET_PSYC_SlaveTransmitHandle *
 GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave,
                             const char *method_name,
-                            const struct GNUNET_ENV_Environment *env,
-                            GNUNET_PSYC_SlaveTransmitNotify notify,
+                            GNUNET_PSYC_TransmitNotifyModifier notify_mod,
+                            GNUNET_PSYC_TransmitNotifyData notify_data,
                             void *notify_cls,
                             enum GNUNET_PSYC_SlaveTransmitFlags flags);
 
@@ -646,7 +669,7 @@ GNUNET_PSYC_slave_transmit (struct GNUNET_PSYC_Slave *slave,
  * @param th Handle of the request that is being resumed.
  */
 void
-GNUNET_PSYC_slave_transmit_resume (struct GNUNET_PSYC_MasterTransmitHandle *th);
+GNUNET_PSYC_slave_transmit_resume (struct GNUNET_PSYC_SlaveTransmitHandle *th);
 
 
 /**