GNUnet 0.22.2
gnunet-service-messenger_member.h File Reference
Include dependency graph for gnunet-service-messenger_member.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_Member
 

Typedefs

typedef enum GNUNET_GenericReturnValue(* GNUNET_MESSENGER_SubscriptionIteratorCallback) (void *cls, const struct GNUNET_ShortHashCode *discourse, struct GNUNET_MESSENGER_Subscription *subscribtion)
 

Functions

struct GNUNET_MESSENGER_Membercreate_member (struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
 Creates and allocates a new member of a room with an optionally defined or random id. More...
 
void destroy_member (struct GNUNET_MESSENGER_Member *member)
 Destroys a member and frees its memory fully. More...
 
const struct GNUNET_ShortHashCodeget_member_id (const struct GNUNET_MESSENGER_Member *member)
 Returns the current id of a given member. More...
 
void load_member (struct GNUNET_MESSENGER_MemberStore *store, const char *directory)
 Loads data from a directory into a new allocated and created member of a store if the required information can be read from the content of the given directory. More...
 
void load_member_next_sessions (const struct GNUNET_MESSENGER_Member *member, const char *directory)
 Loads data about next sessions from a directory into an empty loaded member which does not contain a fully built session graph yet. More...
 
void save_member (struct GNUNET_MESSENGER_Member *member, const char *directory)
 Saves data from a member into a directory which can be load to restore the member completely. More...
 
void sync_member_contacts (struct GNUNET_MESSENGER_Member *member)
 Synchronizes contacts between all sessions from a given member and other sessions which are linked to them. More...
 
struct GNUNET_MESSENGER_MemberSessionget_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. More...
 
struct GNUNET_MESSENGER_MemberSessionget_member_session_of (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Returns the member session of a member using a public key which can verify the signature of a given message and its hash. More...
 
void add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
 Adds a given member session to its member. More...
 
void remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
 Removes a given member session from its member. More...
 
int iterate_member_sessions (struct GNUNET_MESSENGER_Member *member, GNUNET_MESSENGER_MemberIteratorCallback it, void *cls)
 Iterate through all member sessions currently connected to a given member and call the provided iterator callback with a selected closure. More...
 
void add_member_subscription (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_Subscription *subscription)
 Adds a given subscription to a member. More...
 
void remove_member_subscription (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_Subscription *subscription)
 Removes a given subscription from a member. More...
 
struct GNUNET_MESSENGER_Subscriptionget_member_subscription (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_ShortHashCode *discourse)
 Returns the active subscription of a given member to a selected discourse. More...
 
int iterate_member_subscriptions (struct GNUNET_MESSENGER_Member *member, GNUNET_MESSENGER_SubscriptionIteratorCallback it, void *cls)
 Iterate through all subscriptions of a given member and call the provided iterator callback with a selected closure. More...
 

Typedef Documentation

◆ GNUNET_MESSENGER_SubscriptionIteratorCallback

typedef enum GNUNET_GenericReturnValue(* GNUNET_MESSENGER_SubscriptionIteratorCallback) (void *cls, const struct GNUNET_ShortHashCode *discourse, struct GNUNET_MESSENGER_Subscription *subscribtion)

Definition at line 1 of file gnunet-service-messenger_member.h.

Function Documentation

◆ create_member()

struct GNUNET_MESSENGER_Member * create_member ( struct GNUNET_MESSENGER_MemberStore store,
const struct GNUNET_ShortHashCode id 
)

Creates and allocates a new member of a room with an optionally defined or random id.

If the creation fails, NULL gets returned.

Parameters
[in,out]storeMember store
[in]idMember id or NULL
Returns
New member or NULL

Definition at line 34 of file gnunet-service-messenger_member.c.

36{
37 struct GNUNET_MESSENGER_Member *member;
38
40
41 member = GNUNET_new (struct GNUNET_MESSENGER_Member);
42 member->store = store;
43
44 if (id)
45 GNUNET_memcpy (&(member->id), id, sizeof(member->id));
46 else if (GNUNET_YES != generate_free_member_id (&(member->id),
47 store->members))
48 {
49 GNUNET_free (member);
50 return NULL;
51 }
52
55
56 return member;
57}
struct GNUNET_CONTAINER_MultiShortmap * GNUNET_CONTAINER_multishortmap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ 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.
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.
struct GNUNET_CONTAINER_MultiShortmap * members
struct GNUNET_CONTAINER_MultiHashMap * sessions
struct GNUNET_CONTAINER_MultiShortmap * subscriptions
struct GNUNET_MESSENGER_MemberStore * store
struct GNUNET_ShortHashCode id

References generate_free_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_free, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_Member::id, GNUNET_MESSENGER_MemberStore::members, GNUNET_MESSENGER_Member::sessions, GNUNET_MESSENGER_Member::store, and GNUNET_MESSENGER_Member::subscriptions.

Referenced by add_store_member().

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

◆ destroy_member()

void destroy_member ( struct GNUNET_MESSENGER_Member member)

Destroys a member and frees its memory fully.

Parameters
[in,out]memberMember

Definition at line 93 of file gnunet-service-messenger_member.c.

94{
95 GNUNET_assert ((member) && (member->sessions));
96
101
104
105 GNUNET_free (member);
106}
static enum GNUNET_GenericReturnValue iterate_destroy_subscription(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_destroy_session(void *cls, const struct GNUNET_HashCode *key, void *value)
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, iterate_destroy_session(), iterate_destroy_subscription(), GNUNET_MESSENGER_Subscription::member, GNUNET_MESSENGER_Member::sessions, and GNUNET_MESSENGER_Member::subscriptions.

Referenced by add_store_member(), and iterate_destroy_members().

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

◆ get_member_id()

const struct GNUNET_ShortHashCode * get_member_id ( const struct GNUNET_MESSENGER_Member member)

Returns the current id of a given member.

Parameters
[in]memberMember
Returns
Member id

Definition at line 110 of file gnunet-service-messenger_member.c.

111{
112 GNUNET_assert (member);
113
114 return &(member->id);
115}

References GNUNET_assert, and GNUNET_MESSENGER_Member::id.

Referenced by add_store_member(), get_member_session_id(), and join_room().

Here is the caller graph for this function:

◆ load_member()

void load_member ( struct GNUNET_MESSENGER_MemberStore store,
const char *  directory 
)

Loads data from a directory into a new allocated and created member of a store if the required information can be read from the content of the given directory.

Parameters
[out]storeMember store
[in]directoryPath to a directory

Definition at line 143 of file gnunet-service-messenger_member.c.

145{
147 struct GNUNET_MESSENGER_Member *member;
148 char *config_file;
149
150 GNUNET_assert ((store) && (directory));
151
152 GNUNET_asprintf (&config_file, "%s%s", directory, "member.cfg");
153
154 member = NULL;
155
157 goto free_config;
158
159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load member configuration: %s\n",
161
163
164 if (! cfg)
165 goto free_config;
166
168 {
170
171 if (GNUNET_OK != GNUNET_CONFIGURATION_get_data (cfg, "member", "id", &id,
172 sizeof(id)))
173 goto destroy_config;
174
175 member = add_store_member (store, &id);
176 }
177
178destroy_config:
180
181free_config:
183
184 if (! member)
185 return;
186
187 {
188 char *scan_dir;
189 GNUNET_asprintf (&scan_dir, "%s%s%c", directory, "sessions", DIR_SEPARATOR);
190
193
195 }
196}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static char * config_file
Set to the name of the config file used.
Definition: gnunet-arm.c:83
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
static enum GNUNET_GenericReturnValue callback_scan_for_sessions(void *cls, const char *filename)
struct GNUNET_MESSENGER_Member * add_store_member(struct GNUNET_MESSENGER_MemberStore *store, const struct GNUNET_ShortHashCode *id)
Adds a member to a store under a specific id and returns it on success.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_data(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, void *buf, size_t buf_size)
Get Crockford32-encoded fixed-size binary data from a configuration.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(const struct GNUNET_OS_ProjectData *pd)
Create a new configuration object.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Parse a configuration file, add all of the options in the file to the configuration environment.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
Definition: disk.c:506
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition: disk.c:427
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition: disk.c:811
#define GNUNET_log(kind,...)
@ GNUNET_OK
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
#define DIR_SEPARATOR
Definition: platform.h:165
A 256-bit hashcode.

References add_store_member(), callback_scan_for_sessions(), cfg, config_file, DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_get_data(), GNUNET_CONFIGURATION_parse(), GNUNET_DISK_directory_scan(), GNUNET_DISK_directory_test(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_YES, id, find_typedefs::scan_dir(), and GNUNET_MESSENGER_Member::store.

Referenced by callback_scan_for_members().

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

◆ load_member_next_sessions()

void load_member_next_sessions ( const struct GNUNET_MESSENGER_Member member,
const char *  directory 
)

Loads data about next sessions from a directory into an empty loaded member which does not contain a fully built session graph yet.

Parameters
[in,out]memberMember
[in]directoryPath to a directory

Definition at line 231 of file gnunet-service-messenger_member.c.

233{
234 char *load_dir;
235
236 GNUNET_assert ((member) && (directory));
237
238 GNUNET_asprintf (&load_dir, "%s%s%c", directory, "sessions", DIR_SEPARATOR);
239
241 iterate_load_next_session, load_dir);
242
243 GNUNET_free (load_dir);
244}
static enum GNUNET_GenericReturnValue iterate_load_next_session(void *cls, const struct GNUNET_HashCode *key, void *value)

References DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, iterate_load_next_session(), GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_Member::sessions.

Referenced by iterate_load_next_member_sessions().

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

◆ save_member()

void save_member ( struct GNUNET_MESSENGER_Member member,
const char *  directory 
)

Saves data from a member into a directory which can be load to restore the member completely.

Parameters
[in]memberMember
[in]directoryPath to a directory

Definition at line 280 of file gnunet-service-messenger_member.c.

282{
284 char *config_file;
285 char *id_data;
286
287 GNUNET_assert ((member) && (directory));
288
289 GNUNET_asprintf (&config_file, "%s%s", directory, "member.cfg");
290
291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save member configuration: %s\n",
293
295
296 if (! cfg)
297 goto free_config;
298
299 id_data = GNUNET_STRINGS_data_to_string_alloc (&(member->id),
300 sizeof(member->id));
301
302 if (id_data)
303 {
304 GNUNET_CONFIGURATION_set_value_string (cfg, "member", "id", id_data);
305
306 GNUNET_free (id_data);
307 }
308
311
312free_config:
314
315 {
316 char *save_dir;
317 GNUNET_asprintf (&save_dir, "%s%s%c", directory, "sessions", DIR_SEPARATOR);
318
319 if ((GNUNET_YES == GNUNET_DISK_directory_test (save_dir, GNUNET_NO)) ||
322 iterate_save_session, save_dir);
323
324 GNUNET_free (save_dir);
325 }
326}
static enum GNUNET_GenericReturnValue iterate_save_session(void *cls, const struct GNUNET_HashCode *key, void *value)
void GNUNET_CONFIGURATION_set_value_string(struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, const char *value)
Set a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition: disk.c:520
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:787

References cfg, config_file, DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONFIGURATION_write(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_STRINGS_data_to_string_alloc(), GNUNET_YES, GNUNET_MESSENGER_Member::id, iterate_save_session(), and GNUNET_MESSENGER_Member::sessions.

Referenced by iterate_save_members().

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

◆ sync_member_contacts()

void sync_member_contacts ( struct GNUNET_MESSENGER_Member member)

Synchronizes contacts between all sessions from a given member and other sessions which are linked to them.

Parameters
[in,out]memberMember

Definition at line 364 of file gnunet-service-messenger_member.c.

365{
366 GNUNET_assert ((member) && (member->sessions));
367
370}
static enum GNUNET_GenericReturnValue iterate_sync_session_contact(void *cls, const struct GNUNET_HashCode *key, void *value)

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), iterate_sync_session_contact(), GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_Member::sessions.

Referenced by iterate_sync_member_contacts().

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

◆ get_member_session()

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.

If the member does not provide a session with the given key, NULL gets returned.

Parameters
[in]memberMember
[in]public_keyPublic key
Returns
Member session

Definition at line 374 of file gnunet-service-messenger_member.c.

376{
377 struct GNUNET_HashCode hash;
378
379 GNUNET_assert ((member) && (public_key));
380
381 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
382
383 return GNUNET_CONTAINER_multihashmap_get (member->sessions, &hash);
384}
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
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.
A 512-bit hashcode.

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CRYPTO_hash(), and GNUNET_MESSENGER_Member::sessions.

Referenced by get_handle_member_session(), handle_get_message(), load_member_session_next(), solve_srv_room_member_collisions(), and try_member_session().

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

◆ get_member_session_of()

struct GNUNET_MESSENGER_MemberSession * get_member_session_of ( struct GNUNET_MESSENGER_Member member,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Returns the member session of a member using a public key which can verify the signature of a given message and its hash.

If the member does not provide a matching session, NULL gets returned.

Parameters
[in]memberMember
[in]messageMessage
[in]hashHash of message
Returns
Member session

Definition at line 440 of file gnunet-service-messenger_member.c.

443{
444 GNUNET_assert ((member) && (message) && (hash) &&
445 (0 == GNUNET_memcmp (&(member->id),
446 &(message->header.sender_id))));
447
448 if (GNUNET_MESSENGER_KIND_JOIN == message->header.kind)
449 return try_member_session (member, &(message->body.join.key));
450
451 {
453
454 search.message = message;
455 search.hash = hash;
456
457 search.match = NULL;
459 iterate_search_session, &search);
460
461 return search.match;
462 }
463}
static struct GNUNET_MESSENGER_MemberSession * try_member_session(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *public_key)
static enum GNUNET_GenericReturnValue iterate_search_session(void *cls, const struct GNUNET_HashCode *key, void *value)
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
const struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_MessageJoin join
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_ShortHashCode sender_id
The senders id inside of the room the message was sent in.
struct GNUNET_CRYPTO_PublicKey key
The senders public key to verify its signatures.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_memcmp, GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_ClosureSearchSession::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_Member::id, iterate_search_session(), GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageJoin::key, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ClosureSearchSession::match, GNUNET_MESSENGER_MemberSession::member, GNUNET_MESSENGER_ClosureSearchSession::message, GNUNET_MESSENGER_MessageHeader::sender_id, GNUNET_MESSENGER_Member::sessions, and try_member_session().

Referenced by callback_found_message(), callback_room_handle_message(), handle_room_messages(), recv_message_request(), and send_message_join().

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

◆ add_member_session()

void add_member_session ( struct GNUNET_MESSENGER_Member member,
struct GNUNET_MESSENGER_MemberSession session 
)

Adds a given member session to its member.

Parameters
[in,out]memberMember
[in,out]sessionMember session

Definition at line 467 of file gnunet-service-messenger_member.c.

469{
470 const struct GNUNET_CRYPTO_PublicKey *public_key;
471 struct GNUNET_HashCode hash;
472
473 if (! session)
474 return;
475
476 GNUNET_assert ((member) && (session->member == member));
477
478 public_key = get_member_session_public_key (session);
479 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
480
482 member->sessions, &hash, session,
485 "Adding a member session failed: %s\n",
486 GNUNET_h2s (&hash));
487}
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.
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...
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_WARNING
An identity key as per LSD0001.

References get_member_session_public_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_OK, GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_Member::sessions.

Referenced by handle_member_session_switch(), load_member_session(), and try_member_session().

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

◆ remove_member_session()

void remove_member_session ( struct GNUNET_MESSENGER_Member member,
struct GNUNET_MESSENGER_MemberSession session 
)

Removes a given member session from its member.

Parameters
[in,out]memberMember
[in,out]sessionMember session

Definition at line 491 of file gnunet-service-messenger_member.c.

493{
494 const struct GNUNET_CRYPTO_PublicKey *public_key;
495 struct GNUNET_HashCode hash;
496
497 GNUNET_assert ((member) && (session) && (session->member == member));
498
499 public_key = get_member_session_public_key (session);
500 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
501
503 &hash, session))
505 "Removing a member session failed: %s\n",
506 GNUNET_h2s (&hash));
507}
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.

References get_member_session_public_key(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_WARNING, GNUNET_h2s(), GNUNET_log, GNUNET_YES, GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_Member::sessions.

Referenced by remove_room_member_session().

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

◆ iterate_member_sessions()

int iterate_member_sessions ( struct GNUNET_MESSENGER_Member member,
GNUNET_MESSENGER_MemberIteratorCallback  it,
void *  cls 
)

Iterate through all member sessions currently connected to a given member and call the provided iterator callback with a selected closure.

The function will return the amount of member sessions it iterated through.

Parameters
[in,out]memberMember
[in]itIterator callback
[in,out]clsClosure
Returns
Amount of sessions iterated through

Definition at line 535 of file gnunet-service-messenger_member.c.

538{
540
541 GNUNET_assert ((member) && (member->sessions) && (it));
542
543 iterate.it = it;
544 iterate.cls = cls;
545
548 &iterate);
549}
static enum GNUNET_GenericReturnValue iterate_member_sessions_it(void *cls, const struct GNUNET_HashCode *key, void *value)
GNUNET_MESSENGER_MemberIteratorCallback it

References GNUNET_MESSENGER_ClosureIterateSessions::cls, GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_MESSENGER_ClosureIterateSessions::it, iterate_member_sessions_it(), and GNUNET_MESSENGER_Member::sessions.

