]> git.meshlink.io Git - catta/blob - avahi-client/client.h
bad07898ac0ba5972e18fbd34d969909ca73e02f
[catta] / avahi-client / client.h
1 #ifndef fooclienthfoo
2 #define fooclienthfoo
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 <inttypes.h>
26
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>
33
34 /** \file client.h Definitions and functions for the client API over D-Bus */
35
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. */
39
40 /** \example client-browse-services.c Example how to browse for DNS-SD
41  * services using the client interface to avahi-daemon. */
42
43 /** \example glib-integration.c Example of how to integrate
44  * avahi use with GLIB/GTK applications */
45  
46
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 AVAHI_C_DECL_BEGIN
49 #endif
50
51 /** A connection context */
52 typedef struct AvahiClient AvahiClient;
53
54 /** An entry group object */
55 typedef struct AvahiEntryGroup AvahiEntryGroup;
56
57 /** A domain browser object */
58 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
59
60 /** A service browser object */
61 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
62
63 /** A service type browser object */
64 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
65
66 /** A service resolver object */
67 typedef struct AvahiServiceResolver AvahiServiceResolver;
68
69 /** A service resolver object */
70 typedef struct AvahiHostNameResolver AvahiHostNameResolver;
71
72 /** An address resolver object */
73 typedef struct AvahiAddressResolver AvahiAddressResolver;
74
75 /** States of a client object, a superset of AvahiServerState */
76 typedef enum {
77     AVAHI_CLIENT_S_INVALID = AVAHI_SERVER_INVALID,
78     AVAHI_CLIENT_S_REGISTERING = AVAHI_SERVER_REGISTERING,
79     AVAHI_CLIENT_S_RUNNING = AVAHI_SERVER_RUNNING,
80     AVAHI_CLIENT_S_COLLISION = AVAHI_SERVER_COLLISION,
81     AVAHI_CLIENT_DISCONNECTED = 100 /**< Lost DBUS connection to the Avahi daemon */
82 } AvahiClientState;
83
84 /** The function prototype for the callback of an AvahiClient */
85 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
86
87 /** The function prototype for the callback of an AvahiEntryGroup */
88 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
89
90 /** The function prototype for the callback of an AvahiDomainBrowser */
91 typedef void (*AvahiDomainBrowserCallback) (AvahiDomainBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *domain, AvahiLookupResultFlags flags, void *userdata);
92
93 /** The function prototype for the callback of an AvahiServiceBrowser */
94 typedef void (*AvahiServiceBrowserCallback) (AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void *userdata);
95
96 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
97 typedef void (*AvahiServiceTypeBrowserCallback) (AvahiServiceTypeBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *type, const char *domain, AvahiLookupResultFlags flags, void *userdata);
98
99 /** The function prototype for the callback of an AvahiServiceResolver */
100 typedef void (*AvahiServiceResolverCallback) (
101     AvahiServiceResolver *r,
102     AvahiIfIndex interface,
103     AvahiProtocol protocol,
104     AvahiResolverEvent event,
105     const char *name,
106     const char *type,
107     const char *domain,
108     const char *host_name,
109     const AvahiAddress *a,
110     uint16_t port,
111     AvahiStringList *txt,
112     AvahiLookupResultFlags flags, 
113     void *userdata);
114
115 /** The function prototype for the callback of an AvahiHostNameResolver */
116 typedef void (*AvahiHostNameResolverCallback) (
117     AvahiHostNameResolver *r,
118     AvahiIfIndex interface,
119     AvahiProtocol protocol,
120     AvahiResolverEvent event,
121     const char *name,
122     const AvahiAddress *a,
123     AvahiLookupResultFlags flags, 
124     void *userdata);
125
126 /** The function prototype for the callback of an AvahiAddressResolver */
127 typedef void (*AvahiAddressResolverCallback) (
128     AvahiAddressResolver *r,
129     AvahiIfIndex interface,
130     AvahiProtocol protocol,
131     AvahiResolverEvent event,
132     AvahiProtocol aprotocol,
133     const AvahiAddress *a,
134     const char *name,
135     AvahiLookupResultFlags flags, 
136     void *userdata);
137
138 /** Creates a new client instance */
139 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
140
141 /** Free a client instance */
142 void avahi_client_free(AvahiClient *client);
143
144 /** Get the version of the server */
145 const char* avahi_client_get_version_string (AvahiClient*);
146
147 /** Get host name */
148 const char* avahi_client_get_host_name (AvahiClient*);
149
150 /** Get domain name */
151 const char* avahi_client_get_domain_name (AvahiClient*);
152
153 /** Get FQDN domain name */
154 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
155
156 /** Get state */
157 AvahiClientState avahi_client_get_state(AvahiClient *client); 
158
159 /** Get the last error number */
160 int avahi_client_errno (AvahiClient*);
161
162 /** Create a new AvahiEntryGroup object */
163 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
164
165 /** Clean up and free an AvahiEntryGroup object */
166 int avahi_entry_group_free (AvahiEntryGroup *);
167
168 /** Commit an AvahiEntryGroup */
169 int avahi_entry_group_commit (AvahiEntryGroup*);
170
171 /** Reset an AvahiEntryGroup */
172 int avahi_entry_group_reset (AvahiEntryGroup*);
173
174 /** Get an AvahiEntryGroup's state */
175 int avahi_entry_group_get_state (AvahiEntryGroup*);
176
177 /** Check if an AvahiEntryGroup is empty */
178 int avahi_entry_group_is_empty (AvahiEntryGroup*);
179
180 /** Get an AvahiEntryGroup's owning client instance */
181 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
182
183 /** Add a service, takes a variable NULL terminated list of text records */
184 int avahi_entry_group_add_service(
185     AvahiEntryGroup *group,
186     AvahiIfIndex interface,
187     AvahiProtocol protocol,
188     AvahiPublishFlags flags,
189     const char *name,
190     const char *type,
191     const char *domain,
192     const char *host,
193     uint16_t port,
194     ...) AVAHI_GCC_SENTINEL;
195
196 /** Add a service, takes an AvahiStringList for text records */
197 int avahi_entry_group_add_service_strlst(
198     AvahiEntryGroup *group,
199     AvahiIfIndex interface,
200     AvahiProtocol protocol,
201     AvahiPublishFlags flags,
202     const char *name,
203     const char *type,
204     const char *domain,
205     const char *host,
206     uint16_t port,
207     AvahiStringList *txt);
208
209 /** Add a service, takes a NULL terminated va_list for text records */
210 int avahi_entry_group_add_service_va(
211     AvahiEntryGroup *group,
212     AvahiIfIndex interface,
213     AvahiProtocol protocol,
214     AvahiPublishFlags flags,
215     const char *name,
216     const char *type,
217     const char *domain,
218     const char *host,
219     uint16_t port,
220     va_list va);
221
222 /** Add a subtype for a service */
223 int avahi_entry_group_add_service_subtype(
224     AvahiEntryGroup *group,
225     AvahiIfIndex interface,
226     AvahiProtocol protocol,
227     AvahiPublishFlags flags,
228     const char *name,
229     const char *type,
230     const char *domain,
231     const char *subtype);
232
233 /** Browse for domains on the local network */
234 AvahiDomainBrowser* avahi_domain_browser_new (
235     AvahiClient *client,
236     AvahiIfIndex interface,
237     AvahiProtocol protocol,
238     const char *domain,
239     AvahiDomainBrowserType btype,
240     AvahiLookupFlags flags,
241     AvahiDomainBrowserCallback callback,
242     void *userdata);
243
244 /** Get the parent client of an AvahiDomainBrowser object */
245 AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
246
247 /** Cleans up and frees an AvahiDomainBrowser object */
248 int avahi_domain_browser_free (AvahiDomainBrowser *);
249
250 /** Browse for service types on the local network */
251 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
252     AvahiClient *client,
253     AvahiIfIndex interface,
254     AvahiProtocol protocol,
255     const char *domain,
256     AvahiLookupFlags flags,
257     AvahiServiceTypeBrowserCallback callback,
258     void *userdata);
259
260 /** Get the parent client of an AvahiServiceTypeBrowser object */
261 AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
262
263 /** Cleans up and frees an AvahiServiceTypeBrowser object */
264 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
265
266 /** Browse for services of a type on the local network */
267 AvahiServiceBrowser* avahi_service_browser_new (
268     AvahiClient *client,
269     AvahiIfIndex interface,
270     AvahiProtocol protocol,
271     const char *type,
272     const char *domain,
273     AvahiLookupFlags flags,
274     AvahiServiceBrowserCallback callback,
275     void *userdata);
276
277 /** Get the parent client of an AvahiServiceBrowser object */
278 AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
279
280 /* Cleans up and frees an AvahiServiceBrowser object */
281 int avahi_service_browser_free (AvahiServiceBrowser *);
282
283 /** Create a new service resolver object */
284 AvahiServiceResolver * avahi_service_resolver_new(
285     AvahiClient *client,
286     AvahiIfIndex interface,
287     AvahiProtocol protocol,
288     const char *name,
289     const char *type,
290     const char *domain,
291     AvahiProtocol aprotocol,
292     AvahiLookupFlags flags,
293     AvahiServiceResolverCallback callback,
294     void *userdata);
295
296 /** Get the parent client of an AvahiServiceResolver object */
297 AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *);
298
299 /** Free a service resolver object */
300 int avahi_service_resolver_free(AvahiServiceResolver *r);
301
302 /** Create a new hostname resolver object */
303 AvahiHostNameResolver * avahi_host_name_resolver_new(
304     AvahiClient *client,
305     AvahiIfIndex interface,
306     AvahiProtocol protocol,
307     const char *name,
308     AvahiProtocol aprotocol,
309     AvahiLookupFlags flags,
310     AvahiHostNameResolverCallback callback,
311     void *userdata);
312
313 /** Get the parent client of an AvahiHostNameResolver object */
314 AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *);
315
316 /** Free a hostname resolver object */
317 int avahi_host_name_resolver_free(AvahiHostNameResolver *r);
318
319 /** Create a new address resolver object from an address string.  Set aprotocol to AF_UNSPEC for protocol detection. */
320 AvahiAddressResolver * avahi_address_resolver_new(
321     AvahiClient *client,
322     AvahiIfIndex interface,
323     AvahiProtocol protocol,
324     const char *address,
325     AvahiLookupFlags flags,
326     AvahiAddressResolverCallback callback,
327     void *userdata);
328
329 /** Create a new address resolver object from an AvahiAddress object */
330 AvahiAddressResolver* avahi_address_resolver_new_a(
331     AvahiClient *client,
332     AvahiIfIndex interface,
333     AvahiProtocol protocol,
334     const AvahiAddress *a,
335     AvahiLookupFlags flags,
336     AvahiAddressResolverCallback callback,
337     void *userdata);
338
339 /** Get the parent client of an AvahiAddressResolver object */
340 AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *);
341
342 /** Free a AvahiAddressResolver resolver object */
343 int avahi_address_resolver_free(AvahiAddressResolver *r);
344
345 /** Return the local service cookie. returns AVAHI_SERVICE_COOKIE_INVALID on failure. */
346 uint32_t avahi_client_get_local_service_cookie(AvahiClient *client);
347
348 /** Return 1 if the specified service is a registered locally, negative on failure, 0 otherwise. */
349 int avahi_client_is_service_local(AvahiClient *client, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain);
350
351 #ifndef DOXYGEN_SHOULD_SKIP_THIS
352 AVAHI_C_DECL_END
353 #endif
354
355 #endif