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
25 #include <avahi-common/llist.h>
26 #include <avahi-common/watch.h>
28 /** A locally registered DNS resource record */
29 typedef struct AvahiEntry AvahiEntry;
34 #include "timeeventq.h"
40 #include "wide-area.h"
41 #include "multicast-lookup.h"
43 #define AVAHI_MAX_LEGACY_UNICAST_REFLECT_SLOTS 100
45 #define AVAHI_FLAGS_VALID(flags, max) (!((flags) & ~(max)))
47 typedef struct AvahiLegacyUnicastReflectSlot AvahiLegacyUnicastReflectSlot;
49 struct AvahiLegacyUnicastReflectSlot {
52 uint16_t id, original_id;
56 struct timeval elapse_time;
57 AvahiTimeEvent *time_event;
62 AvahiSEntryGroup *group;
66 AvahiPublishFlags flags;
68 AvahiIfIndex interface;
69 AvahiProtocol protocol;
71 AVAHI_LLIST_FIELDS(AvahiEntry, entries);
72 AVAHI_LLIST_FIELDS(AvahiEntry, by_key);
73 AVAHI_LLIST_FIELDS(AvahiEntry, by_group);
75 AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
78 struct AvahiSEntryGroup {
82 AvahiEntryGroupState state;
84 AvahiSEntryGroupCallback callback;
88 unsigned n_register_try;
89 struct timeval register_time;
90 AvahiTimeEvent *register_time_event;
92 struct timeval established_at;
94 AVAHI_LLIST_FIELDS(AvahiSEntryGroup, groups);
95 AVAHI_LLIST_HEAD(AvahiEntry, entries);
99 const AvahiPoll *poll_api;
101 AvahiInterfaceMonitor *monitor;
102 AvahiServerConfig config;
104 AVAHI_LLIST_HEAD(AvahiEntry, entries);
105 AvahiHashmap *entries_by_key;
107 AVAHI_LLIST_HEAD(AvahiSEntryGroup, groups);
109 AVAHI_LLIST_HEAD(AvahiSRecordBrowser, record_browsers);
110 AvahiHashmap *record_browser_hashmap;
111 AVAHI_LLIST_HEAD(AvahiSHostNameResolver, host_name_resolvers);
112 AVAHI_LLIST_HEAD(AvahiSAddressResolver, address_resolvers);
113 AVAHI_LLIST_HEAD(AvahiSDomainBrowser, domain_browsers);
114 AVAHI_LLIST_HEAD(AvahiSServiceTypeBrowser, service_type_browsers);
115 AVAHI_LLIST_HEAD(AvahiSServiceBrowser, service_browsers);
116 AVAHI_LLIST_HEAD(AvahiSServiceResolver, service_resolvers);
117 AVAHI_LLIST_HEAD(AvahiSDNSServerBrowser, dns_server_browsers);
119 int need_entry_cleanup, need_group_cleanup, need_browser_cleanup;
121 AvahiTimeEventQueue *time_event_queue;
123 char *host_name, *host_name_fqdn, *domain_name;
125 int fd_ipv4, fd_ipv6,
126 /* The following two sockets two are used for reflection only */
127 fd_legacy_unicast_ipv4, fd_legacy_unicast_ipv6;
129 AvahiWatch *watch_ipv4, *watch_ipv6,
130 *watch_legacy_unicast_ipv4, *watch_legacy_unicast_ipv6;
132 AvahiServerState state;
133 AvahiServerCallback callback;
136 AvahiSEntryGroup *hinfo_entry_group;
137 AvahiSEntryGroup *browse_domain_entry_group;
138 unsigned n_host_rr_pending;
140 /* Used for assembling responses */
141 AvahiRecordList *record_list;
143 /* Used for reflection of legacy unicast packets */
144 AvahiLegacyUnicastReflectSlot **legacy_unicast_reflect_slots;
145 uint16_t legacy_unicast_reflect_id;
147 /* The last error code */
150 /* The local service cookie */
151 uint32_t local_service_cookie;
153 AvahiMulticastLookupEngine *multicast_lookup_engine;
154 AvahiWideAreaLookupEngine *wide_area_lookup_engine;
157 int avahi_server_entry_match_interface(AvahiEntry *e, AvahiInterface *i);
159 void avahi_server_post_query(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, AvahiKey *key);
161 void avahi_server_prepare_response(AvahiServer *s, AvahiInterface *i, AvahiEntry *e, int unicast_response, int auxiliary);
162 void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, int unicast_response);
163 void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, uint16_t port, int legacy_unicast, int is_probe);
165 void avahi_s_entry_group_change_state(AvahiSEntryGroup *g, AvahiEntryGroupState state);
167 int avahi_entry_is_commited(AvahiEntry *e);
169 void avahi_server_enumerate_aux_records(AvahiServer *s, AvahiInterface *i, AvahiRecord *r, void (*callback)(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata), void* userdata);
171 void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void *userdata);
173 void avahi_server_decrease_host_rr_pending(AvahiServer *s);
174 void avahi_server_increase_host_rr_pending(AvahiServer *s);
176 int avahi_server_set_errno(AvahiServer *s, int error);