35 #define LOG(kind, ...) \
36 GNUNET_log_from (kind, "testbed-cache", __VA_ARGS__)
241 if (NULL != entry->
hello)
static char * peer_id
Option –peer.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
#define LOG_DEBUG(...)
Debug logging shorthand.
data structures shared amongst components of TESTBED service
const struct GNUNET_MessageHeader * GST_cache_lookup_hello(const unsigned int peer_id)
Looks up in the hello cache and returns the HELLO of the given peer.
static int cache_clear_iterator(void *cls, uint32_t key, void *value)
Iterator over hash map entries.
void GST_cache_clear()
Clear cache.
static unsigned int cache_size
Maximum number of elements to cache.
static struct CacheEntry * cache_lookup(unsigned int peer_id)
Looks up in the cache and returns the entry.
static void free_entry(struct CacheEntry *entry)
Free the resources occupied by a cache entry.
static struct CacheEntry * cache_tail
DLL tail for least recently used cache entries; recently used cache items are at the tail....
static struct CacheEntry * add_entry(unsigned int peer_id)
Creates a new cache entry and then puts it into the cache's hashtable.
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
void GST_cache_init(unsigned int size)
Initializes the cache.
static struct CacheEntry * cache_head
DLL head for least recently used cache entries; least recently used cache items are at the head.
void GST_cache_add_hello(const unsigned int peer_id, const struct GNUNET_MessageHeader *hello)
Caches the HELLO of the given peer.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
unsigned int GNUNET_CONTAINER_multihashmap32_size(const struct GNUNET_CONTAINER_MultiHashMap32 *map)
Get the number of key-value pairs in the map.
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MultiHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST
, ' bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE...
#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_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int size
Size of the "table".
unsigned int peer_id
The id of the peer this entry corresponds to.
struct CacheEntry * prev
DLL prev ptr for least recently used cache entries.
struct GNUNET_MessageHeader * hello
The HELLO message.
struct CacheEntry * next
DLL next ptr for least recently used cache entries.
Internal representation of the hash map.