]> git.meshlink.io Git - catta/blob - avahi-core/cache.h
* case insensitive name comparisons
[catta] / avahi-core / cache.h
1 #ifndef foocachehfoo
2 #define foocachehfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of avahi.
8  
9   avahi is free software; you can redistribute it and/or modify it
10   under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13  
14   avahi is distributed in the hope that it will be useful, but WITHOUT
15   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16   or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
17   Public License for more details.
18  
19   You should have received a copy of the GNU Lesser General Public
20   License along with avahi; if not, write to the Free Software
21   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22   USA.
23 ***/
24
25 #include <glib.h>
26
27 typedef struct AvahiCache AvahiCache;
28
29 #include "prioq.h"
30 #include "server.h"
31 #include "llist.h"
32 #include "timeeventq.h"
33
34 typedef enum {
35     AVAHI_CACHE_VALID,
36     AVAHI_CACHE_EXPIRY1,
37     AVAHI_CACHE_EXPIRY2,
38     AVAHI_CACHE_EXPIRY3,
39     AVAHI_CACHE_FINAL
40 } AvahiCacheEntryState;
41
42 typedef struct AvahiCacheEntry AvahiCacheEntry;
43
44 struct AvahiCacheEntry {
45     AvahiCache *cache;
46     AvahiRecord *record;
47     GTimeVal timestamp;
48     GTimeVal expiry;
49     
50     AvahiAddress origin;
51
52     AvahiCacheEntryState state;
53     AvahiTimeEvent *time_event;
54
55     AVAHI_LLIST_FIELDS(AvahiCacheEntry, by_key);
56     AVAHI_LLIST_FIELDS(AvahiCacheEntry, entry);
57 };
58
59 struct AvahiCache {
60     AvahiServer *server;
61     
62     AvahiInterface *interface;
63     
64     GHashTable *hash_table;
65
66     AVAHI_LLIST_HEAD(AvahiCacheEntry, entries);
67 };
68
69 AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *interface);
70 void avahi_cache_free(AvahiCache *c);
71
72 AvahiCacheEntry *avahi_cache_lookup_key(AvahiCache *c, AvahiKey *k);
73 AvahiCacheEntry *avahi_cache_lookup_record(AvahiCache *c, AvahiRecord *r);
74
75 void avahi_cache_update(AvahiCache *c, AvahiRecord *r, gboolean unique, const AvahiAddress *a);
76
77 void avahi_cache_dump(AvahiCache *c, FILE *f);
78
79 typedef gpointer AvahiCacheWalkCallback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, gpointer userdata);
80 gpointer avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, gpointer userdata);
81
82 gboolean avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e);
83
84 void avahi_cache_flush(AvahiCache *c);
85
86 #endif