fix bad free
[oweals/gnunet.git] / src / include / gnunet_psyc_slicer.h
index 077c0c5bd0c253cdca533f0cff7ec780fcda1da2..096794559461f893c56ac8aaa6a03fa59d477824 100644 (file)
@@ -1,21 +1,19 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 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
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     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., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /**
@@ -63,11 +61,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
@@ -75,10 +77,9 @@ struct GNUNET_PSYC_Slicer;
  */
 typedef void
 (*GNUNET_PSYC_MethodCallback) (void *cls,
-                               const struct GNUNET_PSYC_MessageMethod *msg,
+                               const struct GNUNET_PSYC_MessageHeader *msg,
+                               const struct GNUNET_PSYC_MessageMethod *meth,
                                uint64_t message_id,
-                               uint32_t flags,
-                               const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
                                const char *method_name);
 
 
@@ -89,6 +90,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
@@ -104,7 +109,8 @@ typedef void
  */
 typedef void
 (*GNUNET_PSYC_ModifierCallback) (void *cls,
-                                 const struct GNUNET_MessageHeader *msg,
+                                 const struct GNUNET_PSYC_MessageHeader *msg,
+                                 const struct GNUNET_MessageHeader *pmsg,
                                  uint64_t message_id,
                                  enum GNUNET_PSYC_Operator oper,
                                  const char *name,
@@ -118,16 +124,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,
@@ -136,9 +144,9 @@ typedef void
  */
 typedef void
 (*GNUNET_PSYC_DataCallback) (void *cls,
-                             const struct GNUNET_MessageHeader *msg,
+                             const struct GNUNET_PSYC_MessageHeader *msg,
+                             const struct GNUNET_MessageHeader *pmsg,
                              uint64_t message_id,
-                             uint64_t data_offset,
                              const void *data,
                              uint16_t data_size);
 
@@ -152,15 +160,20 @@ 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.
  */
 typedef void
 (*GNUNET_PSYC_EndOfMessageCallback) (void *cls,
-                                     const struct GNUNET_MessageHeader *msg,
+                                     const struct GNUNET_PSYC_MessageHeader *msg,
+                                     const struct GNUNET_MessageHeader *pmsg,
                                      uint64_t message_id,
-                                     uint8_t cancelled);
+                                     uint8_t is_cancelled);
 
 
 /**
@@ -199,6 +212,7 @@ GNUNET_PSYC_slicer_create (void);
 void
 GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer,
                                const char *method_name,
+                               GNUNET_PSYC_MessageCallback msg_cb,
                                GNUNET_PSYC_MethodCallback method_cb,
                                GNUNET_PSYC_ModifierCallback modifier_cb,
                                GNUNET_PSYC_DataCallback data_cb,
@@ -216,13 +230,13 @@ GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer,
  * @param method_name
  *        Name of the method to remove.
  * @param method_cb
- *        Method handler.
+ *        Only remove matching method handler, or NULL.
  * @param modifier_cb
- *        Modifier handler.
+ *        Only remove matching modifier handler, or NULL.
  * @param data_cb
- *        Data handler.
+ *        Only remove matching data handler, or NULL.
  * @param eom_cb
- *        End of message handler.
+ *        Only remove matching End of Message handler, or NULL.
  *
  * @return #GNUNET_OK if a method handler was removed,
  *         #GNUNET_NO if no handler matched the given method name and callbacks.
@@ -230,6 +244,7 @@ GNUNET_PSYC_slicer_method_add (struct GNUNET_PSYC_Slicer *slicer,
 int
 GNUNET_PSYC_slicer_method_remove (struct GNUNET_PSYC_Slicer *slicer,
                                   const char *method_name,
+                                  GNUNET_PSYC_MessageCallback msg_cb,
                                   GNUNET_PSYC_MethodCallback method_cb,
                                   GNUNET_PSYC_ModifierCallback modifier_cb,
                                   GNUNET_PSYC_DataCallback data_cb,
@@ -304,11 +319,8 @@ GNUNET_PSYC_slicer_message (struct GNUNET_PSYC_Slicer *slicer,
  */
 void
 GNUNET_PSYC_slicer_message_part (struct GNUNET_PSYC_Slicer *slicer,
-                                 const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_pub_key,
-                                 uint64_t message_id,
-                                 uint32_t flags,
-                                 uint64_t fragment_offset,
-                                 const struct GNUNET_MessageHeader *msg);
+                                 const struct GNUNET_PSYC_MessageHeader *msg,
+                                 const struct GNUNET_MessageHeader *pmsg);
 
 
 /**