GNUnet 0.26.2-14-ga82e62fdc
 
Loading...
Searching...
No Matches
messenger_api_room.c File Reference
#include "messenger_api_room.h"
#include "gnunet_common.h"
#include "gnunet_messenger_service.h"
#include "gnunet_namestore_service.h"
#include "gnunet_scheduler_lib.h"
#include "gnunet_time_lib.h"
#include "gnunet_util_lib.h"
#include "messenger_api.h"
#include "messenger_api_contact.h"
#include "messenger_api_contact_store.h"
#include "messenger_api_epoch.h"
#include "messenger_api_epoch_announcement.h"
#include "messenger_api_epoch_group.h"
#include "messenger_api_handle.h"
#include "messenger_api_message.h"
#include "messenger_api_message_control.h"
#include "messenger_api_message_kind.h"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for messenger_api_room.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_RoomCancelAction
 
struct  GNUNET_MESSENGER_MemberCall
 
struct  GNUNET_MESSENGER_MemberFind
 
struct  GNUNET_MESSENGER_RoomLinkDeletionInfo
 

Functions

struct GNUNET_MESSENGER_Roomcreate_room (struct GNUNET_MESSENGER_Handle *handle, const union GNUNET_MESSENGER_RoomKey *key)
 Creates and allocates a new room for a handle with a given key for the client API.
 
