GNUnet 0.26.2-1-g232dc9ef2
 
Loading...
Searching...
No Matches
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_BlindablePrivateKey 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_STRINGS_utf8_tolower ((const char *) &crm[1] + key_len);
509 for (ego = ego_head; NULL != ego; ego = ego->next)
510 {
511 if (0 == strcmp (ego->identifier, str))
512 {
513 send_result_code (client,
517 return;
518 }
519 }
520 ego = GNUNET_new (struct Ego);
521 ego->pk = private_key;
524 ego_tail,
525 ego);
527 fn = get_ego_filename (ego);
528 if (GNUNET_OK !=
530 &private_key,
535 GNUNET_free (fn);
537 notify_listeners (ego);
539}
540
541
546{
550 const char *old_name;
551
555 const char *new_name;
556};
557
565static void
566handle_ego_rename (void *cls, const char *section)
567{
568 struct RenameContext *rc = cls;
569 char *id;
570
572 section,
573 "DEFAULT_IDENTIFIER",
574 &id))
575 return;
576 if (0 != strcmp (id, rc->old_name))
577 {
578 GNUNET_free (id);
579 return;
580 }
582 section,
583 "DEFAULT_IDENTIFIER",
584 rc->new_name);
585 GNUNET_free (id);
586}
587
588
596static int
597check_rename_message (void *cls, const struct RenameMessage *msg)
598{
599 uint16_t size;
600 uint16_t old_name_len;
601 uint16_t new_name_len;
602 const char *old_name;
603 const char *new_name;
604
605 size = ntohs (msg->header.size);
606 if (size <= sizeof(struct RenameMessage))
607 {
608 GNUNET_break (0);
609 return GNUNET_SYSERR;
610 }
611 old_name_len = ntohs (msg->old_name_len);
612 new_name_len = ntohs (msg->new_name_len);
613 old_name = (const char *) &msg[1];
614 new_name = &old_name[old_name_len];
615 if ((old_name_len + new_name_len + sizeof(struct RenameMessage) != size) ||
616 ('\0' != old_name[old_name_len - 1]) ||
617 ('\0' != new_name[new_name_len - 1]))
618 {
619 GNUNET_break (0);
620 return GNUNET_SYSERR;
621 }
622
623 return GNUNET_OK;
624}
625
626
634static void
635handle_rename_message (void *cls, const struct RenameMessage *rm)
636{
637 uint16_t old_name_len;
638 struct Ego *ego;
639 char *old_name;
640 char *new_name;
641 struct RenameContext rename_ctx;
642 struct GNUNET_SERVICE_Client *client = cls;
643 char *fn_old;
644 char *fn_new;
645 const char *old_name_tmp;
646
647 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received RENAME message from client\n");
648 old_name_len = ntohs (rm->old_name_len);
649 old_name_tmp = (const char *) &rm[1];
650 old_name = GNUNET_STRINGS_utf8_tolower (old_name_tmp);
651 new_name = GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len]);
652
653 /* check if new name is already in use */
654 for (ego = ego_head; NULL != ego; ego = ego->next)
655 {
656 if (0 == strcmp (ego->identifier, new_name))
657 {
660 GNUNET_free (old_name);
661 GNUNET_free (new_name);
662 return;
663 }
664 }
665
666 /* locate old name and, if found, perform rename */
667 for (ego = ego_head; NULL != ego; ego = ego->next)
668 {
669 if (0 == strcmp (ego->identifier, old_name))
670 {
671 fn_old = get_ego_filename (ego);
672 GNUNET_free (ego->identifier);
673 rename_ctx.old_name = old_name;
674 rename_ctx.new_name = new_name;
677 &rename_ctx);
678 if (GNUNET_OK !=
680 GNUNET_log (
682 _ ("Failed to write subsystem default identifier map to `%s'.\n"),
684 ego->identifier = GNUNET_strdup (new_name);
685 fn_new = get_ego_filename (ego);
686 if (0 != rename (fn_old, fn_new))
688 GNUNET_free (fn_old);
689 GNUNET_free (fn_new);
690 GNUNET_free (old_name);
691 GNUNET_free (new_name);
692 notify_listeners (ego);
695 return;
696 }
697 }
698
699 /* failed to locate old name */
701 GNUNET_free (old_name);
702 GNUNET_free (new_name);
704}
705
706
714static void
715handle_ego_delete (void *cls, const char *section)
716{
717 const char *identifier = cls;
718 char *id;
719
721 section,
722 "DEFAULT_IDENTIFIER",
723 &id))
724 return;
725 if (0 != strcmp (id, identifier))
726 {
727 GNUNET_free (id);
728 return;
729 }
731 section,
732 "DEFAULT_IDENTIFIER",
733 NULL);
734 GNUNET_free (id);
735}
736
737
745static int
746check_delete_message (void *cls, const struct DeleteMessage *msg)
747{
748 uint16_t size;
749 uint16_t name_len;
750 const char *name;
751
752 size = ntohs (msg->header.size);
753 if (size <= sizeof(struct DeleteMessage))
754 {
755 GNUNET_break (0);
756 return GNUNET_SYSERR;
757 }
758 name = (const char *) &msg[1];
759 name_len = ntohs (msg->name_len);
760 if ((name_len + sizeof(struct DeleteMessage) != size) ||
761 (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
762 {
763 GNUNET_break (0);
764 return GNUNET_SYSERR;
765 }
766 return GNUNET_OK;
767}
768
769
777static void
778handle_delete_message (void *cls, const struct DeleteMessage *dm)
779{
780 struct Ego *ego;
781 char *name;
782 char *fn;
783 struct GNUNET_SERVICE_Client *client = cls;
784
786 "Received DELETE message from client\n");
787 name = GNUNET_STRINGS_utf8_tolower ((const char *) &dm[1]);
788
789 for (ego = ego_head; NULL != ego; ego = ego->next)
790 {
791 if (0 == strcmp (ego->identifier, name))
792 {
796 ego->identifier);
797 if (GNUNET_OK !=
799 GNUNET_log (
801 _ ("Failed to write subsystem default identifier map to `%s'.\n"),
803 fn = get_ego_filename (ego);
804 if (0 != unlink (fn))
806 GNUNET_free (fn);
807 GNUNET_free (ego->identifier);
808 ego->identifier = NULL;
809 notify_listeners (ego);
810 GNUNET_free (ego);
814 return;
815 }
816 }
817
821}
822
823
824static int
826 void *buf,
827 size_t buf_size)
828{
829 int fd;
830 struct stat sb;
831
832 fd = open (filename,
833 O_RDONLY);
834 if (-1 == fd)
835 {
836 memset (buf,
837 0,
838 buf_size);
839 return GNUNET_SYSERR;
840 }
841 if (0 != fstat (fd,
842 &sb))
843 {
845 "stat",
846 filename);
847 GNUNET_assert (0 == close (fd));
848 memset (buf,
849 0,
850 buf_size);
851 return GNUNET_SYSERR;
852 }
853 if (sb.st_size != buf_size)
854 {
856 "File `%s' has wrong size (%llu), expected %llu bytes\n",
857 filename,
858 (unsigned long long) sb.st_size,
859 (unsigned long long) buf_size);
860 GNUNET_assert (0 == close (fd));
861 memset (buf,
862 0,
863 buf_size);
864 return GNUNET_SYSERR;
865 }
866 if (buf_size !=
867 read (fd,
868 buf,
869 buf_size))
870 {
872 "read",
873 filename);
874 GNUNET_assert (0 == close (fd));
875 memset (buf,
876 0,
877 buf_size);
878 return GNUNET_SYSERR;
879 }
880 GNUNET_assert (0 == close (fd));
881 return GNUNET_OK;
882}
883
884
895static int
897 const char *filename)
898{
899 struct Ego *ego;
900 const char *fn;
901
902 fn = strrchr (filename, (int) DIR_SEPARATOR);
903 if (NULL == fn)
904 {
905 GNUNET_break (0);
906 return GNUNET_OK;
907 }
908 ego = GNUNET_new (struct Ego);
909 if (GNUNET_OK !=
911 &ego->pk,
912 sizeof (ego->pk)))
913 {
914 GNUNET_free (ego);
916 _ ("Failed to parse ego information in `%s'\n"),
917 filename);
918 return GNUNET_OK;
919 }
921 "Loaded ego `%s'\n",
922 fn + 1);
923 ego->identifier = GNUNET_strdup (fn + 1);
925 return GNUNET_OK;
926}
927
928
936static void
937run (void *cls,
938 const struct GNUNET_CONFIGURATION_Handle *c,
940{
941 cfg = c;
944 "identity",
945 "EGODIR",
947 {
950 return;
951 }
952 if (GNUNET_OK !=
954 "identity",
955 "SUBSYSTEM_CFG",
957 {
959 "identity",
960 "SUBSYSTEM_CFG");
962 return;
963 }
965 "Loading subsystem configuration `%s'\n",
968 ;
970 (GNUNET_OK !=
972 {
974 _ (
975 "Failed to parse subsystem identity configuration file `%s'\n"),
978 return;
979 }
980 stats = GNUNET_STATISTICS_create ("identity", cfg);
982 {
984 _ ("Failed to create directory `%s' for storing egos\n"),
986 }
989 NULL);
991}
992
993
999 "identity",
1001 &run,
1004 NULL,
1005 GNUNET_MQ_hd_fixed_size (start_message,
1007 struct GNUNET_MessageHeader,
1008 NULL),
1009 GNUNET_MQ_hd_var_size (lookup_message,
1011 struct LookupMessage,
1012 NULL),
1013 GNUNET_MQ_hd_var_size (lookup_by_suffix_message,
1015 struct LookupMessage,
1016 NULL),
1019 struct CreateRequestMessage,
1020 NULL),
1021 GNUNET_MQ_hd_var_size (rename_message,
1023 struct RenameMessage,
1024 NULL),
1025 GNUNET_MQ_hd_var_size (delete_message,
1027 struct DeleteMessage,
1028 NULL),
1030
1031
1032/* end of gnunet-service-identity.c */
struct GNUNET_MessageHeader * msg
Definition 005.c:2
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static char * filename
struct GNUNET_SCHEDULER_Task * shutdown_task
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.
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 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:533
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:750
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition disk.c:547
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition disk.c:839
@ 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_write_blindable_sk_to_buffer(const struct GNUNET_CRYPTO_BlindablePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePrivateKey to a compact buffer.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePrivateKey from a compact buffer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
ssize_t GNUNET_CRYPTO_blindable_sk_get_length(const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePrivateKey.
Definition crypto_pkey.c:64
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.
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.
#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
#define GNUNET_SERVICE_MAIN(pd, service_name, service_options, init_cb, connect_cb, disconnect_cb, cls,...)
Creates the "main" function for a GNUnet service.
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the 'monitor' flag on this client.
Definition service.c:2527
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition service.c:2462
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:2450
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition service.c:2544
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition service.c:2433
@ 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).
char * GNUNET_STRINGS_utf8_tolower(const char *input)
Convert the utf-8 input string to lower case.
Definition strings.c:475
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
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
Client requests creation of an identity.
Definition identity.h:149
uint16_t key_len
Key length.
Definition identity.h:163
Client requests deletion of an identity.
Definition identity.h:202
Information we keep about each ego.
struct Ego * prev
We keep egos in a DLL.
struct GNUNET_CRYPTO_BlindablePrivateKey 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:176
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition identity.h:185
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition identity.h:79
uint32_t result_code
Status code for the last operation, in NBO.
Definition identity.h:89
Service informs client about status of a pseudonym.
Definition identity.h:112
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition identity.h:127
uint16_t key_len
Key length.
Definition identity.h:132
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:122
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.
Definition identity.h:116
const char * str
Definition time.c:1252