GNUnet debian-0.24.3-29-g453fda2cf
 
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 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_PrivateKey *key, 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_PrivateKey *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_PublicKeyget_non_anonymous_key (const struct GNUNET_CRYPTO_PublicKey *public_key)
 
const struct GNUNET_CRYPTO_PublicKeyGNUNET_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_PrivateKey *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_PublicKeyGNUNET_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_PublicKey *public_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 1180 of file messenger_api.c.

1181{
1182 if ((GNUNET_YES != is_room_available (room)) || (! (room->handle)))
1183 return;
1184
1185 if (room->handle->mq)
1187 else if (! (room->queue_task))
1190}
@ 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:1231
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
161 room = get_handle_room (handle, key);
162 if (! room)
163 return;
164
165 update_room_last_message (room, prev, epoch);
167}
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,...)
#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)
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, 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 171 of file messenger_api.c.

173{
175 const struct GNUNET_PeerIdentity *door;
176 const struct GNUNET_HashCode *key;
177 const struct GNUNET_HashCode *prev;
178 const struct GNUNET_HashCode *epoch;
179 struct GNUNET_MESSENGER_Room *room;
180
181 GNUNET_assert ((cls) && (msg));
182
183 handle = cls;
184
185 door = &(msg->door);
186 key = &(msg->key);
187 prev = &(msg->previous);
188 epoch = &(msg->epoch);
189
190 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entered room: %s\n", GNUNET_h2s (key));
191
193
194 room = get_handle_room (handle, key);
195 if (! room)
196 return;
197
198 update_room_last_message (room, prev, epoch);
200}
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, 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 204 of file messenger_api.c.

206{
208 const struct GNUNET_HashCode *key;
209 const struct GNUNET_HashCode *prev;
210 const struct GNUNET_HashCode *epoch;
211 struct GNUNET_MESSENGER_Room *room;
212
213 GNUNET_assert ((cls) && (msg));
214
215 handle = cls;
216
217 key = &(msg->key);
218 prev = &(msg->previous);
219 epoch = &(msg->epoch);
220
221 room = get_handle_room (handle, key);
222 if (room)
223 update_room_last_message (room, prev, epoch);
224
225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closed room: %s\n", GNUNET_h2s (key));
226
228}
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, 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 232 of file messenger_api.c.

234{
236 const struct GNUNET_HashCode *key;
237 const struct GNUNET_HashCode *prev;
238 const struct GNUNET_HashCode *epoch;
239 struct GNUNET_MESSENGER_Room *room;
240
241 GNUNET_assert ((cls) && (msg));
242
243 handle = cls;
244
245 key = &(msg->key);
246 prev = &(msg->previous);
247 epoch = &(msg->epoch);
248
249 room = get_handle_room (handle, key);
250 if (! room)
251 return;
252
253 update_room_last_message (room, prev, epoch);
254
255 room->wait_for_sync = GNUNET_NO;
257}
@ GNUNET_NO
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:

◆ handle_member_id()

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

Definition at line 261 of file messenger_api.c.

263{
265 const struct GNUNET_HashCode *key;
266 const struct GNUNET_ShortHashCode *id;
267 struct GNUNET_MESSENGER_Room *room;
268 struct GNUNET_MESSENGER_Message *message;
269 uint32_t reset;
270
271 GNUNET_assert ((cls) && (msg));
272
273 handle = cls;
274
275 key = &(msg->key);
276 id = &(msg->id);
277 reset = msg->reset;
278
279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Changed member id in room: %s\n",
280 GNUNET_h2s (key));
281
282 room = get_handle_room (handle, key);
283 if (! room)
284 {
285 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Room is unknown to handle: %s\n",
286 GNUNET_h2s (key));
287 return;
288 }
289
290 if ((! get_room_sender_id (room)) || (GNUNET_YES == reset))
291 {
292 set_room_sender_id (room, id);
294 }
295 else
296 message = create_message_id (id);
297
298 if (! message)
299 return;
300
301 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
302}
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.
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 * create_message_join(const struct GNUNET_CRYPTO_PrivateKey *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(), 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 306 of file messenger_api.c.

308{
309 struct GNUNET_MESSENGER_Message message;
310 uint16_t full_length, length;
311 const char *buffer;
312
314
315 full_length = ntohs (msg->header.size);
316
317 if (full_length < sizeof(*msg))
318 {
320 "Receiving failed: Message invalid!\n");
321 return GNUNET_NO;
322 }
323
324 length = full_length - sizeof(*msg);
325 buffer = ((const char*) msg) + sizeof(*msg);
326
328 GNUNET_YES))
329 {
331 "Receiving failed: Message too short!\n");
332 return GNUNET_NO;
333 }
334
335 if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES, NULL))
336 {
338 "Receiving failed: Message decoding failed!\n");
339 return GNUNET_NO;
340 }
341
342 cleanup_message (&message);
343 return GNUNET_OK;
344}
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_ERROR
@ 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 348 of file messenger_api.c.

