]> git.meshlink.io Git - catta/blob - avahi-core/core.h
* DBUS: implement org.freedesktop.Avahi.GetVersionString()
[catta] / avahi-core / core.h
1 #ifndef foocorehfoo
2 #define foocorehfoo
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 #include <stdio.h>
26 #include <glib.h>
27
28 /** \file core.h The Avahi Multicast DNS and DNS Service Discovery implmentation. */
29
30 #include <avahi-common/cdecl.h>
31
32 AVAHI_C_DECL_BEGIN
33
34 /** An mDNS responder object */
35 typedef struct AvahiServer AvahiServer;
36
37 /** A locally registered DNS resource record */
38 typedef struct AvahiEntry AvahiEntry;
39
40 /** A group of locally registered DNS RRs */
41 typedef struct AvahiEntryGroup AvahiEntryGroup;
42
43 AVAHI_C_DECL_END
44
45 #include <avahi-common/address.h>
46 #include <avahi-common/rr.h>
47 #include <avahi-common/alternative.h>
48
49 AVAHI_C_DECL_BEGIN
50
51 /** States of a server object */
52 typedef enum {
53     AVAHI_SERVER_INVALID = -1,     /**< Invalid state (initial) */ 
54     AVAHI_SERVER_REGISTERING = 0,  /**< Host RRs are being registered */
55     AVAHI_SERVER_RUNNING,          /**< All host RRs have been established */
56     AVAHI_SERVER_COLLISION,        /**< There is a collision with a host RR. All host RRs have been withdrawn, the user should set a new host name via avahi_server_set_host_name() */
57     AVAHI_SERVER_SLEEPING          /**< The host or domain name has changed and the server waits for old entries to be expired */
58 } AvahiServerState;
59
60 /** Flags for server entries */
61 typedef enum {
62     AVAHI_ENTRY_NULL = 0,          /**< No special flags */
63     AVAHI_ENTRY_UNIQUE = 1,        /**< The RRset is intended to be unique */
64     AVAHI_ENTRY_NOPROBE = 2,       /**< Though the RRset is intended to be unique no probes shall be sent */
65     AVAHI_ENTRY_NOANNOUNCE = 4,    /**< Do not announce this RR to other hosts */
66     AVAHI_ENTRY_ALLOWMUTIPLE = 8   /**< Allow multiple local records of this type, even if they are intended to be unique */
67 } AvahiEntryFlags;
68
69 /** States of an entry group object */
70 typedef enum {
71     AVAHI_ENTRY_GROUP_UNCOMMITED = -1,   /**< The group has not yet been commited, the user must still call avahi_entry_group_commit() */
72     AVAHI_ENTRY_GROUP_REGISTERING = 0,   /**< The entries of the group are currently being registered */
73     AVAHI_ENTRY_GROUP_ESTABLISHED,       /**< The entries have successfully been established */
74     AVAHI_ENTRY_GROUP_COLLISION          /**< A name collision for one of the entries in the group has been detected, the entries have been withdrawn */ 
75 } AvahiEntryGroupState;
76
77 /** Prototype for callback functions which are called whenever the state of an AvahiServer object changes */
78 typedef void (*AvahiServerCallback) (AvahiServer *s, AvahiServerState state, gpointer userdata);
79
80 /** Prototype for callback functions which are called whenever the state of an AvahiEntryGroup object changes */
81 typedef void (*AvahiEntryGroupCallback) (AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, gpointer userdata);
82
83 /** Stores configuration options for a server instance */
84 typedef struct AvahiServerConfig {
85     gchar *host_name;                      /**< Default host name. If left empty defaults to the result of gethostname(2) of the libc */
86     gchar *domain_name;                    /**< Default domain name. If left empty defaults to .local */
87     gboolean use_ipv4;                     /**< Enable IPv4 support */
88     gboolean use_ipv6;                     /**< Enable IPv6 support */
89     gboolean publish_hinfo;                /**< Register a HINFO record for the host containing the local OS and CPU type */
90     gboolean publish_addresses;            /**< Register A, AAAA and PTR records for all local IP addresses */
91     gboolean publish_workstation;          /**< Register a _workstation._tcp service */
92     gboolean publish_domain;               /**< Announce the local domain for browsing */
93     gboolean check_response_ttl;           /**< If enabled the server ignores all incoming responses with IP TTL != 255. Newer versions of the RFC do no longer contain this check, so it is disabled by default. */
94     gboolean use_iff_running;        /**< Require IFF_RUNNING on local network interfaces. This is the official way to check for link beat. Unfortunately this doesn't work with all drivers. So bettere leave this off. */
95     gboolean enable_reflector;             /**< Reflect incoming mDNS traffic to all local networks. This allows mDNS based network browsing beyond ethernet borders */
96     gboolean reflect_ipv;                  /**< if enable_reflector is TRUE, enable/disable reflecting between IPv4 and IPv6 */
97 } AvahiServerConfig;
98
99 /** Allocate a new mDNS responder object. */
100 AvahiServer *avahi_server_new(
101     GMainContext *c,               /**< The GLIB main loop context to attach to */
102     const AvahiServerConfig *sc,   /**< If non-NULL a pointer to a configuration structure for the server. The server makes an internal deep copy of this structure, so you may free it using avahi_server_config_done() immediately after calling this function. */
103     AvahiServerCallback callback,  /**< A callback which is called whenever the state of the server changes */
104     gpointer userdata              /**< An opaque pointer which is passed to the callback function */);
105
106 /** Free an mDNS responder object */
107 void avahi_server_free(AvahiServer* s);
108
109 /** Fill in default values for a server configuration structure. If you
110  * make use of an AvahiServerConfig structure be sure to initialize
111  * it with this function for the sake of upwards library
112  * compatibility. This call may allocate strings on the heap. To
113  * release this memory make sure to call
114  * avahi_server_config_done(). If you want to replace any strings in
115  * the structure be sure to free the strings filled in by this
116  * function with g_free() first and allocate the replacements with
117  * g_malloc() (or g_strdup()).*/
118 AvahiServerConfig* avahi_server_config_init(
119    AvahiServerConfig *c /**< A structure which shall be filled in */ );
120
121 /** Make a deep copy of the configuration structure *c to *ret. */
122 AvahiServerConfig* avahi_server_config_copy(
123     AvahiServerConfig *ret /**< destination */,
124     const AvahiServerConfig *c /**< source */);
125
126 /** Free the data in a server configuration structure. */
127 void avahi_server_config_free(AvahiServerConfig *c);
128
129 /** Return the currently chosen domain name of the server object. The
130  * return value points to an internally allocated string. Be sure to
131  * make a copy of the string before calling any other library
132  * functions. */
133 const gchar* avahi_server_get_domain_name(AvahiServer *s);
134
135 /** Return the currently chosen host name. The return value points to a internally allocated string. */
136 const gchar* avahi_server_get_host_name(AvahiServer *s);
137
138 /** Return the currently chosen host name as a FQDN ("fully qualified
139  * domain name", i.e. the concatenation of the host and domain
140  * name). The return value points to a internally allocated string. */
141 const gchar* avahi_server_get_host_name_fqdn(AvahiServer *s);
142
143 /** Change the host name of a running mDNS responder. This will drop
144 all automicatilly generated RRs and readd them with the new
145 name. Since the responder has to probe for the new RRs this function
146 takes some time to take effect altough it returns immediately. This
147 function is intended to be called when a host name conflict is
148 reported using AvahiServerCallback. The caller should readd all user
149 defined RRs too since they otherwise continue to point to the outdated
150 host name..*/
151 gint avahi_server_set_host_name(AvahiServer *s, const gchar *host_name);
152
153 /** Change the domain name of a running mDNS responder. The same rules
154  * as with avahi_server_set_host_name() apply. */
155 gint avahi_server_set_domain_name(AvahiServer *s, const gchar *domain_name);
156
157 /** Return the opaque user data pointer attached to a server object */
158 gpointer avahi_server_get_data(AvahiServer *s);
159
160 /** Change the opaque user data pointer attached to a server object */
161 void avahi_server_set_data(AvahiServer *s, gpointer userdata);
162
163 /** Return the current state of the server object */
164 AvahiServerState avahi_server_get_state(AvahiServer *s);
165
166 /** Iterate through all local entries of the server. (when g is NULL)
167  * or of a specified entry group. At the first call state should point
168  * to a NULL initialized void pointer, That pointer is used to track
169  * the current iteration. It is not safe to call any other
170  * avahi_server_xxx() function during the iteration. If the last entry
171  * has been read, NULL is returned. */
172 const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiEntryGroup *g, void **state);
173
174 /** Dump the current server status to the specified FILE object */
175 void avahi_server_dump(AvahiServer *s, FILE *f);
176
177 /** Create a new entry group. The specified callback function is
178  * called whenever the state of the group changes. Use entry group
179  * objects to keep track of you RRs. Add new RRs to a group using
180  * avahi_server_add_xxx(). Make sure to call avahi_entry_group_commit()
181  * to start the registration process for your RRs */
182 AvahiEntryGroup *avahi_entry_group_new(AvahiServer *s, AvahiEntryGroupCallback callback, gpointer userdata);
183
184 /** Free an entry group. All RRs assigned to the group are removed from the server */
185 void avahi_entry_group_free(AvahiEntryGroup *g);
186
187 /** Commit an entry group. This starts the probing and registration process for all RRs in the group */
188 gint avahi_entry_group_commit(AvahiEntryGroup *g);
189
190 /** Return the current state of the specified entry group */
191 AvahiEntryGroupState avahi_entry_group_get_state(AvahiEntryGroup *g);
192
193 /** Change the opaque user data pointer attached to an entry group object */
194 void avahi_entry_group_set_data(AvahiEntryGroup *g, gpointer userdata);
195
196 /** Return the opaque user data pointer currently set for the entry group object */
197 gpointer avahi_entry_group_get_data(AvahiEntryGroup *g);
198
199 /** Add a new resource record to the server. Returns 0 on success, negative otherwise. */
200 gint avahi_server_add(
201     AvahiServer *s,           /**< The server object to add this record to */
202     AvahiEntryGroup *g,       /**< An entry group object if this new record shall be attached to one, or NULL. If you plan to remove the record sometime later you a required to pass an entry group object here. */
203     AvahiIfIndex interface,   /**< A numeric index of a network interface to attach this record to, or AVAHI_IF_UNSPEC to attach this record to all interfaces */
204     AvahiProtocol protocol,   /**< A protocol family to attach this record to. One of the AVAHI_PROTO_xxx constants. Use AVAHI_PROTO_UNSPEC to make this record available on all protocols (wich means on both IPv4 and IPv6). */
205     AvahiEntryFlags flags,    /**< Special flags for this record */
206     AvahiRecord *r            /**< The record to add. This function increases the reference counter of this object. */   );
207
208 /** Add a PTR RR to the server. See avahi_server_add() for more information. */
209 gint avahi_server_add_ptr(
210     AvahiServer *s,
211     AvahiEntryGroup *g,
212     AvahiIfIndex interface,
213     AvahiProtocol protocol,
214     AvahiEntryFlags flags,
215     guint32 ttl,             /**< DNS TTL for this record */
216     const gchar *name,       /**< PTR record name */
217     const gchar *dest        /**< pointer destination */  );
218
219 /** Add a PTR RR to the server. See avahi_server_add() for more information. */
220 gint avahi_server_add_txt(
221     AvahiServer *s,
222     AvahiEntryGroup *g,
223     AvahiIfIndex interface,
224     AvahiProtocol protocol,
225     AvahiEntryFlags flags,
226     guint32 ttl,             /**< DNS TTL for this record */
227     const gchar *name,       /**< TXT record name */
228     ... /**< Text record data, terminated by NULL */);
229
230 /** Add a PTR RR to the server. Mostly identical to
231  * avahi_server_add_text but takes a va_list instead of a variable
232  * number of arguments */
233 gint avahi_server_add_txt_va(
234     AvahiServer *s,
235     AvahiEntryGroup *g,
236     AvahiIfIndex interface,
237     AvahiProtocol protocol,
238     AvahiEntryFlags flags,
239     guint32 ttl,
240     const gchar *name,
241     va_list va);
242
243 /** Add a PTR RR to the server. Mostly identical to 
244  * avahi_server_add_text but takes an AvahiStringList record instead of a variable
245  * number of arguments. */
246 gint avahi_server_add_txt_strlst(
247     AvahiServer *s,
248     AvahiEntryGroup *g,
249     AvahiIfIndex interface,
250     AvahiProtocol protocol,
251     AvahiEntryFlags flags,
252     guint32 ttl,
253     const gchar *name,
254     AvahiStringList *strlst  /**< TXT decord data as a AvahiString. Only the pointer to the object and not the object itself is copied into the RR. Therefore you should not free the strlst object yourself, this will be done by the library. If you want to add multiple records with the same RR data you MUST copy the strlst object prior to calling this function with avahi_strlst_copy(). */ );
255
256 /** Add an IP address mapping to the server. This will add both the
257  * host-name-to-address and the reverse mapping to the server. See
258  * avahi_server_add() for more information. If adding one of the RRs
259  * fails, the function returns with an error, but it is not defined if
260  * the other RR is deleted from the server or not. Therefore, you have
261  * to free the AvahiEntryGroup and create a new one before
262  * proceeding. */
263 gint avahi_server_add_address(
264     AvahiServer *s,
265     AvahiEntryGroup *g,
266     AvahiIfIndex interface,
267     AvahiProtocol protocol,
268     AvahiEntryFlags flags,
269     const gchar *name,
270     AvahiAddress *a);
271
272 /** Add an DNS-SD service to the Server. This will add all required
273  * RRs to the server. See avahi_server_add() for more information.  If
274  * adding one of the RRs fails, the function returns with an error,
275  * but it is not defined if the other RR is deleted from the server or
276  * not. Therefore, you have to free the AvahiEntryGroup and create a
277  * new one before proceeding. */
278 gint avahi_server_add_service(
279     AvahiServer *s,
280     AvahiEntryGroup *g,
281     AvahiIfIndex interface,
282     AvahiProtocol protocol,
283     const gchar *name,         /**< Service name, e.g. "Lennart's Files" */
284     const gchar *type,         /**< DNS-SD type, e.g. "_http._tcp" */
285     const gchar *domain,       
286     const gchar *host,         /**< Host name where this servcie resides, or NULL if on the local host */
287     guint16 port,              /**< Port number of the service */
288     ...  /**< Text records, terminated by NULL */);
289
290 /** Mostly identical to avahi_server_add_service(), but takes an va_list for the TXT records. */
291 gint avahi_server_add_service_va(
292     AvahiServer *s,
293     AvahiEntryGroup *g,
294     AvahiIfIndex interface,
295     AvahiProtocol protocol,
296     const gchar *name,
297     const gchar *type,
298     const gchar *domain,
299     const gchar *host,
300     guint16 port,
301     va_list va);
302
303 /** Mostly identical to avahi_server_add_service(), but takes an AvahiStringList object for the TXT records.  The AvahiStringList object is not copied. You need to make a copy if this object if you want to reuse it. The object is freed if the RR is removed from the server. */
304 gint avahi_server_add_service_strlst(
305     AvahiServer *s,
306     AvahiEntryGroup *g,
307     AvahiIfIndex interface,
308     AvahiProtocol protocol,
309     const gchar *name,
310     const gchar *type,
311     const gchar *domain,
312     const gchar *host,
313     guint16 port,
314     AvahiStringList *strlst);
315
316 /** The type of DNS server */
317 typedef enum {
318     AVAHI_DNS_SERVER_RESOLVE,         /**< Unicast DNS servers for normal resolves (_domain._udp)*/
319     AVAHI_DNS_SERVER_UPDATE           /**< Unicast DNS servers for updates (_dns-update._udp)*/
320 } AvahiDNSServerType;
321
322 /** Publish the specified unicast DNS server address via mDNS. You may
323  * browse for records create this way wit
324  * avahi_dns_server_browser_new(). */
325 gint avahi_server_add_dns_server_address(
326     AvahiServer *s,
327     AvahiEntryGroup *g,
328     AvahiIfIndex interface,
329     AvahiProtocol protocol,
330     const gchar *domain,
331     AvahiDNSServerType type,
332     const AvahiAddress *address,
333     guint16 port /** should be 53 */);
334
335 /** Similar to avahi_server_add_dns_server_address(), but specify a
336 host name instead of an address. The specified host name should be
337 resolvable via mDNS */
338 gint avahi_server_add_dns_server_name(
339     AvahiServer *s,
340     AvahiEntryGroup *g,
341     AvahiIfIndex interface,
342     AvahiProtocol protocol,
343     const gchar *domain,
344     AvahiDNSServerType type,
345     const gchar *name,
346     guint16 port /** should be 53 */);
347
348 /** Type of callback event when browsing */
349 typedef enum {
350     AVAHI_BROWSER_NEW = 0,            /**< The object is new on the network */
351     AVAHI_BROWSER_REMOVE = -1         /**< The object has been removed from the network */
352 } AvahiBrowserEvent;
353
354 /** Type of callback event when resolving */
355 typedef enum {
356     AVAHI_RESOLVER_FOUND = 0,         /**< RR found, resolving successful */
357     AVAHI_RESOLVER_TIMEOUT = -1       /**< Noone responded within the timeout, resolving failed */
358 } AvahiResolverEvent;
359
360 /** A browsing object for arbitrary RRs */
361 typedef struct AvahiRecordBrowser AvahiRecordBrowser;
362
363 /** Callback prototype for AvahiRecordBrowser events */
364 typedef void (*AvahiRecordBrowserCallback)(
365     AvahiRecordBrowser *b,       /**< The AvahiRecordBrowser object that is emitting this callback */
366     AvahiIfIndex interface,      /**< Logical OS network interface number the record was found on */
367     AvahiProtocol protocol,      /**< Protocol number the record was found. */
368     AvahiBrowserEvent event,     /**< Browsing event, either AVAHI_BROWSER_NEW or AVAHI_BROWSER_REMOVE */
369     AvahiRecord *record,         /**< The record that was found */
370     gpointer userdata            /**< Arbitrary user data passed to avahi_record_browser_new() */ );
371
372 /** Create a new browsing object for arbitrary RRs */
373 AvahiRecordBrowser *avahi_record_browser_new(
374     AvahiServer *server,                  /**< The server object to which attach this query */
375     AvahiIfIndex interface,               /**< Logical OS interface number where to look for the records, or AVAHI_IF_UNSPEC to look on interfaces */
376     AvahiProtocol protocol,               /**< Protocol number to use when looking for the record, or AVAHI_PROTO_UNSPEC to look on all protocols */
377     AvahiKey *key,                        /**< The search key */
378     AvahiRecordBrowserCallback callback,  /**< The callback to call on browsing events */
379     gpointer userdata                     /**< Arbitrary use suppliable data which is passed to the callback */);
380
381 /** Free an AvahiRecordBrowser object */
382 void avahi_record_browser_free(AvahiRecordBrowser *b);
383
384 /** A host name to IP adddress resolver object */
385 typedef struct AvahiHostNameResolver AvahiHostNameResolver;
386
387 /** Callback prototype for AvahiHostNameResolver events */
388 typedef void (*AvahiHostNameResolverCallback)(
389     AvahiHostNameResolver *r,
390     AvahiIfIndex interface,  
391     AvahiProtocol protocol,
392     AvahiResolverEvent event, /**< Resolving event */
393     const gchar *host_name,   /**< Host name which should be resolved. May differ in case from the query */
394     const AvahiAddress *a,    /**< The address, or NULL if the host name couldn't be resolved. */
395     gpointer userdata);
396
397 /** Create an AvahiHostNameResolver object for resolving a host name to an adddress. See AvahiRecordBrowser for more info on the paramters. */
398 AvahiHostNameResolver *avahi_host_name_resolver_new(
399     AvahiServer *server,
400     AvahiIfIndex interface,
401     AvahiProtocol protocol,
402     const gchar *host_name,    /**< The host name to look for */
403     AvahiProtocol aprotocol,   /**< The address family of the desired address or AVAHI_PROTO_UNSPEC if doesn't matter. */
404     AvahiHostNameResolverCallback calback,
405     gpointer userdata);
406
407 /** Free a AvahiHostNameResolver object */
408 void avahi_host_name_resolver_free(AvahiHostNameResolver *r);
409
410 /** An IP address to host name resolver object ("reverse lookup") */
411 typedef struct AvahiAddressResolver AvahiAddressResolver;
412
413 /** Callback prototype for AvahiAddressResolver events */
414 typedef void (*AvahiAddressResolverCallback)(
415     AvahiAddressResolver *r,
416     AvahiIfIndex interface,
417     AvahiProtocol protocol,
418     AvahiResolverEvent event,
419     const AvahiAddress *a,   
420     const gchar *host_name,   /**< A host name for the specified address, if one was found, i.e. event == AVAHI_RESOLVER_FOUND */
421     gpointer userdata);
422
423 /** Create an AvahiAddressResolver object. See AvahiRecordBrowser for more info on the paramters. */
424 AvahiAddressResolver *avahi_address_resolver_new(
425     AvahiServer *server,
426     AvahiIfIndex interface,
427     AvahiProtocol protocol,
428     const AvahiAddress *address,
429     AvahiAddressResolverCallback calback,
430     gpointer userdata);
431
432 /** Free an AvahiAddressResolver object */
433 void avahi_address_resolver_free(AvahiAddressResolver *r);
434
435 /** The type of domain to browse for */
436 typedef enum {
437     AVAHI_DOMAIN_BROWSER_REGISTER,          /**< Browse for a list of available registering domains */
438     AVAHI_DOMAIN_BROWSER_REGISTER_DEFAULT,  /**< Browse for the default registering domain */
439     AVAHI_DOMAIN_BROWSER_BROWSE,            /**< Browse for a list of available browsing domains */
440     AVAHI_DOMAIN_BROWSER_BROWSE_DEFAULT,    /**< Browse for the default browsing domain */
441     AVAHI_DOMAIN_BROWSER_BROWSE_LEGACY,     /**< Legacy browse domain - see DNS-SD spec for more information */
442     AVAHI_DOMAIN_BROWSER_MAX
443 } AvahiDomainBrowserType;
444
445 /** A local domain browsing object. May be used to enumerate domains used on the local LAN */
446 typedef struct AvahiDomainBrowser AvahiDomainBrowser;
447
448 /** Callback prototype for AvahiDomainBrowser events */
449 typedef void (*AvahiDomainBrowserCallback)(
450     AvahiDomainBrowser *b,
451     AvahiIfIndex interface,
452     AvahiProtocol protocol,
453     AvahiBrowserEvent event,
454     const gchar *domain,
455     gpointer userdata);
456
457 /** Create a new AvahiDomainBrowser object */
458 AvahiDomainBrowser *avahi_domain_browser_new(
459     AvahiServer *server,
460     AvahiIfIndex interface,
461     AvahiProtocol protocol,
462     const gchar *domain,
463     AvahiDomainBrowserType type,
464     AvahiDomainBrowserCallback callback,
465     gpointer userdata);
466
467 /** Free an AvahiDomainBrowser object */
468 void avahi_domain_browser_free(AvahiDomainBrowser *b);
469
470 /** A DNS-SD service type browsing object. May be used to enumerate the service types of all available services on the local LAN */
471 typedef struct AvahiServiceTypeBrowser AvahiServiceTypeBrowser;
472
473 /** Callback prototype for AvahiServiceTypeBrowser events */
474 typedef void (*AvahiServiceTypeBrowserCallback)(
475     AvahiServiceTypeBrowser *b,
476     AvahiIfIndex interface,
477     AvahiProtocol protocol,
478     AvahiBrowserEvent event,
479     const gchar *type,
480     const gchar *domain,
481     gpointer userdata);
482
483 /** Create a new AvahiServiceTypeBrowser object. */
484 AvahiServiceTypeBrowser *avahi_service_type_browser_new(
485     AvahiServer *server,
486     AvahiIfIndex interface,
487     AvahiProtocol protocol,
488     const gchar *domain,
489     AvahiServiceTypeBrowserCallback callback,
490     gpointer userdata);
491
492 /** Free an AvahiServiceTypeBrowser object */
493 void avahi_service_type_browser_free(AvahiServiceTypeBrowser *b);
494
495 /** A DNS-SD service browser. Use this to enumerate available services of a certain kind on the local LAN. Use AvahiServiceResolver to get specific service data like address and port for a service. */
496 typedef struct AvahiServiceBrowser AvahiServiceBrowser;
497
498 /** Callback prototype for AvahiServiceBrowser events */
499 typedef void (*AvahiServiceBrowserCallback)(
500     AvahiServiceBrowser *b,
501     AvahiIfIndex interface,
502     AvahiProtocol protocol,
503     AvahiBrowserEvent event,
504     const gchar *name,     /**< Service name, e.g. "Lennart's Files" */ 
505     const gchar *type,     /**< DNS-SD type, e.g. "_http._tcp" */
506     const gchar *domain,   /**< Domain of this service, e.g. "local" */
507     gpointer userdata);
508
509 /** Create a new AvahiServiceBrowser object. */
510 AvahiServiceBrowser *avahi_service_browser_new(
511     AvahiServer *server,
512     AvahiIfIndex interface,
513     AvahiProtocol protocol,
514     const gchar *service_type, /** DNS-SD service type, e.g. "_http._tcp" */
515     const gchar *domain,
516     AvahiServiceBrowserCallback callback,
517     gpointer userdata);
518
519 /** Free an AvahiServiceBrowser object */
520 void avahi_service_browser_free(AvahiServiceBrowser *b);
521
522 /** A DNS-SD service resolver.  Use this to retrieve addres, port and TXT data for a DNS-SD service */
523 typedef struct AvahiServiceResolver AvahiServiceResolver;
524
525 /** Callback prototype for AvahiServiceResolver events */
526 typedef void (*AvahiServiceResolverCallback)(
527     AvahiServiceResolver *r,
528     AvahiIfIndex interface,
529     AvahiProtocol protocol,
530     AvahiResolverEvent event,
531     const gchar *name,       /**< Service name */
532     const gchar *type,       /**< Service Type */
533     const gchar *domain,
534     const gchar *host_name,  /**< Host name of the service */
535     const AvahiAddress *a,   /**< The resolved host name */
536     guint16 port,            /**< Service name */
537     AvahiStringList *txt,    /**< TXT record data */
538     gpointer userdata);
539
540 /** Create a new AvahiServiceResolver object */
541 AvahiServiceResolver *avahi_service_resolver_new(
542     AvahiServer *server,
543     AvahiIfIndex interface,
544     AvahiProtocol protocol,
545     const gchar *name,
546     const gchar *type,
547     const gchar *domain,
548     AvahiProtocol aprotocol,    /**< Address family of the desired service address. Use AVAHI_PROTO_UNSPEC if you don't care */
549     AvahiServiceResolverCallback calback,
550     gpointer userdata);
551
552 /** Free an AvahiServiceResolver object */
553 void avahi_service_resolver_free(AvahiServiceResolver *r);
554
555 /** A domain service browser object. Use this to browse for
556  * conventional unicast DNS servers which may be used to resolve
557  * conventional domain names */
558 typedef struct AvahiDNSServerBrowser AvahiDNSServerBrowser;
559
560 /** Callback prototype for AvahiDNSServerBrowser events */
561 typedef void (*AvahiDNSServerBrowserCallback)(
562     AvahiDNSServerBrowser *b,
563     AvahiIfIndex interface,
564     AvahiProtocol protocol,
565     AvahiBrowserEvent event,
566     const gchar *host_name,       /**< Host name of the DNS server, probably useless */
567     const AvahiAddress *a,        /**< Address of the DNS server */
568     guint16 port,                 /**< Port number of the DNS servers, probably 53 */
569     gpointer userdata);
570
571 /** Create a new AvahiDNSServerBrowser object */
572 AvahiDNSServerBrowser *avahi_dns_server_browser_new(
573     AvahiServer *server,
574     AvahiIfIndex interface,
575     AvahiProtocol protocol,
576     const gchar *domain,
577     AvahiDNSServerType type,
578     AvahiProtocol aprotocol,  /**< Address protocol for the DNS server */ 
579     AvahiDNSServerBrowserCallback callback,
580     gpointer userdata);
581
582 /** Free an AvahiDNSServerBrowser object */
583 void avahi_dns_server_browser_free(AvahiDNSServerBrowser *b);
584
585 AVAHI_C_DECL_END
586
587 #endif