GNUnet 0.22.2
gnunet-service-identity.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2013 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
33#include "platform.h"
34#include "gnunet_util_lib.h"
35#include "gnunet_protocols.h"
37#include "identity.h"
38
39
43struct Ego
44{
48 struct Ego *next;
49
53 struct Ego *prev;
54
59
64};
65
66
70static const struct GNUNET_CONFIGURATION_Handle *cfg;
71
77
82
87
91static char *ego_directory;
92
96static char *subsystem_cfg_file;
97
101static struct Ego *ego_head;
102
106static struct Ego *ego_tail;
107
108
115static char *
117{
118 char *filename;
119
121 "%s%s%s",
124 ego->identifier);
125 return filename;
126}
127
128
136static void
138 struct GNUNET_SERVICE_Client *client,
139 void *app_ctx)
140{
142 "Client %p disconnected\n",
143 client);
144}
145
146
155static void *
157 struct GNUNET_SERVICE_Client *client,
158 struct GNUNET_MQ_Handle *mq)
159{
160 return client;
161}
162
163
169static void
170shutdown_task (void *cls)
171{
172 struct Ego *e;
173
174 if (NULL != nc)
175 {
177 nc = NULL;
178 }
179 if (NULL != stats)
180 {
182 stats = NULL;
183 }
185 subsystem_cfg = NULL;
187 subsystem_cfg_file = NULL;
189 ego_directory = NULL;
190 while (NULL != (e = ego_head))
191 {
193 ego_tail,
194 e);
196 GNUNET_free (e);
197 }
198}
199
200
207static void
209 uint32_t result_code)
210{
211 struct ResultCodeMessage *rcm;
212 struct GNUNET_MQ_Envelope *env;
213
214 env =
216 rcm->result_code = htonl (result_code);
218 "Sending result %d (%s) to client\n",
219 (int) result_code,
220 GNUNET_ErrorCode_get_hint (result_code));
222}
223
224
231static struct GNUNET_MQ_Envelope *
233{
234 struct UpdateMessage *um;
235 struct GNUNET_MQ_Envelope *env;
236 size_t name_len;
237 ssize_t key_len;
238
240 name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
241 env = GNUNET_MQ_msg_extra (um, name_len + key_len,
243 um->name_len = htons (name_len);
244 um->end_of_list = htons (GNUNET_NO);
245 um->key_len = htons (key_len);
246 GNUNET_memcpy (&um[1], ego->identifier, name_len);
248 ((char*) &um[1]) + name_len,
249 key_len);
250 return env;
251}
252
253
263static void
265 const struct GNUNET_MessageHeader *message)
266{
267 struct GNUNET_SERVICE_Client *client = cls;
268
270 "Received START message from client\n");
275 for (struct Ego *ego = ego_head; NULL != ego; ego = ego->next)
276 {
279 }
280 {
281 struct UpdateMessage *ume;
282 struct GNUNET_MQ_Envelope *env;
283
285 0,
287 ume->end_of_list = htons (GNUNET_YES);
288 ume->name_len = htons (0);
289 ume->key_len = htons (0);
291 env);
292 }
294}
295
296
305static int
307 const struct LookupMessage *message)
308{
310 return GNUNET_OK;
311}
312
313
321static void
323 const struct LookupMessage *message)
324{
325 struct GNUNET_SERVICE_Client *client = cls;
326 const char *name;
327 struct GNUNET_MQ_Envelope *env;
328 struct Ego *ego;
329
331 "Received LOOKUP message from client\n");
332 name = (const char *) &message[1];
333 for (ego = ego_head; NULL != ego; ego = ego->next)
334 {
335 if (0 != strcasecmp (name, ego->identifier))
336 continue;
340 return;
341 }
344}
345
346
355static int
357 const struct LookupMessage *message)
358{
360 return GNUNET_OK;
361}
362
363
371static void
373 const struct LookupMessage *message)
374{
375 struct GNUNET_SERVICE_Client *client = cls;
376 const char *name;
377 struct GNUNET_MQ_Envelope *env;
378 struct Ego *lprefix;
379
381 "Received LOOKUP_BY_SUFFIX message from client\n");
382 name = (const char *) &message[1];
383 lprefix = NULL;
384 for (struct Ego *ego = ego_head; NULL != ego; ego = ego->next)
385 {
386 if ((strlen (ego->identifier) <= strlen (name)) &&
387 (0 == strcmp (ego->identifier,
388 &name[strlen (name) - strlen (ego->identifier)])) &&
389 ((strlen (name) == strlen (ego->identifier)) ||
390 ('.' == name[strlen (name) - strlen (ego->identifier) - 1])) &&
391 ((NULL == lprefix) ||
392 (strlen (ego->identifier) > strlen (lprefix->identifier))))
393 {
394 /* found better match, update! */
395 lprefix = ego;
396 }
397 }
398 if (NULL != lprefix)
399 {
400 env = create_update_message (lprefix);
403 return;
404 }
407}
408
409
415static void
417{
418 struct UpdateMessage *um;
419 size_t name_len;
420 ssize_t key_len;
421
422 name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
424 um = GNUNET_malloc (sizeof(struct UpdateMessage) + name_len + key_len);
426 um->header.size = htons (sizeof(struct UpdateMessage) + name_len + key_len);
427 um->name_len = htons (name_len);
428 um->end_of_list = htons (GNUNET_NO);
429 um->key_len = htons (key_len);
430 GNUNET_memcpy (&um[1], ego->identifier, name_len);
432 ((char*) &um[1]) + name_len,
433 key_len);
435 GNUNET_free (um);
436}
437
438
446static int
448 const struct CreateRequestMessage *msg)
449{
450 uint16_t size;
451 uint16_t name_len;
452 size_t key_len;
453 const char *str;
454
455 size = ntohs (msg->header.size);
456 if (size <= sizeof(struct CreateRequestMessage))
457 {
458 GNUNET_break (0);
459 return GNUNET_SYSERR;
460 }
461 name_len = ntohs (msg->name_len);
462 key_len = ntohs (msg->key_len);
463 if (name_len + key_len + sizeof(struct CreateRequestMessage) != size)
464 {
465 GNUNET_break (0);
466 return GNUNET_SYSERR;
467 }
468 str = (const char *) &msg[1] + key_len;
469 if ('\0' != str[name_len - 1])
470 {
471 GNUNET_break (0);
472 return GNUNET_SYSERR;
473 }
474 return GNUNET_OK;
475}
476
477
484static void
486 const struct CreateRequestMessage *crm)
487{
488 struct GNUNET_CRYPTO_PrivateKey private_key;
489 struct GNUNET_SERVICE_Client *client = cls;
490 struct Ego *ego;
491 char *str;
492 char *fn;
493 size_t key_len;
494 size_t kb_read;
495
496 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREATE message from client\n");
497 key_len = ntohs (crm->key_len);
498 if ((GNUNET_SYSERR ==
500 key_len,
501 &private_key,
502 &kb_read)) ||
503 (kb_read != key_len))
504 {
506 return;
507 }
508 str = GNUNET_strdup ((const char *) &crm[1] + key_len);
509 GNUNET_STRINGS_utf8_tolower ((const char *) &crm[1] + key_len, str);
510 for (ego = ego_head; NULL != ego; ego = ego->next)
511 {
512 if (0 == strcmp (ego->identifier, str))
513 {
514 send_result_code (client,
517 GNUNET_free (str);
518 return;
519 }
520 }
521 ego = GNUNET_new (struct Ego);
522 ego->pk = private_key;
523 ego->identifier = GNUNET_strdup (str);
525 ego_tail,
526 ego);
528 fn = get_ego_filename (ego);
529 if (GNUNET_OK !=
531 &private_key,
532 sizeof(struct GNUNET_CRYPTO_PrivateKey),
536 GNUNET_free (fn);
537 GNUNET_free (str);
538 notify_listeners (ego);
540}
541
542
547{
551 const char *old_name;
552
556 const char *new_name;
557};
558
566static void
567handle_ego_rename (void *cls, const char *section)
568{
569 struct RenameContext *rc = cls;
570 char *id;
571
573 section,
574 "DEFAULT_IDENTIFIER",
575 &id))
576 return;
577 if (0 != strcmp (id, rc->old_name))
578 {
579 GNUNET_free (id);
580 return;
581 }
583 section,
584 "DEFAULT_IDENTIFIER",
585 rc->new_name);
586 GNUNET_free (id);
587}
588
589
597static int
598check_rename_message (void *cls, const struct RenameMessage *msg)
599{
600 uint16_t size;
601 uint16_t old_name_len;
602 uint16_t new_name_len;
603 const char *old_name;
604 const char *new_name;
605
606 size = ntohs (msg->header.size);
607 if (size <= sizeof(struct RenameMessage))
608 {
609 GNUNET_break (0);
610 return GNUNET_SYSERR;
611 }
612 old_name_len = ntohs (msg->old_name_len);
613 new_name_len = ntohs (msg->new_name_len);
614 old_name = (const char *) &msg[1];
615 new_name = &old_name[old_name_len];
616 if ((old_name_len + new_name_len + sizeof(struct RenameMessage) != size) ||
617 ('\0' != old_name[old_name_len - 1]) ||
618 ('\0' != new_name[new_name_len - 1]))
619 {
620 GNUNET_break (0);
621 return GNUNET_SYSERR;
622 }
623
624 return GNUNET_OK;
625}
626
627
635static void
636handle_rename_message (void *cls, const struct RenameMessage *rm)
637{
638 uint16_t old_name_len;
639 struct Ego *ego;
640 char *old_name;
641 char *new_name;
642 struct RenameContext rename_ctx;
643 struct GNUNET_SERVICE_Client *client = cls;
644 char *fn_old;
645 char *fn_new;
646 const char *old_name_tmp;
647
648 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received RENAME message from client\n");
649 old_name_len = ntohs (rm->old_name_len);
650 old_name_tmp = (const char *) &rm[1];
651 old_name = GNUNET_strdup (old_name_tmp);
652 GNUNET_STRINGS_utf8_tolower (old_name_tmp, old_name);
653 new_name = GNUNET_strdup (&old_name_tmp[old_name_len]);
654 GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len], new_name);
655
656 /* check if new name is already in use */
657 for (ego = ego_head; NULL != ego; ego = ego->next)
658 {
659 if (0 == strcmp (ego->identifier, new_name))
660 {
663 GNUNET_free (old_name);
664 GNUNET_free (new_name);
665 return;
666 }
667 }
668
669 /* locate old name and, if found, perform rename */
670 for (ego = ego_head; NULL != ego; ego = ego->next)
671 {
672 if (0 == strcmp (ego->identifier, old_name))
673 {
674 fn_old = get_ego_filename (ego);
675 GNUNET_free (ego->identifier);
676 rename_ctx.old_name = old_name;
677 rename_ctx.new_name = new_name;
680 &rename_ctx);
681 if (GNUNET_OK !=
683 GNUNET_log (
685 _ ("Failed to write subsystem default identifier map to `%s'.\n"),
687 ego->identifier = GNUNET_strdup (new_name);
688 fn_new = get_ego_filename (ego);
689 if (0 != rename (fn_old, fn_new))
691 GNUNET_free (fn_old);
692 GNUNET_free (fn_new);
693 GNUNET_free (old_name);
694 GNUNET_free (new_name);
695 notify_listeners (ego);
698 return;
699 }
700 }
701
702 /* failed to locate old name */
704 GNUNET_free (old_name);
705 GNUNET_free (new_name);
707}
708
709
717static void
718handle_ego_delete (void *cls, const char *section)
719{
720 const char *identifier = cls;
721 char *id;
722
724 section,
725 "DEFAULT_IDENTIFIER",
726 &id))
727 return;
728 if (0 != strcmp (id, identifier))
729 {
730 GNUNET_free (id);
731 return;
732 }
734 section,
735 "DEFAULT_IDENTIFIER",
736 NULL);
737 GNUNET_free (id);
738}
739
740
748static int
749check_delete_message (void *cls, const struct DeleteMessage *msg)
750{
751 uint16_t size;
752 uint16_t name_len;
753 const char *name;
754
755 size = ntohs (msg->header.size);
756 if (size <= sizeof(struct DeleteMessage))
757 {
758 GNUNET_break (0);
759 return GNUNET_SYSERR;
760 }
761 name = (const char *) &msg[1];
762 name_len = ntohs (msg->name_len);
763 if ((name_len + sizeof(struct DeleteMessage) != size) ||
764 (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
765 {
766 GNUNET_break (0);
767 return GNUNET_SYSERR;
768 }
769 return GNUNET_OK;
770}
771
772
780static void
781handle_delete_message (void *cls, const struct DeleteMessage *dm)
782{
783 struct Ego *ego;
784 char *name;
785 char *fn;
786 struct GNUNET_SERVICE_Client *client = cls;
787
788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received DELETE message from client\n");
789 name = GNUNET_strdup ((const char *) &dm[1]);
790 GNUNET_STRINGS_utf8_tolower ((const char *) &dm[1], name);
791
792 for (ego = ego_head; NULL != ego; ego = ego->next)
793 {
794 if (0 == strcmp (ego->identifier, name))
795 {
799 ego->identifier);
800 if (GNUNET_OK !=
802 GNUNET_log (
804 _ ("Failed to write subsystem default identifier map to `%s'.\n"),
806 fn = get_ego_filename (ego);
807 if (0 != unlink (fn))
809 GNUNET_free (fn);
810 GNUNET_free (ego->identifier);
811 ego->identifier = NULL;
812 notify_listeners (ego);
813 GNUNET_free (ego);
817 return;
818 }
819 }
820
824}
825
826
827static int
829 void *buf,
830 size_t buf_size)
831{
832 int fd;
833 struct stat sb;
834
835 fd = open (filename,
836 O_RDONLY);
837 if (-1 == fd)
838 {
839 memset (buf,
840 0,
841 buf_size);
842 return GNUNET_SYSERR;
843 }
844 if (0 != fstat (fd,
845 &sb))
846 {
848 "stat",
849 filename);
850 GNUNET_assert (0 == close (fd));
851 memset (buf,
852 0,
853 buf_size);
854 return GNUNET_SYSERR;
855 }
856 if (sb.st_size != buf_size)
857 {
859 "File `%s' has wrong size (%llu), expected %llu bytes\n",
860 filename,
861 (unsigned long long) sb.st_size,
862 (unsigned long long) buf_size);
863 GNUNET_assert (0 == close (fd));
864 memset (buf,
865 0,
866 buf_size);
867 return GNUNET_SYSERR;
868 }
869 if (buf_size !=
870 read (fd,
871 buf,
872 buf_size))
873 {
875 "read",
876 filename);
877 GNUNET_assert (0 == close (fd));
878 memset (buf,
879 0,
880 buf_size);
881 return GNUNET_SYSERR;
882 }
883 GNUNET_assert (0 == close (fd));
884 return GNUNET_OK;
885}
886
887
898static int
900 const char *filename)
901{
902 struct Ego *ego;
903 const char *fn;
904
905 fn = strrchr (filename, (int) DIR_SEPARATOR);
906 if (NULL == fn)
907 {
908 GNUNET_break (0);
909 return GNUNET_OK;
910 }
911 ego = GNUNET_new (struct Ego);
912 if (GNUNET_OK !=
914 &ego->pk,
915 sizeof (ego->pk)))
916 {
917 GNUNET_free (ego);
919 _ ("Failed to parse ego information in `%s'\n"),
920 filename);
921 return GNUNET_OK;
922 }
924 "Loaded ego `%s'\n",
925 fn + 1);
926 ego->identifier = GNUNET_strdup (fn + 1);
928 return GNUNET_OK;
929}
930
931
939static void
940run (void *cls,
941 const struct GNUNET_CONFIGURATION_Handle *c,
943{
944 cfg = c;
947 "identity",
948 "EGODIR",
950 {
953 return;
954 }
955 if (GNUNET_OK !=
957 "identity",
958 "SUBSYSTEM_CFG",
960 {
962 "identity",
963 "SUBSYSTEM_CFG");
965 return;
966 }
968 "Loading subsystem configuration `%s'\n",
971 ;
973 (GNUNET_OK !=
975 {
977 _ (
978 "Failed to parse subsystem identity configuration file `%s'\n"),
981 return;
982 }
983 stats = GNUNET_STATISTICS_create ("identity", cfg);
985 {
987 _ ("Failed to create directory `%s' for storing egos\n"),
989 }
992 NULL);
994}
995
996
1002 "identity",
1004 &run,
1007 NULL,
1008 GNUNET_MQ_hd_fixed_size (start_message,
1010 struct GNUNET_MessageHeader,
1011 NULL),
1012 GNUNET_MQ_hd_var_size (lookup_message,
1014 struct LookupMessage,
1015 NULL),
1016 GNUNET_MQ_hd_var_size (lookup_by_suffix_message,
1018 struct LookupMessage,
1019 NULL),
1022 struct CreateRequestMessage,
1023 NULL),
1024 GNUNET_MQ_hd_var_size (rename_message,
1026 struct RenameMessage,
1027 NULL),
1028 GNUNET_MQ_hd_var_size (delete_message,
1030 struct DeleteMessage,
1031 NULL),
1033
1034
1035/* end of gnunet-service-identity.c */
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static char * filename
static char * name
Name (label) of the records to list.
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static void handle_create_message(void *cls, const struct CreateRequestMessage *crm)
Handler for CREATE message from client, creates new identity.
GNUNET_SERVICE_MAIN(GNUNET_OS_project_data_gnunet(), "identity", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(start_message, GNUNET_MESSAGE_TYPE_IDENTITY_START, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_var_size(lookup_message, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, struct LookupMessage, NULL), GNUNET_MQ_hd_var_size(lookup_by_suffix_message, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX, struct LookupMessage, NULL), GNUNET_MQ_hd_var_size(create_message, GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, struct CreateRequestMessage, NULL), GNUNET_MQ_hd_var_size(rename_message, GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, struct RenameMessage, NULL), GNUNET_MQ_hd_var_size(delete_message, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, struct DeleteMessage, NULL), GNUNET_MQ_handler_end())
Define "main" method using service macro.
static struct Ego * ego_tail
Tail of DLL of all egos.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static int check_lookup_message(void *cls, const struct LookupMessage *message)
Handler for LOOKUP message from client, sends information about ONE identity to the client immediatel...
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
static void send_result_code(struct GNUNET_SERVICE_Client *client, uint32_t result_code)
Send a result code back to the client.
static int check_create_message(void *cls, const struct CreateRequestMessage *msg)
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_CREATE message.
static struct GNUNET_NotificationContext * nc
Notification context, simplifies client broadcasts.
static void handle_start_message(void *cls, const struct GNUNET_MessageHeader *message)
Handler for START message from client, sends information about all identities to the client immediate...
static int check_delete_message(void *cls, const struct DeleteMessage *msg)
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_DELETE message.
static void handle_lookup_by_suffix_message(void *cls, const struct LookupMessage *message)
Handler for LOOKUP_BY_SUFFIX message from client, sends information about ONE identity to the client ...
static void shutdown_task(void *cls)
Task run during shutdown.
static char * subsystem_cfg_file
Configuration file name where subsystem information is kept.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Add a client to our list of active clients.
static int process_ego_file(void *cls, const char *filename)
Process the given file from the "EGODIR".
static void handle_ego_rename(void *cls, const char *section)
An ego was renamed; rename it in all subsystems where it is currently set as the default.
static void handle_rename_message(void *cls, const struct RenameMessage *rm)
Handler for RENAME message from client, creates new identity.
static int read_from_file(const char *filename, void *buf, size_t buf_size)
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
Handle network size estimate clients.
static void handle_lookup_message(void *cls, const struct LookupMessage *message)
Handler for LOOKUP message from client, sends information about ONE identity to the client immediatel...
static char * ego_directory
Directory where we store the identities.
static void notify_listeners(struct Ego *ego)
Send an updated message for the given ego to all listeners.
static char * get_ego_filename(struct Ego *ego)
Get the name of the file we use to store a given ego.
static void handle_delete_message(void *cls, const struct DeleteMessage *dm)
Handler for DELETE message from client, creates new identity.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
static struct GNUNET_MQ_Envelope * create_update_message(struct Ego *ego)
Create an update message with information about the current state of an ego.
static int check_rename_message(void *cls, const struct RenameMessage *msg)
Checks a GNUNET_MESSAGE_TYPE_IDENTITY_RENAME message.
static void handle_ego_delete(void *cls, const char *section)
An ego was removed, remove it from all subsystems where it is currently set as the default.
static struct Ego * ego_head
Head of DLL of all egos.
static struct GNUNET_CONFIGURATION_Handle * subsystem_cfg
Handle to subsystem configuration which for each subsystem contains the name of the default ego.
static int check_lookup_by_suffix_message(void *cls, const struct LookupMessage *message)
Handler for LOOKUP message from client, sends information about ONE identity to the client immediatel...
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
@ GNUNET_EC_NONE
No error (success).
@ GNUNET_EC_IDENTITY_NOT_FOUND
Ego not found.
@ GNUNET_EC_IDENTITY_NAME_CONFLICT
Identifier already in use for another ego.
Constants for network protocols.
API to create, modify and access statistics.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_SectionIterator iter, void *iter_cls)
Iterate over all sections in the configuration.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Parse a configuration file, add all of the options in the file to the configuration environment.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
Definition: disk.c:520
enum GNUNET_GenericReturnValue GNUNET_DISK_fn_write(const char *fn, const void *buf, size_t buf_size, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file atomically.
Definition: disk.c:737
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition: disk.c:534
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition: disk.c:826
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
ssize_t GNUNET_CRYPTO_private_key_get_length(const struct GNUNET_CRYPTO_PrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_PrivateKey.
Definition: crypto_pkey.c:64
ssize_t GNUNET_CRYPTO_write_private_key_to_buffer(const struct GNUNET_CRYPTO_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PrivateKey to a compact buffer.
Definition: crypto_pkey.c:172
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PrivateKey from a compact buffer.
Definition: crypto_pkey.c:146
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#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.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ 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_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
Definition: nc.c:138
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:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#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:61
struct GNUNET_NotificationContext * GNUNET_notification_context_create(unsigned int queue_length)
Create a new notification context.
Definition: nc.c:122
void GNUNET_notification_context_broadcast(struct GNUNET_NotificationContext *nc, const struct GNUNET_MessageHeader *msg, int can_drop)
Send a message to all subscribers of this context.
Definition: nc.c:190
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
Definition: nc.c:161
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define GNUNET_MESSAGE_TYPE_IDENTITY_CREATE
627 and 628 unused
#define GNUNET_MESSAGE_TYPE_IDENTITY_START
First message send from identity client to service (to subscribe to updates).
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE
Delete identity (client->service).
#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP
First message send from identity client to service to lookup a single ego.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
#define GNUNET_MESSAGE_TYPE_IDENTITY_RENAME
Rename existing identity (client->service).
#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX
First message send from identity client to service to lookup a single ego matching the given suffix (...
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567
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:1339
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the 'monitor' flag on this client.
Definition: service.c:2483
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2418
void GNUNET_SERVICE_client_disable_continue_warning(struct GNUNET_SERVICE_Client *c)
Disable the warning the server issues if a message is not acknowledged in a timely fashion.
Definition: service.c:2406
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2500
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2389
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
enum GNUNET_GenericReturnValue GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:459
Common type definitions for the identity service and API.
struct GNUNET_MESSENGER_Message * create_message(enum GNUNET_MESSENGER_MessageKind kind)
Creates and allocates a new message with a specific kind.
static unsigned int size
Size of the "table".
Definition: peer.c:68
#define DIR_SEPARATOR
Definition: platform.h:166
#define DIR_SEPARATOR_STR
Definition: platform.h:167
#define _(String)
GNU gettext support macro.
Definition: platform.h:179
Client requests creation of an identity.
Definition: identity.h:151
uint16_t key_len
Key length.
Definition: identity.h:165
Client requests deletion of an identity.
Definition: identity.h:204
Information we keep about each ego.
struct Ego * prev
We keep egos in a DLL.
struct GNUNET_CRYPTO_PrivateKey pk
Private key of the ego.
char * identifier
String identifier for the ego.
struct Ego * next
We keep egos in a DLL.
A private key for an identity as per LSD0001.
Handle to a message queue.
Definition: mq.c:87
Header for all communications.
The notification context is the key datastructure for a convenience API used for transmission of noti...
Definition: nc.c:77
Handle to a client that is connected to a service.
Definition: service.c:249
Handle to a service.
Definition: service.c:116
Handle for the service.
Message from client to GNS service to lookup records.
Definition: gns.h:37
Closure for 'handle_ego_rename'.
const char * old_name
Old name.
const char * new_name
New name.
Client requests renaming of an identity.
Definition: identity.h:178
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:187
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:81
uint32_t result_code
Status code for the last operation, in NBO.
Definition: identity.h:91
Service informs client about status of a pseudonym.
Definition: identity.h:114
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition: identity.h:129
uint16_t key_len
Key length.
Definition: identity.h:134
uint16_t name_len
Number of bytes in ego name string including 0-termination, in NBO; 0 if the ego was deleted.
Definition: identity.h:124
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.
Definition: identity.h:118