7 This file is part of avahi.
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.
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.
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
28 /** An mDNS responder object */
29 typedef struct AvahiServer AvahiServer;
31 /** A locally registered DNS resource record */
32 typedef struct AvahiEntry AvahiEntry;
34 /** A group of locally registered DNS RRs */
35 typedef struct AvahiEntryGroup AvahiEntryGroup;
37 #include <avahi-core/address.h>
38 #include <avahi-core/rr.h>
40 /** States of a server object */
42 AVAHI_SERVER_INVALID = -1, /**< Invalid state (initial) */
43 AVAHI_SERVER_REGISTERING = 0, /**< Host RRs are being registered */
44 AVAHI_SERVER_RUNNING, /**< All host RRs have been established */
45 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() */
48 /** Flags for server entries */
50 AVAHI_ENTRY_NULL = 0, /**< No special flags */
51 AVAHI_ENTRY_UNIQUE = 1, /**< The RRset is intended to be unique */
52 AVAHI_ENTRY_NOPROBE = 2, /**< Though the RRset is intended to be unique no probes shall be sent */
53 AVAHI_ENTRY_NOANNOUNCE = 4 /**< Do not announce this RR to other hosts */
56 /** States of an entry group object */
58 AVAHI_ENTRY_GROUP_UNCOMMITED = -1, /**< The group has not yet been commited, the user must still call avahi_entry_group_commit() */
59 AVAHI_ENTRY_GROUP_REGISTERING = 0, /**< The entries of the group are currently being registered */
60 AVAHI_ENTRY_GROUP_ESTABLISHED, /**< The entries have successfully been established */
61 AVAHI_ENTRY_GROUP_COLLISION /**< A name collision for one of the entries in the group has been detected, the entries have been withdrawn */
62 } AvahiEntryGroupState;
64 /** Prototype for callback functions which are called whenever the state of an AvahiServer object changes */
65 typedef void (*AvahiServerCallback) (AvahiServer *s, AvahiServerState state, gpointer userdata);
67 /** Prototype for callback functions which are called whenever the state of an AvahiEntryGroup object changes */
68 typedef void (*AvahiEntryGroupCallback) (AvahiServer *s, AvahiEntryGroup *g, AvahiEntryGroupState state, gpointer userdata);
70 /** Stores configuration options for a server instance */
71 typedef struct AvahiServerConfig {
72 gchar *host_name; /**< Default host name. If left empty defaults to the result of gethostname(2) of the libc */
73 gchar *domain_name; /**< Default domain name. If left empty defaults to .local */
74 gboolean use_ipv4; /**< Enable IPv4 support */
75 gboolean use_ipv6; /**< Enable IPv6 support */
76 gboolean register_hinfo; /**< Register a HINFO record for the host containing the local OS and CPU type */
77 gboolean register_addresses; /**< Register A, AAAA and PTR records for all local IP addresses */
78 gboolean check_response_ttl; /**< If enabled the server ignores all incoming responses with IP TTL != 255 */
81 /** Allocate a new mDNS responder object. */
82 AvahiServer *avahi_server_new(
83 GMainContext *c, /**< The GLIB main loop context to attach to */
84 const AvahiServerConfig *sc, /**< If non-NULL a pointer to a configuration structure for the server */
85 AvahiServerCallback callback, /**< A callback which is called whenever the state of the server changes */
86 gpointer userdata /**< An opaque pointer which is passed to the callback function */);
88 /** Free an mDNS responder object */
89 void avahi_server_free(AvahiServer* s);
91 AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c);
92 AvahiServerConfig* avahi_server_config_copy(AvahiServerConfig *ret, const AvahiServerConfig *c);
93 void avahi_server_config_free(AvahiServerConfig *c);
95 const gchar* avahi_server_get_domain_name(AvahiServer *s);
96 const gchar* avahi_server_get_host_name(AvahiServer *s);
97 const gchar* avahi_server_get_host_name_fqdn(AvahiServer *s);
99 void avahi_server_set_host_name(AvahiServer *s, const gchar *host_name);
100 void avahi_server_set_domain_name(AvahiServer *s, const gchar *domain_name);
102 gpointer avahi_server_get_data(AvahiServer *s);
103 void avahi_server_set_data(AvahiServer *s, gpointer userdata);
105 AvahiServerState avhai_server_get_state(AvahiServer *s);
107 const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiEntryGroup *g, void **state);
108 void avahi_server_dump(AvahiServer *s, FILE *f);
110 AvahiEntryGroup *avahi_entry_group_new(AvahiServer *s, AvahiEntryGroupCallback callback, gpointer userdata);
111 void avahi_entry_group_free(AvahiEntryGroup *g);
112 void avahi_entry_group_commit(AvahiEntryGroup *g);
113 AvahiEntryGroupState avahi_entry_group_get_state(AvahiEntryGroup *g);
114 void avahi_entry_group_set_data(AvahiEntryGroup *g, gpointer userdata);
115 gpointer avahi_entry_group_get_data(AvahiEntryGroup *g);
117 void avahi_server_add(
122 AvahiEntryFlags flags,
125 void avahi_server_add_ptr(
130 AvahiEntryFlags flags,
134 void avahi_server_add_address(
139 AvahiEntryFlags flags,
143 void avahi_server_add_text(
148 AvahiEntryFlags flags,
150 ... /* text records, terminated by NULL */);
152 void avahi_server_add_text_va(
157 AvahiEntryFlags flags,
161 void avahi_server_add_text_strlst(
166 AvahiEntryFlags flags,
168 AvahiStringList *strlst);
170 void avahi_server_add_service(
180 ... /* text records, terminated by NULL */);
182 void avahi_server_add_service_va(
194 void avahi_server_add_service_strlst(
204 AvahiStringList *strlst);
207 AVAHI_SUBSCRIPTION_NEW,
208 AVAHI_SUBSCRIPTION_REMOVE,
209 } AvahiSubscriptionEvent;
211 typedef struct AvahiSubscription AvahiSubscription;
213 typedef void (*AvahiSubscriptionCallback)(AvahiSubscription *s, AvahiRecord *record, gint interface, guchar protocol, AvahiSubscriptionEvent event, gpointer userdata);
215 AvahiSubscription *avahi_subscription_new(AvahiServer *s, AvahiKey *key, gint interface, guchar protocol, AvahiSubscriptionCallback callback, gpointer userdata);
216 void avahi_subscription_free(AvahiSubscription *s);