• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/avahi-0.6.31/avahi-core/
1#ifndef foopublishhfoo
2#define foopublishhfoo
3
4/***
5  This file is part of avahi.
6
7  avahi is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Lesser General Public License as
9  published by the Free Software Foundation; either version 2.1 of the
10  License, or (at your option) any later version.
11
12  avahi is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15  Public License for more details.
16
17  You should have received a copy of the GNU Lesser General Public
18  License along with avahi; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  USA.
21***/
22
23/** \file core/publish.h Functions for publising local services and RRs */
24
25/** \example core-publish-service.c Example how to register a DNS-SD
26 * service using an embedded mDNS stack. It behaves like a network
27 * printer registering both an IPP and a BSD LPR service. */
28
29/** A group of locally registered DNS RRs */
30typedef struct AvahiSEntryGroup AvahiSEntryGroup;
31
32#include <avahi-common/cdecl.h>
33#include <avahi-common/defs.h>
34#include <avahi-core/core.h>
35
36AVAHI_C_DECL_BEGIN
37
38/** Prototype for callback functions which are called whenever the state of an AvahiSEntryGroup object changes */
39typedef void (*AvahiSEntryGroupCallback) (AvahiServer *s, AvahiSEntryGroup *g, AvahiEntryGroupState state, void* userdata);
40
41/** Iterate through all local entries of the server. (when g is NULL)
42 * or of a specified entry group. At the first call state should point
43 * to a NULL initialized void pointer, That pointer is used to track
44 * the current iteration. It is not safe to call any other
45 * avahi_server_xxx() function during the iteration. If the last entry
46 * has been read, NULL is returned. */
47const AvahiRecord *avahi_server_iterate(AvahiServer *s, AvahiSEntryGroup *g, void **state, AvahiPublishProtocol proto);
48
49/** Create a new entry group. The specified callback function is
50 * called whenever the state of the group changes. Use entry group
51 * objects to keep track of you RRs. Add new RRs to a group using
52 * avahi_server_add_xxx(). Make sure to call avahi_s_entry_group_commit()
53 * to start the registration process for your RRs */
54AvahiSEntryGroup *avahi_s_entry_group_new(AvahiServer *s, AvahiSEntryGroupCallback callback, void* userdata);
55
56/** Free an entry group. All RRs assigned to the group are removed from the server */
57void avahi_s_entry_group_free(AvahiSEntryGroup *g);
58
59/** Commit an entry group. This starts the probing and registration process for all RRs in the group */
60int avahi_s_entry_group_commit(AvahiSEntryGroup *g);
61
62/** Remove all entries from the entry group and reset the state to AVAHI_ENTRY_GROUP_UNCOMMITED. */
63void avahi_s_entry_group_reset(AvahiSEntryGroup *g);
64
65/** Return 1 if the entry group is empty, i.e. has no records attached. */
66int avahi_s_entry_group_is_empty(AvahiSEntryGroup *g);
67
68/** Return the current state of the specified entry group */
69AvahiEntryGroupState avahi_s_entry_group_get_state(AvahiSEntryGroup *g);
70
71/** Change the opaque user data pointer attached to an entry group object */
72void avahi_s_entry_group_set_data(AvahiSEntryGroup *g, void* userdata);
73
74/** Return the opaque user data pointer currently set for the entry group object */
75void* avahi_s_entry_group_get_data(AvahiSEntryGroup *g);
76
77/** Add a new resource record to the server. Returns 0 on success, negative otherwise. */
78int avahi_server_add(
79    AvahiServer *s,           /**< The server object to add this record to */
80    AvahiSEntryGroup *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. */
81    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 */
82    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). */
83    AvahiPublishFlags flags,    /**< Special flags for this record */
84    AvahiRecord *r            /**< The record to add. This function increases the reference counter of this object. */);
85
86/** Add an IP address mapping to the server. This will add both the
87 * host-name-to-address and the reverse mapping to the server. See
88 * avahi_server_add() for more information. If adding one of the RRs
89 * fails, the function returns with an error, but it is not defined if
90 * the other RR is deleted from the server or not. Therefore, you have
91 * to free the AvahiSEntryGroup and create a new one before
92 * proceeding. */
93int avahi_server_add_address(
94    AvahiServer *s,
95    AvahiSEntryGroup *g,
96    AvahiIfIndex interface,
97    AvahiProtocol protocol,
98    AvahiPublishFlags flags,
99    const char *name,
100    AvahiAddress *a);
101
102/** Add a CNAME mapping to the server, which will point to the this
103 * servers FQDN. See avahi_server_add() for more information. */
104int avahi_server_add_cname(
105    AvahiServer *s,
106    AvahiSEntryGroup *g,
107    AvahiIfIndex interface,
108    AvahiProtocol protocol,
109    AvahiPublishFlags flags,
110    uint32_t ttl,
111    const char *name);
112
113int avahi_server_add_llmnr_cname(
114    AvahiServer *s,
115    AvahiSEntryGroup *g,
116    AvahiIfIndex interface,
117    AvahiProtocol protocol,
118    AvahiPublishFlags flags,
119    uint32_t ttl,
120    const char *name);
121
122/** Add an DNS-SD service to the Server. This will add all required
123 * RRs to the server. See avahi_server_add() for more information.  If
124 * adding one of the RRs fails, the function returns with an error,
125 * but it is not defined if the other RR is deleted from the server or
126 * not. Therefore, you have to free the AvahiSEntryGroup and create a
127 * new one before proceeding. */
128int avahi_server_add_service(
129    AvahiServer *s,
130    AvahiSEntryGroup *g,
131    AvahiIfIndex interface,
132    AvahiProtocol protocol,
133    AvahiPublishFlags flags,
134    const char *name,         /**< Service name, e.g. "Lennart's Files" */
135    const char *type,         /**< DNS-SD type, e.g. "_http._tcp" */
136    const char *domain,
137    const char *host,         /**< Host name where this servcie resides, or NULL if on the local host */
138    uint16_t port,              /**< Port number of the service */
139    ...  /**< Text records, terminated by NULL */) AVAHI_GCC_SENTINEL;
140
141/** Mostly identical to avahi_server_add_service(), but takes an AvahiStringList object for the TXT records.  The AvahiStringList object is copied. */
142int avahi_server_add_service_strlst(
143    AvahiServer *s,
144    AvahiSEntryGroup *g,
145    AvahiIfIndex interface,
146    AvahiProtocol protocol,
147    AvahiPublishFlags flags,
148    const char *name,
149    const char *type,
150    const char *domain,
151    const char *host,
152    uint16_t port,
153    AvahiStringList *strlst);
154
155/** Add a subtype for an already existing service */
156int avahi_server_add_service_subtype(
157    AvahiServer *s,
158    AvahiSEntryGroup *g,
159    AvahiIfIndex interface,
160    AvahiProtocol protocol,
161    AvahiPublishFlags flags,
162    const char *name,         /**< Specify the name of main service you already added here */
163    const char *type,         /**< Specify the main type of the service you already added here */
164    const char *domain,       /**< Specify the main type of the service you already added here */
165    const char *subtype       /**< The new subtype for the specified service */ );
166
167/** Update the TXT record for a service with the data from the specified string list */
168int avahi_server_update_service_txt_strlst(
169    AvahiServer *s,
170    AvahiSEntryGroup *g,
171    AvahiIfIndex interface,
172    AvahiProtocol protocol,
173    AvahiPublishFlags flags,
174    const char *name,
175    const char *type,
176    const char *domain,
177    AvahiStringList *strlst);
178
179/** Update the TXT record for a service with the NULL termonate list of strings */
180int avahi_server_update_service_txt(
181    AvahiServer *s,
182    AvahiSEntryGroup *g,
183    AvahiIfIndex interface,
184    AvahiProtocol protocol,
185    AvahiPublishFlags flags,
186    const char *name,
187    const char *type,
188    const char *domain,
189    ...) AVAHI_GCC_SENTINEL;
190
191/** Check if there is a service locally defined and return the entry group it is attached to. Returns NULL if the service isn't local*/
192int avahi_server_get_group_of_service(AvahiServer *s, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain, AvahiSEntryGroup** ret_group);
193
194AVAHI_C_DECL_END
195
196#endif
197