management of map that specifies which message types this peer supports More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_service.h"
#include "gnunet-service-core.h"
#include "gnunet-service-core_sessions.h"
#include "gnunet-service-core_typemap.h"
#include <zlib.h>
Go to the source code of this file.
Data Structures | |
struct | GSC_TypeMap |
A type map describing which messages a given neighbour is able to process. More... | |
Functions | |
static void | rehash_typemap () |
Our type map changed, recompute its hash. More... | |
void | GSC_TYPEMAP_hash (const struct GSC_TypeMap *tm, struct GNUNET_HashCode *hc) |
Hash the contents of a type map. More... | |
int | GSC_TYPEMAP_check_hash (const struct GNUNET_HashCode *hc) |
Check if the given hash matches our current type map. More... | |
struct GNUNET_MessageHeader * | GSC_TYPEMAP_compute_type_map_message () |
Compute a type map message for this peer. More... | |
struct GSC_TypeMap * | GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg) |
Extract a type map from a TYPE_MAP message. More... | |
static void | broadcast_my_type_map () |
Send my type map to all connected peers (it got changed). More... | |
void | GSC_TYPEMAP_add (const uint16_t *types, unsigned int tlen) |
Add a set of types to our type map. More... | |
void | GSC_TYPEMAP_remove (const uint16_t *types, unsigned int tlen) |
Remove a set of message types from our type map. More... | |
int | GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap, const uint16_t *types, unsigned int tcnt) |
Test if any of the types from the types array is in the given type map. More... | |
struct GSC_TypeMap * | GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, const uint16_t *types, unsigned int tcnt) |
Add additional types to a given typemap. More... | |
struct GSC_TypeMap * | GSC_TYPEMAP_create () |
Create an empty type map. More... | |
void | GSC_TYPEMAP_destroy (struct GSC_TypeMap *tmap) |
Free the given type map. More... | |
void | GSC_TYPEMAP_init () |
Initialize typemap subsystem. More... | |
void | GSC_TYPEMAP_done () |
Shutdown typemap subsystem. More... | |
Variables | |
static struct GSC_TypeMap | my_type_map |
Bitmap of message types this peer is able to handle. More... | |
static uint8_t | map_counters [UINT16_MAX+1] |
Counters for message types this peer is able to handle. More... | |
static struct GNUNET_HashCode | my_tm_hash |
Current hash of our (uncompressed) type map. More... | |
static int | hash_current |
Is my_tm_hash() current with respect to our type map? More... | |
management of map that specifies which message types this peer supports
Definition in file gnunet-service-core_typemap.c.
|
static |
Our type map changed, recompute its hash.
Definition at line 70 of file gnunet-service-core_typemap.c.
References GNUNET_NO, and hash_current.
Referenced by GSC_TYPEMAP_add(), and GSC_TYPEMAP_remove().
void GSC_TYPEMAP_hash | ( | const struct GSC_TypeMap * | tm, |
struct GNUNET_HashCode * | hc | ||
) |
Hash the contents of a type map.
tm | map to hash |
hc | where to store the hash code |
Definition at line 83 of file gnunet-service-core_typemap.c.
References GNUNET_CRYPTO_hash().
Referenced by GSC_SESSIONS_set_typemap(), and GSC_TYPEMAP_check_hash().
int GSC_TYPEMAP_check_hash | ( | const struct GNUNET_HashCode * | hc | ) |
Check if the given hash matches our current type map.
hc | hash code to check if it matches our type map |
Definition at line 96 of file gnunet-service-core_typemap.c.
References GNUNET_NO, GNUNET_YES, GSC_TYPEMAP_hash(), hash_current, my_tm_hash, and my_type_map.
Referenced by GSC_SESSIONS_confirm_typemap().
struct GNUNET_MessageHeader* GSC_TYPEMAP_compute_type_map_message | ( | void | ) |
Compute a type map message for this peer.
Definition at line 115 of file gnunet-service-core_typemap.c.
References GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP, GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP, my_type_map, GNUNET_MessageHeader::size, and GNUNET_MessageHeader::type.
Referenced by broadcast_my_type_map(), and transmit_typemap_task().
struct GSC_TypeMap* GSC_TYPEMAP_get_from_message | ( | const struct GNUNET_MessageHeader * | msg | ) |
Extract a type map from a TYPE_MAP message.
Extract a type map from a #GNUNET_MESSAGE_TYPE_CORE_COMRESSED_TYPE_MAP or GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP message.
msg | a type map message |
Definition at line 159 of file gnunet-service-core_typemap.c.
References gettext_noop, GNUNET_break, GNUNET_break_op, GNUNET_free, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP, GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP, GNUNET_new, GNUNET_NO, GNUNET_STATISTICS_update(), GSC_stats, msg, ret, GNUNET_MessageHeader::size, size, and GNUNET_MessageHeader::type.
Referenced by GSC_SESSIONS_set_typemap().
|
static |
Send my type map to all connected peers (it got changed).
Definition at line 212 of file gnunet-service-core_typemap.c.
References gettext_noop, GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_update(), GSC_SESSIONS_broadcast_typemap(), GSC_stats, and GSC_TYPEMAP_compute_type_map_message().
Referenced by GSC_TYPEMAP_add(), and GSC_TYPEMAP_remove().
void GSC_TYPEMAP_add | ( | const uint16_t * | types, |
unsigned int | tlen | ||
) |
Add a set of types to our type map.
types | array of message types supported by this peer |
tlen | number of entries in types |
Definition at line 233 of file gnunet-service-core_typemap.c.
References GSC_TypeMap::bits, broadcast_my_type_map(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_YES, map_counters, my_type_map, and rehash_typemap().
Referenced by handle_client_init().
void GSC_TYPEMAP_remove | ( | const uint16_t * | types, |
unsigned int | tlen | ||
) |
Remove a set of message types from our type map.
types | array of message types no longer supported by this peer |
tlen | number of entries in types |
Definition at line 257 of file gnunet-service-core_typemap.c.
References GSC_TypeMap::bits, broadcast_my_type_map(), GNUNET_NO, GNUNET_YES, map_counters, my_type_map, and rehash_typemap().
Referenced by client_disconnect_cb().
int GSC_TYPEMAP_test_match | ( | const struct GSC_TypeMap * | tmap, |
const uint16_t * | types, | ||
unsigned int | tcnt | ||
) |
Test if any of the types from the types array is in the given type map.
tmap | map to test |
types | array of types |
tcnt | number of entries in types |
Definition at line 288 of file gnunet-service-core_typemap.c.
References GSC_TypeMap::bits, GNUNET_NO, and GNUNET_YES.
Referenced by GSC_CLIENTS_notify_client_about_neighbour(), and GSC_SESSIONS_add_to_typemap().
struct GSC_TypeMap* GSC_TYPEMAP_extend | ( | const struct GSC_TypeMap * | tmap, |
const uint16_t * | types, | ||
unsigned int | tcnt | ||
) |
Add additional types to a given typemap.
tmap | map to extend (not changed) |
types | array of types to add |
tcnt | number of entries in types |
Definition at line 312 of file gnunet-service-core_typemap.c.
References GNUNET_memcpy, GNUNET_new, and ret.
Referenced by GSC_SESSIONS_add_to_typemap().
struct GSC_TypeMap* GSC_TYPEMAP_create | ( | void | ) |
Create an empty type map.
Definition at line 333 of file gnunet-service-core_typemap.c.
References GNUNET_new.
Referenced by GSC_SESSIONS_create().
void GSC_TYPEMAP_destroy | ( | struct GSC_TypeMap * | tmap | ) |
Free the given type map.
tmap | a type map |
Definition at line 345 of file gnunet-service-core_typemap.c.
References GNUNET_free.
Referenced by GSC_SESSIONS_add_to_typemap(), GSC_SESSIONS_end(), and GSC_SESSIONS_set_typemap().
void GSC_TYPEMAP_init | ( | void | ) |
Initialize typemap subsystem.
Definition at line 355 of file gnunet-service-core_typemap.c.
Referenced by run().
void GSC_TYPEMAP_done | ( | void | ) |
Shutdown typemap subsystem.
Definition at line 365 of file gnunet-service-core_typemap.c.
Referenced by shutdown_task().
|
static |
Bitmap of message types this peer is able to handle.
Definition at line 1 of file gnunet-service-core_typemap.c.
Referenced by GSC_TYPEMAP_add(), GSC_TYPEMAP_check_hash(), GSC_TYPEMAP_compute_type_map_message(), and GSC_TYPEMAP_remove().
|
static |
Counters for message types this peer is able to handle.
Definition at line 52 of file gnunet-service-core_typemap.c.
Referenced by GSC_TYPEMAP_add(), and GSC_TYPEMAP_remove().
|
static |
Current hash of our (uncompressed) type map.
Lazily computed when needed.
Definition at line 52 of file gnunet-service-core_typemap.c.
Referenced by GSC_TYPEMAP_check_hash().
|
static |
Is my_tm_hash() current with respect to our type map?
Definition at line 63 of file gnunet-service-core_typemap.c.
Referenced by GSC_TYPEMAP_check_hash(), and rehash_typemap().