]> git.meshlink.io Git - catta/blobdiff - avahi-core/server.h
split entry and entry-group management stuff off to its own file entry.c
[catta] / avahi-core / server.h
index 3630d1e7fe18f8967e24b34ef0a9633264a98199..10218368044a1d151e8e02486769ca7e4e046155 100644 (file)
@@ -37,9 +37,17 @@ typedef struct AvahiEntry AvahiEntry;
 #include "dns.h"
 #include "rrlist.h"
 #include "hashmap.h"
+#include "wide-area.h"
+#include "multicast-lookup.h"
 
 #define AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS 100
 
+#define AVAHI_FLAGS_VALID(flags, max) (!((flags) & ~(max)))
+
+#define AVAHI_RR_HOLDOFF_MSEC 1000
+#define AVAHI_RR_HOLDOFF_MSEC_RATE_LIMIT 60000
+#define AVAHI_RR_RATE_LIMIT_COUNT 15
+
 typedef struct AvahiLegacyUnicastReflectSlot AvahiLegacyUnicastReflectSlot;
 
 struct AvahiLegacyUnicastReflectSlot {
@@ -59,7 +67,7 @@ struct AvahiEntry {
 
     int dead;
     
-    AvahiEntryFlags flags;
+    AvahiPublishFlags flags;
     AvahiRecord *record;
     AvahiIfIndex interface;
     AvahiProtocol protocol;
@@ -68,7 +76,7 @@ struct AvahiEntry {
     AVAHI_LLIST_FIELDS(AvahiEntry, by_key);
     AVAHI_LLIST_FIELDS(AvahiEntry, by_group);
     
-    AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
+    AVAHI_LLIST_HEAD(AvahiAnnouncer, announcers);
 };
 
 struct AvahiSEntryGroup {
@@ -84,13 +92,15 @@ struct AvahiSEntryGroup {
     unsigned n_register_try;
     struct timeval register_time;
     AvahiTimeEvent *register_time_event;
+
+    struct timeval established_at;
     
     AVAHI_LLIST_FIELDS(AvahiSEntryGroup, groups);
     AVAHI_LLIST_HEAD(AvahiEntry, entries);
 };
 
 struct AvahiServer {
-    AvahiPoll *poll_api;
+    const AvahiPoll *poll_api;
     
     AvahiInterfaceMonitor *monitor;
     AvahiServerConfig config;
@@ -138,12 +148,20 @@ struct AvahiServer {
     AvahiLegacyUnicastReflectSlot **legacy_unicast_reflect_slots;
     uint16_t legacy_unicast_reflect_id;
 
+    /* The last error code */
     int error;
+
+    /* The local service cookie */
+    uint32_t local_service_cookie;
+
+    AvahiMulticastLookupEngine *multicast_lookup_engine;
+    AvahiWideAreaLookupEngine *wide_area_lookup_engine;
 };
 
-int avahi_server_entry_match_interface(AvahiEntry *e, AvahiInterface *i);
+void avahi_entry_free(AvahiServer*s, AvahiEntry *e);
+void avahi_entry_group_free(AvahiServer *s, AvahiSEntryGroup *g);
 
-void avahi_server_post_query(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key);
+void avahi_cleanup_dead_entries(AvahiServer *s);
 
 void avahi_server_prepare_response(AvahiServer *s, AvahiInterface *i, AvahiEntry *e, int unicast_response, int auxiliary);
 void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, int unicast_response);
@@ -162,4 +180,18 @@ void avahi_server_increase_host_rr_pending(AvahiServer *s);
 
 int avahi_server_set_errno(AvahiServer *s, int error);
 
+#define AVAHI_CHECK_VALIDITY_RETURN_NULL(server, expression, error) { \
+        if (!(expression)) { \
+            avahi_server_set_errno((server), (error)); \
+            return NULL; \
+        } \
+}
+
+#define AVAHI_CHECK_VALIDITY_SET_RET_GOTO_FAIL(server, expression, error) {\
+    if (!(expression)) { \
+        ret = avahi_server_set_errno((server), (error)); \
+        goto fail; \
+    } \
+}
+
 #endif