* adds the client to the notification context for future
* updates.
*
- * @param cls unused
- * @param client who sent the message
+ * @param cls a `struct GNUNET_SERVICE_Client *`
* @param message the message received
*/
static void
handle_start_message (void *cls,
const struct GNUNET_MessageHeader *message)
{
- struct UpdateMessage *ume;
struct GNUNET_SERVICE_Client *client = cls;
+ struct UpdateMessage *ume;
struct GNUNET_MQ_Envelope *env;
struct Ego *ego;
GNUNET_SERVICE_client_continue (client);
}
+
+/**
+ * Handler for LOOKUP message from client, sends information
+ * about ONE identity to the client immediately.
+ *
+ * @param cls unused
+ * @param message the message received
+ * @return #GNUNET_SYSERR if message was ill-formed
+ */
+static int
+check_lookup_message (void *cls,
+ const struct LookupMessage *message)
+{
+ GNUNET_MQ_check_zero_termination (message);
+ return GNUNET_OK;
+}
+
+
+/**
+ * Handler for LOOKUP message from client, sends information
+ * about ONE identity to the client immediately.
+ *
+ * @param cls a `struct GNUNET_SERVICE_Client *`
+ * @param message the message received
+ */
+static void
+handle_lookup_message (void *cls,
+ const struct LookupMessage *message)
+{
+ struct GNUNET_SERVICE_Client *client = cls;
+ const char *name;
+ struct GNUNET_MQ_Envelope *env;
+ struct Ego *ego;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received LOOKUP message from client\n");
+ name = (const char *) &message[1];
+ for (ego = ego_head; NULL != ego; ego = ego->next)
+ {
+ if (0 != strcasecmp (name,
+ ego->identifier))
+ continue;
+ env = create_update_message (ego);
+ GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env);
+ GNUNET_SERVICE_client_continue (client);
+ return;
+ }
+ send_result_code (client,
+ 0,
+ "ego not found");
+ GNUNET_SERVICE_client_continue (client);
+}
+
+
/**
* Checks a #GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT 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 (get_default_message,
GNUNET_MESSAGE_TYPE_IDENTITY_GET_DEFAULT,
struct GetDefaultMessage,
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
uint32_t result_code GNUNET_PACKED;
/* followed by 0-terminated error message (on error) */
+};
+
+/**
+ * Client informs service about desire to lookup a (single) pseudonym.
+ */
+struct LookupMessage
+{
+ /**
+ * Type: #GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP
+ */
+ struct GNUNET_MessageHeader header;
+
+ /* followed by 0-terminated ego name */
};
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
/* followed by 0-terminated ego name */
-
};
-
/**
* Client requests knowledge about default identity for
* a subsystem from identity service.
/* followed by 0-terminated service name */
-
};
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
/* followed by 0-terminated service name */
-
};
struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
/* followed by 0-terminated identity name */
-
};
uint16_t reserved GNUNET_PACKED;
/* followed by 0-terminated name */
-
};
+GNUNET_NETWORK_STRUCT_END
+/**
+ * Handle for an ego.
+ */
+struct GNUNET_IDENTITY_Ego
+{
+ /**
+ * Private key associated with this ego.
+ */
+ struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
+
+ /**
+ * Current name associated with this ego.
+ */
+ char *name;
+
+ /**
+ * Client context associated with this ego.
+ */
+ void *ctx;
+
+ /**
+ * Hash of the public key of this ego.
+ */
+ struct GNUNET_HashCode id;
+};
-GNUNET_NETWORK_STRUCT_END
#endif
#define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
-/**
- * Handle for an ego.
- */
-struct GNUNET_IDENTITY_Ego
-{
- /**
- * Private key associated with this ego.
- */
- struct GNUNET_CRYPTO_EcdsaPrivateKey *pk;
-
- /**
- * Current name associated with this ego.
- */
- char *name;
-
- /**
- * Client context associated with this ego.
- */
- void *ctx;
-
- /**
- * Hash of the public key of this ego.
- */
- struct GNUNET_HashCode id;
-};
-
/**
* Handle for an operation with the identity service.
static int
check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
{
- uint16_t size = ntohs (rcm->header.size) - sizeof (*rcm);
- const char *str = (const char *) &rcm[1];
-
- if (0 == size)
- return GNUNET_OK;
- if ('\0' != str[size - 1])
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ if (sizeof (*rcm) != htons (rcm->header.size))
+ GNUNET_MQ_check_zero_termination (rcm);
return GNUNET_OK;
}
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
+#include "identity.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "identity-api", __VA_ARGS__)
/**
{
/**
- * Handle to the identity service.
+ * Connection to service.
*/
- struct GNUNET_IDENTITY_Handle *identity;
+ struct GNUNET_MQ_Handle *mq;
/**
* Name of the ego we are looking up.
/**
- * Method called to inform about the egos of this peer.
+ * We received a result code from the service. Check the message
+ * is well-formed.
*
- * When used with #GNUNET_IDENTITY_connect, this function is
- * initially called for all egos and then again whenever a
- * ego's name changes or if it is deleted. At the end of
- * the initial pass over all egos, the function is once called
- * with 'NULL' for @a ego. That does NOT mean that the callback won't
- * be invoked in the future or that there was an error.
- *
- * If the @a name matches the name from @a cls, we found the zone
- * for our computation and will invoke the callback.
- * If we have iterated over all egos and not found the name, we
- * invoke the callback with NULL.
+ * @param cls closure
+ * @param rcm result message received
+ * @return #GNUNET_OK if the message is well-formed
+ */
+static int
+check_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
+{
+ if (sizeof (*rcm) != htons (rcm->header.size))
+ GNUNET_MQ_check_zero_termination (rcm);
+ return GNUNET_OK;
+}
+
+
+/**
+ * We received a result code from the service.
*
- * @param cls closure with the `struct GNUNET_IDENTITY_EgoLookup`
- * @param ego ego handle
- * @param ctx context for application to store data for this ego
- * (during the lifetime of this process, initially NULL)
- * @param name name assigned by the user for this ego,
- * NULL if the user just deleted the ego and it
- * must thus no longer be used
+ * @param cls closure
+ * @param rcm result message received
*/
static void
-identity_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *name)
+handle_identity_result_code (void *cls, const struct ResultCodeMessage *rcm)
{
struct GNUNET_IDENTITY_EgoLookup *el = cls;
- if ( (NULL != name) &&
- (0 == strcmp (name,
- el->name)) )
- {
- el->cb (el->cb_cls,
- ego);
- GNUNET_IDENTITY_ego_lookup_cancel (el);
- return;
- }
- if (NULL == ego)
+ el->cb (el->cb_cls, NULL);
+ GNUNET_IDENTITY_ego_lookup_cancel (el);
+}
+
+
+/**
+ * Check validity of identity update message.
+ *
+ * @param cls closure
+ * @param um message received
+ * @return #GNUNET_OK if the message is well-formed
+ */
+static int
+check_identity_update (void *cls, const struct UpdateMessage *um)
+{
+ uint16_t size = ntohs (um->header.size);
+ uint16_t name_len = ntohs (um->name_len);
+ const char *str = (const char *) &um[1];
+
+ if ((size != name_len + sizeof (struct UpdateMessage)) ||
+ ((0 != name_len) && ('\0' != str[name_len - 1])))
{
- /* not found */
- el->cb (el->cb_cls,
- NULL);
- GNUNET_IDENTITY_ego_lookup_cancel (el);
- return;
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
}
+ return GNUNET_OK;
+}
+
+
+/**
+ * Handle identity update message.
+ *
+ * @param cls closure
+ * @param um message received
+ */
+static void
+handle_identity_update (void *cls, const struct UpdateMessage *um)
+{
+ struct GNUNET_IDENTITY_EgoLookup *el = cls;
+ uint16_t name_len = ntohs (um->name_len);
+ const char *str = (0 == name_len) ? NULL : (const char *) &um[1];
+ struct GNUNET_CRYPTO_EcdsaPublicKey pub;
+ struct GNUNET_HashCode id;
+ struct GNUNET_IDENTITY_Ego ego;
+
+ GNUNET_break (GNUNET_YES != ntohs (um->end_of_list));
+ GNUNET_CRYPTO_ecdsa_key_get_public (&um->private_key, &pub);
+ GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
+ ego.pk = (struct GNUNET_CRYPTO_EcdsaPrivateKey *) &um->private_key;
+ ego.name = (char *) str;
+ ego.id = id;
+ el->cb (el->cb_cls, &ego);
+ GNUNET_IDENTITY_ego_lookup_cancel (el);
+}
+
+
+/**
+ * Generic error handler, called with the appropriate error code and
+ * the same closure specified at the creation of the message queue.
+ * Not every message queue implementation supports an error handler.
+ *
+ * @param cls closure with the `struct GNUNET_IDENTITY_EgoLookup *`
+ * @param error error code
+ */
+static void
+mq_error_handler (void *cls, enum GNUNET_MQ_Error error)
+{
+ struct GNUNET_IDENTITY_EgoLookup *el = cls;
+
+ el->cb (el->cb_cls, NULL);
}
*/
struct GNUNET_IDENTITY_EgoLookup *
GNUNET_IDENTITY_ego_lookup (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *name,
- GNUNET_IDENTITY_EgoCallback cb,
- void *cb_cls)
+ const char *name,
+ GNUNET_IDENTITY_EgoCallback cb,
+ void *cb_cls)
{
struct GNUNET_IDENTITY_EgoLookup *el;
+ struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_MessageHeader *req;
+ size_t nlen;
+ GNUNET_assert (NULL != cb);
el = GNUNET_new (struct GNUNET_IDENTITY_EgoLookup);
- el->name = GNUNET_strdup (name);
el->cb = cb;
el->cb_cls = cb_cls;
- el->identity = GNUNET_IDENTITY_connect (cfg,
- &identity_cb,
- el);
- if (NULL == el->identity)
{
- GNUNET_free (el->name);
+ struct GNUNET_MQ_MessageHandler handlers[] =
+ {GNUNET_MQ_hd_var_size (identity_result_code,
+ GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE,
+ struct ResultCodeMessage,
+ el),
+ GNUNET_MQ_hd_var_size (identity_update,
+ GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE,
+ struct UpdateMessage,
+ el),
+ GNUNET_MQ_handler_end ()};
+
+ el->mq =
+ GNUNET_CLIENT_connect (cfg, "identity", handlers, &mq_error_handler, el);
+ }
+ if (NULL == el->mq)
+ {
+ GNUNET_break (0);
GNUNET_free (el);
return NULL;
}
+ el->name = GNUNET_strdup (name);
+ nlen = strlen (name) + 1;
+ env = GNUNET_MQ_msg_extra (req, nlen, GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP);
+ memcpy (&req[1], name, nlen);
+ GNUNET_MQ_send (el->mq, env);
return el;
}
void
GNUNET_IDENTITY_ego_lookup_cancel (struct GNUNET_IDENTITY_EgoLookup *el)
{
- GNUNET_IDENTITY_disconnect (el->identity);
+ GNUNET_MQ_destroy (el->mq);
GNUNET_free (el->name);
GNUNET_free (el);
}
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
static struct GNUNET_SCHEDULER_Task *endbadly_task;
+#define CHECK(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_break (0); \
+ end (); \
+ return; \
+ } \
+ } while (0)
+
/**
* Clean up all resources used.
*/
static void
-cleanup ()
+cleanup (void *cls)
{
+ (void) cls;
if (NULL != op)
{
GNUNET_IDENTITY_cancel (op);
GNUNET_IDENTITY_disconnect (h);
h = NULL;
}
- GNUNET_SCHEDULER_shutdown ();
}
static void
endbadly (void *cls)
{
- cleanup ();
- res = 1;
-}
-
-
-/**
- * Termiante the testcase (success).
- *
- * @param cls NULL
- */
-static void
-end_normally (void *cls)
-{
- cleanup ();
- res = 0;
+ GNUNET_SCHEDULER_shutdown ();
}
*/
static void
notification_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
static struct GNUNET_IDENTITY_Ego *my_ego;
static int round;
switch (round)
{
case 0: /* end of initial iteration */
- GNUNET_assert (NULL == ego);
- GNUNET_assert (NULL == identifier);
+ CHECK (NULL == ego);
+ CHECK (NULL == identifier);
break;
case 1: /* create */
- GNUNET_assert (NULL != ego);
- GNUNET_assert (0 == strcmp (identifier,
- "test-id"));
+ CHECK (NULL != ego);
+ CHECK (NULL != identifier);
+ CHECK (0 == strcmp (identifier, "test-id"));
my_ego = ego;
*ctx = &round;
break;
case 2: /* rename */
- GNUNET_assert (my_ego == ego);
- GNUNET_assert (0 == strcmp (identifier,
- "test"));
- GNUNET_assert (*ctx == &round);
+ CHECK (my_ego == ego);
+ CHECK (NULL != identifier);
+ CHECK (0 == strcmp (identifier, "test"));
+ CHECK (*ctx == &round);
break;
case 3: /* reconnect-down */
- GNUNET_assert (my_ego == ego);
- GNUNET_assert (NULL == identifier);
- GNUNET_assert (*ctx == &round);
+ CHECK (my_ego == ego);
+ CHECK (NULL == identifier);
+ CHECK (*ctx == &round);
*ctx = NULL;
break;
case 4: /* reconnect-up */
- GNUNET_assert (0 == strcmp (identifier,
- "test"));
+ CHECK (NULL != identifier);
+ CHECK (0 == strcmp (identifier, "test"));
my_ego = ego;
*ctx = &round;
break;
case 5: /* end of iteration after reconnect */
- GNUNET_assert (NULL == ego);
- GNUNET_assert (NULL == identifier);
+ CHECK (NULL == ego);
+ CHECK (NULL == identifier);
break;
case 6: /* delete */
- GNUNET_assert (my_ego == ego);
- GNUNET_assert (*ctx == &round);
+ CHECK (my_ego == ego);
+ CHECK (*ctx == &round);
*ctx = NULL;
break;
default:
- GNUNET_break (0);
+ CHECK (0);
}
round++;
}
* @param emsg (should also be NULL)
*/
static void
-delete_cont (void *cls,
- const char *emsg)
+delete_cont (void *cls, const char *emsg)
{
op = NULL;
- GNUNET_assert (NULL == emsg);
+ CHECK (NULL == emsg);
+ res = 0;
end ();
}
static void
finally_delete (void *cls)
{
- op = GNUNET_IDENTITY_delete (h,
- "test",
- &delete_cont,
- NULL);
+ op = GNUNET_IDENTITY_delete (h, "test", &delete_cont, NULL);
}
* @param emsg (should also be NULL)
*/
static void
-fail_rename_cont (void *cls,
- const char *emsg)
+fail_rename_cont (void *cls, const char *emsg)
{
- GNUNET_assert (NULL != emsg);
+ CHECK (NULL != emsg);
op = NULL;
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&finally_delete,
* @param emsg (should also be NULL)
*/
static void
-success_rename_cont (void *cls,
- const char *emsg)
+success_rename_cont (void *cls, const char *emsg)
{
- GNUNET_assert (NULL == emsg);
- op = GNUNET_IDENTITY_rename (h,
- "test-id",
- "test",
- &fail_rename_cont,
- NULL);
+ CHECK (NULL == emsg);
+ op = GNUNET_IDENTITY_rename (h, "test-id", "test", &fail_rename_cont, NULL);
}
*/
static void
create_cb (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
- const char *emsg)
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
+ const char *emsg)
{
- GNUNET_assert (NULL != pk);
- GNUNET_assert (NULL == emsg);
- op = GNUNET_IDENTITY_rename (h,
- "test-id",
- "test",
- &success_rename_cont,
- NULL);
+ CHECK (NULL != pk);
+ CHECK (NULL == emsg);
+ op =
+ GNUNET_IDENTITY_rename (h, "test-id", "test", &success_rename_cont, NULL);
}
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
- endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &endbadly,
- NULL);
- GNUNET_SCHEDULER_add_shutdown (&end_normally,
- NULL);
- h = GNUNET_IDENTITY_connect (cfg,
- ¬ification_cb,
- NULL);
- GNUNET_assert (NULL != h);
- op = GNUNET_IDENTITY_create (h,
- "test-id",
- &create_cb,
- NULL);
-
+ endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
+ h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL);
+ CHECK (NULL != h);
+ op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL);
}
int
main (int argc, char *argv[])
{
- GNUNET_DISK_directory_remove ("/tmp/test-identity-service");
+ GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service");
res = 1;
- if (0 !=
- GNUNET_TESTING_service_run ("test-identity",
- "identity",
- "test_identity.conf",
- &run,
- NULL))
+ if (0 != GNUNET_TESTING_service_run ("test-identity",
+ "identity",
+ "test_identity.conf",
+ &run,
+ NULL))
return 1;
+ GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service");
return res;
}
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
/**
* Handle for task for timeout termination.
*/
-static struct GNUNET_SCHEDULER_Task * endbadly_task;
+static struct GNUNET_SCHEDULER_Task *endbadly_task;
+
+#define CHECK(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_break (0); \
+ end (); \
+ return; \
+ } \
+ } while (0)
/**
* Clean up all resources used.
*/
static void
-cleanup ()
+cleanup (void *cls)
{
+ (void) cls;
if (NULL != op)
{
GNUNET_IDENTITY_cancel (op);
GNUNET_IDENTITY_disconnect (h);
h = NULL;
}
- GNUNET_SCHEDULER_shutdown ();
}
static void
endbadly (void *cls)
{
- cleanup ();
+ GNUNET_SCHEDULER_shutdown ();
res = 1;
}
/**
- * Termiante the testcase (success).
- *
- * @param cls NULL
- */
-static void
-end_normally (void *cls)
-{
- cleanup ();
- res = 0;
-}
-
-
-/**
- * Finish the testcase (successfully).
+ * Termiante the testcase.
*/
static void
end ()
{
- if (endbadly_task != NULL)
+ if (NULL != endbadly_task)
{
GNUNET_SCHEDULER_cancel (endbadly_task);
endbadly_task = NULL;
}
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
- &end_normally, NULL);
+ GNUNET_SCHEDULER_shutdown ();
}
* @param emsg (should also be NULL)
*/
static void
-delete_cont (void *cls,
- const char *emsg)
+delete_cont (void *cls, const char *emsg)
{
op = NULL;
- GNUNET_assert (NULL == emsg);
+ CHECK (NULL == emsg);
+ res = 0;
end ();
}
*/
static void
get_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
- GNUNET_assert (NULL != ego);
- GNUNET_assert (NULL != identifier);
- GNUNET_assert (0 == strcmp (identifier, "test-id"));
- op = GNUNET_IDENTITY_delete (h,
- "test-id",
- &delete_cont,
- NULL);
+ op = NULL;
+ CHECK (NULL != ego);
+ CHECK (NULL != identifier);
+ CHECK (0 == strcmp (identifier, "test-id"));
+ op = GNUNET_IDENTITY_delete (h, "test-id", &delete_cont, NULL);
}
*/
static void
run_get (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
- endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &endbadly, NULL);
+ endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
h = GNUNET_IDENTITY_connect (cfg, NULL, NULL);
- GNUNET_assert (NULL != h);
- op = GNUNET_IDENTITY_get (h,
- "test-service",
- &get_cb,
- NULL);
+ CHECK (NULL != h);
+ op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL);
}
* @param emsg (should also be NULL)
*/
static void
-success_set_cont (void *cls,
- const char *emsg)
+success_set_cont (void *cls, const char *emsg)
{
op = NULL;
- GNUNET_assert (NULL == emsg);
+ CHECK (NULL == emsg);
end ();
}
*/
static void
notification_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
if (NULL == ego)
return; /* skip first call */
if (NULL == identifier)
return; /* deletion / shutdown */
- op = GNUNET_IDENTITY_set (h,
- "test-service",
- ego,
- &success_set_cont,
- NULL);
+ op = GNUNET_IDENTITY_set (h, "test-service", ego, &success_set_cont, NULL);
}
*/
static void
create_cb (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
- const char *emsg)
+ const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
+ const char *emsg)
{
- GNUNET_assert (NULL == emsg);
- GNUNET_assert (NULL != pk);
+ CHECK (NULL == emsg);
+ CHECK (NULL != pk);
op = NULL;
}
*/
static void
run_set (void *cls,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct GNUNET_TESTING_Peer *peer)
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct GNUNET_TESTING_Peer *peer)
{
- endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &endbadly, NULL);
+ endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL);
+ GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL);
h = GNUNET_IDENTITY_connect (cfg, ¬ification_cb, NULL);
- GNUNET_assert (NULL != h);
- op = GNUNET_IDENTITY_create (h,
- "test-id",
- &create_cb,
- NULL);
-
+ CHECK (NULL != h);
+ op = GNUNET_IDENTITY_create (h, "test-id", &create_cb, NULL);
}
int
main (int argc, char *argv[])
{
- GNUNET_DISK_directory_remove ("/tmp/test-identity-service");
+ GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service");
res = 1;
- if (0 !=
- GNUNET_TESTING_service_run ("test-identity-defaults",
- "identity",
- "test_identity.conf",
- &run_set,
- NULL))
+ if (0 != GNUNET_TESTING_service_run ("test-identity-defaults",
+ "identity",
+ "test_identity.conf",
+ &run_set,
+ NULL))
return 1;
- if (0 !=
- GNUNET_TESTING_service_run ("test-identity-defaults",
- "identity",
- "test_identity.conf",
- &run_get,
- NULL))
+ if (0 != GNUNET_TESTING_service_run ("test-identity-defaults",
+ "identity",
+ "test_identity.conf",
+ &run_get,
+ NULL))
return 1;
- GNUNET_DISK_directory_remove ("/tmp/test-identity-service");
+ GNUNET_DISK_directory_remove ("/tmp/gnunet/test-identity-service");
return res;
}
-/* end of test_identity.c */
+/* end of test_identity_defaults.c */
*/
#define GNUNET_MESSAGE_TYPE_IDENTITY_DELETE 631
+/**
+ * First message send from identity client to service to
+ * lookup a single ego. The service will respond with a
+ * #GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE message if the ego
+ * exists, or a #GNUNET_MESSAGE_TYPE_IDENTITY_RESULT_CODE if not.
+ */
+#define GNUNET_MESSAGE_TYPE_IDENTITY_LOOKUP 632
+
/*******************************************************************************
* REVOCATION message types