7 This file is part of avahi.
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.
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.
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
29 #include "timeeventq.h"
35 #define AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS 100
37 typedef struct AvahiLegacyUnicastReflectSlot AvahiLegacyUnicastReflectSlot;
39 struct AvahiLegacyUnicastReflectSlot {
42 guint16 id, original_id;
47 AvahiTimeEvent *time_event;
52 AvahiEntryGroup *group;
56 AvahiEntryFlags flags;
61 AVAHI_LLIST_FIELDS(AvahiEntry, entries);
62 AVAHI_LLIST_FIELDS(AvahiEntry, by_key);
63 AVAHI_LLIST_FIELDS(AvahiEntry, by_group);
65 AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
68 struct AvahiEntryGroup {
72 AvahiEntryGroupState state;
74 AvahiEntryGroupCallback callback;
78 AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups);
79 AVAHI_LLIST_HEAD(AvahiEntry, entries);
83 GMainContext *context;
84 AvahiInterfaceMonitor *monitor;
86 AvahiServerConfig config;
88 AVAHI_LLIST_HEAD(AvahiEntry, entries);
89 GHashTable *entries_by_key;
91 AVAHI_LLIST_HEAD(AvahiEntryGroup, groups);
93 AVAHI_LLIST_HEAD(AvahiRecordBrowser, record_browsers);
94 GHashTable *record_browser_hashtable;
95 AVAHI_LLIST_HEAD(AvahiHostNameResolver, host_name_resolvers);
96 AVAHI_LLIST_HEAD(AvahiAddressResolver, address_resolvers);
97 AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers);
98 AVAHI_LLIST_HEAD(AvahiServiceTypeBrowser, service_type_browsers);
99 AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers);
100 AVAHI_LLIST_HEAD(AvahiServiceResolver, service_resolvers);
101 AVAHI_LLIST_HEAD(AvahiDNSServerBrowser, dns_server_browsers);
103 gboolean need_entry_cleanup, need_group_cleanup, need_browser_cleanup;
105 AvahiTimeEventQueue *time_event_queue;
107 gchar *host_name, *host_name_fqdn, *domain_name;
109 gint fd_ipv4, fd_ipv6,
110 /* The following two sockets two are used for reflection only */
111 fd_legacy_unicast_ipv4, fd_legacy_unicast_ipv6;
113 GPollFD pollfd_ipv4, pollfd_ipv6, pollfd_legacy_unicast_ipv4, pollfd_legacy_unicast_ipv6;
116 AvahiServerState state;
117 AvahiServerCallback callback;
120 AvahiEntryGroup *hinfo_entry_group;
121 AvahiEntryGroup *browse_domain_entry_group;
122 guint n_host_rr_pending;
124 AvahiTimeEvent *register_time_event;
126 /* Used for assembling responses */
127 AvahiRecordList *record_list;
129 /* Used for reflection of legacy unicast packets */
130 AvahiLegacyUnicastReflectSlot **legacy_unicast_reflect_slots;
131 guint16 legacy_unicast_reflect_id;
134 gboolean avahi_server_entry_match_interface(AvahiEntry *e, AvahiInterface *i);
136 void avahi_server_post_query(AvahiServer *s, gint interface, guchar protocol, AvahiKey *key);
138 void avahi_server_prepare_response(AvahiServer *s, AvahiInterface *i, AvahiEntry *e, gboolean unicast_response, gboolean auxiliary);
139 void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, gboolean unicast_response);
140 void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, guint16 port, gboolean legacy_unicast, gboolean is_probe);
142 void avahi_entry_group_change_state(AvahiEntryGroup *g, AvahiEntryGroupState state);
144 gboolean avahi_entry_commited(AvahiEntry *e);
146 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);
148 void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata);
150 void avahi_server_decrease_host_rr_pending(AvahiServer *s);
151 void avahi_server_increase_host_rr_pending(AvahiServer *s);