GNUnet 0.21.2
messenger_api_room.c File Reference
Include dependency graph for messenger_api_room.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_MemberCall
 
struct  GNUNET_MESSENGER_MemberFind
 
struct  GNUNET_MESSENGER_RoomLinkDeletionInfo
 

Functions

struct GNUNET_MESSENGER_Roomcreate_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
 Creates and allocates a new room for a handle with a given key for the client API. More...
 
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)
 
void destroy_room (struct GNUNET_MESSENGER_Room *room)
 Destroys a room and frees its memory fully from the client API. More...
 
enum GNUNET_GenericReturnValue is_room_available (const struct GNUNET_MESSENGER_Room *room)
 Checks whether a room is available to send messages. More...
 
struct GNUNET_MESSENGER_Handleget_room_handle (struct GNUNET_MESSENGER_Room *room)
 Returns the messenger handle of the room. More...
 
const struct GNUNET_ShortHashCodeget_room_sender_id (const struct GNUNET_MESSENGER_Room *room)
 Returns the member id of the room's sender. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
static void handle_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
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_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_private_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
 
void delete_message_in_room (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 
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)
 
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, 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. More...
 
void update_room_last_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Updates the last message hash of a room for the client API so that new messages can point to the latest message hash while sending. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ create_room()

struct GNUNET_MESSENGER_Room * create_room ( struct GNUNET_MESSENGER_Handle handle,
const struct GNUNET_HashCode 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 40 of file messenger_api_room.c.

42{
43 GNUNET_assert ((handle) && (key));
44
45 struct GNUNET_MESSENGER_Room *room = GNUNET_new (struct
47
48 room->handle = handle;
49 GNUNET_memcpy (&(room->key), key, sizeof(*key));
50
51 memset (&(room->last_message), 0, sizeof(room->last_message));
52
53 room->opened = GNUNET_NO;
56
57 room->sender_id = NULL;
58
59 init_list_tunnels (&(room->entries));
60
64
66
67 init_queue_messages (&(room->queue));
68 room->queue_task = NULL;
69
70 room->control = create_message_control (room);
71
72 return room;
73}
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_CONTAINER_MultiShortmap * subscriptions
struct GNUNET_MESSENGER_Handle * handle
enum GNUNET_GenericReturnValue opened
enum GNUNET_GenericReturnValue wait_for_sync
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_MESSENGER_MessageControl * control
struct GNUNET_SCHEDULER_Task * queue_task
struct GNUNET_CONTAINER_MultiHashMap * messages
enum GNUNET_GenericReturnValue use_handle_name
struct GNUNET_MESSENGER_QueueMessages queue
struct GNUNET_MESSENGER_ListTunnels entries
struct GNUNET_ShortHashCode * sender_id
struct GNUNET_HashCode key
struct GNUNET_HashCode last_message

References GNUNET_MESSENGER_Room::control, create_message_control(), GNUNET_MESSENGER_Room::entries, 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(), key, GNUNET_MESSENGER_Room::key, 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::sender_id, GNUNET_MESSENGER_Room::subscriptions, GNUNET_MESSENGER_Room::use_handle_name, and GNUNET_MESSENGER_Room::wait_for_sync.

Referenced by GNUNET_MESSENGER_enter_room(), and GNUNET_MESSENGER_open_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 77 of file messenger_api_room.c.

80{
82
83 destroy_message (entry->message);
84 GNUNET_free (entry);
85
86 return GNUNET_YES;
87}
static char * value
Value of the record to add/remove.
#define GNUNET_free(ptr)
Wrapper around free.
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_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 91 of file messenger_api_room.c.

94{
95 struct GNUNET_HashCode *hash = value;
96 GNUNET_free (hash);
97 return GNUNET_YES;
98}
A 512-bit hashcode.

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

105{
106 struct GNUNET_MESSENGER_RoomSubscription *subscription = value;
107
108 if (subscription->task)
109 GNUNET_SCHEDULER_cancel (subscription->task);
110
111 if (subscription->message)
112 destroy_message (subscription->message);
113
114 GNUNET_free (subscription);
115 return GNUNET_YES;
116}
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
struct GNUNET_SCHEDULER_Task * task
struct GNUNET_MESSENGER_Message * message

References destroy_message(), 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:

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

121{
122 GNUNET_assert (room);
123
125
126 if (room->queue_task)
128
129 clear_queue_messages (&(room->queue));
130 clear_list_tunnels (&(room->entries));
131
132 if (room->subscriptions)
133 {
136 NULL);
137
139 }
140
141 if (room->messages)
142 {
145
147 }
148
149 if (room->members)
151
152 if (room->links)
153 {
156
158 }
159
160 if (room->sender_id)
161 GNUNET_free (room->sender_id);
162
163 GNUNET_free (room);
164}
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 enum GNUNET_GenericReturnValue iterate_destroy_subscription(void *cls, const struct GNUNET_ShortHashCode *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 clear_list_tunnels(), clear_queue_messages(), GNUNET_MESSENGER_Room::control, destroy_message_control(), GNUNET_MESSENGER_Room::entries, 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_link(), iterate_destroy_message(), iterate_destroy_subscription(), GNUNET_MESSENGER_Room::links, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_Room::queue, GNUNET_MESSENGER_Room::queue_task, GNUNET_MESSENGER_RoomSubscription::room, GNUNET_MESSENGER_Room::sender_id, and GNUNET_MESSENGER_Room::subscriptions.

Referenced by close_handle_room(), GNUNET_MESSENGER_enter_room(), GNUNET_MESSENGER_open_room(), and iterate_destroy_room().

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

169{
170 GNUNET_assert (room);
171
172 if (! get_room_sender_id (room))
173 return GNUNET_NO;
174
175 if ((GNUNET_YES == room->opened) || (room->entries.head))
176 return GNUNET_YES;
177 else
178 return GNUNET_NO;
179}
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, GNUNET_MESSENGER_Room::opened, and GNUNET_MESSENGER_RoomSubscription::room.

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

184{
185 GNUNET_assert (room);
186
187 return room->handle;
188}

References GNUNET_assert, and GNUNET_MESSENGER_Room::handle.

Referenced by process_message_control(), and task_message_control().

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

193{
194 GNUNET_assert (room);
195
196 return room->sender_id;
197}

References GNUNET_assert, and GNUNET_MESSENGER_Room::sender_id.

Referenced by get_handle_contact(), handle_member_id(), handle_miss_message(), 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 201 of file messenger_api_room.c.

203{
204 GNUNET_assert (room);
205
206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Set member id for room: %s\n",
207 GNUNET_h2s (&(room->key)));
208
209 if (! id)
210 {
211 if (room->sender_id)
212 GNUNET_free (room->sender_id);
213
214 room->sender_id = NULL;
215 return;
216 }
217
218 if (! room->sender_id)
220
221 GNUNET_memcpy (room->sender_id, id, sizeof(struct GNUNET_ShortHashCode));
222}
#define GNUNET_log(kind,...)
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 GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_MESSENGER_Room::key, 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_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 226 of file messenger_api_room.c.

228{
229 GNUNET_assert ((room) && (hash));
230
233 room->messages, hash);
234
235 if ((! entry) || (GNUNET_YES != entry->completed))
236 return NULL;
237
238 return entry->message;
239}
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 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 GNUNET_MESSENGER_get_message().

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

