summaryrefslogtreecommitdiff
path: root/src/messenger
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger')
-rw-r--r--src/messenger/gnunet-messenger.c16
-rw-r--r--src/messenger/gnunet-service-messenger.c272
-rw-r--r--src/messenger/gnunet-service-messenger.h4
-rw-r--r--src/messenger/gnunet-service-messenger_basement.c1
-rw-r--r--src/messenger/gnunet-service-messenger_ego_store.c274
-rw-r--r--src/messenger/gnunet-service-messenger_ego_store.h71
-rw-r--r--src/messenger/gnunet-service-messenger_handle.c175
-rw-r--r--src/messenger/gnunet-service-messenger_handle.h101
-rw-r--r--src/messenger/gnunet-service-messenger_list_handles.c7
-rw-r--r--src/messenger/gnunet-service-messenger_list_handles.h13
-rw-r--r--src/messenger/gnunet-service-messenger_list_messages.c1
-rw-r--r--src/messenger/gnunet-service-messenger_list_messages.h12
-rw-r--r--src/messenger/gnunet-service-messenger_member.c1
-rw-r--r--src/messenger/gnunet-service-messenger_member.h20
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.c13
-rw-r--r--src/messenger/gnunet-service-messenger_member_session.h19
-rw-r--r--src/messenger/gnunet-service-messenger_member_store.c5
-rw-r--r--src/messenger/gnunet-service-messenger_member_store.h15
-rw-r--r--src/messenger/gnunet-service-messenger_message_handle.c17
-rw-r--r--src/messenger/gnunet-service-messenger_message_handle.h34
-rw-r--r--src/messenger/gnunet-service-messenger_message_kind.c1
-rw-r--r--src/messenger/gnunet-service-messenger_message_kind.h5
-rw-r--r--src/messenger/gnunet-service-messenger_message_recv.c17
-rw-r--r--src/messenger/gnunet-service-messenger_message_recv.h14
-rw-r--r--src/messenger/gnunet-service-messenger_message_send.c9
-rw-r--r--src/messenger/gnunet-service-messenger_message_send.h18
-rw-r--r--src/messenger/gnunet-service-messenger_message_state.c1
-rw-r--r--src/messenger/gnunet-service-messenger_message_state.h2
-rw-r--r--src/messenger/gnunet-service-messenger_message_store.c3
-rw-r--r--src/messenger/gnunet-service-messenger_message_store.h15
-rw-r--r--src/messenger/gnunet-service-messenger_operation.c1
-rw-r--r--src/messenger/gnunet-service-messenger_operation.h11
-rw-r--r--src/messenger/gnunet-service-messenger_operation_store.c1
-rw-r--r--src/messenger/gnunet-service-messenger_operation_store.h12
-rw-r--r--src/messenger/gnunet-service-messenger_room.c249
-rw-r--r--src/messenger/gnunet-service-messenger_room.h167
-rw-r--r--src/messenger/gnunet-service-messenger_service.c33
-rw-r--r--src/messenger/gnunet-service-messenger_service.h36
-rw-r--r--src/messenger/gnunet-service-messenger_tunnel.c15
-rw-r--r--src/messenger/gnunet-service-messenger_tunnel.h29
-rw-r--r--src/messenger/messenger.conf.in6
-rw-r--r--src/messenger/messenger_api.c19
-rw-r--r--src/messenger/messenger_api_contact.c1
-rw-r--r--src/messenger/messenger_api_contact.h12
-rw-r--r--src/messenger/messenger_api_contact_store.c1
-rw-r--r--src/messenger/messenger_api_contact_store.h17
-rw-r--r--src/messenger/messenger_api_handle.c1
-rw-r--r--src/messenger/messenger_api_handle.h22
-rw-r--r--src/messenger/messenger_api_list_tunnels.c1
-rw-r--r--src/messenger/messenger_api_list_tunnels.h19
-rw-r--r--src/messenger/messenger_api_message.c31
-rw-r--r--src/messenger/messenger_api_message.h13
-rw-r--r--src/messenger/messenger_api_room.c1
-rw-r--r--src/messenger/messenger_api_room.h15
-rw-r--r--src/messenger/messenger_api_util.c1
-rw-r--r--src/messenger/messenger_api_util.h6
-rw-r--r--src/messenger/plugin_gnsrecord_messenger.c59
-rw-r--r--src/messenger/test_messenger.c2
-rw-r--r--src/messenger/test_messenger_adapt.c1
-rw-r--r--src/messenger/test_messenger_anonymous.c2
-rw-r--r--src/messenger/test_messenger_async_client.c1
-rw-r--r--src/messenger/test_messenger_async_p2p.c1
-rw-r--r--src/messenger/test_messenger_growth.c1
-rw-r--r--src/messenger/test_messenger_ring.c1
-rw-r--r--src/messenger/test_messenger_server.c1
-rw-r--r--src/messenger/test_messenger_sync_client.c1
-rw-r--r--src/messenger/test_messenger_sync_p2p.c1
-rw-r--r--src/messenger/test_messenger_worst_client.c1
-rw-r--r--src/messenger/test_messenger_worst_p2p.c1
-rw-r--r--src/messenger/testing_messenger_barrier.c1
-rw-r--r--src/messenger/testing_messenger_barrier.h4
-rw-r--r--src/messenger/testing_messenger_setup.c2
72 files changed, 1175 insertions, 781 deletions
diff --git a/src/messenger/gnunet-messenger.c b/src/messenger/gnunet-messenger.c
index e2d106be8..9444fa12d 100644
--- a/src/messenger/gnunet-messenger.c
+++ b/src/messenger/gnunet-messenger.c
@@ -23,9 +23,9 @@
* @brief Print information about messenger groups.
*/
+#include "platform.h"
#include <stdio.h>
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_messenger_service.h"
@@ -34,7 +34,7 @@ struct GNUNET_MESSENGER_Handle *messenger;
/**
* Function called whenever a message is received or sent.
*
- * @param[in/out] cls Closure
+ * @param[in,out] cls Closure
* @param[in] room Room
* @param[in] sender Sender of message
* @param[in] message Message
@@ -104,7 +104,7 @@ struct GNUNET_SCHEDULER_Task *read_task;
/**
* Task to shut down this application.
*
- * @param[in/out] cls Closure
+ * @param[in,out] cls Closure
*/
static void
shutdown_hook (void *cls)
@@ -144,7 +144,7 @@ int private_mode;
/**
* Task run in stdio mode, after some data is available at stdin.
*
- * @param[in/out] cls Closure
+ * @param[in,out] cls Closure
*/
static void
read_stdio (void *cls)
@@ -184,7 +184,7 @@ read_stdio (void *cls)
/**
* Wait for input on STDIO and send it out over the #ch.
*
- * @param[in/out] cls Closure
+ * @param[in,out] cls Closure
*/
static void
listen_stdio (void *cls)
@@ -205,7 +205,7 @@ listen_stdio (void *cls)
/**
* Initial task to startup application.
*
- * @param[in/out] cls Closure
+ * @param[in,out] cls Closure
*/
static void
idle (void *cls)
@@ -226,8 +226,8 @@ struct GNUNET_SCHEDULER_Task *shutdown_task;
/**
* Function called when an identity is retrieved.
*
- * @param[in/out] cls Closure
- * @param[in/out] handle Handle of messenger service
+ * @param[in,out] cls Closure
+ * @param[in,out] handle Handle of messenger service
*/
static void
on_identity (void *cls,
diff --git a/src/messenger/gnunet-service-messenger.c b/src/messenger/gnunet-service-messenger.c
index 546f4c0d2..f0bb853d7 100644
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger.h"
#include "gnunet-service-messenger_handle.h"
@@ -42,7 +43,7 @@ static int
check_create (void *cls,
const struct GNUNET_MESSENGER_CreateMessage *msg)
{
- GNUNET_MQ_check_zero_termination(msg);
+ GNUNET_MQ_check_zero_termination (msg);
return GNUNET_OK;
}
@@ -54,9 +55,9 @@ handle_create (void *cls,
const char *name = ((const char*) msg) + sizeof(*msg);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handle created with name: %s\n", name);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle created with name: %s\n", name);
- setup_handle_name (msg_client->handle, strlen (name) > 0 ? name : NULL);
+ setup_srv_handle_name (msg_client->handle, strlen (name) > 0 ? name : NULL);
GNUNET_SERVICE_client_continue (msg_client->client);
}
@@ -67,7 +68,7 @@ handle_update (void *cls,
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
- update_handle (msg_client->handle);
+ update_srv_handle (msg_client->handle);
GNUNET_SERVICE_client_continue (msg_client->client);
}
@@ -85,7 +86,7 @@ static int
check_set_name (void *cls,
const struct GNUNET_MESSENGER_NameMessage *msg)
{
- GNUNET_MQ_check_zero_termination(msg);
+ GNUNET_MQ_check_zero_termination (msg);
return GNUNET_OK;
}
@@ -97,9 +98,9 @@ handle_set_name (void *cls,
const char *name = ((const char*) msg) + sizeof(*msg);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handles name is now: %s\n", name);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handles name is now: %s\n", name);
- set_handle_name (msg_client->handle, name);
+ set_srv_handle_name (msg_client->handle, name);
GNUNET_SERVICE_client_continue (msg_client->client);
}
@@ -110,23 +111,27 @@ handle_room_open (void *cls,
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (&(msg->key)));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room: %s\n", GNUNET_h2s (
+ &(msg->key)));
- if (GNUNET_YES == open_handle_room (msg_client->handle, &(msg->key)))
+ if (GNUNET_YES == open_srv_handle_room (msg_client->handle, &(msg->key)))
{
- const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (msg_client->handle, &(msg->key));
+ const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (
+ msg_client->handle, &(msg->key));
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n", GNUNET_sh2s (member_id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n",
+ GNUNET_sh2s (member_id));
struct GNUNET_MESSENGER_RoomMessage *response;
struct GNUNET_MQ_Envelope *env;
- env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN);
- GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key));
+ env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN);
+ GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
GNUNET_MQ_send (msg_client->handle->mq, env);
}
else
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n", GNUNET_h2s (&(msg->key)));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Opening room failed: %s\n",
+ GNUNET_h2s (&(msg->key)));
GNUNET_SERVICE_client_continue (msg_client->client);
}
@@ -137,25 +142,30 @@ handle_room_entry (void *cls,
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (&(msg->key)), GNUNET_i2s (&(msg->door)));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room: %s, %s\n", GNUNET_h2s (
+ &(msg->key)), GNUNET_i2s (&(msg->door)));
- if (GNUNET_YES == entry_handle_room (msg_client->handle, &(msg->door), &(msg->key)))
+ if (GNUNET_YES == entry_srv_handle_room (msg_client->handle, &(msg->door),
+ &(msg->key)))
{
- const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (msg_client->handle, &(msg->key));
+ const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (
+ msg_client->handle, &(msg->key));
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n", GNUNET_sh2s (member_id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n",
+ GNUNET_sh2s (member_id));
struct GNUNET_MESSENGER_RoomMessage *response;
struct GNUNET_MQ_Envelope *env;
- env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY);
- GNUNET_memcpy(&(response->door), &(msg->door), sizeof(msg->door));
- GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key));
+ env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY);
+ GNUNET_memcpy (&(response->door), &(msg->door), sizeof(msg->door));
+ GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
GNUNET_MQ_send (msg_client->handle->mq, env);
}
else
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n", GNUNET_h2s (&(msg->key)),
- GNUNET_i2s (&(msg->door)));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Entrance into room failed: %s, %s\n",
+ GNUNET_h2s (&(msg->key)),
+ GNUNET_i2s (&(msg->door)));
GNUNET_SERVICE_client_continue (msg_client->client);
}
@@ -166,23 +176,24 @@ handle_room_close (void *cls,
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (&(msg->key)));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room: %s\n", GNUNET_h2s (
+ &(msg->key)));
- if (GNUNET_YES == close_handle_room (msg_client->handle, &(msg->key)))
+ if (GNUNET_YES == close_srv_handle_room (msg_client->handle, &(msg->key)))
{
- const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (msg_client->handle, &(msg->key));
-
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Closing room with member id: %s\n", GNUNET_sh2s (member_id));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n",
+ GNUNET_h2s (&(msg->key)));
struct GNUNET_MESSENGER_RoomMessage *response;
struct GNUNET_MQ_Envelope *env;
- env = GNUNET_MQ_msg(response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE);
- GNUNET_memcpy(&(response->key), &(msg->key), sizeof(msg->key));
+ env = GNUNET_MQ_msg (response, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE);
+ GNUNET_memcpy (&(response->key), &(msg->key), sizeof(msg->key));
GNUNET_MQ_send (msg_client->handle->mq, env);
}
else
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n", GNUNET_h2s (&(msg->key)));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Closing room failed: %s\n",
+ GNUNET_h2s (&(msg->key)));
GNUNET_SERVICE_client_continue (msg_client->client);
}
@@ -197,39 +208,38 @@ check_send_message (void *cls,
return GNUNET_NO;
const enum GNUNET_MESSENGER_MessageFlags flags = (
- (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
- );
+ (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
+ );
const uint16_t length = full_length - sizeof(*msg);
const char *buffer = ((const char*) msg) + sizeof(*msg);
-
- ssize_t key_length = 0;
-
- if (!(flags & GNUNET_MESSENGER_FLAG_PRIVATE))
- goto check_for_message;
-
struct GNUNET_IDENTITY_PublicKey public_key;
- key_length = GNUNET_IDENTITY_read_key_from_buffer(&public_key, buffer, length);
-check_for_message:
- if (key_length < 0)
- return GNUNET_NO;
+ size_t key_length = 0;
+
+ if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE))
+ if (GNUNET_SYSERR ==
+ GNUNET_IDENTITY_read_public_key_from_buffer (buffer, length,
+ &public_key,
+ &key_length))
+ return GNUNET_NO;
const uint16_t msg_length = length - key_length;
- const char* msg_buffer = buffer + key_length;
+ const char *msg_buffer = buffer + key_length;
struct GNUNET_MESSENGER_Message message;
- if (length < get_message_kind_size(GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO))
+ if (length < get_message_kind_size (GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO))
return GNUNET_NO;
- if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL))
+ if (GNUNET_YES != decode_message (&message, msg_length, msg_buffer, GNUNET_NO,
+ NULL))
return GNUNET_NO;
- const int allowed = filter_message_sending(&message);
+ const int allowed = filter_message_sending (&message);
- cleanup_message(&message);
+ cleanup_message (&message);
return GNUNET_YES == allowed? GNUNET_OK : GNUNET_NO;
}
@@ -240,45 +250,51 @@ handle_send_message (void *cls,
struct GNUNET_MESSENGER_Client *msg_client = cls;
const enum GNUNET_MESSENGER_MessageFlags flags = (
- (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
- );
+ (enum GNUNET_MESSENGER_MessageFlags) (msg->flags)
+ );
const struct GNUNET_HashCode *key = &(msg->key);
const char *buffer = ((const char*) msg) + sizeof(*msg);
const uint16_t length = ntohs (msg->header.size) - sizeof(*msg);
- ssize_t key_length = 0;
+ size_t key_length = 0;
struct GNUNET_IDENTITY_PublicKey public_key;
if (flags & GNUNET_MESSENGER_FLAG_PRIVATE)
- key_length = GNUNET_IDENTITY_read_key_from_buffer(
- &public_key, buffer, length
- );
-
+ {
+ GNUNET_assert (GNUNET_SYSERR !=
+ GNUNET_IDENTITY_read_public_key_from_buffer (buffer,
+ length,
+ &public_key,
+ &key_length));
+ }
const uint16_t msg_length = length - key_length;
- const char* msg_buffer = buffer + key_length;
+ const char*msg_buffer = buffer + key_length;
struct GNUNET_MESSENGER_Message message;
decode_message (&message, msg_length, msg_buffer, GNUNET_NO, NULL);
if ((flags & GNUNET_MESSENGER_FLAG_PRIVATE) &&
- (GNUNET_YES != encrypt_message(&message, &public_key)))
+ (GNUNET_YES != encrypt_message (&message, &public_key)))
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Encrypting message failed: Message got dropped!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Encrypting message failed: Message got dropped!\n");
goto end_handling;
}
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s\n",
- GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (key));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message: %s to %s\n",
+ GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (
+ key));
- if (GNUNET_YES != send_handle_message (msg_client->handle, key, &message))
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n",
- GNUNET_MESSENGER_name_of_kind (message.header.kind), GNUNET_h2s (key));
+ if (GNUNET_YES != send_srv_handle_message (msg_client->handle, key, &message))
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sending message failed: %s to %s\n",
+ GNUNET_MESSENGER_name_of_kind (message.header.kind),
+ GNUNET_h2s (key));
-end_handling:
- cleanup_message(&message);
+ end_handling:
+ cleanup_message (&message);
GNUNET_SERVICE_client_continue (msg_client->client);
}
@@ -291,26 +307,30 @@ callback_found_message (void *cls,
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
- if (!message)
+ if (! message)
{
- send_room_message(room, msg_client->handle, create_message_request(hash));
+ send_srv_room_message (room, msg_client->handle, create_message_request (
+ hash));
return;
}
- struct GNUNET_MESSENGER_MemberStore *store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *store = get_srv_room_member_store (room);
- struct GNUNET_MESSENGER_Member *member = get_store_member_of(store, message);
+ struct GNUNET_MESSENGER_Member *member = get_store_member_of (store, message);
- if (!member)
+ if (! member)
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n", GNUNET_h2s (hash));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sender of message (%s) unknown!\n",
+ GNUNET_h2s (hash));
return;
}
- struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash);
+ struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of (
+ member, message, hash);
if (session)
- notify_handle_message (msg_client->handle, room, session, message, hash);
+ notify_srv_handle_message (msg_client->handle, room, session, message,
+ hash);
}
static void
@@ -319,39 +339,55 @@ handle_get_message (void *cls,
{
struct GNUNET_MESSENGER_Client *msg_client = cls;
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n", GNUNET_h2s (&(msg->key)));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Requesting message from room: %s\n",
+ GNUNET_h2s (&(msg->key)));
- struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (messenger, &(msg->key));
+ struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (messenger,
+ &(msg->key));
- if (!room)
+ if (! room)
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (&(msg->key)));
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Room not found: %s\n", GNUNET_h2s (
+ &(msg->key)));
goto end_handling;
}
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store =
+ get_srv_room_member_store (room);
- struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, get_handle_member_id(
- msg_client->handle, &(msg->key)
- ));
+ struct GNUNET_MESSENGER_Member *member = get_store_member (member_store,
+ get_srv_handle_member_id (
+ msg_client->
+ handle,
+ &(msg->key)
+ ));
- if (!member)
+ if (! member)
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Member not valid to request a message!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Member not valid to request a message!\n");
goto end_handling;
}
- struct GNUNET_MESSENGER_MemberSession *session = get_member_session(member, &(get_handle_ego(msg_client->handle)->pub));
+ struct GNUNET_MESSENGER_MemberSession *session = get_member_session (member,
+ &(
+ get_srv_handle_ego (
+ msg_client
+ ->
+ handle)
+ ->pub));
- if (!session)
+ if (! session)
{
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Session not valid to request a message!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Session not valid to request a message!\n");
goto end_handling;
}
- request_room_message (room, &(msg->hash), session, callback_found_message, msg_client);
+ request_srv_room_message (room, &(msg->hash), session, callback_found_message,
+ msg_client);
-end_handling:
+ end_handling:
GNUNET_SERVICE_client_continue (msg_client->client);
}
@@ -360,7 +396,8 @@ callback_client_connect (void *cls,
struct GNUNET_SERVICE_Client *client,
struct GNUNET_MQ_Handle *mq)
{
- struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new(struct GNUNET_MESSENGER_Client);
+ struct GNUNET_MESSENGER_Client *msg_client = GNUNET_new (struct
+ GNUNET_MESSENGER_Client);
msg_client->client = client;
msg_client->handle = add_service_handle (messenger, mq);
@@ -377,7 +414,7 @@ callback_client_disconnect (void *cls,
remove_service_handle (messenger, msg_client->handle);
- GNUNET_free(msg_client);
+ GNUNET_free (msg_client);
}
/**
@@ -394,27 +431,46 @@ run (void *cls,
{
messenger = create_service (config, service);
- if (!messenger)
+ if (! messenger)
GNUNET_SCHEDULER_shutdown ();
}
/**
* Define "main" method using service macro.
*/
-GNUNET_SERVICE_MAIN(
- GNUNET_MESSENGER_SERVICE_NAME,
- GNUNET_SERVICE_OPTION_NONE,
- &run,
- &callback_client_connect,
- &callback_client_disconnect,
- NULL,
- GNUNET_MQ_hd_var_size( create, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct GNUNET_MESSENGER_CreateMessage, NULL ),
- GNUNET_MQ_hd_fixed_size( update, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE, struct GNUNET_MESSENGER_UpdateMessage, NULL ),
- GNUNET_MQ_hd_fixed_size( destroy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY, struct GNUNET_MESSENGER_DestroyMessage, NULL ),
- GNUNET_MQ_hd_var_size( set_name, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME, struct GNUNET_MESSENGER_NameMessage, NULL ),
- GNUNET_MQ_hd_fixed_size( room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, struct GNUNET_MESSENGER_RoomMessage, NULL ),
- GNUNET_MQ_hd_fixed_size( room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, struct GNUNET_MESSENGER_RoomMessage, NULL ),
- GNUNET_MQ_hd_fixed_size( room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, struct GNUNET_MESSENGER_RoomMessage, NULL ),
- GNUNET_MQ_hd_var_size( send_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct GNUNET_MESSENGER_SendMessage, NULL ),
- GNUNET_MQ_hd_fixed_size( get_message, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, struct GNUNET_MESSENGER_GetMessage, NULL ),
- GNUNET_MQ_handler_end());
+GNUNET_SERVICE_MAIN (
+ GNUNET_MESSENGER_SERVICE_NAME,
+ GNUNET_SERVICE_OPTION_NONE,
+ &run,
+ &callback_client_connect,
+ &callback_client_disconnect,
+ NULL,
+ GNUNET_MQ_hd_var_size (create,
+ GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_CREATE, struct
+ GNUNET_MESSENGER_CreateMessage, NULL),
+ GNUNET_MQ_hd_fixed_size (update,
+ GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_UPDATE,
+ struct
+ GNUNET_MESSENGER_UpdateMessage, NULL),
+ GNUNET_MQ_hd_fixed_size (destroy,
+ GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_DESTROY,
+ struct
+ GNUNET_MESSENGER_DestroyMessage, NULL),
+ GNUNET_MQ_hd_var_size (set_name,
+ GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_SET_NAME,
+ struct
+ GNUNET_MESSENGER_NameMessage, NULL),
+ GNUNET_MQ_hd_fixed_size (room_open, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN,
+ struct GNUNET_MESSENGER_RoomMessage, NULL),
+ GNUNET_MQ_hd_fixed_size (room_entry, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY,
+ struct GNUNET_MESSENGER_RoomMessage, NULL),
+ GNUNET_MQ_hd_fixed_size (room_close, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE,
+ struct GNUNET_MESSENGER_RoomMessage, NULL),
+ GNUNET_MQ_hd_var_size (send_message,
+ GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, struct
+ GNUNET_MESSENGER_SendMessage, NULL),
+ GNUNET_MQ_hd_fixed_size (get_message,
+ GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE,
+ struct
+ GNUNET_MESSENGER_GetMessage, NULL),
+ GNUNET_MQ_handler_end ());
diff --git a/src/messenger/gnunet-service-messenger.h b/src/messenger/gnunet-service-messenger.h
index 253fbaadb..1db5c651c 100644
--- a/src/messenger/gnunet-service-messenger.h
+++ b/src/messenger/gnunet-service-messenger.h
@@ -28,11 +28,7 @@
#include "platform.h"
#include "gnunet_cadet_service.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
#include "gnunet_identity_service.h"
-#include "gnunet_mq_lib.h"
-#include "gnunet_peer_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_util_lib.h"
diff --git a/src/messenger/gnunet-service-messenger_basement.c b/src/messenger/gnunet-service-messenger_basement.c
index 89aa103ee..ae0dcaa62 100644
--- a/src/messenger/gnunet-service-messenger_basement.c
+++ b/src/messenger/gnunet-service-messenger_basement.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_basement.h"
size_t
diff --git a/src/messenger/gnunet-service-messenger_ego_store.c b/src/messenger/gnunet-service-messenger_ego_store.c
index c460ac1c7..3eb313b08 100644
--- a/src/messenger/gnunet-service-messenger_ego_store.c
+++ b/src/messenger/gnunet-service-messenger_ego_store.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_ego_store.h"
#include "gnunet-service-messenger_handle.h"
@@ -33,14 +34,21 @@ callback_update_ego (void *cls,
void **ctx,
const char *identifier)
{
- if ((!ego) || (!identifier))
+ if ((!ctx) || (!identifier))
return;
struct GNUNET_MESSENGER_EgoStore *store = cls;
- 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));
+ 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
@@ -52,6 +60,7 @@ init_ego_store(struct GNUNET_MESSENGER_EgoStore *store,
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;
@@ -60,7 +69,6 @@ init_ego_store(struct GNUNET_MESSENGER_EgoStore *store,
store->op_end = NULL;
}
-
static int
iterate_destroy_egos (void *cls,
const struct GNUNET_HashCode *key,
@@ -109,6 +117,8 @@ clear_ego_store(struct GNUNET_MESSENGER_EgoStore *store)
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);
@@ -117,29 +127,44 @@ clear_ego_store(struct GNUNET_MESSENGER_EgoStore *store)
}
}
+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_IDENTITY_PrivateKey *key,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
struct GNUNET_MESSENGER_EgoOperation *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
- GNUNET_assert(element->identifier);
+ GNUNET_assert (element->identifier);
- if (emsg)
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s\n", emsg);
+ /**
+ * 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_SrvHandle *handle = element->handle;
-
struct GNUNET_MESSENGER_Ego *msg_ego = update_store_ego (store, element->identifier, key);
- set_handle_ego (handle, msg_ego);
+ 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_log (GNUNET_ERROR_TYPE_WARNING, "Creating ego failed!\n");
GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, element);
GNUNET_free (element->identifier);
@@ -148,24 +173,70 @@ callback_ego_create (void *cls,
void
create_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
- const char *identifier,
- void *handle)
+ 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->handle = handle;
+ element->cls = NULL;
element->identifier = GNUNET_strdup (identifier);
- element->operation = GNUNET_IDENTITY_create (store->identity, identifier, NULL,
- GNUNET_IDENTITY_TYPE_ECDSA, callback_ego_create, element);
+ element->operation = GNUNET_IDENTITY_create (
+ store->identity,
+ identifier,
+ NULL,
+ GNUNET_IDENTITY_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)
@@ -173,16 +244,30 @@ callback_ego_lookup (void *cls,
struct GNUNET_MESSENGER_EgoLookup *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
- GNUNET_assert(element->identifier);
+ GNUNET_assert (element->identifier);
- struct GNUNET_MESSENGER_Ego *msg_ego;
+ 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)
+ store,
+ element->identifier,
+ GNUNET_IDENTITY_ego_get_private_key(ego)
);
+ }
else
- msg_ego = NULL;
+ {
+ 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);
@@ -200,43 +285,37 @@ lookup_store_ego(struct GNUNET_MESSENGER_EgoStore *store,
{
GNUNET_assert (store);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Store lookup ego: %s\n", identifier);
+
if (!identifier)
{
lookup(cls, identifier, NULL);
return;
}
- struct GNUNET_HashCode hash;
- GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
-
- struct GNUNET_MESSENGER_Ego *ego = GNUNET_CONTAINER_multihashmap_get (store->egos, &hash);
+ struct GNUNET_MESSENGER_EgoLookup *element = GNUNET_new (struct GNUNET_MESSENGER_EgoLookup);
- if (ego)
- lookup(cls, identifier, ego);
- else
- {
- struct GNUNET_MESSENGER_EgoLookup *element = GNUNET_new (struct GNUNET_MESSENGER_EgoLookup);
-
- element->store = store;
+ element->store = store;
- element->cb = lookup;
- element->cls = cls;
+ element->cb = lookup;
+ element->cls = cls;
- element->identifier = GNUNET_strdup (identifier);
+ element->identifier = GNUNET_strdup (identifier);
- element->lookup = GNUNET_IDENTITY_ego_lookup(store->cfg, identifier, callback_ego_lookup, element);
+ element->lookup = GNUNET_IDENTITY_ego_lookup(store->cfg, identifier, callback_ego_lookup, element);
- GNUNET_CONTAINER_DLL_insert (store->lu_start, store->lu_end, 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_IDENTITY_PrivateKey *key)
+update_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
+ const char *identifier,
+ const struct GNUNET_IDENTITY_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);
@@ -256,26 +335,63 @@ update_store_ego(struct GNUNET_MESSENGER_EgoStore *store,
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,
- const char *emsg)
+ enum GNUNET_ErrorCode ec)
{
struct GNUNET_MESSENGER_EgoOperation *element = cls;
struct GNUNET_MESSENGER_EgoStore *store = element->store;
- GNUNET_assert(element->identifier);
+ GNUNET_assert (element->identifier);
- if (emsg)
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s\n", emsg);
+ /**
+ * 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 ((char*) element->handle, strlen ((char*) element->handle), &hash);
+ GNUNET_CRYPTO_hash (identifier, strlen (identifier), &hash);
GNUNET_CONTAINER_multihashmap_put (store->egos, &hash, ego,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
@@ -283,7 +399,7 @@ callback_ego_rename (void *cls,
else
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Renaming ego failed!\n");
- GNUNET_free (element->handle);
+ GNUNET_free (identifier);
GNUNET_CONTAINER_DLL_remove (store->op_start, store->op_end, element);
GNUNET_free (element->identifier);
@@ -297,14 +413,70 @@ rename_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
{
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->handle = GNUNET_strdup (new_identifier);
+ 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);
+ 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/messenger/gnunet-service-messenger_ego_store.h b/src/messenger/gnunet-service-messenger_ego_store.h
index 4222a4e91..a5f8a69d8 100644
--- a/src/messenger/gnunet-service-messenger_ego_store.h
+++ b/src/messenger/gnunet-service-messenger_ego_store.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -27,7 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_EGO_STORE_H
#include "platform.h"
-#include "gnunet_container_lib.h"
+#include "gnunet_util_lib.h"
#include "messenger_api_ego.h"
@@ -62,7 +62,8 @@ struct GNUNET_MESSENGER_EgoOperation
struct GNUNET_IDENTITY_Operation *operation;
struct GNUNET_MESSENGER_EgoStore *store;
- void *handle;
+
+ void *cls;
char *identifier;
};
@@ -73,6 +74,7 @@ struct GNUNET_MESSENGER_EgoStore
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;
@@ -94,22 +96,45 @@ init_ego_store (struct GNUNET_MESSENGER_EgoStore *store,
/**
* Clears an EGO-store, wipes its content and deallocates its memory.
*
- * @param[in/out] store EGO-store
+ * @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>. A given <i>handle</i> will be informed
- * about the creation and changes its EGO accordingly.
+ * a specific <i>identifier</i>.
*
- * @param[in/out] store EGO-store
+ * @param[in,out] store EGO-store
* @param[in] identifier Identifier string
- * @param[in/out] handle Handle or NULL
*/
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);
@@ -117,7 +142,7 @@ create_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
* 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,out] store EGO-store
* @param[in] identifier Identifier string
* @param[in] lookup Lookup callback (non-NULL)
* @param[in] cls Closure
@@ -132,7 +157,7 @@ lookup_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
* 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,out] store EGO-store
* @param[in] identifier Identifier string
* @param[in] key Private EGO key
* @return Updated EGO
@@ -143,11 +168,22 @@ update_store_ego (struct GNUNET_MESSENGER_EgoStore *store,
const struct GNUNET_IDENTITY_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
+ * a different one under a specific <i>new_identifier</i> replacing
* its old one.
*
- * @param[in/out] store EGO-store
+ * @param[in,out] store EGO-store
* @param[in] old_identifier Old identifier string
* @param[in] new_identifier New identifier string
*/
@@ -156,4 +192,15 @@ 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/messenger/gnunet-service-messenger_handle.c b/src/messenger/gnunet-service-messenger_handle.c
index 341bb7251..17692761d 100644
--- a/src/messenger/gnunet-service-messenger_handle.c
+++ b/src/messenger/gnunet-service-messenger_handle.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_handle.h"
#include "gnunet-service-messenger.h"
@@ -31,8 +32,8 @@
#include "messenger_api_util.h"
struct GNUNET_MESSENGER_SrvHandle*
-create_handle (struct GNUNET_MESSENGER_Service *service,
- struct GNUNET_MQ_Handle *mq)
+create_srv_handle (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MQ_Handle *mq)
{
GNUNET_assert((service) && (mq));
@@ -60,15 +61,21 @@ iterate_free_member_ids (void *cls,
}
void
-destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
+destroy_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert(handle);
if (handle->service->dir)
- save_handle_configuration (handle);
+ save_srv_handle_configuration (handle);
if (handle->name)
+ {
+ struct GNUNET_MESSENGER_EgoStore *store = get_service_ego_store(handle->service);
+
+ unbind_store_ego(store, handle->name, handle);
+
GNUNET_free(handle->name);
+ }
GNUNET_CONTAINER_multihashmap_iterate (handle->member_ids, iterate_free_member_ids, NULL);
GNUNET_CONTAINER_multihashmap_destroy (handle->member_ids);
@@ -77,9 +84,9 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
}
void
-get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
- const char *name,
- char **dir)
+get_srv_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name,
+ char **dir)
{
GNUNET_assert((handle) && (dir));
@@ -118,8 +125,8 @@ create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
}
const struct GNUNET_ShortHashCode*
-get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key)
+get_srv_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -127,9 +134,9 @@ get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
}
int
-change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key,
- const struct GNUNET_ShortHashCode *unique_id)
+change_srv_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key,
+ const struct GNUNET_ShortHashCode *unique_id)
{
GNUNET_assert((handle) && (key) && (unique_id));
@@ -208,9 +215,9 @@ change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
handle->ego = ego;
- ego = get_handle_ego (handle);
+ ego = get_srv_handle_ego (handle);
- const uint16_t length = GNUNET_IDENTITY_key_get_length(&(ego->pub));
+ const uint16_t length = GNUNET_IDENTITY_public_key_get_length(&(ego->pub));
struct GNUNET_MESSENGER_KeyMessage *msg;
struct GNUNET_MQ_Envelope *env;
@@ -219,7 +226,7 @@ change_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
char *extra = ((char*) msg) + sizeof(*msg);
- if (GNUNET_IDENTITY_write_key_to_buffer(&(ego->pub), extra, length) < 0)
+ if (GNUNET_IDENTITY_write_public_key_to_buffer(&(ego->pub), extra, length) < 0)
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Could not write key to buffer.\n");
GNUNET_MQ_send (handle->mq, env);
@@ -238,14 +245,14 @@ iterate_send_message (void *cls,
{
struct GNUNET_MESSENGER_MessageHandle *msg_handle = cls;
- send_handle_message (msg_handle->handle, key, msg_handle->message);
+ send_srv_handle_message (msg_handle->handle, key, msg_handle->message);
return GNUNET_YES;
}
void
-set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Ego *ego)
+set_srv_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Ego *ego)
{
GNUNET_assert((handle) && (ego));
@@ -262,7 +269,7 @@ set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
}
const struct GNUNET_MESSENGER_Ego*
-get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle)
+get_srv_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert(handle);
@@ -296,12 +303,12 @@ callback_setup_handle_name (void *cls,
change_handle_ego (handle, ego);
if (handle->service->dir)
- load_handle_configuration (handle);
+ load_srv_handle_configuration (handle);
}
void
-setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
- const char *name)
+setup_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name)
{
GNUNET_assert(handle);
@@ -317,24 +324,26 @@ callback_update_handle (void *cls,
{
struct GNUNET_MESSENGER_SrvHandle *handle = cls;
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Updating handle...\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Updating handle...\n");
struct GNUNET_MESSENGER_EgoStore *store = get_service_ego_store(handle->service);
+ bind_store_ego(store, handle->name, handle);
+
if (!ego)
- create_store_ego(store, handle->name, handle);
+ create_store_ego (store, handle->name);
else
- change_handle_ego (handle, ego);
+ renew_store_ego (store, handle->name);
}
void
-update_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
+update_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
{
- GNUNET_assert(handle);
+ GNUNET_assert (handle);
if (!handle->name)
{
- GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Updating handle failed: Name is required!\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Updating handle failed: Name is required!\n");
return;
}
@@ -360,51 +369,43 @@ callback_set_handle_name (void *cls,
struct GNUNET_MESSENGER_EgoStore *store = get_service_ego_store(handle->service);
- int rename_ego_in_store = handle->ego? GNUNET_YES : GNUNET_NO;
-
char *old_dir;
- get_handle_data_subdir (handle, handle->name, &old_dir);
+ get_srv_handle_data_subdir (handle, handle->name, &old_dir);
char *new_dir;
- get_handle_data_subdir (handle, name, &new_dir);
+ get_srv_handle_data_subdir (handle, name, &new_dir);
- int result = 0;
+ if ((GNUNET_YES == GNUNET_DISK_directory_test (new_dir, GNUNET_NO)) &&
+ (GNUNET_OK != GNUNET_DISK_directory_remove(new_dir)))
+ goto free_dirs;
if (GNUNET_YES == GNUNET_DISK_directory_test (old_dir, GNUNET_YES))
{
GNUNET_DISK_directory_create_for_file (new_dir);
- result = rename (old_dir, new_dir);
+ if (0 != rename (old_dir, new_dir))
+ goto free_dirs;
}
- else if (GNUNET_YES == GNUNET_DISK_directory_test (new_dir, GNUNET_NO))
- result = -1;
-
- if (0 == result)
- {
- struct GNUNET_MESSENGER_MessageHandle msg_handle;
-
- msg_handle.handle = handle;
- msg_handle.message = create_message_name (name);
- GNUNET_CONTAINER_multihashmap_iterate (handle->member_ids, iterate_send_message, &msg_handle);
+ if (handle->ego)
+ rename_store_ego(store, handle->name, name);
- destroy_message (msg_handle.message);
+ struct GNUNET_MESSENGER_MessageHandle msg_handle;
+ msg_handle.handle = handle;
+ msg_handle.message = create_message_name (name);
- change_handle_name (handle, name);
- }
- else
- rename_ego_in_store = GNUNET_NO;
+ GNUNET_CONTAINER_multihashmap_iterate (handle->member_ids, iterate_send_message, &msg_handle);
+ destroy_message (msg_handle.message);
+ change_handle_name (handle, name);
+free_dirs:
GNUNET_free(old_dir);
GNUNET_free(new_dir);
-
- if (GNUNET_YES == rename_ego_in_store)
- rename_store_ego(store, handle->name, name);
}
void
-set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
- const char *name)
+set_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name)
{
GNUNET_assert(handle);
@@ -424,50 +425,50 @@ set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
}
int
-open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key)
+open_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
- if ((!get_handle_member_id (handle, key)) && (GNUNET_YES != create_handle_member_id (handle, key)))
+ if ((!get_srv_handle_member_id (handle, key)) && (GNUNET_YES != create_handle_member_id (handle, key)))
return GNUNET_NO;
return open_service_room (handle->service, handle, key);
}
int
-entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_PeerIdentity *door,
- const struct GNUNET_HashCode *key)
+entry_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_PeerIdentity *door,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (door) && (key));
- if ((!get_handle_member_id (handle, key)) && (GNUNET_YES != create_handle_member_id (handle, key)))
+ if ((!get_srv_handle_member_id (handle, key)) && (GNUNET_YES != create_handle_member_id (handle, key)))
return GNUNET_NO;
return entry_service_room (handle->service, handle, door, key);
}
int
-close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key)
+close_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
- if (!get_handle_member_id (handle, key))
+ if (!get_srv_handle_member_id (handle, key))
return GNUNET_NO;
return close_service_room (handle->service, handle, key);
}
int
-send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key,
- const struct GNUNET_MESSENGER_Message *message)
+send_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key,
+ const struct GNUNET_MESSENGER_Message *message)
{
GNUNET_assert((handle) && (key) && (message));
- const struct GNUNET_ShortHashCode *id = get_handle_member_id (handle, key);
+ const struct GNUNET_ShortHashCode *id = get_srv_handle_member_id (handle, key);
if (!id)
{
@@ -487,7 +488,7 @@ send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
GNUNET_memcpy(&(msg->header.sender_id), id, sizeof(*id));
- return send_room_message (room, handle, msg);
+ return send_srv_room_message (room, handle, msg);
}
static const struct GNUNET_HashCode*
@@ -506,15 +507,15 @@ get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle,
{
GNUNET_assert((handle) && (room) && (key) && (handle->service));
- const struct GNUNET_ShortHashCode *id = get_handle_member_id(handle, key);
+ const struct GNUNET_ShortHashCode *id = get_srv_handle_member_id(handle, key);
if (!id)
return NULL;
- struct GNUNET_MESSENGER_MemberStore *store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *store = get_srv_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = get_store_member(store, id);
- const struct GNUNET_MESSENGER_Ego *ego = get_handle_ego(handle);
+ const struct GNUNET_MESSENGER_Ego *ego = get_srv_handle_ego(handle);
if (!ego)
return NULL;
@@ -523,17 +524,17 @@ get_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle,
}
void
-notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
- struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message,
- const struct GNUNET_HashCode *hash)
+notify_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((handle) && (room) && (session) && (message) && (hash));
- const struct GNUNET_HashCode *key = get_room_key(room);
+ const struct GNUNET_HashCode *key = get_srv_room_key(room);
- if ((!handle->mq) || (!get_handle_member_id (handle, key)))
+ if ((!handle->mq) || (!get_srv_handle_member_id (handle, key)))
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Notifying client about message requires membership!\n");
return;
@@ -554,7 +555,7 @@ notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
{
private_message = copy_message(message);
- if (GNUNET_YES != decrypt_message(private_message, &(get_handle_ego(handle)->priv)))
+ if (GNUNET_YES != decrypt_message(private_message, &(get_srv_handle_ego(handle)->priv)))
{
destroy_message(private_message);
private_message = NULL;
@@ -612,7 +613,7 @@ callback_scan_for_rooms (void *cls,
if ((GNUNET_OK == GNUNET_CONFIGURATION_get_data (cfg, "room", "key", &key, sizeof(key))) &&
(GNUNET_OK == GNUNET_CONFIGURATION_get_data (cfg, "room", "member_id", &member_id, sizeof(member_id))))
- change_handle_member_id (handle, &key, &member_id);
+ change_srv_handle_member_id (handle, &key, &member_id);
}
GNUNET_CONFIGURATION_destroy (cfg);
@@ -620,12 +621,12 @@ callback_scan_for_rooms (void *cls,
}
void
-load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle)
+load_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert(handle);
char *id_dir;
- get_handle_data_subdir (handle, handle->name, &id_dir);
+ get_srv_handle_data_subdir (handle, handle->name, &id_dir);
if (GNUNET_YES == GNUNET_DISK_directory_test (id_dir, GNUNET_YES))
{
@@ -650,7 +651,7 @@ iterate_save_rooms (void *cls,
struct GNUNET_ShortHashCode *member_id = value;
char *id_dir;
- get_handle_data_subdir (handle, handle->name, &id_dir);
+ get_srv_handle_data_subdir (handle, handle->name, &id_dir);
char *filename;
GNUNET_asprintf (&filename, "%s%s%c%s.cfg", id_dir, "rooms", DIR_SEPARATOR, GNUNET_h2s (key));
@@ -687,12 +688,12 @@ iterate_save_rooms (void *cls,
}
void
-save_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle)
+save_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert(handle);
char *id_dir;
- get_handle_data_subdir (handle, handle->name, &id_dir);
+ get_srv_handle_data_subdir (handle, handle->name, &id_dir);
if ((GNUNET_YES == GNUNET_DISK_directory_test (id_dir, GNUNET_NO)) || (GNUNET_OK
== GNUNET_DISK_directory_create (id_dir)))
diff --git a/src/messenger/gnunet-service-messenger_handle.h b/src/messenger/gnunet-service-messenger_handle.h
index 4438570b9..edcd2ccd0 100644
--- a/src/messenger/gnunet-service-messenger_handle.h
+++ b/src/messenger/gnunet-service-messenger_handle.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -28,11 +28,8 @@
#include "platform.h"
#include "gnunet_cadet_service.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
-#include "gnunet_peer_lib.h"
-#include "gnunet_mq_lib.h"
#include "gnunet-service-messenger_service.h"
#include "gnunet-service-messenger_member_session.h"
@@ -55,21 +52,21 @@ struct GNUNET_MESSENGER_SrvHandle
/**
* Creates and allocates a new handle related to a <i>service</i> and using a given <i>mq</i> (message queue).
*
- * @param[in/out] service MESSENGER Service
- * @param[in/out] mq Message queue
+ * @param[in,out] service MESSENGER Service
+ * @param[in,out] mq Message queue
* @return New handle
*/
struct GNUNET_MESSENGER_SrvHandle*
-create_handle (struct GNUNET_MESSENGER_Service *service,
- struct GNUNET_MQ_Handle *mq);
+create_srv_handle (struct GNUNET_MESSENGER_Service *service,
+ struct GNUNET_MQ_Handle *mq);
/**
* Destroys a handle and frees its memory fully.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
*/
void
-destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
+destroy_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Writes the path of the directory for a given <i>handle</i> using a specific <i>name</i> to the parameter
@@ -80,7 +77,7 @@ destroy_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
* @param[out] dir Path to store data
*/
void
-get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
+get_srv_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
const char *name,
char **dir);
@@ -94,8 +91,8 @@ get_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle,
* @return Member id or NULL
*/
const struct GNUNET_ShortHashCode*
-get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key);
+get_srv_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Changes the member id of a given <i>handle</i> in a specific <i>room</i> to match a <i>unique_id</i>
@@ -103,25 +100,25 @@ get_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle,
*
* The client connected to the <i>handle</i> will be informed afterwards automatically.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of a room
* @param[in] unique_id Unique member id
* @return GNUNET_OK on success, otherwise GNUNET_SYSERR
*/
int
-change_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key,
- const struct GNUNET_ShortHashCode *unique_id);
+change_srv_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key,
+ const struct GNUNET_ShortHashCode *unique_id);
/**
* Sets the EGO used by a given <i>handle</i>.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] ego EGO key pair
*/
void
-set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_MESSENGER_Ego *ego);
+set_srv_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_MESSENGER_Ego *ego);
/**
* Returns the EGO used by a given <i>handle</i>.
@@ -130,26 +127,26 @@ set_handle_ego (struct GNUNET_MESSENGER_SrvHandle *handle,
* @return EGO key pair
*/
const struct GNUNET_MESSENGER_Ego*
-get_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle);
+get_srv_handle_ego (const struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Tries to set the name and EGO key of a <i>handle</i> initially by looking up a specific <i>name</i>.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] name Name (optionally: valid EGO name)
*/
void
-setup_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
- const char *name);
+setup_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name);
/**
* Tries to change the key pair of an EGO of a <i>handle</i> under the same name and informs all rooms
* about the change automatically.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
*/
void
-update_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
+update_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Tries to rename the handle which implies renaming the EGO its using and moving all related data into
@@ -157,79 +154,79 @@ update_handle (struct GNUNET_MESSENGER_SrvHandle *handle);
*
* The client connected to the <i>handle</i> will be informed afterwards automatically.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] name New name
*/
void
-set_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
- const char *name);
+set_srv_handle_name (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const char *name);
/**
* Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and opens the
* room from the handles service.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of a room
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-open_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key);
+open_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Makes a given <i>handle</i> a member of the room using a specific <i>key</i> and enters the room
* through a tunnel to a peer identified by a given <i>door</i> (peer identity).
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] door Peer identity
* @param[in] key Key of a room
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-entry_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_PeerIdentity *door,
- const struct GNUNET_HashCode *key);
+entry_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_PeerIdentity *door,
+ const struct GNUNET_HashCode *key);
/**
* Removes the membership of the room using a specific <i>key</i> and closes it if no other handle
* from this service is still a member of it.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of a room
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
-close_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key);
+close_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key);
/**
* Sends a <i>message</i> from a given <i>handle</i> to the room using a specific <i>key</i>.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of a room
* @param[in] message Message
* @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise.
*/
int
-send_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key,
- const struct GNUNET_MESSENGER_Message *message);
+send_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key,
+ const struct GNUNET_MESSENGER_Message *message);
/**
* Notifies the handle that a new message was received or sent.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] room Room of the message
* @param[in] session Member session
* @param[in] message Message
* @param[in] hash Hash of message
*/
void
-notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
- struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_MESSENGER_Message *message,
- const struct GNUNET_HashCode *hash);
+notify_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Loads member ids and other potential configuration from a given <i>handle</i> which
@@ -238,7 +235,7 @@ notify_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle,
* @param[out] handle Handle
*/
void
-load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
+load_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Saves member ids and other potential configuration from a given <i>handle</i> which
@@ -247,6 +244,6 @@ load_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
* @param[in] handle Handle
*/
void
-save_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
+save_srv_handle_configuration (struct GNUNET_MESSENGER_SrvHandle *handle);
#endif //GNUNET_SERVICE_MESSENGER_HANDLE_H
diff --git a/src/messenger/gnunet-service-messenger_list_handles.c b/src/messenger/gnunet-service-messenger_list_handles.c
index c0ae18716..0703c2de6 100644
--- a/src/messenger/gnunet-service-messenger_list_handles.c
+++ b/src/messenger/gnunet-service-messenger_list_handles.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_list_handles.h"
#include "gnunet-service-messenger_handle.h"
@@ -46,7 +47,7 @@ clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles)
struct GNUNET_MESSENGER_ListHandle *element = handles->head;
GNUNET_CONTAINER_DLL_remove(handles->head, handles->tail, element);
- destroy_handle (element->handle);
+ destroy_srv_handle (element->handle);
GNUNET_free(element);
}
@@ -97,7 +98,7 @@ find_list_handle_by_member (const struct GNUNET_MESSENGER_ListHandles *handles,
struct GNUNET_MESSENGER_ListHandle *element;
for (element = handles->head; element; element = element->next)
- if (get_handle_member_id ((struct GNUNET_MESSENGER_SrvHandle*) element->handle, key))
+ if (get_srv_handle_member_id ((struct GNUNET_MESSENGER_SrvHandle*) element->handle, key))
return element->handle;
return NULL;
diff --git a/src/messenger/gnunet-service-messenger_list_handles.h b/src/messenger/gnunet-service-messenger_list_handles.h
index f4d7ca5c0..8c066519e 100644
--- a/src/messenger/gnunet-service-messenger_list_handles.h
+++ b/src/messenger/gnunet-service-messenger_list_handles.h
@@ -27,8 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_LIST_HANDLES_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_container_lib.h"
+#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_SrvHandle;
@@ -57,7 +56,7 @@ init_list_handles (struct GNUNET_MESSENGER_ListHandles *handles);
/**
* Destroys remaining <i>handles</i> and clears the list.
*
- * @param[in/out] handles List of handles
+ * @param[in,out] handles List of handles
*/
void
clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles);
@@ -65,8 +64,8 @@ clear_list_handles (struct GNUNET_MESSENGER_ListHandles *handles);
/**
* Adds a specific <i>handle</i> to the end of the list.
*
- * @param[in/out] handles List of handles
- * @param[in/out] handle Handle
+ * @param[in,out] handles List of handles
+ * @param[in,out] handle Handle
*/
void
add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles,
@@ -76,8 +75,8 @@ add_list_handle (struct GNUNET_MESSENGER_ListHandles *handles,
* Removes the first entry matching with a specific <i>handle</i> from the list of
* <i>handles</i> and returns #GNUNET_YES on success or #GNUNET_NO on failure.
*
- * @param[in/out] handles List of handles
- * @param[in/out] handle Handle
+ * @param[in,out] handles List of handles
+ * @param[in,out] handle Handle
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
diff --git a/src/messenger/gnunet-service-messenger_list_messages.c b/src/messenger/gnunet-service-messenger_list_messages.c
index 7092dc76f..5bab52806 100644
--- a/src/messenger/gnunet-service-messenger_list_messages.c
+++ b/src/messenger/gnunet-service-messenger_list_messages.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_list_messages.h"
void
diff --git a/src/messenger/gnunet-service-messenger_list_messages.h b/src/messenger/gnunet-service-messenger_list_messages.h
index 7abc8c00f..5839f63ca 100644
--- a/src/messenger/gnunet-service-messenger_list_messages.h
+++ b/src/messenger/gnunet-service-messenger_list_messages.h
@@ -27,9 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_LIST_MESSAGES_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_disk_lib.h"
+#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_ListMessage
{
@@ -56,7 +54,7 @@ init_list_messages (struct GNUNET_MESSENGER_ListMessages *messages);
/**
* Clears the list of message hashes.
*
- * @param[in/out] messages List of hashes
+ * @param[in,out] messages List of hashes
*/
void
clear_list_messages (struct GNUNET_MESSENGER_ListMessages *messages);
@@ -64,7 +62,7 @@ clear_list_messages (struct GNUNET_MESSENGER_ListMessages *messages);
/**
* Adds a specific <i>hash</i> from a message to the end of the list.
*
- * @param[in/out] messages List of hashes
+ * @param[in,out] messages List of hashes
* @param[in] hash Hash of message
*/
void
@@ -74,7 +72,7 @@ add_to_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
/**
* Copies all message hashes from an <i>origin</i> to another list.
*
- * @param[in/out] messages Destination list of hashes
+ * @param[in,out] messages Destination list of hashes
* @param[in] origin Source list of hashes
*/
void
@@ -84,7 +82,7 @@ copy_list_messages (struct GNUNET_MESSENGER_ListMessages *messages,
/**
* Removes the first entry with a matching <i>hash</i> from the list.
*
- * @param[in/out] messages List of hashes
+ * @param[in,out] messages List of hashes
* @param[in] hash Hash of message
*/
void
diff --git a/src/messenger/gnunet-service-messenger_member.c b/src/messenger/gnunet-service-messenger_member.c
index 976b68fe6..444148831 100644
--- a/src/messenger/gnunet-service-messenger_member.c
+++ b/src/messenger/gnunet-service-messenger_member.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_member.h"
#include "gnunet-service-messenger_member_session.h"
diff --git a/src/messenger/gnunet-service-messenger_member.h b/src/messenger/gnunet-service-messenger_member.h
index 46269315a..0c5870fd3 100644
--- a/src/messenger/gnunet-service-messenger_member.h
+++ b/src/messenger/gnunet-service-messenger_member.h
@@ -47,7 +47,7 @@ struct GNUNET_MESSENGER_Member
*
* If the creation fails, NULL gets returned.
*
- * @param[in/out] store Member store
+ * @param[in,out] store Member store
* @param[in] id Member id or NULL
* @return New member or NULL
*/
@@ -58,7 +58,7 @@ create_member (struct GNUNET_MESSENGER_MemberStore *store,
/**
* Destroys a member and frees its memory fully.
*
- * @param[in/out] member Member
+ * @param[in,out] member Member
*/
void
destroy_member (struct GNUNET_MESSENGER_Member *member);
@@ -88,7 +88,7 @@ load_member (struct GNUNET_MESSENGER_MemberStore *store,
* Loads data about next sessions from a <i>directory</i> into an empty loaded
* <i>member</i> which does not contain a fully built session graph yet.
*
- * @param[in/out] member Member
+ * @param[in,out] member Member
* @param[in] directory Path to a directory
*/
void
@@ -110,7 +110,7 @@ save_member (struct GNUNET_MESSENGER_Member *member,
* Synchronizes contacts between all sessions from a given <i>member</i>
* and other sessions which are linked to them.
*
- * @param[in/out] member Member
+ * @param[in,out] member Member
*/
void
sync_member_contacts (struct GNUNET_MESSENGER_Member *member);
@@ -145,8 +145,8 @@ get_member_session_of (struct GNUNET_MESSENGER_Member *member,
/**
* Adds a given member <i>session</i> to its <i>member</i>.
*
- * @param[in/out] member Member
- * @param[in/out] session Member session
+ * @param[in,out] member Member
+ * @param[in,out] session Member session
*/
void
add_member_session (struct GNUNET_MESSENGER_Member *member,
@@ -155,8 +155,8 @@ add_member_session (struct GNUNET_MESSENGER_Member *member,
/**
* Removes a given member <i>session</i> from its <i>member</i>.
*
- * @param[in/out] member Member
- * @param[in/out] session Member session
+ * @param[in,out] member Member
+ * @param[in,out] session Member session
*/
void
remove_member_session (struct GNUNET_MESSENGER_Member *member,
@@ -167,9 +167,9 @@ remove_member_session (struct GNUNET_MESSENGER_Member *member,
* and call the provided iterator callback with a selected closure. The function
* will return the amount of member sessions it iterated through.
*
- * @param[in/out] member Member
+ * @param[in,out] member Member
* @param[in] it Iterator callback
- * @param[in/out] cls Closure
+ * @param[in,out] cls Closure
* @return Amount of sessions iterated through
*/
int
diff --git a/src/messenger/gnunet-service-messenger_member_session.c b/src/messenger/gnunet-service-messenger_member_session.c
index 846dbbe2b..519ac6f05 100644
--- a/src/messenger/gnunet-service-messenger_member_session.c
+++ b/src/messenger/gnunet-service-messenger_member_session.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
+ Copyright (C) 2021--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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_member_session.h"
#include "gnunet-service-messenger_room.h"
@@ -84,6 +85,9 @@ check_member_session_completion (struct GNUNET_MESSENGER_MemberSession *session)
{
GNUNET_assert (session);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Check session history (%s) for completion.\n",
+ GNUNET_sh2s(get_member_session_id(session)));
+
if (!session->messages.tail)
{
session->completed = GNUNET_YES;
@@ -98,7 +102,7 @@ check_member_session_completion (struct GNUNET_MESSENGER_MemberSession *session)
add_to_list_messages(&level, end);
- struct GNUNET_MESSENGER_MessageStore *store = get_room_message_store(session->member->store->room);
+ struct GNUNET_MESSENGER_MessageStore *store = get_srv_room_message_store(session->member->store->room);
struct GNUNET_MESSENGER_ListMessages list;
init_list_messages(&list);
@@ -142,7 +146,10 @@ check_member_session_completion (struct GNUNET_MESSENGER_MemberSession *session)
completion:
if (GNUNET_YES == is_member_session_completed(session))
{
- GNUNET_CONTAINER_multihashmap_destroy (session->history);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Completed session history (%s)\n",
+ GNUNET_sh2s(get_member_session_id(session)));
+
+ GNUNET_CONTAINER_multihashmap_clear (session->history);
struct GNUNET_MESSENGER_ContactStore *store = get_member_contact_store(session->member->store);
diff --git a/src/messenger/gnunet-service-messenger_member_session.h b/src/messenger/gnunet-service-messenger_member_session.h
index 9ba801776..9b4065d05 100644
--- a/src/messenger/gnunet-service-messenger_member_session.h
+++ b/src/messenger/gnunet-service-messenger_member_session.h
@@ -27,8 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_MEMBER_SESSION_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_container_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_time_lib.h"
@@ -62,7 +61,7 @@ struct GNUNET_MESSENGER_MemberSession {
*
* If the creation fails, NULL gets returned.
*
- * @param[in/out] member Member
+ * @param[in,out] member Member
* @param[in] pubkey Public key of EGO
* @return New member session
*/
@@ -77,7 +76,7 @@ create_member_session (struct GNUNET_MESSENGER_Member *member,
* <i>message</i> to switch session. The new session will be linked to the old
* one.
*
- * @param[in/out] session Old member session
+ * @param[in,out] session Old member session
* @param[in] message Message
* @param[in] hash Hash of message
* @return New member session
@@ -90,7 +89,7 @@ switch_member_session (struct GNUNET_MESSENGER_MemberSession *session,
/**
* Destroys a member session and frees its memory fully.
*
- * @param[in/out] session Member session
+ * @param[in,out] session Member session
*/
void
destroy_member_session(struct GNUNET_MESSENGER_MemberSession* session);
@@ -101,7 +100,7 @@ destroy_member_session(struct GNUNET_MESSENGER_MemberSession* session);
* be dropped. The member sessions messages will be cleared but old
* history from uncompleted sessions however can be reused!
*
- * @param[in/out] session Member session
+ * @param[in,out] session Member session
* @param[in] hash Hash of initial message (JOIN message!)
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
@@ -116,7 +115,7 @@ reset_member_session (struct GNUNET_MESSENGER_MemberSession* session,
* Closing a session may complete a session and can't be used without
* a reset! ( @see #reset_member_session() )
*
- * @param[in/out] session Member session
+ * @param[in,out] session Member session
*/
void
close_member_session (struct GNUNET_MESSENGER_MemberSession* session);
@@ -234,7 +233,7 @@ check_member_session_history (const struct GNUNET_MESSENGER_MemberSession *sessi
*
* @see #is_member_session_completed() for updating a history.
*
- * @param[in/out] session Member session
+ * @param[in,out] session Member session
* @param[in] message Message
* @param[in] hash Hash of message
*/
@@ -247,7 +246,7 @@ update_member_session_history (struct GNUNET_MESSENGER_MemberSession *session,
* Removes a message from the history of a <i>session</i> using the messages
* <i>hash</i>.
*
- * @param[in/out] session Member session
+ * @param[in,out] session Member session
* @param[in] hash Hash of message
*/
void
@@ -271,7 +270,7 @@ load_member_session (struct GNUNET_MESSENGER_Member *member,
* next attribute. Necessary information will be loaded from a configuration
* file inside of a given <i>directory</i>.
*
- * @param[in/out] session Member session
+ * @param[in,out] session Member session
* @param[in] directory Path to a directory
*/
void
diff --git a/src/messenger/gnunet-service-messenger_member_store.c b/src/messenger/gnunet-service-messenger_member_store.c
index e96ee3883..fc28babc4 100644
--- a/src/messenger/gnunet-service-messenger_member_store.c
+++ b/src/messenger/gnunet-service-messenger_member_store.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_member_store.h"
#include "gnunet-service-messenger_member.h"
@@ -74,7 +75,7 @@ get_member_store_key (const struct GNUNET_MESSENGER_MemberStore *store)
{
GNUNET_assert (store);
- return get_room_key((const struct GNUNET_MESSENGER_SrvRoom*) store->room);
+ return get_srv_room_key((const struct GNUNET_MESSENGER_SrvRoom*) store->room);
}
static int
diff --git a/src/messenger/gnunet-service-messenger_member_store.h b/src/messenger/gnunet-service-messenger_member_store.h
index af50f0d36..05b00f39a 100644
--- a/src/messenger/gnunet-service-messenger_member_store.h
+++ b/src/messenger/gnunet-service-messenger_member_store.h
@@ -27,8 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_MEMBER_STORE_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_container_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "messenger_api_message.h"
@@ -62,7 +61,7 @@ init_member_store (struct GNUNET_MESSENGER_MemberStore *store,
/**
* Clears a member <i>store</i>, wipes its content and deallocates its memory.
*
- * @param[in/out] store Member store
+ * @param[in,out] store Member store
*/
void
clear_member_store (struct GNUNET_MESSENGER_MemberStore *store);
@@ -70,7 +69,7 @@ clear_member_store (struct GNUNET_MESSENGER_MemberStore *store);
/**
* Returns the used contact store of a given member <i>store</i>.
*
- * @param[in/out] store Member store
+ * @param[in,out] store Member store
* @return Contact store
*/
struct GNUNET_MESSENGER_ContactStore*
@@ -121,7 +120,7 @@ get_store_member (const struct GNUNET_MESSENGER_MemberStore *store,
* Returns the member of a <i>store</i> using a sender id of a given <i>message</i>.
* If the member does not provide a matching session, NULL gets returned.
*
- * @param[in/out] store Member store
+ * @param[in,out] store Member store
* @param[in] message Message
* @return Member or NULL
*/
@@ -132,7 +131,7 @@ get_store_member_of (struct GNUNET_MESSENGER_MemberStore *store,
/**
* Adds a member to a <i>store</i> under a specific <i>id</i> and returns it on success.
*
- * @param[in/out] store Member store
+ * @param[in,out] store Member store
* @param[in] id Member id
* @return Member or NULL
*/
@@ -145,9 +144,9 @@ add_store_member (struct GNUNET_MESSENGER_MemberStore *store,
* member <i>store</i> and call the provided iterator callback with a selected closure.
* The function will return the amount of members it iterated through.
*
- * @param[in/out] store Member store
+ * @param[in,out] store Member store
* @param[in] it Iterator callback
- * @param[in/out] cls Closure
+ * @param[in,out] cls Closure
* @return Amount of members iterated through
*/
int
diff --git a/src/messenger/gnunet-service-messenger_message_handle.c b/src/messenger/gnunet-service-messenger_message_handle.c
index 701d78c89..06b987657 100644
--- a/src/messenger/gnunet-service-messenger_message_handle.c
+++ b/src/messenger/gnunet-service-messenger_message_handle.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_message_handle.h"
static void
@@ -43,12 +44,12 @@ handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_HashCode *hash)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) joins room (%s).\n",
- GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room)));
+ GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_srv_room_key(room)));
if (GNUNET_OK != reset_member_session(session, hash))
GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Resetting member session failed!\n");
- solve_room_member_collisions (
+ solve_srv_room_member_collisions (
room,
&(message->body.join.key),
&(message->header.sender_id),
@@ -63,7 +64,7 @@ handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_HashCode *hash)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Member (%s) leaves room (%s).\n",
- GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_room_key(room)));
+ GNUNET_sh2s (&(message->header.sender_id)), GNUNET_h2s(get_srv_room_key(room)));
close_member_session(session);
}
@@ -101,7 +102,7 @@ handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
add_to_list_tunnels (&(room->basement), &(message->body.peer.peer));
if (room->peer_message)
- rebuild_room_basement_structure (room);
+ rebuild_srv_room_basement_structure (room);
}
void
@@ -112,7 +113,7 @@ handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room,
{
handle_session_switch (session, message, hash);
- solve_room_member_collisions (
+ solve_srv_room_member_collisions (
room,
get_member_session_public_key(session),
&(message->body.id.id),
@@ -134,7 +135,7 @@ handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room,
remove_from_list_tunnels (&(room->basement), element);
if (room->peer_message)
- rebuild_room_basement_structure (room);
+ rebuild_srv_room_basement_structure (room);
}
void
@@ -149,5 +150,5 @@ handle_message_delete (struct GNUNET_MESSENGER_SrvRoom *room,
action = GNUNET_TIME_absolute_add (action, delay);
delay = GNUNET_TIME_absolute_get_difference (GNUNET_TIME_absolute_get (), action);
- delete_room_message (room, session, &(message->body.deletion.hash), delay);
+ delete_srv_room_message (room, session, &(message->body.deletion.hash), delay);
}
diff --git a/src/messenger/gnunet-service-messenger_message_handle.h b/src/messenger/gnunet-service-messenger_message_handle.h
index 0e5be3408..0a97cd840 100644
--- a/src/messenger/gnunet-service-messenger_message_handle.h
+++ b/src/messenger/gnunet-service-messenger_message_handle.h
@@ -27,7 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_MESSAGE_HANDLE_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_message_kind.h"
@@ -39,8 +39,8 @@
* Handles a received or sent join message to make changes of current member information.
* (add matching member and clear member info)
*
- * @param[in/out] room Room of the message
- * @param[in/out] session Member session
+ * @param[in,out] room Room of the message
+ * @param[in,out] session Member session
* @param[in] message JOIN-Message
* @param[in] hash Hash of the message
*/
@@ -54,8 +54,8 @@ handle_message_join (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a received or sent leave message to make changes of current member information.
* (remove matching member and clear member info)
*
- * @param[in/out] room Room of the message
- * @param[in/out] session Member session
+ * @param[in,out] room Room of the message
+ * @param[in,out] session Member session
* @param[in] message LEAVE-Message
* @param[in] hash Hash of the message
*/
@@ -69,8 +69,8 @@ handle_message_leave (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a received or sent name message to rename a current member.
* (change name of matching member)
*
- * @param[in/out] room Room of the message
- * @param[in/out] session Member session
+ * @param[in,out] room Room of the message
+ * @param[in,out] session Member session
* @param[in] message NAME-Message
* @param[in] hash Hash of the message
*/
@@ -84,8 +84,8 @@ handle_message_name (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a received or sent key message to change the key of a member and rearrange the contacts accordingly.
* (move the member in the contacts and change its key)
*
- * @param[in/out] room Room of the message
- * @param[in/out] session Member session
+ * @param[in,out] room Room of the message
+ * @param[in,out] session Member session
* @param[in] message KEY-Message
* @param[in] hash Hash of the message
*/
@@ -99,8 +99,8 @@ handle_message_key (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a received or sent peer message to make changes of the basement in the room.
* (add a new peer to the basement and restructure connections based on updated list of peers)
*
- * @param[in/out] room Room of the message
- * @param[in/out] session Member session
+ * @param[in,out] room Room of the message
+ * @param[in,out] session Member session
* @param[in] message PEER-Message
* @param[in] hash Hash of the message
*/
@@ -114,8 +114,8 @@ handle_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a received or sent id message to change a members id.
* (change id of matching member)
*
- * @param[in/out] room Room of the message
- * @param[in/out] session Member session
+ * @param[in,out] room Room of the message
+ * @param[in,out] session Member session
* @param[in] message ID-Message
* @param[in] hash Hash of the message
*/
@@ -129,8 +129,8 @@ handle_message_id (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a received or sent miss message to drop a peer from the basement in the room.
* (remove a peer from the basement and restructure connections based on updated list of peers)
*
- * @param[in/out] room Room of the message
- * @param[in/out] session Member session
+ * @param[in,out] room Room of the message
+ * @param[in,out] session Member session
* @param[in] message MISS-Message
* @param[in] hash Hash of the message
*/
@@ -144,8 +144,8 @@ handle_message_miss (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a received or sent delete message to delete a specific message from the store.
* (remove a message from the store of a room under a given delay)
*
- * @param[in/out] room Room of the message
- * @param[in/out] session Member session
+ * @param[in,out] room Room of the message
+ * @param[in,out] session Member session
* @param[in] message DELETE-Message
* @param[in] hash Hash of the message
*/
diff --git a/src/messenger/gnunet-service-messenger_message_kind.c b/src/messenger/gnunet-service-messenger_message_kind.c
index 2449b9230..828e84d4f 100644
--- a/src/messenger/gnunet-service-messenger_message_kind.c
+++ b/src/messenger/gnunet-service-messenger_message_kind.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_message_kind.h"
#include "messenger_api_util.h"
diff --git a/src/messenger/gnunet-service-messenger_message_kind.h b/src/messenger/gnunet-service-messenger_message_kind.h
index 508f19074..102a70e33 100644
--- a/src/messenger/gnunet-service-messenger_message_kind.h
+++ b/src/messenger/gnunet-service-messenger_message_kind.h
@@ -27,8 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_MESSAGE_KIND_H
#include "platform.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_time_lib.h"
@@ -150,7 +149,7 @@ create_message_invite (const struct GNUNET_PeerIdentity *door,
const struct GNUNET_HashCode *key);
/**
- * Creates and allocates a new <i>text message containing a string representing text.
+ * Creates and allocates a new <i>text</i> message containing a string representing text.
* (all values are stored as copy)
*
* @param[in] text Text
diff --git a/src/messenger/gnunet-service-messenger_message_recv.c b/src/messenger/gnunet-service-messenger_message_recv.c
index bb6ee6f17..94202fdca 100644
--- a/src/messenger/gnunet-service-messenger_message_recv.c
+++ b/src/messenger/gnunet-service-messenger_message_recv.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_message_recv.h"
#include "gnunet-service-messenger_operation.h"
@@ -36,7 +37,7 @@ forward_about_members (struct GNUNET_MESSENGER_SrvRoom *room,
if (session->prev)
forward_about_members (room, tunnel, session->prev, map);
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
struct GNUNET_MESSENGER_ListMessage *element;
for (element = session->messages.head; element; element = element->next)
@@ -92,7 +93,7 @@ recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room,
if (room->host)
{
- const struct GNUNET_MESSENGER_Ego *ego = get_handle_ego(room->host);
+ const struct GNUNET_MESSENGER_Ego *ego = get_srv_handle_ego(room->host);
send_tunnel_message (tunnel, room->host, create_message_info(ego));
}
@@ -102,12 +103,12 @@ recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room,
if (GNUNET_YES != contains_list_tunnels(&(room->basement), &peer))
{
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room);
iterate_store_members(member_store, iterate_forward_members, tunnel);
}
- check_room_peer_status(room, tunnel);
+ check_srv_room_peer_status(room, tunnel);
return GNUNET_NO;
}
@@ -142,7 +143,7 @@ callback_found_message (void *cls,
if (!message)
{
- struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
+ struct GNUNET_MESSENGER_OperationStore *operation_store = get_srv_room_operation_store(room);
use_store_operation(
operation_store,
@@ -165,7 +166,7 @@ recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Request for message (%s)\n", GNUNET_h2s (hash));
@@ -178,7 +179,7 @@ recv_message_request (struct GNUNET_MESSENGER_SrvRoom *room,
if ((!session) || (GNUNET_YES != check_member_session_history(session, hash, GNUNET_NO)))
return GNUNET_NO;
- if (GNUNET_NO == request_room_message(room, &(message->body.request.hash), session, callback_found_message, tunnel))
+ if (GNUNET_NO == request_srv_room_message(room, &(message->body.request.hash), session, callback_found_message, tunnel))
return GNUNET_YES;
return GNUNET_NO;
diff --git a/src/messenger/gnunet-service-messenger_message_recv.h b/src/messenger/gnunet-service-messenger_message_recv.h
index 400c10245..8e5b02504 100644
--- a/src/messenger/gnunet-service-messenger_message_recv.h
+++ b/src/messenger/gnunet-service-messenger_message_recv.h
@@ -27,7 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_MESSAGE_RECV_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_message_kind.h"
@@ -39,8 +39,8 @@
* Handles a received info message to change the current member id to the one generated by
* the host connected to. (all current tunnels will be informed about the id change)
*
- * @param[in/out] room Room of the message
- * @param[in/out] tunnel Receiving connection
+ * @param[in,out] room Room of the message
+ * @param[in,out] tunnel Receiving connection
* @param[in] message INFO-Message
* @param[in] hash Hash of the message
* @return #GNUNET_NO to not forward the message
@@ -55,8 +55,8 @@ recv_message_info (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a received peer message to link it to its origin tunnel if the peer identity matches.
* (the peer message and the member id can potentially be linked to the tunnel)
*
- * @param[in/out] room Room of the message
- * @param[in/out] tunnel Receiving connection
+ * @param[in,out] room Room of the message
+ * @param[in,out] tunnel Receiving connection
* @param[in] message PEER-Message
* @param[in] hash Hash of the message
* @return #GNUNET_YES to forward the message
@@ -72,8 +72,8 @@ recv_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
* if the message was found.
* (this can also cause this peer to send a new request instead of only forwarding the received one)
*
- * @param[in/out] room Room of the message
- * @param[in/out] tunnel Receiving connection
+ * @param[in,out] room Room of the message
+ * @param[in,out] tunnel Receiving connection
* @param[in] message REQUEST-Message
* @param[in] hash Hash of the message
* @return #GNUNET_YES or #GNUNET_NO depending on required forwarding
diff --git a/src/messenger/gnunet-service-messenger_message_send.c b/src/messenger/gnunet-service-messenger_message_send.c
index 8cc2466d7..09039758b 100644
--- a/src/messenger/gnunet-service-messenger_message_send.c
+++ b/src/messenger/gnunet-service-messenger_message_send.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_message_send.h"
#include "gnunet-service-messenger_member.h"
@@ -35,7 +36,7 @@ send_message_join (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
- check_room_peer_status(room, NULL);
+ check_srv_room_peer_status(room, NULL);
}
void
@@ -56,7 +57,7 @@ send_message_id (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
- change_handle_member_id (handle, get_room_key(room), &(message->body.id.id));
+ change_srv_handle_member_id (handle, get_srv_room_key(room), &(message->body.id.id));
}
void
@@ -65,7 +66,7 @@ send_message_request (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
- struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
+ struct GNUNET_MESSENGER_OperationStore *operation_store = get_srv_room_operation_store(room);
use_store_operation(
operation_store,
diff --git a/src/messenger/gnunet-service-messenger_message_send.h b/src/messenger/gnunet-service-messenger_message_send.h
index 232355c41..4f4c6cfc2 100644
--- a/src/messenger/gnunet-service-messenger_message_send.h
+++ b/src/messenger/gnunet-service-messenger_message_send.h
@@ -27,7 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_MESSAGE_SEND_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_message_kind.h"
@@ -38,8 +38,8 @@
* Handles a sent join message to ensure growth of the decentralized room structure.
* (if the service provides a peer message for this room currently, it will be forwarded)
*
- * @param[in/out] room Room of the message
- * @param[in/out] handle Sending handle
+ * @param[in,out] room Room of the message
+ * @param[in,out] handle Sending handle
* @param[in] message JOIN-Message
* @param[in] hash Hash of the message
*/
@@ -53,8 +53,8 @@ send_message_join (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a sent peer message to update the rooms peer message of this service.
* (a set peer message indicates this service being a part of the decentralized room structure)
*
- * @param[in/out] room Room of the message
- * @param[in/out] handle Sending handle
+ * @param[in,out] room Room of the message
+ * @param[in,out] handle Sending handle
* @param[in] message PEER-Message
* @param[in] hash Hash of the message
*/
@@ -68,8 +68,8 @@ send_message_peer (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a sent id message to update the handles member id in the room.
* (changing member id is useful to prevent collisions)
*
- * @param[in/out] room Room of the message
- * @param[in/out] handle Sending handle
+ * @param[in,out] room Room of the message
+ * @param[in,out] handle Sending handle
* @param[in] message ID-Message
* @param[in] hash Hash of the message
*/
@@ -83,8 +83,8 @@ send_message_id (struct GNUNET_MESSENGER_SrvRoom *room,
* Handles a sent request message to trigger the request operation for this service.
* (the request operation will deactivate the possibility of spamming requests)
*
- * @param[in/out] room Room of the message
- * @param[in/out] handle Sending handle
+ * @param[in,out] room Room of the message
+ * @param[in,out] handle Sending handle
* @param[in] message PEER-Message
* @param[in] hash Hash of the message
*/
diff --git a/src/messenger/gnunet-service-messenger_message_state.c b/src/messenger/gnunet-service-messenger_message_state.c
index 344962d11..b2328588e 100644
--- a/src/messenger/gnunet-service-messenger_message_state.c
+++ b/src/messenger/gnunet-service-messenger_message_state.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_message_state.h"
void
diff --git a/src/messenger/gnunet-service-messenger_message_state.h b/src/messenger/gnunet-service-messenger_message_state.h
index af52b26b6..10e6a2c46 100644
--- a/src/messenger/gnunet-service-messenger_message_state.h
+++ b/src/messenger/gnunet-service-messenger_message_state.h
@@ -27,7 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_MESSAGE_STATE_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "messenger_api_message.h"
#include "gnunet-service-messenger_list_messages.h"
diff --git a/src/messenger/gnunet-service-messenger_message_store.c b/src/messenger/gnunet-service-messenger_message_store.c
index ddad266ad..1f77de9ca 100644
--- a/src/messenger/gnunet-service-messenger_message_store.c
+++ b/src/messenger/gnunet-service-messenger_message_store.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_message_store.h"
#include "messenger_api_message.h"
@@ -259,8 +260,6 @@ iterate_save_entries (void *cls,
struct GNUNET_MESSENGER_ClosureMessageSave *save = cls;
struct GNUNET_MESSENGER_MessageEntry *entry = value;
- struct GNUNET_MESSENGER_MessageEntryStorage storage;
-
GNUNET_DISK_file_write (save->storage, key, sizeof(*key));
GNUNET_DISK_file_write (save->storage, &(entry->offset), sizeof(entry->offset));
GNUNET_DISK_file_write (save->storage, &(entry->length), sizeof(entry->length));
diff --git a/src/messenger/gnunet-service-messenger_message_store.h b/src/messenger/gnunet-service-messenger_message_store.h
index 476d98dd5..262d10555 100644
--- a/src/messenger/gnunet-service-messenger_message_store.h
+++ b/src/messenger/gnunet-service-messenger_message_store.h
@@ -27,8 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_MESSAGE_STORE_H
#include "platform.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_disk_lib.h"
+#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_MessageEntry
{
@@ -69,7 +68,7 @@ init_message_store (struct GNUNET_MESSENGER_MessageStore *store);
/**
* Clears a message <i>store</i>, wipes its content and deallocates its memory.
*
- * @param[in/out] store Message store
+ * @param[in,out] store Message store
*/
void
clear_message_store (struct GNUNET_MESSENGER_MessageStore *store);
@@ -115,7 +114,7 @@ contains_store_message (const struct GNUNET_MESSENGER_MessageStore *store,
* This function requires the message to be loaded into memory!
* @see contains_store_message()
*
- * @param[in/out] store Message store
+ * @param[in,out] store Message store
* @param[in] hash Hash of message
* @return Message or NULL
*/
@@ -131,7 +130,7 @@ get_store_message (struct GNUNET_MESSENGER_MessageStore *store,
* hash. The link which will be returned copies link information from the message for
* temporary usage.
*
- * @param[in/out] store Message store
+ * @param[in,out] store Message store
* @param[in] hash Hash of message
* @param[in] deleted_only Flag
* @return Message link or NULL
@@ -144,9 +143,9 @@ get_store_message_link (struct GNUNET_MESSENGER_MessageStore *store,
/**
* Stores a message into the message store. The result indicates if the operation was successful.
*
- * @param[in/out] store Message store
+ * @param[in,out] store Message store
* @param[in] hash Hash of message
- * @param[in/out] message Message
+ * @param[in,out] message Message
* @return #GNUNET_OK on success, otherwise #GNUNET_NO
*/
int
@@ -158,7 +157,7 @@ put_store_message (struct GNUNET_MESSENGER_MessageStore *store,
* Deletes a message in the message store. It will be removed from disk space and memory. The result
* indicates if the operation was successful.
*
- * @param[in/out] store Message store
+ * @param[in,out] store Message store
* @param[in] hash Hash of message
* @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
diff --git a/src/messenger/gnunet-service-messenger_operation.c b/src/messenger/gnunet-service-messenger_operation.c
index 2b92d0c1d..9c4201fdf 100644
--- a/src/messenger/gnunet-service-messenger_operation.c
+++ b/src/messenger/gnunet-service-messenger_operation.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_operation.h"
#include "gnunet-service-messenger_operation_store.h"
diff --git a/src/messenger/gnunet-service-messenger_operation.h b/src/messenger/gnunet-service-messenger_operation.h
index 485668548..b93282d24 100644
--- a/src/messenger/gnunet-service-messenger_operation.h
+++ b/src/messenger/gnunet-service-messenger_operation.h
@@ -28,9 +28,8 @@
#include "platform.h"
#include "gnunet_configuration_lib.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_scheduler_lib.h"
-#include "gnunet_strings_lib.h"
#include "gnunet_time_lib.h"
enum GNUNET_MESSENGER_OperationType
@@ -66,7 +65,7 @@ create_operation (const struct GNUNET_HashCode *hash);
/**
* Destroys an operation and frees its memory fully.
*
- * @param[in/out] op Operation
+ * @param[in,out] op Operation
*/
void
destroy_operation (struct GNUNET_MESSENGER_Operation *op);
@@ -82,7 +81,7 @@ destroy_operation (struct GNUNET_MESSENGER_Operation *op);
* If the method fails to restore any valid operation from the file,
* NULL gets returned instead.
*
- * @param[in/out] store Operation store
+ * @param[in,out] store Operation store
* @param[in] path Path of a configuration file
*/
struct GNUNET_MESSENGER_Operation*
@@ -107,9 +106,9 @@ save_operation (const struct GNUNET_MESSENGER_Operation *op,
* operations type to process it correctly. An operation can't be
* started twice, it has to be stopped or fully processed first.
*
- * @param[in/out] op Operation
+ * @param[in,out] op Operation
* @param[in] type Type of operation
- * @param[in/out] store Operation store
+ * @param[in,out] store Operation store
* @param[in] delay Delay
* @return #GNUNET_OK on success, otherwise #GNUNET_SYSERR
*/
diff --git a/src/messenger/gnunet-service-messenger_operation_store.c b/src/messenger/gnunet-service-messenger_operation_store.c
index 276f0b92b..6a639d69e 100644
--- a/src/messenger/gnunet-service-messenger_operation_store.c
+++ b/src/messenger/gnunet-service-messenger_operation_store.c
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_operation_store.h"
#include "gnunet-service-messenger_operation.h"
diff --git a/src/messenger/gnunet-service-messenger_operation_store.h b/src/messenger/gnunet-service-messenger_operation_store.h
index 18eb7f8a1..16531758c 100644
--- a/src/messenger/gnunet-service-messenger_operation_store.h
+++ b/src/messenger/gnunet-service-messenger_operation_store.h
@@ -27,9 +27,7 @@
#define GNUNET_SERVICE_MESSENGER_OPERATION_STORE_H
#include "platform.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_scheduler_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_time_lib.h"
struct GNUNET_MESSENGER_SrvRoom;
@@ -45,7 +43,7 @@ struct GNUNET_MESSENGER_OperationStore
* Initializes an operation <i>store</i> as fully empty with a given <i>room</i>.
*
* @param[out] store Operation store
- * @param[in/out] room Room
+ * @param[in,out] room Room
*/
void
init_operation_store (struct GNUNET_MESSENGER_OperationStore *store,
@@ -54,7 +52,7 @@ init_operation_store (struct GNUNET_MESSENGER_OperationStore *store,
/**
* Clears an operation <i>store</i>, stops all operations and deallocates its memory.
*
- * @param[in/out] store Operation store
+ * @param[in,out] store Operation store
*/
void
clear_operation_store (struct GNUNET_MESSENGER_OperationStore *store);
@@ -103,7 +101,7 @@ get_store_operation_type (const struct GNUNET_MESSENGER_OperationStore *store,
* If the new operation could be started successfully the method returns
* #GNUNET_OK, otherwise #GNUNET_SYSERR.
*
- * @param[in/out] store Operation store
+ * @param[in,out] store Operation store
* @param[in] hash Hash of message
* @param[in] type Operation type
* @param[in] delay Delay
@@ -122,7 +120,7 @@ use_store_operation (struct GNUNET_MESSENGER_OperationStore *store,
* Beware that calling this method will also implicitly free the memory
* of any active operation under the given hash!
*
- * @param[in/out] store Operation store
+ * @param[in,out] store Operation store
* @param[in] hash Hash of message
*/
void
diff --git a/src/messenger/gnunet-service-messenger_room.c b/src/messenger/gnunet-service-messenger_room.c
index 7f2fd0ca6..4b734cb40 100644
--- a/src/messenger/gnunet-service-messenger_room.c
+++ b/src/messenger/gnunet-service-messenger_room.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_room.h"
#include "gnunet-service-messenger_member.h"
@@ -43,8 +44,8 @@ static void
idle_request_room_messages (void *cls);
struct GNUNET_MESSENGER_SrvRoom*
-create_room (struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_HashCode *key)
+create_srv_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_HashCode *key)
{
GNUNET_assert((handle) && (key));
@@ -58,9 +59,9 @@ create_room (struct GNUNET_MESSENGER_SrvHandle *handle,
room->tunnels = GNUNET_CONTAINER_multipeermap_create (8, GNUNET_NO);
- init_member_store(get_room_member_store(room), room);
- init_message_store (get_room_message_store(room));
- init_operation_store(get_room_operation_store(room), room);
+ init_member_store(get_srv_room_member_store(room), room);
+ init_message_store (get_srv_room_message_store(room));
+ init_operation_store(get_srv_room_operation_store(room), room);
init_list_tunnels (&(room->basement));
init_message_state(&(room->state));
@@ -71,7 +72,7 @@ create_room (struct GNUNET_MESSENGER_SrvHandle *handle,
room->idle = NULL;
if (room->service->dir)
- load_room (room);
+ load_srv_room (room);
room->idle = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, idle_request_room_messages, room);
@@ -92,14 +93,14 @@ static void
handle_room_messages (struct GNUNET_MESSENGER_SrvRoom *room);
void
-destroy_room (struct GNUNET_MESSENGER_SrvRoom *room)
+destroy_srv_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ int deletion)
{
GNUNET_assert(room);
if (room->idle)
{
GNUNET_SCHEDULER_cancel (room->idle);
-
room->idle = NULL;
}
@@ -107,18 +108,22 @@ destroy_room (struct GNUNET_MESSENGER_SrvRoom *room)
GNUNET_CADET_close_port (room->port);
GNUNET_CONTAINER_multipeermap_iterate (room->tunnels, iterate_destroy_tunnels, NULL);
-
handle_room_messages (room);
- if (room->service->dir)
- save_room (room);
+ if (!(room->service->dir))
+ goto skip_saving;
- clear_member_store (get_room_member_store(room));
- clear_message_store (get_room_message_store(room));
- clear_operation_store(get_room_operation_store(room));
+ if (GNUNET_YES == deletion)
+ remove_srv_room (room);
+ else
+ save_srv_room (room);
- GNUNET_CONTAINER_multipeermap_destroy (room->tunnels);
+skip_saving:
+ clear_member_store (get_srv_room_member_store(room));
+ clear_message_store (get_srv_room_message_store(room));
+ clear_operation_store(get_srv_room_operation_store(room));
+ GNUNET_CONTAINER_multipeermap_destroy (room->tunnels);
clear_list_tunnels (&(room->basement));
clear_message_state(&(room->state));
@@ -129,7 +134,7 @@ destroy_room (struct GNUNET_MESSENGER_SrvRoom *room)
}
struct GNUNET_MESSENGER_MemberStore*
-get_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room)
+get_srv_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert(room);
@@ -137,7 +142,7 @@ get_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room)
}
struct GNUNET_MESSENGER_MessageStore*
-get_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room)
+get_srv_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert(room);
@@ -145,7 +150,7 @@ get_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room)
}
struct GNUNET_MESSENGER_OperationStore*
-get_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room)
+get_srv_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert(room);
@@ -160,7 +165,7 @@ send_room_info (struct GNUNET_MESSENGER_SrvRoom *room,
if ((!handle) || (!is_tunnel_connected (tunnel)))
return GNUNET_NO;
- return send_tunnel_message (tunnel, handle, create_message_info (get_handle_ego (handle)));
+ return send_tunnel_message (tunnel, handle, create_message_info (get_srv_handle_ego (handle)));
}
static void*
@@ -189,7 +194,7 @@ callback_room_connect (void *cls,
bind_tunnel(tunnel, channel);
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "New tunnel in room (%s) established to peer: %s\n",
- GNUNET_h2s(get_room_key(room)), GNUNET_i2s (source));
+ GNUNET_h2s(get_srv_room_key(room)), GNUNET_i2s (source));
if (GNUNET_YES == send_room_info (room, room->host, tunnel))
return tunnel;
@@ -209,15 +214,15 @@ join_room (struct GNUNET_MESSENGER_SrvRoom *room,
{
GNUNET_assert((room) && (handle) && (member));
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (get_room_key (room)),
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (get_srv_room_key (room)),
GNUNET_sh2s (get_member_id(member)));
const struct GNUNET_ShortHashCode *member_id = get_member_id(member);
- if (GNUNET_OK != change_handle_member_id (handle, get_room_key(room), member_id))
+ if (GNUNET_OK != change_srv_handle_member_id (handle, get_srv_room_key(room), member_id))
return GNUNET_NO;
- struct GNUNET_MESSENGER_Message *message = create_message_join (get_handle_ego (handle));
+ struct GNUNET_MESSENGER_Message *message = create_message_join (get_srv_handle_ego (handle));
if (!message)
{
@@ -227,7 +232,7 @@ join_room (struct GNUNET_MESSENGER_SrvRoom *room,
}
GNUNET_memcpy(&(message->header.sender_id), member_id, sizeof(*member_id));
- return send_room_message (room, handle, message);
+ return send_srv_room_message (room, handle, message);
}
struct GNUNET_MESSENGER_MemberNotify
@@ -246,7 +251,7 @@ notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify,
if (session->prev)
notify_about_members (notify, session->prev, map, GNUNET_YES);
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(notify->room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(notify->room);
struct GNUNET_MESSENGER_ListMessage *element;
for (element = session->messages.head; element; element = element->next)
@@ -265,7 +270,7 @@ notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify,
const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, &(element->hash));
if (message)
- notify_handle_message (notify->handle, notify->room, session, message, &(element->hash));
+ notify_srv_handle_message (notify->handle, notify->room, session, message, &(element->hash));
}
}
@@ -291,15 +296,15 @@ static int
join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room,
struct GNUNET_MESSENGER_SrvHandle *handle)
{
- const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room));
+ const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (handle, get_srv_room_key(room));
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = add_store_member(member_store, member_id);
if (GNUNET_NO == join_room (room, handle, member))
return GNUNET_NO;
- const struct GNUNET_MESSENGER_Ego *ego = get_handle_ego(handle);
+ const struct GNUNET_MESSENGER_Ego *ego = get_srv_handle_ego(handle);
struct GNUNET_MESSENGER_MemberSession *session = get_member_session (member, &(ego->pub));
if (!session)
@@ -314,7 +319,7 @@ join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room,
notify.handle = handle;
notify.session = session;
- iterate_store_members(get_room_member_store(room), iterate_notify_about_members, &notify);
+ iterate_store_members(get_srv_room_member_store(room), iterate_notify_about_members, &notify);
return GNUNET_YES;
}
@@ -332,16 +337,16 @@ callback_tunnel_disconnect (void *cls,
const struct GNUNET_CADET_Channel *channel);
int
-open_room (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvHandle *handle)
+open_srv_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert((room) && (handle));
if (room->port)
return join_room_locally (room, handle);
- struct GNUNET_CADET_Handle *cadet = get_room_cadet (room);
- const struct GNUNET_HashCode *key = get_room_key (room);
+ struct GNUNET_CADET_Handle *cadet = get_srv_room_cadet (room);
+ const struct GNUNET_HashCode *key = get_srv_room_key (room);
struct GNUNET_MQ_MessageHandler handlers[] = { GNUNET_MQ_hd_var_size(tunnel_message, GNUNET_MESSAGE_TYPE_CADET_CLI,
struct GNUNET_MessageHeader, NULL),
@@ -354,14 +359,14 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room,
if (room->port)
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Port of room (%s) was opened!\n",
- GNUNET_h2s(get_room_key(room)));
+ GNUNET_h2s(get_srv_room_key(room)));
else
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Port of room (%s) could not be opened!\n",
- GNUNET_h2s(get_room_key(room)));
+ GNUNET_h2s(get_srv_room_key(room)));
- const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room));
+ const struct GNUNET_ShortHashCode *member_id = get_srv_handle_member_id (handle, get_srv_room_key(room));
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = add_store_member(member_store, member_id);
if ((GNUNET_NO == join_room (room, handle, member)) && (room->port))
@@ -376,13 +381,13 @@ open_room (struct GNUNET_MESSENGER_SrvRoom *room,
struct GNUNET_MESSENGER_Message *peer_msg = create_message_peer (room->service);
GNUNET_memcpy(&(peer_msg->header.sender_id), member_id, sizeof(*member_id));
- return (room->port ? send_room_message (room, handle, peer_msg) : GNUNET_NO);
+ return (room->port ? send_srv_room_message (room, handle, peer_msg) : GNUNET_NO);
}
int
-enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_PeerIdentity *door)
+enter_srv_room_at (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_PeerIdentity *door)
{
GNUNET_assert((room) && (handle) && (door));
@@ -419,24 +424,24 @@ enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room,
}
struct GNUNET_MQ_Envelope*
-pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_MESSENGER_SrvHandle *handle,
- struct GNUNET_MESSENGER_Message *message,
- struct GNUNET_HashCode *hash,
- int mode)
+pack_srv_room_message (const struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_HashCode *hash,
+ int mode)
{
GNUNET_assert((room) && (handle) && (message) && (hash));
message->header.timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
- const struct GNUNET_ShortHashCode *id = get_handle_member_id (handle, get_room_key(room));
+ const struct GNUNET_ShortHashCode *id = get_srv_handle_member_id (handle, get_srv_room_key(room));
GNUNET_assert(id);
GNUNET_memcpy(&(message->header.sender_id), id, sizeof(struct GNUNET_ShortHashCode));
get_message_state_chain_hash (&(room->state), &(message->header.previous));
- return pack_message (message, hash, get_handle_ego (handle), mode);
+ return pack_message (message, hash, get_srv_handle_ego (handle), mode);
}
struct GNUNET_MESSENGER_ClosureSendRoom
@@ -469,7 +474,7 @@ iterate_send_room_message (void *cls,
if (closure->packed == GNUNET_NO)
{
- env = pack_room_message (closure->room, closure->handle, closure->message, closure->hash,
+ env = pack_srv_room_message (closure->room, closure->handle, closure->message, closure->hash,
GNUNET_MESSENGER_PACK_MODE_ENVELOPE);
if (env)
@@ -496,9 +501,9 @@ callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_HashCode *hash);
int
-send_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvHandle *handle,
- struct GNUNET_MESSENGER_Message *message)
+send_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_Message *message)
{
GNUNET_assert((room) && (handle));
@@ -506,10 +511,10 @@ send_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
return GNUNET_NO;
if (GNUNET_YES == is_message_session_bound(message))
- merge_room_last_messages(room, handle);
+ merge_srv_room_last_messages(room, handle);
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Sending message from handle with member id: %s\n",
- GNUNET_sh2s(get_handle_member_id(handle, get_room_key(room))));
+ GNUNET_sh2s(get_srv_handle_member_id(handle, get_srv_room_key(room))));
struct GNUNET_HashCode hash;
struct GNUNET_MESSENGER_ClosureSendRoom closure;
@@ -524,7 +529,7 @@ send_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
GNUNET_CONTAINER_multipeermap_iterate (room->tunnels, iterate_send_room_message, &closure);
if (GNUNET_NO == closure.packed)
- pack_room_message (room, handle, message, &hash, GNUNET_MESSENGER_PACK_MODE_UNKNOWN);
+ pack_srv_room_message (room, handle, message, &hash, GNUNET_MESSENGER_PACK_MODE_UNKNOWN);
const int new_message = update_room_message (room, message, &hash);
@@ -554,10 +559,10 @@ send_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
}
void
-forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- struct GNUNET_MESSENGER_Message *message,
- const struct GNUNET_HashCode *hash)
+forward_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash)
{
GNUNET_assert((room) && (tunnel));
@@ -580,13 +585,13 @@ forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
}
void
-check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvTunnel *tunnel)
+check_srv_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel)
{
if (!room->peer_message)
return;
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, room->peer_message);
@@ -597,7 +602,7 @@ check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room,
return;
}
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
if (!member)
@@ -615,12 +620,12 @@ check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room,
resend_peer_message:
if (room->host)
- send_room_message (room, room->host, create_message_peer (room->service));
+ send_srv_room_message (room, room->host, create_message_peer (room->service));
}
void
-merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvHandle *handle)
+merge_srv_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle)
{
GNUNET_assert(room);
@@ -635,7 +640,7 @@ merge_next:
if (!hash)
return;
- send_room_message (room, handle, create_message_merge (hash));
+ send_srv_room_message (room, handle, create_message_merge (hash));
goto merge_next;
}
@@ -643,7 +648,7 @@ void
callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_HashCode *hash)
{
- if (GNUNET_OK != delete_store_message (get_room_message_store(room), hash))
+ if (GNUNET_OK != delete_store_message (get_srv_room_message_store(room), hash))
{
GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Deletion of message failed! (%s)\n", GNUNET_h2s(hash));
return;
@@ -657,14 +662,14 @@ callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room,
if (!room->host)
return;
- send_room_message (room, room->host, create_message_merge (hash));
+ send_srv_room_message (room, room->host, create_message_merge (hash));
}
int
-delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_HashCode *hash,
- const struct GNUNET_TIME_Relative delay)
+delete_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_TIME_Relative delay)
{
GNUNET_assert((room) && (session) && (hash));
@@ -676,7 +681,7 @@ delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
return GNUNET_SYSERR;
}
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, hash);
@@ -691,7 +696,7 @@ delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
return GNUNET_NO;
}
- struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
+ struct GNUNET_MESSENGER_OperationStore *operation_store = get_srv_room_operation_store(room);
if (GNUNET_OK != use_store_operation(operation_store, hash, GNUNET_MESSENGER_OP_DELETE, delay))
{
@@ -703,7 +708,7 @@ delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
}
struct GNUNET_CADET_Handle*
-get_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room)
+get_srv_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert(room);
@@ -711,7 +716,7 @@ get_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room)
}
const struct GNUNET_HashCode*
-get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room)
+get_srv_room_key (const struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert(room);
@@ -719,8 +724,8 @@ get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room)
}
const struct GNUNET_MESSENGER_SrvTunnel*
-get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_PeerIdentity *peer)
+get_srv_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_PeerIdentity *peer)
{
GNUNET_assert((room) && (peer));
@@ -734,7 +739,7 @@ request_room_message_step (struct GNUNET_MESSENGER_SrvRoom *room,
GNUNET_MESSENGER_MessageRequestCallback callback,
void* cls)
{
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
const struct GNUNET_MESSENGER_MessageLink *link = get_store_message_link(
message_store, hash, GNUNET_YES
@@ -767,11 +772,11 @@ forward:
}
int
-request_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_HashCode *hash,
- const struct GNUNET_MESSENGER_MemberSession *session,
- GNUNET_MESSENGER_MessageRequestCallback callback,
- void* cls)
+request_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_MESSENGER_MemberSession *session,
+ GNUNET_MESSENGER_MessageRequestCallback callback,
+ void* cls)
{
GNUNET_assert((room) && (hash));
@@ -800,7 +805,7 @@ callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room,
return;
if (GNUNET_YES == contains_list_tunnels (&(room->basement), &identity))
- send_room_message (room, room->host, create_message_miss (&identity));
+ send_srv_room_message (room, room->host, create_message_miss (&identity));
}
int
@@ -815,7 +820,7 @@ callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
return GNUNET_SYSERR;
}
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
const struct GNUNET_MESSENGER_Message *previous = get_store_message(message_store, &(message->header.previous));
@@ -845,7 +850,7 @@ idle_request_room_messages (void *cls)
room->idle = NULL;
- struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
+ struct GNUNET_MESSENGER_OperationStore *operation_store = get_srv_room_operation_store(room);
const struct GNUNET_HashCode *hash = get_message_state_merge_hash(&(room->state));
if ((hash) &&
@@ -866,14 +871,14 @@ idle_request_room_messages (void *cls)
}
void
-solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_IDENTITY_PublicKey *public_key,
- const struct GNUNET_ShortHashCode *member_id,
- struct GNUNET_TIME_Absolute timestamp)
+solve_srv_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_IDENTITY_PublicKey *public_key,
+ const struct GNUNET_ShortHashCode *member_id,
+ struct GNUNET_TIME_Absolute timestamp)
{
GNUNET_assert ((room) && (public_key) && (member_id));
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, member_id);
if ((!member) || (1 >= GNUNET_CONTAINER_multihashmap_size(member->sessions)))
@@ -884,13 +889,13 @@ solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room,
for (element = handles->head; element; element = element->next)
{
- if (0 != GNUNET_memcmp(member_id, get_handle_member_id(element->handle, get_room_key(room))))
+ if (0 != GNUNET_memcmp(member_id, get_srv_handle_member_id(element->handle, get_srv_room_key(room))))
continue;
- if (0 == GNUNET_memcmp(public_key, &(get_handle_ego(element->handle)->pub)))
+ if (0 == GNUNET_memcmp(public_key, &(get_srv_handle_ego(element->handle)->pub)))
continue;
- struct GNUNET_MESSENGER_MemberSession *session = get_member_session(member, &(get_handle_ego(element->handle)->pub));
+ struct GNUNET_MESSENGER_MemberSession *session = get_member_session(member, &(get_srv_handle_ego(element->handle)->pub));
if (!session)
continue;
@@ -903,12 +908,12 @@ solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room,
struct GNUNET_ShortHashCode random_id;
generate_free_member_id (&random_id, member_store->members);
- send_room_message(room, element->handle, create_message_id(&random_id));
+ send_srv_room_message(room, element->handle, create_message_id(&random_id));
}
}
void
-rebuild_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room)
+rebuild_srv_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert(room);
@@ -957,8 +962,8 @@ rebuild_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room)
static void
handle_room_messages (struct GNUNET_MESSENGER_SrvRoom *room)
{
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room);
while (room->handling.head)
{
@@ -992,7 +997,7 @@ update_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
{
GNUNET_assert((room) && (message) && (hash));
- struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
+ struct GNUNET_MESSENGER_OperationStore *operation_store = get_srv_room_operation_store(room);
const int requested = (GNUNET_MESSENGER_OP_REQUEST == get_store_operation_type(operation_store, hash)?
GNUNET_YES : GNUNET_NO
@@ -1001,11 +1006,11 @@ update_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
if (GNUNET_YES == requested)
cancel_store_operation(operation_store, hash);
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(room);
const struct GNUNET_MESSENGER_Message *old_message = get_store_message (message_store, hash);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handle a message in room (%s).\n", GNUNET_h2s (get_room_key(room)));
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handle a message in room (%s).\n", GNUNET_h2s (get_srv_room_key(room)));
if ((old_message) || (GNUNET_OK != put_store_message (message_store, hash, message)))
{
@@ -1083,7 +1088,7 @@ callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room,
const struct GNUNET_MESSENGER_Message *message,
const struct GNUNET_HashCode *hash)
{
- struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
+ struct GNUNET_MESSENGER_MemberStore *member_store = get_srv_room_member_store(room);
struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Callback for message (%s)\n", GNUNET_h2s (hash));
@@ -1165,11 +1170,11 @@ get_room_data_subdir (struct GNUNET_MESSENGER_SrvRoom *room,
{
GNUNET_assert((room) && (dir));
- GNUNET_asprintf (dir, "%s%s%c%s%c", room->service->dir, "rooms", DIR_SEPARATOR, GNUNET_h2s (get_room_key(room)), DIR_SEPARATOR);
+ GNUNET_asprintf (dir, "%s%s%c%s%c", room->service->dir, "rooms", DIR_SEPARATOR, GNUNET_h2s (get_srv_room_key(room)), DIR_SEPARATOR);
}
void
-load_room (struct GNUNET_MESSENGER_SrvRoom *room)
+load_srv_room (struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert(room);
@@ -1178,9 +1183,9 @@ load_room (struct GNUNET_MESSENGER_SrvRoom *room)
if (GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_YES))
{
- load_member_store (get_room_member_store(room), room_dir);
- load_message_store (get_room_message_store(room), room_dir);
- load_operation_store(get_room_operation_store(room), room_dir);
+ load_member_store (get_srv_room_member_store(room), room_dir);
+ load_message_store (get_srv_room_message_store(room), room_dir);
+ load_operation_store(get_srv_room_operation_store(room), room_dir);
char *basement_file;
GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
@@ -1195,7 +1200,7 @@ load_room (struct GNUNET_MESSENGER_SrvRoom *room)
}
void
-save_room (struct GNUNET_MESSENGER_SrvRoom *room)
+save_srv_room (struct GNUNET_MESSENGER_SrvRoom *room)
{
GNUNET_assert(room);
@@ -1205,9 +1210,9 @@ save_room (struct GNUNET_MESSENGER_SrvRoom *room)
if ((GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_NO)) ||
(GNUNET_OK == GNUNET_DISK_directory_create (room_dir)))
{
- save_member_store(get_room_member_store(room), room_dir);
- save_message_store (get_room_message_store(room), room_dir);
- save_operation_store(get_room_operation_store(room), room_dir);
+ save_member_store(get_srv_room_member_store(room), room_dir);
+ save_message_store (get_srv_room_message_store(room), room_dir);
+ save_operation_store(get_srv_room_operation_store(room), room_dir);
char *basement_file;
GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
@@ -1221,6 +1226,20 @@ save_room (struct GNUNET_MESSENGER_SrvRoom *room)
GNUNET_free(room_dir);
}
+void
+remove_srv_room (struct GNUNET_MESSENGER_SrvRoom *room)
+{
+ GNUNET_assert(room);
+
+ char *room_dir;
+ get_room_data_subdir (room, &room_dir);
+
+ if (GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_YES))
+ GNUNET_DISK_directory_remove(room_dir);
+
+ GNUNET_free(room_dir);
+}
+
static void
remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room,
struct GNUNET_MESSENGER_MemberSession *session)
diff --git a/src/messenger/gnunet-service-messenger_room.h b/src/messenger/gnunet-service-messenger_room.h
index 4b3811104..2e9382595 100644
--- a/src/messenger/gnunet-service-messenger_room.h
+++ b/src/messenger/gnunet-service-messenger_room.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -28,10 +28,8 @@
#include "platform.h"
#include "gnunet_cadet_service.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
-#include "gnunet_mq_lib.h"
#include "gnunet_messenger_service.h"
#include "gnunet-service-messenger_basement.h"
@@ -84,48 +82,53 @@ struct GNUNET_MESSENGER_SrvRoom
/**
* Creates and allocates a new room for a <i>handle</i> with a given <i>key</i>.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of room
* @return New room
*/
struct GNUNET_MESSENGER_SrvRoom*
-create_room (struct GNUNET_MESSENGER_SrvHandle *handle,
+create_srv_room (struct GNUNET_MESSENGER_SrvHandle *handle,
const struct GNUNET_HashCode *key);
/**
* Destroys a room and frees its memory fully.
*
- * @param[in/out] room Room
+ * The <i>deletion</i> flag should only be set to #GNUNET_YES if the
+ * room gets dropped by the service, otherwise #GNUNET_NO.
+ *
+ * @param[in,out] room Room
+ * @param[in] deletion Flag to indicate context of destruction
*/
void
-destroy_room (struct GNUNET_MESSENGER_SrvRoom *room);
+destroy_srv_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ int deletion);
/**
* Returns the used member store of a given <i>room</i>.
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
* @return Member store
*/
struct GNUNET_MESSENGER_MemberStore*
-get_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room);
+get_srv_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Returns the used message store of a given <i>room</i>.
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
* @return Message store
*/
struct GNUNET_MESSENGER_MessageStore*
-get_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room);
+get_srv_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Returns the used operation store of a given <i>room</i>.
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
* @return Operation store
*/
struct GNUNET_MESSENGER_OperationStore*
-get_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room);
+get_srv_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Tries to open a <i>room</i> for a given <i>handle</i>. If the room has already been opened, the handle
@@ -135,28 +138,28 @@ get_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room);
*
* If the function returns #GNUNET_YES the port for this room is guaranteed to be open for incoming connections.
*
- * @param[in/out] room Room
- * @param[in/out] handle Handle
+ * @param[in,out] room Room
+ * @param[in,out] handle Handle
* @return #GNUNET_YES on success, #GNUNET_NO on failure.
*/
int
-open_room (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvHandle *handle);
+open_srv_room (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Connects a tunnel to a hosting peer of a <i>room</i> through a so called <i>door</i> which is represented by
* a peer identity of a hosting peer. During the connection the handle will join the room as a member, waiting for
* an info message from the selected host.
*
- * @param[in/out] room Room
- * @param[in/out] handle Handle
+ * @param[in,out] room Room
+ * @param[in,out] handle Handle
* @param[in] door Peer identity
* @return #GNUNET_YES on success, #GNUNET_NO on failure.
*/
int
-enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvHandle *handle,
- const struct GNUNET_PeerIdentity *door);
+enter_srv_room_at (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ const struct GNUNET_PeerIdentity *door);
/**
* Packs a <i>message</i> depending on the selected <i>mode</i> into a newly allocated envelope. It will set the
@@ -170,17 +173,17 @@ enter_room_at (struct GNUNET_MESSENGER_SrvRoom *room,
*
* @param[in] room Room
* @param[in] handle Handle
- * @param[in/out] message Message
+ * @param[in,out] message Message
* @param[out] hash Hash of message
* @param[in] mode Packing mode
* @return New envelope or NULL
*/
struct GNUNET_MQ_Envelope*
-pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_MESSENGER_SrvHandle *handle,
- struct GNUNET_MESSENGER_Message *message,
- struct GNUNET_HashCode *hash,
- int mode);
+pack_srv_room_message (const struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_Message *message,
+ struct GNUNET_HashCode *hash,
+ int mode);
/**
* Sends a <i>message</i> from a given <i>handle</i> into a <i>room</i>. The <i>hash</i> parameter will be
@@ -192,77 +195,77 @@ pack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room,
* The function returns #GNUNET_YES on success, #GNUNET_NO if message is null and
* #GNUNET_SYSERR if the message was known already.
*
- * @param[in/out] room Room
- * @param[in/out] handle Handle
- * @param[in/out] message Message
+ * @param[in,out] room Room
+ * @param[in,out] handle Handle
+ * @param[in,out] message Message
* @return #GNUNET_YES on success, #GNUNET_NO or #GNUNET_SYSERR otherwise.
*/
int
-send_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvHandle *handle,
- struct GNUNET_MESSENGER_Message *message);
+send_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle,
+ struct GNUNET_MESSENGER_Message *message);
/**
* Forwards a <i>message</i> with a given <i>hash</i> to a specific <i>tunnel</i> inside of a <i>room</i>.
*
- * @param[in/out] room Room
- * @param[in/out] tunnel Tunnel
- * @param[in/out] message Message
+ * @param[in,out] room Room
+ * @param[in,out] tunnel Tunnel
+ * @param[in,out] message Message
* @param[in] hash Hash of message
*/
void
-forward_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvTunnel *tunnel,
- struct GNUNET_MESSENGER_Message *message,
- const struct GNUNET_HashCode *hash);
+forward_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel,
+ struct GNUNET_MESSENGER_Message *message,
+ const struct GNUNET_HashCode *hash);
/**
* Checks the current state of opening a given <i>room</i> from this peer and re-publishes it
* if necessary to a selected <i>tunnel</i> or to all connected tunnels if necessary or if the
* selected tunnel is NULL.
*
- * @param[in/out] room Room
- * @param[in/out] tunnel Tunnel
+ * @param[in,out] room Room
+ * @param[in,out] tunnel Tunnel
*/
void
-check_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvTunnel *tunnel);
+check_srv_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvTunnel *tunnel);
/**
* Reduces all current forks inside of the message history of a <i>room</i> to one remaining last message
* by merging them down. All merge messages will be sent from a given <i>handle</i>.
*
- * @param[in/out] room Room
- * @param[in/out] handle Handle
+ * @param[in,out] room Room
+ * @param[in,out] handle Handle
*/
void
-merge_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_SrvHandle *handle);
+merge_srv_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_SrvHandle *handle);
/**
* Deletes a message from the <i>room</i> with a given <i>hash</i> in a specific <i>delay</i> if
* the provided member by its session is permitted to do so.
*
- * @param[in/out] room Room
- * @param[in/out] session Member session
+ * @param[in,out] room Room
+ * @param[in,out] session Member session
* @param[in] hash Hash of message
* @param[in] delay Delay of deletion
* @return #GNUNET_YES on success, #GNUNET_NO if permission gets denied, #GNUNET_SYSERR on operation failure
*/
int
-delete_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- struct GNUNET_MESSENGER_MemberSession *session,
- const struct GNUNET_HashCode *hash,
- const struct GNUNET_TIME_Relative delay);
+delete_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ struct GNUNET_MESSENGER_MemberSession *session,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_TIME_Relative delay);
/**
* Returns the CADET handle from a rooms service.
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
* @return CADET handle
*/
struct GNUNET_CADET_Handle*
-get_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room);
+get_srv_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Returns the shared secret you need to access a <i>room</i>.
@@ -271,7 +274,7 @@ get_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room);
* @return Shared secret
*/
const struct GNUNET_HashCode*
-get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room);
+get_srv_room_key (const struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Returns a tunnel inside of a <i>room</i> leading towards a given <i>peer</i> if such a tunnel exists,
@@ -282,14 +285,14 @@ get_room_key (const struct GNUNET_MESSENGER_SrvRoom *room);
* @return Tunnel or NULL
*/
const struct GNUNET_MESSENGER_SrvTunnel*
-get_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_PeerIdentity *peer);
+get_srv_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_PeerIdentity *peer);
/**
* Method called whenever a <i>message</i> is found during a request in a <i>room</i>.
*
- * @param[in/out] cls Closure from #request_room_message
- * @param[in/out] room Room
+ * @param[in,out] cls Closure from #request_room_message
+ * @param[in,out] room Room
* @param[in] message Message or NULL
* @param[in] hash Hash of message
*/
@@ -309,42 +312,42 @@ typedef void (GNUNET_MESSENGER_MessageRequestCallback) (
* It is also possible that the given callback will not be called if the requesting session is not
* permitted!
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
* @param[in] hash Hash of message
* @param[in] callback Callback to process result
* @param[in] cls Closure for the <i>callback</i>
* @return #GNUNET_YES if the request could be processed, otherwise #GNUNET_NO
*/
int
-request_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_HashCode *hash,
- const struct GNUNET_MESSENGER_MemberSession *session,
- GNUNET_MESSENGER_MessageRequestCallback callback,
- void* cls);
+request_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_HashCode *hash,
+ const struct GNUNET_MESSENGER_MemberSession *session,
+ GNUNET_MESSENGER_MessageRequestCallback callback,
+ void* cls);
/**
* Checks for potential collisions with member ids and solves them changing active handles ids if they
* use an already used member id (comparing public key and timestamp).
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
* @param[in] public_key Public key of EGO
* @param[in] member_id Member ID
* @param[in] timestamp Timestamp
*/
void
-solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room,
- const struct GNUNET_IDENTITY_PublicKey *public_key,
- const struct GNUNET_ShortHashCode *member_id,
- struct GNUNET_TIME_Absolute timestamp);
+solve_srv_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room,
+ const struct GNUNET_IDENTITY_PublicKey *public_key,
+ const struct GNUNET_ShortHashCode *member_id,
+ struct GNUNET_TIME_Absolute timestamp);
/**
* Rebuilds the decentralized structure for a <i>room</i> by ensuring all required connections are made
* depending on the amount of peers and this peers index in the list of them.
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
*/
void
-rebuild_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room);
+rebuild_srv_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Loads the local configuration for a given <i>room</i> of a service which contains the last messages hash
@@ -353,7 +356,7 @@ rebuild_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room);
* @param[out] room Room
*/
void
-load_room (struct GNUNET_MESSENGER_SrvRoom *room);
+load_srv_room (struct GNUNET_MESSENGER_SrvRoom *room);
/**
* Saves the configuration for a given <i>room</i> of a service which contains the last messages hash
@@ -362,6 +365,14 @@ load_room (struct GNUNET_MESSENGER_SrvRoom *room);
* @param[in] room Room
*/
void
-save_room (struct GNUNET_MESSENGER_SrvRoom *room);
+save_srv_room (struct GNUNET_MESSENGER_SrvRoom *room);
+
+/**
+ * Removes the configuration for a given <i>room</i> of a service.
+ *
+ * @param[in] room Room
+ */
+void
+remove_srv_room (struct GNUNET_MESSENGER_SrvRoom *room);
#endif //GNUNET_SERVICE_MESSENGER_ROOM_H
diff --git a/src/messenger/gnunet-service-messenger_service.c b/src/messenger/gnunet-service-messenger_service.c
index b53b72af8..8dfc258c1 100644
--- a/src/messenger/gnunet-service-messenger_service.c
+++ b/src/messenger/gnunet-service-messenger_service.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_service.h"
#include "gnunet-service-messenger_message_kind.h"
#include "gnunet-service-messenger.h"
@@ -94,7 +95,7 @@ iterate_destroy_rooms (void *cls,
void *value)
{
struct GNUNET_MESSENGER_SrvRoom *room = value;
- destroy_room (room);
+ destroy_srv_room (room, GNUNET_NO);
return GNUNET_YES;
}
@@ -159,7 +160,7 @@ add_service_handle (struct GNUNET_MESSENGER_Service *service,
{
GNUNET_assert((service) && (mq));
- struct GNUNET_MESSENGER_SrvHandle *handle = create_handle (service, mq);
+ struct GNUNET_MESSENGER_SrvHandle *handle = create_srv_handle (service, mq);
if (handle)
{
@@ -179,7 +180,7 @@ remove_service_handle (struct GNUNET_MESSENGER_Service *service,
return;
if (GNUNET_YES == remove_list_handle (&(service->handles), handle))
- destroy_handle (handle);
+ destroy_srv_handle (handle);
}
int
@@ -210,17 +211,17 @@ open_service_room (struct GNUNET_MESSENGER_Service *service,
struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (service, key);
if (room)
- return open_room (room, handle);
+ return open_srv_room (room, handle);
- room = create_room (handle, key);
+ room = create_srv_room (handle, key);
- if ((GNUNET_YES == open_room (room, handle)) &&
+ if ((GNUNET_YES == open_srv_room (room, handle)) &&
(GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (service->rooms,
key, room,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
return GNUNET_YES;
- destroy_room (room);
+ destroy_srv_room (room, GNUNET_YES);
return GNUNET_NO;
}
@@ -236,15 +237,15 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service,
if (room)
{
- if (GNUNET_YES == enter_room_at (room, handle, door))
+ if (GNUNET_YES == enter_srv_room_at (room, handle, door))
return GNUNET_YES;
else
return GNUNET_NO;
}
- room = create_room (handle, key);
+ room = create_srv_room (handle, key);
- if ((GNUNET_YES == enter_room_at (room, handle, door)) &&
+ if ((GNUNET_YES == enter_srv_room_at (room, handle, door)) &&
(GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (service->rooms,
key, room,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)))
@@ -253,7 +254,7 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service,
}
else
{
- destroy_room (room);
+ destroy_srv_room (room, GNUNET_YES);
return GNUNET_NO;
}
@@ -271,9 +272,9 @@ close_service_room (struct GNUNET_MESSENGER_Service *service,
if (!room)
return GNUNET_NO;
- send_room_message (room, handle, create_message_leave ());
+ send_srv_room_message (room, handle, create_message_leave ());
- const struct GNUNET_ShortHashCode *id = get_handle_member_id (handle, key);
+ const struct GNUNET_ShortHashCode *id = get_srv_handle_member_id (handle, key);
GNUNET_assert(id);
@@ -287,7 +288,7 @@ close_service_room (struct GNUNET_MESSENGER_Service *service,
{
if (GNUNET_OK == GNUNET_CONTAINER_multihashmap_remove (service->rooms, key, room))
{
- destroy_room (room);
+ destroy_srv_room (room, GNUNET_YES);
return GNUNET_YES;
}
else
@@ -313,7 +314,7 @@ handle_service_message (struct GNUNET_MESSENGER_Service *service,
while (element)
{
- notify_handle_message (element->handle, room, session, message, hash);
+ notify_srv_handle_message (element->handle, room, session, message, hash);
element = element->next;
}
}
diff --git a/src/messenger/gnunet-service-messenger_service.h b/src/messenger/gnunet-service-messenger_service.h
index d364a93c0..36df81141 100644
--- a/src/messenger/gnunet-service-messenger_service.h
+++ b/src/messenger/gnunet-service-messenger_service.h
@@ -28,9 +28,7 @@
#include "platform.h"
#include "gnunet_configuration_lib.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_disk_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet-service-messenger_ego_store.h"
@@ -64,7 +62,7 @@ struct GNUNET_MESSENGER_Service
* Creates and allocates a new service using a given <i>config</i> and a GNUnet service handle.
*
* @param[in] config Configuration
- * @param[in/out] service_handle GNUnet service handle
+ * @param[in,out] service_handle GNUnet service handle
* @return New service
*/
struct GNUNET_MESSENGER_Service*
@@ -74,7 +72,7 @@ create_service (const struct GNUNET_CONFIGURATION_Handle *config,
/**
* Destroys a <i>service</i> and frees its memory fully.
*
- * @param[in/out] service Service
+ * @param[in,out] service Service
*/
void
destroy_service (struct GNUNET_MESSENGER_Service *service);
@@ -82,7 +80,7 @@ destroy_service (struct GNUNET_MESSENGER_Service *service);
/**
* Returns the used EGO-store of a given <i>service</i>.
*
- * @param[in/out] service Service
+ * @param[in,out] service Service
* @return EGO-store
*/
struct GNUNET_MESSENGER_EgoStore*
@@ -91,7 +89,7 @@ get_service_ego_store (struct GNUNET_MESSENGER_Service *service);
/**
* Returns the used contact store of a given <i>service</i>.
*
- * @param[in/out] service Service
+ * @param[in,out] service Service
* @return Contact store
*/
struct GNUNET_MESSENGER_ContactStore*
@@ -100,8 +98,8 @@ get_service_contact_store (struct GNUNET_MESSENGER_Service *service);
/**
* Creates and adds a new handle to a <i>service</i> using a given message queue.
*
- * @param[in/out] service Service
- * @param[in/out] mq Message queue
+ * @param[in,out] service Service
+ * @param[in,out] mq Message queue
* @return New handle
*/
struct GNUNET_MESSENGER_SrvHandle*
@@ -111,8 +109,8 @@ add_service_handle (struct GNUNET_MESSENGER_Service *service,
/**
* Removes a <i>handle</i> from a <i>service</i> and destroys it.
*
- * @param[in/out] service Service
- * @param[in/out] handle Handle
+ * @param[in,out] service Service
+ * @param[in,out] handle Handle
*/
void
remove_service_handle (struct GNUNET_MESSENGER_Service *service,
@@ -146,8 +144,8 @@ get_service_room (const struct GNUNET_MESSENGER_Service *service,
* Tries to open a room using a given <i>key</i> for a <i>service</i> by a specific <i>handle</i>. The room will be
* created if necessary. If the function is successful, it returns #GNUNET_YES, otherwise #GNUNET_NO.
*
- * @param[in/out] service Service
- * @param[in/out] handle Handle
+ * @param[in,out] service Service
+ * @param[in,out] handle Handle
* @param[in] key Key of room
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
@@ -163,8 +161,8 @@ open_service_room (struct GNUNET_MESSENGER_Service *service,
* The room will be entered through the peer identitied by the peer identity provided as <i>door</i> parameter and
* a new connection will be made.
*
- * @param[in/out] service Service
- * @param[in/out] handle Handle
+ * @param[in,out] service Service
+ * @param[in,out] handle Handle
* @param[in] door Peer identity
* @param[in] key Key of room
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
@@ -182,8 +180,8 @@ entry_service_room (struct GNUNET_MESSENGER_Service *service,
* If the specific handle is currently the host of the room for this service, a new handle which is a member will
* take its place. Otherwise the room will be destroyed for this service.
*
- * @param[in/out] service Service
- * @param[in/out] handle Handle
+ * @param[in,out] service Service
+ * @param[in,out] handle Handle
* @param[in] key Key of room
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
@@ -196,8 +194,8 @@ close_service_room (struct GNUNET_MESSENGER_Service *service,
* Sends a received or sent <i>message</i> with a given <i>hash</i> to each handle of a <i>service</i> which
* is currently member of a specific <i>room</i> for handling it in the client API.
*
- * @param[in/out] service Service
- * @param[in/out] room Room
+ * @param[in,out] service Service
+ * @param[in,out] room Room
* @param[in] session Member session
* @param[in] message Message
* @param[in] hash Hash of message
diff --git a/src/messenger/gnunet-service-messenger_tunnel.c b/src/messenger/gnunet-service-messenger_tunnel.c
index 45c10c1af..8ad7fff1c 100644
--- a/src/messenger/gnunet-service-messenger_tunnel.c
+++ b/src/messenger/gnunet-service-messenger_tunnel.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2020--2021 GNUnet e.V.
+ 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
@@ -23,6 +23,7 @@
* @brief GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet-service-messenger_tunnel.h"
#include "gnunet-service-messenger_handle.h"
@@ -157,13 +158,13 @@ static void
update_tunnel_last_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
const struct GNUNET_HashCode *hash)
{
- struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(tunnel->room);
+ struct GNUNET_MESSENGER_OperationStore *operation_store = get_srv_room_operation_store(tunnel->room);
const int requested = (GNUNET_MESSENGER_OP_REQUEST == get_store_operation_type(operation_store, hash)?
GNUNET_YES : GNUNET_NO
);
- struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(tunnel->room);
+ struct GNUNET_MESSENGER_MessageStore *message_store = get_srv_room_message_store(tunnel->room);
const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, hash);
@@ -221,7 +222,7 @@ handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
if (GNUNET_YES == forward_message)
{
- forward_room_message (tunnel->room, tunnel, &message, &hash);
+ forward_srv_room_message (tunnel->room, tunnel, &message, &hash);
callback_room_handle_message (tunnel->room, NULL, &message, &hash);
}
@@ -241,8 +242,8 @@ connect_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel)
const struct GNUNET_PeerIdentity *door = GNUNET_PEER_resolve2 (tunnel->peer);
- struct GNUNET_CADET_Handle *cadet = get_room_cadet (tunnel->room);
- const struct GNUNET_HashCode *key = get_room_key (tunnel->room);
+ struct GNUNET_CADET_Handle *cadet = get_srv_room_cadet (tunnel->room);
+ const struct GNUNET_HashCode *key = get_srv_room_key (tunnel->room);
struct GNUNET_MQ_MessageHandler handlers[] = { GNUNET_MQ_hd_var_size(tunnel_message, GNUNET_MESSAGE_TYPE_CADET_CLI,
struct GNUNET_MessageHeader, NULL),
@@ -323,7 +324,7 @@ send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
return GNUNET_NO;
struct GNUNET_HashCode hash;
- struct GNUNET_MQ_Envelope *env = pack_room_message (
+ struct GNUNET_MQ_Envelope *env = pack_srv_room_message (
tunnel->room, (struct GNUNET_MESSENGER_SrvHandle*) handle,
message, &hash, GNUNET_MESSENGER_PACK_MODE_ENVELOPE
);
diff --git a/src/messenger/gnunet-service-messenger_tunnel.h b/src/messenger/gnunet-service-messenger_tunnel.h
index 7bd749281..2ffa2d04f 100644
--- a/src/messenger/gnunet-service-messenger_tunnel.h
+++ b/src/messenger/gnunet-service-messenger_tunnel.h
@@ -28,8 +28,7 @@
#include "platform.h"
#include "gnunet_cadet_service.h"
-#include "gnunet_peer_lib.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet-service-messenger_room.h"
#include "gnunet-service-messenger_message_state.h"
@@ -50,7 +49,7 @@ struct GNUNET_MESSENGER_SrvTunnel
/**
* Creates and allocates a tunnel of a <i>room</i> to a specific peer identity (called <i>door</i>).
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
* @param[in] door Peer identity
* @return New tunnel
*/
@@ -61,7 +60,7 @@ create_tunnel (struct GNUNET_MESSENGER_SrvRoom *room,
/**
* Destroys a <i>tunnel</i> and frees its memory fully.
*
- * @param[in/out] tunnel
+ * @param[in,out] tunnel
*/
void
destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel);
@@ -70,8 +69,8 @@ destroy_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel);
* Binds a CADET <i>channel</i> to a <i>tunnel</i> and replaces its channel
* the tunnel is currently bound to if necessary.
*
- * @param[in/out] tunnel Tunnel
- * @param[in/out] channel CADET channel
+ * @param[in,out] tunnel Tunnel
+ * @param[in,out] channel CADET channel
*/
void
bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
@@ -81,7 +80,7 @@ bind_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
* Tries to connect a <i>tunnel</i> by creating a new CADET channel and binding it.
* The function returns #GNUNET_YES on success, otherwise #GNUNET_NO.
*
- * @param[in/out] tunnel Tunnel
+ * @param[in,out] tunnel Tunnel
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
int
@@ -91,7 +90,7 @@ connect_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel);
* Disconnects and unbinds a channel from a <i>tunnel</i>. The actual disconnection
* will be asynchronous.
*
- * @param[in/out] tunnel Tunnel
+ * @param[in,out] tunnel Tunnel
*/
void
disconnect_tunnel (struct GNUNET_MESSENGER_SrvTunnel *tunnel);
@@ -109,8 +108,8 @@ is_tunnel_connected (const struct GNUNET_MESSENGER_SrvTunnel *tunnel);
* Sends an envelope containing a <i>message</i> with a given <i>hash</i> through
* a <i>tunnel</i>.
*
- * @param[in/out] tunnel Tunnel
- * @param[in/out] env Envelope
+ * @param[in,out] tunnel Tunnel
+ * @param[in,out] env Envelope
* @param[in] hash Hash of message
*/
void
@@ -123,9 +122,9 @@ send_tunnel_envelope (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
* through the <i>tunnel</i>. The used <i>handle</i> will sign the message and
* the <i>hash</i> will be calculated and stored.
*
- * @param[in/out] tunnel Tunnel
- * @param[in/out] handle Handle
- * @param[in/out] message Message
+ * @param[in,out] tunnel Tunnel
+ * @param[in,out] handle Handle
+ * @param[in,out] message Message
* @return #GNUNET_YES on success, GNUNET_NO otherwise
*/
int
@@ -136,7 +135,7 @@ send_tunnel_message (struct GNUNET_MESSENGER_SrvTunnel *tunnel,
/**
* Forwards a given <i>message</i> with a known <i>hash</i> through a <i>tunnel</i>.
*
- * @param[in/out] tunnel Tunnel
+ * @param[in,out] tunnel Tunnel
* @param[in] message Message
* @param[in] hash Hash of message
*/
@@ -184,7 +183,7 @@ get_tunnel_messenger_version (const struct GNUNET_MESSENGER_SrvTunnel *tunnel);
* it is compatible to the running peer of the service. Depending on success it
* returns #GNUNET_OK or #GNUNET_SYSERR on failure.
*
- * @param[in/out] tunnel Tunnel
+ * @param[in,out] tunnel Tunnel
* @param[in] version Version of messenger
*/
int
diff --git a/src/messenger/messenger.conf.in b/src/messenger/messenger.conf.in
index 6b54550ea..ef0544681 100644
--- a/src/messenger/messenger.conf.in
+++ b/src/messenger/messenger.conf.in
@@ -1,12 +1,12 @@
[messenger]
-START_ON_DEMAND = YES
+START_ON_DEMAND = @START_ON_DEMAND@
RUN_PER_USER = YES
-PORT = 2097
+@JAVAPORT@PORT = 2125
HOSTNAME = localhost
BINARY = gnunet-service-messenger
ACCEPT_FROM = 127.0.0.1;
ACCEPT_FROM6 = ::1;
-UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-messenger.sock
+UNIXPATH = $GNUNET_USER_RUNTIME_DIR/gnunet-service-messenger.sock
UNIX_MATCH_UID = NO
UNIX_MATCH_GID = YES
diff --git a/src/messenger/messenger_api.c b/src/messenger/messenger_api.c
index a37b1b10b..610c979c4 100644
--- a/src/messenger/messenger_api.c
+++ b/src/messenger/messenger_api.c
@@ -23,6 +23,7 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
+#include "platform.h"
#include "gnunet_messenger_service.h"
#include "gnunet-service-messenger.h"
@@ -64,6 +65,8 @@ GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind)
return "FILE";
case GNUNET_MESSENGER_KIND_PRIVATE:
return "PRIVATE";
+ case GNUNET_MESSENGER_KIND_DELETE:
+ return "DELETE";
default:
return "UNKNOWN";
}
@@ -103,7 +106,10 @@ check_get_key (void *cls,
const char *buffer = ((const char*) msg) + sizeof(*msg);
struct GNUNET_IDENTITY_PublicKey pubkey;
- if (GNUNET_IDENTITY_read_key_from_buffer(&pubkey, buffer, length) < 0)
+ size_t read;
+ if (GNUNET_SYSERR ==
+ GNUNET_IDENTITY_read_public_key_from_buffer(buffer, length,
+ &pubkey, &read))
return GNUNET_NO;
return GNUNET_OK;
@@ -119,7 +125,10 @@ handle_get_key (void *cls,
const char *buffer = ((const char*) msg) + sizeof(*msg);
struct GNUNET_IDENTITY_PublicKey pubkey;
- if (GNUNET_IDENTITY_read_key_from_buffer(&pubkey, buffer, length) < 0)
+ size_t read;
+ if (GNUNET_SYSERR ==
+ GNUNET_IDENTITY_read_public_key_from_buffer(buffer, length,
+ &pubkey, &read))
return;
char* str = GNUNET_IDENTITY_public_key_to_string (&pubkey);
@@ -253,7 +262,7 @@ handle_recv_message (void *cls,
store, context, sender
);
- handle_room_message (room, contact, &message, hash);
+ contact = handle_room_message (room, contact, &message, hash);
const struct GNUNET_MESSENGER_Message *stored_message = get_room_message(room, hash);
@@ -717,7 +726,7 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
);
if (public_key)
- key_length = GNUNET_IDENTITY_key_get_length(public_key);
+ key_length = GNUNET_IDENTITY_public_key_get_length(public_key);
else
key_length = -1;
}
@@ -750,7 +759,7 @@ GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room,
char *msg_buffer = buffer + key_length;
if (key_length > 0)
- GNUNET_IDENTITY_write_key_to_buffer(get_contact_key(contact), buffer, key_length);
+ GNUNET_IDENTITY_write_public_key_to_buffer(get_contact_key(contact), buffer, key_length);
encode_message (message, msg_length, msg_buffer, GNUNET_NO);
diff --git a/src/messenger/messenger_api_contact.c b/src/messenger/messenger_api_contact.c
index cbca17640..a284c3b08 100644
--- a/src/messenger/messenger_api_contact.c
+++ b/src/messenger/messenger_api_contact.c
@@ -23,6 +23,7 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
+#include "platform.h"
#include "messenger_api_contact.h"
struct GNUNET_MESSENGER_Contact*
diff --git a/src/messenger/messenger_api_contact.h b/src/messenger/messenger_api_contact.h
index b5410f998..e2919bcc3 100644
--- a/src/messenger/messenger_api_contact.h
+++ b/src/messenger/messenger_api_contact.h
@@ -27,7 +27,7 @@
#define GNUNET_MESSENGER_API_CONTACT_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
struct GNUNET_MESSENGER_Contact
@@ -50,7 +50,7 @@ create_contact (const struct GNUNET_IDENTITY_PublicKey *key);
/**
* Destroys a contact and frees its memory fully.
*
- * @param[in/out] contact Contact
+ * @param[in,out] contact Contact
*/
void
destroy_contact (struct GNUNET_MESSENGER_Contact *contact);
@@ -67,7 +67,7 @@ get_contact_name (const struct GNUNET_MESSENGER_Contact *contact);
/**
* Changes the current name of a given <i>contact</i> by copying it from the parameter <i>name</i>.
*
- * @param[in/out] contact Contact
+ * @param[in,out] contact Contact
* @param[in] name Name
*/
void
@@ -86,7 +86,7 @@ get_contact_key (const struct GNUNET_MESSENGER_Contact *contact);
/**
* Increases the reference counter of a given <i>contact</i> which is zero as default.
*
- * @param[in/out] contact Contact
+ * @param[in,out] contact Contact
*/
void
increase_contact_rc (struct GNUNET_MESSENGER_Contact *contact);
@@ -95,7 +95,7 @@ increase_contact_rc (struct GNUNET_MESSENGER_Contact *contact);
* Decreases the reference counter if possible (can not underflow!) of a given <i>contact</i>
* and returns #GNUNET_YES if the counter is equal to zero, otherwise #GNUNET_NO.
*
- * @param[in/out] contact Contact
+ * @param[in,out] contact Contact
* @return #GNUNET_YES or #GNUNET_NO depending on the reference counter
*/
int
@@ -106,7 +106,7 @@ decrease_contact_rc (struct GNUNET_MESSENGER_Contact *contact);
*
* @param[in] key Key of room
* @param[in] id Member id
- * @param[out] hash Member context
+ * @param[out] context Member context
*/
void
get_context_from_member (const struct GNUNET_HashCode *key,
diff --git a/src/messenger/messenger_api_contact_store.c b/src/messenger/messenger_api_contact_store.c
index 1c10a8fbf..d42155e20 100644
--- a/src/messenger/messenger_api_contact_store.c
+++ b/src/messenger/messenger_api_contact_store.c
@@ -23,6 +23,7 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
+#include "platform.h"
#include "messenger_api_contact_store.h"
#include "messenger_api_contact.h"
diff --git a/src/messenger/messenger_api_contact_store.h b/src/messenger/messenger_api_contact_store.h
index bdab2ceeb..c74a67740 100644
--- a/src/messenger/messenger_api_contact_store.h
+++ b/src/messenger/messenger_api_contact_store.h
@@ -27,8 +27,7 @@
#define GNUNET_MESSENGER_API_CONTACT_STORE_H
#include "platform.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
struct GNUNET_MESSENGER_Contact;
@@ -50,7 +49,7 @@ init_contact_store (struct GNUNET_MESSENGER_ContactStore *store);
/**
* Clears a contact store, wipes its content and deallocates its memory.
*
- * @param[in/out] store Contact store
+ * @param[in,out] store Contact store
*/
void
clear_contact_store (struct GNUNET_MESSENGER_ContactStore *store);
@@ -63,7 +62,7 @@ clear_contact_store (struct GNUNET_MESSENGER_ContactStore *store);
* In case there is no contact stored which uses the given key or context,
* NULL gets returned.
*
- * @param[in/out] store Contact store
+ * @param[in,out] store Contact store
* @param[in] context Member context
* @param[in] key_hash Hash of public key
*/
@@ -83,7 +82,7 @@ get_store_contact_raw (struct GNUNET_MESSENGER_ContactStore *store,
* The function returns NULL if an error occurs during allocation
* or validation of the contacts key.
*
- * @param[in/out] store Contact store
+ * @param[in,out] store Contact store
* @param[in] context Member context
* @param[in] pubkey Public key of EGO
*/
@@ -98,8 +97,8 @@ get_store_contact (struct GNUNET_MESSENGER_ContactStore *store,
*
* This function allows changes of keys or changes of member contexts!
*
- * @param[in/out] store Contact store
- * @param[in/out] contact Contact
+ * @param[in,out] store Contact store
+ * @param[in,out] contact Contact
* @param[in] context Member context
* @param[in] next_context Member context
* @param[in] pubkey Public key of EGO
@@ -115,8 +114,8 @@ update_store_contact (struct GNUNET_MESSENGER_ContactStore *store,
* Removes a <i>contact</i> from the <i>store</i> which uses
* a given member <i>context</i>.
*
- * @param[in/out] store Contact store
- * @param[in/out] contact Contact
+ * @param[in,out] store Contact store
+ * @param[in,out] contact Contact
* @param[in] context Member context
*/
void
diff --git a/src/messenger/messenger_api_handle.c b/src/messenger/messenger_api_handle.c
index 242389040..ec8d3dc7a 100644
--- a/src/messenger/messenger_api_handle.c
+++ b/src/messenger/messenger_api_handle.c
@@ -23,6 +23,7 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
+#include "platform.h"
#include "messenger_api_handle.h"
#include "messenger_api_util.h"
diff --git a/src/messenger/messenger_api_handle.h b/src/messenger/messenger_api_handle.h
index 6a43f13a6..d246855ff 100644
--- a/src/messenger/messenger_api_handle.h
+++ b/src/messenger/messenger_api_handle.h
@@ -28,10 +28,8 @@
#include "platform.h"
#include "gnunet_cadet_service.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
-#include "gnunet_peer_lib.h"
#include "gnunet_messenger_service.h"
@@ -67,7 +65,7 @@ struct GNUNET_MESSENGER_Handle
*
* @param[in] cfg Configuration
* @param[in] msg_callback Message callback
- * @param[in/out] msg_cls Closure
+ * @param[in,out] msg_cls Closure
* @return New handle
*/
struct GNUNET_MESSENGER_Handle*
@@ -80,7 +78,7 @@ create_handle (const struct GNUNET_CONFIGURATION_Handle *cfg,
/**
* Destroys a <i>handle</i> and frees its memory fully from the client API.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
*/
void
destroy_handle (struct GNUNET_MESSENGER_Handle *handle);
@@ -88,7 +86,7 @@ destroy_handle (struct GNUNET_MESSENGER_Handle *handle);
/**
* Sets the name of a <i>handle</i> to a specific <i>name</i>.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] name New name
*/
void
@@ -107,7 +105,7 @@ get_handle_name (const struct GNUNET_MESSENGER_Handle *handle);
/**
* Sets the public key of a given <i>handle</i> to a specific public key.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] pubkey Public key
*/
void
@@ -126,7 +124,7 @@ get_handle_key (const struct GNUNET_MESSENGER_Handle *handle);
/**
* Returns the used contact store of a given <i>handle</i>.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @return Contact store
*/
struct GNUNET_MESSENGER_ContactStore*
@@ -136,7 +134,7 @@ get_handle_contact_store (struct GNUNET_MESSENGER_Handle *handle);
* Returns the contact of a given <i>handle</i> in a room identified by a
* given <i>key</i>.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of room
* @return Contact
*/
@@ -147,7 +145,7 @@ get_handle_contact (struct GNUNET_MESSENGER_Handle *handle,
/**
* Marks a room known to a <i>handle</i> identified by a given <i>key</i> as open.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of room
*/
void
@@ -158,7 +156,7 @@ open_handle_room (struct GNUNET_MESSENGER_Handle *handle,
* Adds a tunnel for a room known to a <i>handle</i> identified by a given <i>key</i> to a
* list of opened connections.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] door Peer identity
* @param[in] key Key of room
*/
@@ -170,7 +168,7 @@ entry_handle_room_at (struct GNUNET_MESSENGER_Handle *handle,
/**
* Destroys and so implicitly closes a room known to a <i>handle</i> identified by a given <i>key</i>.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of room
*/
void
diff --git a/src/messenger/messenger_api_list_tunnels.c b/src/messenger/messenger_api_list_tunnels.c
index 7e77d8f2f..a4126c286 100644
--- a/src/messenger/messenger_api_list_tunnels.c
+++ b/src/messenger/messenger_api_list_tunnels.c
@@ -23,6 +23,7 @@
* @brief messenger api: client and service implementation of GNUnet MESSENGER service
*/
+#include "platform.h"
#include "messenger_api_list_tunnels.h"
void
diff --git a/src/messenger/messenger_api_list_tunnels.h b/src/messenger/messenger_api_list_tunnels.h
index 0e086ee5e..d2ceeafc2 100644
--- a/src/messenger/messenger_api_list_tunnels.h
+++ b/src/messenger/messenger_api_list_tunnels.h
@@ -27,8 +27,7 @@
#define GNUNET_MESSENGER_API_LIST_TUNNELS_H
#include "platform.h"
-#include "gnunet_peer_lib.h"
-#include "gnunet_container_lib.h"
+#include "gnunet_util_lib.h"
struct GNUNET_MESSENGER_ListTunnel
{
@@ -55,7 +54,7 @@ init_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels);
/**
* Clears the list of tunnels peer identities.
*
- * @param[in/out] tunnels List of peer identities
+ * @param[in,out] tunnels List of peer identities
*/
void
clear_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels);
@@ -63,7 +62,7 @@ clear_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels);
/**
* Adds a specific <i>peer</i> from a tunnel to the end of the list.
*
- * @param[in/out] tunnels List of peer identities
+ * @param[in,out] tunnels List of peer identities
* @param[in] peer Peer identity of tunnel
*/
void
@@ -80,7 +79,7 @@ add_to_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
* the found element in the list. If no matching element is found, <i>index</i> will
* contain the total amount of elements in the list.
*
- * @param[in/out] tunnels List of peer identities
+ * @param[in,out] tunnels List of peer identities
* @param[in] peer Peer identity of tunnel
* @param[out] index Index of found element (optional)
* @return Element in the list with matching peer identity
@@ -94,7 +93,7 @@ find_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
* Tests linearly if the list of tunnels peer identities contains a specific
* <i>peer</i> identity and returns #GNUNET_YES on success, otherwise #GNUNET_NO.
*
- * @param[in/out] tunnels List of peer identities
+ * @param[in,out] tunnels List of peer identities
* @param[in] peer Peer identity of tunnel
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
@@ -106,8 +105,8 @@ contains_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
* Removes a specific <i>element</i> from the list of tunnels peer identities and returns
* the next element in the list.
*
- * @param[in/out] tunnels List of peer identities
- * @param[in/out] element Element of the list
+ * @param[in,out] tunnels List of peer identities
+ * @param[in,out] element Element of the list
* @return Next element in the list
*/
struct GNUNET_MESSENGER_ListTunnel*
@@ -117,7 +116,7 @@ remove_from_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
/**
* Loads the list of tunnels peer identities from a file under a given <i>path</i>.
*
- * @param[out] messages List of hashes
+ * @param[out] tunnels List of hashes
* @param[in] path Path of file
*/
void
@@ -127,7 +126,7 @@ load_list_tunnels (struct GNUNET_MESSENGER_ListTunnels *tunnels,
/**
* Saves the list of tunnels peer identities to a file under a given <i>path</i>.
*
- * @param[in] messages List of hashes
+ * @param[in] tunnels List of hashes
* @param[in] path Path of file
*/
void
diff --git a/src/messenger/messenger_api_message.c b/src/messenger/messenger_api_message.c
index 496c98dbf..ac63f16ca 100644
--- a/src/messenger/messenger_api_message.c
+++ b/src/messenger/messenger_api_message.c
@@ -23,6 +23,7 @@
* @brief messenger api: client and service implementation of GNUnet MESSENGER service
*/
+#include "platform.h"
#include "messenger_api_message.h"
struct GNUNET_MESSENGER_MessageSignature
@@ -219,6 +220,10 @@ get_message_body_kind_size (enum GNUNET_MESSENGER_MessageKind kind)
case GNUNET_MESSENGER_KIND_PRIVATE:
length += member_size(struct GNUNET_MESSENGER_Message, body.privacy.key);
break;
+ case GNUNET_MESSENGER_KIND_DELETE:
+ length += member_size(struct GNUNET_MESSENGER_Message, body.deletion.hash);
+ length += member_size(struct GNUNET_MESSENGER_Message, body.deletion.delay);
+ break;
default:
break;
}
@@ -255,16 +260,16 @@ get_message_body_size (enum GNUNET_MESSENGER_MessageKind kind,
switch (kind)
{
case GNUNET_MESSENGER_KIND_INFO:
- length += GNUNET_IDENTITY_key_get_length(&(body->info.host_key));
+ length += GNUNET_IDENTITY_public_key_get_length(&(body->info.host_key));
break;
case GNUNET_MESSENGER_KIND_JOIN:
- length += GNUNET_IDENTITY_key_get_length(&(body->join.key));
+ length += GNUNET_IDENTITY_public_key_get_length(&(body->join.key));
break;
case GNUNET_MESSENGER_KIND_NAME:
length += (body->name.name ? strlen (body->name.name) : 0);
break;
case GNUNET_MESSENGER_KIND_KEY:
- length += GNUNET_IDENTITY_key_get_length(&(body->key.key));
+ length += GNUNET_IDENTITY_public_key_get_length(&(body->key.key));
break;
case GNUNET_MESSENGER_KIND_TEXT:
length += strlen (body->text.text);
@@ -368,7 +373,7 @@ calc_padded_length (uint16_t length)
} while (0)
#define encode_step_key(dst, offset, src, length) do { \
- ssize_t result = GNUNET_IDENTITY_write_key_to_buffer( \
+ ssize_t result = GNUNET_IDENTITY_write_public_key_to_buffer( \
src, dst + offset, length - offset \
); \
if (result < 0) \
@@ -445,6 +450,10 @@ encode_message_body (enum GNUNET_MESSENGER_MessageKind kind,
encode_step(buffer, offset, &(body->privacy.key));
encode_step_ext(buffer, offset, body->privacy.data, min(length - offset, body->privacy.length));
break;
+ case GNUNET_MESSENGER_KIND_DELETE:
+ encode_step(buffer, offset, &(body->deletion.hash));
+ encode_step(buffer, offset, &(body->deletion.delay));
+ break;
default:
break;
}
@@ -531,13 +540,15 @@ encode_short_message (const struct GNUNET_MESSENGER_ShortMessage *message,
} while (0)
#define decode_step_key(src, offset, dst, length) do { \
- ssize_t result = GNUNET_IDENTITY_read_key_from_buffer( \
- dst, src + offset, length - offset \
+ enum GNUNET_GenericReturnValue result; \
+ size_t read; \
+ result = GNUNET_IDENTITY_read_public_key_from_buffer( \
+ src + offset, length - offset, dst, &read \
); \
- if (result < 0) \
+ if (GNUNET_SYSERR == result) \
GNUNET_break(0); \
else \
- offset += result; \
+ offset += read; \
} while (0)
static uint16_t
@@ -616,6 +627,10 @@ decode_message_body (enum GNUNET_MESSENGER_MessageKind *kind,
body->privacy.length = (length - offset);
decode_step_malloc(buffer, offset, body->privacy.data, length - offset, 0);
break;
+ case GNUNET_MESSENGER_KIND_DELETE:
+ decode_step(buffer, offset, &(body->deletion.hash));
+ decode_step(buffer, offset, &(body->deletion.delay));
+ break;
default:
*kind = GNUNET_MESSENGER_KIND_UNKNOWN;
break;
diff --git a/src/messenger/messenger_api_message.h b/src/messenger/messenger_api_message.h
index 46c5cb024..688c72994 100644
--- a/src/messenger/messenger_api_message.h
+++ b/src/messenger/messenger_api_message.h
@@ -27,9 +27,8 @@
#define GNUNET_MESSENGER_API_MESSAGE_H
#include "platform.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
-#include "gnunet_mq_lib.h"
#include "gnunet_signatures.h"
#include "gnunet_messenger_service.h"
@@ -64,7 +63,7 @@ copy_message (const struct GNUNET_MESSENGER_Message *message);
/**
* Frees the messages body memory.
*
- * @param[in/out] message Message
+ * @param[in,out] message Message
*/
void
cleanup_message (struct GNUNET_MESSENGER_Message *message);
@@ -72,7 +71,7 @@ cleanup_message (struct GNUNET_MESSENGER_Message *message);
/**
* Destroys a message and frees its memory fully.
*
- * @param[in/out] message Message
+ * @param[in,out] message Message
*/
void
destroy_message (struct GNUNET_MESSENGER_Message *message);
@@ -163,7 +162,7 @@ hash_message (const struct GNUNET_MESSENGER_Message *message,
* Signs the <i>hash</i> of a <i>message</i> with a given <i>ego</i> and writes the signature
* into the <i>buffer</i> as well.
*
- * @param[in/out] message Message
+ * @param[in,out] message Message
* @param[in] length Length of buffer
* @param[out] buffer Buffer
* @param[in] hash Hash of message
@@ -196,7 +195,7 @@ verify_message (const struct GNUNET_MESSENGER_Message *message,
* and kind with the now private encrypted <i>message</i>. The function returns
* #GNUNET_YES if the operation succeeded, otherwise #GNUNET_NO.
*
- * @param[in/out] message Message
+ * @param[in,out] message Message
* @param[in] key Public key of EGO
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
@@ -209,7 +208,7 @@ encrypt_message (struct GNUNET_MESSENGER_Message *message,
* and kind with the inner encrypted message. The function returns #GNUNET_YES if the
* operation succeeded, otherwise #GNUNET_NO.
*
- * @param[in/out] message Message
+ * @param[in,out] message Message
* @param[in] key Private key of EGO
* @return #GNUNET_YES on success, otherwise #GNUNET_NO
*/
diff --git a/src/messenger/messenger_api_room.c b/src/messenger/messenger_api_room.c
index 6e2d33f48..c3e8bc957 100644
--- a/src/messenger/messenger_api_room.c
+++ b/src/messenger/messenger_api_room.c
@@ -23,6 +23,7 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
+#include "platform.h"
#include "messenger_api_room.h"
#include "messenger_api_handle.h"
diff --git a/src/messenger/messenger_api_room.h b/src/messenger/messenger_api_room.h
index 320312f0c..d5ffc5c4b 100644
--- a/src/messenger/messenger_api_room.h
+++ b/src/messenger/messenger_api_room.h
@@ -27,8 +27,7 @@
#define GNUNET_MESSENGER_API_ROOM_H
#include "platform.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_messenger_service.h"
@@ -59,7 +58,7 @@ struct GNUNET_MESSENGER_Room
/**
* Creates and allocates a new room for a <i>handle</i> with a given <i>key</i> for the client API.
*
- * @param[in/out] handle Handle
+ * @param[in,out] handle Handle
* @param[in] key Key of room
* @return New room
*/
@@ -70,7 +69,7 @@ create_room (struct GNUNET_MESSENGER_Handle *handle,
/**
* Destroys a room and frees its memory fully from the client API.
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
*/
void
destroy_room (struct GNUNET_MESSENGER_Room *room);
@@ -106,8 +105,8 @@ get_room_sender (const struct GNUNET_MESSENGER_Room *room,
* The contact of the message's sender could be updated or even created. It may not be freed or destroyed though!
* (The contact may still be in use for old messages...)
*
- * @param[in/out] room Room
- * @param[in/out] sender Contact of sender
+ * @param[in,out] room Room
+ * @param[in,out] sender Contact of sender
* @param[in] message Message
* @param[in] hash Hash of message
* @return Contact of sender
@@ -122,9 +121,9 @@ handle_room_message (struct GNUNET_MESSENGER_Room *room,
* Iterates through all members of a given <i>room</i> to forward each of them to a selected
* <i>callback</i> with a custom closure.
*
- * @param[in/out] room Room
+ * @param[in,out] room Room
* @param[in] callback Function called for each member
- * @param[in/out] cls Closure
+ * @param[in,out] cls Closure
* @return Amount of members iterated
*/
int
diff --git a/src/messenger/messenger_api_util.c b/src/messenger/messenger_api_util.c
index 52b4e934a..f56e2e201 100644
--- a/src/messenger/messenger_api_util.c
+++ b/src/messenger/messenger_api_util.c
@@ -23,6 +23,7 @@
* @brief messenger api: client implementation of GNUnet MESSENGER service
*/
+#include "platform.h"
#include "messenger_api_util.h"
static void
diff --git a/src/messenger/messenger_api_util.h b/src/messenger/messenger_api_util.h
index af64790b6..3d68505a8 100644
--- a/src/messenger/messenger_api_util.h
+++ b/src/messenger/messenger_api_util.h
@@ -28,16 +28,14 @@
#include "platform.h"
#include "gnunet_cadet_service.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_crypto_lib.h"
-#include "gnunet_disk_lib.h"
+#include "gnunet_util_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_messenger_service.h"
/**
* Starts an urgent task to close a CADET channel asynchronously.
*
- * @param[in/out] channel Channel
+ * @param[in,out] channel Channel
*/
void
delayed_disconnect_channel (struct GNUNET_CADET_Channel *channel);
diff --git a/src/messenger/plugin_gnsrecord_messenger.c b/src/messenger/plugin_gnsrecord_messenger.c
index 2219f0bde..e09a0330d 100644
--- a/src/messenger/plugin_gnsrecord_messenger.c
+++ b/src/messenger/plugin_gnsrecord_messenger.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2021 GNUnet e.V.
+ Copyright (C) 2021--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
@@ -63,12 +63,30 @@ messenger_value_to_string (void *cls,
char *key = GNUNET_STRINGS_data_to_string_alloc (&(record->key), sizeof(struct GNUNET_HashCode));
char *ret;
- GNUNET_asprintf (&ret, "%s-%s", door, key);
+ 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;
}
@@ -141,7 +159,43 @@ messenger_string_to_value (void *cls,
*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;
}
@@ -158,6 +212,7 @@ static struct
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 }
};
diff --git a/src/messenger/test_messenger.c b/src/messenger/test_messenger.c
index 5784dfd82..8758ce562 100644
--- a/src/messenger/test_messenger.c
+++ b/src/messenger/test_messenger.c
@@ -22,8 +22,8 @@
* @author Tobias Frisch
* @brief Test for the messenger service using cadet API.
*/
-#include <stdio.h>
#include "platform.h"
+#include <stdio.h>
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "gnunet_messenger_service.h"
diff --git a/src/messenger/test_messenger_adapt.c b/src/messenger/test_messenger_adapt.c
index 3230af6b7..b19634152 100644
--- a/src/messenger/test_messenger_adapt.c
+++ b/src/messenger/test_messenger_adapt.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_anonymous.c b/src/messenger/test_messenger_anonymous.c
index 8cb339f0e..13f2b6f0e 100644
--- a/src/messenger/test_messenger_anonymous.c
+++ b/src/messenger/test_messenger_anonymous.c
@@ -22,8 +22,8 @@
* @author Tobias Frisch
* @brief Test for the messenger service using cadet API.
*/
-#include <stdio.h>
#include "platform.h"
+#include <stdio.h>
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
#include "gnunet_messenger_service.h"
diff --git a/src/messenger/test_messenger_async_client.c b/src/messenger/test_messenger_async_client.c
index 8404195dc..580fc1ecb 100644
--- a/src/messenger/test_messenger_async_client.c
+++ b/src/messenger/test_messenger_async_client.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_async_p2p.c b/src/messenger/test_messenger_async_p2p.c
index 25746f7ff..762be9d49 100644
--- a/src/messenger/test_messenger_async_p2p.c
+++ b/src/messenger/test_messenger_async_p2p.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_growth.c b/src/messenger/test_messenger_growth.c
index c3f243cbf..4a73e559d 100644
--- a/src/messenger/test_messenger_growth.c
+++ b/src/messenger/test_messenger_growth.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_ring.c b/src/messenger/test_messenger_ring.c
index 777d79eb8..c6b17861e 100644
--- a/src/messenger/test_messenger_ring.c
+++ b/src/messenger/test_messenger_ring.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_server.c b/src/messenger/test_messenger_server.c
index 61e96e879..fdd9a3684 100644
--- a/src/messenger/test_messenger_server.c
+++ b/src/messenger/test_messenger_server.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_sync_client.c b/src/messenger/test_messenger_sync_client.c
index 02d90a61d..74c9548bc 100644
--- a/src/messenger/test_messenger_sync_client.c
+++ b/src/messenger/test_messenger_sync_client.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_sync_p2p.c b/src/messenger/test_messenger_sync_p2p.c
index 0a900a39e..299d5ff68 100644
--- a/src/messenger/test_messenger_sync_p2p.c
+++ b/src/messenger/test_messenger_sync_p2p.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_worst_client.c b/src/messenger/test_messenger_worst_client.c
index a3d5aafec..ab535b876 100644
--- a/src/messenger/test_messenger_worst_client.c
+++ b/src/messenger/test_messenger_worst_client.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/test_messenger_worst_p2p.c b/src/messenger/test_messenger_worst_p2p.c
index 89e54cfbd..0af9489a4 100644
--- a/src/messenger/test_messenger_worst_p2p.c
+++ b/src/messenger/test_messenger_worst_p2p.c
@@ -23,6 +23,7 @@
* @brief Test for the messenger service using cadet API.
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
/**
diff --git a/src/messenger/testing_messenger_barrier.c b/src/messenger/testing_messenger_barrier.c
index a95ea9ef1..60d1fc0fe 100644
--- a/src/messenger/testing_messenger_barrier.c
+++ b/src/messenger/testing_messenger_barrier.c
@@ -23,6 +23,7 @@
* @brief Pseudo-barriers for simple event handling
*/
+#include "platform.h"
#include "testing_messenger_barrier.h"
struct GNUNET_BarrierHandle
diff --git a/src/messenger/testing_messenger_barrier.h b/src/messenger/testing_messenger_barrier.h
index 3062a393a..5ea0fe137 100644
--- a/src/messenger/testing_messenger_barrier.h
+++ b/src/messenger/testing_messenger_barrier.h
@@ -62,7 +62,7 @@ typedef void
* GNUNET_wait_barrier().
* @param cb the callback to call when the pseudo-barrier is reached or upon
* error. Can be NULL.
- * @param cls closure for the above callback
+ * @param cb_cls closure for the above callback
* @return pseudo-barrier handle; NULL upon error
*/
struct GNUNET_BarrierHandle*
@@ -108,7 +108,7 @@ typedef void
*
* @param barrier the pseudo-barrier handle
* @param cb the pseudo-barrier wait callback
- * @param cls the closure for the above 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.
*/
diff --git a/src/messenger/testing_messenger_setup.c b/src/messenger/testing_messenger_setup.c
index 3cde8c9bb..65cf12e73 100644
--- a/src/messenger/testing_messenger_setup.c
+++ b/src/messenger/testing_messenger_setup.c
@@ -23,10 +23,10 @@
* @brief A simple test-case setup for the messenger service
*/
+#include "platform.h"
#include "testing_messenger_setup.h"
#include <stdio.h>
-#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_logger_service.h"
#include "gnunet_testbed_service.h"