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