GNUnet  0.17.6
namestore_api.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2010-2013, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
29 #include "platform.h"
30 #include "gnunet_util_lib.h"
31 #include "gnunet_crypto_lib.h"
32 #include "gnunet_constants.h"
33 #include "gnunet_dnsparser_lib.h"
34 #include "gnunet_arm_service.h"
35 #include "gnunet_signatures.h"
36 #include "gnunet_gns_service.h"
38 #include "namestore.h"
39 
40 
41 #define LOG(kind, ...) GNUNET_log_from (kind, "namestore-api", __VA_ARGS__)
42 
47 #define NAMESTORE_DELAY_TOLERANCE GNUNET_TIME_UNIT_MINUTES
48 
54 {
59 
64 
69 
74 
78  void *cont_cls;
79 
84 
89 
93  void *proc_cls;
94 
99 
104 
110 
115 
119  uint32_t op_id;
120 };
121 
122 
127 {
132 
137 
142 
147 
152 
157 
162 
166  void *proc_cls;
167 
172 
177 
183 
188 
192  uint32_t op_id;
193 };
194 
195 
200 {
205 
210 
215 
220 
225 
230 
235 
240 
245 
249  uint32_t last_op_id_used;
250 };
251 
252 
258 static void
260 
261 
269 static struct GNUNET_NAMESTORE_QueueEntry *
270 find_qe (struct GNUNET_NAMESTORE_Handle *h, uint32_t rid)
271 {
273 
274  for (qe = h->op_head; qe != NULL; qe = qe->next)
275  if (qe->op_id == rid)
276  return qe;
277  return NULL;
278 }
279 
280 
288 static struct GNUNET_NAMESTORE_ZoneIterator *
289 find_zi (struct GNUNET_NAMESTORE_Handle *h, uint32_t rid)
290 {
292 
293  for (ze = h->z_head; ze != NULL; ze = ze->next)
294  if (ze->op_id == rid)
295  return ze;
296  return NULL;
297 }
298 
299 
305 static void
307 {
308  struct GNUNET_NAMESTORE_Handle *h = qe->h;
309 
310  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, qe);
311  if (NULL != qe->env)
313  if (NULL != qe->timeout_task)
314  GNUNET_SCHEDULER_cancel (qe->timeout_task);
315  GNUNET_free (qe);
316 }
317 
318 
324 static void
326 {
327  struct GNUNET_NAMESTORE_Handle *h = ze->h;
328 
329  GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, ze);
330  if (NULL != ze->env)
331  GNUNET_MQ_discard (ze->env);
332  GNUNET_free (ze);
333 }
334 
335 
345 static int
346 check_rd (size_t rd_len, const void *rd_buf, unsigned int rd_count)
347 {
348  struct GNUNET_GNSRECORD_Data rd[rd_count];
349 
350  if (GNUNET_OK !=
351  GNUNET_GNSRECORD_records_deserialize (rd_len, rd_buf, rd_count, rd))
352  {
353  GNUNET_break (0);
354  return GNUNET_SYSERR;
355  }
356  return GNUNET_OK;
357 }
358 
367 static int
369  const struct RecordStoreResponseMessage *msg)
370 {
371  const char *emsg;
372  size_t msg_len;
373  size_t emsg_len;
374 
375  (void) cls;
376  msg_len = ntohs (msg->gns_header.header.size);
377  emsg_len = ntohs (msg->emsg_len);
378  if (0 != ntohs (msg->reserved))
379  {
380  GNUNET_break (0);
381  return GNUNET_SYSERR;
382  }
383  if (msg_len != sizeof(struct RecordStoreResponseMessage) + emsg_len)
384  {
385  GNUNET_break (0);
386  return GNUNET_SYSERR;
387  }
388  emsg = (const char *) &msg[1];
389  if ((0 != emsg_len) && ('\0' != emsg[emsg_len - 1]))
390  {
391  GNUNET_break (0);
392  return GNUNET_SYSERR;
393  }
394  return GNUNET_OK;
395 }
396 
397 
405 static void
407  const struct RecordStoreResponseMessage *msg)
408 {
409  struct GNUNET_NAMESTORE_Handle *h = cls;
411  int res;
412  const char *emsg;
413 
414  qe = find_qe (h, ntohl (msg->gns_header.r_id));
415  emsg = (const char *) &msg[1];
416  res = ntohl (msg->op_result);
418  "Received RECORD_STORE_RESPONSE with result %d\n",
419  res);
420  if (NULL == qe)
421  return;
422  if (NULL != qe->cont)
423  qe->cont (qe->cont_cls, res,
424  (GNUNET_OK == res) ? NULL : emsg);
425  free_qe (qe);
426 }
427 
428 
437 static int
439 {
440  const char *name;
441  size_t exp_msg_len;
442  size_t msg_len;
443  size_t name_len;
444  size_t rd_len;
445 
446  (void) cls;
447  rd_len = ntohs (msg->rd_len);
448  msg_len = ntohs (msg->gns_header.header.size);
449  name_len = ntohs (msg->name_len);
450  exp_msg_len = sizeof(*msg) + name_len + rd_len;
451  if (msg_len != exp_msg_len)
452  {
453  GNUNET_break (0);
454  return GNUNET_SYSERR;
455  }
456  name = (const char *) &msg[1];
457  if ((name_len > 0) && ('\0' != name[name_len - 1]))
458  {
459  GNUNET_break (0);
460  return GNUNET_SYSERR;
461  }
462  if (GNUNET_NO == ntohs (msg->found))
463  {
464  if (0 != ntohs (msg->rd_count))
465  {
466  GNUNET_break (0);
467  return GNUNET_SYSERR;
468  }
469  return GNUNET_OK;
470  }
471  return check_rd (rd_len, &name[name_len], ntohs (msg->rd_count));
472 }
473 
474 
482 static void
484 {
485  struct GNUNET_NAMESTORE_Handle *h = cls;
487  const char *name;
488  const char *rd_tmp;
489  size_t name_len;
490  size_t rd_len;
491  unsigned int rd_count;
492  int16_t found = (int16_t) ntohs (msg->found);
493 
494  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_LOOKUP_RESULT (found=%i)\n",
495  found);
496  qe = find_qe (h, ntohl (msg->gns_header.r_id));
497  if (NULL == qe)
498  return;
499  rd_len = ntohs (msg->rd_len);
500  rd_count = ntohs (msg->rd_count);
501  name_len = ntohs (msg->name_len);
502  name = (const char *) &msg[1];
503  if (GNUNET_NO == found)
504  {
505  /* label was not in namestore */
506  if (NULL != qe->proc)
507  qe->proc (qe->proc_cls, &msg->private_key, name, 0, NULL);
508  free_qe (qe);
509  return;
510  }
511  if (GNUNET_SYSERR == found)
512  {
513  if (NULL != qe->error_cb)
514  qe->error_cb (qe->error_cb_cls);
515  free_qe (qe);
516  return;
517  }
518 
519  rd_tmp = &name[name_len];
520  {
521  struct GNUNET_GNSRECORD_Data rd[rd_count];
522 
523  GNUNET_assert (
524  GNUNET_OK ==
525  GNUNET_GNSRECORD_records_deserialize (rd_len, rd_tmp, rd_count, rd));
526  if (0 == name_len)
527  name = NULL;
528  if (NULL != qe->proc)
529  qe->proc (qe->proc_cls,
530  &msg->private_key,
531  name,
532  rd_count,
533  (rd_count > 0) ? rd : NULL);
534  }
535  free_qe (qe);
536 }
537 
538 
547 static int
548 check_record_result (void *cls, const struct RecordResultMessage *msg)
549 {
550  static struct GNUNET_IDENTITY_PrivateKey priv_dummy;
551  const char *name;
552  size_t msg_len;
553  size_t name_len;
554  size_t rd_len;
555 
556  (void) cls;
557  rd_len = ntohs (msg->rd_len);
558  msg_len = ntohs (msg->gns_header.header.size);
559  name_len = ntohs (msg->name_len);
560  if (0 != ntohs (msg->reserved))
561  {
562  GNUNET_break (0);
563  return GNUNET_SYSERR;
564  }
565  if (msg_len != sizeof(struct RecordResultMessage) + name_len + rd_len)
566  {
567  GNUNET_break (0);
568  return GNUNET_SYSERR;
569  }
570  name = (const char *) &msg[1];
571  if ((0 == name_len) || ('\0' != name[name_len - 1]))
572  {
573  GNUNET_break (0);
574  return GNUNET_SYSERR;
575  }
576  if (0 == GNUNET_memcmp (&msg->private_key, &priv_dummy))
577  {
578  GNUNET_break (0);
579  return GNUNET_SYSERR;
580  }
581  return check_rd (rd_len, &name[name_len], ntohs (msg->rd_count));
582 }
583 
584 
592 static void
593 handle_record_result (void *cls, const struct RecordResultMessage *msg)
594 {
595  struct GNUNET_NAMESTORE_Handle *h = cls;
598  const char *name;
599  const char *rd_tmp;
600  size_t name_len;
601  size_t rd_len;
602  unsigned int rd_count;
603 
604  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_RESULT\n");
605  rd_len = ntohs (msg->rd_len);
606  rd_count = ntohs (msg->rd_count);
607  name_len = ntohs (msg->name_len);
608  ze = find_zi (h, ntohl (msg->gns_header.r_id));
609  qe = find_qe (h, ntohl (msg->gns_header.r_id));
610  if ((NULL == ze) && (NULL == qe))
611  return; /* rid not found */
612  if ((NULL != ze) && (NULL != qe))
613  {
614  GNUNET_break (0); /* rid ambiguous */
615  force_reconnect (h);
616  return;
617  }
618  name = (const char *) &msg[1];
619  rd_tmp = &name[name_len];
620  {
621  struct GNUNET_GNSRECORD_Data rd[rd_count];
622 
623  GNUNET_assert (
624  GNUNET_OK ==
625  GNUNET_GNSRECORD_records_deserialize (rd_len, rd_tmp, rd_count, rd));
626  if (0 == name_len)
627  name = NULL;
628  if (NULL != qe)
629  {
630  if (NULL != qe->proc)
631  qe->proc (qe->proc_cls,
632  &msg->private_key,
633  name,
634  rd_count,
635  (rd_count > 0) ? rd : NULL);
636  free_qe (qe);
637  return;
638  }
639  if (NULL != ze)
640  {
641  if (NULL != ze->proc)
642  ze->proc (ze->proc_cls, &msg->private_key, name, rd_count, rd);
643  if (NULL != ze->proc2)
644  ze->proc2 (ze->proc_cls, &msg->private_key, name,
645  rd_count, rd, GNUNET_TIME_absolute_ntoh (msg->expire));
646  return;
647  }
648  }
649  GNUNET_assert (0);
650 }
651 
652 
660 static void
662 {
663  struct GNUNET_NAMESTORE_Handle *h = cls;
666 
667  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received RECORD_RESULT_END\n");
668  ze = find_zi (h, ntohl (msg->r_id));
669  qe = find_qe (h, ntohl (msg->r_id));
670  if ((NULL == ze) && (NULL == qe))
671  return; /* rid not found */
672  if ((NULL != ze) && (NULL != qe))
673  {
674  GNUNET_break (0); /* rid ambiguous */
675  force_reconnect (h);
676  return;
677  }
678  LOG (GNUNET_ERROR_TYPE_DEBUG, "Zone iteration completed!\n");
679  if (NULL == ze)
680  {
681  GNUNET_break (0);
682  force_reconnect (h);
683  return;
684  }
685  if (NULL != ze->finish_cb)
686  ze->finish_cb (ze->finish_cb_cls);
687  free_ze (ze);
688 }
689 
698 static int
700  const struct TxControlResultMessage *msg)
701 {
702  const char *err_tmp;
703  size_t err_len;
704 
705  (void) cls;
706  err_len = ntohs (msg->gns_header.header.size)
707  - sizeof (struct TxControlResultMessage);
708  if ((GNUNET_YES == ntohs (msg->success)) && (err_len > 0))
709  {
710  GNUNET_break (0);
711  return GNUNET_SYSERR;
712  }
713  err_tmp = (const char *) &msg[1];
714  if ((err_len > 0) && ('\0' != err_tmp[err_len - 1]))
715  {
716  GNUNET_break (0);
717  return GNUNET_SYSERR;
718  }
719  return GNUNET_OK;
720 }
721 
722 static void
724  const struct TxControlResultMessage *msg)
725 {
726  struct GNUNET_NAMESTORE_Handle *h = cls;
728  int res;
729  const char *emsg;
730 
731  qe = find_qe (h, ntohl (msg->gns_header.r_id));
732  emsg = (const char *) &msg[1];
733  res = ntohs (msg->success);
735  "Received TX_CONTROL_RESULT with result %d\n",
736  res);
737  if (NULL == qe)
738  return;
739  if (NULL != qe->cont)
740  qe->cont (qe->cont_cls, res,
741  (GNUNET_YES == res) ? NULL : emsg);
742  free_qe (qe);
743 }
744 
753 static int
755  const struct ZoneToNameResponseMessage *msg)
756 {
757  size_t name_len;
758  size_t rd_ser_len;
759  const char *name_tmp;
760 
761  (void) cls;
762  if (GNUNET_OK != ntohs (msg->res))
763  return GNUNET_OK;
764  name_len = ntohs (msg->name_len);
765  rd_ser_len = ntohs (msg->rd_len);
766  if (ntohs (msg->gns_header.header.size) !=
767  sizeof(struct ZoneToNameResponseMessage) + name_len + rd_ser_len)
768  {
769  GNUNET_break (0);
770  return GNUNET_SYSERR;
771  }
772  name_tmp = (const char *) &msg[1];
773  if ((name_len > 0) && ('\0' != name_tmp[name_len - 1]))
774  {
775  GNUNET_break (0);
776  return GNUNET_SYSERR;
777  }
778  return check_rd (rd_ser_len, &name_tmp[name_len], ntohs (msg->rd_count));
779 }
780 
781 
789 static void
791  const struct ZoneToNameResponseMessage *msg)
792 {
793  struct GNUNET_NAMESTORE_Handle *h = cls;
795  int res;
796  size_t name_len;
797  size_t rd_ser_len;
798  unsigned int rd_count;
799  const char *name_tmp;
800  const char *rd_tmp;
801 
802  LOG (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME_RESPONSE\n");
803  qe = find_qe (h, ntohl (msg->gns_header.r_id));
804  if (NULL == qe)
805  {
807  "Response queue already gone...\n");
808  return;
809  }
810  res = ntohs (msg->res);
811  switch (res)
812  {
813  case GNUNET_SYSERR:
815  "An error occurred during zone to name operation\n");
816  break;
817 
818  case GNUNET_NO:
820  "Namestore has no result for zone to name mapping \n");
821  if (NULL != qe->proc)
822  qe->proc (qe->proc_cls, &msg->zone, NULL, 0, NULL);
823  free_qe (qe);
824  return;
825 
826  case GNUNET_YES:
828  "Namestore has result for zone to name mapping \n");
829  name_len = ntohs (msg->name_len);
830  rd_count = ntohs (msg->rd_count);
831  rd_ser_len = ntohs (msg->rd_len);
832  name_tmp = (const char *) &msg[1];
833  rd_tmp = &name_tmp[name_len];
834  {
835  struct GNUNET_GNSRECORD_Data rd[rd_count];
836 
839  rd_tmp,
840  rd_count,
841  rd));
842  /* normal end, call continuation with result */
843  if (NULL != qe->proc)
844  qe->proc (qe->proc_cls, &msg->zone, name_tmp, rd_count, rd);
845  /* return is important here: break would call continuation with error! */
846  free_qe (qe);
847  return;
848  }
849 
850  default:
851  GNUNET_break (0);
852  force_reconnect (h);
853  return;
854  }
855  /* error case, call continuation with error */
856  if (NULL != qe->error_cb)
857  qe->error_cb (qe->error_cb_cls);
858  free_qe (qe);
859 }
860 
861 
870 static void
871 mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
872 {
873  struct GNUNET_NAMESTORE_Handle *h = cls;
874 
875  (void) error;
876  force_reconnect (h);
877 }
878 
879 
885 static void
887 {
889  { GNUNET_MQ_hd_var_size (record_store_response,
892  h),
893  GNUNET_MQ_hd_var_size (zone_to_name_response,
896  h),
897  GNUNET_MQ_hd_var_size (record_result,
899  struct RecordResultMessage,
900  h),
901  GNUNET_MQ_hd_fixed_size (record_result_end,
904  h),
905  GNUNET_MQ_hd_var_size (lookup_result,
908  h),
909  GNUNET_MQ_hd_var_size (tx_control_result,
911  struct TxControlResultMessage,
912  h),
916 
917  GNUNET_assert (NULL == h->mq);
918  h->mq =
920  if (NULL == h->mq)
921  return;
922  /* re-transmit pending requests that waited for a reconnect... */
923  for (it = h->z_head; NULL != it; it = it->next)
924  {
925  GNUNET_MQ_send (h->mq, it->env);
926  it->env = NULL;
927  }
928  for (qe = h->op_head; NULL != qe; qe = qe->next)
929  {
930  GNUNET_MQ_send (h->mq, qe->env);
931  qe->env = NULL;
932  }
933 }
934 
935 
941 static void
942 reconnect_task (void *cls)
943 {
944  struct GNUNET_NAMESTORE_Handle *h = cls;
945 
946  h->reconnect_task = NULL;
947  reconnect (h);
948 }
949 
950 
956 static void
958 {
961 
963  h->mq = NULL;
964  while (NULL != (ze = h->z_head))
965  {
966  if (NULL != ze->error_cb)
967  ze->error_cb (ze->error_cb_cls);
968  free_ze (ze);
969  }
970  while (NULL != (qe = h->op_head))
971  {
972  if (NULL != qe->error_cb)
973  qe->error_cb (qe->error_cb_cls);
974  if (NULL != qe->cont)
975  qe->cont (qe->cont_cls,
977  "failure in communication with namestore service");
978  free_qe (qe);
979  }
980 
981  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnecting to namestore\n");
982  h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
983  h->reconnect_task =
984  GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect_task, h);
985 }
986 
987 
994 static uint32_t
996 {
997  return h->last_op_id_used++;
998 }
999 
1000 
1007 struct GNUNET_NAMESTORE_Handle *
1009 {
1010  struct GNUNET_NAMESTORE_Handle *h;
1011 
1013  h->cfg = cfg;
1014  reconnect (h);
1015  if (NULL == h->mq)
1016  {
1017  GNUNET_free (h);
1018  return NULL;
1019  }
1020  return h;
1021 }
1022 
1023 
1030 void
1032 {
1035 
1036  LOG (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
1037  GNUNET_break (NULL == h->op_head);
1038  while (NULL != (q = h->op_head))
1039  {
1040  GNUNET_CONTAINER_DLL_remove (h->op_head, h->op_tail, q);
1041  GNUNET_free (q);
1042  }
1043  GNUNET_break (NULL == h->z_head);
1044  while (NULL != (z = h->z_head))
1045  {
1046  GNUNET_CONTAINER_DLL_remove (h->z_head, h->z_tail, z);
1047  GNUNET_free (z);
1048  }
1049  if (NULL != h->mq)
1050  {
1051  GNUNET_MQ_destroy (h->mq);
1052  h->mq = NULL;
1053  }
1054  if (NULL != h->reconnect_task)
1055  {
1057  h->reconnect_task = NULL;
1058  }
1059  GNUNET_free (h);
1060 }
1061 
1062 
1069 static void
1070 warn_delay (void *cls)
1071 {
1072  struct GNUNET_NAMESTORE_QueueEntry *qe = cls;
1073 
1074  qe->timeout_task = NULL;
1076  "Did not receive response from namestore after %s!\n",
1078  GNUNET_YES));
1079  if (NULL != qe->cont)
1080  {
1081  qe->cont (qe->cont_cls, GNUNET_SYSERR, "timeout");
1082  qe->cont = NULL;
1083  }
1085 }
1086 
1087 
1090  struct GNUNET_NAMESTORE_Handle *h,
1091  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1092  const char *label,
1093  unsigned int rd_count,
1094  const struct GNUNET_GNSRECORD_Data *rd,
1096  void *cont_cls)
1097 {
1099  struct GNUNET_MQ_Envelope *env;
1100  char *name_tmp;
1101  char *rd_ser;
1102  ssize_t rd_ser_len;
1103  size_t name_len;
1104  uint32_t rid;
1105  struct RecordStoreMessage *msg;
1106  ssize_t sret;
1107 
1108  name_len = strlen (label) + 1;
1109  if (name_len > MAX_NAME_LEN)
1110  {
1111  GNUNET_break (0);
1112  return NULL;
1113  }
1114  rd_ser_len = GNUNET_GNSRECORD_records_get_size (rd_count, rd);
1115  if (rd_ser_len < 0)
1116  {
1117  GNUNET_break (0);
1118  return NULL;
1119  }
1120  if (rd_ser_len > UINT16_MAX)
1121  {
1122  GNUNET_break (0);
1123  return NULL;
1124  }
1125  rid = get_op_id (h);
1127  qe->h = h;
1128  qe->cont = cont;
1129  qe->cont_cls = cont_cls;
1130  qe->op_id = rid;
1131  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1132 
1133  /* setup msg */
1135  name_len + rd_ser_len,
1137  msg->gns_header.r_id = htonl (rid);
1138  msg->name_len = htons (name_len);
1139  msg->rd_count = htons (rd_count);
1140  msg->rd_len = htons (rd_ser_len);
1141  msg->reserved = ntohs (0);
1142  msg->private_key = *pkey;
1143 
1144  name_tmp = (char *) &msg[1];
1145  GNUNET_memcpy (name_tmp, label, name_len);
1146  rd_ser = &name_tmp[name_len];
1147  sret = GNUNET_GNSRECORD_records_serialize (rd_count, rd, rd_ser_len, rd_ser);
1148  if ((0 > sret) || (sret != rd_ser_len))
1149  {
1150  GNUNET_break (0);
1151  GNUNET_free (env);
1152  return NULL;
1153  }
1154  GNUNET_assert (rd_ser_len == sret);
1156  "Sending NAMESTORE_RECORD_STORE message for name `%s' with %u records\n",
1157  label,
1158  rd_count);
1159  qe->timeout_task =
1161  if (NULL == h->mq)
1162  {
1163  qe->env = env;
1165  "Delaying NAMESTORE_RECORD_STORE message as namestore is not ready!\n");
1166  }
1167  else
1168  {
1169  GNUNET_MQ_send (h->mq, env);
1170  }
1171  return qe;
1172 }
1173 
1174 static struct GNUNET_NAMESTORE_QueueEntry *
1176  struct GNUNET_NAMESTORE_Handle *h,
1177  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1178  const char *label,
1180  void *error_cb_cls,
1182  void *rm_cls,
1183  int is_edit_request)
1184 {
1186  struct GNUNET_MQ_Envelope *env;
1187  struct LabelLookupMessage *msg;
1188  size_t label_len;
1189 
1190  if (1 == (label_len = strlen (label) + 1))
1191  {
1192  GNUNET_break (0);
1193  return NULL;
1194  }
1195 
1197  qe->h = h;
1198  qe->error_cb = error_cb;
1199  qe->error_cb_cls = error_cb_cls;
1200  qe->proc = rm;
1201  qe->proc_cls = rm_cls;
1202  qe->op_id = get_op_id (h);
1203  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1204 
1206  label_len,
1208  msg->gns_header.r_id = htonl (qe->op_id);
1209  msg->zone = *pkey;
1210  msg->is_edit_request = htonl (is_edit_request);
1211  msg->label_len = htonl (label_len);
1212  GNUNET_memcpy (&msg[1], label, label_len);
1213  if (NULL == h->mq)
1214  qe->env = env;
1215  else
1216  GNUNET_MQ_send (h->mq, env);
1217  return qe;
1218 }
1219 
1222  struct GNUNET_NAMESTORE_Handle *h,
1223  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1224  const char *label,
1226  void *error_cb_cls,
1228  void *rm_cls)
1229 {
1230  return records_lookup (h, pkey, label,
1232  rm, rm_cls, GNUNET_NO);
1233 
1234 }
1235 
1238  struct GNUNET_NAMESTORE_Handle *h,
1239  const struct GNUNET_IDENTITY_PrivateKey *pkey,
1240  const char *label,
1242  void *error_cb_cls,
1244  void *rm_cls)
1245 {
1246  return records_lookup (h, pkey, label,
1248  rm, rm_cls, GNUNET_YES);
1249 }
1250 
1253  struct GNUNET_NAMESTORE_Handle *h,
1254  const struct GNUNET_IDENTITY_PrivateKey *zone,
1255  const struct GNUNET_IDENTITY_PublicKey *value_zone,
1257  void *error_cb_cls,
1259  void *proc_cls)
1260 {
1262  struct GNUNET_MQ_Envelope *env;
1263  struct ZoneToNameMessage *msg;
1264  uint32_t rid;
1265 
1266  rid = get_op_id (h);
1268  qe->h = h;
1269  qe->error_cb = error_cb;
1270  qe->error_cb_cls = error_cb_cls;
1271  qe->proc = proc;
1272  qe->proc_cls = proc_cls;
1273  qe->op_id = rid;
1274  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1275 
1277  msg->gns_header.r_id = htonl (rid);
1278  msg->zone = *zone;
1279  msg->value_zone = *value_zone;
1280  if (NULL == h->mq)
1281  qe->env = env;
1282  else
1283  GNUNET_MQ_send (h->mq, env);
1284  return qe;
1285 }
1286 
1287 
1290  struct GNUNET_NAMESTORE_Handle *h,
1291  const struct GNUNET_IDENTITY_PrivateKey *zone,
1293  void *error_cb_cls,
1295  void *proc_cls,
1297  void *finish_cb_cls)
1298 {
1299  struct GNUNET_NAMESTORE_ZoneIterator *it;
1300  struct GNUNET_MQ_Envelope *env;
1302  uint32_t rid;
1303 
1304  LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_START message\n");
1305  rid = get_op_id (h);
1307  it->h = h;
1308  it->error_cb = error_cb;
1309  it->error_cb_cls = error_cb_cls;
1310  it->finish_cb = finish_cb;
1311  it->finish_cb_cls = finish_cb_cls;
1312  it->proc = proc;
1313  it->proc_cls = proc_cls;
1314  it->op_id = rid;
1315  if (NULL != zone)
1316  it->zone = *zone;
1317  GNUNET_CONTAINER_DLL_insert_tail (h->z_head, h->z_tail, it);
1319  msg->gns_header.r_id = htonl (rid);
1320  if (NULL != zone)
1321  msg->zone = *zone;
1322  if (NULL == h->mq)
1323  it->env = env;
1324  else
1325  GNUNET_MQ_send (h->mq, env);
1326  return it;
1327 }
1328 
1331  struct GNUNET_NAMESTORE_Handle *h,
1332  const struct GNUNET_IDENTITY_PrivateKey *zone,
1334  void *error_cb_cls,
1336  void *proc_cls,
1338  void *finish_cb_cls,
1340 {
1341  struct GNUNET_NAMESTORE_ZoneIterator *it;
1342  struct GNUNET_MQ_Envelope *env;
1344  uint32_t rid;
1345 
1346  LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_START message\n");
1347  rid = get_op_id (h);
1349  it->h = h;
1350  it->error_cb = error_cb;
1351  it->error_cb_cls = error_cb_cls;
1352  it->finish_cb = finish_cb;
1353  it->finish_cb_cls = finish_cb_cls;
1354  it->proc2 = proc;
1355  it->proc_cls = proc_cls;
1356  it->op_id = rid;
1357  if (NULL != zone)
1358  it->zone = *zone;
1359  GNUNET_CONTAINER_DLL_insert_tail (h->z_head, h->z_tail, it);
1361  msg->gns_header.r_id = htonl (rid);
1362  msg->filter = htons ((uint16_t) filter);
1363  if (NULL != zone)
1364  msg->zone = *zone;
1365  if (NULL == h->mq)
1366  it->env = env;
1367  else
1368  GNUNET_MQ_send (h->mq, env);
1369  return it;
1370 }
1371 
1372 
1373 void
1375  uint64_t limit)
1376 {
1377  struct GNUNET_NAMESTORE_Handle *h = it->h;
1378  struct ZoneIterationNextMessage *msg;
1379  struct GNUNET_MQ_Envelope *env;
1380 
1382  "Sending ZONE_ITERATION_NEXT message with limit %llu\n",
1383  (unsigned long long) limit);
1385  msg->gns_header.r_id = htonl (it->op_id);
1386  msg->limit = GNUNET_htonll (limit);
1387  GNUNET_MQ_send (h->mq, env);
1388 }
1389 
1390 
1396 void
1398 {
1399  struct GNUNET_NAMESTORE_Handle *h = it->h;
1400  struct GNUNET_MQ_Envelope *env;
1401  struct ZoneIterationStopMessage *msg;
1402 
1403  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ZONE_ITERATION_STOP message\n");
1404  if (NULL != h->mq)
1405  {
1406  env =
1408  msg->gns_header.r_id = htonl (it->op_id);
1409  GNUNET_MQ_send (h->mq, env);
1410  }
1411  free_ze (it);
1412 }
1413 
1414 
1421 void
1423 {
1424  free_qe (qe);
1425 }
1426 
1431 static struct GNUNET_NAMESTORE_QueueEntry *
1434  void *cont_cls,
1435  enum GNUNET_NAMESTORE_TxControl ctrl)
1436 {
1438  struct GNUNET_MQ_Envelope *env;
1439  struct TxControlMessage *msg;
1440  uint32_t rid;
1441 
1442  rid = get_op_id (h);
1444  qe->h = h;
1445  qe->cont = cont;
1446  qe->cont_cls = cont_cls;
1447  qe->op_id = rid;
1448  GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1449 
1451  msg->gns_header.r_id = htonl (rid);
1452  msg->control = htons (ctrl);
1453  if (NULL == h->mq)
1454  qe->env = env;
1455  else
1456  GNUNET_MQ_send (h->mq, env);
1457  return qe;
1458  GNUNET_break (0);
1459  return NULL;
1460 }
1461 
1465  void *cont_cls)
1466 {
1469 }
1470 
1474  cont,
1475  void *cont_cls)
1476 {
1479 }
1480 
1481 
1485  cont,
1486  void *cont_cls)
1487 {
1490 }
1491 
1492 
1493 /* end of namestore_api.c */
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static void error_cb(void *cls)
Function called if lookup fails.
Definition: gnunet-abd.c:479
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:99
static int res
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static char * pkey
Public key of the zone to look in, in ASCII.
static char * zone
Name of the zone being managed.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static struct GNUNET_CONTAINER_BloomFilter * filter
Bloomfilter to quickly tell if we don't have the content.
cryptographic primitives for GNUnet
API for helper library to parse DNS packets.
API to the GNS service.
API that can be used to store naming information on a GNUnet node;.
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:1055
#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.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
GNUNET_NETWORK_STRUCT_END ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
GNUNET_GNSRECORD_Filter
Filter for GNUNET_GNSRECORD_normalize_record_set().
#define GNUNET_log(kind,...)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:36
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_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.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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:302
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
Definition: mq.c:283
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:56
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:71
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:685
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_transaction_rollback(struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Begin rollback all actions in a transaction.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_transaction_begin(struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
New API draft.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
void(* GNUNET_NAMESTORE_RecordSetMonitor)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
Process a record set that was stored in the namestore.
void(* GNUNET_NAMESTORE_ContinuationWithStatus)(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start2(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT).
GNUNET_NAMESTORE_TxControl
Transaction control types.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
void(* GNUNET_NAMESTORE_RecordMonitor)(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the NAMESTORE service.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_transaction_commit(struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Commit a namestore transaction.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_zone_to_name(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *zone, const struct GNUNET_IDENTITY_PublicKey *value_zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls)
Look for an existing PKEY delegation record for a given public key.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_edit(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
@ GNUNET_NAMESTORE_TX_COMMIT
@ GNUNET_NAMESTORE_TX_ROLLBACK
@ GNUNET_NAMESTORE_TX_BEGIN
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END
Service to client: end of list of results.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT
Return status message for control message.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
Service to client: here is a (plaintext) record you requested.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
Service to client: result of zone-to-name lookup.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
Service to client: result of store operation.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
Client to service: next record(s) in iteration please.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
Client to service: please start iteration; receives "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPON...
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
Client to service: stop iterating.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
Service to client: lookup label.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
Client to service: store records (as authority)
#define GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL
Message type for Begin, Commit or Rollback.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
Client to service: "reverse" lookup for zone name based on zone key.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
Client to service: lookup label.
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:957
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1254
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:736
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:570
#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_NAME_LEN
Maximum length of any name, including 0-termination.
Definition: namecache.h:33
common internal definitions for namestore service
static struct GNUNET_NAMESTORE_QueueEntry * records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_IDENTITY_PrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls, int is_edit_request)
static void handle_zone_to_name_response(void *cls, const struct ZoneToNameResponseMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.
static int check_lookup_result(void *cls, const struct LabelLookupResponseMessage *msg)
Check validity of an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE.
static struct GNUNET_NAMESTORE_QueueEntry * find_qe(struct GNUNET_NAMESTORE_Handle *h, uint32_t rid)
Find the queue entry that matches the rid.
#define NAMESTORE_DELAY_TOLERANCE
We grant the namestore up to 1 minute of latency, if it is slower than that, store queries will fail.
Definition: namestore_api.c:47
static void free_qe(struct GNUNET_NAMESTORE_QueueEntry *qe)
Free qe.
static void handle_record_store_response(void *cls, const struct RecordStoreResponseMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE.
static void handle_tx_control_result(void *cls, const struct TxControlResultMessage *msg)
static void warn_delay(void *cls)
Task launched to warn the user that the namestore is excessively slow and that a query was thus dropp...
static int check_record_result(void *cls, const struct RecordResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT.
static void handle_record_result_end(void *cls, const struct GNUNET_NAMESTORE_Header *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END.
static void free_ze(struct GNUNET_NAMESTORE_ZoneIterator *ze)
Free ze.
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...
static int check_rd(size_t rd_len, const void *rd_buf, unsigned int rd_count)
Check that rd_buf of length rd_len contains rd_count records.
static int check_zone_to_name_response(void *cls, const struct ZoneToNameResponseMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.
static struct GNUNET_NAMESTORE_QueueEntry * send_transaction_control_msg(struct GNUNET_NAMESTORE_Handle *h, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls, enum GNUNET_NAMESTORE_TxControl ctrl)
New API draft.
static void handle_lookup_result(void *cls, const struct LabelLookupResponseMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE.
static void reconnect(struct GNUNET_NAMESTORE_Handle *h)
Reconnect to namestore service.
static void force_reconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from service and then reconnect.
#define LOG(kind,...)
Definition: namestore_api.c:41
static int check_record_store_response(void *cls, const struct RecordStoreResponseMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE.
static struct GNUNET_NAMESTORE_ZoneIterator * find_zi(struct GNUNET_NAMESTORE_Handle *h, uint32_t rid)
Find the zone iteration entry that matches the rid.
static uint32_t get_op_id(struct GNUNET_NAMESTORE_Handle *h)
Get a fresh operation id to distinguish between namestore requests.
static int check_tx_control_result(void *cls, const struct TxControlResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_TX_CONTROL_RESULT.
static void handle_record_result(void *cls, const struct RecordResultMessage *msg)
Handle an incoming message of type GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT.
static void reconnect_task(void *cls)
Re-establish the connection to the service.
const char * name
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
struct GNUNET_DATASTORE_Handle * h
Handle to the master context.
struct GNUNET_MQ_Envelope * env
Envelope of the request to transmit, NULL after transmission.
struct GNUNET_DATASTORE_QueueEntry * next
This is a linked list.
GNUNET_DATASTORE_ContinuationWithStatus cont
Function to call after transmission of the request.
void * cont_cls
Closure for cont.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Handle to a message queue.
Definition: mq.c:86
Message handler for a specific message type.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
Connection to the NAMESTORE service.
uint32_t last_op_id_used
The last operation id used for a NAMESTORE operation.
struct GNUNET_NAMESTORE_ZoneIterator * z_head
Head of pending namestore zone iterator entries.
struct GNUNET_NAMESTORE_QueueEntry * op_tail
Tail of pending namestore queue entries.
struct GNUNET_SCHEDULER_Task * reconnect_task
Reconnect task.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration to use.
struct GNUNET_NAMESTORE_QueueEntry * op_head
Head of pending namestore queue entries.
struct GNUNET_TIME_Relative reconnect_delay
Delay introduced before we reconnect.
struct GNUNET_NAMESTORE_ZoneIterator * z_tail
Tail of pending namestore zone iterator entries.
int reconnect
Should we reconnect to service due to some serious error?
struct GNUNET_MQ_Handle * mq
Connection to the service (if available).
Generic namestore message with op id.
Definition: namestore.h:41
An QueueEntry used to store information for a pending NAMESTORE record operation.
Definition: namestore_api.c:54
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
struct GNUNET_NAMESTORE_QueueEntry * prev
Kept in a DLL.
Definition: namestore_api.c:63
uint32_t op_id
The operation id this zone iteration operation has.
void * error_cb_cls
Closure for error_cb.
GNUNET_NAMESTORE_RecordMonitor proc
Function to call with the records we get back; or NULL.
Definition: namestore_api.c:83
struct GNUNET_NAMESTORE_QueueEntry * next
Kept in a DLL.
Definition: namestore_api.c:58
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
Definition: namestore_api.c:68
GNUNET_NAMESTORE_ContinuationWithStatus cont
Continuation to call.
Definition: namestore_api.c:73
GNUNET_NAMESTORE_RecordSetMonitor proc2
Function to call with the records we get back; or NULL.
Definition: namestore_api.c:88
struct GNUNET_SCHEDULER_Task * timeout_task
Task scheduled to warn us if the namestore is way too slow.
void * cont_cls
Closure for cont.
Definition: namestore_api.c:78
void * proc_cls
Closure for proc.
Definition: namestore_api.c:93
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
Definition: namestore_api.c:98
Handle for a zone iterator operation.
void * finish_cb_cls
Closure for error_cb.
void * error_cb_cls
Closure for error_cb.
struct GNUNET_NAMESTORE_ZoneIterator * next
Kept in a DLL.
GNUNET_NAMESTORE_RecordSetMonitor proc2
The continuation to call with the results.
struct GNUNET_NAMESTORE_Handle * h
Main handle to access the namestore.
void * proc_cls
Closure for proc.
uint32_t op_id
The operation id this zone iteration operation has.
struct GNUNET_IDENTITY_PrivateKey zone
Private key of the zone.
GNUNET_NAMESTORE_RecordMonitor proc
The continuation to call with the results.
GNUNET_SCHEDULER_TaskCallback error_cb
Function to call on errors.
struct GNUNET_MQ_Envelope * env
Envelope of the message to send to the service, if not yet sent.
GNUNET_SCHEDULER_TaskCallback finish_cb
Function to call on completion.
struct GNUNET_NAMESTORE_ZoneIterator * prev
Kept in a DLL.
Entry in list of pending tasks.
Definition: scheduler.c:135
Time for relative time used by GNUnet, in microseconds.
Lookup a label.
Definition: namestore.h:137
uint32_t is_edit_request
GNUNET_YES if this lookup corresponds to an edit request.
Definition: namestore.h:151
uint32_t label_len
Length of the name.
Definition: namestore.h:146
Record is returned from the namestore (as authority).
Definition: namestore.h:276
Store a record to the namestore (as authority).
Definition: namestore.h:59
uint16_t rd_count
Number of records contained.
Definition: namestore.h:83
uint16_t name_len
Name length.
Definition: namestore.h:73
Response to a record storage request.
Definition: namestore.h:106
Send a transaction control message.
Definition: namestore.h:323
Result of a transaction control message.
Definition: namestore.h:345
Ask for next result of zone iteration for the given operation.
Definition: namestore.h:458
Start a zone iteration for the given zone.
Definition: namestore.h:430
Stop zone iteration for the given operation.
Definition: namestore.h:477
Lookup a name for a zone hash.
Definition: namestore.h:211
struct GNUNET_IDENTITY_PublicKey value_zone
The public key of the target zone.
Definition: namestore.h:225
Respone for zone to name lookup.
Definition: namestore.h:233