GNUnet  0.11.x
Data Structures | Functions
gnunet-service-messenger_room.c File Reference

GNUnet MESSENGER service. More...

#include "gnunet-service-messenger_room.h"
#include "gnunet-service-messenger_member.h"
#include "gnunet-service-messenger_member_session.h"
#include "gnunet-service-messenger_message_kind.h"
#include "gnunet-service-messenger_message_handle.h"
#include "gnunet-service-messenger_message_send.h"
#include "gnunet-service-messenger_operation.h"
#include "gnunet-service-messenger.h"
#include "gnunet-service-messenger_service.h"
#include "gnunet-service-messenger_tunnel.h"
#include "messenger_api_util.h"
Include dependency graph for gnunet-service-messenger_room.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_MemberNotify
 
struct  GNUNET_MESSENGER_ClosureSendRoom
 
struct  GNUNET_MESSENGER_MemberSessionCompletion
 
struct  GNUNET_MESSENGER_MemberUpdate
 

Functions

static void idle_request_room_messages (void *cls)
 
struct GNUNET_MESSENGER_SrvRoomcreate_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 int iterate_destroy_tunnels (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 
static void handle_room_messages (struct GNUNET_MESSENGER_SrvRoom *room)
 
void destroy_room (struct GNUNET_MESSENGER_SrvRoom *room)
 Destroys a room and frees its memory fully. More...
 
struct GNUNET_MESSENGER_MemberStoreget_room_member_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used member store of a given room. More...
 
struct GNUNET_MESSENGER_MessageStoreget_room_message_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used message store of a given room. More...
 
struct GNUNET_MESSENGER_OperationStoreget_room_operation_store (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the used operation store of a given room. More...
 
static int 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 int join_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Member *member)
 
static void notify_about_members (struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_CONTAINER_MultiHashMap *map, int check_permission)
 
static int iterate_notify_about_members (void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
 
static int join_room_locally (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
 
int 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)
 
int open_room (struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
 Tries to open a room for a given handle. More...
 
int enter_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...
 
struct GNUNET_MQ_Envelopepack_room_message (const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode)
 Packs a message depending on the selected mode into a newly allocated envelope. More...
 
static int iterate_send_room_message (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
 
int 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, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 
int send_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_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_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_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)
 
int delete_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_room_cadet (struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the CADET handle from a rooms service. More...
 
const struct GNUNET_HashCodeget_room_key (const struct GNUNET_MESSENGER_SrvRoom *room)
 Returns the shared secret you need to access a room. More...
 
const struct GNUNET_MESSENGER_SrvTunnelget_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 int 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)
 
int request_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)
 
int callback_verify_room_message (struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
 
void solve_room_member_collisions (struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_IDENTITY_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_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...
 
static int iterate_update_member_sessions (void *cls, const struct GNUNET_IDENTITY_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_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_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...
 

Detailed Description

GNUnet MESSENGER service.

Author
Tobias Frisch

Definition in file gnunet-service-messenger_room.c.

Function Documentation

◆ idle_request_room_messages()

static void idle_request_room_messages ( void *  cls)
static

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

References get_message_state_merge_hash(), get_room_operation_store(), get_store_operation_type(), 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, GNUNET_MESSENGER_SrvRoom::state, and use_store_operation().

Referenced by create_room().

803 {
804  struct GNUNET_MESSENGER_SrvRoom *room = cls;
805 
806  room->idle = NULL;
807 
808  struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
809  const struct GNUNET_HashCode *hash = get_message_state_merge_hash(&(room->state));
810 
811  if ((hash) &&
812  (GNUNET_MESSENGER_OP_UNKNOWN == get_store_operation_type(operation_store, hash)))
814  operation_store,
815  hash,
818  );
819 
824  cls
825  );
826 }
#define GNUNET_MESSENGER_MERGE_DELAY
static void idle_request_room_messages(void *cls)
struct GNUNET_MESSENGER_MessageState state
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1199
struct GNUNET_MESSENGER_OperationStore * get_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
const struct GNUNET_HashCode * get_message_state_merge_hash(const struct GNUNET_MESSENGER_MessageState *state)
struct GNUNET_SCHEDULER_Task * idle
#define GNUNET_MESSENGER_IDLE_DELAY
A 512-bit hashcode.
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...
Run when otherwise idle.
int 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_room()

struct GNUNET_MESSENGER_SrvRoom* create_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

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

References GNUNET_MESSENGER_SrvRoom::basement, GNUNET_MESSENGER_Service::dir, get_room_member_store(), get_room_message_store(), get_room_operation_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(), GNUNET_MESSENGER_SrvRoom::key, load_room(), GNUNET_MESSENGER_SrvRoom::peer_message, GNUNET_MESSENGER_SrvRoom::port, GNUNET_MESSENGER_SrvHandle::service, GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_SrvRoom::state, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by entry_service_room(), GNUNET_MESSENGER_enter_room(), GNUNET_MESSENGER_open_room(), and open_service_room().

47 {
48  GNUNET_assert((handle) && (key));
49 
51 
52  room->service = handle->service;
53  room->host = handle;
54  room->port = NULL;
55 
56  GNUNET_memcpy(&(room->key), key, sizeof(struct GNUNET_HashCode));
57 
59 
63 
64  init_list_tunnels (&(room->basement));
65  init_message_state(&(room->state));
66 
67  room->peer_message = NULL;
68 
69  init_list_messages (&(room->handling));
70  room->idle = NULL;
71 
72  if (room->service->dir)
73  load_room (room);
74 
76 
77  return room;
78 }
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
static void idle_request_room_messages(void *cls)
struct GNUNET_MESSENGER_MessageState state
void init_message_state(struct GNUNET_MESSENGER_MessageState *state)
struct GNUNET_MESSENGER_Service * service
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CADET_Port * port
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).
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
struct GNUNET_MESSENGER_OperationStore * get_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
struct GNUNET_SCHEDULER_Task * idle
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:1223
void init_list_messages(struct GNUNET_MESSENGER_ListMessages *messages)
Initializes list of message hashes as empty list.
struct GNUNET_MESSENGER_Service * service
struct GNUNET_HashCode * peer_message
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_MESSENGER_ListMessages handling
A 512-bit hashcode.
Run when otherwise idle.
struct GNUNET_MESSENGER_SrvHandle * host
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_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Initializes list of tunnels peer identities as empty list.
struct GNUNET_MESSENGER_ListTunnels basement
void init_message_store(struct GNUNET_MESSENGER_MessageStore *store)
Initializes a message store as fully empty.
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
void load_room(struct GNUNET_MESSENGER_SrvRoom *room)
Loads the local configuration for a given room of a service which contains the last messages hash and...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_destroy_tunnels()

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

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

References destroy_tunnel(), GNUNET_YES, handle_room_messages(), GNUNET_MESSENGER_SrvTunnel::room, and value.

Referenced by destroy_room().

82 {
83  struct GNUNET_MESSENGER_SrvTunnel *tunnel = value;
84  destroy_tunnel (tunnel);
85  return GNUNET_YES;
86 }
static void destroy_tunnel(void *cls)
This tunnel is no longer used, destroy it.
static char * value
Value of the record to add/remove.
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 916 of file gnunet-service-messenger_room.c.

References get_member_session_of(), get_room_member_store(), get_room_message_store(), get_store_member_of(), get_store_message(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, handle_service_message(), GNUNET_MESSENGER_SrvRoom::handling, GNUNET_MESSENGER_ListMessage::hash, GNUNET_MESSENGER_ListMessages::head, GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_MemberNotify::session, and GNUNET_MESSENGER_ListMessages::tail.

Referenced by callback_room_handle_message(), destroy_room(), and iterate_destroy_tunnels().

917 {
918  struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
919  struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
920 
921  while (room->handling.head)
922  {
923  struct GNUNET_MESSENGER_ListMessage *element = room->handling.head;
924 
925  const struct GNUNET_MESSENGER_Message *message = get_store_message (message_store, &(element->hash));
926 
927  if (!message)
928  goto finish_handling;
929 
930  struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
931 
932  if (!member)
933  goto finish_handling;
934 
935  struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, &(element->hash));
936 
937  if (session)
938  handle_service_message (room->service, room, session, message, &(element->hash));
939 
940 finish_handling:
941  GNUNET_CONTAINER_DLL_remove(room->handling.head, room->handling.tail, element);
942  GNUNET_free(element);
943  }
944 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
struct GNUNET_MESSENGER_Service * service
struct GNUNET_MESSENGER_ListMessages handling
void handle_service_message(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_MemberSession *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...
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_MESSENGER_ListMessage * tail
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.
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...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy_room()

void destroy_room ( struct GNUNET_MESSENGER_SrvRoom room)

Destroys a room and frees its memory fully.

Parameters

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

References GNUNET_MESSENGER_SrvRoom::basement, clear_list_tunnels(), clear_member_store(), clear_message_state(), clear_message_store(), clear_operation_store(), GNUNET_MESSENGER_Service::dir, get_room_member_store(), get_room_message_store(), get_room_operation_store(), GNUNET_assert, GNUNET_CADET_close_port(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), handle_room_messages(), GNUNET_MESSENGER_SrvRoom::idle, iterate_destroy_tunnels(), GNUNET_MESSENGER_SrvRoom::peer_message, GNUNET_MESSENGER_SrvRoom::port, save_room(), GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_SrvRoom::state, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by close_handle_room(), close_service_room(), entry_service_room(), GNUNET_MESSENGER_enter_room(), GNUNET_MESSENGER_open_room(), iterate_destroy_room(), iterate_destroy_rooms(), and open_service_room().

93 {
94  GNUNET_assert(room);
95 
96  if (room->idle)
97  {
99 
100  room->idle = NULL;
101  }
102 
103  if (room->port)
105 
107 
108  handle_room_messages (room);
109 
110  if (room->service->dir)
111  save_room (room);
112 
116 
118 
119  clear_list_tunnels (&(room->basement));
120  clear_message_state(&(room->state));
121 
122  if (room->peer_message)
123  GNUNET_free(room->peer_message);
124 
125  GNUNET_free(room);
126 }
void save_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...
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_MessageState state
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_CADET_Port * port
static int iterate_destroy_tunnels(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
struct GNUNET_MESSENGER_OperationStore * get_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
struct GNUNET_SCHEDULER_Task * idle
struct GNUNET_MESSENGER_Service * service
struct GNUNET_HashCode * peer_message
void clear_list_tunnels(struct GNUNET_MESSENGER_ListTunnels *tunnels)
Clears the list of tunnels peer identities.
void clear_operation_store(struct GNUNET_MESSENGER_OperationStore *store)
Clears an operation store, stops all operations and deallocates its memory.
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)
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_MESSENGER_ListTunnels basement
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port().
Definition: cadet_api.c:808
static void handle_room_messages(struct GNUNET_MESSENGER_SrvRoom *room)
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
#define GNUNET_free(ptr)
Wrapper around free.
void clear_message_store(struct GNUNET_MESSENGER_MessageStore *store)
Clears a message store, wipes its content and deallocates its memory.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_room_member_store()

struct GNUNET_MESSENGER_MemberStore* get_room_member_store ( struct GNUNET_MESSENGER_SrvRoom room)

Returns the used member store of a given room.

Parameters

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

References GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::member_store.

Referenced by callback_found_message(), callback_room_handle_message(), check_room_peer_status(), create_room(), destroy_room(), get_handle_member_session(), handle_get_message(), handle_room_messages(), join_room_locally(), load_room(), open_room(), recv_message_info(), recv_message_request(), save_room(), and solve_room_member_collisions().

130 {
131  GNUNET_assert(room);
132 
133  return &(room->member_store);
134 }
struct GNUNET_MESSENGER_MemberStore member_store
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Here is the caller graph for this function:

◆ get_room_message_store()

struct GNUNET_MESSENGER_MessageStore* get_room_message_store ( struct GNUNET_MESSENGER_SrvRoom room)

Returns the used message store of a given room.

Parameters

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

References GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::message_store.

Referenced by callback_room_deletion(), callback_verify_room_message(), check_member_session_completion(), check_room_peer_status(), create_room(), delete_room_message(), destroy_room(), forward_about_members(), handle_room_messages(), load_room(), notify_about_members(), request_room_message_step(), save_room(), update_room_message(), and update_tunnel_last_message().

138 {
139  GNUNET_assert(room);
140 
141  return &(room->message_store);
142 }
struct GNUNET_MESSENGER_MessageStore message_store
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Here is the caller graph for this function:

◆ get_room_operation_store()

struct GNUNET_MESSENGER_OperationStore* get_room_operation_store ( struct GNUNET_MESSENGER_SrvRoom room)

Returns the used operation store of a given room.

Parameters

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

References GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::operation_store.

Referenced by callback_found_message(), create_room(), delete_room_message(), destroy_room(), idle_request_room_messages(), load_room(), save_room(), send_message_request(), update_room_message(), and update_tunnel_last_message().

146 {
147  GNUNET_assert(room);
148 
149  return &(room->operation_store);
150 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_OperationStore operation_store
Here is the caller graph for this function:

◆ send_room_info()

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

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

References create_message_info(), get_handle_ego(), GNUNET_NO, is_tunnel_connected(), and send_tunnel_message().

Referenced by callback_room_connect().

155 {
156  if ((!handle) || (!is_tunnel_connected (tunnel)))
157  return GNUNET_NO;
158 
159  return send_tunnel_message (tunnel, handle, create_message_info (get_handle_ego (handle)));
160 }
int is_tunnel_connected(const struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Returns the status of a currently bound channel of a tunnel.
struct GNUNET_MESSENGER_Message * create_message_info(const struct GNUNET_MESSENGER_Ego *ego)
Creates and allocates a new info message containing the hosts EGO public key and a newly generated un...
int 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...
const struct GNUNET_MESSENGER_Ego * get_handle_ego(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the EGO used by a given handle.
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 163 of file gnunet-service-messenger_room.c.

References bind_tunnel(), create_tunnel(), delayed_disconnect_channel(), destroy_tunnel(), disconnect_tunnel(), get_room_key(), 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, send_room_info(), and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by open_room().

164 {
165  struct GNUNET_MESSENGER_SrvRoom *room = cls;
166 
167  struct GNUNET_MESSENGER_SrvTunnel *tunnel = create_tunnel (room, source);
168 
169  if ((tunnel) &&
170  (GNUNET_OK != GNUNET_CONTAINER_multipeermap_put (room->tunnels, source, tunnel,
172  {
173  destroy_tunnel (tunnel);
174  tunnel = NULL;
175  }
176 
177  if (!tunnel)
178  {
179  delayed_disconnect_channel (channel);
180  return NULL;
181  }
182 
183  bind_tunnel(tunnel, channel);
184 
185  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "New tunnel in room (%s) established to peer: %s\n",
186  GNUNET_h2s(get_room_key(room)), GNUNET_i2s (source));
187 
188  if (GNUNET_YES == send_room_info (room, room->host, tunnel))
189  return tunnel;
190 
191  disconnect_tunnel (tunnel);
192 
193  if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (room->tunnels, source, tunnel))
194  destroy_tunnel (tunnel);
195 
196  return NULL;
197 }
void delayed_disconnect_channel(struct GNUNET_CADET_Channel *channel)
Starts an urgent task to close a CADET channel asynchronously.
int 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.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
static void destroy_tunnel(void *cls)
This tunnel is no longer used, destroy it.
static int send_room_info(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvTunnel *tunnel)
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).
struct GNUNET_MESSENGER_SrvHandle * host
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_log(kind,...)
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...
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
void disconnect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Disconnects and unbinds a channel from a tunnel.
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ join_room()

static int join_room ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_Member member 
)
static

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

References change_handle_member_id(), create_message_join(), get_handle_ego(), get_member_id(), get_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), and send_room_message().

Referenced by join_room_locally(), and open_room().

202 {
203  GNUNET_assert((room) && (handle) && (member));
204 
205  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Joining room: %s (%s)\n", GNUNET_h2s (get_room_key (room)),
206  GNUNET_sh2s (get_member_id(member)));
207 
208  if (GNUNET_OK != change_handle_member_id (handle, get_room_key(room), get_member_id(member)))
209  return GNUNET_NO;
210 
211  struct GNUNET_MESSENGER_Message *message = create_message_join (get_handle_ego (handle));
212 
213  if (!message)
214  {
215  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Your join message could not be created!\n");
216 
217  return GNUNET_NO;
218  }
219 
220  return send_room_message (room, handle, message);
221 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int send_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.
int change_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...
struct GNUNET_MESSENGER_Message * create_message_join(const struct GNUNET_MESSENGER_Ego *ego)
Creates and allocates a new join message containing the clients EGO public key.
#define GNUNET_log(kind,...)
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
const struct GNUNET_ShortHashCode * get_member_id(const struct GNUNET_MESSENGER_Member *member)
Returns the current id of a given member.
const struct GNUNET_MESSENGER_Ego * get_handle_ego(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the EGO used by a given handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify_about_members()

static void notify_about_members ( struct GNUNET_MESSENGER_MemberNotify notify,
struct GNUNET_MESSENGER_MemberSession session,
struct GNUNET_CONTAINER_MultiHashMap map,
int  check_permission 
)
static

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

References check_member_session_history(), get_room_key(), get_room_message_store(), get_store_message(), GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_MemberNotify::handle, GNUNET_MESSENGER_ListMessage::hash, GNUNET_MESSENGER_ListMessages::head, GNUNET_MESSENGER_MemberSession::messages, GNUNET_MESSENGER_ListMessage::next, notify_handle_message(), GNUNET_MESSENGER_MemberSession::prev, GNUNET_MESSENGER_MemberNotify::room, and GNUNET_MESSENGER_MemberNotify::session.

Referenced by iterate_notify_about_members().

233 {
234  if (session->prev)
235  notify_about_members (notify, session->prev, map, GNUNET_YES);
236 
237  struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(notify->room);
238  struct GNUNET_MESSENGER_ListMessage *element;
239 
240  for (element = session->messages.head; element; element = element->next)
241  {
242  if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains(map, &(element->hash)))
243  continue;
244 
245  if ((GNUNET_YES == check_permission) &&
246  (GNUNET_YES != check_member_session_history(notify->session, &(element->hash), GNUNET_NO)))
247  continue;
248 
249  if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put(map, &(element->hash), NULL,
251  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Notification of session message could be duplicated!\n");
252 
253  const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, &(element->hash));
254 
255  if (message)
256  notify_handle_message (notify->handle, get_room_key(notify->room), session, message, &(element->hash));
257  }
258 }
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_MemberSession * session
struct GNUNET_MESSENGER_ListMessage * next
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_SrvRoom * room
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
int check_member_session_history(const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash, int ownership)
Checks the history of a session for a specific message which is identified by its hash and if the own...
const struct GNUNET_MESSENGER_Message * get_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the message from a message store matching a given hash.
void notify_handle_message(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Notifies the handle that a new message was received or sent.
struct GNUNET_MESSENGER_ListMessages messages
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_log(kind,...)
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
struct GNUNET_MESSENGER_SrvHandle * handle
struct GNUNET_MESSENGER_MemberSession * prev
static void notify_about_members(struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_CONTAINER_MultiHashMap *map, int check_permission)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_notify_about_members()

static int iterate_notify_about_members ( void *  cls,
const struct GNUNET_IDENTITY_PublicKey public_key,
struct GNUNET_MESSENGER_MemberSession session 
)
static

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

References GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_NO, GNUNET_YES, is_member_session_completed(), map, notify, notify_about_members(), and GNUNET_MESSENGER_MemberNotify::session.

Referenced by join_room_locally().

263 {
265 
266  if ((notify->session == session) || (GNUNET_YES == is_member_session_completed(session)))
267  return GNUNET_YES;
268 
270 
271  notify_about_members (notify, session, map, GNUNET_NO);
272 
274  return GNUNET_YES;
275 }
struct GNUNET_MESSENGER_MemberSession * session
int is_member_session_completed(const struct GNUNET_MESSENGER_MemberSession *session)
Returns if the given member session has been completed.
Internal representation of the hash map.
static struct GNUNET_CONTAINER_MultiPeerMap * map
Handle to the map used to store old latency values for peers.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
static struct GNUNET_PEERINFO_NotifyContext * notify
Handle to the peerinfo notify service (NULL until we've connected to it).
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
static void notify_about_members(struct GNUNET_MESSENGER_MemberNotify *notify, struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_CONTAINER_MultiHashMap *map, int check_permission)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ join_room_locally()

static int join_room_locally ( struct GNUNET_MESSENGER_SrvRoom room,
struct GNUNET_MESSENGER_SrvHandle handle 
)
static

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

References add_store_member(), callback_tunnel_disconnect(), check_tunnel_message(), get_handle_ego(), get_handle_member_id(), get_member_session(), get_room_key(), get_room_member_store(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_MemberNotify::handle, handle_tunnel_message(), iterate_notify_about_members(), iterate_store_members(), join_room(), GNUNET_MESSENGER_Ego::pub, GNUNET_MESSENGER_MemberNotify::room, and GNUNET_MESSENGER_MemberNotify::session.

Referenced by enter_room_at(), and open_room().

279 {
280  const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room));
281 
282  struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
283  struct GNUNET_MESSENGER_Member *member = add_store_member(member_store, member_id);
284 
285  if (GNUNET_NO == join_room (room, handle, member))
286  return GNUNET_NO;
287 
288  const struct GNUNET_MESSENGER_Ego *ego = get_handle_ego(handle);
289  struct GNUNET_MESSENGER_MemberSession *session = get_member_session (member, &(ego->pub));
290 
291  if (!session)
292  {
293  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "A valid session is required to join a room!\n");
294  return GNUNET_NO;
295  }
296 
298 
299  notify.room = room;
300  notify.handle = handle;
301  notify.session = session;
302 
304 
305  return GNUNET_YES;
306 }
struct GNUNET_MESSENGER_MemberSession * session
static int join_room(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Member *member)
static int iterate_notify_about_members(void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
struct GNUNET_MESSENGER_MemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key)
Returns the member session of a member identified by a given public key.
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 ...
struct GNUNET_MESSENGER_SrvRoom * room
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
A 256-bit hashcode.
struct GNUNET_IDENTITY_PublicKey pub
static struct GNUNET_PEERINFO_NotifyContext * notify
Handle to the peerinfo notify service (NULL until we've connected to it).
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
#define GNUNET_log(kind,...)
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
const struct GNUNET_ShortHashCode * get_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.
const struct GNUNET_MESSENGER_Ego * get_handle_ego(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the EGO used by a given handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_tunnel_message()

int check_tunnel_message ( void *  cls,
const struct GNUNET_MessageHeader header 
)

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

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

Referenced by join_room_locally().

107 {
108  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
109 
110  if (!tunnel)
111  return GNUNET_SYSERR;
112 
113  const uint16_t length = ntohs (header->size) - sizeof(*header);
114  const char *buffer = (const char*) &header[1];
115 
116  struct GNUNET_MESSENGER_Message message;
117 
119  {
120  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Tunnel error: Message too short! (%d)\n", length);
121  return GNUNET_SYSERR;
122  }
123 
124  uint16_t padding = 0;
125 
126  if (GNUNET_YES != decode_message (&message, length, buffer, GNUNET_YES, &padding))
127  {
128  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Tunnel error: Decoding failed!\n");
129  return GNUNET_SYSERR;
130  }
131 
132  struct GNUNET_HashCode hash;
133  hash_message (&message, length - padding, buffer, &hash);
134 
135  return callback_verify_room_message (tunnel->room, cls, &message, &hash);
136 }
int decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, int include_signature, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
uint16_t get_message_kind_size(enum GNUNET_MESSENGER_MessageKind kind)
Returns the minimal size in bytes to encode a message of a specific kind.
int callback_verify_room_message(struct GNUNET_MESSENGER_SrvRoom *room, void *cls, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash)
struct GNUNET_MESSENGER_SrvRoom * room
A 512-bit hashcode.
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.
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_tunnel_message()

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

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

References callback_room_handle_message(), GNUNET_MESSENGER_SrvTunnel::channel, copy_message(), decode_message(), forward_room_message(), GNUNET_CADET_receive_done(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSENGER_KIND_INFO, 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_peer(), recv_message_request(), GNUNET_MESSENGER_SrvTunnel::room, GNUNET_MessageHeader::size, update_room_message(), and update_tunnel_last_message().

Referenced by join_room_locally().

165 {
166  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
167 
168  const uint16_t length = ntohs (header->size) - sizeof(*header);
169  const char *buffer = (const char*) &header[1];
170 
171  struct GNUNET_MESSENGER_Message message;
172  struct GNUNET_HashCode hash;
173 
174  uint16_t padding = 0;
175 
176  decode_message (&message, length, buffer, GNUNET_YES, &padding);
177  hash_message (&message, length - padding, buffer, &hash);
178 
179  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Got message of kind: %s!\n",
180  GNUNET_MESSENGER_name_of_kind(message.header.kind));
181 
182  if (!tunnel)
183  return;
184 
185  const int new_message = update_room_message (
186  tunnel->room, copy_message (&message), &hash
187  );
188 
189  if (GNUNET_YES != new_message)
190  goto receive_done;
191 
192  update_tunnel_last_message (tunnel, &hash);
193 
194  int forward_message = GNUNET_YES;
195 
196  switch (message.header.kind)
197  {
199  forward_message = recv_message_info (tunnel->room, tunnel, &message, &hash);
200  break;
202  forward_message = recv_message_peer (tunnel->room, tunnel, &message, &hash);
203  break;
205  forward_message = recv_message_request (tunnel->room, tunnel, &message, &hash);
206  break;
207  default:
208  break;
209  }
210 
211  if (GNUNET_YES == forward_message)
212  {
213  forward_room_message (tunnel->room, tunnel, &message, &hash);
214  callback_room_handle_message (tunnel->room, NULL, &message, &hash);
215  }
216 
217 receive_done:
219 }
int decode_message(struct GNUNET_MESSENGER_Message *message, uint16_t length, const char *buffer, int include_signature, uint16_t *padding)
Decodes a message from a given buffer of a maximal length in bytes.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format...
int 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...
int update_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:35
struct GNUNET_MESSENGER_SrvRoom * room
A 512-bit hashcode.
int 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...
void callback_room_handle_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
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.
struct GNUNET_CADET_Channel * channel
int 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 GNUNET_CADET_receive_done(struct GNUNET_CADET_Channel *channel)
Send an ack on the channel to confirm the processing of a message.
Definition: cadet_api.c:888
#define GNUNET_log(kind,...)
static void update_tunnel_last_message(struct GNUNET_MESSENGER_SrvTunnel *tunnel, const struct GNUNET_HashCode *hash)
void forward_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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_tunnel_disconnect()

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

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

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

Referenced by connect_tunnel(), join_room_locally(), and open_room().

90 {
91  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
92 
93  if (tunnel)
94  {
95  tunnel->channel = NULL;
96 
97  callback_room_disconnect (tunnel->room, cls);
98  }
99 }
struct GNUNET_MESSENGER_SrvRoom * room
void callback_room_disconnect(struct GNUNET_MESSENGER_SrvRoom *room, void *cls)
struct GNUNET_CADET_Channel * channel
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_room()

int open_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

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

References add_store_member(), cadet, callback_room_connect(), callback_tunnel_disconnect(), convert_messenger_key_to_port(), create_message_peer(), get_handle_member_id(), get_room_cadet(), get_room_key(), get_room_member_store(), get_store_member(), GNUNET_assert, GNUNET_CADET_close_port(), GNUNET_CADET_open_port(), 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, join_room(), join_room_locally(), key, GNUNET_MESSENGER_SrvRoom::port, send_room_message(), and GNUNET_MESSENGER_SrvRoom::service.

Referenced by open_service_room().

319 {
320  GNUNET_assert((room) && (handle));
321 
322  if (room->port)
323  return join_room_locally (room, handle);
324 
325  struct GNUNET_CADET_Handle *cadet = get_room_cadet (room);
326  const struct GNUNET_HashCode *key = get_room_key (room);
327 
329  struct GNUNET_MessageHeader, NULL),
331 
332  struct GNUNET_HashCode port;
335  handlers);
336 
337  if (room->port)
338  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Port of room (%s) was opened!\n",
339  GNUNET_h2s(get_room_key(room)));
340  else
341  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Port of room (%s) could not be opened!\n",
342  GNUNET_h2s(get_room_key(room)));
343 
344  const struct GNUNET_ShortHashCode *member_id = get_handle_member_id (handle, get_room_key(room));
345 
346  struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
347  struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, member_id);
348 
349  if (member)
350  goto exit_open_room;
351 
352  member = add_store_member(member_store, member_id);
353 
354  if ((GNUNET_NO == join_room (room, handle, member)) && (room->port))
355  {
356  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "You could not join the room, therefore it keeps closed!\n");
357 
359  room->port = NULL;
360 
361  return GNUNET_NO;
362  }
363 
364 exit_open_room:
365  return (room->port ? send_room_message (room, handle, create_message_peer (room->service)) : GNUNET_NO);
366 }
static struct GNUNET_CADET_Handle * cadet
Handle for cadet.
Opaque handle to the service.
Definition: cadet_api.c:38
static int join_room(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Member *member)
static void * callback_room_connect(void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
int send_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.
#define GNUNET_MESSAGE_TYPE_CADET_CLI
Traffic (net-cat style) used by the Command Line Interface.
struct GNUNET_CADET_Port * port
struct GNUNET_CADET_Handle * get_room_cadet(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the CADET handle from a rooms service.
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
A 256-bit hashcode.
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:970
struct GNUNET_MESSENGER_Service * service
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
A 512-bit hashcode.
Message handler for a specific message type.
struct GNUNET_HashCode key
The key used in the DHT.
void callback_tunnel_disconnect(void *cls, const struct GNUNET_CADET_Channel *channel)
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...
struct GNUNET_MESSENGER_Message * create_message_peer(const struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new peer message containing a services peer identity.
static uint16_t port
Port number.
Definition: gnunet-bcd.c:83
#define GNUNET_log(kind,...)
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
Header for all communications.
const struct GNUNET_ShortHashCode * get_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.
void GNUNET_CADET_close_port(struct GNUNET_CADET_Port *p)
Close a port opened with GNUNET_CADET_open_port().
Definition: cadet_api.c:808
struct GNUNET_MESSENGER_Member * add_store_member(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Adds a member to a store under a specific id and returns it on success.
struct GNUNET_MESSENGER_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.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
static int join_room_locally(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enter_room_at()

int enter_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

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

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, join_room_locally(), GNUNET_MESSENGER_SrvRoom::service, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by entry_service_room().

371 {
372  GNUNET_assert((room) && (handle) && (door));
373 
374  struct GNUNET_PeerIdentity peer;
375 
376  if ((GNUNET_OK == get_service_peer_identity (room->service, &peer)) &&
377  (0 == GNUNET_memcmp(&peer, door)))
378  return join_room_locally (room, handle);
379 
381 
382  if (!tunnel)
383  {
384  tunnel = create_tunnel (room, door);
385 
386  if (GNUNET_OK != GNUNET_CONTAINER_multipeermap_put (room->tunnels, door, tunnel,
388  {
389  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "You could not connect to that door!\n");
390  destroy_tunnel (tunnel);
391  return GNUNET_NO;
392  }
393  }
394 
395  if (GNUNET_SYSERR == connect_tunnel (tunnel))
396  {
397  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Connection failure during entrance!\n");
398  GNUNET_CONTAINER_multipeermap_remove (room->tunnels, door, tunnel);
399  destroy_tunnel (tunnel);
400  return GNUNET_NO;
401  }
402 
403  return join_room_locally (room, handle);
404 }
int get_service_peer_identity(const 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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int connect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Tries to connect a tunnel by creating a new CADET channel and binding it.
int 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.
static void destroy_tunnel(void *cls)
This tunnel is no longer used, destroy it.
struct GNUNET_MESSENGER_Service * service
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).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
Allow multiple values with the same key.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
The identity of the host (wraps the signing key of the peer).
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.
#define GNUNET_log(kind,...)
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
static int join_room_locally(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_room_message()

struct GNUNET_MQ_Envelope* pack_room_message ( const struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_Message message,
struct GNUNET_HashCode hash,
int  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 EGO.

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

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

References get_handle_ego(), get_handle_member_id(), get_message_state_chain_hash(), get_room_key(), GNUNET_assert, GNUNET_memcpy, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_hton(), GNUNET_MESSENGER_Message::header, pack_message(), GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_SrvRoom::state, and GNUNET_MESSENGER_MessageHeader::timestamp.

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

409 {
410  GNUNET_assert((room) && (handle) && (message) && (hash));
411 
413 
414  const struct GNUNET_ShortHashCode *id = get_handle_member_id (handle, get_room_key(room));
415 
416  GNUNET_assert(id);
417 
418  GNUNET_memcpy(&(message->header.sender_id), id, sizeof(struct GNUNET_ShortHashCode));
419  get_message_state_chain_hash (&(room->state), &(message->header.previous));
420 
421  return pack_message (message, hash, get_handle_ego (handle), mode);
422 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_MESSENGER_MessageState state
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
static enum @8 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
A 256-bit hashcode.
struct GNUNET_MQ_Envelope * pack_message(struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego, int mode)
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_P...
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:86
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
void get_message_state_chain_hash(const struct GNUNET_MESSENGER_MessageState *state, struct GNUNET_HashCode *hash)
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
const struct GNUNET_ShortHashCode * get_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_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:464
const struct GNUNET_MESSENGER_Ego * get_handle_ego(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the EGO used by a given handle.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_send_room_message()

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

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

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

Referenced by forward_room_message(), and send_room_message().

436 {
437  struct GNUNET_MESSENGER_SrvTunnel *tunnel = value;
438 
439  if ((!is_tunnel_connected (tunnel)) ||
441  return GNUNET_YES;
442 
443  struct GNUNET_MESSENGER_ClosureSendRoom *closure = cls;
444 
445  if (tunnel == closure->exclude)
446  return GNUNET_YES;
447 
448  struct GNUNET_MQ_Envelope *env = NULL;
449 
450  if (closure->packed == GNUNET_NO)
451  {
452  env = pack_room_message (closure->room, closure->handle, closure->message, closure->hash,
454 
455  if (env)
456  closure->packed = GNUNET_YES;
457  }
458  else
459  env = pack_message (closure->message, NULL, NULL, GNUNET_MESSENGER_PACK_MODE_ENVELOPE);
460 
461  if (env)
462  send_tunnel_envelope (tunnel, env, closure->hash);
463 
464  return GNUNET_YES;
465 }
struct GNUNET_MESSENGER_SrvHandle * handle
#define GNUNET_MESSENGER_VERSION
Version number of GNUnet Messenger API.
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 ...
int is_tunnel_connected(const struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Returns the status of a currently bound channel of a tunnel.
struct GNUNET_MQ_Envelope * pack_message(struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, const struct GNUNET_MESSENGER_Ego *ego, int mode)
Encodes the message to pack it into a newly allocated envelope if mode is equal to GNUNET_MESSENGER_P...
static char * value
Value of the record to add/remove.
struct GNUNET_MESSENGER_SrvRoom * room
struct GNUNET_MQ_Envelope * pack_room_message(const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode)
Packs a message depending on the selected mode into a newly allocated envelope.
struct GNUNET_MESSENGER_Message * message
#define GNUNET_MESSENGER_PACK_MODE_ENVELOPE
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_MESSENGER_SrvTunnel * exclude
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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_room_message()

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

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

References GNUNET_MESSENGER_Message::body, cancel_store_operation(), destroy_message(), get_room_key(), get_room_message_store(), get_room_operation_store(), get_store_message(), 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_MessageMerge::previous, GNUNET_MESSENGER_MessageHeader::previous, put_store_message(), GNUNET_MESSENGER_SrvRoom::state, and update_message_state().

Referenced by check_tunnel_message(), handle_tunnel_message(), iterate_send_room_message(), and send_room_message().

949 {
950  GNUNET_assert((room) && (message) && (hash));
951 
952  struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
953 
954  const int requested = (GNUNET_MESSENGER_OP_REQUEST == get_store_operation_type(operation_store, hash)?
956  );
957 
958  if (GNUNET_YES == requested)
959  cancel_store_operation(operation_store, hash);
960 
961  struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
962 
963  const struct GNUNET_MESSENGER_Message *old_message = get_store_message (message_store, hash);
964 
965  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Handle a message in room (%s).\n", GNUNET_h2s (get_room_key(room)));
966 
967  if ((old_message) || (GNUNET_OK != put_store_message (message_store, hash, message)))
968  {
969  if (old_message != message)
970  destroy_message(message);
971 
972  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Duplicate message got dropped!\n");
973  return GNUNET_NO;
974  }
975 
976  update_message_state(&(room->state), requested, message, hash);
977 
978  if ((GNUNET_YES == requested) ||
979  (GNUNET_MESSENGER_KIND_INFO == message->header.kind) ||
981  return GNUNET_YES;
982 
983  if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
984  (GNUNET_MESSENGER_OP_MERGE == get_store_operation_type(operation_store, &(message->body.merge.previous))))
985  cancel_store_operation(operation_store, &(message->body.merge.previous));
986 
987  if (GNUNET_MESSENGER_OP_MERGE == get_store_operation_type(operation_store, &(message->header.previous)))
988  cancel_store_operation(operation_store, &(message->header.previous));
989 
990  return GNUNET_YES;
991 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
void destroy_message(struct GNUNET_MESSENGER_Message *message)
Destroys a message and frees its memory fully.
struct GNUNET_MESSENGER_MessageState state
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_MESSENGER_OperationStore * get_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
struct GNUNET_HashCode previous
The hash of a second previous message.
struct GNUNET_MESSENGER_MessageBody body
Body.
struct GNUNET_MESSENGER_MessageMerge merge
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.
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...
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.
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.
#define GNUNET_log(kind,...)
void update_message_state(struct GNUNET_MESSENGER_MessageState *state, int requested, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
int 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.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the 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,
struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

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

References add_to_list_messages(), get_member_session_of(), get_room_member_store(), get_store_member_of(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, 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_NAME, GNUNET_MESSENGER_KIND_PEER, GNUNET_NO, GNUNET_YES, handle_message_delete(), handle_message_id(), handle_message_join(), handle_message_key(), handle_message_leave(), handle_message_miss(), handle_message_name(), handle_message_peer(), handle_room_messages(), GNUNET_MESSENGER_SrvRoom::handling, GNUNET_MESSENGER_MemberUpdate::hash, GNUNET_MESSENGER_ListMessages::head, GNUNET_MESSENGER_MemberUpdate::head, GNUNET_MESSENGER_Message::header, iterate_store_members(), iterate_update_member_sessions(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MemberUpdate::message, remove_room_member_session(), GNUNET_MESSENGER_MemberSessionCompletion::session, and GNUNET_MESSENGER_MemberUpdate::tail.

Referenced by check_tunnel_message(), handle_tunnel_message(), iterate_send_room_message(), and send_room_message().

1038 {
1039  struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
1040  struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
1041 
1042  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Callback for message (%s)\n", GNUNET_h2s (hash));
1043 
1044  if (!member)
1045  {
1046  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Message handling dropped: Member is missing!\n");
1047  return;
1048  }
1049 
1050  struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, hash);
1051 
1052  if (!session)
1053  {
1054  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Message handling dropped: Session is missing!\n");
1055  return;
1056  }
1057 
1058  struct GNUNET_MESSENGER_MemberUpdate update;
1059  update.message = message;
1060  update.hash = hash;
1061 
1062  update.head = NULL;
1063  update.tail = NULL;
1064 
1065  iterate_store_members(member_store, iterate_update_member_sessions, &update);
1066 
1067  while (update.head)
1068  {
1069  struct GNUNET_MESSENGER_MemberSessionCompletion *element = update.head;
1070 
1071  remove_room_member_session (room, element->session);
1072 
1073  GNUNET_CONTAINER_DLL_remove(update.head, update.tail, element);
1074  GNUNET_free (element);
1075  }
1076 
1077  const int start_handle = room->handling.head ? GNUNET_NO : GNUNET_YES;
1078 
1079  add_to_list_messages (&(room->handling), hash);
1080 
1081  switch (message->header.kind)
1082  {
1084  handle_message_join (room, session, message, hash);
1085  break;
1087  handle_message_leave (room, session, message, hash);
1088  break;
1090  handle_message_name (room, session, message, hash);
1091  break;
1093  handle_message_key (room, session, message, hash);
1094  break;
1096  handle_message_peer (room, session, message, hash);
1097  break;
1099  handle_message_id (room, session, message, hash);
1100  break;
1102  handle_message_miss (room, session, message, hash);
1103  break;
1105  handle_message_delete (room, session, message, hash);
1106  break;
1107  default:
1108  break;
1109  }
1110 
1111  if (GNUNET_YES == start_handle)
1112  handle_room_messages (room);
1113 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_MESSENGER_MessageHeader header
Header.
void handle_message_name(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent name message to rename a current member.
void handle_message_peer(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *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.
struct GNUNET_MESSENGER_ListMessage * head
struct GNUNET_MESSENGER_MemberSession * session
void handle_message_leave(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *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.
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 ...
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void handle_message_key(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *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...
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
void handle_message_miss(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *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.
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.
struct GNUNET_MESSENGER_ListMessages handling
static void remove_room_member_session(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session)
static int iterate_update_member_sessions(void *cls, const struct GNUNET_IDENTITY_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
const struct GNUNET_MESSENGER_Message * message
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.
void handle_message_id(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Handles a received or sent id message to change a members id.
#define GNUNET_log(kind,...)
static void handle_room_messages(struct GNUNET_MESSENGER_SrvRoom *room)
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...
void handle_message_delete(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *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_join(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_MemberSession *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.
#define GNUNET_free(ptr)
Wrapper around free.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_room_message()

int send_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

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

References callback_room_handle_message(), GNUNET_MESSENGER_ClosureSendRoom::exclude, get_handle_member_id(), get_room_key(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_MESSENGER_KIND_ID, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_PEER, GNUNET_MESSENGER_KIND_REQUEST, GNUNET_MESSENGER_PACK_MODE_UNKNOWN, GNUNET_NO, GNUNET_sh2s(), GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_MemberNotify::handle, GNUNET_MESSENGER_ClosureSendRoom::handle, GNUNET_MESSENGER_ClosureSendRoom::hash, GNUNET_MESSENGER_Message::header, is_message_session_bound(), iterate_send_room_message(), GNUNET_MESSENGER_MessageHeader::kind, merge_room_last_messages(), GNUNET_MESSENGER_ClosureSendRoom::message, pack_room_message(), GNUNET_MESSENGER_ClosureSendRoom::packed, GNUNET_MESSENGER_MemberNotify::room, GNUNET_MESSENGER_ClosureSendRoom::room, send_message_id(), send_message_join(), send_message_peer(), send_message_request(), GNUNET_MESSENGER_SrvRoom::tunnels, and update_room_message().

Referenced by callback_found_message(), callback_room_disconnect(), callback_room_merge(), check_room_peer_status(), close_service_room(), join_room(), merge_room_last_messages(), open_room(), send_handle_message(), and solve_room_member_collisions().

478 {
479  GNUNET_assert((room) && (handle));
480 
481  if (!message)
482  return GNUNET_NO;
483 
484  if (GNUNET_YES == is_message_session_bound(message))
485  merge_room_last_messages(room, handle);
486 
487  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Sending message from handle with member id: %s\n",
489 
490  struct GNUNET_HashCode hash;
491  struct GNUNET_MESSENGER_ClosureSendRoom closure;
492 
493  closure.room = room;
494  closure.handle = handle;
495  closure.exclude = NULL;
496  closure.message = message;
497  closure.hash = &hash;
498  closure.packed = GNUNET_NO;
499 
501 
502  if (GNUNET_NO == closure.packed)
503  pack_room_message (room, handle, message, &hash, GNUNET_MESSENGER_PACK_MODE_UNKNOWN);
504 
505  const int new_message = update_room_message (room, message, &hash);
506 
507  if (GNUNET_YES != new_message)
508  return GNUNET_SYSERR;
509 
510  switch (message->header.kind)
511  {
513  send_message_join (room, handle, message, &hash);
514  break;
516  send_message_peer (room, handle, message, &hash);
517  break;
519  send_message_id (room, handle, message, &hash);
520  break;
522  send_message_request (room, handle, message, &hash);
523  break;
524  default:
525  break;
526  }
527 
528  callback_room_handle_message (room, handle, message, &hash);
529  return GNUNET_YES;
530 }
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. ...
struct GNUNET_MESSENGER_MessageHeader header
Header.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
static int iterate_send_room_message(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
int is_message_session_bound(const struct GNUNET_MESSENGER_Message *message)
Returns if the message should be bound to a member session.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void callback_room_handle_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
#define GNUNET_MESSENGER_PACK_MODE_UNKNOWN
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. ...
struct GNUNET_MESSENGER_SrvRoom * room
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.
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 merge_room_last_messages(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Reduces all current forks inside of the message history of a room to one remaining last message by me...
struct GNUNET_MQ_Envelope * pack_room_message(const struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message, struct GNUNET_HashCode *hash, int mode)
Packs a message depending on the selected mode into a newly allocated envelope.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_MESSENGER_Message * message
A 512-bit hashcode.
int update_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_log(kind,...)
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
const struct GNUNET_ShortHashCode * get_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_CONTAINER_MultiPeerMap * tunnels
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forward_room_message()

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

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

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_MemberNotify::room, GNUNET_MESSENGER_ClosureSendRoom::room, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by handle_tunnel_message().

535 {
536  GNUNET_assert((room) && (tunnel));
537 
538  if (!message)
539  return;
540 
541  struct GNUNET_MESSENGER_ClosureSendRoom closure;
542  struct GNUNET_HashCode message_hash;
543 
544  GNUNET_memcpy(&message_hash, hash, sizeof(struct GNUNET_HashCode));
545 
546  closure.room = room;
547  closure.handle = NULL;
548  closure.exclude = tunnel;
549  closure.message = message;
550  closure.hash = &message_hash;
551  closure.packed = GNUNET_YES;
552 
554 }
static int iterate_send_room_message(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
A 512-bit hashcode.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_room_peer_status()

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

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

References create_message_peer(), forward_tunnel_message(), get_member_session_of(), get_room_member_store(), get_room_message_store(), get_store_member_of(), get_store_message(), GNUNET_free, GNUNET_YES, GNUNET_MESSENGER_SrvRoom::host, is_member_session_closed(), GNUNET_MESSENGER_SrvRoom::peer_message, send_room_message(), GNUNET_MESSENGER_SrvRoom::service, and GNUNET_MESSENGER_MemberNotify::session.

Referenced by recv_message_info(), and send_message_join().

558 {
559  if (!room->peer_message)
560  return;
561 
562  struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
563 
564  const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, room->peer_message);
565 
566  if (!message)
567  {
568  GNUNET_free(room->peer_message);
569  room->peer_message = NULL;
570  return;
571  }
572 
573  struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
574  struct GNUNET_MESSENGER_Member *member = get_store_member_of(member_store, message);
575 
576  if (!member)
577  goto resend_peer_message;
578 
579  struct GNUNET_MESSENGER_MemberSession *session = get_member_session_of(member, message, room->peer_message);
580 
581  if (GNUNET_YES == is_member_session_closed(session))
582  goto resend_peer_message;
583 
584  if (tunnel)
585  forward_tunnel_message(tunnel, message, room->peer_message);
586 
587  return;
588 
589 resend_peer_message:
590  if (room->host)
591  send_room_message (room, room->host, create_message_peer (room->service));
592 }
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
int is_member_session_closed(const struct GNUNET_MESSENGER_MemberSession *session)
Returns if the given member session has been closed.
int send_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
struct GNUNET_MESSENGER_Service * service
struct GNUNET_HashCode * peer_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_MESSENGER_SrvHandle * host
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.
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.
struct GNUNET_MESSENGER_Message * create_message_peer(const struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new peer message containing a services peer identity.
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...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ merge_room_last_messages()

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

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

References create_message_merge(), get_message_state_merge_hash(), GNUNET_assert, send_room_message(), and GNUNET_MESSENGER_SrvRoom::state.

Referenced by send_room_message().

596 {
597  GNUNET_assert(room);
598 
599  if (!handle)
600  return;
601 
602  const struct GNUNET_HashCode *hash;
603 
604 merge_next:
605  hash = get_message_state_merge_hash (&(room->state));
606 
607  if (!hash)
608  return;
609 
610  send_room_message (room, handle, create_message_merge (hash));
611  goto merge_next;
612 }
struct GNUNET_MESSENGER_MessageState state
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int send_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.
const struct GNUNET_HashCode * get_message_state_merge_hash(const struct GNUNET_MESSENGER_MessageState *state)
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...
A 512-bit hashcode.
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 615 of file gnunet-service-messenger_room.c.

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

Referenced by callback_store_operation(), and cancel_store_operation().

616 {
618  {
619  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Deletion of message failed! (%s)\n", GNUNET_h2s(hash));
620  return;
621  }
622 }
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
int delete_store_message(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Deletes a message in the message store.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_log(kind,...)
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 625 of file gnunet-service-messenger_room.c.

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

Referenced by callback_store_operation(), and cancel_store_operation().

626 {
627  if (!room->host)
628  return;
629 
630  send_room_message (room, room->host, create_message_merge (hash));
631 }
int send_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
struct GNUNET_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...
struct GNUNET_MESSENGER_SrvHandle * host
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_room_message()

int delete_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

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

References check_member_session_history(), get_member_session_id(), get_room_message_store(), get_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, and use_store_operation().

Referenced by handle_message_delete().

636 {
637  GNUNET_assert((room) && (session) && (hash));
638 
640 
641  if (0 == GNUNET_memcmp(&forever, &delay))
642  {
643  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Deletion is delayed forever: operation is impossible!\n");
644  return GNUNET_SYSERR;
645  }
646 
647  struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
648 
649  const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, hash);
650 
651  if (!message)
652  return GNUNET_YES;
653 
654  if (GNUNET_YES != check_member_session_history(session, hash, GNUNET_YES))
655  {
656  GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Unpermitted request for deletion by member (%s) of message (%s)!\n",
657  GNUNET_sh2s(get_member_session_id(session)), GNUNET_h2s(hash));
658 
659  return GNUNET_NO;
660  }
661 
662  struct GNUNET_MESSENGER_OperationStore *operation_store = get_room_operation_store(room);
663 
664  if (GNUNET_OK != use_store_operation(operation_store, hash, GNUNET_MESSENGER_OP_DELETE, delay))
665  {
666  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Deletion has failed: operation denied!\n");
667  return GNUNET_SYSERR;
668  }
669 
670  return GNUNET_YES;
671 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_MESSENGER_OperationStore * get_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_forever_(void)
Return "forever".
Definition: time.c:163
int check_member_session_history(const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash, int ownership)
Checks the history of a session for a specific message which is identified by its hash and if the own...
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.
int 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.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_log(kind,...)
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the member id of a given member session.
Time for relative time used by GNUnet, in microseconds.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_room_cadet()

struct GNUNET_CADET_Handle* get_room_cadet ( struct GNUNET_MESSENGER_SrvRoom room)

Returns the CADET handle from a rooms service.

Parameters

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

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

Referenced by connect_tunnel(), and open_room().

675 {
676  GNUNET_assert(room);
677 
678  return room->service->cadet;
679 }
struct GNUNET_CADET_Handle * cadet
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_Service * service
Here is the caller graph for this function:

◆ get_room_key()

const struct GNUNET_HashCode* get_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 682 of file gnunet-service-messenger_room.c.

References GNUNET_assert, and GNUNET_MESSENGER_SrvRoom::key.

Referenced by callback_found_message(), callback_room_connect(), connect_tunnel(), get_member_store_key(), get_room_data_subdir(), handle_message_join(), handle_message_leave(), handle_service_message(), join_room(), join_room_locally(), notify_about_members(), open_room(), pack_room_message(), send_message_id(), send_room_message(), solve_room_member_collisions(), and update_room_message().

683 {
684  GNUNET_assert(room);
685 
686  return &(room->key);
687 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Here is the caller graph for this function:

◆ get_room_tunnel()

const struct GNUNET_MESSENGER_SrvTunnel* get_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 690 of file gnunet-service-messenger_room.c.

References GNUNET_assert, GNUNET_CONTAINER_multipeermap_get(), and GNUNET_MESSENGER_SrvRoom::tunnels.

691 {
692  GNUNET_assert((room) && (peer));
693 
694  return GNUNET_CONTAINER_multipeermap_get (room->tunnels, peer);
695 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
Here is the call graph for this function:

◆ request_room_message_step()

static int 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 698 of file gnunet-service-messenger_room.c.

References check_member_session_history(), GNUNET_MESSENGER_MessageLink::first, forward, get_room_message_store(), get_store_message(), get_store_message_link(), GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_MessageLink::multiple, result, and GNUNET_MESSENGER_MessageLink::second.

Referenced by request_room_message().

701 {
702  struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
703 
705  message_store, hash, GNUNET_YES
706  );
707 
708  if (!link)
709  goto forward;
710 
711  int result = request_room_message_step(room, &(link->first), session, callback, cls);
712 
713  if ((GNUNET_YES == link->multiple) &&
714  (GNUNET_YES == request_room_message_step(room, &(link->second), session, callback, cls)))
715  return GNUNET_YES;
716  else
717  return result;
718 
719 forward:
720  if (GNUNET_YES != check_member_session_history(session, hash, GNUNET_NO))
721  return GNUNET_YES;
722 
723  const struct GNUNET_MESSENGER_Message *message = get_store_message(message_store, hash);
724 
725  if (!message)
726  return GNUNET_NO;
727 
728  if (callback)
729  callback (cls, room, message, hash);
730 
731  return GNUNET_YES;
732 }
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
static int 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)
const struct GNUNET_MESSENGER_MessageLink * get_store_message_link(struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash, int deleted_only)
Returns the message link from a message store matching a given hash.
static int result
Global testing status.
static int forward
Search direction: forward.
Definition: gnunet-abd.c:162
int check_member_session_history(const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_HashCode *hash, int ownership)
Checks the history of a session for a specific message which is identified by its hash and if the own...
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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ request_room_message()

int request_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

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

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

Referenced by handle_get_message(), and recv_message_request().

738 {
739  GNUNET_assert((room) && (hash));
740 
741  int result = request_room_message_step (room, hash, session, callback, cls);
742 
743  if ((GNUNET_NO == result) && (callback))
744  callback (cls, room, NULL, hash);
745 
746  return result;
747 }
static int 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)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int result
Global testing status.
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 750 of file gnunet-service-messenger_room.c.

References GNUNET_MESSENGER_SrvRoom::basement, contains_list_tunnels(), create_message_miss(), get_tunnel_peer_identity(), GNUNET_CONTAINER_multipeermap_contains(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_YES, GNUNET_MESSENGER_SrvRoom::host, send_room_message(), and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by bind_tunnel(), and callback_tunnel_disconnect().

751 {
752  struct GNUNET_MESSENGER_SrvTunnel *tunnel = cls;
753 
754  if (!room->host)
755  return;
756 
759 
762  return;
763 
766 }
int 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...
int 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.
int send_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
void 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...
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
struct GNUNET_MESSENGER_SrvHandle * host
struct GNUNET_MESSENGER_Message * create_message_miss(const struct GNUNET_PeerIdentity *peer)
Creates and allocates a new miss message containing the missing peer identity.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_MESSENGER_ListTunnels basement
struct GNUNET_CONTAINER_MultiPeerMap * tunnels
int 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)...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ callback_verify_room_message()

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

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

References get_room_message_store(), get_store_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, 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, and GNUNET_MESSENGER_MessageHeader::timestamp.

Referenced by callback_tunnel_disconnect(), and check_tunnel_message().

771 {
772  if (GNUNET_MESSENGER_KIND_UNKNOWN == message->header.kind)
773  {
774  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Message error: Kind is unknown! (%d)\n", message->header.kind);
775  return GNUNET_SYSERR;
776  }
777 
778  struct GNUNET_MESSENGER_MessageStore *message_store = get_room_message_store(room);
779 
780  const struct GNUNET_MESSENGER_Message *previous = get_store_message(message_store, &(message->header.previous));
781 
782  if (!previous)
783  goto skip_time_comparison;
784 
785  struct GNUNET_TIME_Absolute timestamp = GNUNET_TIME_absolute_ntoh(message->header.timestamp);
787 
788  if (GNUNET_TIME_relative_get_zero_().rel_value_us != GNUNET_TIME_absolute_get_difference(timestamp, last).rel_value_us)
789  {
790  GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Message error: Timestamp does not check out!\n");
791  return GNUNET_SYSERR;
792  }
793 
794 skip_time_comparison:
795  GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Receiving message of kind: %s!\n",
797 
798  return GNUNET_OK;
799 }
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition: time.c:542
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition: time.c:100
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:35
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_HashCode previous
The hash of the previous message from the senders perspective.
#define GNUNET_log(kind,...)
Time for absolute times used by GNUnet, in microseconds.
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:248
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ solve_room_member_collisions()

void solve_room_member_collisions ( struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_IDENTITY_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

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

References create_message_id(), generate_free_member_id(), get_handle_ego(), get_handle_member_id(), get_member_session(), get_member_session_start(), get_room_key(), get_room_member_store(), get_store_member(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_size(), GNUNET_memcmp, GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_relative_get_zero_(), GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_Service::handles, GNUNET_MESSENGER_ListHandles::head, GNUNET_MESSENGER_MemberStore::members, GNUNET_MESSENGER_ListHandle::next, GNUNET_MESSENGER_Ego::pub, send_room_message(), GNUNET_MESSENGER_SrvRoom::service, GNUNET_MESSENGER_MemberNotify::session, and GNUNET_MESSENGER_Member::sessions.

Referenced by handle_message_id(), and handle_message_join().

831 {
832  GNUNET_assert ((room) && (public_key) && (member_id));
833 
834  struct GNUNET_MESSENGER_MemberStore *member_store = get_room_member_store(room);
835  struct GNUNET_MESSENGER_Member *member = get_store_member(member_store, member_id);
836 
837  if ((!member) || (1 >= GNUNET_CONTAINER_multihashmap_size(member->sessions)))
838  return;
839 
840  struct GNUNET_MESSENGER_ListHandles *handles = &(room->service->handles);
841  struct GNUNET_MESSENGER_ListHandle* element;
842 
843  for (element = handles->head; element; element = element->next)
844  {
845  if (0 != GNUNET_memcmp(member_id, get_handle_member_id(element->handle, get_room_key(room))))
846  continue;
847 
848  if (0 == GNUNET_memcmp(public_key, &(get_handle_ego(element->handle)->pub)))
849  continue;
850 
851  struct GNUNET_MESSENGER_MemberSession *session = get_member_session(member, &(get_handle_ego(element->handle)->pub));
852 
853  if (!session)
854  continue;
855 
857 
858  if (GNUNET_TIME_relative_get_zero_().rel_value_us != GNUNET_TIME_absolute_get_difference(start, timestamp).rel_value_us)
859  continue;
860 
861  struct GNUNET_ShortHashCode random_id;
862  generate_free_member_id (&random_id, member_store->members);
863 
864  send_room_message(room, element->handle, create_message_id(&random_id));
865  }
866 }
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
struct GNUNET_MESSENGER_ListHandles handles
struct GNUNET_CONTAINER_MultiShortmap * members
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
struct GNUNET_MESSENGER_MemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_IDENTITY_PublicKey *public_key)
Returns the member session of a member identified by a given public key.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int send_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
struct GNUNET_MESSENGER_ListHandle * next
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
A 256-bit hashcode.
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_Service * service
struct GNUNET_IDENTITY_PublicKey pub
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition: time.c:100
int generate_free_member_id(struct GNUNET_ShortHashCode *id, const struct GNUNET_CONTAINER_MultiShortmap *members)
Tries to generate an unused member id and store it into the id parameter.
struct GNUNET_MESSENGER_Message * create_message_id(const struct GNUNET_ShortHashCode *unique_id)
Creates and allocates a new id message containing the unique member id to change to.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
struct GNUNET_CONTAINER_MultiHashMap * sessions
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
const struct GNUNET_ShortHashCode * get_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.
Time for absolute times used by GNUnet, in microseconds.
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:248
struct GNUNET_MESSENGER_ListHandle * head
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.
const struct GNUNET_MESSENGER_Ego * get_handle_ego(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the EGO used by a given handle.
struct GNUNET_MESSENGER_SrvHandle * handle
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rebuild_room_basement_structure()

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

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

References GNUNET_MESSENGER_SrvRoom::basement, connect_tunnel(), count_of_tunnels(), disconnect_tunnel(), find_list_tunnels(), get_service_peer_identity(), GNUNET_assert, GNUNET_CONTAINER_multipeermap_get(), GNUNET_OK, GNUNET_PEER_resolve(), GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_ListTunnels::head, GNUNET_MESSENGER_ListTunnel::next, GNUNET_MESSENGER_ListTunnel::peer, remove_from_list_tunnels(), required_connection_between(), GNUNET_MESSENGER_SrvRoom::service, and GNUNET_MESSENGER_SrvRoom::tunnels.

Referenced by handle_message_miss(), and handle_message_peer().

870 {
871  GNUNET_assert(room);
872 
873  struct GNUNET_PeerIdentity peer;
874  size_t src;
875 
876  if ((GNUNET_OK != get_service_peer_identity (room->service, &peer)) ||
877  (!find_list_tunnels (&(room->basement), &peer, &src)))
878  return;
879 
880  size_t count = count_of_tunnels (&(room->basement));
881 
882  struct GNUNET_MESSENGER_ListTunnel *element = room->basement.head;
883  struct GNUNET_MESSENGER_SrvTunnel *tunnel;
884 
885  size_t dst = 0;
886 
887  while (element)
888  {
889  GNUNET_PEER_resolve (element->peer, &peer);
890 
892 
893  if (!tunnel)
894  {
895  element = remove_from_list_tunnels (&(room->basement), element);
896  continue;
897  }
898 
899  if (GNUNET_YES == required_connection_between (count, src, dst))
900  {
901  if (GNUNET_SYSERR == connect_tunnel (tunnel))
902  {
903  element = remove_from_list_tunnels (&(room->basement), element);
904  continue;
905  }
906  }
907  else
908  disconnect_tunnel (tunnel);
909 
910  element = element->next;
911  dst++;
912  }
913 }
int get_service_peer_identity(const 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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_ListTunnel * head
int connect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Tries to connect a tunnel by creating a new CADET channel and binding it.
struct GNUNET_MESSENGER_ListTunnel * next
void GNUNET_PEER_resolve(GNUNET_PEER_Id id, struct GNUNET_PeerIdentity *pid)
Convert an interned PID to a normal peer identity.
Definition: peer.c:225
int required_connection_between(size_t count, size_t src, size_t dst)
Returns GNUNET_YES or GNUNET_NO to determine if the peers of index src and index dst should be connec...
struct GNUNET_MESSENGER_Service * service
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).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_MESSENGER_ListTunnels basement
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.
void disconnect_tunnel(struct GNUNET_MESSENGER_SrvTunnel *tunnel)
Disconnects and unbinds a channel from a tunnel.
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_CONTAINER_MultiPeerMap * tunnels
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...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iterate_update_member_sessions()

static int iterate_update_member_sessions ( void *  cls,
const struct GNUNET_IDENTITY_PublicKey public_key,
struct GNUNET_MESSENGER_MemberSession session 
)
static

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

References 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, remove_room_member_session(), GNUNET_MESSENGER_MemberNotify::session, GNUNET_MESSENGER_MemberSessionCompletion::session, GNUNET_MESSENGER_MemberUpdate::tail, and update_member_session_history().

Referenced by callback_room_handle_message().

1013 {
1014  struct GNUNET_MESSENGER_MemberUpdate *update = cls;
1015 
1016  update_member_session_history(session, update->message, update->hash);
1017 
1018  if (GNUNET_YES == is_member_session_completed(session))
1019  {
1022  );
1023 
1024  element->session = session;
1025 
1026  GNUNET_CONTAINER_DLL_insert_tail(update->head, update->tail, element);
1027  }
1028 
1029  return GNUNET_YES;
1030 }
struct GNUNET_MESSENGER_MemberSession * session
int is_member_session_completed(const struct GNUNET_MESSENGER_MemberSession *session)
Returns if the given member session has been completed.
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.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
const struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_MemberSessionCompletion * tail
struct GNUNET_MESSENGER_MemberSessionCompletion * head
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 1180 of file gnunet-service-messenger_room.c.

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

Referenced by callback_room_handle_message(), and iterate_update_member_sessions().

1181 {
1182  GNUNET_assert ((room) && (session));
1183 
1184  remove_member_session (session->member, session);
1185 
1186  const struct GNUNET_IDENTITY_PublicKey *public_key = get_member_session_public_key(session);
1187 
1188  struct GNUNET_HashCode hash;
1189  GNUNET_CRYPTO_hash(public_key, sizeof(*public_key), &hash);
1190 
1191  char *room_dir;
1192  get_room_data_subdir (room, &room_dir);
1193 
1194  char* session_dir;
1195  GNUNET_asprintf (
1196  &session_dir, "%s%s%c%s%c%s%c%s%c", room_dir,
1197  "members", DIR_SEPARATOR,
1199  "sessions", DIR_SEPARATOR,
1200  GNUNET_h2s(&hash), DIR_SEPARATOR
1201  );
1202 
1203  GNUNET_free (room_dir);
1204 
1205  GNUNET_DISK_directory_remove(session_dir);
1206  GNUNET_free (session_dir);
1207 
1208  destroy_member_session(session);
1209 }
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
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
A 512-bit hashcode.
void destroy_member_session(struct GNUNET_MESSENGER_MemberSession *session)
Destroys a member session and frees its memory fully.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define DIR_SEPARATOR
Definition: platform.h:164
void remove_member_session(struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
Removes a given member session from its member.
An identity key as per LSD0001.
const struct GNUNET_IDENTITY_PublicKey * get_member_session_public_key(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the public key from an EGO of a given member session.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
Definition: disk.c:1084
static void get_room_data_subdir(struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the member id of a given member session.
#define GNUNET_free(ptr)
Wrapper around free.
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 1116 of file gnunet-service-messenger_room.c.

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

Referenced by load_room(), remove_room_member_session(), and save_room().

1117 {
1118  GNUNET_assert((room) && (dir));
1119 
1120  GNUNET_asprintf (dir, "%s%s%c%s%c", room->service->dir, "rooms", DIR_SEPARATOR, GNUNET_h2s (get_room_key(room)), DIR_SEPARATOR);
1121 }
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_MESSENGER_Service * service
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define DIR_SEPARATOR
Definition: platform.h:164
const struct GNUNET_HashCode * get_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_room()

void load_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 1124 of file gnunet-service-messenger_room.c.

References GNUNET_MESSENGER_SrvRoom::basement, get_room_data_subdir(), get_room_member_store(), get_room_message_store(), get_room_operation_store(), GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_YES, load_list_tunnels(), load_member_store(), load_message_state(), load_message_store(), load_operation_store(), and GNUNET_MESSENGER_SrvRoom::state.

Referenced by create_room().

1125 {
1126  GNUNET_assert(room);
1127 
1128  char *room_dir;
1129  get_room_data_subdir (room, &room_dir);
1130 
1132  {
1133  load_member_store (get_room_member_store(room), room_dir);
1134  load_message_store (get_room_message_store(room), room_dir);
1136 
1137  char *basement_file;
1138  GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1139 
1140  load_list_tunnels(&(room->basement), basement_file);
1141  GNUNET_free(basement_file);
1142 
1143  char *last_messages_file;
1144  GNUNET_asprintf (&last_messages_file, "%s%s", room_dir, "last_messages.list");
1145 
1146  load_message_state(&(room->state), room_dir);
1147  }
1148 
1149  GNUNET_free(room_dir);
1150 }
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_MessageState state
void load_message_state(struct GNUNET_MESSENGER_MessageState *state, const char *path)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
struct GNUNET_MESSENGER_OperationStore * get_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
void load_message_store(struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
Loads messages from a directory into a message store.
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.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
struct GNUNET_MESSENGER_ListTunnels basement
void load_member_store(struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
Loads members from a directory into a member store.
void load_operation_store(struct GNUNET_MESSENGER_OperationStore *store, const char *directory)
Loads operations from a directory into an operation store.
static void get_room_data_subdir(struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
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
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_room()

void save_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 1153 of file gnunet-service-messenger_room.c.

References GNUNET_MESSENGER_SrvRoom::basement, get_room_data_subdir(), get_room_member_store(), get_room_message_store(), get_room_operation_store(), GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_NO, GNUNET_OK, GNUNET_YES, save_list_tunnels(), save_member_store(), save_message_state(), save_message_store(), save_operation_store(), and GNUNET_MESSENGER_SrvRoom::state.

Referenced by destroy_room().

1154 {
1155  GNUNET_assert(room);
1156 
1157  char *room_dir;
1158  get_room_data_subdir (room, &room_dir);
1159 
1160  if ((GNUNET_YES == GNUNET_DISK_directory_test (room_dir, GNUNET_NO)) ||
1161  (GNUNET_OK == GNUNET_DISK_directory_create (room_dir)))
1162  {
1163  save_member_store(get_room_member_store(room), room_dir);
1164  save_message_store (get_room_message_store(room), room_dir);
1166 
1167  char *basement_file;
1168  GNUNET_asprintf (&basement_file, "%s%s", room_dir, "basement.list");
1169 
1170  save_list_tunnels(&(room->basement), basement_file);
1171  GNUNET_free(basement_file);
1172 
1173  save_message_state(&(room->state), room_dir);
1174  }
1175 
1176  GNUNET_free(room_dir);
1177 }
struct GNUNET_MESSENGER_MessageStore * get_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_MessageState state
void save_message_store(struct GNUNET_MESSENGER_MessageStore *store, const char *directory)
Saves messages from a message store into a directory.
void save_message_state(const struct GNUNET_MESSENGER_MessageState *state, const char *path)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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.
struct GNUNET_MESSENGER_MemberStore * get_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
void save_member_store(struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
Saves members from a member store into a directory.
struct GNUNET_MESSENGER_OperationStore * get_room_operation_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used operation store of a given room.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition: disk.c:496
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
void save_operation_store(const struct GNUNET_MESSENGER_OperationStore *store, const char *directory)
Saves operations from an operation store into a directory.
struct GNUNET_MESSENGER_ListTunnels basement
static void get_room_data_subdir(struct GNUNET_MESSENGER_SrvRoom *room, char **dir)
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
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: