142 "Client %p disconnected\n",
209 uint32_t result_code)
218 "Sending result %d (%s) to client\n",
248 ((
char*) &um[1]) + name_len,
270 "Received START message from client\n");
331 "Received LOOKUP message from client\n");
332 name = (
const char *) &message[1];
381 "Received LOOKUP_BY_SUFFIX message from client\n");
382 name = (
const char *) &message[1];
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))))
497 key_len = ntohs (crm->
key_len);
503 (kb_read != key_len))
522 ego->
pk = private_key;
574 "DEFAULT_IDENTIFIER",
584 "DEFAULT_IDENTIFIER",
601 uint16_t old_name_len;
602 uint16_t new_name_len;
612 old_name_len = ntohs (
msg->old_name_len);
613 new_name_len = ntohs (
msg->new_name_len);
617 (
'\0' !=
old_name[old_name_len - 1]) ||
618 (
'\0' !=
new_name[new_name_len - 1]))
638 uint16_t old_name_len;
646 const char *old_name_tmp;
650 old_name_tmp = (
const char *) &rm[1];
685 _ (
"Failed to write subsystem default identifier map to `%s'.\n"),
689 if (0 != rename (fn_old, fn_new))
720 const char *identifier = cls;
725 "DEFAULT_IDENTIFIER",
728 if (0 != strcmp (
id, identifier))
735 "DEFAULT_IDENTIFIER",
762 name_len = ntohs (
msg->name_len);
764 (0 != ntohs (
msg->reserved)) || (
'\0' !=
name[name_len - 1]))
804 _ (
"Failed to write subsystem default identifier map to `%s'.\n"),
807 if (0 != unlink (fn))
856 if (sb.st_size != buf_size)
859 "File `%s' has wrong size (%llu), expected %llu bytes\n",
861 (
unsigned long long) sb.st_size,
862 (
unsigned long long) buf_size);
919 _ (
"Failed to parse ego information in `%s'\n"),
968 "Loading subsystem configuration `%s'\n",
978 "Failed to parse subsystem identity configuration file `%s'\n"),
987 _ (
"Failed to create directory `%s' for storing egos\n"),
struct GNUNET_MQ_Handle * mq
struct GNUNET_MessageHeader * msg
struct GNUNET_MQ_Envelope * env
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).
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.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
@ 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.
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.
#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.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#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.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
#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.
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.
#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.
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.
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,...
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the 'monitor' flag on this client.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
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.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
@ 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.
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".
Client requests creation of an identity.
uint16_t key_len
Key length.
Client requests deletion of an identity.
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.
The notification context is the key datastructure for a convenience API used for transmission of noti...
Handle to a client that is connected to a service.
Message from client to GNS service to lookup records.
Closure for 'handle_ego_rename'.
const char * old_name
Old name.
const char * new_name
New name.
Client requests renaming of an identity.
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
uint32_t result_code
Status code for the last operation, in NBO.
Service informs client about status of a pseudonym.
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
uint16_t key_len
Key length.
uint16_t name_len
Number of bytes in ego name string including 0-termination, in NBO; 0 if the ego was deleted.
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.