GNUnet 0.26.2-16-ge86b66bd5
 
Loading...
Searching...
No Matches
messenger_api.c File Reference
Include dependency graph for messenger_api.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_RoomFind
 

Functions

const char * GNUNET_MESSENGER_name_of_kind (enum GNUNET_MESSENGER_MessageKind kind)
 Get the name of a message kind.
 
void GNUNET_MESSENGER_create_room_key (union GNUNET_MESSENGER_RoomKey *key, const char *input, enum GNUNET_GenericReturnValue is_public, enum GNUNET_GenericReturnValue is_group, enum GNUNET_GenericReturnValue is_feed)
 Creates a room key from given optional input string using certain properties for this targeted room.
 
static void dequeue_messages_from_room (struct GNUNET_MESSENGER_Room *room)
 
static void handle_room_open (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_entry (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_close (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static void handle_room_sync (void *cls, const struct GNUNET_MESSENGER_RoomMessage *msg)
 
static const struct GNUNET_CRYPTO_HpkePublicKeyget_valid_encryption_key_for_room (struct GNUNET_MESSENGER_Room *room)
 
static void handle_member_id (void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg)
 
static enum GNUNET_GenericReturnValue check_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
 
static void handle_recv_message (void *cls, const struct GNUNET_MESSENGER_RecvMessage *msg)
 
static void handle_miss_message (void *cls, const struct GNUNET_MESSENGER_GetMessage *msg)
 
static void reconnect (struct GNUNET_MESSENGER_Handle *handle)
 
static void send_open_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
 
static void send_enter_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_PeerIdentity *door)
 
static void send_close_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
 
static void send_sync_room (struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
 
static enum GNUNET_GenericReturnValue iterate_reset_room (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void callback_reconnect (void *cls)
 
static enum GNUNET_GenericReturnValue iterate_close_room (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void callback_mq_error (void *cls, enum GNUNET_MQ_Error error)
 
struct GNUNET_MESSENGER_HandleGNUNET_MESSENGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *name, const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const struct GNUNET_HashCode *secret, GNUNET_MESSENGER_MessageCallback msg_callback, void *msg_cls)
 Set up a handle for the messenger related functions and connects to all necessary services.
 
void GNUNET_MESSENGER_disconnect (struct GNUNET_MESSENGER_Handle *handle)
 Disconnect all of the messengers used services and clears up its used memory.
 
static void callback_leave_message_sent (void *cls)
 
static void keep_subscription_alive (void *cls)
 
static void handle_discourse_subscription (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message)
 
static void send_message_to_room (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const struct GNUNET_HashCode *epoch, struct GNUNET_HashCode *hash)
 
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.
 
static void dequeue_message_from_room (void *cls)
 
const char * GNUNET_MESSENGER_get_name (const struct GNUNET_MESSENGER_Handle *handle)
 Get the name (if specified, otherwise NULL) used by the messenger.
 
static enum GNUNET_GenericReturnValue iterate_send_name_to_room (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
 
enum GNUNET_GenericReturnValue GNUNET_MESSENGER_set_name (struct GNUNET_MESSENGER_Handle *handle, const char *name)
 Set the name for the messenger handle and sends messages renaming your contact in currently open rooms.
 
static const struct GNUNET_CRYPTO_BlindablePublicKeyget_non_anonymous_key (const struct GNUNET_CRYPTO_BlindablePublicKey *public_key)
 
const struct GNUNET_CRYPTO_BlindablePublicKeyGNUNET_MESSENGER_get_key (const struct GNUNET_MESSENGER_Handle *handle)
 Get the public key used by the messenger or NULL if the anonymous key was used.
 
static enum GNUNET_GenericReturnValue iterate_send_key_to_room (void *cls, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Contact *contact)
 
enum GNUNET_GenericReturnValue GNUNET_MESSENGER_set_key (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
 Set the private key used by the messenger or NULL if the anonymous key should be used instead.
 
struct GNUNET_MESSENGER_RoomGNUNET_MESSENGER_open_room (struct GNUNET_MESSENGER_Handle *handle, const union GNUNET_MESSENGER_RoomKey *key)
 Open a room to send and receive messages.
 
struct GNUNET_MESSENGER_RoomGNUNET_MESSENGER_enter_room (struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const union GNUNET_MESSENGER_RoomKey *key)
 Enter a room to send and receive messages through a door opened using GNUNET_MESSENGER_open_room.
 
void GNUNET_MESSENGER_close_room (struct GNUNET_MESSENGER_Room *room)
 Close a room which was entered, opened or both in various order and variety.
 
static enum GNUNET_GenericReturnValue iterate_find_room (void *cls, const struct GNUNET_HashCode *key, void *value)
 
int GNUNET_MESSENGER_find_rooms (const struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_MESSENGER_Contact *contact, GNUNET_MESSENGER_MemberCallback callback, void *cls)
 Searches for a specific contact in a given room and calls a selected callback with a given closure for each of them containing the contact as a member.
 
const struct GNUNET_HashCodeGNUNET_MESSENGER_room_get_key (const struct GNUNET_MESSENGER_Room *room)
 Get the key of a given room.
 
const struct GNUNET_MESSENGER_ContactGNUNET_MESSENGER_get_sender (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Get the contact of a member in a room which sent a specific message identified with a given hash.
 
const struct GNUNET_MESSENGER_ContactGNUNET_MESSENGER_get_recipient (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Get the contact of a member in a room which has been targeted as recipient of a specific message identified with a given hash.
 
const char * GNUNET_MESSENGER_contact_get_name (const struct GNUNET_MESSENGER_Contact *contact)
 Get the name used by the contact.
 
const struct GNUNET_CRYPTO_BlindablePublicKeyGNUNET_MESSENGER_contact_get_key (const struct GNUNET_MESSENGER_Contact *contact)
 Get the public key used by the contact or NULL if the anonymous key was used.
 
size_t GNUNET_MESSENGER_contact_get_id (const struct GNUNET_MESSENGER_Contact *contact)
 Get the locally unique id of the contact.
 
static void send_message_to_room_with_key (struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, const struct GNUNET_CRYPTO_HpkePublicKey *encryption_key)
 
void GNUNET_MESSENGER_send_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_MESSENGER_Contact *contact)
 Send a message into a room.
 
void GNUNET_MESSENGER_delete_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 Delete a message identified by its hash from a room.
 
void request_message_from_room (const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Requests a specific message from a given room which can be identified by its hash.
 
const struct GNUNET_MESSENGER_MessageGNUNET_MESSENGER_get_message (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Get the message in a room identified by its hash and requests it if necessary.
 
int GNUNET_MESSENGER_iterate_members (struct GNUNET_MESSENGER_Room *room, GNUNET_MESSENGER_MemberCallback callback, void *cls)
 Iterates through all members of a given room and calls a selected callback for each of them with a provided closure.
 

Function Documentation

◆ dequeue_messages_from_room()

static void dequeue_messages_from_room ( struct GNUNET_MESSENGER_Room room)
static

Definition at line 1219 of file messenger_api.c.

1220{
1221 if ((GNUNET_YES != is_room_available (room)) || (! (room->handle)))
1222 return;
1223
1224 if (room->handle->mq)
1226 else if (! (room->queue_task))
1229}
@ GNUNET_SCHEDULER_PRIORITY_HIGH
Run with high priority (important requests).
@ GNUNET_YES
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:1237
static void dequeue_message_from_room(void *cls)
enum GNUNET_GenericReturnValue is_room_available(const struct GNUNET_MESSENGER_Room *room)
Checks whether a room is available to send messages.
struct GNUNET_MQ_Handle * mq
struct GNUNET_MESSENGER_Handle * handle
struct GNUNET_SCHEDULER_Task * queue_task

References dequeue_message_from_room(), GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_YES, GNUNET_MESSENGER_Room::handle, is_room_available(), GNUNET_MESSENGER_Handle::mq, and GNUNET_MESSENGER_Room::queue_task.

Referenced by enqueue_message_to_room(), handle_room_entry(), handle_room_open(), and handle_room_sync().

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

◆ handle_room_open()

static void handle_room_open ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 140 of file messenger_api.c.

142{
144 const struct GNUNET_HashCode *key;
145 const struct GNUNET_HashCode *prev;
146 const struct GNUNET_HashCode *epoch;
147 struct GNUNET_MESSENGER_Room *room;
148
149 GNUNET_assert ((cls) && (msg));
150
151 handle = cls;
152
153 key = &(msg->key);
154 prev = &(msg->previous);
155 epoch = &(msg->epoch);
156
157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opened room: %s\n", GNUNET_h2s (key));
158
160
162
163 if (! room)
164 return;
165
166 update_room_last_message (room, prev, epoch);
168}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
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
#define GNUNET_log(kind,...)
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
static void dequeue_messages_from_room(struct GNUNET_MESSENGER_Room *room)
void open_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Marks a room known to a handle identified by a given key as open.
struct GNUNET_MESSENGER_Room * get_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key, enum GNUNET_GenericReturnValue init)
Returns the room known to a handle identified by a given key.
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 poi...
A 512-bit hashcode.

References dequeue_messages_from_room(), get_handle_room(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, handle, key, msg, open_handle_room(), and update_room_last_message().

Here is the call graph for this function:

◆ handle_room_entry()

static void handle_room_entry ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 172 of file messenger_api.c.

174{
176 const struct GNUNET_PeerIdentity *door;
177 const struct GNUNET_HashCode *key;
178 const struct GNUNET_HashCode *prev;
179 const struct GNUNET_HashCode *epoch;
180 struct GNUNET_MESSENGER_Room *room;
181
182 GNUNET_assert ((cls) && (msg));
183
184 handle = cls;
185
186 door = &(msg->door);
187 key = &(msg->key);
188 prev = &(msg->previous);
189 epoch = &(msg->epoch);
190
191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entered room: %s\n", GNUNET_h2s (key));
192
194
196
197 if (! room)
198 return;
199
200 update_room_last_message (room, prev, epoch);
202}
void entry_handle_room_at(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Adds a tunnel for a room known to a handle identified by a given key to a list of opened connections.
The identity of the host (wraps the signing key of the peer).

References dequeue_messages_from_room(), entry_handle_room_at(), get_handle_room(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, handle, key, msg, and update_room_last_message().

Here is the call graph for this function:

◆ handle_room_close()

static void handle_room_close ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 206 of file messenger_api.c.

208{
210 const struct GNUNET_HashCode *key;
211 const struct GNUNET_HashCode *prev;
212 const struct GNUNET_HashCode *epoch;
213 struct GNUNET_MESSENGER_Room *room;
214
215 GNUNET_assert ((cls) && (msg));
216
217 handle = cls;
218
219 key = &(msg->key);
220 prev = &(msg->previous);
221 epoch = &(msg->epoch);
222
224
225 if (room)
226 update_room_last_message (room, prev, epoch);
227
228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closed room: %s\n", GNUNET_h2s (key));
229
231}
void close_handle_room(struct GNUNET_MESSENGER_Handle *handle, const struct GNUNET_HashCode *key)
Destroys and so implicitly closes a room known to a handle identified by a given key.

References close_handle_room(), get_handle_room(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, handle, key, msg, and update_room_last_message().

Here is the call graph for this function:

◆ handle_room_sync()

static void handle_room_sync ( void *  cls,
const struct GNUNET_MESSENGER_RoomMessage msg 
)
static

Definition at line 235 of file messenger_api.c.

237{
239 const struct GNUNET_HashCode *key;
240 const struct GNUNET_HashCode *prev;
241 const struct GNUNET_HashCode *epoch;
242 struct GNUNET_MESSENGER_Room *room;
243
244 GNUNET_assert ((cls) && (msg));
245
246 handle = cls;
247
248 key = &(msg->key);
249 prev = &(msg->previous);
250 epoch = &(msg->epoch);
251
253
254 if (! room)
255 return;
256
257 update_room_last_message (room, prev, epoch);
258
259 room->wait_for_sync = GNUNET_NO;
261}
enum GNUNET_GenericReturnValue wait_for_sync

References dequeue_messages_from_room(), get_handle_room(), GNUNET_assert, GNUNET_NO, handle, key, msg, update_room_last_message(), and GNUNET_MESSENGER_Room::wait_for_sync.

Here is the call graph for this function:

◆ get_valid_encryption_key_for_room()

static const struct GNUNET_CRYPTO_HpkePublicKey * get_valid_encryption_key_for_room ( struct GNUNET_MESSENGER_Room room)
static

Definition at line 265 of file messenger_api.c.

266{
267 const struct GNUNET_CRYPTO_HpkePublicKey *key;
268
269 GNUNET_assert (room);
270
272
273 if (! key)
274 {
275 if (GNUNET_OK != add_room_encryption_key (room, NULL))
276 {
278 "Could not generate encryption key: %s\n",
279 GNUNET_h2s (get_room_key (room)));
280 return NULL;
281 }
282
284 }
285
287 return key;
288}
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_ERROR
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.
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...
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_Room *room)
Return a the hash representation of a given room.
A public key used for encryption.

References add_room_encryption_key(), get_room_encryption_key(), get_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_OK, and key.

Referenced by enqueue_message_to_room(), handle_member_id(), and iterate_send_key_to_room().

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

◆ handle_member_id()

static void handle_member_id ( void *  cls,
const struct GNUNET_MESSENGER_MemberMessage msg 
)
static

Definition at line 292 of file messenger_api.c.

294{
296 const struct GNUNET_HashCode *key;
297 const struct GNUNET_ShortHashCode *id;
298 struct GNUNET_MESSENGER_Room *room;
299 struct GNUNET_MESSENGER_Message *message;
300 uint32_t reset;
301
302 GNUNET_assert ((cls) && (msg));
303
304 handle = cls;
305
306 key = &(msg->key);
307 id = &(msg->id);
308 reset = msg->reset;
309
310 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Changed member id in room: %s\n",
311 GNUNET_h2s (key));
312
314
315 if (! room)
316 {
317 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Room is unknown to handle: %s\n",
318 GNUNET_h2s (key));
319 return;
320 }
321
322 if ((! get_room_sender_id (room)) || (GNUNET_YES == reset))
323 {
324 set_room_sender_id (room, id);
325 message = create_message_join (
327 }
328 else
329 message = create_message_id (id);
330
331 if (! message)
332 return;
333
334 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
335}
static int reset
Reset argument.
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
@ 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.
static const struct GNUNET_CRYPTO_HpkePublicKey * get_valid_encryption_key_for_room(struct GNUNET_MESSENGER_Room *room)
const struct GNUNET_CRYPTO_BlindablePrivateKey * get_handle_key(const struct GNUNET_MESSENGER_Handle *handle)
Returns the private key of a given handle.
struct GNUNET_MESSENGER_Message * create_message_join(const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const struct GNUNET_CRYPTO_HpkePublicKey *hpke_key)
Creates and allocates a new join message containing the clients public key.
struct GNUNET_MESSENGER_Message * create_message_id(const struct GNUNET_ShortHashCode *unique_id)
Creates and allocates a new id message containing the unique member id to change to.
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.
const struct GNUNET_ShortHashCode * get_room_sender_id(const struct GNUNET_MESSENGER_Room *room)
Returns the member id of the room's sender.
A 256-bit hashcode.

References create_message_id(), create_message_join(), enqueue_message_to_room(), get_handle_key(), get_handle_room(), get_room_sender_id(), get_valid_encryption_key_for_room(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, handle, id, key, msg, reset, and set_room_sender_id().

Here is the call graph for this function:

◆ check_recv_message()

static enum GNUNET_GenericReturnValue check_recv_message ( void *  cls,
const struct GNUNET_MESSENGER_RecvMessage msg 
)
static

Definition at line 339 of file messenger_api.c.

341{
342 struct GNUNET_MESSENGER_Message message;
343 uint16_t full_length, length;
344 const char *buffer;
345
347
348 full_length = ntohs (msg->header.size);
349
350 if (full_length < sizeof(*msg))
351 {
353 "Receiving failed: Message invalid!\n");
354 return GNUNET_NO;
355 }
356
357 length = full_length - sizeof(*msg);
358 buffer = ((const char*) msg) + sizeof(*msg);
359
361 GNUNET_YES))
362 {
364 "Receiving failed: Message too short!\n");
365 return GNUNET_NO;
366 }
367
368 if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES, NULL))
369 {
371 "Receiving failed: Message decoding failed!\n");
372 return GNUNET_NO;
373 }
374
375 cleanup_message (&message);
376 return GNUNET_OK;
377}
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind, enum GNUNET_GenericReturnValue include_header)
Returns the minimal size in bytes to encode a message of a specific kind.
enum GNUNET_GenericReturnValue decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, enum GNUNET_GenericReturnValue include_header, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.

References cleanup_message(), decode_message(), get_message_kind_size(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_NO, GNUNET_OK, GNUNET_YES, msg, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_recv_message()

static void handle_recv_message ( void *  cls,
const struct GNUNET_MESSENGER_RecvMessage msg 
)
static

Definition at line 381 of file messenger_api.c.

383{
385 const struct GNUNET_HashCode *key;
386 const struct GNUNET_HashCode *sender;
387 const struct GNUNET_HashCode *context;
388 const struct GNUNET_HashCode *hash;
389 const struct GNUNET_HashCode *epoch;
391 struct GNUNET_MESSENGER_Message message;
392 struct GNUNET_MESSENGER_Room *room;
393 uint16_t length;
394 const char *buffer;
395
396 GNUNET_assert ((cls) && (msg));
397
398 handle = cls;
399
400 key = &(msg->key);
401 sender = &(msg->sender);
402 context = &(msg->context);
403 hash = &(msg->hash);
404 epoch = &(msg->epoch);
405
406 flags = (enum GNUNET_MESSENGER_MessageFlags) (msg->flags);
407
408 length = ntohs (msg->header.size) - sizeof(*msg);
409 buffer = ((const char*) msg) + sizeof(*msg);
410
411 decode_message (&message, length, buffer, GNUNET_YES, NULL);
412
414 "Receiving message: %s during epoch '%s'\n",
415 GNUNET_MESSENGER_name_of_kind (message.header.kind),
416 GNUNET_h2s (epoch));
417
419
420 if (! room)
421 {
422 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unknown room for this client: %s\n",
423 GNUNET_h2s (key));
424
425 goto skip_message;
426 }
427
429 "Raw contact from sender and context: (%s : %s)\n",
431
433 sender,
434 context,
435 hash,
436 epoch,
437 &message,
438 flags);
439
440skip_message:
441 cleanup_message (&message);
442}
static pa_context * context
Pulseaudio context.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
GNUNET_MESSENGER_MessageFlags
Enum for the different supported flags used by message handling.
void process_message_control(struct GNUNET_MESSENGER_MessageControl *control, const struct GNUNET_HashCode *sender, const struct GNUNET_HashCode *context, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch, const struct GNUNET_MESSENGER_Message *message, enum GNUNET_MESSENGER_MessageFlags flags)
Processes a new message with its hash and regarding information about sender, context and message fla...
struct GNUNET_MESSENGER_MessageControl * control