245{
246 GNUNET_assert ((room) && (hash));
247
250 room->messages, hash);
251
252 if ((! entry) || (GNUNET_YES != entry->completed))
253 return NULL;
254
255 return entry->sender;
256}
struct GNUNET_MESSENGER_Contact * sender

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

Referenced by GNUNET_MESSENGER_get_sender().

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

262{
263 GNUNET_assert ((room) && (hash));
264
267 room->messages, hash);
268
269 if ((! entry) || (GNUNET_YES != entry->completed))
270 return NULL;
271
272 return entry->recipient;
273}
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:

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

279{
280 GNUNET_assert ((room) && (hash));
281
282 struct GNUNET_MESSENGER_Handle *handle = room->handle;
283
284 if (! handle)
285 return;
286
288 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
289
290 if (! entry)
291 return;
292
293 if (handle->msg_callback)
294 handle->msg_callback (handle->msg_cls, room,
295 entry->sender,
296 entry->recipient,
297 entry->message,
298 hash,
299 entry->flags);
300
303}
@ GNUNET_MESSENGER_FLAG_UPDATE
The update flag.
enum GNUNET_MESSENGER_MessageFlags flags

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_delete_message(), handle_message(), and handle_message_control().

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

644{
645 GNUNET_assert ((room) && (hash) && (entry));
646
647 switch (entry->message->header.kind)
648 {
650 handle_join_message (room, hash, entry);
651 break;
653 handle_leave_message (room, hash, entry);
654 break;
656 handle_name_message (room, hash, entry);
657 break;
659 handle_key_message (room, hash, entry);
660 break;
662 handle_id_message (room, hash, entry);
663 break;
665 handle_miss_message (room, hash, entry);
666 break;
668 handle_private_message (room, hash, entry);
669 break;
671 handle_delete_message (room, hash, entry);
672 break;
674 handle_transcript_message (room, hash, entry);
675 break;
676 default:
677 break;
678 }
679
681 callback_room_message (room, hash);
682}
@ 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_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
static void handle_name_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_private_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
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 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)
void handle_join_message(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_RoomMessageEntry *entry)
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_MESSENGER_MessageHeader header
Header.

References callback_room_message(), GNUNET_MESSENGER_RoomMessageEntry::flags, GNUNET_assert, GNUNET_MESSENGER_FLAG_UPDATE, GNUNET_MESSENGER_KIND_DELETE, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_NAME, GNUNET_MESSENGER_KIND_PRIVATE, GNUNET_MESSENGER_KIND_TRANSCRIPT, handle_delete_message(), handle_id_message(), handle_join_message(), handle_key_message(), handle_leave_message(), handle_miss_message(), handle_name_message(), handle_private_message(), handle_transcript_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, and GNUNET_MESSENGER_RoomMessageEntry::message.

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

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

◆ handle_join_message()

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

Definition at line 313 of file messenger_api_room.c.

316{
317 GNUNET_assert ((room) && (hash) && (entry));
318
319 if (! entry->sender)
320 {
322 room->handle);
324
325 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
326 &context);
327
328 entry->sender = get_store_contact (store, &context,
329 &(entry->message->body.join.key));
330 }
331
333 room->members, &(entry->message->header.sender_id), entry->sender)) &&
335 &(entry->message->header
336 .sender_id),
337 entry->sender,
339
341}
static pa_context * context
Pulseaudio context.
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.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
@ GNUNET_OK
void increase_contact_rc(struct GNUNET_MESSENGER_Contact *contact)
Increases the reference counter of a given contact which is zero as default.
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_PublicKey *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.
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_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, context, get_context_from_member(), get_handle_contact_store(), get_store_contact(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_contains_value(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, increase_contact_rc(), GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_RoomMessageEntry::message, 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_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 345 of file messenger_api_room.c.

348{
349 GNUNET_assert ((room) && (hash) && (entry));
350
351 if ((! entry->sender) ||
353 &(entry->message->
354 header.sender_id),
355 entry->sender)))
356 return;
357
358 if (GNUNET_YES == decrease_contact_rc (entry->sender))
360 "A contact does not share any room with you anymore!\n");
361}
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...

References decrease_contact_rc(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, GNUNET_MESSENGER_Room::members, GNUNET_MESSENGER_RoomMessageEntry::message, 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_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 365 of file messenger_api_room.c.

368{
369 GNUNET_assert ((room) && (hash) && (entry));
370
372 {
374 "Set rule for using handle name in room: %s\n",
375 GNUNET_h2s (&(room->key)));
376
377 const char *handle_name = get_handle_name (room->handle);
378
379 if ((handle_name) && (0 == strcmp (handle_name,
380 entry->message->body.name.name)))
382 }
383
384 if (! entry->sender)
385 return;
386
387 set_contact_name (entry->sender, entry->message->body.name.name);
388}
@ GNUNET_MESSENGER_FLAG_SENT
The sent flag.
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(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_FLAG_SENT, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, 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 392 of file messenger_api_room.c.

395{
396 GNUNET_assert ((room) && (hash) && (entry));
397
398 if (! entry->sender)
399 return;
400
402 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
403 &context);
404
406 room->handle);
407
408 update_store_contact (store, entry->sender, &context, &context,
409 &(entry->message->body.key.key));
410}
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_PublicKey *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_PublicKey key
The new public key which replaces the current senders public key.

References GNUNET_MESSENGER_Message::body, context, get_context_from_member(), get_handle_contact_store(), GNUNET_assert, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageKey::key, GNUNET_MESSENGER_MessageBody::key, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_RoomMessageEntry::sender, GNUNET_MESSENGER_MessageHeader::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_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 414 of file messenger_api_room.c.

417{
418 GNUNET_assert ((room) && (hash) && (entry));
419
421 set_room_sender_id (room, &(entry->message->body.id.id));
422
423 if ((! entry->sender) ||
425 &(entry->message->
426 header.sender_id),
427 entry->sender)) ||
429 &(entry->message->body.
430 id.id),
431 entry->sender,
433
434 return;
435
436 struct GNUNET_HashCode context, next_context;
437 get_context_from_member (&(room->key), &(entry->message->header.sender_id),
438 &context);
439 get_context_from_member (&(room->key), &(entry->message->body.id.id),
440 &next_context);
441
443 room->handle);
444
445 update_store_contact (store, entry->sender, &context, &next_context,
446 get_contact_key (entry->sender));
447}
const struct GNUNET_CRYPTO_PublicKey * get_contact_key(const struct GNUNET_MESSENGER_Contact *contact)
Returns the 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(), 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::key, 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 451 of file messenger_api_room.c.

454{
455 GNUNET_assert ((room) && (hash) && (entry));
456
457 if (0 == (GNUNET_MESSENGER_FLAG_SENT & entry->flags))
458 return;
459
461 &(room->entries), &(entry->message->body.miss.peer), NULL);
462
463 if (match)
464 remove_from_list_tunnels (&(room->entries), match);
465}
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_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_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 469 of file messenger_api_room.c.

472{
473 GNUNET_assert ((room) && (hash) && (entry));
474
475 struct GNUNET_MESSENGER_Message *private_message = copy_message (
476 entry->message);
477
478 if (! private_message)
479 return;
480
481 if (GNUNET_YES != decrypt_message (private_message,
482 get_handle_key (room->handle)))
483 {
484 destroy_message (private_message);
485 private_message = NULL;
486 }
487
488 if (! private_message)
489 return;
490
491 destroy_message (entry->message);
492
493 entry->recipient = get_handle_contact (room->handle, &(room->key));
494
495 entry->message = private_message;
497
498 if ((entry->sender) && (entry->recipient))
499 handle_message (room, hash, entry);
500}
@ GNUNET_MESSENGER_FLAG_PRIVATE
The private flag.
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.
const struct GNUNET_CRYPTO_PrivateKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the private key of a given handle.
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_PrivateKey *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_handle_key(), GNUNET_assert, GNUNET_MESSENGER_FLAG_PRIVATE, GNUNET_YES, GNUNET_MESSENGER_Room::handle, handle_message(), GNUNET_MESSENGER_ListTunnel::hash, GNUNET_MESSENGER_Room::key, GNUNET_MESSENGER_RoomMessageEntry::message, 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:

◆ delete_message_in_room()

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

Definition at line 1350 of file messenger_api.c.

