GNUnet 0.26.2-106-g126384b46
 
Loading...
Searching...
No Matches
gnunet-service-messenger_service.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2026 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 */
27
30
31#include "gnunet_common.h"
33#include "gnunet_pils_service.h"
34#include "gnunet_util_lib.h"
35#include "messenger_api_util.h"
36
37static void
39{
41
42 service = cls;
43
44 if (service)
45 {
46 service->shutdown = NULL;
47
49 }
50}
51
52
55 const struct GNUNET_HashCode *key,
56 void *value)
57{
58 const struct GNUNET_PeerIdentity *identity;
59 struct GNUNET_MESSENGER_SrvRoom *room;
60 struct GNUNET_MESSENGER_Message *message;
61
62 GNUNET_assert ((cls) && (key) && (value));
63
64 identity = cls;
65 room = value;
66
67 if (! room->port)
68 return GNUNET_YES;
69
70 message = create_message_miss (identity);
71
72 if (! message)
73 {
75 "Miss message could not be sent: %s\n",
76 GNUNET_h2s (key));
77 return GNUNET_NO;
78 }
79
80 return send_srv_room_message (room, room->host, message);
81}
82
83
86 const struct GNUNET_HashCode *key,
87 void *value)
88{
90 struct GNUNET_MESSENGER_SrvRoom *room;
91 struct GNUNET_MESSENGER_Message *message;
92
93 GNUNET_assert ((cls) && (key) && (value));
94
95 service = cls;
96 room = value;
97
98 if (! room->port)
99 return GNUNET_YES;
100
101 message = create_message_peer (service);
102
103 if (! message)
104 {
106 "Peer message could not be sent: %s\n",
107 GNUNET_h2s (key));
108 return GNUNET_NO;
109 }
110
111 return send_srv_room_message (room, room->host, message);
112}
113
114
115static void
117 const struct GNUNET_HELLO_Parser *parser,
118 GNUNET_UNUSED const struct GNUNET_HashCode *hash)
119{
121 const struct GNUNET_PeerIdentity *new_id;
122 struct GNUNET_PeerIdentity old_id;
123
124 GNUNET_assert ((cls) && (parser));
125
126 service = cls;
127
128 new_id = GNUNET_HELLO_parser_get_id (parser);
129
130 if (NULL == service->identity)
131 {
132 service->identity = GNUNET_new (struct GNUNET_PeerIdentity);
133 GNUNET_assert (service->identity);
134 GNUNET_memcpy (service->identity, new_id, sizeof (*new_id));
135 new_id = service->identity;
136 }
137 else if (0 == GNUNET_memcmp (new_id, service->identity))
138 return;
139 else
140 {
141 GNUNET_memcpy (&old_id, service->identity, sizeof (old_id));
142 GNUNET_memcpy (service->identity, new_id, sizeof (*new_id));
143 }
144
145 GNUNET_assert (0 == GNUNET_memcmp (service->identity, new_id));
146
149 service);
150
151 if (new_id != service->identity)
154 &old_id);
155}
156
157
160 struct GNUNET_SERVICE_Handle *service_handle)
161{
163
164 GNUNET_assert ((config) && (service_handle));
165
166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create new service!\n");
167
169
170 service->config = config;
171 service->service = service_handle;
172
174 service);
175
176 service->identity = NULL;
177 service->dir = NULL;
178
181 "MESSENGER_DIR",
182 &(service->dir)))
183 {
184 if (service->dir)
185 GNUNET_free (service->dir);
186
187 service->dir = NULL;
188 }
189 else
190 {
192 (GNUNET_OK
193 !=
195 {
196 GNUNET_free (service->dir);
197
198 service->dir = NULL;
199 }
200 }
201
203 service->config,
205 "MESSENGER_AUTO_CONNECTING");
206
208 service->config,
210 "MESSENGER_AUTO_ROUTING");
211
213 service->config,
215 "MESSENGER_GROUP_KEYS");
216
218 service->config,
220 "MESSENGER_LOCAL_REQUEST");
221
224 "MESSENGER_MIN_ROUTERS",
225 &(service->min_routers
226 )))
227 service->min_routers = 0;
228
229 service->cadet = GNUNET_CADET_connect (service->config);
230 service->pils = GNUNET_PILS_connect (service->config,
232 service);
234 service->config);
235
236 init_list_handles (&(service->handles));
237
239
241
242 return service;
243}
244
245
248 const struct GNUNET_HashCode *key,
249 void *value)
250{
251 struct GNUNET_MESSENGER_SrvRoom *room;
252
254
255 room = value;
256
258 return GNUNET_YES;
259}
260
261
262void
264{
266
267 if (service->shutdown)
268 {
270 service->shutdown = NULL;
271 }
272
273 clear_list_handles (&(service->handles));
274
276 NULL);
278
280
281 if (service->cadet)
282 {
284 service->cadet = NULL;
285 }
286
287 if (service->pils)
288 {
290 service->pils = NULL;
291 }
292
293 if (service->statistics)
294 {
296 GNUNET_YES);
297 service->statistics = NULL;
298 }
299
300 if (service->dir)
301 {
302 GNUNET_free (service->dir);
303 service->dir = NULL;
304 }
305
306 if (service->identity)
307 {
308 GNUNET_free (service->identity);
309 service->identity = NULL;
310 }
311
313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Free service!\n");
314
316}
317
318
321{
323
324 return &(service->contact_store);
325}
326
327
330 struct GNUNET_MQ_Handle *mq)
331{
333
334 GNUNET_assert ((service) && (mq));
335
337
338 if (handle)
339 {
340 add_list_handle (&(service->handles), handle);
342 "# handles connected",
343 1,
344 GNUNET_NO);
345 }
346
347 return handle;
348}
349
350
351void
354{
356
357 if (! handle)
358 return;
359
360 if (GNUNET_YES == remove_list_handle (&(service->handles), handle))
361 {
364 "# handles connected",
365 -1,
366 GNUNET_NO);
367 }
368}
369
370
373 struct GNUNET_PeerIdentity *peer)
374{
375 GNUNET_assert ((service) && (peer));
376
377 if (NULL == service->identity)
378 {
380 "Service does not know its peer's identity!\n");
381 return GNUNET_SYSERR;
382 }
383
384 GNUNET_memcpy (peer, service->identity, sizeof(*peer));
385 return GNUNET_OK;
386}
387
388
391 const struct GNUNET_HashCode *key)
392{
393 GNUNET_assert ((service) && (key));
394
396}
397
398
405
409 public_key,
410 struct GNUNET_MESSENGER_SrvMemberSession *session)
411{
413 const struct GNUNET_ShortHashCode *id;
414
415 GNUNET_assert ((cls) && (session));
416
417 init = cls;
418
419 if (! public_key)
420 return GNUNET_YES;
421
422 {
424 pubkey = get_srv_handle_key (init->handle);
425
426 if (0 != GNUNET_memcmp (pubkey, public_key))
427 return GNUNET_YES;
428 }
429
430 id = get_member_session_id (session);
431
432 if (! id)
433 {
434 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initialitation: Missing member id!");
435 return GNUNET_NO;
436 }
437
439 "Initialitation: Matching member found (%s)!\n",
440 GNUNET_sh2s (id));
441
443 return GNUNET_NO;
444}
445
446
447static void
449 struct GNUNET_MESSENGER_SrvRoom *room)
450{
451 struct GNUNET_MESSENGER_MemberStore *store;
453
454 GNUNET_assert ((handle) && (room));
455
456 store = get_srv_room_member_store (room);
457 if (! store)
458 return;
459
461 if ((! pubkey) || (0 == GNUNET_memcmp (pubkey, get_anonymous_public_key ())))
462 return;
463
465 "Initialize member id of handle via matching member in room!\n");
466
467 {
470 init.room = room;
471 init.pubkey = pubkey;
472
474 }
475}
476
477
481 const struct GNUNET_HashCode *key)
482{
483 struct GNUNET_MESSENGER_SrvRoom *room;
485
486 GNUNET_assert ((service) && (handle) && (key));
487
488 room = get_service_room (service, key);
489
490 if (room)
491 {
493 result = open_srv_room (room, handle);
494
495 if (GNUNET_YES == result)
497 "# room openings",
498 1,
499 GNUNET_NO);
500 return result;
501 }
502
503 room = create_srv_room (handle, key);
505
506 if ((GNUNET_YES == open_srv_room (room, handle)) &&
508 key, room,
510 {
512 "# room openings",
513 1,
514 GNUNET_NO);
515 GNUNET_STATISTICS_set (service->statistics,
516 "# rooms active",
518 GNUNET_NO);
519 return GNUNET_YES;
520 }
521
523 return GNUNET_NO;
524}
525
526
530 const struct GNUNET_PeerIdentity *door,
531 const struct GNUNET_HashCode *key)
532{
533 struct GNUNET_MESSENGER_SrvRoom *room;
534
535 GNUNET_assert ((service) && (handle) && (door) && (key));
536
537 room = get_service_room (service, key);
538
539 if (room)
540 {
542
543 if (GNUNET_YES == enter_srv_room_at (room, handle, door))
544 {
546 "# room entries",
547 1,
548 GNUNET_NO);
549 return GNUNET_YES;
550 }
551 else
552 return GNUNET_NO;
553 }
554
555 room = create_srv_room (handle, key);
557
558 if ((GNUNET_YES == enter_srv_room_at (room, handle, door)) &&
560 key, room,
562 {
564 "# room entries",
565 1,
566 GNUNET_NO);
567 GNUNET_STATISTICS_set (service->statistics,
568 "# rooms active",
570 GNUNET_NO);
571 return GNUNET_YES;
572 }
573 else
574 {
576 return GNUNET_NO;
577 }
578
579}
580
581
585 const struct GNUNET_HashCode *key,
586 enum GNUNET_GenericReturnValue deletion)
587{
588 struct GNUNET_MESSENGER_SrvRoom *room;
589 struct GNUNET_MESSENGER_SrvHandle *member_handle;
590
591 GNUNET_assert ((service) && (handle) && (key));
592
593 room = get_service_room (service, key);
594
595 if (! room)
596 return GNUNET_NO;
597
598 {
599 struct GNUNET_ShortHashCode *id;
600 id = (struct GNUNET_ShortHashCode*) (
602
603 GNUNET_assert (id);
604
606 key, id))
607 return GNUNET_NO;
608
609 GNUNET_free (id);
610 }
611
612 member_handle = (struct GNUNET_MESSENGER_SrvHandle*) (
613 find_list_handle_by_member (&(service->handles), key));
614
615 if (! member_handle)
616 {
618 room))
619 {
620 destroy_srv_room (room, deletion);
622 "# room closings",
623 1,
624 GNUNET_NO);
625 GNUNET_STATISTICS_set (service->statistics,
626 "# rooms active",
628 ,
629 GNUNET_NO);
630 return GNUNET_YES;
631 }
632 else
633 return GNUNET_NO;
634 }
635
636 if (room->sync == handle)
637 room->sync = NULL;
638
639 if (room->host == handle)
640 {
641 struct GNUNET_MESSENGER_Message *message;
642
643 room->host = member_handle;
644
645 if (! room->peer_message)
646 goto skip_connection_message;
647
648 message = create_message_connection (room);
649
650 if (! message)
652 "Sending connection message failed: %s\n",
653 GNUNET_h2s (&(room->key)));
654 else
655 send_srv_room_message (room, room->host, message);
656 }
657
658skip_connection_message:
660 "# room closings",
661 1,
662 GNUNET_NO);
663
664 return GNUNET_YES;
665}
666
667
668void
670 struct GNUNET_MESSENGER_SrvRoom *room,
671 const struct GNUNET_MESSENGER_SenderSession *session,
672 const struct GNUNET_MESSENGER_Message *message,
673 const struct GNUNET_HashCode *hash,
674 const struct GNUNET_HashCode *epoch,
675 enum GNUNET_GenericReturnValue recent)
676{
677 struct GNUNET_MESSENGER_ListHandle *element;
678
679 GNUNET_assert ((service) && (room) && (session) && (message) && (hash) && (
680 epoch));
681
683 "Notify active clients about message: %s (%s)\n",
685 message->header.kind));
686
687 for (element = service->handles.head; element; element = element->next)
688 {
689 if (! get_srv_handle_member_id (element->handle,
690 get_srv_room_key (room)))
691 continue;
692
693 notify_srv_handle_message (element->handle, room, session, message, hash,
694 epoch, recent);
695 }
696
698 "# message notifications",
699 1,
700 GNUNET_NO);
701}
static char * init
Set to the name of a service to start.
Definition gnunet-arm.c:73
struct GNUNET_HashCode key
The key used in the DHT.
const struct GNUNET_CONFIGURATION_Handle * config
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
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.
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.
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).
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...
const struct GNUNET_CRYPTO_BlindablePublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
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.
void destroy_srv_handle(struct GNUNET_MESSENGER_SrvHandle *handle)
Destroys a handle and frees its memory fully.
struct GNUNET_MESSENGER_SrvHandle * find_list_handle_by_member(const struct GNUNET_MESSENGER_ListHandles *handles, const struct GNUNET_HashCode *key)
Searches linearly through the list of handles for members of a specific room which is identified by a...
void add_list_handle(struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle)
Adds a specific handle to the end of the list.
void init_list_handles(struct GNUNET_MESSENGER_ListHandles *handles)
Initializes list of handles as empty list.
enum GNUNET_GenericReturnValue remove_list_handle(struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle)
Removes the first entry matching with a specific handle from the list of handles and returns GNUNET_Y...
void clear_list_handles(struct GNUNET_MESSENGER_ListHandles *handles)
Destroys remaining handles and clears the list.
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_SrvMemberSession *session)
Returns the member id of a given member session.
int iterate_store_members(struct GNUNET_MESSENGER_MemberStore *store, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls)
Iterate through all member sessions currently connected to the members of the given member store and ...
struct GNUNET_MESSENGER_Message * create_message_connection(const struct GNUNET_MESSENGER_SrvRoom *room)
Creates and allocates a new connection message containing the amount of the peer's connections in a g...
struct GNUNET_MESSENGER_Message * create_message_miss(const struct GNUNET_PeerIdentity *peer)
Creates and allocates a new miss message containing the missing peer identity.
struct GNUNET_MESSENGER_Message * create_message_peer(struct GNUNET_MESSENGER_Service *service)
Creates and allocates a new peer message containing a services peer identity.
struct GNUNET_MESSENGER_SrvRoom * create_srv_room(struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_HashCode *key)
Creates and allocates a new room for a handle with a given key.
enum GNUNET_GenericReturnValue enter_srv_room_at(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle, const struct GNUNET_PeerIdentity *door)
Connects a tunnel to a hosting peer of a room through a so called door which is represented by a peer...
enum GNUNET_GenericReturnValue open_srv_room(struct GNUNET_MESSENGER_SrvRoom *room, struct GNUNET_MESSENGER_SrvHandle *handle)
Tries to open a room for a given handle.
void destroy_srv_room(struct GNUNET_MESSENGER_SrvRoom *room, enum GNUNET_GenericReturnValue deletion)
Destroys a room and frees its memory fully.
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.
void remove_service_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle)
Removes a handle from a service and destroys it.
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.
struct GNUNET_MESSENGER_ContactStore * get_service_contact_store(struct GNUNET_MESSENGER_Service *service)
Returns the used contact store of a given service.
void destroy_service(struct GNUNET_MESSENGER_Service *service)
Destroys a service and frees its memory fully.
static void initialize_service_handle(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *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.
static enum GNUNET_GenericReturnValue iterate_service_update_rooms(void *cls, const struct GNUNET_HashCode *key, void *value)
static void callback_peer_id_changed(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
static enum GNUNET_GenericReturnValue iterate_service_miss_rooms(void *cls, const struct GNUNET_HashCode *key, void *value)
static void callback_shutdown_service(void *cls)
static enum GNUNET_GenericReturnValue find_member_session_in_room(void *cls, const struct GNUNET_CRYPTO_BlindablePublicKey *public_key, struct GNUNET_MESSENGER_SrvMemberSession *session)
void handle_service_message(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvRoom *room, const struct GNUNET_MESSENGER_SenderSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_HashCode *epoch, enum GNUNET_GenericReturnValue recent)
Sends a received or sent message with a given hash to each handle of a service which is currently mem...
struct GNUNET_MESSENGER_SrvHandle * add_service_handle(struct GNUNET_MESSENGER_Service *service, struct GNUNET_MQ_Handle *mq)
Creates and adds a new handle to a service using a given message queue.
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.
static enum GNUNET_GenericReturnValue iterate_destroy_rooms(void *cls, const struct GNUNET_HashCode *key, void *value)
struct GNUNET_MESSENGER_Service * create_service(const struct GNUNET_CONFIGURATION_Handle *config, struct GNUNET_SERVICE_Handle *service_handle)
Creates and allocates a new service using a given config and a GNUnet service handle.
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.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
Helper library for handling HELLO URIs.
struct GNUNET_PILS_Handle * GNUNET_PILS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_PILS_PidChangeCallback pid_change_cb, void *cls)
Connect to the PILS service.
Definition pils_api.c:465
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:488
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
Definition cadet_api.c:897
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition cadet_api.c:777
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition disk.c:466
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition disk.c:573
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_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
const struct GNUNET_PeerIdentity * GNUNET_HELLO_parser_get_id(const struct GNUNET_HELLO_Parser *parser)
Get the PeerIdentity for this builder.
Definition hello-uri.c:354
#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_UNUSED
gcc-ism to document unused arguments
#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_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#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.
#define GNUNET_MESSENGER_SERVICE_NAME
Identifier of GNUnet MESSENGER Service.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition scheduler.c:1345
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
void GNUNET_SERVICE_shutdown(struct GNUNET_SERVICE_Handle *sh)
Explicitly stops the service.
Definition service.c:2512
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void clear_contact_store(struct GNUNET_MESSENGER_ContactStore *store)
Clears a contact store, wipes its content and deallocates its memory.
void init_contact_store(struct GNUNET_MESSENGER_ContactStore *store)
Initializes a contact store as fully empty.
const struct GNUNET_CRYPTO_BlindablePublicKey * get_anonymous_public_key(void)
Returns the public identity key of GNUNET_IDENTITY_ego_get_anonymous() without recalculating it every...
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
An identity key as per LSD0001.
Context for parsing HELLOs.
Definition hello-uri.c:233
A 512-bit hashcode.
struct GNUNET_MESSENGER_ListHandle * next
struct GNUNET_MESSENGER_SrvHandle * handle
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_SrvHandle * sync
struct GNUNET_MESSENGER_SrvHandle * host
Handle to a message queue.
Definition mq.c:87
The identity of the host (wraps the signing key of the peer).
Handle to a service.
Definition service.c:116
A 256-bit hashcode.
const struct GNUNET_CRYPTO_BlindablePublicKey * pubkey
struct GNUNET_MESSENGER_SrvHandle * handle
struct GNUNET_MESSENGER_SrvRoom * room