aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation/defragmentation_new.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fragmentation/defragmentation_new.c')
-rw-r--r--src/fragmentation/defragmentation_new.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/fragmentation/defragmentation_new.c b/src/fragmentation/defragmentation_new.c
new file mode 100644
index 000000000..8fdc334d9
--- /dev/null
+++ b/src/fragmentation/defragmentation_new.c
@@ -0,0 +1,109 @@
1/*
2 This file is part of GNUnet
3 (C) 2009, 2011 Christian Grothoff (and other contributing authors)
4
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 3, or (at your
8 option) any later version.
9
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.
14
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.
19*/
20/**
21 * @file src/fragmentation/defragmentation_new.c
22 * @brief library to help defragment messages
23 * @author Christian Grothoff
24 */
25#include "platform.h"
26#include "gnunet_fragmentation_lib.h"
27#include "fragmentation.h"
28
29/**
30 * Defragmentation context.
31 */
32struct GNUNET_DEFRAGMENT_Context
33{
34
35 /**
36 * For statistics.
37 */
38 struct GNUNET_STATISTICS_Handle *stats;
39
40 /**
41 * Closure for 'proc' and 'ackp'.
42 */
43 void *cls;
44
45 /**
46 * Function to call with defragmented messages.
47 */
48 GNUNET_FRAGMENT_MessageProcessor proc;
49
50 /**
51 * Function to call with acknowledgements.
52 */
53 GNUNET_FRAGMENT_MessageProcessor ackp;
54};
55
56
57/**
58 * Create a defragmentation context.
59 *
60 * @param stats statistics context
61 * @param cls closure for proc and ackp
62 * @param proc function to call with defragmented messages
63 * @param ackp function to call with acknowledgements (to send
64 * back to the other side)
65 * @return the defragmentation context
66 */
67struct GNUNET_DEFRAGMENT_Context *
68GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats,
69 void *cls,
70 GNUNET_FRAGMENT_MessageProcessor proc,
71 GNUNET_FRAGMENT_MessageProcessor ackp)
72{
73 struct GNUNET_DEFRAGMENT_Context *dc;
74
75 dc = GNUNET_malloc (sizeof (struct GNUNET_DEFRAGMENT_Context));
76 dc->stats = stats;
77 dc->cls = cls;
78 dc->proc = proc;
79 dc->ackp = ackp;
80 return dc;
81}
82
83
84/**
85 * Destroy the given defragmentation context.
86 *
87 * @param dc defragmentation context
88 */
89void
90GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc)
91{
92 GNUNET_free (dc);
93}
94
95
96/**
97 * We have received a fragment. Process it.
98 *
99 * @param dc the context
100 * @param msg the message that was received
101 */
102void
103GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc,
104 const struct GNUNET_MessageHeader *msg)
105{
106}
107
108/* end of defragmentation_new.c */
109