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