GNUnet debian-0.24.3-23-g589b01d60
messenger_api.h File Reference
Include dependency graph for messenger_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void enqueue_message_to_room (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *epoch, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript, enum GNUNET_GenericReturnValue sync)
 Enqueus a message and its optional transcript for sending it to a given room and epoch. More...
 
void request_message_from_room (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Requests a specific message from a given room which can be identified by its hash. More...
 
void require_message_from_room (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Requires a specific message in a given room which can be identified by its hash. More...
 

Function Documentation

◆ enqueue_message_to_room()

void enqueue_message_to_room ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode epoch,
struct GNUNET_MESSENGER_Message message,
struct GNUNET_MESSENGER_Message transcript,
enum GNUNET_GenericReturnValue  sync 
)

Enqueus a message and its optional transcript for sending it to a given room and epoch.

Parameters
[in,out]roomRoom
[in]epochHash of epoch
[in]messageMessage
[in]transcriptTranscript of message or NULL
[in]syncGNUNET_YES to enforce syncing, otherwise GNUNET_NO

Definition at line 1065 of file messenger_api.c.

1070{
1071 const struct GNUNET_CRYPTO_PrivateKey *key;
1072
1073 GNUNET_assert ((room) && (message));
1074
1075 key = get_handle_key (room->handle);
1076
1077 if (! epoch)
1078 epoch = &(room->last_epoch);
1079
1080 enqueue_to_messages (&(room->queue),
1081 key,
1082 epoch,
1083 message,
1084 transcript);
1085
1086 if (GNUNET_YES != is_room_available (room))
1087 return;
1088
1089 if ((GNUNET_YES == sync) ||
1090 (GNUNET_YES == is_message_session_bound (message)))
1091 send_sync_room (room->handle, room);
1092 else if (GNUNET_YES != room->wait_for_sync)
1094}
struct GNUNET_HashCode key
The key used in the DHT.
@ GNUNET_YES
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static void dequeue_messages_from_room(struct GNUNET_MESSENGER_Room *room)
static void send_sync_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
const struct GNUNET_CRYPTO_PrivateKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the private key of a given handle.
enum GNUNET_GenericReturnValue is_message_session_bound(const struct GNUNET_MESSENGER_Message *message)
Returns if the message should be bound to a member session.
void enqueue_to_messages(struct GNUNET_MESSENGER_QueueMessages *messages, const struct GNUNET_CRYPTO_PrivateKey *sender, const struct GNUNET_HashCode *epoch, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript)
Adds a specific message to the end or the beginning of the queue.
enum GNUNET_GenericReturnValue is_room_available(const struct GNUNET_MESSENGER_Room *room)
Checks whether a room is available to send messages.
A private key for an identity as per LSD0001.
struct GNUNET_MESSENGER_Handle * handle
enum GNUNET_GenericReturnValue wait_for_sync
struct GNUNET_HashCode last_epoch
struct GNUNET_MESSENGER_QueueMessages queue

References dequeue_messages_from_room(), enqueue_to_messages(), get_handle_key(), GNUNET_assert, GNUNET_YES, GNUNET_MESSENGER_Room::handle, is_message_session_bound(), is_room_available(), key, GNUNET_MESSENGER_Room::last_epoch, GNUNET_MESSENGER_Room::queue, send_sync_room(), and GNUNET_MESSENGER_Room::wait_for_sync.

Referenced by delete_room_message(), GNUNET_MESSENGER_close_room(), handle_member_id(), handle_miss_message(), iterate_send_key_to_room(), iterate_send_name_to_room(), keep_subscription_alive(), send_epoch_message(), and send_message_to_room_with_key().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ request_message_from_room()

void request_message_from_room ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Requests a specific message from a given room which can be identified by its hash.

Parameters
[in]roomRoom
[in]hashHash of message

Definition at line 1648 of file messenger_api.c.

1650{
1652 struct GNUNET_MQ_Envelope *env;
1653
1654 GNUNET_assert ((room) && (hash));
1655
1656 if (GNUNET_is_zero (hash))
1657 return;
1658
1659 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request message (%s)!\n",
1660 GNUNET_h2s (hash));
1661
1663 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
1664 GNUNET_memcpy (&(msg->hash), hash, sizeof(*hash));
1665 GNUNET_MQ_send (room->handle->mq, env);
1666}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:305
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:76
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_Room *room)
Return a the hash representation of a given room.
Message to request something from a room.
struct GNUNET_MQ_Handle * mq

References env, get_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_is_zero, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Handle::mq, and msg.

Referenced by GNUNET_MESSENGER_get_message(), and iterate_room_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ require_message_from_room()

void require_message_from_room ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Requires a specific message in a given room which can be identified by its hash.

The required message will be requested asynchronously.

Parameters
[in]roomRoom
[in]hashHash of message

Definition at line 1122 of file messenger_api_room.c.

1124{
1125 GNUNET_assert ((room) && (hash));
1126
1127 if (GNUNET_is_zero (hash))
1128 return;
1129
1130 if (get_room_message (room, hash))
1131 return;
1132
1134 room->requests,
1135 hash, NULL,
1137 return;
1138
1139 if (room->request_task)
1140 return;
1141
1145 room);
1146}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
@ GNUNET_SCHEDULER_PRIORITY_BACKGROUND
Run as background job (higher than idle, lower than default).
@ GNUNET_OK
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_with_priority(enum GNUNET_SCHEDULER_Priority prio, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified priority.
Definition: scheduler.c:1231
const struct GNUNET_MESSENGER_Message * get_room_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a message locally stored from a map for a given hash in a room.
static void handle_room_request_task(void *cls)
struct GNUNET_SCHEDULER_Task * request_task
struct GNUNET_CONTAINER_MultiHashMap * requests

References get_room_message(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_is_zero, GNUNET_OK, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, handle_room_request_task(), GNUNET_MESSENGER_Room::request_task, and GNUNET_MESSENGER_Room::requests.

Referenced by create_epoch(), GNUNET_MESSENGER_get_message(), handle_join_message(), handle_leave_message(), and handle_merge_message().

Here is the call graph for this function:
Here is the caller graph for this function: