GNUnet 0.27.0
 
Loading...
Searching...
No Matches
gnunet-service-messenger_service.h File Reference
Include dependency graph for gnunet-service-messenger_service.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_Service
 

Functions

struct GNUNET_MESSENGER_Servicecreate_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.
 
void destroy_service (struct GNUNET_MESSENGER_Service *service)
 Destroys a service and frees its memory fully.
 
struct GNUNET_MESSENGER_ContactStoreget_service_contact_store (struct GNUNET_MESSENGER_Service *service)
 Returns the used contact store of a given service.
 
struct GNUNET_MESSENGER_SrvHandleadd_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.
 
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_SrvRoomget_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 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.
 
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 member of a specific room for handling it in the client API.
 

Function Documentation

◆ create_service()

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.

Parameters
[in]configConfiguration
[in,out]service_handleGNUnet service handle
Returns
New service

Definition at line 159 of file gnunet-service-messenger_service.c.

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}
const struct GNUNET_CONFIGURATION_Handle * config
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
void init_list_handles(struct GNUNET_MESSENGER_ListHandles *handles)
Initializes list of handles as empty list.
struct GNUNET_MESSENGER_ContactStore * get_service_contact_store(struct GNUNET_MESSENGER_Service *service)
Returns the used contact store of a given service.
static void callback_peer_id_changed(void *cls, const struct GNUNET_HELLO_Parser *parser, const struct GNUNET_HashCode *hash)
static void callback_shutdown_service(void *cls)
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
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
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
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#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
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void init_contact_store(struct GNUNET_MESSENGER_ContactStore *store)
Initializes a contact store as fully empty.

References callback_peer_id_changed(), callback_shutdown_service(), config, get_service_contact_store(), GNUNET_assert, GNUNET_CADET_connect(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_number(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_CONTAINER_multihashmap_create(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_MESSENGER_SERVICE_NAME, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_PILS_connect(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_STATISTICS_create(), GNUNET_YES, init_contact_store(), init_list_handles(), and service.

Referenced by run().

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

◆ destroy_service()

void destroy_service ( struct GNUNET_MESSENGER_Service service)

Destroys a service and frees its memory fully.

Parameters
[in,out]serviceService

Definition at line 263 of file gnunet-service-messenger_service.c.

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}
void clear_list_handles(struct GNUNET_MESSENGER_ListHandles *handles)
Destroys remaining handles and clears the list.
static enum GNUNET_GenericReturnValue iterate_destroy_rooms(void *cls, const struct GNUNET_HashCode *key, void *value)
void GNUNET_PILS_disconnect(struct GNUNET_PILS_Handle *handle)
Disconnect from the PILS service.
Definition pils_api.c:488
void GNUNET_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition cadet_api.c:777
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
void GNUNET_SERVICE_shutdown(struct GNUNET_SERVICE_Handle *sh)
Explicitly stops the service.
Definition service.c:2512
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.

References clear_contact_store(), clear_list_handles(), get_service_contact_store(), GNUNET_assert, GNUNET_CADET_disconnect(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_PILS_disconnect(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_shutdown(), GNUNET_STATISTICS_destroy(), GNUNET_YES, iterate_destroy_rooms(), and service.

Referenced by callback_shutdown_service().

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

◆ get_service_contact_store()

struct GNUNET_MESSENGER_ContactStore * get_service_contact_store ( struct GNUNET_MESSENGER_Service service)

Returns the used contact store of a given service.

Parameters
[in,out]serviceService
Returns
Contact store

Definition at line 320 of file gnunet-service-messenger_service.c.

321{
323
324 return &(service->contact_store);
325}

References GNUNET_assert, and service.

Referenced by create_service(), destroy_service(), and get_member_contact_store().

Here is the caller graph for this function:

◆ add_service_handle()

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.

Parameters
[in,out]serviceService
[in,out]mqMessage queue
Returns
New handle

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

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}
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).
void add_list_handle(struct GNUNET_MESSENGER_ListHandles *handles, struct GNUNET_MESSENGER_SrvHandle *handle)
Adds a specific handle to the end of the list.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition gnunet-vpn.c:35
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.

References add_list_handle(), create_srv_handle(), GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_update(), handle, mq, and service.

Referenced by callback_client_connect().

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

◆ remove_service_handle()

void remove_service_handle ( struct GNUNET_MESSENGER_Service service,
struct GNUNET_MESSENGER_SrvHandle handle 
)

Removes a handle from a service and destroys it.

Parameters
[in,out]serviceService
[in,out]handleHandle

Definition at line 352 of file gnunet-service-messenger_service.c.

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}
void destroy_srv_handle(struct GNUNET_MESSENGER_SrvHandle *handle)
Destroys a handle and frees its memory fully.
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...

References destroy_srv_handle(), GNUNET_assert, GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_YES, handle, remove_list_handle(), and service.

Referenced by callback_client_disconnect().

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

◆ get_service_peer_identity()

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.

The functions returns GNUNET_OK on success, otherwise GNUNET_SYSERR.

Parameters
[in,out]serviceService
[out]peerPeer identity
Returns
GNUNET_OK on success, otherwise GNUNET_SYSERR

Definition at line 372 of file gnunet-service-messenger_service.c.

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}
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_SYSERR
@ GNUNET_ERROR_TYPE_ERROR

References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_SYSERR, and service.

Referenced by close_srv_room(), create_message_peer(), enter_srv_room_at(), get_store_service_peer_identity(), rebuild_srv_room_basement_structure(), sign_srv_room_message(), and sync_srv_handle_room().

Here is the caller graph for this function:

◆ get_service_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.

If the service doesn't know any room using the given key, NULL gets returned.

Parameters
[in]serviceService
[in]keyKey of room
Returns
Room or NULL

Definition at line 390 of file gnunet-service-messenger_service.c.

392{
393 GNUNET_assert ((service) && (key));
394
396}
struct GNUNET_HashCode key
The key used in the DHT.
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(), key, and service.

Referenced by close_service_room(), entry_service_room(), handle_get_message(), iterate_srv_handle_sync_finished(), open_service_room(), send_srv_handle_message(), and sync_srv_handle_room().

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

◆ open_service_room()

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.

The room will be created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO.

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

Definition at line 479 of file gnunet-service-messenger_service.c.

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}
static int result
Global testing status.
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 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.
static void initialize_service_handle(struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *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.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
GNUNET_GenericReturnValue
Named constants for return values.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.

References create_srv_room(), destroy_srv_room(), get_service_room(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, handle, initialize_service_handle(), key, open_srv_room(), result, and service.

Referenced by open_srv_handle_room().

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

◆ entry_service_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.

The room will be created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO.

The room will be entered through the peer identitied by the peer identity provided as door parameter and a new connection will be made.

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

Definition at line 528 of file gnunet-service-messenger_service.c.

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}
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...

References create_srv_room(), destroy_srv_room(), enter_srv_room_at(), get_service_room(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, handle, initialize_service_handle(), key, and service.

Referenced by entry_srv_handle_room().

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

◆ close_service_room()

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.

The room will be created if necessary. If the function is successful, it returns GNUNET_YES, otherwise GNUNET_NO.

If the specific handle is currently the host of the room for this service, a new handle which is a member will take its place. Otherwise the room will be destroyed for this service.

Parameters
[in,out]serviceService
[in,out]handleHandle
[in]keyKey of room
[in]deletionFlag to indicate context of closing
Returns
GNUNET_YES on success, otherwise GNUNET_NO

Definition at line 583 of file gnunet-service-messenger_service.c.

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}
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
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...
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...
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.
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.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
struct GNUNET_MESSENGER_SrvHandle * sync
struct GNUNET_MESSENGER_SrvHandle * host
A 256-bit hashcode.

References create_message_connection(), destroy_srv_room(), find_list_handle_by_member(), get_service_room(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_YES, handle, GNUNET_MESSENGER_SrvRoom::host, id, key, GNUNET_MESSENGER_SrvRoom::key, GNUNET_MESSENGER_SrvRoom::peer_message, send_srv_room_message(), service, and GNUNET_MESSENGER_SrvRoom::sync.

Referenced by close_srv_handle_room(), and iterate_close_rooms().

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

◆ handle_service_message()

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 member of a specific room for handling it in the client API.

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

Definition at line 669 of file gnunet-service-messenger_service.c.

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}
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.
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.
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
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.

References get_srv_handle_member_id(), get_srv_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_name_of_kind(), GNUNET_NO, GNUNET_STATISTICS_update(), GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ListHandle::next, notify_srv_handle_message(), and service.

Referenced by callback_found_message(), and handle_room_messages().

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