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
25 /** \file avahi-core/lookup.h Functions for browsing/resolving services and other RRs */
27 /** \example core-browse-services.c Example how to browse for DNS-SD
28 * services using an embedded mDNS stack. */
30 /** A browsing object for arbitrary RRs */
31 typedef struct AvahiSRecordBrowser AvahiSRecordBrowser;
33 /** A host name to IP adddress resolver object */
34 typedef struct AvahiSHostNameResolver AvahiSHostNameResolver;
36 /** An IP address to host name resolver object ("reverse lookup") */
37 typedef struct AvahiSAddressResolver AvahiSAddressResolver;
39 /** A local domain browsing object. May be used to enumerate domains used on the local LAN */
40 typedef struct AvahiSDomainBrowser AvahiSDomainBrowser;
42 /** A DNS-SD service type browsing object. May be used to enumerate the service types of all available services on the local LAN */
43 typedef struct AvahiSServiceTypeBrowser AvahiSServiceTypeBrowser;
45 /** A DNS-SD service browser. Use this to enumerate available services of a certain kind on the local LAN. Use AvahiSServiceResolver to get specific service data like address and port for a service. */
46 typedef struct AvahiSServiceBrowser AvahiSServiceBrowser;
48 /** A DNS-SD service resolver. Use this to retrieve addres, port and TXT data for a DNS-SD service */
49 typedef struct AvahiSServiceResolver AvahiSServiceResolver;
51 #include <avahi-common/cdecl.h>
52 #include <avahi-common/defs.h>
53 #include <avahi-core/core.h>
57 /** Callback prototype for AvahiSRecordBrowser events */
58 typedef void (*AvahiSRecordBrowserCallback)(
59 AvahiSRecordBrowser *b, /**< The AvahiSRecordBrowser object that is emitting this callback */
60 AvahiIfIndex interface, /**< Logical OS network interface number the record was found on */
61 AvahiProtocol protocol, /**< Protocol number the record was found. */
62 AvahiBrowserEvent event, /**< Browsing event, either AVAHI_BROWSER_NEW or AVAHI_BROWSER_REMOVE */
63 AvahiRecord *record, /**< The record that was found */
64 AvahiLookupResultFlags flags, /**< Lookup flags */
65 void* userdata /**< Arbitrary user data passed to avahi_s_record_browser_new() */ );
67 /** Create a new browsing object for arbitrary RRs */
68 AvahiSRecordBrowser *avahi_s_record_browser_new(
69 AvahiServer *server, /**< The server object to which attach this query */
70 AvahiIfIndex interface, /**< Logical OS interface number where to look for the records, or AVAHI_IF_UNSPEC to look on interfaces */
71 AvahiProtocol protocol, /**< Protocol number to use when looking for the record, or AVAHI_PROTO_UNSPEC to look on all protocols */
72 AvahiKey *key, /**< The search key */
73 AvahiLookupFlags flags, /**< Lookup flags. Must have set either AVAHI_LOOKUP_FORCE_WIDE_AREA or AVAHI_LOOKUP_FORCE_MULTICAST, since domain based detection is not available here. */
74 AvahiSRecordBrowserCallback callback, /**< The callback to call on browsing events */
75 void* userdata /**< Arbitrary use suppliable data which is passed to the callback */);
77 /** Free an AvahiSRecordBrowser object */
78 void avahi_s_record_browser_free(AvahiSRecordBrowser *b);
80 /** Callback prototype for AvahiSHostNameResolver events */
81 typedef void (*AvahiSHostNameResolverCallback)(
82 AvahiSHostNameResolver *r,
83 AvahiIfIndex interface,
84 AvahiProtocol protocol,
85 AvahiResolverEvent event, /**< Resolving event */
86 const char *host_name, /**< Host name which should be resolved. May differ in case from the query */
87 const AvahiAddress *a, /**< The address, or NULL if the host name couldn't be resolved. */
88 AvahiLookupResultFlags flags, /**< Lookup flags */
91 /** Create an AvahiSHostNameResolver object for resolving a host name to an adddress. See AvahiSRecordBrowser for more info on the paramters. */
92 AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
94 AvahiIfIndex interface,
95 AvahiProtocol protocol,
96 const char *host_name, /**< The host name to look for */
97 AvahiProtocol aprotocol, /**< The address family of the desired address or AVAHI_PROTO_UNSPEC if doesn't matter. */
98 AvahiLookupFlags flags, /**< Lookup flags. */
99 AvahiSHostNameResolverCallback calback,
102 /** Free a AvahiSHostNameResolver object */
103 void avahi_s_host_name_resolver_free(AvahiSHostNameResolver *r);
105 /** Callback prototype for AvahiSAddressResolver events */
106 typedef void (*AvahiSAddressResolverCallback)(
107 AvahiSAddressResolver *r,
108 AvahiIfIndex interface,
109 AvahiProtocol protocol,
110 AvahiResolverEvent event,
111 const AvahiAddress *a,
112 const char *host_name, /**< A host name for the specified address, if one was found, i.e. event == AVAHI_RESOLVER_FOUND */
113 AvahiLookupResultFlags flags, /**< Lookup flags */
116 /** Create an AvahiSAddressResolver object. See AvahiSRecordBrowser for more info on the paramters. */
117 AvahiSAddressResolver *avahi_s_address_resolver_new(
119 AvahiIfIndex interface,
120 AvahiProtocol protocol,
121 const AvahiAddress *address,
122 AvahiLookupFlags flags, /**< Lookup flags. */
123 AvahiSAddressResolverCallback calback,
126 /** Free an AvahiSAddressResolver object */
127 void avahi_s_address_resolver_free(AvahiSAddressResolver *r);
129 /** Callback prototype for AvahiSDomainBrowser events */
130 typedef void (*AvahiSDomainBrowserCallback)(
131 AvahiSDomainBrowser *b,
132 AvahiIfIndex interface,
133 AvahiProtocol protocol,
134 AvahiBrowserEvent event,
136 AvahiLookupResultFlags flags, /**< Lookup flags */
139 /** Create a new AvahiSDomainBrowser object */
140 AvahiSDomainBrowser *avahi_s_domain_browser_new(
142 AvahiIfIndex interface,
143 AvahiProtocol protocol,
145 AvahiDomainBrowserType type,
146 AvahiLookupFlags flags, /**< Lookup flags. */
147 AvahiSDomainBrowserCallback callback,
150 /** Free an AvahiSDomainBrowser object */
151 void avahi_s_domain_browser_free(AvahiSDomainBrowser *b);
153 /** Callback prototype for AvahiSServiceTypeBrowser events */
154 typedef void (*AvahiSServiceTypeBrowserCallback)(
155 AvahiSServiceTypeBrowser *b,
156 AvahiIfIndex interface,
157 AvahiProtocol protocol,
158 AvahiBrowserEvent event,
161 AvahiLookupResultFlags flags, /**< Lookup flags */
164 /** Create a new AvahiSServiceTypeBrowser object. */
165 AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(
167 AvahiIfIndex interface,
168 AvahiProtocol protocol,
170 AvahiLookupFlags flags, /**< Lookup flags. */
171 AvahiSServiceTypeBrowserCallback callback,
174 /** Free an AvahiSServiceTypeBrowser object */
175 void avahi_s_service_type_browser_free(AvahiSServiceTypeBrowser *b);
177 /** Callback prototype for AvahiSServiceBrowser events */
178 typedef void (*AvahiSServiceBrowserCallback)(
179 AvahiSServiceBrowser *b,
180 AvahiIfIndex interface,
181 AvahiProtocol protocol,
182 AvahiBrowserEvent event,
183 const char *name /**< Service name, e.g. "Lennart's Files" */,
184 const char *type /**< DNS-SD type, e.g. "_http._tcp" */,
185 const char *domain /**< Domain of this service, e.g. "local" */,
186 AvahiLookupResultFlags flags, /**< Lookup flags */
189 /** Create a new AvahiSServiceBrowser object. */
190 AvahiSServiceBrowser *avahi_s_service_browser_new(
192 AvahiIfIndex interface,
193 AvahiProtocol protocol,
194 const char *service_type /** DNS-SD service type, e.g. "_http._tcp" */,
196 AvahiLookupFlags flags, /**< Lookup flags. */
197 AvahiSServiceBrowserCallback callback,
200 /** Free an AvahiSServiceBrowser object */
201 void avahi_s_service_browser_free(AvahiSServiceBrowser *b);
203 /** Callback prototype for AvahiSServiceResolver events */
204 typedef void (*AvahiSServiceResolverCallback)(
205 AvahiSServiceResolver *r,
206 AvahiIfIndex interface,
207 AvahiProtocol protocol,
208 AvahiResolverEvent event, /**< Is AVAHI_RESOLVER_FOUND when the service was resolved successfully, and everytime it changes. Is AVAHI_RESOLVER_TIMOUT when the service failed to resolve or disappeared. */
209 const char *name, /**< Service name */
210 const char *type, /**< Service Type */
212 const char *host_name, /**< Host name of the service */
213 const AvahiAddress *a, /**< The resolved host name */
214 uint16_t port, /**< Service name */
215 AvahiStringList *txt, /**< TXT record data */
216 AvahiLookupResultFlags flags, /**< Lookup flags */
219 /** Create a new AvahiSServiceResolver object. The specified callback function will be called with the resolved service data. */
220 AvahiSServiceResolver *avahi_s_service_resolver_new(
222 AvahiIfIndex interface,
223 AvahiProtocol protocol,
227 AvahiProtocol aprotocol, /**< Address family of the desired service address. Use AVAHI_PROTO_UNSPEC if you don't care */
228 AvahiLookupFlags flags, /**< Lookup flags. */
229 AvahiSServiceResolverCallback calback,
232 /** Free an AvahiSServiceResolver object */
233 void avahi_s_service_resolver_free(AvahiSServiceResolver *r);