static enum GNUNET_GenericReturnValue iterate_destroy_action (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static enum GNUNET_GenericReturnValue iterate_destroy_message (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static enum GNUNET_GenericReturnValue iterate_destroy_link (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static enum GNUNET_GenericReturnValue iterate_destroy_subscription (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
static enum GNUNET_GenericReturnValue iterate_destroy_epoch (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void clear_room_encryption_keys (struct GNUNET_MESSENGER_RoomEncryptionKey *head, struct GNUNET_MESSENGER_RoomEncryptionKey *tail)
 
void destroy_room (struct GNUNET_MESSENGER_Room *room)
 Destroys a room and frees its memory fully from the client API.
 
const struct GNUNET_HashCodeget_room_key (const struct GNUNET_MESSENGER_Room *room)
 Return a the hash representation of a given room.
 
enum GNUNET_GenericReturnValue is_room_public (const struct GNUNET_MESSENGER_Room *room)
 Returns whether a given room is public or using epoch keys to encrypt private traffic and sync those keys automatically.
 
const struct GNUNET_CRYPTO_HpkePublicKeyget_room_encryption_key (const struct GNUNET_MESSENGER_Room *room)
 Returns the latest encryption key stored in memory by the current user for a given room.
 
static void cont_write_encryption_key_record (void *cls, enum GNUNET_ErrorCode ec)
 
enum GNUNET_GenericReturnValue add_room_encryption_key (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_CRYPTO_HpkePrivateKey *key)
 Adds an encryption key by the current user to memory of a given room and will be placed to the second latest slot in the list if it's not empty.
 
static enum GNUNET_GenericReturnValue is_message_entry_recent (const struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static struct GNUNET_MESSENGER_Epochget_room_availble_epoch_entry (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_RoomMessageEntry *entry, const struct GNUNET_MESSENGER_Contact *contact)
 
static void handle_room_delayed_deletion (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_room_delayed_announcement (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_room_delayed_appeal (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_room_delayed_action (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 
static void handle_room_action_task (void *cls)
 
void delay_room_action (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 Enqueues delayed handling of a message in a room under a given hash once a specific delay has timed out.
 
void cancel_room_action (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Cancels the delayed handling of a message in a room under a given hash in case it has been queued using the function delay_room_action() before and the action has not been fully processed yet.
 
static enum GNUNET_GenericReturnValue iterate_cancel_action_by (void *cls, const struct GNUNET_HashCode *hash, void *value)
 
static enum GNUNET_GenericReturnValue iterate_cancel_action (void *cls, const struct GNUNET_HashCode *hash, void *value)
 
void cancel_room_actions_by (struct GNUNET_MESSENGER_Room *room, enum GNUNET_MESSENGER_MessageKind kind, const struct GNUNET_HashCode *epoch_hash, const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_MESSENGER_Contact *contact)
 Searches queued actions to handle messages of a specific message kind in a room with any delay and cancels them using the function cancel_room_action().
 
enum GNUNET_GenericReturnValue is_room_available (const struct GNUNET_MESSENGER_Room *room)
 Checks whether a room is available to send messages.
 
struct GNUNET_MESSENGER_Handleget_room_handle (struct GNUNET_MESSENGER_Room *room)
 Returns the messenger handle of the room.
 
const struct GNUNET_ShortHashCodeget_room_sender_id (const struct GNUNET_MESSENGER_Room *room)
 Returns the member id of the room's sender.
 
void set_room_sender_id (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ShortHashCode *id)
 Sets the member id of the room's sender to a specific id or NULL.
 
struct GNUNET_MESSENGER_Epochget_room_epoch (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue recent)
 Returns the epoch in a given room from a specific epoch hash that represents the exact message the epoch starts.
 
void generate_room_epoch_announcement (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Epoch *epoch, struct GNUNET_MESSENGER_EpochAnnouncement **announcement)
 Generate a new announcement for a given epoch in a room under a random and unique announcement identifier.
 
struct GNUNET_MESSENGER_Epochget_room_message_epoch (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns the epoch of a local message with a given hash in a room.
 
const union GNUNET_MESSENGER_EpochIdentifierget_room_message_epoch_identifier (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns the epoch identifier a local message with a given hash is targeting in a room with its specific operation.
 
const struct GNUNET_MESSENGER_Messageget_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.
 
enum GNUNET_GenericReturnValue is_room_message_sent (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns whether a message is sent by the handle of the given room itself or another client that is using the same unique key to sign its sent messages.
 
struct GNUNET_MESSENGER_Contactget_room_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns a messages sender locally stored from a map for a given hash in a room.
 
struct GNUNET_MESSENGER_Contactget_room_recipient (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns a messages recipient locally stored from a map for a given hash in a room.
 
const struct GNUNET_HashCodeget_room_epoch_hash (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Returns the messages epoch hash that is locally stored for a message of a given hash in a room.
 
void delete_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 Deletes a message with a given hash inside a room under a specific delay.
 
void callback_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Executes the message callback for a given hash in a room.
 
static enum GNUNET_GenericReturnValue is_epoch_identifier_upper (const union GNUNET_MESSENGER_EpochIdentifier *identifier, const union GNUNET_MESSENGER_EpochIdentifier *other)
 
static enum GNUNET_GenericReturnValue iterate_room_request (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void handle_room_request_task (void *cls)
 
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.
 
static void handle_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_join_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static enum GNUNET_GenericReturnValue iterate_room_epoch_member_invalidation (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void handle_leave_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_name_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_key_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_id_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_miss_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_merge_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_private_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_delete_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_transcript_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_announcement_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_secret_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_appeal_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_access_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_revolution_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_group_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
static void handle_authorization_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
void handle_room_message (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Contact *sender, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch, enum GNUNET_MESSENGER_MessageFlags flags)
 Handles a message with a given hash in a room for the client API to update members and its information.
 
enum GNUNET_GenericReturnValue update_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Updates any message with a given hash in a room for the client API to force handling the message again after some changes that might affect it.
 
enum GNUNET_GenericReturnValue update_room_secret_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_SymmetricSessionKey *key, enum GNUNET_GenericReturnValue update)
 Updates a secret message with a given hash in a room for the client API trying to decrypt it with the given epoch key from an epoch announcement.
 
void update_room_last_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch)
 Updates the last message hash and its epoch of a room for the client API so that new messages can point to the latest message hash while sending.
 
void copy_room_last_message (const struct GNUNET_MESSENGER_Room *room, struct GNUNET_HashCode *hash)
 Copies the last message hash of a room into a given hash variable.
 
static enum GNUNET_GenericReturnValue iterate_local_members (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
int iterate_room_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
 Iterates through all members of a given room to forward each of them to a selected callback with a custom closure.
 
static enum GNUNET_GenericReturnValue iterate_find_member (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
enum GNUNET_GenericReturnValue find_room_member (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
 Checks through all members of a given room if a specific contact is found and returns a result depending on that.
 
static enum GNUNET_GenericReturnValue find_linked_hash (void *cls, const struct GNUNET_HashCode *key, void *value)
 
void link_room_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *other)
 Links a message identified by its hash inside a given room with another message identified by its other hash.
 
static enum GNUNET_GenericReturnValue clear_linked_hash (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static enum GNUNET_GenericReturnValue delete_linked_hash (void *cls, const struct GNUNET_HashCode *key, void *value)
 
void link_room_deletion (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay, GNUNET_MESSENGER_RoomLinkDeletion deletion)
 Delete all remaining links to a certain message identified by its hash inside a given room and cause a deletion process to all of the linked messages.
 

Function Documentation

◆ create_room()

struct GNUNET_MESSENGER_Room * create_room ( struct GNUNET_MESSENGER_Handle handle,
const union GNUNET_MESSENGER_RoomKey key 
)

Creates and allocates a new room for a handle with a given key for the client API.

Parameters
[in,out]handleHandle
[in]keyKey of room
Returns
New room

Definition at line 51 of file messenger_api_room.c.

53{
54 struct GNUNET_MESSENGER_Room *room;
55
56 GNUNET_assert ((handle) && (key));
57
58 room = GNUNET_new (struct GNUNET_MESSENGER_Room);
59 room->handle = handle;
60
61 GNUNET_memcpy (&(room->key), key, sizeof(*key));
62
63 room->keys_head = NULL;
64 room->keys_tail = NULL;
65
66 memset (&(room->last_message), 0, sizeof(room->last_message));
67 memset (&(room->last_epoch), 0, sizeof(room->last_epoch));
68
69 room->joined = GNUNET_NO;
70 room->opened = GNUNET_NO;
73
74 room->sender_id = NULL;
75
76 init_list_tunnels (&(room->entries));
77
82
86
87 init_queue_messages (&(room->queue));
88 room->queue_task = NULL;
89
90 room->request_task = NULL;
91
92 room->control = create_message_control (room);
93
94 return room;
95}
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void init_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Initializes list of tunnels peer identities as empty list.
struct GNUNET_MESSENGER_MessageControl * create_message_control(struct GNUNET_MESSENGER_Room *room)
Creates and allocates a new message control for a room of the client API.
void init_queue_messages(struct GNUNET_MESSENGER_QueueMessages *messages)
Initializes queue of messages as empty queue.
struct GNUNET_CONTAINER_MultiHashMap * links
struct GNUNET_MESSENGER_RoomEncryptionKey * keys_tail
struct GNUNET_CONTAINER_MultiShortmap * subscriptions
struct GNUNET_MESSENGER_Handle * handle
enum GNUNET_GenericReturnValue opened
union GNUNET_MESSENGER_RoomKey key
enum GNUNET_GenericReturnValue wait_for_sync
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_MESSENGER_MessageControl * control
struct GNUNET_SCHEDULER_Task * request_task
struct GNUNET_CONTAINER_MultiHashMap * requests
struct GNUNET_SCHEDULER_Task * queue_task
struct GNUNET_CONTAINER_MultiHashMap * epochs
struct GNUNET_HashCode last_epoch
struct GNUNET_CONTAINER_MultiHashMap * messages
struct GNUNET_CONTAINER_MultiHashMap * actions
enum GNUNET_GenericReturnValue use_handle_name
struct GNUNET_MESSENGER_QueueMessages queue
enum GNUNET_GenericReturnValue joined
struct GNUNET_MESSENGER_ListTunnels entries
struct GNUNET_MESSENGER_RoomEncryptionKey * keys_head
struct GNUNET_ShortHashCode * sender_id
struct GNUNET_HashCode last_message

References GNUNET_MESSENGER_Room::actions, GNUNET_MESSENGER_Room::control, create_message_control(), GNUNET_MESSENGER_Room::entries, GNUNET_MESSENGER_Room::epochs, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_YES, handle, GNUNET_MESSENGER_Room::handle, init_list_tunnels(), init_queue_messages(), GNUNET_MESSENGER_Room::joined, key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::keys_head, GNUNET_MESSENGER_Room::keys_tail, GNUNET_MESSENGER_Room::last_epoch, GNUNET_MESSENGER_Room::last_message, GNUNET_MESSENGER_Room::links, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_Room::opened, GNUNET_MESSENGER_Room::queue, GNUNET_MESSENGER_Room::queue_task, GNUNET_MESSENGER_Room::request_task, GNUNET_MESSENGER_Room::requests, GNUNET_MESSENGER_Room::sender_id, GNUNET_MESSENGER_Room::subscriptions, GNUNET_MESSENGER_Room::use_handle_name, and GNUNET_MESSENGER_Room::wait_for_sync.

Referenced by get_handle_room().

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

◆ iterate_destroy_action()

static enum GNUNET_GenericReturnValue iterate_destroy_action ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 99 of file messenger_api_room.c.

102{
104
106
107 action = value;
108
109 if (action->task)
111
112 GNUNET_free (action);
113 return GNUNET_YES;
114}
static char * value
Value of the record to add/remove.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:980

References GNUNET_assert, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_YES, and value.

Referenced by cancel_room_action(), and destroy_room().

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

◆ iterate_destroy_message()

static enum GNUNET_GenericReturnValue iterate_destroy_message ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 118 of file messenger_api_room.c.

121{
123
125
126 entry = value;
127
128 destroy_message (entry->message);
129 GNUNET_free (entry);
130 return GNUNET_YES;
131}
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
struct GNUNET_MESSENGER_Message * message

References destroy_message(), GNUNET_assert, GNUNET_free, GNUNET_YES, GNUNET_MESSENGER_RoomMessageEntry::message, and value.

Referenced by destroy_room().

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

◆ iterate_destroy_link()

static enum GNUNET_GenericReturnValue iterate_destroy_link ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 135 of file messenger_api_room.c.

138{
139 struct GNUNET_HashCode *hash;
140
142
143 hash = value;
144
145 GNUNET_free (hash);
146 return GNUNET_YES;
147}
A 512-bit hashcode.

References GNUNET_assert, GNUNET_free, GNUNET_YES, and value.

Referenced by destroy_room().

Here is the caller graph for this function:

◆ iterate_destroy_subscription()

static enum GNUNET_GenericReturnValue iterate_destroy_subscription ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 151 of file messenger_api_room.c.

154{
155 struct GNUNET_MESSENGER_RoomSubscription *subscription;
156
158
159 subscription = value;
160
161 if (subscription->task)
162 GNUNET_SCHEDULER_cancel (subscription->task);
163
164 if (subscription->message)
165 destroy_message (subscription->message);
166
167 GNUNET_free (subscription);
168 return GNUNET_YES;
169}
struct GNUNET_SCHEDULER_Task * task
struct GNUNET_MESSENGER_Message * message

References destroy_message(), GNUNET_assert, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_MESSENGER_RoomSubscription::message, GNUNET_MESSENGER_RoomSubscription::task, and value.

Referenced by destroy_room().

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

◆ iterate_destroy_epoch()

static enum GNUNET_GenericReturnValue iterate_destroy_epoch ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 173 of file messenger_api_room.c.

176{
177 struct GNUNET_MESSENGER_Epoch *epoch;
178
180
181 epoch = value;
182
183 destroy_epoch (epoch);
184 return GNUNET_YES;
185}
void destroy_epoch(struct GNUNET_MESSENGER_Epoch *epoch)
Destroys an epoch and frees its memory fully from the client API.

References destroy_epoch(), GNUNET_assert, GNUNET_YES, and value.

Referenced by destroy_room().

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

◆ clear_room_encryption_keys()

static void clear_room_encryption_keys ( struct GNUNET_MESSENGER_RoomEncryptionKey head,
struct GNUNET_MESSENGER_RoomEncryptionKey tail 
)
static

Definition at line 189 of file messenger_api_room.c.

191{
192 struct GNUNET_MESSENGER_RoomEncryptionKey *encryption_key;
193
194 GNUNET_assert ((head) && (tail));
195
196 do
197 {
198 encryption_key = head;
199
200 GNUNET_CONTAINER_DLL_remove (head, tail, encryption_key);
201
202 if (encryption_key->query)
203 GNUNET_NAMESTORE_cancel (encryption_key->query);
204
205 GNUNET_CRYPTO_hpke_sk_clear (&(encryption_key->key));
206 GNUNET_free (encryption_key);
207 }
208 while (head);
209}
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_CRYPTO_hpke_sk_clear(struct GNUNET_CRYPTO_HpkePrivateKey *key)
Clear memory that was used to store a GNUNET_CRYPTO_HpkePrivateKey.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_QueueEntry * query
struct GNUNET_CRYPTO_HpkePrivateKey key

References GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CRYPTO_hpke_sk_clear(), GNUNET_free, GNUNET_NAMESTORE_cancel(), GNUNET_MESSENGER_RoomEncryptionKey::key, and GNUNET_MESSENGER_RoomEncryptionKey::query.

Referenced by destroy_room().

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

◆ destroy_room()

void destroy_room ( struct GNUNET_MESSENGER_Room room)

Destroys a room and frees its memory fully from the client API.

Parameters
[in,out]roomRoom

Definition at line 213 of file messenger_api_room.c.

214{
215 GNUNET_assert (room);
216
218
219 if (room->actions)
220 {
223
225 }
226
227 if (room->request_task)
229
230 if (room->queue_task)
232
233 clear_queue_messages (&(room->queue));
234 clear_list_tunnels (&(room->entries));
235
236 if (room->requests)
238
239 if (room->epochs)
240 {
243 NULL);
244
246 }
247
248 if (room->subscriptions)
249 {
252 NULL);
253
255 }
256
257 if (room->messages)
258 {
261
263 }
264
265 if (room->members)
267
268 if (room->links)
269 {
272
274 }
275
276 if (room->sender_id)
277 GNUNET_free (room->sender_id);
278
279 if (room->keys_head)
281
282 GNUNET_free (room);
283}
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
void clear_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Clears the list of tunnels peer identities.
void destroy_message_control(struct GNUNET_MESSENGER_MessageControl *control)
Destroys a message control and frees its memory fully from the client API.
void clear_queue_messages(struct GNUNET_MESSENGER_QueueMessages *messages)
Clears the queue of messages.
static void clear_room_encryption_keys(struct GNUNET_MESSENGER_RoomEncryptionKey *head, struct GNUNET_MESSENGER_RoomEncryptionKey *tail)
static enum GNUNET_GenericReturnValue iterate_destroy_epoch(void *cls, const struct GNUNET_HashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_destroy_subscription(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_destroy_action(void *cls, const struct GNUNET_HashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_destroy_link(void *cls, const struct GNUNET_HashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_destroy_message(void *cls, const struct GNUNET_HashCode *key, void *value)

References GNUNET_MESSENGER_Room::actions, clear_list_tunnels(), clear_queue_messages(), clear_room_encryption_keys(), GNUNET_MESSENGER_Room::control, destroy_message_control(), GNUNET_MESSENGER_Room::entries, GNUNET_MESSENGER_Room::epochs, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), iterate_destroy_action(), iterate_destroy_epoch(), iterate_destroy_link(), iterate_destroy_message(), iterate_destroy_subscription(), GNUNET_MESSENGER_Room::keys_head, GNUNET_MESSENGER_Room::keys_tail, GNUNET_MESSENGER_Room::links, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_Room::queue, GNUNET_MESSENGER_Room::queue_task, GNUNET_MESSENGER_Room::request_task, GNUNET_MESSENGER_Room::requests, GNUNET_MESSENGER_Room::sender_id, and GNUNET_MESSENGER_Room::subscriptions.

Referenced by close_handle_room(), get_handle_room(), and iterate_destroy_room().

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

◆ get_room_key()

◆ is_room_public()

enum GNUNET_GenericReturnValue is_room_public ( const struct GNUNET_MESSENGER_Room room)

Returns whether a given room is public or using epoch keys to encrypt private traffic and sync those keys automatically.

Parameters
[in]roomRoom
Returns
GNUNET_YES if the room is public, otherwise GNUNET_NO

Definition at line 296 of file messenger_api_room.c.

297{
298 GNUNET_assert (room);
299
300 return room->key.code.public_bit? GNUNET_YES : GNUNET_NO;
301}
struct GNUNET_MESSENGER_RoomKeyCode code

References GNUNET_MESSENGER_RoomKey::code, GNUNET_assert, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Room::key, and GNUNET_MESSENGER_RoomKeyCode::public_bit.

Referenced by handle_epoch_announcement_delay(), handle_epoch_group_announcement_delay(), and send_message_to_room().

Here is the caller graph for this function:

◆ get_room_encryption_key()

const struct GNUNET_CRYPTO_HpkePublicKey * get_room_encryption_key ( const struct GNUNET_MESSENGER_Room room)

Returns the latest encryption key stored in memory by the current user for a given room.

Parameters
[in]roomRoom
Returns
Public key for hybrid public key encryption

Definition at line 305 of file messenger_api_room.c.

306{
307 static struct GNUNET_CRYPTO_HpkePublicKey public_key;
308
309 GNUNET_assert (room);
310
311 if (! room->keys_tail)
312 return NULL;
313
315 &(room->keys_tail->key), &public_key));
316
317 return &public_key;
318}
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_get_public(const struct GNUNET_CRYPTO_HpkePrivateKey *privkey, struct GNUNET_CRYPTO_HpkePublicKey *key)
Retrieves the GNUNET_CRYPTO_HpkePublicKey representation of a GNUNET_CRYPTO_HpkePrivateKey.
@ GNUNET_OK
A public key used for encryption.

References GNUNET_assert, GNUNET_CRYPTO_hpke_sk_get_public(), GNUNET_OK, GNUNET_MESSENGER_RoomEncryptionKey::key, and GNUNET_MESSENGER_Room::keys_tail.

Referenced by get_valid_encryption_key_for_room().

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

◆ cont_write_encryption_key_record()

static void cont_write_encryption_key_record ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Definition at line 322 of file messenger_api_room.c.

324{
325 struct GNUNET_MESSENGER_RoomEncryptionKey *encryption_key;
326
327 GNUNET_assert (cls);
328
329 encryption_key = cls;
330
331 if (GNUNET_EC_NONE != ec)
333 "Error writing encryption key record: %d\n", (int) ec);
334
335 encryption_key->query = NULL;
336}
@ GNUNET_EC_NONE
No error (success).
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_assert, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, and GNUNET_MESSENGER_RoomEncryptionKey::query.

Referenced by add_room_encryption_key().

Here is the caller graph for this function:

◆ add_room_encryption_key()

enum GNUNET_GenericReturnValue add_room_encryption_key ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_CRYPTO_HpkePrivateKey key 
)

Adds an encryption key by the current user to memory of a given room and will be placed to the second latest slot in the list if it's not empty.

If the provided key is NULL, a new key will be generated and placed as latest key to be used for encryption purposes in the active member session.

Parameters
[in]roomRoom
[in]keyPrivate key for hybrid public key encryption or NULL
Returns
GNUNET_SYSERR on error, otherwise GNUNET_OK

Definition at line 340 of file messenger_api_room.c.

342{
343 struct GNUNET_MESSENGER_RoomEncryptionKey *encryption_key;
344
345 GNUNET_assert (room);
346
347 if (key)
348 {
349 encryption_key = room->keys_tail;
350
351 while (encryption_key)
352 {
353 if (0 == GNUNET_memcmp_priv (key, &(encryption_key->key)))
354 return GNUNET_SYSERR;
355
356 encryption_key = encryption_key->prev;
357 }
358 }
359
360 encryption_key = GNUNET_malloc (sizeof(struct
362
363 if (! encryption_key)
364 return GNUNET_SYSERR;
365
366 if (key)
367 GNUNET_memcpy (&(encryption_key->key), key, sizeof (struct
370 GNUNET_CRYPTO_HPKE_KEY_TYPE_X25519, &(encryption_key->key)))
371 {
372 GNUNET_free (encryption_key);
373 return GNUNET_SYSERR;
374 }
375
376 encryption_key->query = NULL;
377
378 encryption_key->prev = NULL;
379 encryption_key->next = NULL;
380
381 if (key)
383 keys_tail, encryption_key);
384 else
385 {
387 get_room_handle (room),
388 get_room_key (room),
389 &(encryption_key->key),
391 encryption_key,
392 &(encryption_key->query));
393
395 encryption_key);
396 }
397
398 return GNUNET_OK;
399}
#define GNUNET_CONTAINER_DLL_insert_before(head, tail, other, element)
Insert an element into a DLL before the given other element.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_hpke_sk_create(enum GNUNET_CRYPTO_HpkeKeyType type, struct GNUNET_CRYPTO_HpkePrivateKey *pk)
Create a new GNUNET_CRYPTO_HpkePrivateKey of specific type.
#define GNUNET_memcmp_priv(a, b)
Compare memory in a and b in constant time, suitable for private data.
@ GNUNET_SYSERR
@ GNUNET_CRYPTO_HPKE_KEY_TYPE_X25519
Type for X25519 hybrid public key encryption.
#define GNUNET_malloc(size)
Wrapper around malloc.
enum GNUNET_GenericReturnValue store_handle_encryption_key(const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_CRYPTO_HpkePrivateKey *encryption_key, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls, struct GNUNET_NAMESTORE_QueueEntry **query)
Stores an encryption_key for a given room from a handle identified by its key/i>.
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_Room *room)
Return a the hash representation of a given room.
struct GNUNET_MESSENGER_Handle * get_room_handle(struct GNUNET_MESSENGER_Room *room)
Returns the messenger handle of the room.
static void cont_write_encryption_key_record(void *cls, enum GNUNET_ErrorCode ec)
A public key used for decryption.
struct GNUNET_MESSENGER_RoomEncryptionKey * prev
struct GNUNET_MESSENGER_RoomEncryptionKey * next

References cont_write_encryption_key_record(), get_room_handle(), get_room_key(), GNUNET_assert, GNUNET_CONTAINER_DLL_insert_before, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_HPKE_KEY_TYPE_X25519, GNUNET_CRYPTO_hpke_sk_create(), GNUNET_free, GNUNET_malloc, GNUNET_memcmp_priv, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, key, GNUNET_MESSENGER_RoomEncryptionKey::key, GNUNET_MESSENGER_Room::keys_head, GNUNET_MESSENGER_Room::keys_tail, GNUNET_MESSENGER_RoomEncryptionKey::next, GNUNET_MESSENGER_RoomEncryptionKey::prev, GNUNET_MESSENGER_RoomEncryptionKey::query, and store_handle_encryption_key().

Referenced by get_valid_encryption_key_for_room(), iterate_send_key_to_room(), and read_handle_encryption_key().

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

◆ is_message_entry_recent()

static enum GNUNET_GenericReturnValue is_message_entry_recent ( const struct GNUNET_MESSENGER_RoomMessageEntry entry)
static

Definition at line 403 of file messenger_api_room.c.

404{
405 GNUNET_assert (entry);
406
408 return GNUNET_YES;
409 else
410 return GNUNET_NO;
411}
@ GNUNET_MESSENGER_FLAG_RECENT
The recent flag.
enum GNUNET_MESSENGER_MessageFlags flags

References GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_MESSENGER_FLAG_RECENT, GNUNET_NO, and GNUNET_YES.

Referenced by get_room_availble_epoch_entry(), and get_room_message_epoch().

Here is the caller graph for this function:

◆ get_room_availble_epoch_entry()

static struct GNUNET_MESSENGER_Epoch * get_room_availble_epoch_entry ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_RoomMessageEntry entry,
const struct GNUNET_MESSENGER_Contact contact 
)
static

Definition at line 415 of file messenger_api_room.c.

420{
421 struct GNUNET_MESSENGER_Epoch *room_epoch;
422
423 GNUNET_assert ((room) && (hash) && (entry));
424
425 room_epoch = get_room_epoch (
426 room, &(entry->epoch),
428
429 if (! room_epoch)
430 return NULL;
431
433 return NULL;
434
436 room_epoch,
438 return NULL;
439
441 room_epoch, contact? contact : entry->sender))
442 return NULL;
443
444 return room_epoch;
445}
enum GNUNET_GenericReturnValue delay_epoch_message_for_its_members(struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_HashCode *hash)
Adds a message with a given hash to a list that can be delayed in processing for the members of a spe...
enum GNUNET_GenericReturnValue is_epoch_member(const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact)
Returns whether a specific contact is member of a given epoch.
struct GNUNET_MESSENGER_Contact * get_handle_contact(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Returns the contact of a given handle in a room identified by a given key.
struct GNUNET_MESSENGER_Epoch * get_room_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue recent)
Returns the epoch in a given room from a specific epoch hash that represents the exact message the ep...
static enum GNUNET_GenericReturnValue is_message_entry_recent(const struct GNUNET_MESSENGER_RoomMessageEntry *entry)
struct GNUNET_MESSENGER_Room * room
struct GNUNET_HashCode hash

References delay_epoch_message_for_its_members(), GNUNET_MESSENGER_RoomMessageEntry::epoch, get_handle_contact(), get_room_epoch(), get_room_key(), GNUNET_assert, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Epoch::hash, is_epoch_member(), is_message_entry_recent(), GNUNET_MESSENGER_Epoch::room, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_access_message(), handle_announcement_message(), handle_appeal_message(), handle_authorization_message(), handle_group_message(), handle_revolution_message(), handle_room_delayed_announcement(), handle_room_delayed_appeal(), and handle_secret_message().

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

◆ handle_room_delayed_deletion()

static void handle_room_delayed_deletion ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 449 of file messenger_api_room.c.

453{
454 const struct GNUNET_HashCode *target_hash;
456
457 target_hash = &(entry->message->body.deletion.hash);
458
460 {
461 struct GNUNET_TIME_Relative delay;
462
463 delay = get_message_timeout (entry->message);
464
465 link_room_deletion (room, target_hash, delay, delete_room_message);
466 }
467
468 target = GNUNET_CONTAINER_multihashmap_get (room->messages, target_hash);
469 if (! target)
470 return;
471
472 if ((target->sender != entry->sender) &&
473 (! (GNUNET_MESSENGER_FLAG_SENT & entry->flags)))
474 return;
475
477 callback_room_message (room, target_hash);
478
479 switch (target->message->header.kind)
480 {
482 {
483 struct GNUNET_MESSENGER_Epoch *epoch;
484 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
485
486 epoch = get_room_message_epoch (room, target_hash);
487
488 if (! epoch)
489 break;
490
491 announcement = get_epoch_announcement (
492 epoch,
494 GNUNET_NO);
495
496 if (! announcement)
497 break;
498
500 announcement,
501 target_hash,
502 target->message,
503 target->sender);
504 break;
505 }
506 default:
507 break;
508 }
509
511 room->messages, target_hash, target))
512 {
513 destroy_message (target->message);
514 GNUNET_free (target);
515 }
516}
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_MESSENGER_KIND_ANNOUNCEMENT
The announcement kind.
@ GNUNET_MESSENGER_FLAG_SENT
The sent flag.
@ GNUNET_MESSENGER_FLAG_DELETE
The delete flag.
struct GNUNET_MESSENGER_EpochAnnouncement * get_epoch_announcement(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Returns the epoch announcement of a given epoch using a specific unique identifier or NULL.
enum GNUNET_GenericReturnValue revoke_epoch_announcement_member(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Contact *contact)
Revokes an announcement message with its hash from a given epoch announcement removing the caused con...
struct GNUNET_TIME_Relative get_message_timeout(const struct GNUNET_MESSENGER_Message *message)
Return the relative timeout of the content from a given message that controls when a delayed handling...
struct GNUNET_MESSENGER_Epoch * get_room_message_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns the epoch of a local message with a given hash in a room.
void link_room_deletion(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay, GNUNET_MESSENGER_RoomLinkDeletion deletion)
Delete all remaining links to a certain message identified by its hash inside a given room and cause ...
void delete_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Deletes a message with a given hash inside a room under a specific delay.
void callback_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Executes the message callback for a given hash in a room.
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the announcement in an epoch.
struct GNUNET_MESSENGER_MessageAnnouncement announcement
struct GNUNET_MESSENGER_MessageDeletion deletion
struct GNUNET_HashCode hash
The hash of the message to delete.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_Contact * sender
Time for relative time used by GNUnet, in microseconds.

References GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_Message::body, callback_room_message(), delete_room_message(), GNUNET_MESSENGER_MessageBody::deletion, destroy_message(), GNUNET_MESSENGER_EpochAnnouncement::epoch, GNUNET_MESSENGER_RoomMessageEntry::flags, get_epoch_announcement(), get_message_timeout(), get_room_message_epoch(), GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_MESSENGER_FLAG_DELETE, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_MessageDeletion::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageAnnouncement::identifier, GNUNET_MESSENGER_MessageHeader::kind, link_room_deletion(), GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, revoke_epoch_announcement_member(), and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_room_delayed_action().

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

◆ handle_room_delayed_announcement()

static void handle_room_delayed_announcement ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 520 of file messenger_api_room.c.

524{
525 struct GNUNET_MESSENGER_Epoch *epoch;
526 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
528
529 GNUNET_assert ((room) && (hash) && (entry));
530
531 epoch = get_room_availble_epoch_entry (room, hash, entry, NULL);
532
533 if (! epoch)
534 return;
535
536 identifier = &(entry->message->body.announcement.identifier);
537
539 sent = GNUNET_YES;
540 else
541 sent = GNUNET_NO;
542
543 if (identifier->code.group_bit)
544 {
545 struct GNUNET_MESSENGER_EpochGroup *group;
546
548
549 if (! group)
550 return;
551
553 group,
554 entry->message,
555 hash,
556 entry->sender,
557 sent);
558 }
559 else
560 {
561 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
562
564
565 if (! announcement)
566 return;
567
569 announcement,
570 entry->message,
571 hash,
572 entry->sender,
573 sent);
574 }
575}
GNUNET_GenericReturnValue
Named constants for return values.
struct GNUNET_MESSENGER_EpochGroup * get_epoch_group(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Returns the epoch group of a given epoch using a specific unique identifier or NULL.
void handle_epoch_announcement_delay(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Contact *sender, enum GNUNET_GenericReturnValue sent)
Handles an announcement message with hash from its sender inside a given epoch announcement as second...
void handle_epoch_group_announcement_delay(struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Contact *sender, enum GNUNET_GenericReturnValue sent)
Handles an announcement message with hash from its sender inside a given epoch group as second stage ...
static struct GNUNET_MESSENGER_Epoch * get_room_availble_epoch_entry(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_RoomMessageEntry *entry, const struct GNUNET_MESSENGER_Contact *contact)
union GNUNET_MESSENGER_EpochIdentifier identifier
struct GNUNET_MESSENGER_Epoch * epoch
union GNUNET_MESSENGER_EpochIdentifier identifier
An epoch identifier unifies an epoch identifier code and its 256bit hash representation.
struct GNUNET_MESSENGER_EpochIdentifierCode code

References GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, GNUNET_MESSENGER_EpochAnnouncement::epoch, GNUNET_MESSENGER_EpochGroup::epoch, GNUNET_MESSENGER_RoomMessageEntry::flags, get_epoch_announcement(), get_epoch_group(), get_room_availble_epoch_entry(), GNUNET_assert, GNUNET_MESSENGER_FLAG_SENT, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, handle_epoch_announcement_delay(), handle_epoch_group_announcement_delay(), GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_MessageAnnouncement::identifier, GNUNET_MESSENGER_EpochAnnouncement::identifier, GNUNET_MESSENGER_EpochGroup::identifier, GNUNET_MESSENGER_RoomMessageEntry::message, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_room_delayed_action().

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

◆ handle_room_delayed_appeal()

static void handle_room_delayed_appeal ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 579 of file messenger_api_room.c.

583{
584 const struct GNUNET_MESSENGER_RoomMessageEntry *event_entry;
585 struct GNUNET_MESSENGER_Epoch *epoch;
586 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
587 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
589
590 GNUNET_assert ((room) && (hash) && (entry));
591
593 room->messages, &(entry->message->body.appeal.event));
594
595 if (! event_entry)
596 return;
597
599 return;
600
602 room, hash, event_entry, entry->sender);
603
604 if (! epoch)
605 return;
606
607 identifier = &(event_entry->message->body.announcement.identifier);
608
609 if (identifier->code.group_bit)
610 return;
611
612 announcement = get_epoch_announcement (epoch, identifier, GNUNET_NO);
613
614 if (! announcement)
615 return;
616
618 return;
619
620 if (GNUNET_YES != is_epoch_member (epoch, entry->sender))
621 return;
622
623 if (GNUNET_YES == is_epoch_announcement_member (announcement, entry->sender))
624 return;
625
626 key = get_epoch_announcement_key (announcement);
627
628 if (! key)
629 return;
630
631 send_epoch_announcement_access (announcement, hash);
632}
enum GNUNET_GenericReturnValue send_epoch_announcement_access(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_HashCode *event)
Tries to send an access message by the client responding to a previous event in regards to a given ep...
const struct GNUNET_CRYPTO_SymmetricSessionKey * get_epoch_announcement_key(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns the secret key of a given epoch announcement or NULL.
enum GNUNET_GenericReturnValue is_epoch_announcement_member(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Contact *contact)
Returns whether a specific contact is confirmed member of a given epoch announcement.
struct GNUNET_HashCode event
The hash of the linked announcement message event.
struct GNUNET_MESSENGER_MessageAppeal appeal

References GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_MessageBody::appeal, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, GNUNET_MESSENGER_MessageAppeal::event, GNUNET_MESSENGER_RoomMessageEntry::flags, get_epoch_announcement(), get_epoch_announcement_key(), get_room_availble_epoch_entry(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageAnnouncement::identifier, is_epoch_announcement_member(), is_epoch_member(), key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, send_epoch_announcement_access(), and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_room_delayed_action().

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

◆ handle_room_delayed_action()

static void handle_room_delayed_action ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)
static

Definition at line 636 of file messenger_api_room.c.

638{
639 const struct GNUNET_MESSENGER_RoomMessageEntry *entry;
640
641 GNUNET_assert ((room) && (hash));
642
643 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
644
645 if ((! entry) || (! entry->message))
646 return;
647
648 if ((entry->flags & GNUNET_MESSENGER_FLAG_UPDATE) ||
650 goto skip_delayed_handling;
651
652 switch (entry->message->header.kind)
653 {
655 handle_room_delayed_deletion (room, hash, entry);
656 break;
658 handle_room_delayed_announcement (room, hash, entry);
659 break;
661 handle_room_delayed_appeal (room, hash, entry);
662 break;
663 default:
664 break;
665 }
666
667skip_delayed_handling:
669 callback_room_message (room, hash);
670}
@ GNUNET_MESSENGER_KIND_APPEAL
The appeal kind.
@ GNUNET_MESSENGER_KIND_DELETION
The deletion kind.
@ GNUNET_MESSENGER_FLAG_UPDATE
The update flag.
static void handle_room_delayed_announcement(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_room_delayed_appeal(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_room_delayed_deletion(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_RoomMessageEntry *entry)

References callback_room_message(), GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_FLAG_DELETE, GNUNET_MESSENGER_FLAG_UPDATE, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_MESSENGER_KIND_APPEAL, GNUNET_MESSENGER_KIND_DELETION, handle_room_delayed_announcement(), handle_room_delayed_appeal(), handle_room_delayed_deletion(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, and GNUNET_MESSENGER_Room::messages.

Referenced by handle_room_action_task().

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

◆ handle_room_action_task()

static void handle_room_action_task ( void *  cls)
static

Definition at line 674 of file messenger_api_room.c.

675{
677 struct GNUNET_MESSENGER_Room *room;
678
679 GNUNET_assert (cls);
680
681 action = cls;
682 action->task = NULL;
683
684 room = action->room;
685
687 room->actions, &(action->hash), action))
688 handle_room_delayed_action (room, &(action->hash));
689
690 GNUNET_free (action);
691}
static void handle_room_delayed_action(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)

References GNUNET_MESSENGER_Room::actions, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_YES, and handle_room_delayed_action().

Referenced by delay_room_action().

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

◆ delay_room_action()

void delay_room_action ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay 
)

Enqueues delayed handling of a message in a room under a given hash once a specific delay has timed out.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]delayDelay of action

Definition at line 695 of file messenger_api_room.c.

698{
700
701 GNUNET_assert ((room) && (hash));
702
704
705 if (! action)
706 return;
707
709 room->actions, hash, action,
711 {
712 GNUNET_free (action);
713 return;
714 }
715
716 GNUNET_memcpy (&(action->hash), hash, sizeof(action->hash));
717
718 action->room = room;
720 delay,
723 action);
724}
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_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_SCHEDULER_PRIORITY_HIGH
Run with high priority (important requests).
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1207
static void handle_room_action_task(void *cls)
struct GNUNET_HashCode hash
struct GNUNET_MESSENGER_Room * room

References GNUNET_MESSENGER_Room::actions, GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_HIGH, handle_room_action_task(), GNUNET_MESSENGER_RoomAction::hash, and GNUNET_MESSENGER_RoomAction::room.

Referenced by handle_appeal_message(), handle_delete_message(), handle_epoch_announcement(), handle_epoch_group_announcement(), and handle_message().

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

◆ cancel_room_action()

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

Cancels the delayed handling of a message in a room under a given hash in case it has been queued using the function delay_room_action() before and the action has not been fully processed yet.

Parameters
[in,out]roomRoom
[in]hashHash of message

Definition at line 728 of file messenger_api_room.c.

730{
731 GNUNET_assert ((room) && (hash));
732
734 )
735 return;
736
740}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.

References GNUNET_MESSENGER_Room::actions, GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_YES, GNUNET_MESSENGER_RoomAction::hash, iterate_destroy_action(), and GNUNET_MESSENGER_RoomAction::room.

Referenced by handle_access_message(), and iterate_cancel_action().

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

◆ iterate_cancel_action_by()

static enum GNUNET_GenericReturnValue iterate_cancel_action_by ( void *  cls,
const struct GNUNET_HashCode hash,
void *  value 
)
static

Definition at line 754 of file messenger_api_room.c.

757{
760 struct GNUNET_MESSENGER_Room *room;
761 const struct GNUNET_MESSENGER_Message *message;
762
763 GNUNET_assert ((cls) && (hash) && (value));
764
765 cancel = cls;
766 action = value;
767 room = action->room;
768
769 message = get_room_message (room, hash);
770
771 if ((! message) || (message->header.kind != cancel->kind))
772 return GNUNET_YES;
773
774 if (cancel->epoch_hash)
775 {
776 const struct GNUNET_MESSENGER_Epoch *epoch;
777
779
780 if ((! epoch) || (0 != GNUNET_CRYPTO_hash_cmp (&(epoch->hash), cancel->
781 epoch_hash)))
782 return GNUNET_YES;
783 }
784
785 if (cancel->identifier)
786 {
787 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
788
789 identifier = get_room_message_epoch_identifier (room, hash);
790
791 if ((! identifier) || (0 != GNUNET_memcmp (identifier, cancel->identifier)))
792 return GNUNET_YES;
793 }
794
795 if ((cancel->contact) && (cancel->contact != get_room_sender (room, hash)))
796 return GNUNET_YES;
797
800 return GNUNET_YES;
801}
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_MESSENGER_Contact * get_room_sender(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a messages sender locally stored from a map for a given hash in a room.
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.
const union GNUNET_MESSENGER_EpochIdentifier * get_room_message_epoch_identifier(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns the epoch identifier a local message with a given hash is targeting in a room with its specif...
const struct GNUNET_HashCode * epoch_hash
const struct GNUNET_MESSENGER_Contact * contact
enum GNUNET_MESSENGER_MessageKind kind
const union GNUNET_MESSENGER_EpochIdentifier * identifier
struct GNUNET_CONTAINER_MultiHashMap * map

References GNUNET_MESSENGER_RoomCancelAction::contact, GNUNET_MESSENGER_RoomCancelAction::epoch_hash, get_room_message(), get_room_message_epoch(), get_room_message_epoch_identifier(), get_room_sender(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_CRYPTO_hash_cmp(), GNUNET_memcmp, GNUNET_YES, GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_RoomCancelAction::identifier, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomCancelAction::kind, GNUNET_MESSENGER_RoomCancelAction::map, GNUNET_MESSENGER_Epoch::room, and value.

Referenced by cancel_room_actions_by().

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

◆ iterate_cancel_action()

static enum GNUNET_GenericReturnValue iterate_cancel_action ( void *  cls,
const struct GNUNET_HashCode hash,
void *  value 
)
static

Definition at line 805 of file messenger_api_room.c.

808{
809 struct GNUNET_MESSENGER_Room *room;
810
811 GNUNET_assert ((cls) && (hash));
812
813 room = cls;
814
815 cancel_room_action (room, hash);
816 return GNUNET_YES;
817}
void cancel_room_action(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Cancels the delayed handling of a message in a room under a given hash in case it has been queued usi...

References cancel_room_action(), GNUNET_assert, and GNUNET_YES.

Referenced by cancel_room_actions_by().

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

◆ cancel_room_actions_by()

void cancel_room_actions_by ( struct GNUNET_MESSENGER_Room room,
enum GNUNET_MESSENGER_MessageKind  kind,
const struct GNUNET_HashCode epoch_hash,
const union GNUNET_MESSENGER_EpochIdentifier identifier,
const struct GNUNET_MESSENGER_Contact contact 
)

Searches queued actions to handle messages of a specific message kind in a room with any delay and cancels them using the function cancel_room_action().

The actions that need to be cancelled can be filtered by providing the specific hash of the epoch, identifier of the epoch key or group or even the contact from the sender of the exact message. All these parameters are optional.

Parameters
[in,out]roomRoom
[in]kindMessage kind
[in]epoch_hashHash of epoch or NULL
[in]identifierIdentifier of epoch key/group or NULL
[in]contactContact of sender or NULL

Definition at line 821 of file messenger_api_room.c.

827{
829
830 GNUNET_assert (room);
831
832 cancel.kind = kind;
833 cancel.epoch_hash = epoch_hash;
834 cancel.identifier = identifier;
835 cancel.contact = contact;
836
838
839 if (! cancel.map)
840 return;
841
844 &cancel);
845
848 room);
849
851}
static enum GNUNET_GenericReturnValue iterate_cancel_action_by(void *cls, const struct GNUNET_HashCode *hash, void *value)
static enum GNUNET_GenericReturnValue iterate_cancel_action(void *cls, const struct GNUNET_HashCode *hash, void *value)

References GNUNET_MESSENGER_Room::actions, GNUNET_MESSENGER_RoomCancelAction::contact, GNUNET_MESSENGER_RoomCancelAction::epoch_hash, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_NO, GNUNET_MESSENGER_RoomCancelAction::identifier, iterate_cancel_action(), iterate_cancel_action_by(), GNUNET_MESSENGER_RoomCancelAction::kind, and GNUNET_MESSENGER_RoomCancelAction::map.

Referenced by handle_epoch_announcement().

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

◆ is_room_available()

enum GNUNET_GenericReturnValue is_room_available ( const struct GNUNET_MESSENGER_Room room)

Checks whether a room is available to send messages.

Parameters
[in]roomRoom
Returns
GNUNET_YES if the room is available, otherwise GNUNET_NO

Definition at line 855 of file messenger_api_room.c.

856{
857 GNUNET_assert (room);
858
859 if (! get_room_sender_id (room))
860 return GNUNET_NO;
861
862 if ((GNUNET_YES == room->opened) || (room->entries.head))
863 return GNUNET_YES;
864 else
865 return GNUNET_NO;
866}
const struct GNUNET_ShortHashCode * get_room_sender_id(const struct GNUNET_MESSENGER_Room *room)
Returns the member id of the room's sender.
struct GNUNET_MESSENGER_ListTunnel * head

References GNUNET_MESSENGER_Room::entries, get_room_sender_id(), GNUNET_assert, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_ListTunnels::head, and GNUNET_MESSENGER_Room::opened.

Referenced by dequeue_message_from_room(), dequeue_messages_from_room(), and enqueue_message_to_room().

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

◆ get_room_handle()

struct GNUNET_MESSENGER_Handle * get_room_handle ( struct GNUNET_MESSENGER_Room room)

Returns the messenger handle of the room.

Parameters
[in,out]roomRoom
Returns
Messenger handle or NULL

Definition at line 870 of file messenger_api_room.c.

871{
872 GNUNET_assert (room);
873
874 return room->handle;
875}

References GNUNET_assert, and GNUNET_MESSENGER_Room::handle.

Referenced by add_room_encryption_key(), handle_epoch_announcement(), process_message_control(), task_message_control(), write_epoch_announcement_record(), and write_epoch_group_record().

Here is the caller graph for this function:

◆ get_room_sender_id()

const struct GNUNET_ShortHashCode * get_room_sender_id ( const struct GNUNET_MESSENGER_Room room)

Returns the member id of the room's sender.

Parameters
[in]roomRoom
Returns
Member id or NULL

Definition at line 879 of file messenger_api_room.c.

880{
881 GNUNET_assert (room);
882
883 return room->sender_id;
884}

References GNUNET_assert, and GNUNET_MESSENGER_Room::sender_id.

Referenced by get_handle_contact(), GNUNET_MESSENGER_get_message(), handle_join_message(), handle_member_id(), handle_miss_message(), handle_room_request_task(), is_room_available(), and send_message_to_room().

Here is the caller graph for this function:

◆ set_room_sender_id()

void set_room_sender_id ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_ShortHashCode id 
)

Sets the member id of the room's sender to a specific id or NULL.

Parameters
[in,out]roomRoom
[in]idMember id or NULL

Definition at line 888 of file messenger_api_room.c.

890{
891 GNUNET_assert (room);
892
893 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Set member id for room: %s\n",
894 GNUNET_h2s (get_room_key (room)));
895
896 if (! id)
897 {
898 if (room->sender_id)
899 GNUNET_free (room->sender_id);
900
901 room->sender_id = NULL;
902 return;
903 }
904
905 if (! room->sender_id)
907
908 GNUNET_memcpy (room->sender_id, id, sizeof(struct GNUNET_ShortHashCode));
909}
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
A 256-bit hashcode.

References get_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, and GNUNET_MESSENGER_Room::sender_id.

Referenced by handle_id_message(), and handle_member_id().

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

◆ get_room_epoch()

struct GNUNET_MESSENGER_Epoch * get_room_epoch ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
enum GNUNET_GenericReturnValue  recent 
)

Returns the epoch in a given room from a specific epoch hash that represents the exact message the epoch starts.

Parameters
[in,out]roomRoom
[in]hashHash of epoch
[in]recentRecent flag
Returns
Epoch or NULL

Definition at line 913 of file messenger_api_room.c.

916{
917 struct GNUNET_MESSENGER_Epoch *epoch;
918
919 GNUNET_assert ((room) && (hash));
920
921 if (GNUNET_is_zero (hash))
922 return NULL;
923
925
926 if (epoch)
927 return epoch;
928
929 if (GNUNET_YES == recent)
930 epoch = create_new_epoch (room, hash);
931 else
932 epoch = create_epoch (room, hash);
933
934 if (! epoch)
935 return NULL;
936
938 hash,
939 epoch,
941 {
942 destroy_epoch (epoch);
943 return NULL;
944 }
945
946 return epoch;
947}
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
struct GNUNET_MESSENGER_Epoch * create_new_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Creates and allocates a new epoch in a given room which can be identified by a specific hash.
struct GNUNET_MESSENGER_Epoch * create_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Creates and allocates an epoch in a given room which can be identified by a specific hash.

References create_epoch(), create_new_epoch(), destroy_epoch(), GNUNET_MESSENGER_Room::epochs, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_is_zero, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Epoch::hash, and GNUNET_MESSENGER_Epoch::room.

Referenced by get_members_of_epoch(), get_room_availble_epoch_entry(), get_room_message_epoch(), handle_message(), invalidate_epoch_announcement(), invalidate_epoch_group(), read_handle_epoch_key(), send_message_to_room(), and setup_following_epochs_of_previous().

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

◆ generate_room_epoch_announcement()

void generate_room_epoch_announcement ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Epoch epoch,
struct GNUNET_MESSENGER_EpochAnnouncement **  announcement 
)

Generate a new announcement for a given epoch in a room under a random and unique announcement identifier.

The function will automatically generate an announcement message and send it to others.

Parameters
[in,out]roomRoom
[in,out]epochEpoch
[out]announcementEpoch announcement

Definition at line 951 of file messenger_api_room.c.

955{
956 struct GNUNET_MESSENGER_EpochAnnouncement *epoch_announcement;
957
958 GNUNET_assert ((room) && (epoch) && (announcement) && (! (*announcement)));
959
960 epoch_announcement = create_epoch_announcement (epoch, NULL, GNUNET_YES);
961
962 if (! epoch_announcement)
963 return;
964
966 &(epoch_announcement->
968 epoch_announcement,
970 {
971 destroy_epoch_announcement (epoch_announcement);
972 return;
973 }
974
975 if (! get_epoch_announcement_key (epoch_announcement))
976 set_epoch_announcement_key (epoch_announcement, NULL, GNUNET_YES);
977
978 *announcement = epoch_announcement;
979
980 send_epoch_announcement (epoch_announcement);
981}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue send_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Tries to send an announcement message by the client for a given epoch announcement using its secret k...
struct GNUNET_MESSENGER_EpochAnnouncement * create_epoch_announcement(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Creates and allocates a new epoch announcement for a given epoch using a specific announcement identi...
void set_epoch_announcement_key(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key, enum GNUNET_GenericReturnValue write_record)
Sets the secret key of a given epoch announcement to a shared key.
void destroy_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Destroys a given epoch announcement and frees its resources.
struct GNUNET_CONTAINER_MultiShortmap * announcements

References GNUNET_MESSENGER_Epoch::announcements, create_epoch_announcement(), destroy_epoch_announcement(), GNUNET_MESSENGER_EpochAnnouncement::epoch, get_epoch_announcement_key(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_put(), GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_EpochAnnouncement::identifier, send_epoch_announcement(), and set_epoch_announcement_key().

Referenced by send_message_to_room().

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

◆ get_room_message_epoch()

struct GNUNET_MESSENGER_Epoch * get_room_message_epoch ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns the epoch of a local message with a given hash in a room.

If no matching message is found or no matching epoch for that message is available, NULL gets returned.

Parameters
[in,out]roomRoom
[in]hashHash of message
Returns
Epoch or NULL

Definition at line 985 of file messenger_api_room.c.

987{
989
990 GNUNET_assert ((room) && (hash));
991
992 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
993
994 if (! entry)
995 return NULL;
996
997 return get_room_epoch (room, &(entry->epoch),
999}

References GNUNET_MESSENGER_RoomMessageEntry::epoch, get_room_epoch(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), is_message_entry_recent(), and GNUNET_MESSENGER_Room::messages.

Referenced by get_epoch_previous_announcement(), get_epoch_previous_group(), handle_room_delayed_deletion(), and iterate_cancel_action_by().

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

◆ get_room_message_epoch_identifier()

const union GNUNET_MESSENGER_EpochIdentifier * get_room_message_epoch_identifier ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns the epoch identifier a local message with a given hash is targeting in a room with its specific operation.

The function is returning NULL if the given message does not provide any context which can be identified with an epoch identifier or if there's no message available under the given hash.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
Epoch identifier or NULL

Definition at line 1003 of file messenger_api_room.c.

1005{
1007
1008 GNUNET_assert ((room) && (hash));
1009
1010 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
1011
1012 if ((! entry) || (! entry->message))
1013 return NULL;
1014
1015 switch (entry->message->header.kind)
1016 {
1018 return &(entry->message->body.announcement.identifier);
1020 return &(entry->message->body.secret.identifier);
1023 &(entry->message->body.appeal.
1024 event));
1027 &(entry->message->body.access.
1028 event));
1030 return &(entry->message->body.revolution.identifier);
1032 return &(entry->message->body.group.identifier);
1034 return &(entry->message->body.authorization.identifier);
1035 default:
1036 return NULL;
1037 }
1038}
@ GNUNET_MESSENGER_KIND_AUTHORIZATION
The authorization kind.
@ GNUNET_MESSENGER_KIND_ACCESS
The access kind.
@ GNUNET_MESSENGER_KIND_REVOLUTION
The revolution kind.
@ GNUNET_MESSENGER_KIND_SECRET
The secret kind.
@ GNUNET_MESSENGER_KIND_GROUP
The group kind.
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the group in an epoch.
struct GNUNET_MESSENGER_MessageGroup group
struct GNUNET_MESSENGER_MessageSecret secret
struct GNUNET_MESSENGER_MessageRevolution revolution
struct GNUNET_MESSENGER_MessageAccess access
struct GNUNET_MESSENGER_MessageAuthorization authorization
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the group in an epoch.
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the announcement in an epoch.
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the announcement in an epoch.

References GNUNET_MESSENGER_MessageBody::access, GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_MessageBody::appeal, GNUNET_MESSENGER_MessageBody::authorization, GNUNET_MESSENGER_Message::body, get_room_message_epoch_identifier(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_KIND_ACCESS, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_MESSENGER_KIND_APPEAL, GNUNET_MESSENGER_KIND_AUTHORIZATION, GNUNET_MESSENGER_KIND_GROUP, GNUNET_MESSENGER_KIND_REVOLUTION, GNUNET_MESSENGER_KIND_SECRET, GNUNET_MESSENGER_MessageBody::group, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageAnnouncement::identifier, GNUNET_MESSENGER_MessageSecret::identifier, GNUNET_MESSENGER_MessageRevolution::identifier, GNUNET_MESSENGER_MessageGroup::identifier, GNUNET_MESSENGER_MessageAuthorization::identifier, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_MessageBody::revolution, and GNUNET_MESSENGER_MessageBody::secret.

Referenced by get_room_message_epoch_identifier(), and iterate_cancel_action_by().

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

◆ get_room_message()

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.

If no matching message is found, NULL gets returned.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
Message or NULL

Definition at line 1042 of file messenger_api_room.c.

1044{
1046
1047 GNUNET_assert ((room) && (hash));
1048
1049 if (! (room->messages))
1050 return NULL;
1051
1052 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
1053
1054 if ((! entry) || (GNUNET_YES != entry->completed))
1055 return NULL;
1056
1057 return entry->message;
1058}
enum GNUNET_GenericReturnValue completed

References GNUNET_MESSENGER_RoomMessageEntry::completed, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_YES, GNUNET_MESSENGER_RoomMessageEntry::message, and GNUNET_MESSENGER_Room::messages.

Referenced by get_epoch_previous_announcement(), get_epoch_previous_group(), get_epoch_proposal_group(), get_members_of_epoch(), GNUNET_MESSENGER_delete_message(), GNUNET_MESSENGER_get_message(), handle_epoch_announcement_access(), invalidate_epoch_announcement(), invalidate_epoch_group(), is_epoch_member_in_room_graph(), is_epoch_previous_of_other(), iterate_cancel_action_by(), require_message_from_room(), send_epoch_announcement_access(), send_epoch_announcement_authorization(), send_epoch_group(), send_epoch_group_access(), send_epoch_group_authorization(), set_epoch_proposal_group(), and setup_following_epochs_of_previous().

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

◆ is_room_message_sent()

enum GNUNET_GenericReturnValue is_room_message_sent ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns whether a message is sent by the handle of the given room itself or another client that is using the same unique key to sign its sent messages.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
GNUNET_YES if it has been sent, GNUNET_SYSERR on failure, otherwise GNUNET_NO

Definition at line 1062 of file messenger_api_room.c.

1064{
1066
1067 GNUNET_assert ((room) && (hash));
1068
1069 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
1070
1071 if (! entry)
1072 return GNUNET_SYSERR;
1073
1074 if (GNUNET_MESSENGER_FLAG_SENT & entry->flags)
1075 return GNUNET_YES;
1076 else
1077 return GNUNET_NO;
1078}

References GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_FLAG_SENT, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, and GNUNET_MESSENGER_Room::messages.

Referenced by send_epoch_group(), send_epoch_group_access(), and send_epoch_group_authorization().

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

◆ get_room_sender()

struct GNUNET_MESSENGER_Contact * get_room_sender ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns a messages sender locally stored from a map for a given hash in a room.

If no matching message is found, NULL gets returned.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
Contact of sender or NULL

Definition at line 1082 of file messenger_api_room.c.

1084{
1086
1087 GNUNET_assert ((room) && (hash));
1088
1089 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
1090
1091 if ((! entry) || (GNUNET_YES != entry->completed))
1092 return NULL;
1093
1094 return entry->sender;
1095}

References GNUNET_MESSENGER_RoomMessageEntry::completed, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_YES, GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by get_members_of_epoch(), GNUNET_MESSENGER_get_sender(), iterate_cancel_action_by(), and send_epoch_group().

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

◆ get_room_recipient()

struct GNUNET_MESSENGER_Contact * get_room_recipient ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns a messages recipient locally stored from a map for a given hash in a room.

If no matching message is found or the message has not been privately received, NULL gets returned.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
Contact of recipient or NULL

Definition at line 1099 of file messenger_api_room.c.

1101{
1103
1104 GNUNET_assert ((room) && (hash));
1105
1106 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
1107
1108 if ((! entry) || (GNUNET_YES != entry->completed))
1109 return NULL;
1110
1111 return entry->recipient;
1112}
struct GNUNET_MESSENGER_Contact * recipient

References GNUNET_MESSENGER_RoomMessageEntry::completed, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_YES, GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_RoomMessageEntry::recipient.

Referenced by GNUNET_MESSENGER_get_recipient().

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

◆ get_room_epoch_hash()

const struct GNUNET_HashCode * get_room_epoch_hash ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Returns the messages epoch hash that is locally stored for a message of a given hash in a room.

If no matching message is found, NULL gets returned.

Parameters
[in]roomRoom
[in]hashHash of message
Returns
Hash of epoch or NULL

Definition at line 1116 of file messenger_api_room.c.

1118{
1120
1121 GNUNET_assert ((room) && (hash));
1122
1123 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
1124
1125 if (! entry)
1126 return NULL;
1127
1128 return &(entry->epoch);
1129}

References GNUNET_MESSENGER_RoomMessageEntry::epoch, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), and GNUNET_MESSENGER_Room::messages.

Here is the call graph for this function:

◆ delete_room_message()

void delete_room_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay 
)

Deletes a message with a given hash inside a room under a specific delay.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]delayDelay of deletion

Definition at line 1133 of file messenger_api_room.c.

1136{
1137 struct GNUNET_MESSENGER_Message *message;
1138
1139 GNUNET_assert ((room) && (hash));
1140
1141 message = create_message_deletion (hash, delay);
1142
1143 if (! message)
1144 {
1146 "Sending deletion aborted: Message creation failed!\n");
1147 return;
1148 }
1149
1150 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
1151}
@ GNUNET_ERROR_TYPE_WARNING
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.
struct GNUNET_MESSENGER_Message * create_message_deletion(const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Creates and allocates a new deletion message containing the hash of a message to delete after a speci...

References create_message_deletion(), enqueue_message_to_room(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, and GNUNET_NO.

Referenced by GNUNET_MESSENGER_delete_message(), and handle_room_delayed_deletion().

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

◆ callback_room_message()

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

Executes the message callback for a given hash in a room.

Parameters
[in,out]roomRoom
[in]hashHash of message

Definition at line 1155 of file messenger_api_room.c.

1157{
1160
1161 GNUNET_assert ((room) && (hash));
1162
1163 handle = room->handle;
1164 if (! handle)
1165 return;
1166
1167 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
1168 if (! entry)
1169 return;
1170
1171 if (handle->msg_callback)
1172 handle->msg_callback (handle->msg_cls, room,
1173 entry->sender,
1174 entry->recipient,
1175 entry->message,
1176 hash,
1177 entry->flags);
1178
1181}

References GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_FLAG_UPDATE, handle, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_RoomMessageEntry::recipient, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_message_control(), handle_room_delayed_action(), and handle_room_delayed_deletion().

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

◆ is_epoch_identifier_upper()

static enum GNUNET_GenericReturnValue is_epoch_identifier_upper ( const union GNUNET_MESSENGER_EpochIdentifier identifier,
const union GNUNET_MESSENGER_EpochIdentifier other 
)
static

Definition at line 1185 of file messenger_api_room.c.

1188{
1189 uint32_t level, other_level;
1190
1191 GNUNET_assert ((identifier) && (other));
1192
1193 level = (uint32_t) identifier->code.level_bits;
1194 other_level = (uint32_t) other->code.level_bits;
1195
1196 if (level > other_level)
1197 return GNUNET_YES;
1198 else
1199 return GNUNET_NO;
1200}

References GNUNET_MESSENGER_EpochIdentifier::code, GNUNET_assert, GNUNET_NO, GNUNET_YES, and GNUNET_MESSENGER_EpochIdentifierCode::level_bits.

Referenced by handle_access_message(), and handle_authorization_message().

Here is the caller graph for this function:

◆ iterate_room_request()

static enum GNUNET_GenericReturnValue iterate_room_request ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 1204 of file messenger_api_room.c.

1207{
1208 struct GNUNET_MESSENGER_Room *room;
1209
1210 GNUNET_assert ((cls) && (key));
1211
1212 room = cls;
1214
1215 return GNUNET_YES;
1216}
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.

References GNUNET_assert, GNUNET_YES, key, and request_message_from_room().

Referenced by handle_room_request_task().

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

◆ handle_room_request_task()

static void handle_room_request_task ( void *  cls)
static

Definition at line 1220 of file messenger_api_room.c.

1221{
1222 struct GNUNET_MESSENGER_Room *room;
1223
1224 GNUNET_assert (cls);
1225
1226 room = cls;
1227 room->request_task = NULL;
1228
1229 if ((GNUNET_YES != room->joined) || (! get_room_sender_id (room)))
1230 {
1231 struct GNUNET_TIME_Relative delay;
1233 delay = GNUNET_TIME_relative_multiply (delay, 100);
1234
1236 delay,
1239 room);
1240 return;
1241 }
1242
1244 room->requests,
1246 room);
1247
1249}
unsigned int GNUNET_CONTAINER_multihashmap_clear(struct GNUNET_CONTAINER_MultiHashMap *map)
Remove all entries from the map.
@ GNUNET_SCHEDULER_PRIORITY_BACKGROUND
Run as background job (higher than idle, lower than default).
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_millisecond_(void)
Return relative time of 1ms.
Definition time.c:160
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486
static enum GNUNET_GenericReturnValue iterate_room_request(void *cls, const struct GNUNET_HashCode *key, void *value)
static void handle_room_request_task(void *cls)

References get_room_sender_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_clear(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_BACKGROUND, GNUNET_TIME_relative_get_millisecond_(), GNUNET_TIME_relative_multiply(), GNUNET_YES, handle_room_request_task(), iterate_room_request(), GNUNET_MESSENGER_Room::joined, GNUNET_MESSENGER_Room::request_task, and GNUNET_MESSENGER_Room::requests.

Referenced by handle_room_request_task(), and require_message_from_room().

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 1253 of file messenger_api_room.c.

1255{
1256 GNUNET_assert ((room) && (hash));
1257
1258 if (GNUNET_is_zero (hash))
1259 return;
1260
1261 if (get_room_message (room, hash))
1262 return;
1263
1265 room->requests,
1266 hash, NULL,
1268 return;
1269
1270 if (room->request_task)
1271 return;
1272
1276 room);
1277}
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

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:

◆ handle_message()

static void handle_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 2257 of file messenger_api_room.c.

2260{
2261 GNUNET_assert ((room) && (hash) && (entry));
2262
2263 switch (entry->message->header.kind)
2264 {
2266 handle_join_message (room, hash, entry);
2267 break;
2269 handle_leave_message (room, hash, entry);
2270 break;
2272 handle_name_message (room, hash, entry);
2273 break;
2275 handle_key_message (room, hash, entry);
2276 break;
2278 handle_id_message (room, hash, entry);
2279 break;
2281 handle_miss_message (room, hash, entry);
2282 break;
2284 handle_merge_message (room, hash, entry);
2285 break;
2287 handle_private_message (room, hash, entry);
2288 break;
2290 handle_delete_message (room, hash, entry);
2291 break;
2293 handle_transcript_message (room, hash, entry);
2294 break;
2296 handle_announcement_message (room, hash, entry);
2297 break;
2299 handle_secret_message (room, hash, entry);
2300 break;
2302 handle_appeal_message (room, hash, entry);
2303 break;
2305 handle_access_message (room, hash, entry);
2306 break;
2308 handle_revolution_message (room, hash, entry);
2309 break;
2311 handle_group_message (room, hash, entry);
2312 break;
2314 handle_authorization_message (room, hash, entry);
2315 break;
2316 default:
2317 break;
2318 }
2319
2320 if (GNUNET_YES == is_epoch_message (entry->message))
2321 {
2322 struct GNUNET_MESSENGER_Epoch *epoch;
2323
2324 epoch = get_room_epoch (room, &(entry->epoch), GNUNET_NO);
2325
2326 if ((! epoch) || (get_epoch_size (epoch)))
2327 return;
2328
2329 reset_epoch_size (epoch);
2330 }
2331
2334}
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_PRIVATE
The private kind.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_TRANSCRIPT
The transcript kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition time.c:133
uint32_t get_epoch_size(const struct GNUNET_MESSENGER_Epoch *epoch)
Returns the amount of members by a given epoch or zero as long as it's not fully initialized yet.
void reset_epoch_size(struct GNUNET_MESSENGER_Epoch *epoch)
Resets the amount of members by a given epoch to recalculate the exact amount.
enum GNUNET_GenericReturnValue is_epoch_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a certain kind of message from storage contains some specific details that might be r...
static void handle_name_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_appeal_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_authorization_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_id_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_secret_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_announcement_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_access_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_private_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_group_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_revolution_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_join_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_leave_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_miss_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_transcript_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_key_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_delete_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
static void handle_merge_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
void delay_room_action(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Enqueues delayed handling of a message in a room under a given hash once a specific delay has timed o...

References delay_room_action(), GNUNET_MESSENGER_RoomMessageEntry::epoch, GNUNET_MESSENGER_RoomMessageEntry::flags, get_epoch_size(), get_room_epoch(), GNUNET_assert, GNUNET_MESSENGER_FLAG_UPDATE, GNUNET_MESSENGER_KIND_ACCESS, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_MESSENGER_KIND_APPEAL, GNUNET_MESSENGER_KIND_AUTHORIZATION, GNUNET_MESSENGER_KIND_DELETION, GNUNET_MESSENGER_KIND_GROUP, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_REVOLUTION, GNUNET_MESSENGER_KIND_SECRET, GNUNET_MESSENGER_KIND_TRANSCRIPT, GNUNET_NO, GNUNET_TIME_relative_get_zero_(), GNUNET_YES, handle_access_message(), handle_announcement_message(), handle_appeal_message(), handle_authorization_message(), handle_delete_message(), handle_group_message(), handle_id_message(), handle_join_message(), handle_key_message(), handle_leave_message(), handle_merge_message(), handle_miss_message(), handle_name_message(), handle_private_message(), handle_revolution_message(), handle_secret_message(), handle_transcript_message(), GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_Message::header, is_epoch_message(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, reset_epoch_size(), and GNUNET_MESSENGER_Epoch::room.

Referenced by handle_private_message(), handle_room_message(), handle_transcript_message(), update_room_message(), and update_room_secret_message().

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

◆ handle_join_message()

static void handle_join_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1287 of file messenger_api_room.c.

1290{
1291 GNUNET_assert ((room) && (hash) && (entry));
1292
1293 if (! entry->sender)
1294 {
1295 struct GNUNET_MESSENGER_ContactStore *store;
1296 struct GNUNET_HashCode context;
1297
1298 store = get_handle_contact_store (room->handle);
1299
1301 &(entry->message->header.sender_id),
1302 &context);
1303
1304 entry->sender = get_store_contact (store, &context,
1305 &(entry->message->body.join.key));
1306 }
1307
1308 if (! entry->sender)
1309 return;
1310
1312 room->members, &(entry->message->header.sender_id), entry->sender)) &&
1314 room->members,
1315 &(entry->message->header.sender_id),
1316 entry->sender,
1318 increase_contact_rc (entry->sender);
1319
1321 entry->sender, get_room_key (room), &(entry->message->body.join.hpke_key));
1322
1323 if ((get_room_sender_id (room)) &&
1324 (0 == GNUNET_memcmp (&(entry->message->header.sender_id),
1325 get_room_sender_id (room))) &&
1326 (0 == GNUNET_memcmp (&(entry->message->body.join.key), get_handle_pubkey (
1327 room->handle))))
1328 room->joined = GNUNET_YES;
1329
1330 require_message_from_room (room, &(entry->message->body.join.epoch));
1331}
static pa_context * context
Pulseaudio context.
int GNUNET_CONTAINER_multishortmap_contains_value(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Check if the map contains the given value under the given key.
void increase_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Increases the reference counter of a given contact which is zero as default.
void set_contact_encryption_key(struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *key, const struct GNUNET_CRYPTO_HpkePublicKey *encryption_key)
Sets or replaces the encryption_key of a given contact for a specified room that is identified via it...
void get_context_from_member(const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *id, struct GNUNET_HashCode *context)
Calculates the context hash of a member in a room and returns it.
struct GNUNET_MESSENGER_Contact * get_store_contact(struct GNUNET_MESSENGER_ContactStore *store, const struct GNUNET_HashCode *context, const struct GNUNET_CRYPTO_BlindablePublicKey *pubkey)
Returns a contact using a specific public key.
struct GNUNET_MESSENGER_ContactStore * get_handle_contact_store(struct GNUNET_MESSENGER_Handle *handle)
Returns the used contact store of a given handle.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_handle_pubkey(const struct GNUNET_MESSENGER_Handle *handle)
Returns the public key of a given handle.
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.
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_CRYPTO_BlindablePublicKey key
The senders blindable public key to verify its signatures.
struct GNUNET_HashCode epoch
The previous epoch the message was sent from.
struct GNUNET_CRYPTO_HpkePublicKey hpke_key
The senders HPKE public key to encrypt private messages with.

References GNUNET_MESSENGER_Message::body, context, GNUNET_MESSENGER_MessageJoin::epoch, get_context_from_member(), get_handle_contact_store(), get_handle_pubkey(), get_room_key(), get_room_sender_id(), get_store_contact(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_contains_value(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_memcmp, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageJoin::hpke_key, increase_contact_rc(), GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_Room::joined, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_RoomMessageEntry::message, require_message_from_room(), GNUNET_MESSENGER_RoomMessageEntry::sender, GNUNET_MESSENGER_MessageHeader::sender_id, and set_contact_encryption_key().

Referenced by handle_message().

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

◆ iterate_room_epoch_member_invalidation()

static enum GNUNET_GenericReturnValue iterate_room_epoch_member_invalidation ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 1335 of file messenger_api_room.c.

1338{
1339 struct GNUNET_MESSENGER_Contact *contact;
1340 struct GNUNET_MESSENGER_Epoch *epoch;
1341
1342 GNUNET_assert ((cls) && (value));
1343
1344 contact = cls;
1345 epoch = value;
1346
1347 invalidate_epoch_keys_by_member (epoch, contact);
1348 return GNUNET_YES;
1349}
void invalidate_epoch_keys_by_member(struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact)
Invalidates all announced epoch and group keys by a specific contact inside a given epoch.

References GNUNET_assert, GNUNET_YES, invalidate_epoch_keys_by_member(), and value.

Referenced by handle_leave_message().

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

◆ handle_leave_message()

static void handle_leave_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1353 of file messenger_api_room.c.

1356{
1357 GNUNET_assert ((room) && (hash) && (entry));
1358
1359 if ((! entry->sender) ||
1361 room->members,
1362 &(entry->message->header.sender_id),
1363 entry->sender)))
1364 return;
1365
1369 entry->sender);
1370
1371 if (GNUNET_YES == decrease_contact_rc (entry->sender))
1373 "A contact does not share any room with you anymore!\n");
1374
1376}
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue decrease_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Decreases the reference counter if possible (can not underflow!) of a given contact and returns GNUNE...
static enum GNUNET_GenericReturnValue iterate_room_epoch_member_invalidation(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_MESSENGER_MessageLeave leave
struct GNUNET_HashCode epoch
The previous epoch the message was sent from.

References GNUNET_MESSENGER_Message::body, decrease_contact_rc(), GNUNET_MESSENGER_MessageLeave::epoch, GNUNET_MESSENGER_Room::epochs, GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSENGER_FLAG_RECENT, GNUNET_YES, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_Message::header, iterate_room_epoch_member_invalidation(), GNUNET_MESSENGER_MessageBody::leave, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_RoomMessageEntry::message, require_message_from_room(), GNUNET_MESSENGER_Epoch::room, GNUNET_MESSENGER_RoomMessageEntry::sender, and GNUNET_MESSENGER_MessageHeader::sender_id.

Referenced by handle_message().

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

◆ handle_name_message()

static void handle_name_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1380 of file messenger_api_room.c.

1383{
1384 GNUNET_assert ((room) && (hash) && (entry));
1385
1386 if (GNUNET_MESSENGER_FLAG_SENT & entry->flags)
1387 {
1388 const char *handle_name;
1389
1391 "Set rule for using handle name in room: %s\n",
1392 GNUNET_h2s (get_room_key (room)));
1393
1394 handle_name = get_handle_name (room->handle);
1395
1396 if ((handle_name) && (0 == strcmp (handle_name,
1397 entry->message->body.name.name)))
1399 }
1400
1401 if (! entry->sender)
1402 return;
1403
1404 set_contact_name (entry->sender, entry->message->body.name.name);
1405}
void set_contact_name(struct GNUNET_MESSENGER_Contact *contact, const char *name)
Changes the current name of a given contact by copying it from the parameter name.
const char * get_handle_name(const struct GNUNET_MESSENGER_Handle *handle)
Returns the current name of a given handle or NULL if no valid name was assigned yet.
struct GNUNET_MESSENGER_MessageName name
char * name
The new name which replaces the current senders name.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_RoomMessageEntry::flags, get_handle_name(), get_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_FLAG_SENT, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, GNUNET_MESSENGER_Epoch::room, GNUNET_MESSENGER_RoomMessageEntry::sender, set_contact_name(), and GNUNET_MESSENGER_Room::use_handle_name.

Referenced by handle_message().

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

◆ handle_key_message()

static void handle_key_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1409 of file messenger_api_room.c.

1412{
1413 struct GNUNET_HashCode context;
1414 struct GNUNET_MESSENGER_ContactStore *store;
1415
1416 GNUNET_assert ((room) && (hash) && (entry));
1417
1418 if (! entry->sender)
1419 return;
1420
1422 get_room_key (room),
1423 &(entry->message->header.sender_id),
1424 &context);
1425
1426 store = get_handle_contact_store (room->handle);
1427
1428 update_store_contact (store, entry->sender, &context, &context,
1429 &(entry->message->body.key.key));
1430
1432 entry->sender, get_room_key (room), &(entry->message->body.key.hpke_key));
1433}
void update_store_contact(struct GNUNET_MESSENGER_ContactStore *store, struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *next_context, const struct GNUNET_CRYPTO_BlindablePublicKey *pubkey)
Moves a contact from the store to another location matching a given public key and member context.
struct GNUNET_MESSENGER_MessageKey key
struct GNUNET_CRYPTO_BlindablePublicKey key
The new blindable public key which replaces the current senders public key.
struct GNUNET_CRYPTO_HpkePublicKey hpke_key
The new HPKE public key which replaces the current senders HPKE public key.

