GNUnet 0.22.0
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_MemberSessionCompletion
 
struct  GNUNET_MESSENGER_MemberUpdate
 

Functions

static void idle_request_room_messages (void *cls)
 
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. More...
 
static enum GNUNET_GenericReturnValue iterate_destroy_tunnels (void *cls, const struct GNUNET_PeerIdentity *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. More...
 
struct GNUNET_MESSENGER_PeerStoreget_srv_room_peer_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used peer store of a given room. More...
 
struct GNUNET_MESSENGER_MemberStoreget_srv_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used member store of a given room. More...
 
struct GNUNET_MESSENGER_MessageStoreget_srv_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used message store of a given room. More...
 
struct GNUNET_MESSENGER_OperationStoreget_srv_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used operation store of a given room. More...
 
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 check_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
 
void handle_tunnel_message (void *cls, const struct GNUNET_MessageHeader *header)
 
void callback_tunnel_disconnect (void *cls, const struct GNUNET_CADET_Channel *channel)
 
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. More...
 
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. More...
 
static void sign_srv_room_message_by_peer (const void *cls, struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash)
 
struct GNUNET_MQ_Envelopepack_srv_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_PackMode mode)
 Packs a message depending on the selected mode into a newly allocated envelope. More...
 
static enum GNUNET_GenericReturnValue iterate_send_room_message (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 
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)
 
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. More...
 
void forward_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Forwards a message with a given hash to a specific tunnel inside of a room. More...
 
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. More...
 
void 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. More...
 
void callback_room_deletion (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash)
 
void callback_room_merge (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash)
 
enum GNUNET_GenericReturnValue delete_srv_room_message (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *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. More...
 
struct GNUNET_CADET_Handleget_srv_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the CADET handle from a rooms service. More...
 
const struct GNUNET_HashCodeget_srv_room_key (const struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the shared secret you need to access a room. More...
 
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. More...
 
static enum GNUNET_GenericReturnValue request_room_message_step (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_MemberSession *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_MemberSession *session, GNUNET_MESSENGER_MessageRequestCallback callback, void *cls)
 Requests a message from a room identified by a given hash. More...
 
void callback_room_disconnect (struct GNUNET_MESSENGER_SrvRoom *room, void *cls)
 
enum GNUNET_GenericReturnValue callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
 
void solve_srv_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_CRYPTO_PublicKey *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). More...
 
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. More...
 
uint32_t get_srv_room_amount_of_tunnels (const struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the amount of active tunnels of a given room. More...
 
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. More...
 
static enum GNUNET_GenericReturnValue iterate_member_for_subscription (void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *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. More...
 
static enum GNUNET_GenericReturnValue iterate_update_member_sessions (void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
 
static void remove_room_member_session (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session)
 
static void get_room_data_subdir (struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
 
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. More...
 
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. More...
 
void remove_srv_room (struct GNUNET_MESSENGER_SrvRoom *room)
 Removes the configuration for a given room of a service. More...
 

Function Documentation

◆ idle_request_room_messages()

static void idle_request_room_messages ( void *  cls)
static

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

1033{
1034 struct GNUNET_MESSENGER_SrvRoom *room;
1035 struct GNUNET_MESSENGER_OperationStore *operation_store;
1036 const struct GNUNET_HashCode *hash;
1037
1038 GNUNET_assert (cls);
1039
1040 room = cls;
1041 room->idle = NULL;
1042
1043 operation_store = get_srv_room_operation_store (room);
1044 hash = get_message_state_merge_hash (&(room->state));
1045
1046 if ((hash) &&
1048 hash)))
1050 operation_store,
1051 hash,
1054 );
1055
1060 cls
1061 );
1062}
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
@ 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:1206
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_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:

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

48{
49 struct GNUNET_MESSENGER_SrvRoom *room;
50
51 GNUNET_assert ((handle) && (key));
52
54
55 room->service = handle->service;
56 room->host = handle;
57 room->port = NULL;
58
59 GNUNET_memcpy (&(room->key), key, sizeof(struct GNUNET_HashCode));
60
62
67
68 init_list_tunnels (&(room->basement));
69 init_message_state (&(room->state));
70
71 room->peer_message = NULL;
72
74 room->idle = NULL;
75
76 if (room->service->dir)
77 load_srv_room (room);
78
81
82 return room;
83}
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)
Initializes a message store as fully empty.
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.
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_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_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_NO
#define GNUNET_new(type)
Allocate a struct or union of the given type.
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:1230
void init_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Initializes list of tunnels peer identities as empty list.
struct GNUNET_HashCode * peer_message
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
struct GNUNET_MESSENGER_Service * service
struct GNUNET_CADET_Port * port
struct GNUNET_MESSENGER_ListTunnels basement
struct GNUNET_MESSENGER_ListMessages handling
struct GNUNET_MESSENGER_SrvHandle * host

References GNUNET_MESSENGER_SrvRoom::basement, 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_multipeermap_create(), GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_with_priority(), GNUNET_SCHEDULER_PRIORITY_IDLE, 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::state, 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 87 of file gnunet-service-messenger_room.c.

90{
91 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
92
94
95 tunnel = value;
96
97 destroy_tunnel (tunnel);
98 return GNUNET_YES;
99}
static char * value
Value of the record to add/remove.
static void destroy_tunnel(void *cls)
This tunnel is no longer used, destroy it.
@ GNUNET_YES

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:

◆ close_srv_room()

static void close_srv_room ( struct GNUNET_MESSENGER_SrvRoom room)
static

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

404{
405 struct GNUNET_PeerIdentity peer;
406
407 GNUNET_assert (room);
408
409 if (! room->port)
410 return;
411
412 if ((room->peer_message) &&
413 (GNUNET_OK == get_service_peer_identity (room->service, &peer)))
414 send_srv_room_message (room, room->host, create_message_miss (&peer));
415
417 room->port = NULL;
418}
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:801
@ GNUNET_OK
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_OK, GNUNET_MESSENGER_SrvRoom::host, 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 1215 of file gnunet-service-messenger_room.c.

1216{
1217 struct GNUNET_MESSENGER_MessageStore *message_store;
1218 struct GNUNET_MESSENGER_MemberStore *member_store;
1219 struct GNUNET_MESSENGER_PeerStore *peer_store;
1220 const struct GNUNET_HashCode *key;
1221
1222 message_store = get_srv_room_message_store (room);
1223 member_store = get_srv_room_member_store (room);
1224 peer_store = get_srv_room_peer_store (room);
1225
1226 key = get_srv_room_key (room);
1227
1229 "Handling room messages: %s\n", GNUNET_h2s (key));
1230
1231 while (room->handling.head)
1232 {
1233 struct GNUNET_MESSENGER_ListMessage *element;
1234 struct GNUNET_MESSENGER_SenderSession session;
1235 const struct GNUNET_MESSENGER_Message *message;
1236
1237 element = room->handling.head;
1238 message = get_store_message (
1239 message_store, &(element->hash));
1240
1241 if (! message)
1242 goto finish_handling;
1243
1244 if (GNUNET_YES == is_peer_message (message))
1245 {
1246 session.peer = get_store_peer_of (peer_store, message, &(element->hash));
1247
1248 if (! session.peer)
1249 goto finish_handling;
1250 }
1251 else
1252 {
1253 struct GNUNET_MESSENGER_Member *member;
1254
1255 member = get_store_member_of (member_store, message);
1256
1257 if (! member)
1258 goto finish_handling;
1259
1260 session.member = get_member_session_of (member, message,
1261 &(element->hash));
1262
1263 if (! session.member)
1264 goto finish_handling;
1265 }
1266
1267 handle_service_message (room->service, room, &session, message,
1268 &(element->hash));
1269
1270finish_handling:
1272 element);
1273 GNUNET_free (element);
1274 }
1275}
struct GNUNET_MESSENGER_MemberSession * 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_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.
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 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)
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.
#define GNUNET_log(kind,...)
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_free(ptr)
Wrapper around free.
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_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 109 of file gnunet-service-messenger_room.c.

