aboutsummaryrefslogtreecommitdiff
path: root/src/block
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/block
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/block')
-rw-r--r--src/block/block.c23
-rw-r--r--src/block/plugin_block_dht.c26
-rw-r--r--src/block/plugin_block_dns.c17
-rw-r--r--src/block/plugin_block_fs.c40
-rw-r--r--src/block/plugin_block_template.c16
-rw-r--r--src/block/plugin_block_test.c17
-rw-r--r--src/block/test_block.c20
7 files changed, 66 insertions, 93 deletions
diff --git a/src/block/block.c b/src/block/block.c
index bdef55aa3..ac466337c 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -72,8 +72,8 @@ struct GNUNET_BLOCK_Context
72 * @param hc where to store the result. 72 * @param hc where to store the result.
73 */ 73 */
74void 74void
75GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, 75GNUNET_BLOCK_mingle_hash (const GNUNET_HashCode * in, uint32_t mingle_number,
76 uint32_t mingle_number, GNUNET_HashCode * hc) 76 GNUNET_HashCode * hc)
77{ 77{
78 GNUNET_HashCode m; 78 GNUNET_HashCode m;
79 79
@@ -105,8 +105,8 @@ GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
105 if (GNUNET_OK == 105 if (GNUNET_OK ==
106 GNUNET_CONFIGURATION_get_value_string (cfg, "block", "PLUGINS", &plugs)) 106 GNUNET_CONFIGURATION_get_value_string (cfg, "block", "PLUGINS", &plugs))
107 { 107 {
108 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 108 GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading block plugins `%s'\n"),
109 _("Loading block plugins `%s'\n"), plugs); 109 plugs);
110 pos = strtok (plugs, " "); 110 pos = strtok (plugs, " ");
111 while (pos != NULL) 111 while (pos != NULL)
112 { 112 {
@@ -212,18 +212,16 @@ GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx,
212 enum GNUNET_BLOCK_Type type, 212 enum GNUNET_BLOCK_Type type,
213 const GNUNET_HashCode * query, 213 const GNUNET_HashCode * query,
214 struct GNUNET_CONTAINER_BloomFilter **bf, 214 struct GNUNET_CONTAINER_BloomFilter **bf,
215 int32_t bf_mutator, 215 int32_t bf_mutator, const void *xquery,
216 const void *xquery, 216 size_t xquery_size, const void *reply_block,
217 size_t xquery_size, 217 size_t reply_block_size)
218 const void *reply_block, size_t reply_block_size)
219{ 218{
220 struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type); 219 struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type);
221 220
222 if (plugin == NULL) 221 if (plugin == NULL)
223 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 222 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
224 return plugin->evaluate (plugin->cls, 223 return plugin->evaluate (plugin->cls, type, query, bf, bf_mutator, xquery,
225 type, query, bf, bf_mutator, 224 xquery_size, reply_block, reply_block_size);
226 xquery, xquery_size, reply_block, reply_block_size);
227} 225}
228 226
229 227
@@ -240,8 +238,7 @@ GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx,
240 */ 238 */
241int 239int
242GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx, 240GNUNET_BLOCK_get_key (struct GNUNET_BLOCK_Context *ctx,
243 enum GNUNET_BLOCK_Type type, 241 enum GNUNET_BLOCK_Type type, const void *block,
244 const void *block,
245 size_t block_size, GNUNET_HashCode * key) 242 size_t block_size, GNUNET_HashCode * key)
246{ 243{
247 struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type); 244 struct GNUNET_BLOCK_PluginFunctions *plugin = find_plugin (ctx, type);
diff --git a/src/block/plugin_block_dht.c b/src/block/plugin_block_dht.c
index 1fe51e1a3..614628a40 100644
--- a/src/block/plugin_block_dht.c
+++ b/src/block/plugin_block_dht.c
@@ -49,14 +49,12 @@
49 * @return characterization of result 49 * @return characterization of result
50 */ 50 */
51static enum GNUNET_BLOCK_EvaluationResult 51static enum GNUNET_BLOCK_EvaluationResult
52block_plugin_dht_evaluate (void *cls, 52block_plugin_dht_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
53 enum GNUNET_BLOCK_Type type,
54 const GNUNET_HashCode * query, 53 const GNUNET_HashCode * query,
55 struct GNUNET_CONTAINER_BloomFilter **bf, 54 struct GNUNET_CONTAINER_BloomFilter **bf,
56 int32_t bf_mutator, 55 int32_t bf_mutator, const void *xquery,
57 const void *xquery, 56 size_t xquery_size, const void *reply_block,
58 size_t xquery_size, 57 size_t reply_block_size)
59 const void *reply_block, size_t reply_block_size)
60{ 58{
61 switch (type) 59 switch (type)
62 { 60 {
@@ -85,10 +83,9 @@ block_plugin_dht_evaluate (void *cls,
85 * (or if extracting a key from a block of this type does not work) 83 * (or if extracting a key from a block of this type does not work)
86 */ 84 */
87static int 85static int
88block_plugin_dht_get_key (void *cls, 86block_plugin_dht_get_key (void *cls, enum GNUNET_BLOCK_Type type,
89 enum GNUNET_BLOCK_Type type, 87 const void *block, size_t block_size,
90 const void *block, 88 GNUNET_HashCode * key)
91 size_t block_size, GNUNET_HashCode * key)
92{ 89{
93 const struct GNUNET_MessageHeader *msg; 90 const struct GNUNET_MessageHeader *msg;
94 const struct GNUNET_HELLO_Message *hello; 91 const struct GNUNET_HELLO_Message *hello;
@@ -98,16 +95,14 @@ block_plugin_dht_get_key (void *cls,
98 return GNUNET_SYSERR; 95 return GNUNET_SYSERR;
99 if (block_size < sizeof (struct GNUNET_MessageHeader)) 96 if (block_size < sizeof (struct GNUNET_MessageHeader))
100 { 97 {
101 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 98 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht",
102 "block-dht",
103 _("Block not of type %u\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); 99 _("Block not of type %u\n"), GNUNET_BLOCK_TYPE_DHT_HELLO);
104 return GNUNET_NO; 100 return GNUNET_NO;
105 } 101 }
106 msg = block; 102 msg = block;
107 if (block_size != ntohs (msg->size)) 103 if (block_size != ntohs (msg->size))
108 { 104 {
109 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 105 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht",
110 "block-dht",
111 _("Size mismatch for block\n"), 106 _("Size mismatch for block\n"),
112 GNUNET_BLOCK_TYPE_DHT_HELLO); 107 GNUNET_BLOCK_TYPE_DHT_HELLO);
113 return GNUNET_NO; 108 return GNUNET_NO;
@@ -116,8 +111,7 @@ block_plugin_dht_get_key (void *cls,
116 pid = (struct GNUNET_PeerIdentity *) key; 111 pid = (struct GNUNET_PeerIdentity *) key;
117 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid)) 112 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid))
118 { 113 {
119 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, 114 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht",
120 "block-dht",
121 _("Block of type %u is malformed\n"), 115 _("Block of type %u is malformed\n"),
122 GNUNET_BLOCK_TYPE_DHT_HELLO); 116 GNUNET_BLOCK_TYPE_DHT_HELLO);
123 return GNUNET_NO; 117 return GNUNET_NO;
diff --git a/src/block/plugin_block_dns.c b/src/block/plugin_block_dns.c
index 0cf8c50e9..e20370685 100644
--- a/src/block/plugin_block_dns.c
+++ b/src/block/plugin_block_dns.c
@@ -47,14 +47,12 @@
47 * @return characterization of result 47 * @return characterization of result
48 */ 48 */
49static enum GNUNET_BLOCK_EvaluationResult 49static enum GNUNET_BLOCK_EvaluationResult
50block_plugin_dns_evaluate (void *cls, 50block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
51 enum GNUNET_BLOCK_Type type,
52 const GNUNET_HashCode * query, 51 const GNUNET_HashCode * query,
53 struct GNUNET_CONTAINER_BloomFilter **bf, 52 struct GNUNET_CONTAINER_BloomFilter **bf,
54 int32_t bf_mutator, 53 int32_t bf_mutator, const void *xquery,
55 const void *xquery, 54 size_t xquery_size, const void *reply_block,
56 size_t xquery_size, 55 size_t reply_block_size)
57 const void *reply_block, size_t reply_block_size)
58{ 56{
59 switch (type) 57 switch (type)
60 { 58 {
@@ -123,10 +121,9 @@ block_plugin_dns_evaluate (void *cls,
123 * (or if extracting a key from a block of this type does not work) 121 * (or if extracting a key from a block of this type does not work)
124 */ 122 */
125static int 123static int
126block_plugin_dns_get_key (void *cls, 124block_plugin_dns_get_key (void *cls, enum GNUNET_BLOCK_Type type,
127 enum GNUNET_BLOCK_Type type, 125 const void *block, size_t block_size,
128 const void *block, 126 GNUNET_HashCode * key)
129 size_t block_size, GNUNET_HashCode * key)
130{ 127{
131 if (type != GNUNET_BLOCK_TYPE_DNS) 128 if (type != GNUNET_BLOCK_TYPE_DNS)
132 return GNUNET_SYSERR; 129 return GNUNET_SYSERR;
diff --git a/src/block/plugin_block_fs.c b/src/block/plugin_block_fs.c
index db8e59991..627f21a10 100644
--- a/src/block/plugin_block_fs.c
+++ b/src/block/plugin_block_fs.c
@@ -56,14 +56,12 @@
56 * @return characterization of result 56 * @return characterization of result
57 */ 57 */
58static enum GNUNET_BLOCK_EvaluationResult 58static enum GNUNET_BLOCK_EvaluationResult
59block_plugin_fs_evaluate (void *cls, 59block_plugin_fs_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
60 enum GNUNET_BLOCK_Type type,
61 const GNUNET_HashCode * query, 60 const GNUNET_HashCode * query,
62 struct GNUNET_CONTAINER_BloomFilter **bf, 61 struct GNUNET_CONTAINER_BloomFilter **bf,
63 int32_t bf_mutator, 62 int32_t bf_mutator, const void *xquery,
64 const void *xquery, 63 size_t xquery_size, const void *reply_block,
65 size_t xquery_size, 64 size_t reply_block_size)
66 const void *reply_block, size_t reply_block_size)
67{ 65{
68 const struct SBlock *sb; 66 const struct SBlock *sb;
69 GNUNET_HashCode chash; 67 GNUNET_HashCode chash;
@@ -125,8 +123,7 @@ block_plugin_fs_evaluate (void *cls,
125 &sh); 123 &sh);
126 if (0 != memcmp (nsid, &sh, sizeof (GNUNET_HashCode))) 124 if (0 != memcmp (nsid, &sh, sizeof (GNUNET_HashCode)))
127 { 125 {
128 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, 126 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "block-fs",
129 "block-fs",
130 _ 127 _
131 ("Reply mismatched in terms of namespace. Discarded.\n")); 128 ("Reply mismatched in terms of namespace. Discarded.\n"));
132 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 129 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
@@ -162,10 +159,9 @@ block_plugin_fs_evaluate (void *cls,
162 * (or if extracting a key from a block of this type does not work) 159 * (or if extracting a key from a block of this type does not work)
163 */ 160 */
164static int 161static int
165block_plugin_fs_get_key (void *cls, 162block_plugin_fs_get_key (void *cls, enum GNUNET_BLOCK_Type type,
166 enum GNUNET_BLOCK_Type type, 163 const void *block, size_t block_size,
167 const void *block, 164 GNUNET_HashCode * key)
168 size_t block_size, GNUNET_HashCode * key)
169{ 165{
170 const struct KBlock *kb; 166 const struct KBlock *kb;
171 const struct SBlock *sb; 167 const struct SBlock *sb;
@@ -185,9 +181,9 @@ block_plugin_fs_get_key (void *cls,
185 } 181 }
186 kb = block; 182 kb = block;
187 if (block_size - sizeof (struct KBlock) != 183 if (block_size - sizeof (struct KBlock) !=
188 ntohl (kb->purpose.size) 184 ntohl (kb->purpose.size) -
189 - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) 185 sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) -
190 - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)) 186 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))
191 { 187 {
192 GNUNET_break_op (0); 188 GNUNET_break_op (0);
193 return GNUNET_NO; 189 return GNUNET_NO;
@@ -236,9 +232,9 @@ block_plugin_fs_get_key (void *cls,
236 } 232 }
237 nb = block; 233 nb = block;
238 if (block_size - sizeof (struct NBlock) != 234 if (block_size - sizeof (struct NBlock) !=
239 ntohl (nb->ns_purpose.size) 235 ntohl (nb->ns_purpose.size) -
240 - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) 236 sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) -
241 - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)) 237 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))
242 { 238 {
243 GNUNET_break_op (0); 239 GNUNET_break_op (0);
244 return GNUNET_NO; 240 return GNUNET_NO;
@@ -252,16 +248,16 @@ block_plugin_fs_get_key (void *cls,
252 } 248 }
253 if (GNUNET_OK != 249 if (GNUNET_OK !=
254 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG, 250 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG,
255 &nb->ksk_purpose, 251 &nb->ksk_purpose, &nb->ksk_signature,
256 &nb->ksk_signature, &nb->keyspace)) 252 &nb->keyspace))
257 { 253 {
258 GNUNET_break_op (0); 254 GNUNET_break_op (0);
259 return GNUNET_NO; 255 return GNUNET_NO;
260 } 256 }
261 if (GNUNET_OK != 257 if (GNUNET_OK !=
262 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK, 258 GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK,
263 &nb->ns_purpose, 259 &nb->ns_purpose, &nb->ns_signature,
264 &nb->ns_signature, &nb->subspace)) 260 &nb->subspace))
265 { 261 {
266 GNUNET_break_op (0); 262 GNUNET_break_op (0);
267 return GNUNET_NO; 263 return GNUNET_NO;
diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c
index 9eb84ac4b..7ce3004eb 100644
--- a/src/block/plugin_block_template.c
+++ b/src/block/plugin_block_template.c
@@ -46,14 +46,11 @@
46 * @return characterization of result 46 * @return characterization of result
47 */ 47 */
48static enum GNUNET_BLOCK_EvaluationResult 48static enum GNUNET_BLOCK_EvaluationResult
49block_plugin_template_evaluate (void *cls, 49block_plugin_template_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
50 enum GNUNET_BLOCK_Type type,
51 const GNUNET_HashCode * query, 50 const GNUNET_HashCode * query,
52 struct GNUNET_CONTAINER_BloomFilter **bf, 51 struct GNUNET_CONTAINER_BloomFilter **bf,
53 int32_t bf_mutator, 52 int32_t bf_mutator, const void *xquery,
54 const void *xquery, 53 size_t xquery_size, const void *reply_block,
55 size_t xquery_size,
56 const void *reply_block,
57 size_t reply_block_size) 54 size_t reply_block_size)
58{ 55{
59 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 56 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
@@ -72,10 +69,9 @@ block_plugin_template_evaluate (void *cls,
72 * (or if extracting a key from a block of this type does not work) 69 * (or if extracting a key from a block of this type does not work)
73 */ 70 */
74static int 71static int
75block_plugin_template_get_key (void *cls, 72block_plugin_template_get_key (void *cls, enum GNUNET_BLOCK_Type type,
76 enum GNUNET_BLOCK_Type type, 73 const void *block, size_t block_size,
77 const void *block, 74 GNUNET_HashCode * key)
78 size_t block_size, GNUNET_HashCode * key)
79{ 75{
80 return GNUNET_SYSERR; 76 return GNUNET_SYSERR;
81} 77}
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c
index b5c03eea9..6fa535afe 100644
--- a/src/block/plugin_block_test.c
+++ b/src/block/plugin_block_test.c
@@ -53,14 +53,12 @@
53 * @return characterization of result 53 * @return characterization of result
54 */ 54 */
55static enum GNUNET_BLOCK_EvaluationResult 55static enum GNUNET_BLOCK_EvaluationResult
56block_plugin_test_evaluate (void *cls, 56block_plugin_test_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
57 enum GNUNET_BLOCK_Type type,
58 const GNUNET_HashCode * query, 57 const GNUNET_HashCode * query,
59 struct GNUNET_CONTAINER_BloomFilter **bf, 58 struct GNUNET_CONTAINER_BloomFilter **bf,
60 int32_t bf_mutator, 59 int32_t bf_mutator, const void *xquery,
61 const void *xquery, 60 size_t xquery_size, const void *reply_block,
62 size_t xquery_size, 61 size_t reply_block_size)
63 const void *reply_block, size_t reply_block_size)
64{ 62{
65 GNUNET_HashCode chash; 63 GNUNET_HashCode chash;
66 GNUNET_HashCode mhash; 64 GNUNET_HashCode mhash;
@@ -100,10 +98,9 @@ block_plugin_test_evaluate (void *cls,
100 * (or if extracting a key from a block of this type does not work) 98 * (or if extracting a key from a block of this type does not work)
101 */ 99 */
102static int 100static int
103block_plugin_test_get_key (void *cls, 101block_plugin_test_get_key (void *cls, enum GNUNET_BLOCK_Type type,
104 enum GNUNET_BLOCK_Type type, 102 const void *block, size_t block_size,
105 const void *block, 103 GNUNET_HashCode * key)
106 size_t block_size, GNUNET_HashCode * key)
107{ 104{
108 /* always fails since there is no fixed relationship between 105 /* always fails since there is no fixed relationship between
109 * keys and values for test values */ 106 * keys and values for test values */
diff --git a/src/block/test_block.c b/src/block/test_block.c
index 4bfd63ceb..f7a3422e0 100644
--- a/src/block/test_block.c
+++ b/src/block/test_block.c
@@ -37,25 +37,21 @@ test_fs (struct GNUNET_BLOCK_Context *ctx)
37 37
38 memset (block, 1, sizeof (block)); 38 memset (block, 1, sizeof (block));
39 if (GNUNET_OK != 39 if (GNUNET_OK !=
40 GNUNET_BLOCK_get_key (ctx, 40 GNUNET_BLOCK_get_key (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, block,
41 GNUNET_BLOCK_TYPE_FS_DBLOCK, 41 sizeof (block), &key))
42 block, sizeof (block), &key))
43 return 1; 42 return 1;
44 if (GNUNET_BLOCK_EVALUATION_OK_LAST != 43 if (GNUNET_BLOCK_EVALUATION_OK_LAST !=
45 GNUNET_BLOCK_evaluate (ctx, 44 GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
46 GNUNET_BLOCK_TYPE_FS_DBLOCK, 45 NULL, 0, block, sizeof (block)))
47 &key, NULL, 0, NULL, 0, block, sizeof (block)))
48 return 2; 46 return 2;
49 if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID != 47 if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID !=
50 GNUNET_BLOCK_evaluate (ctx, 48 GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
51 GNUNET_BLOCK_TYPE_FS_DBLOCK, 49 NULL, 0, NULL, 0))
52 &key, NULL, 0, NULL, 0, NULL, 0))
53 return 4; 50 return 4;
54 GNUNET_log_skip (1, GNUNET_NO); 51 GNUNET_log_skip (1, GNUNET_NO);
55 if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID != 52 if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID !=
56 GNUNET_BLOCK_evaluate (ctx, 53 GNUNET_BLOCK_evaluate (ctx, GNUNET_BLOCK_TYPE_FS_DBLOCK, &key, NULL, 0,
57 GNUNET_BLOCK_TYPE_FS_DBLOCK, 54 "bogus", 5, NULL, 0))
58 &key, NULL, 0, "bogus", 5, NULL, 0))
59 return 8; 55 return 8;
60 GNUNET_log_skip (0, GNUNET_YES); 56 GNUNET_log_skip (0, GNUNET_YES);
61 return 0; 57 return 0;