]> git.meshlink.io Git - catta/blob - avahi-core/server.h
Impelement AvahiServiceResolver
[catta] / avahi-core / server.h
1 #ifndef fooserverhfoo
2 #define fooserverhfoo
3
4 /* $Id$ */
5
6 /***
7   This file is part of avahi.
8  
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.
13  
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.
18  
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
22   USA.
23 ***/
24
25 #include "core.h"
26 #include "iface.h"
27 #include "prioq.h"
28 #include "llist.h"
29 #include "timeeventq.h"
30 #include "announce.h"
31 #include "browse.h"
32 #include "dns.h"
33 #include "rrlist.h"
34
35 struct AvahiEntry {
36     AvahiServer *server;
37     AvahiEntryGroup *group;
38
39     gboolean dead;
40     
41     AvahiEntryFlags flags;
42     AvahiRecord *record;
43     gint interface;
44     guchar protocol;
45
46     AVAHI_LLIST_FIELDS(AvahiEntry, entries);
47     AVAHI_LLIST_FIELDS(AvahiEntry, by_key);
48     AVAHI_LLIST_FIELDS(AvahiEntry, by_group);
49     
50     AVAHI_LLIST_HEAD(AvahiAnnouncement, announcements);
51 };
52
53 struct AvahiEntryGroup {
54     AvahiServer *server;
55     gboolean dead;
56
57     AvahiEntryGroupState state;
58     gpointer userdata;
59     AvahiEntryGroupCallback callback;
60
61     guint n_probing;
62     
63     AVAHI_LLIST_FIELDS(AvahiEntryGroup, groups);
64     AVAHI_LLIST_HEAD(AvahiEntry, entries);
65 };
66
67 struct AvahiServer {
68     GMainContext *context;
69     AvahiInterfaceMonitor *monitor;
70
71     AvahiServerConfig config;
72
73     AVAHI_LLIST_HEAD(AvahiEntry, entries);
74     GHashTable *entries_by_key;
75
76     AVAHI_LLIST_HEAD(AvahiEntryGroup, groups);
77     
78     AVAHI_LLIST_HEAD(AvahiRecordBrowser, record_browsers);
79     GHashTable *record_browser_hashtable;
80     AVAHI_LLIST_HEAD(AvahiHostNameResolver, host_name_resolvers);
81     AVAHI_LLIST_HEAD(AvahiAddressResolver, address_resolvers);
82     AVAHI_LLIST_HEAD(AvahiDomainBrowser, domain_browsers);
83     AVAHI_LLIST_HEAD(AvahiServiceTypeBrowser, service_type_browsers);
84     AVAHI_LLIST_HEAD(AvahiServiceBrowser, service_browsers);
85     AVAHI_LLIST_HEAD(AvahiServiceResolver, service_resolvers);
86
87     gboolean need_entry_cleanup, need_group_cleanup, need_browser_cleanup;
88     
89     AvahiTimeEventQueue *time_event_queue;
90     
91     gchar *host_name, *host_name_fqdn, *domain_name;
92
93     gint fd_ipv4, fd_ipv6;
94
95     GPollFD pollfd_ipv4, pollfd_ipv6;
96     GSource *source;
97
98     AvahiServerState state;
99     AvahiServerCallback callback;
100     gpointer userdata;
101
102     AvahiEntryGroup *hinfo_entry_group;
103     AvahiEntryGroup *browse_domain_entry_group;
104     guint n_host_rr_pending;
105
106     AvahiTimeEvent *register_time_event;
107     
108     /* Used for assembling responses */
109     AvahiRecordList *record_list;
110 };
111
112 gboolean avahi_server_entry_match_interface(AvahiEntry *e, AvahiInterface *i);
113
114 void avahi_server_post_query(AvahiServer *s, gint interface, guchar protocol, AvahiKey *key);
115
116 void avahi_server_prepare_response(AvahiServer *s, AvahiInterface *i, AvahiEntry *e, gboolean unicast_response, gboolean auxiliary);
117 void avahi_server_prepare_matching_responses(AvahiServer *s, AvahiInterface *i, AvahiKey *k, gboolean unicast_response);
118 void avahi_server_generate_response(AvahiServer *s, AvahiInterface *i, AvahiDnsPacket *p, const AvahiAddress *a, guint16 port, gboolean legacy_unicast);
119
120 void avahi_entry_group_change_state(AvahiEntryGroup *g, AvahiEntryGroupState state);
121
122 gboolean avahi_entry_commited(AvahiEntry *e);
123
124 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);
125
126 void avahi_host_rr_entry_group_callback(AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata);
127
128 void avahi_server_decrease_host_rr_pending(AvahiServer *s);
129 void avahi_server_increase_host_rr_pending(AvahiServer *s);
130
131 #endif