GNUnet  0.10.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_arm_service.h"
32 #include "gnunet_hello_lib.h"
33 #include "gnunet_protocols.h"
34 #include "gnunet_dht_service.h"
35 #include "dht.h"
36 
37 #define LOG(kind,...) GNUNET_log_from (kind, "dht-api",__VA_ARGS__)
38 
39 
44 {
49 
54 
59 
64 
68  void *cont_cls;
69 
74 
75 };
76 
81 {
82 
87 
91  void *iter_cls;
92 
97 
103 
108 
112  uint64_t unique_id;
113 
117  size_t xquery_size;
118 
123 
128 
133 
138  unsigned int seen_results_size;
139 
144  unsigned int seen_results_end;
145 
146 };
147 
148 
153 {
158 
163 
168 
173 
178 
183 
188 
193 
197  void *cb_cls;
198 
199 };
200 
201 
206 {
207 
212 
217 
222 
227 
232 
237 
243 
248 
253  struct GNUNET_TIME_Relative retry_time;
254 
258  uint64_t uid_gen;
259 
260 
261 };
262 
263 
270 static int
272 
273 
279 static void
281 {
282  struct GNUNET_DHT_Handle *h = gh->dht_handle;
283  struct GNUNET_MQ_Envelope *env;
284  struct GNUNET_DHT_ClientGetMessage *get_msg;
285 
286  env = GNUNET_MQ_msg_extra (get_msg,
287  gh->xquery_size,
289  get_msg->options = htonl ((uint32_t) gh->options);
291  get_msg->type = htonl (gh->type);
292  get_msg->key = gh->key;
293  get_msg->unique_id = gh->unique_id;
294  GNUNET_memcpy (&get_msg[1],
295  &gh[1],
296  gh->xquery_size);
297  GNUNET_MQ_send (h->mq,
298  env);
299 }
300 
301 
311 static void
313  unsigned int transmission_offset_start)
314 {
315  struct GNUNET_DHT_Handle *h = gh->dht_handle;
316  struct GNUNET_MQ_Envelope *env;
318  unsigned int delta;
319  unsigned int max;
320  unsigned int transmission_offset;
321 
322  max = (GNUNET_MAX_MESSAGE_SIZE - sizeof (*msg))
323  / sizeof (struct GNUNET_HashCode);
324  transmission_offset = transmission_offset_start;
325  while (transmission_offset < gh->seen_results_end)
326  {
327  delta = gh->seen_results_end - transmission_offset;
328  if (delta > max)
329  delta = max;
330  env = GNUNET_MQ_msg_extra (msg,
331  delta * sizeof (struct GNUNET_HashCode),
333  msg->key = gh->key;
334  msg->unique_id = gh->unique_id;
335  GNUNET_memcpy (&msg[1],
336  &gh->seen_results[transmission_offset],
337  sizeof (struct GNUNET_HashCode) * delta);
338  GNUNET_MQ_send (h->mq,
339  env);
340  transmission_offset += delta;
341  }
342 }
343 
344 
354 static int
356  const struct GNUNET_HashCode *key,
357  void *value)
358 {
359  struct GNUNET_DHT_Handle *handle = cls;
360  struct GNUNET_DHT_GetHandle *gh = value;
361 
363  "Retransmitting request related to %s to DHT %p\n",
364  GNUNET_h2s (key),
365  handle);
366  send_get (gh);
367  send_get_known_results (gh, 0);
368  return GNUNET_YES;
369 }
370 
371 
377 static void
379 {
380  struct GNUNET_DHT_Handle *h = mh->dht_handle;
381  struct GNUNET_MQ_Envelope *env;
383 
384  env = GNUNET_MQ_msg (m,
386  m->type = htonl (mh->type);
387  m->get = htons (NULL != mh->get_cb);
388  m->get_resp = htons (NULL != mh->get_resp_cb);
389  m->put = htons (NULL != mh->put_cb);
390  if (NULL != mh->key)
391  {
392  m->filter_key = htons(1);
393  m->key = *mh->key;
394  }
395  GNUNET_MQ_send (h->mq,
396  env);
397 }
398 
399 
405 static void
406 try_reconnect (void *cls)
407 {
408  struct GNUNET_DHT_Handle *h = cls;
410 
412  "Reconnecting with DHT %p\n",
413  h);
415  h->reconnect_task = NULL;
416  if (GNUNET_YES != try_connect (h))
417  {
419  "DHT reconnect failed!\n");
420  h->reconnect_task
422  &try_reconnect,
423  h);
424  return;
425  }
428  h);
429  for (mh = h->monitor_head; NULL != mh; mh = mh->next)
430  send_monitor_start (mh);
431 }
432 
433 
439 static void
441 {
442  struct GNUNET_DHT_PutHandle *ph;
444  void *cont_cls;
445 
446  if (NULL == h->mq)
447  return;
448  GNUNET_MQ_destroy (h->mq);
449  h->mq = NULL;
451  "Disconnecting from DHT service, will try to reconnect in %s\n",
453  GNUNET_YES));
454  /* notify client about all PUTs that (may) have failed due to disconnect */
455  while (NULL != (ph = h->put_head))
456  {
457  cont = ph->cont;
458  cont_cls = ph->cont_cls;
459  ph->env = NULL;
461  if (NULL != cont)
462  cont (cont_cls);
463  }
464  GNUNET_assert (NULL == h->reconnect_task);
465  h->reconnect_task
467  &try_reconnect,
468  h);
469 }
470 
471 
480 static void
481 mq_error_handler (void *cls,
482  enum GNUNET_MQ_Error error)
483 {
484  struct GNUNET_DHT_Handle *h = cls;
485 
486  do_disconnect (h);
487 }
488 
489 
498 static int
499 check_monitor_get (void *cls,
500  const struct GNUNET_DHT_MonitorGetMessage *msg)
501 {
502  uint32_t plen = ntohl (msg->get_path_length);
503  uint16_t msize = ntohs (msg->header.size) - sizeof (*msg);
504 
505  if ( (plen > UINT16_MAX) ||
506  (plen * sizeof (struct GNUNET_PeerIdentity) != msize) )
507  {
508  GNUNET_break (0);
509  return GNUNET_SYSERR;
510  }
511  return GNUNET_OK;
512 }
513 
514 
521 static void
523  const struct GNUNET_DHT_MonitorGetMessage *msg)
524 {
525  struct GNUNET_DHT_Handle *handle = cls;
527 
528  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
529  {
530  if (NULL == mh->get_cb)
531  continue;
532  if ( ( (GNUNET_BLOCK_TYPE_ANY == mh->type) ||
533  (mh->type == ntohl (msg->type)) ) &&
534  ( (NULL == mh->key) ||
535  (0 == memcmp (mh->key,
536  &msg->key,
537  sizeof (struct GNUNET_HashCode))) ) )
538  mh->get_cb (mh->cb_cls,
539  ntohl (msg->options),
540  (enum GNUNET_BLOCK_Type) ntohl(msg->type),
541  ntohl (msg->hop_count),
542  ntohl (msg->desired_replication_level),
543  ntohl (msg->get_path_length),
544  (struct GNUNET_PeerIdentity *) &msg[1],
545  &msg->key);
546  }
547 }
548 
549 
558 static int
561 {
562  size_t msize = ntohs (msg->header.size) - sizeof (*msg);
563  uint32_t getl = ntohl (msg->get_path_length);
564  uint32_t putl = ntohl (msg->put_path_length);
565 
566  if ( (getl + putl < getl) ||
567  ( (msize / sizeof (struct GNUNET_PeerIdentity)) < getl + putl) )
568  {
569  GNUNET_break (0);
570  return GNUNET_SYSERR;
571  }
572  return GNUNET_OK;
573 }
574 
575 
582 static void
585 {
586  struct GNUNET_DHT_Handle *handle = cls;
587  size_t msize = ntohs (msg->header.size) - sizeof (*msg);
588  const struct GNUNET_PeerIdentity *path;
589  uint32_t getl = ntohl (msg->get_path_length);
590  uint32_t putl = ntohl (msg->put_path_length);
592 
593  path = (const struct GNUNET_PeerIdentity *) &msg[1];
594  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
595  {
596  if (NULL == mh->get_resp_cb)
597  continue;
598  if ( ( (GNUNET_BLOCK_TYPE_ANY == mh->type) ||
599  (mh->type == ntohl(msg->type)) ) &&
600  ( (NULL == mh->key) ||
601  (0 == memcmp (mh->key,
602  &msg->key,
603  sizeof (struct GNUNET_HashCode))) ) )
604  mh->get_resp_cb (mh->cb_cls,
605  (enum GNUNET_BLOCK_Type) ntohl (msg->type),
606  path,
607  getl,
608  &path[getl],
609  putl,
611  &msg->key,
612  (const void *) &path[getl + putl],
613  msize - sizeof (struct GNUNET_PeerIdentity) * (putl + getl));
614  }
615 }
616 
617 
626 static int
627 check_monitor_put (void *cls,
628  const struct GNUNET_DHT_MonitorPutMessage *msg)
629 {
630  size_t msize;
631  uint32_t putl;
632 
633  msize = ntohs (msg->header.size) - sizeof (*msg);
634  putl = ntohl (msg->put_path_length);
635  if ((msize / sizeof (struct GNUNET_PeerIdentity)) < putl)
636  {
637  GNUNET_break (0);
638  return GNUNET_SYSERR;
639  }
640  return GNUNET_OK;
641 }
642 
643 
650 static void
652  const struct GNUNET_DHT_MonitorPutMessage *msg)
653 {
654  struct GNUNET_DHT_Handle *handle = cls;
655  size_t msize = ntohs (msg->header.size) - sizeof (*msg);
656  uint32_t putl = ntohl (msg->put_path_length);
657  const struct GNUNET_PeerIdentity *path;
659 
660  path = (const struct GNUNET_PeerIdentity *) &msg[1];
661  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
662  {
663  if (NULL == mh->put_cb)
664  continue;
665  if ( ( (GNUNET_BLOCK_TYPE_ANY == mh->type) ||
666  (mh->type == ntohl(msg->type)) ) &&
667  ( (NULL == mh->key) ||
668  (0 == memcmp (mh->key,
669  &msg->key,
670  sizeof (struct GNUNET_HashCode))) ) )
671  mh->put_cb (mh->cb_cls,
672  ntohl (msg->options),
673  (enum GNUNET_BLOCK_Type) ntohl(msg->type),
674  ntohl (msg->hop_count),
675  ntohl (msg->desired_replication_level),
676  putl,
677  path,
679  &msg->key,
680  (const void *) &path[putl],
681  msize - sizeof (struct GNUNET_PeerIdentity) * putl);
682  }
683 }
684 
685 
694 static int
696  const struct GNUNET_DHT_ClientResultMessage *msg)
697 {
698  size_t msize = ntohs (msg->header.size) - sizeof (*msg);
699  uint32_t put_path_length = ntohl (msg->put_path_length);
700  uint32_t get_path_length = ntohl (msg->get_path_length);
701  size_t meta_length;
702 
703  meta_length =
704  sizeof (struct GNUNET_PeerIdentity) * (get_path_length + put_path_length);
705  if ( (msize < meta_length) ||
706  (get_path_length >
707  GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) ||
708  (put_path_length >
709  GNUNET_MAX_MESSAGE_SIZE / sizeof (struct GNUNET_PeerIdentity)) )
710  {
711  GNUNET_break (0);
712  return GNUNET_SYSERR;
713  }
714  return GNUNET_OK;
715 }
716 
717 
726 static int
728  const struct GNUNET_HashCode *key,
729  void *value)
730 {
731  const struct GNUNET_DHT_ClientResultMessage *crm = cls;
733  size_t msize = ntohs (crm->header.size) - sizeof (*crm);
734  uint32_t put_path_length = ntohl (crm->put_path_length);
735  uint32_t get_path_length = ntohl (crm->get_path_length);
736  const struct GNUNET_PeerIdentity *put_path;
737  const struct GNUNET_PeerIdentity *get_path;
738  struct GNUNET_HashCode hc;
739  size_t data_length;
740  size_t meta_length;
741  const void *data;
742 
743  if (crm->unique_id != get_handle->unique_id)
744  {
745  /* UID mismatch */
747  "Ignoring reply for %s: UID mismatch: %llu/%llu\n",
748  GNUNET_h2s (key),
749  crm->unique_id,
750  get_handle->unique_id);
751  return GNUNET_YES;
752  }
753  /* FIXME: might want to check that type matches */
754  meta_length =
755  sizeof (struct GNUNET_PeerIdentity) * (get_path_length + put_path_length);
756  data_length = msize - meta_length;
757  put_path = (const struct GNUNET_PeerIdentity *) &crm[1];
758  get_path = &put_path[put_path_length];
759  {
760  char *pp;
761  char *gp;
762 
763  gp = GNUNET_STRINGS_pp2s (get_path,
764  get_path_length);
765  pp = GNUNET_STRINGS_pp2s (put_path,
766  put_path_length);
768  "Giving %u byte reply for %s to application (GP: %s, PP: %s)\n",
769  (unsigned int) data_length,
770  GNUNET_h2s (key),
771  gp,
772  pp);
773  GNUNET_free (gp);
774  GNUNET_free (pp);
775  }
776  data = &get_path[get_path_length];
777  /* remember that we've seen this result */
778  GNUNET_CRYPTO_hash (data,
779  data_length,
780  &hc);
781  if (get_handle->seen_results_size == get_handle->seen_results_end)
782  GNUNET_array_grow (get_handle->seen_results,
783  get_handle->seen_results_size,
784  get_handle->seen_results_size * 2 + 1);
785  get_handle->seen_results[get_handle->seen_results_end++] = hc;
786  /* no need to block it explicitly, service already knows about it! */
787  get_handle->iter (get_handle->iter_cls,
789  key,
790  get_path,
791  get_path_length,
792  put_path,
793  put_path_length,
794  ntohl (crm->type),
795  data_length,
796  data);
797  return GNUNET_YES;
798 }
799 
800 
807 static void
809  const struct GNUNET_DHT_ClientResultMessage *msg)
810 {
811  struct GNUNET_DHT_Handle *handle = cls;
812 
814  &msg->key,
816  (void *) msg);
817 }
818 
819 
825 static void
826 handle_put_cont (void *cls)
827 {
828  struct GNUNET_DHT_PutHandle *ph = cls;
830  void *cont_cls;
831 
832  cont = ph->cont;
833  cont_cls = ph->cont_cls;
834  ph->env = NULL;
836  if (NULL != cont)
837  cont (cont_cls);
838 }
839 
840 
847 static int
849 {
850  struct GNUNET_MQ_MessageHandler handlers[] = {
851  GNUNET_MQ_hd_var_size (monitor_get,
854  h),
855  GNUNET_MQ_hd_var_size (monitor_get_resp,
858  h),
859  GNUNET_MQ_hd_var_size (monitor_put,
862  h),
863  GNUNET_MQ_hd_var_size (client_result,
866  h),
868  };
869  if (NULL != h->mq)
870  return GNUNET_OK;
871  h->mq = GNUNET_CLIENT_connect (h->cfg,
872  "dht",
873  handlers,
875  h);
876  if (NULL == h->mq)
877  {
879  "Failed to connect to the DHT service!\n");
880  return GNUNET_NO;
881  }
882  return GNUNET_YES;
883 }
884 
885 
894 struct GNUNET_DHT_Handle *
896  unsigned int ht_len)
897 {
898  struct GNUNET_DHT_Handle *handle;
899 
900  handle = GNUNET_new (struct GNUNET_DHT_Handle);
901  handle->cfg = cfg;
902  handle->uid_gen
904  UINT64_MAX);
905  handle->active_requests
907  GNUNET_YES);
908  if (GNUNET_NO == try_connect (handle))
909  {
910  GNUNET_DHT_disconnect (handle);
911  return NULL;
912  }
913  return handle;
914 }
915 
916 
922 void
924 {
925  struct GNUNET_DHT_PutHandle *ph;
926 
927  GNUNET_assert (0 ==
929  while (NULL != (ph = handle->put_head))
930  {
931  if (NULL != ph->cont)
932  ph->cont (ph->cont_cls);
934  }
935  if (NULL != handle->mq)
936  {
937  GNUNET_MQ_destroy (handle->mq);
938  handle->mq = NULL;
939  }
940  if (NULL != handle->reconnect_task)
941  {
943  handle->reconnect_task = NULL;
944  }
946  GNUNET_free (handle);
947 }
948 
949 
970 struct GNUNET_DHT_PutHandle *
972  const struct GNUNET_HashCode *key,
973  uint32_t desired_replication_level,
975  enum GNUNET_BLOCK_Type type,
976  size_t size,
977  const void *data,
978  struct GNUNET_TIME_Absolute exp,
980  void *cont_cls)
981 {
982  struct GNUNET_MQ_Envelope *env;
983  struct GNUNET_DHT_ClientPutMessage *put_msg;
984  size_t msize;
985  struct GNUNET_DHT_PutHandle *ph;
986 
987  msize = sizeof (struct GNUNET_DHT_ClientPutMessage) + size;
988  if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
989  (size >= GNUNET_MAX_MESSAGE_SIZE))
990  {
991  GNUNET_break (0);
992  return NULL;
993  }
994  if (NULL == handle->mq)
995  return NULL;
997  "Sending PUT for %s to DHT via %p\n",
998  GNUNET_h2s (key),
999  handle);
1000  ph = GNUNET_new (struct GNUNET_DHT_PutHandle);
1001  ph->dht_handle = handle;
1002  ph->cont = cont;
1003  ph->cont_cls = cont_cls;
1005  handle->put_tail,
1006  ph);
1007  env = GNUNET_MQ_msg_extra (put_msg,
1008  size,
1010  GNUNET_MQ_notify_sent (env,
1011  &handle_put_cont,
1012  ph);
1013  ph->env = env;
1014  put_msg->type = htonl ((uint32_t) type);
1015  put_msg->options = htonl ((uint32_t) options);
1016  put_msg->desired_replication_level = htonl (desired_replication_level);
1017  put_msg->expiration = GNUNET_TIME_absolute_hton (exp);
1018  put_msg->key = *key;
1019  GNUNET_memcpy (&put_msg[1],
1020  data,
1021  size);
1022  GNUNET_MQ_send (handle->mq,
1023  env);
1024  return ph;
1025 }
1026 
1027 
1039 void
1041 {
1042  struct GNUNET_DHT_Handle *handle = ph->dht_handle;
1043 
1044  if (NULL != ph->env)
1046  NULL,
1047  NULL);
1049  handle->put_tail,
1050  ph);
1051  GNUNET_free (ph);
1052 }
1053 
1054 
1071 struct GNUNET_DHT_GetHandle *
1073  enum GNUNET_BLOCK_Type type,
1074  const struct GNUNET_HashCode *key,
1075  uint32_t desired_replication_level,
1077  const void *xquery,
1078  size_t xquery_size,
1080  void *iter_cls)
1081 {
1082  struct GNUNET_DHT_GetHandle *gh;
1083  size_t msize;
1084 
1085  msize = sizeof (struct GNUNET_DHT_ClientGetMessage) + xquery_size;
1086  if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
1087  (xquery_size >= GNUNET_MAX_MESSAGE_SIZE))
1088  {
1089  GNUNET_break (0);
1090  return NULL;
1091  }
1093  "Sending query for %s to DHT %p\n",
1094  GNUNET_h2s (key),
1095  handle);
1096  gh = GNUNET_malloc (sizeof (struct GNUNET_DHT_GetHandle) +
1097  xquery_size);
1098  gh->iter = iter;
1099  gh->iter_cls = iter_cls;
1100  gh->dht_handle = handle;
1101  gh->key = *key;
1102  gh->unique_id = ++handle->uid_gen;
1103  gh->xquery_size = xquery_size;
1105  gh->type = type;
1106  gh->options = options;
1107  GNUNET_memcpy (&gh[1],
1108  xquery,
1109  xquery_size);
1111  &gh->key,
1112  gh,
1114  if (NULL != handle->mq)
1115  send_get (gh);
1116  return gh;
1117 }
1118 
1119 
1130 void
1132  unsigned int num_results,
1133  const struct GNUNET_HashCode *results)
1134 {
1135  unsigned int needed;
1136  unsigned int had;
1137 
1138  had = get_handle->seen_results_end;
1139  needed = had + num_results;
1140  if (needed > get_handle->seen_results_size)
1141  GNUNET_array_grow (get_handle->seen_results,
1142  get_handle->seen_results_size,
1143  needed);
1144  GNUNET_memcpy (&get_handle->seen_results[get_handle->seen_results_end],
1145  results,
1146  num_results * sizeof (struct GNUNET_HashCode));
1147  get_handle->seen_results_end += num_results;
1148  if (NULL != get_handle->dht_handle->mq)
1149  send_get_known_results (get_handle,
1150  had);
1151 }
1152 
1153 
1159 void
1161 {
1162  struct GNUNET_DHT_Handle *handle = get_handle->dht_handle;
1163 
1165  "Sending STOP for %s to DHT via %p\n",
1166  GNUNET_h2s (&get_handle->key),
1167  handle);
1168  if (NULL != handle->mq)
1169  {
1170  struct GNUNET_MQ_Envelope *env;
1171  struct GNUNET_DHT_ClientGetStopMessage *stop_msg;
1172 
1173  env = GNUNET_MQ_msg (stop_msg,
1175  stop_msg->reserved = htonl (0);
1176  stop_msg->unique_id = get_handle->unique_id;
1177  stop_msg->key = get_handle->key;
1178  GNUNET_MQ_send (handle->mq,
1179  env);
1180  }
1183  &get_handle->key,
1184  get_handle));
1185  GNUNET_array_grow (get_handle->seen_results,
1186  get_handle->seen_results_end,
1187  0);
1188  GNUNET_free (get_handle);
1189 }
1190 
1191 
1204 struct GNUNET_DHT_MonitorHandle *
1206  enum GNUNET_BLOCK_Type type,
1207  const struct GNUNET_HashCode *key,
1211  void *cb_cls)
1212 {
1213  struct GNUNET_DHT_MonitorHandle *mh;
1214 
1215  mh = GNUNET_new (struct GNUNET_DHT_MonitorHandle);
1216  mh->get_cb = get_cb;
1217  mh->get_resp_cb = get_resp_cb;
1218  mh->put_cb = put_cb;
1219  mh->cb_cls = cb_cls;
1220  mh->type = type;
1221  mh->dht_handle = handle;
1222  if (NULL != key)
1223  {
1224  mh->key = GNUNET_new (struct GNUNET_HashCode);
1225  *mh->key = *key;
1226  }
1228  handle->monitor_tail,
1229  mh);
1230  if (NULL != handle->mq)
1231  send_monitor_start (mh);
1232  return mh;
1233 }
1234 
1235 
1243 void
1245 {
1246  struct GNUNET_DHT_Handle *handle = mh->dht_handle;
1248  struct GNUNET_MQ_Envelope *env;
1249 
1251  handle->monitor_tail,
1252  mh);
1253  env = GNUNET_MQ_msg (m,
1255  m->type = htonl (mh->type);
1256  m->get = htons (NULL != mh->get_cb);
1257  m->get_resp = htons(NULL != mh->get_resp_cb);
1258  m->put = htons (NULL != mh->put_cb);
1259  if (NULL != mh->key)
1260  {
1261  m->filter_key = htons (1);
1262  m->key = *mh->key;
1263  }
1264  GNUNET_MQ_send (handle->mq,
1265  env);
1266  GNUNET_free_non_null (mh->key);
1267  GNUNET_free (mh);
1268 }
1269 
1270 
1271 /* end of dht_api.c */
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_DHT_MonitorHandle * next
DLL.
Definition: dht_api.c:157
struct GNUNET_HashCode key
The key to search for.
Definition: dht.h:98
uint64_t unique_id
Unique ID identifying this request, if 0 then the client will not expect a response.
Definition: dht.h:104
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT
Service returns result to client.
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:340
uint64_t unique_id
Unique ID of the matching GET request.
Definition: dht.h:174
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint32_t hop_count
Hop count so far.
Definition: dht.h:254
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:670
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:35
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT
Receive information about transiting PUTs.
void GNUNET_DHT_put_cancel(struct GNUNET_DHT_PutHandle *ph)
Cancels a DHT PUT operation.
Definition: dht_api.c:1040
DHT GET RESULTS KNOWN message sent from clients to service.
Definition: dht.h:115
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:522
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
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:163
Any type of block, used as a wildcard when searching.
uint32_t get_path_length
Length of the GET path that follows (if tracked).
Definition: dht.h:395
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
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:901
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:583
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT
Client wants to store item in DHT.
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:242
struct GNUNET_MQ_Envelope * env
Envelope from the PUT operation.
Definition: dht_api.c:73
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
unsigned int seen_results_size
Size of the seen_results array.
Definition: dht_api.c:138
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:259
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:144
enum GNUNET_BLOCK_Type type
Type of the block we are looking for.
Definition: dht_api.c:127
GNUNET_MQ_Error
Error codes for the queue.
uint64_t GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max)
Random on unsigned 64-bit values.
void(* GNUNET_DHT_MonitorGetRespCB)(void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static struct GNUNET_CADET_Handle * mh
Cadet handle.
Definition: gnunet-cadet.c:92
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
GNUNET_DHT_GetIterator iter
Iterator to call on data receipt.
Definition: dht_api.c:86
void GNUNET_DHT_monitor_stop(struct GNUNET_DHT_MonitorHandle *mh)
Stop monitoring.
Definition: dht_api.c:1244
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_PeerIdentity *path, const struct GNUNET_HashCode *key)
Callback called on each GET request going through the DHT.
uint32_t type
The type of data desired, GNUNET_BLOCK_TYPE_ANY for all.
Definition: dht.h:298
struct GNUNET_HashCode key
The key of the corresponding GET request.
Definition: dht.h:405
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition: dht_api.c:63
GNUNET_DHT_MonitorGetRespCB get_resp_cb
Callback for each received message of type get response.
Definition: dht_api.c:187
Message to insert data into the DHT, sent from clients to DHT service.
Definition: dht.h:194
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT.
Definition: dht.h:380
uint32_t desired_replication_level
Desired replication level.
Definition: dht_api.c:122
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static int get_cb(void *cls, const struct GNUNET_HashCode *key, void *value)
Function called during GET to find matching blocks.
uint32_t type
The type of data in the request.
Definition: dht.h:249
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_NO
Definition: gnunet_common.h:81
int16_t get_resp
Flag whether to notify about GET_REPONSE messages.
Definition: dht.h:308
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition: dht_api.c:96
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_START
Request information about transiting messages.
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP
Stop information about transiting messages.
GNUNET_DHT_MonitorPutCB put_cb
Callback for each received message of type put.
Definition: dht_api.c:192
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static int 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:627
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
void(* GNUNET_SCHEDULER_TaskCallback)(void *cls)
Signature of the main function of a task.
Connection to the DHT service.
Definition: dht_api.c:205
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:82
struct GNUNET_DHT_PutHandle * prev
Kept in a DLL.
Definition: dht_api.c:53
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:214
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for trying to reconnect.
Definition: dht_api.c:247
static struct GNUNET_DHT_GetHandle * get_handle
Handle for the get request.
uint64_t uid_gen
Generator for unique ids.
Definition: dht_api.c:258
void * iter_cls
Closure for iter.
Definition: dht_api.c:91
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
uint64_t unique_id
Unique ID identifying this request.
Definition: dht.h:58
uint32_t put_path_length
Length of the PUT path that follows (if tracked).
Definition: dht.h:390
#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
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:1246
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:312
uint32_t type
The type of data to insert.
Definition: dht.h:204
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
uint32_t reserved
Always zero.
Definition: dht.h:53
#define GNUNET_memcpy(dst, src, n)
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:1205
Message to monitor put requests going through peer, DHT service -> clients.
Definition: dht.h:234
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:774
static char * value
Value of the record to add/remove.
GNUNET_SCHEDULER_TaskCallback cont
Continuation to call when done.
Definition: dht_api.c:58
uint32_t type
The type for the data for the GET request; actually an &#39;enum GNUNET_BLOCK_Type&#39;.
Definition: dht.h:93
int16_t filter_key
Flag whether to use the provided key to filter messages.
Definition: dht.h:318
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:44
uint64_t unique_id
Unique ID identifying this request.
Definition: dht.h:136
int16_t put
Flag whether to notify about PUT messages.
Definition: dht.h:313
struct GNUNET_TIME_AbsoluteNBO expiration_time
How long should this data persist?
Definition: dht.h:270
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
Message to request monitoring messages, clients -> DHT service.
Definition: dht.h:287
struct GNUNET_HashCode key
The key that was searched for.
Definition: dht.h:184
GNUNET_DHT_MonitorGetCB get_cb
Callback for each received message of type get.
Definition: dht_api.c:182
char * GNUNET_STRINGS_pp2s(const struct GNUNET_PeerIdentity *pids, unsigned int num_pids)
Convert a peer path to a human-readable string.
Definition: strings.c:99
void * cont_cls
Closure for cont.
Definition: dht_api.c:68
struct GNUNET_DHT_PutHandle * put_head
Head of active PUT requests.
Definition: dht_api.c:231
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:727
void(* GNUNET_DHT_GetIterator)(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *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_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_PeerIdentity *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.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_RESULTS_KNOWN
Certain results are already known to the client, filter those.
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.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_DHT_PutHandle * put_tail
Tail of active PUT requests.
Definition: dht_api.c:236
struct GNUNET_DHT_MonitorHandle * prev
DLL.
Definition: dht_api.c:162
struct GNUNET_TIME_AbsoluteNBO expiration
When does this entry expire?
Definition: dht.h:179
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:209
uint32_t type
The type for the data.
Definition: dht.h:157
struct GNUNET_HashCode * key
Key being looked for, NULL == all.
Definition: dht_api.c:177
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:366
A 512-bit hashcode.
Message handler for a specific message type.
GNUNET_DHT_RouteOption
Options for routing.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1160
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET
Receive information about transiting GETs.
struct GNUNET_HashCode * seen_results
Array of hash codes over the results that we have already seen.
Definition: dht_api.c:102
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: dht_api.c:211
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition: dht_api.c:167
static int 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:559
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT.
Definition: dht.h:152
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static int try_connect(struct GNUNET_DHT_Handle *h)
Try to (re)connect to the DHT service.
Definition: dht_api.c:848
struct GNUNET_DHT_MonitorHandle * monitor_head
Head of linked list of messages we would like to monitor.
Definition: dht_api.c:221
struct GNUNET_TIME_AbsoluteNBO expiration
How long should this data persist?
Definition: dht.h:219
struct GNUNET_DHT_MonitorHandle * monitor_tail
Tail of linked list of messages we would like to monitor.
Definition: dht_api.c:226
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET_STOP
Client wants to stop search in DHT.
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:971
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:1131
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:895
uint32_t get_path_length
Number of peers recorded in the outgoing path from source to the storage location of this message...
Definition: dht.h:361
size_t xquery_size
Size of the extended query, allocated at the end of this struct.
Definition: dht_api.c:117
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:923
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
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.
uint32_t put_path_length
Number of peers recorded in the outgoing path from source to the storage location of this message...
Definition: dht.h:265
Handle to a GET request.
Definition: dht_api.c:80
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
static void send_monitor_start(struct GNUNET_DHT_MonitorHandle *mh)
Send GNUNET_MESSAGE_TYPE_DHT_MONITOR_START message.
Definition: dht_api.c:378
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:355
struct GNUNET_TIME_Relative retry_time
How quickly should we retry? Used for exponential back-off on connect-errors.
Definition: dht_api.c:253
static int 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:499
Allow multiple values with the same key.
Handle to a message queue.
Definition: mq.c:85
int16_t get
Flag whether to notify about GET messages.
Definition: dht.h:303
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:224
The identity of the host (wraps the signing key of the peer).
#define GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP
Receive information about transiting GET responses.
uint32_t get_path_length
The number of peer identities recorded from the storage location to this peer.
Definition: dht.h:169
Handle to a PUT request.
Definition: dht_api.c:43
struct GNUNET_HashCode key
Key of this request.
Definition: dht.h:63
static int 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:355
configuration data
Definition: configuration.c:85
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:1072
DHT GET message sent from clients to service.
Definition: dht.h:72
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
static struct GNUNET_TRANSPORT_HelloGetHandle * gh
Pending GNUNET_TRANSPORT_hello_get() operation.
static void send_get(struct GNUNET_DHT_GetHandle *gh)
Send GET message for a get_handle to DHT.
Definition: dht_api.c:280
static unsigned int results
Definition: gnunet-search.c:52
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:134
static int 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:695
enum GNUNET_DHT_RouteOption options
Routing options.
Definition: dht_api.c:132
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
uint32_t type
The type of data in the request.
Definition: dht.h:345
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:481
static int 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:727
#define GNUNET_MESSAGE_TYPE_DHT_CLIENT_GET
Client wants to lookup item in DHT.
struct GNUNET_HashCode key
The key to filter messages by.
Definition: dht.h:323
Message which indicates the DHT should cancel outstanding requests and discard any state...
Definition: dht.h:43
uint32_t type
Content type.
Definition: dht.h:385
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
enum GNUNET_BLOCK_Type type
Type of block looked for.
Definition: dht_api.c:172
Time for absolute times used by GNUnet, in microseconds.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_YES
Definition: gnunet_common.h:80
Message to monitor get requests going through peer, DHT service -> clients.
Definition: dht.h:330
struct GNUNET_HashCode key
Key that this get request is for.
Definition: dht_api.c:107
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:353
uint32_t hop_count
Hop count.
Definition: dht.h:350
static void try_reconnect(void *cls)
Try reconnecting to the dht service.
Definition: dht_api.c:406
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:87
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the content expire?
Definition: dht.h:400
static void handle_put_cont(void *cls)
Process a MQ PUT transmission notification.
Definition: dht_api.c:826
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:244
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 void handle_monitor_put(void *cls, const struct GNUNET_DHT_MonitorPutMessage *msg)
Process a put monitor message from the service.
Definition: dht_api.c:651
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:654
uint64_t unique_id
Unique identifier for this request (for key collisions).
Definition: dht_api.c:112
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:808
Message to monitor get results going through peer, DHT service -> clients.
Definition: dht.h:375
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Handle to a monitoring request.
Definition: dht_api.c:152
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:275
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_MQ_Handle * mq
Connection to DHT service.
Definition: dht_api.c:216
Reply to a GET send from the service to a client.
Definition: dht.h:147
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT.
Definition: dht.h:239
struct GNUNET_HashCode key
The key we are searching for (to make it easy to find the corresponding GET inside the service)...
Definition: dht.h:131
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
void * cb_cls
Closure for get_cb, put_cb and get_resp_cb.
Definition: dht_api.c:197
#define LOG(kind,...)
Definition: dht_api.c:37
static void do_disconnect(struct GNUNET_DHT_Handle *h)
Try reconnecting to the DHT service.
Definition: dht_api.c:440
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:965
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET.
Definition: dht.h:335
struct GNUNET_DHT_PutHandle * next
Kept in a DLL.
Definition: dht_api.c:48