References cleanup_message(), context, GNUNET_MESSENGER_Room::control, decode_message(), get_handle_room(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_h2s_full(), GNUNET_log, GNUNET_MESSENGER_name_of_kind(), GNUNET_NO, GNUNET_YES, handle, GNUNET_MESSENGER_Message::header, key, GNUNET_MESSENGER_MessageHeader::kind, msg, process_message_control(), and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_miss_message()

static void handle_miss_message ( void *  cls,
const struct GNUNET_MESSENGER_GetMessage msg 
)
static

Definition at line 446 of file messenger_api.c.

448{
450 const struct GNUNET_HashCode *key;
451 const struct GNUNET_HashCode *hash;
452 struct GNUNET_MESSENGER_Room *room;
453
454 GNUNET_assert ((cls) && (msg));
455
456 handle = cls;
457
458 key = &(msg->key);
459 hash = &(msg->hash);
460
461 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Missing message in room: %s\n",
462 GNUNET_h2s (hash));
463
465
466 if (! room)
467 {
469 "Miss in unknown room for this client: %s\n", GNUNET_h2s (key));
470 return;
471 }
472
473 if (! get_room_sender_id (room))
474 return;
475
476 {
477 struct GNUNET_MESSENGER_Message *message;
478
479 message = create_message_request (hash);
480 if (! message)
481 return;
482
483 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
484 }
485}
struct GNUNET_MESSENGER_Message * create_message_request(const struct GNUNET_HashCode *hash)
Creates and allocates a new request message containing the hash of a missing message.