111{
112 GNUNET_assert (room);
113
114 if (room->idle)
115 {
117 room->idle = NULL;
118 }
119
120 close_srv_room (room);
121
123 NULL);
125
126 if (! (room->service->dir))
127 goto skip_saving;
128
129 if (GNUNET_YES == deletion)
130 remove_srv_room (room);
131 else
132 save_srv_room (room);
133
134skip_saving:
139
141 clear_list_tunnels (&(room->basement));
142 clear_message_state (&(room->state));
143
144 if (room->peer_message)
146
147 GNUNET_free (room);
148}
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...
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)
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_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:979
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_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_YES, handle_room_messages(), GNUNET_MESSENGER_SrvRoom::idle, iterate_destroy_tunnels(), GNUNET_MESSENGER_SrvRoom::peer_message, remove_srv_room(), GNUNET_MESSENGER_SrvTunnel::room, save_srv_room(), GNUNET_MESSENGER_SrvRoom::service, 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 152 of file gnunet-service-messenger_room.c.

153{
154 GNUNET_assert (room);
155
156 return &(room->peer_store);
157}
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(), and save_srv_room().

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

162{
163 GNUNET_assert (room);
164
165 return &(room->member_store);
166}
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(), and solve_srv_room_member_collisions().

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)

Returns the used message store of a given room.

Parameters
[in,out]roomRoom
Returns
Message store

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

171{
172 GNUNET_assert (room);
173
174 return &(room->message_store);
175}
struct GNUNET_MESSENGER_MessageStore message_store

References GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::message_store.

Referenced by callback_room_deletion(), callback_verify_room_message(), check_member_session_completion(), check_srv_room_peer_status(), cleanup_srv_room_discourse_messages(), create_srv_room(), delete_srv_room_message(), destroy_srv_room(), forward_about_members(), handle_room_messages(), load_srv_room(), notify_about_members(), recv_message_info(), request_room_message_step(), save_srv_room(), update_room_message(), and update_tunnel_last_message().

Here is the caller graph for this function:

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

180{
181 GNUNET_assert (room);
182
183 return &(room->operation_store);
184}
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 188 of file gnunet-service-messenger_room.c.

191{
192 if ((! handle) || (! is_tunnel_connected (tunnel)))
193 return GNUNET_NO;
194
196 room->service));
197}
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 201 of file gnunet-service-messenger_room.c.

204{
205 struct GNUNET_MESSENGER_SrvRoom *room;
206 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
207
208 GNUNET_assert ((cls) && (channel) && (source));
209
210 room = cls;
211 tunnel = create_tunnel (room, source);
212
213 if ((tunnel) &&
215 tunnel,
217 {
218 destroy_tunnel (tunnel);
219 tunnel = NULL;
220 }
221
222 if (! tunnel)
223 {
225 return NULL;
226 }
227
228 bind_tunnel (tunnel, channel);
229
231 "New tunnel in room (%s) established to peer: %s\n",
233
234 if (GNUNET_YES == send_room_info (room, room->host, tunnel))
235 return tunnel;
236
237 disconnect_tunnel (tunnel);
238
240 tunnel))
241 destroy_tunnel (tunnel);
242
243 return NULL;
244}
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).
@ GNUNET_ERROR_TYPE_INFO
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_INFO, 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 248 of file gnunet-service-messenger_room.c.

252{
253 const struct GNUNET_ShortHashCode *member_id;
254
255 GNUNET_assert ((room) && (handle) && (member));
256
257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (
258 get_srv_room_key (room)),
259 GNUNET_sh2s (get_member_id (member)));
260
261 member_id = get_member_id (member);
262
264 member_id))
265 return GNUNET_NO;
266
267 {
269 if ((! id) || (0 != GNUNET_memcmp (id, member_id)))
271 else
273
274 notify_srv_handle_member_id (handle, room, member_id, reset);
275 }
276
277 return GNUNET_YES;
278}
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 282 of file gnunet-service-messenger_room.c.

284{
285 struct GNUNET_MESSENGER_MemberStore *member_store;
286 const struct GNUNET_ShortHashCode *member_id;
287 struct GNUNET_MESSENGER_Member *member;
288
289 member_store = get_srv_room_member_store (room);
291 member = add_store_member (member_store, member_id);
292
293 if (GNUNET_NO == join_room (room, handle, member, member_id))
294 return GNUNET_NO;
295
296 return GNUNET_YES;
297}
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:

◆ check_tunnel_message()

enum GNUNET_GenericReturnValue check_tunnel_message ( void *  cls,
const struct GNUNET_MessageHeader header 
)

Definition at line 121 of file gnunet-service-messenger_tunnel.c.

123{
124 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
125 struct GNUNET_MESSENGER_Message message;
126 struct GNUNET_HashCode hash;
127 uint16_t length;
128 const char *buffer;
129
130 GNUNET_assert (header);
131
132 tunnel = cls;
133
134 if (! tunnel)
135 return GNUNET_SYSERR;
136
137 length = ntohs (header->size) - sizeof(*header);
138 buffer = (const char*) &header[1];
139
141 GNUNET_YES))
142 {
144 "Tunnel error: Message too short! (%d)\n", length);
145 return GNUNET_SYSERR;
146 }
147
148 {
149 uint16_t padding;
150 padding = 0;
151
152 if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES,
153 &padding))
154 {
155 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Tunnel error: Decoding failed!\n");
156 return GNUNET_SYSERR;
157 }
158
159 hash_message (&message, length - padding, buffer, &hash);
160 }
161
162 return callback_verify_room_message (tunnel->room, cls, &message, &hash);
163}
enum GNUNET_GenericReturnValue callback_verify_room_message(struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_MESSENGER_KIND_UNKNOWN
The unknown kind.
void hash_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, struct GNUNET_HashCode *hash)
Calculates a hash of a given buffer with a length in bytes from a message.
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind, enum GNUNET_GenericReturnValue include_header)
Returns the minimal size in bytes to encode a message of a specific kind.
enum GNUNET_GenericReturnValue decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, enum GNUNET_GenericReturnValue include_header, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.

References callback_verify_room_message(), decode_message(), get_message_kind_size(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_SYSERR, GNUNET_YES, hash_message(), GNUNET_MESSENGER_SrvTunnel::room, and GNUNET_MessageHeader::size.

Here is the call graph for this function:

◆ handle_tunnel_message()

void handle_tunnel_message ( void *  cls,
const struct GNUNET_MessageHeader header 
)

Definition at line 207 of file gnunet-service-messenger_tunnel.c.

208{
209 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
210 struct GNUNET_MESSENGER_Message message;
211 struct GNUNET_HashCode hash;
212 uint16_t length;
213 const char *buffer;
214
215 GNUNET_assert (header);
216
217 tunnel = cls;
218
219 if (! tunnel)
220 return;
221
222 length = ntohs (header->size) - sizeof(*header);
223 buffer = (const char*) &header[1];
224
225 {
226 uint16_t padding;
227 padding = 0;
228
229 decode_message (&message, length, buffer, GNUNET_YES, &padding);
230 hash_message (&message, length - padding, buffer, &hash);
231 }
232
233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message of kind: %s!\n",
234 GNUNET_MESSENGER_name_of_kind (message.header.kind));
235
236 {
237 enum GNUNET_GenericReturnValue new_message;
238 new_message = update_room_message (tunnel->room,
239 copy_message (&message),
240 &hash);
241
242 if (GNUNET_YES != new_message)
243 goto receive_done;
244 }
245
246 update_tunnel_last_message (tunnel, &hash);
247
248 {
249 enum GNUNET_GenericReturnValue forward_message;
250 forward_message = GNUNET_YES;
251
252 switch (message.header.kind)
253 {
255 forward_message = recv_message_info (tunnel->room, tunnel, &message, &hash);
256 break;
258 forward_message = recv_message_peer (tunnel->room, tunnel, &message, &hash);
259 break;
261 forward_message = recv_message_miss (tunnel->room, tunnel, &message, &hash);
262 break;
264 forward_message = recv_message_request (tunnel->room, tunnel, &message,
265 &hash);
266 break;
267 default:
268 break;
269 }
270
271 if (GNUNET_YES == forward_message)
272 {
273 forward_srv_room_message (tunnel->room, tunnel, &message, &hash);
274 callback_room_handle_message (tunnel->room, &message, &hash);
275 }
276 }
277
278receive_done:
279 cleanup_message (&message);
280
282}
enum GNUNET_GenericReturnValue recv_message_request(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received request message by checking for the requested message and forwarding it back if th...
enum GNUNET_GenericReturnValue recv_message_miss(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received miss message to react to activity in the basement of a room.
enum GNUNET_GenericReturnValue recv_message_info(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received info message to change the current member id to the one generated by the host conn...
enum GNUNET_GenericReturnValue recv_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received peer message to link it to its origin tunnel if the peer identity matches.
void forward_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Forwards a message with a given hash to a specific tunnel inside of a room.
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 update_tunnel_last_message(struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_HashCode *hash)
void GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Indicate readiness to receive the next message on a channel.
Definition: cadet_api.c:872
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:43
@ GNUNET_MESSENGER_KIND_INFO
The info kind.
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_REQUEST
The request kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
void cleanup_message(struct GNUNET_MESSENGER_Message *message)
Frees the messages body memory.

References callback_room_handle_message(), GNUNET_MESSENGER_SrvTunnel::channel, cleanup_message(), copy_message(), decode_message(), forward_srv_room_message(), GNUNET_assert, GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSENGER_KIND_INFO, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_name_of_kind(), GNUNET_YES, hash_message(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, recv_message_info(), recv_message_miss(), recv_message_peer(), recv_message_request(), GNUNET_MESSENGER_SrvTunnel::room, GNUNET_MessageHeader::size, update_room_message(), and update_tunnel_last_message().

Here is the call graph for this function:

◆ callback_tunnel_disconnect()

void callback_tunnel_disconnect ( void *  cls,
const struct GNUNET_CADET_Channel channel 
)

Definition at line 98 of file gnunet-service-messenger_tunnel.c.

100{
101 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
102
103 tunnel = cls;
104
105 if (tunnel)
106 {
107 tunnel->channel = NULL;
108
109 callback_room_disconnect (tunnel->room, cls);
110 }
111}
void callback_room_disconnect(struct GNUNET_MESSENGER_SrvRoom *room, void *cls)

References callback_room_disconnect(), GNUNET_MESSENGER_SrvTunnel::channel, and GNUNET_MESSENGER_SrvTunnel::room.

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

316{
317 GNUNET_assert (room);
318
319 if (handle)
320 room->host = handle;
321
322 if (room->port)
323 {
324 if (! handle)
325 return GNUNET_YES;
326
327 return join_room_locally (room, handle);
328 }
329
330 {
332 const struct GNUNET_HashCode *key;
333 struct GNUNET_HashCode port;
334
336 tunnel_message,
338 struct
341
342 cadet = get_srv_room_cadet (room);
343 key = get_srv_room_key (room);
344
347 room, NULL, callback_tunnel_disconnect,
348 handlers);
349 }
350
351 if (room->port)
352 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Port of room (%s) was opened!\n",
354 else
356 "Port of room (%s) could not be opened!\n",
358
359 if (! handle)
360 goto complete_opening;
361
362 {
363 struct GNUNET_MESSENGER_MemberStore *member_store;
364 const struct GNUNET_ShortHashCode *member_id;
365 struct GNUNET_MESSENGER_Member *member;
366
367 member_store = get_srv_room_member_store (room);
369 member = add_store_member (member_store, member_id);
370
371 if ((GNUNET_NO == join_room (room, handle, member, member_id)) &&
372 (room->port))
373 {
375 "You could not join the room, therefore it keeps closed!\n");
376
377 close_srv_room (room);
378 return GNUNET_NO;
379 }
380 }
381
382complete_opening:
383 if (! room->port)
384 return GNUNET_NO;
385
386 {
387 struct GNUNET_MESSENGER_Message *message;
388 message = create_message_peer (room->service);
389
390 if (! message)
391 {
393 "Peer message could not be sent!\n");
394 return GNUNET_NO;
395 }
396
397 return send_srv_room_message (room, handle, message);
398 }
399}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static uint16_t port
Port number.
Definition: gnunet-bcd.c:147
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)
void callback_tunnel_disconnect(void *cls, const struct GNUNET_CADET_Channel *channel)
struct GNUNET_CADET_Handle * get_srv_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
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:954
@ 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 struct GNUNET_HashCode *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.

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_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_CADET_CLI, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_NO, 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 422 of file gnunet-service-messenger_room.c.

425{
426 struct GNUNET_PeerIdentity peer;
427 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
428
429 GNUNET_assert ((room) && (handle) && (door));
430
432 (0 == GNUNET_memcmp (&peer, door)))
433 return join_room_locally (room, handle);
434
436
437 if (! tunnel)
438 {
439 tunnel = create_tunnel (room, door);
440
442 tunnel,
444 {
446 "You could not connect to that door!\n");
447 destroy_tunnel (tunnel);
448 return GNUNET_NO;
449 }
450 }
451
452 if (GNUNET_SYSERR == connect_tunnel (tunnel))
453 {
455 "Connection failure during entrance!\n");
457 destroy_tunnel (tunnel);
458 return GNUNET_NO;
459 }
460
461 return join_room_locally (room, handle);
462}
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_room_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_by_peer()

static void sign_srv_room_message_by_peer ( const void *  cls,
struct GNUNET_MESSENGER_Message message,
uint16_t  length,
char *  buffer,
const struct GNUNET_HashCode hash 
)
static

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

471{
473
474 GNUNET_assert ((cls) && (message) && (buffer) && (hash));
475
476 handle = cls;
477
478 GNUNET_assert (handle->service);
479
480 sign_message_by_peer (message, length, buffer, hash, handle->service->config);
481}
void sign_message_by_peer(struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash, const struct GNUNET_CONFIGURATION_Handle *cfg)
Signs the hash of a message with the peer identity of a given config and writes the signature into th...

References GNUNET_assert, handle, and sign_message_by_peer().

Referenced by pack_srv_room_message().

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

◆ pack_srv_room_message()

struct GNUNET_MQ_Envelope * pack_srv_room_message ( const struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_Message message,
struct GNUNET_HashCode hash,
enum GNUNET_MESSENGER_PackMode  mode 
)

Packs a message depending on the selected mode 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 handles private key.

If the optional hash parameter is a valid pointer, its value will be overridden by the signed messages hash.

If mode is set to GNUNET_MESSENGER_PACK_MODE_ENVELOPE, the function returns a valid envelope to send through a message queue, otherwise NULL.

Parameters
[in]roomRoom
[in]handleHandle
[in,out]messageMessage
[out]hashHash of message
[in]modePacking mode
Returns
New envelope or NULL

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

490{
491 struct GNUNET_PeerIdentity peer;
492
493 GNUNET_assert ((room) && (handle) && (message) && (hash));
494
495 if (GNUNET_YES != is_peer_message (message))
496 return pack_message (message, hash, NULL, mode, NULL);
497
500
501 if (GNUNET_OK != get_service_peer_identity (handle->service, &peer))
502 return NULL;
503
504 convert_peer_identity_to_id (&peer, &(message->header.sender_id));
505 get_message_state_chain_hash (&(room->state), &(message->header.previous));
506
508 "Packing message with peer signature: %s\n",
509 GNUNET_sh2s (&(message->header.sender_id)));
510
512 return pack_message (message, hash, sign_srv_room_message_by_peer, mode,
513 handle);
514}
void get_message_state_chain_hash(const struct GNUNET_MESSENGER_MessageState *state, struct GNUNET_HashCode *hash)
static void sign_srv_room_message_by_peer(const void *cls, struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, const struct GNUNET_HashCode *hash)
static enum @44 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:640
struct GNUNET_MQ_Envelope * pack_message(struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, const GNUNET_MESSENGER_SignFunction sign, enum GNUNET_MESSENGER_PackMode mode, const void *cls)
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_P...
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 ...
uint32_t type
Type of signature.
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
struct GNUNET_CRYPTO_Signature signature
The signature of the senders private key.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_MESSENGER_MessageHeader header
Header.

References convert_peer_identity_to_id(), get_message_state_chain_hash(), get_service_peer_identity(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_PUBLIC_KEY_TYPE_EDDSA, GNUNET_sh2s(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_YES, handle, GNUNET_MESSENGER_Message::header, is_peer_message(), mode, pack_message(), GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageHeader::sender_id, sign_srv_room_message_by_peer(), GNUNET_MESSENGER_MessageHeader::signature, GNUNET_MESSENGER_SrvRoom::state, GNUNET_MESSENGER_MessageHeader::timestamp, and GNUNET_CRYPTO_Signature::type.

Referenced by iterate_send_room_message(), send_srv_room_message(), and send_tunnel_message().

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

◆ iterate_send_room_message()

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

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

531{
532 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
533 struct GNUNET_MESSENGER_ClosureSendRoom *closure;
534 struct GNUNET_MQ_Envelope *env;
535
536 GNUNET_assert ((cls) && (value));
537
538 tunnel = value;
539
540 if ((! is_tunnel_connected (tunnel)) ||
542 return GNUNET_YES;
543
544 closure = cls;
545
546 if (tunnel == closure->exclude)
547 return GNUNET_YES;
548
549 env = NULL;
550
551 if (closure->packed == GNUNET_NO)
552 {
553 env = pack_srv_room_message (closure->room, closure->handle,
554 closure->message, closure->hash,
556
557 if (env)
558 closure->packed = GNUNET_YES;
559 }
560 else
561 env = pack_message (closure->message, NULL, NULL,
563
564 if (env)
565 send_tunnel_envelope (tunnel, env, closure->hash);
566
567 return GNUNET_YES;
568}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MQ_Envelope * pack_srv_room_message(const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, enum GNUNET_MESSENGER_PackMode mode)
Packs a message depending on the selected mode into a newly allocated envelope.
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.
@ GNUNET_MESSENGER_PACK_MODE_ENVELOPE
struct GNUNET_MESSENGER_SrvHandle * handle
struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_SrvTunnel * exclude
struct GNUNET_MESSENGER_SrvRoom * room

References env, GNUNET_MESSENGER_ClosureSendRoom::exclude, get_tunnel_messenger_version(), GNUNET_assert, GNUNET_MESSENGER_PACK_MODE_ENVELOPE, GNUNET_MESSENGER_VERSION, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_ClosureSendRoom::handle, GNUNET_MESSENGER_ClosureSendRoom::hash, is_tunnel_connected(), GNUNET_MESSENGER_ClosureSendRoom::message, pack_message(), pack_srv_room_message(), GNUNET_MESSENGER_ClosureSendRoom::packed, GNUNET_MESSENGER_ClosureSendRoom::room, send_tunnel_envelope(), and value.

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

1282{
1283 struct GNUNET_MESSENGER_OperationStore *operation_store;
1284 struct GNUNET_MESSENGER_MessageStore *message_store;
1285 enum GNUNET_GenericReturnValue requested;
1286
1287 GNUNET_assert ((room) && (message) && (hash));
1288
1289 operation_store = get_srv_room_operation_store (room);
1290
1291 requested = (GNUNET_MESSENGER_OP_REQUEST ==
1292 get_store_operation_type (operation_store, hash)?
1294
1295 if (GNUNET_YES == requested)
1296 cancel_store_operation (operation_store, hash);
1297
1298 message_store = get_srv_room_message_store (room);
1299
1300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handle a message in room (%s).\n",
1301 GNUNET_h2s (get_srv_room_key (room)));
1302
1303 if (GNUNET_YES == contains_store_message (message_store, hash))
1304 {
1305 destroy_message (message);
1306
1307 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Duplicate message got dropped!\n");
1308 return GNUNET_NO;
1309 }
1310
1311 if (GNUNET_OK != put_store_message (message_store, hash, message))
1312 {
1313 destroy_message (message);
1314
1315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Storing message failed!\n");
1316 return GNUNET_NO;
1317 }
1318
1319 update_message_state (&(room->state), requested, message, hash);
1320
1321 if ((GNUNET_YES == requested) ||
1322 (GNUNET_MESSENGER_KIND_INFO == message->header.kind) ||
1324 return GNUNET_YES;
1325
1326 if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
1328 &(message->body.
1329 merge.previous))))
1330 cancel_store_operation (operation_store, &(message->body.merge.previous));
1331
1333 &(message->header.
1334 previous)))
1335 cancel_store_operation (operation_store, &(message->header.previous));
1336
1337 return GNUNET_YES;
1338}
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_MERGE
The merge kind.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
struct GNUNET_MESSENGER_MessageMerge merge
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_MESSENGER_MessageBody body
Body.

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 handle_tunnel_message(), and send_srv_room_message().

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

1450{
1451 struct GNUNET_MESSENGER_PeerStore *peer_store;
1452 struct GNUNET_MESSENGER_MemberStore *member_store;
1453 struct GNUNET_MESSENGER_SenderSession session;
1454 enum GNUNET_GenericReturnValue start_handle;
1455
1456 GNUNET_assert ((room) && (message) && (hash));
1457
1458 peer_store = get_srv_room_peer_store (room);
1459 member_store = get_srv_room_member_store (room);
1460
1461 if (GNUNET_YES == is_peer_message (message))
1462 {
1463 session.peer = get_store_peer_of (peer_store, message, hash);
1464
1465 if (! session.peer)
1466 {
1468 "Message handling dropped: Peer is missing!\n");
1469 return;
1470 }
1471 }
1472 else
1473 {
1474 struct GNUNET_MESSENGER_Member *member;
1475 member = get_store_member_of (member_store, message);
1476
1477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for message (%s)\n",
1478 GNUNET_h2s (hash));
1479
1480 if (! member)
1481 {
1483 "Message handling dropped: Member is missing!\n");
1484 return;
1485 }
1486
1487 session.member = get_member_session_of (member, message, hash);
1488
1489 if (! session.member)
1490 {
1492 "Message handling dropped: Session is missing!\n");
1493 return;
1494 }
1495 }
1496
1497 {
1498 struct GNUNET_MESSENGER_MemberUpdate update;
1499 update.message = message;
1500 update.hash = hash;
1501
1502 update.head = NULL;
1503 update.tail = NULL;
1504
1506
1507 while (update.head)
1508 {
1509 struct GNUNET_MESSENGER_MemberSessionCompletion *element = update.head;
1510
1511 remove_room_member_session (room, element->session);
1512
1513 GNUNET_CONTAINER_DLL_remove (update.head, update.tail, element);
1514 GNUNET_free (element);
1515 }
1516 }
1517
1518 start_handle = room->handling.head ? GNUNET_NO : GNUNET_YES;
1519
1520 add_to_list_messages (&(room->handling), hash);
1521
1522 switch (message->header.kind)
1523 {
1525 handle_message_join (room, &session, message, hash);
1526 break;
1528 handle_message_leave (room, &session, message, hash);
1529 break;
1531 handle_message_key (room, &session, message, hash);
1532 break;
1534 handle_message_peer (room, &session, message, hash);
1535 break;
1537 handle_message_id (room, &session, message, hash);
1538 break;
1540 handle_message_miss (room, &session, message, hash);
1541 break;
1543 handle_message_delete (room, &session, message, hash);
1544 break;
1546 handle_message_connection (room, &session, message, hash);
1547 break;
1549 handle_message_subscribe (room, &session, message, hash);
1550 break;
1551 default:
1552 break;
1553 }
1554
1555 if (GNUNET_YES == start_handle)
1556 handle_room_messages (room);
1557}
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 void remove_room_member_session(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session)
static enum GNUNET_GenericReturnValue iterate_update_member_sessions(void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_SUBSCRIBE
The subscribe kind.
@ GNUNET_MESSENGER_KIND_KEY
The key kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_DELETE
The delete kind.
@ GNUNET_MESSENGER_KIND_CONNECTION
The connection kind.
@ GNUNET_MESSENGER_KIND_ID
The id kind.
struct GNUNET_MESSENGER_MemberSession * session
const struct GNUNET_MESSENGER_Message * message

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_DELETE, 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_SUBSCRIBE, 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_MemberSessionCompletion::session, and GNUNET_MESSENGER_MemberUpdate::tail.

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

585{
586 struct GNUNET_HashCode hash;
587
588 GNUNET_assert ((room) && (handle));
589
590 if (! message)
591 return GNUNET_NO;
592
594 "Sending message from handle in room: %s (%s)\n",
595 GNUNET_h2s (&(room->key)),
597
598 {
600
601 closure.room = room;
602 closure.handle = handle;
603 closure.exclude = NULL;
604 closure.message = message;
605 closure.hash = &hash;
606 closure.packed = GNUNET_NO;
607
609 iterate_send_room_message, &closure);
610
611 if (GNUNET_NO == closure.packed)
614 }
615
616 {
617 enum GNUNET_GenericReturnValue new_message;
618 new_message = update_room_message (room, message, &hash);
619
620 if (GNUNET_YES != new_message)
621 {
622 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Sending duplicate message failed!\n");
623 return GNUNET_SYSERR;
624 }
625 }
626
627 switch (message->header.kind)
628 {
631 break;
634 break;
637 break;
640 break;
643 break;
644 default:
645 break;
646 }
647
649 return GNUNET_YES;
650}
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 callback_room_handle_message(struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
static enum GNUNET_GenericReturnValue iterate_send_room_message(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
@ GNUNET_MESSENGER_PACK_MODE_UNKNOWN

References callback_room_handle_message(), GNUNET_MESSENGER_ClosureSendRoom::exclude, GNUNET_assert, GNUNET_CONTAINER_multipeermap_iterate(), 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_PEER, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_name_of_kind(), GNUNET_MESSENGER_PACK_MODE_UNKNOWN, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, handle, GNUNET_MESSENGER_ClosureSendRoom::handle, GNUNET_MESSENGER_ClosureSendRoom::hash, GNUNET_MESSENGER_Message::header, iterate_send_room_message(), GNUNET_MESSENGER_SrvRoom::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ClosureSendRoom::message, pack_srv_room_message(), GNUNET_MESSENGER_ClosureSendRoom::packed, GNUNET_MESSENGER_ClosureSendRoom::room, send_message_id(), send_message_join(), send_message_key(), send_message_peer(), send_message_request(), GNUNET_MESSENGER_SrvRoom::tunnels, and update_room_message().

Referenced by callback_room_disconnect(), callback_room_merge(), close_service_room(), close_srv_room(), 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:

◆ forward_srv_room_message()

void forward_srv_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvTunnel tunnel,
struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Forwards a message with a given hash to a specific tunnel inside of a room.

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

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

658{
660 struct GNUNET_HashCode message_hash;
661
662 GNUNET_assert ((room) && (tunnel));
663
664 if (! message)
665 return;
666
667 GNUNET_memcpy (&message_hash, hash, sizeof(struct GNUNET_HashCode));
668
669 closure.room = room;
670 closure.handle = NULL;
671 closure.exclude = tunnel;
672 closure.message = message;
673 closure.hash = &message_hash;
674 closure.packed = GNUNET_YES;
675
677 iterate_send_room_message, &closure);
678}

References GNUNET_MESSENGER_ClosureSendRoom::exclude, GNUNET_assert, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_memcpy, GNUNET_YES, GNUNET_MESSENGER_ClosureSendRoom::handle, GNUNET_MESSENGER_ClosureSendRoom::hash, iterate_send_room_message(), GNUNET_MESSENGER_ClosureSendRoom::message, GNUNET_MESSENGER_ClosureSendRoom::packed, GNUNET_MESSENGER_ClosureSendRoom::room, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by 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 682 of file gnunet-service-messenger_room.c.

684{
685 struct GNUNET_MESSENGER_MessageStore *message_store;
686 const struct GNUNET_MESSENGER_Message *message;
687
688 if (! room->peer_message)
689 return;
690
691 message_store = get_srv_room_message_store (room);
692 message = get_store_message (message_store, room->peer_message);
693
694 if (! message)
695 {
697 room->peer_message = NULL;
698 return;
699 }
700
701 if (tunnel)
702 forward_tunnel_message (tunnel, message, room->peer_message);
703}
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()

void 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.

Parameters
[in,out]roomRoom
[in,out]handleHandle

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

709{
710 const struct GNUNET_HashCode *hash;
711
712 GNUNET_assert (room);
713
714 if (! handle)
715 return;
716
718 "Merging messages by handle in room: %s\n",
719 GNUNET_h2s (&(room->key)));
720
721 do
722 {
723 struct GNUNET_MESSENGER_Message *message;
724
725 hash = get_message_state_merge_hash (&(room->state));
726
727 if (! hash)
728 break;
729
730 message = create_message_merge (hash);
731
732 if (! message)
733 {
735 "Merging messages failed: %s\n",
736 GNUNET_h2s (&(room->key)));
737 }
738
739 send_srv_room_message (room, handle, message);
740 }
741 while (hash);
742}
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_log, handle, GNUNET_MESSENGER_SrvRoom::key, send_srv_room_message(), and GNUNET_MESSENGER_SrvRoom::state.

Referenced by sync_srv_handle_messages().

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

◆ callback_room_deletion()

void callback_room_deletion ( struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_HashCode hash 
)

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

748{
750 hash))
751 {
752 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Deletion of message failed! (%s)\n",
753 GNUNET_h2s (hash));
754 return;
755 }
756}
enum GNUNET_GenericReturnValue delete_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Deletes a message in the message store.

References delete_store_message(), get_srv_room_message_store(), GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, and GNUNET_OK.

Referenced by callback_store_operation().

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

◆ callback_room_merge()

void callback_room_merge ( struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_HashCode hash 
)

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

762{
763 if (! room->host)
764 return;
765
766 send_srv_room_message (room, room->host, create_message_merge (hash));
767}

References create_message_merge(), GNUNET_MESSENGER_SrvRoom::host, and send_srv_room_message().

Referenced by callback_store_operation().

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

775{
776 const struct GNUNET_MESSENGER_Message *message;
777 struct GNUNET_TIME_Relative forever;
778
779 GNUNET_assert ((room) && (session) && (hash));
780
782
783 if (0 == GNUNET_memcmp (&forever, &delay))
784 {
786 "Deletion is delayed forever: operation is impossible!\n");
787 return GNUNET_SYSERR;
788 }
789
790 {
791 struct GNUNET_MESSENGER_MessageStore *message_store;
792
793 message_store = get_srv_room_message_store (room);
794 message = get_store_message (message_store, hash);
795 }
796
797 if (! message)
798 return GNUNET_YES;
799
800 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_YES))
801 {
803 "Unpermitted request for deletion by member (%s) of message (%s)!\n",
805 hash));
806
807 return GNUNET_NO;
808 }
809
810 {
811 struct GNUNET_MESSENGER_OperationStore *operation_store;
812
813 operation_store = get_srv_room_operation_store (room);
814
815 if (GNUNET_OK != use_store_operation (operation_store, hash,
817 {
819 "Deletion has failed: operation denied!\n");
820 return GNUNET_SYSERR;
821 }
822 }
823
824 return GNUNET_YES;
825}
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the member id of a given member session.
enum GNUNET_GenericReturnValue check_member_session_history(const struct GNUNET_MESSENGER_MemberSession *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_INFO, 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 829 of file gnunet-service-messenger_room.c.

830{
831 GNUNET_assert (room);
832
833 return room->service->cadet;
834}
struct GNUNET_CADET_Handle * cadet

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

839{
840 GNUNET_assert (room);
841
842 return &(room->key);
843}

References GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::key.

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

849{
850 GNUNET_assert ((room) && (peer));
851
852 return GNUNET_CONTAINER_multipeermap_get (room->tunnels, peer);
853}

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_MemberSession session,
GNUNET_MESSENGER_MessageRequestCallback  callback,
void *  cls 
)
static

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

862{
863 struct GNUNET_MESSENGER_MessageStore *message_store;
864 const struct GNUNET_MESSENGER_MessageLink *link;
865 const struct GNUNET_MESSENGER_Message *message;
866
867 GNUNET_assert ((room) && (hash) && (session));
868
869 message_store = get_srv_room_message_store (room);
870 link = get_store_message_link (message_store, hash, GNUNET_YES);
871
872 if (! link)
873 goto forward;
874
876 "Requesting link of message with hash: %s\n",
877 GNUNET_h2s (hash));
878
879 {
881 result = request_room_message_step (room, &(link->first), session,
882 callback, cls);
883
884 if ((GNUNET_YES == link->multiple) &&
885 (GNUNET_YES == request_room_message_step (room, &(link->second), session,
886 callback, cls)))
887 return GNUNET_YES;
888 else
889 return result;
890 }
891
892forward:
893 message = get_store_message (message_store, hash);
894
895 if (! message)
896 {
898 "Requested message is missing in local storage: %s\n",
899 GNUNET_h2s (hash));
900 return GNUNET_NO;
901 }
902
903 if (GNUNET_YES != check_member_session_history (session, hash, GNUNET_NO))
905 "Unpermitted request for access by member (%s) of message (%s)!\n",
907 hash));
908 else if (callback)
909 callback (cls, room, message, hash);
910
911 return GNUNET_YES;
912}
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_MemberSession *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_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_sh2s(), GNUNET_YES, 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_MemberSession 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 916 of file gnunet-service-messenger_room.c.

921{
923
924 GNUNET_assert ((room) && (hash));
925
926 result = request_room_message_step (room, hash, session, callback, cls);
927
928 if ((GNUNET_NO == result) && (callback))
929 callback (cls, room, NULL, hash);
930
931 return result;
932}

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:

◆ callback_room_disconnect()

void callback_room_disconnect ( struct GNUNET_MESSENGER_SrvRoom room,
void *  cls 
)

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

938{
939 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
941
942 GNUNET_assert ((room) && (cls));
943
944 tunnel = cls;
945
946 if (! room->host)
947 return;
948
950
952 &identity,
953 tunnel)) ||
955 &identity)))
956 return;
957
960
963 return;
964
965 {
966 struct GNUNET_MESSENGER_ListTunnel *element;
967 element = find_list_tunnels_alternate (&(room->basement), &identity);
968
969 if (! element)
970 return;
971
972 GNUNET_PEER_resolve (element->peer, &identity);
973 }
974
975 enter_srv_room_at (room, room->host, &identity);
976}
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
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...
void get_tunnel_peer_identity(const struct GNUNET_MESSENGER_SrvTunnel *tunnel, struct GNUNET_PeerIdentity *peer)
Writes the peer identity of the peer connected via tunnel to this peer into the peer parameter.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multipeermap_contains(const struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key)
Check if the map contains any value under the given key (including values that are NULL).
unsigned int GNUNET_CONTAINER_multipeermap_size(const struct GNUNET_CONTAINER_MultiPeerMap *map)
Get the number of key-value pairs in the map.
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
struct GNUNET_MESSENGER_ListTunnel * find_list_tunnels_alternate(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer)
Searches linearly through the list of tunnels peer identities for matching against a specific peer id...
enum GNUNET_GenericReturnValue contains_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels, const struct GNUNET_PeerIdentity *peer)
Tests linearly if the list of tunnels peer identities contains a specific peer identity and returns G...
enum GNUNET_GenericReturnValue auto_connecting

References GNUNET_MESSENGER_Service::auto_connecting, GNUNET_MESSENGER_SrvRoom::basement, contains_list_tunnels(), create_message_miss(), enter_srv_room_at(), find_list_tunnels_alternate(), get_tunnel_peer_identity(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_contains(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multipeermap_size(), GNUNET_NO, GNUNET_PEER_resolve(), GNUNET_YES, GNUNET_MESSENGER_SrvRoom::host, identity, GNUNET_MESSENGER_ListTunnel::peer, send_srv_room_message(), GNUNET_MESSENGER_SrvRoom::service, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by callback_tunnel_disconnect().

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

◆ callback_verify_room_message()

enum GNUNET_GenericReturnValue callback_verify_room_message ( struct GNUNET_MESSENGER_SrvRoom room,
void *  cls,
struct GNUNET_MESSENGER_Message message,
struct GNUNET_HashCode hash 
)

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

984{
985 const struct GNUNET_MESSENGER_Message *previous;
986
987 GNUNET_assert ((room) && (message));
988
990 {
992 "Message error: Kind is unknown! (%d)\n", message->header.kind);
993 return GNUNET_SYSERR;
994 }
995
996 {
997 struct GNUNET_MESSENGER_MessageStore *message_store;
998
999 message_store = get_srv_room_message_store (room);
1000
1001 previous = get_store_message (
1002 message_store, &(message->header.previous));
1003 }
1004
1005 if (! previous)
1006 goto skip_time_comparison;
1007
1008 {
1010 struct GNUNET_TIME_Absolute last;
1011
1013 last = GNUNET_TIME_absolute_ntoh (previous->header.timestamp);
1014
1015 if (GNUNET_TIME_relative_get_zero_ ().rel_value_us !=
1017 {
1019 "Message warning: Timestamp does not check out!\n");
1020 }
1021 }
1022
1023skip_time_comparison:
1024 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message of kind: %s!\n",
1026
1027 return GNUNET_OK;
1028}
static uint64_t timestamp(void)
Get current timestamp.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition: time.c:133
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:739
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
Time for absolute times used by GNUnet, in microseconds.

References get_srv_room_message_store(), get_store_message(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_MESSENGER_KIND_UNKNOWN, GNUNET_MESSENGER_name_of_kind(), GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_get_zero_(), GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageHeader::timestamp, and timestamp().

Referenced by check_tunnel_message().

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

1071{
1072 struct GNUNET_MESSENGER_MemberStore *member_store;
1073 struct GNUNET_MESSENGER_Member *member;
1074 struct GNUNET_MESSENGER_ListHandles *handles;
1075 struct GNUNET_MESSENGER_ListHandle *element;
1076
1077 GNUNET_assert ((room) && (public_key) && (member_id));
1078
1079 member_store = get_srv_room_member_store (room);
1080 member = get_store_member (member_store, member_id);
1081
1082 if ((! member) || (1 >= GNUNET_CONTAINER_multihashmap_size (
1083 member->sessions)))
1084 return;
1085
1086 handles = &(room->service->handles);
1087
1088 for (element = handles->head; element; element = element->next)
1089 {
1090 const struct GNUNET_CRYPTO_PublicKey *pubkey;
1091 struct GNUNET_MESSENGER_MemberSession *session;
1092
1093 if (0 != GNUNET_memcmp (member_id, get_srv_handle_member_id (
1094 element->handle, get_srv_room_key (room))))
1095 continue;
1096
1097 pubkey = get_srv_handle_key (element->handle);
1098
1099 if (0 == GNUNET_memcmp (public_key, pubkey))
1100 continue;
1101
1102 session = get_member_session (member, pubkey);
1103
1104 if (! session)
1105 continue;
1106
1107 {
1109 start = get_member_session_start (session);
1110
1111 if (GNUNET_TIME_relative_get_zero_ ().rel_value_us !=
1113 continue;
1114 }
1115
1116 {
1117 struct GNUNET_ShortHashCode random_id;
1118 generate_free_member_id (&random_id, member_store->members);
1119
1120 notify_srv_handle_member_id (element->handle, room, &random_id, GNUNET_NO);
1121 }
1122 }
1123}
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:38
static struct GNUNET_CRYPTO_PublicKey pubkey
Public key of the zone to look in.
const struct GNUNET_CRYPTO_PublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
struct GNUNET_MESSENGER_MemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *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_MemberSession *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.
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

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_MemberSession::member, GNUNET_MESSENGER_MemberStore::members, GNUNET_MESSENGER_ListHandle::next, notify_srv_handle_member_id(), pubkey, GNUNET_MESSENGER_MemberSession::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 1127 of file gnunet-service-messenger_room.c.

1128{
1129 struct GNUNET_MESSENGER_ListTunnel *element;
1130 struct GNUNET_PeerIdentity peer;
1131 size_t count;
1132 size_t src;
1133 size_t dst;
1134
1135 GNUNET_assert (room);
1136
1137 if (GNUNET_OK != get_service_peer_identity (room->service, &peer))
1138 return;
1139
1140 count = count_of_tunnels (&(room->basement));
1141
1142 if (! find_list_tunnels (&(room->basement), &peer, &src))
1143 return;
1144
1145 if ((count > room->service->min_routers) &&
1146 (GNUNET_NO == is_srv_handle_routing (room->host, &(room->key))) &&
1148 &peer,
1150 {
1151 close_srv_room (room);
1152 return;
1153 }
1154
1155 element = room->basement.head;
1156 dst = 0;
1157
1158 while (element)
1159 {
1160 struct GNUNET_MESSENGER_SrvTunnel *tunnel;
1161
1162 GNUNET_PEER_resolve (element->peer, &peer);
1163
1165
1166 if (! tunnel)
1167 {
1168 element = remove_from_list_tunnels (&(room->basement), element);
1169 continue;
1170 }
1171
1172 if (GNUNET_YES == required_connection_between (count, src, dst))
1173 {
1174 if (GNUNET_SYSERR == connect_tunnel (tunnel))
1175 {
1176 element = remove_from_list_tunnels (&(room->basement), element);
1177 continue;
1178 }
1179 }
1180 else
1181 disconnect_tunnel (tunnel);
1182
1183 element = element->next;
1184 dst++;
1185 }
1186}
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.
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 1190 of file gnunet-service-messenger_room.c.

1191{
1192 GNUNET_assert (room);
1193
1195}

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

1200{
1201 uint32_t flags;
1202
1203 GNUNET_assert (room);
1204
1206
1207 if (GNUNET_YES == room->service->auto_routing)
1209
1210 return flags;
1211}
@ 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_PublicKey public_key,
struct GNUNET_MESSENGER_MemberSession session 
)
static

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

1351{
1353 struct GNUNET_MESSENGER_Member *member;
1354 struct GNUNET_MESSENGER_Subscription *subscribtion;
1355
1356 GNUNET_assert ((cls) && (session));
1357
1358 it = cls;
1359 member = session->member;
1360
1361 subscribtion = get_member_subscription (member, it->discourse);
1362
1363 if (! subscribtion)
1364 return GNUNET_YES;
1365
1366 if (GNUNET_TIME_absolute_cmp (subscribtion->start, <, it->start))
1367 it->start = subscribtion->start;
1368
1369 return GNUNET_YES;
1370}
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_MemberSession::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 1373 of file gnunet-service-messenger_room.c.

1375{
1377 struct GNUNET_MESSENGER_MemberStore *member_store;
1378 struct GNUNET_MESSENGER_MessageStore *message_store;
1379
1380 GNUNET_assert ((room) && (discourse));
1381
1382 it.discourse = discourse;
1384
1385 member_store = get_srv_room_member_store (room);
1386
1388
1389 message_store = get_srv_room_message_store (room);
1390
1392 discourse,
1393 it.start);
1394}
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_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *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_PublicKey public_key,
struct GNUNET_MESSENGER_MemberSession session 
)
static

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

1419{
1420 struct GNUNET_MESSENGER_MemberUpdate *update;
1421
1422 GNUNET_assert ((cls) && (session));
1423
1424 update = cls;
1425
1426 update_member_session_history (session, update->message, update->hash);
1427
1428 if (GNUNET_YES == is_member_session_completed (session))
1429 {
1431
1433 element->session = session;
1434
1435 GNUNET_CONTAINER_DLL_insert_tail (update->head, update->tail, element);
1436 }
1437
1438 return GNUNET_YES;
1439}
void update_member_session_history(struct GNUNET_MESSENGER_MemberSession *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_MemberSession *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_MemberSessionCompletion * head
struct GNUNET_MESSENGER_MemberSessionCompletion * tail

References GNUNET_assert, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_new, GNUNET_YES, GNUNET_MESSENGER_MemberUpdate::hash, GNUNET_MESSENGER_MemberUpdate::head, is_member_session_completed(), GNUNET_MESSENGER_MemberUpdate::message, GNUNET_MESSENGER_MemberSessionCompletion::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_MemberSession session 
)
static

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

1673{
1674 struct GNUNET_HashCode hash;
1675 char *session_dir;
1676 char *room_dir;
1677
1678 GNUNET_assert ((room) && (session));
1679
1681 "Remove member session from room: %s (%s)\n",
1683 GNUNET_h2s (get_srv_room_key (room)));
1684
1685 remove_member_session (session->member, session);
1686
1687 {
1688 const struct GNUNET_CRYPTO_PublicKey *public_key;
1689 public_key = get_member_session_public_key (session);
1690
1691 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
1692 }
1693
1694
1695 get_room_data_subdir (room, &room_dir);
1696
1698 &session_dir, "%s%s%c%s%c%s%c%s%c", room_dir,
1699 "members", DIR_SEPARATOR,
1701 "sessions", DIR_SEPARATOR,
1702 GNUNET_h2s (&hash), DIR_SEPARATOR
1703 );
1704
1705 GNUNET_free (room_dir);
1706
1707 GNUNET_DISK_directory_remove (session_dir);
1708 GNUNET_free (session_dir);
1709
1710 destroy_member_session (session);
1711}
void remove_member_session(struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
Removes a given member session from its member.
void destroy_member_session(struct GNUNET_MESSENGER_MemberSession *session)
Destroys a member session and frees its memory fully.
const struct GNUNET_CRYPTO_PublicKey * get_member_session_public_key(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the public key of a given member session.
static void get_room_data_subdir(struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1088
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
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define DIR_SEPARATOR
Definition: platform.h:165

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_MemberSession::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:

◆ get_room_data_subdir()

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

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

1563{
1564 GNUNET_assert ((room) && (dir));
1565
1566 GNUNET_asprintf (dir, "%s%s%c%s%c", room->service->dir, "rooms",
1569}
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:88

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 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:

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

1574{
1575 char *room_dir;
1576
1577 GNUNET_assert (room);
1578
1579 get_room_data_subdir (room, &room_dir);
1580
1581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load room from directory: %s\n",
1582 room_dir);
1583
1585 {
1586 char *peers_file;
1587 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1588
1589 load_peer_store (get_srv_room_peer_store (room), peers_file);
1590 GNUNET_free (peers_file);
1591
1595
1596 {
1597 char *basement_file;
1598 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1599
1600 load_list_tunnels (&(room->basement), basement_file);
1601 GNUNET_free (basement_file);
1602 }
1603
1604 load_message_state (&(room->state), room_dir);
1605 }
1606
1607 GNUNET_free (room_dir);
1608}
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, const char *directory)
Loads messages from a directory into a message store.
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:404
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(), 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 1612 of file gnunet-service-messenger_room.c.

1613{
1614 char *room_dir;
1615
1616 GNUNET_assert (room);
1617
1618 get_room_data_subdir (room, &room_dir);
1619
1620 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save room to directory: %s\n",
1621 room_dir);
1622
1623 if ((GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_NO)) ||
1625 {
1626 char *peers_file;
1627 GNUNET_asprintf (&peers_file, "%s%s", room_dir, "peers.list");
1628
1629 save_peer_store (get_srv_room_peer_store (room), peers_file);
1630 GNUNET_free (peers_file);
1631
1635
1636 {
1637 char *basement_file;
1638 GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1639
1640 save_list_tunnels (&(room->basement), basement_file);
1641 GNUNET_free (basement_file);
1642 }
1643
1644 save_message_state (&(room->state), room_dir);
1645 }
1646
1647 GNUNET_free (room_dir);
1648}
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, const char *directory)
Saves messages from a message store into a 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:497
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, 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 1652 of file gnunet-service-messenger_room.c.

1653{
1654 char *room_dir;
1655
1656 GNUNET_assert (room);
1657
1658 get_room_data_subdir (room, &room_dir);
1659
1660 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Remove room from directory: %s\n",
1661 room_dir);
1662
1665
1666 GNUNET_free (room_dir);
1667}

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: