USA.
***/
-#include <glib.h>
-
typedef struct AvahiCache AvahiCache;
+#include <avahi-common/llist.h>
#include "prioq.h"
-#include "server.h"
-#include "llist.h"
+#include "internal.h"
#include "timeeventq.h"
+#include "hashmap.h"
typedef enum {
AVAHI_CACHE_VALID,
AVAHI_CACHE_EXPIRY1,
AVAHI_CACHE_EXPIRY2,
AVAHI_CACHE_EXPIRY3,
- AVAHI_CACHE_FINAL
+ AVAHI_CACHE_EXPIRY_FINAL,
+ AVAHI_CACHE_POOF, /* Passive observation of failure */
+ AVAHI_CACHE_POOF_FINAL,
+ AVAHI_CACHE_GOODBYE_FINAL,
+ AVAHI_CACHE_REPLACE_FINAL
} AvahiCacheEntryState;
typedef struct AvahiCacheEntry AvahiCacheEntry;
struct AvahiCacheEntry {
AvahiCache *cache;
AvahiRecord *record;
- GTimeVal timestamp;
- GTimeVal expiry;
- gboolean cache_flush;
+ struct timeval timestamp;
+ struct timeval poof_timestamp;
+ struct timeval expiry;
+ int cache_flush;
+ int poof_num;
AvahiAddress origin;
AvahiCacheEntryState state;
AvahiTimeEvent *time_event;
+ AvahiAddress poof_address;
+
AVAHI_LLIST_FIELDS(AvahiCacheEntry, by_key);
AVAHI_LLIST_FIELDS(AvahiCacheEntry, entry);
};
AvahiInterface *interface;
- GHashTable *hash_table;
+ AvahiHashmap *hashmap;
AVAHI_LLIST_HEAD(AvahiCacheEntry, entries);
- guint n_entries;
+ unsigned n_entries;
+
+ int last_rand;
+ time_t last_rand_timestamp;
};
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, int cache_flush, const AvahiAddress *a);
+
+int avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, void* userdata);
-void avahi_cache_update(AvahiCache *c, AvahiRecord *r, gboolean cache_flush, const AvahiAddress *a);
+typedef void* AvahiCacheWalkCallback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata);
+void* avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, void* userdata);
-void avahi_cache_dump(AvahiCache *c, AvahiDumpCallback callback, gpointer userdata);
+int avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e);
-typedef gpointer AvahiCacheWalkCallback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, gpointer userdata);
-gpointer avahi_cache_walk(AvahiCache *c, AvahiKey *pattern, AvahiCacheWalkCallback cb, gpointer userdata);
+/** Start the "Passive observation of Failure" algorithm for all
+ * records of the specified key. The specified address is */
+void avahi_cache_start_poof(AvahiCache *c, AvahiKey *key, const AvahiAddress *a);
-gboolean avahi_cache_entry_half_ttl(AvahiCache *c, AvahiCacheEntry *e);
+/* Stop a previously started POOF algorithm for a record. (Used for response suppresions records */
+void avahi_cache_stop_poof(AvahiCache *c, AvahiRecord *record, const AvahiAddress *a);
void avahi_cache_flush(AvahiCache *c);