1 #ifndef _discovery_discovery_h
2 #define _discovery_discovery_h
5 * Copyright 2003, 2004 Porchdog Software. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted provided that the following conditions are met:
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.
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.
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.
32 #include <salt/salt.h>
33 #include <salt/socket.h>
36 #if defined(__cplusplus)
43 typedef struct _sw_discovery * sw_discovery;
47 * keeps track of different discovery operations
49 typedef sw_uint32 sw_discovery_oid;
53 * For backwards compatibility
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
62 * how to connect to server
64 typedef enum _sw_discovery_init_flags
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;
73 * status for asynchronous registration call
75 typedef enum _sw_discovery_publish_status
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;
84 typedef enum _sw_discovery_browse_status
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;
97 typedef enum _sw_discovery_query_record_status
99 SW_DISCOVERY_QUERY_RECORD_ADD = 0x1
100 } sw_discovery_query_record_status;
104 (HOWL_API *sw_discovery_publish_reply)(
105 sw_discovery session,
106 sw_discovery_oid oid,
107 sw_discovery_publish_status status,
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,
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,
131 sw_octets text_record,
132 sw_uint32 text_record_len,
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,
146 sw_const_octets rrdata,
152 * API for publishing/browsing/resolving services
156 sw_discovery * self);
160 sw_discovery_init_with_flags(
162 sw_discovery_init_flags flags);
171 sw_discovery_publish_host(
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,
179 sw_discovery_oid * oid);
183 sw_discovery_publish(
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,
191 sw_octets text_record,
192 sw_uint32 text_record_len,
193 sw_discovery_publish_reply reply,
195 sw_discovery_oid * oid);
199 sw_discovery_publish_update(
201 sw_discovery_oid oid,
202 sw_octets text_record,
203 sw_uint32 text_record_len);
208 * API for browsing domains
211 sw_discovery_browse_domains(
213 sw_uint32 interface_index,
214 sw_discovery_browse_reply reply,
216 sw_discovery_oid * oid);
221 * API for browsing services
226 sw_uint32 interface_index,
227 sw_const_string type,
228 sw_const_string domain,
229 sw_discovery_browse_reply reply,
231 sw_discovery_oid * oid);
235 * API for resolving services
238 sw_discovery_resolve(
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,
246 sw_discovery_oid * oid);
250 sw_discovery_query_record(
252 sw_uint32 interface_index,
254 sw_const_string fullname,
257 sw_discovery_query_record_reply reply,
259 sw_discovery_oid * oid);
265 sw_discovery_oid oid);
269 /* ----------------------------------------------------------
271 * Event Processing APIs
273 * ----------------------------------------------------------
283 sw_discovery_stop_run(
293 sw_discovery_read_socket(
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)
322 #if defined(__cplusplus)