X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fserver.h;h=5810dfaa5bd77a7032b4f8820acb60ef3dbe67eb;hb=707e763398063186c20d8aba3abdef20e3d39253;hp=4290cb01fc7e84674d6bad47772807bee8fef69b;hpb=40e040d548a681ad13eef7ff5734efcce5b1a878;p=catta diff --git a/avahi-core/server.h b/avahi-core/server.h index 4290cb0..5810dfa 100644 --- a/avahi-core/server.h +++ b/avahi-core/server.h @@ -22,15 +22,32 @@ USA. ***/ +#include #include "core.h" #include "iface.h" #include "prioq.h" -#include "llist.h" #include "timeeventq.h" #include "announce.h" -#include "subscribe.h" +#include "browse.h" +#include "dns.h" +#include "rrlist.h" -struct _AvahiEntry { +#define AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS 100 + +typedef struct AvahiLegacyUnicastReflectSlot AvahiLegacyUnicastReflectSlot; + +struct AvahiLegacyUnicastReflectSlot { + AvahiServer *server; + + guint16 id, original_id; + AvahiAddress address; + guint16 port; + gint interface; + GTimeVal elapse_time; + AvahiTimeEvent *time_event; +}; + +struct AvahiEntry { AvahiServer *server; AvahiEntryGroup *group; @@ -38,8 +55,8 @@ struct _AvahiEntry { AvahiEntryFlags flags; AvahiRecord *record; - gint interface; - guchar protocol; + AvahiIfIndex interface; + AvahiProtocol protocol; AVAHI_LLIST_FIELDS(AvahiEntry, entries); AVAHI_LLIST_FIELDS(AvahiEntry, by_key); @@ -48,7 +65,7 @@ struct _AvahiEntry { AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements); }; -struct _AvahiEntryGroup { +struct AvahiEntryGroup { AvahiServer *server; gboolean dead; @@ -58,43 +75,85 @@ struct _AvahiEntryGroup { guint n_probing; + guint n_register_try; + GTimeVal register_time; + AvahiTimeEvent *register_time_event; + AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups); AVAHI_LLIST_HEAD(AvahiEntry, entries); }; -struct _AvahiServer { +struct AvahiServer { GMainContext *context; AvahiInterfaceMonitor *monitor; + AvahiServerConfig config; + AVAHI_LLIST_HEAD(AvahiEntry, entries); GHashTable *entries_by_key; AVAHI_LLIST_HEAD(AvahiEntryGroup, groups); - AVAHI_LLIST_HEAD(AvahiSubscription, subscriptions); - GHashTable *subscription_hashtable; - - gboolean need_entry_cleanup, need_group_cleanup; + AVAHI_LLIST_HEAD(AvahiRecordBrowser, record_browsers); + GHashTable *record_browser_hashtable; + AVAHI_LLIST_HEAD(AvahiHostNameResolver, host_name_resolvers); + AVAHI_LLIST_HEAD(AvahiAddressResolver, address_resolvers); + AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers); + AVAHI_LLIST_HEAD(AvahiServiceTypeBrowser, service_type_browsers); + AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers); + AVAHI_LLIST_HEAD(AvahiServiceResolver, service_resolvers); + AVAHI_LLIST_HEAD(AvahiDNSServerBrowser, dns_server_browsers); + + gboolean need_entry_cleanup, need_group_cleanup, need_browser_cleanup; AvahiTimeEventQueue *time_event_queue; - gchar *hostname; + gchar *host_name, *host_name_fqdn, *domain_name; - gint fd_ipv4, fd_ipv6; + gint fd_ipv4, fd_ipv6, + /* The following two sockets two are used for reflection only */ + fd_legacy_unicast_ipv4, fd_legacy_unicast_ipv6; - GPollFD pollfd_ipv4, pollfd_ipv6; + GPollFD pollfd_ipv4, pollfd_ipv6, pollfd_legacy_unicast_ipv4, pollfd_legacy_unicast_ipv6; GSource *source; - gboolean ignore_bad_ttl; + AvahiServerState state; + AvahiServerCallback callback; + gpointer userdata; + + AvahiEntryGroup *hinfo_entry_group; + AvahiEntryGroup *browse_domain_entry_group; + guint n_host_rr_pending; + + /* Used for assembling responses */ + AvahiRecordList *record_list; + + /* Used for reflection of legacy unicast packets */ + AvahiLegacyUnicastReflectSlot **legacy_unicast_reflect_slots; + guint16 legacy_unicast_reflect_id; + + gint error; }; gboolean avahi_server_entry_match_interface(AvahiEntry *e, AvahiInterface *i); -void avahi_server_post_query(AvahiServer *s, gint interface, guchar protocol, AvahiKey *key); -void avahi_server_post_response(AvahiServer *s, gint interface, guchar protocol, AvahiRecord *record, gboolean flush_cache); +void avahi_server_post_query(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key); + +void avahi_server_prepare_response(AvahiServer *s, AvahiInterface *i, AvahiEntry *e, gboolean unicast_response, gboolean auxiliary); +void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, gboolean unicast_response); +void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, guint16 port, gboolean legacy_unicast, gboolean is_probe); void avahi_entry_group_change_state(AvahiEntryGroup *g, AvahiEntryGroupState state); gboolean avahi_entry_commited(AvahiEntry *e); +void avahi_server_enumerate_aux_records(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, void (*callback)(AvahiServer *s, AvahiRecord *r, gboolean flush_cache, gpointer userdata), gpointer userdata); + +void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata); + +void avahi_server_decrease_host_rr_pending(AvahiServer *s); +void avahi_server_increase_host_rr_pending(AvahiServer *s); + +gint avahi_server_set_errno(AvahiServer *s, gint error); + #endif