]> git.meshlink.io Git - catta/blob - avahi-client/publish.h
0884d3ef50f9a82b91c853fa6dbe8204c4ae0108
[catta] / avahi-client / publish.h
1 #ifndef fooclientpublishhfoo
2 #define fooclientpublishhfoo
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 <inttypes.h>
26
27 #include <avahi-common/cdecl.h>
28 #include <avahi-common/address.h>
29 #include <avahi-common/strlst.h>
30 #include <avahi-common/defs.h>
31 #include <avahi-common/watch.h>
32 #include <avahi-common/gccmacro.h>
33
34 #include <avahi-client/client.h>
35
36 /** \file avahi-client/publish.h Publishing Client API */
37
38 /** \example client-publish-service.c Example how to register a DNS-SD
39  * service using the client interface to avahi-daemon. It behaves like a network
40  * printer registering both an IPP and a BSD LPR service. */
41
42 AVAHI_C_DECL_BEGIN
43
44 /** An entry group object */
45 typedef struct AvahiEntryGroup AvahiEntryGroup;
46
47 /** The function prototype for the callback of an AvahiEntryGroup */
48 typedef void (*AvahiEntryGroupCallback) (
49     AvahiEntryGroup *g,
50     AvahiEntryGroupState state /**< The new state of the entry group */,
51     void* userdata /* The arbitrary user data pointer originally passed to avahi_entry_group_new()*/);
52
53 /** @{ \name Construction and destruction */
54
55 /** Create a new AvahiEntryGroup object */
56 AvahiEntryGroup* avahi_entry_group_new(
57     AvahiClient* c,
58     AvahiEntryGroupCallback callback /**< This callback is called whenever the state of this entry group changes. May not be NULL. Please note that this function is called for the first time from within the avahi_entry_group_new() context! Thus, in the callback you should not make use of global variables that are initialized only after your call to avahi_entry_group_new(). A common mistake is to store the AvahiEntryGroup pointer returned by avahi_entry_group_new() in a global variable and assume that this global variable already contains the valid pointer when the callback is called for the first time. A work-around for this is to always use the AvahiEntryGroup pointer passed to the callback function instead of the global pointer. */,
59     void *userdata /**< This arbitrary user data pointer will be passed to the callback functon */);
60
61 /** Clean up and free an AvahiEntryGroup object */
62 int avahi_entry_group_free (AvahiEntryGroup *);
63
64 /** @} */
65
66 /** @{ \name State */
67
68 /** Commit an AvahiEntryGroup. The entries in the entry group are now registered on the network. Commiting empty entry groups is considered an error. */
69 int avahi_entry_group_commit (AvahiEntryGroup*);
70
71 /** Reset an AvahiEntryGroup. This takes effect immediately. */
72 int avahi_entry_group_reset (AvahiEntryGroup*);
73
74 /** Get an AvahiEntryGroup's state */
75 int avahi_entry_group_get_state (AvahiEntryGroup*);
76
77 /** Check if an AvahiEntryGroup is empty */
78 int avahi_entry_group_is_empty (AvahiEntryGroup*);
79
80 /** Get an AvahiEntryGroup's owning client instance */
81 AvahiClient* avahi_entry_group_get_client (AvahiEntryGroup*);
82
83 /** @} */
84
85 /** @{ \name Adding and updating entries */
86
87 /** Add a service. Takes a variable NULL terminated list of TXT record strings as last arguments. Please note that this service is not announced on the network before avahi_entry_group_commit() is called. */
88 int avahi_entry_group_add_service(
89     AvahiEntryGroup *group,
90     AvahiIfIndex interface /**< The interface this service shall be announced on. We recommend to pass AVAHI_IF_UNSPEC here, to announce on all interfaces. */,
91     AvahiProtocol protocol /**< The protocol this service shall be announced with, i.e. MDNS over IPV4 or MDNS over IPV6. We recommend to pass AVAHI_PROTO_UNSPEC here, to announce this service on all protocols the daemon supports. */,
92     AvahiPublishFlags flags /**< Usually 0, unless you know what you do */,
93     const char *name        /**< The name for the new service. Must be valid service name. i.e. a string shorter than 63 characters and valid UTF-8. May not be NULL. */,
94     const char *type        /**< The service type for the new service, such as _http._tcp. May not be NULL. */,
95     const char *domain      /**< The domain to register this domain in. We recommend to pass NULL here, to let the daemon decide */,
96     const char *host        /**< The host this services is residing on. We recommend to pass NULL here, the daemon will than automatically insert the local host name in that case */,
97     uint16_t port           /**< The IP port number of this service */,
98     ...) AVAHI_GCC_SENTINEL;
99
100 /** Add a service, takes an AvahiStringList for TXT records. Arguments have the same meaning as for avahi_entry_group_add_service(). */
101 int avahi_entry_group_add_service_strlst(
102     AvahiEntryGroup *group,
103     AvahiIfIndex interface,
104     AvahiProtocol protocol,
105     AvahiPublishFlags flags,
106     const char *name,
107     const char *type,
108     const char *domain,
109     const char *host,
110     uint16_t port,
111     AvahiStringList *txt /**< The TXT data for this service. You may free this object after calling this function, it is not referenced any further */);
112
113 /** Add a subtype for a service. The service should already be existent in the entry group. You may add as many subtypes for a service as you wish. */
114 int avahi_entry_group_add_service_subtype(
115     AvahiEntryGroup *group,
116     AvahiIfIndex interface /**< The interface this subtype shall be announced on. This should match the value passed for the original avahi_entry_group_add_service() call. */,
117     AvahiProtocol protocol /**< The protocol this subtype shall be announced with. This should match the value passed for the original avahi_entry_group_add_service() call. */,
118     AvahiPublishFlags flags  /**< Only != 0 if you really know what you do */,
119     const char *name         /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */,
120     const char *type         /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */,
121     const char *domain       /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */,
122     const char *subtype /**< The new subtype to register for the specified service. May not be NULL. */);
123
124 /** Update a TXT record for an existing service. The service should already be existent in the entry group. */
125 int avahi_entry_group_update_service_txt(
126     AvahiEntryGroup *g,
127     AvahiIfIndex interface   /**< The interface this service is announced on. This should match the value passed to the original avahi_entry_group_add_service() call. */,
128     AvahiProtocol protocol   /**< The protocol this service is announced with. This should match the value passed to the original avahi_entry_group_add_service() call. */,
129     AvahiPublishFlags flags  /**< Only != 0 if you really know what you do */,
130     const char *name         /**< The name of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */,
131     const char *type         /**< The type of the service, as passed to avahi_entry_group_add_service(). May not be NULL. */,
132     const char *domain       /**< The domain this service resides is, as passed to avahi_entry_group_add_service(). May be NULL. */,
133     ...) AVAHI_GCC_SENTINEL;
134
135 /** Update a TXT record for an existing service. Similar to avahi_entry_group_update_service_txt() but takes an AvahiStringList for the TXT strings, instead of a NULL terminated list of arguments. */
136 int avahi_entry_group_update_service_txt_strlst(
137     AvahiEntryGroup *g,
138     AvahiIfIndex interface,
139     AvahiProtocol protocol,
140     AvahiPublishFlags flags,
141     const char *name,
142     const char *type,
143     const char *domain,
144     AvahiStringList *strlst);
145
146 /** \cond fulldocs */
147 /** Add a host/address pair */
148 int avahi_entry_group_add_address(
149     AvahiEntryGroup *group,
150     AvahiIfIndex interface,
151     AvahiProtocol protocol,
152     AvahiPublishFlags flags,
153     const char *name /**< The FDQN of the new hostname to register */,
154     const AvahiAddress *a /**< The address this host name shall map to */);
155 /** \endcond */
156
157 /** Add an arbitrary record. I hope you know what you do. */
158 int avahi_entry_group_add_record(
159     AvahiEntryGroup *group,
160     AvahiIfIndex interface,
161     AvahiProtocol protocol,
162     AvahiPublishFlags flags,
163     const char *name,
164     uint16_t clazz,
165     uint16_t type,
166     uint32_t ttl,
167     const void *rdata,
168     size_t size);
169
170 /** @} */
171
172 AVAHI_C_DECL_END
173
174 #endif