GNUnet 0.22.0
gnunet-service-messenger_service.c File Reference
Include dependency graph for gnunet-service-messenger_service.c:

Go to the source code of this file.

Data Structures

struct  HandleInitializationClosure
 

Functions

static void callback_shutdown_service (void *cls)
 
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. More...
 
static enum GNUNET_GenericReturnValue iterate_destroy_rooms (void *cls, const struct GNUNET_HashCode *key, void *value)
 
void destroy_service (struct GNUNET_MESSENGER_Service *service)
 Destroys a service and frees its memory fully. More...
 
struct GNUNET_MESSENGER_ContactStoreget_service_contact_store (struct GNUNET_MESSENGER_Service *service)
 Returns the used contact store of a given service. More...
 
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. More...
 
void remove_service_handle (struct GNUNET_MESSENGER_Service *service, struct GNUNET_MESSENGER_SrvHandle *handle)
 Removes a handle from a service and destroys it. More...
 
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. More...
 
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. More...
 
static enum GNUNET_GenericReturnValue find_member_session_in_room (void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
 
static void initialize_service_handle (struct GNUNET_MESSENGER_SrvHandle *handle, struct GNUNET_MESSENGER_SrvRoom *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. More...
 
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. More...
 
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. More...
 
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)
 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. More...
 

Function Documentation

◆ callback_shutdown_service()

static void callback_shutdown_service ( void *  cls)
static

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

36{
38
39 service = cls;
40
41 if (service)
42 {
43 service->shutdown = NULL;
44
46 }
47}
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
void destroy_service(struct GNUNET_MESSENGER_Service *service)
Destroys a service and frees its memory fully.

References destroy_service(), and service.

Referenced by create_service().

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

◆ 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 51 of file gnunet-service-messenger_service.c.

53{
55
56 GNUNET_assert ((config) && (service_handle));
57
59
60 service->config = config;
61 service->service = service_handle;
62
64 service);
65
66 service->peer = NULL;
67 service->dir = NULL;
68
71 "MESSENGER_DIR",
72 &(service->dir)))
73 {
74 if (service->dir)
75 GNUNET_free (service->dir);
76
77 service->dir = NULL;
78 }
79 else
80 {
83 !=
85 {
86 GNUNET_free (service->dir);
87
88 service->dir = NULL;
89 }
90 }
91
93 service->config,
95 "MESSENGER_AUTO_CONNECTING");
96
99 "MESSENGER_AUTO_ROUTING");
100
103 "MESSENGER_MIN_ROUTERS",
104 &(service->min_routers)))
105 service->min_routers = 0;
106
107 service->cadet = GNUNET_CADET_connect (service->config);
108
109 init_list_handles (&(service->handles));
110
112
114
115 return service;
116}
const struct GNUNET_CONFIGURATION_Handle * config
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_shutdown_service(void *cls)
struct GNUNET_CADET_Handle * GNUNET_CADET_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the MQ-based cadet service.
Definition: cadet_api.c:894
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:404
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition: disk.c:497
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_OK
@ GNUNET_YES
@ 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.
#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:1338
void init_contact_store(struct GNUNET_MESSENGER_ContactStore *store)
Initializes a contact store as fully empty.

References 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_free, GNUNET_MESSENGER_SERVICE_NAME, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), 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:

◆ iterate_destroy_rooms()

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

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

123{
124 struct GNUNET_MESSENGER_SrvRoom *room;
125
127
128 room = value;
129
131 return GNUNET_YES;
132}
static char * value
Value of the record to add/remove.
void destroy_srv_room(struct GNUNET_MESSENGER_SrvRoom *room, enum GNUNET_GenericReturnValue deletion)
Destroys a room and frees its memory fully.

References destroy_srv_room(), GNUNET_assert, GNUNET_NO, GNUNET_YES, and value.

Referenced by destroy_service().

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 136 of file gnunet-service-messenger_service.c.

137{
139
140 if (service->shutdown)
141 {
143
144 service->shutdown = NULL;
145 }
146
147 clear_list_handles (&(service->handles));
148
150 NULL);
152
154
155 if (service->cadet)
156 {
158
159 service->cadet = NULL;
160 }
161
162 if (service->dir)
163 {
164 GNUNET_free (service->dir);
165
166 service->dir = NULL;
167 }
168
169 if (service->peer)
170 {
171 GNUNET_free (service->peer);
172
173 service->peer = NULL;
174 }
175
177
179}
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_CADET_disconnect(struct GNUNET_CADET_Handle *handle)
Disconnect from the cadet service.
Definition: cadet_api.c:774
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:979
void GNUNET_SERVICE_shutdown(struct GNUNET_SERVICE_Handle *sh)
Explicitly stops the service.
Definition: service.c:2426
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_free, GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_shutdown(), 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 183 of file gnunet-service-messenger_service.c.

184{
186
187 return &(service->contact_store);
188}

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 192 of file gnunet-service-messenger_service.c.

194{
196
197 GNUNET_assert ((service) && (mq));
198
200
201 if (handle)
202 add_list_handle (&(service->handles), handle);
203
204 return handle;
205}
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
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

References add_list_handle(), create_srv_handle(), GNUNET_assert, 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 209 of file gnunet-service-messenger_service.c.

211{
213
214 if (! handle)
215 return;
216
217 if (GNUNET_YES == remove_list_handle (&(service->handles), handle))
219}
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_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 223 of file gnunet-service-messenger_service.c.

225{
227
228 GNUNET_assert ((service) && (peer));
229
230 if (service->peer)
231 {
232 GNUNET_memcpy (peer, service->peer, sizeof(struct GNUNET_PeerIdentity));
233 return GNUNET_OK;
234 }
235
237
238 if (GNUNET_OK != result)
239 return result;
240
241 if (! service->peer)
242 service->peer = GNUNET_new (struct GNUNET_PeerIdentity);
243
244 GNUNET_memcpy (service->peer, peer, sizeof(struct GNUNET_PeerIdentity));
245 return result;
246}
static int result
Global testing status.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_PeerIdentity *dst)
Retrieve the identity of the host's peer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
The identity of the host (wraps the signing key of the peer).

References GNUNET_assert, GNUNET_CRYPTO_get_peer_identity(), GNUNET_memcpy, GNUNET_new, GNUNET_OK, result, and service.

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

Here is the call graph for this function:
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 250 of file gnunet-service-messenger_service.c.

252{
253 GNUNET_assert ((service) && (key));
254
256}
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(), open_service_room(), send_srv_handle_message(), and sync_srv_handle_messages().

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

◆ find_member_session_in_room()

static enum GNUNET_GenericReturnValue find_member_session_in_room ( void *  cls,
const struct GNUNET_CRYPTO_PublicKey public_key,
struct GNUNET_MESSENGER_MemberSession session 
)
static

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

270{
272 const struct GNUNET_ShortHashCode *id;
273
274 GNUNET_assert ((cls) && (session));
275
276 init = cls;
277
278 if (! public_key)
279 return GNUNET_YES;
280
281 {
282 const struct GNUNET_CRYPTO_PublicKey *pubkey;
283 pubkey = get_srv_handle_key (init->handle);
284
285 if (0 != GNUNET_memcmp (pubkey, public_key))
286 return GNUNET_YES;
287 }
288
289 id = get_member_session_id (session);
290
291 if (! id)
292 {
293 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initialitation: Missing member id!");
294 return GNUNET_NO;
295 }
296
298 "Initialitation: Matching member found (%s)!\n",
299 GNUNET_sh2s (id));
300
302 return GNUNET_NO;
303}
static char * init
Set to the name of a service to start.
Definition: gnunet-arm.c:73
static struct GNUNET_CRYPTO_PublicKey pubkey
Public key of the zone to look in.
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
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_PublicKey * get_srv_handle_key(const struct GNUNET_MESSENGER_SrvHandle *handle)
Returns the public key of a given handle.
const struct GNUNET_ShortHashCode * get_member_session_id(const struct GNUNET_MESSENGER_MemberSession *session)
Returns the member id of a given member session.
const struct GNUNET_HashCode * get_srv_room_key(const struct GNUNET_MESSENGER_SrvRoom *room)
Returns the shared secret you need to access a room.
#define GNUNET_log(kind,...)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
An identity key as per LSD0001.
A 256-bit hashcode.

References change_srv_handle_member_id(), get_member_session_id(), get_srv_handle_key(), get_srv_room_key(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_sh2s(), GNUNET_YES, id, init, and pubkey.

Referenced by initialize_service_handle().

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

◆ initialize_service_handle()

static void initialize_service_handle ( struct GNUNET_MESSENGER_SrvHandle handle,
struct GNUNET_MESSENGER_SrvRoom room 
)
static

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

309{
310 struct GNUNET_MESSENGER_MemberStore *store;
311 const struct GNUNET_CRYPTO_PublicKey *pubkey;
312
313 GNUNET_assert ((handle) && (room));
314
315 store = get_srv_room_member_store (room);
316 if (! store)
317 return;
318
320 if ((! pubkey) || (0 == GNUNET_memcmp (pubkey, get_anonymous_public_key ())))
321 return;
322
324 "Initialize member id of handle via matching member in room!\n");
325
326 {
328 init.handle = handle;
329 init.room = room;
330 init.pubkey = pubkey;
331
333 }
334}
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_MemberStore * get_srv_room_member_store(struct GNUNET_MESSENGER_SrvRoom *room)
Returns the used member store of a given room.
static enum GNUNET_GenericReturnValue find_member_session_in_room(void *cls, const struct GNUNET_CRYPTO_PublicKey *public_key, struct GNUNET_MESSENGER_MemberSession *session)
const struct GNUNET_CRYPTO_PublicKey * get_anonymous_public_key(void)
Returns the public identity key of GNUNET_IDENTITY_ego_get_anonymous() without recalculating it every...
struct GNUNET_MESSENGER_SrvRoom * room

References find_member_session_in_room(), get_anonymous_public_key(), get_srv_handle_key(), get_srv_room_member_store(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcmp, handle, init, iterate_store_members(), pubkey, and HandleInitializationClosure::room.

Referenced by entry_service_room(), and open_service_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 338 of file gnunet-service-messenger_service.c.

341{
342 struct GNUNET_MESSENGER_SrvRoom *room;
343
344 GNUNET_assert ((service) && (handle) && (key));
345
346 room = get_service_room (service, key);
347
348 if (room)
349 {
351 return open_srv_room (room, handle);
352 }
353
354 room = create_srv_room (handle, key);
356
357 if ((GNUNET_YES == open_srv_room (room, handle)) &&
359 key, room,
361 return GNUNET_YES;
362
364 return GNUNET_NO;
365}
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.
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...

References create_srv_room(), destroy_srv_room(), get_service_room(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle, initialize_service_handle(), key, open_srv_room(), 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 369 of file gnunet-service-messenger_service.c.

373{
374 struct GNUNET_MESSENGER_SrvRoom *room;
375
376 GNUNET_assert ((service) && (handle) && (door) && (key));
377
378 room = get_service_room (service, key);
379
380 if (room)
381 {
383
384 if (GNUNET_YES == enter_srv_room_at (room, handle, door))
385 return GNUNET_YES;
386 else
387 return GNUNET_NO;
388 }
389
390 room = create_srv_room (handle, key);
392
393 if ((GNUNET_YES == enter_srv_room_at (room, handle, door)) &&
395 key, room,
397 {
398 return GNUNET_YES;
399 }
400 else
401 {
403 return GNUNET_NO;
404 }
405
406}
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_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_NO, GNUNET_OK, 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 410 of file gnunet-service-messenger_service.c.

414{
415 struct GNUNET_MESSENGER_SrvRoom *room;
416 struct GNUNET_MESSENGER_SrvHandle *member_handle;
417
418 GNUNET_assert ((service) && (handle) && (key));
419
420 room = get_service_room (service, key);
421
422 if (! room)
423 return GNUNET_NO;
424
425 {
426 struct GNUNET_ShortHashCode *id;
427 id = (struct GNUNET_ShortHashCode*) (
429
430 GNUNET_assert (id);
431
433 key, id))
434 return GNUNET_NO;
435
436 GNUNET_free (id);
437 }
438
439 member_handle = (struct GNUNET_MESSENGER_SrvHandle*) (
440 find_list_handle_by_member (&(service->handles), key));
441
442 if (! member_handle)
443 {
445 room))
446 {
447 destroy_srv_room (room, deletion);
448 return GNUNET_YES;
449 }
450 else
451 return GNUNET_NO;
452 }
453
454 if (room->host == handle)
455 {
456 room->host = member_handle;
457
458 if (room->peer_message)
460 room));
461 }
462
463 return GNUNET_YES;
464}
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.
struct GNUNET_HashCode * peer_message
struct GNUNET_MESSENGER_SrvHandle * host

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_free, GNUNET_NO, GNUNET_OK, GNUNET_YES, handle, GNUNET_MESSENGER_SrvRoom::host, id, key, GNUNET_MESSENGER_SrvRoom::peer_message, send_srv_room_message(), and service.

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 
)

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

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

473{
474 struct GNUNET_MESSENGER_ListHandle *element;
475
476 GNUNET_assert ((service) && (room) && (session) && (message) && (hash));
477
479 "Notify active clients about message: %s (%s)\n",
481 message->header.kind));
482
483 element = service->handles.head;
484
485 while (element)
486 {
487 notify_srv_handle_message (element->handle, room, session, message, hash,
488 GNUNET_YES);
489 element = element->next;
490 }
491}
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.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
const char * GNUNET_MESSENGER_name_of_kind(enum GNUNET_MESSENGER_MessageKind kind)
Get the name of a message kind.
Definition: messenger_api.c:44
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 GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSENGER_name_of_kind(), GNUNET_YES, GNUNET_MESSENGER_ListHandle::handle, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ListHandle::next, notify_srv_handle_message(), and service.

Referenced by handle_room_messages().

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