GNUnet  0.11.x
Data Structures | Functions | Variables
gnunet-service-identity.c File Reference

identity management service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_constants.h"
#include "gnunet_protocols.h"
#include "gnunet_statistics_service.h"
#include "gnunet_identity_service.h"
#include "identity.h"
Include dependency graph for gnunet-service-identity.c:

Go to the source code of this file.

Data Structures

struct  Ego
 Information we keep about each ego. More...
 
struct  RenameContext
 Closure for 'handle_ego_rename'. More...
 

Functions

static char * get_ego_filename (struct Ego *ego)
 Get the name of the file we use to store a given ego. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Called whenever a client is disconnected. More...
 
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. More...
 
static void shutdown_task (void *cls)
 Task run during shutdown. More...
 
static void send_result_code (struct GNUNET_SERVICE_Client *client, uint32_t result_code, const char *emsg)
 Send a result code back to the client. More...
 
static struct GNUNET_MQ_Envelopecreate_update_message (struct Ego *ego)
 Create an update message with information about the current state of an ego. More...
 
static struct GNUNET_MQ_Envelopecreate_set_default_message (struct Ego *ego, const char *servicename)
 Create a set default message with information about the current state of an ego. More...
 
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 immediately and adds the client to the notification context for future updates. More...
 
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 immediately. More...
 
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 immediately. More...
 
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 immediately. More...
 
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 immediately. More...
 
static int check_get_default_message (void *cls, const struct GetDefaultMessage *msg)
 Checks a GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message. More...
 
static void handle_get_default_message (void *cls, const struct GetDefaultMessage *gdm)
 Handler for GET_DEFAULT message from client, returns default identity for some service. More...
 
static int key_cmp (const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk1, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk2)
 Compare the given two private keys for equality. More...
 
static int check_set_default_message (void *cls, const struct SetDefaultMessage *msg)
 Checks a GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT message. More...
 
static void handle_set_default_message (void *cls, const struct SetDefaultMessage *sdm)
 Handler for SET_DEFAULT message from client, updates default identity for some service. More...
 
static void notify_listeners (struct Ego *ego)
 Send an updated message for the given ego to all listeners. More...
 
static int check_create_message (void *cls, const struct CreateRequestMessage *msg)
 Checks a GNUNET_MESSAGE_TYPE_IDENTITY_CREATE message. More...
 
static void handle_create_message (void *cls, const struct CreateRequestMessage *crm)
 Handler for CREATE message from client, creates new identity. More...
 
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. More...
 
static int check_rename_message (void *cls, const struct RenameMessage *msg)
 Checks a GNUNET_MESSAGE_TYPE_IDENTITY_RENAME message. More...
 
static void handle_rename_message (void *cls, const struct RenameMessage *rm)
 Handler for RENAME message from client, creates new identity. More...
 
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. More...
 
static int check_delete_message (void *cls, const struct DeleteMessage *msg)
 Checks a GNUNET_MESSAGE_TYPE_IDENTITY_DELETE message. More...
 
static void handle_delete_message (void *cls, const struct DeleteMessage *dm)
 Handler for DELETE message from client, creates new identity. More...
 
static int process_ego_file (void *cls, const char *filename)
 Process the given file from the "EGODIR". More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *c, struct GNUNET_SERVICE_Handle *service)
 Handle network size estimate clients. More...
 
 GNUNET_SERVICE_MAIN ("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(get_default_message, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, struct GetDefaultMessage, NULL), GNUNET_MQ_hd_var_size(set_default_message, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, struct SetDefaultMessage, 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. More...
 

Variables

static const struct GNUNET_CONFIGURATION_Handlecfg
 Handle to our current configuration. More...
 
static struct GNUNET_CONFIGURATION_Handlesubsystem_cfg
 Handle to subsystem configuration which for each subsystem contains the name of the default ego. More...
 
static struct GNUNET_STATISTICS_Handlestats
 Handle to the statistics service. More...
 
static struct GNUNET_NotificationContextnc
 Notification context, simplifies client broadcasts. More...
 
static char * ego_directory
 Directory where we store the identities. More...
 
static char * subsystem_cfg_file
 Configuration file name where subsystem information is kept. More...
 
static struct Egoego_head
 Head of DLL of all egos. More...
 
static struct Egoego_tail
 Tail of DLL of all egos. More...
 

Detailed Description

identity management service

Author
Christian Grothoff

The purpose of this service is to manage private keys that represent the various egos/pseudonyms/identities of a GNUnet user.

Todo:

Definition in file gnunet-service-identity.c.

Function Documentation

◆ get_ego_filename()

static char* get_ego_filename ( struct Ego ego)
static

Get the name of the file we use to store a given ego.

Parameters
egoego for which we need the filename
Returns
full filename for the given ego

Definition at line 118 of file gnunet-service-identity.c.

References DIR_SEPARATOR_STR, ego_directory, filename, GNUNET_asprintf(), and Ego::identifier.

Referenced by handle_create_message(), handle_delete_message(), and handle_rename_message().

119 {
120  char *filename;
121 
122  GNUNET_asprintf (&filename,
123  "%s%s%s",
126  ego->identifier);
127  return filename;
128 }
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define DIR_SEPARATOR_STR
Definition: platform.h:168
static char * filename
char * identifier
String identifier for the ego.
static char * ego_directory
Directory where we store the identities.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Called whenever a client is disconnected.

Parameters
clsclosure
clientidentification of the client
app_ctxclient

Definition at line 139 of file gnunet-service-identity.c.

References GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.

Referenced by run().

142 {
143  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
144 }
#define GNUNET_log(kind,...)
Here is the caller graph for this function:

◆ client_connect_cb()

static void* client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Add a client to our list of active clients.

Parameters
clsNULL
clientclient to add
mqmessage queue for client
Returns
internal namestore client structure for this client

Definition at line 156 of file gnunet-service-identity.c.

Referenced by run().

159 {
160  return client;
161 }
Here is the caller graph for this function:

◆ shutdown_task()

static void shutdown_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 170 of file gnunet-service-identity.c.

References e, ego_directory, GNUNET_CONFIGURATION_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NO, GNUNET_notification_context_destroy(), GNUNET_STATISTICS_destroy(), Ego::identifier, Ego::pk, and subsystem_cfg_file.

Referenced by run().

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  GNUNET_free (e->pk);
194  GNUNET_free (e->identifier);
195  GNUNET_free (e);
196  }
197 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct Experiment * e
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key of the ego.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
char * identifier
String identifier for the ego.
static struct GNUNET_NotificationContext * nc
Notification context, simplifies client broadcasts.
static struct Ego * ego_head
Head of DLL of all egos.
static char * subsystem_cfg_file
Configuration file name where subsystem information is kept.
Information we keep about each ego.
static char * ego_directory
Directory where we store the identities.
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
Definition: nc.c:137
static struct Ego * ego_tail
Tail 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...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_result_code()

static void send_result_code ( struct GNUNET_SERVICE_Client client,
uint32_t  result_code,
const char *  emsg 
)
static

Send a result code back to the client.

Parameters
clientclient that should receive the result code
result_codecode to transmit
emsgerror message to include (or NULL for none)

Definition at line 208 of file gnunet-service-identity.c.

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_SERVICE_client_get_mq(), and ResultCodeMessage::result_code.

Referenced by handle_create_message(), handle_delete_message(), handle_get_default_message(), handle_lookup_by_suffix_message(), handle_lookup_message(), handle_rename_message(), and handle_set_default_message().

211 {
212  struct ResultCodeMessage *rcm;
213  struct GNUNET_MQ_Envelope *env;
214  size_t elen;
215 
216  if (NULL == emsg)
217  elen = 0;
218  else
219  elen = strlen (emsg) + 1;
220  env =
222  rcm->result_code = htonl (result_code);
223  if (0 < elen)
224  GNUNET_memcpy (&rcm[1], emsg, elen);
226  "Sending result %d (%s) to client\n",
227  (int) result_code,
228  emsg);
230 }
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#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:52
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t result_code
Status code for the last operation, in NBO.
Definition: identity.h:53
#define GNUNET_log(kind,...)
#define GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE
Generic response from identity service with success and/or error message.
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:353
Answer from service to client about last operation; GET_DEFAULT maybe answered with this message on f...
Definition: identity.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_update_message()

static struct GNUNET_MQ_Envelope* create_update_message ( struct Ego ego)
static

Create an update message with information about the current state of an ego.

Parameters
egoego to create message for
Returns
corresponding update message

Definition at line 240 of file gnunet-service-identity.c.

References UpdateMessage::end_of_list, env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_msg_extra, GNUNET_NO, Ego::identifier, UpdateMessage::name_len, Ego::pk, and UpdateMessage::private_key.

Referenced by handle_lookup_by_suffix_message(), handle_lookup_message(), and handle_start_message().

241 {
242  struct UpdateMessage *um;
243  struct GNUNET_MQ_Envelope *env;
244  size_t name_len;
245 
246  name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
248  um->name_len = htons (name_len);
249  um->end_of_list = htons (GNUNET_NO);
250  um->private_key = *ego->pk;
251  GNUNET_memcpy (&um[1], ego->identifier, name_len);
252  return env;
253 }
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:98
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key of the ego.
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
#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:52
char * identifier
String identifier for the ego.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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:88
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition: identity.h:93
Service informs client about status of a pseudonym.
Definition: identity.h:77
Here is the caller graph for this function:

◆ create_set_default_message()

static struct GNUNET_MQ_Envelope* create_set_default_message ( struct Ego ego,
const char *  servicename 
)
static

Create a set default message with information about the current state of an ego.

Parameters
egoego to create message for
servicenamename of the service to provide in the message
Returns
corresponding set default message

Definition at line 264 of file gnunet-service-identity.c.

References env, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, GNUNET_MQ_msg_extra, SetDefaultMessage::name_len, Ego::pk, SetDefaultMessage::private_key, and SetDefaultMessage::reserved.

Referenced by handle_get_default_message().

265 {
266  struct SetDefaultMessage *sdm;
267  struct GNUNET_MQ_Envelope *env;
268  size_t name_len;
269 
270  name_len = (NULL == servicename) ? 0 : (strlen (servicename) + 1);
271  env = GNUNET_MQ_msg_extra (sdm,
272  name_len,
274  sdm->name_len = htons (name_len);
275  sdm->reserved = htons (0);
276  sdm->private_key = *ego->pk;
277  GNUNET_memcpy (&sdm[1], servicename, name_len);
278  return env;
279 }
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:154
#define GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT
Client sets default identity; or service informs about default identity.
Used from service to client as a result to the GET_DEFAULT message, used from client to service to SE...
Definition: identity.h:134
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:144
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key of the ego.
uint16_t reserved
Always zero.
Definition: identity.h:149
#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:52
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Here is the caller graph for this function:

◆ handle_start_message()

static void handle_start_message ( void *  cls,
const struct GNUNET_MessageHeader message 
)
static

Handler for START message from client, sends information about all identities to the client immediately and adds the client to the notification context for future updates.

Parameters
clsa struct GNUNET_SERVICE_Client *
messagethe message received

Definition at line 292 of file gnunet-service-identity.c.

References create_update_message(), UpdateMessage::end_of_list, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_notification_context_add(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_disable_continue_warning(), GNUNET_SERVICE_client_get_mq(), GNUNET_SERVICE_client_mark_monitor(), GNUNET_YES, UpdateMessage::name_len, and Ego::next.

293 {
294  struct GNUNET_SERVICE_Client *client = cls;
295  struct UpdateMessage *ume;
296  struct GNUNET_MQ_Envelope *env;
297  struct Ego *ego;
298 
299  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received START message from client\n");
303  for (ego = ego_head; NULL != ego; ego = ego->next)
304  {
305  env = create_update_message (ego);
307  }
309  ume->end_of_list = htons (GNUNET_YES);
310  ume->name_len = htons (0);
313 }
struct Ego * next
We keep egos in a DLL.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
void GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
Definition: nc.c:160
Handle to a client that is connected to a service.
Definition: service.c:250
#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:52
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the &#39;monitor&#39; flag on this client.
Definition: service.c:2407
static struct GNUNET_NotificationContext * nc
Notification context, simplifies client broadcasts.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct Ego * ego_head
Head of DLL of all egos.
Information we keep about each ego.
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:88
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition: identity.h:93
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
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:353
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:2267
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
static struct GNUNET_MQ_Envelope * create_update_message(struct Ego *ego)
Create an update message with information about the current state of an ego.
Service informs client about status of a pseudonym.
Definition: identity.h:77
Here is the call graph for this function:

◆ check_lookup_message()

static int check_lookup_message ( void *  cls,
const struct LookupMessage message 
)
static

Handler for LOOKUP message from client, sends information about ONE identity to the client immediately.

Parameters
clsunused
messagethe message received
Returns
GNUNET_SYSERR if message was ill-formed

Definition at line 325 of file gnunet-service-identity.c.

References GNUNET_MQ_check_zero_termination, and GNUNET_OK.

326 {
328  return GNUNET_OK;
329 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_lookup_message()

static void handle_lookup_message ( void *  cls,
const struct LookupMessage message 
)
static

Handler for LOOKUP message from client, sends information about ONE identity to the client immediately.

Parameters
clsa struct GNUNET_SERVICE_Client *
messagethe message received

Definition at line 340 of file gnunet-service-identity.c.

References create_update_message(), env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), Ego::identifier, name, Ego::next, and send_result_code().

341 {
342  struct GNUNET_SERVICE_Client *client = cls;
343  const char *name;
344  struct GNUNET_MQ_Envelope *env;
345  struct Ego *ego;
346 
347  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received LOOKUP message from client\n");
348  name = (const char *) &message[1];
349  for (ego = ego_head; NULL != ego; ego = ego->next)
350  {
351  if (0 != strcasecmp (name, ego->identifier))
352  continue;
353  env = create_update_message (ego);
356  return;
357  }
358  send_result_code (client, 0, "ego not found");
360 }
struct Ego * next
We keep egos in a DLL.
static void send_result_code(struct GNUNET_SERVICE_Client *client, uint32_t result_code, const char *emsg)
Send a result code back to the client.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
Handle to a client that is connected to a service.
Definition: service.c:250
char * identifier
String identifier for the ego.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct Ego * ego_head
Head of DLL of all egos.
Information we keep about each ego.
const char * name
#define GNUNET_log(kind,...)
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:353
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
static struct GNUNET_MQ_Envelope * create_update_message(struct Ego *ego)
Create an update message with information about the current state of an ego.
Here is the call graph for this function:

◆ check_lookup_by_suffix_message()

static int check_lookup_by_suffix_message ( void *  cls,
const struct LookupMessage message 
)
static

Handler for LOOKUP message from client, sends information about ONE identity to the client immediately.

Parameters
clsunused
messagethe message received
Returns
GNUNET_SYSERR if message was ill-formed

Definition at line 372 of file gnunet-service-identity.c.

References GNUNET_MQ_check_zero_termination, and GNUNET_OK.

373 {
375  return GNUNET_OK;
376 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...

◆ handle_lookup_by_suffix_message()

static void handle_lookup_by_suffix_message ( void *  cls,
const struct LookupMessage message 
)
static

Handler for LOOKUP_BY_SUFFIX message from client, sends information about ONE identity to the client immediately.

Parameters
clsa struct GNUNET_SERVICE_Client *
messagethe message received

Definition at line 387 of file gnunet-service-identity.c.

References create_update_message(), env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), Ego::identifier, name, Ego::next, and send_result_code().

388 {
389  struct GNUNET_SERVICE_Client *client = cls;
390  const char *name;
391  struct GNUNET_MQ_Envelope *env;
392  struct Ego *lprefix;
393 
395  "Received LOOKUP_BY_SUFFIX message from client\n");
396  name = (const char *) &message[1];
397  lprefix = NULL;
398  for (struct Ego *ego = ego_head; NULL != ego; ego = ego->next)
399  {
400  if ((strlen (ego->identifier) <= strlen (name)) &&
401  (0 == strcmp (ego->identifier,
402  &name[strlen (name) - strlen (ego->identifier)])) &&
403  ((strlen (name) == strlen (ego->identifier)) ||
404  ('.' == name[strlen (name) - strlen (ego->identifier) - 1])) &&
405  ((NULL == lprefix) ||
406  (strlen (ego->identifier) > strlen (lprefix->identifier))))
407  {
408  /* found better match, update! */
409  lprefix = ego;
410  }
411  }
412  if (NULL != lprefix)
413  {
414  env = create_update_message (lprefix);
417  return;
418  }
419  send_result_code (client, 0, "ego not found");
421 }
struct Ego * next
We keep egos in a DLL.
static void send_result_code(struct GNUNET_SERVICE_Client *client, uint32_t result_code, const char *emsg)
Send a result code back to the client.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
Handle to a client that is connected to a service.
Definition: service.c:250
char * identifier
String identifier for the ego.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct Ego * ego_head
Head of DLL of all egos.
Information we keep about each ego.
const char * name
#define GNUNET_log(kind,...)
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:353
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
static struct GNUNET_MQ_Envelope * create_update_message(struct Ego *ego)
Create an update message with information about the current state of an ego.
Here is the call graph for this function:

◆ check_get_default_message()

static int check_get_default_message ( void *  cls,
const struct GetDefaultMessage msg 
)
static

Checks a GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message.

Parameters
clsclient sending the message
msgmessage of type struct GetDefaultMessage
Returns
GNUNET_OK if msg is well-formed

Definition at line 432 of file gnunet-service-identity.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GetDefaultMessage::header, name, GetDefaultMessage::name_len, GetDefaultMessage::reserved, size, and GNUNET_MessageHeader::size.

433 {
434  uint16_t size;
435  uint16_t name_len;
436  const char *name;
437 
438  size = ntohs (msg->header.size);
439  if (size <= sizeof(struct GetDefaultMessage))
440  {
441  GNUNET_break (0);
442  return GNUNET_SYSERR;
443  }
444  name = (const char *) &msg[1];
445  name_len = ntohs (msg->name_len);
446  if ((name_len + sizeof(struct GetDefaultMessage) != size) ||
447  (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
448  {
449  GNUNET_break (0);
450  return GNUNET_SYSERR;
451  }
452  return GNUNET_OK;
453 }
uint16_t reserved
Always zero.
Definition: identity.h:123
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:118
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT.
Definition: identity.h:113
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
const char * name
Client requests knowledge about default identity for a subsystem from identity service.
Definition: identity.h:108

◆ handle_get_default_message()

static void handle_get_default_message ( void *  cls,
const struct GetDefaultMessage gdm 
)
static

Handler for GET_DEFAULT message from client, returns default identity for some service.

Parameters
clsunused
clientwho sent the message
messagethe message received

Definition at line 465 of file gnunet-service-identity.c.

References create_set_default_message(), env, gettext_noop, GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_get_mq(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), Ego::identifier, name, Ego::next, and send_result_code().

466 {
467  struct GNUNET_MQ_Envelope *env;
468  struct GNUNET_SERVICE_Client *client = cls;
469  struct Ego *ego;
470  char *name;
471  char *identifier;
472 
473 
474  name = GNUNET_strdup ((const char *) &gdm[1]);
475  GNUNET_STRINGS_utf8_tolower ((const char *) &gdm[1], name);
477  "Received GET_DEFAULT for service `%s' from client\n",
478  name);
480  name,
481  "DEFAULT_IDENTIFIER",
482  &identifier))
483  {
484  send_result_code (client, 1, gettext_noop ("no default known"));
486  GNUNET_free (name);
487  return;
488  }
489  for (ego = ego_head; NULL != ego; ego = ego->next)
490  {
491  if (0 == strcmp (ego->identifier, identifier))
492  {
493  env = create_set_default_message (ego, name);
496  GNUNET_free (identifier);
497  GNUNET_free (name);
498  return;
499  }
500  }
501  GNUNET_free (identifier);
502  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to find ego `%s'\n", name);
503  GNUNET_free (name);
504  send_result_code (client,
505  1,
506  gettext_noop (
507  "default configured, but ego unknown (internal error)"));
509 }
struct Ego * next
We keep egos in a DLL.
static void send_result_code(struct GNUNET_SERVICE_Client *client, uint32_t result_code, const char *emsg)
Send a result code back to the client.
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2437
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Handle to a client that is connected to a service.
Definition: service.c:250
static struct GNUNET_MQ_Envelope * create_set_default_message(struct Ego *ego, const char *servicename)
Create a set default message with information about the current state of an ego.
char * identifier
String identifier for the ego.
int 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.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct Ego * ego_head
Head of DLL of all egos.
Information we keep about each ego.
const char * name
#define GNUNET_log(kind,...)
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:353
static struct GNUNET_CONFIGURATION_Handle * subsystem_cfg
Handle to subsystem configuration which for each subsystem contains the name of the default ego...
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:553
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ key_cmp()

static int key_cmp ( const struct GNUNET_CRYPTO_EcdsaPrivateKey pk1,
const struct GNUNET_CRYPTO_EcdsaPrivateKey pk2 
)
static

Compare the given two private keys for equality.

Parameters
pk1one private key
pk2another private key
Returns
0 if the keys are equal

Definition at line 520 of file gnunet-service-identity.c.

References GNUNET_memcmp.

Referenced by handle_set_default_message().

522 {
523  return GNUNET_memcmp (pk1, pk2);
524 }
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
Here is the caller graph for this function:

◆ check_set_default_message()

static int check_set_default_message ( void *  cls,
const struct SetDefaultMessage msg 
)
static

Checks a GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT message.

Parameters
clsclient sending the message
msgmessage of type struct SetDefaultMessage
Returns
GNUNET_OK if msg is well-formed

Definition at line 535 of file gnunet-service-identity.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, SetDefaultMessage::header, SetDefaultMessage::name_len, SetDefaultMessage::reserved, size, and GNUNET_MessageHeader::size.

536 {
537  uint16_t size;
538  uint16_t name_len;
539  const char *str;
540 
541  size = ntohs (msg->header.size);
542  if (size <= sizeof(struct SetDefaultMessage))
543  {
544  GNUNET_break (0);
545  return GNUNET_SYSERR;
546  }
547  name_len = ntohs (msg->name_len);
548  GNUNET_break (0 == ntohs (msg->reserved));
549  if (name_len + sizeof(struct SetDefaultMessage) != size)
550  {
551  GNUNET_break (0);
552  return GNUNET_SYSERR;
553  }
554  str = (const char *) &msg[1];
555  if ('\0' != str[name_len - 1])
556  {
557  GNUNET_break (0);
558  return GNUNET_SYSERR;
559  }
560  return GNUNET_OK;
561 }
Used from service to client as a result to the GET_DEFAULT message, used from client to service to SE...
Definition: identity.h:134
uint16_t name_len
Number of bytes in service name string including 0-termination, in NBO.
Definition: identity.h:144
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint16_t reserved
Always zero.
Definition: identity.h:149
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT.
Definition: identity.h:139

◆ handle_set_default_message()

static void handle_set_default_message ( void *  cls,
const struct SetDefaultMessage sdm 
)
static

Handler for SET_DEFAULT message from client, updates default identity for some service.

Parameters
clsunused
clientwho sent the message
messagethe message received

Definition at line 573 of file gnunet-service-identity.c.

References _, GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), Ego::identifier, key_cmp(), Ego::next, Ego::pk, send_result_code(), and subsystem_cfg_file.

574 {
575  struct Ego *ego;
576  struct GNUNET_SERVICE_Client *client = cls;
577  char *str;
578 
579  str = GNUNET_strdup ((const char *) &sdm[1]);
580  GNUNET_STRINGS_utf8_tolower ((const char *) &sdm[1], str);
581 
583  "Received SET_DEFAULT for service `%s' from client\n",
584  str);
585  for (ego = ego_head; NULL != ego; ego = ego->next)
586  {
587  if (0 == key_cmp (ego->pk, &sdm->private_key))
588  {
590  str,
591  "DEFAULT_IDENTIFIER",
592  ego->identifier);
593  if (GNUNET_OK !=
595  GNUNET_log (
597  _ ("Failed to write subsystem default identifier map to `%s'.\n"),
599  send_result_code (client, 0, NULL);
601  GNUNET_free (str);
602  return;
603  }
604  }
605  send_result_code (client,
606  1,
607  _ ("Unknown ego specified for service (internal error)"));
608  GNUNET_free (str);
610 }
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:154
struct Ego * next
We keep egos in a DLL.
int GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
static void send_result_code(struct GNUNET_SERVICE_Client *client, uint32_t result_code, const char *emsg)
Send a result code back to the client.
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key of the ego.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Handle to a client that is connected to a service.
Definition: service.c:250
char * identifier
String identifier for the ego.
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.
static struct Ego * ego_head
Head of DLL of all egos.
static char * subsystem_cfg_file
Configuration file name where subsystem information is kept.
Information we keep about each ego.
static int key_cmp(const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk1, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk2)
Compare the given two private keys for equality.
#define GNUNET_log(kind,...)
static struct GNUNET_CONFIGURATION_Handle * subsystem_cfg
Handle to subsystem configuration which for each subsystem contains the name of the default ego...
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:553
Here is the call graph for this function:

