GNUnet debian-0.24.3-23-g589b01d60
gnunet-service-messenger_peer_store.c File Reference
Include dependency graph for gnunet-service-messenger_peer_store.c:

Go to the source code of this file.

Data Structures

struct  GNUNET_MESSENGER_PeerStoreEntry
 
struct  GNUNET_MESSENGER_ClosureVerifyPeer
 
struct  GNUNET_MESSENGER_ClosureFindPeer
 

Functions

void init_peer_store (struct GNUNET_MESSENGER_PeerStore *store, struct GNUNET_MESSENGER_Service *service)
 Initializes a peer store as fully empty. More...
 
static enum GNUNET_GenericReturnValue iterate_destroy_peers (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
 
void clear_peer_store (struct GNUNET_MESSENGER_PeerStore *store)
 Clears a peer store, wipes its content and deallocates its memory. More...
 
void load_peer_store (struct GNUNET_MESSENGER_PeerStore *store, const char *path)
 Loads peer identities from a file into a peer store. More...
 
static enum GNUNET_GenericReturnValue iterate_save_peers (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
 
void save_peer_store (const struct GNUNET_MESSENGER_PeerStore *store, const char *path)
 Saves peer identities from a peer store into a file. More...
 
static enum GNUNET_GenericReturnValue verify_store_peer (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
 
static struct GNUNET_MESSENGER_PeerStoreEntryadd_peer_store_entry (struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_ShortHashCode *id, enum GNUNET_GenericReturnValue active)
 
static const struct GNUNET_PeerIdentityget_store_service_peer_identity (struct GNUNET_MESSENGER_PeerStore *store)
 
struct GNUNET_PeerIdentityget_store_peer_of (struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash)
 Returns the peer identity inside the store which verifies the signature of a given message as valid. More...
 
static enum GNUNET_GenericReturnValue find_store_peer (void *cls, const struct GNUNET_ShortHashCode *id, void *value)
 
void update_store_peer (struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_PeerIdentity *peer, enum GNUNET_GenericReturnValue active)
 Adds a peer identity to the store if necessary. More...
 

Function Documentation

◆ init_peer_store()

void init_peer_store ( struct GNUNET_MESSENGER_PeerStore store,
struct GNUNET_MESSENGER_Service service 
)

Initializes a peer store as fully empty.

Parameters
[out]storePeer store
[in,out]serviceMessenger service

Definition at line 40 of file gnunet-service-messenger_peer_store.c.

42{
43 GNUNET_assert ((store) && (service));
44
45 store->service = service;
47}
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
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).
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MESSENGER_Service * service
struct GNUNET_CONTAINER_MultiShortmap * peers

References GNUNET_assert, GNUNET_CONTAINER_multishortmap_create(), GNUNET_NO, GNUNET_MESSENGER_PeerStore::peers, service, and GNUNET_MESSENGER_PeerStore::service.

Referenced by create_srv_room().

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

◆ iterate_destroy_peers()

static enum GNUNET_GenericReturnValue iterate_destroy_peers ( void *  cls,
const struct GNUNET_ShortHashCode id,
void *  value 
)
static

Definition at line 51 of file gnunet-service-messenger_peer_store.c.

53{
55
57
58 entry = value;
59
60 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Free peer store entry: %s -> %s\n",
61 GNUNET_sh2s (id),
62 GNUNET_i2s (&(entry->peer)));
63
64 GNUNET_free (entry);
65 return GNUNET_YES;
66}
static char * value
Value of the record to add/remove.
#define GNUNET_log(kind,...)
@ GNUNET_YES
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
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_free(ptr)
Wrapper around free.

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_PeerStoreEntry::peer, and value.

Referenced by clear_peer_store().

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

◆ clear_peer_store()

void clear_peer_store ( struct GNUNET_MESSENGER_PeerStore store)

Clears a peer store, wipes its content and deallocates its memory.

Parameters
[in,out]storePeer store

Definition at line 70 of file gnunet-service-messenger_peer_store.c.

71{
72 GNUNET_assert ((store) && (store->peers));
73
74 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Clear peer store\n");
75
77 NULL);
79
80 store->peers = NULL;
81}
static enum GNUNET_GenericReturnValue iterate_destroy_peers(void *cls, const struct GNUNET_ShortHashCode *id, void *value)
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_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, iterate_destroy_peers(), and GNUNET_MESSENGER_PeerStore::peers.

Referenced by destroy_srv_room().

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

◆ load_peer_store()

void load_peer_store ( struct GNUNET_MESSENGER_PeerStore store,
const char *  path 
)

Loads peer identities from a file into a peer store.

Parameters
[out]storePeer store
[in]pathPath to a file

