GNUnet  0.11.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 
40 #define WARN_RELATIVE_EXPIRATION_LIMIT GNUNET_TIME_relative_multiply ( \
41  GNUNET_TIME_UNIT_MINUTES, 15)
42 
47 {
52 
57 };
58 
59 
63 static struct GNUNET_NAMESTORE_Handle *ns;
64 
69 
74 
78 static struct GNUNET_IDENTITY_Handle *idh;
79 
84 
88 static char *ego_name;
89 
93 static int add;
94 
99 
104 
109 
114 
118 static int list;
119 
124 
128 static int del;
129 
133 static int is_public;
134 
138 static int is_shadow;
139 
144 
149 
153 static char *name;
154 
158 static char *value;
159 
163 static char *uri;
164 
168 static char *reverse_pkey;
169 
173 static char *typestring;
174 
178 static char *expirationstring;
179 
183 static char *nickstring;
184 
188 static int ret;
189 
193 static uint32_t type;
194 
198 static void *data;
199 
203 static size_t data_size;
204 
208 static uint64_t etime;
209 
214 
219 
223 static int monitor;
224 
228 static struct RecordSetEntry *recordset;
229 
230 
236 static void
237 do_shutdown (void *cls)
238 {
239  (void) cls;
240  if (NULL != get_default)
241  {
243  get_default = NULL;
244  }
245  if (NULL != idh)
246  {
248  idh = NULL;
249  }
250  if (NULL != el)
251  {
253  el = NULL;
254  }
255  if (NULL != list_it)
256  {
258  list_it = NULL;
259  }
260  if (NULL != add_qe)
261  {
263  add_qe = NULL;
264  }
265  if (NULL != set_qe)
266  {
268  set_qe = NULL;
269  }
270  if (NULL != add_qe_uri)
271  {
273  add_qe_uri = NULL;
274  }
275  if (NULL != get_qe)
276  {
278  get_qe = NULL;
279  }
280  if (NULL != del_qe)
281  {
283  del_qe = NULL;
284  }
285  if (NULL != ns)
286  {
288  ns = NULL;
289  }
290  memset (&zone_pkey, 0, sizeof(zone_pkey));
291  if (NULL != uri)
292  {
293  GNUNET_free (uri);
294  uri = NULL;
295  }
296  if (NULL != zm)
297  {
299  zm = NULL;
300  }
301  if (NULL != data)
302  {
303  GNUNET_free (data);
304  data = NULL;
305  }
306 }
307 
308 
312 static void
314 {
315  if ((NULL == add_qe) && (NULL == add_qe_uri) && (NULL == get_qe) &&
316  (NULL == del_qe) && (NULL == reverse_qe) && (NULL == list_it))
318 }
319 
320 
331 static void
332 add_continuation (void *cls, int32_t success, const char *emsg)
333 {
334  struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
335 
336  *qe = NULL;
337  if (GNUNET_YES != success)
338  {
339  fprintf (stderr,
340  _ ("Adding record failed: %s\n"),
341  (GNUNET_NO == success) ? "record exists" : emsg);
342  if (GNUNET_NO != success)
343  ret = 1;
344  }
345  ret = 0;
346  test_finished ();
347 }
348 
349 
360 static void
361 del_continuation (void *cls, int32_t success, const char *emsg)
362 {
363  (void) cls;
364  del_qe = NULL;
365  if (GNUNET_NO == success)
366  {
367  fprintf (stderr,
368  _ ("Deleting record failed, record does not exist%s%s\n"),
369  (NULL != emsg) ? ": " : "",
370  (NULL != emsg) ? emsg : "");
371  }
372  if (GNUNET_SYSERR == success)
373  {
374  fprintf (stderr,
375  _ ("Deleting record failed%s%s\n"),
376  (NULL != emsg) ? ": " : "",
377  (NULL != emsg) ? emsg : "");
378  }
379  test_finished ();
380 }
381 
382 
386 static void
388 {
389  (void) cls;
390  list_it = NULL;
391  test_finished ();
392 }
393 
394 
398 static void
400 {
401  (void) cls;
402  list_it = NULL;
403  fprintf (stderr, "Error iterating over zone\n");
404  ret = 1;
405  test_finished ();
406 }
407 
408 
416 static void
417 display_record (const char *rname,
418  unsigned int rd_len,
419  const struct GNUNET_GNSRECORD_Data *rd)
420 {
421  const char *typestr;
422  char *s;
423  const char *ets;
424  struct GNUNET_TIME_Absolute at;
425  struct GNUNET_TIME_Relative rt;
426  int have_record;
427 
428  if ((NULL != name) && (0 != strcmp (name, rname)))
429  {
431  return;
432  }
433  have_record = GNUNET_NO;
434  for (unsigned int i = 0; i < rd_len; i++)
435  {
436  if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
437  (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
438  continue;
439  if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
440  continue;
441  if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
442  continue;
443  have_record = GNUNET_YES;
444  break;
445  }
446  if (GNUNET_NO == have_record)
447  return;
448  fprintf (stdout, "%s:\n", rname);
449  if (NULL != typestring)
451  else
453  for (unsigned int i = 0; i < rd_len; i++)
454  {
455  if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
456  (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
457  continue;
458  if (GNUNET_GNSRECORD_TYPE_TOMBSTONE == rd[i].record_type)
459  continue;
460  if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
461  continue;
462  typestr = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
463  s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
464  rd[i].data,
465  rd[i].data_size);
466  if (NULL == s)
467  {
468  fprintf (stdout,
469  _ ("\tCorrupt or unsupported record of type %u\n"),
470  (unsigned int) rd[i].record_type);
471  continue;
472  }
473  if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
474  {
475  rt.rel_value_us = rd[i].expiration_time;
477  }
478  else
479  {
480  at.abs_value_us = rd[i].expiration_time;
482  }
483  fprintf (stdout,
484  "\t%s: %s (%s)\t%s\t%s\n",
485  typestr,
486  s,
487  ets,
488  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE"
489  : "PUBLIC",
490  (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD)) ? "SHADOW"
491  : "");
492  GNUNET_free (s);
493  }
494  fprintf (stdout, "%s", "\n");
495 }
496 
497 
507 static void
509  const struct GNUNET_IDENTITY_PrivateKey *zone_key,
510  const char *rname,
511  unsigned int rd_len,
512  const struct GNUNET_GNSRECORD_Data *rd)
513 {
514  (void) cls;
515  (void) zone_key;
516  display_record (rname, rd_len, rd);
518 }
519 
520 
530 static void
532  const struct GNUNET_IDENTITY_PrivateKey *zone_key,
533  const char *rname,
534  unsigned int rd_len,
535  const struct GNUNET_GNSRECORD_Data *rd)
536 {
537  (void) cls;
538  (void) zone_key;
539  display_record (rname, rd_len, rd);
541 }
542 
543 
553 static void
555  const struct GNUNET_IDENTITY_PrivateKey *zone_key,
556  const char *rname,
557  unsigned int rd_len,
558  const struct GNUNET_GNSRECORD_Data *rd)
559 {
560  (void) cls;
561  (void) zone_key;
562  get_qe = NULL;
563  display_record (rname, rd_len, rd);
564  test_finished ();
565 }
566 
567 
573 static void
574 sync_cb (void *cls)
575 {
576  (void) cls;
577  fprintf (stdout, "%s", "Monitor is now in sync.\n");
578 }
579 
580 
586 static void
587 monitor_error_cb (void *cls)
588 {
589  (void) cls;
590  fprintf (stderr, "%s", "Monitor disconnected and out of sync.\n");
591 }
592 
593 
599 static void
600 lookup_error_cb (void *cls)
601 {
602  (void) cls;
603  get_qe = NULL;
604  fprintf (stderr, "%s", "Failed to lookup record.\n");
605  test_finished ();
606 }
607 
608 
612 static void
613 add_error_cb (void *cls)
614 {
615  (void) cls;
616  add_qe = NULL;
617  GNUNET_break (0);
618  ret = 1;
619  test_finished ();
620 }
621 
622 
633 static void
635  const struct GNUNET_IDENTITY_PrivateKey *zone_key,
636  const char *rec_name,
637  unsigned int rd_count,
638  const struct GNUNET_GNSRECORD_Data *rd)
639 {
640  struct GNUNET_GNSRECORD_Data rdn[rd_count + 1];
641  struct GNUNET_GNSRECORD_Data *rde;
642 
643  (void) cls;
644  (void) zone_key;
645  add_qe = NULL;
646  if (0 != strcmp (rec_name, name))
647  {
648  GNUNET_break (0);
649  ret = 1;
650  test_finished ();
651  return;
652  }
653 
655  "Received %u records for name `%s'\n",
656  rd_count,
657  rec_name);
658  for (unsigned int i = 0; i < rd_count; i++)
659  {
660  switch (rd[i].record_type)
661  {
664  {
665  fprintf (
666  stderr,
667  _ (
668  "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"),
669  rec_name);
670  ret = 1;
671  test_finished ();
672  return;
673  }
674  break;
675  }
676  }
677  memset (rdn, 0, sizeof(struct GNUNET_GNSRECORD_Data));
678  GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof(struct GNUNET_GNSRECORD_Data));
679  rde = &rdn[0];
680  rde->data = data;
681  rde->data_size = data_size;
682  rde->record_type = type;
683  if (1 == is_shadow)
685  if (1 != is_public)
687  rde->expiration_time = etime;
688  if (GNUNET_YES == etime_is_rel)
690  else if (GNUNET_NO != etime_is_rel)
691  rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
692  GNUNET_assert (NULL != name);
694  &zone_pkey,
695  name,
696  rd_count + 1,
697  rde,
699  &add_qe);
700 }
701 
702 
706 static void
707 reverse_error_cb (void *cls)
708 {
709  (void) cls;
710  reverse_qe = NULL;
711  fprintf (stdout, "%s.zkey\n", reverse_pkey);
712 }
713 
714 
725 static void
727  const struct GNUNET_IDENTITY_PrivateKey *zone,
728  const char *label,
729  unsigned int rd_count,
730  const struct GNUNET_GNSRECORD_Data *rd)
731 {
732  (void) cls;
733  (void) zone;
734  (void) rd_count;
735  (void) rd;
736  reverse_qe = NULL;
737  if (NULL == label)
738  fprintf (stdout, "%s\n", reverse_pkey);
739  else
740  fprintf (stdout, "%s.%s\n", label, ego_name);
741  test_finished ();
742 }
743 
744 
748 static void
750 {
751  (void) cls;
752  del_qe = NULL;
753  GNUNET_break (0);
754  ret = 1;
755  test_finished ();
756 }
757 
758 
770 static void
771 del_monitor (void *cls,
772  const struct GNUNET_IDENTITY_PrivateKey *zone,
773  const char *label,
774  unsigned int rd_count,
775  const struct GNUNET_GNSRECORD_Data *rd)
776 {
777  struct GNUNET_GNSRECORD_Data rdx[rd_count];
778  unsigned int rd_left;
779  uint32_t type;
780  char *vs;
781 
782  (void) cls;
783  (void) zone;
784  del_qe = NULL;
785  if (0 == rd_count)
786  {
787  fprintf (stderr,
788  _ (
789  "There are no records under label `%s' that could be deleted.\n"),
790  label);
791  ret = 1;
792  test_finished ();
793  return;
794  }
795  if ((NULL == value) && (NULL == typestring))
796  {
797  /* delete everything */
799  &zone_pkey,
800  name,
801  0,
802  NULL,
804  NULL);
805  return;
806  }
807  rd_left = 0;
808  if (NULL != typestring)
810  else
812  for (unsigned int i = 0; i < rd_count; i++)
813  {
814  vs = NULL;
815  if (! (((GNUNET_GNSRECORD_TYPE_ANY == type) ||
816  (rd[i].record_type == type)) &&
817  ((NULL == value) ||
818  (NULL ==
820  rd[i].data,
821  rd[i].data_size)))) ||
822  (0 == strcmp (vs, value)))))
823  rdx[rd_left++] = rd[i];
824  GNUNET_free (vs);
825  }
826  if (rd_count == rd_left)
827  {
828  /* nothing got deleted */
829  fprintf (
830  stderr,
831  _ (
832  "There are no records under label `%s' that match the request for deletion.\n"),
833  label);
834  test_finished ();
835  return;
836  }
837  /* delete everything but what we copied to 'rdx' */
839  &zone_pkey,
840  name,
841  rd_left,
842  rdx,
844  NULL);
845 }
846 
847 
856 static int
858  int *etime_is_rel,
859  uint64_t *etime)
860 {
861  struct GNUNET_TIME_Relative etime_rel;
862  struct GNUNET_TIME_Absolute etime_abs;
863 
864  if (0 == strcmp (expirationstring, "never"))
865  {
866  *etime = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
868  return GNUNET_OK;
869  }
870  if (GNUNET_OK ==
872  {
874  *etime = etime_rel.rel_value_us;
876  {
878  "Relative expiration times of less than %s are not recommended. To improve availability, consider increasing this value.\n",
881  }
883  "Storing record with relative expiration time of %s\n",
885  return GNUNET_OK;
886  }
887  if (GNUNET_OK ==
889  {
891  *etime = etime_abs.abs_value_us;
893  "Storing record with absolute expiration time of %s\n",
895  return GNUNET_OK;
896  }
897  return GNUNET_SYSERR;
898 }
899 
900 
911 static void
912 replace_cont (void *cls, int success, const char *emsg)
913 {
914  (void) cls;
915 
916  set_qe = NULL;
917  if (GNUNET_OK != success)
918  {
920  _ ("Failed to replace records: %s\n"),
921  emsg);
922  ret = 1; /* fail from 'main' */
923  }
925 }
926 
927 
934 static void
936 {
937  struct GNUNET_GNSRECORD_Data rd;
938 
939  if (! (add | del | list | (NULL != nickstring) | (NULL != uri)
940  | (NULL != reverse_pkey) | (NULL != recordset)))
941  {
942  /* nothing more to be done */
943  fprintf (stderr, _ ("No options given\n"));
945  return;
946  }
948  if (NULL == ns)
949  {
951  _ ("Failed to connect to namestore\n"));
952  return;
953  }
954 
955  if (NULL != recordset)
956  {
957  /* replace entire record set */
958  unsigned int rd_count;
959  struct GNUNET_GNSRECORD_Data *rd;
960 
961  if (NULL == name)
962  {
963  fprintf (stderr,
964  _ ("Missing option `%s' for operation `%s'\n"),
965  "-R",
966  _ ("replace"));
968  ret = 1;
969  return;
970  }
971  rd_count = 0;
972  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
973  rd_count++;
974  rd = GNUNET_new_array (rd_count, struct GNUNET_GNSRECORD_Data);
975  rd_count = 0;
976  for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
977  {
978  rd[rd_count] = e->record;
979  rd_count++;
980  }
982  &zone_pkey,
983  name,
984  rd_count,
985  rd,
986  &replace_cont,
987  NULL);
988  GNUNET_free (rd);
989  return;
990  }
991  if (NULL != nickstring)
992  {
993  if (0 == strlen (nickstring))
994  {
995  fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
997  ret = 1;
998  return;
999  }
1000  add = 1;
1005  is_public = 0;
1006  expirationstring = GNUNET_strdup ("never");
1008  nickstring = NULL;
1009  }
1010 
1011  if (add)
1012  {
1013  if (NULL == name)
1014  {
1015  fprintf (stderr,
1016  _ ("Missing option `%s' for operation `%s'\n"),
1017  "-n",
1018  _ ("add"));
1020  ret = 1;
1021  return;
1022  }
1023  if (NULL == typestring)
1024  {
1025  fprintf (stderr,
1026  _ ("Missing option `%s' for operation `%s'\n"),
1027  "-t",
1028  _ ("add"));
1030  ret = 1;
1031  return;
1032  }
1034  if (UINT32_MAX == type)
1035  {
1036  fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring);
1038  ret = 1;
1039  return;
1040  }
1041  if ((GNUNET_DNSPARSER_TYPE_SRV == type) ||
1044  {
1045  fprintf (stderr,
1046  _ ("For DNS record types `SRV', `TLSA' and `OPENPGPKEY'"));
1047  fprintf (stderr, ", please use a `BOX' record instead\n");
1049  ret = 1;
1050  return;
1051  }
1052  if (NULL == value)
1053  {
1054  fprintf (stderr,
1055  _ ("Missing option `%s' for operation `%s'\n"),
1056  "-V",
1057  _ ("add"));
1058  ret = 1;
1060  return;
1061  }
1062  if (GNUNET_OK !=
1064  {
1065  fprintf (stderr,
1066  _ ("Value `%s' invalid for record type `%s'\n"),
1067  value,
1068  typestring);
1070  ret = 1;
1071  return;
1072  }
1073  if (NULL == expirationstring)
1074  {
1075  fprintf (stderr,
1076  _ ("Missing option `%s' for operation `%s'\n"),
1077  "-e",
1078  _ ("add"));
1080  ret = 1;
1081  return;
1082  }
1084  {
1085  fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1087  ret = 1;
1088  return;
1089  }
1091  &zone_pkey,
1092  name,
1093  &add_error_cb,
1094  NULL,
1096  NULL);
1097  }
1098  if (del)
1099  {
1100  if (NULL == name)
1101  {
1102  fprintf (stderr,
1103  _ ("Missing option `%s' for operation `%s'\n"),
1104  "-n",
1105  _ ("del"));
1107  ret = 1;
1108  return;
1109  }
1111  &zone_pkey,
1112  name,
1114  NULL,
1115  &del_monitor,
1116  NULL);
1117  }
1118  if (list)
1119  {
1120  if (NULL != name)
1122  &zone_pkey,
1123  name,
1124  &lookup_error_cb,
1125  NULL,
1127  NULL);
1128  else
1130  &zone_pkey,
1132  NULL,
1134  NULL,
1136  NULL);
1137  }
1138  if (NULL != reverse_pkey)
1139  {
1141 
1142  if (GNUNET_OK !=
1144  &pubkey))
1145  {
1146  fprintf (stderr,
1147  _ ("Invalid public key for reverse lookup `%s'\n"),
1148  reverse_pkey);
1150  }
1152  &zone_pkey,
1153  &pubkey,
1155  NULL,
1157  NULL);
1158  }
1159  if (NULL != uri)
1160  {
1161  char sh[105];
1162  char sname[64];
1164 
1165  memset (sh, 0, 105);
1166  memset (sname, 0, 64);
1167 
1168  if ((2 != (sscanf (uri, "gnunet://gns/%58s/%63s", sh, sname))) ||
1169  (GNUNET_OK !=
1171  {
1172  fprintf (stderr, _ ("Invalid URI `%s'\n"), uri);
1174  ret = 1;
1175  return;
1176  }
1177  if (NULL == expirationstring)
1178  {
1179  fprintf (stderr,
1180  _ ("Missing option `%s' for operation `%s'\n"),
1181  "-e",
1182  _ ("add"));
1184  ret = 1;
1185  return;
1186  }
1188  {
1189  fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1191  ret = 1;
1192  return;
1193  }
1194  memset (&rd, 0, sizeof(rd));
1195  rd.data = &pkey;
1197  rd.record_type = ntohl (pkey.type);
1198  rd.expiration_time = etime;
1199  if (GNUNET_YES == etime_is_rel)
1201  if (1 == is_shadow)
1204  &zone_pkey,
1205  sname,
1206  1,
1207  &rd,
1209  &add_qe_uri);
1210  }
1211  if (monitor)
1212  {
1214  &zone_pkey,
1215  GNUNET_YES,
1217  NULL,
1219  NULL,
1220  &sync_cb,
1221  NULL);
1222  }
1223 }
1224 
1225 
1233 static void
1234 identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego)
1235 {
1236  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1237 
1238  el = NULL;
1239 
1240  if (NULL == ego)
1241  {
1242  if (NULL != ego_name)
1243  {
1244  fprintf (stderr,
1245  _ ("Ego `%s' not known to identity service\n"),
1246  ego_name);
1247  }
1249  ret = -1;
1250  return;
1251  }
1254  ego_name = NULL;
1256 }
1257 
1258 
1269 static void
1270 default_ego_cb (void *cls,
1271  struct GNUNET_IDENTITY_Ego *ego,
1272  void **ctx,
1273  const char *name)
1274 {
1275  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1276 
1277  (void) ctx;
1278  (void) name;
1279  get_default = NULL;
1280  if (NULL == ego)
1281  {
1282  fprintf (stderr,
1283  _ ("No default identity configured for `namestore' subsystem\n"
1284  "Run gnunet-identity -s namestore -e $NAME to set the default to $NAME\n"
1285  "Run gnunet-identity -d to get a list of choices for $NAME\n"));
1287  ret = -1;
1288  return;
1289  }
1290  else
1291  {
1292  identity_cb ((void *) cfg, ego);
1293  }
1294 }
1295 
1296 
1309 static void
1310 id_connect_cb (void *cls,
1311  struct GNUNET_IDENTITY_Ego *ego,
1312  void **ctx,
1313  const char *name)
1314 {
1315  const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1316 
1317  (void) ctx;
1318  (void) name;
1319  if (NULL != ego)
1320  return;
1321  get_default =
1322  GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg);
1323 }
1324 
1325 
1334 static void
1335 run (void *cls,
1336  char *const *args,
1337  const char *cfgfile,
1338  const struct GNUNET_CONFIGURATION_Handle *cfg)
1339 {
1340  const char *pkey_str;
1341 
1342  (void) cls;
1343  (void) args;
1344  (void) cfgfile;
1345  if (NULL != args[0])
1346  GNUNET_log (
1348  _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
1349  args[0]);
1350  if ((NULL != args[0]) && (NULL == uri))
1351  uri = GNUNET_strdup (args[0]);
1352 
1354  pkey_str = getenv ("GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1355  if (NULL != pkey_str)
1356  {
1357  if (GNUNET_OK != GNUNET_STRINGS_string_to_data (pkey_str,
1358  strlen (pkey_str),
1359  &zone_pkey,
1360  sizeof(zone_pkey)))
1361  {
1362  fprintf (stderr,
1363  "Malformed private key `%s' in $%s\n",
1364  pkey_str,
1365  "GNUNET_NAMESTORE_EGO_PRIVATE_KEY");
1366  ret = 1;
1368  return;
1369  }
1371  return;
1372  }
1373  if (NULL == ego_name)
1374  {
1376  if (NULL == idh)
1377  fprintf (stderr, _ ("Cannot connect to identity service\n"));
1378  ret = -1;
1379  return;
1380  }
1382 }
1383 
1384 
1402 static int
1404  void *scls,
1405  const char *option,
1406  const char *value)
1407 {
1408  struct RecordSetEntry **head = scls;
1409  struct RecordSetEntry *r;
1411  char *cp;
1412  char *tok;
1413  char *saveptr;
1414  int etime_is_rel;
1415  void *raw_data;
1416 
1417  (void) ctx;
1418  (void) option;
1419  cp = GNUNET_strdup (value);
1420  tok = strtok_r (cp, " ", &saveptr);
1421  if (NULL == tok)
1422  {
1424  _ ("Empty record line argument is not allowed.\n"));
1425  GNUNET_free (cp);
1426  return GNUNET_SYSERR;
1427  }
1428  {
1429  char *etime_in_s;
1430 
1431  GNUNET_asprintf (&etime_in_s, "%s s", tok);
1432  if (GNUNET_OK !=
1433  parse_expiration (etime_in_s, &etime_is_rel, &record.expiration_time))
1434  {
1436  _ ("Invalid expiration time `%s' (must be without unit)\n"),
1437  tok);
1438  GNUNET_free (cp);
1439  GNUNET_free (etime_in_s);
1440  return GNUNET_SYSERR;
1441  }
1442  GNUNET_free (etime_in_s);
1443  }
1444  tok = strtok_r (NULL, " ", &saveptr);
1445  if (NULL == tok)
1446  {
1448  _ ("Missing entries in record line `%s'.\n"),
1449  value);
1450  GNUNET_free (cp);
1451  return GNUNET_SYSERR;
1452  }
1453  record.record_type = GNUNET_GNSRECORD_typename_to_number (tok);
1454  if (UINT32_MAX == record.record_type)
1455  {
1456  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok);
1457  GNUNET_free (cp);
1458  return GNUNET_SYSERR;
1459  }
1460  tok = strtok_r (NULL, " ", &saveptr);
1461  if (NULL == tok)
1462  {
1464  _ ("Missing entries in record line `%s'.\n"),
1465  value);
1466  GNUNET_free (cp);
1467  return GNUNET_SYSERR;
1468  }
1470  if (etime_is_rel)
1472  if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */
1474  if (NULL != strchr (tok, (unsigned char) 's'))
1476  /* find beginning of record value */
1477  tok = strchr (&value[tok - cp], (unsigned char) ' ');
1478  if (NULL == tok)
1479  {
1481  _ ("Missing entries in record line `%s'.\n"),
1482  value);
1483  GNUNET_free (cp);
1484  return GNUNET_SYSERR;
1485  }
1486  GNUNET_free (cp);
1487  tok++; /* skip space */
1489  tok,
1490  &raw_data,
1491  &record.data_size))
1492  {
1494  _ ("Invalid record data for type %s: `%s'.\n"),
1496  tok);
1497  return GNUNET_SYSERR;
1498  }
1499 
1500  r = GNUNET_malloc (sizeof(struct RecordSetEntry) + record.data_size);
1501  r->next = *head;
1502  record.data = &r[1];
1503  memcpy (&r[1], raw_data, record.data_size);
1504  GNUNET_free (raw_data);
1505  r->record = record;
1506  *head = r;
1507  return GNUNET_OK;
1508 }
1509 
1510 
1522  const char *name,
1523  const char *argumentHelp,
1524  const char *description,
1525  struct RecordSetEntry **rs)
1526 {
1528  .name = name,
1529  .argumentHelp = argumentHelp,
1530  .description = description,
1531  .require_argument = 1,
1532  .processor =
1534  .scls = (void *) rs };
1535 
1536  return clo;
1537 }
1538 
1539 
1547 int
1548 main (int argc, char *const *argv)
1549 {
1551  { GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add),
1553  "delete",
1554  gettext_noop ("delete record"),
1555  &del),
1557  "display",
1558  gettext_noop ("display records"),
1559  &list),
1561  'e',
1562  "expiration",
1563  "TIME",
1564  gettext_noop (
1565  "expiration time for record to use (for adding only), \"never\" is possible"),
1566  &expirationstring),
1568  "nick",
1569  "NICKNAME",
1570  gettext_noop (
1571  "set the desired nick name for the zone"),
1572  &nickstring),
1574  "monitor",
1575  gettext_noop (
1576  "monitor changes in the namestore"),
1577  &monitor),
1579  "name",
1580  "NAME",
1581  gettext_noop (
1582  "name of the record to add/delete/display"),
1583  &name),
1585  "reverse",
1586  "PKEY",
1587  gettext_noop (
1588  "determine our name for the given PKEY"),
1589  &reverse_pkey),
1591  'R',
1592  "replace",
1593  "RECORDLINE",
1594  gettext_noop (
1595  "set record set to values given by (possibly multiple) RECORDLINES; can be specified multiple times"),
1596  &recordset),
1598  "type",
1599  "TYPE",
1600  gettext_noop (
1601  "type of the record to add/delete/display"),
1602  &typestring),
1604  "uri",
1605  "URI",
1606  gettext_noop ("URI to import into our zone"),
1607  &uri),
1609  "value",
1610  "VALUE",
1611  gettext_noop (
1612  "value of the record to add/delete"),
1613  &value),
1615  "public",
1616  gettext_noop ("create or list public record"),
1617  &is_public),
1619  's',
1620  "shadow",
1621  gettext_noop (
1622  "create shadow record (only valid if all other records of the same type have expired"),
1623  &is_shadow),
1625  "zone",
1626  "EGO",
1627  gettext_noop (
1628  "name of the ego controlling the zone"),
1629  &ego_name),
1631  int lret;
1632 
1633  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
1634  return 2;
1635 
1636  is_public = -1;
1637  is_shadow = -1;
1638  GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
1639  if (GNUNET_OK !=
1640  (lret = GNUNET_PROGRAM_run (argc,
1641  argv,
1642  "gnunet-namestore",
1643  _ ("GNUnet zone manipulation tool"),
1644  options,
1645  &run,
1646  NULL)))
1647  {
1648  GNUNET_free_nz ((void *) argv);
1649  // FIXME
1650  // GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1651  return lret;
1652  }
1653  GNUNET_free_nz ((void *) argv);
1654  // FIXME
1655  // GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
1656  return ret;
1657 }
1658 
1659 
1660 /* end of gnunet-namestore.c */
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
char * getenv()
#define gettext_noop(String)
Definition: gettext.h:69
#define GNUNET_GNSRECORD_TYPE_NICK
GNS nick names.
#define GNUNET_GNSRECORD_TYPE_TOMBSTONE
Record type to indicate a previously delete record (PRIVATE only)
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct Experiment * e
static struct SolverHandle * sh
static struct PendingResolutions * head
Head of list of pending resolution requests.
Definition: gnunet-ats.c:230
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static char * pkey
Public key of the zone to look in, in ASCII.
static struct GNUNET_IDENTITY_PublicKey pubkey
Public key of the zone to look in.
static char * zone
Name of the zone being managed.
static const struct GNUNET_IDENTITY_PrivateKey * zone_key
Private key of the zone.
static void zone_iteration_finished(void *cls)
Function called when we are done with a zone iteration.
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
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.
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the 'lookup' operation.
static void del_lookup_error_cb(void *cls)
Function called if lookup for deletion fails.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static void display_record_monitor(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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 struct GNUNET_IDENTITY_PrivateKey zone_pkey
Private key for the our zone.
static void del_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
#define WARN_RELATIVE_EXPIRATION_LIMIT
The upper bound for the zone iteration interval (per record).
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the 'add' operation.
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.
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego)
Callback invoked from identity service with ego information.
static char * nickstring
Desired nick name.
static int monitor
Enables monitor mode.
static void replace_cont(void *cls, int success, const char *emsg)
Function called when namestore is done with the replace operation.
static char * value
Value of the record to add/remove.
static int list
Desired action is to list records.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the 'del' operation.
static char * name
Name of the records to add/list/remove.
static struct GNUNET_NAMESTORE_QueueEntry * set_qe
Queue entry for the 'set/replace' operation.
static int ret
Global return value.
static void * data
Value in binary format.
static void lookup_error_cb(void *cls)
Function called on errors while monitoring.
static void do_shutdown(void *cls)
Task run on shutdown.
static struct GNUNET_IDENTITY_EgoLookup * el
Handle to identity lookup.
static struct GNUNET_IDENTITY_Handle * idh
Identity service handle.
static struct RecordSetEntry * recordset
Entry in record set for processing records in bulk.
static char * ego_name
Name of the ego controlling the zone.
static void reverse_error_cb(void *cls)
Function called if we encountered an error in zone-to-name.
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.
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 int is_shadow
Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW_RECORD)
static void handle_reverse_lookup(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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 get_existing_record(void *cls, const struct GNUNET_IDENTITY_PrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We're storing a record; this function is given the existing record so that we can merge the informati...
static int del
Desired action is to remove a record.
static int etime_is_rel
Is expiration time relative or absolute time?
static void add_error_cb(void *cls)
Function called if lookup fails.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
static int parse_expiration(const char *expirationstring, int *etime_is_rel, uint64_t *etime)
Parse expiration time.
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...
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the 'list' operation.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run.
static void monitor_error_cb(void *cls)
Function called on errors while monitoring.
static void run_with_zone_pkey(const struct GNUNET_CONFIGURATION_Handle *cfg)
We have obtained the zone's private key, so now process the main commands using it.
static void display_record_iterator(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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 add_continuation(void *cls, int32_t success, const char *emsg)
Continuation called to notify client about result of the operation.
int main(int argc, char *const *argv)
The main function for gnunet-namestore.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static void del_monitor(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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.
static char * expirationstring
Desired expiration time.
static void test_finished()
Check if we are finished, and if so, perform shutdown.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe_uri
Queue entry for the 'add-uri' operation.
static void display_record_lookup(void *cls, const struct GNUNET_IDENTITY_PrivateKey *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 int add
Desired action is to add a record.
static struct GNUNET_NAMESTORE_QueueEntry * reverse_qe
Queue entry for the 'reverse lookup' operation (in combination with a name).
static void zone_iteration_error_cb(void *cls)
Function called when we encountered an error in a zone iteration.
struct GNUNET_IDENTITY_Operation * get_default
Obtain default ego.
static char * typestring
Type of the record to add/remove, NULL to remove all.
static char * uri
URI to import.
static uint64_t etime
Expiration string converted to numeric value.
static char * reverse_pkey
Reverse lookup to perform.
static int is_public
Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE)
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
#define GNUNET_DNSPARSER_TYPE_OPENPGPKEY
#define GNUNET_DNSPARSER_TYPE_TLSA
#define GNUNET_DNSPARSER_TYPE_SRV
#define GNUNET_DNSPARSER_TYPE_SOA
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_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.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string (e.g.
Definition: gnsrecord.c:244
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the 'value' of a record to a string.
Definition: gnsrecord.c:156
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (e.g "AAAA") to the corresponding number.
Definition: gnsrecord.c:217
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a 'value' of a record to the binary representation.
Definition: gnsrecord.c:188
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/'*'.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_SHADOW_RECORD
This record should not be used unless all (other) records with an absolute expiration time have expir...
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be handed out to other peers.
@ GNUNET_GNSRECORD_RF_NONE
No special options.
const struct GNUNET_IDENTITY_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:639
enum GNUNET_GenericReturnValue GNUNET_IDENTITY_public_key_from_string(const char *str, struct GNUNET_IDENTITY_PublicKey *key)
Parses a (Base32) string representation of the public key.
void GNUNET_IDENTITY_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
Definition: identity_api.c:904
void GNUNET_IDENTITY_ego_lookup_cancel(struct GNUNET_IDENTITY_EgoLookup *el)
Abort ego lookup attempt.
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:675
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:610
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:921
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.
ssize_t GNUNET_IDENTITY_key_get_length(const struct GNUNET_IDENTITY_PublicKey *key)
Get the compacted length of a GNUNET_IDENTITY_PublicKey.
Definition: identity_api.c:991
int GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
#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_ERROR
@ GNUNET_ERROR_TYPE_MESSAGE
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
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)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT).
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.
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_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Stop monitoring a zone for changes.
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.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_IDENTITY_PrivateKey *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.
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).
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.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
enum GNUNET_GenericReturnValue 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,...
Definition: program.c:399
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:531
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,...
Definition: scheduler.c:1331
enum GNUNET_GenericReturnValue 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:789
enum GNUNET_GenericReturnValue 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:261
enum GNUNET_GenericReturnValue GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1223
#define GNUNET_TIME_relative_cmp(t1, op, t2)
Compare two relative times.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition: strings.c:617
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_UNIT_FOREVER_ABS
Constant used to specify "forever".
enum GNUNET_GenericReturnValue 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:303
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
Definition of a command line option.
const char * description
Help text for the option (description)
const char * argumentHelp
Name of the argument for the user in help text.
const char shortName
Short name of the option.
General context for command line processors.
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
Handle for ego lookup.
Handle for an ego.
Definition: identity.h:37
Handle for the service.
Definition: identity_api.c:96
Handle for an operation with the identity service.
Definition: identity_api.c:40
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Definition: namestore_api.c:54
Handle for a zone iterator operation.
Handle for a monitoring activity.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Entry in record set for bulk processing.
struct GNUNET_GNSRECORD_Data record
The record to add/remove.
struct RecordSetEntry * next
Kept in a linked list.