GNUnet 0.21.1
gnunet-service-messenger_handle.h File Reference
Include dependency graph for gnunet-service-messenger_handle.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_SrvHandle
 

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). More...
 
void destroy_srv_handle (struct GNUNET_MESSENGER_SrvHandle *handle)
 Destroys a handle and frees its memory fully. More...
 
void set_srv_handle_key (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_CRYPTO_PublicKey *key)
 Sets the public key of a given handle. More...
 
const struct GNUNET_CRYPTO_PublicKeyget_srv_handle_key (const struct GNUNET_MESSENGER_SrvHandle *handle)
 Returns the public key of a given handle. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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). More...
 
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. More...
 
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. More...
 
void sync_srv_handle_messages (struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key, const struct GNUNET_HashCode *prev, struct GNUNET_HashCode *hash)
 Returns the latest merged hash from a room of a given handle using a specific key and the handles own latest known hash of a message. More...
 
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. More...
 
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, enum GNUNET_GenericReturnValue recent)
 Notifies the handle that a new message was received or sent. More...
 
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. More...
 

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 42 of file gnunet-service-messenger_handle.c.

44{
45 GNUNET_assert ((service) && (mq));
46
49
50 handle->service = service;
51 handle->mq = mq;
52
56
57 handle->notify = NULL;
58
59 return handle;
60}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
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.
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:

◆ 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 85 of file gnunet-service-messenger_handle.c.

86{
88
91
92 if (handle->notify)
94
99
103
105}
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.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981

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_PublicKey key 
)

Sets the public key of a given handle.

Parameters
[out]handleHandle
[in]keyPublic key

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

111{
113
114 if ((handle->key) && (! key))
115 {
116 GNUNET_free (handle->key);
117 handle->key = NULL;
118 }
119 else if (! handle->key)
121
122 if (key)
123 memcpy (handle->key, key, sizeof(struct GNUNET_CRYPTO_PublicKey));
124}
struct GNUNET_HashCode key
The key used in the DHT.
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_PublicKey * 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 128 of file gnunet-service-messenger_handle.c.

129{
131
132 return handle->key;
133}

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 137 of file gnunet-service-messenger_handle.c.

140{
141 GNUNET_assert ((handle) && (dir));
142
143 if (name)
144 GNUNET_asprintf (dir, "%s%s%c%s%c", handle->service->dir, "identities",
146 else
147 GNUNET_asprintf (dir, "%s%s%c", handle->service->dir, "anonymous",
149}
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
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:165

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

Here is the call 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 184 of file gnunet-service-messenger_handle.c.

186{
187 GNUNET_assert ((handle) && (key));
188
189 return GNUNET_CONTAINER_multihashmap_get (handle->member_ids, key);
190}
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_room_entry(), handle_room_open(), 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_messages().

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 194 of file gnunet-service-messenger_handle.c.

197{
198 GNUNET_assert ((handle) && (key) && (unique_id));
199
201 handle->member_ids, key);
202
203 if (! member_id)
204 {
205 member_id = GNUNET_new (struct GNUNET_ShortHashCode);
206 GNUNET_memcpy (member_id, unique_id, sizeof(*member_id));
207
209 member_id,
211 {
212 GNUNET_free (member_id);
213 return GNUNET_SYSERR;
214 }
215 }
216
217 if (0 == GNUNET_memcmp (unique_id, member_id))
218 return GNUNET_OK;
219
221 "Change a member id (%s) for room (%s).\n", GNUNET_sh2s (
222 member_id),
223 GNUNET_h2s (key));
224
225 GNUNET_memcpy (member_id, unique_id, sizeof(*unique_id));
226
227 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Member id changed to (%s).\n",
228 GNUNET_sh2s (unique_id));
229 return GNUNET_OK;
230}
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,...)
#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_OK
@ GNUNET_SYSERR
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_INFO
A 256-bit hashcode.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_ERROR_TYPE_INFO, 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 234 of file gnunet-service-messenger_handle.c.

236{
237 GNUNET_assert ((handle) && (key));
238
240 key,
241 NULL,
243 return GNUNET_NO;
244
247 key)))
248 return GNUNET_NO;
249
250 return open_service_room (handle->service, handle, key);
251}
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.
@ GNUNET_YES

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 255 of file gnunet-service-messenger_handle.c.

258{
259 GNUNET_assert ((handle) && (door) && (key));
260
263 handle, key)))
264 return GNUNET_NO;
265
266 return entry_service_room (handle->service, handle, door, key);
267}
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 271 of file gnunet-service-messenger_handle.c.

273{
274 GNUNET_assert ((handle) && (key));
275
277 iterate_free_values, NULL);
279
280 if ((handle->notify) && (0 == GNUNET_CONTAINER_multihashmap_size (
281 handle->next_ids)))
282 {
284 handle->notify = NULL;
285 }
286
288 return GNUNET_NO;
289
292
293 if (GNUNET_YES != result)
294 return result;
295
297 return result;
298}
static int result
Global testing status.
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.
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 302 of file gnunet-service-messenger_handle.c.

304{
305 GNUNET_assert ((handle) && (key));
306
308}
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:

◆ sync_srv_handle_messages()

void sync_srv_handle_messages ( struct GNUNET_MESSENGER_SrvHandle handle,
const struct GNUNET_HashCode key,
const struct GNUNET_HashCode prev,
struct GNUNET_HashCode hash 
)

Returns the latest merged hash from a room of a given handle using a specific key and the handles own latest known hash of a message.

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.

Parameters
[in,out]handleHandle
[in]keyKey of a room
[in]prevKnown hash of a message
[out]hashHash of the latest merged message in a room available to the handle

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

316{
317 GNUNET_assert ((handle) && (key) && (prev) && (hash));
318
319 struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (handle->service,
320 key);
321
322 if ((! room) || (! get_srv_handle_member_id (handle, key)))
323 {
324 GNUNET_memcpy (hash, prev, sizeof(*hash));
325 return;
326 }
327
329 get_message_state_chain_hash (&(room->state), hash);
330}
void get_message_state_chain_hash(const struct GNUNET_MESSENGER_MessageState *state, struct GNUNET_HashCode *hash)
void merge_srv_room_last_messages(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Reduces all current forks inside of the message history of a room to one remaining last message by me...
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.
struct GNUNET_MESSENGER_MessageState state

References get_message_state_chain_hash(), get_service_room(), get_srv_handle_member_id(), GNUNET_assert, GNUNET_memcpy, handle, key, merge_srv_room_last_messages(), and GNUNET_MESSENGER_SrvRoom::state.

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

337{
338 GNUNET_assert ((handle) && (key) && (message));
339
341 key);
342
343 if (! id)
344 {
346 "It is required to be a member of a room to send messages!\n");
347 return GNUNET_NO;
348 }
349
350 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message with member id: %s\n",
351 GNUNET_sh2s (id));
352
353 if (0 != GNUNET_memcmp (id, &(message->header.sender_id)))
354 {
356 "Member id does not match with handle!\n");
357 return GNUNET_NO;
358 }
359
360 struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (handle->service,
361 key);
362
363 if (! room)
364 {
365 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "The room (%s) is unknown!\n",
366 GNUNET_h2s (key));
367 return GNUNET_NO;
368 }
369
370 struct GNUNET_MESSENGER_Message *msg = copy_message (message);
371 return send_srv_room_message (room, handle, msg);
372}
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
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
@ GNUNET_ERROR_TYPE_DEBUG
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_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_sh2s(), handle, GNUNET_MESSENGER_Message::header, 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:

◆ 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,
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]recentWhether the message was recently handled

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

428{
429 GNUNET_assert ((handle) && (room) && (session) && (message) && (hash));
430
431 const struct GNUNET_HashCode *key = get_srv_room_key (room);
432
433 if ((! handle->mq) || (! get_srv_handle_member_id (handle, key)))
434 {
436 "Notifying client about message requires membership!\n");
437 return;
438 }
439
440 struct GNUNET_HashCode sender;
441 const struct GNUNET_HashCode *context = NULL;
442
443 if (GNUNET_YES == is_peer_message (message))
444 {
445 const struct GNUNET_PeerIdentity *identity = session->peer;
446 GNUNET_CRYPTO_hash (identity, sizeof(*identity), &sender);
447
448 context = &sender;
449 }
450 else
451 {
453 session->member->contact);
454 GNUNET_CRYPTO_hash (pubkey, sizeof(*pubkey), &sender);
455
457 }
458
460 "Notifying client about message: %s (%s)\n",
462 message->header.kind));
463
465 struct GNUNET_MQ_Envelope *env;
466
467 uint16_t length = get_message_size (message, GNUNET_YES);
468
469 env = GNUNET_MQ_msg_extra (msg, length,
471
472 GNUNET_memcpy (&(msg->key), key, sizeof(msg->key));
473 GNUNET_memcpy (&(msg->sender), &sender, sizeof(msg->sender));
474 GNUNET_memcpy (&(msg->context), context, sizeof(msg->context));
475 GNUNET_memcpy (&(msg->hash), hash, sizeof(msg->hash));
476
477 msg->flags = (uint32_t) GNUNET_MESSENGER_FLAG_NONE;
478
479 if (GNUNET_YES == is_peer_message (message))
480 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_PEER;
481 else if (get_handle_member_session (handle, room, key) == session->member)
482 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_SENT;
483
484 if (GNUNET_YES == recent)
485 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_RECENT;
486
487 char *buffer = ((char*) msg) + sizeof(*msg);
488 encode_message (message, length, buffer, GNUNET_YES);
489
491}
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static pa_context * context
Pulseaudio context.
static struct GNUNET_CRYPTO_PublicKey pubkey
Public key of the zone to look in.
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_HashCode * get_next_member_session_context(const struct GNUNET_MESSENGER_MemberSession *session)
static const struct GNUNET_MESSENGER_MemberSession * get_handle_member_session(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_HashCode *key)
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
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
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:43
@ GNUNET_MESSENGER_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.
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:304
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
Definition: gnunet_mq_lib.h:63
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE
const struct GNUNET_CRYPTO_PublicKey * get_contact_key(const struct GNUNET_MESSENGER_Contact *contact)
Returns the public key of a given contact.
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 maximal 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.
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
Message to receive something from a room.
struct GNUNET_MESSENGER_MemberSession * member
The identity of the host (wraps the signing key of the peer).

References GNUNET_MESSENGER_MemberSession::contact, context, encode_message(), env, get_contact_key(), get_handle_member_session(), get_message_size(), get_next_member_session_context(), get_srv_handle_member_id(), get_srv_room_key(), GNUNET_assert, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_INFO, 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_name_of_kind(), GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_YES, handle, GNUNET_MESSENGER_Message::header, identity, is_peer_message(), key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_SenderSession::member, GNUNET_VPN_Handle::mq, msg, GNUNET_MESSENGER_SenderSession::peer, and pubkey.

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

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 531 of file gnunet-service-messenger_handle.c.

535{
536 GNUNET_assert ((handle) && (room) && (member_id));
537
538 struct GNUNET_MESSENGER_NextMemberId *next = GNUNET_new (struct
540 if (! next)
541 {
542 return;
543 }
544
545 GNUNET_memcpy (&(next->id), member_id, sizeof(next->id));
546 next->reset = reset;
547
548 const struct GNUNET_HashCode *key = get_srv_room_key (room);
549
550 struct GNUNET_MESSENGER_NextMemberId *prev =
553 next,
555 {
556 return;
557 }
558
559 if (prev)
560 GNUNET_free (prev);
561
562 if (! handle->notify)
564 handle);
565}
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:1305
enum GNUNET_GenericReturnValue reset

References get_srv_room_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE, GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_SCHEDULER_add_now(), 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: