Electroneum
Loading...
Searching...
No Matches
val_kcache.h File Reference
Include dependency graph for val_kcache.h:

Go to the source code of this file.

Classes

struct  key_cache

Functions

struct key_cachekey_cache_create (struct config_file *cfg)
void key_cache_delete (struct key_cache *kcache)
void key_cache_insert (struct key_cache *kcache, struct key_entry_key *kkey, struct module_qstate *qstate)
void key_cache_remove (struct key_cache *kcache, uint8_t *name, size_t namelen, uint16_t key_class)
struct key_entry_keykey_cache_obtain (struct key_cache *kcache, uint8_t *name, size_t namelen, uint16_t key_class, struct regional *region, time_t now)
size_t key_cache_get_mem (struct key_cache *kcache)

Detailed Description

This file contains functions for caching validated key entries.

Definition in file val_kcache.h.

Function Documentation

◆ key_cache_create()

struct key_cache * key_cache_create ( struct config_file * cfg)

Create the key cache

Parameters
cfgconfig settings for the key cache.
Returns
new key cache or NULL on malloc failure.

◆ key_cache_delete()

void key_cache_delete ( struct key_cache * kcache)

Delete the key cache

Parameters
kcacheto delete

◆ key_cache_get_mem()

size_t key_cache_get_mem ( struct key_cache * kcache)

Get memory in use by the key cache.

Parameters
kcachethe key cache.
Returns
memory in use in bytes.

◆ key_cache_insert()

void key_cache_insert ( struct key_cache * kcache,
struct key_entry_key * kkey,
struct module_qstate * qstate )

Insert or update a key cache entry. Note that the insert may silently fail if there is not enough memory.

Parameters
kcachethe key cache.
kkeykey entry key, assumed malloced in a region, is copied to perform update or insertion. Its data pointer is also copied.
qstatestore errinf reason in case its bad.

◆ key_cache_obtain()

struct key_entry_key * key_cache_obtain ( struct key_cache * kcache,
uint8_t * name,
size_t namelen,
uint16_t key_class,
struct regional * region,
time_t now )

Lookup key entry in the cache. Looks up the closest key entry above the given name.

Parameters
kcachethe key cache.
namefor what name to look; uncompressed wireformat
namelenlength of the name.
key_classclass of the key.
regiona copy of the key_entry is allocated in this region.
nowcurrent time.
Returns
pointer to a newly allocated key_entry copy in the region, if a key entry could be found, and allocation succeeded and TTL was OK. Otherwise, NULL is returned.

◆ key_cache_remove()

void key_cache_remove ( struct key_cache * kcache,
uint8_t * name,
size_t namelen,
uint16_t key_class )

Remove an entry from the key cache.

Parameters
kcachethe key cache.
namefor what name to look; uncompressed wireformat
namelenlength of the name.
key_classclass of the key.