References create_message_request(), enqueue_message_to_room(), get_handle_room(), get_room_sender_id(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_NO, handle, key, and msg.

Here is the call graph for this function:

◆ reconnect()

static void reconnect ( struct GNUNET_MESSENGER_Handle handle)
static

Definition at line 710 of file messenger_api.c.

711{
713
714 {
715 const struct GNUNET_MQ_MessageHandler handlers[] = {
717 member_id,
720 ),
722 room_open,
725 ),
727 room_entry,
730 ),
732 room_close,
735 ),
740 ),
742 miss_message,
745 ),
747 room_sync,
750 ),
752 };
753
757 handle);
758 }
759}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition 003.c:1
static enum GNUNET_GenericReturnValue recv_message(void *cls, const struct GNUNET_MessageHeader *msg)
We have received a full message, pass to the MQ dispatcher.
Definition client.c:335
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
Definition client.c:1060
#define GNUNET_MESSENGER_SERVICE_NAME
Identifier of GNUnet MESSENGER Service.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
static void callback_mq_error(void *cls, enum GNUNET_MQ_Error error)
Message to request something from a room.
Message to receive the current member id of a handle in room.
Message to receive something from a room.
General message to confirm interaction with a room.
Message handler for a specific message type.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition vpn_api.c:44

