GNUnet 0.29.1-7-g14698f198
 
Loading...
Searching...
No Matches
gnunet-service-messenger_room.h File Reference
Include dependency graph for gnunet-service-messenger_room.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_SrvRoomSignature
 
struct  GNUNET_MESSENGER_SrvRoom
 

Macros

#define GNUNET_MESSENGER_IDLE_DELAY
 
#define GNUNET_MESSENGER_SAVE_DELAY
 
#define GNUNET_MESSENGER_REQUEST_DELAY
 
#define GNUNET_MESSENGER_MERGE_DELAY
 

Typedefs

typedef void(* GNUNET_MESSENGER_SignedCallback) (void *cls, struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)
 
typedef void() GNUNET_MESSENGER_MessageRequestCallback(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Method called whenever a message is found during a request in a room.
 

Functions

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.
 
void destroy_srv_room (struct GNUNET_MESSENGER_SrvRoom *room, enum GNUNET_GenericReturnValue deletion)
 Destroys a room and frees its memory fully.
 
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.
 
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_OperationStore * get_srv_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used operation store of a given 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.
 
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.
 
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 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.
 
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_Handle * get_srv_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the CADET handle from a rooms service.
 
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 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.
 
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.
 
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.
 
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.
 

Macro Definition Documentation

◆ GNUNET_MESSENGER_IDLE_DELAY

#define GNUNET_MESSENGER_IDLE_DELAY
Value:
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_second_(void)
Return relative time of 1s.
Definition time.c:169
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486

Definition at line 46 of file gnunet-service-messenger_room.h.

72{
73 struct GNUNET_MESSENGER_SrvRoom *room;
74 struct GNUNET_PILS_Operation *operation;
75
76 struct GNUNET_MESSENGER_Message *message;
77 struct GNUNET_MQ_Envelope *envelope;
78
80 void *closure;
81
82 struct GNUNET_HashCode hash;
83};
84
86{
90 struct GNUNET_CADET_Port *port;
91
92 struct GNUNET_HashCode key;
93
96
101
104
106
110};
111
121 const struct GNUNET_HashCode *key);
122
132void
134 enum GNUNET_GenericReturnValue deletion);
135
144
153
162
171
187
201 const struct GNUNET_PeerIdentity *door);
202
219 struct GNUNET_MESSENGER_Message *message,
221 void *closure);
222
241 struct GNUNET_MESSENGER_Message *message);
242
254void
256 struct GNUNET_MESSENGER_SrvTunnel *tunnel,
257 struct GNUNET_MQ_Envelope *envelope,
258 const struct GNUNET_HashCode *hash);
259
268void
270 struct GNUNET_MESSENGER_SrvTunnel *tunnel);
271
287
300 struct GNUNET_MESSENGER_SrvMemberSession *session,
301 const struct GNUNET_HashCode *hash,
302 const struct GNUNET_TIME_Relative delay);
303
312
319const struct GNUNET_HashCode*
320get_srv_room_key (const struct GNUNET_MESSENGER_SrvRoom *room);
321
330const struct GNUNET_MESSENGER_SrvTunnel*
332 const struct GNUNET_PeerIdentity *peer);
333
343 void *cls,
344 struct GNUNET_MESSENGER_SrvRoom *room,
345 const struct GNUNET_MESSENGER_Message *message,
346 const struct GNUNET_HashCode *hash);
347
365 const struct GNUNET_HashCode *hash,
367 session,
369 void *cls);
370
380void
382 const struct
384 const struct GNUNET_ShortHashCode *member_id,
386
393void
395
402uint32_t
404
411uint32_t
413
421void
423 const struct GNUNET_ShortHashCode *
424 discourse);
425
432void
434
441void
443
449void
451
452#endif // GNUNET_SERVICE_MESSENGER_ROOM_H
static uint64_t timestamp(void)
Get current timestamp.
struct GNUNET_HashCode key
The key used in the DHT.
uint32_t get_srv_room_amount_of_tunnels(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the amount of active tunnels of a given room.
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.
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,...
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.
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...
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 dependi...
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
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...
struct GNUNET_MESSENGER_PeerStore * get_srv_room_peer_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used peer store of a given 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...
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 s...
void remove_srv_room(struct GNUNET_MESSENGER_SrvRoom *room)
Removes the configuration for a given room of a service.
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.
void destroy_srv_room(struct GNUNET_MESSENGER_SrvRoom *room, enum GNUNET_GenericReturnValue deletion)
Destroys a room and frees its memory fully.
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 memb...
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.
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.
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 me...
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() GNUNET_MESSENGER_MessageRequestCallback(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Method called whenever a message is found during a request in a room.
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.
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 u...
struct GNUNET_MESSENGER_OperationStore * get_srv_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
struct GNUNET_CADET_Handle * get_srv_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a 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...
void(* GNUNET_MESSENGER_SignedCallback)(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MQ_Envelope *envelope, const struct GNUNET_HashCode *hash)
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
GNUNET_GenericReturnValue
Named constants for return values.
Opaque handle to the service.
Definition cadet_api.c:39
Opaque handle to a port.
Definition cadet_api.c:80
Internal representation of the hash map.
Internal representation of the hash map.
An identity key as per LSD0001.
A 512-bit hashcode.
struct GNUNET_MESSENGER_PeerStore peer_store
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
struct GNUNET_MESSENGER_MemberStore member_store
struct GNUNET_MESSENGER_Service * service
struct GNUNET_MESSENGER_SrvHandle * sync
struct GNUNET_MESSENGER_ListTunnels basement
struct GNUNET_MESSENGER_MessageStore message_store
struct GNUNET_SCHEDULER_Task * save_task
struct GNUNET_MESSENGER_MessageState state
struct GNUNET_SCHEDULER_Task * idle_task
struct GNUNET_MESSENGER_ListMessages handling
struct GNUNET_MESSENGER_OperationStore operation_store
struct GNUNET_MESSENGER_SrvHandle * host
struct GNUNET_CONTAINER_MultiHashMap * signatures
struct GNUNET_MESSENGER_SrvRoom * room
The identity of the host (wraps the signing key of the peer).
Entry in list of pending tasks.
Definition scheduler.c:141
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.

◆ GNUNET_MESSENGER_SAVE_DELAY

#define GNUNET_MESSENGER_SAVE_DELAY

◆ GNUNET_MESSENGER_REQUEST_DELAY

#define GNUNET_MESSENGER_REQUEST_DELAY
Value:
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_minute_(void)
Return relative time of 1 minute.
Definition time.c:178

Definition at line 52 of file gnunet-service-messenger_room.h.

◆ GNUNET_MESSENGER_MERGE_DELAY

#define GNUNET_MESSENGER_MERGE_DELAY

Typedef Documentation

◆ GNUNET_MESSENGER_SignedCallback

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

Definition at line 62 of file gnunet-service-messenger_room.h.

◆ GNUNET_MESSENGER_MessageRequestCallback

typedef void() GNUNET_MESSENGER_MessageRequestCallback(void *cls, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)

Method called whenever a message is found during a request in a room.

Parameters
[in,out]clsClosure from #request_room_message
[in,out]roomRoom
[in]messageMessage or NULL
[in]hashHash of message

Definition at line 343 of file gnunet-service-messenger_room.h.

Function Documentation

◆ 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_task = NULL;
108 room->save_task = NULL;
109
110 if (room->service->dir)
111 load_srv_room (room);
112
115
116 return room;
117}
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.
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.
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...
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_SCHEDULER_PRIORITY_IDLE
Run when otherwise idle.
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
#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.

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, idle_request_room_messages(), GNUNET_MESSENGER_SrvRoom::idle_task, 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::save_task, 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:

◆ 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 168 of file gnunet-service-messenger_room.c.

170{
171 GNUNET_assert (room);
172
173 if (room->save_task)
174 {
176 room->save_task = NULL;
177 }
178
179 if (room->idle_task)
180 {
182 room->idle_task = NULL;
183 }
184
185 close_srv_room (room);
186
188 NULL);
190
191 if (! (room->service->dir))
192 goto skip_saving;
193
194 if (GNUNET_YES == deletion)
195 remove_srv_room (room);
196 else
197 save_srv_room (room);
198
199skip_saving:
204
207 room);
209
211 clear_list_tunnels (&(room->basement));
212 clear_message_state (&(room->state));
213
214 if (room->peer_message)
216
217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Free room: %s\n",
218 GNUNET_h2s (&(room->key)));
219
220 GNUNET_free (room);
221}
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_task, 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::save_task, 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 225 of file gnunet-service-messenger_room.c.

226{
227 GNUNET_assert (room);
228
229 return &(room->peer_store);
230}

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 234 of file gnunet-service-messenger_room.c.

235{
236 GNUNET_assert (room);
237
238 return &(room->member_store);
239}

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()

◆ 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 252 of file gnunet-service-messenger_room.c.

253{
254 GNUNET_assert (room);
255
256 return &(room->operation_store);
257}

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:

◆ 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 379 of file gnunet-service-messenger_room.c.

381{
382 GNUNET_assert (room);
383
384 if (handle)
385 room->host = handle;
386
387 if (room->port)
388 {
390 "Port of room (%s) was already open!\n",
392
393 if (! handle)
394 return GNUNET_YES;
395
396 return join_room_locally (room, handle);
397 }
398
399 {
402 struct GNUNET_HashCode port;
403
405 tunnel_message,
407 struct
409 ,
411
412 cadet = get_srv_room_cadet (room);
413
415 &(key.hash),
416 get_srv_room_key (room),
417 sizeof (key.hash));
418
419 if ((key.code.feed_bit) && (! key.code.group_bit))
420 {
422 "Opening port of personal room containing private feeds failed!");
423 return GNUNET_SYSERR;
424 }
425
427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to open CADET port: %s\n",
428 GNUNET_h2s (&port));
429
431 room, NULL, callback_tunnel_disconnect,
432 handlers);
433 }
434
435 if (room->port)
436 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Port of room (%s) was opened!\n",
438 else
440 "Port of room (%s) could not be opened!\n",
442
443 if (! handle)
444 goto complete_opening;
445
446 {
447 struct GNUNET_MESSENGER_MemberStore *member_store;
448 const struct GNUNET_ShortHashCode *member_id;
449 struct GNUNET_MESSENGER_Member *member;
450
451 member_store = get_srv_room_member_store (room);
453 member = add_store_member (member_store, member_id);
454
455 if ((GNUNET_NO == join_room (room, handle, member, member_id)) &&
456 (room->port))
457 {
459 "You could not join the room, therefore it keeps closed!\n");
460
461 close_srv_room (room);
462 return GNUNET_NO;
463 }
464 }
465
466complete_opening:
467 if (! room->port)
468 return GNUNET_NO;
469
470 {
471 struct GNUNET_MESSENGER_Message *message;
472 message = create_message_peer (room->service);
473
474 if (! message)
475 {
477 "Peer message could not be sent!\n");
478 return GNUNET_NO;
479 }
480
481 return send_srv_room_message (room, handle, message);
482 }
483}
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.
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.
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 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 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)
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.
struct GNUNET_CADET_Handle * get_srv_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
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
@ GNUNET_ERROR_TYPE_ERROR
#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...
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 517 of file gnunet-service-messenger_room.c.

520{
521 struct GNUNET_PeerIdentity peer;
522 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
524
525 GNUNET_assert ((room) && (handle) && (door));
526
527 if ((GNUNET_is_zero (door)) ||
529 (0 == GNUNET_memcmp (&peer, door))))
530 return join_room_locally (room, handle);
531
533
534 if (! tunnel)
535 {
536 tunnel = create_tunnel (room, door);
537
539 tunnel,
541 {
543 "You could not connect to that door!\n");
544 destroy_tunnel (tunnel);
545 return GNUNET_NO;
546 }
547 }
548
549 ret = connect_tunnel (tunnel);
550
551 if (GNUNET_YES != ret)
552 {
554 destroy_tunnel (tunnel);
555
556 if (GNUNET_SYSERR == ret)
557 {
559 "Connection failure during entrance!\n");
560 return GNUNET_NO;
561 }
562 }
563
564 return join_room_locally (room, handle);
565}
static int ret
Final status code.
Definition gnunet-arm.c:93
static void destroy_tunnel(void *cls)
This tunnel is no longer used, destroy it.
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.
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).
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.
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.
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_OK

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_is_zero, GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, handle, join_room_locally(), GNUNET_MESSENGER_SrvTunnel::peer, ret, 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:

◆ 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 630 of file gnunet-service-messenger_room.c.

634{
635 struct GNUNET_MESSENGER_SrvRoomSignature *signature;
637
638 GNUNET_assert ((room) && (message) && (callback));
639
640 if (GNUNET_YES != is_peer_message (message))
641 {
642 struct GNUNET_MQ_Envelope *envelope;
643 struct GNUNET_HashCode hash;
644
645 envelope = pack_message (message, &hash,
647
648 if (! envelope)
649 {
651 "Packing message into envelope failed: %s\n",
653 return GNUNET_SYSERR;
654 }
655
656 callback (closure, room, message, envelope, &hash);
657 return GNUNET_YES;
658 }
659
660 if (GNUNET_YES == is_epoch_message (message))
663 else
666
668 {
669 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Peer identity is missing!\n");
670 return GNUNET_SYSERR;
671 }
672
674 get_message_state_chain_hash (&(room->state), &(message->header.previous));
675
677 {
678 const struct GNUNET_MESSENGER_MessageStore *store;
679 const struct GNUNET_HashCode *epoch;
680
681 store = get_srv_room_message_store (room);
682 epoch = get_store_message_epoch (store, &(message->header.previous));
683
684 if (epoch)
685 GNUNET_memcpy (&(message->body.merge.epochs[0]), epoch,
686 sizeof (struct GNUNET_HashCode));
687
688 epoch = get_store_message_epoch (store, &(message->body.merge.previous));
689
690 if (epoch)
691 GNUNET_memcpy (&(message->body.merge.epochs[1]), epoch,
692 sizeof (struct GNUNET_HashCode));
693 }
694
696 GNUNET_assert (signature);
697
698 signature->room = room;
699 signature->message = message;
700
702 "Packing message with peer signature: %s\n",
703 GNUNET_sh2s (&(signature->message->header.sender_id)));
704
706 signature->envelope = pack_message (signature->message, &(signature->hash),
708
709 if (! signature->envelope)
710 {
712 "Packing message into envelope failed: %s\n",
714 ;
715 destroy_message (signature->message);
716 GNUNET_free (signature);
717 return GNUNET_SYSERR;
718 }
719
721 &(signature->hash)))
722 {
724 "Signature operation already queued: %s\n",
725 GNUNET_h2s (&(signature->hash)));
726
727 destroy_message (signature->message);
728 GNUNET_free (signature->envelope);
729 GNUNET_free (signature);
730 return GNUNET_SYSERR;
731 }
732
733 signature->callback = callback;
734 signature->closure = closure;
735
736 signature->operation = sign_message_by_peer (signature->message,
737 &(signature->hash),
738 room->service->pils,
740 signature);
741
742 if (! signature->operation)
743 {
745 "Signing message by peer identity (%s) failed: %s\n",
747 GNUNET_h2s (&(signature->hash)));
748
749 destroy_message (signature->message);
750 GNUNET_free (signature->envelope);
751 GNUNET_free (signature);
752 return GNUNET_SYSERR;
753 }
754
756 &(signature->hash),
757 signature,
759 {
761 "Signature operation could not be stored: %s\n",
762 GNUNET_h2s (&(signature->hash)));
763
764 iterate_cancel_signature (NULL, &(signature->hash),
765 signature);
766 return GNUNET_SYSERR;
767 }
768
769 return GNUNET_YES;
770}
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
void get_message_state_chain_hash(const struct GNUNET_MESSENGER_MessageState *state, struct GNUNET_HashCode *hash)
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.
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_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).
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_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
@ GNUNET_MESSENGER_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_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...
enum GNUNET_GenericReturnValue is_epoch_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a certain kind of message from storage contains some specific details that might be r...
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
@ 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.
struct GNUNET_CRYPTO_BlindableKeySignature signature
The signature of the senders private key.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_HashCode epochs[2]
The previous epochs the message was sent from.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_SrvRoom * room
struct GNUNET_MESSENGER_Message * message

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_contains(), 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:

◆ 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 843 of file gnunet-service-messenger_room.c.

846{
847 GNUNET_assert ((room) && (handle));
848
849 if (! message)
850 return GNUNET_NO;
851
853 "Sending message from handle in room: %s (%s)\n",
854 GNUNET_h2s (&(room->key)),
856
857 return sign_srv_room_message (room, message,
859 handle);
860}
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:

◆ 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 906 of file gnunet-service-messenger_room.c.

910{
912
913 GNUNET_assert ((room) && (envelope));
914
915 closure.exclude = tunnel;
916 closure.envelope = envelope;
917 closure.hash = hash;
918
921 &closure);
922
924}
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 928 of file gnunet-service-messenger_room.c.

930{
931 struct GNUNET_MESSENGER_MessageStore *message_store;
932 const struct GNUNET_MESSENGER_Message *message;
933
934 if (! room->peer_message)
935 return;
936
937 message_store = get_srv_room_message_store (room);
938 message = get_store_message (message_store, room->peer_message);
939
940 if (! message)
941 {
943 room->peer_message = NULL;
944 return;
945 }
946
947 if (tunnel)
948 forward_tunnel_message (tunnel, message, room->peer_message);
949}
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.
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 953 of file gnunet-service-messenger_room.c.

955{
956 const struct GNUNET_HashCode *hash;
957 struct GNUNET_MESSENGER_Message *message;
958
959 GNUNET_assert (room);
960
961 if (! handle)
962 return GNUNET_SYSERR;
963
965 "Merging messages by handle in room: %s\n",
966 GNUNET_h2s (&(room->key)));
967
968 hash = get_message_state_merge_hash (&(room->state));
969
970 if ((! hash) || (GNUNET_is_zero (hash)))
971 return GNUNET_NO;
972
973 message = create_message_merge (hash);
974
975 if (! message)
976 {
978 "Merging messages failed: %s\n",
979 GNUNET_h2s (&(room->key)));
980 return GNUNET_SYSERR;
981 }
982
983 return send_srv_room_message (room, handle, message);
984}
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...
const struct GNUNET_HashCode * get_message_state_merge_hash(const struct GNUNET_MESSENGER_MessageState *state)

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 988 of file gnunet-service-messenger_room.c.

992{
993 const struct GNUNET_MESSENGER_Message *message;
994 struct GNUNET_TIME_Relative forever;
995
996 GNUNET_assert ((room) && (session) && (hash));
997
999
1000 if (0 == GNUNET_memcmp (&forever, &delay))
1001 {
1003 "Deletion is delayed forever: operation is impossible!\n");
1004 return GNUNET_SYSERR;
1005 }
1006
1007 {
1008 struct GNUNET_MESSENGER_MessageStore *message_store;
1009
1010 message_store = get_srv_room_message_store (room);
1011 message = get_store_message (message_store, hash);
1012 }
1013
1014 if (! message)
1015 return GNUNET_YES;
1016
1017 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_YES))
1018 {
1020 "Unpermitted request for deletion by member (%s) of message (%s)!\n",
1022 hash));
1023
1024 return GNUNET_NO;
1025 }
1026
1027 {
1028 struct GNUNET_MESSENGER_OperationStore *operation_store;
1029
1030 operation_store = get_srv_room_operation_store (room);
1031
1032 if (GNUNET_OK != use_store_operation (operation_store, hash,
1034 {
1036 "Deletion has failed: operation denied!\n");
1037 return GNUNET_SYSERR;
1038 }
1039 }
1040
1041 return GNUNET_YES;
1042}
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...
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.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_(void)
Return "forever".
Definition time.c:196

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 1046 of file gnunet-service-messenger_room.c.

1047{
1048 GNUNET_assert (room);
1049
1050 return room->service->cadet;
1051}

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 1055 of file gnunet-service-messenger_room.c.

1056{
1057 GNUNET_assert (room);
1058
1059 return &(room->key);
1060}

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 1064 of file gnunet-service-messenger_room.c.

1066{
1067 GNUNET_assert ((room) && (peer));
1068
1069 return GNUNET_CONTAINER_multipeermap_get (room->tunnels, peer);
1070}

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_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 1142 of file gnunet-service-messenger_room.c.

1148{
1150
1151 GNUNET_assert ((room) && (hash));
1152
1153 result = request_room_message_step (room, hash, session, callback, cls);
1154
1155 if ((GNUNET_NO == result) && (callback))
1156 callback (cls, room, NULL, hash);
1157
1158 return result;
1159}
static int result
Global testing status.
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 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 1195 of file gnunet-service-messenger_room.c.

1200{
1201 struct GNUNET_MESSENGER_MemberStore *member_store;
1202 struct GNUNET_MESSENGER_Member *member;
1203 struct GNUNET_MESSENGER_ListHandles *handles;
1204 struct GNUNET_MESSENGER_ListHandle *element;
1205
1206 GNUNET_assert ((room) && (public_key) && (member_id));
1207
1208 member_store = get_srv_room_member_store (room);
1209 member = get_store_member (member_store, member_id);
1210
1211 if ((! member) || (1 >= GNUNET_CONTAINER_multihashmap_size (
1212 member->sessions)))
1213 return;
1214
1215 handles = &(room->service->handles);
1216
1217 for (element = handles->head; element; element = element->next)
1218 {
1221 struct GNUNET_MESSENGER_SrvMemberSession *session;
1222
1224 get_srv_room_key (room));
1225
1226 if ((! handle_member_id) ||
1227 (0 != GNUNET_memcmp (member_id, handle_member_id)))
1228 continue;
1229
1230 pubkey = get_srv_handle_key (element->handle);
1231
1232 if (0 == GNUNET_memcmp (public_key, pubkey))
1233 continue;
1234
1235 session = get_member_session (member, pubkey);
1236
1237 if (! session)
1238 continue;
1239
1240 {
1242 start = get_member_session_start (session);
1243
1244 if (GNUNET_TIME_relative_get_zero_ ().rel_value_us !=
1246 continue;
1247 }
1248
1249 {
1250 struct GNUNET_ShortHashCode random_id;
1251 generate_free_member_id (&random_id, member_store->members);
1252
1254 element->handle,
1255 room,
1256 &random_id,
1257 GNUNET_NO);
1258 }
1259 }
1260}
static int start
Set if we are to start default services (including ARM).
Definition gnunet-arm.c:38
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
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_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
static void handle_member_id(void *cls, const struct GNUNET_MESSENGER_MemberMessage *msg)
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.
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

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, handle_member_id(), 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 1264 of file gnunet-service-messenger_room.c.

1265{
1266 struct GNUNET_MESSENGER_ListTunnel *element;
1267 struct GNUNET_PeerIdentity peer;
1268 size_t count;
1269 size_t src;
1270 size_t dst;
1271
1272 GNUNET_assert (room);
1273
1274 if (GNUNET_OK != get_service_peer_identity (room->service, &peer))
1275 return;
1276
1277 count = count_of_tunnels (&(room->basement));
1278
1279 if (! find_list_tunnels (&(room->basement), &peer, &src))
1280 return;
1281
1282 if ((count > room->service->min_routers) &&
1283 (GNUNET_NO == is_srv_handle_routing (room->host, &(room->key))) &&
1285 &peer,
1287 {
1288 close_srv_room (room);
1289 return;
1290 }
1291
1292 element = room->basement.head;
1293 dst = 0;
1294
1295 while (element)
1296 {
1297 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
1298
1299 GNUNET_PEER_resolve (element->peer, &peer);
1300
1302
1303 if (! tunnel)
1304 {
1305 element = remove_from_list_tunnels (&(room->basement), element);
1306 continue;
1307 }
1308
1309 if (GNUNET_YES == required_connection_between (count, src, dst))
1310 {
1311 if (GNUNET_SYSERR == connect_tunnel (tunnel))
1312 {
1313 element = remove_from_list_tunnels (&(room->basement), element);
1314 continue;
1315 }
1316 }
1317 else
1318 disconnect_tunnel (tunnel);
1319
1320 element = element->next;
1321 dst++;
1322 }
1323}
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...
void disconnect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Disconnects and unbinds a channel from a tunnel.
@ 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 1327 of file gnunet-service-messenger_room.c.

1328{
1329 GNUNET_assert (room);
1330
1332}
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 1336 of file gnunet-service-messenger_room.c.

1337{
1338 uint32_t flags;
1339
1340 GNUNET_assert (room);
1341
1343
1344 if (GNUNET_YES == room->service->auto_routing)
1346
1347 return flags;
1348}
@ 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:

◆ 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 1552 of file gnunet-service-messenger_room.c.

1555{
1557 struct GNUNET_MESSENGER_MemberStore *member_store;
1558 struct GNUNET_MESSENGER_MessageStore *message_store;
1559
1560 GNUNET_assert ((room) && (discourse));
1561
1562 it.discourse = discourse;
1564
1565 member_store = get_srv_room_member_store (room);
1566
1568
1569 message_store = get_srv_room_message_store (room);
1570
1572 discourse,
1573 it.start);
1574}
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 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:

◆ 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 1762 of file gnunet-service-messenger_room.c.

1763{
1764 char *room_dir;
1765
1766 GNUNET_assert (room);
1767
1768 get_room_data_subdir (room, &room_dir);
1769
1770 if (! room_dir)
1771 return;
1772
1773 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load room from directory: %s\n",
1774 room_dir);
1775
1777 {
1778 char *peers_file;
1779 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1780
1781 load_peer_store (get_srv_room_peer_store (room), peers_file);
1782 GNUNET_free (peers_file);
1783
1788
1789 {
1790 char *basement_file;
1791 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1792
1793 load_list_tunnels (&(room->basement), basement_file);
1794 GNUNET_free (basement_file);
1795 }
1796
1797 load_message_state (&(room->state), room_dir);
1798 }
1799
1800 GNUNET_free (room_dir);
1801}
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
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
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 1805 of file gnunet-service-messenger_room.c.

1806{
1807 char *room_dir;
1808
1809 GNUNET_assert (room);
1810
1811 if (room->save_task)
1812 {
1814 room->save_task = NULL;
1815 }
1816
1817 get_room_data_subdir (room, &room_dir);
1818
1819 if (! room_dir)
1820 return;
1821
1822 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save room to directory: %s\n",
1823 room_dir);
1824
1825 if ((GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_NO)) ||
1827 {
1828 char *peers_file;
1829 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1830
1831 save_peer_store (get_srv_room_peer_store (room), peers_file);
1832 GNUNET_free (peers_file);
1833
1838
1839 {
1840 char *basement_file;
1841 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1842
1843 save_list_tunnels (&(room->basement), basement_file);
1844 GNUNET_free (basement_file);
1845 }
1846
1847 save_message_state (&(room->state), room_dir);
1848 }
1849
1850 GNUNET_free (room_dir);
1851}
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_SCHEDULER_cancel(), GNUNET_YES, move_message_store(), save_list_tunnels(), save_member_store(), save_message_state(), save_message_store(), save_operation_store(), save_peer_store(), GNUNET_MESSENGER_SrvRoom::save_task, and GNUNET_MESSENGER_SrvRoom::state.

Referenced by autosave_room_messages(), and 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 1855 of file gnunet-service-messenger_room.c.

1856{
1857 char *room_dir;
1858
1859 GNUNET_assert (room);
1860
1861 get_room_data_subdir (room, &room_dir);
1862
1863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove room from directory: %s\n",
1864 room_dir);
1865
1868
1869 GNUNET_free (room_dir);
1870}
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition disk.c:1140

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: