GNUnet 0.21.2
gnunet-service-messenger_handle.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2024 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
26#include "platform.h"
28
32
33#include "messenger_api_util.h"
34
36{
39};
40
43 struct GNUNET_MQ_Handle *mq)
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}
61
62
65 const struct GNUNET_HashCode *key,
66 void *value)
67{
70 return GNUNET_YES;
71}
72
73
76 const struct GNUNET_HashCode *key,
77 void *value)
78{
80 return GNUNET_YES;
81}
82
83
84void
86{
88
91
92 if (handle->notify)
94
99
103
105}
106
107
108void
110 const struct GNUNET_CRYPTO_PublicKey *key)
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}
125
126
127const struct GNUNET_CRYPTO_PublicKey*
129{
131
132 return handle->key;
133}
134
135
136void
138 const char *name,
139 char **dir)
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}
150
151
154 const struct GNUNET_HashCode *key)
155{
156 GNUNET_assert ((handle) && (key));
157
158 struct GNUNET_ShortHashCode *random_id = GNUNET_new (struct
160
161 if (! random_id)
162 return GNUNET_NO;
163
164 generate_free_member_id (random_id, NULL);
165
167 random_id,
169 {
170 GNUNET_free (random_id);
171 return GNUNET_NO;
172 }
173
175 "Created a new member id (%s) for room: %s\n", GNUNET_sh2s (
176 random_id),
177 GNUNET_h2s (key));
178
179 return GNUNET_YES;
180}
181
182
183const struct GNUNET_ShortHashCode*
185 const struct GNUNET_HashCode *key)
186{
187 GNUNET_assert ((handle) && (key));
188
189 return GNUNET_CONTAINER_multihashmap_get (handle->member_ids, key);
190}
191
192
195 const struct GNUNET_HashCode *key,
196 const struct GNUNET_ShortHashCode *unique_id)
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}
231
232
235 const struct GNUNET_HashCode *key)
236{
237 GNUNET_assert ((handle) && (key));
238
240 key,
241 NULL,
243
244 return GNUNET_NO;
245
248 key)))
249 return GNUNET_NO;
250
251 return open_service_room (handle->service, handle, key);
252}
253
254
257 const struct GNUNET_PeerIdentity *door,
258 const struct GNUNET_HashCode *key)
259{
260 GNUNET_assert ((handle) && (door) && (key));
261
264 handle, key)))
265 return GNUNET_NO;
266
267 return entry_service_room (handle->service, handle, door, key);
268}
269
270
273 const struct GNUNET_HashCode *key)
274{
275 GNUNET_assert ((handle) && (key));
276
278 iterate_free_values, NULL);
280
281 if ((handle->notify) && (0 == GNUNET_CONTAINER_multihashmap_size (
282 handle->next_ids)))
283 {
285 handle->notify = NULL;
286 }
287
289 return GNUNET_NO;
290
293
294 if (GNUNET_YES != result)
295 return result;
296
298 return result;
299}
300
301
304 const struct GNUNET_HashCode *key)
305{
306 GNUNET_assert ((handle) && (key));
307
309}
310
311
312void
314 const struct GNUNET_HashCode *key,
315 const struct GNUNET_HashCode *prev,
316 struct GNUNET_HashCode *hash)
317{
318 GNUNET_assert ((handle) && (key) && (prev) && (hash));
319
320 struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (handle->service,
321 key);
322
323 if ((! room) || (! get_srv_handle_member_id (handle, key)))
324 {
325 GNUNET_memcpy (hash, prev, sizeof(*hash));
326 return;
327 }
328
330 get_message_state_chain_hash (&(room->state), hash);
331}
332
333
336 const struct GNUNET_HashCode *key,
337 const struct GNUNET_MESSENGER_Message *message)
338{
339 GNUNET_assert ((handle) && (key) && (message));
340
342 key);
343
344 if (! id)
345 {
347 "It is required to be a member of a room to send messages!\n");
348 return GNUNET_NO;
349 }
350
351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending message with member id: %s\n",
352 GNUNET_sh2s (id));
353
354 if (0 != GNUNET_memcmp (id, &(message->header.sender_id)))
355 {
357 "Member id does not match with handle!\n");
358 return GNUNET_NO;
359 }
360
361 struct GNUNET_MESSENGER_SrvRoom *room = get_service_room (handle->service,
362 key);
363
364 if (! room)
365 {
366 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "The room (%s) is unknown!\n",
367 GNUNET_h2s (key));
368 return GNUNET_NO;
369 }
370
371 struct GNUNET_MESSENGER_Message *msg = copy_message (message);
372 return send_srv_room_message (room, handle, msg);
373}
374
375
376static const struct GNUNET_HashCode*
379{
380 if (session->next)
381 return get_next_member_session_context (session->next);
382 else
383 return get_member_session_context (session);
384}
385
386
387static const struct GNUNET_MESSENGER_MemberSession*
389 struct GNUNET_MESSENGER_SrvRoom *room,
390 const struct GNUNET_HashCode *key)
391{
392 GNUNET_assert ((handle) && (room) && (key) && (handle->service));
393
395 key);
396
397 if (! id)
398 {
400 "Handle is missing a member id for its member session! (%s)\n",
401 GNUNET_h2s (key));
402 return NULL;
403 }
404
406 struct GNUNET_MESSENGER_Member *member = get_store_member (store, id);
407
409
410 if (! pubkey)
411 {
413 "Handle is missing a public key for its member session! (%s)\n",
414 GNUNET_h2s (key));
415 return NULL;
416 }
417
418 return get_member_session (member, pubkey);
419}
420
421
422void
424 struct GNUNET_MESSENGER_SrvRoom *room,
425 const struct GNUNET_MESSENGER_SenderSession *session,
426 const struct GNUNET_MESSENGER_Message *message,
427 const struct GNUNET_HashCode *hash,
428 enum GNUNET_GenericReturnValue recent)
429{
430 GNUNET_assert ((handle) && (room) && (session) && (message) && (hash));
431
432 const struct GNUNET_HashCode *key = get_srv_room_key (room);
434 key);
435
436 if ((! handle->mq) || (! id))
437 {
439 "Notifying client about message requires membership!\n");
440 return;
441 }
442
443 struct GNUNET_HashCode sender;
444 const struct GNUNET_HashCode *context = NULL;
445
446 if (GNUNET_MESSENGER_KIND_TALK != message->header.kind)
447 goto skip_message_filter;
448
449 struct GNUNET_TIME_Absolute timestamp =
451 const struct GNUNET_ShortHashCode *discourse =
452 &(message->body.talk.discourse);
453
454 struct GNUNET_MESSENGER_MemberStore *member_store =
456
457 if (! member_store)
458 return;
459
460 struct GNUNET_MESSENGER_Member *member =
461 get_store_member (member_store, id);
462
463 if (! member)
464 return;
465
466 struct GNUNET_MESSENGER_Subscription *subscription =
468
469 if ((! subscription) ||
470 (GNUNET_YES != has_subscription_of_timestamp(subscription, timestamp)))
471 {
473 "Dropping message for client outside of subscription: %s\n",
474 GNUNET_h2s (hash));
475 return;
476 }
477
478skip_message_filter:
479 if (GNUNET_YES == is_peer_message (message))
480 {
481 const struct GNUNET_PeerIdentity *identity = session->peer;
482 GNUNET_CRYPTO_hash (identity, sizeof(*identity), &sender);
483
484 context = &sender;
485 }
486 else
487 {
488 const struct GNUNET_CRYPTO_PublicKey *pubkey;
490 GNUNET_CRYPTO_hash (pubkey, sizeof(*pubkey), &sender);
491
493 }
494
496 "Notifying client about message: %s (%s)\n",
498 message->header.kind));
499
501 struct GNUNET_MQ_Envelope *env;
502
503 uint16_t length = get_message_size (message, GNUNET_YES);
504
505 env = GNUNET_MQ_msg_extra (msg, length,
507
508 GNUNET_memcpy (&(msg->key), key, sizeof(msg->key));
509 GNUNET_memcpy (&(msg->sender), &sender, sizeof(msg->sender));
510 GNUNET_memcpy (&(msg->context), context, sizeof(msg->context));
511 GNUNET_memcpy (&(msg->hash), hash, sizeof(msg->hash));
512
513 msg->flags = (uint32_t) GNUNET_MESSENGER_FLAG_NONE;
514
515 if (GNUNET_YES == is_peer_message (message))
516 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_PEER;
517 else if (get_handle_member_session (handle, room, key) == session->member)
518 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_SENT;
519
520 if (GNUNET_YES == recent)
521 msg->flags |= (uint32_t) GNUNET_MESSENGER_FLAG_RECENT;
522
523 char *buffer = ((char*) msg) + sizeof(*msg);
524 encode_message (message, length, buffer, GNUNET_YES);
525
527}
528
529
532 const struct GNUNET_HashCode *key,
533 void *value)
534{
537
539 "Notifying client about next member id: %s (%s)\n",
540 GNUNET_sh2s (&(next->id)), GNUNET_h2s (key));
541
543 struct GNUNET_MQ_Envelope *env;
544
546
547 GNUNET_memcpy (&(msg->key), key, sizeof(*key));
548 GNUNET_memcpy (&(msg->id), &(next->id), sizeof(next->id));
549 msg->reset = (uint32_t) next->reset;
550
552
554 return GNUNET_YES;
555}
556
557
558static void
560{
562 handle->notify = NULL;
563
567}
568
569
570void
572 struct GNUNET_MESSENGER_SrvRoom *room,
573 const struct GNUNET_ShortHashCode *member_id,
575{
576 GNUNET_assert ((handle) && (room) && (member_id));
577
578 struct GNUNET_MESSENGER_NextMemberId *next = GNUNET_new (struct
580 if (! next)
581 {
582 return;
583 }
584
585 GNUNET_memcpy (&(next->id), member_id, sizeof(next->id));
586 next->reset = reset;
587
588 const struct GNUNET_HashCode *key = get_srv_room_key (room);
589
590 struct GNUNET_MESSENGER_NextMemberId *prev =
593 next,
595 {
596 return;
597 }
598
599 if (prev)
600 GNUNET_free (prev);
601
602 if (! handle->notify)
604 handle);
605}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
struct GNUNET_HashCode key
The key used in the DHT.
static pa_context * context
Pulseaudio context.
static char * name
Name (label) of the records to list.
static struct GNUNET_CRYPTO_PublicKey pubkey
Public key of the zone to look in.
static int reset
Reset argument.
static char * value
Value of the record to add/remove.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static int result
Global testing status.
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
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).
static const struct GNUNET_HashCode * get_next_member_session_context(const struct GNUNET_MESSENGER_MemberSession *session)
static enum GNUNET_GenericReturnValue iterate_free_values(void *cls, const struct GNUNET_HashCode *key, void *value)
void set_srv_handle_key(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_CRYPTO_PublicKey *key)
Sets the public key of a given handle.
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.
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...
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 se...
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.
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.
static void task_notify_srv_handle_member_id(void *cls)
static enum GNUNET_GenericReturnValue iterate_close_rooms(void *cls, const struct GNUNET_HashCode *key, void *value)
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 t...
static enum GNUNET_GenericReturnValue iterate_next_member_ids(void *cls, const struct GNUNET_HashCode *key, void *value)
const struct GNUNET_CRYPTO_PublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
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)
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...
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 is_srv_handle_routing(const struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Returns whether a given handle has enabled routing for a room using a specific key by opening that ro...
void 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.
void destroy_srv_handle(struct GNUNET_MESSENGER_SrvHandle *handle)
Destroys a handle and frees its memory fully.
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 se...
struct GNUNET_MESSENGER_MemberSession * get_member_session(const struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *public_key)
Returns the member session of a member identified by a given public key.
struct GNUNET_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_PublicKey * get_member_session_public_key(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the public key of a given member session.
const struct GNUNET_HashCode * get_member_session_context(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the member context of a given member session.
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.
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...
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.
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
struct GNUNET_MESSENGER_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
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.
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.
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.
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.
enum GNUNET_GenericReturnValue has_subscription_of_timestamp(const struct GNUNET_MESSENGER_Subscription *subscribtion, struct GNUNET_TIME_Absolute timestamp)
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
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
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).
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.
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_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
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.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
unsigned int GNUNET_CONTAINER_multihashmap_clear(struct GNUNET_CONTAINER_MultiHashMap *map)
Remove all entries from 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_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE
If a value with the given key exists, replace it.
#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_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:43
@ GNUNET_MESSENGER_KIND_TALK
The talk 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.
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_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:78
#define GNUNET_MESSAGE_TYPE_MESSENGER_ROOM_RECV_MESSAGE
#define GNUNET_MESSAGE_TYPE_MESSENGER_CONNECTION_MEMBER_ID
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
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
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 maximal length in bytes.
struct GNUNET_MESSENGER_Message * copy_message(const struct GNUNET_MESSENGER_Message *message)
Creates and allocates a copy of a given message.
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.
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.
#define DIR_SEPARATOR
Definition: platform.h:165
An identity key as per LSD0001.
A 512-bit hashcode.
Message to receive the current member id of a handle in room.
struct GNUNET_MESSENGER_MemberSession * next
struct GNUNET_MESSENGER_MemberStore * store
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 sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_ShortHashCode discourse
The hash of the discourse to talk.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.
enum GNUNET_GenericReturnValue reset
Message to receive something from a room.
struct GNUNET_MESSENGER_MemberSession * member
struct GNUNET_MESSENGER_MessageState state
struct GNUNET_MQ_Envelope * next
Messages are stored in a linked list.
Definition: mq.c:39
Handle to a message queue.
Definition: mq.c:87
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Definition: vpn_api.c:44