xref: /titanic_44/usr/src/lib/libtsol/common/labeld.h (revision 9455584c67f6bed7407417f74a9b5b0ab615384b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LABELD_H
27 #define	_LABELD_H
28 
29 #include <sys/types.h>
30 #include <tsol/label.h>
31 #include <sys/tsol/label_macro.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 /*
38  *	Definitions for the call parameters for the door-based label
39  * translation service.
40  */
41 
42 #define	BUFSIZE	4096
43 
44 #define	DOOR_PATH	"/var/tsol/doors/"
45 #define	DOOR_NAME	"labeld"
46 #define	COOKIE		0x6c616264ull	/* "labd" */
47 
48 /*	Op codes */
49 
50 /*	Labeld Commands */
51 
52 #define	LABELDNULL	1
53 
54 /*	Miscellaneous */
55 
56 #define	BLINSET		10
57 #define	BSLVALID	11
58 #define	BILVALID	12
59 #define	BCLEARVALID	13
60 #define	LABELINFO	14
61 #define	LABELVERS	15
62 #define	BLTOCOLOR	16
63 
64 /*	Binary to String Label Translation */
65 
66 #define	BSLTOS		23
67 #define	BCLEARTOS	25
68 
69 /*	String to Binary Label Translation */
70 
71 #define	STOBSL		31
72 #define	STOBCLEAR	33
73 
74 /*
75  *	Dimming List Routines
76  *	Contract private for label builders
77  */
78 
79 #define	BSLCVT		40
80 #define	BCLEARCVT	42
81 #define	LABELFIELDS	43
82 #define	UDEFS		44
83 
84 #define	GETFLABEL	45
85 #define	SETFLABEL	46
86 #define	ZCOPY		47
87 
88 /* NEW LABELS */
89 /* DIA printer banner labels */
90 
91 #define	PR_CAVEATS	101
92 #define	PR_CHANNELS	102
93 #define	PR_LABEL	103
94 #define	PR_TOP		104
95 
96 /* DIA label to string  */
97 
98 #define	LTOS		105
99 
100 /* DIA string to label */
101 
102 #define	STOL		106
103 
104 /*	Structures */
105 
106 typedef	uint_t	bufp_t;		/* offset into buf[] in/out string buffer */
107 
108 /* Null call */
109 
110 typedef	struct {
111 	int	null;
112 } null_call_t;
113 
114 typedef	struct {
115 	int	null;
116 } null_ret_t;
117 
118 /* Miscellaneous interfaces */
119 
120 typedef	struct {
121 	bslabel_t label;
122 	int	type;
123 } inset_call_t;
124 
125 typedef	struct {
126 	int	inset;
127 } inset_ret_t;
128 
129 typedef	struct {
130 	bslabel_t label;
131 } slvalid_call_t;
132 
133 typedef	struct {
134 	int	valid;
135 } slvalid_ret_t;
136 
137 typedef	struct {
138 	bclear_t clear;
139 } clrvalid_call_t;
140 
141 typedef	struct {
142 	int	valid;
143 } clrvalid_ret_t;
144 
145 typedef	struct {
146 	int	null;
147 } info_call_t;
148 
149 typedef	struct {
150 	struct label_info info;
151 } info_ret_t;
152 
153 typedef	struct {
154 	int	null;
155 } vers_call_t;
156 
157 typedef	struct {
158 	char	vers[BUFSIZE];
159 } vers_ret_t;
160 
161 typedef struct {
162 	blevel_t label;
163 } color_call_t;
164 
165 typedef struct {
166 	char	color[BUFSIZE];
167 } color_ret_t;
168 
169 /* Binary Label to String interfaces */
170 
171 typedef	struct {
172 	bslabel_t label;
173 	uint_t	flags;
174 } bsltos_call_t;
175 
176 typedef	struct {
177 	char	slabel[BUFSIZE];
178 } bsltos_ret_t;
179 
180 typedef	struct {
181 	bclear_t clear;
182 	uint_t	flags;
183 } bcleartos_call_t;
184 
185 typedef	struct {
186 	char	cslabel[BUFSIZE];
187 } bcleartos_ret_t;
188 
189 /* String to Binary Label interfaces */
190 
191 typedef	struct {
192 	bslabel_t label;
193 	uint_t	flags;
194 	char	string[BUFSIZE];
195 } stobsl_call_t;
196 
197 typedef	struct {
198 	bslabel_t label;
199 } stobsl_ret_t;
200 
201 typedef	struct {
202 	bclear_t clear;
203 	uint_t	flags;
204 	char	string[BUFSIZE];
205 } stobclear_call_t;
206 
207 typedef	struct {
208 	bclear_t clear;
209 } stobclear_ret_t;
210 
211 /*
212  * The following Dimming List and Miscellaneous interfaces
213  * implement contract private interfaces for the label builder
214  * interfaces.
215  */
216 
217 /* Dimming List interfaces */
218 
219 typedef	struct {
220 	bslabel_t label;
221 	brange_t bounds;
222 	uint_t	flags;
223 } bslcvt_call_t;
224 
225 typedef	struct {
226 	bufp_t	string;
227 	bufp_t	dim;
228 	bufp_t	lwords;
229 	bufp_t	swords;
230 	size_t	d_len;
231 	size_t	l_len;
232 	size_t	s_len;
233 	int	first_comp;
234 	int	first_mark;
235 	char	buf[BUFSIZE];
236 } cvt_ret_t;
237 
238 typedef cvt_ret_t bslcvt_ret_t;
239 
240 typedef	struct {
241 	bclear_t clear;
242 	brange_t bounds;
243 	uint_t	flags;
244 } bclearcvt_call_t;
245 
246 typedef cvt_ret_t bclearcvt_ret_t;
247 
248 /* Miscellaneous interfaces */
249 
250 typedef	struct {
251 	int	null;
252 } fields_call_t;
253 
254 typedef	struct {
255 	bufp_t	classi;
256 	bufp_t	compsi;
257 	bufp_t	marksi;
258 	char	buf[BUFSIZE];
259 } fields_ret_t;
260 
261 typedef	struct {
262 	int	null;
263 } udefs_call_t;
264 
265 typedef	struct {
266 	bslabel_t sl;
267 	bclear_t  clear;
268 } udefs_ret_t;
269 
270 typedef	struct {
271 	bslabel_t  sl;
272 	char	pathname[BUFSIZE];
273 } setfbcl_call_t;
274 
275 typedef	struct {
276 	int	status;
277 } setfbcl_ret_t;
278 
279 typedef	struct {
280 	bslabel_t  src_win_sl;
281 	int	transfer_mode;
282 	bufp_t  remote_dir;
283 	bufp_t  filename;
284 	bufp_t  local_dir;
285 	bufp_t  display;
286 	char    buf[BUFSIZE];
287 } zcopy_call_t;
288 
289 typedef	struct {
290 	int	status;
291 } zcopy_ret_t;
292 
293 typedef	struct {
294 	m_label_t label;
295 	uint_t	flags;
296 } pr_call_t;
297 
298 typedef	struct {
299 	char	buf[BUFSIZE];
300 } pr_ret_t;
301 
302 typedef	struct {
303 	m_label_t label;
304 	uint_t	flags;
305 } ls_call_t;
306 
307 typedef	struct {
308 	char	buf[BUFSIZE];
309 } ls_ret_t;
310 
311 typedef	struct {
312 	m_label_t label;
313 	uint_t	flags;
314 	char	string[BUFSIZE];
315 } sl_call_t;
316 
317 typedef	struct {
318 	m_label_t label;
319 } sl_ret_t;
320 
321 /* Labeld operation call structure */
322 
323 typedef	struct {
324 	uint_t	op;
325 	union	{
326 		null_call_t	null_arg;
327 
328 		inset_call_t	inset_arg;
329 		slvalid_call_t	slvalid_arg;
330 		clrvalid_call_t	clrvalid_arg;
331 		info_call_t	info_arg;
332 		vers_call_t	vers_arg;
333 		color_call_t	color_arg;
334 
335 		bsltos_call_t	bsltos_arg;
336 		bcleartos_call_t	bcleartos_arg;
337 
338 		stobsl_call_t	stobsl_arg;
339 		stobclear_call_t	stobclear_arg;
340 
341 		bslcvt_call_t	bslcvt_arg;
342 		bclearcvt_call_t	bclearcvt_arg;
343 		fields_call_t	fields_arg;
344 		udefs_call_t	udefs_arg;
345 		setfbcl_call_t	setfbcl_arg;
346 		zcopy_call_t	zcopy_arg;
347 		pr_call_t	pr_arg;
348 		ls_call_t	ls_arg;
349 		sl_call_t	sl_arg;
350 	} cargs;
351 } labeld_call_t;
352 
353 /* Labeld operation return structure */
354 
355 typedef struct {
356 	int	ret;		/* labeld return codes */
357 	int	err;		/* function error codes */
358 	union	{
359 		null_ret_t	null_ret;
360 
361 		inset_ret_t	inset_ret;
362 		slvalid_ret_t	slvalid_ret;
363 		clrvalid_ret_t	clrvalid_ret;
364 		info_ret_t	info_ret;
365 		vers_ret_t	vers_ret;
366 		color_ret_t	color_ret;
367 
368 		bsltos_ret_t	bsltos_ret;
369 		bcleartos_ret_t	bcleartos_ret;
370 
371 		stobsl_ret_t	stobsl_ret;
372 		stobclear_ret_t	stobclear_ret;
373 
374 		bslcvt_ret_t	bslcvt_ret;
375 		bclearcvt_ret_t	bclearcvt_ret;
376 		fields_ret_t	fields_ret;
377 		udefs_ret_t	udefs_ret;
378 		setfbcl_ret_t	setfbcl_ret;
379 		zcopy_ret_t	zcopy_ret;
380 		pr_ret_t	pr_ret;
381 		ls_ret_t	ls_ret;
382 		sl_ret_t	sl_ret;
383 	} rvals;
384 } labeld_ret_t;
385 
386 /* Labeld call/return structure */
387 
388 typedef	struct {
389 	union {
390 		labeld_call_t	acall;
391 		labeld_ret_t	aret;
392 	} param;
393 } labeld_data_t;
394 
395 #define	callop	param.acall.op
396 #define	retret	param.aret.ret
397 #define	reterr	param.aret.err
398 
399 #define	CALL_SIZE(type, buf)	(size_t)(sizeof (type) + sizeof (int) + (buf))
400 #define	RET_SIZE(type, buf)	(size_t)(sizeof (type) + 2*sizeof (int) + (buf))
401 #define	CALL_SIZE_STR(type, buf)	CALL_SIZE(type, (-BUFSIZE +(buf)))
402 
403 /* Labeld common client call function */
404 
405 int
406 __call_labeld(labeld_data_t **dptr, size_t *ndata, size_t *adata);
407 
408 /* Return Codes */
409 
410 #define	SUCCESS		1	/* Call OK */
411 #define	NOTFOUND	-1	/* Function not found */
412 #define	SERVERFAULT	-2	/* Internal labeld error */
413 #define	NOSERVER	-3	/* No server thread available, try later */
414 
415 /* Flag Translation Values */
416 
417 #define	L_NEW_LABEL		0x10000000
418 
419 /* GFI FLAGS */
420 
421 #define	GFI_FLAG_MASK		 0x0000FFFF
422 #define	GFI_ACCESS_RELATED	 0x00000001
423 
424 /* binary to ASCII */
425 
426 #define	LABELS_NO_CLASS		 0x00010000
427 #define	LABELS_SHORT_CLASS	 0x00020000
428 #define	LABELS_SHORT_WORDS	 0x00040000
429 
430 /* Label view */
431 
432 #define	LABELS_VIEW_INTERNAL	 0x00100000
433 #define	LABELS_VIEW_EXTERNAL	 0x00200000
434 
435 /* Dimming list (convert -- b*cvt* ) */
436 
437 #define	LABELS_FULL_CONVERT	 0x00010000
438 
439 /* ASCII to binary */
440 
441 #define	LABELS_NEW_LABEL	 0x00010000
442 #define	LABELS_FULL_PARSE	 0x00020000
443 #define	LABELS_ONLY_INFO_LABEL	 0x00040000
444 
445 #define	MOVE_FILE	0
446 #define	COPY_FILE	1
447 #define	LINK_FILE	2
448 
449 #define	PIPEMSG_FILEOP_ERROR	1
450 #define	PIPEMSG_EXIST_ERROR	2
451 #define	PIPEMSG_DONE 		7
452 #define	PIPEMSG_PATH_ERROR	20
453 #define	PIPEMSG_ZONE_ERROR	21
454 #define	PIPEMSG_LABEL_ERROR	22
455 #define	PIPEMSG_READ_ERROR	23
456 #define	PIPEMSG_READONLY_ERROR  24
457 #define	PIPEMSG_WRITE_ERROR	25
458 #define	PIPEMSG_CREATE_ERROR	26
459 #define	PIPEMSG_DELETE_ERROR	27
460 #define	PIPEMSG_CANCEL		101
461 #define	PIPEMSG_PROCEED		102
462 #define	PIPEMSG_MERGE		103
463 #define	PIPEMSG_REPLACE_BUFFER	104
464 #define	PIPEMSG_RENAME_BUFFER	105
465 #define	PIPEMSG_MULTI_PROCEED	106
466 #define	PIPEMSG_RENAME_FILE	107
467 
468 #ifdef	__cplusplus
469 }
470 #endif
471 
472 #endif	/* _LABELD_H */
473