X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=cache.h;h=de0ec9fc5bb01bc1db1d39fd47e91537dd9299b0;hb=7dce450bdc23ea306a61e00f914481e29ebcb176;hp=7f7d0bdc3bcd87d1f01c993919946957bb6e79ac;hpb=f0f4bb0c37eeed71934e3191cffa5afb1cfdca0d;p=catta diff --git a/cache.h b/cache.h index 7f7d0bd..de0ec9f 100644 --- a/cache.h +++ b/cache.h @@ -3,57 +3,64 @@ #include -struct _flxCache; -typedef struct _flxCache flxCache; +struct _AvahiCache; +typedef struct _AvahiCache AvahiCache; #include "prioq.h" #include "server.h" #include "llist.h" +#include "timeeventq.h" typedef enum { - FLX_CACHE_VALID, - FLX_CACHE_EXPIRY1, - FLX_CACHE_EXPIRY2, - FLX_CACHE_EXPIRY3 - -} flxCacheEntryState; - -typedef struct flxCacheEntry flxCacheEntry; - -struct flxCacheEntry { - flxRecord *record; + AVAHI_CACHE_VALID, + AVAHI_CACHE_EXPIRY1, + AVAHI_CACHE_EXPIRY2, + AVAHI_CACHE_EXPIRY3, + AVAHI_CACHE_FINAL +} AvahiCacheEntryState; + +typedef struct AvahiCacheEntry AvahiCacheEntry; + +struct AvahiCacheEntry { + AvahiCache *cache; + AvahiRecord *record; GTimeVal timestamp; GTimeVal expiry; - flxAddress origin; + AvahiAddress origin; - flxCacheEntryState state; + AvahiCacheEntryState state; + AvahiTimeEvent *time_event; - FLX_LLIST_FIELDS(flxCacheEntry, by_name); - - flxPrioQueueNode *node; - + AVAHI_LLIST_FIELDS(AvahiCacheEntry, by_key); + AVAHI_LLIST_FIELDS(AvahiCacheEntry, entry); }; -struct _flxCache { - flxServer *server; +struct _AvahiCache { + AvahiServer *server; - flxInterface *interface; + AvahiInterface *interface; GHashTable *hash_table; + + AVAHI_LLIST_HEAD(AvahiCacheEntry, entries); }; -flxCache *flx_cache_new(flxServer *server, flxInterface *interface); -void flx_cache_free(flxCache *c); +AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *interface); +void avahi_cache_free(AvahiCache *c); + +AvahiCacheEntry *avahi_cache_lookup_key(AvahiCache *c, AvahiKey *k); +AvahiCacheEntry *avahi_cache_lookup_record(AvahiCache *c, AvahiRecord *r); + +void avahi_cache_update(AvahiCache *c, AvahiRecord *r, gboolean unique, const AvahiAddress *a); -flxCacheEntry *flx_cache_lookup_key(flxCache *c, flxKey *k); -flxCacheEntry *flx_cache_lookup_record(flxCache *c, flxRecord *r); +void avahi_cache_drop_record(AvahiCache *c, AvahiRecord *r); -flxCacheEntry *flx_cache_update(flxCache *c, flxRecord *r, gboolean unique, const flxAddress *a); +void avahi_cache_dump(AvahiCache *c, FILE *f); -void flx_cache_drop_key(flxCache *c, flxKey *k); -void flx_cache_drop_record(flxCache *c, flxRecord *r); +typedef gpointer AvahiCacheWalkCallback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, gpointer userdata); +gpointer avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, gpointer userdata); -void flx_cache_dump(flxCache *c, FILE *f); +gboolean avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e); #endif