]> git.meshlink.io Git - catta/blob - libavahi-core/cache.h
move the sources to libavahi-core/
[catta] / libavahi-core / cache.h
1 #ifndef foocachehfoo
2 #define foocachehfoo
3
4 #include <glib.h>
5
6 struct _AvahiCache;
7 typedef struct _AvahiCache AvahiCache;
8
9 #include "prioq.h"
10 #include "server.h"
11 #include "llist.h"
12 #include "timeeventq.h"
13
14 typedef enum {
15     AVAHI_CACHE_VALID,
16     AVAHI_CACHE_EXPIRY1,
17     AVAHI_CACHE_EXPIRY2,
18     AVAHI_CACHE_EXPIRY3,
19     AVAHI_CACHE_FINAL
20 } AvahiCacheEntryState;
21
22 typedef struct AvahiCacheEntry AvahiCacheEntry;
23
24 struct AvahiCacheEntry {
25     AvahiCache *cache;
26     AvahiRecord *record;
27     GTimeVal timestamp;
28     GTimeVal expiry;
29     
30     AvahiAddress origin;
31
32     AvahiCacheEntryState state;
33     AvahiTimeEvent *time_event;
34
35     AVAHI_LLIST_FIELDS(AvahiCacheEntry, by_key);
36     AVAHI_LLIST_FIELDS(AvahiCacheEntry, entry);
37 };
38
39 struct _AvahiCache {
40     AvahiServer *server;
41     
42     AvahiInterface *interface;
43     
44     GHashTable *hash_table;
45
46     AVAHI_LLIST_HEAD(AvahiCacheEntry, entries);
47 };
48
49 AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *interface);
50 void avahi_cache_free(AvahiCache *c);
51
52 AvahiCacheEntry *avahi_cache_lookup_key(AvahiCache *c, AvahiKey *k);
53 AvahiCacheEntry *avahi_cache_lookup_record(AvahiCache *c, AvahiRecord *r);
54
55 void avahi_cache_update(AvahiCache *c, AvahiRecord *r, gboolean unique, const AvahiAddress *a);
56
57 void avahi_cache_drop_record(AvahiCache *c,  AvahiRecord *r);
58
59 void avahi_cache_dump(AvahiCache *c, FILE *f);
60
61 typedef gpointer AvahiCacheWalkCallback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, gpointer userdata);
62 gpointer avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, gpointer userdata);
63
64 gboolean avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e);
65
66 #endif