1353{
1354 struct GNUNET_MESSENGER_Message *message = create_message_delete (hash,
1355 delay);
1356
1357 if (! message)
1358 {
1360 "Sending deletion aborted: Message creation failed!\n");
1361 return;
1362 }
1363
1364 enqueue_message_to_room (room, message, NULL);
1365}
@ GNUNET_ERROR_TYPE_WARNING
void enqueue_message_to_room(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript)
struct GNUNET_MESSENGER_Message * create_message_delete(const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
Creates and allocates a new delete message containing the hash of a message to delete after a specifi...

References create_message_delete(), enqueue_message_to_room(), GNUNET_ERROR_TYPE_WARNING, and GNUNET_log.

Referenced by GNUNET_MESSENGER_delete_message(), and handle_delete_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 510 of file messenger_api_room.c.

513{
514 GNUNET_assert ((room) && (hash) && (entry));
515
516 const struct GNUNET_HashCode *target_hash =
517 &(entry->message->body.deletion.hash);
518
519 if (get_handle_contact (room->handle, &(room->key)) == entry->sender)
520 {
521 struct GNUNET_TIME_Relative delay;
523
525
528
530 action);
531
532 link_room_deletion (room, target_hash, delay, delete_message_in_room);
533 }
534
535 struct GNUNET_MESSENGER_RoomMessageEntry *target =
536 GNUNET_CONTAINER_multihashmap_get (room->messages, target_hash);
537
538 if (! target)
539 return;
540
541 if (((target->sender != entry->sender) &&
542 (get_handle_contact (room->handle, &(room->key)) != entry->sender)))
543 return;
544
546 callback_room_message (room, target_hash);
547
549 target_hash,
550 target))
551 {
552 destroy_message (target->message);
553 GNUNET_free (target);
554 }
555}
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_FLAG_DELETE
The delete flag.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:628
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:737
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:450
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:421
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_message_in_room(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
struct GNUNET_MESSENGER_MessageDelete deletion
struct GNUNET_HashCode hash
The hash of the message to delete.
struct GNUNET_TIME_RelativeNBO delay
The delay of the delete operation to get processed.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.

References consensus-simulation::action, GNUNET_MESSENGER_Message::body, callback_room_message(), GNUNET_MESSENGER_MessageDelete::delay, delete_message_in_room(), GNUNET_MESSENGER_MessageBody::deletion, destroy_message(), GNUNET_MESSENGER_RoomMessageEntry::flags, get_handle_contact(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_free, GNUNET_MESSENGER_FLAG_DELETE, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_ntoh(), GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_MessageDelete::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_Room::key, link_room_deletion(), GNUNET_MESSENGER_RoomMessageEntry::message, GNUNET_MESSENGER_Room::messages, GNUNET_MESSENGER_RoomMessageEntry::sender, and GNUNET_MESSENGER_MessageHeader::timestamp.

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

562{
563 GNUNET_assert ((room) && (hash) && (entry));
564
565 if (get_handle_contact (room->handle, &(room->key)) != entry->sender)
566 return;
567
568 const struct GNUNET_HashCode *original_hash =
569 &(entry->message->body.transcript.hash);
571 room->handle);
572
573 struct GNUNET_MESSENGER_RoomMessageEntry *original =
574 GNUNET_CONTAINER_multihashmap_get (room->messages, original_hash);
575 struct GNUNET_MESSENGER_Message *original_message;
576
577 if (original)
578 goto read_transcript;
579
581
582 if (! original)
583 return;
584
585 original->sender = NULL;
586 original->recipient = NULL;
587
588 original->message = NULL;
590 original->completed = GNUNET_NO;
591
593 original_hash,
594 original,
596 {
597 GNUNET_free (original);
598 return;
599 }
600
601read_transcript:
602 original_message = copy_message (entry->message);
603
604 if (! original_message)
605 return;
606
607 if (GNUNET_YES != read_transcript_message (original_message))
608 {
609 destroy_message (original_message);
610 return;
611 }
612
613 original->recipient = get_store_contact (store,
614 NULL,
615 &(entry->message->body.transcript.key
616 ));
617
618 if (original->message)
619 {
622
623 copy_message_header (original_message, &(original->message->header));
624 destroy_message (original->message);
625 }
626
627 original->message = original_message;
628
629 link_room_message (room, hash, original_hash);
630 link_room_message (room, original_hash, hash);
631
632 if ((original->sender) && (original->recipient))
633 {
635 handle_message (room, original_hash, original);
636 }
637}
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_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ 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_PublicKey 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(), 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_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_Room::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_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,
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]flagsFlags of message

Definition at line 686 of file messenger_api_room.c.

691{
692 GNUNET_assert ((room) && (message) && (hash));
693
695 entry = GNUNET_CONTAINER_multihashmap_get (room->messages, hash);
696
697 if (entry)
698 goto update_entry;
699
701
702 if (! entry)
703 return;
704
705 entry->sender = NULL;
706 entry->recipient = NULL;
707
708 entry->message = NULL;
710 entry->completed = GNUNET_NO;
711
713 entry,
715 {
716 GNUNET_free (entry);
717 return;
718 }
719
720update_entry:
721 entry->sender = sender;
722 entry->flags = flags;
723
724 if (entry->message)
725 {
728
730 }
731 else
732 entry->message = copy_message (message);
733
734 entry->completed = GNUNET_YES;
735
736 handle_message (room, hash, entry);
737}

