]> git.meshlink.io Git - catta/blob - avahi-core/lookup.h
* move unicast DNS server registration/browsing routines to their own header dns...
[catta] / avahi-core / lookup.h
1 #ifndef foolookuphfoo
2 #define foolookuphfoo
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 /** \file avahi-core/lookup.h Functions for browsing/resolving services and other RRs */
26
27 /** \example core-browse-services.c Example how to browse for DNS-SD
28  * services using an embedded mDNS stack. */
29
30 /** A browsing object for arbitrary RRs */
31 typedef struct AvahiSRecordBrowser AvahiSRecordBrowser;
32
33 /** A host name to IP adddress resolver object */
34 typedef struct AvahiSHostNameResolver AvahiSHostNameResolver;
35
36 /** An IP address to host name resolver object ("reverse lookup") */
37 typedef struct AvahiSAddressResolver AvahiSAddressResolver;
38
39 /** A local domain browsing object. May be used to enumerate domains used on the local LAN */
40 typedef struct AvahiSDomainBrowser AvahiSDomainBrowser;
41
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;
44
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;
47
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;
50
51 #include <avahi-common/cdecl.h>
52 #include <avahi-common/defs.h>
53 #include <avahi-core/core.h>
54
55 #ifndef DOXYGEN_SHOULD_SKIP_THIS
56 AVAHI_C_DECL_BEGIN
57 #endif
58
59 /** Callback prototype for AvahiSRecordBrowser events */
60 typedef void (*AvahiSRecordBrowserCallback)(
61     AvahiSRecordBrowser *b,          /**< The AvahiSRecordBrowser object that is emitting this callback */
62     AvahiIfIndex interface,          /**< Logical OS network interface number the record was found on */
63     AvahiProtocol protocol,          /**< Protocol number the record was found. */
64     AvahiBrowserEvent event,         /**< Browsing event, either AVAHI_BROWSER_NEW or AVAHI_BROWSER_REMOVE */
65     AvahiRecord *record,             /**< The record that was found */
66     AvahiLookupResultFlags flags,  /**< Lookup flags */
67     void* userdata                   /**< Arbitrary user data passed to avahi_s_record_browser_new() */ );
68
69 /** Create a new browsing object for arbitrary RRs */
70 AvahiSRecordBrowser *avahi_s_record_browser_new(
71     AvahiServer *server,                    /**< The server object to which attach this query */
72     AvahiIfIndex interface,                 /**< Logical OS interface number where to look for the records, or AVAHI_IF_UNSPEC to look on interfaces */
73     AvahiProtocol protocol,                 /**< Protocol number to use when looking for the record, or AVAHI_PROTO_UNSPEC to look on all protocols */
74     AvahiKey *key,                          /**< The search key */
75     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. */
76     AvahiSRecordBrowserCallback callback,   /**< The callback to call on browsing events */
77     void* userdata                          /**< Arbitrary use suppliable data which is passed to the callback */);
78
79 /** Free an AvahiSRecordBrowser object */
80 void avahi_s_record_browser_free(AvahiSRecordBrowser *b);
81
82 /** Callback prototype for AvahiSHostNameResolver events */
83 typedef void (*AvahiSHostNameResolverCallback)(
84     AvahiSHostNameResolver *r,
85     AvahiIfIndex interface,  
86     AvahiProtocol protocol,
87     AvahiResolverEvent event, /**< Resolving event */
88     const char *host_name,   /**< Host name which should be resolved. May differ in case from the query */
89     const AvahiAddress *a,    /**< The address, or NULL if the host name couldn't be resolved. */
90     AvahiLookupResultFlags flags,  /**< Lookup flags */
91     void* userdata);
92
93 /** Create an AvahiSHostNameResolver object for resolving a host name to an adddress. See AvahiSRecordBrowser for more info on the paramters. */
94 AvahiSHostNameResolver *avahi_s_host_name_resolver_new(
95     AvahiServer *server,
96     AvahiIfIndex interface,
97     AvahiProtocol protocol,
98     const char *host_name,                  /**< The host name to look for */
99     AvahiProtocol aprotocol,                /**< The address family of the desired address or AVAHI_PROTO_UNSPEC if doesn't matter. */
100     AvahiLookupFlags flags,                 /**< Lookup flags. */
101     AvahiSHostNameResolverCallback calback,
102     void* userdata);
103
104 /** Free a AvahiSHostNameResolver object */
105 void avahi_s_host_name_resolver_free(AvahiSHostNameResolver *r);
106
107 /** Callback prototype for AvahiSAddressResolver events */
108 typedef void (*AvahiSAddressResolverCallback)(
109     AvahiSAddressResolver *r,
110     AvahiIfIndex interface,
111     AvahiProtocol protocol,
112     AvahiResolverEvent event,
113     const AvahiAddress *a,   
114     const char *host_name,   /**< A host name for the specified address, if one was found, i.e. event == AVAHI_RESOLVER_FOUND */
115     AvahiLookupResultFlags flags,  /**< Lookup flags */
116     void* userdata);
117
118 /** Create an AvahiSAddressResolver object. See AvahiSRecordBrowser for more info on the paramters. */
119 AvahiSAddressResolver *avahi_s_address_resolver_new(
120     AvahiServer *server,
121     AvahiIfIndex interface,
122     AvahiProtocol protocol,
123     const AvahiAddress *address,
124     AvahiLookupFlags flags,                 /**< Lookup flags. */
125     AvahiSAddressResolverCallback calback,
126     void* userdata);
127
128 /** Free an AvahiSAddressResolver object */
129 void avahi_s_address_resolver_free(AvahiSAddressResolver *r);
130
131 /** Callback prototype for AvahiSDomainBrowser events */
132 typedef void (*AvahiSDomainBrowserCallback)(
133     AvahiSDomainBrowser *b,
134     AvahiIfIndex interface,
135     AvahiProtocol protocol,
136     AvahiBrowserEvent event,
137     const char *domain,
138     AvahiLookupResultFlags flags,  /**< Lookup flags */
139     void* userdata);
140
141 /** Create a new AvahiSDomainBrowser object */
142 AvahiSDomainBrowser *avahi_s_domain_browser_new(
143     AvahiServer *server,
144     AvahiIfIndex interface,
145     AvahiProtocol protocol,
146     const char *domain,
147     AvahiDomainBrowserType type,
148     AvahiLookupFlags flags,                 /**< Lookup flags. */
149     AvahiSDomainBrowserCallback callback,
150     void* userdata);
151
152 /** Free an AvahiSDomainBrowser object */
153 void avahi_s_domain_browser_free(AvahiSDomainBrowser *b);
154
155 /** Callback prototype for AvahiSServiceTypeBrowser events */
156 typedef void (*AvahiSServiceTypeBrowserCallback)(
157     AvahiSServiceTypeBrowser *b,
158     AvahiIfIndex interface,
159     AvahiProtocol protocol,
160     AvahiBrowserEvent event,
161     const char *type,
162     const char *domain,
163     AvahiLookupResultFlags flags,  /**< Lookup flags */
164     void* userdata);
165
166 /** Create a new AvahiSServiceTypeBrowser object. */
167 AvahiSServiceTypeBrowser *avahi_s_service_type_browser_new(
168     AvahiServer *server,
169     AvahiIfIndex interface,
170     AvahiProtocol protocol,
171     const char *domain,
172     AvahiLookupFlags flags,                 /**< Lookup flags. */
173     AvahiSServiceTypeBrowserCallback callback,
174     void* userdata);
175
176 /** Free an AvahiSServiceTypeBrowser object */
177 void avahi_s_service_type_browser_free(AvahiSServiceTypeBrowser *b);
178
179 /** Callback prototype for AvahiSServiceBrowser events */
180 typedef void (*AvahiSServiceBrowserCallback)(
181     AvahiSServiceBrowser *b,
182     AvahiIfIndex interface,
183     AvahiProtocol protocol,
184     AvahiBrowserEvent event,
185     const char *name     /**< Service name, e.g. "Lennart's Files" */,
186     const char *type     /**< DNS-SD type, e.g. "_http._tcp" */,
187     const char *domain   /**< Domain of this service, e.g. "local" */,
188     AvahiLookupResultFlags flags,  /**< Lookup flags */
189     void* userdata);
190
191 /** Create a new AvahiSServiceBrowser object. */
192 AvahiSServiceBrowser *avahi_s_service_browser_new(
193     AvahiServer *server,
194     AvahiIfIndex interface,
195     AvahiProtocol protocol,
196     const char *service_type /** DNS-SD service type, e.g. "_http._tcp" */,
197     const char *domain,
198     AvahiLookupFlags flags,                 /**< Lookup flags. */
199     AvahiSServiceBrowserCallback callback,
200     void* userdata);
201
202 /** Free an AvahiSServiceBrowser object */
203 void avahi_s_service_browser_free(AvahiSServiceBrowser *b);
204
205 /** Callback prototype for AvahiSServiceResolver events */
206 typedef void (*AvahiSServiceResolverCallback)(
207     AvahiSServiceResolver *r,
208     AvahiIfIndex interface,
209     AvahiProtocol protocol,
210     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. */
211     const char *name,       /**< Service name */
212     const char *type,       /**< Service Type */
213     const char *domain,
214     const char *host_name,  /**< Host name of the service */
215     const AvahiAddress *a,   /**< The resolved host name */
216     uint16_t port,            /**< Service name */
217     AvahiStringList *txt,    /**< TXT record data */
218     AvahiLookupResultFlags flags,  /**< Lookup flags */
219     void* userdata);
220
221 /** Create a new AvahiSServiceResolver object. The specified callback function will be called with the resolved service data. */
222 AvahiSServiceResolver *avahi_s_service_resolver_new(
223     AvahiServer *server,
224     AvahiIfIndex interface,
225     AvahiProtocol protocol,
226     const char *name,
227     const char *type,
228     const char *domain,
229     AvahiProtocol aprotocol,    /**< Address family of the desired service address. Use AVAHI_PROTO_UNSPEC if you don't care */
230     AvahiLookupFlags flags,                 /**< Lookup flags. */
231     AvahiSServiceResolverCallback calback,
232     void* userdata);
233
234 /** Free an AvahiSServiceResolver object */
235 void avahi_s_service_resolver_free(AvahiSServiceResolver *r);
236
237 #ifndef DOXYGEN_SHOULD_SKIP_THIS
238 AVAHI_C_DECL_END
239 #endif
240
241 #endif