psycutil: slicer callback args
authorGabor X Toth <*@tg-x.net>
Tue, 26 Jan 2016 20:37:09 +0000 (20:37 +0000)
committerGabor X Toth <*@tg-x.net>
Tue, 26 Jan 2016 20:37:09 +0000 (20:37 +0000)
src/include/gnunet_psyc_service.h
src/include/gnunet_psyc_slicer.h
src/psycutil/psyc_message.c
src/psycutil/psyc_slicer.c
src/social/gnunet-service-social.c
src/social/social_api.c

index 87de9badbffe00cc128a9d0b99e3f7166db71610..16be33b15697d9b26c62364a04b0c3e6f1de7f89 100644 (file)
@@ -250,7 +250,6 @@ struct GNUNET_PSYC_MessageHeader
 
   /**
    * Byte offset of this @e fragment of the @e message.
-   * FIXME: use data_offset instead
    */
   uint64_t fragment_offset GNUNET_PACKED;
 
@@ -551,9 +550,8 @@ typedef void
  *        Sequence number of the message.
  * @param flags
  *        OR'ed GNUNET_PSYC_MessageFlags
- * @param data_offset
- *        Byte offset of data, only set if @a msg has a type
- *        #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_DATA
+ * @param fragment_offset
+ *        Multicast message fragment offset.
  * @param msg  Message part, one of the following types:
  * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER
  * - #GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD
@@ -567,7 +565,7 @@ typedef void
                                     const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
                                     uint64_t message_id,
                                     uint32_t flags,
-                                    uint64_t data_offset,
+                                    uint64_t fragment_offset,
                                     const struct GNUNET_MessageHeader *msg);
 
 
index d29c231e1ba8658ce7f2d7625c7d50f28a20809c..f6b6547f39c82e08ab3d78cae9717500b6314682 100644 (file)
@@ -63,11 +63,15 @@ struct GNUNET_PSYC_Slicer;
  *        Message part, as it arrived from the network.
  * @param message_id
  *        Message counter, monotonically increasing from 1.
+ * @param flags
+ *        OR'ed GNUNET_PSYC_MessageFlags
+ * @param fragment_offset
+ *        Multicast message fragment offset.
+ * @param tmit_flags
+ *        OR'ed GNUNET_PSYC_MasterTransmitFlags
  * @param nym
  *        The sender of the message.
  *        Can be NULL if the message is not connected to a pseudonym.
- * @param flags
- *        OR'ed GNUNET_PSYC_MessageFlags
  * @param method_name
  *        Original method name from PSYC.
  *        May be more specific than the registered method name due to
@@ -78,6 +82,8 @@ typedef void
                                const struct GNUNET_PSYC_MessageMethod *msg,
                                uint64_t message_id,
                                uint32_t flags,
+                               uint64_t fragment_offset,
+                               uint32_t tmit_flags,
                                const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
                                const char *method_name);
 
@@ -89,6 +95,10 @@ typedef void
  *        Closure.
  * @param message_id
  *        Message ID this data fragment belongs to.
+ * @param flags
+ *        OR'ed GNUNET_PSYC_MessageFlags
+ * @param fragment_offset
+ *        Multicast message fragment offset.
  * @param msg
  *        Message part, as it arrived from the network.
  * @param oper
