summaryrefslogtreecommitdiff
path: root/usr/src/lib/libtsol/common/labeld.h
blob: 5b41e800dbad882496d8478e04412436174ee2ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_LABELD_H
#define	_LABELD_H

#include <sys/types.h>
#include <tsol/label.h>
#include <sys/tsol/label_macro.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 *	Definitions for the call parameters for the door-based label
 * translation service.
 */

#define	BUFSIZE	4096

#define	DOOR_PATH	"/var/tsol/doors/"
#define	DOOR_NAME	"labeld"
#define	COOKIE		0x6c616264ull	/* "labd" */

/*	Op codes */

/*	Labeld Commands */

#define	LABELDNULL	1

/*	Miscellaneous */

#define	BLINSET		10
#define	BSLVALID	11
#define	BILVALID	12
#define	BCLEARVALID	13
#define	LABELINFO	14
#define	LABELVERS	15
#define	BLTOCOLOR	16

/*	Binary to String Label Translation */

#define	BSLTOS		23
#define	BCLEARTOS	25

/*	String to Binary Label Translation */

#define	STOBSL		31
#define	STOBCLEAR	33

/*
 *	Dimming List Routines
 *	Contract private for label builders
 */

#define	BSLCVT		40
#define	BCLEARCVT	42
#define	LABELFIELDS	43
#define	UDEFS		44

#define	GETFLABEL	45
#define	SETFLABEL	46
#define	ZCOPY		47

/* NEW LABELS */
/* DIA printer banner labels */

#define	PR_CAVEATS	101
#define	PR_CHANNELS	102
#define	PR_LABEL	103
#define	PR_TOP		104

/* DIA label to string  */

#define	LTOS		105

/* DIA string to label */

#define	STOL		106

/*	Structures */

typedef	uint_t	bufp_t;		/* offset into buf[] in/out string buffer */

/* Null call */

typedef	struct {
	int	null;
} null_call_t;

typedef	struct {
	int	null;
} null_ret_t;

/* Miscellaneous interfaces */

typedef	struct {
	bslabel_t label;
	int	type;
} inset_call_t;

typedef	struct {
	int	inset;
} inset_ret_t;

typedef	struct {
	bslabel_t label;
} slvalid_call_t;

typedef	struct {
	int	valid;
} slvalid_ret_t;

typedef	struct {
	bclear_t clear;
} clrvalid_call_t;

typedef	struct {
	int	valid;
} clrvalid_ret_t;

typedef	struct {
	int	null;
} info_call_t;

typedef	struct {
	struct label_info info;
} info_ret_t;

typedef	struct {
	int	null;
} vers_call_t;

typedef	struct {
	char	vers[BUFSIZE];
} vers_ret_t;

typedef struct {
	blevel_t label;
} color_call_t;

typedef struct {
	char	color[BUFSIZE];
} color_ret_t;

/* Binary Label to String interfaces */

typedef	struct {
	bslabel_t label;
	uint_t	flags;
} bsltos_call_t;

typedef	struct {
	char	slabel[BUFSIZE];
} bsltos_ret_t;

typedef	struct {
	bclear_t clear;
	uint_t	flags;
} bcleartos_call_t;

typedef	struct {
	char	cslabel[BUFSIZE];
} bcleartos_ret_t;

/* String to Binary Label interfaces */

typedef	struct {
	bslabel_t label;
	uint_t	flags;
	char	string[BUFSIZE];
} stobsl_call_t;

typedef	struct {
	bslabel_t label;
} stobsl_ret_t;

typedef	struct {
	bclear_t clear;
	uint_t	flags;
	char	string[BUFSIZE];
} stobclear_call_t;

typedef	struct {
	bclear_t clear;
} stobclear_ret_t;

/*
 * The following Dimming List and Miscellaneous interfaces
 * implement contract private interfaces for the label builder
 * interfaces.
 */

/* Dimming List interfaces */

typedef	struct {
	bslabel_t label;
	brange_t bounds;
	uint_t	flags;
} bslcvt_call_t;

typedef	struct {
	bufp_t	string;
	bufp_t	dim;
	bufp_t	lwords;
	bufp_t	swords;
	size_t	d_len;
	size_t	l_len;
	size_t	s_len;
	int	first_comp;
	int	first_mark;
	char	buf[BUFSIZE];
} cvt_ret_t;

typedef cvt_ret_t bslcvt_ret_t;

typedef	struct {
	bclear_t clear;
	brange_t bounds;
	uint_t	flags;
} bclearcvt_call_t;

typedef cvt_ret_t bclearcvt_ret_t;

/* Miscellaneous interfaces */

typedef	struct {
	int	null;
} fields_call_t;

typedef	struct {
	bufp_t	classi;
	bufp_t	compsi;
	bufp_t	marksi;
	char	buf[BUFSIZE];
} fields_ret_t;

typedef	struct {
	int	null;
} udefs_call_t;

typedef	struct {
	bslabel_t sl;
	bclear_t  clear;
} udefs_ret_t;

typedef	struct {
	bslabel_t  sl;
	char	pathname[BUFSIZE];
} setfbcl_call_t;

typedef	struct {
	int	status;
} setfbcl_ret_t;

typedef	struct {
	bslabel_t  src_win_sl;
	int	transfer_mode;
	bufp_t  remote_dir;
	bufp_t  filename;
	bufp_t  local_dir;
	bufp_t  display;
	char    buf[BUFSIZE];
} zcopy_call_t;

typedef	struct {
	int	status;
} zcopy_ret_t;

typedef	struct {
	m_label_t label;
	uint_t	flags;
} pr_call_t;

typedef	struct {
	char	buf[BUFSIZE];
} pr_ret_t;

typedef	struct {
	m_label_t label;
	uint_t	flags;
} ls_call_t;

typedef	struct {
	char	buf[BUFSIZE];
} ls_ret_t;

typedef	struct {
	m_label_t label;
	uint_t	flags;
	char	string[BUFSIZE];
} sl_call_t;

typedef	struct {
	m_label_t label;
} sl_ret_t;

/* Labeld operation call structure */

typedef	struct {
	uint_t	op;
	union	{
		null_call_t	null_arg;

		inset_call_t	inset_arg;
		slvalid_call_t	slvalid_arg;
		clrvalid_call_t	clrvalid_arg;
		info_call_t	info_arg;
		vers_call_t	vers_arg;
		color_call_t	color_arg;

		bsltos_call_t	bsltos_arg;
		bcleartos_call_t	bcleartos_arg;

		stobsl_call_t	stobsl_arg;
		stobclear_call_t	stobclear_arg;

		bslcvt_call_t	bslcvt_arg;
		bclearcvt_call_t	bclearcvt_arg;
		fields_call_t	fields_arg;
		udefs_call_t	udefs_arg;
		setfbcl_call_t	setfbcl_arg;
		zcopy_call_t	zcopy_arg;
		pr_call_t	pr_arg;
		ls_call_t	ls_arg;
		sl_call_t	sl_arg;
	} cargs;
} labeld_call_t;

/* Labeld operation return structure */

typedef struct {
	int	ret;		/* labeld return codes */
	int	err;		/* function error codes */
	union	{
		null_ret_t	null_ret;

		inset_ret_t	inset_ret;
		slvalid_ret_t	slvalid_ret;
		clrvalid_ret_t	clrvalid_ret;
		info_ret_t	info_ret;
		vers_ret_t	vers_ret;
		color_ret_t	color_ret;

		bsltos_ret_t	bsltos_ret;
		bcleartos_ret_t	bcleartos_ret;

		stobsl_ret_t	stobsl_ret;
		stobclear_ret_t	stobclear_ret;

		bslcvt_ret_t	bslcvt_ret;
		bclearcvt_ret_t	bclearcvt_ret;
		fields_ret_t	fields_ret;
		udefs_ret_t	udefs_ret;
		setfbcl_ret_t	setfbcl_ret;
		zcopy_ret_t	zcopy_ret;
		pr_ret_t	pr_ret;
		ls_ret_t	ls_ret;
		sl_ret_t	sl_ret;
	} rvals;
} labeld_ret_t;

/* Labeld call/return structure */

typedef	struct {
	union {
		labeld_call_t	acall;
		labeld_ret_t	aret;
	} param;
} labeld_data_t;

#define	callop	param.acall.op
#define	retret	param.aret.ret
#define	reterr	param.aret.err

#define	CALL_SIZE(type, buf)	(size_t)(sizeof (type) + sizeof (int) + (buf))
#define	RET_SIZE(type, buf)	(size_t)(sizeof (type) + 2*sizeof (int) + (buf))
#define	CALL_SIZE_STR(type, buf)	CALL_SIZE(type, (-BUFSIZE +(buf)))

/* Labeld common client call function */

int
__call_labeld(labeld_data_t **dptr, size_t *ndata, size_t *adata);

/* Return Codes */

#define	SUCCESS		1	/* Call OK */
#define	NOTFOUND	-1	/* Function not found */
#define	SERVERFAULT	-2	/* Internal labeld error */
#define	NOSERVER	-3	/* No server thread available, try later */

/* Flag Translation Values */

#define	L_NEW_LABEL		0x10000000

/* GFI FLAGS */

#define	GFI_FLAG_MASK		 0x0000FFFF
#define	GFI_ACCESS_RELATED	 0x00000001

/* binary to ASCII */

#define	LABELS_NO_CLASS		 0x00010000
#define	LABELS_SHORT_CLASS	 0x00020000
#define	LABELS_SHORT_WORDS	 0x00040000

/* Label view */

#define	LABELS_VIEW_INTERNAL	 0x00100000
#define	LABELS_VIEW_EXTERNAL	 0x00200000

/* Dimming list (convert -- b*cvt* ) */

#define	LABELS_FULL_CONVERT	 0x00010000

/* ASCII to binary */

#define	LABELS_NEW_LABEL	 0x00010000
#define	LABELS_FULL_PARSE	 0x00020000
#define	LABELS_ONLY_INFO_LABEL	 0x00040000

#define	MOVE_FILE	0
#define	COPY_FILE	1
#define	LINK_FILE	2

#define	PIPEMSG_FILEOP_ERROR	1
#define	PIPEMSG_EXIST_ERROR	2
#define	PIPEMSG_DONE 		7
#define	PIPEMSG_PATH_ERROR	20
#define	PIPEMSG_ZONE_ERROR	21
#define	PIPEMSG_LABEL_ERROR	22
#define	PIPEMSG_READ_ERROR	23
#define	PIPEMSG_READONLY_ERROR  24
#define	PIPEMSG_WRITE_ERROR	25
#define	PIPEMSG_CREATE_ERROR	26
#define	PIPEMSG_DELETE_ERROR	27
#define	PIPEMSG_CANCEL		101
#define	PIPEMSG_PROCEED		102
#define	PIPEMSG_MERGE		103
#define	PIPEMSG_REPLACE_BUFFER	104
#define	PIPEMSG_RENAME_BUFFER	105
#define	PIPEMSG_MULTI_PROCEED	106
#define	PIPEMSG_RENAME_FILE	107

#ifdef	__cplusplus
}
#endif

#endif	/* _LABELD_H */