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

GNUnet MESSENGER service. More...

#include "messenger_api_list_tunnels.h"
Include dependency graph for gnunet-service-messenger_basement.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

size_t count_of_tunnels (const struct GNUNET_MESSENGER_ListTunnels *tunnels)
 Returns the count of peers in a list (typically from the basement of a room). More...
 
int should_connect_tunnel_to (size_t count, size_t src, size_t dst)
 Returns GNUNET_YES or GNUNET_NO to determine if the peer at index src should or should not connect outgoing to the peer at index dst to construct a complete basement with a given count of peers. More...
 
int required_connection_between (size_t count, size_t src, size_t dst)
 Returns GNUNET_YES or GNUNET_NO to determine if the peers of index src and index dst should be connected in any direction to construct a complete basement with a given count of peers. More...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_basement.h.

Function Documentation

◆ count_of_tunnels()

size_t count_of_tunnels ( const struct GNUNET_MESSENGER_ListTunnels tunnels)

Returns the count of peers in a list (typically from the basement of a room).

Parameters
[in]tunnelsList of peer identities
Returns
Count of the entries in the list

Definition at line 29 of file gnunet-service-messenger_basement.c.

30 {
31  GNUNET_assert(tunnels);
32 
33  const struct GNUNET_MESSENGER_ListTunnel *element;
34  size_t count = 0;
35 
36  for (element = tunnels->head; element; element = element->next)
37  count++;
38 
39  return count;
40 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_ListTunnel * next
struct GNUNET_MESSENGER_ListTunnel * head

References GNUNET_assert, GNUNET_MESSENGER_ListTunnels::head, and GNUNET_MESSENGER_ListTunnel::next.

Referenced by rebuild_room_basement_structure().

Here is the caller graph for this function:

◆ should_connect_tunnel_to()

int should_connect_tunnel_to ( size_t  count,
size_t  src,
size_t  dst 
)

Returns GNUNET_YES or GNUNET_NO to determine if the peer at index src should or should not connect outgoing to the peer at index dst to construct a complete basement with a given count of peers.

Parameters
[in]countCount of peers
[in]srcSource index
[in]dstDestination index
Returns
GNUNET_YES or GNUNET_NO based on topologic requirement

Definition at line 43 of file gnunet-service-messenger_basement.c.

46 {
47  if ((src + 1) % count == dst % count)
48  return GNUNET_YES;
49 
50  return GNUNET_NO;
51 }
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94

References GNUNET_NO, and GNUNET_YES.

Referenced by required_connection_between().

Here is the caller graph for this function:

◆ required_connection_between()

int required_connection_between ( size_t  count,
size_t  src,
size_t  dst 
)

Returns GNUNET_YES or GNUNET_NO to determine if the peers of index src and index dst should be connected in any direction to construct a complete basement with a given count of peers.

Parameters
[in]countCount of peers
[in]srcSource index
[in]dstDestination index
Returns
GNUNET_YES or GNUNET_NO based on topologic requirement

Definition at line 54 of file gnunet-service-messenger_basement.c.

57 {
58  if (GNUNET_YES == should_connect_tunnel_to (count, src, dst))
59  return GNUNET_YES;
60  if (GNUNET_YES == should_connect_tunnel_to (count, dst, src))
61  return GNUNET_YES;
62 
63  return GNUNET_NO;
64 }
int should_connect_tunnel_to(size_t count, size_t src, size_t dst)
Returns GNUNET_YES or GNUNET_NO to determine if the peer at index src should or should not connect ou...

References GNUNET_NO, GNUNET_YES, and should_connect_tunnel_to().

Referenced by rebuild_room_basement_structure().

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