References GNUNET_MESSENGER_Message::body, context, get_context_from_member(), get_handle_contact_store(), get_room_key(), GNUNET_assert, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageKey::hpke_key, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_RoomMessageEntry::sender, GNUNET_MESSENGER_MessageHeader::sender_id, set_contact_encryption_key(), and update_store_contact().

Referenced by handle_message().

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

◆ handle_id_message()

static void handle_id_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1437 of file messenger_api_room.c.

1440{
1441 struct GNUNET_HashCode context, next_context;
1442 struct GNUNET_MESSENGER_ContactStore *store;
1443
1444 GNUNET_assert ((room) && (hash) && (entry));
1445
1446 if (GNUNET_MESSENGER_FLAG_SENT & entry->flags)
1447 set_room_sender_id (room, &(entry->message->body.id.id));
1448
1449 if ((! entry->sender) ||
1451 room->members, &(entry->message->header.sender_id),
1452 entry->sender)) ||
1454 room->members, &(entry->message->body.id.id),
1455 entry->sender,
1457 return;
1458
1460 sender_id),
1461 &context);
1463 &next_context);
1464
1465 store = get_handle_contact_store (room->handle);
1466
1467 update_store_contact (store, entry->sender, &context, &next_context,
1468 get_contact_key (entry->sender));
1469}
const struct GNUNET_CRYPTO_BlindablePublicKey * get_contact_key(const struct GNUNET_MESSENGER_Contact *contact)
Returns the blindable public key of a given contact.
void set_room_sender_id(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_ShortHashCode *id)
Sets the member id of the room's sender to a specific id or NULL.
struct GNUNET_MESSENGER_MessageId id
struct GNUNET_ShortHashCode id
The new id which will replace the senders id in a room.

References GNUNET_MESSENGER_Message::body, context, GNUNET_MESSENGER_RoomMessageEntry::flags, get_contact_key(), get_context_from_member(), get_handle_contact_store(), get_room_key(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_MESSENGER_FLAG_SENT, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageId::id, GNUNET_MESSENGER_MessageBody::id, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_RoomMessageEntry::sender, GNUNET_MESSENGER_MessageHeader::sender_id, set_room_sender_id(), and update_store_contact().

Referenced by handle_message().

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

◆ handle_miss_message()

static void handle_miss_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1473 of file messenger_api_room.c.

1476{
1477 struct GNUNET_MESSENGER_ListTunnel *match;
1478
1479 GNUNET_assert ((room) && (hash) && (entry));
1480
1481 if (0 == (GNUNET_MESSENGER_FLAG_SENT & entry->flags))
1482 return;
1483
1484 match = find_list_tunnels (
1485 &(room->entries),
1486 &(entry->message->body.miss.peer),
1487 NULL);
1488
1489 if (match)
1490 remove_from_list_tunnels (&(room->entries), match);
1491}
struct GNUNET_MESSENGER_ListTunnel * find_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index)
Searches linearly through the list of tunnels peer identities for matching a specific peer identity a...
struct GNUNET_MESSENGER_ListTunnel * remove_from_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element)
Removes a specific element from the list of tunnels peer identities and returns the next element in t...
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_PeerIdentity peer
The peer identity of a disconnected door to a room.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_Room::entries, find_list_tunnels(), GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_ListTunnel::hash, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessageMiss::peer, and remove_from_list_tunnels().

Referenced by handle_message().

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

◆ handle_merge_message()

static void handle_merge_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1495 of file messenger_api_room.c.

1498{
1499 GNUNET_assert ((room) && (hash) && (entry));
1500
1501 require_message_from_room (room, &(entry->message->body.merge.epochs[0]));
1502 require_message_from_room (room, &(entry->message->body.merge.epochs[1]));
1503}
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_HashCode epochs[2]
The previous epochs the message was sent from.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_MessageMerge::epochs, GNUNET_assert, GNUNET_MESSENGER_ListTunnel::hash, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_RoomMessageEntry::message, and require_message_from_room().

Referenced by handle_message().

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

◆ handle_private_message()

static void handle_private_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1507 of file messenger_api_room.c.

1510{
1511 const struct GNUNET_MESSENGER_RoomEncryptionKey *encryption_key;
1512 struct GNUNET_MESSENGER_Message *private_message;
1513
1514 GNUNET_assert ((room) && (hash) && (entry));
1515
1516 encryption_key = room->keys_tail;
1517
1518 if (! encryption_key)
1519 return;
1520
1521 private_message = copy_message (entry->message);
1522
1523 if (! private_message)
1524 return;
1525
1526 while (encryption_key)
1527 {
1528 if (GNUNET_YES == decrypt_message (private_message, &(encryption_key->key)))
1529 break;
1530
1531 encryption_key = encryption_key->prev;
1532 }
1533
1534 if (! encryption_key)
1535 {
1536 destroy_message (private_message);
1537 private_message = NULL;
1538 }
1539
1540 if (! private_message)
1541 return;
1542
1543 destroy_message (entry->message);
1544
1545 entry->recipient = get_handle_contact (room->handle, get_room_key (room));
1546
1547 entry->message = private_message;
1549
1550 if ((entry->sender) && (entry->recipient))
1551 handle_message (room, hash, entry);
1552}
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
enum GNUNET_GenericReturnValue decrypt_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_HpkePrivateKey *hpke_key)
Decrypts a private message using a given private key and replaces its body and kind with the inner en...
static void handle_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)

References copy_message(), decrypt_message(), destroy_message(), GNUNET_MESSENGER_RoomMessageEntry::flags, get_handle_contact(), get_room_key(), GNUNET_assert, GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_YES, GNUNET_MESSENGER_Room::handle, handle_message(), GNUNET_MESSENGER_RoomEncryptionKey::key, GNUNET_MESSENGER_Room::keys_tail, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_RoomEncryptionKey::prev, GNUNET_MESSENGER_RoomMessageEntry::recipient, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_message().

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

◆ handle_delete_message()

static void handle_delete_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1556 of file messenger_api_room.c.

1559{
1560 struct GNUNET_TIME_Relative delay;
1561
1562 GNUNET_assert ((room) && (hash) && (entry));
1563
1564 delay = get_message_timeout (entry->message);
1565
1566 delay_room_action (room, hash, delay);
1567}

References delay_room_action(), get_message_timeout(), GNUNET_assert, and GNUNET_MESSENGER_RoomMessageEntry::message.

Referenced by handle_message().

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

◆ handle_transcript_message()

static void handle_transcript_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1571 of file messenger_api_room.c.

1574{
1575 const struct GNUNET_HashCode *original_hash;
1576 struct GNUNET_MESSENGER_RoomMessageEntry *original;
1577 struct GNUNET_MESSENGER_Message *original_message;
1578
1579 GNUNET_assert ((room) && (hash) && (entry));
1580
1581 if (! (GNUNET_MESSENGER_FLAG_SENT & entry->flags))
1582 return;
1583
1584 original_hash = &(entry->message->body.transcript.hash);
1585
1586 original = GNUNET_CONTAINER_multihashmap_get (room->messages, original_hash);
1587
1588 if (original)
1589 goto read_transcript;
1590
1592
1593 if (! original)
1594 return;
1595
1596 original->sender = NULL;
1597 original->recipient = NULL;
1598
1599 original->message = NULL;
1601 original->completed = GNUNET_NO;
1602
1604 room->messages, original_hash, original,
1606 {
1607 GNUNET_free (original);
1608 return;
1609 }
1610
1611read_transcript:
1612 original_message = copy_message (entry->message);
1613
1614 if (! original_message)
1615 return;
1616
1617 if (GNUNET_YES != read_transcript_message (original_message))
1618 {
1619 destroy_message (original_message);
1620 return;
1621 }
1622
1623 {
1624 struct GNUNET_MESSENGER_ContactStore *store;
1625
1626 store = get_handle_contact_store (room->handle);
1627 original->recipient = get_store_contact (
1628 store, NULL,
1629 &(entry->message->body.transcript.key));
1630 }
1631
1632 if (original->message)
1633 {
1636
1637 copy_message_header (original_message, &(original->message->header));
1638 destroy_message (original->message);
1639 }
1640
1641 original->message = original_message;
1642
1643 link_room_message (room, hash, original_hash);
1644 link_room_message (room, original_hash, hash);
1645
1646 if ((original->sender) && (original->recipient))
1647 {
1649 handle_message (room, original_hash, original);
1650 }
1651}
@ GNUNET_MESSENGER_FLAG_NONE
The none flag.
void copy_message_header(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_MessageHeader *header)
Copy message header details from another message to a given message.
enum GNUNET_GenericReturnValue read_transcript_message(struct GNUNET_MESSENGER_Message *message)
Read the original message from a transcript message and replaces its body and kind with the inner enc...
void link_room_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *other)
Links a message identified by its hash inside a given room with another message identified by its oth...
struct GNUNET_MESSENGER_MessageTranscript transcript
struct GNUNET_HashCode hash
The hash of the original message.
struct GNUNET_CRYPTO_BlindablePublicKey key
The key from the recipient of the original message.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_RoomMessageEntry::completed, copy_message(), copy_message_header(), destroy_message(), GNUNET_MESSENGER_RoomMessageEntry::flags, get_handle_contact_store(), get_store_contact(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_free, GNUNET_MESSENGER_FLAG_NONE, GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_FLAG_UPDATE, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Room::handle, handle_message(), GNUNET_MESSENGER_MessageTranscript::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageTranscript::key, GNUNET_MESSENGER_MessageHeader::kind, link_room_message(), GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, read_transcript_message(), GNUNET_MESSENGER_RoomMessageEntry::recipient, GNUNET_MESSENGER_RoomMessageEntry::sender, and GNUNET_MESSENGER_MessageBody::transcript.

Referenced by handle_message().

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

◆ handle_announcement_message()

static void handle_announcement_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1655 of file messenger_api_room.c.

1658{
1659 struct GNUNET_MESSENGER_Epoch *epoch;
1660 const union GNUNET_MESSENGER_EpochNonce *nonce;
1661 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
1662 enum GNUNET_GenericReturnValue sent;
1663
1664 GNUNET_assert ((room) && (hash) && (entry));
1665
1666 epoch = get_room_availble_epoch_entry (room, hash, entry, NULL);
1667
1668 if (! epoch)
1669 return;
1670
1671 nonce = &(entry->message->body.announcement.nonce);
1672
1674 epoch->nonces, &(nonce->hash)))
1675 {
1677 "Unsafe announcement: Nonce (%s) has already been used in this epoch! [%s]\n",
1678 GNUNET_sh2s (&(nonce->hash)), GNUNET_h2s (&(epoch->hash)));
1679 return;
1680 }
1681
1682 GNUNET_CONTAINER_multishortmap_put (epoch->nonces, &(nonce->hash), NULL,
1684
1685 identifier = &(entry->message->body.announcement.identifier);
1686
1687 if (GNUNET_MESSENGER_FLAG_SENT & entry->flags)
1688 sent = GNUNET_YES;
1689 else
1690 sent = GNUNET_NO;
1691
1692 if (identifier->code.group_bit)
1693 {
1694 struct GNUNET_MESSENGER_EpochGroup *group;
1695
1697
1698 if (! group)
1699 return;
1700
1702 group,
1703 entry->message,
1704 hash,
1705 entry->sender,
1706 sent);
1707 }
1708 else
1709 {
1710 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
1711
1713
1714 if (! announcement)
1715 return;
1716
1718 announcement,
1719 entry->message,
1720 hash,
1721 entry->sender,
1722 sent);
1723 }
1724}
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
void handle_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Contact *sender, enum GNUNET_GenericReturnValue sent)
Handles an announcement message with hash from its sender inside a given epoch announcement as first ...
void handle_epoch_group_announcement(struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Contact *sender, enum GNUNET_GenericReturnValue sent)
Handles an announcement message with hash from its sender inside a given epoch group as first stage.
struct GNUNET_CONTAINER_MultiShortmap * nonces
union GNUNET_MESSENGER_EpochNonce nonce
The nonce of the announcement.
An epoch nonce unifies the epoch nonce data and its 256bit hash representation.
struct GNUNET_ShortHashCode hash

References GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, GNUNET_MESSENGER_EpochAnnouncement::epoch, GNUNET_MESSENGER_EpochGroup::epoch, GNUNET_MESSENGER_RoomMessageEntry::flags, get_epoch_announcement(), get_epoch_group(), get_room_availble_epoch_entry(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_contains(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_FLAG_SENT, GNUNET_NO, GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, handle_epoch_announcement(), handle_epoch_group_announcement(), GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_EpochNonce::hash, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_MessageAnnouncement::identifier, GNUNET_MESSENGER_EpochAnnouncement::identifier, GNUNET_MESSENGER_EpochGroup::identifier, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_MessageAnnouncement::nonce, GNUNET_MESSENGER_Epoch::nonces, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_message().

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

◆ handle_secret_message()

static void handle_secret_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1728 of file messenger_api_room.c.

1731{
1732 struct GNUNET_MESSENGER_Epoch *epoch;
1733 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
1734 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
1735
1736 GNUNET_assert ((room) && (hash) && (entry));
1737
1738 epoch = get_room_availble_epoch_entry (room, hash, entry, NULL);
1739
1740 if (! epoch)
1741 return;
1742
1744
1746 return;
1747
1749
1750 if (! announcement)
1751 return;
1752
1754 announcement, entry->message, hash);
1755}
void handle_epoch_announcement_message(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles an encrypted message with hash by a given epoch announcement using its secret key for decrypt...

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, GNUNET_MESSENGER_EpochAnnouncement::epoch, get_epoch_announcement(), get_room_availble_epoch_entry(), GNUNET_assert, GNUNET_NO, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, handle_epoch_announcement_message(), GNUNET_MESSENGER_MessageSecret::identifier, GNUNET_MESSENGER_EpochAnnouncement::identifier, GNUNET_MESSENGER_RoomMessageEntry::message, and GNUNET_MESSENGER_MessageBody::secret.

Referenced by handle_message().

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

◆ handle_appeal_message()

static void handle_appeal_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1759 of file messenger_api_room.c.

1762{
1763 const struct GNUNET_MESSENGER_RoomMessageEntry *event_entry;
1764 struct GNUNET_MESSENGER_Epoch *epoch;
1765 const struct GNUNET_MESSENGER_Contact *contact;
1766 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
1767 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
1769
1770 GNUNET_assert ((room) && (hash) && (entry));
1771
1772 event_entry = GNUNET_CONTAINER_multihashmap_get (
1773 room->messages, &(entry->message->body.appeal.event));
1774
1775 if (! event_entry)
1776 return;
1777
1779 return;
1780
1782 room, hash, event_entry, entry->sender);
1783
1784 if (! epoch)
1785 return;
1786
1787 contact = get_handle_contact (room->handle, get_room_key (room));
1788
1789 if (! contact)
1790 return;
1791
1792 if (GNUNET_YES != is_epoch_member (epoch, contact))
1793 return;
1794
1795 identifier = &(event_entry->message->body.announcement.identifier);
1796
1797 if (identifier->code.group_bit)
1798 return;
1799
1800 announcement = get_epoch_announcement (epoch, identifier, GNUNET_NO);
1801
1802 if (! announcement)
1803 return;
1804
1805 if (GNUNET_YES == is_epoch_announcement_member (announcement, entry->sender))
1806 {
1808 "Appealing contact is already member of epoch announcement! [%s]\n",
1809 GNUNET_sh2s (&(identifier->hash)));
1810 return;
1811 }
1812
1813 if (contact == event_entry->sender)
1815 else
1816 {
1818
1820 return;
1821
1823 timeout, get_epoch_position_factor (epoch, contact, NULL));
1824 }
1825
1826 if (GNUNET_MESSENGER_FLAG_SENT & entry->flags)
1827 set_epoch_announcement_appeal (announcement,
1828 get_message_timeout (entry->message));
1829
1830 delay_room_action (room, hash, timeout);
1831}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition gnunet-arm.c:118
bool GNUNET_TIME_relative_is_zero(struct GNUNET_TIME_Relative rel)
Test if rel is zero.
Definition time.c:660
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply_double(struct GNUNET_TIME_Relative rel, double factor)
Multiply relative time by a given factor.
Definition time.c:506
double get_epoch_position_factor(const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_MESSENGER_EpochMembership *membership)
Returns a relative member position of a specific contact inside a given epoch in relation to its list...
void set_epoch_announcement_appeal(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, struct GNUNET_TIME_Relative timeout)
Sets a specified timeout for a given epoch announcement of the client for its own appeal of the annou...

References GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_MessageBody::appeal, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, delay_room_action(), GNUNET_MESSENGER_MessageAppeal::event, GNUNET_MESSENGER_RoomMessageEntry::flags, get_epoch_announcement(), get_epoch_position_factor(), get_handle_contact(), get_message_timeout(), get_room_availble_epoch_entry(), get_room_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_NO, GNUNET_sh2s(), GNUNET_TIME_relative_get_zero_(), GNUNET_TIME_relative_is_zero(), GNUNET_TIME_relative_multiply_double(), GNUNET_YES, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageAnnouncement::identifier, is_epoch_announcement_member(), is_epoch_member(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_RoomMessageEntry::sender, set_epoch_announcement_appeal(), and timeout.

Referenced by handle_message().

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

◆ handle_access_message()

static void handle_access_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1835 of file messenger_api_room.c.

1838{
1839 const struct GNUNET_MESSENGER_RoomMessageEntry *event_entry;
1840 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
1841 struct GNUNET_MESSENGER_Epoch *epoch;
1842
1843 GNUNET_assert ((room) && (hash) && (entry));
1844
1845 if (! (GNUNET_MESSENGER_FLAG_RECENT & entry->flags))
1846 return;
1847
1848 event_entry = GNUNET_CONTAINER_multihashmap_get (
1849 room->messages, &(entry->message->body.access.event));
1850
1851 if (! event_entry)
1852 return;
1853
1854 switch (event_entry->message->header.kind)
1855 {
1857 {
1858 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
1859 enum GNUNET_GenericReturnValue appealed;
1860
1861 if (GNUNET_MESSENGER_FLAG_SENT & event_entry->flags)
1862 appealed = GNUNET_YES;
1863 else
1864 appealed = GNUNET_NO;
1865
1866 event_entry = GNUNET_CONTAINER_multihashmap_get (room->messages,
1867 &(event_entry->message->
1868 body.appeal.event));
1869
1870 if (! event_entry)
1871 return;
1872
1874 kind)
1875 return;
1876
1877 identifier = &(event_entry->message->body.announcement.identifier);
1878 epoch = get_room_availble_epoch_entry (room, hash, event_entry, entry->
1879 sender);
1880
1881 if (! epoch)
1882 return;
1883
1885
1886 if (! announcement)
1887 return;
1888
1889 if (GNUNET_YES != appealed)
1890 {
1891 const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key;
1892
1893 shared_key = get_epoch_announcement_key (announcement);
1894
1895 if ((shared_key) && (GNUNET_OK == verify_message_by_key (entry->message,
1896 shared_key)))
1897 cancel_room_action (room, &(entry->message->body.access.event));
1898
1899 return;
1900 }
1901
1902 handle_epoch_announcement_access (announcement, entry->message, hash);
1903 break;
1904 }
1906 {
1907 struct GNUNET_MESSENGER_EpochGroup *group;
1908 const struct GNUNET_HashCode *partner_hash;
1909 const struct GNUNET_MESSENGER_RoomMessageEntry *init_entry;
1910
1911 identifier = &(event_entry->message->body.group.identifier);
1912 epoch = get_room_availble_epoch_entry (room, hash, event_entry, entry->
1913 sender);
1914
1915 if (! epoch)
1916 return;
1917
1918 if ((epoch->main_announcement) &&
1919 (GNUNET_YES != is_epoch_identifier_upper (identifier, &(epoch->
1920 main_announcement
1921 ->identifier))
1922 ))
1923 return;
1924
1925 if ((epoch->main_group) &&
1926 (GNUNET_YES != is_epoch_identifier_upper (identifier, &(epoch->
1927 main_group->
1928 identifier))))
1929 return;
1930
1931 partner_hash = &(event_entry->message->body.group.partner);
1932 init_entry = GNUNET_CONTAINER_multihashmap_get (room->messages,
1933 &(event_entry->message->
1934 body.group.initiator));
1935
1936 if ((! init_entry) || (event_entry->sender != init_entry->sender))
1937 return;
1938
1940 )
1941 return;
1942
1943 event_entry = GNUNET_CONTAINER_multihashmap_get (room->messages,
1944 partner_hash);
1945
1946 if (! event_entry)
1947 return;
1948
1950 kind)
1951 return;
1952
1953 if (! (GNUNET_MESSENGER_FLAG_SENT & event_entry->flags))
1954 return;
1955
1956 {
1957 struct GNUNET_HashCode main_hash;
1958 enum GNUNET_GenericReturnValue has_hash;
1959
1960 if (epoch->main_group)
1961 has_hash = get_epoch_group_member_hash (epoch->main_group, &main_hash,
1962 GNUNET_NO);
1963 else if (epoch->main_announcement)
1964 has_hash = get_epoch_announcement_member_hash (epoch->
1965 main_announcement, &
1966 main_hash, GNUNET_NO);
1967 else
1968 return;
1969
1970 if ((GNUNET_OK != has_hash) ||
1971 (0 != GNUNET_CRYPTO_hash_cmp (&main_hash, partner_hash)))
1972 return;
1973 }
1974
1975 group = get_epoch_group (epoch, identifier, GNUNET_NO);
1976
1977 if (! group)
1978 return;
1979
1980 handle_epoch_group_access (group, entry->message, hash);
1981 break;
1982 }
1983 default:
1984 return;
1985 }
1986}
enum GNUNET_GenericReturnValue get_epoch_announcement_member_hash(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue other)
Provides an announcement hash of a member from a given epoch announcement.
void handle_epoch_announcement_access(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles an access message with hash from its sender inside a given epoch announcement.
void handle_epoch_group_access(struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles an access message with hash from its sender inside a given epoch group.
enum GNUNET_GenericReturnValue get_epoch_group_member_hash(const struct GNUNET_MESSENGER_EpochGroup *group, struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue other)
Provides an announcement hash of a member from a given epoch group.
enum GNUNET_GenericReturnValue verify_message_by_key(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Verifies the hmac of a given message body with a specific shared key.
static enum GNUNET_GenericReturnValue is_epoch_identifier_upper(const union GNUNET_MESSENGER_EpochIdentifier *identifier, const union GNUNET_MESSENGER_EpochIdentifier *other)
struct GNUNET_MESSENGER_EpochGroup * main_group
struct GNUNET_MESSENGER_EpochAnnouncement * main_announcement
struct GNUNET_HashCode event
The hash of the linked announcement or group message event.
struct GNUNET_HashCode partner
The hash of the partner group announcement.

References GNUNET_MESSENGER_MessageBody::access, GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_Message::body, cancel_room_action(), GNUNET_MESSENGER_EpochAnnouncement::epoch, GNUNET_MESSENGER_RoomMessageEntry::epoch, GNUNET_MESSENGER_MessageAccess::event, GNUNET_MESSENGER_RoomMessageEntry::flags, get_epoch_announcement(), get_epoch_announcement_key(), get_epoch_announcement_member_hash(), get_epoch_group(), get_epoch_group_member_hash(), get_room_availble_epoch_entry(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash_cmp(), GNUNET_MESSENGER_FLAG_RECENT, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_MESSENGER_KIND_APPEAL, GNUNET_MESSENGER_KIND_GROUP, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_MessageBody::group, handle_epoch_announcement_access(), handle_epoch_group_access(), GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageAnnouncement::identifier, GNUNET_MESSENGER_MessageGroup::identifier, GNUNET_MESSENGER_EpochAnnouncement::identifier, is_epoch_identifier_upper(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_Epoch::main_announcement, GNUNET_MESSENGER_Epoch::main_group, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_MessageGroup::partner, GNUNET_MESSENGER_Epoch::room, GNUNET_MESSENGER_RoomMessageEntry::sender, and verify_message_by_key().

Referenced by handle_message().

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

◆ handle_revolution_message()

static void handle_revolution_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 1990 of file messenger_api_room.c.

1993{
1994 struct GNUNET_MESSENGER_Epoch *epoch;
1995 const union GNUNET_MESSENGER_EpochNonce *nonce;
1996 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
1997
1998 GNUNET_assert ((room) && (hash) && (entry));
1999
2000 epoch = get_room_availble_epoch_entry (room, hash, entry, entry->sender);
2001
2002 if (! epoch)
2003 return;
2004
2005 nonce = &(entry->message->body.announcement.nonce);
2006
2008 nonce->hash)))
2009 {
2011 "Unsafe revolution: Nonce (%s) has already been used in this epoch! [%s]\n",
2012 GNUNET_sh2s (&(nonce->hash)), GNUNET_h2s (&(epoch->hash)));
2013 return;
2014 }
2015
2016 GNUNET_CONTAINER_multishortmap_put (epoch->nonces, &(nonce->hash), NULL,
2018
2019 identifier = &(entry->message->body.revolution.identifier);
2020
2021 if (identifier->code.group_bit)
2022 {
2023 struct GNUNET_MESSENGER_EpochGroup *group;
2025
2026 group = get_epoch_group (epoch, identifier, GNUNET_YES);
2027
2028 if (! group)
2029 return;
2030
2031 key = get_epoch_group_key (group);
2032
2033 if (! key)
2034 return;
2035
2036 if (GNUNET_OK != verify_message_by_key (entry->message, key))
2037 return;
2038
2039 invalidate_epoch_group (group, NULL);
2040 }
2041 else
2042 {
2043 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
2045
2046 announcement = get_epoch_announcement (epoch, identifier, GNUNET_YES);
2047
2048 if (! announcement)
2049 return;
2050
2051 key = get_epoch_announcement_key (announcement);
2052
2053 if (! key)
2054 return;
2055
2056 if (GNUNET_OK != verify_message_by_key (entry->message, key))
2057 return;
2058
2059 invalidate_epoch_announcement (announcement, NULL);
2060 }
2061}
void invalidate_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_Contact *contact)
Invalidates a given epoch announcement by a specific contact.
void invalidate_epoch_group(struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_MESSENGER_Contact *contact)
Invalidates a given epoch group by a specific contact.
const struct GNUNET_CRYPTO_SymmetricSessionKey * get_epoch_group_key(const struct GNUNET_MESSENGER_EpochGroup *group)
Returns the secret key of a given epoch group or NULL.

References GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, get_epoch_announcement(), get_epoch_announcement_key(), get_epoch_group(), get_epoch_group_key(), get_room_availble_epoch_entry(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_contains(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_EpochNonce::hash, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_MessageRevolution::identifier, invalidate_epoch_announcement(), invalidate_epoch_group(), key, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_MessageAnnouncement::nonce, GNUNET_MESSENGER_Epoch::nonces, GNUNET_MESSENGER_MessageBody::revolution, GNUNET_MESSENGER_RoomMessageEntry::sender, and verify_message_by_key().

Referenced by handle_message().

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

◆ handle_group_message()

static void handle_group_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 2065 of file messenger_api_room.c.

2068{
2069 struct GNUNET_MESSENGER_Epoch *epoch;
2070 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
2071 struct GNUNET_MESSENGER_EpochGroup *group;
2072
2073 GNUNET_assert ((room) && (hash) && (entry));
2074
2075 epoch = get_room_availble_epoch_entry (room, hash, entry, entry->sender);
2076
2077 if (! epoch)
2078 return;
2079
2080 identifier = &(entry->message->body.group.identifier);
2082
2083 if (! (GNUNET_MESSENGER_FLAG_SENT & entry->flags))
2084 return;
2085
2087
2088 set_epoch_group_key (group, NULL, GNUNET_YES);
2089 send_epoch_group_access (group, hash);
2090}
void set_epoch_proposal_group(struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_HashCode *hash)
Sets the current group of proposal for a given epoch to the group specified by a message identified b...
enum GNUNET_GenericReturnValue send_epoch_group_access(struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_HashCode *event)
Tries to send an access message by the client responding to a previous event in regards to a given ep...
void set_epoch_group_key(struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key, enum GNUNET_GenericReturnValue write_record)
Sets the secret key of a given epoch group to a shared key.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochGroup::epoch, GNUNET_MESSENGER_RoomMessageEntry::flags, get_epoch_group(), get_room_availble_epoch_entry(), GNUNET_assert, GNUNET_MESSENGER_FLAG_SENT, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_MessageBody::group, GNUNET_MESSENGER_MessageGroup::identifier, GNUNET_MESSENGER_EpochGroup::identifier, GNUNET_MESSENGER_RoomMessageEntry::message, send_epoch_group_access(), GNUNET_MESSENGER_RoomMessageEntry::sender, set_epoch_group_key(), and set_epoch_proposal_group().

Referenced by handle_message().

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

◆ handle_authorization_message()

static void handle_authorization_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
struct GNUNET_MESSENGER_RoomMessageEntry entry 
)
static

Definition at line 2094 of file messenger_api_room.c.

2097{
2098 struct GNUNET_MESSENGER_Epoch *epoch;
2099 const union GNUNET_MESSENGER_EpochIdentifier *identifier;
2100 struct GNUNET_MESSENGER_EpochGroup *auth_group;
2101 const struct GNUNET_CRYPTO_SymmetricSessionKey *group_key;
2102 const struct GNUNET_MESSENGER_RoomMessageEntry *event_entry;
2103 struct GNUNET_CRYPTO_SymmetricSessionKey shared_key;
2104
2105 GNUNET_assert ((room) && (hash) && (entry));
2106
2107 epoch = get_room_availble_epoch_entry (room, hash, entry, entry->sender);
2108
2109 if (! epoch)
2110 return;
2111
2112 identifier = &(entry->message->body.authorization.identifier);
2113 auth_group = get_epoch_group (epoch, identifier, GNUNET_NO);
2114
2115 if (! auth_group)
2116 return;
2117
2118 group_key = get_epoch_group_key (auth_group);
2119
2120 if (! group_key)
2121 return;
2122
2123 event_entry = GNUNET_CONTAINER_multihashmap_get (
2124 room->messages, &(entry->message->body.authorization.event));
2125
2126 if (! event_entry)
2127 return;
2128
2129 switch (event_entry->message->header.kind)
2130 {
2132 {
2133 identifier = &(event_entry->message->body.announcement.identifier);
2134
2135 if (0 == GNUNET_memcmp (identifier, &(auth_group->identifier)))
2136 return;
2137
2138 if (identifier->code.group_bit)
2139 {
2140 struct GNUNET_MESSENGER_EpochGroup *group;
2141 uint32_t next_level;
2142
2144 identifier, &(auth_group->identifier)))
2145 return;
2146
2148
2149 if (! group)
2150 return;
2151
2152 next_level = get_epoch_group_level (auth_group) + 1;
2153
2154 if (next_level != get_epoch_group_level (group))
2155 return;
2156
2158 entry->message, group_key, &shared_key))
2159 return;
2160
2161 if (get_epoch_group_key (group))
2162 return;
2163
2166 }
2167 else
2168 {
2169 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
2170
2172
2173 if (! announcement)
2174 return;
2175
2177 entry->message, group_key, &shared_key))
2178 return;
2179
2181 event_entry->message, &shared_key))
2182 return;
2183
2184 if (get_epoch_announcement_key (announcement))
2185 return;
2186
2188 send_epoch_announcement (announcement);
2189 }
2190
2191 break;
2192 }
2194 {
2195 struct GNUNET_MESSENGER_EpochGroup *group;
2196 const struct GNUNET_HashCode *announcement_hash;
2197 uint32_t next_level;
2198
2199 identifier = &(event_entry->message->body.group.identifier);
2200
2201 if ((0 == GNUNET_memcmp (identifier, &(auth_group->identifier))) ||
2202 (GNUNET_YES != is_epoch_identifier_upper (identifier, &(auth_group->
2203 identifier))))
2204 return;
2205
2206 if (! (identifier->code.group_bit))
2207 return;
2208
2209 group = get_epoch_group (epoch, identifier, GNUNET_NO);
2210
2211 if (! group)
2212 return;
2213
2214 next_level = get_epoch_group_level (auth_group) + 1;
2215
2216 if (next_level != get_epoch_group_level (group))
2217 return;
2218
2219 if (event_entry->sender == entry->sender)
2220 announcement_hash = &(event_entry->message->body.group.initiator);
2221 else
2222 announcement_hash = &(event_entry->message->body.group.partner);
2223
2224 event_entry = GNUNET_CONTAINER_multihashmap_get (room->messages,
2225 announcement_hash);
2226
2227 if (! event_entry)
2228 return;
2229
2231 kind)
2232 return;
2233
2234 identifier = &(event_entry->message->body.announcement.identifier);
2235
2236 if (0 != GNUNET_memcmp (identifier, &(auth_group->identifier)))
2237 return;
2238
2240 entry->message, group_key, &shared_key))
2241 return;
2242
2243 if (get_epoch_group_key (group))
2244 return;
2245
2246 set_epoch_group_key (group, &shared_key, GNUNET_YES);
2248 break;
2249 }
2250 default:
2251 break;
2252 }
2253}
enum GNUNET_GenericReturnValue send_epoch_group_announcement(struct GNUNET_MESSENGER_EpochGroup *group)
Tries to send an announcement message by the client for a given epoch group using its secret key.
uint32_t get_epoch_group_level(const struct GNUNET_MESSENGER_EpochGroup *group)
Returns the group level of a given epoch group.
enum GNUNET_GenericReturnValue extract_authorization_message_key(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_SymmetricSessionKey *key, struct GNUNET_CRYPTO_SymmetricSessionKey *shared_key)
Extracts the shared epoch or group key from an authorization message using a previously exchanged sha...
struct GNUNET_CRYPTO_SymmetricSessionKey * shared_key
struct GNUNET_CRYPTO_SymmetricSessionKey * shared_key
struct GNUNET_HashCode event
The hash of the linked group message event.
struct GNUNET_HashCode initiator
The hash of the initiator group announcement.

