1 #ifndef fooclientlookuphfoo
2 #define fooclientlookuphfoo
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 #include <avahi-client/client.h>
36 /** \file avahi-client/lookup.h Lookup Client API */
38 /** \example client-browse-services.c Example how to browse for DNS-SD
39 * services using the client interface to avahi-daemon. */
43 /** @{ \name Domain Browser */
45 /** A domain browser object */
46 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
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,
55 AvahiLookupResultFlags flags,
58 /** Browse for domains on the local network */
59 AvahiDomainBrowser* avahi_domain_browser_new (
61 AvahiIfIndex interface,
62 AvahiProtocol protocol,
64 AvahiDomainBrowserType btype,
65 AvahiLookupFlags flags,
66 AvahiDomainBrowserCallback callback,
69 /** Get the parent client of an AvahiDomainBrowser object */
70 AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
72 /** Cleans up and frees an AvahiDomainBrowser object */
73 int avahi_domain_browser_free (AvahiDomainBrowser *);
77 /** @{ \name Service Browser */
79 /** A service browser object */
80 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
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,
91 AvahiLookupResultFlags flags,
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
105 AvahiServiceBrowser* avahi_service_browser_new (
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,
115 /** Get the parent client of an AvahiServiceBrowser object */
116 AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
118 /** Cleans up and frees an AvahiServiceBrowser object */
119 int avahi_service_browser_free (AvahiServiceBrowser *);
123 /** \cond fulldocs */
124 /** A service type browser object */
125 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
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,
135 AvahiLookupResultFlags flags,
138 /** Browse for service types on the local network */
139 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
141 AvahiIfIndex interface,
142 AvahiProtocol protocol,
144 AvahiLookupFlags flags,
145 AvahiServiceTypeBrowserCallback callback,
148 /** Get the parent client of an AvahiServiceTypeBrowser object */
149 AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
151 /** Cleans up and frees an AvahiServiceTypeBrowser object */
152 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
156 /** @{ \name Service Resolver */
158 /** A service resolver object */
159 typedef struct AvahiServiceResolver AvahiServiceResolver;
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,
170 const char *host_name,
171 const AvahiAddress *a,
173 AvahiStringList *txt,
174 AvahiLookupResultFlags flags,
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(
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,
203 /** Get the parent client of an AvahiServiceResolver object */
204 AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *);
206 /** Free a service resolver object */
207 int avahi_service_resolver_free(AvahiServiceResolver *r);
211 /** \cond fulldocs */
212 /** A service resolver object */
213 typedef struct AvahiHostNameResolver AvahiHostNameResolver;
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,
222 const AvahiAddress *a,
223 AvahiLookupResultFlags flags,
226 /** Create a new hostname resolver object */
227 AvahiHostNameResolver * avahi_host_name_resolver_new(
229 AvahiIfIndex interface,
230 AvahiProtocol protocol,
232 AvahiProtocol aprotocol,
233 AvahiLookupFlags flags,
234 AvahiHostNameResolverCallback callback,
237 /** Get the parent client of an AvahiHostNameResolver object */
238 AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *);
240 /** Free a hostname resolver object */
241 int avahi_host_name_resolver_free(AvahiHostNameResolver *r);
243 /** An address resolver object */
244 typedef struct AvahiAddressResolver AvahiAddressResolver;
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,
254 AvahiLookupResultFlags flags,
257 /** Create a new address resolver object from an AvahiAddress object */
258 AvahiAddressResolver* avahi_address_resolver_new(
260 AvahiIfIndex interface,
261 AvahiProtocol protocol,
262 const AvahiAddress *a,
263 AvahiLookupFlags flags,
264 AvahiAddressResolverCallback callback,
267 /** Get the parent client of an AvahiAddressResolver object */
268 AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *);
270 /** Free a AvahiAddressResolver resolver object */
271 int avahi_address_resolver_free(AvahiAddressResolver *r);
275 /** @{ \name Record Browser */
277 /** A record browser object */
278 typedef struct AvahiRecordBrowser AvahiRecordBrowser;
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,
291 AvahiLookupResultFlags flags,
294 /** Browse for records of a type on the local network */
295 AvahiRecordBrowser* avahi_record_browser_new(
297 AvahiIfIndex interface,
298 AvahiProtocol protocol,
302 AvahiLookupFlags flags,
303 AvahiRecordBrowserCallback callback,
306 /** Get the parent client of an AvahiRecordBrowser object */
307 AvahiClient* avahi_record_browser_get_client(AvahiRecordBrowser *);
309 /** Cleans up and frees an AvahiRecordBrowser object */
310 int avahi_record_browser_free(AvahiRecordBrowser *);