Go to the source code of this file.
Data Structures | |
struct | IBF_Key |
Keys that can be inserted into and removed from an IBF. More... | |
struct | IBF_KeyHash |
Hash of an IBF key. More... | |
struct | IBF_Count |
Type of the count field of IBF buckets. More... | |
struct | InvertibleBloomFilter |
Invertible bloom filter (IBF). More... | |
Macros | |
#define | IBF_BUCKET_SIZE |
Size of one ibf bucket in bytes. More... | |
Functions | |
void | ibf_write_slice (const struct InvertibleBloomFilter *ibf, uint32_t start, uint64_t count, void *buf, uint8_t counter_max_length) |
Write buckets from an ibf to a buffer. More... | |
void | ibf_read_slice (const void *buf, uint32_t start, uint64_t count, struct InvertibleBloomFilter *ibf, uint8_t counter_max_length) |
Read buckets from a buffer into an ibf. More... | |
struct IBF_Key | ibf_key_from_hashcode (const struct GNUNET_HashCode *hash) |
Create a key from a hashcode. More... | |
void | ibf_hashcode_from_key (struct IBF_Key key, struct GNUNET_HashCode *dst) |
Create a hashcode from a key, by replicating the key until the hascode is filled. More... | |
struct InvertibleBloomFilter * | ibf_create (uint32_t size, uint8_t hash_num) |
Create an invertible bloom filter. More... | |
void | ibf_insert (struct InvertibleBloomFilter *ibf, struct IBF_Key key) |
Insert a key into an IBF. More... | |
void | ibf_remove (struct InvertibleBloomFilter *ibf, struct IBF_Key key) |
Remove a key from an IBF. More... | |
void | ibf_subtract (struct InvertibleBloomFilter *ibf1, const struct InvertibleBloomFilter *ibf2) |
Subtract ibf2 from ibf1, storing the result in ibf1. More... | |
int | ibf_decode (struct InvertibleBloomFilter *ibf, int *ret_side, struct IBF_Key *ret_id) |
Decode and remove an element from the IBF, if possible. More... | |
struct InvertibleBloomFilter * | ibf_dup (const struct InvertibleBloomFilter *ibf) |
Create a copy of an IBF, the copy has to be destroyed properly. More... | |
void | ibf_destroy (struct InvertibleBloomFilter *ibf) |
Destroy all resources associated with the invertible bloom filter. More... | |
uint8_t | ibf_get_max_counter (struct InvertibleBloomFilter *ibf) |
Returns the minimal bytes needed to store the counter of the IBF. More... | |
void | pack_counter (const struct InvertibleBloomFilter *ibf, uint32_t start, uint64_t count, uint8_t *buf, uint8_t counter_max_length) |
Packs the counter to transmit only the smallest possible amount of bytes and preventing overflow of the counter. More... | |
void | unpack_counter (const struct InvertibleBloomFilter *ibf, uint32_t start, uint64_t count, uint8_t *buf, uint8_t counter_max_length) |
Unpacks the counter to transmit only the smallest possible amount of bytes and preventing overflow of the counter. More... | |
#define IBF_BUCKET_SIZE |
Size of one ibf bucket in bytes.
void ibf_write_slice | ( | const struct InvertibleBloomFilter * | ibf, |
uint32_t | start, | ||
uint64_t | count, | ||
void * | buf, | ||
uint8_t | counter_max_length | ||
) |
Write buckets from an ibf to a buffer.
Exactly (IBF_BUCKET_SIZE*ibf->size) bytes are written to buf.
ibf | the ibf to write |
start | with which bucket to start |
count | how many buckets to write |
buf | buffer to write the data to |
Exactly (IBF_BUCKET_SIZE*ibf->size) bytes are written to buf.
ibf | the ibf to write |
start | with which bucket to start |
count | how many buckets to write |
buf | buffer to write the data to |
max | bit length of a counter for unpacking |
Definition at line 312 of file ibf.c.
References GNUNET_assert, GNUNET_memcpy, InvertibleBloomFilter::key_hash_sum, InvertibleBloomFilter::key_sum, pack_counter(), size, and start.
void ibf_read_slice | ( | const void * | buf, |
uint32_t | start, | ||
uint64_t | count, | ||
struct InvertibleBloomFilter * | ibf, | ||
uint8_t | counter_max_length | ||
) |
Read buckets from a buffer into an ibf.
buf | pointer to the buffer to read from |
start | which bucket to start at |
count | how many buckets to read |
ibf | the ibf to write to |
buf | pointer to the buffer to read from |
start | which bucket to start at |
count | how many buckets to read |
ibf | the ibf to read from |
max | bit length of a counter for unpacking |
Definition at line 493 of file ibf.c.
References GNUNET_assert, GNUNET_memcpy, InvertibleBloomFilter::key_hash_sum, InvertibleBloomFilter::key_sum, size, start, and unpack_counter().
struct IBF_Key ibf_key_from_hashcode | ( | const struct GNUNET_HashCode * | hash | ) |
Create a key from a hashcode.
hash | the hashcode |
Definition at line 44 of file ibf.c.
Referenced by insert_iterator(), and register_hashcode().
void ibf_hashcode_from_key | ( | struct IBF_Key | key, |
struct GNUNET_HashCode * | dst | ||
) |
Create a hashcode from a key, by replicating the key until the hascode is filled.
key | the key |
dst | hashcode to store the result in |
Definition at line 58 of file ibf.c.
Referenced by iter_hashcodes(), and register_hashcode().
struct InvertibleBloomFilter * ibf_create | ( | uint32_t | size, |
uint8_t | hash_num | ||
) |
Create an invertible bloom filter.
size | number of IBF buckets |
hash_num | number of buckets one element is hashed in, usually 3 or 4 |
size | number of IBF buckets |
hash_num | number of buckets one element is hashed in |
Definition at line 80 of file ibf.c.
References InvertibleBloomFilter::count, GNUNET_assert, GNUNET_free, GNUNET_malloc_large, GNUNET_new, hash_num, InvertibleBloomFilter::hash_num, InvertibleBloomFilter::key_hash_sum, InvertibleBloomFilter::key_sum, InvertibleBloomFilter::size, and size.
Referenced by handle_union_p2p_ibf(), prepare_ibf(), run(), and strata_estimator_create().
void ibf_insert | ( | struct InvertibleBloomFilter * | ibf, |
struct IBF_Key | key | ||
) |
Insert a key into an IBF.
ibf | the IBF |
key | the element's hash code |
Definition at line 168 of file ibf.c.
References GNUNET_assert, InvertibleBloomFilter::hash_num, ibf_get_indices(), ibf_insert_into(), key, and InvertibleBloomFilter::size.
Referenced by insert_iterator(), prepare_ibf_iterator(), and strata_estimator_insert().
void ibf_remove | ( | struct InvertibleBloomFilter * | ibf, |
struct IBF_Key | key | ||
) |
Remove a key from an IBF.
ibf | the IBF |
key | the element's hash code |
Definition at line 185 of file ibf.c.
References GNUNET_assert, InvertibleBloomFilter::hash_num, ibf_get_indices(), ibf_insert_into(), key, and InvertibleBloomFilter::size.
Referenced by strata_estimator_remove().
void ibf_subtract | ( | struct InvertibleBloomFilter * | ibf1, |
const struct InvertibleBloomFilter * | ibf2 | ||
) |
Subtract ibf2 from ibf1, storing the result in ibf1.
The two IBF's must have the same parameters size and hash_num.
ibf1 | IBF that is subtracted from |
ibf2 | IBF that will be subtracted from ibf1 |
Definition at line 357 of file ibf.c.
References InvertibleBloomFilter::count, IBF_Count::count_val, GNUNET_assert, InvertibleBloomFilter::hash_num, InvertibleBloomFilter::key_hash_sum, IBF_KeyHash::key_hash_val, InvertibleBloomFilter::key_sum, IBF_Key::key_val, and InvertibleBloomFilter::size.
Referenced by decode_and_send(), run(), and strata_estimator_difference().
int ibf_decode | ( | struct InvertibleBloomFilter * | ibf, |
int * | ret_side, | ||
struct IBF_Key * | ret_id | ||
) |
Decode and remove an element from the IBF, if possible.
ibf | the invertible bloom filter to decode |
ret_side | sign of the cell's count where the decoded element came from. A negative sign indicates that the element was recovered resides in an IBF that was previously subtracted from. |
ret_id | receives the hash code of the decoded element, if successful |
ibf | the invertible bloom filter to decode |
ret_side | sign of the cell's count where the decoded element came from. A negative sign indicates that the element was recovered resides in an IBF that was previously subtracted from. |
ret_id | receives the hash code of the decoded element, if successful |
ibf | the invertible bloom filter to decode |
ret_side | sign of the cell's count where the decoded element came from. A negative sign indicates that the element was recovered resides in an IBF that was previously subtracted from. |
ret_id | receives the hash code of the decoded element, if successful |
ibf | the invertible bloom filter to decode |
ret_side | sign of the cell's count where the decoded element came from. A negative sign indicates that the element was recovered resides in an IBF that was previously subtracted from. |
ret_id | receives the hash code of the decoded element, if successful |
Definition at line 229 of file ibf.c.
References InvertibleBloomFilter::count, IBF_Count::count_val, GNUNET_assert, GNUNET_NO, GNUNET_SYSERR, GNUNET_YES, InvertibleBloomFilter::hash_num, ibf_get_indices(), ibf_insert_into(), ibf_is_empty(), IBF_KEY_HASH_VAL, InvertibleBloomFilter::key_hash_sum, IBF_KeyHash::key_hash_val, InvertibleBloomFilter::key_sum, InvertibleBloomFilter::local_decoded_count, InvertibleBloomFilter::remote_decoded_count, and InvertibleBloomFilter::size.
Referenced by decode_and_send(), run(), and strata_estimator_difference().
struct InvertibleBloomFilter * ibf_dup | ( | const struct InvertibleBloomFilter * | ibf | ) |
Create a copy of an IBF, the copy has to be destroyed properly.
ibf | the IBF to copy |
Definition at line 380 of file ibf.c.
References InvertibleBloomFilter::count, GNUNET_malloc, GNUNET_memdup, InvertibleBloomFilter::hash_num, InvertibleBloomFilter::key_hash_sum, InvertibleBloomFilter::key_sum, and InvertibleBloomFilter::size.
Referenced by decode_and_send(), strata_estimator_difference(), and strata_estimator_dup().
void ibf_destroy | ( | struct InvertibleBloomFilter * | ibf | ) |
Destroy all resources associated with the invertible bloom filter.
No more ibf_*-functions may be called on ibf after calling destroy.
ibf | the intertible bloom filter to destroy |
Definition at line 404 of file ibf.c.
References InvertibleBloomFilter::count, GNUNET_free, InvertibleBloomFilter::key_hash_sum, and InvertibleBloomFilter::key_sum.
Referenced by _GSS_operation_destroy(), decode_and_send(), prepare_ibf(), strata_estimator_create(), strata_estimator_destroy(), strata_estimator_difference(), and union_op_cancel().
uint8_t ibf_get_max_counter | ( | struct InvertibleBloomFilter * | ibf | ) |
Returns the minimal bytes needed to store the counter of the IBF.
ibf | the IBF |
Definition at line 287 of file ibf.c.
References InvertibleBloomFilter::count, IBF_Count::count_val, and InvertibleBloomFilter::size.
Referenced by send_ibf().
void pack_counter | ( | const struct InvertibleBloomFilter * | ibf, |
uint32_t | start, | ||
uint64_t | count, | ||
uint8_t * | buf, | ||
uint8_t | counter_max_length | ||
) |
Packs the counter to transmit only the smallest possible amount of bytes and preventing overflow of the counter.
ibf | the ibf to write |
start | with which bucket to start |
count | how many buckets to write |
buf | buffer to write the data to |
max | bit length of a counter for unpacking |
Iterate over IBF bucket
Pack and compose counters to byte values
Shift bits if more than a byte has to be written or the store size is not empty
Pack data left in story before finishing
Definition at line 348 of file ibf.c.
References InvertibleBloomFilter::count, IBF_Count::count_val, and start.
Referenced by ibf_write_slice().
void unpack_counter | ( | const struct InvertibleBloomFilter * | ibf, |
uint32_t | start, | ||
uint64_t | count, | ||
uint8_t * | buf, | ||
uint8_t | counter_max_length | ||
) |
Unpacks the counter to transmit only the smallest possible amount of bytes and preventing overflow of the counter.
ibf | the ibf to write |
start | with which bucket to start |
count | how many buckets to write |
buf | buffer to write the data to |
max | bit length of a counter for unpacking |
Iterate over received bytes
Pack data left in story before finishing
Stop decoding when end is reached
Definition at line 411 of file ibf.c.
References InvertibleBloomFilter::count, IBF_Count::count_val, and start.
Referenced by ibf_read_slice().