Go to the source code of this file.
Macros | |
| #define | LOG(kind, ...) GNUNET_log_from (kind, "setu", __VA_ARGS__) |
| #define | IBF_KEY_HASH_VAL(k) |
| Compute the key's hash from the key. | |
Functions | |
| struct IBF_Key | ibf_key_from_hashcode (const struct GNUNET_HashCode *hash) |
| Create a key from a 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. | |
| struct InvertibleBloomFilter * | ibf_create (uint32_t size, uint8_t hash_num) |
| Create an invertible bloom filter. | |
| static void | ibf_get_indices (const struct InvertibleBloomFilter *ibf, struct IBF_Key key, int *dst) |
| Store unique bucket indices for the specified key in dst. | |
| static void | ibf_insert_into (struct InvertibleBloomFilter *ibf, struct IBF_Key key, const int *buckets, int side) |
| void | ibf_insert (struct InvertibleBloomFilter *ibf, struct IBF_Key key) |
| Insert a key into an IBF. | |
| void | ibf_remove (struct InvertibleBloomFilter *ibf, struct IBF_Key key) |
| Remove a key from an IBF. | |
| static int | ibf_is_empty (struct InvertibleBloomFilter *ibf) |
| Test is the IBF is empty, i.e. | |
| int | ibf_decode (struct InvertibleBloomFilter *ibf, int *ret_side, struct IBF_Key *ret_id) |
| Decode and remove an element from the IBF, if possible. | |
| uint8_t | ibf_get_max_counter (struct InvertibleBloomFilter *ibf) |
| Returns the minimal bytes needed to store the counter of the IBF. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| void | ibf_subtract (struct InvertibleBloomFilter *ibf1, const struct InvertibleBloomFilter *ibf2) |
| Subtract ibf2 from ibf1, storing the result in ibf1. | |
| struct InvertibleBloomFilter * | ibf_dup (const struct InvertibleBloomFilter *ibf) |
| Create a copy of an IBF, the copy has to be destroyed properly. | |
| void | ibf_destroy (struct InvertibleBloomFilter *ibf) |
| Destroy all resources associated with the invertible bloom filter. | |
| #define LOG | ( | kind, | |
| ... | |||
| ) | GNUNET_log_from (kind, "setu", __VA_ARGS__) |
| #define IBF_KEY_HASH_VAL | ( | k | ) |
Compute the key's hash from the key.
Redefine to use a different hash function.
Definition at line 38 of file ibf.c.
| struct IBF_Key ibf_key_from_hashcode | ( | const struct GNUNET_HashCode * | hash | ) |
| void ibf_hashcode_from_key | ( | struct IBF_Key | key, |
| struct GNUNET_HashCode * | dst | ||
| ) |
| 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 |
Definition at line 84 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.
|
static |
Store unique bucket indices for the specified key in dst.
Definition at line 123 of file ibf.c.
References GNUNET_CRYPTO_crc32_n(), InvertibleBloomFilter::hash_num, key, and InvertibleBloomFilter::size.
|
static |
Definition at line 148 of file ibf.c.
References InvertibleBloomFilter::count, IBF_Count::count_val, InvertibleBloomFilter::hash_num, IBF_KEY_HASH_VAL, key, InvertibleBloomFilter::key_hash_sum, IBF_KeyHash::key_hash_val, InvertibleBloomFilter::key_sum, and IBF_Key::key_val.
| 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 172 of file ibf.c.
References GNUNET_assert, InvertibleBloomFilter::hash_num, ibf_get_indices(), ibf_insert_into(), key, and InvertibleBloomFilter::size.
| 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 190 of file ibf.c.
References GNUNET_assert, InvertibleBloomFilter::hash_num, ibf_get_indices(), ibf_insert_into(), key, and InvertibleBloomFilter::size.
|
static |
Test is the IBF is empty, i.e.
all counts, keys and key hashes are zero.
Definition at line 205 of file ibf.c.
References InvertibleBloomFilter::count, IBF_Count::count_val, GNUNET_NO, GNUNET_YES, InvertibleBloomFilter::key_hash_sum, IBF_KeyHash::key_hash_val, InvertibleBloomFilter::key_sum, IBF_Key::key_val, and InvertibleBloomFilter::size.
| 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 |
Definition at line 221 of file ibf.c.
References InvertibleBloomFilter::count, IBF_Count::count_val, 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.
| 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 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 |
| 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 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().
| 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 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().
| 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 533 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.
| 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 554 of file ibf.c.
References InvertibleBloomFilter::count, GNUNET_malloc, GNUNET_memdup, InvertibleBloomFilter::hash_num, InvertibleBloomFilter::key_hash_sum, InvertibleBloomFilter::key_sum, and InvertibleBloomFilter::size.
| 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 578 of file ibf.c.
References InvertibleBloomFilter::count, GNUNET_free, InvertibleBloomFilter::key_hash_sum, and InvertibleBloomFilter::key_sum.