]> git.meshlink.io Git - catta/blob - avahi-compat-howl/include/discovery/discovery.h
fix avahi_netlink_new to allow multiple netlinks per process
[catta] / avahi-compat-howl / include / discovery / discovery.h
1 #ifndef _discovery_discovery_h
2 #define _discovery_discovery_h
3
4 /*
5  * Copyright 2003, 2004 Porchdog Software. All rights reserved.
6  *
7  *      Redistribution and use in source and binary forms, with or without modification,
8  *      are permitted provided that the following conditions are met:
9  *
10  *              1. Redistributions of source code must retain the above copyright notice,
11  *                 this list of conditions and the following disclaimer.
12  *              2. Redistributions in binary form must reproduce the above copyright notice,
13  *                 this list of conditions and the following disclaimer in the documentation
14  *                 and/or other materials provided with the distribution.
15  *
16  *      THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY
17  *      EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  *      WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  *      IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20  *      INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  *      BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  *      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23  *      OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24  *      OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25  *      OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  *      The views and conclusions contained in the software and documentation are those
28  *      of the authors and should not be interpreted as representing official policies,
29  *      either expressed or implied, of Porchdog Software.
30  */
31
32 #include <salt/salt.h>
33 #include <salt/socket.h>
34
35
36 #if defined(__cplusplus)
37 extern "C"
38 {
39 #endif
40
41
42 struct                                                                  _sw_discovery;
43 typedef struct _sw_discovery    *       sw_discovery;
44
45
46 /*
47  * keeps track of different discovery operations
48  */
49 typedef sw_uint32                                               sw_discovery_oid;
50
51
52 /*
53  * For backwards compatibility
54  */
55 #define sw_discovery_publish_host_id    sw_discovery_oid
56 #define sw_discovery_publish_id                 sw_discovery_oid
57 #define sw_discovery_browse_id                  sw_discovery_oid
58 #define sw_discovery_resolve_id                 sw_discovery_oid
59
60
61 /*
62  * how to connect to server
63  */
64 typedef enum _sw_discovery_init_flags
65 {
66         SW_DISCOVERY_USE_SHARED_SERVICE         =       0x1,
67         SW_DISCOVERY_USE_PRIVATE_SERVICE                =       0x2,
68         SW_DISCOVERY_SKIP_VERSION_CHECK         =       0x4
69 } sw_discovery_init_flags;
70
71
72 /*
73  * status for asynchronous registration call
74  */
75 typedef enum _sw_discovery_publish_status
76 {
77         SW_DISCOVERY_PUBLISH_STARTED,
78         SW_DISCOVERY_PUBLISH_STOPPED,
79         SW_DISCOVERY_PUBLISH_NAME_COLLISION,
80         SW_DISCOVERY_PUBLISH_INVALID
81 } sw_discovery_publish_status;
82
83
84 typedef enum _sw_discovery_browse_status
85 {
86         SW_DISCOVERY_BROWSE_INVALID,
87         SW_DISCOVERY_BROWSE_RELEASE,
88         SW_DISCOVERY_BROWSE_ADD_DOMAIN,
89         SW_DISCOVERY_BROWSE_ADD_DEFAULT_DOMAIN,
90         SW_DISCOVERY_BROWSE_REMOVE_DOMAIN,
91         SW_DISCOVERY_BROWSE_ADD_SERVICE,
92         SW_DISCOVERY_BROWSE_REMOVE_SERVICE,
93         SW_DISCOVERY_BROWSE_RESOLVED
94 } sw_discovery_browse_status;
95
96
97 typedef enum _sw_discovery_query_record_status
98 {
99         SW_DISCOVERY_QUERY_RECORD_ADD                   =       0x1
100 } sw_discovery_query_record_status;
101
102
103 typedef sw_result
104 (HOWL_API *sw_discovery_publish_reply)(
105                                                         sw_discovery                                            session,
106                                                         sw_discovery_oid                                        oid,
107                                                         sw_discovery_publish_status     status,
108                                                         sw_opaque                                                       extra);
109
110 typedef sw_result
111 (HOWL_API *sw_discovery_browse_reply)(
112                                                         sw_discovery                                            session,
113                                                         sw_discovery_oid                                        oid,
114                                                         sw_discovery_browse_status              status,
115                                                         sw_uint32                                                       interface_index,
116                                                         sw_const_string                                 name,
117                                                         sw_const_string                                 type,
118                                                         sw_const_string                                 domain,
119                                                         sw_opaque                                                       extra);
120
121 typedef sw_result
122 (HOWL_API *sw_discovery_resolve_reply)(
123                                                         sw_discovery                                            session,
124                                                         sw_discovery_oid                                        oid,
125                                                         sw_uint32                                                       interface_index,
126                                                         sw_const_string                                 name,
127                                                         sw_const_string                                 type,
128                                                         sw_const_string                                 domain,
129                                                         sw_ipv4_address                                 address,
130                                                         sw_port                                                         port,
131                                                         sw_octets                                                       text_record,
132                                                         sw_uint32                                                       text_record_len,
133                                                         sw_opaque                                                       extra);
134
135
136 typedef sw_result
137 (HOWL_API *sw_discovery_query_record_reply)(
138                                                         sw_discovery                                                            session,
139                                                         sw_discovery_oid                                                        oid,
140                                                         sw_discovery_query_record_status                status,
141                                                         sw_uint32                                                                       interface_index,
142                                                         sw_const_string                                                 fullname,
143                                                         sw_uint16                                                                       rrtype,
144                                                         sw_uint16                                                                       rrclass,
145                                                         sw_uint16                                                                       rrdatalen,
146                                                         sw_const_octets                                                 rrdata,
147                                                         sw_uint32                                                                       ttl,
148                                                         sw_opaque                                                                       extra);
149
150
151 /*
152  * API for publishing/browsing/resolving services
153  */
154 sw_result HOWL_API
155 sw_discovery_init(
156                                         sw_discovery                    *       self);
157
158
159 sw_result HOWL_API
160 sw_discovery_init_with_flags(
161                                         sw_discovery                    *       self,
162                                         sw_discovery_init_flags flags);
163
164
165 sw_result HOWL_API
166 sw_discovery_fina(
167                                         sw_discovery            self);
168
169
170 sw_result HOWL_API
171 sw_discovery_publish_host(
172                                         sw_discovery                                            self,
173                                         sw_uint32                                                       interface_index,
174                                         sw_const_string                                 name,
175                                         sw_const_string                                 domain,
176                                         sw_ipv4_address                                 address,
177                                         sw_discovery_publish_reply              reply,
178                                         sw_opaque                                                       extra,
179                                         sw_discovery_oid                                *       oid);
180
181
182 sw_result HOWL_API
183 sw_discovery_publish(
184                                         sw_discovery                                            self,
185                                         sw_uint32                                                       interface_index,
186                                         sw_const_string                                 name,
187                                         sw_const_string                                 type,
188                                         sw_const_string                                 domain,
189                                         sw_const_string                                 host,
190                                         sw_port                                                         port,
191                                         sw_octets                                                       text_record,
192                                         sw_uint32                                                       text_record_len,
193                                         sw_discovery_publish_reply              reply,
194                                         sw_opaque                                                       extra,
195                                         sw_discovery_oid                                *       oid);
196
197
198 sw_result HOWL_API
199 sw_discovery_publish_update(
200                                         sw_discovery                                            self,
201                                         sw_discovery_oid                                        oid,
202                                         sw_octets                                                       text_record,
203                                         sw_uint32                                                       text_record_len);
204
205
206
207 /*
208  * API for browsing domains
209  */
210 sw_result HOWL_API
211 sw_discovery_browse_domains(
212                                         sw_discovery                                            self,
213                                         sw_uint32                                                       interface_index,
214                                         sw_discovery_browse_reply               reply,
215                                         sw_opaque                                                       extra,
216                                         sw_discovery_oid                                *       oid);
217
218
219
220 /*
221  * API for browsing services
222  */
223 sw_result HOWL_API
224 sw_discovery_browse(
225                                         sw_discovery                                            self,
226                                         sw_uint32                                                       interface_index,
227                                         sw_const_string                                 type,
228                                         sw_const_string                                 domain,
229                                         sw_discovery_browse_reply               reply,
230                                         sw_opaque                                                       extra,
231                                         sw_discovery_oid                                *       oid);
232
233
234 /*
235  * API for resolving services
236  */
237 sw_result HOWL_API
238 sw_discovery_resolve(
239                                         sw_discovery                                            self,
240                                         sw_uint32                                                       interface_index,
241                                         sw_const_string                                 name,
242                                         sw_const_string                                 type,
243                                         sw_const_string                                 domain,
244                                         sw_discovery_resolve_reply              reply,
245                                         sw_opaque                                                       extra,
246                                         sw_discovery_oid                                *       oid);
247
248
249 sw_result HOWL_API
250 sw_discovery_query_record(
251                                         sw_discovery                                                            self,
252                                         sw_uint32                                                                       interface_index,
253                                         sw_uint32                                                                       flags,
254                                         sw_const_string                                                 fullname,
255                                         sw_uint16                                                                       rrtype,
256                                         sw_uint16                                                                       rrclass,
257                                         sw_discovery_query_record_reply         reply,
258                                         sw_opaque                                                                       extra,
259                                         sw_discovery_oid                                                *       oid);
260
261
262 sw_result HOWL_API
263 sw_discovery_cancel(
264                                         sw_discovery            self,
265                                         sw_discovery_oid        oid);
266
267
268
269 /* ----------------------------------------------------------
270  *
271  * Event Processing APIs
272  *
273  * ----------------------------------------------------------
274  */
275
276
277 sw_result HOWL_API
278 sw_discovery_run(
279                                         sw_discovery                                            self);
280
281
282 sw_result HOWL_API
283 sw_discovery_stop_run(
284                                         sw_discovery                                            self);
285
286
287 int HOWL_API
288 sw_discovery_socket(
289                                         sw_discovery                                            self);
290
291
292 sw_result HOWL_API
293 sw_discovery_read_socket(
294                                         sw_discovery                                            self);
295
296
297 sw_result HOWL_API
298 sw_discovery_salt(
299                                         sw_discovery    self,
300                                         sw_salt         *       salt);
301
302
303 /*
304  * Error codes
305  */
306 #define SW_DISCOVERY_E_BASE                                     900
307 #define SW_DISCOVERY_E_UNKNOWN                          (SW_DISCOVERY_E_BASE + 2)
308 #define SW_DISCOVERY_E_NO_SUCH_NAME                     (SW_DISCOVERY_E_BASE + 3)
309 #define SW_DISCOVERY_E_NO_MEM                                   (SW_DISCOVERY_E_BASE + 4)
310 #define SW_DISCOVERY_E_BAD_PARAM                                (SW_DISCOVERY_E_BASE + 5)
311 #define SW_DISCOVERY_E_BAD_REFERENCE            (SW_DISCOVERY_E_BASE + 6)
312 #define SW_DISCOVERY_E_BAD_STATE                                (SW_DISCOVERY_E_BASE + 7)
313 #define SW_DISCOVERY_E_BAD_FLAGS                                (SW_DISCOVERY_E_BASE + 8)
314 #define SW_DISCOVERY_E_NOT_SUPPORTED            (SW_DISCOVERY_E_BASE + 9)
315 #define SW_DISCOVERY_E_NOT_INITIALIZED          (SW_DISCOVERY_E_BASE + 10)
316 #define SW_DISCOVERY_E_NO_CACHE                         (SW_DISCOVERY_E_BASE + 11)
317 #define SW_DISCOVERY_E_ALREADY_REGISTERED       (SW_DISCOVERY_E_BASE + 12)
318 #define SW_DISCOVERY_E_NAME_CONFLICT            (SW_DISCOVERY_E_BASE + 13)
319 #define SW_DISCOVERY_E_INVALID                          (SW_DISCOVERY_E_BASE + 14)
320
321
322 #if defined(__cplusplus)
323 }
324 #endif
325
326
327 #endif