References callback_mq_error(), GNUNET_assert, GNUNET_CLIENT_connect(), GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_GET_MESSAGE, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC, GNUNET_MESSENGER_SERVICE_NAME, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, handle, handlers, GNUNET_VPN_Handle::mq, and recv_message().

Here is the call graph for this function:

◆ send_open_room()

static void send_open_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room 
)
static

Definition at line 492 of file messenger_api.c.

494{
497 struct GNUNET_MQ_Envelope *env;
498 char *msg_buffer;
499 ssize_t len;
500
501 GNUNET_assert ((handle) && (handle->mq) && (room));
502
504
506 "Open room (%s) by member using key: %s\n",
507 GNUNET_h2s (get_room_key (room)),
509
511
512 env = GNUNET_MQ_msg_extra (msg, len > 0 ? len : 0,
514 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
515 copy_room_last_message (room, &(msg->previous));
516
517 msg_buffer = ((char*) msg) + sizeof(*msg);
518
519 if (len > 0)
521
523}
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
char * GNUNET_CRYPTO_blindable_public_key_to_string(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Creates a (Base32) string representation of the public key.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
ssize_t GNUNET_CRYPTO_write_blindable_pk_to_buffer(const struct GNUNET_CRYPTO_BlindablePublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePublicKey to a compact buffer.
ssize_t GNUNET_CRYPTO_blindable_pk_get_length(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePublicKey.
Definition crypto_pkey.c:85
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition mq.c:305
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_handle_pubkey(const struct GNUNET_MESSENGER_Handle *handle)
Returns the public key of a given handle.
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.
An identity key as per LSD0001.

References copy_room_last_message(), env, get_handle_pubkey(), get_room_key(), GNUNET_assert, GNUNET_CRYPTO_blindable_pk_get_length(), GNUNET_CRYPTO_blindable_public_key_to_string(), GNUNET_CRYPTO_write_blindable_pk_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), handle, key, GNUNET_VPN_Handle::mq, and msg.

Referenced by GNUNET_MESSENGER_open_room(), and iterate_reset_room().

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

◆ send_enter_room()

static void send_enter_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_PeerIdentity door 
)
static

Definition at line 527 of file messenger_api.c.

530{
533 struct GNUNET_MQ_Envelope *env;
534 char *msg_buffer;
535 ssize_t len;
536
537 GNUNET_assert ((handle) && (handle->mq) && (room) && (door));
538
540
541 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Enter room (%s) via door: %s (%s)\n",
542 GNUNET_h2s (get_room_key (room)),
543 GNUNET_i2s (door),
545
547
548 env = GNUNET_MQ_msg_extra (msg, len > 0 ? len : 0,
550 GNUNET_memcpy (&(msg->door), door, sizeof(*door));
551 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
552 copy_room_last_message (room, &(msg->previous));
553
554 msg_buffer = ((char*) msg) + sizeof(*msg);
555
556 if (len > 0)
558
560}
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).

References copy_room_last_message(), env, get_handle_pubkey(), get_room_key(), GNUNET_assert, GNUNET_CRYPTO_blindable_pk_get_length(), GNUNET_CRYPTO_blindable_public_key_to_string(), GNUNET_CRYPTO_write_blindable_pk_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), handle, key, GNUNET_VPN_Handle::mq, and msg.

Referenced by GNUNET_MESSENGER_enter_room(), and iterate_reset_room().

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

◆ send_close_room()

static void send_close_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room 
)
static

Definition at line 564 of file messenger_api.c.

566{
568 struct GNUNET_MQ_Envelope *env;
569
570 GNUNET_assert ((handle) && (handle->mq) && (room));
571
572 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Close room (%s)!\n",
573 GNUNET_h2s (get_room_key (room)));
574
576
577 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
578 copy_room_last_message (room, &(msg->previous));
579
581}
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.

References copy_room_last_message(), env, get_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_MQ_msg, GNUNET_MQ_send(), handle, GNUNET_VPN_Handle::mq, and msg.

Referenced by callback_leave_message_sent(), and iterate_close_room().

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

◆ send_sync_room()

static void send_sync_room ( struct GNUNET_MESSENGER_Handle handle,
struct GNUNET_MESSENGER_Room room 
)
static

Definition at line 585 of file messenger_api.c.

587{
589 struct GNUNET_MQ_Envelope *env;
590
591 GNUNET_assert ((handle) && (handle->mq) && (room));
592
593 if (GNUNET_YES == room->wait_for_sync)
594 return;
595
597
598 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sync room (%s)!\n",
599 GNUNET_h2s (get_room_key (room)));
600
602
603 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
604 copy_room_last_message (room, &(msg->previous));
605
607}

References copy_room_last_message(), env, get_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, handle, GNUNET_VPN_Handle::mq, msg, and GNUNET_MESSENGER_Room::wait_for_sync.

Referenced by enqueue_message_to_room().

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

◆ iterate_reset_room()

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

Definition at line 611 of file messenger_api.c.

614{
616 struct GNUNET_MESSENGER_Room *room;
617 struct GNUNET_MESSENGER_ListTunnel *entry;
618
619 GNUNET_assert ((cls) && (value));
620
621 handle = cls;
622 room = value;
623
624 if (GNUNET_YES == room->opened)
625 send_open_room (handle, room);
626
627 entry = room->entries.head;
628 while (entry)
629 {
630 struct GNUNET_PeerIdentity door;
631
632 GNUNET_PEER_resolve (entry->peer, &door);
633 send_enter_room (handle, room, &door);
634
635 entry = entry->next;
636 }
637
638 return GNUNET_YES;
639}
static char * value
Value of the record to add/remove.
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition peer.c:220
static void send_enter_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room, const struct GNUNET_PeerIdentity *door)
static void send_open_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
struct GNUNET_MESSENGER_ListTunnel * next
struct GNUNET_MESSENGER_ListTunnel * head
enum GNUNET_GenericReturnValue opened
struct GNUNET_MESSENGER_ListTunnels entries

References GNUNET_MESSENGER_Room::entries, GNUNET_assert, GNUNET_PEER_resolve(), GNUNET_YES, handle, GNUNET_MESSENGER_ListTunnels::head, GNUNET_MESSENGER_ListTunnel::next, GNUNET_MESSENGER_Room::opened, GNUNET_MESSENGER_ListTunnel::peer, send_enter_room(), send_open_room(), and value.

Referenced by callback_reconnect().

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

◆ callback_reconnect()

static void callback_reconnect ( void *  cls)
static

Definition at line 643 of file messenger_api.c.

644{
646
647 GNUNET_assert (cls);
648
649 handle = cls;
650
651 handle->reconnect_task = NULL;
652 handle->reconnect_time = GNUNET_TIME_STD_BACKOFF (handle->reconnect_time);
653
654 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnect messenger!\n");
655
657
659 handle);
660}
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
static enum GNUNET_GenericReturnValue iterate_reset_room(void *cls, const struct GNUNET_HashCode *key, void *value)
static void reconnect(void)
Adjust exponential back-off and reconnect to the service.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TIME_STD_BACKOFF, handle, iterate_reset_room(), and reconnect().

Referenced by callback_mq_error().

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

◆ iterate_close_room()

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

Definition at line 664 of file messenger_api.c.

667{
669 struct GNUNET_MESSENGER_Room *room;
670
671 GNUNET_assert ((cls) && (value));
672
673 handle = cls;
674 room = value;
675
676 send_close_room (handle, room);
677
678 return GNUNET_YES;
679}
static void send_close_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)

References GNUNET_assert, GNUNET_YES, handle, send_close_room(), and value.

Referenced by callback_mq_error().

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

◆ callback_mq_error()

static void callback_mq_error ( void *  cls,
enum GNUNET_MQ_Error  error 
)
static

Definition at line 683 of file messenger_api.c.

685{
687
688 GNUNET_assert (cls);
689
690 handle = cls;
691
692 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MQ_Error: %u\n", error);
693
695 handle);
696
697 if (handle->mq)
698 {
700 handle->mq = NULL;
701 }
702
703 handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->reconnect_time,
705 handle);
706}
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition mq.c:700
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1283
static void callback_reconnect(void *cls)
static enum GNUNET_GenericReturnValue iterate_close_room(void *cls, const struct GNUNET_HashCode *key, void *value)

References callback_reconnect(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_add_delayed(), handle, iterate_close_room(), and GNUNET_VPN_Handle::mq.

Referenced by reconnect().

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

◆ callback_leave_message_sent()

static void callback_leave_message_sent ( void *  cls)
static

Definition at line 821 of file messenger_api.c.

822{
823 struct GNUNET_MESSENGER_Room *room;
824
825 GNUNET_assert (cls);
826
827 room = cls;
828
829 room->opened = GNUNET_NO;
830 clear_list_tunnels (&(room->entries));
831
832 send_close_room (room->handle, room);
833}
void clear_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Clears the list of tunnels peer identities.

References clear_list_tunnels(), GNUNET_MESSENGER_Room::entries, GNUNET_assert, GNUNET_NO, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Room::opened, and send_close_room().

Referenced by send_message_to_room().

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

◆ keep_subscription_alive()

static void keep_subscription_alive ( void *  cls)
static

Definition at line 837 of file messenger_api.c.

838{
839 struct GNUNET_MESSENGER_RoomSubscription *subscription;
840 struct GNUNET_MESSENGER_Room *room;
841 struct GNUNET_MESSENGER_Message *message;
842 const struct GNUNET_ShortHashCode *discourse;
843
844 GNUNET_assert (cls);
845
846 subscription = cls;
847 subscription->task = NULL;
848
849 room = subscription->room;
850 message = subscription->message;
851
852 subscription->message = NULL;
853
854 discourse = &(message->body.subscription.discourse);
855
857 discourse,
858 subscription))
859 {
860 destroy_message (message);
861 return;
862 }
863
864 GNUNET_free (subscription);
865
866 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
867}
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.
#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_MessageSubscribtion subscription
struct GNUNET_ShortHashCode discourse
The hash of the discourse to subscription.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_SCHEDULER_Task * task
struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_Room * room
struct GNUNET_CONTAINER_MultiShortmap * subscriptions

References GNUNET_MESSENGER_Message::body, destroy_message(), GNUNET_MESSENGER_MessageSubscribtion::discourse, enqueue_message_to_room(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_free, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_RoomSubscription::message, GNUNET_MESSENGER_RoomSubscription::room, GNUNET_MESSENGER_MessageBody::subscription, GNUNET_MESSENGER_Room::subscriptions, and GNUNET_MESSENGER_RoomSubscription::task.

Referenced by handle_discourse_subscription().

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

◆ handle_discourse_subscription()

static void handle_discourse_subscription ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Message message 
)
static

Definition at line 871 of file messenger_api.c.

873{
874 const struct GNUNET_ShortHashCode *discourse;
875 struct GNUNET_MESSENGER_RoomSubscription *subscription;
876 struct GNUNET_TIME_Relative time;
877 uint32_t flags;
878
879 GNUNET_assert ((room) && (message));
880
881 flags = message->body.subscription.flags;
882
883 discourse = &(message->body.subscription.discourse);
884
886 discourse);
887
889 goto active_subscription;
890
891 if (! subscription)
892 return;
893
894 if (subscription->task)
895 GNUNET_SCHEDULER_cancel (subscription->task);
896
897 if (subscription->message)
898 destroy_message (subscription->message);
899
901 discourse,
902 subscription))
903 {
904 subscription->task = NULL;
905 subscription->message = NULL;
906 return;
907 }
908
909 GNUNET_free (subscription);
910 return;
911
912active_subscription:
914 return;
915
917
918 if (! subscription)
919 {
920 subscription = GNUNET_new (struct GNUNET_MESSENGER_RoomSubscription);
921
923 room->subscriptions, discourse, subscription,
925 {
926 GNUNET_free (subscription);
927 return;
928 }
929
930 subscription->room = room;
931 }
932 else
933 {
934 if (subscription->task)
935 GNUNET_SCHEDULER_cancel (subscription->task);
936
937 if (subscription->message)
938 destroy_message (subscription->message);
939 }
940
941 subscription->message = create_message_subscription (discourse, time,
942 flags);
943
944 if (! subscription->message)
945 {
946 subscription->task = NULL;
947 return;
948 }
949
950 {
951 struct GNUNET_TIME_Relative delay;
952 delay = GNUNET_TIME_relative_multiply_double (time, 0.9);
953
956 keep_subscription_alive, subscription);
957 }
958}
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.
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#define GNUNET_new(type)
Allocate a struct or union of the given type.
@ GNUNET_MESSENGER_FLAG_SUBSCRIPTION_KEEP_ALIVE
The keep alive flag.
@ GNUNET_MESSENGER_FLAG_SUBSCRIPTION_UNSUBSCRIBE
The unsubscribe flag.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
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:1213
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition time.c:626
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
static void keep_subscription_alive(void *cls)
struct GNUNET_MESSENGER_Message * create_message_subscription(const struct GNUNET_ShortHashCode *discourse, const struct GNUNET_TIME_Relative time, uint32_t flags)
Creates and allocates a new subscribe message for a subscription of a given discourse with a specific...
uint32_t flags
The flags about the subscription to a discourse.
struct GNUNET_TIME_RelativeNBO time
The time window of the subscription.
Time for relative time used by GNUnet, in microseconds.

References GNUNET_MESSENGER_Message::body, create_message_subscription(), destroy_message(), GNUNET_MESSENGER_MessageSubscribtion::discourse, GNUNET_MESSENGER_MessageSubscribtion::flags, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_get(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_free, GNUNET_MESSENGER_FLAG_SUBSCRIPTION_KEEP_ALIVE, GNUNET_MESSENGER_FLAG_SUBSCRIPTION_UNSUBSCRIBE, GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_TIME_relative_multiply_double(), GNUNET_TIME_relative_ntoh(), GNUNET_YES, keep_subscription_alive(), GNUNET_MESSENGER_RoomSubscription::message, GNUNET_MESSENGER_RoomSubscription::room, GNUNET_MESSENGER_MessageBody::subscription, GNUNET_MESSENGER_Room::subscriptions, GNUNET_MESSENGER_RoomSubscription::task, and GNUNET_MESSENGER_MessageSubscribtion::time.

Referenced by send_message_to_room().

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

◆ send_message_to_room()

static void send_message_to_room ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_CRYPTO_BlindablePrivateKey key,
const struct GNUNET_HashCode epoch,
struct GNUNET_HashCode hash 
)
static

Definition at line 962 of file messenger_api.c.

967{
968 const struct GNUNET_ShortHashCode *sender_id;
970 struct GNUNET_MQ_Envelope *env;
971 uint16_t msg_length;
972 char *msg_buffer;
973
974 GNUNET_assert ((room) && (message) && (key) && (hash));
975
976 sender_id = get_room_sender_id (room);
977
978 if (GNUNET_NO == is_service_message (message))
979 {
980 struct GNUNET_MESSENGER_Epoch *last_epoch;
981 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
982 const struct GNUNET_CRYPTO_SymmetricSessionKey *epoch_key;
983
984 last_epoch = get_room_epoch (room, epoch, GNUNET_YES);
985
986 if (! last_epoch)
987 goto send_message;
988
989 announcement = get_epoch_announcement (last_epoch, NULL, GNUNET_YES);
990
991 if ((! announcement) && (GNUNET_YES != is_room_public (room)))
992 generate_room_epoch_announcement (room, last_epoch, &announcement);
993
994 if (announcement)
995 epoch_key = get_epoch_announcement_key (announcement);
996 else
997 epoch_key = NULL;
998
999 if (! epoch_key)
1000 goto send_message;
1001
1002 if (GNUNET_YES != encrypt_secret_message (message, &(announcement->
1003 identifier), epoch_key)
1004 )
1005 {
1006 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Encrypting message (%s) failed!\n",
1007 GNUNET_h2s (hash));
1008 return;
1009 }
1010 }
1011
1013 if (GNUNET_YES == is_epoch_message (message))
1016 else
1019
1020 GNUNET_memcpy (&(message->header.sender_id), sender_id,
1021 sizeof(message->header.sender_id));
1022
1023 if (0 == GNUNET_CRYPTO_hash_cmp (epoch, &(room->last_epoch)))
1024 copy_room_last_message (room, &(message->header.previous));
1025 else
1026 GNUNET_memcpy (&(message->header.previous), epoch,
1027 sizeof(message->header.previous));
1028
1029 switch (message->header.kind)
1030 {
1032 {
1033 GNUNET_memcpy (&(message->body.join.epoch), epoch,
1034 sizeof(message->body.join.epoch));
1035 break;
1036 }
1038 {
1039 GNUNET_memcpy (&(message->body.leave.epoch), epoch,
1040 sizeof(message->body.leave.epoch));
1041 break;
1042 }
1043 default:
1044 break;
1045 }
1046
1047 message->header.signature.type = key->type;
1048
1049 msg_length = get_message_size (message, GNUNET_YES);
1050
1052 msg, msg_length,
1054
1055 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
1056
1057 msg_buffer = ((char*) msg) + sizeof(*msg);
1058 encode_message (message, msg_length, msg_buffer, GNUNET_YES);
1059
1060 hash_message (message, msg_length, msg_buffer, hash);
1061 sign_message (message, msg_length, msg_buffer, hash, key);
1062
1063 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send message (%s)!\n",
1064 GNUNET_h2s (hash));
1065
1066 if (! get_message_discourse (message))
1067 {
1068 const struct GNUNET_HashCode *epoch;
1069
1070 switch (message->header.kind)
1071 {
1074 epoch = hash;
1075 break;
1076 default:
1077 epoch = &(room->last_epoch);
1078 break;
1079 }
1080
1081 update_room_last_message (room, hash, epoch);
1082 }
1083
1084 switch (message->header.kind)
1085 {
1088 break;
1090 handle_discourse_subscription (room, message);
1091 break;
1092 default:
1093 break;
1094 }
1095
1096 GNUNET_MQ_send (room->handle->mq, env);
1097}
static void send_message(struct PeerContext *peer_ctx, struct GNUNET_MQ_Envelope *ev, const char *type)
Send a message to another peer.
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_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_SUBSCRIBTION
The subscription kind.
void GNUNET_MQ_notify_sent(struct GNUNET_MQ_Envelope *ev, GNUNET_SCHEDULER_TaskCallback cb, void *cb_cls)
Call a callback once the envelope has been sent, that is, sending it can not be canceled anymore.
Definition mq.c:655
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_(void)
Return absolute time of 0ms.
Definition time.c:142
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:636
static void callback_leave_message_sent(void *cls)
static void handle_discourse_subscription(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message)
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.
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.
void encode_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, enum GNUNET_GenericReturnValue include_header)
Encodes a given message into a buffer of a maximal length in bytes.
enum GNUNET_GenericReturnValue is_service_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message contains service critical information.
void sign_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Signs the hash of a message with a given private key and writes the signature into the buffer as well...
const struct GNUNET_ShortHashCode * get_message_discourse(const struct GNUNET_MESSENGER_Message *message)
Returns the discourse hash of a message depending on its kind.
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...
void hash_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer with a length in bytes from a message.
uint16_t get_message_size(const struct GNUNET_MESSENGER_Message *message, enum GNUNET_GenericReturnValue include_header)
Returns the exact size in bytes to encode a given message.
enum GNUNET_GenericReturnValue encrypt_secret_message(struct GNUNET_MESSENGER_Message *message, const union GNUNET_MESSENGER_EpochIdentifier *identifier, const struct GNUNET_CRYPTO_SymmetricSessionKey *key)
Encrypts a message using a given shared key from an announcement of an epoch and replaces its body an...
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 identi...
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...
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 ...
struct GNUNET_MESSENGER_MessageLeave leave
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
struct GNUNET_CRYPTO_BlindableKeySignature signature
The signature of the senders private key.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_HashCode epoch
The previous epoch the message was sent from.
struct GNUNET_HashCode epoch
The previous epoch the message was sent from.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_HashCode last_epoch
Message to send something into a room.

References GNUNET_MESSENGER_Message::body, callback_leave_message_sent(), copy_room_last_message(), encode_message(), encrypt_secret_message(), env, GNUNET_MESSENGER_MessageJoin::epoch, GNUNET_MESSENGER_MessageLeave::epoch, generate_room_epoch_announcement(), get_epoch_announcement(), get_epoch_announcement_key(), get_message_discourse(), get_message_size(), get_room_epoch(), get_room_key(), get_room_sender_id(), GNUNET_assert, GNUNET_CRYPTO_hash_cmp(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SEND_MESSAGE, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_SUBSCRIBTION, GNUNET_MQ_msg_extra, GNUNET_MQ_notify_sent(), GNUNET_MQ_send(), GNUNET_NO, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_zero_(), GNUNET_TIME_absolute_hton(), GNUNET_YES, GNUNET_MESSENGER_Room::handle, handle_discourse_subscription(), hash_message(), GNUNET_MESSENGER_Message::header, is_epoch_message(), is_room_public(), is_service_message(), GNUNET_MESSENGER_MessageBody::join, key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_Room::last_epoch, GNUNET_MESSENGER_MessageBody::leave, GNUNET_MESSENGER_Handle::mq, msg, GNUNET_MESSENGER_MessageHeader::previous, send_message(), GNUNET_MESSENGER_MessageHeader::sender_id, sign_message(), GNUNET_MESSENGER_MessageHeader::signature, GNUNET_MESSENGER_MessageHeader::timestamp, GNUNET_CRYPTO_BlindableKeySignature::type, and update_room_last_message().

Referenced by dequeue_message_from_room().

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

◆ enqueue_message_to_room()

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

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

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

Definition at line 1101 of file messenger_api.c.

1106{
1108 const struct GNUNET_CRYPTO_HpkePublicKey *transcript_key;
1109
1110 GNUNET_assert ((room) && (message));
1111
1112 key = get_handle_key (room->handle);
1113
1114 if (! epoch)
1115 epoch = &(room->last_epoch);
1116
1117 transcript_key = get_valid_encryption_key_for_room (room);
1118
1119 enqueue_to_messages (&(room->queue),
1120 key,
1121 transcript_key,
1122 epoch,
1123 message,
1124 transcript);
1125
1126 if (GNUNET_YES != is_room_available (room))
1127 return;
1128
1129 if ((GNUNET_YES == sync) ||
1130 (GNUNET_YES == is_message_session_bound (message)))
1131 send_sync_room (room->handle, room);
1132 else if (GNUNET_YES != room->wait_for_sync)
1134}
static void send_sync_room(struct GNUNET_MESSENGER_Handle *handle, struct GNUNET_MESSENGER_Room *room)
enum GNUNET_GenericReturnValue is_message_session_bound(const struct GNUNET_MESSENGER_Message *message)
Returns if the message should be bound to a member session.
void enqueue_to_messages(struct GNUNET_MESSENGER_QueueMessages *messages, const struct GNUNET_CRYPTO_BlindablePrivateKey *sender, const struct GNUNET_CRYPTO_HpkePublicKey *transcript_key, const struct GNUNET_HashCode *epoch, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript)
Adds a specific message to the end or the beginning of the queue.
A private key for an identity as per LSD0001.
struct GNUNET_MESSENGER_QueueMessages queue

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

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

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

◆ dequeue_message_from_room()

static void dequeue_message_from_room ( void *  cls)
static

Definition at line 1138 of file messenger_api.c.

1139{
1140 struct GNUNET_MESSENGER_Room *room;
1141 struct GNUNET_MESSENGER_Message *message;
1142 struct GNUNET_MESSENGER_Message *transcript;
1144 struct GNUNET_CRYPTO_HpkePublicKey transcript_key;
1145 struct GNUNET_HashCode epoch;
1146 struct GNUNET_HashCode hash;
1147
1148 GNUNET_assert (cls);
1149
1150 room = cls;
1151
1152 GNUNET_assert (room->handle);
1153
1154 room->queue_task = NULL;
1155
1156 if ((GNUNET_YES != is_room_available (room)) || (! (room->handle->mq)))
1157 goto next_message;
1158
1159 message = NULL;
1160 transcript = NULL;
1161 memset (&key, 0, sizeof(key));
1162 memset (&transcript_key, 0, sizeof(transcript_key));
1163
1164 message = dequeue_from_messages (&(room->queue),
1165 &key,
1166 &transcript_key,
1167 &epoch,
1168 &transcript);
1169
1170 if (! message)
1171 {
1172 if (transcript)
1173 destroy_message (transcript);
1174
1175 return;
1176 }
1177
1178 send_message_to_room (room, message, &key, &epoch, &hash);
1179 destroy_message (message);
1180
1181 if (! transcript)
1182 {
1184 goto next_message;
1185 }
1186
1187 GNUNET_memcpy (&(transcript->body.transcript.hash), &hash, sizeof(hash));
1188
1189 if (GNUNET_YES == encrypt_message (transcript, &transcript_key))
1190 {
1191 struct GNUNET_HashCode other;
1192 send_message_to_room (room, transcript, &key, &epoch, &other);
1193
1195
1196 link_room_message (room, &hash, &other);
1197 link_room_message (room, &other, &hash);
1198 }
1199 else
1200 {
1202
1204 "Sending transcript aborted: Encryption failed!\n");
1205 }
1206
1207 destroy_message (transcript);
1208
1210 if (! room->queue.head)
1211 return;
1212
1215}
static struct GNUNET_NSE_FloodMessage next_message
Message for the next round, if we got any.
void GNUNET_CRYPTO_private_key_clear(struct GNUNET_CRYPTO_BlindablePrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_pkey.c:47
static void send_message_to_room(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const struct GNUNET_HashCode *epoch, struct GNUNET_HashCode *hash)
enum GNUNET_GenericReturnValue encrypt_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_HpkePublicKey *hpke_key)
Encrypts a message using a given public key and replaces its body and kind with the now private encry...
struct GNUNET_MESSENGER_Message * dequeue_from_messages(struct GNUNET_MESSENGER_QueueMessages *messages, struct GNUNET_CRYPTO_BlindablePrivateKey *sender, struct GNUNET_CRYPTO_HpkePublicKey *transcript_key, struct GNUNET_HashCode *epoch, struct GNUNET_MESSENGER_Message **transcript)
Remove the message from the front of the queue and returns it.
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_MESSENGER_QueueMessage * head

References GNUNET_MESSENGER_Message::body, dequeue_from_messages(), dequeue_message_from_room(), destroy_message(), encrypt_message(), GNUNET_assert, GNUNET_CRYPTO_private_key_clear(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memcpy, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_MessageTranscript::hash, GNUNET_MESSENGER_QueueMessages::head, is_room_available(), key, link_room_message(), GNUNET_MESSENGER_Handle::mq, next_message, GNUNET_MESSENGER_Room::queue, GNUNET_MESSENGER_Room::queue_task, send_message_to_room(), and GNUNET_MESSENGER_MessageBody::transcript.

Referenced by dequeue_message_from_room(), and dequeue_messages_from_room().

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

◆ iterate_send_name_to_room()

static enum GNUNET_GenericReturnValue iterate_send_name_to_room ( void *  cls,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_MESSENGER_Contact contact 
)
static

Definition at line 1243 of file messenger_api.c.

1246{
1247 const struct GNUNET_MESSENGER_Handle *handle;
1248 struct GNUNET_MESSENGER_Message *message;
1249 const char *name;
1250
1251 GNUNET_assert ((cls) && (room));
1252
1253 handle = cls;
1254
1255 if (GNUNET_YES != room->use_handle_name)
1256 return GNUNET_YES;
1257
1259 if (! name)
1260 return GNUNET_YES;
1261
1262 message = create_message_name (name);
1263 if (! message)
1264 return GNUNET_NO;
1265
1266 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
1267 return GNUNET_YES;
1268}
static char * name
Name (label) of the records to list.
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_Message * create_message_name(const char *name)
Creates and allocates a new name message containing the name to change to.
enum GNUNET_GenericReturnValue use_handle_name

References create_message_name(), enqueue_message_to_room(), get_handle_name(), GNUNET_assert, GNUNET_NO, GNUNET_YES, handle, name, and GNUNET_MESSENGER_Room::use_handle_name.

Referenced by GNUNET_MESSENGER_set_name().

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

◆ get_non_anonymous_key()

static const struct GNUNET_CRYPTO_BlindablePublicKey * get_non_anonymous_key ( const struct GNUNET_CRYPTO_BlindablePublicKey public_key)
static

Definition at line 1285 of file messenger_api.c.

1287{
1288 if (0 == GNUNET_memcmp (public_key, get_anonymous_public_key ()))
1289 return NULL;
1290
1291 return public_key;
1292}
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_anonymous_public_key(void)
Returns the public identity key of GNUNET_IDENTITY_ego_get_anonymous() without recalculating it every...

References get_anonymous_public_key(), and GNUNET_memcmp.

Referenced by GNUNET_MESSENGER_contact_get_key(), GNUNET_MESSENGER_get_key(), and GNUNET_MESSENGER_send_message().

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

◆ iterate_send_key_to_room()

static enum GNUNET_GenericReturnValue iterate_send_key_to_room ( void *  cls,
struct GNUNET_MESSENGER_Room room,
const struct GNUNET_MESSENGER_Contact contact 
)
static

Definition at line 1306 of file messenger_api.c.

1309{
1311 struct GNUNET_MESSENGER_Message *message;
1312
1313 GNUNET_assert ((cls) && (room));
1314
1315 key = cls;
1316
1317 add_room_encryption_key (room, NULL);
1318
1320 if (! message)
1321 return GNUNET_NO;
1322
1323 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
1324 return GNUNET_YES;
1325}
struct GNUNET_MESSENGER_Message * create_message_key(const struct GNUNET_CRYPTO_BlindablePrivateKey *key, const struct GNUNET_CRYPTO_HpkePublicKey *hpke_key)
Creates and allocates a new key message containing the public key to change to derived from its priva...

References add_room_encryption_key(), create_message_key(), enqueue_message_to_room(), get_valid_encryption_key_for_room(), GNUNET_assert, GNUNET_NO, GNUNET_YES, and key.

Referenced by GNUNET_MESSENGER_set_key().

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

◆ iterate_find_room()

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

Definition at line 1431 of file messenger_api.c.

1434{
1435 struct GNUNET_MESSENGER_RoomFind *find;
1436 struct GNUNET_MESSENGER_Room *room;
1438
1439 GNUNET_assert ((cls) && (value));
1440
1441 find = cls;
1442 room = value;
1444
1445 if ((! find->contact) ||
1446 (GNUNET_YES == find_room_member (room, find->contact)))
1447 find->counter--;
1448
1449 if (find->callback)
1450 result = find->callback (find->cls, room, find->contact);
1451
1452 if (find->counter <= 0)
1453 result = GNUNET_NO;
1454
1455 return result;
1456}
static int result
Global testing status.
GNUNET_GenericReturnValue
Named constants for return values.
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 depend...
GNUNET_MESSENGER_MemberCallback callback
const struct GNUNET_MESSENGER_Contact * contact

References GNUNET_MESSENGER_RoomFind::callback, GNUNET_MESSENGER_RoomFind::cls, GNUNET_MESSENGER_RoomFind::contact, GNUNET_MESSENGER_RoomFind::counter, find_room_member(), GNUNET_assert, GNUNET_NO, GNUNET_YES, result, and value.

Referenced by GNUNET_MESSENGER_find_rooms().

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

◆ send_message_to_room_with_key()

static void send_message_to_room_with_key ( struct GNUNET_MESSENGER_Room room,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_CRYPTO_BlindablePublicKey public_key,
const struct GNUNET_CRYPTO_HpkePublicKey encryption_key 
)
static

Definition at line 1549 of file messenger_api.c.

1555{
1556 struct GNUNET_MESSENGER_Message *transcript;
1558 const char *handle_name;
1559 char *original_name;
1560
1561 GNUNET_assert ((room) && (message));
1562 GNUNET_assert ((! public_key) == (! encryption_key));
1563
1564 transcript = NULL;
1565
1566 if (GNUNET_MESSENGER_KIND_NAME != message->header.kind)
1567 goto skip_naming;
1568
1569 original_name = message->body.name.name;
1571 "Apply rule for using handle name in room: %s\n", GNUNET_h2s (
1572 get_room_key (room)));
1573
1574 handle_name = get_handle_name (room->handle);
1575
1576 if ((handle_name) && (GNUNET_YES == room->use_handle_name) &&
1577 ((! original_name) || (0 == strlen (original_name))))
1578 {
1579 if (original_name)
1580 GNUNET_free (original_name);
1581
1582 message->body.name.name = GNUNET_strdup (handle_name);
1583 }
1584
1585skip_naming:
1586 if ((! public_key) || (! encryption_key))
1587 goto skip_encryption;
1588
1590
1591 if (0 != GNUNET_memcmp (pubkey, public_key))
1592 transcript = transcribe_message (message, public_key);
1593
1594 if (GNUNET_YES != encrypt_message (message, encryption_key))
1595 {
1597 "Sending message aborted: Encryption failed!\n");
1598
1599 if (transcript)
1600 destroy_message (transcript);
1601
1602 destroy_message (message);
1603 return;
1604 }
1605
1606skip_encryption:
1607 enqueue_message_to_room (room, NULL, message, transcript, GNUNET_NO);
1608}
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
@ GNUNET_MESSENGER_KIND_NAME
The name kind.
struct GNUNET_MESSENGER_Message * transcribe_message(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Transcribes a message as a new transcript message using a given public key from the recipient of the ...
struct GNUNET_MESSENGER_MessageName name
char * name
The new name which replaces the current senders name.

References GNUNET_MESSENGER_Message::body, destroy_message(), encrypt_message(), enqueue_message_to_room(), get_handle_name(), get_handle_pubkey(), get_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_MESSENGER_KIND_NAME, GNUNET_NO, GNUNET_strdup, GNUNET_YES, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageName::name, GNUNET_MESSENGER_MessageBody::name, pubkey, transcribe_message(), and GNUNET_MESSENGER_Room::use_handle_name.

Referenced by GNUNET_MESSENGER_send_message().

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

◆ request_message_from_room()

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

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

Parameters
[in]roomRoom
[in]hashHash of message

Definition at line 1693 of file messenger_api.c.

1695{
1697 struct GNUNET_MQ_Envelope *env;
1698
1699 GNUNET_assert ((room) && (hash));
1700
1701 if (GNUNET_is_zero (hash))
1702 return;
1703
1704 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request message (%s)!\n",
1705 GNUNET_h2s (hash));
1706
1708 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
1709 GNUNET_memcpy (&(msg->hash), hash, sizeof(*hash));
1710 GNUNET_MQ_send (room->handle->mq, env);
1711}
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.

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

Referenced by GNUNET_MESSENGER_get_message(), and iterate_room_request().

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