350{
352 const struct GNUNET_HashCode *key;
353 const struct GNUNET_HashCode *sender;
354 const struct GNUNET_HashCode *context;
355 const struct GNUNET_HashCode *hash;
356 const struct GNUNET_HashCode *epoch;
358 struct GNUNET_MESSENGER_Message message;
359 struct GNUNET_MESSENGER_Room *room;
360 uint16_t length;
361 const char *buffer;
362
363 GNUNET_assert ((cls) && (msg));
364
365 handle = cls;
366
367 key = &(msg->key);
368 sender = &(msg->sender);
369 context = &(msg->context);
370 hash = &(msg->hash);
371 epoch = &(msg->epoch);
372
373 flags = (enum GNUNET_MESSENGER_MessageFlags) (msg->flags);
374
375 length = ntohs (msg->header.size) - sizeof(*msg);
376 buffer = ((const char*) msg) + sizeof(*msg);
377
378 decode_message (&message, length, buffer, GNUNET_YES, NULL);
379
381 "Receiving message: %s during epoch '%s'\n",
382 GNUNET_MESSENGER_name_of_kind (message.header.kind),
383 GNUNET_h2s (epoch));
384
385 room = get_handle_room (handle, key);
386 if (! room)
387 {
388 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unknown room for this client: %s\n",
389 GNUNET_h2s (key));
390
391 goto skip_message;
392 }
393
395 "Raw contact from sender and context: (%s : %s)\n",
397
399 sender,
400 context,
401 hash,
402 epoch,
403 &message,
404 flags);
405
406skip_message:
407 cleanup_message (&message);
408}
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_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 412 of file messenger_api.c.

414{
416 const struct GNUNET_HashCode *key;
417 const struct GNUNET_HashCode *hash;
418 struct GNUNET_MESSENGER_Room *room;
419
420 GNUNET_assert ((cls) && (msg));
421
422 handle = cls;
423
424 key = &(msg->key);
425 hash = &(msg->hash);
426
427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Missing message in room: %s\n",
428 GNUNET_h2s (hash));
429
430 room = get_handle_room (handle, key);
431 if (! room)
432 {
434 "Miss in unknown room for this client: %s\n", GNUNET_h2s (key));
435 return;
436 }
437
438 if (! get_room_sender_id (room))
439 return;
440
441 {
442 struct GNUNET_MESSENGER_Message *message;
443
444 message = create_message_request (hash);
445 if (! message)
446 return;
447
448 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
449 }
450}
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 675 of file messenger_api.c.

676{
678
679 {
680 const struct GNUNET_MQ_MessageHandler handlers[] = {
682 member_id,
685 ),
687 room_open,
690 ),
692 room_entry,
695 ),
697 room_close,
700 ),
705 ),
707 miss_message,
710 ),
712 room_sync,
715 ),
717 };
718
722 handle);
723 }
724}
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 457 of file messenger_api.c.

