GNUnet  0.17.6
gnunet-service-revocation.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2013, 2014, 2016 GNUnet e.V.
4 
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
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your 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  Affero General Public License for more details.
14 
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/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
38 #include "platform.h"
39 #include <math.h>
40 #include "gnunet_util_lib.h"
41 #include "gnunet_block_lib.h"
42 #include "gnunet_constants.h"
43 #include "gnunet_protocols.h"
44 #include "gnunet_signatures.h"
46 #include "gnunet_core_service.h"
48 #include "gnunet_setu_service.h"
49 #include "revocation.h"
50 #include <gcrypt.h>
51 
52 
56 struct PeerEntry
57 {
62 
66  struct GNUNET_PeerIdentity id;
67 
72 
77 };
78 
79 
84 
90 
94 static const struct GNUNET_CONFIGURATION_Handle *cfg;
95 
100 
105 
110 
114 static struct GNUNET_PeerIdentity my_identity;
115 
120 
125 
129 static unsigned long long revocation_work_required;
130 
135 
141 
142 
149 static struct PeerEntry *
151 {
152  struct PeerEntry *peer_entry;
153 
154  peer_entry = GNUNET_new (struct PeerEntry);
155  peer_entry->id = *peer;
158  &peer_entry->id,
159  peer_entry,
161  return peer_entry;
162 }
163 
164 
172 static enum GNUNET_GenericReturnValue
173 verify_revoke_message (const struct RevokeMessage *rm)
174 {
175  const struct GNUNET_REVOCATION_PowP *pow
176  = (const struct GNUNET_REVOCATION_PowP *) &rm[1];
177 
178  if (GNUNET_YES !=
180  (unsigned int) revocation_work_required,
182  {
184  "Proof of work invalid!\n");
185  GNUNET_break_op (0);
186  return GNUNET_NO;
187  }
188  return GNUNET_YES;
189 }
190 
191 
200 static void *
201 client_connect_cb (void *cls,
202  struct GNUNET_SERVICE_Client *client,
203  struct GNUNET_MQ_Handle *mq)
204 {
205  return client;
206 }
207 
208 
216 static void
218  struct GNUNET_SERVICE_Client *client,
219  void *app_cls)
220 {
221  GNUNET_assert (client == app_cls);
222 }
223 
224 
231 static void
233  const struct QueryMessage *qm)
234 {
235  struct GNUNET_SERVICE_Client *client = cls;
236  struct GNUNET_MQ_Envelope *env;
237  struct QueryResponseMessage *qrm;
238  struct GNUNET_HashCode hc;
239  int res;
240 
241  GNUNET_CRYPTO_hash (&qm->key,
242  sizeof(struct GNUNET_IDENTITY_PublicKey),
243  &hc);
245  &hc);
247  (GNUNET_NO == res)
248  ? "Received revocation check for valid key `%s' from client\n"
249  : "Received revocation check for revoked key `%s' from client\n",
250  GNUNET_h2s (&hc));
251  env = GNUNET_MQ_msg (qrm,
253  qrm->is_valid = htonl ((GNUNET_YES == res) ? GNUNET_NO : GNUNET_YES);
255  env);
257 }
258 
259 
268 static enum GNUNET_GenericReturnValue
269 do_flood (void *cls,
270  const struct GNUNET_PeerIdentity *target,
271  void *value)
272 {
273  const struct RevokeMessage *rm = cls;
274  struct PeerEntry *pe = value;
275  struct GNUNET_MQ_Envelope *e;
276  struct RevokeMessage *cp;
277 
278  if (NULL == pe->mq)
279  return GNUNET_OK; /* peer connected to us via SET,
280  but we have no direct CORE
281  connection for flooding */
282  e = GNUNET_MQ_msg_extra (cp,
283  htonl (rm->pow_size),
285  *cp = *rm;
286  memcpy (&cp[1],
287  &rm[1],
288  htonl (rm->pow_size));
290  "Flooding revocation to `%s'\n",
291  GNUNET_i2s (target));
292  GNUNET_MQ_send (pe->mq,
293  e);
294  return GNUNET_OK;
295 }
296 
297 
307 static enum GNUNET_GenericReturnValue
308 publicize_rm (const struct RevokeMessage *rm)
309 {
310  struct RevokeMessage *cp;
311  struct GNUNET_HashCode hc;
312  struct GNUNET_SETU_Element e;
313  ssize_t pklen;
314  const struct GNUNET_REVOCATION_PowP *pow
315  = (const struct GNUNET_REVOCATION_PowP *) &rm[1];
316  const struct GNUNET_IDENTITY_PublicKey *pk
317  = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
318 
320  if (0 > pklen)
321  {
322  GNUNET_break_op (0);
323  return GNUNET_SYSERR;
324  }
326  pklen,
327  &hc);
328  if (GNUNET_YES ==
330  &hc))
331  {
333  "Duplicate revocation received from peer. Ignored.\n");
334  return GNUNET_OK;
335  }
336  if (GNUNET_OK !=
338  {
339  GNUNET_break_op (0);
340  return GNUNET_SYSERR;
341  }
342  /* write to disk */
343  if (sizeof(struct RevokeMessage) !=
345  rm,
346  sizeof(struct RevokeMessage)))
347  {
349  "write");
350  return GNUNET_NO;
351  }
352  if (GNUNET_OK !=
354  {
356  "sync");
357  return GNUNET_NO;
358  }
359  /* keep copy in memory */
360  cp = (struct RevokeMessage *) GNUNET_copy_message (&rm->header);
363  &hc,
364  cp,
366  /* add to set for future connections */
367  e.size = htons (rm->header.size);
368  e.element_type = GNUNET_BLOCK_TYPE_REVOCATION;
369  e.data = rm;
370  if (GNUNET_OK !=
372  &e,
373  NULL,
374  NULL))
375  {
376  GNUNET_break (0);
377  return GNUNET_OK;
378  }
379  else
380  {
382  "Added revocation info to SET\n");
383  }
384  /* flood to neighbours */
386  &do_flood,
387  cp);
388  return GNUNET_OK;
389 }
390 
391 
392 static int
394  const struct RevokeMessage *rm)
395 {
396  uint16_t size;
397 
398  size = ntohs (rm->header.size);
399  if (size <= sizeof(struct RevokeMessage) ||
400  (size > UINT16_MAX))
401  {
402  GNUNET_break (0);
403  return GNUNET_SYSERR;
404  }
405  return GNUNET_OK;
406 
407 }
408 
409 
416 static void
418  const struct RevokeMessage *rm)
419 {
420  struct GNUNET_SERVICE_Client *client = cls;
421  struct GNUNET_MQ_Envelope *env;
422  struct RevocationResponseMessage *rrm;
423  int ret;
424 
426  "Received REVOKE message from client\n");
427  if (GNUNET_SYSERR == (ret = publicize_rm (rm)))
428  {
429  GNUNET_break_op (0);
431  return;
432  }
433  env = GNUNET_MQ_msg (rrm,
435  rrm->is_valid = htonl ((GNUNET_OK == ret) ? GNUNET_NO : GNUNET_YES);
437  env);
439 }
440 
441 
442 static int
443 check_p2p_revoke (void *cls,
444  const struct RevokeMessage *rm)
445 {
446  uint16_t size;
447 
448  size = ntohs (rm->header.size);
449  if (size <= sizeof(struct RevokeMessage))
450  {
451  GNUNET_break (0);
452  return GNUNET_SYSERR;
453  }
454  return GNUNET_OK;
455 
456 }
457 
458 
465 static void
466 handle_p2p_revoke (void *cls,
467  const struct RevokeMessage *rm)
468 {
470  "Received REVOKE message\n");
472  publicize_rm (rm));
473 }
474 
475 
486 static void
487 add_revocation (void *cls,
488  const struct GNUNET_SETU_Element *element,
489  uint64_t current_size,
491 {
492  struct PeerEntry *peer_entry = cls;
493  const struct RevokeMessage *rm;
494 
495  switch (status)
496  {
498  if (element->size != sizeof(struct RevokeMessage))
499  {
500  GNUNET_break_op (0);
501  return;
502  }
504  {
506  gettext_noop (
507  "# unsupported revocations received via set union"),
508  1,
509  GNUNET_NO);
510  return;
511  }
512  rm = element->data;
513  (void) handle_p2p_revoke (NULL,
514  rm);
516  gettext_noop (
517  "# revocation messages received via set union"),
518  1, GNUNET_NO);
519  break;
522  _ ("Error computing revocation set union with %s\n"),
523  GNUNET_i2s (&peer_entry->id));
524  peer_entry->so = NULL;
526  gettext_noop ("# revocation set unions failed"),
527  1,
528  GNUNET_NO);
529  break;
531  peer_entry->so = NULL;
533  gettext_noop (
534  "# revocation set unions completed"),
535  1,
536  GNUNET_NO);
537  break;
538  default:
539  GNUNET_break (0);
540  break;
541  }
542 }
543 
544 
551 static void
552 transmit_task_cb (void *cls)
553 {
554  struct PeerEntry *peer_entry = cls;
555 
557  "Starting set exchange with peer `%s'\n",
558  GNUNET_i2s (&peer_entry->id));
559  peer_entry->transmit_task = NULL;
560  GNUNET_assert (NULL == peer_entry->so);
561  peer_entry->so = GNUNET_SETU_prepare (&peer_entry->id,
563  NULL,
564  (struct GNUNET_SETU_Option[]) { { 0 } },
566  peer_entry);
567  if (GNUNET_OK !=
568  GNUNET_SETU_commit (peer_entry->so,
570  {
572  _ ("SET service crashed, terminating revocation service\n"));
574  return;
575  }
576 }
577 
578 
586 static void *
588  const struct GNUNET_PeerIdentity *peer,
589  struct GNUNET_MQ_Handle *mq)
590 {
591  struct PeerEntry *peer_entry;
592  struct GNUNET_HashCode my_hash;
593  struct GNUNET_HashCode peer_hash;
594 
595  if (0 == GNUNET_memcmp (peer,
596  &my_identity))
597  {
598  return NULL;
599  }
600 
602  "Peer `%s' connected to us\n",
603  GNUNET_i2s (peer));
605  "# peers connected",
606  1,
607  GNUNET_NO);
609  peer);
610  if (NULL != peer_entry)
611  {
612  /* This can happen if "core"'s notification is a tad late
613  and CADET+SET were faster and already produced a
614  #handle_revocation_union_request() for us to deal
615  with. This should be rare, but isn't impossible. */
616  peer_entry->mq = mq;
617  return peer_entry;
618  }
619  peer_entry = new_peer_entry (peer);
620  peer_entry->mq = mq;
622  sizeof(my_identity),
623  &my_hash);
625  sizeof(*peer),
626  &peer_hash);
627  if (0 < GNUNET_CRYPTO_hash_cmp (&my_hash,
628  &peer_hash))
629  {
631  "Starting SET operation with peer `%s'\n",
632  GNUNET_i2s (peer));
633  peer_entry->transmit_task =
636  peer_entry);
637  }
638  return peer_entry;
639 }
640 
641 
650 static void
652  const struct GNUNET_PeerIdentity *peer,
653  void *internal_cls)
654 {
655  struct PeerEntry *peer_entry = internal_cls;
656 
657  if (0 == GNUNET_memcmp (peer,
658  &my_identity))
659  return;
660  GNUNET_assert (NULL != peer_entry);
662  "Peer `%s' disconnected from us\n",
663  GNUNET_i2s (peer));
666  peer,
667  peer_entry));
668  if (NULL != peer_entry->transmit_task)
669  {
671  peer_entry->transmit_task = NULL;
672  }
673  if (NULL != peer_entry->so)
674  {
675  GNUNET_SETU_operation_cancel (peer_entry->so);
676  peer_entry->so = NULL;
677  }
678  GNUNET_free (peer_entry);
680  "# peers connected",
681  -1,
682  GNUNET_NO);
683 }
684 
685 
694 static int
695 free_entry (void *cls,
696  const struct GNUNET_HashCode *key,
697  void *value)
698 {
699  GNUNET_free (value);
700  return GNUNET_OK;
701 }
702 
703 
709 static void
710 shutdown_task (void *cls)
711 {
712  if (NULL != revocation_set)
713  {
715  revocation_set = NULL;
716  }
717  if (NULL != revocation_union_listen_handle)
718  {
721  }
722  if (NULL != core_api)
723  {
725  core_api = NULL;
726  }
727  if (NULL != stats)
728  {
730  stats = NULL;
731  }
732  if (NULL != peers)
733  {
735  peers = NULL;
736  }
737  if (NULL != revocation_db)
738  {
740  revocation_db = NULL;
741  }
743  &free_entry,
744  NULL);
746 }
747 
748 
755 static void
756 core_init (void *cls,
757  const struct GNUNET_PeerIdentity *identity)
758 {
759  if (NULL == identity)
760  {
762  "Connection to core FAILED!\n");
764  return;
765  }
767 }
768 
769 
785 static void
787  const struct GNUNET_PeerIdentity *other_peer,
788  const struct GNUNET_MessageHeader *context_msg,
790 {
791  struct PeerEntry *peer_entry;
792 
793  if (NULL == request)
794  {
795  GNUNET_break (0);
796  return;
797  }
799  "Received set exchange request from peer `%s'\n",
800  GNUNET_i2s (other_peer));
802  other_peer);
803  if (NULL == peer_entry)
804  {
805  peer_entry = new_peer_entry (other_peer);
806  }
807  if (NULL != peer_entry->so)
808  {
809  GNUNET_break_op (0);
810  return;
811  }
812  peer_entry->so = GNUNET_SETU_accept (request,
813  (struct GNUNET_SETU_Option[]) { { 0 } },
815  peer_entry);
816  if (GNUNET_OK !=
817  GNUNET_SETU_commit (peer_entry->so,
819  {
820  GNUNET_break (0);
822  return;
823  }
824 }
825 
826 
834 static void
835 run (void *cls,
836  const struct GNUNET_CONFIGURATION_Handle *c,
838 {
839  struct GNUNET_MQ_MessageHandler core_handlers[] = {
840  GNUNET_MQ_hd_var_size (p2p_revoke,
842  struct RevokeMessage,
843  NULL),
845  };
846  char *fn;
847  uint64_t left;
848  struct RevokeMessage *rm;
849  struct GNUNET_HashCode hc;
850  const struct GNUNET_IDENTITY_PublicKey *pk;
851 
852  GNUNET_CRYPTO_hash ("revocation-set-union-application-id",
853  strlen ("revocation-set-union-application-id"),
855  if (GNUNET_OK !=
857  "REVOCATION",
858  "DATABASE",
859  &fn))
860  {
862  "REVOCATION",
863  "DATABASE");
865  return;
866  }
867  cfg = c;
869  GNUNET_NO);
870  if (GNUNET_OK !=
872  "REVOCATION",
873  "WORKBITS",
875  {
877  "REVOCATION",
878  "WORKBITS");
880  GNUNET_free (fn);
881  return;
882  }
883  if (revocation_work_required >= sizeof(struct GNUNET_HashCode) * 8)
884  {
886  "REVOCATION",
887  "WORKBITS",
888  _ ("Value is too large.\n"));
890  GNUNET_free (fn);
891  return;
892  }
893  if (GNUNET_OK !=
895  "REVOCATION",
896  "EPOCH_DURATION",
897  &epoch_duration))
898  {
900  "REVOCATION",
901  "EPOCH_DURATION");
903  GNUNET_free (fn);
904  return;
905  }
906 
912  NULL);
920  if (NULL == revocation_db)
921  {
923  "REVOCATION",
924  "DATABASE",
925  _ ("Could not open revocation database file!"));
927  GNUNET_free (fn);
928  return;
929  }
930  if (GNUNET_OK !=
932  left = 0;
933  while (left > sizeof(struct RevokeMessage))
934  {
935  rm = GNUNET_new (struct RevokeMessage);
936  if (sizeof(struct RevokeMessage) !=
938  rm,
939  sizeof(struct RevokeMessage)))
940  {
942  "read",
943  fn);
944  GNUNET_free (rm);
946  GNUNET_free (fn);
947  return;
948  }
949  struct GNUNET_REVOCATION_PowP *pow = (struct
950  GNUNET_REVOCATION_PowP *) &rm[1];
951  ssize_t ksize;
952  pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
954  if (0 > ksize)
955  {
956  GNUNET_break_op (0);
957  GNUNET_free (rm);
958  GNUNET_free (fn);
959  return;
960  }
962  ksize,
963  &hc);
966  &hc,
967  rm,
969  }
970  GNUNET_free (fn);
971 
973  NULL);
975  GNUNET_YES);
976  /* Connect to core service and register core handlers */
977  core_api = GNUNET_CORE_connect (cfg, /* Main configuration */
978  NULL, /* Closure passed to functions */
979  &core_init, /* Call core_init once connected */
980  &handle_core_connect, /* Handle connects */
981  &handle_core_disconnect, /* Handle disconnects */
982  core_handlers); /* Register these handlers */
983  if (NULL == core_api)
984  {
986  return;
987  }
988  stats = GNUNET_STATISTICS_create ("revocation",
989  cfg);
990 }
991 
992 
997  ("revocation",
999  &run,
1002  NULL,
1003  GNUNET_MQ_hd_fixed_size (query_message,
1005  struct QueryMessage,
1006  NULL),
1007  GNUNET_MQ_hd_var_size (revoke_message,
1009  struct RevokeMessage,
1010  NULL),
1012 
1013 
1014 #if defined(__linux__) && defined(__GLIBC__)
1015 #include <malloc.h>
1016 
1020 void __attribute__ ((constructor))
1021 GNUNET_REVOCATION_memory_init ()
1022 {
1023  mallopt (M_TRIM_THRESHOLD, 4 * 1024);
1024  mallopt (M_TOP_PAD, 1 * 1024);
1025  malloc_trim (0);
1026 }
1027 
1028 
1029 #endif
1030 
1031 
1032 /* end of gnunet-service-revocation.c */
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
@ GNUNET_BLOCK_TYPE_REVOCATION
Block type for a revocation message by which a key is revoked.
#define gettext_noop(String)
Definition: gettext.h:69
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct Experiment * e
static int res
struct GNUNET_HashCode key
The key used in the DHT.
uint16_t status
See PRISM_STATUS_*-constants.
enum RadiotapType __attribute__
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
static char * value
Value of the record to add/remove.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_SETU_ListenHandle * revocation_union_listen_handle
Handle for us listening to incoming revocation set union requests.
static struct GNUNET_CONTAINER_MultiPeerMap * peers
Map of all connected peers.
GNUNET_SERVICE_MAIN("revocation", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(query_message, GNUNET_MESSAGE_TYPE_REVOCATION_QUERY, struct QueryMessage, NULL), GNUNET_MQ_hd_var_size(revoke_message, GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE, struct RevokeMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static struct GNUNET_DISK_FileHandle * revocation_db
File handle for the revocation database.
static void transmit_task_cb(void *cls)
The timeout for performing the set union has expired, run the set operation on the revocation certifi...
static void core_init(void *cls, const struct GNUNET_PeerIdentity *identity)
Called on core init/fail.
static struct GNUNET_PeerIdentity my_identity
The peer identity of this peer.
static void handle_revoke_message(void *cls, const struct RevokeMessage *rm)
Handle REVOKE message from client.
static struct GNUNET_CONTAINER_MultiHashMap * revocation_map
Hash map with all revoked keys, maps the hash of the public key to the respective struct RevokeMessag...
static struct GNUNET_TIME_Relative epoch_duration
Length of an expiration expoch.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
static int free_entry(void *cls, const struct GNUNET_HashCode *key, void *value)
Free all values in a hash map.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_cls)
Handle client connecting to the service.
static void shutdown_task(void *cls)
Task run during shutdown.
static int check_revoke_message(void *cls, const struct RevokeMessage *rm)
static void handle_query_message(void *cls, const struct QueryMessage *qm)
Handle QUERY message from client.
static struct GNUNET_CORE_Handle * core_api
Handle to the core service (for flooding)
static struct PeerEntry * new_peer_entry(const struct GNUNET_PeerIdentity *peer)
Create a new PeerEntry and add it to the peers multipeermap.
static struct GNUNET_SETU_Handle * revocation_set
Set from all revocations known to us.
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Handle network size estimate clients.
static enum GNUNET_GenericReturnValue publicize_rm(const struct RevokeMessage *rm)
Publicize revocation message.
static int check_p2p_revoke(void *cls, const struct RevokeMessage *rm)
static enum GNUNET_GenericReturnValue do_flood(void *cls, const struct GNUNET_PeerIdentity *target, void *value)
Flood the given revocation message to all neighbours.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Handle client connecting to the service.
static struct GNUNET_HashCode revocation_set_union_app_id
Our application ID for set union operations.
static enum GNUNET_GenericReturnValue verify_revoke_message(const struct RevokeMessage *rm)
An revoke message has been received, check that it is well-formed.
static void add_revocation(void *cls, const struct GNUNET_SETU_Element *element, uint64_t current_size, enum GNUNET_SETU_Status status)
Callback for set operation results.
static void handle_core_disconnect(void *cls, const struct GNUNET_PeerIdentity *peer, void *internal_cls)
Method called whenever a peer disconnects.
static void * handle_core_connect(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a peer connects.
static unsigned long long revocation_work_required
Amount of work required (W-bit collisions) for REVOCATION proofs, in collision-bits.
static void handle_revocation_union_request(void *cls, const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_MessageHeader *context_msg, struct GNUNET_SETU_Request *request)
Called when another peer wants to do a set operation with the local peer.
static void handle_p2p_revoke(void *cls, const struct RevokeMessage *rm)
Core handler for flooded revocation messages.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
Library for data block manipulation.
Core service; the main API for encrypted P2P communications.
Constants for network protocols.
API to perform and access key revocations.
Two-peer set union operations.
API to create, modify and access statistics.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
struct GNUNET_CORE_Handle * GNUNET_CORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Connect to the core service.
Definition: core_api.c:692
void GNUNET_CORE_disconnect(struct GNUNET_CORE_Handle *handle)
Disconnect from the core service.
Definition: core_api.c:730
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1235
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:686
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
Definition: disk.c:222
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:1425
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1306
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:622
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:220
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
ssize_t GNUNET_IDENTITY_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:991
#define GNUNET_log(kind,...)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_log_config_invalid(enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
Log error message about invalid configuration option value.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:302
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:56
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:71
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY
Client to service: was this key revoked?
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE
Client to service OR peer-to-peer: revoke this key!
#define GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE_RESPONSE
Service to client: revocation confirmed.
#define GNUNET_MESSAGE_TYPE_REVOCATION_QUERY_RESPONSE
Service to client: answer if key was revoked!
enum GNUNET_GenericReturnValue GNUNET_REVOCATION_check_pow(const struct GNUNET_REVOCATION_PowP *pow, unsigned int matching_bits, struct GNUNET_TIME_Relative epoch_duration)
Check if the given proof-of-work is valid.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:533
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1316
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:957
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1254
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2329
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2442
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2248
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_SETU_Handle * GNUNET_SETU_create(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create an empty set, supporting the specified operation.
Definition: setu_api.c:384
void GNUNET_SETU_operation_cancel(struct GNUNET_SETU_OperationHandle *oh)
Cancel the given set operation.
Definition: setu_api.c:320
struct GNUNET_SETU_ListenHandle * GNUNET_SETU_listen(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_HashCode *app_id, GNUNET_SETU_ListenCallback listen_cb, void *listen_cls)
Wait for set operation requests for the given application ID.
Definition: setu_api.c:729
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_prepare(const struct GNUNET_PeerIdentity *other_peer, const struct GNUNET_HashCode *app_id, const struct GNUNET_MessageHeader *context_msg, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Prepare a set operation to be evaluated with another peer.
Definition: setu_api.c:509
void GNUNET_SETU_destroy(struct GNUNET_SETU_Handle *set)
Destroy the set handle, and free all associated resources.
Definition: setu_api.c:471
struct GNUNET_SETU_OperationHandle * GNUNET_SETU_accept(struct GNUNET_SETU_Request *request, const struct GNUNET_SETU_Option options[], GNUNET_SETU_ResultIterator result_cb, void *result_cls)
Accept a request we got via GNUNET_SETU_listen().
Definition: setu_api.c:795
int GNUNET_SETU_commit(struct GNUNET_SETU_OperationHandle *oh, struct GNUNET_SETU_Handle *set)
Commit a set to be used with a set operation.
Definition: setu_api.c:877
GNUNET_SETU_Status
Status for the result callback.
void GNUNET_SETU_listen_cancel(struct GNUNET_SETU_ListenHandle *lh)
Cancel the given listen operation.
Definition: setu_api.c:761
int GNUNET_SETU_add_element(struct GNUNET_SETU_Handle *set, const struct GNUNET_SETU_Element *element, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Add an element to the given set.
Definition: setu_api.c:429
@ GNUNET_SETU_STATUS_DONE
Success, all elements have been sent (and received).
@ GNUNET_SETU_STATUS_FAILURE
The other peer refused to do the operation with us, or something went wrong.
@ GNUNET_SETU_STATUS_ADD_LOCAL
Element should be added to the result set of the local peer, i.e.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
#define GNUNET_TIME_UNIT_SECONDS
One second.
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
messages for key revocation
Internal representation of the hash map.
Internal representation of the hash map.
Context for the core service connection.
Definition: core_api.c:78
Handle used to access files (and pipes).
A 512-bit hashcode.
An identity key as per LSD0001.
Handle to a message queue.
Definition: mq.c:86
Message handler for a specific message type.
Header for all communications.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
The identity of the host (wraps the signing key of the peer).
Struct for a proof of work as part of the revocation.
Entry in list of pending tasks.
Definition: scheduler.c:135
Handle to a client that is connected to a service.
Definition: service.c:251
Handle to a service.
Definition: service.c:117
Element stored in a set.
uint16_t element_type
Application-specific element type.
uint16_t size
Number of bytes in the buffer pointed to by data.
const void * data
Actual data of the element.
Opaque handle to a set.
Definition: setu_api.c:40
Opaque handle to a listen operation.
Definition: setu_api.c:146
Handle to an operation.
Definition: setu_api.c:95
Option for set operations.
Handle for a set operation request from another peer.
Definition: setu_api.c:75
Handle for the service.
Time for relative time used by GNUnet, in microseconds.
Per-peer information.
struct GNUNET_PeerIdentity id
What is the identity of the peer?
struct GNUNET_SCHEDULER_Task * transmit_task
Tasked used to trigger the set union operation.
struct GNUNET_SETU_OperationHandle * so
Handle to active set union operation (over revocation sets).
struct GNUNET_MQ_Handle * mq
Queue for sending messages to this peer.
Query key revocation status.
Definition: revocation.h:38
struct GNUNET_IDENTITY_PublicKey key
Key to check.
Definition: revocation.h:52
Key revocation response.
Definition: revocation.h:60
uint32_t is_valid
GNUNET_NO if revoked, GNUNET_YES if valid.
Definition: revocation.h:69
Key revocation response.
Definition: revocation.h:100
uint32_t is_valid
GNUNET_NO if revocation failed for internal reasons (e.g.
Definition: revocation.h:110
Revoke key.
Definition: revocation.h:81
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_REVOCATION_REVOKE.
Definition: revocation.h:85
uint32_t pow_size
Length of PoW with signature.
Definition: revocation.h:90
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.