GNUnet  0.10.x
gnunet-namestore.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2012, 2013, 2014, 2019 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  */
28 #include "platform.h"
29 #include <gnunet_util_lib.h>
30 #include <gnunet_dnsparser_lib.h>
32 #include <gnunet_gnsrecord_lib.h>
33 #include <gnunet_gns_service.h>
35 
36 
45 
50 };
51 
52 
56 static struct GNUNET_NAMESTORE_Handle *ns;
57 
62 
67 
71 static struct GNUNET_IDENTITY_Handle *idh;
72 
77 
81 static char *ego_name;
82 
86 static int add;
87 
92 
97 
102 
107 
111 static int list;
112 
117 
121 static int del;
122 
126 static int is_public;
127 
131 static int is_shadow;
132 
137 
142 
146 static char *name;
147 
151 static char *value;
152 
156 static char *uri;
157 
161 static char *reverse_pkey;
162 
166 static char *typestring;
167 
171 static char *expirationstring;
172 
176 static char *nickstring;
177 
181 static int ret;
182 
186 static uint32_t type;
187 
191 static void *data;
192 
196 static size_t data_size;
197 
201 static uint64_t etime;
202 
207 
212 
216 static int monitor;
217 
221 static struct RecordSetEntry *recordset;
222 
223 
229 static void
230 do_shutdown(void *cls)
231 {
232  (void)cls;
233  if (NULL != get_default)
234  {
235  GNUNET_IDENTITY_cancel(get_default);
236  get_default = NULL;
237  }
238  if (NULL != idh)
239  {
241  idh = NULL;
242  }
243  if (NULL != el)
244  {
246  el = NULL;
247  }
248  if (NULL != list_it)
249  {
251  list_it = NULL;
252  }
253  if (NULL != add_qe)
254  {
255  GNUNET_NAMESTORE_cancel(add_qe);
256  add_qe = NULL;
257  }
258  if (NULL != set_qe)
259  {
260  GNUNET_NAMESTORE_cancel(set_qe);
261  set_qe = NULL;
262  }
263  if (NULL != add_qe_uri)
264  {
265  GNUNET_NAMESTORE_cancel(add_qe_uri);
266  add_qe_uri = NULL;
267  }
268  if (NULL != get_qe)
269  {
270  GNUNET_NAMESTORE_cancel(get_qe);
271  get_qe = NULL;
272  }
273  if (NULL != del_qe)
274  {
275  GNUNET_NAMESTORE_cancel(del_qe);
276  del_qe = NULL;
277  }
278  if (NULL != ns)
279  {
281  ns = NULL;
282  }
283  memset(&zone_pkey, 0, sizeof(zone_pkey));
284  if (NULL != uri)
285  {
286  GNUNET_free(uri);
287  uri = NULL;
288  }
289  if (NULL != zm)
290  {
292  zm = NULL;
293  }
294  if (NULL != data)
295  {
296  GNUNET_free(data);
297  data = NULL;
298  }
299 }
300 
301 
305 static void
307 {
308  if ((NULL == add_qe) && (NULL == add_qe_uri) && (NULL == get_qe) &&
309  (NULL == del_qe) && (NULL == reverse_qe) && (NULL == list_it))
311 }
312 
313 
324 static void
325 add_continuation(void *cls, int32_t success, const char *emsg)
326 {
327  struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
328 
329  *qe = NULL;
330  if (GNUNET_YES != success)
331  {
332  fprintf(stderr,
333  _("Adding record failed: %s\n"),
334  (GNUNET_NO == success) ? "record exists" : emsg);
335  if (GNUNET_NO != success)
336  ret = 1;
337  }
338  ret = 0;
339  test_finished();
340 }
341 
342 
353 static void
354 del_continuation(void *cls, int32_t success, const char *emsg)
355 {
356  (void)cls;
357  del_qe = NULL;
358  if (GNUNET_NO == success)
359  {
360  fprintf(stderr,
361  _("Deleting record failed, record does not exist%s%s\n"),
362  (NULL != emsg) ? ": " : "",
363  (NULL != emsg) ? emsg : "");
364  }
365  if (GNUNET_SYSERR == success)
366  {
367  fprintf(stderr,
368  _("Deleting record failed%s%s\n"),
369  (NULL != emsg) ? ": " : "",
370  (NULL != emsg) ? emsg : "");
371  }
372  test_finished();
373 }
374 
375 
379 static void
381 {
382  (void)cls;
383  list_it = NULL;
384  test_finished();
385 }
386 
387 
391 static void
393 {
394  (void)cls;
395  list_it = NULL;
396  fprintf(stderr, "Error iterating over zone\n");
397  ret = 1;
398  test_finished();
399 }
400 
401 
409 static void
410 display_record(const char *rname,
411  unsigned int rd_len,
412  const struct GNUNET_GNSRECORD_Data *rd)
413 {
414  const char *typestr;
415  char *s;
416  const char *ets;
417  struct GNUNET_TIME_Absolute at;
418  struct GNUNET_TIME_Relative rt;
419  int have_record;
420 
421  if ((NULL != name) && (0 != strcmp(name, rname)))
422  {
424  return;
425  }
426  have_record = GNUNET_NO;
427  for (unsigned int i = 0; i < rd_len; i++)
428  {
429  if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
430  (0 != strcmp(rname, GNUNET_GNS_EMPTY_LABEL_AT)))
431  continue;
432  if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
433  continue;
434  have_record = GNUNET_YES;
435  break;
436  }
437  if (GNUNET_NO == have_record)
438  return;
439  fprintf(stdout, "%s:\n", rname);
440  if (NULL != typestring)
442  else
444  for (unsigned int i = 0; i < rd_len; i++)
445  {
446  if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
447  (0 != strcmp(rname, GNUNET_GNS_EMPTY_LABEL_AT)))
448  continue;
449  if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
450  continue;
451  typestr = GNUNET_GNSRECORD_number_to_typename(rd[i].record_type);
452  s = GNUNET_GNSRECORD_value_to_string(rd[i].record_type,
453  rd[i].data,
454  rd[i].data_size);
455  if (NULL == s)
456  {
457  fprintf(stdout,
458  _("\tCorrupt or unsupported record of type %u\n"),
459  (unsigned int)rd[i].record_type);
460  continue;
461  }
462  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
463  {
464  rt.rel_value_us = rd[i].expiration_time;
466  }
467  else
468  {
469  at.abs_value_us = rd[i].expiration_time;
471  }
472  fprintf(stdout,
473  "\t%s: %s (%s)\t%s\t%s\n",
474  typestr,
475  s,
476  ets,
477  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE"
478  : "PUBLIC",
479  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW"
480  : "");
481  GNUNET_free(s);
482  }
483  fprintf(stdout, "%s", "\n");
484 }
485 
486 
496 static void
498  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
499  const char *rname,
500  unsigned int rd_len,
501  const struct GNUNET_GNSRECORD_Data *rd)
502 {
503  (void)cls;
504  (void)zone_key;
505  display_record(rname, rd_len, rd);
507 }
508 
509 
519 static void
521  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
522  const char *rname,
523  unsigned int rd_len,
524  const struct GNUNET_GNSRECORD_Data *rd)
525 {
526  (void)cls;
527  (void)zone_key;
528  display_record(rname, rd_len, rd);
530 }
531 
532 
542 static void
544  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
545  const char *rname,
546  unsigned int rd_len,
547  const struct GNUNET_GNSRECORD_Data *rd)
548 {
549  (void)cls;
550  (void)zone_key;
551  get_qe = NULL;
552  display_record(rname, rd_len, rd);
553  test_finished();
554 }
555 
556 
562 static void
563 sync_cb(void *cls)
564 {
565  (void)cls;
566  fprintf(stdout, "%s", "Monitor is now in sync.\n");
567 }
568 
569 
575 static void
577 {
578  (void)cls;
579  fprintf(stderr, "%s", "Monitor disconnected and out of sync.\n");
580 }
581 
582 
588 static void
589 lookup_error_cb(void *cls)
590 {
591  (void)cls;
592  get_qe = NULL;
593  fprintf(stderr, "%s", "Failed to lookup record.\n");
594  test_finished();
595 }
596 
597 
601 static void
602 add_error_cb(void *cls)
603 {
604  (void)cls;
605  add_qe = NULL;
606  GNUNET_break(0);
607  ret = 1;
608  test_finished();
609 }
610 
611 
622 static void
624  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
625  const char *rec_name,
626  unsigned int rd_count,
627  const struct GNUNET_GNSRECORD_Data *rd)
628 {
629  struct GNUNET_GNSRECORD_Data rdn[rd_count + 1];
630  struct GNUNET_GNSRECORD_Data *rde;
631 
632  (void)cls;
633  (void)zone_key;
634  add_qe = NULL;
635  if (0 != strcmp(rec_name, name))
636  {
637  GNUNET_break(0);
638  ret = 1;
639  test_finished();
640  return;
641  }
642 
644  "Received %u records for name `%s'\n",
645  rd_count,
646  rec_name);
647  for (unsigned int i = 0; i < rd_count; i++)
648  {
649  switch (rd[i].record_type)
650  {
652  fprintf(
653  stderr,
654  _(
655  "A %s record exists already under `%s', no other records can be added.\n"),
656  "CNAME",
657  rec_name);
658  ret = 1;
659  test_finished();
660  return;
661 
663  fprintf(
664  stderr,
665  _(
666  "A %s record exists already under `%s', no other records can be added.\n"),
667  "PKEY",
668  rec_name);
669  ret = 1;
670  test_finished();
671  return;
672 
675  {
676  fprintf(
677  stderr,
678  _(
679  "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"),
680  rec_name);
681  ret = 1;
682  test_finished();
683  return;
684  }
685  break;
686  }
687  }
688  switch (type)
689  {
691  if (0 != rd_count)
692  {
693  fprintf(stderr,
694  _(
695  "Records already exist under `%s', cannot add `%s' record.\n"),
696  rec_name,
697  "CNAME");
698  ret = 1;
699  test_finished();
700  return;
701  }
702  break;
703 
705  if (0 != rd_count)
706  {
707  fprintf(stderr,
708  _(
709  "Records already exist under `%s', cannot add `%s' record.\n"),
710  rec_name,
711  "PKEY");
712  ret = 1;
713  test_finished();
714  return;
715  }
716  break;
717 
719  for (unsigned int i = 0; i < rd_count; i++)
721  {
722  fprintf(
723  stderr,
724  _(
725  "Non-GNS2DNS records already exist under `%s', cannot add GNS2DNS record.\n"),
726  rec_name);
727  ret = 1;
728  test_finished();
729  return;
730  }
731  break;
732  }
733  memset(rdn, 0, sizeof(struct GNUNET_GNSRECORD_Data));
734  GNUNET_memcpy(&rdn[1], rd, rd_count * sizeof(struct GNUNET_GNSRECORD_Data));
735  rde = &rdn[0];
736  rde->data = data;
737  rde->data_size = data_size;
738  rde->record_type = type;
739  if (1 == is_shadow)
741  if (1 != is_public)
743  rde->expiration_time = etime;
744  if (GNUNET_YES == etime_is_rel)
746  else if (GNUNET_NO != etime_is_rel)
747  rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
748  GNUNET_assert(NULL != name);
749  add_qe = GNUNET_NAMESTORE_records_store(ns,
750  &zone_pkey,
751  name,
752  rd_count + 1,
753  rde,
755  &add_qe);
756 }
757 
758 
762 static void
764 {
765  (void)cls;
766  reverse_qe = NULL;
767  fprintf(stdout, "%s.zkey\n", reverse_pkey);
768 }
769 
770 
781 static void
783  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
784  const char *label,
785  unsigned int rd_count,
786  const struct GNUNET_GNSRECORD_Data *rd)
787 {
788  (void)cls;
789  (void)zone;
790  (void)rd_count;
791  (void)rd;
792  reverse_qe = NULL;
793  if (NULL == label)
794  fprintf(stdout, "%s\n", reverse_pkey);
795  else
796  fprintf(stdout, "%s.%s\n", label, ego_name);
797  test_finished();
798 }
799 
800 
804 static void
806 {
807  (void)cls;
808  del_qe = NULL;
809  GNUNET_break(0);
810  ret = 1;
811  test_finished();
812 }
813 
814 
826 static void
827 del_monitor(void *cls,
828  const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
829  const char *label,
830  unsigned int rd_count,
831  const struct GNUNET_GNSRECORD_Data *rd)
832 {
833  struct GNUNET_GNSRECORD_Data rdx[rd_count];
834  unsigned int rd_left;
835  uint32_t type;
836  char *vs;
837 
838  (void)cls;
839  (void)zone;
840  del_qe = NULL;
841  if (0 == rd_count)
842  {
843  fprintf(stderr,
844  _(
845  "There are no records under label `%s' that could be deleted.\n"),
846  label);
847  ret = 1;
848  test_finished();
849  return;
850  }
851  if ((NULL == value) && (NULL == typestring))
852  {
853  /* delete everything */
854  del_qe = GNUNET_NAMESTORE_records_store(ns,
855  &zone_pkey,
856  name,
857  0,
858  NULL,
860  NULL);
861  return;
862  }
863  rd_left = 0;
864  if (NULL != typestring)
866  else
868  for (unsigned int i = 0; i < rd_count; i++)
869  {
870  vs = NULL;
871  if (!(((GNUNET_GNSRECORD_TYPE_ANY == type) ||
872  (rd[i].record_type == type)) &&
873  ((NULL == value) ||
874  (NULL ==
876  rd[i].data,
877  rd[i].data_size)))) ||
878  (0 == strcmp(vs, value)))))
879  rdx[rd_left++] = rd[i];
881  }
882  if (rd_count == rd_left)
883  {
884  /* nothing got deleted */
885  fprintf(
886  stderr,
887  _(
888  "There are no records under label `%s' that match the request for deletion.\n"),
889  label);
890  test_finished();
891  return;
892  }
893  /* delete everything but what we copied to 'rdx' */
894  del_qe = GNUNET_NAMESTORE_records_store(ns,
895  &zone_pkey,
896  name,
897  rd_left,
898  rdx,
900  NULL);
901 }
902 
903 
912 static int
914  int *etime_is_rel,
915  uint64_t *etime)
916 {
917  struct GNUNET_TIME_Relative etime_rel;
918  struct GNUNET_TIME_Absolute etime_abs;
919 
920  if (0 == strcmp(expirationstring, "never"))
921  {
922  *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
923  *etime_is_rel = GNUNET_NO;
924  return GNUNET_OK;
925  }
926  if (GNUNET_OK ==
927  GNUNET_STRINGS_fancy_time_to_relative(expirationstring, &etime_rel))
928  {
929  *etime_is_rel = GNUNET_YES;
930  *etime = etime_rel.rel_value_us;
932  "Storing record with relative expiration time of %s\n",
934  return GNUNET_OK;
935  }
936  if (GNUNET_OK ==
937  GNUNET_STRINGS_fancy_time_to_absolute(expirationstring, &etime_abs))
938  {
939  *etime_is_rel = GNUNET_NO;
940  *etime = etime_abs.abs_value_us;
942  "Storing record with absolute expiration time of %s\n",
944  return GNUNET_OK;
945  }
946  return GNUNET_SYSERR;
947 }
948 
949 
960 static void
961 replace_cont(void *cls, int success, const char *emsg)
962 {
963  (void)cls;
964 
965  set_qe = NULL;
966  if (GNUNET_OK != success)
967  {
969  _("Failed to replace records: %s\n"),
970  emsg);
971  ret = 1; /* fail from 'main' */
972  }
974 }
975 
976 
983 static void
985 {
986  struct GNUNET_GNSRECORD_Data rd;
987 
988  if (!(add | del | list | (NULL != nickstring) | (NULL != uri) |
989  (NULL != reverse_pkey) | (NULL != recordset)))
990  {
991  /* nothing more to be done */
992  fprintf(stderr, _("No options given\n"));
994  return;
995  }
996  ns = GNUNET_NAMESTORE_connect(cfg);
997  if (NULL == ns)
998  {
1000  _("Failed to connect to namestore\n"));
1001  return;
1002  }
1003 
1004  if (NULL != recordset)
1005  {
1006  /* replace entire record set */
1007  unsigned int rd_count;
1008  struct GNUNET_GNSRECORD_Data *rd;
1009 
1010  if (NULL == name)
1011  {
1012  fprintf(stderr,
1013  _("Missing option `%s' for operation `%s'\n"),
1014  "-R",
1015  _("replace"));
1017  ret = 1;
1018  return;
1019  }
1020  rd_count = 0;
1021  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1022  rd_count++;
1023  rd = GNUNET_new_array(rd_count, struct GNUNET_GNSRECORD_Data);
1024  rd_count = 0;
1025  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1026  {
1027  rd[rd_count] = e->record;
1028  rd_count++;
1029  }
1030  set_qe = GNUNET_NAMESTORE_records_store(ns,
1031  &zone_pkey,
1032  name,
1033  rd_count,
1034  rd,
1035  &replace_cont,
1036  NULL);
1037  GNUNET_free(rd);
1038  return;
1039  }
1040 
1041  if (add)
1042  {
1043  if (NULL == name)
1044  {
1045  fprintf(stderr,
1046  _("Missing option `%s' for operation `%s'\n"),
1047  "-n",
1048  _("add"));
1050  ret = 1;
1051  return;
1052  }
1053  if (NULL == typestring)
1054  {
1055  fprintf(stderr,
1056  _("Missing option `%s' for operation `%s'\n"),
1057  "-t",
1058  _("add"));
1060  ret = 1;
1061  return;
1062  }
1064  if (UINT32_MAX == type)
1065  {
1066  fprintf(stderr, _("Unsupported type `%s'\n"), typestring);
1068  ret = 1;
1069  return;
1070  }
1071  if (NULL == value)
1072  {
1073  fprintf(stderr,
1074  _("Missing option `%s' for operation `%s'\n"),
1075  "-V",
1076  _("add"));
1077  ret = 1;
1079  return;
1080  }
1081  if (GNUNET_OK !=
1083  {
1084  fprintf(stderr,
1085  _("Value `%s' invalid for record type `%s'\n"),
1086  value,
1087  typestring);
1089  ret = 1;
1090  return;
1091  }
1092  if (NULL == expirationstring)
1093  {
1094  fprintf(stderr,
1095  _("Missing option `%s' for operation `%s'\n"),
1096  "-e",
1097  _("add"));
1099  ret = 1;
1100  return;
1101  }
1103  {
1104  fprintf(stderr, _("Invalid time format `%s'\n"), expirationstring);
1106  ret = 1;
1107  return;
1108  }
1109  add_qe = GNUNET_NAMESTORE_records_lookup(ns,
1110  &zone_pkey,
1111  name,
1112  &add_error_cb,
1113  NULL,
1115  NULL);
1116  }
1117  if (del)
1118  {
1119  if (NULL == name)
1120  {
1121  fprintf(stderr,
1122  _("Missing option `%s' for operation `%s'\n"),
1123  "-n",
1124  _("del"));
1126  ret = 1;
1127  return;
1128  }
1129  del_qe = GNUNET_NAMESTORE_records_lookup(ns,
1130  &zone_pkey,
1131  name,
1133  NULL,
1134  &del_monitor,
1135  NULL);
1136  }
1137  if (list)
1138  {
1139  if (NULL != name)
1140  get_qe = GNUNET_NAMESTORE_records_lookup(ns,
1141  &zone_pkey,
1142  name,
1143  &lookup_error_cb,
1144  NULL,
1146  NULL);
1147  else
1149  &zone_pkey,
1151  NULL,
1153  NULL,
1155  NULL);
1156  }
1157  if (NULL != reverse_pkey)
1158  {
1159  struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
1160 
1161  if (GNUNET_OK !=
1163  strlen(reverse_pkey),
1164  &pubkey))
1165  {
1166  fprintf(stderr,
1167  _("Invalid public key for reverse lookup `%s'\n"),
1168  reverse_pkey);
1170  }
1171  reverse_qe = GNUNET_NAMESTORE_zone_to_name(ns,
1172  &zone_pkey,
1173  &pubkey,
1175  NULL,
1177  NULL);
1178  }
1179  if (NULL != uri)
1180  {
1181  char sh[105];
1182  char sname[64];
1183  struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
1184 
1186  if ((2 != (sscanf(uri, "gnunet://gns/%52s/%63s", sh, sname))) ||
1187  (GNUNET_OK !=
1188  GNUNET_CRYPTO_ecdsa_public_key_from_string(sh, strlen(sh), &pkey)))
1189  {
1190  fprintf(stderr, _("Invalid URI `%s'\n"), uri);
1192  ret = 1;
1193  return;
1194  }
1195  memset(&rd, 0, sizeof(rd));
1196  rd.data = &pkey;
1197  rd.data_size = sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey);
1199  rd.expiration_time = etime;
1200  if (GNUNET_YES == etime_is_rel)
1202  if (1 == is_shadow)
1204  add_qe_uri = GNUNET_NAMESTORE_records_store(ns,
1205  &zone_pkey,
1206  sname,
1207  1,
1208  &rd,
1210  &add_qe_uri);
1211  }
1212  if (NULL != nickstring)
1213  {
1214  if (0 == strlen(nickstring))
1215  {
1216  fprintf(stderr, _("Invalid nick `%s'\n"), nickstring);
1218  ret = 1;
1219  return;
1220  }
1221  add_qe_uri = GNUNET_NAMESTORE_set_nick(ns,
1222  &zone_pkey,
1223  nickstring,
1225  &add_qe_uri);
1226  }
1227  if (monitor)
1228  {
1230  &zone_pkey,
1231  GNUNET_YES,
1233  NULL,
1235  NULL,
1236  &sync_cb,
1237  NULL);
1238  }
1239 }
1240 
1241 
1249 static void
1250 identity_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego)
1251 {
1252  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1253 
1254  el = NULL;
1255  if ((NULL != name) && (0 != strchr(name, '.')))
1256  {
1257  fprintf(stderr,
1258  _("Label `%s' contains `.' which is not allowed\n"),
1259  name);
1261  ret = -1;
1262  return;
1263  }
1264 
1265  if (NULL == ego)
1266  {
1267  if (NULL != ego_name)
1268  {
1269  fprintf(stderr,
1270  _("Ego `%s' not known to identity service\n"),
1271  ego_name);
1272  }
1274  ret = -1;
1275  return;
1276  }
1279  ego_name = NULL;
1280  run_with_zone_pkey(cfg);
1281 }
1282 
1283 
1294 static void
1295 default_ego_cb(void *cls,
1296  struct GNUNET_IDENTITY_Ego *ego,
1297  void **ctx,
1298  const char *name)
1299 {
1300  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1301 
1302  (void)ctx;
1303  (void)name;
1304  get_default = NULL;
1305  if (NULL == ego)
1306  {
1307  fprintf(stderr, _("No default ego configured in identity service\n"));
1309  ret = -1;
1310  return;
1311  }
1312  else
1313  {
1314  identity_cb((void *)cfg, ego);
1315  }
1316 }
1317 
1318 
1331 static void
1332 id_connect_cb(void *cls,
1333  struct GNUNET_IDENTITY_Ego *ego,
1334  void **ctx,
1335  const char *name)
1336 {
1337  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1338 
1339  (void)ctx;
1340  (void)name;
1341  if (NULL != ego)
1342  return;
1343  get_default =
1344  GNUNET_IDENTITY_get(idh, "namestore", &default_ego_cb, (void *)cfg);
1345 }
1346 
1347 
1356 static void
1357 run(void *cls,
1358  char *const *args,
1359  const char *cfgfile,
1360  const struct GNUNET_CONFIGURATION_Handle *cfg)
1361 {
1362  const char *pkey_str;
1363 
1364  (void)cls;
1365  (void)args;
1366  (void)cfgfile;
1367  if (NULL != args[0])
1368  GNUNET_log(
1370  _("Superfluous command line arguments (starting with `%s') ignored\n"),
1371  args[0]);
1372  if ((NULL != args[0]) && (NULL == uri))
1373  uri = GNUNET_strdup(args[0]);
1374 
1376  pkey_str = getenv("GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1377  if (NULL != pkey_str)
1378  {
1379  if (GNUNET_OK != GNUNET_STRINGS_string_to_data(pkey_str,
1380  strlen(pkey_str),
1381  &zone_pkey,
1382  sizeof(zone_pkey)))
1383  {
1384  fprintf(stderr,
1385  "Malformed private key `%s' in $%s\n",
1386  pkey_str,
1387  "GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1388  ret = 1;
1390  return;
1391  }
1392  run_with_zone_pkey(cfg);
1393  return;
1394  }
1395  if (NULL == ego_name)
1396  {
1397  idh = GNUNET_IDENTITY_connect(cfg, &id_connect_cb, (void *)cfg);
1398  if (NULL == idh)
1399  fprintf(stderr, _("Cannot connect to identity service\n"));
1400  ret = -1;
1401  return;
1402  }
1403  el = GNUNET_IDENTITY_ego_lookup(cfg, ego_name, &identity_cb, (void *)cfg);
1404 }
1405 
1406 
1424 static int
1426  void *scls,
1427  const char *option,
1428  const char *value)
1429 {
1430  struct RecordSetEntry **head = scls;
1431  struct RecordSetEntry *r;
1432  struct GNUNET_GNSRECORD_Data record;
1433  char *cp;
1434  char *tok;
1435  char *saveptr;
1436  int etime_is_rel;
1437  void *raw_data;
1438 
1439  (void)ctx;
1440  (void)option;
1441  cp = GNUNET_strdup(value);
1442  tok = strtok_r(cp, " ", &saveptr);
1443  if (NULL == tok)
1444  {
1446  _("Empty record line argument is not allowed.\n"));
1447  GNUNET_free(cp);
1448  return GNUNET_SYSERR;
1449  }
1450  {
1451  char *etime_in_s;
1452 
1453  GNUNET_asprintf(&etime_in_s, "%s s", tok);
1454  if (GNUNET_OK !=
1455  parse_expiration(etime_in_s, &etime_is_rel, &record.expiration_time))
1456  {
1458  _("Invalid expiration time `%s' (must be without unit)\n"),
1459  tok);
1460  GNUNET_free(cp);
1461  GNUNET_free(etime_in_s);
1462  return GNUNET_SYSERR;
1463  }
1464  GNUNET_free(etime_in_s);
1465  }
1466  tok = strtok_r(NULL, " ", &saveptr);
1467  if (NULL == tok)
1468  {
1470  _("Missing entries in record line `%s'.\n"),
1471  value);
1472  GNUNET_free(cp);
1473  return GNUNET_SYSERR;
1474  }
1476  if (UINT32_MAX == record.record_type)
1477  {
1478  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Unknown record type `%s'\n"), tok);
1479  GNUNET_free(cp);
1480  return GNUNET_SYSERR;
1481  }
1482  tok = strtok_r(NULL, " ", &saveptr);
1483  if (NULL == tok)
1484  {
1486  _("Missing entries in record line `%s'.\n"),
1487  value);
1488  GNUNET_free(cp);
1489  return GNUNET_SYSERR;
1490  }
1492  if (etime_is_rel)
1494  if (NULL == strchr(tok, (unsigned char)'p')) /* p = public */
1496  if (NULL != strchr(tok, (unsigned char)'s'))
1498  /* find beginning of record value */
1499  tok = strchr(&value[tok - cp], (unsigned char)' ');
1500  if (NULL == tok)
1501  {
1503  _("Missing entries in record line `%s'.\n"),
1504  value);
1505  GNUNET_free(cp);
1506  return GNUNET_SYSERR;
1507  }
1508  GNUNET_free(cp);
1509  tok++; /* skip space */
1511  tok,
1512  &raw_data,
1513  &record.data_size))
1514  {
1516  _("Invalid record data for type %s: `%s'.\n"),
1518  tok);
1519  return GNUNET_SYSERR;
1520  }
1521 
1522  r = GNUNET_malloc(sizeof(struct RecordSetEntry) + record.data_size);
1523  r->next = *head;
1524  record.data = &r[1];
1525  memcpy(&r[1], raw_data, record.data_size);
1526  GNUNET_free(raw_data);
1527  r->record = record;
1528  *head = r;
1529  return GNUNET_OK;
1530 }
1531 
1532 
1544  const char *name,
1545  const char *argumentHelp,
1546  const char *description,
1547  struct RecordSetEntry **rs)
1548 {
1550  .name = name,
1551  .argumentHelp = argumentHelp,
1552  .description = description,
1553  .require_argument = 1,
1554  .processor =
1556  .scls = (void *)rs };
1557 
1558  return clo;
1559 }
1560 
1561 
1569 int
1570 main(int argc, char *const *argv)
1571 {
1572  struct GNUNET_GETOPT_CommandLineOption options[] =
1573  { GNUNET_GETOPT_option_flag('a', "add", gettext_noop("add record"), &add),
1575  "delete",
1576  gettext_noop("delete record"),
1577  &del),
1579  "display",
1580  gettext_noop("display records"),
1581  &list),
1583  'e',
1584  "expiration",
1585  "TIME",
1586  gettext_noop(
1587  "expiration time for record to use (for adding only), \"never\" is possible"),
1588  &expirationstring),
1590  "nick",
1591  "NICKNAME",
1592  gettext_noop(
1593  "set the desired nick name for the zone"),
1594  &nickstring),
1596  "monitor",
1597  gettext_noop(
1598  "monitor changes in the namestore"),
1599  &monitor),
1601  "name",
1602  "NAME",
1603  gettext_noop(
1604  "name of the record to add/delete/display"),
1605  &name),
1607  "reverse",
1608  "PKEY",
1609  gettext_noop(
1610  "determine our name for the given PKEY"),
1611  &reverse_pkey),
1613  'R',
1614  "replace",
1615  "RECORDLINE",
1616  gettext_noop(
1617  "set record set to values given by (possibly multiple) RECORDLINES; can be specified multiple times"),
1618  &recordset),
1620  "type",
1621  "TYPE",
1622  gettext_noop(
1623  "type of the record to add/delete/display"),
1624  &typestring),
1626  "uri",
1627  "URI",
1628  gettext_noop("URI to import into our zone"),
1629  &uri),
1631  "value",
1632  "VALUE",
1633  gettext_noop(
1634  "value of the record to add/delete"),
1635  &value),
1637  "public",
1638  gettext_noop("create or list public record"),
1639  &is_public),
1641  's',
1642  "shadow",
1643  gettext_noop(
1644  "create shadow record (only valid if all other records of the same type have expired"),
1645  &is_shadow),
1647  "zone",
1648  "EGO",
1649  gettext_noop(
1650  "name of the ego controlling the zone"),
1651  &ego_name),
1653  int lret;
1654 
1655  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
1656  return 2;
1657 
1658  is_public = -1;
1659  is_shadow = -1;
1660  GNUNET_log_setup("gnunet-namestore", "WARNING", NULL);
1661  if (GNUNET_OK !=
1662  (lret = GNUNET_PROGRAM_run(argc,
1663  argv,
1664  "gnunet-namestore",
1665  _("GNUnet zone manipulation tool"),
1666  options,
1667  &run,
1668  NULL)))
1669  {
1670  GNUNET_free((void *)argv);
1672  return lret;
1673  }
1674  GNUNET_free((void *)argv);
1676  return ret;
1677 }
1678 
1679 /* end of gnunet-namestore.c */
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:525
General context for command line processors.
static void add_error_cb(void *cls)
Function called if lookup fails.
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:816
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
This record should not be used unless all (other) records with an absolute expiration time have expir...
struct RecordSetEntry * next
Kept in a linked list.
const char * argumentHelp
Name of the argument for the user in help text.
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
Handle for ego lookup.
uint64_t rel_value_us
The actual value.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the &#39;add&#39; operation.
static void lookup_error_cb(void *cls)
Function called on errors while monitoring.
static char * pkey
Public key of the zone to look in, in ASCII.
static int parse_expiration(const char *expirationstring, int *etime_is_rel, uint64_t *etime)
Parse expiration time.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe_uri
Queue entry for the &#39;add-uri&#39; operation.
struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, int iterate_first, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor monitor, void *monitor_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls)
Begin monitoring a zone for changes.
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
static void run_with_zone_pkey(const struct GNUNET_CONFIGURATION_Handle *cfg)
We have obtained the zone&#39;s private key, so now process the main commands using it.
void GNUNET_CRYPTO_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk)
Clear memory that was used to store a private key.
Definition: crypto_ecc.c:585
#define GNUNET_DNSPARSER_TYPE_CNAME
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *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.
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *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)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT)...
const char * description
Help text for the option (description)
static struct GNUNET_IDENTITY_EgoLookup * el
Handle to identity lookup.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1439
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (i.e.
Definition: gnsrecord.c:203
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:350
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/&#39;*&#39;.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:553
static void handle_reverse_lookup(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function called with the result of our attempt to obtain a name for a given public key...
static void do_shutdown(void *cls)
Task run on shutdown.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static void * data
Value in binary format.
int GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
Definition: strings.c:401
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_get(struct GNUNET_IDENTITY_Handle *h, const char *service_name, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Obtain the identity that is currently preferred/default for a service.
Definition: identity_api.c:584
void GNUNET_NAMESTORE_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Stop monitoring a zone for changes.
int main(int argc, char *const *argv)
The main function for gnunet-namestore.
static struct Experiment * e
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static void get_existing_record(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We&#39;re storing a record; this function is given the existing record so that we can merge the informati...
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
size_t data_size
Number of bytes in data.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
Definition of a command line option.
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...
Private ECC key encoded for transmission.
static char * name
Name of the records to add/list/remove.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
static void zone_iteration_finished(void *cls)
Function called when we are done with a zone iteration.
const char shortName
Short name of the option.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_GNSRECORD_TYPE_NICK
Record type for GNS nick names ("NICK").
static struct RecordSetEntry * recordset
Entry in record set for processing records in bulk.
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Handle for an operation with the identity service.
Definition: identity_api.c:39
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
static void zone_iteration_error_cb(void *cls)
Function called when we encountered an error in a zone iteration.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static int etime_is_rel
Is expiration time relative or absolute time?
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *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.
static struct GNUNET_IDENTITY_Handle * idh
Identity service handle.
static void add_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
static char * zone
Name of the zone we manage.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
Handle for a monitoring activity.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
Handle for a zone iterator operation.
Handle for an ego.
Definition: identity.h:237
static void replace_cont(void *cls, int success, const char *emsg)
Function called when namestore is done with the replace operation.
static int is_shadow
Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW_RECORD)
#define GNUNET_DNSPARSER_TYPE_SOA
const void * data
Binary value stored in the DNS record.
static void identity_cb(void *cls, const struct GNUNET_IDENTITY_Ego *ego)
Callback invoked from identity service with ego information.
static char * value
Value of the record to add/remove.
static int monitor
Enables monitor mode.
static int del
Desired action is to remove a record.
#define GNUNET_GNSRECORD_TYPE_PKEY
Record type for GNS zone transfer ("PKEY").
Connection to the NAMESTORE service.
Handle for the service.
Definition: identity_api.c:94
uint64_t expiration_time
Expiration time for the DNS record.
static int ret
Global return value.
static struct SolverHandle * sh
#define GNUNET_GNSRECORD_TYPE_GNS2DNS
Record type for delegation to DNS.
static struct GNUNET_NAMESTORE_QueueEntry * set_qe
Queue entry for the &#39;set/replace&#39; operation.
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
static void display_record_lookup(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static char * option
Name of the option.
Definition: gnunet-config.c:38
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
static void id_connect_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called with ALL of the egos known to the identity service, used on startup if the user did n...
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:835
static void del_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
This is a private record of this peer and it should thus not be handed out to other peers...
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
static void del_monitor(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We were asked to delete something; this function is called with the existing records.
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a &#39;value&#39; of a record to the binary representation.
Definition: gnsrecord.c:174
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
static struct GNUNET_NAMESTORE_QueueEntry * reverse_qe
Queue entry for the &#39;reverse lookup&#39; operation (in combination with a name).
static uint64_t etime
Expiration string converted to numeric value.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
An QueueEntry used to store information for a pending NAMESTORE record operation. ...
Definition: namestore_api.c:53
static char * reverse_pkey
Reverse lookup to perform.
static char * expirationstring
Desired expiration time.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
char * getenv()
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static char * uri
URI to import.
struct GNUNET_GNSRECORD_Data record
The record to add/remove.
static int is_public
Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE)
static int add
Desired action is to add a record.
static int list
Desired action is to list records.
static void display_record_iterator(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static void default_ego_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Function called with the default ego to be used for GNS operations.
Entry in record set for bulk processing.
static void display_record_monitor(void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
struct GNUNET_IDENTITY_EgoLookup * GNUNET_IDENTITY_ego_lookup(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, GNUNET_IDENTITY_EgoCallback cb, void *cb_cls)
Lookup an ego by name.
struct GNUNET_IDENTITY_Operation * get_default
Obtain default ego.
int GNUNET_CRYPTO_ecdsa_public_key_from_string(const char *enc, size_t enclen, struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a string representing a public key to a public key.
Definition: crypto_ecc.c:468
static uint32_t type
Type string converted to DNS type value.
uint32_t record_type
Type of the GNS/DNS record.
static void del_lookup_error_cb(void *cls)
Function called if lookup for deletion fails.
static char * nickstring
Desired nick name.
configuration data
Definition: configuration.c:83
static struct PendingResolutions * head
Head of list of pending resolution requests.
Definition: gnunet-ats.c:228
static char * ego_name
Name of the ego controlling the zone.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
static struct GNUNET_CRYPTO_EcdsaPrivateKey zone_pkey
Private key for the our zone.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_zone_to_name(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const struct GNUNET_CRYPTO_EcdsaPublicKey *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.
#define GNUNET_log(kind,...)
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the &#39;list&#39; operation.
static void monitor_error_cb(void *cls)
Function called on errors while monitoring.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the &#39;lookup&#39; operation.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the &#39;del&#39; operation.
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
static char * typestring
Type of the record to add/remove, NULL to remove all.
static void display_record(const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This flag is currently unused; former RF_PENDING flag.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:741
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
static void reverse_error_cb(void *cls)
Function called if we encountered an error in zone-to-name.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_set_nick(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const char *nick, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Set the desired nick name for a zone.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;value&#39; of a record to a string.
Definition: gnsrecord.c:142
static int multirecord_process(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Command-line option parser function that allows the user to specify a complete record as one argument...
static size_t data_size
Number of bytes in data.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number (i.e.
Definition: gnsrecord.c:230
void GNUNET_NAMESTORE_zone_monitor_next(struct GNUNET_NAMESTORE_ZoneMonitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_NAMESTORE_zone_monitor_start for the next record(s)...
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
#define GNUNET_malloc(size)
Wrapper around malloc.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:953
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
struct GNUNET_GETOPT_CommandLineOption multirecord_option(char shortName, const char *name, const char *argumentHelp, const char *description, struct RecordSetEntry **rs)
Allow user to specify keywords.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:552
#define gettext_noop(String)
Definition: gettext.h:69