459{
460 const struct GNUNET_CRYPTO_PublicKey *key;
462 struct GNUNET_MQ_Envelope *env;
463 char *msg_buffer;
464 ssize_t len;
465
466 GNUNET_assert ((handle) && (handle->mq) && (room));
467
469
471 "Open room (%s) by member using key: %s\n",
472 GNUNET_h2s (get_room_key (room)),
474
476
477 env = GNUNET_MQ_msg_extra (msg, len > 0 ? len : 0,
479 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
480 copy_room_last_message (room, &(msg->previous));
481
482 msg_buffer = ((char*) msg) + sizeof(*msg);
483
484 if (len > 0)
486
488}
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
Definition crypto_pkey.c:85
char * GNUNET_CRYPTO_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
ssize_t GNUNET_CRYPTO_write_public_key_to_buffer(const struct GNUNET_CRYPTO_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PublicKey to a compact buffer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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_PublicKey * 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.
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_Room *room)
Return a the hash representation of a given room.
An identity key as per LSD0001.

References copy_room_last_message(), env, get_handle_pubkey(), get_room_key(), GNUNET_assert, GNUNET_CRYPTO_public_key_get_length(), GNUNET_CRYPTO_public_key_to_string(), GNUNET_CRYPTO_write_public_key_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 492 of file messenger_api.c.

495{
496 const struct GNUNET_CRYPTO_PublicKey *key;
498 struct GNUNET_MQ_Envelope *env;
499 char *msg_buffer;
500 ssize_t len;
501
502 GNUNET_assert ((handle) && (handle->mq) && (room) && (door));
503
505
506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Enter room (%s) via door: %s (%s)\n",
507 GNUNET_h2s (get_room_key (room)),
508 GNUNET_i2s (door),
510
512
513 env = GNUNET_MQ_msg_extra (msg, len > 0 ? len : 0,
515 GNUNET_memcpy (&(msg->door), door, sizeof(*door));
516 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
517 copy_room_last_message (room, &(msg->previous));
518
519 msg_buffer = ((char*) msg) + sizeof(*msg);
520
521 if (len > 0)
523
525}
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_public_key_get_length(), GNUNET_CRYPTO_public_key_to_string(), GNUNET_CRYPTO_write_public_key_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 529 of file messenger_api.c.

531{
533 struct GNUNET_MQ_Envelope *env;
534
535 GNUNET_assert ((handle) && (handle->mq) && (room));
536
537 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Close room (%s)!\n",
538 GNUNET_h2s (get_room_key (room)));
539
541
542 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
543 copy_room_last_message (room, &(msg->previous));
544
546}
#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 550 of file messenger_api.c.

552{
554 struct GNUNET_MQ_Envelope *env;
555
556 GNUNET_assert ((handle) && (handle->mq) && (room));
557
558 if (GNUNET_YES == room->wait_for_sync)
559 return;
560
562
563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sync room (%s)!\n",
564 GNUNET_h2s (get_room_key (room)));
565
567
568 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
569 copy_room_last_message (room, &(msg->previous));
570
572}

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 576 of file messenger_api.c.

579{
581 struct GNUNET_MESSENGER_Room *room;
582 struct GNUNET_MESSENGER_ListTunnel *entry;
583
584 GNUNET_assert ((cls) && (value));
585
586 handle = cls;
587 room = value;
588
589 if (GNUNET_YES == room->opened)
590 send_open_room (handle, room);
591
592 entry = room->entries.head;
593 while (entry)
594 {
595 struct GNUNET_PeerIdentity door;
596
597 GNUNET_PEER_resolve (entry->peer, &door);
598 send_enter_room (handle, room, &door);
599
600 entry = entry->next;
601 }
602
603 return GNUNET_YES;
604}
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 608 of file messenger_api.c.

609{
611
612 GNUNET_assert (cls);
613
614 handle = cls;
615
616 handle->reconnect_task = NULL;
617 handle->reconnect_time = GNUNET_TIME_STD_BACKOFF (handle->reconnect_time);
618
619 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Reconnect messenger!\n");
620
622
624 handle);
625}
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 629 of file messenger_api.c.

632{
634 struct GNUNET_MESSENGER_Room *room;
635
636 GNUNET_assert ((cls) && (value));
637
638 handle = cls;
639 room = value;
640
641 send_close_room (handle, room);
642
643 return GNUNET_YES;
644}
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 648 of file messenger_api.c.

650{
652
653 GNUNET_assert (cls);
654
655 handle = cls;
656
657 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "MQ_Error: %u\n", error);
658
660 handle);
661
662 if (handle->mq)
663 {
665 handle->mq = NULL;
666 }
667
668 handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->reconnect_time,
670 handle);
671}
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:1277
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 785 of file messenger_api.c.

786{
787 struct GNUNET_MESSENGER_Room *room;
788
789 GNUNET_assert (cls);
790
791 room = cls;
792
793 room->opened = GNUNET_NO;
794 clear_list_tunnels (&(room->entries));
795
796 send_close_room (room->handle, room);
797}
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 801 of file messenger_api.c.

802{
803 struct GNUNET_MESSENGER_RoomSubscription *subscription;
804 struct GNUNET_MESSENGER_Room *room;
805 struct GNUNET_MESSENGER_Message *message;
806 const struct GNUNET_ShortHashCode *discourse;
807
808 GNUNET_assert (cls);
809
810 subscription = cls;
811 subscription->task = NULL;
812
813 room = subscription->room;
814 message = subscription->message;
815
816 subscription->message = NULL;
817
818 discourse = &(message->body.subscribtion.discourse);
819
821 discourse,
822 subscription))
823 {
824 destroy_message (message);
825 return;
826 }
827
828 GNUNET_free (subscription);
829
830 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
831}
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 subscribtion
struct GNUNET_ShortHashCode discourse
The hash of the discourse to subscribtion.
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::subscribtion, 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 835 of file messenger_api.c.

837{
838 const struct GNUNET_ShortHashCode *discourse;
839 struct GNUNET_MESSENGER_RoomSubscription *subscription;
840 struct GNUNET_TIME_Relative time;
841 uint32_t flags;
842
843 GNUNET_assert ((room) && (message));
844
845 flags = message->body.subscribtion.flags;
846
847 discourse = &(message->body.subscribtion.discourse);
848
850 discourse);
851
853 goto active_subscription;
854
855 if (! subscription)
856 return;
857
858 if (subscription->task)
859 GNUNET_SCHEDULER_cancel (subscription->task);
860
861 if (subscription->message)
862 destroy_message (subscription->message);
863
865 discourse,
866 subscription))
867 {
868 subscription->task = NULL;
869 subscription->message = NULL;
870 return;
871 }
872
873 GNUNET_free (subscription);
874 return;
875
876active_subscription:
878 return;
879
881
882 if (! subscription)
883 {
884 subscription = GNUNET_new (struct GNUNET_MESSENGER_RoomSubscription);
885
887 room->subscriptions, discourse, subscription,
889 {
890 GNUNET_free (subscription);
891 return;
892 }
893
894 subscription->room = room;
895 }
896 else
897 {
898 if (subscription->task)
899 GNUNET_SCHEDULER_cancel (subscription->task);
900
901 if (subscription->message)
902 destroy_message (subscription->message);
903 }
904
905 subscription->message = create_message_subscribtion (discourse, time,
906 flags);
907
908 if (! subscription->message)
909 {
910 subscription->task = NULL;
911 return;
912 }
913
914 {
915 struct GNUNET_TIME_Relative delay;
916 delay = GNUNET_TIME_relative_multiply_double (time, 0.9);
917
920 keep_subscription_alive, subscription);
921 }
922}
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:980
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1207
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition time.c:630
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_subscribtion(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_subscribtion(), 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::subscribtion, 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_PrivateKey key,
const struct GNUNET_HashCode epoch,
struct GNUNET_HashCode hash 
)
static

Definition at line 926 of file messenger_api.c.

