GNUnet debian-0.24.3-29-g453fda2cf
 
Loading...
Searching...
No Matches
gnunet-service-messenger_member.c File Reference
Include dependency graph for gnunet-service-messenger_member.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_ClosureSearchSession
 
struct  GNUNET_MESSENGER_ClosureIterateSessions
 

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.
 
static enum GNUNET_GenericReturnValue iterate_destroy_session (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static enum GNUNET_GenericReturnValue iterate_destroy_subscription (void *cls, const struct GNUNET_ShortHashCode *key, void *value)
 
void destroy_member (struct GNUNET_MESSENGER_Member *member)
 Destroys a member and frees its memory fully.
 
const struct GNUNET_ShortHashCodeget_member_id (const struct GNUNET_MESSENGER_Member *member)
 Returns the current id of a given member.
 
static enum GNUNET_GenericReturnValue callback_scan_for_sessions (void *cls, const char *filename)
 
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.
 
static enum GNUNET_GenericReturnValue iterate_load_next_session (void *cls, const struct GNUNET_HashCode *key, void *value)
 
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.
 
static enum GNUNET_GenericReturnValue iterate_save_session (void *cls, const struct GNUNET_HashCode *key, void *value)
 
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.
 
static void sync_session_contact_from_next (struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_MESSENGER_MemberSession *next)
 
static enum GNUNET_GenericReturnValue iterate_sync_session_contact (void *cls, const struct GNUNET_HashCode *key, void *value)
 
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.
 
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.
 
static enum GNUNET_GenericReturnValue iterate_search_session (void *cls, const struct GNUNET_HashCode *key, void *value)
 
static struct GNUNET_MESSENGER_MemberSessiontry_member_session (struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *public_key)
 
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.
 
void add_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
 Adds a given member session to its member.
 
void remove_member_session (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
 Removes a given member session from its member.
 
static enum GNUNET_GenericReturnValue iterate_member_sessions_it (void *cls, const struct GNUNET_HashCode *key, void *value)
 
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.
 
void add_member_subscription (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_Subscription *subscription)
 Adds a given subscription to a member.
 
void remove_member_subscription (struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_Subscription *subscription)
 Removes a given subscription from a member.
 
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.
 
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.
 

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 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Create new member: %s\n",
42 GNUNET_sh2s (id));
43
44 member = GNUNET_new (struct GNUNET_MESSENGER_Member);
45 member->store = store;
46
47 if (id)
48 GNUNET_memcpy (&(member->id), id, sizeof(member->id));
49 else if (GNUNET_YES != generate_free_member_id (&(member->id),
50 store->members))
51 {
52 GNUNET_free (member);
53 return NULL;
54 }
55
58
59 return member;
60}
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_log(kind,...)
#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.
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
#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

References generate_free_member_id(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_sh2s(), 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:

◆ iterate_destroy_session()

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

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

67{
68 struct GNUNET_MESSENGER_MemberSession *session;
69
71
72 session = value;
73
74 destroy_member_session (session);
75 return GNUNET_YES;
76}
static char * value
Value of the record to add/remove.
void destroy_member_session(struct GNUNET_MESSENGER_MemberSession *session)
Destroys a member session and frees its memory fully.

References destroy_member_session(), GNUNET_assert, GNUNET_YES, and value.

Referenced by destroy_member().

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

◆ iterate_destroy_subscription()

static enum GNUNET_GenericReturnValue iterate_destroy_subscription ( void *  cls,
const struct GNUNET_ShortHashCode key,
void *  value 
)
static

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

83{
84 struct GNUNET_MESSENGER_Subscription *subscription;
85
87
88 subscription = value;
89
90 destroy_subscription (subscription);
91 return GNUNET_YES;
92}
void destroy_subscription(struct GNUNET_MESSENGER_Subscription *subscription)

References destroy_subscription(), GNUNET_assert, GNUNET_YES, and value.

Referenced by destroy_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 96 of file gnunet-service-messenger_member.c.

97{
98 GNUNET_assert ((member) && (member->sessions));
99
104
107
108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Free member: %s\n",
109 GNUNET_sh2s (&(member->id)));
110
111 GNUNET_free (member);
112}
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_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_sh2s(), GNUNET_MESSENGER_Member::id, 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 116 of file gnunet-service-messenger_member.c.

117{
118 GNUNET_assert (member);
119
120 return &(member->id);
121}

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:

◆ callback_scan_for_sessions()

static enum GNUNET_GenericReturnValue callback_scan_for_sessions ( void *  cls,
const char *  filename 
)
static

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

127{
128 struct GNUNET_MESSENGER_Member *member;
129
130 GNUNET_assert ((cls) && (filename));
131
132 member = cls;
133
135 {
136 char *directory;
137
138 GNUNET_asprintf (&directory, "%s%c", filename, DIR_SEPARATOR);
139
140 load_member_session (member, directory);
141 GNUNET_free (directory);
142 }
143
144 return GNUNET_OK;
145}
static char * filename
void load_member_session(struct GNUNET_MESSENGER_Member *member, const char *directory)
Loads data from a directory into a new allocated and created member session of a member if the requir...
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition disk.c:454
@ GNUNET_OK
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define DIR_SEPARATOR
Definition platform.h:166

References DIR_SEPARATOR, filename, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_OK, GNUNET_YES, and load_member_session().

Referenced by load_member().

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

151{
153 struct GNUNET_MESSENGER_Member *member;
154 char *config_file;
155
156 GNUNET_assert ((store) && (directory));
157
158 GNUNET_asprintf (&config_file, "%s%s", directory, "member.cfg");
159
160 member = NULL;
161
163 goto free_config;
164
165 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load member configuration: %s\n",
167
169
170 if (! cfg)
171 goto free_config;
172
174 {
176
177 if (GNUNET_OK != GNUNET_CONFIGURATION_get_data (cfg, "member", "id", &id,
178 sizeof(id)))
179 goto destroy_config;
180
181 member = add_store_member (store, &id);
182 }
183
184destroy_config:
186
187free_config:
189
190 if (! member)
191 return;
192
193 {
194 char *scan_dir;
195 GNUNET_asprintf (&scan_dir, "%s%s%c", directory, "sessions", DIR_SEPARATOR);
196
199
200 GNUNET_free (scan_dir);
201 }
202}
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:533
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
Definition disk.c:839
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
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, 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:

◆ iterate_load_next_session()

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

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

209{
210 const char *sessions_directory;
211 char *load_dir;
212
213 GNUNET_assert ((cls) && (key));
214
215 sessions_directory = cls;
216
217 GNUNET_asprintf (&load_dir, "%s%s%c", sessions_directory, GNUNET_h2s (key),
219
220 {
221 struct GNUNET_MESSENGER_MemberSession *session;
222
224
225 session = value;
226
228 load_member_session_next (session, load_dir);
229 }
230
231 GNUNET_free (load_dir);
232 return GNUNET_YES;
233}
struct GNUNET_HashCode key
The key used in the DHT.
void load_member_session_next(struct GNUNET_MESSENGER_MemberSession *session, const char *directory)
Loads the connection from one session to another through the next attribute.
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).

References DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_h2s(), GNUNET_YES, key, load_member_session_next(), and value.

Referenced by load_member_next_sessions().

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 237 of file gnunet-service-messenger_member.c.

239{
240 char *load_dir;
241
242 GNUNET_assert ((member) && (directory));
243
244 GNUNET_asprintf (&load_dir, "%s%s%c", directory, "sessions", DIR_SEPARATOR);
245
247 iterate_load_next_session, load_dir);
248
249 GNUNET_free (load_dir);
250}
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:

◆ iterate_save_session()

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

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

257{
258 const char *sessions_directory;
259 char *save_dir;
260
261 GNUNET_assert ((cls) && (key));
262
263 sessions_directory = cls;
264
265 GNUNET_asprintf (&save_dir, "%s%s%c", sessions_directory, GNUNET_h2s (key),
267
268 {
269 struct GNUNET_MESSENGER_MemberSession *session;
270
272
273 session = value;
274
275 if ((GNUNET_YES == GNUNET_DISK_directory_test (save_dir, GNUNET_NO)) ||
277 save_member_session (session, save_dir);
278 }
279
280 GNUNET_free (save_dir);
281 return GNUNET_YES;
282}
void save_member_session(struct GNUNET_MESSENGER_MemberSession *session, const char *directory)
Saves data from a member session into a directory which can be load to restore the member session com...
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
Definition disk.c:547

References DIR_SEPARATOR, GNUNET_asprintf(), GNUNET_assert, GNUNET_DISK_directory_create(), GNUNET_DISK_directory_test(), GNUNET_free, GNUNET_h2s(), GNUNET_NO, GNUNET_OK, GNUNET_YES, key, save_member_session(), and value.

Referenced by save_member().

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 286 of file gnunet-service-messenger_member.c.

288{
290 char *config_file;
291 char *id_data;
292
293 GNUNET_assert ((member) && (directory));
294
295 GNUNET_asprintf (&config_file, "%s%s", directory, "member.cfg");
296
297 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save member configuration: %s\n",
299
301
302 if (! cfg)
303 goto free_config;
304
305 id_data = GNUNET_STRINGS_data_to_string_alloc (&(member->id),
306 sizeof(member->id));
307
308 if (id_data)
309 {
310 GNUNET_CONFIGURATION_set_value_string (cfg, "member", "id", id_data);
311
312 GNUNET_free (id_data);
313 }
314
317
318free_config:
320
321 {
322 char *save_dir;
323 GNUNET_asprintf (&save_dir, "%s%s%c", directory, "sessions", DIR_SEPARATOR);
324
325 if ((GNUNET_YES == GNUNET_DISK_directory_test (save_dir, GNUNET_NO)) ||
328 iterate_save_session, save_dir);
329
330 GNUNET_free (save_dir);
331 }
332}
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.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition strings.c:807

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_session_contact_from_next()

static void sync_session_contact_from_next ( struct GNUNET_MESSENGER_MemberSession session,
struct GNUNET_MESSENGER_MemberSession next 
)
static

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

338{
339 GNUNET_assert ((session) && (next));
340
341 if (session == next)
342 return;
343
344 if (next->next)
345 sync_session_contact_from_next (session, next->next);
346 else
347 session->contact = next->contact;
348}
static void sync_session_contact_from_next(struct GNUNET_MESSENGER_MemberSession *session, struct GNUNET_MESSENGER_MemberSession *next)
struct GNUNET_MESSENGER_MemberSession * next

References GNUNET_MESSENGER_MemberSession::contact, GNUNET_assert, GNUNET_MESSENGER_MemberSession::next, and sync_session_contact_from_next().

Referenced by iterate_sync_session_contact(), and sync_session_contact_from_next().

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

◆ iterate_sync_session_contact()

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

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

355{
356 struct GNUNET_MESSENGER_MemberSession *session;
357
359
360 session = value;
361
362 if (session->next)
363 sync_session_contact_from_next (session, session->next);
364
365 return GNUNET_YES;
366}

References GNUNET_assert, GNUNET_YES, GNUNET_MESSENGER_MemberSession::next, sync_session_contact_from_next(), and value.

Referenced by sync_member_contacts().

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 370 of file gnunet-service-messenger_member.c.

371{
372 GNUNET_assert ((member) && (member->sessions));
373
376}
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 380 of file gnunet-service-messenger_member.c.

382{
383 struct GNUNET_HashCode hash;
384
385 GNUNET_assert ((member) && (public_key));
386
387 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
388
389 return GNUNET_CONTAINER_multihashmap_get (member->sessions, &hash);
390}
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:

◆ iterate_search_session()

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

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

405{
407 struct GNUNET_MESSENGER_MemberSession *session;
408
409 GNUNET_assert ((cls) && (value));
410
411 search = cls;
412 session = value;
413
414 if (GNUNET_OK != verify_member_session_as_sender (session, search->message,
415 search->hash))
416 return GNUNET_YES;
417
418 search->match = session;
419 return GNUNET_NO;
420}
enum GNUNET_GenericReturnValue verify_member_session_as_sender(const struct GNUNET_MESSENGER_MemberSession *session, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
Verifies a given member session as sender of a selected message and its hash.
const struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_MemberSession * match

References GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_ClosureSearchSession::hash, GNUNET_MESSENGER_ClosureSearchSession::match, GNUNET_MESSENGER_ClosureSearchSession::message, value, and verify_member_session_as_sender().

Referenced by get_member_session_of().

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

◆ try_member_session()

static struct GNUNET_MESSENGER_MemberSession * try_member_session ( struct GNUNET_MESSENGER_Member member,
const struct GNUNET_CRYPTO_PublicKey public_key 
)
static

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

426{
427 struct GNUNET_MESSENGER_MemberSession *session;
428
430
432
433 if (session)
434 return session;
435
437
438 if (session)
439 add_member_session (member, session);
440
441 return session;
442}
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.
void add_member_session(struct GNUNET_MESSENGER_Member *member, struct GNUNET_MESSENGER_MemberSession *session)
Adds a given member session to its member.
struct GNUNET_MESSENGER_MemberSession * create_member_session(struct GNUNET_MESSENGER_Member *member, const struct GNUNET_CRYPTO_PublicKey *pubkey)
Creates and allocates a new member session of a member with a given public key.

References add_member_session(), create_member_session(), get_member_session(), GNUNET_assert, GNUNET_MESSENGER_MemberSession::member, and GNUNET_MESSENGER_MemberSession::public_key.

Referenced by get_member_session_of().

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 446 of file gnunet-service-messenger_member.c.

449{
450 GNUNET_assert ((member) && (message) && (hash) &&
451 (0 == GNUNET_memcmp (&(member->id),
452 &(message->header.sender_id))));
453
454 if (GNUNET_MESSENGER_KIND_JOIN == message->header.kind)
455 return try_member_session (member, &(message->body.join.key));
456
457 {
459
460 search.message = message;
461 search.hash = hash;
462
463 search.match = NULL;
465 iterate_search_session, &search);
466
467 return search.match;
468 }
469}
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.
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(), send_message_join(), and traverse_epoch_session_message().

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 473 of file gnunet-service-messenger_member.c.

475{
476 const struct GNUNET_CRYPTO_PublicKey *public_key;
477 struct GNUNET_HashCode hash;
478
479 if (! session)
480 return;
481
482 GNUNET_assert ((member) && (session->member == member));
483
484 public_key = get_member_session_public_key (session);
485 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
486
488 member->sessions, &hash, session,
491 "Adding a member session failed: %s\n",
492 GNUNET_h2s (&hash));
493}
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...
@ 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 497 of file gnunet-service-messenger_member.c.

499{
500 const struct GNUNET_CRYPTO_PublicKey *public_key;
501 struct GNUNET_HashCode hash;
502
503 GNUNET_assert ((member) && (session) && (session->member == member));
504
505 public_key = get_member_session_public_key (session);
506 GNUNET_CRYPTO_hash (public_key, sizeof(*public_key), &hash);
507
509 &hash, session))
511 "Removing a member session failed: %s\n",
512 GNUNET_h2s (&hash));
513}
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_it()

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

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

526{
528 struct GNUNET_MESSENGER_MemberSession *session;
529
530 GNUNET_assert ((cls) && (value));
531
532 iterate = cls;
533 session = value;
534
535 return iterate->it (iterate->cls, get_member_session_public_key (session),
536 session);
537}

References GNUNET_MESSENGER_ClosureIterateSessions::cls, get_member_session_public_key(), GNUNET_assert, GNUNET_MESSENGER_ClosureIterateSessions::it, and value.

Referenced by iterate_member_sessions().

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 541 of file gnunet-service-messenger_member.c.

544{
546
547 GNUNET_assert ((member) && (member->sessions) && (it));
548
549 iterate.it = it;
550 iterate.cls = cls;
551
554 &iterate);
555}
static enum GNUNET_GenericReturnValue iterate_member_sessions_it(void *cls, const struct GNUNET_HashCode *key, void *value)

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 559 of file gnunet-service-messenger_member.c.

561{
562 const struct GNUNET_ShortHashCode *discourse;
563
564 GNUNET_assert ((member) && (member->subscriptions) && (subscription));
565
566 discourse = get_subscription_discourse (subscription);
567
569 member->subscriptions, discourse, subscription,
572 "Adding a member subscription failed: %s\n",
573 GNUNET_sh2s (discourse));
574}
const struct GNUNET_ShortHashCode * get_subscription_discourse(const struct GNUNET_MESSENGER_Subscription *subscription)
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.

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 578 of file gnunet-service-messenger_member.c.

580{
581 const struct GNUNET_ShortHashCode *discourse;
582
583 GNUNET_assert ((member) && (member->subscriptions) && (subscription));
584
585 discourse = get_subscription_discourse (subscription);
586
588 ,
589 discourse,
590 subscription))
592 "Removing a member subscription failed: %s\n",
593 GNUNET_sh2s (discourse));
594}
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 598 of file gnunet-service-messenger_member.c.

600{
601 GNUNET_assert ((member) && (member->subscriptions) && (discourse));
602
603 return GNUNET_CONTAINER_multishortmap_get (member->subscriptions, discourse);
604}
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 608 of file gnunet-service-messenger_member.c.

611{
612 GNUNET_assert ((member) && (member->subscriptions) && (it));
613
615 (
617 it,
618 cls);
619}
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: