aboutsummaryrefslogtreecommitdiff
path: root/src/identity/gnunet-service-identity.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/identity/gnunet-service-identity.c')
-rw-r--r--src/identity/gnunet-service-identity.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index a675a01f0..3e92a04cd 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -378,6 +378,73 @@ handle_lookup_message (void *cls,
378 378
379 379
380/** 380/**
381 * Handler for LOOKUP message from client, sends information
382 * about ONE identity to the client immediately.
383 *
384 * @param cls unused
385 * @param message the message received
386 * @return #GNUNET_SYSERR if message was ill-formed
387 */
388static int
389check_lookup_by_suffix_message (void *cls,
390 const struct LookupMessage *message)
391{
392 GNUNET_MQ_check_zero_termination (message);
393 return GNUNET_OK;
394}
395
396
397/**
398 * Handler for LOOKUP_BY_SUFFIX message from client, sends information
399 * about ONE identity to the client immediately.
400 *
401 * @param cls a `struct GNUNET_SERVICE_Client *`
402 * @param message the message received
403 */
404static void
405handle_lookup_by_suffix_message (void *cls,
406 const struct LookupMessage *message)
407{
408 struct GNUNET_SERVICE_Client *client = cls;
409 const char *name;
410 struct GNUNET_MQ_Envelope *env;
411 struct Ego *lprefix;
412
413 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
414 "Received LOOKUP_BY_SUFFIX message from client\n");
415 name = (const char *) &message[1];
416 lprefix = NULL;
417 for (struct Ego *ego = ego_head; NULL != ego; ego = ego->next)
418 {
419
420 if ((strlen (ego->identifier) <= strlen (name)) &&
421 (0 == strcmp (ego->identifier,
422 &name[strlen (name) - strlen (ego->identifier)])) &&
423 ((strlen (name) == strlen (ego->identifier)) ||
424 ('.' == name[strlen (name) -
425 strlen (ego->identifier) - 1])) &&
426 ((NULL == lprefix) ||
427 (strlen (ego->identifier) > strlen (lprefix->identifier))))
428 {
429 /* found better match, update! */
430 lprefix = ego;
431 }
432 }
433 if (NULL != lprefix)
434 {
435 env = create_update_message (lprefix);
436 GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
437 GNUNET_SERVICE_client_continue (client);
438 return;
439 }
440 send_result_code (client,
441 0,
442 "ego not found");
443 GNUNET_SERVICE_client_continue (client);
444}
445
446
447/**
381 * Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message 448 * Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT message
382 * 449 *
383 * @param cls client sending the message 450 * @param cls client sending the message
@@ -1118,6 +1185,10 @@ GNUNET_SERVICE_MAIN
1118 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP, 1185 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP,
1119 struct LookupMessage, 1186 struct LookupMessage,
1120 NULL), 1187 NULL),
1188 GNUNET_MQ_hd_var_size (lookup_by_suffix_message,
1189 GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP_BY_SUFFIX,
1190 struct LookupMessage,
1191 NULL),
1121 GNUNET_MQ_hd_var_size (get_default_message, 1192 GNUNET_MQ_hd_var_size (get_default_message,
1122 GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT, 1193 GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT,
1123 struct GetDefaultMessage, 1194 struct GetDefaultMessage,