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