931{
932 const struct GNUNET_ShortHashCode *sender_id;
934 struct GNUNET_MQ_Envelope *env;
935 uint16_t msg_length;
936 char *msg_buffer;
937
938 GNUNET_assert ((room) && (message) && (key) && (hash));
939
940 sender_id = get_room_sender_id (room);
941
942 if (GNUNET_NO == is_service_message (message))
943 {
944 struct GNUNET_MESSENGER_Epoch *last_epoch;
945 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
946 const struct GNUNET_CRYPTO_SymmetricSessionKey *epoch_key;
947
948 last_epoch = get_room_epoch (room, epoch, GNUNET_YES);
949
950 if (! last_epoch)
951 goto send_message;
952
953 announcement = get_epoch_announcement (last_epoch, NULL, GNUNET_YES);
954
955 if ((! announcement) && (GNUNET_YES != is_room_public (room)))
956 generate_room_epoch_announcement (room, last_epoch, &announcement);
957
958 if (announcement)
959 epoch_key = get_epoch_announcement_key (announcement);
960 else
961 epoch_key = NULL;
962
963 if (! epoch_key)
964 goto send_message;
965
966 if (GNUNET_YES != encrypt_secret_message (message, &(announcement->
967 identifier), epoch_key)
968 )
969 {
970 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Encrypting message (%s) failed!\n",
971 GNUNET_h2s (hash));
972 return;
973 }
974 }
975
977 if (GNUNET_YES == is_epoch_message (message))
980 else
983
984 GNUNET_memcpy (&(message->header.sender_id), sender_id,
985 sizeof(message->header.sender_id));
986
987 if (0 == GNUNET_CRYPTO_hash_cmp (epoch, &(room->last_epoch)))
988 copy_room_last_message (room, &(message->header.previous));
989 else
990 GNUNET_memcpy (&(message->header.previous), epoch,
991 sizeof(message->header.previous));
992
993 switch (message->header.kind)
994 {
996 {
997 GNUNET_memcpy (&(message->body.join.epoch), epoch,
998 sizeof(message->body.join.epoch));
999 break;
1000 }
1002 {
1003 GNUNET_memcpy (&(message->body.leave.epoch), epoch,
1004 sizeof(message->body.leave.epoch));
1005 break;
1006 }
1007 default:
1008 break;
1009 }
1010
1011 message->header.signature.type = key->type;
1012
1013 msg_length = get_message_size (message, GNUNET_YES);
1014
1016 msg, msg_length,
1018
1019 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
1020
1021 msg_buffer = ((char*) msg) + sizeof(*msg);
1022 encode_message (message, msg_length, msg_buffer, GNUNET_YES);
1023
1024 hash_message (message, msg_length, msg_buffer, hash);
1025 sign_message (message, msg_length, msg_buffer, hash, key);
1026
1027 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send message (%s)!\n",
1028 GNUNET_h2s (hash));
1029
1030 if (! get_message_discourse (message))
1031 {
1032 const struct GNUNET_HashCode *epoch;
1033
1034 switch (message->header.kind)
1035 {
1038 epoch = hash;
1039 break;
1040 default:
1041 epoch = &(room->last_epoch);
1042 break;
1043 }
1044
1045 update_room_last_message (room, hash, epoch);
1046 }
1047
1048 switch (message->header.kind)
1049 {
1052 break;
1054 handle_discourse_subscription (room, message);
1055 break;
1056 default:
1057 break;
1058 }
1059
1060 GNUNET_MQ_send (room->handle->mq, env);
1061}
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 subscribtion 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:640
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.
void sign_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CRYPTO_PrivateKey *key)
Signs the hash of a message with a given private key and writes the signature into the buffer as well...
enum GNUNET_GenericReturnValue is_service_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message contains service critical information.
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 ...
uint32_t type
Type of signature.
struct GNUNET_MESSENGER_MessageLeave leave
struct GNUNET_MESSENGER_MessageJoin join
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_CRYPTO_Signature signature
The signature of the senders private key.
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_Signature::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 1065 of file messenger_api.c.

1070{
1071 const struct GNUNET_CRYPTO_PrivateKey *key;
1072
1073 GNUNET_assert ((room) && (message));
1074
1075 key = get_handle_key (room->handle);
1076
1077 if (! epoch)
1078 epoch = &(room->last_epoch);
1079
1080 enqueue_to_messages (&(room->queue),
1081 key,
1082 epoch,
1083 message,
1084 transcript);
1085
1086 if (GNUNET_YES != is_room_available (room))
1087 return;
1088
1089 if ((GNUNET_YES == sync) ||
1090 (GNUNET_YES == is_message_session_bound (message)))
1091 send_sync_room (room->handle, room);
1092 else if (GNUNET_YES != room->wait_for_sync)
1094}
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_PrivateKey *sender, const struct GNUNET_HashCode *epoch, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript)
Adds a specific message to the end or the beginning of the queue.
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(), 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 1098 of file messenger_api.c.

1099{
1100 struct GNUNET_MESSENGER_Room *room;
1101 struct GNUNET_MESSENGER_Message *message;
1102 struct GNUNET_MESSENGER_Message *transcript;
1104 struct GNUNET_HashCode epoch;
1105 struct GNUNET_HashCode hash;
1107
1108 GNUNET_assert (cls);
1109
1110 room = cls;
1111
1112 GNUNET_assert (room->handle);
1113
1114 room->queue_task = NULL;
1115
1116 if ((GNUNET_YES != is_room_available (room)) || (! (room->handle->mq)))
1117 goto next_message;
1118
1119 message = NULL;
1120 transcript = NULL;
1121 memset (&key, 0, sizeof(key));
1122
1123 message = dequeue_from_messages (&(room->queue),
1124 &key,
1125 &epoch,
1126 &transcript);
1127
1128 if (! message)
1129 {
1130 if (transcript)
1131 destroy_message (transcript);
1132
1133 return;
1134 }
1135
1136 send_message_to_room (room, message, &key, &epoch, &hash);
1137 destroy_message (message);
1138
1139 if (! transcript)
1140 {
1142 goto next_message;
1143 }
1144
1145 GNUNET_memcpy (&(transcript->body.transcript.hash), &hash, sizeof(hash));
1146
1147 memset (&pubkey, 0, sizeof(pubkey));
1149
1150 if (GNUNET_YES == encrypt_message (transcript, &pubkey))
1151 {
1152 struct GNUNET_HashCode other;
1153 send_message_to_room (room, transcript, &key, &epoch, &other);
1154
1156
1157 link_room_message (room, &hash, &other);
1158 link_room_message (room, &other, &hash);
1159 }
1160 else
1161 {
1163
1165 "Sending transcript aborted: Encryption failed!\n");
1166 }
1167
1168 destroy_message (transcript);
1169
1171 if (! room->queue.head)
1172 return;
1173
1176}
static struct GNUNET_CRYPTO_PublicKey pubkey
Public key of the zone to look in.
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_PrivateKey *pk)
Clear memory that was used to store a private key.
Definition crypto_pkey.c:47
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
static void send_message_to_room(struct GNUNET_MESSENGER_Room *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PrivateKey *key, const struct GNUNET_HashCode *epoch, struct GNUNET_HashCode *hash)
enum GNUNET_GenericReturnValue encrypt_message(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_CRYPTO_PublicKey *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_PrivateKey *sender, 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_key_get_public(), 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, pubkey, 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 1204 of file messenger_api.c.

1207{
1208 const struct GNUNET_MESSENGER_Handle *handle;
1209 struct GNUNET_MESSENGER_Message *message;
1210 const char *name;
1211
1212 GNUNET_assert ((cls) && (room));
1213
1214 handle = cls;
1215
1216 if (GNUNET_YES != room->use_handle_name)
1217 return GNUNET_YES;
1218
1220 if (! name)
1221 return GNUNET_YES;
1222
1223 message = create_message_name (name);
1224 if (! message)
1225 return GNUNET_NO;
1226
1227 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
1228 return GNUNET_YES;
1229}
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_PublicKey * get_non_anonymous_key ( const struct GNUNET_CRYPTO_PublicKey public_key)
static

Definition at line 1246 of file messenger_api.c.

1247{
1248 if (0 == GNUNET_memcmp (public_key, get_anonymous_public_key ()))
1249 return NULL;
1250
1251 return public_key;
1252}
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
const struct GNUNET_CRYPTO_PublicKey * 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 1266 of file messenger_api.c.

1269{
1270 const struct GNUNET_CRYPTO_PrivateKey *key;
1271 struct GNUNET_MESSENGER_Message *message;
1272
1273 GNUNET_assert ((cls) && (room));
1274
1275 key = cls;
1276
1277 message = create_message_key (key);
1278 if (! message)
1279 return GNUNET_NO;
1280
1281 enqueue_message_to_room (room, NULL, message, NULL, GNUNET_NO);
1282 return GNUNET_YES;
1283}
struct GNUNET_MESSENGER_Message * create_message_key(const struct GNUNET_CRYPTO_PrivateKey *key)
Creates and allocates a new key message containing the public key to change to derived from its priva...

References create_message_key(), enqueue_message_to_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 1407 of file messenger_api.c.

1410{
1411 struct GNUNET_MESSENGER_RoomFind *find;
1412 struct GNUNET_MESSENGER_Room *room;
1414
1415 GNUNET_assert ((cls) && (value));
1416
1417 find = cls;
1418 room = value;
1420
1421 if ((! find->contact) ||
1422 (GNUNET_YES == find_room_member (room, find->contact)))
1423 find->counter--;
1424
1425 if (find->callback)
1426 result = find->callback (find->cls, room, find->contact);
1427
1428 if (find->counter <= 0)
1429 result = GNUNET_NO;
1430
1431 return result;
1432}
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_PublicKey public_key 
)
static

Definition at line 1525 of file messenger_api.c.

1528{
1529 struct GNUNET_MESSENGER_Message *transcript;
1530 const struct GNUNET_CRYPTO_PublicKey *pubkey;
1531 const char *handle_name;
1532 char *original_name;
1533
1534 transcript = NULL;
1535
1536 if (GNUNET_MESSENGER_KIND_NAME != message->header.kind)
1537 goto skip_naming;
1538
1539 original_name = message->body.name.name;
1541 "Apply rule for using handle name in room: %s\n", GNUNET_h2s (
1542 get_room_key (room)));
1543
1544 handle_name = get_handle_name (room->handle);
1545
1546 if ((handle_name) && (GNUNET_YES == room->use_handle_name) &&
1547 ((! original_name) || (0 == strlen (original_name))))
1548 {
1549 if (original_name)
1550 GNUNET_free (original_name);
1551
1552 message->body.name.name = GNUNET_strdup (handle_name);
1553 }
1554
1555skip_naming:
1556 if (! public_key)
1557 goto skip_encryption;
1558
1560
1561 if (0 != GNUNET_memcmp (pubkey, public_key))
1562 transcript = transcribe_message (message, public_key);
1563
1564 if (GNUNET_YES != encrypt_message (message, public_key))
1565 {
1567 "Sending message aborted: Encryption failed!\n");
1568
1569 if (transcript)
1570 destroy_message (transcript);
1571
1572 destroy_message (message);
1573 return;
1574 }
1575
1576skip_encryption:
1577 enqueue_message_to_room (room, NULL, message, transcript, GNUNET_NO);
1578}
#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_PublicKey *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_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 1648 of file messenger_api.c.

1650{
1652 struct GNUNET_MQ_Envelope *env;
1653
1654 GNUNET_assert ((room) && (hash));
1655
1656 if (GNUNET_is_zero (hash))
1657 return;
1658
1659 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request message (%s)!\n",
1660 GNUNET_h2s (hash));
1661
1663 GNUNET_memcpy (&(msg->key), get_room_key (room), sizeof(msg->key));
1664 GNUNET_memcpy (&(msg->hash), hash, sizeof(*hash));
1665 GNUNET_MQ_send (room->handle->mq, env);
1666}
#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: