aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_block_plugin.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-20 15:09:00 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-20 15:09:19 +0100
commita3882b58f1c5976677aa65b0af8a48e8e946b06e (patch)
treebd841d8e78052a05821e194d002ca843693fb2c9 /src/include/gnunet_block_plugin.h
parentf0149c5430f42a8bad422e9c51754af59c7bfa2f (diff)
downloadgnunet-a3882b58f1c5976677aa65b0af8a48e8e946b06e.tar.gz
gnunet-a3882b58f1c5976677aa65b0af8a48e8e946b06e.zip
first half of new BLOCK API to generalize duplicate detection beyond BFs
Diffstat (limited to 'src/include/gnunet_block_plugin.h')
-rw-r--r--src/include/gnunet_block_plugin.h87
1 files changed, 86 insertions, 1 deletions
diff --git a/src/include/gnunet_block_plugin.h b/src/include/gnunet_block_plugin.h
index 5c320457e..d7454b5d5 100644
--- a/src/include/gnunet_block_plugin.h
+++ b/src/include/gnunet_block_plugin.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2010,2013 GNUnet e.V. 3 Copyright (C) 2010,2013,2017 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -40,6 +40,86 @@
40 40
41 41
42/** 42/**
43 * Serialize state of a block group.
44 *
45 * @param bg group to serialize
46 * @param[out] raw_data set to the serialized state
47 * @param[out] raw_data_size set to the number of bytes in @a raw_data
48 * @return #GNUNET_OK on success, #GNUNET_NO if serialization is not
49 * supported, #GNUNET_SYSERR on error
50 */
51typedef int
52(*GNUNET_BLOCK_GroupSerializeFunction)(struct GNUNET_BLOCK_Group *bg,
53 void **raw_data,
54 size_t *raw_data_size);
55
56
57/**
58 * Destroy resources used by a block group.
59 *
60 * @param bg group to destroy, NULL is allowed
61 */
62typedef void
63(*GNUNET_BLOCK_GroupDestroyFunction)(struct GNUNET_BLOCK_Group *bg);
64
65
66/**
67 * Block group data. The plugin must initialize the callbacks
68 * and can use the @e internal_cls as it likes.
69 */
70struct GNUNET_BLOCK_Group
71{
72
73 /**
74 * Context owning the block group. Set by the main block library.
75 */
76 struct GNUENT_BLOCK_Context *ctx;
77
78 /**
79 * Type for the block group. Set by the main block library.
80 */
81 enum GNUNET_BLOCK_Type type;
82
83 /**
84 * Serialize the block group data, can be NULL if
85 * not supported.
86 */
87 GNUNET_BLOCK_GroupSerializeFunction serialize_cb;
88
89 /**
90 * Function to call to destroy the block group.
91 * Must not be NULL.
92 */
93 GNUNET_BLOCK_GroupDestroyFunction destroy_cb;
94
95 /**
96 * Internal data structure of the plugin.
97 */
98 void *internal_cls;
99
100};
101
102
103/**
104 * Create a new block group.
105 *
106 * @param ctx block context in which the block group is created
107 * @param type type of the block for which we are creating the group
108 * @param nonce random value used to seed the group creation
109 * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh
110 * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh
111 * @return block group handle, NULL if block groups are not supported
112 * by this @a type of block (this is not an error)
113 */
114typedef struct GNUNET_BLOCK_Group *
115(*GNUNET_BLOCK_GroupCreateFunction)(void *cls,
116 enum GNUNET_BLOCK_Type type,
117 uint32_t nonce,
118 const void *raw_data,
119 size_t raw_data_size);
120
121
122/**
43 * Function called to validate a reply or a request. For 123 * Function called to validate a reply or a request. For
44 * request evaluation, simply pass "NULL" for the @a reply_block. 124 * request evaluation, simply pass "NULL" for the @a reply_block.
45 * Note that it is assumed that the reply has already been 125 * Note that it is assumed that the reply has already been
@@ -121,6 +201,11 @@ struct GNUNET_BLOCK_PluginFunctions
121 */ 201 */
122 GNUNET_BLOCK_GetKeyFunction get_key; 202 GNUNET_BLOCK_GetKeyFunction get_key;
123 203
204 /**
205 * Create a block group to process a bunch of blocks in a shared
206 * context (i.e. to detect duplicates).
207 */
208 GNUNET_BLOCK_GroupCreateFunction create_group;
124}; 209};
125 210
126#endif 211#endif