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