5 This file is part of avahi.
7 avahi is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 2.1 of the
10 License, or (at your option) any later version.
12 avahi is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15 Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with avahi; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 typedef struct AvahiCache AvahiCache;
25 #include <avahi-common/llist.h>
28 #include "timeeventq.h"
36 AVAHI_CACHE_EXPIRY_FINAL,
37 AVAHI_CACHE_POOF, /* Passive observation of failure */
38 AVAHI_CACHE_POOF_FINAL,
39 AVAHI_CACHE_GOODBYE_FINAL,
40 AVAHI_CACHE_REPLACE_FINAL
41 } AvahiCacheEntryState;
43 typedef struct AvahiCacheEntry AvahiCacheEntry;
45 struct AvahiCacheEntry {
48 struct timeval timestamp;
49 struct timeval poof_timestamp;
50 struct timeval expiry;
56 AvahiCacheEntryState state;
57 AvahiTimeEvent *time_event;
59 AvahiAddress poof_address;
61 AVAHI_LLIST_FIELDS(AvahiCacheEntry, by_key);
62 AVAHI_LLIST_FIELDS(AvahiCacheEntry, entry);
68 AvahiInterface *interface;
70 AvahiHashmap *hashmap;
72 AVAHI_LLIST_HEAD(AvahiCacheEntry, entries);
77 time_t last_rand_timestamp;
80 AvahiCache *avahi_cache_new(AvahiServer *server, AvahiInterface *interface);
81 void avahi_cache_free(AvahiCache *c);
83 void avahi_cache_update(AvahiCache *c, AvahiRecord *r, int cache_flush, const AvahiAddress *a);
85 int avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, void* userdata);
87 typedef void* AvahiCacheWalkCallback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata);
88 void* avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, void* userdata);
90 int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e);
92 /** Start the "Passive observation of Failure" algorithm for all
93 * records of the specified key. The specified address is */
94 void avahi_cache_start_poof(AvahiCache *c, AvahiKey *key, const AvahiAddress *a);
96 /* Stop a previously started POOF algorithm for a record. (Used for response suppresions records */
97 void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddress *a);
99 void avahi_cache_flush(AvahiCache *c);