diff options
Diffstat (limited to 'src/seti/plugin_block_seti_test.c')
-rw-r--r-- | src/seti/plugin_block_seti_test.c | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/src/seti/plugin_block_seti_test.c b/src/seti/plugin_block_seti_test.c index 55cf31bea..af86e1af6 100644 --- a/src/seti/plugin_block_seti_test.c +++ b/src/seti/plugin_block_seti_test.c | |||
@@ -66,6 +66,87 @@ block_plugin_seti_test_evaluate (void *cls, | |||
66 | 66 | ||
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Function called to validate a query. | ||
70 | * | ||
71 | * @param cls closure | ||
72 | * @param ctx block context | ||
73 | * @param type block type | ||
74 | * @param query original query (hash) | ||
75 | * @param xquery extrended query data (can be NULL, depending on type) | ||
76 | * @param xquery_size number of bytes in @a xquery | ||
77 | * @return #GNUNET_OK if the query is fine, #GNUNET_NO if not | ||
78 | */ | ||
79 | static enum GNUNET_GenericReturnValue | ||
80 | block_plugin_seti_test_check_query (void *cls, | ||
81 | enum GNUNET_BLOCK_Type type, | ||
82 | const struct GNUNET_HashCode *query, | ||
83 | const void *xquery, | ||
84 | size_t xquery_size) | ||
85 | { | ||
86 | return GNUNET_OK; | ||
87 | } | ||
88 | |||
89 | |||
90 | /** | ||
91 | * Function called to validate a block for storage. | ||
92 | * | ||
93 | * @param cls closure | ||
94 | * @param type block type | ||
95 | * @param query key for the block (hash), must match exactly | ||
96 | * @param block block data to validate | ||
97 | * @param block_size number of bytes in @a block | ||
98 | * @return #GNUNET_OK if the block is fine, #GNUNET_NO if not | ||
99 | */ | ||
100 | static enum GNUNET_GenericReturnValue | ||
101 | block_plugin_seti_test_check_block (void *cls, | ||
102 | enum GNUNET_BLOCK_Type type, | ||
103 | const struct GNUNET_HashCode *query, | ||
104 | const void *block, | ||
105 | size_t block_size) | ||
106 | { | ||
107 | if ((NULL == block) || | ||
108 | (0 == block_size) || | ||
109 | (0 != ((char *) block)[0])) | ||
110 | return GNUNET_SYSERR; | ||
111 | return GNUNET_OK; | ||
112 | } | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Function called to validate a reply to a request. Note that it is assumed | ||
117 | * that the reply has already been matched to the key (and signatures checked) | ||
118 | * as it would be done with the GetKeyFunction and the | ||
119 | * BlockEvaluationFunction. | ||
120 | * | ||
121 | * @param cls closure | ||
122 | * @param type block type | ||
123 | * @param group which block group to use for evaluation | ||
124 | * @param query original query (hash) | ||
125 | * @param xquery extrended query data (can be NULL, depending on type) | ||
126 | * @param xquery_size number of bytes in @a xquery | ||
127 | * @param reply_block response to validate | ||
128 | * @param reply_block_size number of bytes in @a reply_block | ||
129 | * @return characterization of result | ||
130 | */ | ||
131 | static enum GNUNET_BLOCK_ReplyEvaluationResult | ||
132 | block_plugin_seti_test_check_reply (void *cls, | ||
133 | enum GNUNET_BLOCK_Type type, | ||
134 | struct GNUNET_BLOCK_Group *group, | ||
135 | const struct GNUNET_HashCode *query, | ||
136 | const void *xquery, | ||
137 | size_t xquery_size, | ||
138 | const void *reply_block, | ||
139 | size_t reply_block_size) | ||
140 | { | ||
141 | if ( (NULL == reply_block) || | ||
142 | (0 == reply_block_size) || | ||
143 | (0 != ((char *) reply_block)[0]) ) | ||
144 | return GNUNET_BLOCK_REPLY_INVALID; | ||
145 | return GNUNET_BLOCK_REPLY_OK_MORE; | ||
146 | } | ||
147 | |||
148 | |||
149 | /** | ||
69 | * Function called to obtain the key for a block. | 150 | * Function called to obtain the key for a block. |
70 | * | 151 | * |
71 | * @param cls closure | 152 | * @param cls closure |
@@ -76,7 +157,7 @@ block_plugin_seti_test_evaluate (void *cls, | |||
76 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported | 157 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if type not supported |
77 | * (or if extracting a key from a block of this type does not work) | 158 | * (or if extracting a key from a block of this type does not work) |
78 | */ | 159 | */ |
79 | static int | 160 | static enum GNUNET_GenericReturnValue |
80 | block_plugin_seti_test_get_key (void *cls, | 161 | block_plugin_seti_test_get_key (void *cls, |
81 | enum GNUNET_BLOCK_Type type, | 162 | enum GNUNET_BLOCK_Type type, |
82 | const void *block, | 163 | const void *block, |
@@ -102,6 +183,9 @@ libgnunet_plugin_block_seti_test_init (void *cls) | |||
102 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); | 183 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
103 | api->evaluate = &block_plugin_seti_test_evaluate; | 184 | api->evaluate = &block_plugin_seti_test_evaluate; |
104 | api->get_key = &block_plugin_seti_test_get_key; | 185 | api->get_key = &block_plugin_seti_test_get_key; |
186 | api->check_query = &block_plugin_seti_test_check_query; | ||
187 | api->check_block = &block_plugin_seti_test_check_block; | ||
188 | api->check_reply = &block_plugin_seti_test_check_reply; | ||
105 | api->types = types; | 189 | api->types = types; |
106 | return api; | 190 | return api; |
107 | } | 191 | } |