@@ -106,6 +116,8 @@ typedef void
 (*GNUNET_PSYC_ModifierCallback) (void *cls,
                                  const struct GNUNET_MessageHeader *msg,
                                  uint64_t message_id,
+                                 uint32_t flags,
+                                 uint64_t fragment_offset,
                                  enum GNUNET_PSYC_Operator oper,
                                  const char *name,
                                  const void *value,
@@ -118,16 +130,18 @@ typedef void
  *
  * @param cls
  *        Closure.
- * @param message_id
- *        Message ID this data fragment belongs to.
  * @param msg
  *        Message part, as it arrived from the network.
- * @param data_offset
- *        Byte offset of @a data in the overall data of the method.
- * @param data_size
- *        Number of bytes in @a data.
+ * @param message_id
+ *        Message ID this data fragment belongs to.
+ * @param flags
+ *        OR'ed GNUNET_PSYC_MessageFlags
+ * @param fragment_offset
+ *        Multicast message fragment offset.
  * @param data
  *        Data stream given to the method.
+ * @param data_size
+ *        Number of bytes in @a data.
  * @param end
  *        End of message?
  *        #GNUNET_NO     if there are further fragments,
@@ -138,7 +152,8 @@ typedef void
 (*GNUNET_PSYC_DataCallback) (void *cls,
                              const struct GNUNET_MessageHeader *msg,
                              uint64_t message_id,
-                             uint64_t data_offset,
+                             uint32_t flags,
+                             uint64_t fragment_offset,
                              const void *data,
                              uint16_t data_size);
 
@@ -152,6 +167,10 @@ typedef void
  *        Message part, as it arrived from the network.
  * @param message_id
  *        Message ID this data fragment belongs to.
+ * @param flags
+ *        OR'ed GNUNET_PSYC_MessageFlags
+ * @param fragment_offset
+ *        Multicast message fragment offset.
  * @param cancelled
  *        #GNUNET_YES if the message was cancelled,
  *        #GNUNET_NO  if the message is complete.
@@ -160,6 +179,8 @@ typedef void
 (*GNUNET_PSYC_EndOfMessageCallback) (void *cls,
                                      const struct GNUNET_MessageHeader *msg,
                                      uint64_t message_id,
+                                     uint32_t flags,
+                                     uint64_t fragment_offset,
                                      uint8_t cancelled);
 
 
index 62a5b8f1425292b80d42b33bd6a3b6e7ebab1b3a..f75a809efa77c2f696d201930fa0870145d7e50d 100644 (file)
@@ -1101,7 +1101,7 @@ GNUNET_PSYC_receive_message (struct GNUNET_PSYC_ReceiveHandle *recv,
     if (NULL != recv->message_part_cb)
       recv->message_part_cb (recv->cb_cls, &recv->slave_pub_key,
                              recv->message_id, recv->flags,
-                             0, // FIXME: data_offset
+                             GNUNET_ntohll (msg->fragment_offset),
                              pmsg);
 
     switch (ptype)
@@ -1181,7 +1181,7 @@ struct ParseMessageClosure
 static void
 parse_message_part_cb (void *cls,
                        const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
-                       uint64_t message_id, uint32_t flags, uint64_t data_offset,
+                       uint64_t message_id, uint32_t flags, uint64_t fragment_offset,
                        const struct GNUNET_MessageHeader *msg)
 {
   struct ParseMessageClosure *pmc = cls;
index 7586b39707bb99bffb6b2c914949b743a646d0ee..735eb1511f5d488d76b32e4e26a0f927d71b03ee 100644 (file)
@@ -64,6 +64,16 @@ struct GNUNET_PSYC_Slicer
    */
   uint64_t message_id;
 
+  /**
+   * Fragment offset of currently being received message.
+   */
+  uint64_t fragment_offset;
+
+  /**
+   * Flags of currently being received message.
+   */
+  uint32_t flags;
+
   /**
    * Method name of currently being received message.
    */
@@ -174,6 +184,7 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
     struct GNUNET_PSYC_MessageMethod *
       meth = (struct GNUNET_PSYC_MessageMethod *) msg;
     cbs->method_cb (cbs->cls, meth, slicer->message_id,
+                    slicer->flags, slicer->fragment_offset,
                     ntohl (meth->flags),
                     &slicer->nym_pub_key,
                     slicer->method_name);
@@ -187,6 +198,7 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
     struct GNUNET_PSYC_MessageModifier *
       mod = (struct GNUNET_PSYC_MessageModifier *) msg;
     cbs->modifier_cb (cbs->cls, &mod->header, slicer->message_id,
+                      slicer->flags, slicer->fragment_offset,
                       mod->oper, (const char *) &mod[1],
                       (const void *) &mod[1] + ntohs (mod->name_size),
                       ntohs (mod->header.size) - sizeof (*mod) - ntohs (mod->name_size),
@@ -199,6 +211,7 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
     if (NULL == cbs->modifier_cb)
       break;
     cbs->modifier_cb (cbs->cls, msg, slicer->message_id,
+                      slicer->flags, slicer->fragment_offset,
                       slicer->mod_oper, slicer->mod_name, &msg[1],
                       ntohs (msg->size) - sizeof (*msg),
                       slicer->mod_full_value_size);
@@ -209,22 +222,24 @@ slicer_method_handler_notify (void *cls, const struct GNUNET_HashCode *key,
   {
     if (NULL == cbs->data_cb)
       break;
-    uint64_t data_offset = 0; // FIXME
     cbs->data_cb (cbs->cls, msg, slicer->message_id,
-                  data_offset, &msg[1], ntohs (msg->size) - sizeof (*msg));
+                  slicer->flags, slicer->fragment_offset,
+                  &msg[1], ntohs (msg->size) - sizeof (*msg));
     break;
   }
 
   case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
     if (NULL == cbs->eom_cb)
       break;
-    cbs->eom_cb (cbs->cls, msg, slicer->message_id, GNUNET_NO);
+    cbs->eom_cb (cbs->cls, msg, slicer->message_id,
+                 slicer->flags, slicer->fragment_offset, GNUNET_NO);
     break;
 
   case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
     if (NULL == cbs->eom_cb)
       break;
-    cbs->eom_cb (cbs->cls, msg, slicer->message_id, GNUNET_YES);
+    cbs->eom_cb (cbs->cls, msg, slicer->message_id,
+                 slicer->flags, slicer->fragment_offset, GNUNET_YES);
     break;
   }
   return GNUNET_YES;
@@ -241,8 +256,9 @@ slicer_modifier_handler_notify (void *cls, const struct GNUNET_HashCode *key,
   struct GNUNET_PSYC_Slicer *slicer = cls;
   struct SlicerModifierCallbacks *cbs = value;
 
-  cbs->modifier_cb (cbs->cls, slicer->msg, slicer->message_id, slicer->mod_oper,
-                    slicer->mod_name, slicer->mod_value,
+  cbs->modifier_cb (cbs->cls, slicer->msg,
+                    slicer->message_id, slicer->flags, slicer->fragment_offset,
+                    slicer->mod_oper, slicer->mod_name, slicer->mod_value,
                     slicer->mod_value_size, slicer->mod_full_value_size);
   return GNUNET_YES;
 }
@@ -296,6 +312,8 @@ GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer,
     slicer->method_name = GNUNET_malloc (slicer->method_name_size);
     memcpy (slicer->method_name, &meth[1], slicer->method_name_size);
     slicer->message_id = message_id;
+    slicer->flags = flags;
+    slicer->fragment_offset = fragment_offset;
   }
   else
   {
index 04d506c12fcfecf295ea2ff6f61cc9efa3322c8f..828506c07a78aa91102fc4983ff39e6d07b21132 100644 (file)
@@ -769,13 +769,15 @@ place_recv_relay_method (void *cls,
                          const struct GNUNET_PSYC_MessageMethod *meth,
                          uint64_t message_id,
                          uint32_t flags,
+                         uint64_t fragment_offset,
+                         uint32_t tmit_flags,
                          const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
                          const char *method_name)
 {
   struct Host *hst = cls;
   struct Place *plc = &hst->plc;
 
-  // FIXME: relay message
+
 }
 
 
@@ -783,6 +785,8 @@ static void
 place_recv_relay_modifier (void *cls,
                            const struct GNUNET_MessageHeader *msg,
                            uint64_t message_id,
+                           uint32_t flags,
+                           uint64_t fragment_offset,
                            enum GNUNET_PSYC_Operator oper,
                            const char *name,
                            const void *value,
@@ -797,6 +801,8 @@ static void
 place_recv_relay_eom (void *cls,
                       const struct GNUNET_MessageHeader *msg,
                       uint64_t message_id,
+                      uint32_t flags,
+                      uint64_t fragment_offset,
                       uint8_t cancelled)
 {
 
@@ -807,7 +813,8 @@ static void
 place_recv_relay_data (void *cls,
                        const struct GNUNET_MessageHeader *msg,
                        uint64_t message_id,
-                       uint64_t data_offset,
+                       uint32_t flags,
+                       uint64_t fragment_offset,
                        const void *data,
                        uint16_t data_size)
 {
@@ -820,6 +827,8 @@ place_recv_save_method (void *cls,
                         const struct GNUNET_PSYC_MessageMethod *meth,
                         uint64_t message_id,
                         uint32_t flags,
+                        uint64_t fragment_offset,
+                        uint32_t tmit_flags,
                         const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
                         const char *method_name)
 {
@@ -852,7 +861,8 @@ static void
 place_recv_save_data (void *cls,
                       const struct GNUNET_MessageHeader *msg,
                       uint64_t message_id,
-                      uint64_t data_offset,
+                      uint32_t flags,
+                      uint64_t fragment_offset,
                       const void *data,
                       uint16_t data_size)
 {
@@ -888,6 +898,8 @@ static void
 place_recv_save_eom (void *cls,
                      const struct GNUNET_MessageHeader *msg,
                      uint64_t message_id,
+                     uint32_t flags,
+                     uint64_t fragment_offset,
                      uint8_t cancelled)
 {
   struct Place *plc = cls;
@@ -1235,10 +1247,10 @@ host_enter (const struct HostEnterRequest *hreq, struct Host **ret_hst)
 
 
 const struct MsgProcRequest *
-relay_req_parse (const struct GNUNET_MessageHeader *msg,
-                 uint32_t *flags,
-                 const char **method_prefix,
-                 struct GNUNET_HashCode *method_hash)
+msg_proc_parse (const struct GNUNET_MessageHeader *msg,
+                uint32_t *flags,
+                const char **method_prefix,
+                struct GNUNET_HashCode *method_hash)
 {
   const struct MsgProcRequest *mpreq = (const struct MsgProcRequest *) msg;
   uint8_t method_size = ntohs (mpreq->header.size) - sizeof (*mpreq);
@@ -1275,7 +1287,7 @@ client_recv_msg_proc_set (void *cls, struct GNUNET_SERVER_Client *client,
   uint32_t flags = 0;
   struct GNUNET_HashCode method_hash;
   const struct MsgProcRequest *
-    mpreq = relay_req_parse (msg, &flags, &method_prefix, &method_hash);
+    mpreq = msg_proc_parse (msg, &flags, &method_prefix, &method_hash);
 
   if (NULL == mpreq) {
     GNUNET_break (0);
index 428afd2b9d03c3b1981d5c748d2d2b3ec6970223..c2398714536354b39c3eff5f3ca8770526386b00 100644 (file)
@@ -401,6 +401,8 @@ host_recv_notice_place_leave_method (void *cls,
                                      const struct GNUNET_PSYC_MessageMethod *meth,
                                      uint64_t message_id,
                                      uint32_t flags,
+                                     uint64_t fragment_offset,
+                                     uint32_t tmit_flags,
                                      const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
                                      const char *method_name)
 {
@@ -430,6 +432,8 @@ static void
 host_recv_notice_place_leave_modifier (void *cls,
                                        const struct GNUNET_MessageHeader *msg,
                                        uint64_t message_id,
+                                       uint32_t flags,
+                                       uint64_t fragment_offset,
                                        enum GNUNET_PSYC_Operator oper,
                                        const char *name,
                                        const void *value,
@@ -459,6 +463,8 @@ static void
 host_recv_notice_place_leave_eom (void *cls,
                                   const struct GNUNET_MessageHeader *msg,
                                   uint64_t message_id,
+                                  uint32_t flags,
+                                  uint64_t fragment_offset,
                                   uint8_t cancelled)
 {
   struct GNUNET_SOCIAL_Host *hst = cls;