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. */
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 /** A connection context */
49 typedef struct AvahiClient AvahiClient;
51 /** An entry group object */
52 typedef struct AvahiEntryGroup AvahiEntryGroup;
54 /** A domain browser object */
55 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
57 /** A service browser object */
58 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
60 /** A service type browser object */
61 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
63 /** A service resolver object */
64 typedef struct AvahiServiceResolver AvahiServiceResolver;
66 /** States of a client object, a superset of AvahiServerState */
68 AVAHI_CLIENT_S_INVALID = AVAHI_SERVER_INVALID,
69 AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING,
70 AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING,
71 AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION,
72 AVAHI_CLIENT_DISCONNECTED = 100 /**< Lost DBUS connection to the Avahi daemon */
75 /** The function prototype for the callback of an AvahiClient */
76 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
78 /** The function prototype for the callback of an AvahiEntryGroup */
79 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
81 /** The function prototype for the callback of an AvahiDomainBrowser */
82 typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, void *userdata);
84 /** The function prototype for the callback of an AvahiServiceBrowser */
85 typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, void *userdata);
87 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
88 typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, void *userdata);
90 /** The function prototype for the callback of an AvahiServiceResolver */
91 typedef void (*AvahiServiceResolverCallback) (
92 AvahiServiceResolver *r,
93 AvahiIfIndex interface,
94 AvahiProtocol protocol,
95 AvahiResolverEvent event,
99 const char *host_name,
100 const AvahiAddress *a,
102 AvahiStringList *txt,
105 /** Creates a new client instance */
106 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
108 /** Free a client instance */
109 void avahi_client_free(AvahiClient *client);
111 /** Get the version of the server */
112 const char* avahi_client_get_version_string (AvahiClient*);
115 const char* avahi_client_get_host_name (AvahiClient*);
117 /** Get domain name */
118 const char* avahi_client_get_domain_name (AvahiClient*);
120 /** Get FQDN domain name */
121 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
124 AvahiClientState avahi_client_get_state(AvahiClient *client);
126 /** Get the last error number */
127 int avahi_client_errno (AvahiClient*);
129 /** Create a new AvahiEntryGroup object */
130 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
132 /** Clean up and free an AvahiEntryGroup object */
133 int avahi_entry_group_free (AvahiEntryGroup *);
135 /** Commit an AvahiEntryGroup */
136 int avahi_entry_group_commit (AvahiEntryGroup*);
138 /** Reset an AvahiEntryGroup */
139 int avahi_entry_group_reset (AvahiEntryGroup*);
141 /** Get an AvahiEntryGroup's state */
142 int avahi_entry_group_get_state (AvahiEntryGroup*);
144 /** Check if an AvahiEntryGroup is empty */
145 int avahi_entry_group_is_empty (AvahiEntryGroup*);
147 /** Get an AvahiEntryGroup's owning client instance */
148 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
150 /** Add a service, takes a variable NULL terminated list of text records */
151 int avahi_entry_group_add_service(
152 AvahiEntryGroup *group,
153 AvahiIfIndex interface,
154 AvahiProtocol protocol,
160 ...) AVAHI_GCC_SENTINEL;
162 /** Add a service, takes an AvahiStringList for text records */
163 int avahi_entry_group_add_service_strlst(
164 AvahiEntryGroup *group,
165 AvahiIfIndex interface,
166 AvahiProtocol protocol,
172 AvahiStringList *txt);
174 /** Add a service, takes a NULL terminated va_list for text records */
175 int avahi_entry_group_add_service_va(
176 AvahiEntryGroup *group,
177 AvahiIfIndex interface,
178 AvahiProtocol protocol,
186 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
187 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
189 /** Browse for domains on the local network */
190 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
191 AvahiIfIndex interface,
192 AvahiProtocol protocol,
194 AvahiDomainBrowserType btype,
195 AvahiDomainBrowserCallback callback,
198 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
199 const char* avahi_domain_browser_get_dbus_path (AvahiDomainBrowser *);
201 /** Cleans up and frees an AvahiDomainBrowser object */
202 int avahi_domain_browser_free (AvahiDomainBrowser *);
204 /** Browse for service types on the local network */
205 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
207 AvahiIfIndex interface,
208 AvahiProtocol protocol,
210 AvahiServiceTypeBrowserCallback callback,
213 /** Get the D-Bus path of an AvahiServiceTypeBrowser object, for debugging purposes only. */
214 const char* avahi_service_type_browser_get_dbus_path(AvahiServiceTypeBrowser *);
216 /** Cleans up and frees an AvahiServiceTypeBrowser object */
217 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
219 /** Browse for services of a type on the local network */
220 AvahiServiceBrowser* avahi_service_browser_new (
222 AvahiIfIndex interface,
223 AvahiProtocol protocol,
226 AvahiServiceBrowserCallback callback,
229 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
230 const char* avahi_service_browser_get_dbus_path (AvahiServiceBrowser *);
232 /* Cleans up and frees an AvahiServiceBrowser object */
233 int avahi_service_browser_free (AvahiServiceBrowser *);
235 /** Create a new service resolver object */
236 AvahiServiceResolver * avahi_service_resolver_new(
238 AvahiIfIndex interface,
239 AvahiProtocol protocol,
243 AvahiProtocol aprotocol,
244 AvahiServiceResolverCallback callback,
247 /** Free a service resolver object */
248 int avahi_service_resolver_free(AvahiServiceResolver *r);
250 /** Block until the resolving is complete */
251 int avahi_service_resolver_block(AvahiServiceResolver *r);
253 #ifndef DOXYGEN_SHOULD_SKIP_THIS