◆ notify_listeners()

static void notify_listeners ( struct Ego ego)
static

Send an updated message for the given ego to all listeners.

Parameters
egoego to send the update for

Definition at line 619 of file gnunet-service-identity.c.

References UpdateMessage::end_of_list, GNUNET_free, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE, GNUNET_NO, GNUNET_notification_context_broadcast(), UpdateMessage::header, Ego::identifier, UpdateMessage::name_len, Ego::pk, UpdateMessage::private_key, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.

Referenced by handle_create_message(), handle_delete_message(), and handle_rename_message().

620 {
621  struct UpdateMessage *um;
622  size_t name_len;
623 
624  name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
625  um = GNUNET_malloc (sizeof(struct UpdateMessage) + name_len);
627  um->header.size = htons (sizeof(struct UpdateMessage) + name_len);
628  um->name_len = htons (name_len);
629  um->end_of_list = htons (GNUNET_NO);
630  um->private_key = *ego->pk;
631  GNUNET_memcpy (&um[1], ego->identifier, name_len);
633  GNUNET_free (um);
634 }
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE.
Definition: identity.h:82
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:98
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key of the ego.
#define GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE
Update about identity status from service to clients.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
char * identifier
String identifier for the ego.
static struct GNUNET_NotificationContext * nc
Notification context, simplifies client broadcasts.
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:88
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:189
uint16_t end_of_list
Usually GNUNET_NO, GNUNET_YES to signal end of list.
Definition: identity.h:93
#define GNUNET_malloc(size)
Wrapper around malloc.
Service informs client about status of a pseudonym.
Definition: identity.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_create_message()

static int check_create_message ( void *  cls,
const struct CreateRequestMessage msg 
)
static

Checks a GNUNET_MESSAGE_TYPE_IDENTITY_CREATE message.

Parameters
clsclient sending the message
msgmessage of type struct CreateRequestMessage
Returns
GNUNET_OK if msg is well-formed

Definition at line 645 of file gnunet-service-identity.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, CreateRequestMessage::header, UpdateMessage::name_len, CreateRequestMessage::name_len, CreateRequestMessage::reserved, size, and GNUNET_MessageHeader::size.

646 {
647  uint16_t size;
648  uint16_t name_len;
649  const char *str;
650 
651  size = ntohs (msg->header.size);
652  if (size <= sizeof(struct CreateRequestMessage))
653  {
654  GNUNET_break (0);
655  return GNUNET_SYSERR;
656  }
657  name_len = ntohs (msg->name_len);
658  GNUNET_break (0 == ntohs (msg->reserved));
659  if (name_len + sizeof(struct CreateRequestMessage) != size)
660  {
661  GNUNET_break (0);
662  return GNUNET_SYSERR;
663  }
664  str = (const char *) &msg[1];
665  if ('\0' != str[name_len - 1])
666  {
667  GNUNET_break (0);
668  return GNUNET_SYSERR;
669  }
670  return GNUNET_OK;
671 }
uint16_t reserved
Always zero.
Definition: identity.h:179
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_CREATE.
Definition: identity.h:169
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t name_len
Number of bytes in identity name string including 0-termination, in NBO.
Definition: identity.h:174
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Client requests creation of an identity.
Definition: identity.h:164
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
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:88

◆ handle_create_message()

static void handle_create_message ( void *  cls,
const struct CreateRequestMessage crm 
)
static

Handler for CREATE message from client, creates new identity.

Parameters
clsunused
clientwho sent the message
messagethe message received

Definition at line 683 of file gnunet-service-identity.c.

References fn, get_ego_filename(), gettext_noop, GNUNET_CONTAINER_DLL_insert, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_fn_write(), GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), Ego::identifier, Ego::next, notify_listeners(), Ego::pk, and send_result_code().

684 {
685  struct GNUNET_SERVICE_Client *client = cls;
686  struct Ego *ego;
687  char *str;
688  char *fn;
689 
690  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received CREATE message from client\n");
691  str = GNUNET_strdup ((const char *) &crm[1]);
692  GNUNET_STRINGS_utf8_tolower ((const char *) &crm[1], str);
693  for (ego = ego_head; NULL != ego; ego = ego->next)
694  {
695  if (0 == strcmp (ego->identifier, str))
696  {
697  send_result_code (client,
698  1,
699  gettext_noop (
700  "identifier already in use for another ego"));
702  GNUNET_free (str);
703  return;
704  }
705  }
706  ego = GNUNET_new (struct Ego);
708  *ego->pk = crm->private_key;
709  ego->identifier = GNUNET_strdup (str);
711  send_result_code (client, 0, NULL);
712  fn = get_ego_filename (ego);
714  if (sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey) !=
716  &crm->private_key,
717  sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey),
721  GNUNET_free (fn);
722  GNUNET_free (str);
723  notify_listeners (ego);
725 }
struct Ego * next
We keep egos in a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static char * get_ego_filename(struct Ego *ego)
Get the name of the file we use to store a given ego.
static void send_result_code(struct GNUNET_SERVICE_Client *client, uint32_t result_code, const char *emsg)
Send a result code back to the client.
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:684
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key of the ego.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Private ECC key encoded for transmission.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
ssize_t GNUNET_DISK_fn_write(const char *fn, const void *buffer, size_t n, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file.
Definition: disk.c:880
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key
The private key.
Definition: identity.h:184
Handle to a client that is connected to a service.
Definition: service.c:250
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
char * identifier
String identifier for the ego.
static struct Ego * ego_head
Head of DLL of all egos.
Information we keep about each ego.
static void notify_listeners(struct Ego *ego)
Send an updated message for the given ego to all listeners.
#define GNUNET_log(kind,...)
static struct Ego * ego_tail
Tail of DLL of all egos.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:553
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ handle_ego_rename()

static void handle_ego_rename ( void *  cls,
const char *  section 
)
static

An ego was renamed; rename it in all subsystems where it is currently set as the default.

Parameters
clsthe 'struct RenameContext'
sectiona section in the configuration to process

Definition at line 752 of file gnunet-service-identity.c.

References GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, id, RenameContext::new_name, and RenameContext::old_name.

Referenced by handle_rename_message().

753 {
754  struct RenameContext *rc = cls;
755  char *id;
756 
758  section,
759  "DEFAULT_IDENTIFIER",
760  &id))
761  return;
762  if (0 != strcmp (id, rc->old_name))
763  {
764  GNUNET_free (id);
765  return;
766  }
768  section,
769  "DEFAULT_IDENTIFIER",
770  rc->new_name);
771  GNUNET_free (id);
772 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Closure for &#39;handle_ego_rename&#39;.
static char * section
Name of the section.
Definition: gnunet-config.c:33
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.
int 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.
const char * new_name
New name.
const char * old_name
Old name.
static struct GNUNET_CONFIGURATION_Handle * subsystem_cfg
Handle to subsystem configuration which for each subsystem contains the name of the default ego...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_rename_message()

static int check_rename_message ( void *  cls,
const struct RenameMessage msg 
)
static

Checks a GNUNET_MESSAGE_TYPE_IDENTITY_RENAME message.

Parameters
clsclient sending the message
msgmessage of type struct RenameMessage
Returns
GNUNET_OK if msg is well-formed

Definition at line 783 of file gnunet-service-identity.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, RenameMessage::header, RenameContext::new_name, RenameMessage::new_name_len, RenameContext::old_name, RenameMessage::old_name_len, size, and GNUNET_MessageHeader::size.

784 {
785  uint16_t size;
786  uint16_t old_name_len;
787  uint16_t new_name_len;
788  const char *old_name;
789  const char *new_name;
790 
791  size = ntohs (msg->header.size);
792  if (size <= sizeof(struct RenameMessage))
793  {
794  GNUNET_break (0);
795  return GNUNET_SYSERR;
796  }
797  old_name_len = ntohs (msg->old_name_len);
798  new_name_len = ntohs (msg->new_name_len);
799  old_name = (const char *) &msg[1];
800  new_name = &old_name[old_name_len];
801  if ((old_name_len + new_name_len + sizeof(struct RenameMessage) != size) ||
802  ('\0' != old_name[old_name_len - 1]) ||
803  ('\0' != new_name[new_name_len - 1]))
804  {
805  GNUNET_break (0);
806  return GNUNET_SYSERR;
807  }
808 
809  return GNUNET_OK;
810 }
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:204
Client requests renaming of an identity.
Definition: identity.h:194
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
const char * new_name
New name.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
uint16_t new_name_len
Number of characters in the new name including 0-termination, in NBO.
Definition: identity.h:209
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_RENAME.
Definition: identity.h:199
const char * old_name
Old name.

◆ handle_rename_message()

static void handle_rename_message ( void *  cls,
const struct RenameMessage rm 
)
static

Handler for RENAME message from client, creates new identity.

Parameters
clsunused
clientwho sent the message
messagethe message received

Definition at line 822 of file gnunet-service-identity.c.

References _, get_ego_filename(), gettext_noop, GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), handle_ego_rename(), Ego::identifier, RenameContext::new_name, Ego::next, notify_listeners(), RenameContext::old_name, RenameMessage::old_name_len, send_result_code(), and subsystem_cfg_file.

823 {
824  uint16_t old_name_len;
825  struct Ego *ego;
826  char *old_name;
827  char *new_name;
828  struct RenameContext rename_ctx;
829  struct GNUNET_SERVICE_Client *client = cls;
830  char *fn_old;
831  char *fn_new;
832  const char *old_name_tmp;
833 
834  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received RENAME message from client\n");
835  old_name_len = ntohs (rm->old_name_len);
836  old_name_tmp = (const char *) &rm[1];
837  old_name = GNUNET_strdup (old_name_tmp);
838  GNUNET_STRINGS_utf8_tolower (old_name_tmp, old_name);
839  new_name = GNUNET_strdup (&old_name_tmp[old_name_len]);
840  GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len], new_name);
841 
842  /* check if new name is already in use */
843  for (ego = ego_head; NULL != ego; ego = ego->next)
844  {
845  if (0 == strcmp (ego->identifier, new_name))
846  {
847  send_result_code (client, 1, gettext_noop ("target name already exists"));
849  GNUNET_free (old_name);
850  GNUNET_free (new_name);
851  return;
852  }
853  }
854 
855  /* locate old name and, if found, perform rename */
856  for (ego = ego_head; NULL != ego; ego = ego->next)
857  {
858  if (0 == strcmp (ego->identifier, old_name))
859  {
860  fn_old = get_ego_filename (ego);
861  GNUNET_free (ego->identifier);
862  rename_ctx.old_name = old_name;
863  rename_ctx.new_name = new_name;
866  &rename_ctx);
867  if (GNUNET_OK !=
869  GNUNET_log (
871  _ ("Failed to write subsystem default identifier map to `%s'.\n"),
873  ego->identifier = GNUNET_strdup (new_name);
874  fn_new = get_ego_filename (ego);
875  if (0 != rename (fn_old, fn_new))
877  GNUNET_free (fn_old);
878  GNUNET_free (fn_new);
879  GNUNET_free (old_name);
880  GNUNET_free (new_name);
881  notify_listeners (ego);
882  send_result_code (client, 0, NULL);
884  return;
885  }
886  }
887 
888  /* failed to locate old name */
889  send_result_code (client, 1, gettext_noop ("no matching ego found"));
890  GNUNET_free (old_name);
891  GNUNET_free (new_name);
893 }
struct Ego * next
We keep egos in a DLL.
int GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
static char * get_ego_filename(struct Ego *ego)
Get the name of the file we use to store a given ego.
static void send_result_code(struct GNUNET_SERVICE_Client *client, uint32_t result_code, const char *emsg)
Send a result code back to the client.
uint16_t old_name_len
Number of characters in the old name including 0-termination, in NBO.
Definition: identity.h:204
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Closure for &#39;handle_ego_rename&#39;.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Handle to a client that is connected to a service.
Definition: service.c:250
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
char * identifier
String identifier for the ego.
static struct Ego * ego_head
Head of DLL of all egos.
static char * subsystem_cfg_file
Configuration file name where subsystem information is kept.
Information we keep about each ego.
static void notify_listeners(struct Ego *ego)
Send an updated message for the given ego to all listeners.
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Section_Iterator iter, void *iter_cls)
Iterate over all sections in the configuration.
#define GNUNET_log(kind,...)
static struct GNUNET_CONFIGURATION_Handle * subsystem_cfg
Handle to subsystem configuration which for each subsystem contains the name of the default ego...
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.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:553
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ handle_ego_delete()

static void handle_ego_delete ( void *  cls,
const char *  section 
)
static

An ego was removed, remove it from all subsystems where it is currently set as the default.

Parameters
clsname of the removed ego (const char *)
sectiona section in the configuration to process

Definition at line 904 of file gnunet-service-identity.c.

References GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_free, GNUNET_OK, id, and Ego::identifier.

Referenced by handle_delete_message().

905 {
906  const char *identifier = cls;
907  char *id;
908 
910  section,
911  "DEFAULT_IDENTIFIER",
912  &id))
913  return;
914  if (0 != strcmp (id, identifier))
915  {
916  GNUNET_free (id);
917  return;
918  }
920  section,
921  "DEFAULT_IDENTIFIER",
922  NULL);
923  GNUNET_free (id);
924 }
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * section
Name of the section.
Definition: gnunet-config.c:33
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.
int 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.
static struct GNUNET_CONFIGURATION_Handle * subsystem_cfg
Handle to subsystem configuration which for each subsystem contains the name of the default ego...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_delete_message()

static int check_delete_message ( void *  cls,
const struct DeleteMessage msg 
)
static

Checks a GNUNET_MESSAGE_TYPE_IDENTITY_DELETE message.

Parameters
clsclient sending the message
msgmessage of type struct DeleteMessage
Returns
GNUNET_OK if msg is well-formed

Definition at line 935 of file gnunet-service-identity.c.

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, DeleteMessage::header, name, DeleteMessage::name_len, DeleteMessage::reserved, size, and GNUNET_MessageHeader::size.

936 {
937  uint16_t size;
938  uint16_t name_len;
939  const char *name;
940 
941  size = ntohs (msg->header.size);
942  if (size <= sizeof(struct DeleteMessage))
943  {
944  GNUNET_break (0);
945  return GNUNET_SYSERR;
946  }
947  name = (const char *) &msg[1];
948  name_len = ntohs (msg->name_len);
949  if ((name_len + sizeof(struct DeleteMessage) != size) ||
950  (0 != ntohs (msg->reserved)) || ('\0' != name[name_len - 1]))
951  {
952  GNUNET_break (0);
953  return GNUNET_SYSERR;
954  }
955  return GNUNET_OK;
956 }
uint16_t reserved
Always zero.
Definition: identity.h:235
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_MessageHeader header
Type: GNUNET_MESSAGE_TYPE_IDENTITY_DELETE.
Definition: identity.h:225
Client requests deletion of an identity.
Definition: identity.h:220
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
const char * name
uint16_t name_len
Number of characters in the name including 0-termination, in NBO.
Definition: identity.h:230

◆ handle_delete_message()

static void handle_delete_message ( void *  cls,
const struct DeleteMessage dm 
)
static

Handler for DELETE message from client, creates new identity.

Parameters
clsunused
clientwho sent the message
messagethe message received

Definition at line 968 of file gnunet-service-identity.c.

References _, fn, get_ego_filename(), gettext_noop, GNUNET_CONFIGURATION_iterate_sections(), GNUNET_CONFIGURATION_write(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_strdup, GNUNET_STRINGS_utf8_tolower(), handle_ego_delete(), Ego::identifier, name, Ego::next, notify_listeners(), Ego::pk, send_result_code(), and subsystem_cfg_file.

969 {
970  struct Ego *ego;
971  char *name;
972  char *fn;
973  struct GNUNET_SERVICE_Client *client = cls;
974 
975  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received DELETE message from client\n");
976  name = GNUNET_strdup ((const char *) &dm[1]);
977  GNUNET_STRINGS_utf8_tolower ((const char *) &dm[1], name);
978 
979  for (ego = ego_head; NULL != ego; ego = ego->next)
980  {
981  if (0 == strcmp (ego->identifier, name))
982  {
986  ego->identifier);
987  if (GNUNET_OK !=
989  GNUNET_log (
991  _ ("Failed to write subsystem default identifier map to `%s'.\n"),
993  fn = get_ego_filename (ego);
994  if (0 != unlink (fn))
996  GNUNET_free (fn);
997  GNUNET_free (ego->identifier);
998  ego->identifier = NULL;
999  notify_listeners (ego);
1000  GNUNET_free (ego->pk);
1001  GNUNET_free (ego);
1002  GNUNET_free (name);
1003  send_result_code (client, 0, NULL);
1005  return;
1006  }
1007  }
1008 
1009  send_result_code (client, 1, gettext_noop ("no matching ego found"));
1010  GNUNET_free (name);
1012 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct Ego * next
We keep egos in a DLL.
int GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
static char * get_ego_filename(struct Ego *ego)
Get the name of the file we use to store a given ego.
static void send_result_code(struct GNUNET_SERVICE_Client *client, uint32_t result_code, const char *emsg)
Send a result code back to the client.
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key of the ego.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Handle to a client that is connected to a service.
Definition: service.c:250
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...
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
char * identifier
String identifier for the ego.
static struct Ego * ego_head
Head of DLL of all egos.
static char * subsystem_cfg_file
Configuration file name where subsystem information is kept.
Information we keep about each ego.
static void notify_listeners(struct Ego *ego)
Send an updated message for the given ego to all listeners.
const char * name
void GNUNET_CONFIGURATION_iterate_sections(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_Section_Iterator iter, void *iter_cls)
Iterate over all sections in the configuration.
#define GNUNET_log(kind,...)
static struct Ego * ego_tail
Tail 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...
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2243
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_STRINGS_utf8_tolower(const char *input, char *output)
Convert the utf-8 input string to lower case.
Definition: strings.c:553
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

◆ process_ego_file()

static int process_ego_file ( void *  cls,
const char *  filename 
)
static

Process the given file from the "EGODIR".

Parses the file and creates the respective 'struct Ego' in memory.

Parameters
clsNULL
filenamename of the file to parse
Returns
GNUNET_OK to continue to iterate, GNUNET_NO to stop iteration with no error, GNUNET_SYSERR to abort iteration with error!

Definition at line 1026 of file gnunet-service-identity.c.

References _, DIR_SEPARATOR, fn, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_ecdsa_key_create_from_file(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_strdup, Ego::identifier, and Ego::pk.

Referenced by run().

1027 {
1028  struct Ego *ego;
1029  const char *fn;
1030 
1031  fn = strrchr (filename, (int) DIR_SEPARATOR);
1032  if (NULL == fn)
1033  {
1034  GNUNET_break (0);
1035  return GNUNET_OK;
1036  }
1037  ego = GNUNET_new (struct Ego);
1039  if (NULL == ego->pk)
1040  {
1041  GNUNET_free (ego);
1043  _ ("Failed to parse ego information in `%s'\n"),
1044  filename);
1045  return GNUNET_OK;
1046  }
1047  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded ego `%s'\n", fn + 1);
1048  ego->identifier = GNUNET_strdup (fn + 1);
1050  return GNUNET_OK;
1051 }
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
struct GNUNET_CRYPTO_EcdsaPrivateKey * pk
Private key of the ego.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static char * fn
Filename of the unique file.
static char * filename
char * identifier
String identifier for the ego.
#define DIR_SEPARATOR
Definition: platform.h:167
struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_CRYPTO_ecdsa_key_create_from_file(const char *filename)
Create a new private key by reading it from a file.
static struct Ego * ego_head
Head of DLL of all egos.
Information we keep about each ego.
#define GNUNET_log(kind,...)
static struct Ego * ego_tail
Tail of DLL of all egos.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle c,
struct GNUNET_SERVICE_Handle service 
)
static

Handle network size estimate clients.

Parameters
clsclosure
serverthe initialized server
cconfiguration to use

Definition at line 1062 of file gnunet-service-identity.c.

References _, client_connect_cb(), client_disconnect_cb(), ego_directory, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_parse(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_scan(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_log_config_missing(), GNUNET_MESSAGE_TYPE_IDENTITY_CREATE, GNUNET_MESSAGE_TYPE_IDENTITY_DELETE, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX, GNUNET_MESSAGE_TYPE_IDENTITY_RENAME, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, GNUNET_MESSAGE_TYPE_IDENTITY_START, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_notification_context_create(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_STATISTICS_create(), GNUNET_YES, process_ego_file(), shutdown_task(), and subsystem_cfg_file.

1065 {
1066  cfg = c;
1069  "identity",
1070  "EGODIR",
1071  &ego_directory))
1072  {
1073  GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "identity", "EGODIR");
1075  return;
1076  }
1077  if (GNUNET_OK !=
1079  "identity",
1080  "SUBSYSTEM_CFG",
1082  {
1084  "identity",
1085  "SUBSYSTEM_CFG");
1087  return;
1088  }
1090  "Loading subsystem configuration `%s'\n",
1094  (GNUNET_OK !=
1096  {
1098  _ (
1099  "Failed to parse subsystem identity configuration file `%s'\n"),
1102  return;
1103  }
1104  stats = GNUNET_STATISTICS_create ("identity", cfg);
1106  {
1108  _ ("Failed to create directory `%s' for storing egos\n"),
1109  ego_directory);
1110  }
1113 }
int 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:544
int GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition: disk.c:589
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1300
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
int 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...
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition: disk.c:912
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static const struct GNUNET_CONFIGURATION_Handle * cfg
Handle to our current configuration.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static void shutdown_task(void *cls)
Task run during shutdown.
static struct GNUNET_NotificationContext * nc
Notification context, simplifies client broadcasts.
static char * subsystem_cfg_file
Configuration file name where subsystem information is kept.
struct GNUNET_NotificationContext * GNUNET_notification_context_create(unsigned int queue_length)
Create a new notification context.
Definition: nc.c:121
#define GNUNET_log(kind,...)
int 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.
static char * ego_directory
Directory where we store the identities.
#define GNUNET_YES
Definition: gnunet_common.h:77
static int process_ego_file(void *cls, const char *filename)
Process the given file from the "EGODIR".
static struct GNUNET_CONFIGURATION_Handle * subsystem_cfg
Handle to subsystem configuration which for each subsystem contains the name of the default ego...
Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

GNUNET_SERVICE_MAIN ( "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(get_default_message, GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, struct GetDefaultMessage, NULL)  ,
GNUNET_MQ_hd_var_size(set_default_message, GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT, struct SetDefaultMessage, 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.

Referenced by run().

Here is the caller graph for this function:

Variable Documentation

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg
static

Handle to our current configuration.

Definition at line 72 of file gnunet-service-identity.c.

◆ subsystem_cfg

struct GNUNET_CONFIGURATION_Handle* subsystem_cfg
static

Handle to subsystem configuration which for each subsystem contains the name of the default ego.

Definition at line 78 of file gnunet-service-identity.c.

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

Handle to the statistics service.

Definition at line 83 of file gnunet-service-identity.c.

◆ nc

struct GNUNET_NotificationContext* nc
static

Notification context, simplifies client broadcasts.

Definition at line 88 of file gnunet-service-identity.c.

◆ ego_directory

char* ego_directory
static

Directory where we store the identities.

Definition at line 93 of file gnunet-service-identity.c.

Referenced by get_ego_filename(), run(), and shutdown_task().

◆ subsystem_cfg_file

char* subsystem_cfg_file
static

Configuration file name where subsystem information is kept.

Definition at line 98 of file gnunet-service-identity.c.

Referenced by handle_delete_message(), handle_rename_message(), handle_set_default_message(), run(), and shutdown_task().

◆ ego_head

struct Ego* ego_head
static

Head of DLL of all egos.

Definition at line 103 of file gnunet-service-identity.c.

◆ ego_tail

struct Ego* ego_tail
static

Tail of DLL of all egos.

Definition at line 108 of file gnunet-service-identity.c.