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
27 #include <avahi-common/cdecl.h>
28 #include <avahi-common/address.h>
29 #include <avahi-common/strlst.h>
30 #include <avahi-common/defs.h>
31 #include <avahi-common/watch.h>
32 #include <avahi-common/gccmacro.h>
34 /** \file client.h Definitions and functions for the client API over D-Bus */
36 /** \example client-publish-service.c Example how to register a DNS-SD
37 * service using the client interface to avahi-daemon. It behaves like a network
38 * printer registering both an IPP and a BSD LPR service. */
40 /** \example client-browse-services.c Example how to browse for DNS-SD
41 * services using the client interface to avahi-daemon. */
43 /** \example glib-integration.c Example of how to integrate
44 * avahi use with GLIB/GTK applications */
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 /** A connection context */
52 typedef struct AvahiClient AvahiClient;
54 /** An entry group object */
55 typedef struct AvahiEntryGroup AvahiEntryGroup;
57 /** A domain browser object */
58 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
60 /** A service browser object */
61 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
63 /** A service type browser object */
64 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
66 /** A service resolver object */
67 typedef struct AvahiServiceResolver AvahiServiceResolver;
69 /** A service resolver object */
70 typedef struct AvahiHostNameResolver AvahiHostNameResolver;
72 /** States of a client object, a superset of AvahiServerState */
74 AVAHI_CLIENT_S_INVALID = AVAHI_SERVER_INVALID,
75 AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING,
76 AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING,
77 AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION,
78 AVAHI_CLIENT_DISCONNECTED = 100 /**< Lost DBUS connection to the Avahi daemon */
81 /** The function prototype for the callback of an AvahiClient */
82 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
84 /** The function prototype for the callback of an AvahiEntryGroup */
85 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
87 /** The function prototype for the callback of an AvahiDomainBrowser */
88 typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void *userdata);
90 /** The function prototype for the callback of an AvahiServiceBrowser */
91 typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void *userdata);
93 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
94 typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void *userdata);
96 /** The function prototype for the callback of an AvahiServiceResolver */
97 typedef void (*AvahiServiceResolverCallback) (
98 AvahiServiceResolver *r,
99 AvahiIfIndex interface,
100 AvahiProtocol protocol,
101 AvahiResolverEvent event,
105 const char *host_name,
106 const AvahiAddress *a,
108 AvahiStringList *txt,
111 /** The function prototype for the callback of an AvahiHostNameResolver */
112 typedef void (*AvahiHostNameResolverCallback) (
113 AvahiHostNameResolver *r,
114 AvahiIfIndex interface,
115 AvahiProtocol protocol,
116 AvahiResolverEvent event,
118 const AvahiAddress *a,
121 /** Creates a new client instance */
122 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
124 /** Free a client instance */
125 void avahi_client_free(AvahiClient *client);
127 /** Get the version of the server */
128 const char* avahi_client_get_version_string (AvahiClient*);
131 const char* avahi_client_get_host_name (AvahiClient*);
133 /** Get domain name */
134 const char* avahi_client_get_domain_name (AvahiClient*);
136 /** Get FQDN domain name */
137 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
140 AvahiClientState avahi_client_get_state(AvahiClient *client);
142 /** Get the last error number */
143 int avahi_client_errno (AvahiClient*);
145 /** Create a new AvahiEntryGroup object */
146 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
148 /** Clean up and free an AvahiEntryGroup object */
149 int avahi_entry_group_free (AvahiEntryGroup *);
151 /** Commit an AvahiEntryGroup */
152 int avahi_entry_group_commit (AvahiEntryGroup*);
154 /** Reset an AvahiEntryGroup */
155 int avahi_entry_group_reset (AvahiEntryGroup*);
157 /** Get an AvahiEntryGroup's state */
158 int avahi_entry_group_get_state (AvahiEntryGroup*);
160 /** Check if an AvahiEntryGroup is empty */
161 int avahi_entry_group_is_empty (AvahiEntryGroup*);
163 /** Get an AvahiEntryGroup's owning client instance */
164 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
166 /** Add a service, takes a variable NULL terminated list of text records */
167 int avahi_entry_group_add_service(
168 AvahiEntryGroup *group,
169 AvahiIfIndex interface,
170 AvahiProtocol protocol,
176 ...) AVAHI_GCC_SENTINEL;
178 /** Add a service, takes an AvahiStringList for text records */
179 int avahi_entry_group_add_service_strlst(
180 AvahiEntryGroup *group,
181 AvahiIfIndex interface,
182 AvahiProtocol protocol,
188 AvahiStringList *txt);
190 /** Add a service, takes a NULL terminated va_list for text records */
191 int avahi_entry_group_add_service_va(
192 AvahiEntryGroup *group,
193 AvahiIfIndex interface,
194 AvahiProtocol protocol,
202 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
203 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
205 /** Browse for domains on the local network */
206 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
207 AvahiIfIndex interface,
208 AvahiProtocol protocol,
210 AvahiDomainBrowserType btype,
211 AvahiDomainBrowserCallback callback,
214 /** Get the parent client of an AvahiDomainBrowser object */
215 AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
217 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
218 const char* avahi_domain_browser_get_dbus_path (AvahiDomainBrowser *);
220 /** Cleans up and frees an AvahiDomainBrowser object */
221 int avahi_domain_browser_free (AvahiDomainBrowser *);
223 /** Browse for service types on the local network */
224 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
226 AvahiIfIndex interface,
227 AvahiProtocol protocol,
229 AvahiServiceTypeBrowserCallback callback,
232 /** Get the parent client of an AvahiServiceTypeBrowser object */
233 AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
235 /** Get the D-Bus path of an AvahiServiceTypeBrowser object, for debugging purposes only. */
236 const char* avahi_service_type_browser_get_dbus_path(AvahiServiceTypeBrowser *);
238 /** Cleans up and frees an AvahiServiceTypeBrowser object */
239 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
241 /** Browse for services of a type on the local network */
242 AvahiServiceBrowser* avahi_service_browser_new (
244 AvahiIfIndex interface,
245 AvahiProtocol protocol,
248 AvahiServiceBrowserCallback callback,
251 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
252 const char* avahi_service_browser_get_dbus_path (AvahiServiceBrowser *);
254 /** Get the parent client of an AvahiServiceBrowser object */
255 AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
257 /* Cleans up and frees an AvahiServiceBrowser object */
258 int avahi_service_browser_free (AvahiServiceBrowser *);
260 /** Create a new service resolver object */
261 AvahiServiceResolver * avahi_service_resolver_new(
263 AvahiIfIndex interface,
264 AvahiProtocol protocol,
268 AvahiProtocol aprotocol,
269 AvahiServiceResolverCallback callback,
272 /** Get the parent client of an AvahiServiceResolver object */
273 AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *);
275 /** Free a service resolver object */
276 int avahi_service_resolver_free(AvahiServiceResolver *r);
278 /** Block until the resolving is complete */
279 int avahi_service_resolver_block(AvahiServiceResolver *r);
281 /** Create a new hostname resolver object */
282 AvahiHostNameResolver * avahi_host_name_resolver_new(
284 AvahiIfIndex interface,
285 AvahiProtocol protocol,
287 AvahiProtocol aprotocol,
288 AvahiHostNameResolverCallback callback,
291 /** Get the parent client of an AvahiHostNameResolver object */
292 AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *);
294 /** Free a hostname resolver object */
295 int avahi_host_name_resolver_free(AvahiHostNameResolver *r);
297 /** Block until the resolving is complete */
298 int avahi_host_name_resolver_block(AvahiHostNameResolver *r);
300 #ifndef DOXYGEN_SHOULD_SKIP_THIS