2 This file is part of GNUnet
3 (C) 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
21 * @file include/gnunet_fragmentation_lib.h
22 * @brief library to help fragment messages
23 * @author Christian Grothoff
26 #ifndef GNUNET_FRAGMENTATION_LIB_H
27 #define GNUNET_FRAGMENTATION_LIB_H
29 #include "gnunet_common.h"
30 #include "gnunet_statistics_service.h"
35 #if 0 /* keep Emacsens' auto-indent happy */
41 * Function that is called with messages
42 * created by the fragmentation module.
45 * @param msg the message that was created
47 typedef void (*GNUNET_FRAGMENT_MessageProcessor) (void *cls,
49 GNUNET_MessageHeader * msg);
53 * Fragment an over-sized message.
55 * @param msg the message to fragment
56 * @param mtu the maximum message size
57 * @param proc function to call for each fragment
58 * @param proc_cls closure for proc
60 void GNUNET_FRAGMENT_fragment (const struct GNUNET_MessageHeader *msg,
62 GNUNET_FRAGMENT_MessageProcessor proc,
66 * Defragmentation context.
68 struct GNUNET_FRAGMENT_Context;
71 * Create a defragmentation context.
73 * @param stats statistics context
74 * @param proc function to call with defragmented messages
75 * @param proc_cls closure for proc
76 * @return the defragmentation context
78 struct GNUNET_FRAGMENT_Context *GNUNET_FRAGMENT_context_create (struct
79 GNUNET_STATISTICS_Handle
81 GNUNET_FRAGMENT_MessageProcessor
88 * Destroy the given defragmentation context.
90 void GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *ctx);
94 * We have received a fragment. Process it.
96 * @param ctx the context
97 * @param sender who transmitted the fragment
98 * @param msg the message that was received
100 void GNUNET_FRAGMENT_process (struct GNUNET_FRAGMENT_Context *ctx,
101 const struct GNUNET_PeerIdentity *sender,
102 const struct GNUNET_MessageHeader *msg);
105 #if 0 /* keep Emacsens' auto-indent happy */
112 /* end of gnunet_fragmentation_lib.h */