GNUnet 0.26.2-106-g126384b46
 
Loading...
Searching...
No Matches
gnunet-service-messenger_room.c File Reference
Include dependency graph for gnunet-service-messenger_room.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_ClosureSendRoom
 
struct  GNUNET_MESSENGER_MemberSubscriptionIteration
 
struct  GNUNET_MESSENGER_SrvMemberSessionCompletion
 
struct  GNUNET_MESSENGER_MemberUpdate
 

Functions

static void idle_request_room_messages (void *cls)
 
static void get_room_data_subdir (struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
 
struct GNUNET_MESSENGER_SrvRoomcreate_srv_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
 Creates and allocates a new room for a handle with a given key.
 
static enum GNUNET_GenericReturnValue iterate_destroy_tunnels (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 
static enum GNUNET_GenericReturnValue iterate_cancel_signature (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void close_srv_room (struct GNUNET_MESSENGER_SrvRoom *room)
 
static void handle_room_messages (struct GNUNET_MESSENGER_SrvRoom *room)
 
void destroy_srv_room (struct GNUNET_MESSENGER_SrvRoom *room, enum GNUNET_GenericReturnValue deletion)
 Destroys a room and frees its memory fully.
 
struct GNUNET_MESSENGER_PeerStoreget_srv_room_peer_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used peer store of a given room.
 
struct GNUNET_MESSENGER_MemberStoreget_srv_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used member store of a given room.
 
struct GNUNET_MESSENGER_MessageStoreget_srv_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used message store of a given room.
 
struct GNUNET_MESSENGER_OperationStoreget_srv_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used operation store of a given room.
 
static enum GNUNET_GenericReturnValue send_room_info (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
 
static void * callback_room_connect (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
 
static enum GNUNET_GenericReturnValue join_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ShortHashCode *id)
 
static enum GNUNET_GenericReturnValue join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
 
enum GNUNET_GenericReturnValue open_srv_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
 Tries to open a room for a given handle.
 
enum GNUNET_GenericReturnValue enter_srv_room_at (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door)
 Connects a tunnel to a hosting peer of a room through a so called door which is represented by a peer identity of a hosting peer.
 
static void callback_srv_room_sign_result (void *cls, const struct GNUNET_PeerIdentity *identity, const struct GNUNET_CRYPTO_EddsaSignature *peer_signature)
 
enum GNUNET_GenericReturnValue sign_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, GNUNET_MESSENGER_SignedCallback callback, void *closure)
 Packs a message depending on its kind into a newly allocated envelope.
 
enum GNUNET_GenericReturnValue update_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 
void callback_room_handle_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 
static void callback_srv_room_message_signed (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)
 
enum GNUNET_GenericReturnValue send_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
 Sends a message from a given handle into a room.
 
static enum GNUNET_GenericReturnValue iterate_send_room_envelope (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 
void send_srv_room_envelope (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)
 Sends an envelope from a message with a given hash excluding a specific tunnel inside of a room.
 
void check_srv_room_peer_status (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
 Checks the current state of opening a given room from this peer and re-publishes it if necessary to a selected tunnel or to all connected tunnels if necessary or if the selected tunnel is NULL.
 
enum GNUNET_GenericReturnValue merge_srv_room_last_messages (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
 Reduces all current forks inside of the message history of a room to one remaining last message by merging them down.
 
enum GNUNET_GenericReturnValue delete_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_HashCode *hash, const struct GNUNET_TIME_Relative delay)
 Deletes a message from the room with a given hash in a specific delay if the provided member by its session is permitted to do so.
 
struct GNUNET_CADET_Handleget_srv_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the CADET handle from a rooms service.
 
const struct GNUNET_HashCodeget_srv_room_key (const struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the shared secret you need to access a room.
 
const struct GNUNET_MESSENGER_SrvTunnelget_srv_room_tunnel (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *peer)
 Returns a tunnel inside of a room leading towards a given peer if such a tunnel exists, otherwise NULL.
 
static enum GNUNET_GenericReturnValue request_room_message_step (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_SrvMemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
 
enum GNUNET_GenericReturnValue request_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_SrvMemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
 Requests a message from a room identified by a given hash.
 
void solve_srv_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, const struct GNUNET_ShortHashCode *member_id, struct GNUNET_TIME_Absolute timestamp)
 Checks for potential collisions with member ids and solves them changing active handles ids if they use an already used member id (comparing public key and timestamp).
 
void rebuild_srv_room_basement_structure (struct GNUNET_MESSENGER_SrvRoom *room)
 Rebuilds the decentralized structure for a room by ensuring all required connections are made depending on the amount of peers and this peers index in the list of them.
 
uint32_t get_srv_room_amount_of_tunnels (const struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the amount of active tunnels of a given room.
 
uint32_t get_srv_room_connection_flags (const struct GNUNET_MESSENGER_SrvRoom *room)
 Returns connection flags about connection information of a given room and the service managing it.
 
static enum GNUNET_GenericReturnValue iterate_member_for_subscription (void *cls, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, struct GNUNET_MESSENGER_SrvMemberSession *session)
 
void cleanup_srv_room_discourse_messages (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *discourse)
 Cleanup discourse messages outside of current subscriptions from a specific discourse of all the members in a given room.
 
static enum GNUNET_GenericReturnValue iterate_update_member_sessions (void *cls, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, struct GNUNET_MESSENGER_SrvMemberSession *session)
 
static void remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvMemberSession *session)
 
void load_srv_room (struct GNUNET_MESSENGER_SrvRoom *room)
 Loads the local configuration for a given room of a service which contains the last messages hash and the ruleset for general access of new members.
 
void save_srv_room (struct GNUNET_MESSENGER_SrvRoom *room)
 Saves the configuration for a given room of a service which contains the last messages hash and the ruleset for general access of new members locally.
 
void remove_srv_room (struct GNUNET_MESSENGER_SrvRoom *room)
 Removes the configuration for a given room of a service.
 

Function Documentation

◆ idle_request_room_messages()

static void idle_request_room_messages ( void *  cls)
static

Definition at line 1135 of file gnunet-service-messenger_room.c.

1136{
1137 struct GNUNET_MESSENGER_SrvRoom *room;
1138 struct GNUNET_MESSENGER_OperationStore *operation_store;
1139 const struct GNUNET_HashCode *hash;
1140
1141 GNUNET_assert (cls);
1142
1143 room = cls;
1144 room->idle = NULL;
1145
1146 operation_store = get_srv_room_operation_store (room);
1147 hash = get_message_state_merge_hash (&(room->state));
1148
1149 if ((hash) && (! GNUNET_is_zero (hash)) &&
1151 hash)))
1153 operation_store,
1154 hash,
1157
1162 cls);
1163}
const struct GNUNET_HashCode * get_message_state_merge_hash(const struct GNUNET_MESSENGER_MessageState *state)
enum GNUNET_MESSENGER_OperationType get_store_operation_type(const struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash)
Returns the type of the active operation under a given hash in a specific operation store.
enum GNUNET_GenericReturnValue use_store_operation(struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_OperationType type, struct GNUNET_TIME_Relative delay)
Tries to use an operation under a given hash in a specific operation store.
static void idle_request_room_messages(void *cls)
struct GNUNET_MESSENGER_OperationStore * get_srv_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
#define GNUNET_MESSENGER_MERGE_DELAY
#define GNUNET_MESSENGER_IDLE_DELAY
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
@ GNUNET_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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
A 512-bit hashcode.
struct GNUNET_SCHEDULER_Task * idle
struct GNUNET_MESSENGER_MessageState state

References get_message_state_merge_hash(), get_srv_room_operation_store(), get_store_operation_type(), GNUNET_assert, GNUNET_is_zero, GNUNET_MESSENGER_IDLE_DELAY, GNUNET_MESSENGER_MERGE_DELAY, GNUNET_MESSENGER_OP_MERGE, GNUNET_MESSENGER_OP_UNKNOWN, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_MESSENGER_SrvRoom::idle, idle_request_room_messages(), GNUNET_MESSENGER_SrvRoom::state, and use_store_operation().

Referenced by create_srv_room(), and idle_request_room_messages().

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

◆ get_room_data_subdir()

static void get_room_data_subdir ( struct GNUNET_MESSENGER_SrvRoom room,
char **  dir 
)
static

Definition at line 53 of file gnunet-service-messenger_room.c.

55{
56 GNUNET_assert ((room) && (dir));
57
58 if (room->service->dir)
59 GNUNET_asprintf (dir, "%s%s%c%s%c", room->service->dir, "rooms",
62 else
63 *dir = NULL;
64}
static char * dir
Set to the directory where runtime files are stored.
Definition gnunet-arm.c:88
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define DIR_SEPARATOR
Definition platform.h:166
struct GNUNET_MESSENGER_Service * service

References dir, GNUNET_MESSENGER_Service::dir, DIR_SEPARATOR, get_srv_room_key(), GNUNET_asprintf(), GNUNET_assert, GNUNET_h2s(), and GNUNET_MESSENGER_SrvRoom::service.

Referenced by create_srv_room(), load_srv_room(), remove_room_member_session(), remove_srv_room(), and save_srv_room().

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

◆ create_srv_room()

struct GNUNET_MESSENGER_SrvRoom * create_srv_room ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key 
)

Creates and allocates a new room for a handle with a given key.

Parameters
[in,out]handleHandle
[in]keyKey of room
Returns
New room

Definition at line 68 of file gnunet-service-messenger_room.c.

70{
71 struct GNUNET_MESSENGER_SrvRoom *room;
72 char *room_dir;
73
74 GNUNET_assert ((handle) && (key));
75
76 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create new room: %s\n",
77 GNUNET_h2s (key));
78
80
81 room->service = handle->service;
82 room->host = handle;
83 room->sync = NULL;
84 room->port = NULL;
85
86 GNUNET_memcpy (&(room->key), key, sizeof(struct GNUNET_HashCode));
87
89
90 get_room_data_subdir (room, &room_dir);
91
93
98
99 GNUNET_free (room_dir);
100
101 init_list_tunnels (&(room->basement));
102 init_message_state (&(room->state));
103
104 room->peer_message = NULL;
105
106 init_list_messages (&(room->handling));
107 room->idle = NULL;
108
109 if (room->service->dir)
110 load_srv_room (room);
111
114
115 return room;
116}
struct GNUNET_HashCode key
The key used in the DHT.
void init_list_messages(struct GNUNET_MESSENGER_ListMessages *messages)
Initializes list of message hashes as empty list.
void init_member_store(struct GNUNET_MESSENGER_MemberStore *store, struct GNUNET_MESSENGER_SrvRoom *room)
Initializes a member store as fully empty connected to a room.
void init_message_state(struct GNUNET_MESSENGER_MessageState *state)
void init_message_store(struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
Initializes a message store as fully empty using a specific directory.
void init_operation_store(struct GNUNET_MESSENGER_OperationStore *store, struct GNUNET_MESSENGER_SrvRoom *room)
Initializes an operation store as fully empty with a given room.
void init_peer_store(struct GNUNET_MESSENGER_PeerStore *store, struct GNUNET_MESSENGER_Service *service)
Initializes a peer store as fully empty.
static void get_room_data_subdir(struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_PeerStore * get_srv_room_peer_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used peer store of a given room.
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
void load_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
Loads the local configuration for a given room of a service which contains the last messages hash and...
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
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
void init_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Initializes list of tunnels peer identities as empty list.
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
struct GNUNET_MESSENGER_SrvHandle * sync
struct GNUNET_MESSENGER_ListTunnels basement
struct GNUNET_MESSENGER_ListMessages handling
struct GNUNET_MESSENGER_SrvHandle * host
struct GNUNET_CONTAINER_MultiHashMap * signatures

References GNUNET_MESSENGER_SrvRoom::basement, GNUNET_MESSENGER_Service::dir, get_room_data_subdir(), get_srv_room_member_store(), get_srv_room_message_store(), get_srv_room_operation_store(), get_srv_room_peer_store(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multipeermap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, GNUNET_YES, handle, GNUNET_MESSENGER_SrvRoom::handling, GNUNET_MESSENGER_SrvRoom::host, GNUNET_MESSENGER_SrvRoom::idle, idle_request_room_messages(), init_list_messages(), init_list_tunnels(), init_member_store(), init_message_state(), init_message_store(), init_operation_store(), init_peer_store(), key, GNUNET_MESSENGER_SrvRoom::key, load_srv_room(), GNUNET_MESSENGER_SrvRoom::peer_message, GNUNET_MESSENGER_SrvRoom::port, GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_SrvRoom::signatures, GNUNET_MESSENGER_SrvRoom::state, GNUNET_MESSENGER_SrvRoom::sync, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by entry_service_room(), and open_service_room().

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

◆ iterate_destroy_tunnels()

static enum GNUNET_GenericReturnValue iterate_destroy_tunnels ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Definition at line 120 of file gnunet-service-messenger_room.c.

123{
124 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
125
127
128 tunnel = value;
129
130 destroy_tunnel (tunnel);
131 return GNUNET_YES;
132}
static char * value
Value of the record to add/remove.
static void destroy_tunnel(void *cls)
This tunnel is no longer used, destroy it.

References destroy_tunnel(), GNUNET_assert, GNUNET_YES, and value.

Referenced by destroy_srv_room().

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

◆ iterate_cancel_signature()

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

Definition at line 136 of file gnunet-service-messenger_room.c.

139{
140 struct GNUNET_MESSENGER_SrvRoomSignature *signature;
141
143
144 signature = value;
145
146 if (signature->operation)
147 GNUNET_PILS_cancel (signature->operation);
148
149 if (signature->message)
150 destroy_message (signature->message);
151
152 if (signature->envelope)
153 GNUNET_free (signature->envelope);
154
155 GNUNET_free (signature);
156 return GNUNET_YES;
157}
void GNUNET_PILS_cancel(struct GNUNET_PILS_Operation *op)
Cancel request.
Definition pils_api.c:623
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
struct GNUNET_MESSENGER_Message * message

References destroy_message(), GNUNET_MESSENGER_SrvRoomSignature::envelope, GNUNET_assert, GNUNET_free, GNUNET_PILS_cancel(), GNUNET_YES, GNUNET_MESSENGER_SrvRoomSignature::message, GNUNET_MESSENGER_SrvRoomSignature::operation, and value.

Referenced by destroy_srv_room(), and sign_srv_room_message().

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

◆ close_srv_room()

static void close_srv_room ( struct GNUNET_MESSENGER_SrvRoom room)
static

Definition at line 480 of file gnunet-service-messenger_room.c.

481{
482 struct GNUNET_PeerIdentity peer;
483
484 GNUNET_assert (room);
485
486 if (! room->port)
487 return;
488
489 if ((room->peer_message) &&
490 (GNUNET_OK == get_service_peer_identity (room->service, &peer)))
491 {
492 struct GNUNET_MESSENGER_Message *message;
493
494 message = create_message_miss (&peer);
495
496 if (! message)
498 "Sending miss message about peer failed: %s\n",
499 GNUNET_h2s (&(room->key)));
500 else
501 send_srv_room_message (room, room->host, message);
502 }
503
505 room->port = NULL;
506}
struct GNUNET_MESSENGER_Message * create_message_miss(const struct GNUNET_PeerIdentity *peer)
Creates and allocates a new miss message containing the missing peer identity.
enum GNUNET_GenericReturnValue send_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
enum GNUNET_GenericReturnValue get_service_peer_identity(struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer)
Tries to write the peer identity of the peer running a service on to the peer parameter.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port.
Definition cadet_api.c:804
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_ERROR
The identity of the host (wraps the signing key of the peer).

References create_message_miss(), get_service_peer_identity(), GNUNET_assert, GNUNET_CADET_close_port(), GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_MESSENGER_SrvRoom::host, GNUNET_MESSENGER_SrvRoom::key, GNUNET_MESSENGER_SrvRoom::peer_message, GNUNET_MESSENGER_SrvRoom::port, send_srv_room_message(), and GNUNET_MESSENGER_SrvRoom::service.

Referenced by destroy_srv_room(), open_srv_room(), and rebuild_srv_room_basement_structure().

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

◆ handle_room_messages()

static void handle_room_messages ( struct GNUNET_MESSENGER_SrvRoom room)
static

Definition at line 1320 of file gnunet-service-messenger_room.c.

1321{
1322 struct GNUNET_MESSENGER_MessageStore *message_store;
1323 struct GNUNET_MESSENGER_MemberStore *member_store;
1324 struct GNUNET_MESSENGER_PeerStore *peer_store;
1325 const struct GNUNET_HashCode *key;
1326
1327 message_store = get_srv_room_message_store (room);
1328 member_store = get_srv_room_member_store (room);
1329 peer_store = get_srv_room_peer_store (room);
1330
1331 key = get_srv_room_key (room);
1332
1334 "Handling room messages: %s\n", GNUNET_h2s (key));
1335
1336 while (room->handling.head)
1337 {
1338 struct GNUNET_MESSENGER_ListMessage *element;
1339 struct GNUNET_MESSENGER_SenderSession session;
1340 const struct GNUNET_MESSENGER_Message *message;
1341 const struct GNUNET_HashCode *epoch;
1342
1343 element = room->handling.head;
1344 message = get_store_message (
1345 message_store, &(element->hash));
1346
1347 if (! message)
1348 goto finish_handling;
1349
1350 if (GNUNET_YES == is_peer_message (message))
1351 {
1352 session.peer = get_store_peer_of (peer_store, message, &(element->hash));
1353
1354 if (! session.peer)
1355 goto finish_handling;
1356 }
1357 else
1358 {
1359 struct GNUNET_MESSENGER_Member *member;
1360
1361 member = get_store_member_of (member_store, message);
1362
1363 if (! member)
1364 goto finish_handling;
1365
1366 session.member = get_member_session_of (member, message,
1367 &(element->hash));
1368
1369 if (! session.member)
1370 goto finish_handling;
1371 }
1372
1373 epoch = get_store_message_epoch (message_store, &(element->hash));
1374
1375 handle_service_message (room->service, room, &session, message,
1376 &(element->hash), epoch, GNUNET_YES);
1377
1378finish_handling:
1380 element);
1381 GNUNET_free (element);
1382 }
1383}
struct GNUNET_MESSENGER_SrvMemberSession * get_member_session_of(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Returns the member session of a member using a public key which can verify the signature of a given m...
struct GNUNET_MESSENGER_Member * get_store_member_of(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_MESSENGER_Message *message)
Returns the member of a store using a sender id of a given message.
const struct GNUNET_HashCode * get_store_message_epoch(const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the epoch hash of a message from a message store matching a given hash.
const struct GNUNET_MESSENGER_Message * get_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the message from a message store matching a given hash.
struct GNUNET_PeerIdentity * get_store_peer_of(struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Returns the peer identity inside the store which verifies the signature of a given message as valid.
void handle_service_message(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch, enum GNUNET_GenericReturnValue recent)
Sends a received or sent message with a given hash to each handle of a service which is currently mem...
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
enum GNUNET_GenericReturnValue is_peer_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message can be sent by the service without usage of a clients priv...
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_ListMessage * tail

References get_member_session_of(), get_srv_room_key(), get_srv_room_member_store(), get_srv_room_message_store(), get_srv_room_peer_store(), get_store_member_of(), get_store_message(), get_store_message_epoch(), get_store_peer_of(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_YES, handle_service_message(), GNUNET_MESSENGER_SrvRoom::handling, GNUNET_MESSENGER_ListMessage::hash, GNUNET_MESSENGER_ListMessages::head, is_peer_message(), key, GNUNET_MESSENGER_SenderSession::member, GNUNET_MESSENGER_SenderSession::peer, GNUNET_MESSENGER_SrvRoom::service, and GNUNET_MESSENGER_ListMessages::tail.

Referenced by callback_room_handle_message(), and destroy_srv_room().

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

◆ destroy_srv_room()

void destroy_srv_room ( struct GNUNET_MESSENGER_SrvRoom room,
enum GNUNET_GenericReturnValue  deletion 
)

Destroys a room and frees its memory fully.

The deletion flag should only be set to GNUNET_YES if the room gets dropped by the service, otherwise GNUNET_NO.

Parameters
[in,out]roomRoom
[in]deletionFlag to indicate context of destruction

Definition at line 167 of file gnunet-service-messenger_room.c.

169{
170 GNUNET_assert (room);
171
172 if (room->idle)
173 {
175 room->idle = NULL;
176 }
177
178 close_srv_room (room);
179
181 NULL);
183
184 if (! (room->service->dir))
185 goto skip_saving;
186
187 if (GNUNET_YES == deletion)
188 remove_srv_room (room);
189 else
190 save_srv_room (room);
191
192skip_saving:
197
200 room);
202
204 clear_list_tunnels (&(room->basement));
205 clear_message_state (&(room->state));
206
207 if (room->peer_message)
209
210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Free room: %s\n",
211 GNUNET_h2s (&(room->key)));
212
213 GNUNET_free (room);
214}
void clear_member_store(struct GNUNET_MESSENGER_MemberStore *store)
Clears a member store, wipes its content and deallocates its memory.
void clear_message_state(struct GNUNET_MESSENGER_MessageState *state)
void clear_message_store(struct GNUNET_MESSENGER_MessageStore *store)
Clears a message store, wipes its content and deallocates its memory.
void clear_operation_store(struct GNUNET_MESSENGER_OperationStore *store)
Clears an operation store, stops all operations and deallocates its memory.
void clear_peer_store(struct GNUNET_MESSENGER_PeerStore *store)
Clears a peer store, wipes its content and deallocates its memory.
static enum GNUNET_GenericReturnValue iterate_destroy_tunnels(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
void save_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
Saves the configuration for a given room of a service which contains the last messages hash and the r...
static enum GNUNET_GenericReturnValue iterate_cancel_signature(void *cls, const struct GNUNET_HashCode *key, void *value)
void remove_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
Removes the configuration for a given room of a service.
static void handle_room_messages(struct GNUNET_MESSENGER_SrvRoom *room)
static void close_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
void clear_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Clears the list of tunnels peer identities.

References GNUNET_MESSENGER_SrvRoom::basement, clear_list_tunnels(), clear_member_store(), clear_message_state(), clear_message_store(), clear_operation_store(), clear_peer_store(), close_srv_room(), GNUNET_MESSENGER_Service::dir, get_srv_room_member_store(), get_srv_room_message_store(), get_srv_room_operation_store(), get_srv_room_peer_store(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_SCHEDULER_cancel(), GNUNET_YES, handle_room_messages(), GNUNET_MESSENGER_SrvRoom::idle, iterate_cancel_signature(), iterate_destroy_tunnels(), GNUNET_MESSENGER_SrvRoom::key, GNUNET_MESSENGER_SrvRoom::peer_message, remove_srv_room(), GNUNET_MESSENGER_SrvRoomSignature::room, save_srv_room(), GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_SrvRoom::signatures, GNUNET_MESSENGER_SrvRoom::state, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by close_service_room(), entry_service_room(), iterate_destroy_rooms(), and open_service_room().

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

◆ get_srv_room_peer_store()

struct GNUNET_MESSENGER_PeerStore * get_srv_room_peer_store ( struct GNUNET_MESSENGER_SrvRoom room)

Returns the used peer store of a given room.

Parameters
[in,out]roomRoom
Returns
Peer store

Definition at line 218 of file gnunet-service-messenger_room.c.

219{
220 GNUNET_assert (room);
221
222 return &(room->peer_store);
223}
struct GNUNET_MESSENGER_PeerStore peer_store

References GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::peer_store.

Referenced by callback_found_message(), callback_room_handle_message(), create_srv_room(), destroy_srv_room(), handle_message_miss(), handle_message_peer(), handle_room_messages(), load_srv_room(), save_srv_room(), and traverse_epoch_session_message().

Here is the caller graph for this function:

◆ get_srv_room_member_store()

struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store ( struct GNUNET_MESSENGER_SrvRoom room)

Returns the used member store of a given room.

Parameters
[in,out]roomRoom
Returns
Member store

Definition at line 227 of file gnunet-service-messenger_room.c.

228{
229 GNUNET_assert (room);
230
231 return &(room->member_store);
232}
struct GNUNET_MESSENGER_MemberStore member_store

References GNUNET_assert, GNUNET_MESSENGER_SrvRoom::member_store, and GNUNET_MESSENGER_MemberStore::room.

Referenced by callback_found_message(), callback_room_handle_message(), cleanup_srv_room_discourse_messages(), create_srv_room(), destroy_srv_room(), get_handle_member_session(), handle_get_message(), handle_room_messages(), initialize_service_handle(), join_room_locally(), load_srv_room(), notify_srv_handle_message(), open_srv_room(), recv_message_info(), recv_message_request(), save_srv_room(), send_message_join(), solve_srv_room_member_collisions(), and traverse_epoch_session_message().

Here is the caller graph for this function:

◆ get_srv_room_message_store()

struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store ( struct GNUNET_MESSENGER_SrvRoom room)

◆ get_srv_room_operation_store()

struct GNUNET_MESSENGER_OperationStore * get_srv_room_operation_store ( struct GNUNET_MESSENGER_SrvRoom room)

Returns the used operation store of a given room.

Parameters
[in,out]roomRoom
Returns
Operation store

Definition at line 245 of file gnunet-service-messenger_room.c.

246{
247 GNUNET_assert (room);
248
249 return &(room->operation_store);
250}
struct GNUNET_MESSENGER_OperationStore operation_store

References GNUNET_assert, GNUNET_MESSENGER_SrvRoom::operation_store, and GNUNET_MESSENGER_OperationStore::room.

Referenced by callback_found_message(), create_srv_room(), delete_srv_room_message(), destroy_srv_room(), idle_request_room_messages(), load_srv_room(), save_srv_room(), send_message_request(), update_room_message(), and update_tunnel_last_message().

Here is the caller graph for this function:

◆ send_room_info()

static enum GNUNET_GenericReturnValue send_room_info ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_SrvTunnel tunnel 
)
static

Definition at line 254 of file gnunet-service-messenger_room.c.

257{
258 if ((! handle) || (! is_tunnel_connected (tunnel)))
259 return GNUNET_NO;
260
262 room->service));
263}
struct GNUNET_MESSENGER_Message * create_message_info(struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new info message containing the hosts service peer identity and version.
enum GNUNET_GenericReturnValue is_tunnel_connected(const struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Returns the status of a currently bound channel of a tunnel.
enum GNUNET_GenericReturnValue send_tunnel_message(struct GNUNET_MESSENGER_SrvTunnel *tunnel, void *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message by packing it automatically into an envelope and passing it through the tunnel.

References create_message_info(), GNUNET_NO, handle, is_tunnel_connected(), GNUNET_MESSENGER_OperationStore::room, send_tunnel_message(), and GNUNET_MESSENGER_SrvRoom::service.

Referenced by callback_room_connect().

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

◆ callback_room_connect()

static void * callback_room_connect ( void *  cls,
struct GNUNET_CADET_Channel channel,
const struct GNUNET_PeerIdentity source 
)
static

Definition at line 267 of file gnunet-service-messenger_room.c.

270{
271 struct GNUNET_MESSENGER_SrvRoom *room;
272 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
273
274 GNUNET_assert ((cls) && (channel) && (source));
275
276 room = cls;
277
279 "New incoming connection to room (%s) from peer: %s\n",
281
282 tunnel = create_tunnel (room, source);
283
284 if ((tunnel) &&
286 tunnel,
288 {
289 destroy_tunnel (tunnel);
290 tunnel = NULL;
291 }
292
293 if (! tunnel)
294 {
296 return NULL;
297 }
298
299 bind_tunnel (tunnel, channel);
300
302 "New tunnel in room (%s) established to peer: %s\n",
304
305 if (GNUNET_YES == send_room_info (room, room->host, tunnel))
306 return tunnel;
307
308 disconnect_tunnel (tunnel);
309
311 tunnel))
312 destroy_tunnel (tunnel);
313
314 return NULL;
315}
static GstElement * source
Appsrc instance into which we write data for the pipeline.
static enum GNUNET_GenericReturnValue send_room_info(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
void bind_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_CADET_Channel *channel)
Binds a CADET channel to a tunnel and replaces its channel the tunnel is currently bound to if necess...
struct GNUNET_MESSENGER_SrvTunnel * create_tunnel(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_PeerIdentity *door)
Creates and allocates a tunnel of a room to a specific peer identity (called door).
void disconnect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Disconnects and unbinds a channel from a tunnel.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void delayed_disconnect_channel(struct GNUNET_CADET_Channel *channel)
Starts an urgent task to close a CADET channel asynchronously.
struct GNUNET_CADET_Channel * channel
struct GNUNET_MESSENGER_SrvRoom * room

References bind_tunnel(), GNUNET_MESSENGER_SrvTunnel::channel, create_tunnel(), delayed_disconnect_channel(), destroy_tunnel(), disconnect_tunnel(), get_srv_room_key(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_SrvRoom::host, GNUNET_MESSENGER_SrvTunnel::room, send_room_info(), source, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by open_srv_room().

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

◆ join_room()

static enum GNUNET_GenericReturnValue join_room ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_Member member,
const struct GNUNET_ShortHashCode id 
)
static

Definition at line 319 of file gnunet-service-messenger_room.c.

323{
324 const struct GNUNET_ShortHashCode *member_id;
325
326 GNUNET_assert ((room) && (handle) && (member));
327
328 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (
329 get_srv_room_key (room)),
330 GNUNET_sh2s (get_member_id (member)));
331
332 member_id = get_member_id (member);
333
335 member_id))
336 return GNUNET_NO;
337
338 {
340 if ((! id) || (0 != GNUNET_memcmp (id, member_id)))
342 else
344
345 notify_srv_handle_member_id (handle, room, member_id, reset);
346 }
347
348 return GNUNET_YES;
349}
static int reset
Reset argument.
enum GNUNET_GenericReturnValue change_srv_handle_member_id(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *unique_id)
Changes the member id of a given handle in a specific room to match a unique_id and returns GNUNET_OK...
void notify_srv_handle_member_id(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *member_id, enum GNUNET_GenericReturnValue reset)
Notifies the handle that a new member id needs to be used.
const struct GNUNET_ShortHashCode * get_member_id(const struct GNUNET_MESSENGER_Member *member)
Returns the current id of a given member.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
GNUNET_GenericReturnValue
Named constants for return values.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
A 256-bit hashcode.

References change_srv_handle_member_id(), get_member_id(), get_srv_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, handle, notify_srv_handle_member_id(), and reset.

Referenced by join_room_locally(), and open_srv_room().

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

◆ join_room_locally()

static enum GNUNET_GenericReturnValue join_room_locally ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle 
)
static