Definition at line 85 of file gnunet-service-messenger_peer_store.c.

87{
90 struct GNUNET_PeerIdentity peer;
91 ssize_t len;
92
93 GNUNET_assert ((store) && (path));
94
96 return;
97
98 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Load peer store from path: %s\n",
99 path);
100
101 {
102 enum GNUNET_DISK_AccessPermissions permission;
103
106 }
107
108 if (! handle)
109 return;
110
112
113 do {
115
116 len = GNUNET_DISK_file_read (handle, &peer, sizeof(peer));
117
118 if (len != sizeof(peer))
119 break;
120
122
123 if (! entry)
124 continue;
125
126 GNUNET_memcpy (&(entry->peer), &peer, sizeof(entry->peer));
127 entry->active = GNUNET_YES;
128
130
132 store->peers, &peer_id, entry,
134 continue;
135
136 GNUNET_free (entry);
137 } while (len == sizeof(peer));
138
140}
static char * peer_id
Option –peer.
Definition: gnunet-cadet.c:42
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1258
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
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition: disk.c:219
GNUNET_DISK_AccessPermissions
File access permissions, UNIX-style.
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1332
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:673
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_SEEK_SET
Seek an absolute position (from the start of the file).
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE
Allow multiple values with the same key.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void convert_peer_identity_to_id(const struct GNUNET_PeerIdentity *identity, struct GNUNET_ShortHashCode *id)
Converts a peers identity to a short hash code which can be used as id to refer to a peer via sender ...
Handle used to access files (and pipes).
The identity of the host (wraps the signing key of the peer).
A 256-bit hashcode.

References GNUNET_MESSENGER_PeerStoreEntry::active, convert_peer_identity_to_id(), GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_put(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_read(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_test(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_DISK_SEEK_SET, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_YES, handle, GNUNET_MESSENGER_PeerStoreEntry::peer, peer_id, and GNUNET_MESSENGER_PeerStore::peers.

Referenced by load_srv_room().

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

◆ iterate_save_peers()

static enum GNUNET_GenericReturnValue iterate_save_peers ( void *  cls,
const struct GNUNET_ShortHashCode id,
void *  value 
)
static

Definition at line 144 of file gnunet-service-messenger_peer_store.c.

146{
149
150 GNUNET_assert ((cls) && (id) && (value));
151
152 handle = cls;
153 entry = value;
154
155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save peer store entry: %s\n",
156 GNUNET_sh2s (id));
157
158 if ((! entry) || (GNUNET_YES != entry->active))
159 return GNUNET_YES;
160
161 GNUNET_DISK_file_write (handle, &(entry->peer), sizeof(entry->peer));
162 return GNUNET_YES;
163}
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:710

References GNUNET_MESSENGER_PeerStoreEntry::active, GNUNET_assert, GNUNET_DISK_file_write(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_sh2s(), GNUNET_YES, handle, GNUNET_MESSENGER_PeerStoreEntry::peer, and value.

Referenced by save_peer_store().

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

◆ save_peer_store()

void save_peer_store ( const struct GNUNET_MESSENGER_PeerStore store,
const char *  path 
)

Saves peer identities from a peer store into a file.

Parameters
[in]storePeer store
[in]pathPath to a file

Definition at line 167 of file gnunet-service-messenger_peer_store.c.

169{
171
172 GNUNET_assert ((store) && (path));
173
174 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Save peer store to path: %s\n",
175 path);
176
177 {
178 enum GNUNET_DISK_AccessPermissions permission;
179
182 path,
184 permission);
185 }
186
187 if (! handle)
188 return;
189
192 handle);
193
196}
static enum GNUNET_GenericReturnValue iterate_save_peers(void *cls, const struct GNUNET_ShortHashCode *id, void *value)
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
Definition: disk.c:1451
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.

References GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_seek(), GNUNET_DISK_file_sync(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_WRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_DISK_SEEK_SET, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, handle, iterate_save_peers(), and GNUNET_MESSENGER_PeerStore::peers.

Referenced by save_srv_room().

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

◆ verify_store_peer()

static enum GNUNET_GenericReturnValue verify_store_peer ( void *  cls,
const struct GNUNET_ShortHashCode id,
void *  value 
)
static

Definition at line 207 of file gnunet-service-messenger_peer_store.c.

209{
212
213 GNUNET_assert ((cls) && (value));
214
215 verify = cls;
216 entry = value;
217
218 if (! entry)
219 return GNUNET_YES;
220
221 if (GNUNET_OK == verify_message_by_peer (verify->message,
222 verify->hash, &(entry->peer)))
223 {
224 verify->sender = &(entry->peer);
225 return GNUNET_NO;
226 }
227
228 return GNUNET_YES;
229}
static int verify
Verify mode.
Definition: gnunet-abd.c:128
enum GNUNET_GenericReturnValue verify_message_by_peer(const struct GNUNET_MESSENGER_Message *message, const struct GNUNET_HashCode *hash, const struct GNUNET_PeerIdentity *identity)
Verifies the signature of a given message and its hash with a specific peer's identity.

References GNUNET_assert, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_PeerStoreEntry::peer, value, verify, and verify_message_by_peer().

Referenced by get_store_peer_of().

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

◆ add_peer_store_entry()

static struct GNUNET_MESSENGER_PeerStoreEntry * add_peer_store_entry ( struct GNUNET_MESSENGER_PeerStore store,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_ShortHashCode id,
enum GNUNET_GenericReturnValue  active 
)
static

Definition at line 233 of file gnunet-service-messenger_peer_store.c.

237{
239
240 GNUNET_assert ((store) && (peer));
241
242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Add peer store entry: %s -> %s\n",
243 GNUNET_sh2s (id),
244 GNUNET_i2s (peer));
245
247
248 if (! entry)
249 return NULL;
250
251 GNUNET_memcpy (&(entry->peer), peer, sizeof(entry->peer));
252 entry->active = active;
253
255 store->peers, id, entry,
257 {
258 GNUNET_free (entry);
259 return NULL;
260 }
261
262 return entry;
263}

References GNUNET_MESSENGER_PeerStoreEntry::active, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multishortmap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_sh2s(), GNUNET_MESSENGER_PeerStoreEntry::peer, and GNUNET_MESSENGER_PeerStore::peers.

Referenced by get_store_peer_of(), and update_store_peer().

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

◆ get_store_service_peer_identity()

static const struct GNUNET_PeerIdentity * get_store_service_peer_identity ( struct GNUNET_MESSENGER_PeerStore store)
static

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

268{
269 static struct GNUNET_PeerIdentity peer;
270
271 if (GNUNET_OK != get_service_peer_identity (store->service, &peer))
272 return NULL;
273
274 return &peer;
275}
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.

References get_service_peer_identity(), GNUNET_OK, and GNUNET_MESSENGER_PeerStore::service.

Referenced by get_store_peer_of().

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

◆ get_store_peer_of()

struct GNUNET_PeerIdentity * get_store_peer_of ( struct GNUNET_MESSENGER_PeerStore store,
const struct GNUNET_MESSENGER_Message message,
const struct GNUNET_HashCode hash 
)

Returns the peer identity inside the store which verifies the signature of a given message as valid.

The specific peer identity has to be added to the store previously. Otherwise the function returns NULL.

Parameters
[in,out]storePeer store
[in]messageMessage
[in]hashHash of message
Returns
Peer identity or NULL

Definition at line 279 of file gnunet-service-messenger_peer_store.c.

282{
283 const struct GNUNET_PeerIdentity *peer;
284 enum GNUNET_GenericReturnValue active;
286
287 GNUNET_assert ((store) && (store->peers) && (message) && (hash));
288
289 if (GNUNET_YES != is_peer_message (message))
290 return NULL;
291
292 {
294 verify.message = message;
295 verify.hash = hash;
296 verify.sender = NULL;
297
301
302 if (verify.sender)
303 return verify.sender;
304 }
305
307 {
308 peer = &(message->body.peer.peer);
309 active = GNUNET_YES;
310 }
312 {
313 peer = &(message->body.miss.peer);
314 active = GNUNET_NO;
315 }
316 else
317 {
319 "Peer message does not contain a peer identity\n");
320
321 peer = get_store_service_peer_identity (store);
322 active = GNUNET_NO;
323
324 if (! peer)
325 return NULL;
326 }
327
329
331 {
333 "Sender id does not match peer identity\n");
334 return NULL;
335 }
336
338 {
340 "Verification of message with peer identity failed!\n");
341 }
342
343 {
345 entry = add_peer_store_entry (store, peer, &peer_id, active);
346
347 if (! entry)
348 {
350 "Initialization of entry in peer store failed: %s\n",
352
353 return NULL;
354 }
355
356 return &(entry->peer);
357 }
358}
static const struct GNUNET_PeerIdentity * get_store_service_peer_identity(struct GNUNET_MESSENGER_PeerStore *store)
static struct GNUNET_MESSENGER_PeerStoreEntry * add_peer_store_entry(struct GNUNET_MESSENGER_PeerStore *store, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_ShortHashCode *id, enum GNUNET_GenericReturnValue active)
static enum GNUNET_GenericReturnValue verify_store_peer(void *cls, const struct GNUNET_ShortHashCode *id, void *value)
int GNUNET_CONTAINER_multishortmap_get_multiple(struct GNUNET_CONTAINER_MultiShortmap *map, const struct GNUNET_ShortHashCode *key, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_MESSENGER_KIND_MISS
The miss kind.
@ GNUNET_MESSENGER_KIND_PEER
The peer kind.
enum GNUNET_GenericReturnValue is_peer_message(const struct GNUNET_MESSENGER_Message *message)
Returns whether a specific kind of message can be sent by the service without usage of a clients priv...
const struct GNUNET_MESSENGER_Message * message
struct GNUNET_MESSENGER_MessageMiss miss
struct GNUNET_MESSENGER_MessagePeer peer
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_PeerIdentity peer
The peer identity of a disconnected door to a room.
struct GNUNET_PeerIdentity peer
The peer identity of the sender opening a room.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_PeerStoreEntry::active, add_peer_store_entry(), GNUNET_MESSENGER_Message::body, convert_peer_identity_to_id(), get_store_service_peer_identity(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcmp, GNUNET_MESSENGER_KIND_MISS, GNUNET_MESSENGER_KIND_PEER, GNUNET_NO, GNUNET_OK, GNUNET_sh2s(), GNUNET_YES, GNUNET_MESSENGER_ClosureVerifyPeer::hash, GNUNET_MESSENGER_Message::header, is_peer_message(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_ClosureVerifyPeer::message, GNUNET_MESSENGER_MessageBody::miss, GNUNET_MESSENGER_MessagePeer::peer, GNUNET_MESSENGER_MessageMiss::peer, GNUNET_MESSENGER_MessageBody::peer, GNUNET_MESSENGER_PeerStoreEntry::peer, peer_id, GNUNET_MESSENGER_PeerStore::peers, GNUNET_MESSENGER_MessageHeader::sender_id, verify, verify_message_by_peer(), and verify_store_peer().

Referenced by callback_found_message(), callback_room_handle_message(), handle_room_messages(), and traverse_epoch_session_message().

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

◆ find_store_peer()

static enum GNUNET_GenericReturnValue find_store_peer ( void *  cls,
const struct GNUNET_ShortHashCode id,
void *  value 
)
static

Definition at line 368 of file gnunet-service-messenger_peer_store.c.

369{
372
373 GNUNET_assert ((cls) && (value));
374
375 find = cls;
376 entry = value;
377
378 if (! entry)
379 return GNUNET_YES;
380
381 if (0 == GNUNET_memcmp (find->requested, &(entry->peer)))
382 {
383 find->match = entry;
384 return GNUNET_NO;
385 }
386
387 return GNUNET_YES;
388}
struct GNUNET_MESSENGER_PeerStoreEntry * match
const struct GNUNET_PeerIdentity * requested

References GNUNET_assert, GNUNET_memcmp, GNUNET_NO, GNUNET_YES, GNUNET_MESSENGER_ClosureFindPeer::match, GNUNET_MESSENGER_PeerStoreEntry::peer, GNUNET_MESSENGER_ClosureFindPeer::requested, and value.

Referenced by update_store_peer().

Here is the caller graph for this function:

◆ update_store_peer()

void update_store_peer ( struct GNUNET_MESSENGER_PeerStore store,
const struct GNUNET_PeerIdentity peer,
enum GNUNET_GenericReturnValue  active 
)

Adds a peer identity to the store if necessary.

It ensures that the given peer can be verified as sender of a message afterwards by the store.

Parameters
[in,out]storePeer store
[in]peerPeer identity
[in]activeWhether the peer is active or not

Definition at line 392 of file gnunet-service-messenger_peer_store.c.

395{
397
398 GNUNET_assert ((store) && (store->peers) && (peer));
399
401
402 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Update peer store entry: %s\n",
404
405 {
407 find.requested = peer;
408 find.match = NULL;
409
411 find_store_peer, &find);
412
413 if (find.match)
414 {
415 find.match->active = active;
416 return;
417 }
418 }
419
420 if (! add_peer_store_entry (store, peer, &peer_id, active))
422 "Initial update of entry in peer store failed: %s\n",
424}
static enum GNUNET_GenericReturnValue find_store_peer(void *cls, const struct GNUNET_ShortHashCode *id, void *value)

References GNUNET_MESSENGER_PeerStoreEntry::active, add_peer_store_entry(), convert_peer_identity_to_id(), find_store_peer(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_get_multiple(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_sh2s(), GNUNET_MESSENGER_ClosureFindPeer::match, peer_id, GNUNET_MESSENGER_PeerStore::peers, and GNUNET_MESSENGER_ClosureFindPeer::requested.

Referenced by handle_message_miss(), and handle_message_peer().

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