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