References GNUNET_MESSENGER_RoomMessageEntry::completed, copy_message(), copy_message_header(), GNUNET_MESSENGER_RoomMessageEntry::flags, 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_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_last_message()

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

Updates the last message hash 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

Definition at line 741 of file messenger_api_room.c.

743{
744 GNUNET_assert ((room) && (hash));
745
746 GNUNET_memcpy (&(room->last_message), hash, sizeof(room->last_message));
747}

References GNUNET_assert, GNUNET_memcpy, 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:

◆ iterate_local_members()

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

Definition at line 758 of file messenger_api_room.c.

761{
763 struct GNUNET_MESSENGER_Contact *contact = value;
764
765 return call->callback (call->cls, call->room, contact);
766}
static struct GNUNET_CONVERSATION_Call * call
Call handle (for active outgoing call).

References call, GNUNET_MESSENGER_MemberCall::cls, 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 770 of file messenger_api_room.c.

773{
774 GNUNET_assert (room);
775
776 if (! callback)
777 return GNUNET_CONTAINER_multishortmap_iterate (room->members, NULL, NULL);
778
780
781 call.room = room;
782 call.callback = callback;
783 call.cls = cls;
784
786
789 &call);
790}
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 800 of file messenger_api_room.c.

803{
804 struct GNUNET_MESSENGER_MemberFind *find = cls;
805 struct GNUNET_MESSENGER_Contact *contact = value;
806
807 if (contact == find->contact)
808 {
809 find->result = GNUNET_YES;
810 return GNUNET_NO;
811 }
812
813 return GNUNET_YES;
814}
const struct GNUNET_MESSENGER_Contact * contact
enum GNUNET_GenericReturnValue result

References GNUNET_MESSENGER_MemberFind::contact, 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 818 of file messenger_api_room.c.

820{
821 GNUNET_assert (room);
822
823 struct GNUNET_MESSENGER_MemberFind find;
824
825 find.contact = contact;
826 find.result = GNUNET_NO;
827
829 &find);
830
831 return find.result;
832}
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 836 of file messenger_api_room.c.

839{
840 const struct GNUNET_HashCode **result = cls;
841 struct GNUNET_HashCode *hash = value;
842
843 if (0 == GNUNET_CRYPTO_hash_cmp (hash, *result))
844 {
845 *result = NULL;
846 return GNUNET_NO;
847 }
848
849 return GNUNET_YES;
850}
static int result
Global testing status.
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.
Definition: crypto_hash.c:221

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

857{
858 GNUNET_assert ((room) && (hash) && (other));
859
860 const struct GNUNET_HashCode **result = &other;
863
864 if (! *result)
865 return;
866
867 struct GNUNET_HashCode *value = GNUNET_memdup (other, sizeof(struct
869 ;
870 if (! value)
871 return;
872
875
877}
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.
#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 889 of file messenger_api_room.c.

892{
893 struct GNUNET_HashCode **linked = cls;
894 struct GNUNET_HashCode *hash = value;
895
896 if (0 != GNUNET_CRYPTO_hash_cmp (*linked, hash))
897 return GNUNET_YES;
898
899 *linked = hash;
900 return GNUNET_NO;
901}

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

908{
910 struct GNUNET_HashCode *hash = value;
911
912 struct GNUNET_HashCode key_value;
913 GNUNET_memcpy (&key_value, key, sizeof (key_value));
914
915 struct GNUNET_HashCode *linked = &key_value;
916
918 clear_linked_hash, &linked);
919
920 if ((linked != &key_value) &&
922 hash, linked)))
923 GNUNET_free (linked);
924
925 if (info->deletion)
926 info->deletion (info->room, hash, info->delay);
927
928 GNUNET_free (hash);
929 return GNUNET_YES;
930}
#define info
static enum GNUNET_GenericReturnValue clear_linked_hash(void *cls, const struct GNUNET_HashCode *key, void *value)

References clear_linked_hash(), 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 934 of file messenger_api_room.c.

938{
939 GNUNET_assert ((room) && (hash));
940
942 info.room = room;
943 info.delay = delay;
944 info.deletion = deletion;
945
949}
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.
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_delete_message().

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