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 /** States of a client object, a superset of AvahiServerState */
71 AVAHI_CLIENT_S_INVALID = AVAHI_SERVER_INVALID,
72 AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING,
73 AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING,
74 AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION,
75 AVAHI_CLIENT_DISCONNECTED = 100 /**< Lost DBUS connection to the Avahi daemon */
78 /** The function prototype for the callback of an AvahiClient */
79 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
81 /** The function prototype for the callback of an AvahiEntryGroup */
82 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
84 /** The function prototype for the callback of an AvahiDomainBrowser */
85 typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void *userdata);
87 /** The function prototype for the callback of an AvahiServiceBrowser */
88 typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void *userdata);
90 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
91 typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void *userdata);
93 /** The function prototype for the callback of an AvahiServiceResolver */
94 typedef void (*AvahiServiceResolverCallback) (
95 AvahiServiceResolver *r,
96 AvahiIfIndex interface,
97 AvahiProtocol protocol,
98 AvahiResolverEvent event,
102 const char *host_name,
103 const AvahiAddress *a,
105 AvahiStringList *txt,
108 /** Creates a new client instance */
109 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
111 /** Free a client instance */
112 void avahi_client_free(AvahiClient *client);
114 /** Get the version of the server */
115 const char* avahi_client_get_version_string (AvahiClient*);
118 const char* avahi_client_get_host_name (AvahiClient*);
120 /** Get domain name */
121 const char* avahi_client_get_domain_name (AvahiClient*);
123 /** Get FQDN domain name */
124 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
127 AvahiClientState avahi_client_get_state(AvahiClient *client);
129 /** Get the last error number */
130 int avahi_client_errno (AvahiClient*);
132 /** Create a new AvahiEntryGroup object */
133 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
135 /** Clean up and free an AvahiEntryGroup object */
136 int avahi_entry_group_free (AvahiEntryGroup *);
138 /** Commit an AvahiEntryGroup */
139 int avahi_entry_group_commit (AvahiEntryGroup*);
141 /** Reset an AvahiEntryGroup */
142 int avahi_entry_group_reset (AvahiEntryGroup*);
144 /** Get an AvahiEntryGroup's state */
145 int avahi_entry_group_get_state (AvahiEntryGroup*);
147 /** Check if an AvahiEntryGroup is empty */
148 int avahi_entry_group_is_empty (AvahiEntryGroup*);
150 /** Get an AvahiEntryGroup's owning client instance */
151 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
153 /** Add a service, takes a variable NULL terminated list of text records */
154 int avahi_entry_group_add_service(
155 AvahiEntryGroup *group,
156 AvahiIfIndex interface,
157 AvahiProtocol protocol,
163 ...) AVAHI_GCC_SENTINEL;
165 /** Add a service, takes an AvahiStringList for text records */
166 int avahi_entry_group_add_service_strlst(
167 AvahiEntryGroup *group,
168 AvahiIfIndex interface,
169 AvahiProtocol protocol,
175 AvahiStringList *txt);
177 /** Add a service, takes a NULL terminated va_list for text records */
178 int avahi_entry_group_add_service_va(
179 AvahiEntryGroup *group,
180 AvahiIfIndex interface,
181 AvahiProtocol protocol,
189 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
190 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
192 /** Browse for domains on the local network */
193 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
194 AvahiIfIndex interface,
195 AvahiProtocol protocol,
197 AvahiDomainBrowserType btype,
198 AvahiDomainBrowserCallback callback,
201 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
202 const char* avahi_domain_browser_get_dbus_path (AvahiDomainBrowser *);
204 /** Cleans up and frees an AvahiDomainBrowser object */
205 int avahi_domain_browser_free (AvahiDomainBrowser *);
207 /** Browse for service types on the local network */
208 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
210 AvahiIfIndex interface,
211 AvahiProtocol protocol,
213 AvahiServiceTypeBrowserCallback callback,
216 /** Get the D-Bus path of an AvahiServiceTypeBrowser object, for debugging purposes only. */
217 const char* avahi_service_type_browser_get_dbus_path(AvahiServiceTypeBrowser *);
219 /** Cleans up and frees an AvahiServiceTypeBrowser object */
220 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
222 /** Browse for services of a type on the local network */
223 AvahiServiceBrowser* avahi_service_browser_new (
225 AvahiIfIndex interface,
226 AvahiProtocol protocol,
229 AvahiServiceBrowserCallback callback,
232 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
233 const char* avahi_service_browser_get_dbus_path (AvahiServiceBrowser *);
235 /* Cleans up and frees an AvahiServiceBrowser object */
236 int avahi_service_browser_free (AvahiServiceBrowser *);
238 /** Create a new service resolver object */
239 AvahiServiceResolver * avahi_service_resolver_new(
241 AvahiIfIndex interface,
242 AvahiProtocol protocol,
246 AvahiProtocol aprotocol,
247 AvahiServiceResolverCallback callback,
250 /** Free a service resolver object */
251 int avahi_service_resolver_free(AvahiServiceResolver *r);
253 /** Block until the resolving is complete */
254 int avahi_service_resolver_block(AvahiServiceResolver *r);
256 #ifndef DOXYGEN_SHOULD_SKIP_THIS