GNUnet  0.11.x
dht_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2009, 2010, 2011, 2012, 2016, 2018 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 
28 #include "platform.h"
29 #include "gnunet_util_lib.h"
30 #include "gnunet_constants.h"
31 #include "gnunet_signatures.h"
32 #include "gnunet_arm_service.h"
33 #include "gnunet_hello_lib.h"
34 #include "gnunet_protocols.h"
35 #include "gnunet_dht_service.h"
36 #include "dht.h"
37 
38 #define LOG(kind, ...) GNUNET_log_from (kind, "dht-api", __VA_ARGS__)
39 
40 
45 {
50 
55 
60 
65 
69  void *cont_cls;
70 
75 };
76 
81 {
86 
90  void *iter_cls;
91 
96 
102 
106  struct GNUNET_HashCode key;
107 
111  uint64_t unique_id;
112 
116  size_t xquery_size;
117 
122 
126  enum GNUNET_BLOCK_Type type;
127 
132 
137  unsigned int seen_results_size;
138 
143  unsigned int seen_results_end;
144 };
145 
146 
151 {
156 
161 
166 
170  enum GNUNET_BLOCK_Type type;
171 
176 
181 
186 
191 
195  void *cb_cls;
196 };
197 
198 
203 {
208 
213 
218 
223 
228 
233 
239 
244 
250 
254  uint64_t uid_gen;
255 };
256 
257 
264 static enum GNUNET_GenericReturnValue
266 
267 
273 static void
275 {
276  struct GNUNET_DHT_Handle *h = gh->dht_handle;
277  struct GNUNET_MQ_Envelope *env;
278  struct GNUNET_DHT_ClientGetMessage *get_msg;
279 
280  env = GNUNET_MQ_msg_extra (get_msg,
281  gh->xquery_size,
283  get_msg->options = htonl ((uint32_t) gh->options);
284  get_msg->desired_replication_level = htonl (gh->desired_replication_level);
285  get_msg->type = htonl (gh->type);
286  get_msg->key = gh->key;
287  get_msg->unique_id = gh->unique_id;
288  GNUNET_memcpy (&get_msg[1],
289  &gh[1],
290  gh->xquery_size);
291  GNUNET_MQ_send (h->mq,
292  env);
293 }
294 
295 
305 static void
307  unsigned int transmission_offset_start)
308 {
309  struct GNUNET_DHT_Handle *h = gh->dht_handle;
310  struct GNUNET_MQ_Envelope *env;
312  unsigned int delta;
313  unsigned int max;
314  unsigned int transmission_offset;
315 
316  max = (GNUNET_MAX_MESSAGE_SIZE - sizeof(*msg))
317  / sizeof(struct GNUNET_HashCode);
318  transmission_offset = transmission_offset_start;
319  while (transmission_offset < gh->seen_results_end)
320  {
321  delta = gh->seen_results_end - transmission_offset;
322  if (delta > max)
323  delta = max;
325  delta * sizeof(struct GNUNET_HashCode),
327  msg->key = gh->key;
328  msg->unique_id = gh->unique_id;
329  GNUNET_memcpy (&msg[1],
330  &gh->seen_results[transmission_offset],
331  sizeof(struct GNUNET_HashCode) * delta);
332  GNUNET_MQ_send (h->mq,
333  env);
334  transmission_offset += delta;
335  }
336 }
337 
338 
348 static enum GNUNET_GenericReturnValue
349 add_get_request_to_pending (void *cls,
350  const struct GNUNET_HashCode *key,
351  void *value)
352 {
353  struct GNUNET_DHT_Handle *handle = cls;
354  struct GNUNET_DHT_GetHandle *gh = value;
355 
357  "Retransmitting request related to %s to DHT %p\n",
358  GNUNET_h2s (key),
359  handle);
360  send_get (gh);
362  return GNUNET_YES;
363 }
364 
365 
371 static void
373 {
374  struct GNUNET_DHT_Handle *h = mh->dht_handle;
375  struct GNUNET_MQ_Envelope *env;
377 
378  env = GNUNET_MQ_msg (m,
380  m->type = htonl (mh->type);
381  m->get = htons (NULL != mh->get_cb);
382  m->get_resp = htons (NULL != mh->get_resp_cb);
383  m->put = htons (NULL != mh->put_cb);
384  if (NULL != mh->key)
385  {
386  m->filter_key = htons (1);
387  m->key = *mh->key;
388  }
389  GNUNET_MQ_send (h->mq,
390  env);
391 }
392 
393 
399 static void
400 try_reconnect (void *cls)
401 {
402  struct GNUNET_DHT_Handle *h = cls;
404 
406  "Reconnecting with DHT %p\n",
407  h);
408  h->retry_time = GNUNET_TIME_STD_BACKOFF (h->retry_time);
409  h->reconnect_task = NULL;
410  if (GNUNET_YES != try_connect (h))
411  {
413  "DHT reconnect failed!\n");
415  = GNUNET_SCHEDULER_add_delayed (h->retry_time,
416  &try_reconnect,
417  h);
418  return;
419  }
420  GNUNET_CONTAINER_multihashmap_iterate (h->active_requests,
422  h);
423  for (mh = h->monitor_head; NULL != mh; mh = mh->next)
425 }
426 
427 
433 static void
435 {
436  struct GNUNET_DHT_PutHandle *ph;
438  void *cont_cls;
439 
440  if (NULL == h->mq)
441  return;
443  h->mq = NULL;
445  "Disconnecting from DHT service, will try to reconnect in %s\n",
447  GNUNET_YES));
448  /* notify client about all PUTs that (may) have failed due to disconnect */
449  while (NULL != (ph = h->put_head))
450  {
451  cont = ph->cont;
452  cont_cls = ph->cont_cls;
453  ph->env = NULL;
455  if (NULL != cont)
456  cont (cont_cls);
457  }
458  GNUNET_assert (NULL == h->reconnect_task);
460  = GNUNET_SCHEDULER_add_delayed (h->retry_time,
461  &try_reconnect,
462  h);
463 }
464 
465 
474 static void
475 mq_error_handler (void *cls,
476  enum GNUNET_MQ_Error error)
477 {
478  struct GNUNET_DHT_Handle *h = cls;
479 
480  do_disconnect (h);
481 }
482 
483 
492 static enum GNUNET_GenericReturnValue
493 check_monitor_get (void *cls,
494  const struct GNUNET_DHT_MonitorGetMessage *msg)
495 {
496  uint32_t plen = ntohl (msg->get_path_length);
497  uint16_t msize = ntohs (msg->header.size) - sizeof(*msg);
498 
499  if ((plen > UINT16_MAX) ||
500  (plen * sizeof(struct GNUNET_DHT_PathElement) != msize))
501  {
502  GNUNET_break (0);
503  return GNUNET_SYSERR;
504  }
505  return GNUNET_OK;
506 }
507 
508 
515 static void
517  const struct GNUNET_DHT_MonitorGetMessage *msg)
518 {
519  struct GNUNET_DHT_Handle *handle = cls;
521 
522  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
523  {
524  if (NULL == mh->get_cb)
525  continue;
526  if (((GNUNET_BLOCK_TYPE_ANY == mh->type) ||
527  (mh->type == ntohl (msg->type))) &&
528  ((NULL == mh->key) ||
529  (0 == memcmp (mh->key,
530  &msg->key,
531  sizeof(struct GNUNET_HashCode)))))
532  mh->get_cb (mh->cb_cls,
533  ntohl (msg->options),
534  (enum GNUNET_BLOCK_Type) ntohl (msg->type),
535  ntohl (msg->hop_count),
536  ntohl (msg->desired_replication_level),
537  ntohl (msg->get_path_length),
538  (struct GNUNET_DHT_PathElement *) &msg[1],
539  &msg->key);
540  }
541 }
542 
543 
552 static enum GNUNET_GenericReturnValue
553 check_monitor_get_resp (void *cls,
555 {
556  size_t msize = ntohs (msg->header.size) - sizeof(*msg);
557  uint32_t getl = ntohl (msg->get_path_length);
558  uint32_t putl = ntohl (msg->put_path_length);
559 
560  if ((getl + putl < getl) ||
561  ((msize / sizeof(struct GNUNET_DHT_PathElement)) < getl + putl))
562  {
563  GNUNET_break (0);
564  return GNUNET_SYSERR;
565  }
566  return GNUNET_OK;
567 }
568 
569 
576 static void
579 {
580  struct GNUNET_DHT_Handle *handle = cls;
581  size_t msize = ntohs (msg->header.size) - sizeof(*msg);
582  const struct GNUNET_DHT_PathElement *path;
583  uint32_t getl = ntohl (msg->get_path_length);
584  uint32_t putl = ntohl (msg->put_path_length);
586 
587  path = (const struct GNUNET_DHT_PathElement *) &msg[1];
588  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
589  {
590  if (NULL == mh->get_resp_cb)
591  continue;
592  if (((GNUNET_BLOCK_TYPE_ANY == mh->type) ||
593  (mh->type == ntohl (msg->type))) &&
594  ((NULL == mh->key) ||
595  (0 == memcmp (mh->key,
596  &msg->key,
597  sizeof(struct GNUNET_HashCode)))))
598  mh->get_resp_cb (mh->cb_cls,
599  (enum GNUNET_BLOCK_Type) ntohl (msg->type),
600  path,
601  getl,
602  &path[getl],
603  putl,
604  GNUNET_TIME_absolute_ntoh (msg->expiration_time),
605  &msg->key,
606  (const void *) &path[getl + putl],
607  msize - sizeof(struct GNUNET_DHT_PathElement) * (putl
608  + getl));
609  }
610 }
611 
612 
621 static enum GNUNET_GenericReturnValue
622 check_monitor_put (void *cls,
623  const struct GNUNET_DHT_MonitorPutMessage *msg)
624 {
625  size_t msize;
626  uint32_t putl;
627 
628  msize = ntohs (msg->header.size) - sizeof(*msg);
629  putl = ntohl (msg->put_path_length);
630  if ((msize / sizeof(struct GNUNET_DHT_PathElement)) < putl)
631  {
632  GNUNET_break (0);
633  return GNUNET_SYSERR;
634  }
635  return GNUNET_OK;
636 }
637 
638 
645 static void
647  const struct GNUNET_DHT_MonitorPutMessage *msg)
648 {
649  struct GNUNET_DHT_Handle *handle = cls;
650  size_t msize = ntohs (msg->header.size) - sizeof(*msg);
651  uint32_t putl = ntohl (msg->put_path_length);
652  const struct GNUNET_DHT_PathElement *path;
654 
655  path = (const struct GNUNET_DHT_PathElement *) &msg[1];
656  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
657  {
658  if (NULL == mh->put_cb)
659  continue;
660  if (((GNUNET_BLOCK_TYPE_ANY == mh->type) ||
661  (mh->type == ntohl (msg->type))) &&
662  ((NULL == mh->key) ||
663  (0 == memcmp (mh->key,
664  &msg->key,
665  sizeof(struct GNUNET_HashCode)))))
666  mh->put_cb (mh->cb_cls,
667  ntohl (msg->options),
668  (enum GNUNET_BLOCK_Type) ntohl (msg->type),
669  ntohl (msg->hop_count),
670  ntohl (msg->desired_replication_level),
671  putl,
672  path,
673  GNUNET_TIME_absolute_ntoh (msg->expiration_time),
674  &msg->key,
675  (const void *) &path[putl],
676  msize - sizeof(struct GNUNET_DHT_PathElement) * putl);
677  }
678 }
679 
680 
689 static enum GNUNET_GenericReturnValue
690 check_client_result (void *cls,
691  const struct GNUNET_DHT_ClientResultMessage *msg)
692 {
693  size_t msize = ntohs (msg->header.size) - sizeof(*msg);
694  uint32_t put_path_length = ntohl (msg->put_path_length);
695  uint32_t get_path_length = ntohl (msg->get_path_length);
696  size_t meta_length;
697 
698  meta_length =
699  sizeof(struct GNUNET_DHT_PathElement) * (get_path_length + put_path_length);
700  if ((msize < meta_length) ||
701  (get_path_length >
703  (put_path_length >
705  {
706  GNUNET_break (0);
707  return GNUNET_SYSERR;
708  }
709  return GNUNET_OK;
710 }
711 
712 
721 static enum GNUNET_GenericReturnValue
722 process_client_result (void *cls,
723  const struct GNUNET_HashCode *key,
724  void *value)
725 {
726  const struct GNUNET_DHT_ClientResultMessage *crm = cls;
728  size_t msize = ntohs (crm->header.size) - sizeof(*crm);
729  uint32_t put_path_length = ntohl (crm->put_path_length);
730  uint32_t get_path_length = ntohl (crm->get_path_length);
731  const struct GNUNET_DHT_PathElement *put_path;
732  const struct GNUNET_DHT_PathElement *get_path;
733  struct GNUNET_HashCode hc;
734  size_t data_length;
735  size_t meta_length;
736  const void *data;
737 
738  if (crm->unique_id != get_handle->unique_id)
739  {
740  /* UID mismatch */
742  "Ignoring reply for %s: UID mismatch: %llu/%llu\n",
743  GNUNET_h2s (key),
744  (unsigned long long) crm->unique_id,
745  (unsigned long long) get_handle->unique_id);
746  return GNUNET_YES;
747  }
748  /* FIXME: might want to check that type matches */
749  meta_length =
750  sizeof(struct GNUNET_DHT_PathElement) * (get_path_length + put_path_length);
751  data_length = msize - meta_length;
752  put_path = (const struct GNUNET_DHT_PathElement *) &crm[1];
753  get_path = &put_path[put_path_length];
754  {
755  char *pp;
756  char *gp;
757 
758  gp = GNUNET_DHT_pp2s (get_path,
759  get_path_length);
760  pp = GNUNET_DHT_pp2s (put_path,
761  put_path_length);
763  "Giving %u byte reply for %s to application (GP: %s, PP: %s)\n",
764  (unsigned int) data_length,
765  GNUNET_h2s (key),
766  gp,
767  pp);
768  GNUNET_free (gp);
769  GNUNET_free (pp);
770  }
771  data = &get_path[get_path_length];
772  /* remember that we've seen this result */
774  data_length,
775  &hc);
779  get_handle->seen_results_size * 2 + 1);
781  /* no need to block it explicitly, service already knows about it! */
784  key,
785  get_path,
786  get_path_length,
787  put_path,
788  put_path_length,
789  ntohl (crm->type),
790  data_length,
791  data);
792  return GNUNET_YES;
793 }
794 
795 
802 static void
804  const struct GNUNET_DHT_ClientResultMessage *msg)
805 {
806  struct GNUNET_DHT_Handle *handle = cls;
807 
809  &msg->key,
811  (void *) msg);
812 }
813 
814 
820 static void
821 handle_put_cont (void *cls)
822 {
823  struct GNUNET_DHT_PutHandle *ph = cls;
825  void *cont_cls;
826 
827  cont = ph->cont;
828  cont_cls = ph->cont_cls;
829  ph->env = NULL;
831  if (NULL != cont)
832  cont (cont_cls);
833 }
834 
835 
842 static enum GNUNET_GenericReturnValue
844 {
846  GNUNET_MQ_hd_var_size (monitor_get,
849  h),
850  GNUNET_MQ_hd_var_size (monitor_get_resp,
853  h),
854  GNUNET_MQ_hd_var_size (monitor_put,
857  h),
858  GNUNET_MQ_hd_var_size (client_result,
861  h),
863  };
864 
865  if (NULL != h->mq)
866  return GNUNET_OK;
868  "dht",
869  handlers,
871  h);
872  if (NULL == h->mq)
873  {
875  "Failed to connect to the DHT service!\n");
876  return GNUNET_NO;
877  }
878  return GNUNET_YES;
879 }
880 
881 
882 struct GNUNET_DHT_Handle *
884  unsigned int ht_len)
885 {
886  struct GNUNET_DHT_Handle *handle;
887 
889  handle->cfg = cfg;
890  handle->uid_gen
892  UINT64_MAX);
893  handle->active_requests
895  GNUNET_YES);
896  if (GNUNET_NO == try_connect (handle))
897  {
899  return NULL;
900  }
901  return handle;
902 }
903 
904 
905 void
907 {
908  struct GNUNET_DHT_PutHandle *ph;
909 
910  GNUNET_assert (0 ==
911  GNUNET_CONTAINER_multihashmap_size (handle->active_requests));
912  while (NULL != (ph = handle->put_head))
913  {
914  if (NULL != ph->cont)
915  ph->cont (ph->cont_cls);
917  }
918  if (NULL != handle->mq)
919  {
921  handle->mq = NULL;
922  }
923  if (NULL != handle->reconnect_task)
924  {
926  handle->reconnect_task = NULL;
927  }
930 }
931 
932 
933 struct GNUNET_DHT_PutHandle *
935  const struct GNUNET_HashCode *key,
936  uint32_t desired_replication_level,
938  enum GNUNET_BLOCK_Type type,
939  size_t size,
940  const void *data,
941  struct GNUNET_TIME_Absolute exp,
943  void *cont_cls)
944 {
945  struct GNUNET_MQ_Envelope *env;
946  struct GNUNET_DHT_ClientPutMessage *put_msg;
947  size_t msize;
948  struct GNUNET_DHT_PutHandle *ph;
949 
950  msize = sizeof(struct GNUNET_DHT_ClientPutMessage) + size;
951  if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
953  {
954  GNUNET_break (0);
955  return NULL;
956  }
957  if (NULL == handle->mq)
958  return NULL;
960  "Sending PUT for %s to DHT via %p\n",
961  GNUNET_h2s (key),
962  handle);
964  ph->dht_handle = handle;
965  ph->cont = cont;
966  ph->cont_cls = cont_cls;
968  handle->put_tail,
969  ph);
970  env = GNUNET_MQ_msg_extra (put_msg,
971  size,
975  ph);
976  ph->env = env;
977  put_msg->type = htonl ((uint32_t) type);
978  put_msg->options = htonl ((uint32_t) options);
980  put_msg->expiration = GNUNET_TIME_absolute_hton (exp);
981  put_msg->key = *key;
982  GNUNET_memcpy (&put_msg[1],
983  data,
984  size);
986  env);
987  return ph;
988 }
989 
990 
991 void
993 {
994  struct GNUNET_DHT_Handle *handle = ph->dht_handle;
995 
996  if (NULL != ph->env)
998  NULL,
999  NULL);
1001  handle->put_tail,
1002  ph);
1003  GNUNET_free (ph);
1004 }
1005 
1006 
1007 struct GNUNET_DHT_GetHandle *
1009  enum GNUNET_BLOCK_Type type,
1010  const struct GNUNET_HashCode *key,
1011  uint32_t desired_replication_level,
1013  const void *xquery,
1014  size_t xquery_size,
1016  void *iter_cls)
1017 {
1018  struct GNUNET_DHT_GetHandle *gh;
1019  size_t msize;
1020 
1021  msize = sizeof(struct GNUNET_DHT_ClientGetMessage) + xquery_size;
1022  if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
1023  (xquery_size >= GNUNET_MAX_MESSAGE_SIZE))
1024  {
1025  GNUNET_break (0);
1026  return NULL;
1027  }
1029  "Sending query for %s to DHT %p\n",
1030  GNUNET_h2s (key),
1031  handle);
1032  gh = GNUNET_malloc (sizeof(struct GNUNET_DHT_GetHandle)
1033  + xquery_size);
1034  gh->iter = iter;
1035  gh->iter_cls = iter_cls;
1036  gh->dht_handle = handle;
1037  gh->key = *key;
1038  gh->unique_id = ++handle->uid_gen;
1039  gh->xquery_size = xquery_size;
1040  gh->desired_replication_level = desired_replication_level;
1041  gh->type = type;
1042  gh->options = options;
1043  GNUNET_memcpy (&gh[1],
1044  xquery,
1045  xquery_size);
1046  GNUNET_CONTAINER_multihashmap_put (handle->active_requests,
1047  &gh->key,
1048  gh,
1050  if (NULL != handle->mq)
1051  send_get (gh);
1052  return gh;
1053 }
1054 
1055 
1056 void
1058  unsigned int num_results,
1059  const struct GNUNET_HashCode *results)
1060 {
1061  unsigned int needed;
1062  unsigned int had;
1063 
1065  needed = had + num_results;
1066  if (needed > get_handle->seen_results_size)
1069  needed);
1071  results,
1072  num_results * sizeof(struct GNUNET_HashCode));
1073  get_handle->seen_results_end += num_results;
1074  if (NULL != get_handle->dht_handle->mq)
1076  had);
1077 }
1078 
1079 
1080 void
1082 {
1084 
1086  "Sending STOP for %s to DHT via %p\n",
1088  handle);
1089  if (NULL != handle->mq)
1090  {
1091  struct GNUNET_MQ_Envelope *env;
1092  struct GNUNET_DHT_ClientGetStopMessage *stop_msg;
1093 
1094  env = GNUNET_MQ_msg (stop_msg,
1096  stop_msg->reserved = htonl (0);
1097  stop_msg->unique_id = get_handle->unique_id;
1098  stop_msg->key = get_handle->key;
1100  env);
1101  }
1103  GNUNET_CONTAINER_multihashmap_remove (handle->active_requests,
1104  &get_handle->key,
1105  get_handle));
1108  0);
1110 }
1111 
1112 
1113 struct GNUNET_DHT_MonitorHandle *
1115  enum GNUNET_BLOCK_Type type,
1116  const struct GNUNET_HashCode *key,
1120  void *cb_cls)
1121 {
1122  struct GNUNET_DHT_MonitorHandle *mh;
1123 
1125  mh->get_cb = get_cb;
1126  mh->get_resp_cb = get_resp_cb;
1127  mh->put_cb = put_cb;
1128  mh->cb_cls = cb_cls;
1129  mh->type = type;
1130  mh->dht_handle = handle;
1131  if (NULL != key)
1132  {
1133  mh->key = GNUNET_new (struct GNUNET_HashCode);
1134  *mh->key = *key;
1135  }
1136  GNUNET_CONTAINER_DLL_insert (handle->monitor_head,
1137  handle->monitor_tail,
1138  mh);
1139  if (NULL != handle->mq)
1141  return mh;
1142 }
1143 
1144 
1145 void
1147 {
1148  struct GNUNET_DHT_Handle *handle = mh->dht_handle;
1150  struct GNUNET_MQ_Envelope *env;
1151 
1152  GNUNET_CONTAINER_DLL_remove (handle->monitor_head,
1153  handle->monitor_tail,
1154  mh);
1155  env = GNUNET_MQ_msg (m,
1157  m->type = htonl (mh->type);
1158  m->get = htons (NULL != mh->get_cb);
1159  m->get_resp = htons (NULL != mh->get_resp_cb);
1160  m->put = htons (NULL != mh->put_cb);
1161  if (NULL != mh->key)
1162  {
1163  m->filter_key = htons (1);
1164  m->key = *mh->key;
1165  }
1167  env);
1168  GNUNET_free (mh->key);
1169  GNUNET_free (mh);
1170 }
1171 
1172 
1173 char *
1175  unsigned int path_len)
1176 {
1177  char *buf;
1178  size_t off;
1179  size_t plen = path_len * 5 + 1;
1180 
1181  GNUNET_assert (path_len < UINT32_MAX / 5);
1182  off = 0;
1183  buf = GNUNET_malloc (plen);
1184  for (unsigned int i = 0; i < path_len; i++)
1185  {
1186  off += GNUNET_snprintf (&buf[off],
1187  plen - off,
1188  "%s%s",
1189  GNUNET_i2s (&path[i].pred),
1190  (i == path_len - 1) ? "" : "-");
1191  }
1192  return buf;
1193 }
1194 
1195 
1196 unsigned int
1198  const void *data,
1199  size_t data_size,
1200  struct GNUNET_TIME_Absolute exp_time,
1201  const struct GNUNET_DHT_PathElement *put_path,
1202  unsigned int put_path_len,
1203  const struct GNUNET_DHT_PathElement *get_path,
1204  unsigned int get_path_len,
1205  const struct GNUNET_PeerIdentity *me)
1206 {
1207  struct GNUNET_DHT_HopSignature hs = {
1209  .purpose.size = htonl (sizeof (hs)),
1210  .expiration_time = GNUNET_TIME_absolute_hton (exp_time),
1211  .key = *key,
1212  };
1213  unsigned int i;
1214 
1215  if (0 == get_path_len + put_path_len)
1216  return 0;
1218  "Verifying signatures with GPL: %u PPL: %u!\n",
1219  get_path_len,
1220  put_path_len);
1221  i = put_path_len + get_path_len - 1;
1223  data_size,
1224  &hs.h_data);
1225  while (i > 0)
1226  {
1227  hs.pred = (i - 1 >= put_path_len)
1228  ? get_path[i - put_path_len - 1].pred
1229  : put_path[i - 1].pred;
1230  if (i + 1 == get_path_len + put_path_len)
1231  hs.succ = *me;
1232  else
1233  hs.succ = (i + 1 >= put_path_len)
1234  ? get_path[i + 1 - put_path_len].pred
1235  : put_path[i + 1].pred;
1236  if (GNUNET_OK !=
1239  &hs,
1240  (i - 1 >= put_path_len)
1241  ? &get_path[i - put_path_len - 1].sig
1242  : &put_path[i - 1].sig,
1243  (i >= put_path_len)
1244  ? &get_path[i - put_path_len].pred.public_key
1245  : &put_path[i].pred.public_key))
1246  return i;
1247  i--;
1248  }
1249  return i;
1250 }
1251 
1252 
1253 /* end of dht_api.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static void send_get(struct GNUNET_DHT_GetHandle *gh)
Send GET message for a get_handle to DHT.
Definition: dht_api.c:274
static void handle_monitor_get_resp(void *cls, const struct GNUNET_DHT_MonitorGetRespMessage *msg)
Process a get response monitor message from the service.
Definition: dht_api.c:577
static enum GNUNET_GenericReturnValue check_monitor_get(void *cls, const struct GNUNET_DHT_MonitorGetMessage *msg)
Verify integrity of a get monitor message from the service.
Definition: dht_api.c:493
static enum GNUNET_GenericReturnValue try_connect(struct GNUNET_DHT_Handle *h)
Try to (re)connect to the DHT service.
Definition: dht_api.c:843
static void handle_client_result(void *cls, const struct GNUNET_DHT_ClientResultMessage *msg)
Process a client result message received from the service.
Definition: dht_api.c:803
static void try_reconnect(void *cls)
Try reconnecting to the dht service.
Definition: dht_api.c:400
static enum GNUNET_GenericReturnValue process_client_result(void *cls, const struct GNUNET_HashCode *key, void *value)
Process a given reply that might match the given request.
Definition: dht_api.c:722
static enum GNUNET_GenericReturnValue check_monitor_get_resp(void *cls, const struct GNUNET_DHT_MonitorGetRespMessage *msg)
Validate a get response monitor message from the service.
Definition: dht_api.c:553
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
Definition: dht_api.c:475
static void handle_monitor_get(void *cls, const struct GNUNET_DHT_MonitorGetMessage *msg)
Process a get monitor message from the service.
Definition: dht_api.c:516
static enum GNUNET_GenericReturnValue check_client_result(void *cls, const struct GNUNET_DHT_ClientResultMessage *msg)
Verify that client result message received from the service is well-formed.
Definition: dht_api.c:690
static void do_disconnect(struct GNUNET_DHT_Handle *h)
Try reconnecting to the DHT service.
Definition: dht_api.c:434
static void handle_put_cont(void *cls)
Process a MQ PUT transmission notification.
Definition: dht_api.c:821
static enum GNUNET_GenericReturnValue add_get_request_to_pending(void *cls, const struct GNUNET_HashCode *key, void *value)
Add the GET request corresponding to the given route handle to the pending queue (if it is not alread...
Definition: dht_api.c:349
static void send_get_known_results(struct GNUNET_DHT_GetHandle *gh, unsigned int transmission_offset_start)
Send GET message(s) for indicating which results are already known for a get_handle to DHT.
Definition: dht_api.c:306
static void handle_monitor_put(void *cls, const struct GNUNET_DHT_MonitorPutMessage *msg)
Process a put monitor message from the service.
Definition: dht_api.c:646
#define LOG(kind,...)
Definition: dht_api.c:38
static enum GNUNET_GenericReturnValue check_monitor_put(void *cls, const struct GNUNET_DHT_MonitorPutMessage *msg)
Check validity of a put monitor message from the service.
Definition: dht_api.c:622
static void send_monitor_start(struct GNUNET_DHT_MonitorHandle *mh)
Send GNUNET_MESSAGE_TYPE_DHT_MONITOR_START message.
Definition: dht_api.c:372
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
static GNUNET_NETWORK_STRUCT_END struct GNUNET_PeerIdentity me
Our own peer identity.
static struct GNUNET_DHT_GetHandle * get_handle
Handle for the get request.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
uint32_t data
The data value.
static char * value
Value of the record to add/remove.
static struct GNUNET_TRANSPORT_HelloGetHandle * gh
Pending GNUNET_TRANSPORT_hello_get() operation.
static unsigned int results
Definition: gnunet-search.c:52
static char buf[2048]
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:92
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_SIGNATURE_PURPOSE_DHT_HOP
Signature by which a peer affirms that it forwarded a message in the DHT.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
@ GNUNET_BLOCK_TYPE_ANY
Any type of block, used as a wildcard when searching.
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition: client.c:1064
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
#define GNUNET_CRYPTO_eddsa_verify(purp, ps, sig, pub)
Verify EdDSA signature.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition: dht_api.c:992
GNUNET_DHT_RouteOption
Options for routing.
char * GNUNET_DHT_pp2s(const struct GNUNET_DHT_PathElement *path, unsigned int path_len)
Convert a peer path to a human-readable string.
Definition: dht_api.c:1174
struct GNUNET_DHT_MonitorHandle * GNUNET_DHT_monitor_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, GNUNET_DHT_MonitorGetCB get_cb, GNUNET_DHT_MonitorGetRespCB get_resp_cb, GNUNET_DHT_MonitorPutCB put_cb, void *cb_cls)
Start monitoring the local DHT service.
Definition: dht_api.c:1114
void(* GNUNET_DHT_GetIterator)(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data)
Iterator called on each result obtained for a DHT operation that expects a reply.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1081
void GNUNET_DHT_get_filter_known_results(struct GNUNET_DHT_GetHandle *get_handle, unsigned int num_results, const struct GNUNET_HashCode *results)
Tell the DHT not to return any of the following known results to this client.
Definition: dht_api.c:1057
unsigned int GNUNET_DHT_verify_path(const struct GNUNET_HashCode *key, const void *data, size_t data_size, struct GNUNET_TIME_Absolute exp_time, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_len, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_len, const struct GNUNET_PeerIdentity *me)
Verify signatures on a path consisting of put_path and get_path in reverse order (starting at the las...
Definition: dht_api.c:1197
void(* GNUNET_DHT_MonitorPutCB)(void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_DHT_PathElement *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Callback called on each PUT request going through the DHT.
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
Definition: dht_api.c:883
struct GNUNET_DHT_PutHandle * GNUNET_DHT_put(struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform a PUT operation storing data in the DHT.
Definition: dht_api.c:934
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:906
void(* GNUNET_DHT_MonitorGetRespCB)(void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Callback called on each GET reply going through the DHT.
struct GNUNET_DHT_GetHandle * GNUNET_DHT_get_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, const void *xquery, size_t xquery_size, GNUNET_DHT_GetIterator iter, void *iter_cls)
Perform an asynchronous GET operation on the DHT identified.
Definition: dht_api.c:1008
void(* GNUNET_DHT_MonitorGetCB)(void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_DHT_PathElement *path, const struct GNUNET_HashCode *key)
Callback called on each GET request going through the DHT.
void GNUNET_DHT_monitor_stop(struct GNUNET_DHT_MonitorHandle *mh)
Stop monitoring.
Definition: dht_api.c:1146
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
int GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from 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_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.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the 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.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
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).
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_MQ_Error
Error codes for the queue.
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:355
#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:52
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition: mq.c:789
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:839
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET
Receive information about transiting GETs.
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP
Receive information about transiting GET responses.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT
Client wants to store item in DHT.
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_START
Request information about transiting messages.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN
Certain results are already known to the client, filter those.
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT
Receive information about transiting PUTs.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP
Client wants to stop search in DHT.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT
Service returns result to client.
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP
Stop information about transiting messages.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET
Client wants to lookup item in DHT.
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
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:1269
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:699
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:543
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:607
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
#define max(x, y)
static unsigned int size
Size of the "table".
Definition: peer.c:67
static int put_cb(void *cls, const struct GNUNET_HashCode *key, void *value)
Function called during PUT to detect if an equivalent block already exists.
static int get_cb(void *cls, const struct GNUNET_HashCode *key, void *value)
Function called during GET to find matching blocks.
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
struct GNUNET_MQ_Handle * mq
Our connection to the ARM service.
Definition: arm_api.c:107
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration that we are using.
Definition: arm_api.c:112
struct GNUNET_SCHEDULER_Task * reconnect_task
ID of the reconnect task (if any).
Definition: arm_api.c:147
Internal representation of the hash map.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
DHT GET message sent from clients to service.
Definition: dht.h:72
uint64_t unique_id
Unique ID identifying this request, if 0 then the client will not expect a response.
Definition: dht.h:103
uint32_t options
Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
Definition: dht.h:81
struct GNUNET_HashCode key
The key to search for.
Definition: dht.h:97
uint32_t type
The type for the data for the GET request; actually an 'enum GNUNET_BLOCK_Type'.
Definition: dht.h:92
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:86
DHT GET RESULTS KNOWN message sent from clients to service.
Definition: dht.h:114
Message which indicates the DHT should cancel outstanding requests and discard any state.
Definition: dht.h:44
uint64_t unique_id
Unique ID identifying this request.
Definition: dht.h:58
struct GNUNET_HashCode key
Key of this request.
Definition: dht.h:63
uint32_t reserved
Always zero.
Definition: dht.h:53
Message to insert data into the DHT, sent from clients to DHT service.
Definition: dht.h:190
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:219
uint32_t type
The type of data to insert.
Definition: dht.h:199
uint32_t options
Message options, actually an 'enum GNUNET_DHT_RouteOption' value.
Definition: dht.h:204
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:209
struct GNUNET_TIME_AbsoluteNBO expiration
How long should this data persist?
Definition: dht.h:214
Reply to a GET send from the service to a client.
Definition: dht.h:144
uint32_t put_path_length
Number of peers recorded in the outgoing path from source to the storgage location of this message.
Definition: dht.h:159
uint64_t unique_id
Unique ID of the matching GET request.
Definition: dht.h:170
struct GNUNET_TIME_AbsoluteNBO expiration
When does this entry expire?
Definition: dht.h:175
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT.
Definition: dht.h:148
uint32_t type
The type for the data.
Definition: dht.h:153
uint32_t get_path_length
The number of peer identities recorded from the storage location to this peer.
Definition: dht.h:165
Handle to a GET request.
Definition: dht_api.c:81
GNUNET_DHT_GetIterator iter
Iterator to call on data receipt.
Definition: dht_api.c:85
enum GNUNET_BLOCK_Type type
Type of the block we are looking for.
Definition: dht_api.c:126
void * iter_cls
Closure for iter.
Definition: dht_api.c:90
unsigned int seen_results_end
Offset into the seen_results array marking the end of the positions that are actually used.
Definition: dht_api.c:143
struct GNUNET_HashCode * seen_results
Array of hash codes over the results that we have already seen.
Definition: dht_api.c:101
size_t xquery_size
Size of the extended query, allocated at the end of this struct.
Definition: dht_api.c:116
uint32_t desired_replication_level
Desired replication level.
Definition: dht_api.c:121
struct GNUNET_HashCode key
Key that this get request is for.
Definition: dht_api.c:106
uint64_t unique_id
Unique identifier for this request (for key collisions).
Definition: dht_api.c:111
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition: dht_api.c:95
enum GNUNET_DHT_RouteOption options
Routing options.
Definition: dht_api.c:131
unsigned int seen_results_size
Size of the seen_results array.
Definition: dht_api.c:137
Connection to the DHT service.
Definition: dht_api.c:203
struct GNUNET_CONTAINER_MultiHashMap * active_requests
Hash map containing the current outstanding unique GET requests (values are of type struct GNUNET_DHT...
Definition: dht_api.c:238
struct GNUNET_TIME_Relative retry_time
How quickly should we retry? Used for exponential back-off on connect-errors.
Definition: dht_api.c:249
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for trying to reconnect.
Definition: dht_api.c:243
struct GNUNET_DHT_PutHandle * put_tail
Tail of active PUT requests.
Definition: dht_api.c:232
struct GNUNET_DHT_MonitorHandle * monitor_tail
Tail of linked list of messages we would like to monitor.
Definition: dht_api.c:222
struct GNUNET_MQ_Handle * mq
Connection to DHT service.
Definition: dht_api.c:212
struct GNUNET_DHT_PutHandle * put_head
Head of active PUT requests.
Definition: dht_api.c:227
struct GNUNET_DHT_MonitorHandle * monitor_head
Head of linked list of messages we would like to monitor.
Definition: dht_api.c:217
uint64_t uid_gen
Generator for unique ids.
Definition: dht_api.c:254
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: dht_api.c:207
Message signed by a peer when doing path tracking.
struct GNUNET_HashCode h_data
Hash over the payload of the block.
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Must be GNUNET_SIGNATURE_PURPOSE_DHT_HOP.
struct GNUNET_PeerIdentity pred
Previous hop the message was received from.
struct GNUNET_PeerIdentity succ
Next hop the message was forwarded to.
Message to monitor get requests going through peer, DHT service -> clients.
Definition: dht.h:324
Message to monitor get results going through peer, DHT service -> clients.
Definition: dht.h:368
Handle to a monitoring request.
Definition: dht_api.c:151
GNUNET_DHT_MonitorGetRespCB get_resp_cb
Callback for each received message of type get response.
Definition: dht_api.c:185
struct GNUNET_HashCode * key
Key being looked for, NULL == all.
Definition: dht_api.c:175
struct GNUNET_DHT_MonitorHandle * prev
DLL.
Definition: dht_api.c:160
struct GNUNET_DHT_MonitorHandle * next
DLL.
Definition: dht_api.c:155
GNUNET_DHT_MonitorPutCB put_cb
Callback for each received message of type put.
Definition: dht_api.c:190
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition: dht_api.c:165
GNUNET_DHT_MonitorGetCB get_cb
Callback for each received message of type get.
Definition: dht_api.c:180
void * cb_cls
Closure for get_cb, put_cb and get_resp_cb.
Definition: dht_api.c:195
enum GNUNET_BLOCK_Type type
Type of block looked for.
Definition: dht_api.c:170
Message to monitor put requests going through peer, DHT service -> clients.
Definition: dht.h:229
Message to request monitoring messages, clients -> DHT service.
Definition: dht.h:281
A (signed) path tracking a block's flow through the DHT is represented by an array of path elements,...
struct GNUNET_PeerIdentity pred
Previous peer on the path (matches "pred" in the signed field).
struct GNUNET_CRYPTO_EddsaSignature sig
Signature affirming the hop of type GNUNET_SIGNATURE_PURPOSE_DHT_HOP.
Handle to a PUT request.
Definition: dht_api.c:45
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition: dht_api.c:64
struct GNUNET_DHT_PutHandle * prev
Kept in a DLL.
Definition: dht_api.c:54
void * cont_cls
Closure for cont.
Definition: dht_api.c:69
struct GNUNET_MQ_Envelope * env
Envelope from the PUT operation.
Definition: dht_api.c:74
struct GNUNET_DHT_PutHandle * next
Kept in a DLL.
Definition: dht_api.c:49
GNUNET_SCHEDULER_TaskCallback cont
Continuation to call when done.
Definition: dht_api.c:59
struct GNUNET_SCHEDULER_Task * reconnect_task
Task to reconnect to the service.
Definition: dns_api.c:81
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: dns_api.c:66
struct GNUNET_MQ_Handle * mq
Connection to DNS service, or NULL.
Definition: dns_api.c:61
A 512-bit hashcode.
Handle to a message queue.
Definition: mq.c:86
Message handler for a specific message type.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
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 GNUNET_CRYPTO_EddsaPublicKey public_key
Entry in list of pending tasks.
Definition: scheduler.c:135
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model