xref: /titanic_52/usr/src/lib/libslp/clib/slp-internal.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SLP_INTERNAL_H
28*7c478bd9Sstevel@tonic-gate #define	_SLP_INTERNAL_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <thread.h>
37*7c478bd9Sstevel@tonic-gate #include <synch.h>
38*7c478bd9Sstevel@tonic-gate #include <errno.h>
39*7c478bd9Sstevel@tonic-gate #include <string.h>
40*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
41*7c478bd9Sstevel@tonic-gate #include <limits.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/uio.h>
44*7c478bd9Sstevel@tonic-gate #include <slp.h>
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /* SLPv2 function numbers */
47*7c478bd9Sstevel@tonic-gate #define	SRVRQST		1
48*7c478bd9Sstevel@tonic-gate #define	SRVRPLY		2
49*7c478bd9Sstevel@tonic-gate #define	SRVREG		3
50*7c478bd9Sstevel@tonic-gate #define	SRVDEREG	4
51*7c478bd9Sstevel@tonic-gate #define	SRVACK		5
52*7c478bd9Sstevel@tonic-gate #define	ATTRRQST	6
53*7c478bd9Sstevel@tonic-gate #define	ATTRRPLY	7
54*7c478bd9Sstevel@tonic-gate #define	DAADVERT	8
55*7c478bd9Sstevel@tonic-gate #define	SRVTYPERQST	9
56*7c478bd9Sstevel@tonic-gate #define	SRVTYPERPLY	10
57*7c478bd9Sstevel@tonic-gate #define	SAADVERT	11
58*7c478bd9Sstevel@tonic-gate 
59*7c478bd9Sstevel@tonic-gate /* SLPv2 protocol error functions, hidden under the API */
60*7c478bd9Sstevel@tonic-gate typedef enum {
61*7c478bd9Sstevel@tonic-gate 	SLP_MSG_PARSE_ERROR		= 256,	/* used internally */
62*7c478bd9Sstevel@tonic-gate 	SLP_VER_NOT_SUPPORTED		= 9,
63*7c478bd9Sstevel@tonic-gate 	SLP_SICK_DA			= 10,
64*7c478bd9Sstevel@tonic-gate 	SLP_DA_BUSY_NOW			= 11,
65*7c478bd9Sstevel@tonic-gate 	SLP_OPTION_NOT_UNDERSTOOD	= 12,
66*7c478bd9Sstevel@tonic-gate 	SLP_RQST_NOT_SUPPORTED		= 13
67*7c478bd9Sstevel@tonic-gate } slp_proto_err;
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate /* Defaults and properties */
70*7c478bd9Sstevel@tonic-gate #define	SLP_VERSION	2
71*7c478bd9Sstevel@tonic-gate #define	SLP_DEFAULT_SENDMTU		1400
72*7c478bd9Sstevel@tonic-gate #define	SLP_PORT	427
73*7c478bd9Sstevel@tonic-gate #define	SLP_DEFAULT_MAXWAIT	15000
74*7c478bd9Sstevel@tonic-gate #define	SLP_DEFAULT_MAXRESULTS	-1
75*7c478bd9Sstevel@tonic-gate #define	SLP_MULTICAST_ADDRESS	inet_addr("239.255.255.253")
76*7c478bd9Sstevel@tonic-gate #define	SLP_MAX_STRINGLEN	USHRT_MAX
77*7c478bd9Sstevel@tonic-gate #define	SLP_MAX_MSGLEN		16777216	/* max message length 2^24 */
78*7c478bd9Sstevel@tonic-gate #define	SLP_SUN_SCOPES_TAG	"424242SUN-TABLE-SCOPES424242"
79*7c478bd9Sstevel@tonic-gate #define	SLP_SUN_VERSION_TAG	"424242SUN-TABLE-VERSION424242"
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate /* Property names */
82*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_USESCOPES		"net.slp.useScopes"
83*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_ISBROADCASTONLY	"net.slp.isBroadcastOnly"
84*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_MULTICASTTTL		"net.slp.multicastTTL"
85*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_MULTICASTMAXWAIT	"net.slp.multicastMaximumWait"
86*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_DATAGRAMTIMEOUTS	"net.slp.datagramTimeouts"
87*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_MULTICASTTIMEOUTS	"net.slp.multicastTimeouts"
88*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_MTU			"net.slp.mtu"
89*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_INTERFACES		"net.slp.interfaces"
90*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_LOCALE		"net.slp.locale"
91*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_MAXRESULTS		"net.slp.maxResults"
92*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_USEGETXXXBYYYY	"sun.net.slp.usegetxxxbyyyy"
93*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_TYPEHINT		"net.slp.typeHint"
94*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_SECURITY_ON		"net.slp.securityEnabled"
95*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_SPI			"sun.net.slp.SPIs"
96*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_SIGN_AS		"sun.net.slp.signAs"
97*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_BYPASS_AUTH		"sun.net.slp.bypassAuth"
98*7c478bd9Sstevel@tonic-gate #define	SLP_CONFIG_AUTH_BACKEND		"sun.net.slp.authBackend"
99*7c478bd9Sstevel@tonic-gate #define	SLP_SUN_DA_TYPE			"service:directory-agent.sun"
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate #define	SLP_DEFAULT_CONFIG_FILE		"/etc/inet/slp.conf"
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate extern void slp_readConfig(void);
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate /* Synchronized queue structures and functions */
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate typedef void slp_queue_t;
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate extern slp_queue_t *slp_new_queue(SLPError *);
110*7c478bd9Sstevel@tonic-gate extern SLPError slp_enqueue(slp_queue_t *, void *);
111*7c478bd9Sstevel@tonic-gate extern SLPError slp_enqueue_at_head(slp_queue_t *, void *);
112*7c478bd9Sstevel@tonic-gate extern void *slp_dequeue_timed(slp_queue_t *, timestruc_t *, SLPBoolean *);
113*7c478bd9Sstevel@tonic-gate extern void *slp_dequeue(slp_queue_t *);
114*7c478bd9Sstevel@tonic-gate extern void slp_flush_queue(slp_queue_t *, void (*)(void *));
115*7c478bd9Sstevel@tonic-gate extern void slp_destroy_queue(slp_queue_t *);
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate typedef struct {
118*7c478bd9Sstevel@tonic-gate 	struct iovec	*iov;
119*7c478bd9Sstevel@tonic-gate 	int		iovlen;
120*7c478bd9Sstevel@tonic-gate 	char	*msg;
121*7c478bd9Sstevel@tonic-gate 	struct iovec	prlistlen;
122*7c478bd9Sstevel@tonic-gate 	struct iovec	*prlist;
123*7c478bd9Sstevel@tonic-gate 	struct iovec	scopeslen;
124*7c478bd9Sstevel@tonic-gate 	struct iovec	*scopes;
125*7c478bd9Sstevel@tonic-gate } slp_msg_t;
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate /* Implementation of SLPHandle */
128*7c478bd9Sstevel@tonic-gate typedef struct handle_impl {
129*7c478bd9Sstevel@tonic-gate 	const char	*locale;	/* language tag */
130*7c478bd9Sstevel@tonic-gate 	int		fid;		/* SLP function ID */
131*7c478bd9Sstevel@tonic-gate 	slp_msg_t	msg;		/* The SLP message */
132*7c478bd9Sstevel@tonic-gate 	mutex_t		*tcp_lock;	/* TCP thread wait lock */
133*7c478bd9Sstevel@tonic-gate 	int		tcp_ref_cnt;	/* TCP thread reference count */
134*7c478bd9Sstevel@tonic-gate 	cond_t		*tcp_wait;	/* TCP thread wait condition var */
135*7c478bd9Sstevel@tonic-gate 	SLPBoolean	async;		/* asynchronous flag */
136*7c478bd9Sstevel@tonic-gate 	slp_queue_t	*q;		/* message queue for this handle */
137*7c478bd9Sstevel@tonic-gate 	thread_t	producer_tid;	/* thr ID of message producer */
138*7c478bd9Sstevel@tonic-gate 	thread_t	consumer_tid;	/* thr ID of message consumer */
139*7c478bd9Sstevel@tonic-gate 	int		cancel;		/* cancellation flag */
140*7c478bd9Sstevel@tonic-gate 	void		*ifinfo;	/* interface info */
141*7c478bd9Sstevel@tonic-gate 	SLPBoolean	force_multicast; /* for SAAdvert solicitations */
142*7c478bd9Sstevel@tonic-gate 	SLPBoolean	internal_call;	/* current call is an internal op */
143*7c478bd9Sstevel@tonic-gate 	SLPBoolean	pending_outcall; /* is handle in use? */
144*7c478bd9Sstevel@tonic-gate 	mutex_t		outcall_lock;	/* protects pending_outcall */
145*7c478bd9Sstevel@tonic-gate 	cond_t		outcall_cv;	/* outcall cond var */
146*7c478bd9Sstevel@tonic-gate 	SLPBoolean	close_on_end;	/* cleanup on slp_end_call */
147*7c478bd9Sstevel@tonic-gate } slp_handle_impl_t;
148*7c478bd9Sstevel@tonic-gate 
149*7c478bd9Sstevel@tonic-gate extern SLPError slp_start_call(slp_handle_impl_t *);
150*7c478bd9Sstevel@tonic-gate extern void slp_end_call(slp_handle_impl_t *);
151*7c478bd9Sstevel@tonic-gate extern void slp_cleanup_handle(slp_handle_impl_t *);
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate /* UA common functionality */
154*7c478bd9Sstevel@tonic-gate typedef void SLPGenericAppCB();
155*7c478bd9Sstevel@tonic-gate typedef SLPBoolean SLPMsgReplyCB(slp_handle_impl_t *, char *, void (*)(),
156*7c478bd9Sstevel@tonic-gate 					void *, void **, int *);
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate extern SLPError slp_ua_common(SLPHandle, const char *, SLPGenericAppCB, void *,
159*7c478bd9Sstevel@tonic-gate 				SLPMsgReplyCB);
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate extern SLPError slp_packSrvRqst(const char *, const char *,
162*7c478bd9Sstevel@tonic-gate 				slp_handle_impl_t *);
163*7c478bd9Sstevel@tonic-gate extern SLPError slp_packSrvRqst_single(const char *, const char *,
164*7c478bd9Sstevel@tonic-gate 					const char *, char **,
165*7c478bd9Sstevel@tonic-gate 					const char *);
166*7c478bd9Sstevel@tonic-gate extern SLPBoolean slp_unpackSrvReply(slp_handle_impl_t *, char *,
167*7c478bd9Sstevel@tonic-gate 					SLPSrvURLCallback, void *,
168*7c478bd9Sstevel@tonic-gate 					void **, int *);
169*7c478bd9Sstevel@tonic-gate extern SLPError slp_packAttrRqst_single(const char *,
170*7c478bd9Sstevel@tonic-gate 					const char *,
171*7c478bd9Sstevel@tonic-gate 					const char *,
172*7c478bd9Sstevel@tonic-gate 					char **,
173*7c478bd9Sstevel@tonic-gate 					const char *);
174*7c478bd9Sstevel@tonic-gate extern SLPBoolean slp_UnpackAttrReply(slp_handle_impl_t *, char *,
175*7c478bd9Sstevel@tonic-gate 					SLPAttrCallback, void *,
176*7c478bd9Sstevel@tonic-gate 					void **, int *);
177*7c478bd9Sstevel@tonic-gate extern SLPError slp_getDAbyScope(const char *, slp_queue_t *);
178*7c478bd9Sstevel@tonic-gate extern SLPError slp_SAAdvert(slp_handle_impl_t *, void *);
179*7c478bd9Sstevel@tonic-gate extern SLPError slp_unpackDAAdvert(char *, char **, char **, char **,
180*7c478bd9Sstevel@tonic-gate 					char **, SLPError *);
181*7c478bd9Sstevel@tonic-gate extern SLPError slp_unpackSAAdvert(char *, char **, char **, char **);
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate /* target selection routines */
184*7c478bd9Sstevel@tonic-gate typedef void slp_target_list_t;
185*7c478bd9Sstevel@tonic-gate typedef void slp_target_t;
186*7c478bd9Sstevel@tonic-gate extern SLPError slp_new_target_list(slp_handle_impl_t *hp, const char *,
187*7c478bd9Sstevel@tonic-gate 					slp_target_list_t **);
188*7c478bd9Sstevel@tonic-gate extern const char *slp_get_uc_scopes(slp_target_list_t *);
189*7c478bd9Sstevel@tonic-gate extern const char *slp_get_mc_scopes(slp_target_list_t *);
190*7c478bd9Sstevel@tonic-gate extern slp_target_t *slp_next_uc_target(slp_target_list_t *);
191*7c478bd9Sstevel@tonic-gate extern slp_target_t *slp_next_failover(slp_target_t *);
192*7c478bd9Sstevel@tonic-gate extern void *slp_get_target_sin(slp_target_t *);
193*7c478bd9Sstevel@tonic-gate extern void slp_mark_target_used(slp_target_t *);
194*7c478bd9Sstevel@tonic-gate extern void slp_mark_target_failed(slp_target_t *);
195*7c478bd9Sstevel@tonic-gate extern slp_target_t *slp_fabricate_target(void *);
196*7c478bd9Sstevel@tonic-gate extern void slp_free_target(slp_target_t *);
197*7c478bd9Sstevel@tonic-gate extern void slp_destroy_target_list(slp_target_list_t *);
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate /* short-lived DA cache */
200*7c478bd9Sstevel@tonic-gate extern char *slp_find_das_cached(const char *);
201*7c478bd9Sstevel@tonic-gate extern void slp_put_das_cached(const char *, const char *, unsigned int);
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate /* networking */
204*7c478bd9Sstevel@tonic-gate extern void slp_uc_tcp_send(slp_handle_impl_t *, slp_target_t *,
205*7c478bd9Sstevel@tonic-gate 				const char *, SLPBoolean, unsigned short);
206*7c478bd9Sstevel@tonic-gate extern void slp_uc_udp_send(slp_handle_impl_t *, slp_target_t *,
207*7c478bd9Sstevel@tonic-gate 				const char *);
208*7c478bd9Sstevel@tonic-gate extern void slp_mc_send(slp_handle_impl_t *, const char *);
209*7c478bd9Sstevel@tonic-gate extern void slp_tcp_wait(slp_handle_impl_t *);
210*7c478bd9Sstevel@tonic-gate extern SLPError slp_tcp_read(int, char **);
211*7c478bd9Sstevel@tonic-gate extern char *slp_ntop(char *, int, const void *);
212*7c478bd9Sstevel@tonic-gate extern int slp_pton(const char *, void *);
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate /* IPC */
215*7c478bd9Sstevel@tonic-gate extern SLPError slp_send2slpd(const char *, char **);
216*7c478bd9Sstevel@tonic-gate extern SLPError slp_send2slpd_iov(struct iovec *, int, char **);
217*7c478bd9Sstevel@tonic-gate 
218*7c478bd9Sstevel@tonic-gate /* SLP-style list management */
219*7c478bd9Sstevel@tonic-gate extern int slp_onlist(const char *, const char *);
220*7c478bd9Sstevel@tonic-gate extern void slp_add2list(const char *, char **, SLPBoolean);
221*7c478bd9Sstevel@tonic-gate extern void slp_list_subtract(const char *, char **);
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate /* searching and storing */
224*7c478bd9Sstevel@tonic-gate typedef enum { preorder, postorder, endorder, leaf } VISIT;
225*7c478bd9Sstevel@tonic-gate extern void slp_twalk(void *, void (*)(void *, VISIT, int, void *),
226*7c478bd9Sstevel@tonic-gate 			int, void *);
227*7c478bd9Sstevel@tonic-gate extern void *slp_tsearch(const void *, void **, int (*)());
228*7c478bd9Sstevel@tonic-gate extern void *slp_tfind(const void *, void *const *,
229*7c478bd9Sstevel@tonic-gate 		int (*)(const void *, const void *));
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate /* DA and scope discovery routines */
232*7c478bd9Sstevel@tonic-gate extern SLPError slp_find_das(const char *, char **);
233*7c478bd9Sstevel@tonic-gate extern SLPError slp_administrative_scopes(char **, SLPBoolean);
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate /* UTF8 routines */
236*7c478bd9Sstevel@tonic-gate extern char *slp_utf_strchr(const char *, char);
237*7c478bd9Sstevel@tonic-gate extern int slp_strcasecmp(const char *, const char *);
238*7c478bd9Sstevel@tonic-gate 
239*7c478bd9Sstevel@tonic-gate /* Error reporting */
240*7c478bd9Sstevel@tonic-gate extern void slp_err(int, int, char *, char *, ...);
241*7c478bd9Sstevel@tonic-gate 
242*7c478bd9Sstevel@tonic-gate /* Mapping from protocol to API error codes */
243*7c478bd9Sstevel@tonic-gate extern SLPError slp_map_err(unsigned short);
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate /* Security: signing and verifying */
246*7c478bd9Sstevel@tonic-gate extern SLPError slp_sign(struct iovec *, int, time_t, struct iovec *, int);
247*7c478bd9Sstevel@tonic-gate extern SLPError slp_verify(struct iovec *, int, const char *,
248*7c478bd9Sstevel@tonic-gate 			    size_t, int, size_t *);
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate /* Config convenience wrappers */
251*7c478bd9Sstevel@tonic-gate extern size_t slp_get_mtu();
252*7c478bd9Sstevel@tonic-gate extern int slp_get_next_onlist(char **);
253*7c478bd9Sstevel@tonic-gate extern int slp_get_maxResults();
254*7c478bd9Sstevel@tonic-gate #define	slp_get_mcmaxwait() atoi(SLPGetProperty(SLP_CONFIG_MULTICASTMAXWAIT))
255*7c478bd9Sstevel@tonic-gate #define	slp_get_maxresults() atoi(SLPGetProperty(SLP_CONFIG_MAXRESULTS))
256*7c478bd9Sstevel@tonic-gate #define	slp_get_multicastTTL() atoi(SLPGetProperty(SLP_CONFIG_MULTICASTTTL))
257*7c478bd9Sstevel@tonic-gate #define	slp_get_usebroadcast() \
258*7c478bd9Sstevel@tonic-gate 	(!strcasecmp(SLPGetProperty(SLP_CONFIG_ISBROADCASTONLY), "true"))
259*7c478bd9Sstevel@tonic-gate #define	slp_get_security_on() \
260*7c478bd9Sstevel@tonic-gate 	(!strcasecmp(SLPGetProperty(SLP_CONFIG_SECURITY_ON), "true"))
261*7c478bd9Sstevel@tonic-gate #define	slp_get_bypass_auth() \
262*7c478bd9Sstevel@tonic-gate 	(!strcasecmp(SLPGetProperty(SLP_CONFIG_BYPASS_AUTH), "true"))
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate /* Primitive encoding routines */
265*7c478bd9Sstevel@tonic-gate extern SLPError slp_add_byte(char *, size_t, int, size_t *);
266*7c478bd9Sstevel@tonic-gate extern SLPError slp_add_sht(char *, size_t, unsigned short, size_t *);
267*7c478bd9Sstevel@tonic-gate extern SLPError slp_add_int32(char *, size_t, unsigned int, size_t *);
268*7c478bd9Sstevel@tonic-gate extern SLPError slp_add_string(char *, size_t, const char *, size_t *);
269*7c478bd9Sstevel@tonic-gate extern SLPError slp_get_byte(const char *, size_t, size_t *, int *);
270*7c478bd9Sstevel@tonic-gate extern SLPError slp_get_sht(const char *, size_t, size_t *, unsigned short *);
271*7c478bd9Sstevel@tonic-gate extern SLPError slp_get_int32(const char *, size_t, size_t *, unsigned int *);
272*7c478bd9Sstevel@tonic-gate extern SLPError slp_get_string(const char *, size_t, size_t *, char **);
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate /* Header generation and handling */
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate /* OFFSETS to fields in the header */
277*7c478bd9Sstevel@tonic-gate #define	SLP_VER		0
278*7c478bd9Sstevel@tonic-gate #define	SLP_FUN		1
279*7c478bd9Sstevel@tonic-gate #define	SLP_LEN		2
280*7c478bd9Sstevel@tonic-gate #define	SLP_FLAGS	5
281*7c478bd9Sstevel@tonic-gate #define	SLP_NEXTOP	7
282*7c478bd9Sstevel@tonic-gate #define	SLP_XID		10
283*7c478bd9Sstevel@tonic-gate #define	SLP_LANGLEN	12
284*7c478bd9Sstevel@tonic-gate #define	SLP_HDRLEN	14
285*7c478bd9Sstevel@tonic-gate 
286*7c478bd9Sstevel@tonic-gate /* Flags */
287*7c478bd9Sstevel@tonic-gate #define	SLP_OVERFLOW	(char)0x80
288*7c478bd9Sstevel@tonic-gate #define	SLP_FRESH	(char)0x40
289*7c478bd9Sstevel@tonic-gate #define	SLP_MCAST	(char)0x20
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate /* One byte macros (not needing byte order conversion) */
292*7c478bd9Sstevel@tonic-gate #define	slp_get_version(h)	(h)[SLP_VER]
293*7c478bd9Sstevel@tonic-gate #define	slp_set_version(h, v)	(h)[SLP_VER] = (v);
294*7c478bd9Sstevel@tonic-gate #define	slp_get_function(h)	(h)[SLP_FUN]
295*7c478bd9Sstevel@tonic-gate #define	slp_set_function(h, f)	(h)[SLP_FUN] = (f)
296*7c478bd9Sstevel@tonic-gate #define	slp_get_overflow(h)	((h)[SLP_FLAGS] & SLP_OVERFLOW)
297*7c478bd9Sstevel@tonic-gate #define	slp_set_overflow(h)	(h)[SLP_FLAGS] |= SLP_OVERFLOW
298*7c478bd9Sstevel@tonic-gate #define	slp_set_fresh(h)	(h)[SLP_FLAGS] |= SLP_FRESH
299*7c478bd9Sstevel@tonic-gate #define	slp_set_mcast(h)	(h)[SLP_FLAGS] |= SLP_MCAST
300*7c478bd9Sstevel@tonic-gate 
301*7c478bd9Sstevel@tonic-gate /* Routines requiring byte order conversions */
302*7c478bd9Sstevel@tonic-gate extern unsigned short slp_header_get_sht(const char *, size_t);
303*7c478bd9Sstevel@tonic-gate extern void slp_header_set_sht(char *, unsigned short, size_t);
304*7c478bd9Sstevel@tonic-gate extern unsigned int slp_header_get_int24(const char *, size_t);
305*7c478bd9Sstevel@tonic-gate extern void slp_header_set_int24(char *, unsigned int, size_t);
306*7c478bd9Sstevel@tonic-gate extern slp_proto_err slp_get_errcode(char *);
307*7c478bd9Sstevel@tonic-gate #define	slp_get_length(h)	slp_header_get_int24((h), SLP_LEN)
308*7c478bd9Sstevel@tonic-gate #define	slp_set_length(h, x)	slp_header_set_int24((h), (int)(x), SLP_LEN)
309*7c478bd9Sstevel@tonic-gate #define	slp_get_langlen(h)	slp_header_get_sht((h), SLP_LANGLEN)
310*7c478bd9Sstevel@tonic-gate #define	slp_set_langlen(h, x)	slp_header_set_sht((h), (x), SLP_LANGLEN)
311*7c478bd9Sstevel@tonic-gate #define	slp_get_option(h)	slp_header_get_int24((h), SLP_NEXTOP)
312*7c478bd9Sstevel@tonic-gate #define	slp_set_option(h, x)	slp_header_set_int24((h), (x), SLP_NEXTOP)
313*7c478bd9Sstevel@tonic-gate #define	slp_get_xid(h)		slp_header_get_sht((h), SLP_XID)
314*7c478bd9Sstevel@tonic-gate #define	slp_set_xid(h, x)	slp_header_set_sht((h), (x), SLP_XID)
315*7c478bd9Sstevel@tonic-gate 
316*7c478bd9Sstevel@tonic-gate extern SLPError slp_add_header(const char *, char *, size_t, int,
317*7c478bd9Sstevel@tonic-gate 				size_t, size_t *);
318*7c478bd9Sstevel@tonic-gate #define	slp_hdrlang_length(h)	\
319*7c478bd9Sstevel@tonic-gate 		(SLP_HDRLEN + strlen(((slp_handle_impl_t *)(h))->locale))
320*7c478bd9Sstevel@tonic-gate 
321*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
322*7c478bd9Sstevel@tonic-gate }
323*7c478bd9Sstevel@tonic-gate #endif
324*7c478bd9Sstevel@tonic-gate 
325*7c478bd9Sstevel@tonic-gate #endif	/* _SLP_INTERNAL_H */
326