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 
48 
53 
58 
63 
67  void *cont_cls;
68 
73 };
74 
83 
87  void *iter_cls;
88 
93 
99 
104 
108  uint64_t unique_id;
109 
113  size_t xquery_size;
114 
119 
124 
129 
134  unsigned int seen_results_size;
135 
140  unsigned int seen_results_end;
141 };
142 
143 
152 
157 
162 
167 
172 
177 
182 
187 
191  void *cb_cls;
192 };
193 
194 
203 
208 
213 
218 
223 
228 
234 
239 
244  struct GNUNET_TIME_Relative retry_time;
245 
249  uint64_t uid_gen;
250 };
251 
252 
259 static int
261 
262 
268 static void
270 {
271  struct GNUNET_DHT_Handle *h = gh->dht_handle;
272  struct GNUNET_MQ_Envelope *env;
273  struct GNUNET_DHT_ClientGetMessage *get_msg;
274 
275  env = GNUNET_MQ_msg_extra(get_msg,
276  gh->xquery_size,
278  get_msg->options = htonl((uint32_t)gh->options);
280  get_msg->type = htonl(gh->type);
281  get_msg->key = gh->key;
282  get_msg->unique_id = gh->unique_id;
283  GNUNET_memcpy(&get_msg[1],
284  &gh[1],
285  gh->xquery_size);
286  GNUNET_MQ_send(h->mq,
287  env);
288 }
289 
290 
300 static void
302  unsigned int transmission_offset_start)
303 {
304  struct GNUNET_DHT_Handle *h = gh->dht_handle;
305  struct GNUNET_MQ_Envelope *env;
307  unsigned int delta;
308  unsigned int max;
309  unsigned int transmission_offset;
310 
311  max = (GNUNET_MAX_MESSAGE_SIZE - sizeof(*msg))
312  / sizeof(struct GNUNET_HashCode);
313  transmission_offset = transmission_offset_start;
314  while (transmission_offset < gh->seen_results_end)
315  {
316  delta = gh->seen_results_end - transmission_offset;
317  if (delta > max)
318  delta = max;
319  env = GNUNET_MQ_msg_extra(msg,
320  delta * sizeof(struct GNUNET_HashCode),
322  msg->key = gh->key;
323  msg->unique_id = gh->unique_id;
324  GNUNET_memcpy(&msg[1],
325  &gh->seen_results[transmission_offset],
326  sizeof(struct GNUNET_HashCode) * delta);
327  GNUNET_MQ_send(h->mq,
328  env);
329  transmission_offset += delta;
330  }
331 }
332 
333 
343 static int
345  const struct GNUNET_HashCode *key,
346  void *value)
347 {
348  struct GNUNET_DHT_Handle *handle = cls;
349  struct GNUNET_DHT_GetHandle *gh = value;
350 
352  "Retransmitting request related to %s to DHT %p\n",
353  GNUNET_h2s(key),
354  handle);
355  send_get(gh);
356  send_get_known_results(gh, 0);
357  return GNUNET_YES;
358 }
359 
360 
366 static void
368 {
369  struct GNUNET_DHT_Handle *h = mh->dht_handle;
370  struct GNUNET_MQ_Envelope *env;
372 
373  env = GNUNET_MQ_msg(m,
375  m->type = htonl(mh->type);
376  m->get = htons(NULL != mh->get_cb);
377  m->get_resp = htons(NULL != mh->get_resp_cb);
378  m->put = htons(NULL != mh->put_cb);
379  if (NULL != mh->key)
380  {
381  m->filter_key = htons(1);
382  m->key = *mh->key;
383  }
384  GNUNET_MQ_send(h->mq,
385  env);
386 }
387 
388 
394 static void
395 try_reconnect(void *cls)
396 {
397  struct GNUNET_DHT_Handle *h = cls;
399 
401  "Reconnecting with DHT %p\n",
402  h);
404  h->reconnect_task = NULL;
405  if (GNUNET_YES != try_connect(h))
406  {
408  "DHT reconnect failed!\n");
409  h->reconnect_task
411  &try_reconnect,
412  h);
413  return;
414  }
417  h);
418  for (mh = h->monitor_head; NULL != mh; mh = mh->next)
419  send_monitor_start(mh);
420 }
421 
422 
428 static void
430 {
431  struct GNUNET_DHT_PutHandle *ph;
433  void *cont_cls;
434 
435  if (NULL == h->mq)
436  return;
437  GNUNET_MQ_destroy(h->mq);
438  h->mq = NULL;
440  "Disconnecting from DHT service, will try to reconnect in %s\n",
442  GNUNET_YES));
443  /* notify client about all PUTs that (may) have failed due to disconnect */
444  while (NULL != (ph = h->put_head))
445  {
446  cont = ph->cont;
447  cont_cls = ph->cont_cls;
448  ph->env = NULL;
450  if (NULL != cont)
451  cont(cont_cls);
452  }
453  GNUNET_assert(NULL == h->reconnect_task);
454  h->reconnect_task
456  &try_reconnect,
457  h);
458 }
459 
460 
469 static void
471  enum GNUNET_MQ_Error error)
472 {
473  struct GNUNET_DHT_Handle *h = cls;
474 
475  do_disconnect(h);
476 }
477 
478 
487 static int
489  const struct GNUNET_DHT_MonitorGetMessage *msg)
490 {
491  uint32_t plen = ntohl(msg->get_path_length);
492  uint16_t msize = ntohs(msg->header.size) - sizeof(*msg);
493 
494  if ((plen > UINT16_MAX) ||
495  (plen * sizeof(struct GNUNET_PeerIdentity) != msize))
496  {
497  GNUNET_break(0);
498  return GNUNET_SYSERR;
499  }
500  return GNUNET_OK;
501 }
502 
503 
510 static void
512  const struct GNUNET_DHT_MonitorGetMessage *msg)
513 {
514  struct GNUNET_DHT_Handle *handle = cls;
516 
517  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
518  {
519  if (NULL == mh->get_cb)
520  continue;
521  if (((GNUNET_BLOCK_TYPE_ANY == mh->type) ||
522  (mh->type == ntohl(msg->type))) &&
523  ((NULL == mh->key) ||
524  (0 == memcmp(mh->key,
525  &msg->key,
526  sizeof(struct GNUNET_HashCode)))))
527  mh->get_cb(mh->cb_cls,
528  ntohl(msg->options),
529  (enum GNUNET_BLOCK_Type)ntohl(msg->type),
530  ntohl(msg->hop_count),
531  ntohl(msg->desired_replication_level),
532  ntohl(msg->get_path_length),
533  (struct GNUNET_PeerIdentity *)&msg[1],
534  &msg->key);
535  }
536 }
537 
538 
547 static int
550 {
551  size_t msize = ntohs(msg->header.size) - sizeof(*msg);
552  uint32_t getl = ntohl(msg->get_path_length);
553  uint32_t putl = ntohl(msg->put_path_length);
554 
555  if ((getl + putl < getl) ||
556  ((msize / sizeof(struct GNUNET_PeerIdentity)) < getl + putl))
557  {
558  GNUNET_break(0);
559  return GNUNET_SYSERR;
560  }
561  return GNUNET_OK;
562 }
563 
564 
571 static void
574 {
575  struct GNUNET_DHT_Handle *handle = cls;
576  size_t msize = ntohs(msg->header.size) - sizeof(*msg);
577  const struct GNUNET_PeerIdentity *path;
578  uint32_t getl = ntohl(msg->get_path_length);
579  uint32_t putl = ntohl(msg->put_path_length);
581 
582  path = (const struct GNUNET_PeerIdentity *)&msg[1];
583  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
584  {
585  if (NULL == mh->get_resp_cb)
586  continue;
587  if (((GNUNET_BLOCK_TYPE_ANY == mh->type) ||
588  (mh->type == ntohl(msg->type))) &&
589  ((NULL == mh->key) ||
590  (0 == memcmp(mh->key,
591  &msg->key,
592  sizeof(struct GNUNET_HashCode)))))
593  mh->get_resp_cb(mh->cb_cls,
594  (enum GNUNET_BLOCK_Type)ntohl(msg->type),
595  path,
596  getl,
597  &path[getl],
598  putl,
600  &msg->key,
601  (const void *)&path[getl + putl],
602  msize - sizeof(struct GNUNET_PeerIdentity) * (putl + getl));
603  }
604 }
605 
606 
615 static int
617  const struct GNUNET_DHT_MonitorPutMessage *msg)
618 {
619  size_t msize;
620  uint32_t putl;
621 
622  msize = ntohs(msg->header.size) - sizeof(*msg);
623  putl = ntohl(msg->put_path_length);
624  if ((msize / sizeof(struct GNUNET_PeerIdentity)) < putl)
625  {
626  GNUNET_break(0);
627  return GNUNET_SYSERR;
628  }
629  return GNUNET_OK;
630 }
631 
632 
639 static void
641  const struct GNUNET_DHT_MonitorPutMessage *msg)
642 {
643  struct GNUNET_DHT_Handle *handle = cls;
644  size_t msize = ntohs(msg->header.size) - sizeof(*msg);
645  uint32_t putl = ntohl(msg->put_path_length);
646  const struct GNUNET_PeerIdentity *path;
648 
649  path = (const struct GNUNET_PeerIdentity *)&msg[1];
650  for (mh = handle->monitor_head; NULL != mh; mh = mh->next)
651  {
652  if (NULL == mh->put_cb)
653  continue;
654  if (((GNUNET_BLOCK_TYPE_ANY == mh->type) ||
655  (mh->type == ntohl(msg->type))) &&
656  ((NULL == mh->key) ||
657  (0 == memcmp(mh->key,
658  &msg->key,
659  sizeof(struct GNUNET_HashCode)))))
660  mh->put_cb(mh->cb_cls,
661  ntohl(msg->options),
662  (enum GNUNET_BLOCK_Type)ntohl(msg->type),
663  ntohl(msg->hop_count),
664  ntohl(msg->desired_replication_level),
665  putl,
666  path,
668  &msg->key,
669  (const void *)&path[putl],
670  msize - sizeof(struct GNUNET_PeerIdentity) * putl);
671  }
672 }
673 
674 
683 static int
685  const struct GNUNET_DHT_ClientResultMessage *msg)
686 {
687  size_t msize = ntohs(msg->header.size) - sizeof(*msg);
688  uint32_t put_path_length = ntohl(msg->put_path_length);
689  uint32_t get_path_length = ntohl(msg->get_path_length);
690  size_t meta_length;
691 
692  meta_length =
693  sizeof(struct GNUNET_PeerIdentity) * (get_path_length + put_path_length);
694  if ((msize < meta_length) ||
695  (get_path_length >
696  GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)) ||
697  (put_path_length >
698  GNUNET_MAX_MESSAGE_SIZE / sizeof(struct GNUNET_PeerIdentity)))
699  {
700  GNUNET_break(0);
701  return GNUNET_SYSERR;
702  }
703  return GNUNET_OK;
704 }
705 
706 
715 static int
717  const struct GNUNET_HashCode *key,
718  void *value)
719 {
720  const struct GNUNET_DHT_ClientResultMessage *crm = cls;
722  size_t msize = ntohs(crm->header.size) - sizeof(*crm);
723  uint32_t put_path_length = ntohl(crm->put_path_length);
724  uint32_t get_path_length = ntohl(crm->get_path_length);
725  const struct GNUNET_PeerIdentity *put_path;
726  const struct GNUNET_PeerIdentity *get_path;
727  struct GNUNET_HashCode hc;
728  size_t data_length;
729  size_t meta_length;
730  const void *data;
731 
732  if (crm->unique_id != get_handle->unique_id)
733  {
734  /* UID mismatch */
736  "Ignoring reply for %s: UID mismatch: %llu/%llu\n",
737  GNUNET_h2s(key),
738  crm->unique_id,
739  get_handle->unique_id);
740  return GNUNET_YES;
741  }
742  /* FIXME: might want to check that type matches */
743  meta_length =
744  sizeof(struct GNUNET_PeerIdentity) * (get_path_length + put_path_length);
745  data_length = msize - meta_length;
746  put_path = (const struct GNUNET_PeerIdentity *)&crm[1];
747  get_path = &put_path[put_path_length];
748  {
749  char *pp;
750  char *gp;
751 
752  gp = GNUNET_STRINGS_pp2s(get_path,
753  get_path_length);
754  pp = GNUNET_STRINGS_pp2s(put_path,
755  put_path_length);
757  "Giving %u byte reply for %s to application (GP: %s, PP: %s)\n",
758  (unsigned int)data_length,
759  GNUNET_h2s(key),
760  gp,
761  pp);
762  GNUNET_free(gp);
763  GNUNET_free(pp);
764  }
765  data = &get_path[get_path_length];
766  /* remember that we've seen this result */
767  GNUNET_CRYPTO_hash(data,
768  data_length,
769  &hc);
770  if (get_handle->seen_results_size == get_handle->seen_results_end)
771  GNUNET_array_grow(get_handle->seen_results,
772  get_handle->seen_results_size,
773  get_handle->seen_results_size * 2 + 1);
774  get_handle->seen_results[get_handle->seen_results_end++] = hc;
775  /* no need to block it explicitly, service already knows about it! */
776  get_handle->iter(get_handle->iter_cls,
778  key,
779  get_path,
780  get_path_length,
781  put_path,
782  put_path_length,
783  ntohl(crm->type),
784  data_length,
785  data);
786  return GNUNET_YES;
787 }
788 
789 
796 static void
798  const struct GNUNET_DHT_ClientResultMessage *msg)
799 {
800  struct GNUNET_DHT_Handle *handle = cls;
801 
803  &msg->key,
805  (void *)msg);
806 }
807 
808 
814 static void
815 handle_put_cont(void *cls)
816 {
817  struct GNUNET_DHT_PutHandle *ph = cls;
819  void *cont_cls;
820 
821  cont = ph->cont;
822  cont_cls = ph->cont_cls;
823  ph->env = NULL;
825  if (NULL != cont)
826  cont(cont_cls);
827 }
828 
829 
836 static int
838 {
839  struct GNUNET_MQ_MessageHandler handlers[] = {
840  GNUNET_MQ_hd_var_size(monitor_get,
843  h),
844  GNUNET_MQ_hd_var_size(monitor_get_resp,
847  h),
848  GNUNET_MQ_hd_var_size(monitor_put,
851  h),
852  GNUNET_MQ_hd_var_size(client_result,
855  h),
857  };
858 
859  if (NULL != h->mq)
860  return GNUNET_OK;
861  h->mq = GNUNET_CLIENT_connect(h->cfg,
862  "dht",
863  handlers,
865  h);
866  if (NULL == h->mq)
867  {
869  "Failed to connect to the DHT service!\n");
870  return GNUNET_NO;
871  }
872  return GNUNET_YES;
873 }
874 
875 
884 struct GNUNET_DHT_Handle *
886  unsigned int ht_len)
887 {
888  struct GNUNET_DHT_Handle *handle;
889 
890  handle = GNUNET_new(struct GNUNET_DHT_Handle);
891  handle->cfg = cfg;
892  handle->uid_gen
894  UINT64_MAX);
895  handle->active_requests
897  GNUNET_YES);
898  if (GNUNET_NO == try_connect(handle))
899  {
900  GNUNET_DHT_disconnect(handle);
901  return NULL;
902  }
903  return handle;
904 }
905 
906 
912 void
914 {
915  struct GNUNET_DHT_PutHandle *ph;
916 
917  GNUNET_assert(0 ==
919  while (NULL != (ph = handle->put_head))
920  {
921  if (NULL != ph->cont)
922  ph->cont(ph->cont_cls);
924  }
925  if (NULL != handle->mq)
926  {
927  GNUNET_MQ_destroy(handle->mq);
928  handle->mq = NULL;
929  }
930  if (NULL != handle->reconnect_task)
931  {
933  handle->reconnect_task = NULL;
934  }
936  GNUNET_free(handle);
937 }
938 
939 
960 struct GNUNET_DHT_PutHandle *
962  const struct GNUNET_HashCode *key,
963  uint32_t desired_replication_level,
965  enum GNUNET_BLOCK_Type type,
966  size_t size,
967  const void *data,
968  struct GNUNET_TIME_Absolute exp,
970  void *cont_cls)
971 {
972  struct GNUNET_MQ_Envelope *env;
973  struct GNUNET_DHT_ClientPutMessage *put_msg;
974  size_t msize;
975  struct GNUNET_DHT_PutHandle *ph;
976 
977  msize = sizeof(struct GNUNET_DHT_ClientPutMessage) + size;
978  if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
979  (size >= GNUNET_MAX_MESSAGE_SIZE))
980  {
981  GNUNET_break(0);
982  return NULL;
983  }
984  if (NULL == handle->mq)
985  return NULL;
987  "Sending PUT for %s to DHT via %p\n",
988  GNUNET_h2s(key),
989  handle);
990  ph = GNUNET_new(struct GNUNET_DHT_PutHandle);
991  ph->dht_handle = handle;
992  ph->cont = cont;
993  ph->cont_cls = cont_cls;
995  handle->put_tail,
996  ph);
997  env = GNUNET_MQ_msg_extra(put_msg,
998  size,
1001  &handle_put_cont,
1002  ph);
1003  ph->env = env;
1004  put_msg->type = htonl((uint32_t)type);
1005  put_msg->options = htonl((uint32_t)options);
1006  put_msg->desired_replication_level = htonl(desired_replication_level);
1007  put_msg->expiration = GNUNET_TIME_absolute_hton(exp);
1008  put_msg->key = *key;
1009  GNUNET_memcpy(&put_msg[1],
1010  data,
1011  size);
1012  GNUNET_MQ_send(handle->mq,
1013  env);
1014  return ph;
1015 }
1016 
1017 
1029 void
1031 {
1032  struct GNUNET_DHT_Handle *handle = ph->dht_handle;
1033 
1034  if (NULL != ph->env)
1036  NULL,
1037  NULL);
1039  handle->put_tail,
1040  ph);
1041  GNUNET_free(ph);
1042 }
1043 
1044 
1061 struct GNUNET_DHT_GetHandle *
1063  enum GNUNET_BLOCK_Type type,
1064  const struct GNUNET_HashCode *key,
1065  uint32_t desired_replication_level,
1067  const void *xquery,
1068  size_t xquery_size,
1070  void *iter_cls)
1071 {
1072  struct GNUNET_DHT_GetHandle *gh;
1073  size_t msize;
1074 
1075  msize = sizeof(struct GNUNET_DHT_ClientGetMessage) + xquery_size;
1076  if ((msize >= GNUNET_MAX_MESSAGE_SIZE) ||
1077  (xquery_size >= GNUNET_MAX_MESSAGE_SIZE))
1078  {
1079  GNUNET_break(0);
1080  return NULL;
1081  }
1083  "Sending query for %s to DHT %p\n",
1084  GNUNET_h2s(key),
1085  handle);
1086  gh = GNUNET_malloc(sizeof(struct GNUNET_DHT_GetHandle) +
1087  xquery_size);
1088  gh->iter = iter;
1089  gh->iter_cls = iter_cls;
1090  gh->dht_handle = handle;
1091  gh->key = *key;
1092  gh->unique_id = ++handle->uid_gen;
1093  gh->xquery_size = xquery_size;
1095  gh->type = type;
1096  gh->options = options;
1097  GNUNET_memcpy(&gh[1],
1098  xquery,
1099  xquery_size);
1101  &gh->key,
1102  gh,
1104  if (NULL != handle->mq)
1105  send_get(gh);
1106  return gh;
1107 }
1108 
1109 
1120 void
1122  unsigned int num_results,
1123  const struct GNUNET_HashCode *results)
1124 {
1125  unsigned int needed;
1126  unsigned int had;
1127 
1128  had = get_handle->seen_results_end;
1129  needed = had + num_results;
1130  if (needed > get_handle->seen_results_size)
1131  GNUNET_array_grow(get_handle->seen_results,
1132  get_handle->seen_results_size,
1133  needed);
1134  GNUNET_memcpy(&get_handle->seen_results[get_handle->seen_results_end],
1135  results,
1136  num_results * sizeof(struct GNUNET_HashCode));
1137  get_handle->seen_results_end += num_results;
1138  if (NULL != get_handle->dht_handle->mq)
1139  send_get_known_results(get_handle,
1140  had);
1141 }
1142 
1143 
1149 void
1151 {
1152  struct GNUNET_DHT_Handle *handle = get_handle->dht_handle;
1153 
1155  "Sending STOP for %s to DHT via %p\n",
1156  GNUNET_h2s(&get_handle->key),
1157  handle);
1158  if (NULL != handle->mq)
1159  {
1160  struct GNUNET_MQ_Envelope *env;
1161  struct GNUNET_DHT_ClientGetStopMessage *stop_msg;
1162 
1163  env = GNUNET_MQ_msg(stop_msg,
1165  stop_msg->reserved = htonl(0);
1166  stop_msg->unique_id = get_handle->unique_id;
1167  stop_msg->key = get_handle->key;
1168  GNUNET_MQ_send(handle->mq,
1169  env);
1170  }
1173  &get_handle->key,
1174  get_handle));
1175  GNUNET_array_grow(get_handle->seen_results,
1176  get_handle->seen_results_end,
1177  0);
1178  GNUNET_free(get_handle);
1179 }
1180 
1181 
1194 struct GNUNET_DHT_MonitorHandle *
1196  enum GNUNET_BLOCK_Type type,
1197  const struct GNUNET_HashCode *key,
1201  void *cb_cls)
1202 {
1203  struct GNUNET_DHT_MonitorHandle *mh;
1204 
1205  mh = GNUNET_new(struct GNUNET_DHT_MonitorHandle);
1206  mh->get_cb = get_cb;
1207  mh->get_resp_cb = get_resp_cb;
1208  mh->put_cb = put_cb;
1209  mh->cb_cls = cb_cls;
1210  mh->type = type;
1211  mh->dht_handle = handle;
1212  if (NULL != key)
1213  {
1214  mh->key = GNUNET_new(struct GNUNET_HashCode);
1215  *mh->key = *key;
1216  }
1218  handle->monitor_tail,
1219  mh);
1220  if (NULL != handle->mq)
1221  send_monitor_start(mh);
1222  return mh;
1223 }
1224 
1225 
1233 void
1235 {
1236  struct GNUNET_DHT_Handle *handle = mh->dht_handle;
1238  struct GNUNET_MQ_Envelope *env;
1239 
1241  handle->monitor_tail,
1242  mh);
1243  env = GNUNET_MQ_msg(m,
1245  m->type = htonl(mh->type);
1246  m->get = htons(NULL != mh->get_cb);
1247  m->get_resp = htons(NULL != mh->get_resp_cb);
1248  m->put = htons(NULL != mh->put_cb);
1249  if (NULL != mh->key)
1250  {
1251  m->filter_key = htons(1);
1252  m->key = *mh->key;
1253  }
1254  GNUNET_MQ_send(handle->mq,
1255  env);
1257  GNUNET_free(mh);
1258 }
1259 
1260 
1261 /* 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:151
struct GNUNET_HashCode key
The key to search for.
Definition: dht.h:95
uint64_t unique_id
Unique ID identifying this request, if 0 then the client will not expect a response.
Definition: dht.h:101
#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:326
uint64_t unique_id
Unique ID of the matching GET request.
Definition: dht.h:167
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
uint32_t hop_count
Hop count so far.
Definition: dht.h:243
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:671
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:1030
DHT GET RESULTS KNOWN message sent from clients to service.
Definition: dht.h:111
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:511
#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:156
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:379
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:900
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:572
#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:233
struct GNUNET_MQ_Envelope * env
Envelope from the PUT operation.
Definition: dht_api.c:72
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:134
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:248
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:140
enum GNUNET_BLOCK_Type type
Type of the block we are looking for.
Definition: dht_api.c:123
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:82
void GNUNET_DHT_monitor_stop(struct GNUNET_DHT_MonitorHandle *mh)
Stop monitoring.
Definition: dht_api.c:1234
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:285
struct GNUNET_HashCode key
The key of the corresponding GET request.
Definition: dht.h:389
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition: dht_api.c:62
GNUNET_DHT_MonitorGetRespCB get_resp_cb
Callback for each received message of type get response.
Definition: dht_api.c:181
Message to insert data into the DHT, sent from clients to DHT service.
Definition: dht.h:186
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_P2P_RESULT.
Definition: dht.h:364
uint32_t desired_replication_level
Desired replication level.
Definition: dht_api.c:118
#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:238
#define GNUNET_NO
Definition: gnunet_common.h:78
int16_t get_resp
Flag whether to notify about GET_REPONSE messages.
Definition: dht.h:295
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
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:92
#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:186
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:616
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:198
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:79
struct GNUNET_DHT_PutHandle * prev
Kept in a DLL.
Definition: dht_api.c:52
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:205
struct GNUNET_SCHEDULER_Task * reconnect_task
Task for trying to reconnect.
Definition: dht_api.c:238
static struct GNUNET_DHT_GetHandle * get_handle
Handle for the get request.
uint64_t uid_gen
Generator for unique ids.
Definition: dht_api.c:249
void * iter_cls
Closure for iter.
Definition: dht_api.c:87
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:57
uint32_t put_path_length
Length of the PUT path that follows (if tracked).
Definition: dht.h:374
#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:1237
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:301
uint32_t type
The type of data to insert.
Definition: dht.h:195
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
uint32_t reserved
Always zero.
Definition: dht.h:52
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:1195
Message to monitor put requests going through peer, DHT service -> clients.
Definition: dht.h:224
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:772
static char * value
Value of the record to add/remove.
GNUNET_SCHEDULER_TaskCallback cont
Continuation to call when done.
Definition: dht_api.c:57
uint32_t type
The type for the data for the GET request; actually an &#39;enum GNUNET_BLOCK_Type&#39;.
Definition: dht.h:90
int16_t filter_key
Flag whether to use the provided key to filter messages.
Definition: dht.h:305
#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:131
int16_t put
Flag whether to notify about PUT messages.
Definition: dht.h:300
struct GNUNET_TIME_AbsoluteNBO expiration_time
How long should this data persist?
Definition: dht.h:259
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:275
struct GNUNET_HashCode key
The key that was searched for.
Definition: dht.h:177
GNUNET_DHT_MonitorGetCB get_cb
Callback for each received message of type get.
Definition: dht_api.c:176
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:100
void * cont_cls
Closure for cont.
Definition: dht_api.c:67
struct GNUNET_DHT_PutHandle * put_head
Head of active PUT requests.
Definition: dht_api.c:222
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:686
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:227
struct GNUNET_DHT_MonitorHandle * prev
DLL.
Definition: dht_api.c:156
struct GNUNET_TIME_AbsoluteNBO expiration
When does this entry expire?
Definition: dht.h:172
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:200
uint32_t type
The type for the data.
Definition: dht.h:150
struct GNUNET_HashCode * key
Key being looked for, NULL == all.
Definition: dht_api.c:171
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:352
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:1150
#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:98
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
Definition: dht_api.c:202
struct GNUNET_DHT_Handle * dht_handle
Main handle to this DHT api.
Definition: dht_api.c:161
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:548
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT.
Definition: dht.h:145
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:837
struct GNUNET_DHT_MonitorHandle * monitor_head
Head of linked list of messages we would like to monitor.
Definition: dht_api.c:212
struct GNUNET_TIME_AbsoluteNBO expiration
How long should this data persist?
Definition: dht.h:210
struct GNUNET_DHT_MonitorHandle * monitor_tail
Tail of linked list of messages we would like to monitor.
Definition: dht_api.c:217
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:961
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
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:1121
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:885
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:347
size_t xquery_size
Size of the extended query, allocated at the end of this struct.
Definition: dht_api.c:113
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
Definition: dht_api.c:913
#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:254
Handle to a GET request.
Definition: dht_api.c:78
#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:367
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:341
struct GNUNET_TIME_Relative retry_time
How quickly should we retry? Used for exponential back-off on connect-errors.
Definition: dht_api.c:244
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:488
Allow multiple values with the same key.
Handle to a message queue.
Definition: mq.c:84
int16_t get
Flag whether to notify about GET messages.
Definition: dht.h:290
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:215
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:162
Handle to a PUT request.
Definition: dht_api.c:43
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.
struct GNUNET_HashCode key
Key of this request.
Definition: dht.h:62
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:344
configuration data
Definition: configuration.c:83
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:1062
DHT GET message sent from clients to service.
Definition: dht.h:70
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:269
static unsigned int results
Definition: gnunet-search.c:52
#define GNUNET_log(kind,...)
Entry in list of pending tasks.
Definition: scheduler.c:131
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:684
enum GNUNET_DHT_RouteOption options
Routing options.
Definition: dht_api.c:128
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:331
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:470
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:716
#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:310
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:369
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
enum GNUNET_BLOCK_Type type
Type of block looked for.
Definition: dht_api.c:166
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:821
#define GNUNET_YES
Definition: gnunet_common.h:77
Message to monitor get requests going through peer, DHT service -> clients.
Definition: dht.h:317
struct GNUNET_HashCode key
Key that this get request is for.
Definition: dht_api.c:103
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:351
uint32_t hop_count
Hop count.
Definition: dht.h:336
static void try_reconnect(void *cls)
Try reconnecting to the dht service.
Definition: dht_api.c:395
uint32_t desired_replication_level
Replication level for this message.
Definition: dht.h:84
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the content expire?
Definition: dht.h:384
static void handle_put_cont(void *cls)
Process a MQ PUT transmission notification.
Definition: dht_api.c:815
uint32_t options
Message options, actually an &#39;enum GNUNET_DHT_RouteOption&#39; value.
Definition: dht.h:233
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.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MulitHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
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:640
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:655
uint64_t unique_id
Unique identifier for this request (for key collisions).
Definition: dht_api.c:108
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:797
Message to monitor get results going through peer, DHT service -> clients.
Definition: dht.h:360
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
Handle to a monitoring request.
Definition: dht_api.c:147
struct GNUNET_HashCode key
The key to store the value under.
Definition: dht.h:264
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:207
Reply to a GET send from the service to a client.
Definition: dht.h:141
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT.
Definition: dht.h:228
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:126
#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:191
#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:429
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET.
Definition: dht.h:321
struct GNUNET_DHT_PutHandle * next
Kept in a DLL.
Definition: dht_api.c:47