]> git.meshlink.io Git - catta/blob - avahi-client/client.h
* Implement the HostNameResolver in the avahi-client C api
[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 /** States of a client object, a superset of AvahiServerState */
73 typedef enum {
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 */
79 } AvahiClientState;
80
81 /** The function prototype for the callback of an AvahiClient */
82 typedef void (*AvahiClientCallback) (AvahiClient *s, AvahiClientState state, void* userdata);
83
84 /** The function prototype for the callback of an AvahiEntryGroup */
85 typedef void (*AvahiEntryGroupCallback) (AvahiEntryGroup *g, AvahiEntryGroupState state, void* userdata);
86
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);
89
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);
92
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);
95
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,
102     const char *name,
103     const char *type,
104     const char *domain,
105     const char *host_name,
106     const AvahiAddress *a,
107     uint16_t port,
108     AvahiStringList *txt,
109     void *userdata);
110
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,
117     const char *name,
118     const AvahiAddress *a,
119     void *userdata);
120
121 /** Creates a new client instance */
122 AvahiClient* avahi_client_new (const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *error);
123
124 /** Free a client instance */
125 void avahi_client_free(AvahiClient *client);
126
127 /** Get the version of the server */
128 const char* avahi_client_get_version_string (AvahiClient*);
129
130 /** Get host name */
131 const char* avahi_client_get_host_name (AvahiClient*);
132
133 /** Get domain name */
134 const char* avahi_client_get_domain_name (AvahiClient*);
135
136 /** Get FQDN domain name */
137 const char* avahi_client_get_host_name_fqdn (AvahiClient*);
138
139 /** Get state */
140 AvahiClientState avahi_client_get_state(AvahiClient *client); 
141
142 /** Get the last error number */
143 int avahi_client_errno (AvahiClient*);
144
145 /** Create a new AvahiEntryGroup object */
146 AvahiEntryGroup* avahi_entry_group_new (AvahiClient*, AvahiEntryGroupCallback callback, void *userdata);
147
148 /** Clean up and free an AvahiEntryGroup object */
149 int avahi_entry_group_free (AvahiEntryGroup *);
150
151 /** Commit an AvahiEntryGroup */
152 int avahi_entry_group_commit (AvahiEntryGroup*);
153
154 /** Reset an AvahiEntryGroup */
155 int avahi_entry_group_reset (AvahiEntryGroup*);
156
157 /** Get an AvahiEntryGroup's state */
158 int avahi_entry_group_get_state (AvahiEntryGroup*);
159
160 /** Check if an AvahiEntryGroup is empty */
161 int avahi_entry_group_is_empty (AvahiEntryGroup*);
162
163 /** Get an AvahiEntryGroup's owning client instance */
164 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
165
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,
171     const char *name,
172     const char *type,
173     const char *domain,
174     const char *host,
175     uint16_t port,
176     ...) AVAHI_GCC_SENTINEL;
177
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,
183     const char *name,
184     const char *type,
185     const char *domain,
186     const char *host,
187     uint16_t port,
188     AvahiStringList *txt);
189
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,
195     const char *name,
196     const char *type,
197     const char *domain,
198     const char *host,
199     uint16_t port,
200     va_list va);
201
202 /** Get the D-Bus path of an AvahiEntryGroup object, for debugging purposes only. */
203 const char* avahi_entry_group_get_dbus_path (AvahiEntryGroup *);
204
205 /** Browse for domains on the local network */
206 AvahiDomainBrowser* avahi_domain_browser_new (AvahiClient *client,
207                                               AvahiIfIndex interface,
208                                               AvahiProtocol protocol,
209                                               const char *domain,
210                                               AvahiDomainBrowserType btype,
211                                               AvahiDomainBrowserCallback callback,
212                                               void *userdata);
213
214 /** Get the parent client of an AvahiDomainBrowser object */
215 AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
216
217 /** Get the D-Bus path of an AvahiDomainBrowser object, for debugging purposes only. */
218 const char* avahi_domain_browser_get_dbus_path (AvahiDomainBrowser *);
219
220 /** Cleans up and frees an AvahiDomainBrowser object */
221 int avahi_domain_browser_free (AvahiDomainBrowser *);
222
223 /** Browse for service types on the local network */
224 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
225                 AvahiClient *client,
226                 AvahiIfIndex interface,
227                 AvahiProtocol protocol,
228                 const char *domain,
229                 AvahiServiceTypeBrowserCallback callback,
230                 void *userdata);
231
232 /** Get the parent client of an AvahiServiceTypeBrowser object */
233 AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
234
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 *);
237
238 /** Cleans up and frees an AvahiServiceTypeBrowser object */
239 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
240
241 /** Browse for services of a type on the local network */
242 AvahiServiceBrowser* avahi_service_browser_new (
243                 AvahiClient *client,
244                 AvahiIfIndex interface,
245                 AvahiProtocol protocol,
246                 const char *type,
247                 const char *domain,
248                 AvahiServiceBrowserCallback callback,
249                 void *userdata);
250
251 /** Get the D-Bus path of an AvahiServiceBrowser object, for debugging purposes only. */
252 const char* avahi_service_browser_get_dbus_path (AvahiServiceBrowser *);
253
254 /** Get the parent client of an AvahiServiceBrowser object */
255 AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
256
257 /* Cleans up and frees an AvahiServiceBrowser object */
258 int avahi_service_browser_free (AvahiServiceBrowser *);
259
260 /** Create a new service resolver object */
261 AvahiServiceResolver * avahi_service_resolver_new(
262     AvahiClient *client,
263     AvahiIfIndex interface,
264     AvahiProtocol protocol,
265     const char *name,
266     const char *type,
267     const char *domain,
268     AvahiProtocol aprotocol,
269     AvahiServiceResolverCallback callback,
270     void *userdata);
271
272 /** Get the parent client of an AvahiServiceResolver object */
273 AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *);
274
275 /** Free a service resolver object */
276 int avahi_service_resolver_free(AvahiServiceResolver *r);
277
278 /** Block until the resolving is complete */
279 int avahi_service_resolver_block(AvahiServiceResolver *r);
280
281 /** Create a new hostname resolver object */
282 AvahiHostNameResolver * avahi_host_name_resolver_new(
283     AvahiClient *client,
284     AvahiIfIndex interface,
285     AvahiProtocol protocol,
286     const char *name,
287     AvahiProtocol aprotocol,
288     AvahiHostNameResolverCallback callback,
289     void *userdata);
290
291 /** Get the parent client of an AvahiHostNameResolver object */
292 AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *);
293
294 /** Free a hostname resolver object */
295 int avahi_host_name_resolver_free(AvahiHostNameResolver *r);
296
297 /** Block until the resolving is complete */
298 int avahi_host_name_resolver_block(AvahiHostNameResolver *r);
299
300 #ifndef DOXYGEN_SHOULD_SKIP_THIS
301 AVAHI_C_DECL_END
302 #endif
303
304 #endif