]> git.meshlink.io Git - catta/blob - avahi-client/lookup.h
rework documentation a bit, and explain the issues pointed out in #185 by Mathias...
[catta] / avahi-client / lookup.h
1 #ifndef fooclientlookuphfoo
2 #define fooclientlookuphfoo
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 #include <avahi-client/client.h>
35
36 /** \file avahi-client/lookup.h Lookup Client API */
37
38 /** \example client-browse-services.c Example how to browse for DNS-SD
39  * services using the client interface to avahi-daemon. */
40
41 AVAHI_C_DECL_BEGIN
42
43 /** @{ \name Domain Browser */
44
45 /** A domain browser object */
46 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
47
48 /** The function prototype for the callback of an AvahiDomainBrowser */
49 typedef void (*AvahiDomainBrowserCallback) (
50     AvahiDomainBrowser *b,
51     AvahiIfIndex interface,
52     AvahiProtocol protocol,
53     AvahiBrowserEvent event,
54     const char *domain,
55     AvahiLookupResultFlags flags,
56     void *userdata);
57
58 /** Browse for domains on the local network */
59 AvahiDomainBrowser* avahi_domain_browser_new (
60     AvahiClient *client,
61     AvahiIfIndex interface,
62     AvahiProtocol protocol,
63     const char *domain,
64     AvahiDomainBrowserType btype,
65     AvahiLookupFlags flags,
66     AvahiDomainBrowserCallback callback,
67     void *userdata);
68
69 /** Get the parent client of an AvahiDomainBrowser object */
70 AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
71
72 /** Cleans up and frees an AvahiDomainBrowser object */
73 int avahi_domain_browser_free (AvahiDomainBrowser *);
74
75 /** @} */
76
77 /** @{ \name Service Browser */
78
79 /** A service browser object */
80 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
81
82 /** The function prototype for the callback of an AvahiServiceBrowser */
83 typedef void (*AvahiServiceBrowserCallback) (
84     AvahiServiceBrowser *b,
85     AvahiIfIndex interface,
86     AvahiProtocol protocol,
87     AvahiBrowserEvent event,
88     const char *name,
89     const char *type,
90     const char *domain,
91     AvahiLookupResultFlags flags,
92     void *userdata);
93
94 /** Browse for services of a type on the network. In most cases you
95  * probably want to pass AVAHI_IF_UNSPEC and AVAHI_PROTO_UNSPED in
96  * interface, resp. protocol to browse on all local networks. The
97  * specified callback will be called whenever a new service appears
98  * or is removed from the network. Please note that events may be
99  * collapsed to minimize traffic (i.e. a REMOVED followed by a NEW for
100  * the same service data is dropped because redundant). If you want to
101  * subscribe to service data changes, you should use
102  * avahi_service_resolver_new() and keep it open, in which case you
103  * will be notified via AVAHI_RESOLVE_FOUND everytime the service data
104  * changes. */
105 AvahiServiceBrowser* avahi_service_browser_new (
106     AvahiClient *client,
107     AvahiIfIndex interface,     /**< In most cases pass AVAHI_IF_UNSPEC here */
108     AvahiProtocol protocol,     /**< In most cases pass AVAHI_PROTO_UNSPEC here */
109     const char *type,           /**< A service type such as "_http._tcp" */
110     const char *domain,         /**< A domain to browse in. In most cases you want to pass NULL here for the default domain (usually ".local") */
111     AvahiLookupFlags flags,
112     AvahiServiceBrowserCallback callback,
113     void *userdata);
114
115 /** Get the parent client of an AvahiServiceBrowser object */
116 AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
117
118 /** Cleans up and frees an AvahiServiceBrowser object */
119 int avahi_service_browser_free (AvahiServiceBrowser *);
120
121 /** @} */
122
123 /** \cond fulldocs */
124 /** A service type browser object */
125 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
126
127 /** The function prototype for the callback of an AvahiServiceTypeBrowser */
128 typedef void (*AvahiServiceTypeBrowserCallback) (
129     AvahiServiceTypeBrowser *b,
130     AvahiIfIndex interface,
131     AvahiProtocol protocol,
132     AvahiBrowserEvent event,
133     const char *type,
134     const char *domain,
135     AvahiLookupResultFlags flags,
136     void *userdata);
137
138 /** Browse for service types on the local network */
139 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
140     AvahiClient *client,
141     AvahiIfIndex interface,
142     AvahiProtocol protocol,
143     const char *domain,
144     AvahiLookupFlags flags,
145     AvahiServiceTypeBrowserCallback callback,
146     void *userdata);
147
148 /** Get the parent client of an AvahiServiceTypeBrowser object */
149 AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
150
151 /** Cleans up and frees an AvahiServiceTypeBrowser object */
152 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
153
154 /** \endcond */
155
156 /** @{ \name Service Resolver */
157
158 /** A service resolver object */
159 typedef struct AvahiServiceResolver AvahiServiceResolver;
160
161 /** The function prototype for the callback of an AvahiServiceResolver */
162 typedef void (*AvahiServiceResolverCallback) (
163     AvahiServiceResolver *r,
164     AvahiIfIndex interface,
165     AvahiProtocol protocol,
166     AvahiResolverEvent event,
167     const char *name,
168     const char *type,
169     const char *domain,
170     const char *host_name,
171     const AvahiAddress *a,
172     uint16_t port,
173     AvahiStringList *txt,
174     AvahiLookupResultFlags flags,
175     void *userdata);
176
177 /** Create a new service resolver object. Please make sure to pass all
178  * the service data you received via avahi_service_browser_new()'s
179  * callback function, especially interface and protocol. The protocol
180  * argument specifies the protocol (IPv4 or IPv6) to use as transport
181  * for the queries which are sent out by this resolver. The
182  * aprotocol argument specifies the adress family (IPv4 or IPv6) of
183  * the address of the service we are looking for. Generally, on
184  * "protocol" you should only pass what was supplied to you as
185  * parameter to your AvahiServiceBrowserCallback. In "aprotocol" you
186  * should pass what your application code can deal with when
187  * connecting to the service. Or, more technically speaking: protocol
188  * specifies if the mDNS queries should be sent as UDP/IPv4
189  * resp. UDP/IPv6 packets. aprotocol specifies whether the query is for a A
190  * resp. AAAA resource record. */
191 AvahiServiceResolver * avahi_service_resolver_new(
192     AvahiClient *client,
193     AvahiIfIndex interface,   /**< Pass the interface argument you recieved in AvahiServiceBrowserCallback here. */
194     AvahiProtocol protocol,   /**< Pass the protocol argument you recieved in AvahiServiceBrowserCallback here. */
195     const char *name,         /**< Pass the name argument you recieved in AvahiServiceBrowserCallback here. */
196     const char *type,         /**< Pass the type argument you recieved in AvahiServiceBrowserCallback here. */
197     const char *domain,       /**< Pass the domain argument you recieved in AvahiServiceBrowserCallback here. */
198     AvahiProtocol aprotocol,  /**< The desired address family of the service address to resolve. AVAHI_PROTO_UNSPEC if your application can deal with both IPv4 and IPv6 */
199     AvahiLookupFlags flags,
200     AvahiServiceResolverCallback callback,
201     void *userdata);
202
203 /** Get the parent client of an AvahiServiceResolver object */
204 AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *);
205
206 /** Free a service resolver object */
207 int avahi_service_resolver_free(AvahiServiceResolver *r);
208
209 /** @} */
210
211 /** \cond fulldocs */
212 /** A service resolver object */
213 typedef struct AvahiHostNameResolver AvahiHostNameResolver;
214
215 /** The function prototype for the callback of an AvahiHostNameResolver */
216 typedef void (*AvahiHostNameResolverCallback) (
217     AvahiHostNameResolver *r,
218     AvahiIfIndex interface,
219     AvahiProtocol protocol,
220     AvahiResolverEvent event,
221     const char *name,
222     const AvahiAddress *a,
223     AvahiLookupResultFlags flags,
224     void *userdata);
225
226 /** Create a new hostname resolver object */
227 AvahiHostNameResolver * avahi_host_name_resolver_new(
228     AvahiClient *client,
229     AvahiIfIndex interface,
230     AvahiProtocol protocol,
231     const char *name,
232     AvahiProtocol aprotocol,
233     AvahiLookupFlags flags,
234     AvahiHostNameResolverCallback callback,
235     void *userdata);
236
237 /** Get the parent client of an AvahiHostNameResolver object */
238 AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *);
239
240 /** Free a hostname resolver object */
241 int avahi_host_name_resolver_free(AvahiHostNameResolver *r);
242
243 /** An address resolver object */
244 typedef struct AvahiAddressResolver AvahiAddressResolver;
245
246 /** The function prototype for the callback of an AvahiAddressResolver */
247 typedef void (*AvahiAddressResolverCallback) (
248     AvahiAddressResolver *r,
249     AvahiIfIndex interface,
250     AvahiProtocol protocol,
251     AvahiResolverEvent event,
252     const AvahiAddress *a,
253     const char *name,
254     AvahiLookupResultFlags flags,
255     void *userdata);
256
257 /** Create a new address resolver object from an AvahiAddress object */
258 AvahiAddressResolver* avahi_address_resolver_new(
259     AvahiClient *client,
260     AvahiIfIndex interface,
261     AvahiProtocol protocol,
262     const AvahiAddress *a,
263     AvahiLookupFlags flags,
264     AvahiAddressResolverCallback callback,
265     void *userdata);
266
267 /** Get the parent client of an AvahiAddressResolver object */
268 AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *);
269
270 /** Free a AvahiAddressResolver resolver object */
271 int avahi_address_resolver_free(AvahiAddressResolver *r);
272
273 /** \endcond */
274
275 /** @{ \name Record Browser */
276
277 /** A record browser object */
278 typedef struct AvahiRecordBrowser AvahiRecordBrowser;
279
280 /** The function prototype for the callback of an AvahiRecordBrowser */
281 typedef void (*AvahiRecordBrowserCallback) (
282     AvahiRecordBrowser *b,
283     AvahiIfIndex interface,
284     AvahiProtocol protocol,
285     AvahiBrowserEvent event,
286     const char *name,
287     uint16_t clazz,
288     uint16_t type,
289     const void *rdata,
290     size_t size,
291     AvahiLookupResultFlags flags,
292     void *userdata);
293
294 /** Browse for records of a type on the local network */
295 AvahiRecordBrowser* avahi_record_browser_new(
296     AvahiClient *client,
297     AvahiIfIndex interface,
298     AvahiProtocol protocol,
299     const char *name,
300     uint16_t clazz,
301     uint16_t type,
302     AvahiLookupFlags flags,
303     AvahiRecordBrowserCallback callback,
304     void *userdata);
305
306 /** Get the parent client of an AvahiRecordBrowser object */
307 AvahiClient* avahi_record_browser_get_client(AvahiRecordBrowser *);
308
309 /** Cleans up and frees an AvahiRecordBrowser object */
310 int avahi_record_browser_free(AvahiRecordBrowser *);
311
312 /** @} */
313
314 AVAHI_C_DECL_END
315
316 #endif