aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/gnunet-service-revocation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/revocation/gnunet-service-revocation.c')
-rw-r--r--src/revocation/gnunet-service-revocation.c985
1 files changed, 493 insertions, 492 deletions
diff --git a/src/revocation/gnunet-service-revocation.c b/src/revocation/gnunet-service-revocation.c
index e4ea1f2ff..62be5a96b 100644
--- a/src/revocation/gnunet-service-revocation.c
+++ b/src/revocation/gnunet-service-revocation.c
@@ -1,19 +1,19 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2013, 2014, 2016 GNUnet e.V. 3 Copyright (C) 2013, 2014, 2016 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License, 7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 */ 19 */
@@ -53,9 +53,7 @@
53/** 53/**
54 * Per-peer information. 54 * Per-peer information.
55 */ 55 */
56struct PeerEntry 56struct PeerEntry {
57{
58
59 /** 57 /**
60 * Queue for sending messages to this peer. 58 * Queue for sending messages to this peer.
61 */ 59 */
@@ -75,7 +73,6 @@ struct PeerEntry
75 * Handle to active set union operation (over revocation sets). 73 * Handle to active set union operation (over revocation sets).
76 */ 74 */
77 struct GNUNET_SET_OperationHandle *so; 75 struct GNUNET_SET_OperationHandle *so;
78
79}; 76};
80 77
81 78
@@ -148,13 +145,13 @@ new_peer_entry(const struct GNUNET_PeerIdentity *peer)
148{ 145{
149 struct PeerEntry *peer_entry; 146 struct PeerEntry *peer_entry;
150 147
151 peer_entry = GNUNET_new (struct PeerEntry); 148 peer_entry = GNUNET_new(struct PeerEntry);
152 peer_entry->id = *peer; 149 peer_entry->id = *peer;
153 GNUNET_assert (GNUNET_OK == 150 GNUNET_assert(GNUNET_OK ==
154 GNUNET_CONTAINER_multipeermap_put (peers, 151 GNUNET_CONTAINER_multipeermap_put(peers,
155 &peer_entry->id, 152 &peer_entry->id,
156 peer_entry, 153 peer_entry,
157 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 154 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
158 return peer_entry; 155 return peer_entry;
159} 156}
160 157
@@ -167,27 +164,27 @@ new_peer_entry(const struct GNUNET_PeerIdentity *peer)
167 * #GNUNET_NO if the key/signature don't verify 164 * #GNUNET_NO if the key/signature don't verify
168 */ 165 */
169static int 166static int
170verify_revoke_message (const struct RevokeMessage *rm) 167verify_revoke_message(const struct RevokeMessage *rm)
171{ 168{
172 if (GNUNET_YES != 169 if (GNUNET_YES !=
173 GNUNET_REVOCATION_check_pow (&rm->public_key, 170 GNUNET_REVOCATION_check_pow(&rm->public_key,
174 rm->proof_of_work, 171 rm->proof_of_work,
175 (unsigned int) revocation_work_required)) 172 (unsigned int)revocation_work_required))
176 { 173 {
177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 174 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
178 "Proof of work invalid!\n"); 175 "Proof of work invalid!\n");
179 GNUNET_break_op (0); 176 GNUNET_break_op(0);
180 return GNUNET_NO; 177 return GNUNET_NO;
181 } 178 }
182 if (GNUNET_OK != 179 if (GNUNET_OK !=
183 GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_REVOCATION, 180 GNUNET_CRYPTO_ecdsa_verify(GNUNET_SIGNATURE_PURPOSE_REVOCATION,
184 &rm->purpose, 181 &rm->purpose,
185 &rm->signature, 182 &rm->signature,
186 &rm->public_key)) 183 &rm->public_key))
187 { 184 {
188 GNUNET_break_op (0); 185 GNUNET_break_op(0);
189 return GNUNET_NO; 186 return GNUNET_NO;
190 } 187 }
191 return GNUNET_YES; 188 return GNUNET_YES;
192} 189}
193 190
@@ -201,9 +198,9 @@ verify_revoke_message (const struct RevokeMessage *rm)
201 * @return @a client 198 * @return @a client
202 */ 199 */
203static void * 200static void *
204client_connect_cb (void *cls, 201client_connect_cb(void *cls,
205 struct GNUNET_SERVICE_Client *client, 202 struct GNUNET_SERVICE_Client *client,
206 struct GNUNET_MQ_Handle *mq) 203 struct GNUNET_MQ_Handle *mq)
207{ 204{
208 return client; 205 return client;
209} 206}
@@ -217,11 +214,11 @@ client_connect_cb (void *cls,
217 * @param app_cls must alias @a client 214 * @param app_cls must alias @a client
218 */ 215 */
219static void 216static void
220client_disconnect_cb (void *cls, 217client_disconnect_cb(void *cls,
221 struct GNUNET_SERVICE_Client *client, 218 struct GNUNET_SERVICE_Client *client,
222 void *app_cls) 219 void *app_cls)
223{ 220{
224 GNUNET_assert (client == app_cls); 221 GNUNET_assert(client == app_cls);
225} 222}
226 223
227 224
@@ -232,8 +229,8 @@ client_disconnect_cb (void *cls,
232 * @param qm the message received 229 * @param qm the message received
233 */ 230 */
234static void 231static void
235handle_query_message (void *cls, 232handle_query_message(void *cls,
236 const struct QueryMessage *qm) 233 const struct QueryMessage *qm)
237{ 234{
238 struct GNUNET_SERVICE_Client *client = cls; 235 struct GNUNET_SERVICE_Client *client = cls;
239 struct GNUNET_MQ_Envelope *env; 236 struct GNUNET_MQ_Envelope *env;
@@ -241,22 +238,22 @@ handle_query_message (void *cls,
241 struct GNUNET_HashCode hc; 238 struct GNUNET_HashCode hc;
242 int res; 239 int res;
243 240
244 GNUNET_CRYPTO_hash (&qm->key, 241 GNUNET_CRYPTO_hash(&qm->key,
245 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), 242 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
246 &hc); 243 &hc);
247 res = GNUNET_CONTAINER_multihashmap_contains (revocation_map, 244 res = GNUNET_CONTAINER_multihashmap_contains(revocation_map,
248 &hc); 245 &hc);
249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 246 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
250 (GNUNET_NO == res) 247 (GNUNET_NO == res)
251 ? "Received revocation check for valid key `%s' from client\n" 248 ? "Received revocation check for valid key `%s' from client\n"
252 : "Received revocation check for revoked key `%s' from client\n", 249 : "Received revocation check for revoked key `%s' from client\n",
253 GNUNET_h2s (&hc)); 250 GNUNET_h2s(&hc));
254 env = GNUNET_MQ_msg (qrm, 251 env = GNUNET_MQ_msg(qrm,
255 GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE); 252 GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE);
256 qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES); 253 qrm->is_valid = htonl((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
257 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 254 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client),
258 env); 255 env);
259 GNUNET_SERVICE_client_continue (client); 256 GNUNET_SERVICE_client_continue(client);
260} 257}
261 258
262 259
@@ -269,9 +266,9 @@ handle_query_message (void *cls,
269 * @return #GNUNET_OK (continue to iterate) 266 * @return #GNUNET_OK (continue to iterate)
270 */ 267 */
271static int 268static int
272do_flood (void *cls, 269do_flood(void *cls,
273 const struct GNUNET_PeerIdentity *target, 270 const struct GNUNET_PeerIdentity *target,
274 void *value) 271 void *value)
275{ 272{
276 const struct RevokeMessage *rm = cls; 273 const struct RevokeMessage *rm = cls;
277 struct PeerEntry *pe = value; 274 struct PeerEntry *pe = value;
@@ -280,16 +277,16 @@ do_flood (void *cls,
280 277
281 if (NULL == pe->mq) 278 if (NULL == pe->mq)
282 return GNUNET_OK; /* peer connected to us via SET, 279 return GNUNET_OK; /* peer connected to us via SET,
283 but we have no direct CORE 280 but we have no direct CORE
284 connection for flooding */ 281 connection for flooding */
285 e = GNUNET_MQ_msg (cp, 282 e = GNUNET_MQ_msg(cp,
286 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE); 283 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE);
287 *cp = *rm; 284 *cp = *rm;
288 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 285 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
289 "Flooding revocation to `%s'\n", 286 "Flooding revocation to `%s'\n",
290 GNUNET_i2s (target)); 287 GNUNET_i2s(target));
291 GNUNET_MQ_send (pe->mq, 288 GNUNET_MQ_send(pe->mq,
292 e); 289 e);
293 return GNUNET_OK; 290 return GNUNET_OK;
294} 291}
295 292
@@ -304,75 +301,75 @@ do_flood (void *cls,
304 * #GNUNET_SYSERR if the message was malformed 301 * #GNUNET_SYSERR if the message was malformed
305 */ 302 */
306static int 303static int
307publicize_rm (const struct RevokeMessage *rm) 304publicize_rm(const struct RevokeMessage *rm)
308{ 305{
309 struct RevokeMessage *cp; 306 struct RevokeMessage *cp;
310 struct GNUNET_HashCode hc; 307 struct GNUNET_HashCode hc;
311 struct GNUNET_SET_Element e; 308 struct GNUNET_SET_Element e;
312 309
313 GNUNET_CRYPTO_hash (&rm->public_key, 310 GNUNET_CRYPTO_hash(&rm->public_key,
314 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), 311 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
315 &hc); 312 &hc);
316 if (GNUNET_YES == 313 if (GNUNET_YES ==
317 GNUNET_CONTAINER_multihashmap_contains (revocation_map, 314 GNUNET_CONTAINER_multihashmap_contains(revocation_map,
318 &hc)) 315 &hc))
319 { 316 {
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 317 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
321 "Duplicate revocation received from peer. Ignored.\n"); 318 "Duplicate revocation received from peer. Ignored.\n");
322 return GNUNET_OK; 319 return GNUNET_OK;
323 } 320 }
324 if (GNUNET_OK != 321 if (GNUNET_OK !=
325 verify_revoke_message (rm)) 322 verify_revoke_message(rm))
326 { 323 {
327 GNUNET_break_op (0); 324 GNUNET_break_op(0);
328 return GNUNET_SYSERR; 325 return GNUNET_SYSERR;
329 } 326 }
330 /* write to disk */ 327 /* write to disk */
331 if (sizeof (struct RevokeMessage) != 328 if (sizeof(struct RevokeMessage) !=
332 GNUNET_DISK_file_write (revocation_db, 329 GNUNET_DISK_file_write(revocation_db,
333 rm, 330 rm,
334 sizeof (struct RevokeMessage))) 331 sizeof(struct RevokeMessage)))
335 { 332 {
336 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, 333 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR,
337 "write"); 334 "write");
338 return GNUNET_NO; 335 return GNUNET_NO;
339 } 336 }
340 if (GNUNET_OK != 337 if (GNUNET_OK !=
341 GNUNET_DISK_file_sync (revocation_db)) 338 GNUNET_DISK_file_sync(revocation_db))
342 { 339 {
343 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, 340 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR,
344 "sync"); 341 "sync");
345 return GNUNET_NO; 342 return GNUNET_NO;
346 } 343 }
347 /* keep copy in memory */ 344 /* keep copy in memory */
348 cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header); 345 cp = (struct RevokeMessage *)GNUNET_copy_message(&rm->header);
349 GNUNET_break (GNUNET_OK == 346 GNUNET_break(GNUNET_OK ==
350 GNUNET_CONTAINER_multihashmap_put (revocation_map, 347 GNUNET_CONTAINER_multihashmap_put(revocation_map,
351 &hc, 348 &hc,
352 cp, 349 cp,
353 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 350 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
354 /* add to set for future connections */ 351 /* add to set for future connections */
355 e.size = htons (rm->header.size); 352 e.size = htons(rm->header.size);
356 e.element_type = GNUNET_BLOCK_TYPE_REVOCATION; 353 e.element_type = GNUNET_BLOCK_TYPE_REVOCATION;
357 e.data = rm; 354 e.data = rm;
358 if (GNUNET_OK != 355 if (GNUNET_OK !=
359 GNUNET_SET_add_element (revocation_set, 356 GNUNET_SET_add_element(revocation_set,
360 &e, 357 &e,
361 NULL, 358 NULL,
362 NULL)) 359 NULL))
363 { 360 {
364 GNUNET_break (0); 361 GNUNET_break(0);
365 return GNUNET_OK; 362 return GNUNET_OK;
366 } 363 }
367 else 364 else
368 { 365 {
369 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 366 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
370 "Added revocation info to SET\n"); 367 "Added revocation info to SET\n");
371 } 368 }
372 /* flood to neighbours */ 369 /* flood to neighbours */
373 GNUNET_CONTAINER_multipeermap_iterate (peers, 370 GNUNET_CONTAINER_multipeermap_iterate(peers,
374 &do_flood, 371 &do_flood,
375 cp); 372 cp);
376 return GNUNET_OK; 373 return GNUNET_OK;
377} 374}
378 375
@@ -384,28 +381,28 @@ publicize_rm (const struct RevokeMessage *rm)
384 * @param rm the message received 381 * @param rm the message received
385 */ 382 */
386static void 383static void
387handle_revoke_message (void *cls, 384handle_revoke_message(void *cls,
388 const struct RevokeMessage *rm) 385 const struct RevokeMessage *rm)
389{ 386{
390 struct GNUNET_SERVICE_Client *client = cls; 387 struct GNUNET_SERVICE_Client *client = cls;
391 struct GNUNET_MQ_Envelope *env; 388 struct GNUNET_MQ_Envelope *env;
392 struct RevocationResponseMessage *rrm; 389 struct RevocationResponseMessage *rrm;
393 int ret; 390 int ret;
394 391
395 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 392 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
396 "Received REVOKE message from client\n"); 393 "Received REVOKE message from client\n");
397 if (GNUNET_SYSERR == (ret = publicize_rm (rm))) 394 if (GNUNET_SYSERR == (ret = publicize_rm(rm)))
398 { 395 {
399 GNUNET_break_op (0); 396 GNUNET_break_op(0);
400 GNUNET_SERVICE_client_drop (client); 397 GNUNET_SERVICE_client_drop(client);
401 return; 398 return;
402 } 399 }
403 env = GNUNET_MQ_msg (rrm, 400 env = GNUNET_MQ_msg(rrm,
404 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE); 401 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE);
405 rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES); 402 rrm->is_valid = htonl((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
406 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), 403 GNUNET_MQ_send(GNUNET_SERVICE_client_get_mq(client),
407 env); 404 env);
408 GNUNET_SERVICE_client_continue (client); 405 GNUNET_SERVICE_client_continue(client);
409} 406}
410 407
411 408
@@ -416,13 +413,13 @@ handle_revoke_message (void *cls,
416 * @param rm revocation message 413 * @param rm revocation message
417 */ 414 */
418static void 415static void
419handle_p2p_revoke (void *cls, 416handle_p2p_revoke(void *cls,
420 const struct RevokeMessage *rm) 417 const struct RevokeMessage *rm)
421{ 418{
422 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 419 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
423 "Received REVOKE message\n"); 420 "Received REVOKE message\n");
424 GNUNET_break_op (GNUNET_SYSERR != 421 GNUNET_break_op(GNUNET_SYSERR !=
425 publicize_rm (rm)); 422 publicize_rm(rm));
426} 423}
427 424
428 425
@@ -437,60 +434,64 @@ handle_p2p_revoke (void *cls,
437 * @param status see `enum GNUNET_SET_Status` 434 * @param status see `enum GNUNET_SET_Status`
438 */ 435 */
439static void 436static void
440add_revocation (void *cls, 437add_revocation(void *cls,
441 const struct GNUNET_SET_Element *element, 438 const struct GNUNET_SET_Element *element,
442 uint64_t current_size, 439 uint64_t current_size,
443 enum GNUNET_SET_Status status) 440 enum GNUNET_SET_Status status)
444{ 441{
445 struct PeerEntry *peer_entry = cls; 442 struct PeerEntry *peer_entry = cls;
446 const struct RevokeMessage *rm; 443 const struct RevokeMessage *rm;
447 444
448 switch (status) 445 switch (status)
449 {
450 case GNUNET_SET_STATUS_OK:
451 if (element->size != sizeof (struct RevokeMessage))
452 { 446 {
453 GNUNET_break_op (0); 447 case GNUNET_SET_STATUS_OK:
454 return; 448 if (element->size != sizeof(struct RevokeMessage))
449 {
450 GNUNET_break_op(0);
451 return;
452 }
453 if (GNUNET_BLOCK_TYPE_REVOCATION != element->element_type)
454 {
455 GNUNET_STATISTICS_update(stats,
456 gettext_noop("# unsupported revocations received via set union"),
457 1,
458 GNUNET_NO);
459 return;
460 }
461 rm = element->data;
462 (void)handle_p2p_revoke(NULL,
463 rm);
464 GNUNET_STATISTICS_update(stats,
465 gettext_noop("# revocation messages received via set union"),
466 1, GNUNET_NO);
467 break;
468
469 case GNUNET_SET_STATUS_FAILURE:
470 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
471 _("Error computing revocation set union with %s\n"),
472 GNUNET_i2s(&peer_entry->id));
473 peer_entry->so = NULL;
474 GNUNET_STATISTICS_update(stats,
475 gettext_noop("# revocation set unions failed"),
476 1,
477 GNUNET_NO);
478 break;
479
480 case GNUNET_SET_STATUS_HALF_DONE:
481 break;
482
483 case GNUNET_SET_STATUS_DONE:
484 peer_entry->so = NULL;
485 GNUNET_STATISTICS_update(stats,
486 gettext_noop("# revocation set unions completed"),
487 1,
488 GNUNET_NO);
489 break;
490
491 default:
492 GNUNET_break(0);
493 break;
455 } 494 }
456 if (GNUNET_BLOCK_TYPE_REVOCATION != element->element_type)
457 {
458 GNUNET_STATISTICS_update (stats,
459 gettext_noop ("# unsupported revocations received via set union"),
460 1,
461 GNUNET_NO);
462 return;
463 }
464 rm = element->data;
465 (void) handle_p2p_revoke (NULL,
466 rm);
467 GNUNET_STATISTICS_update (stats,
468 gettext_noop ("# revocation messages received via set union"),
469 1, GNUNET_NO);
470 break;
471 case GNUNET_SET_STATUS_FAILURE:
472 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
473 _("Error computing revocation set union with %s\n"),
474 GNUNET_i2s (&peer_entry->id));
475 peer_entry->so = NULL;
476 GNUNET_STATISTICS_update (stats,
477 gettext_noop ("# revocation set unions failed"),
478 1,
479 GNUNET_NO);
480 break;
481 case GNUNET_SET_STATUS_HALF_DONE:
482 break;
483 case GNUNET_SET_STATUS_DONE:
484 peer_entry->so = NULL;
485 GNUNET_STATISTICS_update (stats,
486 gettext_noop ("# revocation set unions completed"),
487 1,
488 GNUNET_NO);
489 break;
490 default:
491 GNUNET_break (0);
492 break;
493 }
494} 495}
495 496
496 497
@@ -501,31 +502,31 @@ add_revocation (void *cls,
501 * @param cls NULL 502 * @param cls NULL
502 */ 503 */
503static void 504static void
504transmit_task_cb (void *cls) 505transmit_task_cb(void *cls)
505{ 506{
506 struct PeerEntry *peer_entry = cls; 507 struct PeerEntry *peer_entry = cls;
507 508
508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 509 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
509 "Starting set exchange with peer `%s'\n", 510 "Starting set exchange with peer `%s'\n",
510 GNUNET_i2s (&peer_entry->id)); 511 GNUNET_i2s(&peer_entry->id));
511 peer_entry->transmit_task = NULL; 512 peer_entry->transmit_task = NULL;
512 GNUNET_assert (NULL == peer_entry->so); 513 GNUNET_assert(NULL == peer_entry->so);
513 peer_entry->so = GNUNET_SET_prepare (&peer_entry->id, 514 peer_entry->so = GNUNET_SET_prepare(&peer_entry->id,
514 &revocation_set_union_app_id, 515 &revocation_set_union_app_id,
515 NULL, 516 NULL,
516 GNUNET_SET_RESULT_ADDED, 517 GNUNET_SET_RESULT_ADDED,
517 (struct GNUNET_SET_Option[]) {{ 0 }}, 518 (struct GNUNET_SET_Option[]) { { 0 } },
518 &add_revocation, 519 &add_revocation,
519 peer_entry); 520 peer_entry);
520 if (GNUNET_OK != 521 if (GNUNET_OK !=
521 GNUNET_SET_commit (peer_entry->so, 522 GNUNET_SET_commit(peer_entry->so,
522 revocation_set)) 523 revocation_set))
523 { 524 {
524 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 525 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
525 _("SET service crashed, terminating revocation service\n")); 526 _("SET service crashed, terminating revocation service\n"));
526 GNUNET_SCHEDULER_shutdown (); 527 GNUNET_SCHEDULER_shutdown();
527 return; 528 return;
528 } 529 }
529} 530}
530 531
531 532
@@ -537,57 +538,57 @@ transmit_task_cb (void *cls)
537 * @param peer peer identity this notification is about 538 * @param peer peer identity this notification is about
538 */ 539 */
539static void * 540static void *
540handle_core_connect (void *cls, 541handle_core_connect(void *cls,
541 const struct GNUNET_PeerIdentity *peer, 542 const struct GNUNET_PeerIdentity *peer,
542 struct GNUNET_MQ_Handle *mq) 543 struct GNUNET_MQ_Handle *mq)
543{ 544{
544 struct PeerEntry *peer_entry; 545 struct PeerEntry *peer_entry;
545 struct GNUNET_HashCode my_hash; 546 struct GNUNET_HashCode my_hash;
546 struct GNUNET_HashCode peer_hash; 547 struct GNUNET_HashCode peer_hash;
547 548
548 if (0 == GNUNET_memcmp (peer, 549 if (0 == GNUNET_memcmp(peer,
549 &my_identity)) 550 &my_identity))
550 { 551 {
551 return NULL; 552 return NULL;
552 } 553 }
553 554
554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 555 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
555 "Peer `%s' connected to us\n", 556 "Peer `%s' connected to us\n",
556 GNUNET_i2s (peer)); 557 GNUNET_i2s(peer));
557 GNUNET_STATISTICS_update (stats, 558 GNUNET_STATISTICS_update(stats,
558 "# peers connected", 559 "# peers connected",
559 1, 560 1,
560 GNUNET_NO); 561 GNUNET_NO);
561 peer_entry = GNUNET_CONTAINER_multipeermap_get (peers, 562 peer_entry = GNUNET_CONTAINER_multipeermap_get(peers,
562 peer); 563 peer);
563 if (NULL != peer_entry) 564 if (NULL != peer_entry)
564 { 565 {
565 /* This can happen if "core"'s notification is a tad late 566 /* This can happen if "core"'s notification is a tad late
566 and CADET+SET were faster and already produced a 567 and CADET+SET were faster and already produced a
567 #handle_revocation_union_request() for us to deal 568 #handle_revocation_union_request() for us to deal
568 with. This should be rare, but isn't impossible. */ 569 with. This should be rare, but isn't impossible. */
569 peer_entry->mq = mq; 570 peer_entry->mq = mq;
570 return peer_entry; 571 return peer_entry;
571 } 572 }
572 peer_entry = new_peer_entry (peer); 573 peer_entry = new_peer_entry(peer);
573 peer_entry->mq = mq; 574 peer_entry->mq = mq;
574 GNUNET_CRYPTO_hash (&my_identity, 575 GNUNET_CRYPTO_hash(&my_identity,
575 sizeof (my_identity), 576 sizeof(my_identity),
576 &my_hash); 577 &my_hash);
577 GNUNET_CRYPTO_hash (peer, 578 GNUNET_CRYPTO_hash(peer,
578 sizeof (*peer), 579 sizeof(*peer),
579 &peer_hash); 580 &peer_hash);
580 if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash, 581 if (0 < GNUNET_CRYPTO_hash_cmp(&my_hash,
581 &peer_hash)) 582 &peer_hash))
582 { 583 {
583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 584 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
584 "Starting SET operation with peer `%s'\n", 585 "Starting SET operation with peer `%s'\n",
585 GNUNET_i2s (peer)); 586 GNUNET_i2s(peer));
586 peer_entry->transmit_task = 587 peer_entry->transmit_task =
587 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 588 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS,
588 &transmit_task_cb, 589 &transmit_task_cb,
589 peer_entry); 590 peer_entry);
590 } 591 }
591 return peer_entry; 592 return peer_entry;
592} 593}
593 594
@@ -601,38 +602,38 @@ handle_core_connect (void *cls,
601 * @param internal_cls our `struct PeerEntry` for this peer 602 * @param internal_cls our `struct PeerEntry` for this peer
602 */ 603 */
603static void 604static void
604handle_core_disconnect (void *cls, 605handle_core_disconnect(void *cls,
605 const struct GNUNET_PeerIdentity *peer, 606 const struct GNUNET_PeerIdentity *peer,
606 void *internal_cls) 607 void *internal_cls)
607{ 608{
608 struct PeerEntry *peer_entry = internal_cls; 609 struct PeerEntry *peer_entry = internal_cls;
609 610
610 if (0 == GNUNET_memcmp (peer, 611 if (0 == GNUNET_memcmp(peer,
611 &my_identity)) 612 &my_identity))
612 return; 613 return;
613 GNUNET_assert (NULL != peer_entry); 614 GNUNET_assert(NULL != peer_entry);
614 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 615 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
615 "Peer `%s' disconnected from us\n", 616 "Peer `%s' disconnected from us\n",
616 GNUNET_i2s (peer)); 617 GNUNET_i2s(peer));
617 GNUNET_assert (GNUNET_YES == 618 GNUNET_assert(GNUNET_YES ==
618 GNUNET_CONTAINER_multipeermap_remove (peers, 619 GNUNET_CONTAINER_multipeermap_remove(peers,
619 peer, 620 peer,
620 peer_entry)); 621 peer_entry));
621 if (NULL != peer_entry->transmit_task) 622 if (NULL != peer_entry->transmit_task)
622 { 623 {
623 GNUNET_SCHEDULER_cancel (peer_entry->transmit_task); 624 GNUNET_SCHEDULER_cancel(peer_entry->transmit_task);
624 peer_entry->transmit_task = NULL; 625 peer_entry->transmit_task = NULL;
625 } 626 }
626 if (NULL != peer_entry->so) 627 if (NULL != peer_entry->so)
627 { 628 {
628 GNUNET_SET_operation_cancel (peer_entry->so); 629 GNUNET_SET_operation_cancel(peer_entry->so);
629 peer_entry->so = NULL; 630 peer_entry->so = NULL;
630 } 631 }
631 GNUNET_free (peer_entry); 632 GNUNET_free(peer_entry);
632 GNUNET_STATISTICS_update (stats, 633 GNUNET_STATISTICS_update(stats,
633 "# peers connected", 634 "# peers connected",
634 -1, 635 -1,
635 GNUNET_NO); 636 GNUNET_NO);
636} 637}
637 638
638 639
@@ -645,11 +646,11 @@ handle_core_disconnect (void *cls,
645 * @return #GNUNET_OK (continue to iterate) 646 * @return #GNUNET_OK (continue to iterate)
646 */ 647 */
647static int 648static int
648free_entry (void *cls, 649free_entry(void *cls,
649 const struct GNUNET_HashCode *key, 650 const struct GNUNET_HashCode *key,
650 void *value) 651 void *value)
651{ 652{
652 GNUNET_free (value); 653 GNUNET_free(value);
653 return GNUNET_OK; 654 return GNUNET_OK;
654} 655}
655 656
@@ -660,42 +661,42 @@ free_entry (void *cls,
660 * @param cls unused 661 * @param cls unused
661 */ 662 */
662static void 663static void
663shutdown_task (void *cls) 664shutdown_task(void *cls)
664{ 665{
665 if (NULL != revocation_set) 666 if (NULL != revocation_set)
666 { 667 {
667 GNUNET_SET_destroy (revocation_set); 668 GNUNET_SET_destroy(revocation_set);
668 revocation_set = NULL; 669 revocation_set = NULL;
669 } 670 }
670 if (NULL != revocation_union_listen_handle) 671 if (NULL != revocation_union_listen_handle)
671 { 672 {
672 GNUNET_SET_listen_cancel (revocation_union_listen_handle); 673 GNUNET_SET_listen_cancel(revocation_union_listen_handle);
673 revocation_union_listen_handle = NULL; 674 revocation_union_listen_handle = NULL;
674 } 675 }
675 if (NULL != core_api) 676 if (NULL != core_api)
676 { 677 {
677 GNUNET_CORE_disconnect (core_api); 678 GNUNET_CORE_disconnect(core_api);
678 core_api = NULL; 679 core_api = NULL;
679 } 680 }
680 if (NULL != stats) 681 if (NULL != stats)
681 { 682 {
682 GNUNET_STATISTICS_destroy (stats, GNUNET_NO); 683 GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
683 stats = NULL; 684 stats = NULL;
684 } 685 }
685 if (NULL != peers) 686 if (NULL != peers)
686 { 687 {
687 GNUNET_CONTAINER_multipeermap_destroy (peers); 688 GNUNET_CONTAINER_multipeermap_destroy(peers);
688 peers = NULL; 689 peers = NULL;
689 } 690 }
690 if (NULL != revocation_db) 691 if (NULL != revocation_db)
691 { 692 {
692 GNUNET_DISK_file_close (revocation_db); 693 GNUNET_DISK_file_close(revocation_db);
693 revocation_db = NULL; 694 revocation_db = NULL;
694 } 695 }
695 GNUNET_CONTAINER_multihashmap_iterate (revocation_map, 696 GNUNET_CONTAINER_multihashmap_iterate(revocation_map,
696 &free_entry, 697 &free_entry,
697 NULL); 698 NULL);
698 GNUNET_CONTAINER_multihashmap_destroy (revocation_map); 699 GNUNET_CONTAINER_multihashmap_destroy(revocation_map);
699} 700}
700 701
701 702
@@ -706,16 +707,16 @@ shutdown_task (void *cls)
706 * @param identity the public identity of this peer 707 * @param identity the public identity of this peer
707 */ 708 */
708static void 709static void
709core_init (void *cls, 710core_init(void *cls,
710 const struct GNUNET_PeerIdentity *identity) 711 const struct GNUNET_PeerIdentity *identity)
711{ 712{
712 if (NULL == identity) 713 if (NULL == identity)
713 { 714 {
714 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 715 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
715 "Connection to core FAILED!\n"); 716 "Connection to core FAILED!\n");
716 GNUNET_SCHEDULER_shutdown (); 717 GNUNET_SCHEDULER_shutdown();
717 return; 718 return;
718 } 719 }
719 my_identity = *identity; 720 my_identity = *identity;
720} 721}
721 722
@@ -736,45 +737,45 @@ core_init (void *cls,
736 * message. It's necessary to specify the timeout. 737 * message. It's necessary to specify the timeout.
737 */ 738 */
738static void 739static void
739handle_revocation_union_request (void *cls, 740handle_revocation_union_request(void *cls,
740 const struct GNUNET_PeerIdentity *other_peer, 741 const struct GNUNET_PeerIdentity *other_peer,
741 const struct GNUNET_MessageHeader *context_msg, 742 const struct GNUNET_MessageHeader *context_msg,
742 struct GNUNET_SET_Request *request) 743 struct GNUNET_SET_Request *request)
743{ 744{
744 struct PeerEntry *peer_entry; 745 struct PeerEntry *peer_entry;
745 746
746 if (NULL == request) 747 if (NULL == request)
747 { 748 {
748 GNUNET_break (0); 749 GNUNET_break(0);
749 return; 750 return;
750 } 751 }
751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 752 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
752 "Received set exchange request from peer `%s'\n", 753 "Received set exchange request from peer `%s'\n",
753 GNUNET_i2s (other_peer)); 754 GNUNET_i2s(other_peer));
754 peer_entry = GNUNET_CONTAINER_multipeermap_get (peers, 755 peer_entry = GNUNET_CONTAINER_multipeermap_get(peers,
755 other_peer); 756 other_peer);
756 if (NULL == peer_entry) 757 if (NULL == peer_entry)
757 { 758 {
758 peer_entry = new_peer_entry (other_peer); 759 peer_entry = new_peer_entry(other_peer);
759 } 760 }
760 if (NULL != peer_entry->so) 761 if (NULL != peer_entry->so)
761 { 762 {
762 GNUNET_break_op (0); 763 GNUNET_break_op(0);
763 return; 764 return;
764 } 765 }
765 peer_entry->so = GNUNET_SET_accept (request, 766 peer_entry->so = GNUNET_SET_accept(request,
766 GNUNET_SET_RESULT_ADDED, 767 GNUNET_SET_RESULT_ADDED,
767 (struct GNUNET_SET_Option[]) {{ 0 }}, 768 (struct GNUNET_SET_Option[]) { { 0 } },
768 &add_revocation, 769 &add_revocation,
769 peer_entry); 770 peer_entry);
770 if (GNUNET_OK != 771 if (GNUNET_OK !=
771 GNUNET_SET_commit (peer_entry->so, 772 GNUNET_SET_commit(peer_entry->so,
772 revocation_set)) 773 revocation_set))
773 { 774 {
774 GNUNET_break (0); 775 GNUNET_break(0);
775 GNUNET_SCHEDULER_shutdown (); 776 GNUNET_SCHEDULER_shutdown();
776 return; 777 return;
777 } 778 }
778} 779}
779 780
780 781
@@ -786,136 +787,136 @@ handle_revocation_union_request (void *cls,
786 * @param c configuration to use 787 * @param c configuration to use
787 */ 788 */
788static void 789static void
789run (void *cls, 790run(void *cls,
790 const struct GNUNET_CONFIGURATION_Handle *c, 791 const struct GNUNET_CONFIGURATION_Handle *c,
791 struct GNUNET_SERVICE_Handle *service) 792 struct GNUNET_SERVICE_Handle *service)
792{ 793{
793 struct GNUNET_MQ_MessageHandler core_handlers[] = { 794 struct GNUNET_MQ_MessageHandler core_handlers[] = {
794 GNUNET_MQ_hd_fixed_size (p2p_revoke, 795 GNUNET_MQ_hd_fixed_size(p2p_revoke,
795 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, 796 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE,
796 struct RevokeMessage, 797 struct RevokeMessage,
797 NULL), 798 NULL),
798 GNUNET_MQ_handler_end () 799 GNUNET_MQ_handler_end()
799 }; 800 };
800 char *fn; 801 char *fn;
801 uint64_t left; 802 uint64_t left;
802 struct RevokeMessage *rm; 803 struct RevokeMessage *rm;
803 struct GNUNET_HashCode hc; 804 struct GNUNET_HashCode hc;
804 805
805 GNUNET_CRYPTO_hash ("revocation-set-union-application-id", 806 GNUNET_CRYPTO_hash("revocation-set-union-application-id",
806 strlen ("revocation-set-union-application-id"), 807 strlen("revocation-set-union-application-id"),
807 &revocation_set_union_app_id); 808 &revocation_set_union_app_id);
808 if (GNUNET_OK != 809 if (GNUNET_OK !=
809 GNUNET_CONFIGURATION_get_value_filename (c, 810 GNUNET_CONFIGURATION_get_value_filename(c,
810 "REVOCATION", 811 "REVOCATION",
811 "DATABASE", 812 "DATABASE",
812 &fn)) 813 &fn))
813 { 814 {
814 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 815 GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR,
815 "REVOCATION", 816 "REVOCATION",
816 "DATABASE"); 817 "DATABASE");
817 GNUNET_SCHEDULER_shutdown (); 818 GNUNET_SCHEDULER_shutdown();
818 return; 819 return;
819 } 820 }
820 cfg = c; 821 cfg = c;
821 revocation_map = GNUNET_CONTAINER_multihashmap_create (16, 822 revocation_map = GNUNET_CONTAINER_multihashmap_create(16,
822 GNUNET_NO); 823 GNUNET_NO);
823 if (GNUNET_OK != 824 if (GNUNET_OK !=
824 GNUNET_CONFIGURATION_get_value_number (cfg, 825 GNUNET_CONFIGURATION_get_value_number(cfg,
825 "REVOCATION", 826 "REVOCATION",
826 "WORKBITS", 827 "WORKBITS",
827 &revocation_work_required)) 828 &revocation_work_required))
828 { 829 {
829 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, 830 GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR,
830 "REVOCATION", 831 "REVOCATION",
831 "WORKBITS"); 832 "WORKBITS");
832 GNUNET_SCHEDULER_shutdown (); 833 GNUNET_SCHEDULER_shutdown();
833 GNUNET_free (fn); 834 GNUNET_free(fn);
834 return; 835 return;
835 } 836 }
836 if (revocation_work_required >= sizeof (struct GNUNET_HashCode) * 8) 837 if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
837 { 838 {
838 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, 839 GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_ERROR,
839 "REVOCATION", 840 "REVOCATION",
840 "WORKBITS", 841 "WORKBITS",
841 _("Value is too large.\n")); 842 _("Value is too large.\n"));
842 GNUNET_SCHEDULER_shutdown (); 843 GNUNET_SCHEDULER_shutdown();
843 GNUNET_free (fn); 844 GNUNET_free(fn);
844 return; 845 return;
845 } 846 }
846 revocation_set = GNUNET_SET_create (cfg, 847 revocation_set = GNUNET_SET_create(cfg,
847 GNUNET_SET_OPERATION_UNION); 848 GNUNET_SET_OPERATION_UNION);
848 revocation_union_listen_handle 849 revocation_union_listen_handle
849 = GNUNET_SET_listen (cfg, 850 = GNUNET_SET_listen(cfg,
850 GNUNET_SET_OPERATION_UNION, 851 GNUNET_SET_OPERATION_UNION,
851 &revocation_set_union_app_id, 852 &revocation_set_union_app_id,
852 &handle_revocation_union_request, 853 &handle_revocation_union_request,
853 NULL); 854 NULL);
854 revocation_db = GNUNET_DISK_file_open (fn, 855 revocation_db = GNUNET_DISK_file_open(fn,
855 GNUNET_DISK_OPEN_READWRITE | 856 GNUNET_DISK_OPEN_READWRITE |
856 GNUNET_DISK_OPEN_CREATE, 857 GNUNET_DISK_OPEN_CREATE,
857 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE | 858 GNUNET_DISK_PERM_USER_READ | GNUNET_DISK_PERM_USER_WRITE |
858 GNUNET_DISK_PERM_GROUP_READ | 859 GNUNET_DISK_PERM_GROUP_READ |
859 GNUNET_DISK_PERM_OTHER_READ); 860 GNUNET_DISK_PERM_OTHER_READ);
860 if (NULL == revocation_db) 861 if (NULL == revocation_db)
861 { 862 {
862 GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, 863 GNUNET_log_config_invalid(GNUNET_ERROR_TYPE_ERROR,
863 "REVOCATION", 864 "REVOCATION",
864 "DATABASE", 865 "DATABASE",
865 _("Could not open revocation database file!")); 866 _("Could not open revocation database file!"));
866 GNUNET_SCHEDULER_shutdown (); 867 GNUNET_SCHEDULER_shutdown();
867 GNUNET_free (fn); 868 GNUNET_free(fn);
868 return;
869 }
870 if (GNUNET_OK !=
871 GNUNET_DISK_file_size (fn, &left, GNUNET_YES, GNUNET_YES))
872 left = 0;
873 while (left > sizeof (struct RevokeMessage))
874 {
875 rm = GNUNET_new (struct RevokeMessage);
876 if (sizeof (struct RevokeMessage) !=
877 GNUNET_DISK_file_read (revocation_db,
878 rm,
879 sizeof (struct RevokeMessage)))
880 {
881 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
882 "read",
883 fn);
884 GNUNET_free (rm);
885 GNUNET_SCHEDULER_shutdown ();
886 GNUNET_free (fn);
887 return; 869 return;
888 } 870 }
889 GNUNET_break (0 == ntohl (rm->reserved)); 871 if (GNUNET_OK !=
890 GNUNET_CRYPTO_hash (&rm->public_key, 872 GNUNET_DISK_file_size(fn, &left, GNUNET_YES, GNUNET_YES))
891 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), 873 left = 0;
892 &hc); 874 while (left > sizeof(struct RevokeMessage))
893 GNUNET_break (GNUNET_OK == 875 {
894 GNUNET_CONTAINER_multihashmap_put (revocation_map, 876 rm = GNUNET_new(struct RevokeMessage);
877 if (sizeof(struct RevokeMessage) !=
878 GNUNET_DISK_file_read(revocation_db,
879 rm,
880 sizeof(struct RevokeMessage)))
881 {
882 GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR,
883 "read",
884 fn);
885 GNUNET_free(rm);
886 GNUNET_SCHEDULER_shutdown();
887 GNUNET_free(fn);
888 return;
889 }
890 GNUNET_break(0 == ntohl(rm->reserved));
891 GNUNET_CRYPTO_hash(&rm->public_key,
892 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey),
893 &hc);
894 GNUNET_break(GNUNET_OK ==
895 GNUNET_CONTAINER_multihashmap_put(revocation_map,
895 &hc, 896 &hc,
896 rm, 897 rm,
897 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 898 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
898 } 899 }
899 GNUNET_free (fn); 900 GNUNET_free(fn);
900 901
901 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, 902 GNUNET_SCHEDULER_add_shutdown(&shutdown_task,
902 NULL); 903 NULL);
903 peers = GNUNET_CONTAINER_multipeermap_create (128, 904 peers = GNUNET_CONTAINER_multipeermap_create(128,
904 GNUNET_YES); 905 GNUNET_YES);
905 /* Connect to core service and register core handlers */ 906 /* Connect to core service and register core handlers */
906 core_api = GNUNET_CORE_connect (cfg, /* Main configuration */ 907 core_api = GNUNET_CORE_connect(cfg, /* Main configuration */
907 NULL, /* Closure passed to functions */ 908 NULL, /* Closure passed to functions */
908 &core_init, /* Call core_init once connected */ 909 &core_init, /* Call core_init once connected */
909 &handle_core_connect, /* Handle connects */ 910 &handle_core_connect, /* Handle connects */
910 &handle_core_disconnect, /* Handle disconnects */ 911 &handle_core_disconnect, /* Handle disconnects */
911 core_handlers); /* Register these handlers */ 912 core_handlers); /* Register these handlers */
912 if (NULL == core_api) 913 if (NULL == core_api)
913 { 914 {
914 GNUNET_SCHEDULER_shutdown (); 915 GNUNET_SCHEDULER_shutdown();
915 return; 916 return;
916 } 917 }
917 stats = GNUNET_STATISTICS_create ("revocation", 918 stats = GNUNET_STATISTICS_create("revocation",
918 cfg); 919 cfg);
919} 920}
920 921
921 922
@@ -923,21 +924,21 @@ run (void *cls,
923 * Define "main" method using service macro. 924 * Define "main" method using service macro.
924 */ 925 */
925GNUNET_SERVICE_MAIN 926GNUNET_SERVICE_MAIN
926("revocation", 927 ("revocation",
927 GNUNET_SERVICE_OPTION_NONE, 928 GNUNET_SERVICE_OPTION_NONE,
928 &run, 929 &run,
929 &client_connect_cb, 930 &client_connect_cb,
930 &client_disconnect_cb, 931 &client_disconnect_cb,
931 NULL, 932 NULL,
932 GNUNET_MQ_hd_fixed_size (query_message, 933 GNUNET_MQ_hd_fixed_size(query_message,
933 GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, 934 GNUNET_MESSAGE_TYPE_REVOCATION_QUERY,
934 struct QueryMessage, 935 struct QueryMessage,
935 NULL), 936 NULL),
936 GNUNET_MQ_hd_fixed_size (revoke_message, 937 GNUNET_MQ_hd_fixed_size(revoke_message,
937 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, 938 GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE,
938 struct RevokeMessage, 939 struct RevokeMessage,
939 NULL), 940 NULL),
940 GNUNET_MQ_handler_end ()); 941 GNUNET_MQ_handler_end());
941 942
942 943
943#if defined(LINUX) && defined(__GLIBC__) 944#if defined(LINUX) && defined(__GLIBC__)
@@ -947,11 +948,11 @@ GNUNET_SERVICE_MAIN
947 * MINIMIZE heap size (way below 128k) since this process doesn't need much. 948 * MINIMIZE heap size (way below 128k) since this process doesn't need much.
948 */ 949 */
949void __attribute__ ((constructor)) 950void __attribute__ ((constructor))
950GNUNET_REVOCATION_memory_init () 951GNUNET_REVOCATION_memory_init()
951{ 952{
952 mallopt (M_TRIM_THRESHOLD, 4 * 1024); 953 mallopt(M_TRIM_THRESHOLD, 4 * 1024);
953 mallopt (M_TOP_PAD, 1 * 1024); 954 mallopt(M_TOP_PAD, 1 * 1024);
954 malloc_trim (0); 955 malloc_trim(0);
955} 956}
956 957
957#endif 958#endif