Definition at line 353 of file gnunet-service-messenger_room.c.

355{
356 struct GNUNET_MESSENGER_MemberStore *member_store;
357 const struct GNUNET_ShortHashCode *member_id;
358 struct GNUNET_MESSENGER_Member *member;
359
360 member_store = get_srv_room_member_store (room);
362 member = add_store_member (member_store, member_id);
363
364 if (GNUNET_NO == join_room (room, handle, member, member_id))
365 return GNUNET_NO;
366
367 return GNUNET_YES;
368}
const struct GNUNET_ShortHashCode * get_srv_handle_member_id(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns the member id of a given handle in a specific room.
struct GNUNET_MESSENGER_Member * add_store_member(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Adds a member to a store under a specific id and returns it on success.
static enum GNUNET_GenericReturnValue join_room(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ShortHashCode *id)

References add_store_member(), get_srv_handle_member_id(), get_srv_room_key(), get_srv_room_member_store(), GNUNET_NO, GNUNET_YES, handle, and join_room().

Referenced by enter_srv_room_at(), and open_srv_room().

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

◆ open_srv_room()

enum GNUNET_GenericReturnValue open_srv_room ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle 
)

Tries to open a room for a given handle.

If the room has already been opened, the handle will locally join the room.

Calling this method should result in joining a room and sending a peer message as well for this peer.

If the function returns GNUNET_YES the port for this room is guaranteed to be open for incoming connections.

Parameters
[in,out]roomRoom
[in,out]handleHandle
Returns
GNUNET_YES on success, GNUNET_NO on failure.

Definition at line 372 of file gnunet-service-messenger_room.c.

374{
375 GNUNET_assert (room);
376
377 if (handle)
378 room->host = handle;
379
380 if (room->port)
381 {
383 "Port of room (%s) was already open!\n",
385
386 if (! handle)
387 return GNUNET_YES;
388
389 return join_room_locally (room, handle);
390 }
391
392 {
395 struct GNUNET_HashCode port;
396
398 tunnel_message,
400 struct
402 ,
404
405 cadet = get_srv_room_cadet (room);
406
408 &(key.hash),
409 get_srv_room_key (room),
410 sizeof (key.hash));
411
412 if ((key.code.feed_bit) && (! key.code.group_bit))
413 {
415 "Opening port of personal room containing private feeds failed!");
416 return GNUNET_SYSERR;
417 }
418
420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to open CADET port: %s\n",
421 GNUNET_h2s (&port));
422
424 room, NULL, callback_tunnel_disconnect,
425 handlers);
426 }
427
428 if (room->port)
429 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Port of room (%s) was opened!\n",
431 else
433 "Port of room (%s) could not be opened!\n",
435
436 if (! handle)
437 goto complete_opening;
438
439 {
440 struct GNUNET_MESSENGER_MemberStore *member_store;
441 const struct GNUNET_ShortHashCode *member_id;
442 struct GNUNET_MESSENGER_Member *member;
443
444 member_store = get_srv_room_member_store (room);
446 member = add_store_member (member_store, member_id);
447
448 if ((GNUNET_NO == join_room (room, handle, member, member_id)) &&
449 (room->port))
450 {
452 "You could not join the room, therefore it keeps closed!\n");
453
454 close_srv_room (room);
455 return GNUNET_NO;
456 }
457 }
458
459complete_opening:
460 if (! room->port)
461 return GNUNET_NO;
462
463 {
464 struct GNUNET_MESSENGER_Message *message;
465 message = create_message_peer (room->service);
466
467 if (! message)
468 {
470 "Peer message could not be sent!\n");
471 return GNUNET_NO;
472 }
473
474 return send_srv_room_message (room, handle, message);
475 }
476}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition 003.c:1
static uint16_t port
Port number.
Definition gnunet-bcd.c:146
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
struct GNUNET_MESSENGER_Message * create_message_peer(struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new peer message containing a services peer identity.
static void * callback_room_connect(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
static enum GNUNET_GenericReturnValue join_room_locally(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
struct GNUNET_CADET_Handle * get_srv_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
void callback_tunnel_disconnect(void *cls, const struct GNUNET_CADET_Channel *channel)
Callback for a CADET channel disconnecting to manage this event as a proper tunnel provided as its cl...
struct GNUNET_CADET_Port * GNUNET_CADET_open_port(struct GNUNET_CADET_Handle *h, const struct GNUNET_HashCode *port, GNUNET_CADET_ConnectEventHandler connects, void *connects_cls, GNUNET_CADET_WindowSizeEventHandler window_changes, GNUNET_CADET_DisconnectEventHandler disconnects, const struct GNUNET_MQ_MessageHandler *handlers)
Open a port to receive incoming MQ-based channels.
Definition cadet_api.c:966
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
void convert_messenger_key_to_port(const union GNUNET_MESSENGER_RoomKey *key, struct GNUNET_HashCode *port)
Converts a Messenger service key of a room to the specific port which gets used for the CADET channel...
Opaque handle to the service.
Definition cadet_api.c:39
Message handler for a specific message type.
Header for all communications.
A room key unifies a room key code and its 512bit hash representation.

References add_store_member(), cadet, callback_room_connect(), callback_tunnel_disconnect(), close_srv_room(), convert_messenger_key_to_port(), create_message_peer(), get_srv_handle_member_id(), get_srv_room_cadet(), get_srv_room_key(), get_srv_room_member_store(), GNUNET_assert, GNUNET_CADET_open_port(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CADET_CLI, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, handle, handlers, GNUNET_MESSENGER_SrvRoom::host, join_room(), join_room_locally(), key, port, GNUNET_MESSENGER_SrvRoom::port, send_srv_room_message(), and GNUNET_MESSENGER_SrvRoom::service.

Referenced by open_service_room(), and recv_message_miss().

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

◆ enter_srv_room_at()

enum GNUNET_GenericReturnValue enter_srv_room_at ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_PeerIdentity door 
)

Connects a tunnel to a hosting peer of a room through a so called door which is represented by a peer identity of a hosting peer.

During the connection the handle will join the room as a member, waiting for an info message from the selected host.

Parameters
[in,out]roomRoom
[in,out]handleHandle
[in]doorPeer identity
Returns
GNUNET_YES on success, GNUNET_NO on failure.

Definition at line 510 of file gnunet-service-messenger_room.c.

513{
514 struct GNUNET_PeerIdentity peer;
515 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
516
517 GNUNET_assert ((room) && (handle) && (door));
518
520 (0 == GNUNET_memcmp (&peer, door)))
521 return join_room_locally (room, handle);
522
524
525 if (! tunnel)
526 {
527 tunnel = create_tunnel (room, door);
528
530 tunnel,
532 {
534 "You could not connect to that door!\n");
535 destroy_tunnel (tunnel);
536 return GNUNET_NO;
537 }
538 }
539
540 if (GNUNET_SYSERR == connect_tunnel (tunnel))
541 {
543 "Connection failure during entrance!\n");
545 destroy_tunnel (tunnel);
546 return GNUNET_NO;
547 }
548
549 return join_room_locally (room, handle);
550}
enum GNUNET_GenericReturnValue connect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Tries to connect a tunnel by creating a new CADET channel and binding it.
void * GNUNET_CONTAINER_multipeermap_get(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Given a key find a value in the map matching the key.

References connect_tunnel(), create_tunnel(), destroy_tunnel(), get_service_peer_identity(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_get(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, handle, join_room_locally(), GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_SrvTunnel::room, GNUNET_MESSENGER_SrvRoom::service, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by callback_tunnel_disconnect(), and entry_service_room().

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

◆ callback_srv_room_sign_result()

static void callback_srv_room_sign_result ( void *  cls,
const struct GNUNET_PeerIdentity identity,
const struct GNUNET_CRYPTO_EddsaSignature peer_signature 
)
static

Definition at line 554 of file gnunet-service-messenger_room.c.

558{
559 struct GNUNET_MESSENGER_SrvRoomSignature *signature;
560 struct GNUNET_MessageHeader *header;
561 uint16_t padded_length;
562 char *buffer;
563
564 GNUNET_assert ((cls) && (peer_signature));
565
566 signature = cls;
567
569 "Signature operation with peer identity (%s) completed: %s\n",
571 GNUNET_h2s (&(signature->hash)));
572
573 GNUNET_assert (signature->operation);
574 signature->operation = NULL;
575
576 GNUNET_assert ((signature->room) && (signature->message) && (signature->
577 envelope));
578
580 peer_signature, sizeof (*peer_signature));
581
582 header = (struct GNUNET_MessageHeader *) GNUNET_MQ_env_get_msg (signature->
583 envelope);
584 padded_length = header->size - sizeof (*header);
585 buffer = (char *) &(header[1]);
586
587 encode_message_signature (signature->message, padded_length, buffer);
588
589 GNUNET_assert (signature->callback);
590 signature->callback (signature->closure,
591 signature->room,
592 signature->message,
593 signature->envelope,
594 &(signature->hash));
595
597 signatures,
598 &(signature->hash),
599 signature))
600 {
601 signature->message = NULL;
602 signature->envelope = NULL;
603
605 "Signature operation could not be removed: %s\n",
606 GNUNET_h2s (&(signature->hash)));
607 return;
608 }
609
610 GNUNET_free (signature);
611}
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
const struct GNUNET_MessageHeader * GNUNET_MQ_env_get_msg(const struct GNUNET_MQ_Envelope *env)
Obtain message contained in envelope.
Definition mq.c:896
void encode_message_signature(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer)
Encodes the signature of a given message into a buffer of a maximum length in bytes.
struct GNUNET_CRYPTO_EddsaSignature eddsa_signature
AN EdDSA signature.
struct GNUNET_CRYPTO_BlindableKeySignature signature
The signature of the senders private key.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_SrvRoom * room

References GNUNET_MESSENGER_SrvRoomSignature::callback, GNUNET_MESSENGER_SrvRoomSignature::closure, GNUNET_CRYPTO_BlindableKeySignature::eddsa_signature, encode_message_signature(), GNUNET_MESSENGER_SrvRoomSignature::envelope, GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MQ_env_get_msg(), GNUNET_YES, GNUNET_MESSENGER_SrvRoomSignature::hash, GNUNET_MESSENGER_Message::header, identity, GNUNET_MESSENGER_SrvRoomSignature::message, GNUNET_MESSENGER_SrvRoomSignature::operation, GNUNET_MESSENGER_SrvRoomSignature::room, GNUNET_MESSENGER_MessageHeader::signature, and GNUNET_MessageHeader::size.

Referenced by sign_srv_room_message().

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

◆ sign_srv_room_message()

enum GNUNET_GenericReturnValue sign_srv_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_Message message,
GNUNET_MESSENGER_SignedCallback  callback,
void *  closure 
)

Packs a message depending on its kind into a newly allocated envelope.

It will set the timestamp of the message, the sender id and the previous messages hash automatically before packing. The message will be signed by the peers private key if necessary.

When the message has been signed, the message and the packed envelope are passed into the provided callback which is required.

Parameters
[in,out]roomRoom
[in,out]messageMessage
[in]callbackCallback of signature
[in,out]closureClosure
Returns
GNUNET_YES on success, GNUNET_SYSERR on failure and GNUNET_NO otherwise.

