1 #ifndef fooclientlookuphfoo
2 #define fooclientlookuphfoo
5 This file is part of avahi.
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.
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.
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
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>
32 #include <avahi-client/client.h>
34 /** \file avahi-client/lookup.h Lookup Client API */
36 /** \example client-browse-services.c Example how to browse for DNS-SD
37 * services using the client interface to avahi-daemon. */
41 /** @{ \name Domain Browser */
43 /** A domain browser object */
44 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
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,
53 AvahiLookupResultFlags flags,
56 /** Browse for domains on the local network */
57 AvahiDomainBrowser* avahi_domain_browser_new (
59 AvahiIfIndex interface,
60 AvahiProtocol protocol,
62 AvahiDomainBrowserType btype,
63 AvahiLookupFlags flags,
64 AvahiDomainBrowserCallback callback,
67 /** Get the parent client of an AvahiDomainBrowser object */
68 AvahiClient* avahi_domain_browser_get_client (AvahiDomainBrowser *);
70 /** Cleans up and frees an AvahiDomainBrowser object */
71 int avahi_domain_browser_free (AvahiDomainBrowser *);
75 /** @{ \name Service Browser */
77 /** A service browser object */
78 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
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,
89 AvahiLookupResultFlags flags,
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
103 AvahiServiceBrowser* avahi_service_browser_new (
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,
113 /** Get the parent client of an AvahiServiceBrowser object */
114 AvahiClient* avahi_service_browser_get_client (AvahiServiceBrowser *);
116 /** Cleans up and frees an AvahiServiceBrowser object */
117 int avahi_service_browser_free (AvahiServiceBrowser *);
121 /** \cond fulldocs */
122 /** A service type browser object */
123 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
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,
133 AvahiLookupResultFlags flags,
136 /** Browse for service types on the local network */
137 AvahiServiceTypeBrowser* avahi_service_type_browser_new (
139 AvahiIfIndex interface,
140 AvahiProtocol protocol,
142 AvahiLookupFlags flags,
143 AvahiServiceTypeBrowserCallback callback,
146 /** Get the parent client of an AvahiServiceTypeBrowser object */
147 AvahiClient* avahi_service_type_browser_get_client (AvahiServiceTypeBrowser *);
149 /** Cleans up and frees an AvahiServiceTypeBrowser object */
150 int avahi_service_type_browser_free (AvahiServiceTypeBrowser *);
154 /** @{ \name Service Resolver */
156 /** A service resolver object */
157 typedef struct AvahiServiceResolver AvahiServiceResolver;
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,
168 const char *host_name,
169 const AvahiAddress *a,
171 AvahiStringList *txt,
172 AvahiLookupResultFlags flags,
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(
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,
201 /** Get the parent client of an AvahiServiceResolver object */
202 AvahiClient* avahi_service_resolver_get_client (AvahiServiceResolver *);
204 /** Free a service resolver object */
205 int avahi_service_resolver_free(AvahiServiceResolver *r);
209 /** \cond fulldocs */
210 /** A service resolver object */
211 typedef struct AvahiHostNameResolver AvahiHostNameResolver;
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,
220 const AvahiAddress *a,
221 AvahiLookupResultFlags flags,
224 /** Create a new hostname resolver object */
225 AvahiHostNameResolver * avahi_host_name_resolver_new(
227 AvahiIfIndex interface,
228 AvahiProtocol protocol,
230 AvahiProtocol aprotocol,
231 AvahiLookupFlags flags,
232 AvahiHostNameResolverCallback callback,
235 /** Get the parent client of an AvahiHostNameResolver object */
236 AvahiClient* avahi_host_name_resolver_get_client (AvahiHostNameResolver *);
238 /** Free a hostname resolver object */
239 int avahi_host_name_resolver_free(AvahiHostNameResolver *r);
241 /** An address resolver object */
242 typedef struct AvahiAddressResolver AvahiAddressResolver;
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,
252 AvahiLookupResultFlags flags,
255 /** Create a new address resolver object from an AvahiAddress object */
256 AvahiAddressResolver* avahi_address_resolver_new(
258 AvahiIfIndex interface,
259 AvahiProtocol protocol,
260 const AvahiAddress *a,
261 AvahiLookupFlags flags,
262 AvahiAddressResolverCallback callback,
265 /** Get the parent client of an AvahiAddressResolver object */
266 AvahiClient* avahi_address_resolver_get_client (AvahiAddressResolver *);
268 /** Free a AvahiAddressResolver resolver object */
269 int avahi_address_resolver_free(AvahiAddressResolver *r);
273 /** @{ \name Record Browser */
275 /** A record browser object */
276 typedef struct AvahiRecordBrowser AvahiRecordBrowser;
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,
289 AvahiLookupResultFlags flags,
292 /** Browse for records of a type on the local network */
293 AvahiRecordBrowser* avahi_record_browser_new(
295 AvahiIfIndex interface,
296 AvahiProtocol protocol,
300 AvahiLookupFlags flags,
301 AvahiRecordBrowserCallback callback,
304 /** Get the parent client of an AvahiRecordBrowser object */
305 AvahiClient* avahi_record_browser_get_client(AvahiRecordBrowser *);
307 /** Cleans up and frees an AvahiRecordBrowser object */
308 int avahi_record_browser_free(AvahiRecordBrowser *);