GNUnet debian-0.24.3-23-g589b01d60
messenger_api_epoch.h File Reference
Include dependency graph for messenger_api_epoch.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_Epoch
 

Functions

struct GNUNET_MESSENGER_Epochcreate_epoch (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Creates and allocates an epoch in a given room which can be identified by a specific hash. More...
 
struct GNUNET_MESSENGER_Epochcreate_new_epoch (struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
 Creates and allocates a new epoch in a given room which can be identified by a specific hash. More...
 
void destroy_epoch (struct GNUNET_MESSENGER_Epoch *epoch)
 Destroys an epoch and frees its memory fully from the client API. More...
 
uint32_t get_epoch_size (const struct GNUNET_MESSENGER_Epoch *epoch)
 Returns the amount of members by a given epoch or zero as long as it's not fully initialized yet. More...
 
void reset_epoch_size (struct GNUNET_MESSENGER_Epoch *epoch)
 Resets the amount of members by a given epoch to recalculate the exact amount. More...
 
enum GNUNET_GenericReturnValue delay_epoch_message_for_its_members (struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_HashCode *hash)
 Adds a message with a given hash to a list that can be delayed in processing for the members of a specific epoch until the list of members is complete. More...
 
const struct GNUNET_CRYPTO_EcdhePrivateKeyget_epoch_private_key (struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_TIME_Relative timeout)
 Returns the asymmetric private key (ECDHE) from a handle for a given epoch that can be used for HPKE key exchange until a specific timeout. More...
 
const struct GNUNET_TIME_Relative get_epoch_private_key_timeout (const struct GNUNET_MESSENGER_Epoch *epoch)
 Returns the current relative timeout for the private key (ECDHE) of a given epoch that limits the usage for its key in terms of HPKE. More...
 
struct GNUNET_MESSENGER_EpochAnnouncementget_epoch_announcement (struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
 Returns the epoch announcement of a given epoch using a specific unique identifier or NULL. More...
 
struct GNUNET_MESSENGER_EpochGroupget_epoch_group (struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
 Returns the epoch group of a given epoch using a specific unique identifier or NULL. More...
 
enum GNUNET_GenericReturnValue is_epoch_previous_of_other (const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Epoch *other)
 Returns whether a given epoch is the epoch before some other epoch. More...
 
const struct GNUNET_MESSENGER_EpochAnnouncementget_epoch_previous_announcement (struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier)
 Returns the epoch announcement of a previous epoch from a given epoch using a specific announcement identifier. More...
 
const struct GNUNET_MESSENGER_EpochGroupget_epoch_previous_group (struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier)
 Returns the epoch group of a previous epoch from a given epoch using a specific group identifier. More...
 
uint32_t get_epoch_member_position (const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact)
 Returns the index position of a specific contact inside a given epoch in relation to its list of members. More...
 
enum GNUNET_GenericReturnValue is_epoch_member (const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact)
 Returns whether a specific contact is member of a given epoch. More...
 
double get_epoch_position_factor (const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact, const struct GNUNET_MESSENGER_EpochMembership *membership)
 Returns a relative member positon of a specific contact inside a given epoch in relation to its list of members. More...
 
void send_epoch_message (const struct GNUNET_MESSENGER_Epoch *epoch, struct GNUNET_MESSENGER_Message *message)
 Sends a created and allocated message in a room of a given epoch enforcing the message gets interpreted as part of that exact epoch. More...
 
void update_epoch_announcement (struct GNUNET_MESSENGER_Epoch *epoch, struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
 Updates the main announcement of a given epoch, looking into replacing the current main announcement with a specific epoch announcement that's provided. More...
 
void update_epoch_group (struct GNUNET_MESSENGER_Epoch *epoch, struct GNUNET_MESSENGER_EpochGroup *group)
 Updates the main group of a given epoch, looking into replacing the current main group with a specific epoch group that's provided. More...
 
void propose_epoch_group (struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_TIME_Relative timeout)
 Tries to propose a new group inside a given epoch that will automatically be formed by using the clients own main group and another group on the same level. More...
 
void set_epoch_proposal_group (struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_HashCode *hash)
 Sets the current group of proposal for a given epoch to the group specified by a message identified by its hash. More...
 
const struct GNUNET_MESSENGER_EpochGroupget_epoch_proposal_group (struct GNUNET_MESSENGER_Epoch *epoch)
 Returns the current group of proposal for a given epoch. More...
 
void cancel_epoch_proposal_group (struct GNUNET_MESSENGER_Epoch *epoch)
 Cancels the current proposal of a new group from a given epoch. More...
 
void invalidate_epoch_keys_by_member (struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact)
 Invalidates all announced epoch and group keys by a specific contact inside a given epoch. More...
 

Function Documentation

◆ create_epoch()

struct GNUNET_MESSENGER_Epoch * create_epoch ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Creates and allocates an epoch in a given room which can be identified by a specific hash.

Parameters
[in,out]roomRoom
[in]hashHash of epoch
Returns
Epoch

Definition at line 369 of file messenger_api_epoch.c.

371{
372 struct GNUNET_MESSENGER_Epoch *epoch;
373
374 GNUNET_assert ((room) && (hash));
375
376 if (GNUNET_is_zero (hash))
377 return NULL;
378
379 epoch = GNUNET_new (struct GNUNET_MESSENGER_Epoch);
380
381 if (! epoch)
382 return NULL;
383
385
386 GNUNET_memcpy (&(epoch->hash), hash, sizeof (epoch->hash));
389
390 epoch->room = room;
391 epoch->private_key = NULL;
392
394 8, GNUNET_NO);
395
397 1, GNUNET_NO);
398
400 1, GNUNET_NO);
401
403 1, GNUNET_NO);
404
405 epoch->members_count = 0;
406 epoch->members = NULL;
407
408 epoch->main_announcement = NULL;
409 epoch->main_group = NULL;
410
411 memset (&(epoch->proposal_hash), 0, sizeof (epoch->proposal_hash));
412 epoch->proposal_timeout = NULL;
413
414 epoch->following_count = 0;
415 epoch->following = NULL;
416
417 reset_epoch_size (epoch);
418
419 return epoch;
420}
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_is_zero(a)
Check that memory in a is all zeros.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ 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.
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get_zero_(void)
Return absolute time of 0ms.
Definition: time.c:142
void require_message_from_room(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Requires a specific message in a given room which can be identified by its hash.
void reset_epoch_size(struct GNUNET_MESSENGER_Epoch *epoch)
Resets the amount of members by a given epoch to recalculate the exact amount.
struct GNUNET_MESSENGER_Room * room
struct GNUNET_CONTAINER_MultiHashMap * waiting
struct GNUNET_CONTAINER_MultiShortmap * announcements
struct GNUNET_MESSENGER_Epoch ** following
struct GNUNET_MESSENGER_EpochGroup * main_group
struct GNUNET_SCHEDULER_Task * proposal_timeout
struct GNUNET_CONTAINER_MultiShortmap * nonces
struct GNUNET_TIME_Absolute private_key_expiration
struct GNUNET_MESSENGER_EpochAnnouncement * main_announcement
struct GNUNET_CRYPTO_EcdhePrivateKey * private_key
struct GNUNET_CONTAINER_MultiShortmap * groups
const struct GNUNET_MESSENGER_Contact ** members
struct GNUNET_TIME_Absolute proposal_expiration
struct GNUNET_HashCode proposal_hash
struct GNUNET_HashCode hash

References GNUNET_MESSENGER_Epoch::announcements, GNUNET_MESSENGER_Epoch::following, GNUNET_MESSENGER_Epoch::following_count, GNUNET_assert, GNUNET_CONTAINER_multihashmap_create(), GNUNET_CONTAINER_multishortmap_create(), GNUNET_is_zero, GNUNET_memcpy, GNUNET_new, GNUNET_NO, GNUNET_TIME_absolute_get_zero_(), GNUNET_MESSENGER_Epoch::groups, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_Epoch::main_announcement, GNUNET_MESSENGER_Epoch::main_group, GNUNET_MESSENGER_Epoch::members, GNUNET_MESSENGER_Epoch::members_count, GNUNET_MESSENGER_Epoch::nonces, GNUNET_MESSENGER_Epoch::private_key, GNUNET_MESSENGER_Epoch::private_key_expiration, GNUNET_MESSENGER_Epoch::proposal_expiration, GNUNET_MESSENGER_Epoch::proposal_hash, GNUNET_MESSENGER_Epoch::proposal_timeout, require_message_from_room(), reset_epoch_size(), GNUNET_MESSENGER_Epoch::room, and GNUNET_MESSENGER_Epoch::waiting.

Referenced by create_new_epoch(), and get_room_epoch().

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

◆ create_new_epoch()

struct GNUNET_MESSENGER_Epoch * create_new_epoch ( struct GNUNET_MESSENGER_Room room,
const struct GNUNET_HashCode hash 
)

Creates and allocates a new epoch in a given room which can be identified by a specific hash.

Parameters
[in,out]roomRoom
[in]hashHash of epoch
Returns
New epoch

Definition at line 508 of file messenger_api_epoch.c.

510{
511 const struct GNUNET_MESSENGER_Contact **members;
512 struct GNUNET_MESSENGER_Epoch *epoch;
513 uint32_t members_count;
514
515 GNUNET_assert ((room) && (hash));
516
518
519 if (! members)
520 return NULL;
521
522 epoch = create_epoch (room, hash);
523
524 if (! epoch)
525 {
526 if (members)
528
529 return NULL;
530 }
531
533 epoch->members = members;
534
535 {
536 const struct GNUNET_MESSENGER_EpochGroup *previous;
537
538 previous = get_epoch_previous_group (epoch, NULL);
539
540 if ((! previous) || (GNUNET_YES != previous->valid) ||
541 (! get_epoch_group_key (previous)) ||
543 return epoch;
544
547 epoch);
548
551
552 if (epoch->main_group)
554 }
555
556 return epoch;
557}
int GNUNET_CONTAINER_multishortmap_iterate(struct GNUNET_CONTAINER_MultiShortmap *map, GNUNET_CONTAINER_ShortmapIterator it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_YES
@ GNUNET_SYSERR
#define GNUNET_free(ptr)
Wrapper around free.
static const struct GNUNET_MESSENGER_Contact ** get_members_of_new_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *epoch, uint32_t *members_count)
struct GNUNET_MESSENGER_Epoch * create_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Creates and allocates an epoch in a given room which can be identified by a specific hash.
struct GNUNET_MESSENGER_EpochGroup * get_epoch_group(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Returns the epoch group of a given epoch using a specific unique identifier or NULL.
const struct GNUNET_MESSENGER_EpochGroup * get_epoch_previous_group(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier)
Returns the epoch group of a previous epoch from a given epoch using a specific group identifier.
static enum GNUNET_GenericReturnValue it_move_epoch_groups_from_previous_epoch(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
enum GNUNET_GenericReturnValue send_epoch_group_announcement(struct GNUNET_MESSENGER_EpochGroup *group)
Tries to send an announcement message by the client for a given epoch group using its secret key.
enum GNUNET_GenericReturnValue is_epoch_group_compatible(const struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_MESSENGER_Epoch *epoch)
Returns whether a given epoch group is compatible with a specific epoch with its members.
const struct GNUNET_CRYPTO_SymmetricSessionKey * get_epoch_group_key(const struct GNUNET_MESSENGER_EpochGroup *group)
Returns the secret key of a given epoch group or NULL.
enum GNUNET_GenericReturnValue valid
struct GNUNET_MESSENGER_Epoch * epoch
union GNUNET_MESSENGER_EpochIdentifier identifier

References create_epoch(), GNUNET_MESSENGER_EpochGroup::epoch, get_epoch_group(), get_epoch_group_key(), get_epoch_previous_group(), get_members_of_new_epoch(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Epoch::groups, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_EpochGroup::identifier, is_epoch_group_compatible(), it_move_epoch_groups_from_previous_epoch(), GNUNET_MESSENGER_Epoch::main_group, GNUNET_MESSENGER_Epoch::members, GNUNET_MESSENGER_Epoch::members_count, GNUNET_MESSENGER_Epoch::room, send_epoch_group_announcement(), and GNUNET_MESSENGER_EpochGroup::valid.

Referenced by get_room_epoch().

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

◆ destroy_epoch()

void destroy_epoch ( struct GNUNET_MESSENGER_Epoch epoch)

Destroys an epoch and frees its memory fully from the client API.

Parameters
[in,out]epochEpoch

Definition at line 593 of file messenger_api_epoch.c.

594{
595 GNUNET_assert (epoch);
596
597 if (epoch->proposal_timeout)
598 {
600 epoch->proposal_timeout = NULL;
601 }
602
603 memset (&(epoch->proposal_hash), 0, sizeof (epoch->proposal_hash));
604
605 epoch->main_group = NULL;
606 epoch->main_announcement = NULL;
607
608 if (epoch->nonces)
610
611 if (epoch->groups)
612 {
615 NULL);
616
618 }
619
620 if (epoch->announcements)
621 {
624 NULL);
625
627 }
628
629 if (epoch->waiting)
631
632 if (epoch->following)
633 GNUNET_free (epoch->following);
634
635 if (epoch->members)
636 GNUNET_free (epoch->members);
637
638 if (epoch->private_key)
639 GNUNET_free (epoch->private_key);
640
641 GNUNET_free (epoch);
642}
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
void GNUNET_CONTAINER_multishortmap_destroy(struct GNUNET_CONTAINER_MultiShortmap *map)
Destroy a hash map.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980
static enum GNUNET_GenericReturnValue iterate_destroy_announcement(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_destroy_group(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References GNUNET_MESSENGER_Epoch::announcements, GNUNET_MESSENGER_EpochAnnouncement::epoch, GNUNET_MESSENGER_Epoch::following, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multishortmap_destroy(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_MESSENGER_Epoch::groups, iterate_destroy_announcement(), iterate_destroy_group(), GNUNET_MESSENGER_Epoch::main_announcement, GNUNET_MESSENGER_Epoch::main_group, GNUNET_MESSENGER_Epoch::members, GNUNET_MESSENGER_Epoch::nonces, GNUNET_MESSENGER_Epoch::private_key, GNUNET_MESSENGER_Epoch::proposal_hash, GNUNET_MESSENGER_Epoch::proposal_timeout, and GNUNET_MESSENGER_Epoch::waiting.

Referenced by get_room_epoch(), and iterate_destroy_epoch().

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

◆ get_epoch_size()

uint32_t get_epoch_size ( const struct GNUNET_MESSENGER_Epoch epoch)

Returns the amount of members by a given epoch or zero as long as it's not fully initialized yet.

Parameters
[in]epochEpoch
Returns
Amount of members

Definition at line 646 of file messenger_api_epoch.c.

647{
648 GNUNET_assert (epoch);
649
650 return epoch->members_count;
651}

References GNUNET_MESSENGER_EpochAnnouncement::epoch, GNUNET_assert, and GNUNET_MESSENGER_Epoch::members_count.

Referenced by get_epoch_announcement_size(), get_epoch_position_factor(), and handle_message().

Here is the caller graph for this function:

◆ reset_epoch_size()

void reset_epoch_size ( struct GNUNET_MESSENGER_Epoch epoch)

Resets the amount of members by a given epoch to recalculate the exact amount.

Parameters
[in,out]epochEpoch

Definition at line 671 of file messenger_api_epoch.c.

672{
673 const struct GNUNET_MESSENGER_Contact **members;
674 uint32_t members_count;
675 uint32_t i;
676
677 GNUNET_assert (epoch);
678
680
681 members = get_members_of_epoch (
682 epoch->room, &(epoch->hash), &members_count);
683
684 if (! members)
685 return;
686
687 if (epoch->members)
688 GNUNET_free (epoch->members);
689
690 epoch->members_count = members_count;
691 epoch->members = members;
692
696
697 for (i = 0; i < epoch->following_count; i++)
698 reset_epoch_size (epoch->following[i]);
699}
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
unsigned int GNUNET_CONTAINER_multihashmap_clear(struct GNUNET_CONTAINER_MultiHashMap *map)
Remove all entries from the map.
static const struct GNUNET_MESSENGER_Contact ** get_members_of_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *epoch, uint32_t *members_count)
static enum GNUNET_GenericReturnValue it_handle_epoch_message_delayed(void *cls, const struct GNUNET_HashCode *key, void *value)
static void setup_following_epochs_of_previous(struct GNUNET_MESSENGER_Epoch *epoch)

References GNUNET_MESSENGER_Epoch::following, GNUNET_MESSENGER_Epoch::following_count, get_members_of_epoch(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_clear(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_free, GNUNET_MESSENGER_Epoch::hash, it_handle_epoch_message_delayed(), GNUNET_MESSENGER_Epoch::members, GNUNET_MESSENGER_Epoch::members_count, reset_epoch_size(), GNUNET_MESSENGER_Epoch::room, setup_following_epochs_of_previous(), and GNUNET_MESSENGER_Epoch::waiting.

Referenced by create_epoch(), handle_message(), and reset_epoch_size().

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

◆ delay_epoch_message_for_its_members()

enum GNUNET_GenericReturnValue delay_epoch_message_for_its_members ( struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_HashCode hash 
)

Adds a message with a given hash to a list that can be delayed in processing for the members of a specific epoch until the list of members is complete.

Parameters
[in,out]epochEpoch
[in]hashHash of message
Returns
GNUNET_YES if the message gets delayed, GNUNET_SYSERR on failure, otherwise GNUNET_NO

Definition at line 703 of file messenger_api_epoch.c.

705{
706 GNUNET_assert ((epoch) && (hash));
707
708 if (epoch->members)
709 return GNUNET_NO;
710
712 epoch->waiting, hash))
713 return GNUNET_YES;
714
716 epoch->waiting, hash, NULL,
718 return GNUNET_SYSERR;
719 else
720 return GNUNET_YES;
721}
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL).
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_OK

References GNUNET_assert, GNUNET_CONTAINER_multihashmap_contains(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Epoch::members, and GNUNET_MESSENGER_Epoch::waiting.

Referenced by get_room_availble_epoch_entry().

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

◆ get_epoch_private_key()

const struct GNUNET_CRYPTO_EcdhePrivateKey * get_epoch_private_key ( struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_TIME_Relative  timeout 
)

Returns the asymmetric private key (ECDHE) from a handle for a given epoch that can be used for HPKE key exchange until a specific timeout.

Parameters
[in,out]epochEpoch
[in]timeoutTimeout for the key
Returns
Private key

Definition at line 725 of file messenger_api_epoch.c.

727{
728 GNUNET_assert (epoch);
729
730 if (epoch->private_key)
731 return epoch->private_key;
732
734
735 if (! epoch->private_key)
736 return NULL;
737
739
742
743 return epoch->private_key;
744}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
Definition: gnunet-arm.c:118
void GNUNET_CRYPTO_ecdhe_key_create(struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
Create a new private key.
Definition: crypto_ecc.c:454
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:111
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_add(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Relative duration)
Add a given relative duration to the given start time.
Definition: time.c:452
Private ECC key encoded for transmission.

References GNUNET_assert, GNUNET_CRYPTO_ecdhe_key_create(), GNUNET_new, GNUNET_TIME_absolute_add(), GNUNET_TIME_absolute_get(), GNUNET_MESSENGER_Epoch::private_key, GNUNET_MESSENGER_Epoch::private_key_expiration, and timeout.

Referenced by handle_epoch_announcement_access(), handle_epoch_group_access(), send_epoch_announcement(), send_epoch_announcement_appeal(), and send_epoch_group_announcement().

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

◆ get_epoch_private_key_timeout()

const struct GNUNET_TIME_Relative get_epoch_private_key_timeout ( const struct GNUNET_MESSENGER_Epoch epoch)

Returns the current relative timeout for the private key (ECDHE) of a given epoch that limits the usage for its key in terms of HPKE.

Parameters
[in]epochEpoch
Returns
Timeout of private key

Definition at line 748 of file messenger_api_epoch.c.

749{
750 GNUNET_assert (epoch);
751
752 if (! epoch->private_key)
754
756}
struct GNUNET_TIME_Relative GNUNET_TIME_relative_get_zero_(void)
Return relative time of 0ms.
Definition: time.c:133
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition: time.c:406

References GNUNET_assert, GNUNET_TIME_absolute_get_remaining(), and GNUNET_TIME_relative_get_zero_().

Referenced by send_epoch_announcement(), send_epoch_announcement_appeal(), and send_epoch_group_announcement().

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

◆ get_epoch_announcement()

struct GNUNET_MESSENGER_EpochAnnouncement * get_epoch_announcement ( struct GNUNET_MESSENGER_Epoch epoch,
const union GNUNET_MESSENGER_EpochIdentifier identifier,
enum GNUNET_GenericReturnValue  valid 
)

Returns the epoch announcement of a given epoch using a specific unique identifier or NULL.

An optional flag states whether it is important to find a valid epoch announcement for sending encrypted messages. If the identifier is NULL, the announcement with most members gets returned. If the validity flag is set to GNUNET_SYSERR, no new epoch announcement gets created automatically.

Parameters
[in,out]epochEpoch
[in]identifierAnnouncement identifier or NULL
[in]validValidity flag
Returns
Epoch announcement or NULL

Definition at line 830 of file messenger_api_epoch.c.

834{
835 struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
837
839
840 announcement = NULL;
841
842 if (GNUNET_YES == valid)
844 else
846
847 if (identifier)
848 {
850 &(identifier->hash),
851 iterator,
852 &announcement);
853
854 if ((announcement) || (GNUNET_SYSERR == valid))
855 return announcement;
856
858
859 if (! announcement)
860 return NULL;
861
863 &(identifier->hash),
864 announcement,
866 {
867 destroy_epoch_announcement (announcement);
868 return NULL;
869 }
870
871 if ((GNUNET_YES == valid) && (GNUNET_YES != announcement->valid))
872 return NULL;
873 }
874 else
876 iterator,
877 &announcement);
878
879 return announcement;
880}
enum GNUNET_GenericReturnValue(* GNUNET_CONTAINER_ShortmapIterator)(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
Iterator over hash map entries.
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.
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.
static enum GNUNET_GenericReturnValue it_find_valid_announcement_with_most_members(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static enum GNUNET_GenericReturnValue it_find_announcement_with_most_members(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
struct GNUNET_MESSENGER_EpochAnnouncement * create_epoch_announcement(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Creates and allocates a new epoch announcement for a given epoch using a specific announcement identi...
void destroy_epoch_announcement(struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Destroys a given epoch announcement and frees its resources.
union GNUNET_MESSENGER_EpochIdentifier identifier

References GNUNET_MESSENGER_Epoch::announcements, create_epoch_announcement(), destroy_epoch_announcement(), GNUNET_MESSENGER_EpochAnnouncement::epoch, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_get_multiple(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_EpochAnnouncement::identifier, it_find_announcement_with_most_members(), it_find_valid_announcement_with_most_members(), and GNUNET_MESSENGER_EpochAnnouncement::valid.

Referenced by cb_key_monitor(), get_epoch_previous_announcement(), handle_access_message(), handle_announcement_message(), handle_appeal_message(), handle_authorization_message(), handle_revolution_message(), handle_room_delayed_announcement(), handle_room_delayed_appeal(), handle_room_delayed_deletion(), handle_secret_message(), invalidate_epoch_announcement(), and send_message_to_room().

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

◆ get_epoch_group()

struct GNUNET_MESSENGER_EpochGroup * get_epoch_group ( struct GNUNET_MESSENGER_Epoch epoch,
const union GNUNET_MESSENGER_EpochIdentifier identifier,
enum GNUNET_GenericReturnValue  valid 
)

Returns the epoch group of a given epoch using a specific unique identifier or NULL.

An optional flag states whether it is important to find a valid epoch group for sending encrypted messages. If the identifier is NULL, the group with most members gets returned. If the validity flag is set to GNUNET_SYSERR, no new epoch group gets created automatically.

Parameters
[in,out]epochEpoch
[in]identifierGroup identifier or NULL
[in]validValidity flag
Returns
Epoch group or NULL

Definition at line 950 of file messenger_api_epoch.c.

953{
954 struct GNUNET_MESSENGER_EpochGroup *group;
956
958
959 group = NULL;
960
961 if (GNUNET_YES == valid)
963 else
965
966 if (identifier)
967 {
969 &(identifier->hash),
970 iterator,
971 &group);
972
973 if ((group) || (GNUNET_SYSERR == valid))
974 return group;
975
978 valid);
979
980 if (! group)
981 return NULL;
982
984 &(identifier->hash),
985 group,
987 {
988 destroy_epoch_group (group);
989 return NULL;
990 }
991 }
992 else
994 iterator,
995 &group);
996
997 return group;
998}
static enum GNUNET_GenericReturnValue it_find_valid_group_with_most_members(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static enum GNUNET_GenericReturnValue it_find_group_with_most_members(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
struct GNUNET_MESSENGER_EpochGroup * create_epoch_group(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, uint32_t level, enum GNUNET_GenericReturnValue valid)
Creates and allocates a new epoch group for a given epoch using a specific group identifier or NULL a...
void destroy_epoch_group(struct GNUNET_MESSENGER_EpochGroup *group)
Destroys a given epoch group and frees its resources.
struct GNUNET_MESSENGER_EpochIdentifierCode code

References GNUNET_MESSENGER_EpochIdentifier::code, create_epoch_group(), destroy_epoch_group(), GNUNET_MESSENGER_EpochGroup::epoch, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_get_multiple(), GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Epoch::groups, GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_EpochGroup::identifier, it_find_group_with_most_members(), it_find_valid_group_with_most_members(), GNUNET_MESSENGER_EpochIdentifierCode::level_bits, and GNUNET_MESSENGER_EpochGroup::valid.

Referenced by cb_key_monitor(), create_new_epoch(), get_epoch_previous_group(), get_epoch_proposal_group(), handle_access_message(), handle_announcement_message(), handle_authorization_message(), handle_group_message(), handle_revolution_message(), handle_room_delayed_announcement(), invalidate_epoch_group(), it_move_epoch_groups_from_previous_epoch(), and send_epoch_group_authorization().

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

◆ is_epoch_previous_of_other()

enum GNUNET_GenericReturnValue is_epoch_previous_of_other ( const struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_MESSENGER_Epoch other 
)

Returns whether a given epoch is the epoch before some other epoch.

Parameters
[in]epochEpoch
[in]otherOther epoch
Returns
GNUNET_YES if epoch is the previous epoch, GNUNET_SYSERR on internal failure, otherwise GNUNET_NO

Definition at line 1002 of file messenger_api_epoch.c.

1004{
1005 const struct GNUNET_MESSENGER_Message *message;
1006
1007 GNUNET_assert ((epoch) && (other));
1008
1009 if (epoch->room != other->room)
1010 return GNUNET_NO;
1011
1012 message = get_room_message (other->room, &(other->hash));
1013
1014 if (! message)
1015 return GNUNET_SYSERR;
1016
1017 switch (message->header.kind)
1018 {
1020 return 0 == GNUNET_CRYPTO_hash_cmp (&(epoch->hash), &(message->body.join.
1021 epoch))?
1024 return 0 == GNUNET_CRYPTO_hash_cmp (&(epoch->hash), &(message->body.leave.
1025 epoch))?
1028 if (0 == GNUNET_CRYPTO_hash_cmp (&(epoch->hash), &(message->body.merge.
1029 epochs[0])))
1030 return GNUNET_YES;
1031
1032 if (0 == GNUNET_CRYPTO_hash_cmp (&(epoch->hash), &(message->body.merge.
1033 epochs[1])))
1034 return GNUNET_YES;
1035
1036 return GNUNET_NO;
1037 default:
1038 return GNUNET_SYSERR;
1039 }
1040}
static unsigned int epochs
-e option.
int GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, const struct GNUNET_HashCode *h2)
Compare function for HashCodes, producing a total ordering of all hashcodes.
Definition: crypto_hash.c:218
@ GNUNET_MESSENGER_KIND_LEAVE
The leave kind.
@ GNUNET_MESSENGER_KIND_JOIN
The join kind.
@ GNUNET_MESSENGER_KIND_MERGE
The merge kind.
const struct GNUNET_MESSENGER_Message * get_room_message(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns a message locally stored from a map for a given hash in a room.
struct GNUNET_MESSENGER_MessageMerge merge
struct GNUNET_MESSENGER_MessageLeave leave
struct GNUNET_MESSENGER_MessageJoin join
enum GNUNET_MESSENGER_MessageKind kind
The kind of the message.
struct GNUNET_MESSENGER_MessageHeader header
Header.
struct GNUNET_MESSENGER_MessageBody body
Body.

References GNUNET_MESSENGER_Message::body, epochs, get_room_message(), GNUNET_assert, GNUNET_CRYPTO_hash_cmp(), GNUNET_MESSENGER_KIND_JOIN, GNUNET_MESSENGER_KIND_LEAVE, GNUNET_MESSENGER_KIND_MERGE, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageBody::join, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageBody::leave, GNUNET_MESSENGER_MessageBody::merge, and GNUNET_MESSENGER_Epoch::room.

Here is the call graph for this function:

◆ get_epoch_previous_announcement()

const struct GNUNET_MESSENGER_EpochAnnouncement * get_epoch_previous_announcement ( struct GNUNET_MESSENGER_Epoch epoch,
const union GNUNET_MESSENGER_EpochIdentifier identifier 
)

Returns the epoch announcement of a previous epoch from a given epoch using a specific announcement identifier.

This is utilized for potential key derivation.

Parameters
[in,out]epochEpoch
[in]identifierAnnouncement identifier or NULL
Returns
Epoch announcement or NULL

Definition at line 1044 of file messenger_api_epoch.c.

1047{
1048 const struct GNUNET_MESSENGER_Message *message;
1049 struct GNUNET_MESSENGER_Epoch *previous;
1050 const struct GNUNET_MESSENGER_EpochAnnouncement *announcement;
1051
1053
1054 message = get_room_message (epoch->room, &(epoch->hash));
1055
1056 if ((! message) || (GNUNET_MESSENGER_KIND_LEAVE == message->header.kind))
1057 return NULL;
1058
1059 previous = get_room_message_epoch (epoch->room,
1060 &(message->header.previous));
1061
1062 if (epoch == previous)
1063 return NULL;
1064
1065 if (previous)
1066 announcement = get_epoch_announcement (previous, identifier,
1068 else
1069 announcement = NULL;
1070
1071 if ((! announcement) ||
1072 (announcement->epoch == epoch) ||
1073 (0 == GNUNET_CRYPTO_hash_cmp (&(announcement->epoch->hash),
1074 &(epoch->hash))))
1075 return NULL;
1076
1077 return announcement;
1078}
struct GNUNET_MESSENGER_EpochAnnouncement * get_epoch_announcement(struct GNUNET_MESSENGER_Epoch *epoch, const union GNUNET_MESSENGER_EpochIdentifier *identifier, enum GNUNET_GenericReturnValue valid)
Returns the epoch announcement of a given epoch using a specific unique identifier or NULL.
struct GNUNET_MESSENGER_Epoch * get_room_message_epoch(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *hash)
Returns the epoch of a local message with a given hash in a room.
struct GNUNET_HashCode previous
The hash of the previous message from the senders perspective.

References GNUNET_MESSENGER_EpochAnnouncement::epoch, get_epoch_announcement(), get_room_message(), get_room_message_epoch(), GNUNET_assert, GNUNET_CRYPTO_hash_cmp(), GNUNET_MESSENGER_KIND_LEAVE, GNUNET_SYSERR, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_EpochAnnouncement::identifier, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageHeader::previous, and GNUNET_MESSENGER_Epoch::room.

Referenced by create_epoch_announcement().

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

◆ get_epoch_previous_group()

const struct GNUNET_MESSENGER_EpochGroup * get_epoch_previous_group ( struct GNUNET_MESSENGER_Epoch epoch,
const union GNUNET_MESSENGER_EpochIdentifier identifier 
)

Returns the epoch group of a previous epoch from a given epoch using a specific group identifier.

This is utilized for potential key derivation and taking over groups from one previous epoch into the current.

Parameters
[in,out]epochEpoch
[in]identifierGroup identifier or NULL
Returns
Epoch group or NULL

Definition at line 1082 of file messenger_api_epoch.c.

1085{
1086 const struct GNUNET_MESSENGER_Message *message;
1087 struct GNUNET_MESSENGER_Epoch *previous;
1088 const struct GNUNET_MESSENGER_EpochGroup *group;
1089
1091
1092 message = get_room_message (epoch->room, &(epoch->hash));
1093
1094 if (! message)
1095 return NULL;
1096
1097 previous = get_room_message_epoch (epoch->room, &(message->header.previous));
1098
1099 if (epoch == previous)
1100 return NULL;
1101
1102 if (previous)
1103 group = get_epoch_group (previous,
1104 identifier,
1105 identifier?
1107 else
1108 group = NULL;
1109
1110 if (GNUNET_MESSENGER_KIND_MERGE == message->header.kind)
1111 {
1112 struct GNUNET_MESSENGER_Epoch *other;
1113 const struct GNUNET_MESSENGER_EpochGroup *other_group;
1114
1115 other = get_room_message_epoch (
1116 epoch->room,
1117 &(message->body.merge.previous));
1118
1119 if (previous == other)
1120 goto skip_merge;
1121
1122 if (other)
1123 other_group = get_epoch_group (other, identifier, GNUNET_SYSERR);
1124 else
1125 other_group = NULL;
1126
1127 if (GNUNET_YES == is_other_epoch_group_better (group, other_group))
1128 group = other_group;
1129 }
1130
1131skip_merge:
1132 if ((group) && ((group->epoch == epoch) ||
1133 (0 == GNUNET_CRYPTO_hash_cmp (&(group->epoch->hash),
1134 &(epoch->hash)))))
1135 return NULL;
1136
1137 return group;
1138}
static enum GNUNET_GenericReturnValue is_other_epoch_group_better(const struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_MESSENGER_EpochGroup *other)
struct GNUNET_HashCode previous
The hash of a second previous message.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochGroup::epoch, get_epoch_group(), get_room_message(), get_room_message_epoch(), GNUNET_assert, GNUNET_CRYPTO_hash_cmp(), GNUNET_MESSENGER_KIND_MERGE, GNUNET_SYSERR, GNUNET_YES, GNUNET_MESSENGER_Epoch::hash, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_EpochGroup::identifier, is_other_epoch_group_better(), GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_MessageBody::merge, GNUNET_MESSENGER_MessageHeader::previous, GNUNET_MESSENGER_MessageMerge::previous, and GNUNET_MESSENGER_Epoch::room.

Referenced by create_epoch_group(), create_new_epoch(), and get_epoch_group_position_factor().

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

◆ get_epoch_member_position()

uint32_t get_epoch_member_position ( const struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_MESSENGER_Contact contact 
)

Returns the index position of a specific contact inside a given epoch in relation to its list of members.

Every member of an epoch gets a unique position.

Parameters
[in]epochEpoch
[in]contactContact
Returns
Member position

Definition at line 1162 of file messenger_api_epoch.c.

1164{
1165 const struct GNUNET_CRYPTO_PublicKey *key;
1166 char *key_string;
1167 uint32_t position;
1168 uint32_t i;
1169 int result;
1170
1171 GNUNET_assert ((epoch) && (contact));
1172
1173 key = get_contact_key (contact);
1175
1176 if (! key_string)
1177 return epoch->members_count;
1178
1179 position = 0;
1180
1181 for (i = 0; i < epoch->members_count; i++)
1182 {
1184 key_string, get_contact_key (epoch->members[i]));
1185
1186 if ((0 < result) ||
1187 ((0 == result) && (contact->id < epoch->members[i]->id)))
1188 position++;
1189 }
1190
1191 GNUNET_free (key_string);
1192 return position;
1193}
struct GNUNET_HashCode key
The key used in the DHT.
static int result
Global testing status.
char * GNUNET_CRYPTO_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
Definition: crypto_pkey.c:379
const struct GNUNET_CRYPTO_PublicKey * get_contact_key(const struct GNUNET_MESSENGER_Contact *contact)
Returns the public key of a given contact.
static int compare_member_public_keys(const char *key_string, const struct GNUNET_CRYPTO_PublicKey *key)
An identity key as per LSD0001.

References compare_member_public_keys(), get_contact_key(), GNUNET_assert, GNUNET_CRYPTO_public_key_to_string(), GNUNET_free, GNUNET_MESSENGER_Contact::id, key, GNUNET_MESSENGER_Epoch::members, GNUNET_MESSENGER_Epoch::members_count, and result.

Referenced by get_epoch_position_factor().

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

◆ is_epoch_member()

enum GNUNET_GenericReturnValue is_epoch_member ( const struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_MESSENGER_Contact contact 
)

Returns whether a specific contact is member of a given epoch.

Parameters
[in]epochEpoch
[in]contactContact
Returns
GNUNET_YES if contact is a member, GNUNET_SYSERR on internal failure, otherwise GNUNET_NO

Definition at line 1304 of file messenger_api_epoch.c.

1306{
1307 uint32_t i;
1308
1309 GNUNET_assert ((epoch) && (contact));
1310
1311 for (i = 0; i < epoch->members_count; i++)
1312 if (contact == epoch->members[i])
1313 return GNUNET_YES;
1314
1315 return is_epoch_member_in_room (epoch->room, &(epoch->hash), contact);
1316}
static enum GNUNET_GenericReturnValue is_epoch_member_in_room(const struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *epoch, const struct GNUNET_MESSENGER_Contact *contact)

References GNUNET_assert, GNUNET_YES, GNUNET_MESSENGER_Epoch::hash, is_epoch_member_in_room(), GNUNET_MESSENGER_Epoch::members, GNUNET_MESSENGER_Epoch::members_count, and GNUNET_MESSENGER_Epoch::room.

Referenced by confirm_epoch_announcement_member(), confirm_epoch_group_member(), get_room_availble_epoch_entry(), handle_appeal_message(), handle_room_delayed_appeal(), invalidate_epoch_announcement(), and invalidate_epoch_group().

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

◆ get_epoch_position_factor()

double get_epoch_position_factor ( const struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_MESSENGER_Contact contact,
const struct GNUNET_MESSENGER_EpochMembership membership 
)

Returns a relative member positon of a specific contact inside a given epoch in relation to its list of members.

The position gets reduced depending on an optional active membership from a subgroup.

Parameters
[in]epochEpoch
[in]contactContact
[in]membershipMembership or NULL
Returns
Member position as factor between 0.0 and 1.0

Definition at line 1320 of file messenger_api_epoch.c.

1324{
1325 uint32_t members_count;
1326 uint32_t announced;
1327 uint32_t position;
1328
1329 GNUNET_assert ((epoch) && (contact));
1330
1331 members_count = get_epoch_size (epoch);
1332 announced = membership?
1333 get_epoch_membership_count (membership) : 0;
1334
1335 if (members_count <= announced)
1336 return 0.0;
1337
1338 position = get_epoch_member_position (epoch, contact);
1339
1340 if (position > announced)
1341 position -= announced;
1342 else
1343 position = 0;
1344
1345 return (0.0 + position) / (members_count - announced);
1346}
uint32_t get_epoch_member_position(const struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact)
Returns the index position of a specific contact inside a given epoch in relation to its list of memb...
uint32_t get_epoch_size(const struct GNUNET_MESSENGER_Epoch *epoch)
Returns the amount of members by a given epoch or zero as long as it's not fully initialized yet.
uint32_t get_epoch_membership_count(const struct GNUNET_MESSENGER_EpochMembership *membership)
Returns the current amount of individual members inside a given epoch membership.

References get_epoch_member_position(), get_epoch_membership_count(), get_epoch_size(), and GNUNET_assert.

Referenced by handle_appeal_message(), and handle_epoch_announcement().

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

◆ send_epoch_message()

void send_epoch_message ( const struct GNUNET_MESSENGER_Epoch epoch,
struct GNUNET_MESSENGER_Message message 
)

Sends a created and allocated message in a room of a given epoch enforcing the message gets interpreted as part of that exact epoch.

Parameters
[in]epochEpoch
[in,out]messageMessage

Definition at line 1350 of file messenger_api_epoch.c.

1352{
1353 GNUNET_assert ((epoch) && (message));
1354
1356 &(epoch->hash),
1357 message,
1358 NULL,
1359 GNUNET_YES);
1360}
void enqueue_message_to_room(struct GNUNET_MESSENGER_Room *room, const struct GNUNET_HashCode *epoch, struct GNUNET_MESSENGER_Message *message, struct GNUNET_MESSENGER_Message *transcript, enum GNUNET_GenericReturnValue sync)
Enqueus a message and its optional transcript for sending it to a given room and epoch.

References enqueue_message_to_room(), GNUNET_assert, GNUNET_YES, GNUNET_MESSENGER_Epoch::hash, and GNUNET_MESSENGER_Epoch::room.

Referenced by send_epoch_announcement(), send_epoch_announcement_access(), send_epoch_announcement_appeal(), send_epoch_announcement_authorization(), send_epoch_announcement_revolution(), send_epoch_group(), send_epoch_group_access(), send_epoch_group_announcement(), send_epoch_group_authorization(), and send_epoch_group_revolution().

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

◆ update_epoch_announcement()

void update_epoch_announcement ( struct GNUNET_MESSENGER_Epoch epoch,
struct GNUNET_MESSENGER_EpochAnnouncement announcement 
)

Updates the main announcement of a given epoch, looking into replacing the current main announcement with a specific epoch announcement that's provided.

The main announcement will be used for encrypting own messages in that epoch.

Parameters
[in,out]epochEpoch
[in,out]announcementEpoch announcement

Definition at line 1364 of file messenger_api_epoch.c.

1367{
1368 GNUNET_assert ((epoch) && (announcement));
1369
1370 if (! get_epoch_announcement_key (announcement))
1371 return;
1372
1373 if (GNUNET_YES != announcement->valid)
1374 return;
1375
1376 if ((! epoch->main_announcement) ||
1378 epoch->main_announcement, announcement)))
1379 epoch->main_announcement = announcement;
1380}
static enum GNUNET_GenericReturnValue is_other_epoch_announcement_better(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, const struct GNUNET_MESSENGER_EpochAnnouncement *other)
const struct GNUNET_CRYPTO_SymmetricSessionKey * get_epoch_announcement_key(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns the secret key of a given epoch announcement or NULL.

References get_epoch_announcement_key(), GNUNET_assert, GNUNET_YES, is_other_epoch_announcement_better(), GNUNET_MESSENGER_Epoch::main_announcement, and GNUNET_MESSENGER_EpochAnnouncement::valid.

Referenced by confirm_epoch_announcement_member(), and set_epoch_announcement_key().

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

◆ update_epoch_group()

void update_epoch_group ( struct GNUNET_MESSENGER_Epoch epoch,
struct GNUNET_MESSENGER_EpochGroup group 
)

Updates the main group of a given epoch, looking into replacing the current main group with a specific epoch group that's provided.

The main group will be used for encrypted key exchange.

Parameters
[in,out]epochEpoch
[in,out]groupEpoch group

Definition at line 1413 of file messenger_api_epoch.c.

1415{
1416 GNUNET_assert ((epoch) && (group));
1417
1418 if (! get_epoch_group_key (group))
1419 return;
1420
1421 if (GNUNET_YES != group->valid)
1422 return;
1423
1424 if (GNUNET_YES != is_epoch_group_completed (group))
1425 return;
1426
1427 if (GNUNET_YES == is_epoch_group_proposal (group))
1428 {
1429 if (epoch->proposal_timeout)
1431
1432 epoch->proposal_timeout = NULL;
1433
1434 memset (&(epoch->proposal_hash), 0, sizeof (epoch->proposal_hash));
1436 }
1437
1438 if ((! epoch->main_group) ||
1440 group)))
1441 epoch->main_group = group;
1442}
static void set_epoch_proposing(struct GNUNET_MESSENGER_Epoch *epoch, struct GNUNET_TIME_Relative timeout)
enum GNUNET_GenericReturnValue is_epoch_group_proposal(const struct GNUNET_MESSENGER_EpochGroup *group)
Returns whether a given epoch group is the current proposal of the client.
enum GNUNET_GenericReturnValue is_epoch_group_completed(const struct GNUNET_MESSENGER_EpochGroup *group)
Returns whether a given epoch group is complete in terms of confirmed announcements from its members.

References get_epoch_group_key(), GNUNET_assert, GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_get_zero_(), GNUNET_YES, is_epoch_group_completed(), is_epoch_group_proposal(), is_other_epoch_group_better(), GNUNET_MESSENGER_Epoch::main_group, GNUNET_MESSENGER_Epoch::proposal_hash, GNUNET_MESSENGER_Epoch::proposal_timeout, set_epoch_proposing(), and GNUNET_MESSENGER_EpochGroup::valid.

Referenced by confirm_epoch_group_member(), and set_epoch_group_key().

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

◆ propose_epoch_group()

void propose_epoch_group ( struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_TIME_Relative  timeout 
)

Tries to propose a new group inside a given epoch that will automatically be formed by using the clients own main group and another group on the same level.

The proposal is active until a specified timeout. Multiple groups can not be proposed in parallel by the same client.

Parameters
[in,out]epochEpoch
[in]timeoutTimeout for proposal

Definition at line 1536 of file messenger_api_epoch.c.

1538{
1539 uint32_t level;
1540 struct GNUNET_MESSENGER_EpochGroup *group;
1541 struct GNUNET_HashCode initiator;
1542 struct GNUNET_HashCode partner;
1543
1544 GNUNET_assert (epoch);
1545
1546 if (GNUNET_YES != epoch->room->handle->group_keys)
1547 return;
1548
1549 if ((epoch->proposal_timeout) ||
1550 (GNUNET_YES == is_epoch_proposing (epoch)))
1551 return;
1552
1553 if (epoch->main_group)
1554 {
1556
1558 return;
1559
1560 if (GNUNET_OK != get_epoch_group_member_hash (epoch->main_group, &(initiator
1561 ),
1562 GNUNET_NO))
1563 return;
1564
1565 level = get_epoch_group_level (epoch->main_group);
1567
1568 if (! iter)
1569 return;
1570
1571 group = NULL;
1572
1574 NULL,
1575 (const
1576 void**)
1577 &group))
1578 {
1579 if ((epoch->main_group != group) &&
1580 (level == get_epoch_group_level (group)) &&
1581 (GNUNET_YES == is_epoch_group_completed (group)) &&
1582 (GNUNET_YES != is_epoch_subgroup_of_any_group (epoch, group)))
1583 break;
1584
1585 group = NULL;
1586 }
1587
1589
1590 if (! group)
1591 return;
1592
1593 if (GNUNET_OK != get_epoch_group_member_hash (group, &partner, GNUNET_YES))
1594 return;
1595 }
1596 else if (epoch->main_announcement)
1597 {
1599 struct GNUNET_HashCode hash;
1600 const struct GNUNET_MESSENGER_Contact *contact;
1601
1603 )
1604 return;
1605
1607 main_announcement, &(
1608 initiator), GNUNET_NO
1609 ))
1610 return;
1611
1612 level = 0;
1614 main_announcement->
1615 membership->members);
1616
1617 if (! iter)
1618 return;
1619
1620 contact = NULL;
1621
1623 hash,
1624 (const
1625 void**) &
1626 contact))
1627 {
1628 if ((0 != GNUNET_CRYPTO_hash_cmp (&initiator, &hash)) &&
1629 (GNUNET_NO == is_epoch_member_in_any_group (epoch, contact)))
1630 break;
1631
1632 contact = NULL;
1633 }
1634
1636
1637 if (! contact)
1638 return;
1639
1640 GNUNET_memcpy (&partner, &hash, sizeof (partner));
1641 }
1642 else
1643 return;
1644
1645 level++;
1646 if (level >= 0x80)
1647 return;
1648
1649 group = create_epoch_group (epoch, NULL, level, GNUNET_YES);
1650
1651 if (! group)
1652 return;
1653
1655 &(group->identifier.hash)
1656 ,
1657 group,
1659 {
1660 destroy_epoch_group (group);
1661 return;
1662 }
1663
1664 if (GNUNET_OK != send_epoch_group (group, &initiator, &partner, timeout))
1665 {
1666 GNUNET_CONTAINER_multishortmap_remove (epoch->groups, &(group->identifier.
1667 hash), group);
1668 destroy_epoch_group (group);
1669 return;
1670 }
1671
1673}
void GNUNET_CONTAINER_multishortmap_iterator_destroy(struct GNUNET_CONTAINER_MultiShortmapIterator *iter)
Destroy a multishortmap iterator.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_iterator_next(struct GNUNET_CONTAINER_MultiHashMapIterator *iter, struct GNUNET_HashCode *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
struct GNUNET_CONTAINER_MultiShortmapIterator * GNUNET_CONTAINER_multishortmap_iterator_create(const struct GNUNET_CONTAINER_MultiShortmap *map)
Create an iterator for a multihashmap.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multishortmap_iterator_next(struct GNUNET_CONTAINER_MultiShortmapIterator *iter, struct GNUNET_ShortHashCode *key, const void **value)
Retrieve the next element from the hash map at the iterator's position.
void GNUNET_CONTAINER_multihashmap_iterator_destroy(struct GNUNET_CONTAINER_MultiHashMapIterator *iter)
Destroy a multihashmap iterator.
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.
struct GNUNET_CONTAINER_MultiHashMapIterator * GNUNET_CONTAINER_multihashmap_iterator_create(const struct GNUNET_CONTAINER_MultiHashMap *map)
Create an iterator for a multihashmap.
static enum GNUNET_GenericReturnValue is_epoch_subgroup_of_any_group(struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_EpochGroup *subgroup)
enum GNUNET_GenericReturnValue is_epoch_member_in_any_group(struct GNUNET_MESSENGER_Epoch *epoch, const struct GNUNET_MESSENGER_Contact *contact)
static enum GNUNET_GenericReturnValue is_epoch_proposing(const struct GNUNET_MESSENGER_Epoch *epoch)
enum GNUNET_GenericReturnValue get_epoch_announcement_member_hash(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement, struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue other)
Provides an announcement hash of a member from a given epoch announcement.
enum GNUNET_GenericReturnValue is_epoch_announcement_announced(const struct GNUNET_MESSENGER_EpochAnnouncement *announcement)
Returns whether the client has announced being part of a given epoch announcement owning its secret k...
enum GNUNET_GenericReturnValue send_epoch_group(struct GNUNET_MESSENGER_EpochGroup *group, const struct GNUNET_HashCode *initiator_event, const struct GNUNET_HashCode *partner_event, struct GNUNET_TIME_Relative timeout)
Tries to send a group message by the client for a given epoch group to propose it forming a group out...
uint32_t get_epoch_group_level(const struct GNUNET_MESSENGER_EpochGroup *group)
Returns the group level of a given epoch group.
enum GNUNET_GenericReturnValue get_epoch_group_member_hash(const struct GNUNET_MESSENGER_EpochGroup *group, struct GNUNET_HashCode *hash, enum GNUNET_GenericReturnValue other)
Provides an announcement hash of a member from a given epoch group.
A 512-bit hashcode.
enum GNUNET_GenericReturnValue group_keys
struct GNUNET_MESSENGER_Handle * handle

References create_epoch_group(), destroy_epoch_group(), get_epoch_announcement_member_hash(), get_epoch_group_level(), get_epoch_group_member_hash(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterator_create(), GNUNET_CONTAINER_multihashmap_iterator_destroy(), GNUNET_CONTAINER_multihashmap_iterator_next(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST, GNUNET_CONTAINER_multishortmap_iterator_create(), GNUNET_CONTAINER_multishortmap_iterator_destroy(), GNUNET_CONTAINER_multishortmap_iterator_next(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_CRYPTO_hash_cmp(), GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_YES, GNUNET_MESSENGER_Handle::group_keys, GNUNET_MESSENGER_Epoch::groups, GNUNET_MESSENGER_Room::handle, GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_EpochGroup::identifier, is_epoch_announcement_announced(), is_epoch_group_completed(), is_epoch_member_in_any_group(), is_epoch_proposing(), is_epoch_subgroup_of_any_group(), GNUNET_MESSENGER_Epoch::main_announcement, GNUNET_MESSENGER_Epoch::main_group, GNUNET_MESSENGER_Epoch::members, GNUNET_MESSENGER_Epoch::proposal_timeout, GNUNET_MESSENGER_Epoch::room, send_epoch_group(), set_epoch_proposing(), and timeout.

Referenced by handle_epoch_announcement_delay(), and handle_epoch_group_announcement_delay().

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

◆ set_epoch_proposal_group()

void set_epoch_proposal_group ( struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_HashCode hash 
)

Sets the current group of proposal for a given epoch to the group specified by a message identified by its hash.

Timeout for the proposal and other properties will be derived from that message accordingly.

Parameters
[in,out]epochEpoch
[in]hashHash of message

Definition at line 1677 of file messenger_api_epoch.c.

1679{
1680 const struct GNUNET_MESSENGER_Message *group_message;
1682
1683 GNUNET_assert ((epoch) && (hash));
1684
1685 if (epoch->proposal_timeout)
1686 return;
1687
1688 group_message = get_room_message (epoch->room, hash);
1689
1690 if (! group_message)
1691 return;
1692
1693 if (GNUNET_MESSENGER_KIND_GROUP != group_message->header.kind)
1694 return;
1695
1696 if (! group_message->body.group.identifier.code.group_bit)
1697 return;
1698
1699 timeout = get_message_timeout (group_message);
1700
1702 return;
1703
1704 GNUNET_memcpy (&(epoch->proposal_hash), hash, sizeof (epoch->proposal_hash));
1706
1708 timeout,
1711 epoch);
1712}
@ GNUNET_SCHEDULER_PRIORITY_HIGH
Run with high priority (important requests).
@ GNUNET_MESSENGER_KIND_GROUP
The group kind.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed_with_priority(struct GNUNET_TIME_Relative delay, enum GNUNET_SCHEDULER_Priority priority, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1207
bool GNUNET_TIME_relative_is_zero(struct GNUNET_TIME_Relative rel)
Test if rel is zero.
Definition: time.c:664
static void on_epoch_proposal_timeout(void *cls)
struct GNUNET_TIME_Relative get_message_timeout(const struct GNUNET_MESSENGER_Message *message)
Return the relative timeout of the content from a given message that controls when a delayed handling...
struct GNUNET_MESSENGER_MessageGroup group
union GNUNET_MESSENGER_EpochIdentifier identifier
The identifier of the group in an epoch.
Time for relative time used by GNUnet, in microseconds.

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, get_message_timeout(), get_room_message(), GNUNET_assert, GNUNET_memcpy, GNUNET_MESSENGER_KIND_GROUP, GNUNET_SCHEDULER_add_delayed_with_priority(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_TIME_relative_is_zero(), GNUNET_MESSENGER_MessageBody::group, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageGroup::identifier, GNUNET_MESSENGER_MessageHeader::kind, on_epoch_proposal_timeout(), GNUNET_MESSENGER_Epoch::proposal_hash, GNUNET_MESSENGER_Epoch::proposal_timeout, GNUNET_MESSENGER_Epoch::room, set_epoch_proposing(), and timeout.

Referenced by handle_group_message().

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

◆ get_epoch_proposal_group()

const struct GNUNET_MESSENGER_EpochGroup * get_epoch_proposal_group ( struct GNUNET_MESSENGER_Epoch epoch)

Returns the current group of proposal for a given epoch.

Parameters
[in,out]epochEpoch
Returns
Proposal group or NULL

Definition at line 1716 of file messenger_api_epoch.c.

1717{
1718 const struct GNUNET_MESSENGER_Message *group_message;
1719
1720 GNUNET_assert (epoch);
1721
1722 group_message = get_room_message (epoch->room, &(epoch->proposal_hash));
1723
1724 if (! group_message)
1725 return NULL;
1726
1727 if (GNUNET_MESSENGER_KIND_GROUP != group_message->header.kind)
1728 return NULL;
1729
1730 if (! group_message->body.group.identifier.code.group_bit)
1731 return NULL;
1732
1733 return get_epoch_group (epoch, &(group_message->body.group.identifier),
1734 GNUNET_NO);
1735}

References GNUNET_MESSENGER_Message::body, GNUNET_MESSENGER_EpochIdentifier::code, get_epoch_group(), get_room_message(), GNUNET_assert, GNUNET_MESSENGER_KIND_GROUP, GNUNET_NO, GNUNET_MESSENGER_MessageBody::group, GNUNET_MESSENGER_EpochIdentifierCode::group_bit, GNUNET_MESSENGER_Message::header, GNUNET_MESSENGER_MessageGroup::identifier, GNUNET_MESSENGER_MessageHeader::kind, GNUNET_MESSENGER_Epoch::proposal_hash, and GNUNET_MESSENGER_Epoch::room.

Referenced by cancel_epoch_proposal_group(), handle_epoch_group_announcement(), and is_epoch_group_proposal().

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

◆ cancel_epoch_proposal_group()

void cancel_epoch_proposal_group ( struct GNUNET_MESSENGER_Epoch epoch)

Cancels the current proposal of a new group from a given epoch.

Parameters
[in,out]epochEpoch

Definition at line 1739 of file messenger_api_epoch.c.

1740{
1741 const struct GNUNET_MESSENGER_EpochGroup *proposal_group;
1742
1744
1746 {
1748 epoch->proposal_timeout = NULL;
1749 }
1750
1751 proposal_group = get_epoch_proposal_group (epoch);
1752
1753 memset (&(epoch->proposal_hash), 0, sizeof (epoch->proposal_hash));
1754
1755 if (! proposal_group)
1756 return;
1757
1758 if (GNUNET_YES != is_epoch_group_completed (proposal_group))
1760 &(proposal_group->identifier.hash),
1761 proposal_group);
1762}
const struct GNUNET_MESSENGER_EpochGroup * get_epoch_proposal_group(struct GNUNET_MESSENGER_Epoch *epoch)
Returns the current group of proposal for a given epoch.

References GNUNET_MESSENGER_EpochGroup::epoch, get_epoch_proposal_group(), GNUNET_assert, GNUNET_CONTAINER_multishortmap_remove(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, GNUNET_MESSENGER_Epoch::groups, GNUNET_MESSENGER_EpochIdentifier::hash, GNUNET_MESSENGER_EpochGroup::identifier, is_epoch_group_completed(), GNUNET_MESSENGER_Epoch::proposal_hash, and GNUNET_MESSENGER_Epoch::proposal_timeout.

Referenced by handle_epoch_group_access(), handle_epoch_group_announcement(), and on_epoch_proposal_timeout().

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

◆ invalidate_epoch_keys_by_member()

void invalidate_epoch_keys_by_member ( struct GNUNET_MESSENGER_Epoch epoch,
const struct GNUNET_MESSENGER_Contact contact 
)

Invalidates all announced epoch and group keys by a specific contact inside a given epoch.

Parameters
[in,out]epochEpoch
[in]contactContact

Definition at line 1802 of file messenger_api_epoch.c.

1805{
1806 GNUNET_assert ((epoch) && (contact));
1807
1810 &contact);
1811
1814 &contact);
1815}
static enum GNUNET_GenericReturnValue iterate_epoch_announcement_invalidation(void *cls, const struct GNUNET_ShortHashCode *key, void *value)
static enum GNUNET_GenericReturnValue iterate_epoch_group_invalidation(void *cls, const struct GNUNET_ShortHashCode *key, void *value)

References GNUNET_MESSENGER_Epoch::announcements, GNUNET_MESSENGER_EpochGroup::epoch, GNUNET_assert, GNUNET_CONTAINER_multishortmap_iterate(), GNUNET_MESSENGER_Epoch::groups, iterate_epoch_announcement_invalidation(), and iterate_epoch_group_invalidation().

Referenced by iterate_room_epoch_member_invalidation().

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