Definition at line 615 of file gnunet-service-messenger_room.c.

619{
620 struct GNUNET_MESSENGER_SrvRoomSignature *signature;
622
623 GNUNET_assert ((room) && (message) && (callback));
624
625 if (GNUNET_YES != is_peer_message (message))
626 {
627 struct GNUNET_MQ_Envelope *envelope;
628 struct GNUNET_HashCode hash;
629
630 envelope = pack_message (message, &hash,
632
633 if (! envelope)
634 {
636 "Packing message into envelope failed: %s\n",
638 return GNUNET_SYSERR;
639 }
640
641 callback (closure, room, message, envelope, &hash);
642 return GNUNET_YES;
643 }
644
645 if (GNUNET_YES == is_epoch_message (message))
648 else
651
653 {
654 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer identity is missing!\n");
655 return GNUNET_SYSERR;
656 }
657
659 get_message_state_chain_hash (&(room->state), &(message->header.previous));
660
662 {
663 const struct GNUNET_MESSENGER_MessageStore *store;
664 const struct GNUNET_HashCode *epoch;
665
666 store = get_srv_room_message_store (room);
667 epoch = get_store_message_epoch (store, &(message->header.previous));
668
669 if (epoch)
670 GNUNET_memcpy (&(message->body.merge.epochs[0]), epoch,
671 sizeof (struct GNUNET_HashCode));
672
673 epoch = get_store_message_epoch (store, &(message->body.merge.previous));
674
675 if (epoch)
676 GNUNET_memcpy (&(message->body.merge.epochs[1]), epoch,
677 sizeof (struct GNUNET_HashCode));
678 }
679
681 GNUNET_assert (signature);
682
683 signature->room = room;
684 signature->message = message;
685
687 "Packing message with peer signature: %s\n",
688 GNUNET_sh2s (&(signature->message->header.sender_id)));
689
691 signature->envelope = pack_message (signature->message, &(signature->hash),
693
694 if (! signature->envelope)
695 {
697 "Packing message into envelope failed: %s\n",
699 ;
700 destroy_message (signature->message);
701 GNUNET_free (signature);
702 return GNUNET_SYSERR;
703 }
704
705 signature->callback = callback;
706 signature->closure = closure;
707
708 signature->operation = sign_message_by_peer (signature->message,
709 &(signature->hash),
710 room->service->pils,
712 signature);
713
714 if (! signature->operation)
715 {
717 "Signing message by peer identity (%s) failed: %s\n",
719 GNUNET_h2s (&(signature->hash)));
720
721 destroy_message (signature->message);
722 GNUNET_free (signature->envelope);
723 GNUNET_free (signature);
724 return GNUNET_SYSERR;
725 }
726
728 &(signature->hash),
729 signature,
731 {
733 "Signature operation could not be stored: %s\n",
734 GNUNET_h2s (&(signature->hash)));
735
736 iterate_cancel_signature (NULL, &(signature->hash),
737 signature);
738 return GNUNET_SYSERR;
739 }
740
741 return GNUNET_YES;
742}
void get_message_state_chain_hash(const struct GNUNET_MESSENGER_MessageState *state, struct GNUNET_HashCode *hash)
static void callback_srv_room_sign_result(void *cls, const struct GNUNET_PeerIdentity *identity, const struct GNUNET_CRYPTO_EddsaSignature *peer_signature)
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
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
struct GNUNET_MQ_Envelope * pack_message(struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_PackMode mode)
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_P...
struct GNUNET_PILS_Operation * sign_message_by_peer(struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, struct GNUNET_PILS_Handle *pils, const GNUNET_PILS_SignResultCallback sign_cb, void *cls)
Signs the hash of a message with the peer identity of a given pils service going into a callback with...
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...
@ GNUNET_MESSENGER_PACK_MODE_ENVELOPE
void convert_peer_identity_to_id(const struct GNUNET_PeerIdentity *identity, struct GNUNET_ShortHashCode *id)
Converts a peers identity to a short hash code which can be used as id to refer to a peer via sender ...
struct GNUNET_MESSENGER_MessageMerge merge
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_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 previous
The hash of a second previous message.
struct GNUNET_HashCode epochs[2]
The previous epochs the message was sent from.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_SrvRoomSignature::callback, callback_srv_room_sign_result(), GNUNET_MESSENGER_SrvRoomSignature::closure, convert_peer_identity_to_id(), destroy_message(), GNUNET_MESSENGER_SrvRoomSignature::envelope, GNUNET_MESSENGER_MessageMerge::epochs, get_message_state_chain_hash(), get_service_peer_identity(), get_srv_room_message_store(), get_store_message_epoch(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_i2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_name_of_kind(), GNUNET_MESSENGER_PACK_MODE_ENVELOPE, GNUNET_new, GNUNET_OK, GNUNET_PUBLIC_KEY_TYPE_EDDSA, GNUNET_sh2s(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_zero_(), GNUNET_TIME_absolute_hton(), GNUNET_YES, GNUNET_MESSENGER_SrvRoomSignature::hash, GNUNET_MESSENGER_Message::header, identity, is_epoch_message(), is_peer_message(), iterate_cancel_signature(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_SrvRoomSignature::message, GNUNET_MESSENGER_SrvRoomSignature::operation, pack_message(), GNUNET_MESSENGER_Service::pils, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageMerge::previous, GNUNET_MESSENGER_SrvRoomSignature::room, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_SrvRoom::service, sign_message_by_peer(), GNUNET_MESSENGER_MessageHeader::signature, GNUNET_MESSENGER_SrvRoom::signatures, GNUNET_MESSENGER_SrvRoom::state, GNUNET_MESSENGER_MessageHeader::timestamp, and GNUNET_CRYPTO_BlindableKeySignature::type.

Referenced by send_srv_room_message(), and send_tunnel_message().

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

◆ update_room_message()

enum GNUNET_GenericReturnValue update_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Definition at line 1387 of file gnunet-service-messenger_room.c.

1390{
1391 struct GNUNET_MESSENGER_OperationStore *operation_store;
1392 struct GNUNET_MESSENGER_MessageStore *message_store;
1393 enum GNUNET_GenericReturnValue requested;
1394
1395 GNUNET_assert ((room) && (message) && (hash));
1396
1397 operation_store = get_srv_room_operation_store (room);
1398
1399 requested = (GNUNET_MESSENGER_OP_REQUEST ==
1400 get_store_operation_type (operation_store, hash)?
1402
1403 if (GNUNET_YES == requested)
1404 cancel_store_operation (operation_store, hash);
1405
1406 message_store = get_srv_room_message_store (room);
1407
1408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle a message in room (%s).\n",
1409 GNUNET_h2s (get_srv_room_key (room)));
1410
1411 if (GNUNET_YES == contains_store_message (message_store, hash))
1412 {
1413 destroy_message (message);
1414
1415 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Duplicate message got dropped!\n");
1416 return GNUNET_NO;
1417 }
1418
1419 if (GNUNET_OK != put_store_message (message_store, hash, message))
1420 {
1421 destroy_message (message);
1422
1423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing message failed!\n");
1424 return GNUNET_NO;
1425 }
1426
1427 update_message_state (&(room->state), requested, message, hash);
1428
1429 if ((GNUNET_YES == requested) ||
1430 (GNUNET_MESSENGER_KIND_INFO == message->header.kind) ||
1432 return GNUNET_YES;
1433
1434 if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
1436 &(message->body.
1437 merge.previous))
1438 ))
1439 cancel_store_operation (operation_store, &(message->body.merge.previous));
1440
1442 &(message->header.
1443 previous)))
1444 cancel_store_operation (operation_store, &(message->header.previous));
1445
1446 return GNUNET_YES;
1447}
void update_message_state(struct GNUNET_MESSENGER_MessageState *state, enum GNUNET_GenericReturnValue requested, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
enum GNUNET_GenericReturnValue contains_store_message(const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Checks if a message matching a given hash is stored in a message store.
enum GNUNET_GenericReturnValue put_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, struct GNUNET_MESSENGER_Message *message)
Stores a message into the message store.
void cancel_store_operation(struct GNUNET_MESSENGER_OperationStore *store, const struct GNUNET_HashCode *hash)
Stops any active operation under a given hash in a specific operation store.
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.

References GNUNET_MESSENGER_Message::body, cancel_store_operation(), contains_store_message(), destroy_message(), get_srv_room_key(), get_srv_room_message_store(), get_srv_room_operation_store(), get_store_operation_type(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_OP_MERGE, GNUNET_MESSENGER_OP_REQUEST, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageMerge::previous, put_store_message(), GNUNET_MESSENGER_SrvRoom::state, and update_message_state().

Referenced by callback_srv_room_message_signed(), handle_tunnel_message(), and it_handle_epoch_message_delayed().

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

◆ callback_room_handle_message()

void callback_room_handle_message ( struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Definition at line 1563 of file gnunet-service-messenger_room.c.

1566{
1567 struct GNUNET_MESSENGER_PeerStore *peer_store;
1568 struct GNUNET_MESSENGER_MemberStore *member_store;
1569 struct GNUNET_MESSENGER_SenderSession session;
1570 enum GNUNET_GenericReturnValue start_handle;
1571
1572 GNUNET_assert ((room) && (message) && (hash));
1573
1574 peer_store = get_srv_room_peer_store (room);
1575 member_store = get_srv_room_member_store (room);
1576
1577 if (GNUNET_YES == is_peer_message (message))
1578 {
1579 session.peer = get_store_peer_of (peer_store, message, hash);
1580
1581 if (! session.peer)
1582 {
1584 "Message handling dropped: Peer is missing!\n");
1585 return;
1586 }
1587 }
1588 else
1589 {
1590 struct GNUNET_MESSENGER_Member *member;
1591 member = get_store_member_of (member_store, message);
1592
1593 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for message (%s)\n",
1594 GNUNET_h2s (hash));
1595
1596 if (! member)
1597 {
1599 "Message handling dropped: Member is missing!\n");
1600 return;
1601 }
1602
1603 session.member = get_member_session_of (member, message, hash);
1604
1605 if (! session.member)
1606 {
1608 "Message handling dropped: Session is missing!\n");
1609 return;
1610 }
1611 }
1612
1613 {
1614 struct GNUNET_MESSENGER_MemberUpdate update;
1615 update.message = message;
1616 update.hash = hash;
1617
1618 update.head = NULL;
1619 update.tail = NULL;
1620
1622 member_store,
1624 &update);
1625
1626 while (update.head)
1627 {
1628 struct GNUNET_MESSENGER_SrvMemberSessionCompletion *element = update.head;
1629
1630 remove_room_member_session (room, element->session);
1631
1632 GNUNET_CONTAINER_DLL_remove (update.head, update.tail, element);
1634 "Remove member session completion from queue!\n");
1635
1636 GNUNET_free (element);
1637 }
1638 }
1639
1640 start_handle = room->handling.head ? GNUNET_NO : GNUNET_YES;
1641
1642 add_to_list_messages (&(room->handling), hash);
1643
1644 switch (message->header.kind)
1645 {
1647 handle_message_join (room, &session, message, hash);
1648 break;
1650 handle_message_leave (room, &session, message, hash);
1651 break;
1653 handle_message_key (room, &session, message, hash);
1654 break;
1656 handle_message_peer (room, &session, message, hash);
1657 break;
1659 handle_message_id (room, &session, message, hash);
1660 break;
1662 handle_message_miss (room, &session, message, hash);
1663 break;
1665 handle_message_delete (room, &session, message, hash);
1666 break;
1668 handle_message_connection (room, &session, message, hash);
1669 break;
1671 handle_message_subscribe (room, &session, message, hash);
1672 break;
1673 default:
1674 break;
1675 }
1676
1677 if (GNUNET_YES == start_handle)
1678 handle_room_messages (room);
1679}
void add_to_list_messages(struct GNUNET_MESSENGER_ListMessages *messages, const struct GNUNET_HashCode *hash)
Adds a specific hash from a message to the end of the list.
int iterate_store_members(struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls)
Iterate through all member sessions currently connected to the members of the given member store and ...
void handle_message_id(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent id message to change a members id.
void handle_message_delete(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent delete message to delete a specific message from the store.
void handle_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent peer message to make changes of the basement in the room.
void handle_message_join(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent join message to make changes of current member information.
void handle_message_key(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent key message to change the key of a member and rearrange the contacts accor...
void handle_message_leave(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent leave message to make changes of current member information.
void handle_message_subscribe(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent subscribe message to subscribe a member to a discourse.
void handle_message_connection(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent connection message to update connection information about a peer.
void handle_message_miss(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent miss message to drop a peer from the basement in the room.
static enum GNUNET_GenericReturnValue iterate_update_member_sessions(void *cls, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, struct GNUNET_MESSENGER_SrvMemberSession *session)
static void remove_room_member_session(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvMemberSession *session)
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_SUBSCRIBTION
The subscription kind.
@ GNUNET_MESSENGER_KIND_DELETION
The deletion kind.
@ GNUNET_MESSENGER_KIND_CONNECTION
The connection kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
const struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_SrvMemberSession * session

References add_to_list_messages(), get_member_session_of(), get_srv_room_member_store(), get_srv_room_peer_store(), get_store_member_of(), get_store_peer_of(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_KIND_CONNECTION, GNUNET_MESSENGER_KIND_DELETION, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_SUBSCRIBTION, GNUNET_NO, GNUNET_YES, handle_message_connection(), handle_message_delete(), handle_message_id(), handle_message_join(), handle_message_key(), handle_message_leave(), handle_message_miss(), handle_message_peer(), handle_message_subscribe(), handle_room_messages(), GNUNET_MESSENGER_SrvRoom::handling, GNUNET_MESSENGER_MemberUpdate::hash, GNUNET_MESSENGER_ListMessages::head, GNUNET_MESSENGER_MemberUpdate::head, GNUNET_MESSENGER_Message::header, is_peer_message(), iterate_store_members(), iterate_update_member_sessions(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_SenderSession::member, GNUNET_MESSENGER_MemberUpdate::message, GNUNET_MESSENGER_SenderSession::peer, remove_room_member_session(), GNUNET_MESSENGER_SrvMemberSessionCompletion::session, and GNUNET_MESSENGER_MemberUpdate::tail.

Referenced by callback_srv_room_message_signed(), and handle_tunnel_message().

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

◆ callback_srv_room_message_signed()

static void callback_srv_room_message_signed ( void *  cls,
struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_Message message,
struct GNUNET_MQ_Envelope envelope,
const struct GNUNET_HashCode hash 
)
static

Definition at line 756 of file gnunet-service-messenger_room.c.

761{
763 enum GNUNET_GenericReturnValue new_message;
764
765 GNUNET_assert ((cls) && (room) && (message) && (envelope) && (hash));
766
767 handle = cls;
768
769 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending room message: %s\n",
770 GNUNET_h2s (hash));
771
772 send_srv_room_envelope (room, NULL, envelope, hash);
773 new_message = update_room_message (room, message, hash);
774
775 if (GNUNET_YES != new_message)
776 {
778 "Sending duplicate message failed: %s\n",
779 GNUNET_h2s (hash));
780 return;
781 }
782
783 switch (message->header.kind)
784 {
786 send_message_join (room, handle, message, hash);
787 break;
789 send_message_key (room, handle, message, hash);
790 break;
792 send_message_peer (room, handle, message, hash);
793 break;
795 send_message_id (room, handle, message, hash);
796 break;
798 send_message_request (room, handle, message, hash);
799 break;
800 default:
801 break;
802 }
803
804 callback_room_handle_message (room, message, hash);
805
806 if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
807 (room->sync == handle) &&
809 room->key))))
811}
void merge_srv_handle_room_to_sync(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room)
Merges the latest hash from a specific room by a given handle until the message graph of the room is ...
void send_message_id(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent id message to update the handles member id in the room.
void send_message_request(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent request message to trigger the request operation for this service.
void send_message_join(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent join message to ensure growth of the decentralized room structure.
void send_message_key(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent key message to ensure changes to the public key of the sending handle.
void send_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a sent peer message to update the rooms peer message of this service.
enum GNUNET_GenericReturnValue update_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
void send_srv_room_envelope(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)
Sends an envelope from a message with a given hash excluding a specific tunnel inside of a room.
void callback_room_handle_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).

References callback_room_handle_message(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_KEY, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_YES, handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_SrvRoom::key, GNUNET_MESSENGER_MessageHeader::kind, merge_srv_handle_room_to_sync(), send_message_id(), send_message_join(), send_message_key(), send_message_peer(), send_message_request(), send_srv_room_envelope(), GNUNET_MESSENGER_SrvRoom::sync, and update_room_message().

Referenced by send_srv_room_message().

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

◆ send_srv_room_message()

enum GNUNET_GenericReturnValue send_srv_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_Message message 
)

Sends a message from a given handle into a room.

The hash parameter will be updated with the hash-value resulting from the sent message.

The function handles packing the message automatically and will call linked message-events locally even if the message won't be sent to another peer.

The function returns GNUNET_YES on success, GNUNET_NO if message is null and GNUNET_SYSERR if the message was known already.

Parameters
[in,out]roomRoom
[in,out]handleHandle
[in,out]messageMessage
Returns
GNUNET_YES on success, GNUNET_NO or GNUNET_SYSERR otherwise.

Definition at line 815 of file gnunet-service-messenger_room.c.

818{
819 GNUNET_assert ((room) && (handle));
820
821 if (! message)
822 return GNUNET_NO;
823
825 "Sending message from handle in room: %s (%s)\n",
826 GNUNET_h2s (&(room->key)),
828
829 return sign_srv_room_message (room, message,
831 handle);
832}
enum GNUNET_GenericReturnValue sign_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, GNUNET_MESSENGER_SignedCallback callback, void *closure)
Packs a message depending on its kind into a newly allocated envelope.
static void callback_srv_room_message_signed(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)

References callback_srv_room_message_signed(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_name_of_kind(), GNUNET_NO, handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_SrvRoom::key, GNUNET_MESSENGER_MessageHeader::kind, and sign_srv_room_message().

Referenced by callback_operation(), callback_tunnel_disconnect(), close_service_room(), close_srv_room(), iterate_service_miss_rooms(), iterate_service_update_rooms(), merge_srv_room_last_messages(), open_srv_room(), send_message_peer(), and send_srv_handle_message().

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

◆ iterate_send_room_envelope()

static enum GNUNET_GenericReturnValue iterate_send_room_envelope ( void *  cls,
const struct GNUNET_PeerIdentity key,
void *  value 
)
static

Definition at line 846 of file gnunet-service-messenger_room.c.

849{
850 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
851 struct GNUNET_MESSENGER_ClosureSendRoom *closure;
852 struct GNUNET_MQ_Envelope *envelope;
853
854 GNUNET_assert ((cls) && (value));
855
856 closure = cls;
857 tunnel = value;
858
859 GNUNET_assert ((closure->envelope) && (closure->hash));
860
861 if ((! is_tunnel_connected (tunnel)) ||
863 return GNUNET_YES;
864
865 if (tunnel == closure->exclude)
866 return GNUNET_YES;
867
868 envelope = GNUNET_MQ_env_copy (closure->envelope);
869
870 if (envelope)
871 send_tunnel_envelope (tunnel, envelope, closure->hash);
872
873 return GNUNET_YES;
874}
void send_tunnel_envelope(struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MQ_Envelope *env, const struct GNUNET_HashCode *hash)
Sends an envelope containing a message with a given hash through a tunnel.
uint32_t get_tunnel_messenger_version(const struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Returns the current messenger version the peer connected via a given tunnel has reported to be using ...
#define GNUNET_MESSENGER_VERSION
Version number of GNUnet Messenger API.
struct GNUNET_MQ_Envelope * GNUNET_MQ_env_copy(struct GNUNET_MQ_Envelope *env)
Function to copy an envelope.
Definition mq.c:373
struct GNUNET_MESSENGER_SrvTunnel * exclude

References GNUNET_MESSENGER_ClosureSendRoom::envelope, GNUNET_MESSENGER_ClosureSendRoom::exclude, get_tunnel_messenger_version(), GNUNET_assert, GNUNET_MESSENGER_VERSION, GNUNET_MQ_env_copy(), GNUNET_YES, GNUNET_MESSENGER_ClosureSendRoom::hash, is_tunnel_connected(), send_tunnel_envelope(), and value.

Referenced by send_srv_room_envelope().

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

◆ send_srv_room_envelope()

void send_srv_room_envelope ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvTunnel tunnel,
struct GNUNET_MQ_Envelope envelope,
const struct GNUNET_HashCode hash 
)

Sends an envelope from a message with a given hash excluding a specific tunnel inside of a room.

The function will send copies from the given envelope and frees the original afterwards.

Parameters
[in,out]roomRoom
[in,out]tunnelTunnel
[in,out]messageMessage
[in]hashHash of message

Definition at line 878 of file gnunet-service-messenger_room.c.

882{
884
885 GNUNET_assert ((room) && (envelope));
886
887 closure.exclude = tunnel;
888 closure.envelope = envelope;
889 closure.hash = hash;
890
893 &closure);
894
896}
static enum GNUNET_GenericReturnValue iterate_send_room_envelope(void *cls, const struct GNUNET_PeerIdentity *key, void *value)

References GNUNET_MESSENGER_ClosureSendRoom::envelope, GNUNET_MESSENGER_ClosureSendRoom::exclude, GNUNET_assert, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_MESSENGER_ClosureSendRoom::hash, iterate_send_room_envelope(), and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by callback_srv_room_message_signed(), and handle_tunnel_message().

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

◆ check_srv_room_peer_status()

void check_srv_room_peer_status ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvTunnel tunnel 
)

Checks the current state of opening a given room from this peer and re-publishes it if necessary to a selected tunnel or to all connected tunnels if necessary or if the selected tunnel is NULL.

Parameters
[in,out]roomRoom
[in,out]tunnelTunnel

Definition at line 900 of file gnunet-service-messenger_room.c.

902{
903 struct GNUNET_MESSENGER_MessageStore *message_store;
904 const struct GNUNET_MESSENGER_Message *message;
905
906 if (! room->peer_message)
907 return;
908
909 message_store = get_srv_room_message_store (room);
910 message = get_store_message (message_store, room->peer_message);
911
912 if (! message)
913 {
915 room->peer_message = NULL;
916 return;
917 }
918
919 if (tunnel)
920 forward_tunnel_message (tunnel, message, room->peer_message);
921}
void forward_tunnel_message(struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Forwards a given message with a known hash through a tunnel.

References forward_tunnel_message(), get_srv_room_message_store(), get_store_message(), GNUNET_free, and GNUNET_MESSENGER_SrvRoom::peer_message.

Referenced by recv_message_info(), and send_message_join().

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

◆ merge_srv_room_last_messages()

enum GNUNET_GenericReturnValue merge_srv_room_last_messages ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle 
)

Reduces all current forks inside of the message history of a room to one remaining last message by merging them down.

All merge messages will be sent from a given handle.

The function will only try to merge one existing fork of the message graph and continue automatically if any active handle inside the room is syncing. Should there be no existing fork in the message graph it returns GNUNET_NO.

Parameters
[in,out]roomRoom
[in,out]handleHandle
Returns
GNUNET_YES on success, GNUNET_SYSERR on failure, otherwise GNUNET_NO

Definition at line 925 of file gnunet-service-messenger_room.c.

927{
928 const struct GNUNET_HashCode *hash;
929 struct GNUNET_MESSENGER_Message *message;
930
931 GNUNET_assert (room);
932
933 if (! handle)
934 return GNUNET_SYSERR;
935
937 "Merging messages by handle in room: %s\n",
938 GNUNET_h2s (&(room->key)));
939
940 hash = get_message_state_merge_hash (&(room->state));
941
942 if ((! hash) || (GNUNET_is_zero (hash)))
943 return GNUNET_NO;
944
945 message = create_message_merge (hash);
946
947 if (! message)
948 {
950 "Merging messages failed: %s\n",
951 GNUNET_h2s (&(room->key)));
952 return GNUNET_SYSERR;
953 }
954
955 return send_srv_room_message (room, handle, message);
956}
struct GNUNET_MESSENGER_Message * create_message_merge(const struct GNUNET_HashCode *previous)
Creates and allocates a new merge message containing the hash of a second previous message besides th...

References create_message_merge(), get_message_state_merge_hash(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_is_zero, GNUNET_log, GNUNET_NO, GNUNET_SYSERR, handle, GNUNET_MESSENGER_SrvRoom::key, send_srv_room_message(), and GNUNET_MESSENGER_SrvRoom::state.

Referenced by merge_srv_handle_room_to_sync().

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

◆ delete_srv_room_message()

enum GNUNET_GenericReturnValue delete_srv_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvMemberSession session,
const struct GNUNET_HashCode hash,
const struct GNUNET_TIME_Relative  delay 
)

Deletes a message from the room with a given hash in a specific delay if the provided member by its session is permitted to do so.

Parameters
[in,out]roomRoom
[in,out]sessionMember session
[in]hashHash of message
[in]delayDelay of deletion
Returns
GNUNET_YES on success, GNUNET_NO if permission gets denied, GNUNET_SYSERR on operation failure

Definition at line 960 of file gnunet-service-messenger_room.c.

964{
965 const struct GNUNET_MESSENGER_Message *message;
966 struct GNUNET_TIME_Relative forever;
967
968 GNUNET_assert ((room) && (session) && (hash));
969
971
972 if (0 == GNUNET_memcmp (&forever, &delay))
973 {
975 "Deletion is delayed forever: operation is impossible!\n");
976 return GNUNET_SYSERR;
977 }
978
979 {
980 struct GNUNET_MESSENGER_MessageStore *message_store;
981
982 message_store = get_srv_room_message_store (room);
983 message = get_store_message (message_store, hash);
984 }
985
986 if (! message)
987 return GNUNET_YES;
988
989 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_YES))
990 {
992 "Unpermitted request for deletion by member (%s) of message (%s)!\n",
994 hash));
995
996 return GNUNET_NO;
997 }
998
999 {
1000 struct GNUNET_MESSENGER_OperationStore *operation_store;
1001
1002 operation_store = get_srv_room_operation_store (room);
1003
1004 if (GNUNET_OK != use_store_operation (operation_store, hash,
1006 {
1008 "Deletion has failed: operation denied!\n");
1009 return GNUNET_SYSERR;
1010 }
1011 }
1012
1013 return GNUNET_YES;
1014}
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the member id of a given member session.
enum GNUNET_GenericReturnValue check_member_session_history(const struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue ownership)
Checks the history of a session for a specific message which is identified by its hash and if the own...
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_(void)
Return "forever".
Definition time.c:196
Time for relative time used by GNUnet, in microseconds.

References check_member_session_history(), get_member_session_id(), get_srv_room_message_store(), get_srv_room_operation_store(), get_store_message(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_MESSENGER_OP_DELETE, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_SYSERR, GNUNET_TIME_relative_get_forever_(), GNUNET_YES, GNUNET_MESSENGER_OperationStore::room, and use_store_operation().

Referenced by handle_message_delete().

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

◆ get_srv_room_cadet()

struct GNUNET_CADET_Handle * get_srv_room_cadet ( struct GNUNET_MESSENGER_SrvRoom room)

Returns the CADET handle from a rooms service.

Parameters
[in,out]roomRoom
Returns
CADET handle

Definition at line 1018 of file gnunet-service-messenger_room.c.

1019{
1020 GNUNET_assert (room);
1021
1022 return room->service->cadet;
1023}

References GNUNET_MESSENGER_Service::cadet, GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::service.

Referenced by connect_tunnel(), and open_srv_room().

Here is the caller graph for this function:

◆ get_srv_room_key()

const struct GNUNET_HashCode * get_srv_room_key ( const struct GNUNET_MESSENGER_SrvRoom room)

Returns the shared secret you need to access a room.

Parameters
[in]roomRoom
Returns
Shared secret

Definition at line 1027 of file gnunet-service-messenger_room.c.

1028{
1029 GNUNET_assert (room);
1030
1031 return &(room->key);
1032}

References GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::key.

Referenced by callback_room_connect(), callback_tunnel_disconnect(), clear_member_store(), clear_operation_store(), connect_tunnel(), find_member_session_in_room(), get_member_store_key(), get_room_data_subdir(), handle_message_join(), handle_message_leave(), handle_room_messages(), handle_service_message(), join_room(), join_room_locally(), notify_srv_handle_member_id(), notify_srv_handle_message(), open_srv_room(), remove_room_member_session(), send_message_id(), solve_srv_room_member_collisions(), and update_room_message().

Here is the caller graph for this function:

◆ get_srv_room_tunnel()

const struct GNUNET_MESSENGER_SrvTunnel * get_srv_room_tunnel ( const struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_PeerIdentity peer 
)

Returns a tunnel inside of a room leading towards a given peer if such a tunnel exists, otherwise NULL.

Parameters
[in]roomRoom
[in]peerPeer identity
Returns
Tunnel or NULL

Definition at line 1036 of file gnunet-service-messenger_room.c.

1038{
1039 GNUNET_assert ((room) && (peer));
1040
1041 return GNUNET_CONTAINER_multipeermap_get (room->tunnels, peer);
1042}

References GNUNET_assert, GNUNET_CONTAINER_multipeermap_get(), GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_SrvTunnel::room, and GNUNET_MESSENGER_SrvRoom::tunnels.

Here is the call graph for this function:

◆ request_room_message_step()

static enum GNUNET_GenericReturnValue request_room_message_step ( struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_SrvMemberSession session,
GNUNET_MESSENGER_MessageRequestCallback  callback,
void *  cls 
)
static

Definition at line 1046 of file gnunet-service-messenger_room.c.

1052{
1053 struct GNUNET_MESSENGER_MessageStore *message_store;
1054 const struct GNUNET_MESSENGER_MessageLink *link;
1055 const struct GNUNET_MESSENGER_Message *message;
1056
1057 GNUNET_assert ((room) && (hash) && (session));
1058
1059 message_store = get_srv_room_message_store (room);
1060 link = get_store_message_link (message_store, hash, GNUNET_YES);
1061
1062 if (! link)
1063 goto forward;
1064
1066 "Requesting link of message with hash: %s\n",
1067 GNUNET_h2s (hash));
1068
1069 {
1071 result = request_room_message_step (room, &(link->first), session,
1072 callback, cls);
1073
1074 if ((GNUNET_YES == link->multiple) &&
1075 (GNUNET_YES == request_room_message_step (room, &(link->second),
1076 session, callback, cls)))
1077 return GNUNET_YES;
1078 else
1079 return result;
1080 }
1081
1082forward:
1083 message = get_store_message (message_store, hash);
1084
1085 if (! message)
1086 {
1088 "Requested message is missing in local storage: %s\n",
1089 GNUNET_h2s (hash));
1090 return GNUNET_NO;
1091 }
1092
1093 if (GNUNET_YES == is_epoch_message (message))
1094 goto skip_member_session;
1095
1096 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_NO))
1097 {
1099 "Unpermitted request for access by member (%s) of message (%s)!\n",
1101 GNUNET_h2s (hash));
1102 return GNUNET_YES;
1103 }
1104
1105skip_member_session:
1106 if (callback)
1107 callback (cls, room, message, hash);
1108
1109 return GNUNET_YES;
1110}
static int forward
Search direction: forward.
Definition gnunet-abd.c:163
static int result
Global testing status.
const struct GNUNET_MESSENGER_MessageLink * get_store_message_link(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue deleted_only)
Returns the message link from a message store matching a given hash.
static enum GNUNET_GenericReturnValue request_room_message_step(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_SrvMemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)

References check_member_session_history(), GNUNET_MESSENGER_MessageLink::first, forward, get_member_session_id(), get_srv_room_message_store(), get_store_message(), get_store_message_link(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_sh2s(), GNUNET_YES, is_epoch_message(), GNUNET_MESSENGER_MessageLink::multiple, request_room_message_step(), result, and GNUNET_MESSENGER_MessageLink::second.

Referenced by request_room_message_step(), and request_srv_room_message().

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

◆ request_srv_room_message()

enum GNUNET_GenericReturnValue request_srv_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_HashCode hash,
const struct GNUNET_MESSENGER_SrvMemberSession session,
GNUNET_MESSENGER_MessageRequestCallback  callback,
void *  cls 
)

Requests a message from a room identified by a given hash.

If the message is found, the selected callback will be called with it and the provided closure. If no matching message is found but it wasn't deleted the selected callback will be called with #NULL as message instead. In case of deletion the next available previous message will be used to call the callback.

It is also possible that the given callback will not be called if the requesting session is not permitted!

Parameters
[in,out]roomRoom
[in]hashHash of message
[in]callbackCallback to process result
[in]clsClosure for the callback
Returns
GNUNET_YES if the request could be processed, otherwise GNUNET_NO

Definition at line 1114 of file gnunet-service-messenger_room.c.

1120{
1122
1123 GNUNET_assert ((room) && (hash));
1124
1125 result = request_room_message_step (room, hash, session, callback, cls);
1126
1127 if ((GNUNET_NO == result) && (callback))
1128 callback (cls, room, NULL, hash);
1129
1130 return result;
1131}

References GNUNET_assert, GNUNET_NO, request_room_message_step(), and result.

Referenced by handle_get_message(), and recv_message_request().

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

◆ solve_srv_room_member_collisions()

void solve_srv_room_member_collisions ( struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_CRYPTO_BlindablePublicKey public_key,
const struct GNUNET_ShortHashCode member_id,
struct GNUNET_TIME_Absolute  timestamp 
)

Checks for potential collisions with member ids and solves them changing active handles ids if they use an already used member id (comparing public key and timestamp).

Parameters
[in,out]roomRoom
[in]public_keyPublic key
[in]member_idMember ID
[in]timestampTimestamp

Definition at line 1167 of file gnunet-service-messenger_room.c.

1172{
1173 struct GNUNET_MESSENGER_MemberStore *member_store;
1174 struct GNUNET_MESSENGER_Member *member;
1175 struct GNUNET_MESSENGER_ListHandles *handles;
1176 struct GNUNET_MESSENGER_ListHandle *element;
1177
1178 GNUNET_assert ((room) && (public_key) && (member_id));
1179
1180 member_store = get_srv_room_member_store (room);
1181 member = get_store_member (member_store, member_id);
1182
1183 if ((! member) || (1 >= GNUNET_CONTAINER_multihashmap_size (
1184 member->sessions)))
1185 return;
1186
1187 handles = &(room->service->handles);
1188
1189 for (element = handles->head; element; element = element->next)
1190 {
1192 struct GNUNET_MESSENGER_SrvMemberSession *session;
1193
1194 if (0 != GNUNET_memcmp (member_id, get_srv_handle_member_id (
1195 element->handle, get_srv_room_key (room))))
1196 continue;
1197
1198 pubkey = get_srv_handle_key (element->handle);
1199
1200 if (0 == GNUNET_memcmp (public_key, pubkey))
1201 continue;
1202
1203 session = get_member_session (member, pubkey);
1204
1205 if (! session)
1206 continue;
1207
1208 {
1210 start = get_member_session_start (session);
1211
1212 if (GNUNET_TIME_relative_get_zero_ ().rel_value_us !=
1214 continue;
1215 }
1216
1217 {
1218 struct GNUNET_ShortHashCode random_id;
1219 generate_free_member_id (&random_id, member_store->members);
1220
1222 element->handle,
1223 room,
1224 &random_id,
1225 GNUNET_NO);
1226 }
1227 }
1228}
static int start
Set if we are to start default services (including ARM).
Definition gnunet-arm.c:38
static uint64_t timestamp(void)
Get current timestamp.
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
struct GNUNET_MESSENGER_SrvMemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key)
Returns the member session of a member identified by a given public key.
struct GNUNET_TIME_Absolute get_member_session_start(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the timestamp of the member session's start.
struct GNUNET_MESSENGER_Member * get_store_member(const struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Returns the member in a store identified by a given id.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition time.c:133
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition time.c:423
enum GNUNET_GenericReturnValue 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.
An identity key as per LSD0001.
struct GNUNET_MESSENGER_ListHandle * next
struct GNUNET_MESSENGER_SrvHandle * handle
struct GNUNET_MESSENGER_ListHandle * head
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_CONTAINER_MultiHashMap * sessions
struct GNUNET_MESSENGER_ListHandles handles
struct GNUNET_CRYPTO_BlindablePublicKey public_key
Time for absolute times used by GNUnet, in microseconds.

References generate_free_member_id(), get_member_session(), get_member_session_start(), get_srv_handle_key(), get_srv_handle_member_id(), get_srv_room_key(), get_srv_room_member_store(), get_store_member(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_size(), GNUNET_memcmp, GNUNET_NO, GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_relative_get_zero_(), GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_Service::handles, GNUNET_MESSENGER_ListHandles::head, GNUNET_MESSENGER_SrvMemberSession::member, GNUNET_MESSENGER_MemberStore::members, GNUNET_MESSENGER_ListHandle::next, notify_srv_handle_member_id(), pubkey, GNUNET_MESSENGER_SrvMemberSession::public_key, GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_Member::sessions, start, and timestamp().

Referenced by handle_message_id(), and handle_message_join().

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

◆ rebuild_srv_room_basement_structure()

void rebuild_srv_room_basement_structure ( struct GNUNET_MESSENGER_SrvRoom room)

Rebuilds the decentralized structure for a room by ensuring all required connections are made depending on the amount of peers and this peers index in the list of them.

Parameters
[in,out]roomRoom

Definition at line 1232 of file gnunet-service-messenger_room.c.

1233{
1234 struct GNUNET_MESSENGER_ListTunnel *element;
1235 struct GNUNET_PeerIdentity peer;
1236 size_t count;
1237 size_t src;
1238 size_t dst;
1239
1240 GNUNET_assert (room);
1241
1242 if (GNUNET_OK != get_service_peer_identity (room->service, &peer))
1243 return;
1244
1245 count = count_of_tunnels (&(room->basement));
1246
1247 if (! find_list_tunnels (&(room->basement), &peer, &src))
1248 return;
1249
1250 if ((count > room->service->min_routers) &&
1251 (GNUNET_NO == is_srv_handle_routing (room->host, &(room->key))) &&
1253 &peer,
1255 {
1256 close_srv_room (room);
1257 return;
1258 }
1259
1260 element = room->basement.head;
1261 dst = 0;
1262
1263 while (element)
1264 {
1265 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
1266
1267 GNUNET_PEER_resolve (element->peer, &peer);
1268
1270
1271 if (! tunnel)
1272 {
1273 element = remove_from_list_tunnels (&(room->basement), element);
1274 continue;
1275 }
1276
1277 if (GNUNET_YES == required_connection_between (count, src, dst))
1278 {
1279 if (GNUNET_SYSERR == connect_tunnel (tunnel))
1280 {
1281 element = remove_from_list_tunnels (&(room->basement), element);
1282 continue;
1283 }
1284 }
1285 else
1286 disconnect_tunnel (tunnel);
1287
1288 element = element->next;
1289 dst++;
1290 }
1291}
enum GNUNET_GenericReturnValue 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 connec...
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).
enum GNUNET_GenericReturnValue is_srv_handle_routing(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns whether a given handle has enabled routing for a room using a specific key by opening that ro...
@ GNUNET_MESSENGER_FLAG_CONNECTION_AUTO
The auto flag.
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
enum GNUNET_GenericReturnValue verify_list_tunnels_flag_token(const struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, enum GNUNET_MESSENGER_ConnectionFlags flag)
Verifies that a specific tunnel selected by its peer identity in a list of tunnels is the first in or...
struct GNUNET_MESSENGER_ListTunnel * find_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer, size_t *index)
Searches linearly through the list of tunnels peer identities for matching a specific peer identity a...
struct GNUNET_MESSENGER_ListTunnel * remove_from_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, struct GNUNET_MESSENGER_ListTunnel *element)
Removes a specific element from the list of tunnels peer identities and returns the next element in t...
struct GNUNET_MESSENGER_ListTunnel * next
struct GNUNET_MESSENGER_ListTunnel * head

References GNUNET_MESSENGER_SrvRoom::basement, close_srv_room(), connect_tunnel(), count_of_tunnels(), disconnect_tunnel(), find_list_tunnels(), get_service_peer_identity(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_get(), GNUNET_MESSENGER_FLAG_CONNECTION_AUTO, GNUNET_NO, GNUNET_OK, GNUNET_PEER_resolve(), GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_ListTunnels::head, GNUNET_MESSENGER_SrvRoom::host, is_srv_handle_routing(), GNUNET_MESSENGER_SrvRoom::key, GNUNET_MESSENGER_Service::min_routers, GNUNET_MESSENGER_ListTunnel::next, GNUNET_MESSENGER_SrvTunnel::peer, GNUNET_MESSENGER_ListTunnel::peer, remove_from_list_tunnels(), required_connection_between(), GNUNET_MESSENGER_SrvTunnel::room, GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_SrvRoom::tunnels, and verify_list_tunnels_flag_token().

Referenced by handle_message_miss(), and handle_message_peer().

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

◆ get_srv_room_amount_of_tunnels()

uint32_t get_srv_room_amount_of_tunnels ( const struct GNUNET_MESSENGER_SrvRoom room)

Returns the amount of active tunnels of a given room.

Parameters
[in]roomRoom
Returns
Amount of tunnels

Definition at line 1295 of file gnunet-service-messenger_room.c.

1296{
1297 GNUNET_assert (room);
1298
1300}
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.

References GNUNET_assert, GNUNET_CONTAINER_multipeermap_size(), GNUNET_MESSENGER_SrvTunnel::room, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by create_message_connection().

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

◆ get_srv_room_connection_flags()

uint32_t get_srv_room_connection_flags ( const struct GNUNET_MESSENGER_SrvRoom room)

Returns connection flags about connection information of a given room and the service managing it.

Parameters
[in]roomRoom
Returns
Connection flags

Definition at line 1304 of file gnunet-service-messenger_room.c.

1305{
1306 uint32_t flags;
1307
1308 GNUNET_assert (room);
1309
1311
1312 if (GNUNET_YES == room->service->auto_routing)
1314
1315 return flags;
1316}
@ GNUNET_MESSENGER_FLAG_CONNECTION_NONE
The none flag.
enum GNUNET_GenericReturnValue auto_routing

References GNUNET_MESSENGER_Service::auto_routing, GNUNET_assert, GNUNET_MESSENGER_FLAG_CONNECTION_AUTO, GNUNET_MESSENGER_FLAG_CONNECTION_NONE, GNUNET_YES, GNUNET_MESSENGER_SrvTunnel::room, and GNUNET_MESSENGER_SrvRoom::service.

Referenced by create_message_connection().

Here is the caller graph for this function:

◆ iterate_member_for_subscription()

static enum GNUNET_GenericReturnValue iterate_member_for_subscription ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePublicKey public_key,
struct GNUNET_MESSENGER_SrvMemberSession session 
)
static

Definition at line 1457 of file gnunet-service-messenger_room.c.

1462{
1464 struct GNUNET_MESSENGER_Member *member;
1465 struct GNUNET_MESSENGER_Subscription *subscription;
1466
1467 GNUNET_assert ((cls) && (session));
1468
1469 it = cls;
1470 member = session->member;
1471
1472 subscription = get_member_subscription (member, it->discourse);
1473 if (! subscription)
1474 return GNUNET_YES;
1475
1476 if (GNUNET_TIME_absolute_cmp (subscription->start, <, it->start))
1477 it->start = subscription->start;
1478
1479 return GNUNET_YES;
1480}
struct GNUNET_MESSENGER_Subscription * get_member_subscription(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ShortHashCode *discourse)
Returns the active subscription of a given member to a selected discourse.
#define GNUNET_TIME_absolute_cmp(t1, op, t2)
Compare two absolute times.

References GNUNET_MESSENGER_MemberSubscriptionIteration::discourse, get_member_subscription(), GNUNET_assert, GNUNET_TIME_absolute_cmp, GNUNET_YES, GNUNET_MESSENGER_SrvMemberSession::member, GNUNET_MESSENGER_Subscription::member, GNUNET_MESSENGER_MemberSubscriptionIteration::start, and GNUNET_MESSENGER_Subscription::start.

Referenced by cleanup_srv_room_discourse_messages().

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

◆ cleanup_srv_room_discourse_messages()

void cleanup_srv_room_discourse_messages ( struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_ShortHashCode discourse 
)

Cleanup discourse messages outside of current subscriptions from a specific discourse of all the members in a given room.

Parameters
[in,out]roomRoom
[in]discourseHash of discourse

Definition at line 1484 of file gnunet-service-messenger_room.c.

1487{
1489 struct GNUNET_MESSENGER_MemberStore *member_store;
1490 struct GNUNET_MESSENGER_MessageStore *message_store;
1491
1492 GNUNET_assert ((room) && (discourse));
1493
1494 it.discourse = discourse;
1496
1497 member_store = get_srv_room_member_store (room);
1498
1500
1501 message_store = get_srv_room_message_store (room);
1502
1504 discourse,
1505 it.start);
1506}
void cleanup_store_discourse_messages_before(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_ShortHashCode *discourse, const struct GNUNET_TIME_Absolute timestamp)
Cleans up and deletes all discourse messages existing in the message store memory before a certain ti...
static enum GNUNET_GenericReturnValue iterate_member_for_subscription(void *cls, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, struct GNUNET_MESSENGER_SrvMemberSession *session)
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_forever_(void)
Return "forever".
Definition time.c:205

References cleanup_store_discourse_messages_before(), GNUNET_MESSENGER_MemberSubscriptionIteration::discourse, get_srv_room_member_store(), get_srv_room_message_store(), GNUNET_assert, GNUNET_TIME_absolute_get_forever_(), iterate_member_for_subscription(), iterate_store_members(), and GNUNET_MESSENGER_MemberSubscriptionIteration::start.

Referenced by handle_message_subscribe(), and task_subscription_exit().

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

◆ iterate_update_member_sessions()

static enum GNUNET_GenericReturnValue iterate_update_member_sessions ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePublicKey public_key,
struct GNUNET_MESSENGER_SrvMemberSession session 
)
static

Definition at line 1527 of file gnunet-service-messenger_room.c.

1532{
1533 struct GNUNET_MESSENGER_MemberUpdate *update;
1534
1535 GNUNET_assert ((cls) && (session));
1536
1537 update = cls;
1538
1539 update_member_session_history (session, update->message, update->hash);
1540
1541 if (GNUNET_YES == is_member_session_completed (session))
1542 {
1544
1546 "Add member session completion to queue!\n");
1547
1549 element->session = session;
1550
1551 GNUNET_CONTAINER_DLL_insert_tail (update->head, update->tail, element);
1552 }
1553
1554 return GNUNET_YES;
1555}
void update_member_session_history(struct GNUNET_MESSENGER_SrvMemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Adds a given message to the history of a session using the messages hash.
enum GNUNET_GenericReturnValue is_member_session_completed(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns if the given member session has been completed.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_MESSENGER_SrvMemberSessionCompletion * tail
struct GNUNET_MESSENGER_SrvMemberSessionCompletion * head

References GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_YES, GNUNET_MESSENGER_MemberUpdate::hash, GNUNET_MESSENGER_MemberUpdate::head, is_member_session_completed(), GNUNET_MESSENGER_MemberUpdate::message, GNUNET_MESSENGER_SrvMemberSessionCompletion::session, GNUNET_MESSENGER_MemberUpdate::tail, and update_member_session_history().

Referenced by callback_room_handle_message().

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

◆ remove_room_member_session()

static void remove_room_member_session ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvMemberSession session 
)
static

Definition at line 1783 of file gnunet-service-messenger_room.c.

1785{
1786 struct GNUNET_HashCode hash;
1787 char *session_dir;
1788 char *room_dir;
1789
1790 GNUNET_assert ((room) && (session));
1791
1793 "Remove member session from room: %s (%s)\n",
1795 GNUNET_h2s (get_srv_room_key (room)));
1796
1797 remove_member_session (session->member, session);
1798
1799 {
1800 const struct GNUNET_CRYPTO_BlindablePublicKey *public_key;
1801 public_key = get_member_session_public_key (session);
1802
1803 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
1804 }
1805
1806
1807 get_room_data_subdir (room, &room_dir);
1808
1810 &session_dir, "%s%s%c%s%c%s%c%s%c", room_dir,
1811 "members", DIR_SEPARATOR,
1813 "sessions", DIR_SEPARATOR,
1814 GNUNET_h2s (&hash), DIR_SEPARATOR);
1815
1816 GNUNET_free (room_dir);
1817
1818 GNUNET_DISK_directory_remove (session_dir);
1819 GNUNET_free (session_dir);
1820
1821 destroy_member_session (session);
1822}
void remove_member_session(struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_SrvMemberSession *session)
Removes a given member session from its member.
void destroy_member_session(struct GNUNET_MESSENGER_SrvMemberSession *session)
Destroys a member session and frees its memory fully.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_member_session_public_key(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the public key of a given member session.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition disk.c:1140
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:41

References destroy_member_session(), DIR_SEPARATOR, get_member_session_id(), get_member_session_public_key(), get_room_data_subdir(), get_srv_room_key(), GNUNET_asprintf(), GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_DISK_directory_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_sh2s(), GNUNET_MESSENGER_SrvMemberSession::member, and remove_member_session().

Referenced by callback_room_handle_message().

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

◆ load_srv_room()

void load_srv_room ( struct GNUNET_MESSENGER_SrvRoom room)

Loads the local configuration for a given room of a service which contains the last messages hash and the ruleset for general access of new members.

Parameters
[out]roomRoom

Definition at line 1683 of file gnunet-service-messenger_room.c.

1684{
1685 char *room_dir;
1686
1687 GNUNET_assert (room);
1688
1689 get_room_data_subdir (room, &room_dir);
1690
1691 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load room from directory: %s\n",
1692 room_dir);
1693
1695 {
1696 char *peers_file;
1697 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1698
1699 load_peer_store (get_srv_room_peer_store (room), peers_file);
1700 GNUNET_free (peers_file);
1701
1706
1707 {
1708 char *basement_file;
1709 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1710
1711 load_list_tunnels (&(room->basement), basement_file);
1712 GNUNET_free (basement_file);
1713 }
1714
1715 load_message_state (&(room->state), room_dir);
1716 }
1717
1718 GNUNET_free (room_dir);
1719}
void load_member_store(struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
Loads members from a directory into a member store.
void load_message_state(struct GNUNET_MESSENGER_MessageState *state, const char *path)
void load_message_store(struct GNUNET_MESSENGER_MessageStore *store)
Loads messages from its directory into a message store.
void move_message_store(struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
Moves all storage from a message store from its current directory to a given directory.
void load_operation_store(struct GNUNET_MESSENGER_OperationStore *store, const char *directory)
Loads operations from a directory into an operation store.
void load_peer_store(struct GNUNET_MESSENGER_PeerStore *store, const char *path)
Loads peer identities from a file into a peer store.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition disk.c:466
void load_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path)
Loads the list of tunnels peer identities from a file under a given path.

References GNUNET_MESSENGER_SrvRoom::basement, get_room_data_subdir(), get_srv_room_member_store(), get_srv_room_message_store(), get_srv_room_operation_store(), get_srv_room_peer_store(), GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_YES, load_list_tunnels(), load_member_store(), load_message_state(), load_message_store(), load_operation_store(), load_peer_store(), move_message_store(), and GNUNET_MESSENGER_SrvRoom::state.

Referenced by create_srv_room().

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

◆ save_srv_room()

void save_srv_room ( struct GNUNET_MESSENGER_SrvRoom room)

Saves the configuration for a given room of a service which contains the last messages hash and the ruleset for general access of new members locally.

Parameters
[in]roomRoom

Definition at line 1723 of file gnunet-service-messenger_room.c.

1724{
1725 char *room_dir;
1726
1727 GNUNET_assert (room);
1728
1729 get_room_data_subdir (room, &room_dir);
1730
1731 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save room to directory: %s\n",
1732 room_dir);
1733
1734 if ((GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_NO)) ||
1736 {
1737 char *peers_file;
1738 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1739
1740 save_peer_store (get_srv_room_peer_store (room), peers_file);
1741 GNUNET_free (peers_file);
1742
1747
1748 {
1749 char *basement_file;
1750 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1751
1752 save_list_tunnels (&(room->basement), basement_file);
1753 GNUNET_free (basement_file);
1754 }
1755
1756 save_message_state (&(room->state), room_dir);
1757 }
1758
1759 GNUNET_free (room_dir);
1760}
void save_member_store(struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
Saves members from a member store into a directory.
void save_message_state(const struct GNUNET_MESSENGER_MessageState *state, const char *path)
void save_message_store(struct GNUNET_MESSENGER_MessageStore *store)
Saves messages from a message store into its directory.
void save_operation_store(const struct GNUNET_MESSENGER_OperationStore *store, const char *directory)
Saves operations from an operation store into a directory.
void save_peer_store(const struct GNUNET_MESSENGER_PeerStore *store, const char *path)
Saves peer identities from a peer store into a file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition disk.c:573
void save_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const char *path)
Saves the list of tunnels peer identities to a file under a given path.

References GNUNET_MESSENGER_SrvRoom::basement, get_room_data_subdir(), get_srv_room_member_store(), get_srv_room_message_store(), get_srv_room_operation_store(), get_srv_room_peer_store(), GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_YES, move_message_store(), save_list_tunnels(), save_member_store(), save_message_state(), save_message_store(), save_operation_store(), save_peer_store(), and GNUNET_MESSENGER_SrvRoom::state.

Referenced by destroy_srv_room().

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

◆ remove_srv_room()

void remove_srv_room ( struct GNUNET_MESSENGER_SrvRoom room)

Removes the configuration for a given room of a service.

Parameters
[in]roomRoom

Definition at line 1764 of file gnunet-service-messenger_room.c.

1765{
1766 char *room_dir;
1767
1768 GNUNET_assert (room);
1769
1770 get_room_data_subdir (room, &room_dir);
1771
1772 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove room from directory: %s\n",
1773 room_dir);
1774
1777
1778 GNUNET_free (room_dir);
1779}

References get_room_data_subdir(), GNUNET_assert, GNUNET_DISK_directory_remove(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, and GNUNET_YES.

Referenced by destroy_srv_room().

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