Referenced by iterate_store_members_it().

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

◆ add_member_subscription()

void add_member_subscription ( struct GNUNET_MESSENGER_Member member,
struct GNUNET_MESSENGER_Subscription subscription 
)

Adds a given subscription to a member.

Parameters
[in,out]memberMember
[in,out]subscriptionSubscription

Definition at line 553 of file gnunet-service-messenger_member.c.

555{
556 const struct GNUNET_ShortHashCode *discourse;
557
558 GNUNET_assert ((member) && (member->subscriptions) && (subscription));
559
560 discourse = get_subscription_discourse (subscription);
561
563 member->subscriptions, discourse, subscription,
566 "Adding a member subscription failed: %s\n",
567 GNUNET_sh2s (discourse));
568}
const struct GNUNET_ShortHashCode * get_subscription_discourse(const struct GNUNET_MESSENGER_Subscription *subscribtion)
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_put(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
const char * GNUNET_sh2s(const struct GNUNET_ShortHashCode *shc)
Convert a short hash value to a string (for printing debug messages).

References get_subscription_discourse(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_put(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_OK, GNUNET_sh2s(), and GNUNET_MESSENGER_Member::subscriptions.

Referenced by handle_message_subscribe().

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

◆ remove_member_subscription()

void remove_member_subscription ( struct GNUNET_MESSENGER_Member member,
struct GNUNET_MESSENGER_Subscription subscription 
)

Removes a given subscription from a member.

Parameters
[in,out]memberMember
[in,out]subscriptionSubscription

Definition at line 572 of file gnunet-service-messenger_member.c.

574{
575 const struct GNUNET_ShortHashCode *discourse;
576
577 GNUNET_assert ((member) && (member->subscriptions) && (subscription));
578
579 discourse = get_subscription_discourse (subscription);
580
582 ,
583 discourse,
584 subscription))
586 "Removing a member subscription failed: %s\n",
587 GNUNET_sh2s (discourse));
588}
int GNUNET_CONTAINER_multishortmap_remove(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, const void *value)
Remove the given key-value pair from the map.

References get_subscription_discourse(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_sh2s(), GNUNET_YES, and GNUNET_MESSENGER_Member::subscriptions.

Referenced by task_subscription_exit().

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

◆ get_member_subscription()

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.

Parameters
[in]memberMember
[in]discourseDiscourse
Returns
Subscription or NULL

Definition at line 592 of file gnunet-service-messenger_member.c.

594{
595 GNUNET_assert ((member) && (member->subscriptions) && (discourse));
596
597 return GNUNET_CONTAINER_multishortmap_get (member->subscriptions, discourse);
598}
void * GNUNET_CONTAINER_multishortmap_get(const struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key)
Given a key find a value in the map matching the key.

References GNUNET_MESSENGER_Subscription::discourse, GNUNET_assert, GNUNET_CONTAINER_multishortmap_get(), GNUNET_MESSENGER_Subscription::member, and GNUNET_MESSENGER_Member::subscriptions.

Referenced by handle_message_subscribe(), iterate_member_for_subscription(), and notify_srv_handle_message().

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

◆ iterate_member_subscriptions()

int iterate_member_subscriptions ( struct GNUNET_MESSENGER_Member member,
GNUNET_MESSENGER_SubscriptionIteratorCallback  it,
void *  cls 
)

Iterate through all subscriptions of a given member and call the provided iterator callback with a selected closure.

The function will return the amount of subscriptions it iterated through.

Parameters
[in,out]memberMember
[in]itIterator callback
[in,out]clsClosure
Returns
Amount of subscriptions iterated through

Definition at line 602 of file gnunet-service-messenger_member.c.

605{
606 GNUNET_assert ((member) && (member->subscriptions) && (it));
607
609 (
611 it,
612 cls);
613}
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_ShortmapIterator)(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
Iterator over hash map entries.

References GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_MESSENGER_Subscription::member, and GNUNET_MESSENGER_Member::subscriptions.

Here is the call graph for this function: