GNUnet  0.11.x
Functions
gnunet-service-messenger_util.h File Reference

GNUnet MESSENGER service. More...

#include "platform.h"
#include "gnunet_cadet_service.h"
#include "gnunet_container_lib.h"
#include "gnunet_crypto_lib.h"
Include dependency graph for gnunet-service-messenger_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void delayed_disconnect_channel (struct GNUNET_CADET_Channel *channel)
 Starts an urgent task to close a CADET channel asynchronously. More...
 
int generate_free_member_id (struct GNUNET_ShortHashCode *id, const struct GNUNET_CONTAINER_MultiShortmap *members)
 Tries to generate an unused member id and store it into the id parameter. More...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_util.h.

Function Documentation

◆ delayed_disconnect_channel()

void delayed_disconnect_channel ( struct GNUNET_CADET_Channel channel)

Starts an urgent task to close a CADET channel asynchronously.

Parameters
channelChannel

Definition at line 38 of file gnunet-service-messenger_util.c.

References callback_close_channel(), GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_URGENT, and GNUNET_TIME_relative_get_zero_().

Referenced by bind_tunnel(), callback_room_connect(), and disconnect_tunnel().

39 {
41  callback_close_channel, channel);
42 }
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:1199
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition: time.c:135
Run with priority for urgent tasks.
static void callback_close_channel(void *cls)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_free_member_id()

int generate_free_member_id ( struct GNUNET_ShortHashCode id,
const struct GNUNET_CONTAINER_MultiShortmap members 
)

Tries to generate an unused member id and store it into the id parameter.

A map containing all currently used member ids is used to check against.

Parameters
[out]idNew member id
membersMap of member ids
Returns
GNUNET_YES on success, GNUNET_NO on failure

Definition at line 45 of file gnunet-service-messenger_util.c.

References GNUNET_CONTAINER_multishortmap_contains(), GNUNET_CONTAINER_multishortmap_size(), GNUNET_CRYPTO_QUALITY_STRONG, GNUNET_CRYPTO_random_block(), GNUNET_NO, and GNUNET_YES.

Referenced by create_message_info(), generate_room_member_id(), and generate_service_new_member_id().

46 {
47  size_t counter = 1 + (members ? GNUNET_CONTAINER_multishortmap_size (members) : 0);
48 
49  do
50  {
52 
53  if ((members) && (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (members, id)))
54  counter--;
55  else
56  break;
57  }
58  while (counter > 0);
59 
60  if (counter)
61  return GNUNET_YES;
62 
63  return GNUNET_NO;
64 }
unsigned int GNUNET_CONTAINER_multishortmap_size(const struct GNUNET_CONTAINER_MultiShortmap *map)
Get the number of key-value pairs in the map.
A 256-bit hashcode.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
int GNUNET_CONTAINER_multishortmap_contains(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
High-quality operations are desired.
Here is the call graph for this function:
Here is the caller graph for this function: