GNUnet 0.28.0-dev.2-27-gc87478450
 
Loading...
Searching...
No Matches
gnunet-service-messenger_handle.c File Reference
Include dependency graph for gnunet-service-messenger_handle.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_NextMemberId
 

Functions

struct GNUNET_MESSENGER_SrvHandlecreate_srv_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq)
 Creates and allocates a new handle related to a service and using a given mq (message queue).
 
static enum GNUNET_GenericReturnValue iterate_close_rooms (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static enum GNUNET_GenericReturnValue iterate_free_values (void *cls, const struct GNUNET_HashCode *key, void *value)
 
void destroy_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
 Destroys a handle and frees its memory fully.
 
void set_srv_handle_key (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_CRYPTO_BlindablePublicKey *key)
 Sets the public key of a given handle.
 
const struct GNUNET_CRYPTO_BlindablePublicKeyget_srv_handle_key (const struct GNUNET_MESSENGER_SrvHandle *handle)
 Returns the public key of a given handle.
 
void get_srv_handle_data_subdir (const struct GNUNET_MESSENGER_SrvHandle *handle, const char *name, char **dir)
 Writes the path of the directory for a given handle using a specific name to the parameter dir.
 
static enum GNUNET_GenericReturnValue create_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
 
const struct GNUNET_ShortHashCodeget_srv_handle_member_id (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
 Returns the member id of a given handle in a specific room.
 
enum GNUNET_GenericReturnValue change_srv_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_ShortHashCode *unique_id)
 Changes the member id of a given handle in a specific room to match a unique_id and returns GNUNET_OK on success.
 
enum GNUNET_GenericReturnValue open_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
 Makes a given handle a member of the room using a specific key and opens the room from the handles service.
 
enum GNUNET_GenericReturnValue entry_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
 Makes a given handle a member of the room using a specific key and enters the room through a tunnel to a peer identified by a given door (peer identity).
 
enum GNUNET_GenericReturnValue close_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
 Removes the membership of the room using a specific key and closes it if no other handle from this service is still a member of it.
 
enum GNUNET_GenericReturnValue is_srv_handle_routing (const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
 Returns whether a given handle has enabled routing for a room using a specific key by opening that room.
 
static enum GNUNET_GenericReturnValue iterate_srv_handle_sync_finished (void *cls, const struct GNUNET_HashCode *key, void *value)
 
void merge_srv_handle_room_to_sync (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room)
 Merges the latest hash from a specific room by a given handle until the message graph of the room is fully synced.
 
void sync_srv_handle_room (struct GNUNET_MESSENGER_SrvHandle *handle, uint16_t response_type, const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *previous, const struct GNUNET_HashCode *epoch, const struct GNUNET_PeerIdentity *door)
 Starts merging message hashes until the state from a room of a given handle using a specific key is fully synced to then send a response using a specified response_type to the handles client with the latest known hash and epoch of a message in that room.
 
enum GNUNET_GenericReturnValue send_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_MESSENGER_Message *message)
 Sends a message from a given handle to the room using a specific key.
 
static const struct GNUNET_HashCodeget_next_member_session_context (const struct GNUNET_MESSENGER_SrvMemberSession *session)
 
static const struct GNUNET_MESSENGER_SrvMemberSessionget_handle_member_session (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *key)
 
void notify_srv_handle_message (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch, enum GNUNET_GenericReturnValue recent)
 Notifies the handle that a new message was received or sent.
 
static enum GNUNET_GenericReturnValue iterate_next_member_ids (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static void task_notify_srv_handle_member_id (void *cls)
 
void notify_srv_handle_member_id (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_ShortHashCode *member_id, enum GNUNET_GenericReturnValue reset)
 Notifies the handle that a new member id needs to be used.
 

Function Documentation

◆ create_srv_handle()

struct GNUNET_MESSENGER_SrvHandle * create_srv_handle ( struct GNUNET_MESSENGER_Service service,
struct GNUNET_MQ_Handle mq 
)

Creates and allocates a new handle related to a service and using a given mq (message queue).

Parameters
[in,out]serviceMESSENGER Service
[in,out]mqMessage queue
Returns
New handle

Definition at line 45 of file gnunet-service-messenger_handle.c.

47{
49
50 GNUNET_assert ((service) && (mq));
51
53
54 handle->service = service;
55 handle->mq = mq;
56
61
62 handle->notify = NULL;
63
64 return handle;
65}
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition vpn_api.c:44

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_new, GNUNET_NO, handle, mq, GNUNET_VPN_Handle::mq, and service.

Referenced by add_service_handle().

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

◆ iterate_close_rooms()

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

Definition at line 69 of file gnunet-service-messenger_handle.c.

72{
74
75 GNUNET_assert ((cls) && (key));
76
77 handle = cls;
78
80 return GNUNET_YES;
81}
struct GNUNET_HashCode key
The key used in the DHT.
enum GNUNET_GenericReturnValue close_service_room(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, enum GNUNET_GenericReturnValue deletion)
Tries to close a room using a given key for a service by a specific handle.
@ GNUNET_YES

References close_service_room(), GNUNET_assert, GNUNET_NO, GNUNET_YES, handle, and key.

Referenced by destroy_srv_handle().

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

◆ iterate_free_values()

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

Definition at line 85 of file gnunet-service-messenger_handle.c.

88{
90
92 return GNUNET_YES;
93}
static char * value
Value of the record to add/remove.
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_assert, GNUNET_free, GNUNET_YES, and value.

Referenced by close_srv_handle_room(), and destroy_srv_handle().

Here is the caller graph for this function:

◆ destroy_srv_handle()

void destroy_srv_handle ( struct GNUNET_MESSENGER_SrvHandle handle)

Destroys a handle and frees its memory fully.

Parameters
[in,out]handleHandle

Definition at line 97 of file gnunet-service-messenger_handle.c.

98{
100
103
104 if (handle->notify)
106
108 iterate_free_values, NULL);
110 iterate_free_values, NULL);
112 iterate_free_values, NULL);
113
118
120}
static enum GNUNET_GenericReturnValue iterate_free_values(void *cls, const struct GNUNET_HashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_close_rooms(void *cls, const struct GNUNET_HashCode *key, void *value)
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), handle, iterate_close_rooms(), and iterate_free_values().

Referenced by clear_list_handles(), and remove_service_handle().

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

◆ set_srv_handle_key()

void set_srv_handle_key ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_CRYPTO_BlindablePublicKey key 
)

Sets the public key of a given handle.

Parameters
[out]handleHandle
[in]keyPublic key

Definition at line 124 of file gnunet-service-messenger_handle.c.

126{
128
129 if ((handle->key) && (! key))
130 {
131 GNUNET_free (handle->key);
132 handle->key = NULL;
133 }
134 else if (! handle->key)
136
137 if (key)
138 memcpy (handle->key, key, sizeof(struct GNUNET_CRYPTO_BlindablePublicKey));
139}
An identity key as per LSD0001.

References GNUNET_assert, GNUNET_free, GNUNET_new, handle, and key.

Referenced by initialize_handle_via_key(), send_message_join(), and send_message_key().

Here is the caller graph for this function:

◆ get_srv_handle_key()

const struct GNUNET_CRYPTO_BlindablePublicKey * get_srv_handle_key ( const struct GNUNET_MESSENGER_SrvHandle handle)

Returns the public key of a given handle.

Parameters
[in]handleHandle
Returns
Public key of handle

Definition at line 143 of file gnunet-service-messenger_handle.c.

144{
146
147 return handle->key;
148}

References GNUNET_assert, and handle.

Referenced by find_member_session_in_room(), get_handle_member_session(), handle_get_message(), initialize_service_handle(), and solve_srv_room_member_collisions().

Here is the caller graph for this function:

◆ get_srv_handle_data_subdir()

void get_srv_handle_data_subdir ( const struct GNUNET_MESSENGER_SrvHandle handle,
const char *  name,
char **  dir 
)

Writes the path of the directory for a given handle using a specific name to the parameter dir.

This directory will be used to store data regarding the handle and its messages.

Parameters
[in]handleHandle
[in]namePotential name of the handle
[out]dirPath to store data

Definition at line 152 of file gnunet-service-messenger_handle.c.

155{
156 GNUNET_assert ((handle) && (dir));
157
158 if (name)
159 GNUNET_asprintf (dir, "%s%s%c%s%c", handle->service->dir, "identities",
161 else
162 GNUNET_asprintf (dir, "%s%s%c", handle->service->dir, "anonymous",
164}
static char * dir
Set to the directory where runtime files are stored.
Definition gnunet-arm.c:88
static char * name
Name (label) of the records to list.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define DIR_SEPARATOR
Definition platform.h:166

References dir, DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, handle, and name.

Here is the call graph for this function:

◆ create_handle_member_id()

static enum GNUNET_GenericReturnValue create_handle_member_id ( const struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key 
)
static

Definition at line 168 of file gnunet-service-messenger_handle.c.

170{
171 struct GNUNET_ShortHashCode *random_id;
172
173 GNUNET_assert ((handle) && (key));
174
175 random_id = GNUNET_new (struct GNUNET_ShortHashCode);
176
177 if (! random_id)
178 return GNUNET_NO;
179
180 generate_free_member_id (random_id, NULL);
181
183 random_id,
185 {
186 GNUNET_free (random_id);
187 return GNUNET_NO;
188 }
189
191 "Created a new member id (%s) for room: %s\n", GNUNET_sh2s (
192 random_id),
193 GNUNET_h2s (key));
194
195 return GNUNET_YES;
196}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#define GNUNET_log(kind,...)
@ GNUNET_OK
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
enum GNUNET_GenericReturnValue generate_free_member_id(struct GNUNET_ShortHashCode *id, const struct GNUNET_CONTAINER_MultiShortmap *members)
Tries to generate an unused member id and store it into the id parameter.
A 256-bit hashcode.

References generate_free_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, handle, and key.

Referenced by entry_srv_handle_room(), and open_srv_handle_room().

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

◆ get_srv_handle_member_id()

const struct GNUNET_ShortHashCode * get_srv_handle_member_id ( const struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key 
)

Returns the member id of a given handle in a specific room.

If the handle is not a member of the specific room, NULL gets returned.

Parameters
[in]handleHandle
[in]keyKey of a room
Returns
Member id or NULL

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

202{
203 GNUNET_assert ((handle) && (key));
204
205 return GNUNET_CONTAINER_multihashmap_get (handle->member_ids, key);
206}
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), handle, and key.

Referenced by close_srv_handle_room(), entry_srv_handle_room(), find_list_handle_by_member(), get_handle_member_session(), handle_get_message(), handle_service_message(), iterate_srv_handle_sync_finished(), join_room_locally(), notify_srv_handle_message(), open_srv_handle_room(), open_srv_room(), send_srv_handle_message(), solve_srv_room_member_collisions(), and sync_srv_handle_room().

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

◆ change_srv_handle_member_id()

enum GNUNET_GenericReturnValue change_srv_handle_member_id ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key,
const struct GNUNET_ShortHashCode unique_id 
)

Changes the member id of a given handle in a specific room to match a unique_id and returns GNUNET_OK on success.

The client connected to the handle will be informed afterwards automatically.

Parameters
[in,out]handleHandle
[in]keyKey of a room
[in]unique_idUnique member id
Returns
GNUNET_OK on success, otherwise GNUNET_SYSERR

Definition at line 210 of file gnunet-service-messenger_handle.c.

213{
214 struct GNUNET_ShortHashCode *member_id;
215
216 GNUNET_assert ((handle) && (key) && (unique_id));
217
218 member_id = GNUNET_CONTAINER_multihashmap_get (handle->member_ids, key);
219
220 if (! member_id)
221 {
222 member_id = GNUNET_new (struct GNUNET_ShortHashCode);
223 GNUNET_memcpy (member_id, unique_id, sizeof(*member_id));
224
226 member_id,
228 {
229 GNUNET_free (member_id);
230 return GNUNET_SYSERR;
231 }
232 }
233
234 if (0 == GNUNET_memcmp (unique_id, member_id))
235 return GNUNET_OK;
236
238 "Change a member id (%s) for room (%s).\n", GNUNET_sh2s (
239 member_id),
240 GNUNET_h2s (key));
241
242 GNUNET_memcpy (member_id, unique_id, sizeof(*unique_id));
243
244 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Member id changed to (%s).\n",
245 GNUNET_sh2s (unique_id));
246 return GNUNET_OK;
247}
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_SYSERR

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_sh2s(), GNUNET_SYSERR, handle, and key.

Referenced by find_member_session_in_room(), join_room(), and send_message_id().

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

◆ open_srv_handle_room()

enum GNUNET_GenericReturnValue open_srv_handle_room ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key 
)

Makes a given handle a member of the room using a specific key and opens the room from the handles service.

Parameters
[in,out]handleHandle
[in]keyKey of a room
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 251 of file gnunet-service-messenger_handle.c.

253{
254 GNUNET_assert ((handle) && (key));
255
257 handle->routing, key, NULL,
259 return GNUNET_NO;
260
263 key)))
264 return GNUNET_NO;
265
266 return open_service_room (handle->service, handle, key);
267}
const struct GNUNET_ShortHashCode * get_srv_handle_member_id(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns the member id of a given handle in a specific room.
static enum GNUNET_GenericReturnValue create_handle_member_id(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
enum GNUNET_GenericReturnValue open_service_room(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Tries to open a room using a given key for a service by a specific handle.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.

References create_handle_member_id(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle, key, and open_service_room().

Referenced by handle_room_open().

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

◆ entry_srv_handle_room()

enum GNUNET_GenericReturnValue entry_srv_handle_room ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_PeerIdentity door,
const struct GNUNET_HashCode key 
)

Makes a given handle a member of the room using a specific key and enters the room through a tunnel to a peer identified by a given door (peer identity).

Parameters
[in,out]handleHandle
[in]doorPeer identity
[in]keyKey of a room
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 271 of file gnunet-service-messenger_handle.c.

274{
275 GNUNET_assert ((handle) && (door) && (key));
276
279 return GNUNET_NO;
280
281 return entry_service_room (handle->service, handle, door, key);
282}
enum GNUNET_GenericReturnValue entry_service_room(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door, const struct GNUNET_HashCode *key)
Tries to enter a room using a given key for a service by a specific handle.

References create_handle_member_id(), entry_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_NO, GNUNET_YES, handle, and key.

Referenced by handle_room_entry().

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

◆ close_srv_handle_room()

enum GNUNET_GenericReturnValue close_srv_handle_room ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key 
)

Removes the membership of the room using a specific key and closes it if no other handle from this service is still a member of it.

Parameters
[in,out]handleHandle
[in]keyKey of a room
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 286 of file gnunet-service-messenger_handle.c.

288{
289 GNUNET_assert ((handle) && (key));
290
292 iterate_free_values, NULL);
294
295 if ((handle->notify) && (0 == GNUNET_CONTAINER_multihashmap_size (
296 handle->next_ids)))
297 {
299 handle->notify = NULL;
300 }
301
303 return GNUNET_NO;
304
305 {
308
309 if (GNUNET_YES != result)
310 return result;
311
313 return result;
314 }
315}
static int result
Global testing status.
int GNUNET_CONTAINER_multihashmap_remove_all(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Remove all entries for the given key from the map.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map that match a particular key.
GNUNET_GenericReturnValue
Named constants for return values.

References close_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_YES, handle, iterate_free_values(), key, and result.

Referenced by handle_room_close().

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

◆ is_srv_handle_routing()

enum GNUNET_GenericReturnValue is_srv_handle_routing ( const struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key 
)

Returns whether a given handle has enabled routing for a room using a specific key by opening that room.

Parameters
[in]handleHandle
[in]keyKey of a room
Returns
GNUNET_YES is routing is enabled, otherwise GNUNET_NO

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

321{
322 GNUNET_assert ((handle) && (key));
323
325}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), handle, and key.

Referenced by find_list_handle_by_member(), and rebuild_srv_room_basement_structure().

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

◆ iterate_srv_handle_sync_finished()

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

Definition at line 329 of file gnunet-service-messenger_handle.c.

332{
335 struct GNUNET_MESSENGER_SrvRoom *room;
336 const struct GNUNET_ShortHashCode *member_id;
337 struct GNUNET_MESSENGER_MessageStore *store;
338
339 GNUNET_assert ((cls) && (key) && (value));
340
341 handle = cls;
342 sync = value;
343
344 room = get_service_room (handle->service, key);
345 member_id = get_srv_handle_member_id (handle, key);
346
347 if ((! room) || (! member_id))
348 goto sync_epoch;
349
350 get_message_state_chain_hash (&(room->state), &(sync->hash));
351
352sync_epoch:
353 if (! room)
354 {
355 GNUNET_memcpy (&(sync->epoch), &(sync->hash),
356 sizeof(sync->epoch));
357 goto send_response;
358 }
359
360 store = get_srv_room_message_store (room);
361
362 if (! store)
363 goto send_response;
364
365 GNUNET_memcpy (&(sync->epoch),
366 get_store_message_epoch (store, &(sync->hash)),
367 sizeof(sync->epoch));
368
370 {
372 struct GNUNET_MQ_Envelope *envelope;
373
374 switch (sync->response_type)
375 {
377 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Opening room with member id: %s\n",
378 GNUNET_sh2s (member_id));
379 break;
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Entering room with member id: %s\n",
382 GNUNET_sh2s (member_id));
383 break;
385 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Closing room succeeded: %s\n",
386 GNUNET_h2s (key));
387 break;
389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Synced room: %s\n",
390 GNUNET_h2s (key));
391 break;
392 default:
393 break;
394 }
395
396 envelope = GNUNET_MQ_msg (response, sync->response_type);
397
398 GNUNET_memcpy (&(response->door), &(sync->door), sizeof(response->door));
399 GNUNET_memcpy (&(response->key), key, sizeof(response->key));
400 GNUNET_memcpy (&(response->previous), &(sync->hash), sizeof(response->
401 previous));
402 GNUNET_memcpy (&(response->epoch), &(sync->epoch), sizeof(response->epoch));
403
404 GNUNET_MQ_send (handle->mq, envelope);
405 }
406
407 GNUNET_free (sync);
408 return GNUNET_YES;
409}
static struct MHD_Response * response
Our canonical response.
static void send_response(struct Request *request)
Send the response for the given request and clean up.
void get_message_state_chain_hash(const struct GNUNET_MESSENGER_MessageState *state, struct GNUNET_HashCode *hash)
const struct GNUNET_HashCode * get_store_message_epoch(const struct GNUNET_MESSENGER_MessageStore *store, const struct GNUNET_HashCode *hash)
Returns the epoch hash of a message from a message store matching a given hash.
struct GNUNET_MESSENGER_MessageStore * get_srv_room_message_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used message store of a given room.
struct GNUNET_MESSENGER_SrvRoom * get_service_room(const struct GNUNET_MESSENGER_Service *service, const struct GNUNET_HashCode *key)
Returns the room identified by a given key for a service.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition mq.c:305
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY
General message to confirm interaction with a room.
struct GNUNET_MESSENGER_MessageState state

References GNUNET_MESSENGER_SrvHandleSync::door, GNUNET_MESSENGER_SrvHandleSync::epoch, get_message_state_chain_hash(), get_service_room(), get_srv_handle_member_id(), get_srv_room_message_store(), get_store_message_epoch(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_CLOSE, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_ENTRY, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_OPEN, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_SYNC, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_sh2s(), GNUNET_YES, handle, GNUNET_MESSENGER_SrvHandleSync::hash, key, GNUNET_VPN_Handle::mq, response, GNUNET_MESSENGER_SrvHandleSync::response_type, send_response(), GNUNET_MESSENGER_SrvRoom::state, and value.

Referenced by merge_srv_handle_room_to_sync(), and sync_srv_handle_room().

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

◆ merge_srv_handle_room_to_sync()

void merge_srv_handle_room_to_sync ( struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_SrvRoom room 
)

Merges the latest hash from a specific room by a given handle until the message graph of the room is fully synced.

The function will be called automatically in case the given handle is actively syncing.

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

Definition at line 413 of file gnunet-service-messenger_handle.c.

415{
417
418 GNUNET_assert ((handle) && (room));
419
421 syncing,
422 &(room->
423 key)));
424
426
427 if (GNUNET_NO == result)
428 {
430 "Finish syncing room: %s\n",
431 GNUNET_h2s (&(room->key)));
432
434 &(room->key),
435 &
437 handle);
439 room->sync = NULL;
440 }
441 else if (GNUNET_YES != result)
442 {
444 "Merging messages failed while syncing: %s\n",
445 GNUNET_h2s (&(room->key)));
446 room->sync = NULL;
447 }
448 else if (NULL == room->sync)
449 room->sync = handle;
450}
static enum GNUNET_GenericReturnValue iterate_srv_handle_sync_finished(void *cls, const struct GNUNET_HashCode *key, void *value)
enum GNUNET_GenericReturnValue merge_srv_room_last_messages(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Reduces all current forks inside of the message history of a room to one remaining last message by me...
@ GNUNET_ERROR_TYPE_ERROR
struct GNUNET_MESSENGER_SrvHandle * sync

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_get_multiple(), GNUNET_CONTAINER_multihashmap_remove_all(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, handle, iterate_srv_handle_sync_finished(), key, GNUNET_MESSENGER_SrvRoom::key, merge_srv_room_last_messages(), result, and GNUNET_MESSENGER_SrvRoom::sync.

Referenced by callback_srv_room_message_signed(), notify_srv_handle_message(), and sync_srv_handle_room().

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

◆ sync_srv_handle_room()

void sync_srv_handle_room ( struct GNUNET_MESSENGER_SrvHandle handle,
uint16_t  response_type,
const struct GNUNET_HashCode key,
const struct GNUNET_HashCode hash,
const struct GNUNET_HashCode epoch,
const struct GNUNET_PeerIdentity door 
)

Starts merging message hashes until the state from a room of a given handle using a specific key is fully synced to then send a response using a specified response_type to the handles client with the latest known hash and epoch of a message in that room.

If the room does not contain other messages being accessible to the handle and older than the provided hash, the function returns the originally provided hash as fallback. Similar goes for the provided epoch and door identifier.

Parameters
[in,out]handleHandle
[in]response_typeType of response
[in]keyKey of a room
[in]prevKnown hash of a message
[in]epochKnown epoch in a room
[in]doorKnown door identity or NULL

Definition at line 454 of file gnunet-service-messenger_handle.c.

460{
461 struct GNUNET_MESSENGER_SrvRoom *room;
463
464 GNUNET_assert ((handle) && (key) && (previous));
465
466 room = get_service_room (handle->service, key);
467
469 "%s syncing room: %s\n",
470 (room) && (room->sync)? "Continue" : "Start",
471 GNUNET_h2s (key));
472
474
475 GNUNET_assert (sync);
477
478 if (door)
479 GNUNET_memcpy (&(sync->door), door, sizeof(sync->door));
480 else if (GNUNET_OK != get_service_peer_identity (handle->service, &(sync->door
481 )))
482 memset (&(sync->door), 0, sizeof(sync->door));
483
484 GNUNET_memcpy (&(sync->hash), previous, sizeof(sync->hash));
485 GNUNET_memcpy (&(sync->epoch), epoch, sizeof(sync->epoch));
486
487 if ((! room) || (! get_srv_handle_member_id (handle, key)) ||
488 (NULL == get_message_state_merge_hash (&(room->state))))
489 {
491 "Finish syncing room quickly: %s\n",
492 GNUNET_h2s (key));
493
495 return;
496 }
497
499 key, sync,
501 {
503 "Could not wait for syncing room: %s\n",
504 GNUNET_h2s (key));
505 GNUNET_free (sync);
506 }
507
508 if (NULL != room->sync)
510 "Wait for syncing: %s\n",
511 GNUNET_h2s (&(room->key)));
512 else
514}
void merge_srv_handle_room_to_sync(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room)
Merges the latest hash from a specific room by a given handle until the message graph of the room is ...
const struct GNUNET_HashCode * get_message_state_merge_hash(const struct GNUNET_MESSENGER_MessageState *state)
enum GNUNET_GenericReturnValue get_service_peer_identity(struct GNUNET_MESSENGER_Service *service, struct GNUNET_PeerIdentity *peer)
Tries to write the peer identity of the peer running a service on to the peer parameter.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.

References GNUNET_MESSENGER_SrvHandleSync::door, GNUNET_MESSENGER_SrvHandleSync::epoch, get_message_state_merge_hash(), get_service_peer_identity(), get_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_OK, handle, GNUNET_MESSENGER_SrvHandleSync::hash, iterate_srv_handle_sync_finished(), key, GNUNET_MESSENGER_SrvRoom::key, merge_srv_handle_room_to_sync(), GNUNET_MESSENGER_SrvHandleSync::response_type, GNUNET_MESSENGER_SrvRoom::state, and GNUNET_MESSENGER_SrvRoom::sync.

Referenced by handle_room_close(), handle_room_entry(), handle_room_open(), and handle_room_sync().

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

◆ send_srv_handle_message()

enum GNUNET_GenericReturnValue send_srv_handle_message ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key,
const struct GNUNET_MESSENGER_Message message 
)

Sends a message from a given handle to the room using a specific key.

Parameters
[in,out]handleHandle
[in]keyKey of a room
[in]messageMessage
Returns
GNUNET_YES on success, GNUNET_NO or GNUNET_SYSERR otherwise.

Definition at line 518 of file gnunet-service-messenger_handle.c.

521{
522 const struct GNUNET_ShortHashCode *id;
523 struct GNUNET_MESSENGER_SrvRoom *room;
524
525 GNUNET_assert ((handle) && (key) && (message));
526
528
529 if (! id)
530 {
532 "It is required to be a member of a room to send messages!\n");
533 return GNUNET_NO;
534 }
535
536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message with member id: %s\n",
537 GNUNET_sh2s (id));
538
539 if (0 != GNUNET_memcmp (id, &(message->header.sender_id)))
540 {
542 "Member id does not match with handle!\n");
543 return GNUNET_NO;
544 }
545
546 room = get_service_room (handle->service, key);
547
548 if (! room)
549 {
550 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "The room (%s) is unknown!\n",
551 GNUNET_h2s (key));
552 return GNUNET_NO;
553 }
554
555 {
557 msg = copy_message (message);
558
559 if (! msg)
560 {
561 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Copying message failed!\n");
562 return GNUNET_NO;
563 }
564
565 return send_srv_room_message (room, handle, msg);
566 }
567}
struct GNUNET_MessageHeader * msg
Definition 005.c:2
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
enum GNUNET_GenericReturnValue send_srv_room_message(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_Message *message)
Sends a message from a given handle into a room.
@ GNUNET_ERROR_TYPE_WARNING
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_MESSENGER_MessageHeader header
Header.

References copy_message(), get_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_sh2s(), handle, GNUNET_MESSENGER_Message::header, id, key, msg, send_srv_room_message(), and GNUNET_MESSENGER_MessageHeader::sender_id.

Referenced by handle_send_message().

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

◆ get_next_member_session_context()

static const struct GNUNET_HashCode * get_next_member_session_context ( const struct GNUNET_MESSENGER_SrvMemberSession session)
static

Definition at line 571 of file gnunet-service-messenger_handle.c.

573{
574 GNUNET_assert (session);
575
576 if (session->next)
577 return get_next_member_session_context (session->next);
578 else
579 return get_member_session_context (session);
580}
static const struct GNUNET_HashCode * get_next_member_session_context(const struct GNUNET_MESSENGER_SrvMemberSession *session)
const struct GNUNET_HashCode * get_member_session_context(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the member context of a given member session.
struct GNUNET_MESSENGER_SrvMemberSession * next

References get_member_session_context(), get_next_member_session_context(), GNUNET_assert, and GNUNET_MESSENGER_SrvMemberSession::next.

Referenced by get_next_member_session_context(), and notify_srv_handle_message().

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

◆ get_handle_member_session()

static const struct GNUNET_MESSENGER_SrvMemberSession * get_handle_member_session ( struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_HashCode key 
)
static

Definition at line 584 of file gnunet-service-messenger_handle.c.

587{
588 const struct GNUNET_ShortHashCode *id;
590
591 GNUNET_assert ((handle) && (room) && (key) && (handle->service));
592
594
595 if (! id)
596 {
598 "Handle is missing a member id for its member session! (%s)\n",
599 GNUNET_h2s (key));
600 return NULL;
601 }
602
604
605 if (! pubkey)
606 {
608 "Handle is missing a public key for its member session! (%s)\n",
609 GNUNET_h2s (key));
610 return NULL;
611 }
612
613 {
614 struct GNUNET_MESSENGER_MemberStore *store;
615 struct GNUNET_MESSENGER_Member *member;
616
618 member = get_store_member (store, id);
619
620 return get_member_session (member, pubkey);
621 }
622}
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
struct GNUNET_MESSENGER_SrvMemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key)
Returns the member session of a member identified by a given public key.
struct GNUNET_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.
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
struct GNUNET_MESSENGER_MemberStore * store

References get_member_session(), get_srv_handle_key(), get_srv_handle_member_id(), get_srv_room_member_store(), get_store_member(), GNUNET_assert, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, handle, id, key, pubkey, and GNUNET_MESSENGER_Member::store.

Referenced by notify_srv_handle_message().

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

◆ notify_srv_handle_message()

void notify_srv_handle_message ( struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_MESSENGER_SenderSession session,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash,
const struct GNUNET_HashCode epoch,
enum GNUNET_GenericReturnValue  recent 
)

Notifies the handle that a new message was received or sent.

Parameters
[in,out]handleHandle
[in]roomRoom of the message
[in]sessionSender session
[in]messageMessage
[in]hashHash of message
[in]epochHash of epoch
[in]recentWhether the message was recently received

Definition at line 626 of file gnunet-service-messenger_handle.c.

633{
634 const struct GNUNET_HashCode *key;
635 const struct GNUNET_ShortHashCode *id;
636 const struct GNUNET_HashCode *context;
638 const struct GNUNET_ShortHashCode *discourse;
639 struct GNUNET_MESSENGER_Subscription *subscription;
640 struct GNUNET_HashCode sender;
641
642 GNUNET_assert ((handle) && (room) && (session) && (message) && (hash) && (
643 epoch));
644
645 key = get_srv_room_key (room);
647
648 if (! handle->mq)
649 {
651 "Notifying client is missing a message queue!\n");
652 return;
653 }
654
655 if ((GNUNET_MESSENGER_KIND_MERGE == message->header.kind) &&
657 key)) &&
658 (NULL == get_message_state_merge_hash (&(room->state))))
660
661 if (! id)
662 {
664 "Notifying client about message requires membership!\n");
665 return;
666 }
667
668 context = NULL;
669
670 if (GNUNET_MESSENGER_KIND_TALK != message->header.kind)
671 goto skip_message_filter;
672
674 discourse = &(message->body.talk.discourse);
675
676 {
677 struct GNUNET_MESSENGER_MemberStore *member_store;
678 struct GNUNET_MESSENGER_Member *member;
679
680 member_store = get_srv_room_member_store (room);
681
682 if (! member_store)
683 {
685 "Room does not offer a member store: %s\n",
686 GNUNET_h2s (key));
687 return;
688 }
689
690 member = get_store_member (member_store, id);
691
692 if (! member)
693 {
695 "Could not find member in store with given id: %s (%s)\n",
696 GNUNET_sh2s (id),
697 GNUNET_h2s (key));
698 return;
699 }
700
701 subscription = get_member_subscription (member, discourse);
702 }
703
704 if ((! subscription) ||
706 {
708 "Dropping message for client outside of subscription: %s\n",
709 GNUNET_h2s (hash));
710 return;
711 }
712
713skip_message_filter:
714 if (GNUNET_YES == is_peer_message (message))
715 {
716 const struct GNUNET_PeerIdentity *identity = session->peer;
717 GNUNET_CRYPTO_hash (identity, sizeof(*identity), &sender);
718
719 context = &sender;
720 }
721 else
722 {
725 GNUNET_CRYPTO_hash (pubkey, sizeof(*pubkey), &sender);
726
728 }
729
731 "Notifying client about message: %s (%s)\n",
733 message->header.kind));
734
735 {
737 struct GNUNET_MQ_Envelope *env;
738 uint16_t length;
739 char *buffer;
740
741 length = get_message_size (message, GNUNET_YES);
742
743 env = GNUNET_MQ_msg_extra (msg, length,
745
746 GNUNET_memcpy (&(msg->key), key, sizeof(msg->key));
747 GNUNET_memcpy (&(msg->sender), &sender, sizeof(msg->sender));
748 GNUNET_memcpy (&(msg->context), context, sizeof(msg->context));
749 GNUNET_memcpy (&(msg->hash), hash, sizeof(msg->hash));
750 GNUNET_memcpy (&(msg->epoch), epoch, sizeof(msg->epoch));
751
752 msg->flags = (uint32_t) GNUNET_MESSENGER_FLAG_NONE;
753
754 if (GNUNET_YES == is_peer_message (message))
755 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_PEER;
756 else if (get_handle_member_session (handle, room, key) == session->member)
757 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_SENT;
758
759 if (GNUNET_YES == recent)
760 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_RECENT;
761
762 buffer = ((char*) msg) + sizeof(*msg);
763 encode_message (message, length, buffer, GNUNET_YES);
764
766 }
767}
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
static uint64_t timestamp(void)
Get current timestamp.
static pa_context * context
Pulseaudio context.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static const struct GNUNET_MESSENGER_SrvMemberSession * get_handle_member_session(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *key)
struct GNUNET_MESSENGER_Subscription * get_member_subscription(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ShortHashCode *discourse)
Returns the active subscription of a given member to a selected discourse.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_member_session_public_key(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the public key of a given member session.
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
enum GNUNET_GenericReturnValue has_subscription_of_timestamp(const struct GNUNET_MESSENGER_Subscription *subscription, struct GNUNET_TIME_Absolute timestamp)
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:40
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
@ GNUNET_MESSENGER_KIND_TALK
The talk kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
@ GNUNET_MESSENGER_FLAG_SENT
The sent flag.
@ GNUNET_MESSENGER_FLAG_NONE
The none flag.
@ GNUNET_MESSENGER_FLAG_PEER
The peer flag.
@ GNUNET_MESSENGER_FLAG_RECENT
The recent flag.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_ntoh(struct GNUNET_TIME_AbsoluteNBO a)
Convert absolute time from network byte order.
Definition time.c:737
void encode_message(const struct GNUNET_MESSENGER_Message *message, uint16_t length, char *buffer, enum GNUNET_GenericReturnValue include_header)
Encodes a given message into a buffer of a maximum length in bytes.
enum GNUNET_GenericReturnValue is_peer_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message can be sent by the service without usage of a clients priv...
uint16_t get_message_size(const struct GNUNET_MESSENGER_Message *message, enum GNUNET_GenericReturnValue include_header)
Returns the exact size in bytes to encode a given message.
A 512-bit hashcode.
struct GNUNET_MESSENGER_MessageTalk talk
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_TIME_AbsoluteNBO timestamp
The timestamp of the message.
struct GNUNET_ShortHashCode discourse
The hash of the discourse to talk.
struct GNUNET_MESSENGER_MessageBody body
Body.
Message to receive something from a room.
struct GNUNET_MESSENGER_SrvMemberSession * member
The identity of the host (wraps the signing key of the peer).
Time for absolute times used by GNUnet, in microseconds.

References GNUNET_MESSENGER_Message::body, context, GNUNET_MESSENGER_MessageTalk::discourse, encode_message(), env, get_handle_member_session(), get_member_session_public_key(), get_member_subscription(), get_message_size(), get_message_state_merge_hash(), get_next_member_session_context(), get_srv_handle_member_id(), get_srv_room_key(), get_srv_room_member_store(), get_store_member(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE, GNUNET_MESSENGER_FLAG_NONE, GNUNET_MESSENGER_FLAG_PEER, GNUNET_MESSENGER_FLAG_RECENT, GNUNET_MESSENGER_FLAG_SENT, GNUNET_MESSENGER_KIND_MERGE, GNUNET_MESSENGER_KIND_TALK, GNUNET_MESSENGER_name_of_kind(), GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_sh2s(), GNUNET_TIME_absolute_ntoh(), GNUNET_YES, handle, has_subscription_of_timestamp(), GNUNET_MESSENGER_Message::header, id, identity, is_peer_message(), key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_SenderSession::member, merge_srv_handle_room_to_sync(), GNUNET_VPN_Handle::mq, msg, GNUNET_MESSENGER_SenderSession::peer, pubkey, GNUNET_MESSENGER_SrvRoom::state, GNUNET_MESSENGER_MessageBody::talk, GNUNET_MESSENGER_MessageHeader::timestamp, and timestamp().

Referenced by callback_found_message(), handle_service_message(), notify_about_members(), and traverse_epoch_session_message().

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

◆ iterate_next_member_ids()

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

Definition at line 771 of file gnunet-service-messenger_handle.c.

774{
777
778 GNUNET_assert ((cls) && (value));
779
780 handle = cls;
781 next = value;
782
784 "Notifying client about next member id: %s (%s)\n",
785 GNUNET_sh2s (&(next->id)), GNUNET_h2s (key));
786
787 {
789 struct GNUNET_MQ_Envelope *env;
790
793
794 GNUNET_memcpy (&(msg->key), key, sizeof(*key));
795 GNUNET_memcpy (&(msg->id), &(next->id), sizeof(next->id));
796 msg->reset = (uint32_t) next->reset;
797
799 }
800
802 return GNUNET_YES;
803}
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID
Message to receive the current member id of a handle in room.
struct GNUNET_MQ_Envelope * next
Messages are stored in a linked list.
Definition mq.c:39

References env, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_sh2s(), GNUNET_YES, handle, GNUNET_MESSENGER_NextMemberId::id, key, GNUNET_VPN_Handle::mq, msg, GNUNET_MQ_Envelope::next, and value.

Referenced by task_notify_srv_handle_member_id().

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

◆ task_notify_srv_handle_member_id()

static void task_notify_srv_handle_member_id ( void *  cls)
static

Definition at line 807 of file gnunet-service-messenger_handle.c.

808{
810
811 GNUNET_assert (cls);
812
813 handle = cls;
814 handle->notify = NULL;
815
819}
static enum GNUNET_GenericReturnValue iterate_next_member_ids(void *cls, const struct GNUNET_HashCode *key, void *value)
unsigned int GNUNET_CONTAINER_multihashmap_clear(struct GNUNET_CONTAINER_MultiHashMap *map)
Remove all entries from the map.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_clear(), GNUNET_CONTAINER_multihashmap_iterate(), handle, and iterate_next_member_ids().

Referenced by notify_srv_handle_member_id().

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

◆ notify_srv_handle_member_id()

void notify_srv_handle_member_id ( struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_SrvRoom room,
const struct GNUNET_ShortHashCode member_id,
enum GNUNET_GenericReturnValue  reset 
)

Notifies the handle that a new member id needs to be used.

Parameters
[in,out]handleHandle
[in]roomRoom of the member
[in]member_idMember id
[in]resetReset member session with join message

Definition at line 823 of file gnunet-service-messenger_handle.c.

827{
830 const struct GNUNET_HashCode *key;
831
832 GNUNET_assert ((handle) && (room) && (member_id));
833
835 key = get_srv_room_key (room);
836
837 if (! next)
838 {
840 "Allocation of next member id failed: %s (%s)\n",
841 GNUNET_sh2s (member_id), GNUNET_h2s (key));
842 return;
843 }
844
845 GNUNET_memcpy (&(next->id), member_id, sizeof(next->id));
846 next->reset = reset;
847
848 prev = GNUNET_CONTAINER_multihashmap_get (handle->next_ids, key);
849
851 next,
853 {
855 "Update of next member id failed: %s (%s)\n",
856 GNUNET_sh2s (member_id), GNUNET_h2s (key));
857 return;
858 }
859
860 if (prev)
861 GNUNET_free (prev);
862
863 if (! handle->notify)
865 handle);
866}
static int reset
Reset argument.
static void task_notify_srv_handle_member_id(void *cls)
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition scheduler.c:1310

References get_srv_room_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_SCHEDULER_add_now(), GNUNET_sh2s(), GNUNET_YES, handle, GNUNET_MESSENGER_NextMemberId::id, key, reset, GNUNET_MESSENGER_NextMemberId::reset, and task_notify_srv_handle_member_id().

Referenced by join_room(), and solve_srv_room_member_collisions().

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