[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: MESSENGER: Cleanup unused code files in
From: |
gnunet |
Subject: |
[gnunet] branch master updated: MESSENGER: Cleanup unused code files in service directory |
Date: |
Tue, 14 Nov 2023 18:06:31 +0100 |
This is an automated email from the git hooks/post-receive script.
thejackimonster pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new b0fdf8fb6 MESSENGER: Cleanup unused code files in service directory
b0fdf8fb6 is described below
commit b0fdf8fb67b371dbc413d48ae53eef5be0fcbbcd
Author: TheJackiMonster <thejackimonster@gmail.com>
AuthorDate: Tue Nov 14 18:06:24 2023 +0100
MESSENGER: Cleanup unused code files in service directory
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
---
.../messenger/gnunet-service-messenger_ego_store.c | 527 ------------------
.../messenger/gnunet-service-messenger_ego_store.h | 206 -------
.../gnunet-service-messenger_message_kind.h | 1 -
src/service/messenger/messenger_api_ego.h | 38 --
src/service/messenger/plugin_gnsrecord_messenger.c | 305 -----------
src/service/messenger/test_messenger_adapt.c | 49 --
.../messenger/test_messenger_async_client.c | 49 --
src/service/messenger/test_messenger_async_p2p.c | 49 --
src/service/messenger/test_messenger_growth.c | 49 --
src/service/messenger/test_messenger_ring.c | 49 --
src/service/messenger/test_messenger_server.c | 49 --
src/service/messenger/test_messenger_sync_client.c | 49 --
src/service/messenger/test_messenger_sync_p2p.c | 49 --
.../messenger/test_messenger_worst_client.c | 49 --
src/service/messenger/test_messenger_worst_p2p.c | 49 --
src/service/messenger/testing_messenger_barrier.c | 181 -------
src/service/messenger/testing_messenger_barrier.h | 131 -----
src/service/messenger/testing_messenger_setup.c | 594 ---------------------
src/service/messenger/testing_messenger_setup.h | 40 --
19 files changed, 2513 deletions(-)
diff --git a/src/service/messenger/gnunet-service-messenger_ego_store.c
b/src/service/messenger/gnunet-service-messenger_ego_store.c
deleted file mode 100644
index e7faa9eed..000000000
--- a/src/service/messenger/gnunet-service-messenger_ego_store.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2020--2023 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @author Tobias Frisch
- * @file src/messenger/gnunet-service-messenger_ego_store.c
- * @brief GNUnet MESSENGER service
- */
-
-#include "platform.h"
-#include "gnunet-service-messenger_ego_store.h"
-
-#include "gnunet-service-messenger_handle.h"
-
-static void
-callback_update_ego (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
-{
- if ((! ctx) || (! identifier))
- return;
-
- struct GNUNET_MESSENGER_EgoStore *store = cls;
-
- if (ego)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New ego in use: '%s'\n", identifier);
- update_store_ego (store, identifier,
- GNUNET_IDENTITY_ego_get_private_key (ego));
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego got deleted: '%s'\n",
identifier);
- delete_store_ego (store, identifier);
- }
-}
-
-
-void
-init_ego_store (struct GNUNET_MESSENGER_EgoStore *store,
- const struct GNUNET_CONFIGURATION_Handle *config)
-{
- GNUNET_assert ((store) && (config));
-
- store->cfg = config;
- store->identity = GNUNET_IDENTITY_connect (config, &callback_update_ego,
- store);
- store->egos = GNUNET_CONTAINER_multihashmap_create (8, GNUNET_NO);
- store->handles = GNUNET_CONTAINER_multihashmap_create (8, GNUNET_NO);
-
- store->lu_start = NULL;
- store->lu_end = NULL;
-
- store->op_start = NULL;
- store->op_end = NULL;
-}
-
-
-static int
-iterate_destroy_egos (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct GNUNET_MESSENGER_Ego *ego = value;
- GNUNET_free (ego);
- return GNUNET_YES;
-}
-
-
-void
-clear_ego_store (struct GNUNET_MESSENGER_EgoStore *store)
-{
- GNUNET_assert (store);
-
- struct GNUNET_MESSENGER_EgoOperation *op;
-
- while (store->op_start)
- {
- op = store->op_start;
-
- GNUNET_IDENTITY_cancel (op->operation);
- GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, op);
-
- if (op->identifier)
- GNUNET_free (op->identifier);
-
- GNUNET_free (op);
- }
-
- struct GNUNET_MESSENGER_EgoLookup *lu;
-
- while (store->lu_start)
- {
- lu = store->lu_start;
-
- GNUNET_IDENTITY_ego_lookup_cancel (lu->lookup);
- GNUNET_CONTAINER_DLL_remove (store->lu_start, store->lu_end, lu);
-
- if (lu->identifier)
- GNUNET_free (lu->identifier);
-
- GNUNET_free (lu);
- }
-
- GNUNET_CONTAINER_multihashmap_iterate (store->egos,
- iterate_destroy_egos,
- NULL);
- GNUNET_CONTAINER_multihashmap_destroy (store->egos);
- GNUNET_CONTAINER_multihashmap_destroy (store->handles);
-
- if (store->identity)
- {
- GNUNET_IDENTITY_disconnect (store->identity);
-
- store->identity = NULL;
- }
-}
-
-
-static int
-iterate_create_ego (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
-{
- struct GNUNET_MESSENGER_SrvHandle *handle = value;
- set_srv_handle_ego (handle, (struct GNUNET_MESSENGER_Ego*) cls);
- return GNUNET_YES;
-}
-
-
-static void
-callback_ego_create (void *cls,
- const struct GNUNET_CRYPTO_PrivateKey *key,
- enum GNUNET_ErrorCode ec)
-{
- struct GNUNET_MESSENGER_EgoOperation *element = cls;
- struct GNUNET_MESSENGER_EgoStore *store = element->store;
-
- GNUNET_assert (element->identifier);
-
- /**
- * FIXME: This is dangerous, please handle errors
- */
- if (GNUNET_EC_NONE != ec)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n",
- GNUNET_ErrorCode_get_hint (ec));
-
- if (key)
- {
- struct GNUNET_MESSENGER_Ego *msg_ego = update_store_ego (store,
-
element->identifier,
- key);
-
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier),
- &hash);
-
- GNUNET_CONTAINER_multihashmap_get_multiple (store->handles, &hash,
- iterate_create_ego, msg_ego);
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Creating ego failed!\n");
-
- GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, element);
- GNUNET_free (element->identifier);
- GNUNET_free (element);
-}
-
-
-void
-create_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier)
-{
- GNUNET_assert ((store) && (identifier));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store create ego: %s\n", identifier);
-
- struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct
-
GNUNET_MESSENGER_EgoOperation);
-
- element->store = store;
- element->cls = NULL;
-
- element->identifier = GNUNET_strdup (identifier);
-
- element->operation = GNUNET_IDENTITY_create (
- store->identity,
- identifier,
- NULL,
- GNUNET_PUBLIC_KEY_TYPE_ECDSA,
- callback_ego_create,
- element
- );
-
- GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element);
-}
-
-
-void
-bind_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- void *handle)
-{
- GNUNET_assert ((store) && (identifier) && (handle));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store bind ego: %s\n", identifier);
-
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
-
- if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value (
- store->handles, &hash, handle))
- return;
-
- if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (store->handles, &hash,
- handle,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Putting handle binding to ego store failed!\n");
-}
-
-
-void
-unbind_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- void *handle)
-{
- GNUNET_assert ((store) && (identifier) && (handle));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store unbind ego: %s\n", identifier);
-
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
-
- if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_contains_value (
- store->handles, &hash, handle))
- return;
-
- if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->handles,
&hash,
- handle))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Removing handle binding from ego store failed!\n");
-}
-
-
-static void
-callback_ego_lookup (void *cls,
- struct GNUNET_IDENTITY_Ego *ego)
-{
- struct GNUNET_MESSENGER_EgoLookup *element = cls;
- struct GNUNET_MESSENGER_EgoStore *store = element->store;
-
- GNUNET_assert (element->identifier);
-
- struct GNUNET_MESSENGER_Ego *msg_ego = NULL;
-
- if (ego)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New ego looked up: '%s'\n",
- element->identifier);
- msg_ego = update_store_ego (
- store,
- element->identifier,
- GNUNET_IDENTITY_ego_get_private_key (ego)
- );
- }
- else
- {
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier),
- &hash);
-
- if (GNUNET_CONTAINER_multihashmap_get (store->egos, &hash))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looked up ego got deleted: '%s'\n",
- element->identifier);
- delete_store_ego (store, element->identifier);
- }
- }
-
- if (element->cb)
- element->cb (element->cls, element->identifier, msg_ego);
-
- GNUNET_CONTAINER_DLL_remove (store->lu_start, store->lu_end, element);
- GNUNET_free (element->identifier);
- GNUNET_free (element);
-}
-
-
-void
-lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- GNUNET_MESSENGER_EgoLookupCallback lookup,
- void *cls)
-{
- GNUNET_assert (store);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store lookup ego: %s\n", identifier);
-
- if (! identifier)
- {
- lookup (cls, identifier, NULL);
- return;
- }
-
- struct GNUNET_MESSENGER_EgoLookup *element = GNUNET_new (struct
-
GNUNET_MESSENGER_EgoLookup);
-
- element->store = store;
-
- element->cb = lookup;
- element->cls = cls;
-
- element->identifier = GNUNET_strdup (identifier);
-
- element->lookup = GNUNET_IDENTITY_ego_lookup (store->cfg, identifier,
- callback_ego_lookup, element);
-
- GNUNET_CONTAINER_DLL_insert (store->lu_start, store->lu_end, element);
-}
-
-
-struct GNUNET_MESSENGER_Ego*
-update_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- const struct GNUNET_CRYPTO_PrivateKey *key)
-{
- GNUNET_assert ((store) && (identifier) && (key));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store update ego: %s\n", identifier);
-
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
-
- struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (
- store->egos, &hash);
-
- if (! ego)
- {
- ego = GNUNET_new (struct GNUNET_MESSENGER_Ego);
- GNUNET_CONTAINER_multihashmap_put (store->egos, &hash, ego,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- }
-
- GNUNET_memcpy (&(ego->priv), key, sizeof(*key));
-
- if (GNUNET_OK != GNUNET_CRYPTO_key_get_public (key, &(ego->pub)))
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Updating invalid ego key failed!\n");
-
- return ego;
-}
-
-
-void
-delete_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier)
-{
- GNUNET_assert ((store) && (identifier));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store delete ego: %s\n", identifier);
-
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
-
- struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (
- store->egos, &hash);
-
- if (ego)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Ego is not stored!\n");
- return;
- }
-
- if (GNUNET_YES != GNUNET_CONTAINER_multihashmap_remove (store->egos, &hash,
- ego))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Removing ego from store failed!\n");
- return;
- }
-
- GNUNET_free (ego);
-}
-
-
-static void
-callback_ego_rename (void *cls,
- enum GNUNET_ErrorCode ec)
-{
- struct GNUNET_MESSENGER_EgoOperation *element = cls;
- struct GNUNET_MESSENGER_EgoStore *store = element->store;
-
- GNUNET_assert (element->identifier);
-
- /**
- * FIXME: Dangerous, handle error
- */
- if (GNUNET_EC_NONE != ec)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n",
- GNUNET_ErrorCode_get_hint (ec));
-
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (element->identifier, strlen (element->identifier),
&hash);
-
- struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (
- store->egos, &hash);
-
- if (! ego)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Ego is not stored!\n");
-
- char *identifier = (char*) element->cls;
-
- if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (store->egos, &hash,
- ego))
- {
- GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
-
- GNUNET_CONTAINER_multihashmap_put (store->egos, &hash, ego,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Renaming ego failed!\n");
-
- GNUNET_free (identifier);
-
- GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, element);
- GNUNET_free (element->identifier);
- GNUNET_free (element);
-}
-
-
-void
-rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *old_identifier,
- const char *new_identifier)
-{
- GNUNET_assert ((store) && (old_identifier) && (new_identifier));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store rename ego: %s -> %s\n",
- old_identifier, new_identifier);
-
- struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct
-
GNUNET_MESSENGER_EgoOperation);
-
- element->store = store;
- element->cls = GNUNET_strdup (new_identifier);
-
- element->identifier = GNUNET_strdup (old_identifier);
-
- element->operation = GNUNET_IDENTITY_rename (
- store->identity,
- old_identifier,
- new_identifier,
- callback_ego_rename,
- element
- );
-
- GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element);
-}
-
-
-static void
-callback_ego_delete (void *cls,
- enum GNUNET_ErrorCode ec)
-{
- struct GNUNET_MESSENGER_EgoOperation *element = cls;
- struct GNUNET_MESSENGER_EgoStore *store = element->store;
-
- GNUNET_assert (element->identifier);
-
- /**
- * FIXME: Dangerous, handle error
- */
- if (GNUNET_EC_NONE != ec)
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s\n",
- GNUNET_ErrorCode_get_hint (ec));
-
- create_store_ego (store, element->identifier);
-
- GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, element);
- GNUNET_free (element->identifier);
- GNUNET_free (element);
-}
-
-
-void
-renew_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier)
-{
- GNUNET_assert ((store) && (identifier));
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Store renew ego: %s\n", identifier);
-
- struct GNUNET_MESSENGER_EgoOperation *element = GNUNET_new (struct
-
GNUNET_MESSENGER_EgoOperation);
-
- element->store = store;
- element->cls = NULL;
-
- element->identifier = GNUNET_strdup (identifier);
-
- element->operation = GNUNET_IDENTITY_delete (
- store->identity,
- identifier,
- callback_ego_delete,
- element
- );
-
- GNUNET_CONTAINER_DLL_insert (store->op_start, store->op_end, element);
-}
diff --git a/src/service/messenger/gnunet-service-messenger_ego_store.h
b/src/service/messenger/gnunet-service-messenger_ego_store.h
deleted file mode 100644
index bf901bf5e..000000000
--- a/src/service/messenger/gnunet-service-messenger_ego_store.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2020--2022 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @author Tobias Frisch
- * @file src/messenger/gnunet-service-messenger_ego_store.h
- * @brief GNUnet MESSENGER service
- */
-
-#ifndef GNUNET_SERVICE_MESSENGER_EGO_STORE_H
-#define GNUNET_SERVICE_MESSENGER_EGO_STORE_H
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-
-#include "messenger_api_ego.h"
-
-struct GNUNET_MESSENGER_Ego;
-struct GNUNET_MESSENGER_EgoStore;
-
-typedef void
-(*GNUNET_MESSENGER_EgoLookupCallback) (void *cls,
- const char *identifier,
- const struct GNUNET_MESSENGER_Ego *ego);
-
-struct GNUNET_MESSENGER_EgoLookup
-{
- struct GNUNET_MESSENGER_EgoLookup *prev;
- struct GNUNET_MESSENGER_EgoLookup *next;
-
- struct GNUNET_IDENTITY_EgoLookup *lookup;
-
- struct GNUNET_MESSENGER_EgoStore *store;
-
- GNUNET_MESSENGER_EgoLookupCallback cb;
- void *cls;
-
- char *identifier;
-};
-
-struct GNUNET_MESSENGER_EgoOperation
-{
- struct GNUNET_MESSENGER_EgoOperation *prev;
- struct GNUNET_MESSENGER_EgoOperation *next;
-
- struct GNUNET_IDENTITY_Operation *operation;
-
- struct GNUNET_MESSENGER_EgoStore *store;
-
- void *cls;
-
- char *identifier;
-};
-
-struct GNUNET_MESSENGER_EgoStore
-{
- const struct GNUNET_CONFIGURATION_Handle *cfg;
-
- struct GNUNET_IDENTITY_Handle *identity;
- struct GNUNET_CONTAINER_MultiHashMap *egos;
- struct GNUNET_CONTAINER_MultiHashMap *handles;
-
- struct GNUNET_MESSENGER_EgoLookup *lu_start;
- struct GNUNET_MESSENGER_EgoLookup *lu_end;
-
- struct GNUNET_MESSENGER_EgoOperation *op_start;
- struct GNUNET_MESSENGER_EgoOperation *op_end;
-};
-
-/**
- * Initializes an EGO-store as fully empty.
- *
- * @param[out] store EGO-store
- * @param[in] config Configuration handle
- */
-void
-init_ego_store (struct GNUNET_MESSENGER_EgoStore *store,
- const struct GNUNET_CONFIGURATION_Handle *config);
-
-/**
- * Clears an EGO-store, wipes its content and deallocates its memory.
- *
- * @param[in,out] store EGO-store
- */
-void
-clear_ego_store (struct GNUNET_MESSENGER_EgoStore *store);
-
-/**
- * Creates a new EGO which will be registered to a <i>store</i> under
- * a specific <i>identifier</i>.
- *
- * @param[in,out] store EGO-store
- * @param[in] identifier Identifier string
- */
-void
-create_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier);
-
-/**
- * Binds an EGO which was registered to a <i>store</i> under
- * a specific <i>identifier</i> to a given <i>handle</i>
- *
- * @param[in,out] store EGO-store
- * @param[in] identifier Identifier string
- * @param[in,out] handle Handle
- */
-void
-bind_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- void *handle);
-
-/**
- * Binds an EGO which was registered to a <i>store</i> under
- * a specific <i>identifier</i> to a given <i>handle</i>
- *
- * @param[in,out] store EGO-store
- * @param[in] identifier Identifier string
- * @param[in,out] handle Handle
- */
-void
-unbind_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- void *handle);
-
-/**
- * Lookups an EGO which was registered to a <i>store</i> under
- * a specific <i>identifier</i>.
- *
- * @param[in,out] store EGO-store
- * @param[in] identifier Identifier string
- * @param[in] lookup Lookup callback (non-NULL)
- * @param[in] cls Closure
- */
-void
-lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- GNUNET_MESSENGER_EgoLookupCallback lookup,
- void *cls);
-
-/**
- * Updates the registration of an EGO to a <i>store</i> under
- * a specific <i>identifier</i> with a new <i>key</i>.
- *
- * @param[in,out] store EGO-store
- * @param[in] identifier Identifier string
- * @param[in] key Private EGO key
- * @return Updated EGO
- */
-struct GNUNET_MESSENGER_Ego*
-update_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- const struct GNUNET_CRYPTO_PrivateKey *key);
-
-/**
- * Deletes the registration of an EGO in a <i>store</i> under
- * a specific <i>identifier</i>.
- *
- * @param[in,out] store EGO-store
- * @param[in] identifier Identifier string
- */
-void
-delete_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier);
-
-/**
- * Updates the location of a registered EGO in a <i>store</i> to
- * a different one under a specific <i>new_identifier</i> replacing
- * its old one.
- *
- * @param[in,out] store EGO-store
- * @param[in] old_identifier Old identifier string
- * @param[in] new_identifier New identifier string
- */
-void
-rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *old_identifier,
- const char *new_identifier);
-
-/**
- * Replaces the registered EGO in a <i>store</i> under a specific
- * <i>identifier</i> with a newly created one.
- *
- * @param[in,out] store EGO-store
- * @param[in] identifier Identifier string
- */
-void
-renew_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier);
-
-#endif //GNUNET_SERVICE_MESSENGER_EGO_STORE_H
diff --git a/src/service/messenger/gnunet-service-messenger_message_kind.h
b/src/service/messenger/gnunet-service-messenger_message_kind.h
index 2e13e7710..4ac8bd8e2 100644
--- a/src/service/messenger/gnunet-service-messenger_message_kind.h
+++ b/src/service/messenger/gnunet-service-messenger_message_kind.h
@@ -33,7 +33,6 @@
#include "messenger_api_message.h"
#include "gnunet-service-messenger_service.h"
-#include "messenger_api_ego.h"
/**
* Creates and allocates a new info message containing the hosts service peer
identity and version.
diff --git a/src/service/messenger/messenger_api_ego.h
b/src/service/messenger/messenger_api_ego.h
deleted file mode 100644
index 1d84c524f..000000000
--- a/src/service/messenger/messenger_api_ego.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @author Tobias Frisch
- * @file src/messenger/messenger_api_ego.h
- * @brief GNUnet MESSENGER service
- */
-
-#ifndef GNUNET_MESSENGER_API_EGO_H
-#define GNUNET_MESSENGER_API_EGO_H
-
-#include "platform.h"
-#include "gnunet_identity_service.h"
-
-struct GNUNET_MESSENGER_Ego
-{
- struct GNUNET_CRYPTO_PrivateKey priv;
- struct GNUNET_CRYPTO_PublicKey pub;
-};
-
-#endif //GNUNET_MESSENGER_API_EGO_H
diff --git a/src/service/messenger/plugin_gnsrecord_messenger.c
b/src/service/messenger/plugin_gnsrecord_messenger.c
deleted file mode 100644
index ed675dd1d..000000000
--- a/src/service/messenger/plugin_gnsrecord_messenger.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021--2023 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @author Tobias Frisch
- * @file src/messenger/plugin_gnsrecord_messenger.c
- * @brief Plugin to provide the API for useful GNS records to improve
- * the usability of the messenger service.
- */
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-#include "gnunet_gnsrecord_lib.h"
-#include "gnunet_messenger_service.h"
-#include "gnunet_gnsrecord_plugin.h"
-
-
-/**
- * Convert the 'value' of a record to a string.
- *
- * @param cls closure, unused
- * @param type type of the record
- * @param data value in binary encoding
- * @param data_size number of bytes in @a data
- * @return NULL on error, otherwise human-readable representation of the value
- */
-static char *
-messenger_value_to_string (void *cls,
- uint32_t type,
- const void *data,
- size_t data_size)
-{
- (void) cls;
- switch (type)
- {
- case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY:
- {
- if (data_size != sizeof(struct GNUNET_MESSENGER_RoomEntryRecord))
- {
- GNUNET_break_op (0);
- return NULL;
- }
-
- const struct GNUNET_MESSENGER_RoomEntryRecord *record = data;
-
- char *door = GNUNET_CRYPTO_eddsa_public_key_to_string (
- &(record->door.public_key));
- char *key = GNUNET_STRINGS_data_to_string_alloc (&(record->key),
- sizeof(struct
-
GNUNET_HashCode));
-
- char *ret;
- GNUNET_asprintf (&ret, "%s-%s", key, door);
- GNUNET_free (key);
- GNUNET_free (door);
- return ret;
- }
- case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS:
- {
- if (data_size != sizeof(struct GNUNET_MESSENGER_RoomDetailsRecord))
- {
- GNUNET_break_op (0);
- return NULL;
- }
-
- const struct GNUNET_MESSENGER_RoomDetailsRecord *record = data;
-
- char *name = GNUNET_strndup (record->name, 256);
- char *flags = GNUNET_STRINGS_data_to_string_alloc (&(record->flags),
- sizeof(uint32_t));
-
- char *ret;
- GNUNET_asprintf (&ret, "%s-%s", flags, name);
- GNUNET_free (flags);
- GNUNET_free (name);
- return ret;
- }
- default:
- return NULL;
- }
-}
-
-
-/**
- * Convert human-readable version of a 'value' of a record to the binary
- * representation.
- *
- * @param cls closure, unused
- * @param type type of the record
- * @param s human-readable string
- * @param data set to value in binary encoding (will be allocated)
- * @param data_size set to number of bytes in @a data
- * @return #GNUNET_OK on success
- */
-static int
-messenger_string_to_value (void *cls,
- uint32_t type,
- const char *s,
- void **data,
- size_t *data_size)
-{
- (void) cls;
- if (NULL == s)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
-
- switch (type)
- {
- case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY:
- {
- char key[103];
- const char *dash;
- struct GNUNET_PeerIdentity door;
-
- if ((NULL == (dash = strchr (s, '-'))) ||
- (1 != sscanf (s, "%103s-", key)) ||
- (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (dash + 1,
- strlen (
- dash +
1),
- &(door.
-
public_key))))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Unable to parse MESSENGER_ROOM_ENTRY record `%s'\n"),
- s);
- return GNUNET_SYSERR;
- }
-
- struct GNUNET_MESSENGER_RoomEntryRecord *record = GNUNET_new (
- struct GNUNET_MESSENGER_RoomEntryRecord
- );
-
- if (GNUNET_OK != GNUNET_STRINGS_string_to_data (key,
- strlen (key),
- &(record->key),
- sizeof(struct
- GNUNET_HashCode)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Unable to parse MESSENGER_ROOM_ENTRY record `%s'\n"),
- s);
- GNUNET_free (record);
- return GNUNET_SYSERR;
- }
-
- record->door = door;
- *data = record;
- *data_size = sizeof(struct GNUNET_MESSENGER_RoomEntryRecord);
- return GNUNET_OK;
- }
- case GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS:
- {
- char flags[7];
- const char *dash;
-
- if ((NULL == (dash = strchr (s, '-'))) ||
- (1 != sscanf (s, "%7s-", flags)) ||
- (strlen (dash + 1) > 256))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Unable to parse MESSENGER_ROOM_DETAILS record `%s'\n"),
- s);
- return GNUNET_SYSERR;
- }
-
- struct GNUNET_MESSENGER_RoomDetailsRecord *record = GNUNET_new (
- struct GNUNET_MESSENGER_RoomDetailsRecord
- );
-
- if (GNUNET_OK != GNUNET_STRINGS_string_to_data (flags,
- strlen (flags),
- &(record->flags),
- sizeof(uint32_t)))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _ ("Unable to parse MESSENGER_ROOM_DETAILS record `%s'\n"),
- s);
- GNUNET_free (record);
- return GNUNET_SYSERR;
- }
-
- GNUNET_memcpy (record->name, dash + 1, strlen (dash + 1));
-
- *data = record;
- *data_size = sizeof(struct GNUNET_MESSENGER_RoomDetailsRecord);
- return GNUNET_OK;
- }
- default:
- return GNUNET_SYSERR;
- }
-}
-
-
-/**
- * Mapping of record type numbers to human-readable
- * record type names.
- */
-static struct
-{
- const char *name;
- uint32_t number;
-} name_map[] = {
- { "MESSENGER_ROOM_ENTRY", GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_ENTRY },
- { "MESSENGER_ROOM_DETAILS", GNUNET_GNSRECORD_TYPE_MESSENGER_ROOM_DETAILS },
- { NULL, UINT32_MAX }
-};
-
-
-/**
- * Convert a type name (e.g. "AAAA") to the corresponding number.
- *
- * @param cls closure, unused
- * @param gns_typename name to convert
- * @return corresponding number, UINT32_MAX on error
- */
-static uint32_t
-messenger_typename_to_number (void *cls,
- const char *gns_typename)
-{
- unsigned int i;
-
- (void) cls;
- i = 0;
- while ((name_map[i].name != NULL) &&
- (0 != strcasecmp (gns_typename, name_map[i].name)))
- i++;
- return name_map[i].number;
-}
-
-
-/**
- * Convert a type number to the corresponding type string (e.g. 1 to "A")
- *
- * @param cls closure, unused
- * @param type number of a type to convert
- * @return corresponding typestring, NULL on error
- */
-static const char *
-messenger_number_to_typename (void *cls,
- uint32_t type)
-{
- unsigned int i;
-
- (void) cls;
- i = 0;
- while ((name_map[i].name != NULL) &&
- (type != name_map[i].number))
- i++;
- return name_map[i].name;
-}
-
-
-/**
- * Entry point for the plugin.
- *
- * @param cls NULL
- * @return the exported block API
- */
-void *
-libgnunet_plugin_gnsrecord_messenger_init (void *cls)
-{
- struct GNUNET_GNSRECORD_PluginFunctions *api;
-
- (void) cls;
- api = GNUNET_new (struct GNUNET_GNSRECORD_PluginFunctions);
- api->value_to_string = &messenger_value_to_string;
- api->string_to_value = &messenger_string_to_value;
- api->typename_to_number = &messenger_typename_to_number;
- api->number_to_typename = &messenger_number_to_typename;
- return api;
-}
-
-
-/**
- * Exit point from the plugin.
- *
- * @param cls the return value from #libgnunet_plugin_block_test_init
- * @return NULL
- */
-void *
-libgnunet_plugin_gnsrecord_messenger_done (void *cls)
-{
- struct GNUNET_GNSRECORD_PluginFunctions *api = cls;
-
- GNUNET_free (api);
- return NULL;
-}
diff --git a/src/service/messenger/test_messenger_adapt.c
b/src/service/messenger/test_messenger_adapt.c
deleted file mode 100644
index b19634152..000000000
--- a/src/service/messenger/test_messenger_adapt.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_adapt.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 5, 1, 2, 3, 6, 7, 8, 4 };
- unsigned int stages [] = { 0x21, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x21 };
-
- struct test_configuration cfg;
- cfg.count = 8;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_adapt", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_async_client.c
b/src/service/messenger/test_messenger_async_client.c
deleted file mode 100644
index 580fc1ecb..000000000
--- a/src/service/messenger/test_messenger_async_client.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_async_client.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 0, 1 };
- unsigned int stages [] = { 0x10, 0x20 };
-
- struct test_configuration cfg;
- cfg.count = 2;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_async_client", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_async_p2p.c
b/src/service/messenger/test_messenger_async_p2p.c
deleted file mode 100644
index 762be9d49..000000000
--- a/src/service/messenger/test_messenger_async_p2p.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_async_p2p.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 2, 1 };
- unsigned int stages [] = { 0x30, 0x30 };
-
- struct test_configuration cfg;
- cfg.count = 2;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_async_p2p", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_growth.c
b/src/service/messenger/test_messenger_growth.c
deleted file mode 100644
index 4a73e559d..000000000
--- a/src/service/messenger/test_messenger_growth.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_growth.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 0, 1, 1, 1, 1, 1, 1, 1 };
- unsigned int stages [] = { 0x01, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 };
-
- struct test_configuration cfg;
- cfg.count = 8;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_growth", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_ring.c
b/src/service/messenger/test_messenger_ring.c
deleted file mode 100644
index c6b17861e..000000000
--- a/src/service/messenger/test_messenger_ring.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_ring.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 8, 1, 2, 3, 4, 5, 6, 7 };
- unsigned int stages [] = { 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21 };
-
- struct test_configuration cfg;
- cfg.count = 8;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_ring", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_server.c
b/src/service/messenger/test_messenger_server.c
deleted file mode 100644
index fdd9a3684..000000000
--- a/src/service/messenger/test_messenger_server.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_server.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 0, 1, 1, 1, 1, 1, 1, 1 };
- unsigned int stages [] = { 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
-
- struct test_configuration cfg;
- cfg.count = 8;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_server", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_sync_client.c
b/src/service/messenger/test_messenger_sync_client.c
deleted file mode 100644
index 74c9548bc..000000000
--- a/src/service/messenger/test_messenger_sync_client.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_sync_client.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 0, 1 };
- unsigned int stages [] = { 0x01, 0x20 };
-
- struct test_configuration cfg;
- cfg.count = 2;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_sync_client", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_sync_p2p.c
b/src/service/messenger/test_messenger_sync_p2p.c
deleted file mode 100644
index 299d5ff68..000000000
--- a/src/service/messenger/test_messenger_sync_p2p.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_sync_p2p.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 2, 1 };
- unsigned int stages [] = { 0x21, 0x21 };
-
- struct test_configuration cfg;
- cfg.count = 2;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_sync_p2p", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_worst_client.c
b/src/service/messenger/test_messenger_worst_client.c
deleted file mode 100644
index ab535b876..000000000
--- a/src/service/messenger/test_messenger_worst_client.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_worst_client.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 0, 1 };
- unsigned int stages [] = { 0x10, 0x02 };
-
- struct test_configuration cfg;
- cfg.count = 2;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_worst_client", &cfg);
-}
diff --git a/src/service/messenger/test_messenger_worst_p2p.c
b/src/service/messenger/test_messenger_worst_p2p.c
deleted file mode 100644
index 0af9489a4..000000000
--- a/src/service/messenger/test_messenger_worst_p2p.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/test_messenger_worst_p2p.c
- * @author Tobias Frisch
- * @brief Test for the messenger service using cadet API.
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-/**
- * The main function.
- *
- * @param argc number of arguments from the command line
- * @param argv command line arguments
- * @return 0 ok, 1 on error
- */
-int
-main (int argc,
- char **argv)
-{
- unsigned int doors [] = { 2, 1 };
- unsigned int stages [] = { 0x12, 0x12 };
-
- struct test_configuration cfg;
- cfg.count = 2;
- cfg.doors = doors;
- cfg.stages = stages;
-
- return GNUNET_run_messenger_setup ("test_messenger_worst_p2p", &cfg);
-}
diff --git a/src/service/messenger/testing_messenger_barrier.c
b/src/service/messenger/testing_messenger_barrier.c
deleted file mode 100644
index ecebe1582..000000000
--- a/src/service/messenger/testing_messenger_barrier.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021, 2023 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/testing_messenger_barrier.c
- * @author Tobias Frisch
- * @brief Pseudo-barriers for simple event handling
- */
-
-#include "platform.h"
-#include "testing_messenger_barrier.h"
-
-struct GNUNET_BarrierHandle
-{
- unsigned int requirement;
- GNUNET_BarrierStatusCallback cb;
- void *cls;
-
- struct GNUNET_BarrierWaitHandle *head;
- struct GNUNET_BarrierWaitHandle *tail;
-
- struct GNUNET_SCHEDULER_Task *task;
-};
-
-struct GNUNET_BarrierHandle*
-GNUNET_init_barrier (unsigned int requirement,
- GNUNET_BarrierStatusCallback cb,
- void *cb_cls)
-{
- if (0 == requirement)
- return NULL;
-
- struct GNUNET_BarrierHandle *barrier = GNUNET_new (struct
- GNUNET_BarrierHandle);
-
- if (! barrier)
- return NULL;
-
- barrier->requirement = requirement;
- barrier->cb = cb;
- barrier->cls = cb_cls;
- barrier->head = NULL;
- barrier->tail = NULL;
- barrier->task = NULL;
-
- return barrier;
-}
-
-
-static void
-exit_status (struct GNUNET_BarrierHandle *barrier,
- int status);
-
-static void
-cancel_barrier (void *cls)
-{
- exit_status ((struct GNUNET_BarrierHandle*) cls, GNUNET_SYSERR);
-}
-
-
-static void
-complete_barrier (void *cls)
-{
- exit_status ((struct GNUNET_BarrierHandle*) cls, GNUNET_OK);
-}
-
-
-void
-GNUNET_cancel_barrier (struct GNUNET_BarrierHandle *barrier)
-{
- if ((! barrier) || (barrier->task))
- return;
-
- barrier->task = GNUNET_SCHEDULER_add_now (cancel_barrier, barrier);
-}
-
-
-struct GNUNET_BarrierWaitHandle
-{
- GNUNET_BarrierWaitStatusCallback cb;
- void *cls;
-
- struct GNUNET_BarrierWaitHandle *prev;
- struct GNUNET_BarrierWaitHandle *next;
-
- struct GNUNET_BarrierHandle *barrier;
-};
-
-static void
-exit_status (struct GNUNET_BarrierHandle *barrier,
- int status)
-{
- struct GNUNET_BarrierWaitHandle *waiting = barrier->head;
- while (waiting)
- {
- struct GNUNET_BarrierWaitHandle *current = waiting;
-
- if (current->cb)
- current->cb (current->cls, current, status);
-
- waiting = waiting->next;
-
- GNUNET_CONTAINER_DLL_remove (barrier->head, barrier->tail, current);
- GNUNET_free (current);
- }
-
- if (barrier->cb)
- barrier->cb (barrier->cls, barrier, status);
-
- GNUNET_free (barrier);
-}
-
-
-struct GNUNET_BarrierWaitHandle*
-GNUNET_wait_barrier (struct GNUNET_BarrierHandle *barrier,
- GNUNET_BarrierWaitStatusCallback cb,
- void *cb_cls)
-{
- if ((! barrier) || (0 == barrier->requirement))
- return NULL;
-
- struct GNUNET_BarrierWaitHandle *waiting = GNUNET_new (struct
-
GNUNET_BarrierWaitHandle);
-
- if (! waiting)
- return NULL;
-
- waiting->cb = cb;
- waiting->cls = cb_cls;
- waiting->prev = NULL;
- waiting->next = NULL;
- waiting->barrier = barrier;
-
- GNUNET_CONTAINER_DLL_insert_tail (barrier->head, barrier->tail, waiting);
- barrier->requirement--;
-
- if ((barrier->requirement == 0) && (! barrier->task))
- barrier->task = GNUNET_SCHEDULER_add_now (complete_barrier, barrier);
-
- return waiting;
-}
-
-
-void
-GNUNET_cancel_wait_barrier (struct GNUNET_BarrierWaitHandle *waiting)
-{
- if (! waiting)
- return;
-
- struct GNUNET_BarrierHandle *barrier = waiting->barrier;
-
- if (! barrier)
- return;
-
- if ((barrier->requirement == 0) && (barrier->task))
- {
- GNUNET_SCHEDULER_cancel (barrier->task);
- barrier->task = NULL;
- }
-
- barrier->requirement++;
- GNUNET_CONTAINER_DLL_remove (barrier->head, barrier->tail, waiting);
-
- GNUNET_free (waiting);
-}
diff --git a/src/service/messenger/testing_messenger_barrier.h
b/src/service/messenger/testing_messenger_barrier.h
deleted file mode 100644
index 5ea0fe137..000000000
--- a/src/service/messenger/testing_messenger_barrier.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/testing_messenger_barrier.h
- * @author Tobias Frisch
- * @brief Pseudo-barriers for simple event handling
- */
-
-#ifndef GNUNET_TESTING_MESSENGER_BARRIER_H_
-#define GNUNET_TESTING_MESSENGER_BARRIER_H_
-
-#include "platform.h"
-#include "gnunet_util_lib.h"
-
-/**
- * Handle for pseudo-barrier
- */
-struct GNUNET_BarrierHandle;
-
-
-/**
- * Functions of this type are to be given as callback argument to
- * GNUNET_init_barrier(). The callback will be called when status
- * information is available for the pseudo-barrier.
- *
- * @param cls the closure given to GNUNET_init_barrier()
- * @param barrier the pseudo-barrier handle
- * @param status status of the pseudo-barrier. The pseudo-barrier is removed
- * once it has been crossed or an error occurs while processing it.
- * Therefore it is invalid to call GNUNET_cancel_barrier() on a
- * crossed or errored pseudo-barrier.
- */
-typedef void
-(*GNUNET_BarrierStatusCallback) (void *cls,
- struct GNUNET_BarrierHandle *barrier,
- int status);
-
-
-/**
- * Initialise a pseudo-barrier and call the given callback when the required
- * amount of peers (requirement) reach the pseudo-barrier OR upon error.
- *
- * @param requirement the amount of peers that is required to reach the
- * pseudo-barrier. Peers signal reaching a pseudo-barrier by calling
- * GNUNET_wait_barrier().
- * @param cb the callback to call when the pseudo-barrier is reached or upon
- * error. Can be NULL.
- * @param cb_cls closure for the above callback
- * @return pseudo-barrier handle; NULL upon error
- */
-struct GNUNET_BarrierHandle*
-GNUNET_init_barrier (unsigned int requirement,
- GNUNET_BarrierStatusCallback cb,
- void *cb_cls);
-
-
-/**
- * Cancel a pseudo-barrier.
- *
- * @param barrier the pseudo-barrier handle
- */
-void
-GNUNET_cancel_barrier (struct GNUNET_BarrierHandle *barrier);
-
-
-/**
- * Handle for pseudo-barrier wait
- */
-struct GNUNET_BarrierWaitHandle;
-
-
-/**
- * Functions of this type are to be given as acallback argument to
- * GNUNET_wait_barrier(). The callback will be called when the pseudo-barrier
- * corresponding given in GNUNET_wait_barrier() is crossed or cancelled.
- *
- * @param cls closure pointer given to GNUNET_wait_barrier()
- * @param waiting the pseudo-barrier wait handle
- * @param status #GNUNET_SYSERR in case of error while waiting for the
- * pseudo-barrier; #GNUNET_OK if the pseudo-barrier is crossed
- */
-typedef void
-(*GNUNET_BarrierWaitStatusCallback) (void *cls,
- struct GNUNET_BarrierWaitHandle *waiting,
- int status);
-
-
-/**
- * Wait for a pseudo-barrier to be crossed. This function should be called for
- * the peers which have been started by the testbed.
- *
- * @param barrier the pseudo-barrier handle
- * @param cb the pseudo-barrier wait callback
- * @param cb_cls the closure for the above callback
- * @return pseudo-barrier wait handle which can be used to cancel the waiting
- * at anytime before the callback is called. NULL upon error.
- */
-struct GNUNET_BarrierWaitHandle*
-GNUNET_wait_barrier (struct GNUNET_BarrierHandle *barrier,
- GNUNET_BarrierWaitStatusCallback cb,
- void *cb_cls);
-
-
-/**
- * Cancel a pseudo-barrier wait handle. Should not be called in or after the
- * callback given to GNUNET_wait_barrier() has been called.
- *
- * @param waiting the pseudo-barrier wait handle
- */
-void
-GNUNET_cancel_wait_barrier (struct GNUNET_BarrierWaitHandle *waiting);
-
-
-#endif /* GNUNET_TESTING_MESSENGER_BARRIER_H_ */
diff --git a/src/service/messenger/testing_messenger_setup.c
b/src/service/messenger/testing_messenger_setup.c
deleted file mode 100644
index e4dfa203f..000000000
--- a/src/service/messenger/testing_messenger_setup.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2020--2023 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/testing_messenger_barrier.c
- * @author Tobias Frisch
- * @brief A simple test-case setup for the messenger service
- */
-
-#include "platform.h"
-#include "testing_messenger_setup.h"
-
-#include <stdio.h>
-#include "gnunet_util_lib.h"
-#include "gnunet_testbed_logger_service.h"
-#include "gnunet_testbed_service.h"
-#include "gnunet_testing_lib.h"
-#include "gnunet_messenger_service.h"
-#include "testing_messenger_barrier.h"
-
-#define TEST_ROOM "test"
-#define TEST_NAME "tester"
-
-struct test_properties;
-
-struct test_peer
-{
- struct test_properties *props;
- unsigned int num;
-
- struct GNUNET_SCHEDULER_Task *op_task;
- struct GNUNET_TESTBED_Operation *op;
-
- struct GNUNET_TESTBED_Peer *peer;
- struct GNUNET_PeerIdentity peer_id;
- struct GNUNET_BarrierWaitHandle *wait;
-
- struct GNUNET_MESSENGER_Handle *handle;
- struct GNUNET_MESSENGER_Room *room;
-
- struct GNUNET_CONTAINER_MultiPeerMap *map;
-
- const char *message;
-};
-
-struct test_properties
-{
- const struct test_configuration *cfg;
-
- unsigned int num_hosts;
-
- struct GNUNET_SCHEDULER_Task *die_task;
- struct GNUNET_SCHEDULER_Task *end_task;
-
- struct GNUNET_BarrierHandle *barrier;
-
- struct test_peer *peers;
- unsigned int num_peer;
-
- int status;
-};
-
-static void
-shutdown_cb (void *cls)
-{
- struct test_properties *properties = cls;
-
- for (unsigned int i = 0; i < properties->num_peer; i++)
- {
- struct test_peer *peer = &properties->peers[i];
-
- GNUNET_assert (peer != NULL);
-
- if (peer->op_task)
- GNUNET_SCHEDULER_cancel (peer->op_task);
-
- peer->op_task = NULL;
-
- if (peer->op)
- GNUNET_TESTBED_operation_done (peer->op);
-
- peer->op = NULL;
-
- if (peer->wait)
- GNUNET_cancel_wait_barrier (peer->wait);
-
- peer->wait = NULL;
-
- if (peer->room)
- GNUNET_MESSENGER_close_room (peer->room);
-
- peer->room = NULL;
-
- if (peer->handle)
- GNUNET_MESSENGER_disconnect (peer->handle);
-
- if (peer->map)
- GNUNET_CONTAINER_multipeermap_destroy (peer->map);
-
- peer->handle = NULL;
- }
-
- if (properties->die_task)
- GNUNET_SCHEDULER_cancel (properties->die_task);
-
- properties->die_task = NULL;
- properties->end_task = NULL;
-
- if (properties->barrier)
- GNUNET_cancel_barrier (properties->barrier);
-
- properties->barrier = NULL;
-}
-
-
-static void
-end_cb (void *cls)
-{
- struct test_properties *properties = cls;
-
- GNUNET_assert (properties != NULL);
-
- properties->die_task = NULL;
-
- int status = 0;
-
- for (unsigned int i = 0; i < properties->num_peer; i++)
- {
- struct test_peer *peer = &properties->peers[i];
-
- GNUNET_assert (peer != NULL);
-
- const int members = GNUNET_MESSENGER_iterate_members (peer->room, NULL,
- NULL);
-
- GNUNET_assert (members >= 0);
-
- if (peer->props->num_peer != (unsigned int) members)
- {
- fprintf (stderr, "Testcase failed (members: %d/%u).\n", members,
- peer->props->num_peer);
- status = 1;
- break;
- }
- }
-
- GNUNET_SCHEDULER_shutdown ();
-
- properties->status = status;
-}
-
-
-static void
-end_badly_cb (void *cls)
-{
- struct test_properties *properties = cls;
-
- GNUNET_assert (properties != NULL);
-
- fprintf (stderr, "Testcase failed (timeout).\n");
-
- end_cb (properties);
-
- properties->status = 1;
-}
-
-
-static void
-end_operation_cb (void *cls)
-{
- struct test_peer *peer = cls;
-
- GNUNET_assert (peer != NULL);
-
- peer->op_task = NULL;
-
- fprintf (stderr, "Testcase failed (operation: '%s').\n", peer->message);
-
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-static void
-end_error_cb (void *cls)
-{
- struct test_peer *peer = cls;
-
- GNUNET_assert (peer != NULL);
-
- peer->op_task = NULL;
-
- fprintf (stderr, "Testcase failed (error: '%s').\n", peer->message);
- GNUNET_free (peer);
-
- GNUNET_SCHEDULER_shutdown ();
-}
-
-
-static void
-barrier2_wait_cb (void *cls,
- struct GNUNET_BarrierWaitHandle *waiting,
- int status)
-{
- struct test_peer *peer = cls;
-
- GNUNET_assert (peer != NULL);
-
- if (peer->wait == waiting)
- peer->wait = NULL;
-}
-
-
-static void
-barrier_wait_cb (void *cls,
- struct GNUNET_BarrierWaitHandle *waiting,
- int status)
-{
- struct test_peer *peer = cls;
-
- GNUNET_assert (peer != NULL);
-
- if (peer->wait == waiting)
- peer->wait = NULL;
-
- if (0 != (peer->props->cfg->stages[peer->num - 1] & 0x02))
- {
- unsigned int door = peer->props->cfg->doors[peer->num - 1];
-
- if (door == 0)
- door = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- peer->props->cfg->count);
- else
- door = door - 1;
-
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (TEST_ROOM, sizeof(TEST_ROOM), &hash);
-
- struct GNUNET_MESSENGER_Room *room;
- room = GNUNET_MESSENGER_enter_room (peer->handle,
- &(peer->props->peers[door].peer_id),
- &hash);
-
- if (peer->room)
- GNUNET_assert (room == peer->room);
- else
- GNUNET_assert (room != NULL);
-
- peer->room = room;
- }
-}
-
-
-/**
- * Function called whenever a message is received or sent.
- *
- * @param cls Closure
- * @param room Room
- * @param sender Sender
- * @param message Message
- * @param hash Hash of message
- * @param flags Flags of message
- */
-static void
-on_message (void *cls,
- struct GNUNET_MESSENGER_Room *room,
- const struct GNUNET_MESSENGER_Contact *sender,
- const struct GNUNET_MESSENGER_Message *message,
- const struct GNUNET_HashCode *hash,
- enum GNUNET_MESSENGER_MessageFlags flags)
-{
- struct test_peer *peer = cls;
-
- GNUNET_assert (peer != NULL);
-
- fprintf (stderr, "Peer: %s; [%s] Message: %s (%s)\n",
- GNUNET_i2s (&(peer->peer_id)),
- GNUNET_sh2s (&(message->header.sender_id)),
- GNUNET_MESSENGER_name_of_kind (message->header.kind),
- GNUNET_h2s (hash));
-
- if (GNUNET_MESSENGER_KIND_PEER == message->header.kind)
- GNUNET_CONTAINER_multipeermap_put (peer->map, &(message->body.peer.peer),
- NULL,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
-
- const int members = GNUNET_MESSENGER_iterate_members (peer->room, NULL,
NULL);
-
- const uint32_t num_peers = GNUNET_CONTAINER_multipeermap_size (peer->map);
- if ((members == peer->props->num_peer) && (peer->props->num_hosts ==
- num_peers))
- peer->wait = GNUNET_wait_barrier (peer->props->barrier, &barrier2_wait_cb,
- peer);
- else if (peer->props->num_hosts < num_peers)
- {
- if (peer->wait)
- GNUNET_cancel_wait_barrier (peer->wait);
-
- peer->wait = NULL;
-
- if (peer->op_task)
- GNUNET_SCHEDULER_cancel (peer->op_task);
-
- peer->message = "peer";
- peer->op_task = GNUNET_SCHEDULER_add_now (&end_operation_cb, peer);
- }
-}
-
-
-static void
-second_stage (void *cls)
-{
- struct test_peer *peer = cls;
-
- GNUNET_assert (peer != NULL);
-
- peer->op_task = NULL;
-
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (TEST_ROOM, sizeof(TEST_ROOM), &hash);
-
- if (0 != (peer->props->cfg->stages[peer->num - 1] & 0x10))
- {
- struct GNUNET_MESSENGER_Room *room;
- room = GNUNET_MESSENGER_open_room (peer->handle, &hash);
-
- if (peer->room)
- GNUNET_assert (room == peer->room);
- else
- GNUNET_assert (room != NULL);
-
- peer->room = room;
- }
-
- if (0 != (peer->props->cfg->stages[peer->num - 1] & 0x20))
- {
- unsigned int door = peer->props->cfg->doors[peer->num - 1];
-
- if (door == 0)
- door = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
- peer->props->cfg->count);
- else
- door = door - 1;
-
- struct GNUNET_MESSENGER_Room *room;
- room = GNUNET_MESSENGER_enter_room (peer->handle,
- &(peer->props->peers[door].peer_id),
- &hash);
-
- if (peer->room)
- GNUNET_assert (room == peer->room);
- else
- GNUNET_assert (room != NULL);
-
- peer->room = room;
- }
-}
-
-
-static void
-on_peer (void *cb_cls,
- struct GNUNET_TESTBED_Operation *op,
- const struct GNUNET_TESTBED_PeerInformation *pinfo,
- const char *emsg)
-{
- struct test_peer *peer = cb_cls;
-
- GNUNET_assert (peer != NULL);
-
- if (emsg)
- {
- peer->message = GNUNET_strdup (emsg);
- peer->op_task = GNUNET_SCHEDULER_add_now (&end_error_cb, peer);
- return;
- }
-
- if (! pinfo)
- {
- peer->message = "info";
- peer->op_task = GNUNET_SCHEDULER_add_now (&end_operation_cb, peer);
- return;
- }
-
- if (pinfo->pit != GNUNET_TESTBED_PIT_CONFIGURATION)
- {
- peer->message = "config";
- peer->op_task = GNUNET_SCHEDULER_add_now (&end_operation_cb, peer);
- return;
- }
-
- peer->handle = GNUNET_MESSENGER_connect (pinfo->result.cfg, TEST_NAME, NULL,
- &on_message, peer);
-
- GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_get_peer_identity (
- pinfo->result.cfg, &(peer->peer_id)
- ));
-
- if (0 != (peer->props->cfg->stages[peer->num - 1] & 0x01))
- {
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (TEST_ROOM, sizeof(TEST_ROOM), &hash);
-
- peer->room = GNUNET_MESSENGER_open_room (peer->handle, &hash);
-
- GNUNET_assert (peer->room != NULL);
- }
- else
- peer->room = NULL;
-
- peer->wait = GNUNET_wait_barrier (peer->props->barrier, &barrier_wait_cb,
- peer);
-}
-
-
-/**
- * Main function for a peer of the testcase.
- *
- * @param cls Closure
- * @param event Information about the event
- */
-static void
-run (void *cls,
- const struct GNUNET_TESTBED_EventInformation *event)
-{
- struct test_properties *properties = cls;
-
- GNUNET_assert (properties != NULL);
-
- if (GNUNET_TESTBED_ET_PEER_START != event->type)
- {
- fprintf (stderr, "Testcase failed (operation: 'start').\n");
-
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- struct test_peer *peer = &(properties->peers[properties->num_peer++]);
-
- peer->props = properties;
- peer->num = properties->num_peer;
-
- peer->peer = event->details.peer_start.peer;
- peer->op = GNUNET_TESTBED_peer_get_information (peer->peer,
-
GNUNET_TESTBED_PIT_CONFIGURATION,
- on_peer, peer);
-
- peer->map = GNUNET_CONTAINER_multipeermap_create (peer->props->num_hosts,
- GNUNET_NO);
-}
-
-
-static void
-barrier2_cb (void *cls,
- struct GNUNET_BarrierHandle *barrier,
- int status)
-{
- struct test_properties *properties = cls;
-
- GNUNET_assert (properties != NULL);
-
- if (properties->barrier == barrier)
- properties->barrier = NULL;
-
- if (GNUNET_SYSERR == status)
- {
- fprintf (stderr, "Testcase failed (operation: 'barrier2').\n");
-
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- else if (GNUNET_OK == status)
- {
- if (properties->die_task)
- GNUNET_SCHEDULER_cancel (properties->die_task);
-
- properties->die_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- properties->cfg->count),
- &end_cb, properties
- );
- }
-}
-
-
-static void
-barrier_cb (void *cls,
- struct GNUNET_BarrierHandle *barrier,
- int status)
-{
- struct test_properties *properties = cls;
-
- GNUNET_assert (properties != NULL);
-
- if (properties->barrier == barrier)
- properties->barrier = NULL;
- else if (! properties->barrier)
- return;
-
- if (properties->num_peer != properties->cfg->count)
- {
- fprintf (stderr, "Testcase failed (operation: 'process').\n");
-
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
-
- if (GNUNET_SYSERR == status)
- {
- fprintf (stderr, "Testcase failed (operation: 'barrier').\n");
-
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- else if (GNUNET_OK == status)
- {
- properties->barrier = GNUNET_init_barrier (properties->num_peer,
- &barrier2_cb, properties);
-
- for (unsigned int i = 0; i < properties->num_peer; i++)
- properties->peers[i].op_task = GNUNET_SCHEDULER_add_now (&second_stage,
- &(properties->
- peers[i]));
- }
-}
-
-
-static void
-init (void *cls,
- struct GNUNET_TESTBED_RunHandle *h,
- unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers,
- unsigned int links_succeeded,
- unsigned int links_failed)
-{
- struct test_properties *properties = cls;
-
- GNUNET_assert (properties != NULL);
-
- properties->end_task = GNUNET_SCHEDULER_add_shutdown (&shutdown_cb,
- properties);
- properties->die_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- properties->cfg->count * 5),
- &end_badly_cb, properties
- );
-}
-
-
-int
-GNUNET_run_messenger_setup (const char *test_name,
- const struct test_configuration *cfg)
-{
- struct test_properties properties;
- memset (&properties, 0, sizeof(properties));
-
- properties.cfg = cfg;
- properties.peers = GNUNET_new_array (cfg->count, struct test_peer);
-
- for (unsigned int i = 0; i < cfg->count; i++)
- if (0 != (cfg->stages[i] & 0x11))
- properties.num_hosts++;
-
- properties.status = 1;
- properties.barrier = GNUNET_init_barrier (cfg->count, &barrier_cb,
- &properties);
-
- if (GNUNET_OK != GNUNET_TESTBED_test_run (test_name,
- "test_messenger_api.conf",
- cfg->count,
- (1LL <<
- GNUNET_TESTBED_ET_PEER_START),
- &run, &properties,
- &init, &properties))
- return 1;
-
- GNUNET_free (properties.peers);
-
- return properties.status;
-}
diff --git a/src/service/messenger/testing_messenger_setup.h
b/src/service/messenger/testing_messenger_setup.h
deleted file mode 100644
index d2e72b51f..000000000
--- a/src/service/messenger/testing_messenger_setup.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- This file is part of GNUnet.
- Copyright (C) 2021, 2023 GNUnet e.V.
-
- GNUnet is free software: you can redistribute it and/or modify it
- under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License,
- or (at your option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- 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/>.
-
- SPDX-License-Identifier: AGPL3.0-or-later
- */
-/**
- * @file messenger/testing_messenger_setup.h
- * @author Tobias Frisch
- * @brief A simple test-case setup for the messenger service
- */
-
-#ifndef GNUNET_TESTING_MESSENGER_SETUP_H_
-#define GNUNET_TESTING_MESSENGER_SETUP_H_
-
-struct test_configuration
-{
- unsigned int count;
- unsigned int *doors;
- unsigned int *stages;
-};
-
-int
-GNUNET_run_messenger_setup (const char *test_name,
- const struct test_configuration *cfg);
-
-#endif /* GNUNET_TESTING_MESSENGER_SETUP_H_ */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: MESSENGER: Cleanup unused code files in service directory,
gnunet <=