References GNUNET_MESSENGER_MessageBody::announcement, GNUNET_MESSENGER_MessageBody::authorization, GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, GNUNET_MESSENGER_EpochAnnouncement::epoch, GNUNET_MESSENGER_EpochGroup::epoch, GNUNET_MESSENGER_MessageAuthorization::event, extract_authorization_message_key(), get_epoch_announcement(), get_epoch_announcement_key(), get_epoch_group(), get_epoch_group_key(), get_epoch_group_level(), get_room_availble_epoch_entry(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_memcmp, GNUNET_MESSENGER_KIND_ANNOUNCEMENT, GNUNET_MESSENGER_KIND_GROUP, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_MessageBody::group, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageAnnouncement::identifier, GNUNET_MESSENGER_MessageGroup::identifier, GNUNET_MESSENGER_MessageAuthorization::identifier, GNUNET_MESSENGER_EpochAnnouncement::identifier, GNUNET_MESSENGER_EpochGroup::identifier, GNUNET_MESSENGER_MessageGroup::initiator, is_epoch_identifier_upper(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_MessageGroup::partner, send_epoch_announcement(), send_epoch_group_announcement(), GNUNET_MESSENGER_RoomMessageEntry::sender, set_epoch_announcement_key(), set_epoch_group_key(), GNUNET_MESSENGER_EpochAnnouncement::shared_key, GNUNET_MESSENGER_EpochGroup::shared_key, and verify_message_by_key().

Referenced by handle_message().

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

◆ handle_room_message()

void handle_room_message ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Contact sender,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash,
const struct GNUNET_HashCode epoch,
enum GNUNET_MESSENGER_MessageFlags  flags 
)

Handles a message with a given hash in a room for the client API to update members and its information.

The function also stores the message in map locally for access afterwards.

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...)

Parameters
[in,out]roomRoom
[in,out]senderContact of sender
[in]messageMessage
[in]hashHash of message
[in]epochHash of epoch
[in]flagsFlags of message

Definition at line 2338 of file messenger_api_room.c.

2344{
2346
2347 GNUNET_assert ((room) && (message) && (hash));
2348
2349 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
2350
2351 if (entry)
2352 goto update_entry;
2353
2355
2356 if (! entry)
2357 return;
2358
2359 entry->sender = NULL;
2360 entry->recipient = NULL;
2361
2362 entry->message = NULL;
2363
2364 GNUNET_memcpy (&(entry->epoch), epoch, sizeof (entry->epoch));
2365
2367 entry->completed = GNUNET_NO;
2368
2370 room->messages, hash, entry,
2372 {
2373 GNUNET_free (entry);
2374 return;
2375 }
2376
2377update_entry:
2378 entry->sender = sender;
2379 entry->flags = flags;
2380
2381 if (entry->message)
2382 {
2385
2387 }
2388 else
2389 entry->message = copy_message (message);
2390
2391 entry->completed = GNUNET_YES;
2392 handle_message (room, hash, entry);
2393}

References GNUNET_MESSENGER_RoomMessageEntry::completed, copy_message(), copy_message_header(), GNUNET_MESSENGER_RoomMessageEntry::epoch, GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_free, GNUNET_memcpy, GNUNET_MESSENGER_FLAG_NONE, GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_RoomMessageEntry::recipient, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_message_control().

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

◆ update_room_message()

enum GNUNET_GenericReturnValue update_room_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Updates any message with a given hash in a room for the client API to force handling the message again after some changes that might affect it.

Parameters
[in,out]roomRoom
[in]hashHash of message
Returns
GNUNET_YES if successful, GNUNET_NO on failure and otherwise GNUNET_SYSERR

Definition at line 2397 of file messenger_api_room.c.

2399{
2401
2402 GNUNET_assert ((room) && (hash));
2403
2404 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
2405
2406 if ((! entry) || (! entry->message))
2407 return GNUNET_SYSERR;
2408
2410 return GNUNET_NO;
2411
2413 handle_message (room, hash, entry);
2414 return GNUNET_YES;
2415}

References GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_FLAG_UPDATE, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, handle_message(), GNUNET_MESSENGER_RoomMessageEntry::message, and GNUNET_MESSENGER_Room::messages.

Here is the call graph for this function:

◆ update_room_secret_message()

enum GNUNET_GenericReturnValue update_room_secret_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_CRYPTO_SymmetricSessionKey key,
enum GNUNET_GenericReturnValue  update 
)

Updates a secret message with a given hash in a room for the client API trying to decrypt it with the given epoch key from an epoch announcement.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]keyEpoch key
[in]updateFlag message as update on success
Returns
GNUNET_YES if successful, GNUNET_NO on failure and otherwise GNUNET_SYSERR

Definition at line 2419 of file messenger_api_room.c.

2423{
2425 struct GNUNET_MESSENGER_Message *secret_message;
2426
2427 GNUNET_assert ((room) && (hash) && (key));
2428
2429 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
2430
2431 if ((! entry) || (! entry->message) ||
2433 return GNUNET_SYSERR;
2434
2435 secret_message = copy_message (entry->message);
2436
2437 if (! secret_message)
2438 return GNUNET_NO;
2439
2440 if (GNUNET_YES != decrypt_secret_message (secret_message, key))
2441 {
2442 destroy_message (secret_message);
2443 secret_message = NULL;
2444 }
2445
2446 if (! secret_message)
2447 return GNUNET_NO;
2448
2449 destroy_message (entry->message);
2450
2451 entry->message = secret_message;
2453
2454 if (GNUNET_YES == update)
2456
2457 if (entry->sender)
2458 handle_message (room, hash, entry);
2459
2460 return GNUNET_YES;
2461}
@ GNUNET_MESSENGER_FLAG_SECRET
The secret flag.
enum GNUNET_GenericReturnValue decrypt_secret_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Decrypts a secret message using a given shared key and replaces its body and kind with the inner encr...

References copy_message(), decrypt_secret_message(), destroy_message(), GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_MESSENGER_FLAG_SECRET, GNUNET_MESSENGER_FLAG_UPDATE, GNUNET_MESSENGER_KIND_SECRET, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, handle_message(), GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, and GNUNET_MESSENGER_RoomMessageEntry::sender.

Referenced by handle_secret_message_with_key().

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

◆ update_room_last_message()

void update_room_last_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_HashCode epoch 
)

Updates the last message hash and its epoch of a room for the client API so that new messages can point to the latest message hash while sending.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]epochHash of epoch

Definition at line 2465 of file messenger_api_room.c.

2468{
2469 GNUNET_assert ((room) && (hash) && (epoch));
2470
2471 GNUNET_memcpy (&(room->last_message), hash, sizeof(room->last_message));
2472
2473 if (epoch)
2474 GNUNET_memcpy (&(room->last_epoch), epoch, sizeof(room->last_epoch));
2475}

References GNUNET_assert, GNUNET_memcpy, GNUNET_MESSENGER_Room::last_epoch, and GNUNET_MESSENGER_Room::last_message.

Referenced by handle_message_control(), handle_room_close(), handle_room_entry(), handle_room_open(), handle_room_sync(), and send_message_to_room().

Here is the caller graph for this function:

◆ copy_room_last_message()

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

Copies the last message hash of a room into a given hash variable.

Parameters
[in]roomRoom
[out]hashHash of message

Definition at line 2479 of file messenger_api_room.c.

2481{
2482 GNUNET_assert (room);
2483
2484 GNUNET_memcpy (hash, &(room->last_message), sizeof(room->last_message));
2485}

References GNUNET_assert, GNUNET_memcpy, and GNUNET_MESSENGER_Room::last_message.

Referenced by send_close_room(), send_enter_room(), send_message_to_room(), send_open_room(), and send_sync_room().

Here is the caller graph for this function:

◆ iterate_local_members()

static enum GNUNET_GenericReturnValue iterate_local_members ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 2496 of file messenger_api_room.c.

2499{
2501 struct GNUNET_MESSENGER_Contact *contact;
2502
2503 GNUNET_assert ((cls) && (value));
2504
2505 call = cls;
2506 contact = value;
2507
2508 return call->callback (call->cls, call->room, contact);
2509}
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).

References call, GNUNET_assert, and value.

Referenced by iterate_room_members().

Here is the caller graph for this function:

◆ iterate_room_members()

int iterate_room_members ( struct GNUNET_MESSENGER_Room room,
GNUNET_MESSENGER_MemberCallback  callback,
void *  cls 
)

Iterates through all members of a given room to forward each of them to a selected callback with a custom closure.

Parameters
[in,out]roomRoom
[in]callbackFunction called for each member
[in,out]clsClosure
Returns
Amount of members iterated

Definition at line 2513 of file messenger_api_room.c.

2516{
2518
2520
2521 if (! callback)
2523
2524 call.room = room;
2525 call.callback = callback;
2526 call.cls = cls;
2527
2529
2532 &call);
2533}
static enum GNUNET_GenericReturnValue iterate_local_members(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
GNUNET_MESSENGER_MemberCallback callback
struct GNUNET_MESSENGER_Room * room

References call, GNUNET_MESSENGER_MemberCall::callback, GNUNET_MESSENGER_MemberCall::cls, GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), iterate_local_members(), GNUNET_MESSENGER_Room::members, and GNUNET_MESSENGER_MemberCall::room.

Referenced by GNUNET_MESSENGER_iterate_members().

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

◆ iterate_find_member()

static enum GNUNET_GenericReturnValue iterate_find_member ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

Definition at line 2543 of file messenger_api_room.c.

2546{
2547 struct GNUNET_MESSENGER_MemberFind *find;
2548 struct GNUNET_MESSENGER_Contact *contact;
2549
2550 GNUNET_assert ((cls) && (value));
2551
2552 find = cls;
2553 contact = value;
2554
2555 if (contact == find->contact)
2556 {
2557 find->result = GNUNET_YES;
2558 return GNUNET_NO;
2559 }
2560
2561 return GNUNET_YES;
2562}
const struct GNUNET_MESSENGER_Contact * contact
enum GNUNET_GenericReturnValue result

References GNUNET_MESSENGER_MemberFind::contact, GNUNET_assert, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_MemberFind::result, and value.

Referenced by find_room_member().

Here is the caller graph for this function:

◆ find_room_member()

enum GNUNET_GenericReturnValue find_room_member ( const struct GNUNET_MESSENGER_Room room,
const struct GNUNET_MESSENGER_Contact contact 
)

Checks through all members of a given room if a specific contact is found and returns a result depending on that.

Parameters
[in]roomRoom
[in]contact
Returns
GNUNET_YES if found, otherwise GNUNET_NO

Definition at line 2566 of file messenger_api_room.c.

2568{
2569 struct GNUNET_MESSENGER_MemberFind find;
2570
2571 GNUNET_assert (room);
2572
2573 find.contact = contact;
2574 find.result = GNUNET_NO;
2575
2577 room->members, iterate_find_member, &find);
2578
2579 return find.result;
2580}
static enum GNUNET_GenericReturnValue iterate_find_member(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References GNUNET_MESSENGER_MemberFind::contact, GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_NO, iterate_find_member(), GNUNET_MESSENGER_Room::members, and GNUNET_MESSENGER_MemberFind::result.

Referenced by iterate_find_room().

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

◆ find_linked_hash()

static enum GNUNET_GenericReturnValue find_linked_hash ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 2584 of file messenger_api_room.c.

2587{
2588 const struct GNUNET_HashCode **result;
2589 struct GNUNET_HashCode *hash;
2590
2591 GNUNET_assert ((cls) && (value));
2592
2593 result = cls;
2594 hash = value;
2595
2596 if (0 == GNUNET_CRYPTO_hash_cmp (hash, *result))
2597 {
2598 *result = NULL;
2599 return GNUNET_NO;
2600 }
2601
2602 return GNUNET_YES;
2603}
static int result
Global testing status.

References GNUNET_assert, GNUNET_CRYPTO_hash_cmp(), GNUNET_NO, GNUNET_YES, result, and value.

Referenced by link_room_message().

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

◆ link_room_message()

void link_room_message ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_HashCode other 
)

Links a message identified by its hash inside a given room with another message identified by its other hash.

Linked messages will be deleted automatically, if any linked message to it gets deleted.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]otherHash of other message

Definition at line 2607 of file messenger_api_room.c.

2610{
2611 const struct GNUNET_HashCode **result;
2612 struct GNUNET_HashCode *value;
2613
2614 GNUNET_assert ((room) && (hash) && (other));
2615
2616 result = &other;
2619
2620 if (! *result)
2621 return;
2622
2623 value = GNUNET_memdup (other, sizeof(struct GNUNET_HashCode));
2624 if (! value)
2625 return;
2626
2628 room->links, hash, value,
2631}
#define GNUNET_memdup(buf, size)
Allocate and initialize a block of memory.
static enum GNUNET_GenericReturnValue find_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)

References find_linked_hash(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_free, GNUNET_memdup, GNUNET_OK, GNUNET_MESSENGER_Room::links, result, and value.

Referenced by dequeue_message_from_room(), and handle_transcript_message().

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

◆ clear_linked_hash()

static enum GNUNET_GenericReturnValue clear_linked_hash ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 2643 of file messenger_api_room.c.

2646{
2647 struct GNUNET_HashCode **linked;
2648 struct GNUNET_HashCode *hash;
2649
2650 GNUNET_assert ((cls) && (value));
2651
2652 linked = cls;
2653 hash = value;
2654
2655 if (0 != GNUNET_CRYPTO_hash_cmp (*linked, hash))
2656 return GNUNET_YES;
2657
2658 *linked = hash;
2659 return GNUNET_NO;
2660}

References GNUNET_assert, GNUNET_CRYPTO_hash_cmp(), GNUNET_NO, GNUNET_YES, and value.

Referenced by delete_linked_hash().

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

◆ delete_linked_hash()

static enum GNUNET_GenericReturnValue delete_linked_hash ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Definition at line 2664 of file messenger_api_room.c.

2667{
2669 struct GNUNET_HashCode *hash;
2670 struct GNUNET_HashCode key_value;
2671 struct GNUNET_HashCode *linked;
2672
2673 GNUNET_assert ((cls) && (key) && (value));
2674
2675 info = cls;
2676 hash = value;
2677
2678 GNUNET_memcpy (&key_value, key, sizeof (key_value));
2679
2680 linked = &key_value;
2682 clear_linked_hash, &linked);
2683
2684 if ((linked != &key_value) &&
2686 hash, linked)))
2687 GNUNET_free (linked);
2688
2689 if (info->deletion)
2690 info->deletion (info->room, hash, info->delay);
2691
2692 GNUNET_free (hash);
2693 return GNUNET_YES;
2694}
#define info
static enum GNUNET_GenericReturnValue clear_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)

References clear_linked_hash(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_memcpy, GNUNET_YES, info, key, and value.

Referenced by link_room_deletion().

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

◆ link_room_deletion()

void link_room_deletion ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay,
GNUNET_MESSENGER_RoomLinkDeletion  deletion 
)

Delete all remaining links to a certain message identified by its hash inside a given room and cause a deletion process to all of the linked messages.

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]delayDelay for linked deletion
[in]deletionFunction called for each linked deletion

Definition at line 2698 of file messenger_api_room.c.

2702{
2704
2705 GNUNET_assert ((room) && (hash));
2706
2707 info.room = room;
2708 info.delay = delay;
2709 info.deletion = deletion;
2710
2714}
static enum GNUNET_GenericReturnValue delete_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_MESSENGER_Room * room
GNUNET_MESSENGER_RoomLinkDeletion deletion

References GNUNET_MESSENGER_RoomLinkDeletionInfo::delay, delete_linked_hash(), GNUNET_MESSENGER_RoomLinkDeletionInfo::deletion, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_remove_all(), info, GNUNET_MESSENGER_Room::links, and GNUNET_MESSENGER_RoomLinkDeletionInfo::room.

Referenced by handle_room_delayed_deletion().

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